Repository navigation
fix(backend): key the all-ungrounded memory guard on candidates seen, not container truthiness (#11685) - #11702
Merged
kodjima33 merged 1 commit intoAug 16, 2026
Conversation
… not container truthiness PR #11688 added a guard that raises when every extracted L1 candidate fails evidence grounding, so the run cannot submit an empty replacement that would retract the source's existing memories. It gated that raise on `extracted_candidates and not capture_candidates` — the truthiness of whatever extract_canonical_l1_memory_candidates returned. Truthiness is not a count. Any truthy object that yields nothing when iterated reads as "candidates existed and all of them failed grounding", so the guard fires on a conversation that simply produced no candidates and aborts conversation finalization for it. That is exactly what broke Backend Unit Tests on main from 5af7e53 onward: test_app_summary_results_reach_the_database stubs the extractor with a bare MagicMock, which is truthy and iterates empty. Count the candidates the loop actually yielded and gate on that. Behaviour for a real list is unchanged; the guard now states what it means. Verification: cd backend : > /tmp/f.txt echo tests/unit/test_process_conversation_usage_context.py >> /tmp/f.txt echo tests/unit/test_memory_replace_policy.py >> /tmp/f.txt BACKEND_UNIT_TEST_FILE_LIST=/tmp/f.txt bash test.sh -> 30 passed (usage_context, was 1 failed/29 passed), 16 passed (replace_policy) Reverting only the process_conversation.py hunk fails the new test (test_canonical_capture_accepts_an_extractor_that_yields_no_candidates), so the regression test does catch this. Failure-Class: none
kodjima33
deleted the
watchdog/issue-11685-canonical-extractor-empty-guard
branch
August 16, 2026 18:39
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.
Bug
Backend Unit Testshas been red onmainsince 5af7e53 (PR #11688, the fix for #11685).tests/unit/test_process_conversation_usage_context.py::test_app_summary_results_reach_the_databasefails with
ValueError: canonical memory extraction returned evidence without a unique source binding.Three consecutive main pushes are red (5af7e53, 43b30d6, 13de450); every other lane on
13de450 is green, so this single file is the whole red.
Root cause
PR #11688 stopped one ungrounded L1 candidate from aborting the entire canonical extraction run,
and kept a guard for the genuinely untrustworthy case — every candidate failed grounding — because
replace_conversation_memoriesis called unconditionally and an empty replacement would retract thesource's existing memories.
That guard was gated on
extracted_candidates and not capture_candidates: the truthiness ofwhatever
extract_canonical_l1_memory_candidatesreturned. Truthiness is not a count. Any truthyobject that yields nothing when iterated reads as "candidates existed and all of them failed
grounding", so the guard fires on a conversation that simply produced no candidates and aborts its
finalization.
test_app_summary_results_reach_the_databasestubs the extractor with a bareMagicMock— truthy, iterates empty — and trips exactly that.Fix
Count the candidates the loop actually yielded and gate the raise on that count. Behaviour for a real
list is unchanged (a non-empty list yields non-zero); the guard now states what it means, and the
dropped-candidate warning reports the counted total instead of
len()on the same container.Tested
test_process_conversation_usage_context.py→ 1 failed, 29 passed (reproduces CI exactly)test_memory_replace_policy.py16 passed5af7e53fd7^that the same file was 30 passed, confirming fix(backend): drop only the ungrounded memory candidate, not the whole run (#11685) #11688 is the breaking committest_canonical_capture_accepts_an_extractor_that_yields_no_candidatescalls_extract_memories_canonicalthrough the real seam; reverting only theprocess_conversation.pyhunk makes it fail, so it does catch this
make preflightgreenLine-Count-Exception: backend/utils/conversations/process_conversation.py | 1806 -> 1810 | one loop counter plus the comment explaining why the guard counts observed candidates instead of reading the container's truthiness
Failure-Class: none
🤖 automated by hourly watchdog — tested and merged