Skip to content

feat(library): add local semantic knowledge library#114

Merged
keli-wen merged 5 commits into
masterfrom
codex/issue-111-local-knowledge-library
Jul 16, 2026
Merged

feat(library): add local semantic knowledge library#114
keli-wen merged 5 commits into
masterfrom
codex/issue-111-local-knowledge-library

Conversation

@keli-wen

@keli-wen keli-wen commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add the focused quantmind.library public API with only LocalKnowledgeLibrary, SemanticQuery, and SemanticHit.
  • Persist canonical knowledge in SQLite using knowledge_items for typed aggregate roots and knowledge_nodes for normalized tree nodes; keep semantic_records and NumPy exact-cosine matrices rebuildable and derived.
  • Index flat items, tree roots, and non-root tree nodes at the feat(library): local semantic knowledge library MVP #111 grain, with deterministic per-target embedding invalidation, transactional put/delete, typed get, combined metadata filters, financial-time filters, and explicit not-found/stale/corrupt behavior.
  • Add optional BaseKnowledge.available_at, keep provider/storage seams private, and enforce the library-to-knowledge import boundary without introducing a generic RAG/backend API.
  • Keep LocalKnowledgeLibrary as a 248-line public facade and group concrete implementation under quantmind.library._internal: retrieval-target construction, index-only embeddings, the concrete SQLite store, and deterministic exact-cosine ranking.
  • Remove the standalone private ports module; the fakeable embedding protocol now lives beside its OpenAI implementation and remains private.
  • Add an executable AI-infrastructure scenario backed by a real arXiv paper tree, Microsoft investment announcement, and NVIDIA earnings release.
  • Precompile the auditable canonical JSON into a 96 KiB SQLite bundle containing three items, four normalized tree nodes, and six real text-embedding-3-small 1536-dimensional targets; the user example only performs open → search → get and embeds the query once.
  • Move the maintainer build tool to scripts/examples/build_ai_infrastructure_bundle.py and add examples/library/README.md so agents can discover the run path, artifact provenance, and rebuild procedure locally.
  • Document why SQLite is the canonical default and where a future vector database such as Chroma could replace only the private derived-index layer.

Related Issue

Closes #111.

Example Sources

Verification

  • pytest -q tests/library --no-cov — 23 passed.
  • bash scripts/verify.sh — 317 passed with 86.47% total coverage; Ruff, basedpyright, import-linter, and pytest all passed.
  • SQLite PRAGMA integrity_check returned ok; the compiled bundle contains exactly 3 canonical items, 4 canonical nodes, and 6 text-embedding-3-small × 1536 semantic records.
  • The relocated maintainer build and user-facing example were both run successfully against the configured OpenAI API; the live query returned all six targets across News, Paper, and Earnings.
  • Commit and pre-push hooks passed without bypassing; the pre-push hook reran scripts/verify.sh successfully.
  • The committed bundle was checked for API-key-like strings, and the offline test uses a private deterministic query provider without network access.
  • Unsupported knowledge types are tested to fail before any embedding-provider call.

Checklist

  • The title uses English Conventional Commit format.
  • The related issue is linked.
  • bash scripts/verify.sh passes.
  • Public behavior has focused unittest.TestCase / unittest.IsolatedAsyncioTestCase coverage, one focused example, and documentation.
  • Canonical tree nodes are stored separately from aggregate-root payloads.
  • The user-facing example does not parse source JSON, ingest documents, or build document embeddings.
  • Private implementation files describe concrete responsibilities and do not imply alternative library backends.
  • The change is scoped to feat(library): local semantic knowledge library MVP #111 and contains no paper-flow integration, answer generation, knowledge graph, PageIndex, public backend interface, or generic RAG abstraction.

@keli-wen keli-wen self-assigned this Jul 16, 2026
@keli-wen keli-wen added area: knowledge Canonical knowledge models, collections, indexing, and semantic search type: feature Adds a new capability or observable behavior labels Jul 16, 2026 — with ChatGPT Codex Connector
@keli-wen
keli-wen marked this pull request as ready for review July 16, 2026 14:13
@keli-wen
keli-wen merged commit 2c1f2cb into master Jul 16, 2026
1 check passed
@keli-wen
keli-wen deleted the codex/issue-111-local-knowledge-library branch July 16, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: knowledge Canonical knowledge models, collections, indexing, and semantic search type: feature Adds a new capability or observable behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(library): local semantic knowledge library MVP

1 participant