fix: fail closed on unhealthy prewrite search - #3
Open
VailElla wants to merge 2 commits into
Open
Conversation
VailElla
force-pushed
the
agent/fix-prewrite-reconciliation
branch
from
July 12, 2026 13:07
e04e6e3 to
51f3163
Compare
VailElla
marked this pull request as ready for review
July 12, 2026 13:07
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
Root cause
The closeout wrapper treated search-process failures as an empty candidate list. That made an unhealthy primary index indistinguishable from a legitimate no-match result, so prewrite could recommend
ADD. Long descriptions also diluted one-way lexical coverage enough to miss an existing memory even when its title was present.The matching shortcuts need their own guard: a short generic title or a candidate with only a few tokens can otherwise achieve high reverse coverage from an incidental mention. This revision limits those shortcuts while preserving specific English and Chinese title matches.
Impact
Prewrite now returns
status=errorandrecommendation_unavailable_reason=reconcile_search_unhealthywhen SQLite search is unavailable. Postwrite reconciliation records a blocking finding for the same condition. Ordinary failures from the optional vector backend remain non-blocking warnings when SQLite is healthy.The branch is rebased onto
3cc6b43and includes the updated postwrite test contract introduced on currentmain.Safety and privacy
Validation
/usr/bin/python3 -m unittest discover -s tests -p 'test_*.py'— 38 tests passedUPDATEfor the existing workflow/usr/bin/python3 -m compileall -q scripts tests/usr/bin/python3 scripts/agent_memory_check.py --skip-state-dbgit diff --check upstream/main