Repository navigation
Same-key and value-update supersession use the write's user - #752
Conversation
A write that names its user, under a namespace-wide token, now reads that user's rows only — the same scope the conflict verdict already uses — so it no longer retires another user's memory. Closes ClickHouse#723 Signed-off-by: ningyixi <[email protected]>
There was a problem hiding this comment.
The same-key fix does not reach the point-write and update-by-id callers, so cross-user retirement remains on those paths. The new peer-query tests supply a user_id that production point-write batches omit; the inline finding uses the actual production helpers.
223 related unit tests pass locally. One ClickHouse-local test fails identically on this branch and main because the installed binary lacks enable_quantized_codec. Live ClickHouse and Postgres write behavior was not exercised locally.
Same-key supersession reads the write's user from the batch. The production point-write and update-by-id helpers omitted that field, so a namespace-wide token writing Bob could still retire Alice's row. Signed-off-by: ningyixi <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
The point-write and update-by-id batches carry the write's user, fixing the earlier finding. All 255 other focused scope, conflict-resolver and definition tests pass. The remaining ClickHouse-local test cannot run with the installed binary because it lacks enable_quantized_codec; live ClickHouse and Postgres behavior remains for CI.
|
Three required CI jobs fail on this head; neither is a retry candidate.
The unit failure reproduces locally on this head and passes on main. The source fix for the earlier review finding remains correct. Update the tests for the intended scope and let CI validate the full write paths before merge. The integration failure was checked against its source and CI output; it was not run locally. |
zlareb1
left a comment
There was a problem hiding this comment.
P2 — The test updates in the existing CI explanation are required before merge. tests/unit/test_memory_update_conflict.py::test_clear_verdict_writes_an_active_version_and_resets_the_old_mark fails on this head and passes on current main: its expected batch omits the carried user_id. The integration control also needs to exercise same-user supersession while preserving the cross-user isolation assertion. The source correction for named-user isolation remains sound; the required test suite must validate that intended behavior.
The clear-verdict update assertion now checks the carried user_id. The deferred isolation test keeps both named users' rows active, then revises the same user from another session so permitted supersession is still covered. Signed-off-by: ningyixi <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
The unit expectation is fixed, and 425 focused unit tests pass. The revised deferred-write integration control still fails against a fresh private ClickHouse with fake providers and authentication enabled: user-x has no superseded row after the final replay. The inline finding describes the failing assertion and fixture issue. One additional unit test needs a newer local ClickHouse binary.
…text Signed-off-by: ningyixi <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
The deferred-write control passes against a fresh private ClickHouse with authentication enabled and fake providers. It verifies both cross-user isolation and same-user supersession across sessions. All 425 other focused unit tests pass; one ClickHouse-local test needs a binary with enable_quantized_codec. No blocking findings remain.
|
@ningyixi could u check test failure? |
|
The failing check is on PR head Please attach the failure entry from |
Closes: #723
Related: #701
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):
A write that names its user, under a namespace-wide token, no longer retires another user's memory through same-key supersession or the value-update pass.
Why
#701 made the write-time conflict verdict read only the write's user's rows (
_writer_scopeinserver/memory/app/conflicts.py). Same-key supersession (_live_same_key_rows) and the value-update peer reads (_peers_many,_peers_joined,_peers_codes_first) still usedrequest_scope(). Under a namespace-wide token, a write of keyseatfor Bob could retire Alice's liveseatrow, and a bulk orset_from_messageswrite for Bob could mark Alice's dated factsuperseded. A write that names no user keeps today's namespace-wide behaviour.Scope and risk
Touches only the two post-insert retirement paths named in #723, plus tests. Conflict checks, pinned-peer refusal, and a token already pinned to one user are unchanged:
_writer_scopeis the same helper #701 introduced. If the write's scope cannot be resolved, those paths retire nothing (fail-open, as they already do on a lookup error). A mixed-user batch is read per write user.Compatibility, rollout and rollback
Tests
Reproduced on
mainat32afe0awith a fake ClickHouse client and a namespace-wide service token: a write that namesuser_id="bob"issued an unscoped same-key / value-update peer read (the new tests failed before the change). After the fix:LOOM_ENV_FILE= .venv/bin/python -m pytest -q -p no:randomly tests/unit/test_write_scope.py tests/unit/test_key_supersession.py tests/unit/test_value_updates.py tests/unit/test_definition_write_rules.py tests/unit/test_auto_resolution.py tests/unit/test_write_peer_reads.py tests/unit/test_write_candidates_batched.py— 223 passed, 1 skipped.ruff formatandruff checkon the changed files: clean.scripts/gates/function_length_gate.py: passed (baseline unchanged).mypy --strictonserver/memory/app/key_supersession.pyandserver/memory/app/value_updates.py: clean.Did not run the full
make test-unitintegration suite or a live ClickHouse / Postgres server in this environment (makeis not installed here; the local venv is missing some extras such asnumpyandtree_sitter). The existing token-pinned write-scope tests still pass, and a namespace-wide write that names no user still reads the whole namespace.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Cursor / Grok Bot. I selected the issue, reproduced the unscoped reads against current
main, applied_writer_scopeto the two paths Same-key supersession and the value-update pass can retire another user's memory under a namespace-wide token #723 names, and ran the tests listed above.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheck,make test-unitand the integration suite were not run in this environment (see Tests)._writer_scope.git commit -s), as CONTRIBUTING.md asks.