fix(searcher): guard CLI divergence before Chroma open - #2016
Merged
Conversation
Co-authored-by: Tom Boucher <trekkie@nomorestars.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the CLI search() path with the MCP path by probing for Chroma HNSW divergence before attempting to open a Chroma collection, and falls back to the existing SQLite BM25-only search when divergence is detected—avoiding native crashes while keeping output formatting consistent.
Changes:
- Add a pre-open Chroma HNSW divergence probe for CLI search and route diverged palaces to BM25-only output.
- Introduce a dedicated CLI BM25-only result printer that mirrors the normal vector-path output shape and includes an actionable repair notice.
- Add regression tests covering diverged/healthy Chroma paths and ensuring non-Chroma backends don’t invoke the Chroma-specific probe.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mempalace/searcher.py | Adds pre-open HNSW divergence gating and a BM25-only CLI fallback printer to avoid Chroma open/query crashes. |
| tests/test_searcher.py | Adds regression coverage for diverged vs healthy Chroma behavior and ensures other backends aren’t fenced by the Chroma probe. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merged
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.
What changed
get_collection()in CLI search.Why
#1967 guarded only
col.query(), after collection opening. That ordering still allowed Chroma client construction and embedder-identity enforcement (including a possiblecollection.count()) to touch damaged native index state before the guard ran. The MCP path already probes before_get_client; the CLI path needs the same boundary.This draft supersedes #1967 with the pre-open ordering fix while retaining its useful BM25 fallback. Original design and implementation credit: @trek-e.
Local validation
uv run pytest tests/test_searcher.py tests/test_hnsw_capacity.py tests/test_backends.py -q— 169 passedget_collection()raise if called, and confirmed CLI search returned the exact stored sentence through BM25 without opening Chroma.