Repository navigation
memory.update_by_id leaves a hash-only audit row, and memory.update's no longer holds the value - #242
Merged
Merged
Conversation
… no longer holds the value memory.update_by_id was declared audit=False and its handler wrote no row, so a revision by id left no trace in loom.audit_log. memory.update, on the same write path, was audited by the transport with the whole input as the subject, the new value included, and also on a not_found answer that wrote nothing. The shared revision path now writes one row after the version lands: key, memory id, content_sha256, source_class, version and verdict, never the value, in the row's own namespace (an update_by_id request carries none). Both ops are audit=False so the transport adds no second row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…at row The row now goes out beside the memory.revised event, so a revision whose version row is in leaves it even when a later step (embedding insert, supersession, edges) fails. Its namespace, actor, source_class, version and hash come from the version row written, which under if_match_sha256 is built from the head re-read under the key lock. It carries the request id, as the transport row did. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s its verdict Each memory.update / memory.update_by_id now awaits its audit row's waited insert inside the handler, so both base budgets and their webhook shapes rise by one ch_batched_insert_wait_max_ms. The audit page says the row's verdict is the conflict check's, before post-write marking. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…as memory.set records it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…n unchecked revision's empty verdict is documented and tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
With no token the row says '-', as memory.set's does; the version row keeps its own fallback to the previous author. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rite's own row names its actor Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…'s actor; a decision-extract test comment matches the handler-written row Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
8 of 9 tasks
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.update_by_idnow leaves an audit row, and thememory.updateaudit row no longer contains the new value. Both rows hold only the key, memory id, content hash, source class, version and verdict.Why
Failing case:
memory.update_by_id(memory_id=X, value="new")writes a new version with a newcontent_sha256, andloom.audit_loggets no row. The op was declaredaudit=Falseand its handler (server/memory/app/update.py) wrote no row of its own.memory.updateruns the same_update_live_rowand was audited by the transport, so a revision was audited or not depending on how it was addressed.Pattern: the transport audit for
memory.updatehad noaudit_subject, so its subject was the whole input, with the new value in it. It was also written on anot_foundanswer, which changes nothing. The memory-plane rule says every write that creates or changes memory leaves one hash-only audit row.memory.bulk_setand the embedded path ofmemory.setwrite their row in the handler.update_by_idcannot use a transport row, because its request carries no namespace and the row would be stamped-.Fix: the shared revision path (
_write_revision) writes the row as soon as the version row is in, beside thememory.revisedevent (_record_revision). So a revision whose version landed is audited even when a later step (embedding insert, supersession, edges) fails. Everything in the row comes from the written version row:event_type= the op name, that row's namespace, the caller as actor (asmemory.setnames it;-with no token), the request id, and a subject ofmemory_key,memory_id,content_sha256,source_class,versionand the verdict the write was checked with. Underif_match_sha256, that row is built from the head re-read under the key lock. Both ops are nowaudit=False, so the transport writes no second row.Scope and risk
Touches only the two revision ops. Out of scope:
memory.set's plain-insert path (non-embedded types andhighrows) writes no audit row; that is a separate fix. Each revision now awaits its audit row's waited insert inside the handler; formemory.updatethat wait used to fall after the measured handler time. So both base budgets and theirwebhookshapes rise by onech_batched_insert_wait_max_ms(memory.update170 / 220,memory.update_by_id130 / 180). The row'sverdictisduplicatefor a version written as one (asmemory.setrecords it), else the conflict check's, before post-write marking, because the row is written as soon as the version lands. The audit page says so. The audit write is fail-open (audit.emit), as it is formemory.set, so a failed insert never fails the revision.memory.touch(an expiry-only rewrite,audit=False) is left as it is: whether an expiry change counts as changing memory is a separate design question.Compatibility, rollout and rollback
auditflag ofmemory.updatein the op table and SDKOPSchanges from true to false, because the handler now writes the row. Thesubjectof amemory.updateaudit row changes from the input body to the hash-only shape. A reader that parsedvalueorreasonfrom it no longer finds them. Itsactorchanges from the bare token subject (anonymouswith auth off) tokind:subject(-with no token), asmemory.set's row already names it. In-process revisions (the decision extractor's tag rewrite throughmemory.update_by_id) now leave a row too.memory.updaterows written before this change hold the input value insubject, and erasure does not reachloom.audit_log(the census lists it as holding no memory content). This change stops new ones. What to do with the existing tamper-hashed rows is left to a follow-up.Tests
tests/unit/test_memory_update_by_key.py::test_a_revision_leaves_one_hash_only_audit_row_in_the_rows_namespace[memory.update|memory.update_by_id]checks that exactly oneloom.audit_logrow is written, with the row's namespace, the bound request id and the exact hash-only subject, and that the value does not appear. Both cases failed before the fix (no row).test_a_conditional_revision_audits_the_head_it_wrote_from: underif_match_sha256, the subject'ssource_classis the re-read head's.test_a_revision_that_fails_after_its_version_lands_is_still_audited: a supersession failure after the insert still leaves the row.test_a_revision_written_as_a_duplicate_is_audited_as_one[merge|duplicate]: the subject's verdict isduplicate.test_a_revision_that_is_not_conflict_checked_is_audited_with_no_verdict[episodic|high]: no conflict check ran, so the verdict is empty.test_a_revisions_audit_row_names_the_caller_not_the_earlier_writer[token|no-token]: the actor is the caller's (-with no token), never the row's earlier writer.test_an_update_that_finds_no_row_leaves_no_audit_row: an id that does not resolve writes no row.make format lint typecheck, the memory update, write-lock, revision, conflict, scoped-token, toolset, audit-subject, public-copy and doc-link unit tests, and the SDK and docs reference generators.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 the audit path end to end (transport
post_handler_rows,audit.emit, the namespace a by-id request carries) and the generated table diffs.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lintandmake typecheckpass; the targeted unit tests above pass locally, and CI runs the full unit and integration suites.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code