Skip to content

feat: Add BackendFactory and enhanced KnowledgeBackend ABC - #231

Closed
esafwan wants to merge 2 commits into
developfrom
kimi/vector-store-factory-abc
Closed

feat: Add BackendFactory and enhanced KnowledgeBackend ABC#231
esafwan wants to merge 2 commits into
developfrom
kimi/vector-store-factory-abc

Conversation

@esafwan

@esafwan esafwan commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements BackendFactory pattern and enhances KnowledgeBackend ABC for multi-backend support.

Changes

  • BackendFactory - Registry-based factory with connection pooling and site-aware caching
  • Enhanced ABC - Added health_check(), supports_filters(), supports_hybrid_search() methods
  • Auto-registration - Backends auto-register on module load
  • Updated backends - SQLite backends implement new interface methods

Factory Features

  • Site-scoped instance caching
  • Health check aggregation
  • Cache management utilities

Related

Enables pluggable vector database backends (pgvector, Chroma, Redis, etc.).

esafwan added 2 commits March 28, 2026 11:04
- PRD: Programmable Memory & Learning Layer
- DocType designs: Memory Record, Policy, Profile
- Tech specs: Capture/Retrieval, Storage Architecture
- Profiles: Travel Planning, Programming, Documentation
- Implementation plan and project tracking
@esafwan

esafwan commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Status update: largely superseded by PR #280 + PR #406

Since this PR was opened, the direction it explored has been adopted through other work:

  • The enhanced KnowledgeBackend ABC now exists on the PR #280 branch, including get_advanced_config_schema() and a shared LlamaIndexBackend base class (backends/llamaindex_base.py).
  • The registry/factory idea has been implemented as a hook-based dynamic registry (huf_knowledge_backends, mirroring the huf_tools pattern) in PR #406 (depends on feat: add PGVector knowledge source #280), including hook discovery, subclass validation, collision handling, tests, and a BACKEND_CONTRACT.md. The BackendFactory + auto-registration-at-module-load design in this PR (huf/ai/knowledge/backends/factory.py) is not the chosen direction.

What remains salvageable from this PR

The capability methods (health_check, supports_filters, supports_hybrid_search) are still valuable and align with the cross-backend standardization plan (capability flags on the contract):

Once the capability-flag port is done (or deliberately deferred), this PR can be closed with a pointer to #280/#406.

@esafwan

esafwan commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing as stale / re-scoped.

The knowledge-backend architecture has standardised on the #280#406#434 line: LlamaIndexBackend base class (#280), the huf_knowledge_backends hook registry + BACKEND_CONTRACT.md (#406), and hook-registered backends (#434). This PR predates that line: it targets the hardcoded get_backend() registry, carries the ~5k-line PRD/planning doc bundle, and conflicts with the contract's config model (advanced_config schemas vs separate settings DocTypes).

A backend from this PR can be revived as a small contract-compliant implementation (see huf/ai/knowledge/backends/BACKEND_CONTRACT.md on develop after #280/#406 merge): subclass LlamaIndexBackend (~50–100 lines) or implement KnowledgeBackend directly, register via huf_knowledge_backends in the owning app's hooks.py, expose tuning via get_advanced_config_schema(), and pass the live-test bar. The Redis backend in #434 is the reference implementation.

@esafwan esafwan closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant