feat(library): add local semantic knowledge library#114
Merged
Conversation
keli-wen
marked this pull request as ready for review
July 16, 2026 14:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
quantmind.librarypublic API with onlyLocalKnowledgeLibrary,SemanticQuery, andSemanticHit.knowledge_itemsfor typed aggregate roots andknowledge_nodesfor normalized tree nodes; keepsemantic_recordsand NumPy exact-cosine matrices rebuildable and derived.put/delete, typedget, combined metadata filters, financial-time filters, and explicit not-found/stale/corrupt behavior.BaseKnowledge.available_at, keep provider/storage seams private, and enforce the library-to-knowledge import boundary without introducing a generic RAG/backend API.LocalKnowledgeLibraryas a 248-line public facade and group concrete implementation underquantmind.library._internal: retrieval-target construction, index-only embeddings, the concrete SQLite store, and deterministic exact-cosine ranking.text-embedding-3-small1536-dimensional targets; the user example only performsopen → search → getand embeds the query once.scripts/examples/build_ai_infrastructure_bundle.pyand addexamples/library/README.mdso agents can discover the run path, artifact provenance, and rebuild procedure locally.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.PRAGMA integrity_checkreturnedok; the compiled bundle contains exactly 3 canonical items, 4 canonical nodes, and 6text-embedding-3-small× 1536 semantic records.News,Paper, andEarnings.scripts/verify.shsuccessfully.Checklist
bash scripts/verify.shpasses.unittest.TestCase/unittest.IsolatedAsyncioTestCasecoverage, one focused example, and documentation.