Repository navigation
The namespace.tune test compares a FINAL snapshot, so a merge or an extractor pass does not read as a write - #230
Merged
Merged
Conversation
… does not read as a write counts() read loom.memory and loom.categories (both ReplacingMergeTree) without FINAL; a merge between the two counts collapsed versions and failed the 'changes nothing' check (12 rows before, 10 after) with no write in between. 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]>
…hange A FINAL count would miss a revision or tombstone of an existing row; the snapshot leaves out version and entities, which the entity extractor moves. 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]>
… count Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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):
Why
tests/integration/test_namespace_tune.py::test_tune_drafts_from_the_rows_and_changes_nothingfails at random:assert (10, 0) == (12, 0). Itscounts()helper readscount()fromloom.memoryandloom.categorieswithoutFINAL. Both areReplacingMergeTree(version), so the raw count moves withoutnamespace.tunewriting anything. A background merge between the "before" and "after" counts collapses row versions (12 to 10). The entity extractor, on by default, also writes a new version of a row it tags (apply_entities_batch), which can raise the count the other way.The fix: the check compares a
FINALsnapshot of the fields a write would change instead of a raw count: per memory row its agent, key, id,content_sha256,status,pinned,tags,tombstoned_at,actor,source_classandreinforcement_count, and per category its name, id, description andtombstoned_at. A merge cannot move it, the extractor's new versions do not touch those columns (versionandentitiesare left out), and a revision, tombstone, pin, reinforce, re-stamp or new category still fails the check, as the module docstring promises. The cited row's version is compared with>=for the same reason: the entity extractor may write a newer version of it betweennamespace.tuneand thememory.getthat checks the citation; its id andcontent_sha256must still match exactly.Scope and risk
One test helper. No server code changes.
Compatibility, rollout and rollback
Tests
tests/integration/test_namespace_tune.pyagainst a local server and ClickHouse, three runs: 1 passed, 1 skipped each time. Those runs cannot show the race is gone, since forcing a merge or an extractor pass at the right moment is not practical here; the argument is that aFINALsnapshot of those columns is the same whatever versions exist. The failure above appeared on an unrelated PR's integration job.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. I checked both tables' engines in
schemas/schema.sql.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.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code