Repository navigation
erasure.status returns the erasure's receipt: every substrate its latest census counted, and the purge it applied - #462
Merged
Merged
Conversation
…est census counted, and the purge it applied Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/erasure-receipt
branch
from
November 10, 2026 03:50
c9ffbd0 to
f55beee
Compare
The integration module lists the receipt's behaviours; a unit test pins the hygiene re-verify of a bare-array namespace list to the purge its saga ran. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The census fields and the receipt section name every case it is None; the self-check reads the erased id at a prompt, out of the shell history; tests cover a failed census's receipt and tie the read window to the ledger's TTL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A complete census always carries provider_rebuild_copies, 0 when no copy exists, so every receipt has the same keys; the receipt section says when a failed run has one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The self-check says each statement reads the grant's whole scope and which caps can stop it, and how to check a namespace_list erasure. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The migration and the test module say the column holds the latest row's census; the self-check names its fourth statement as the request ledger check; a test pins a step checkpoint writing no census. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The completed path works out the census once, and one helper writes the ledger's census text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Each path works out the census once and passes it to the ledger columns, the audit row and the answer; the erased-namespaces list moves out of run_saga. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The self-check says the request ledger view confirms a scrub only for rows inside its window. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The self-check names the rejected versions the history view leaves out. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
_verify_columns works out the census from its holder again, so no caller can pass one that disagrees with the counts; the receipt section says census is null, and purge is always served. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This was referenced Nov 10, 2026
Merged
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.
Related: #450
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):
erasure.statusanderasure.requestreturn the erasure's receipt:census, every substrate the final residue census counted with its count (zeros included), andpurge, whether the saga deleted or tombstoned. The retention and erasure page shows how to re-count the memory and conversation tables through the SQL surface.Why
An erasure ends with a residue census over every substrate Loom reads, but the ledger kept only the non-zero counts. A completed saga stored
residue = {}, so the list of what was checked was lost. A receipt the requester can keep, and partly check themselves, needs the whole census: each table and its zero, and when the census ran.Design
Receipt shape. Two fields on
ErasureStatusOutputandErasureRequestOutput:census: dict[str, int] | Nonepurge: boolThe subject and the time are already there (
org,scope_type,scope_value,verified_at), so the receipt adds no copy of them.pg:<table>for the Postgres authority,objects.document_originals, andprovider_rebuild_copies. The last sums a provider rebuild's per-rebuild copy tables, so the keys stay stable from one rebuild to the next.censusis the latest ledger row's: null while a run is in progress, when its census could not run or left a store uncounted, or on a row an older build wrote.Storage. Migration 091 adds
loom.erasure_requests.census(a JSON string).censusis inVerifyColumns, so every terminal and failed checkpoint writes it.list_unabandoned_exhausted→_ledger_verify), and so doesverify_columns_from_output.VerifyColumnskey.Correctness fixes the receipt depends on.
run_sagadropsverify.residuefrom the completed set on every resume. Before, a crash between the census and the terminal row wrote acompletedrow with noverified_at, because the in-progress checkpoint carries no verify columns. The resume then skipped the census.applied_purge(scope_type, scope_value, requested)inserver/erasure/domain/scopes.pyis the rule the saga runs by: a user's as requested, a namespace list's from its scope, a single namespace's never.ledger_reads.purges, the saga's inline branches andhygiene._re_verify_scope.parse_purge_flagandparse_external_flagmove there with it.purgecolumn now records the applied purge, so a single-namespace saga that was asked to purge saysfalse.purgewith the same rule, so rows written before this change read right too.requested_at, which every checkpoint repeats. Near the end, an older checkpoint can outlive the terminal row.ledger.pyread now carriesLIVE_LEDGER(requested_at > now() - INTERVAL 89 DAY): status, list, stuck, failed, completed and exhausted.unfinished_since,unfinished_reaching) do not, because a stale unfinished row keeps fencing, which fails closed.Durable copy. The
erasure.completedaudit subject carries the census, counts only. Audit outlives the ledger row. The write is best effort and happens after the completed checkpoint, so the docs say the answer itself is the copy to keep.Self-check. A new docs section, "Checking an erasure yourself", covers:
*SQL grant runs against the SQL surface's views to re-countloom.memory,loom.memory_versionsandloom.conversations;clickhouse-client;namespace.restorefrom an older snapshot, and user-scope bucket objects;Alternatives rejected.
residue: that changes an existing field's meaning.memory.restorecannot reach an erased row, because the first saga step deletes its head.restore.pyis not gated by authority, so under Postgres it can only record a row written after the erasure.erasure.list'sreversals_countshows those.The design went through a principal-architect review to zero findings before coding.
Scope and risk
docs/features/memory/retention-and-erasure.mdanddocs/architecture/rolling-upgrades.md(rule 41).run_sagareached the 200-line function gate with the receipt's lines, so the webhook's erased-namespaces list moved into_erased_namespacesunchanged.loom erasure-re-verify --resumeof an oldernamespace_listrow whose scope is a bare array now takes the ledger'spurgecolumn, as the saga does, where it tookfalse.purgecolumn readsfalse. Nothing reads that column for a namespace scope except the status.Compatibility, rollout and rollback
erasure.statusanderasure.requestoutputs,census(nullable) andpurge. Nothing is removed.census. A row N-1 checkpoints reads'', which N answers ascensus: null.Tests
tests/unit/test_erasure_receipt.py:copy_residueemits;LIVE_LEDGER, and the status statement sent carrying it;erasure.statusanswering no receipt for an empty census, andpurge: falsefor a single-namespace row that asked to purge.tests/unit/test_erasure_resume_reopens_steps.py: a resume always re-runs the census.tests/integration/test_erasure.pyagainst a local ClickHouse 26.10 and a server from this branch:purge: false, and the status agrees;erasure.completedaudit row carries the same census;purge: truereportspurge: false, with a zero census;clickhouse-clientas a granted SQL user: 0 on all four for an erased user, 1 on memories, history and request ledger for a kept one.system.query_logshowed ClickHouse writes bound parameter values into the logged text (HTTP and native), so the page says so instead of claiming binding keeps them out.make format lint typecheckpass.schemas/schema.sqlwas re-dumped after migrate.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 design was reviewed to zero findings by an architect subagent before coding, and the integration tests were run against a live ClickHouse.
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.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