Repository navigation
memory.reject writes version rows, leaving no patch part on memory_embeddings - #213
Merged
Merged
Conversation
…beddings memory.reject and negative-outcome quarantine flipped status with a lightweight UPDATE on loom.memory and loom.memory_embeddings. On the embeddings table that leaves an active patch part, and while one exists the patch-parts probe keeps the fact leg's codes-first read off for the whole table. The integration test that runs the probe on the CI table read 1 whenever a reject ran before it in the random order. reject_by_identity in the lifecycle store now reads the identity's live rows and re-emits them with status 'rejected' through write_versions_by_ids, whose status mirror writes the vector rows as new versions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The reject row takes its read version + 1, so a memory.set drawn after the read stays the head. write_versions_by_ids passes strict to the status mirror, so a failed vector write reaches the caller instead of answering rejected=True while recall still serves the row. The statement corpus drives the usage fold's lightweight UPDATE of loom.memory, which the block-column table-settings gate reads. Tests cover every session's row, the vector version and the outcome path's inserts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
At read version + 1 the status mirror skipped a vector row a metadata copy had already moved to read + 1 (the conflict resolver's judged stamp, entity tags, verify), so recall kept serving a rejected row. One next_version() drawn before the id read sits above every earlier read + 1 copy, and a write drawn after it still stays the head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
write_versions_by_ids passes strong to mirror_status_to_embeddings as a sequentially consistent vector read, so a reject on another replica finds a vector row written just before it. The docs no longer call quarantine a lightweight update, and reject_by_identity is imported from its module only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… matched Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/analyzer-patch-probe
branch
from
November 3, 2026 14:34
8486b62 to
708d920
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
memory.rejectand negative-outcome quarantine no longer switch off the codes-first vector read for every namespace. They now write the rejected status as a new row version instead of an in-place update.Why
Failing case: on
main,tests/integration/test_search_statements_pass_analyzer.py::test_patch_part_probe_and_reemit_reads_pass_the_analyzerfails withassert 1 == 0. The probe statement passes the analyzer. It then reads one active patch part onloom.memory_embeddings, where the test expects none. The statement passed on the two earliermainruns checked. The commit just before the failing run changed nothing near this table.Pattern: integration tests run in a random order (pytest-randomly is installed and the integration step does not turn it off). The probe reads 1 whenever a test calling
memory.reject(test_memory_import.py,test_cross_principal_leakage.py) runs first and no merge has applied the patch yet._quarantine_by_identityranUPDATE loom.memory_embeddings SET status = 'rejected', a lightweight UPDATE. On a local 26.10 server that statement on one row leaves exactly one active patch part.The CI failure points at a production problem. While
memory_embeddingshas any patch part,patch_free()is False and the fact leg dropsvector_search_use_quantized_codes = 1for the whole table. One reject in one namespace therefore turned the codes-first read off for every tenant until a merge applied the patch. The docs listed this as the one exception to "no in-place updates on vector tables". This PR removes the exception.Fix:
reject_by_identityinserver/memory/store/lifecycle.pyreads the identity's live rows (every session of(org, namespace, agent, user_id, memory_key), as before). It then re-emits them withstatus = 'rejected'and the reason throughwrite_versions_by_ids, the path supersession and conflict marks already use. Its status mirror writes the vector rows as new versions. Bothmemory.rejectand the negative-outcome threshold call it._quarantine_by_identityand itsALTER UPDATEfallback are deleted.Scope and risk
loom.memorystays: that table has no codes-first read.memory.setfinds both rows on any replica.write_versions_by_ids(strong=True)now also reads the mirror's vector rows sequentially (mirror_status_to_embeddings(sequential=True)). That applies to every caller that asks forstrong.version, onenext_version()drawn before the id read, and land inmemory_versionslike every other lifecycle change. The old in-place edit left no history row. Amemory.setthat lands during the reject draws a higher version and stays the head, the same outcome as a set just after the old UPDATE. The drawn version also sits above any vector row a metadata copy left at read + 1 (the conflict resolver's judged stamp, entity tags, verify), so the status mirror does not skip it. A reject at read version + 1 would have skipped it.write_versions_by_ids(strict=True)passesstrictto the status mirror), as the failed UPDATE did. Without it the op would answerrejected=Truewhile recall still served the row. A retried reject re-emits and mirrors again.UPDATE loom.memory SET .... The block-column check intests/unit/test_table_settings.pyreads its table list from the corpus, and the two reject UPDATEs were the only entries.Compatibility, rollout and rollback
memory.rejecttakes and returns the same fields.Tests
tests/unit/test_status_mirror.py::test_reject_writes_version_rows_and_updates_no_embeddings_partfailed first on the twoUPDATEstatements. With the fix it passes: no execute, and the key's rows in two sessions are re-emittedrejectedat one drawn version. Each vector row starts one version above its memory row and is re-emitted at that drawn version.test_reject_raises_when_the_vector_rows_are_not_writtencovers the strict mirror.tests/unit/test_negative_escalation.pyruns the threshold path through the real reject and checks therejectedmemory and vector rows, the reason, and that no UPDATE is issued.tests/analyzer/shapes.txtwas regenerated (python -m tests.analyzer.corpus --write): the two reject UPDATE shapes are gone, and the id read and the usage fold's UPDATE are added.Full unit suite (
pytest tests/unit -p no:randomly) on the first head: 25667 passed, 1 failed (test_table_settings, fixed in the second commit).Against a local ClickHouse 26.10 and a server from this branch:
pytest -p no:randomly tests/integration/test_memory_import.py tests/integration/test_search_statements_pass_analyzer.py::test_patch_part_probe_and_reemit_reads_pass_the_analyzerpassed 18 of 18, with the reject test first. Afterwardssystem.partsshowed 0 patch parts onmemory_embeddings. On the same server, the old statement on one inserted row left 1 active patch part.make format lint typecheck, plus the unit tests around reject, outcome, write scope, import, mutation inventory, package contracts, public copy, agent instructions, doc links and the analyzer corpus: 570 passed.Full unit suite on the rebased head (
pytest tests/unit -p no:randomly): 25801 passed.The one red check on the head is a failure
mainalready has, which #179 fixes:tests/integration/same_key/test_retirement_ch.py(two tests,alias_merges() got an unexpected keyword argument 'cap'). The rest of the integration job passed,test_patch_part_probe_and_reemit_reads_pass_the_analyzerincluded.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The cause was checked against the CI log, the patch-part count on a local server, and the doc that named the exception.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code