refactor: route all chromadb access through ChromaBackend (v4 prep)#852
Merged
refactor: route all chromadb access through ChromaBackend (v4 prep)#852
Conversation
Prerequisite for RFC 001 (plugin spec, #743). Removes every direct `import chromadb` outside the ChromaDB backend itself so the core modules depend only on the backend abstraction layer. Extends ChromaBackend with make_client, get_or_create_collection, delete_collection, create_collection, and backend_version. Adds update() to the BaseCollection contract. Non-backend callers (mcp_server, dedup, repair, migrate, cli) now go through the abstraction; tests patch ChromaBackend instead of chromadb. With this landed, the RFC 001 spec can be enforced and PalaceStore (#643) can ship as a plugin without touching core modules.
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
Prerequisite for RFC 001 (storage backend plugin spec, #743) and PalaceStore. Removes every direct
import chromadboutside the ChromaDB backend itself so core modules depend only on the backend abstraction layer.With this in, RFC 001 can be enforced and third-party backends — starting with PalaceStore — can ship as plugins without touching core modules.
What changed
backends/base.py— addedupdate()to theBaseCollectioncontract.backends/chroma.py— per-instance client cache, plus new methods:make_client,backend_version,get_or_create_collection,delete_collection,create_collection,update.mcp_server.py,dedup.py,repair.py,cli.py,migrate.py— all chromadb access routed throughChromaBackend.tests/test_cli.py,test_dedup.py,test_repair.py— patchChromaBackendinstead ofchromadb.Only remaining
import chromadblives inmempalace/backends/chroma.py(as intended).v4 roadmap (for context)
pip install mempalace-chromadb, ship an explicitmigrate --to palace_store(no auto-migration — safer for users' data).Test plan
uv run pytest tests/ --ignore=tests/benchmarks— 864/864 passuv run ruff check .cleanuvx --from 'ruff>=0.4.0,<0.5' ruff format --check .clean (CI-pinned ruff)backends/chroma.pyimportschromadb