feat: hook-based knowledge backend registry + backend contract doc (depends on #280)#406
Draft
esafwan wants to merge 1 commit into
Draft
Conversation
…+ backend contract doc
This was referenced Jul 19, 2026
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.
Depends on #280
This PR builds directly on #280 (
feat/pgvector-knowledge-doctypes) and is intentionally based on that branch — do not merge before #280 lands. After #280 merges to develop, this PR's base should be retargeted todevelop.What this adds
huf_knowledge_backendshook + dynamic registry — replaces the hardcoded backend dict inhuf/ai/knowledge/backends/__init__.py::get_backend()with hook-based discovery, mirroring the existinghuf_toolspattern. External Frappe apps can now register their own knowledge backend:Validation: registered classes must subclass
KnowledgeBackend; collisions with built-in type keys are logged and skipped (external apps cannot shadow built-ins).BACKEND_CONTRACT.md— documents the backend contract and the two sanctioned implementation paths:LlamaIndexBackend(added in feat: add PGVector knowledge source #280) for stores LlamaIndex supports — recommended, ~50–100 lines per backend;KnowledgeBackenddirectly for portable/unsupported stores (the sqlite_vec exception).Also covers: embeddings stay HUF-side, core connection fields vs
advanced_configtuning params, and the live-test bar for new backends.Tests —
test_backend_registry.py: hook merging, collision handling, subclass validation (mockedfrappe.get_hooks), run green in-bench.Why
Audited across all knowledge backends: the hardcoded registry was the single blocker to external-app pluggability. This unlocks the standardization plan the historical vector-store PRs (#234, #235, #236, #238, #149, #168, #230, #231, #232) are being re-scoped against — each carries a TODO comment pointing here.
🤖 Generated with Claude Code