Repository navigation
Erasure audit rows name the request token's principal, not the body's requester - #203
Merged
Merged
Conversation
zlareb1
force-pushed
the
fix/erasure-audit-actor-from-token
branch
from
November 3, 2026 18:06
900e1ec to
7e0c353
Compare
… requester erasure.started, erasure.failed, erasure.completed and erasure.exported recorded `actor = input.requester`, a free-text field the caller fills in. The actor now comes from the token (`writer_actor`), and `requester` moves into each row's subject. The saga's ledger row keeps the actor in a new `erasure_requests.actor` column (migration 079), so a saga the recovery worker or `loom erasure-re-verify --resume` continues without a token names the original principal; a row from before the column names the worker. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…h resume path Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…he actor column Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ry ledger read selects it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…older-build checkpoint case Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…allback only for its audit rows Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tly; the worker's actor is named for what it is 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]>
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]>
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]>
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]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…res every column it reads Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…eps its kind:subject form Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ommand on every row Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e.* rows only 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/erasure-audit-actor-from-token
branch
from
November 3, 2026 20:17
badb9c9 to
0949b08
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):
The
erasure.started,erasure.failed,erasure.completedanderasure.exportedaudit rows name the principal of the request's token asactor; the body'srequesteris recorded in the row's subject.Why
Failing case: an admin calls
erasure.request {org:"o", scope_type:"user_id", scope_value:"u-42", requester:"someone-else@o"}. Everyerasure.*audit row of that saga was written withactor = "someone-else@o", anderasure.exportwrote itserasure.exportedrow the same way.audit.emitstores the actor it is given, so the caller chose who the audit log blamed.Pattern: the server sets
actorfrom the token (server.memory.app.provenance.writer_actor); these four rows took it from a free-text body field instead.Fix: the actor comes from
writer_actor(input.requester), which reads the token first and the body only with auth off (a CLI command's pipeline actor wins over the body too).requestermoves into each audit row's subject. A saga can be resumed without a token, by the recovery worker or byloom erasure-re-verify --resume, so the actor is kept on the saga's ledger row in a newloom.erasure_requests.actorcolumn (081_erasure_request_actor.sql) and every checkpoint carries it forward. A resumed saga's rows name the principal that asked. A ledger row from before the column, or checkpointed since by an older build during a rolling upgrade, reads'', and its resumed saga's rows name the process that resumes it:erasure-recovery-worker(the actor the worker already uses forerasure.recoveredanderasure.abandoned), or the CLI command'sprocess:cli:...actor.I considered an alternative that needs no migration: a resumed saga's rows would name the recovery worker. That loses the requesting principal from a resumed saga's
erasure.completedrow. The extraction queue'senqueued_bycolumn is the same pattern as the one used here.Scope and risk
Touches the erasure saga (
server/erasure/app/saga.py), the export handler, the recovery worker,loom erasure-re-verify --resume, and the ledger reads that feed a resume.request_row_templatenow takesactor. The ledger'srequestercolumn and therequesterfields oferasure.status/erasure.list/erasure.exportkeep the body's value as before. Audit rows a saga step writes itself (a user's grant revocations,writer_actor("-")) are unchanged.Rolling upgrade: N-1 never reads the column, and its inserts leave it at the default
''. If an N-1 replica checkpoints a saga that N started, the actor resets to''and a later resume names the resuming process (the recovery worker or the CLI command).docs/architecture/rolling-upgrades.mdrule 27 records this.Compatibility, rollout and rollback
actorof the four audit events changes from the body'srequesterto the token'skind:subject.make migrate). Nothing else.Tests
tests/unit/test_erasure_audit_actor.py(new): a completed saga and a failed saga run under an admin token with a differentrequester. Theerasure.started/erasure.completed/erasure.failedrows and every ledger row namehuman:admin@o, and the subject keeps the requester. A recovery-worker resume with no token carries the ledger row's actor forward unchanged, and itserasure.completedrow names that actor, orerasure-recovery-workerwhen the row has none. Run againstmain(with the worker's actor written out as a string),test_a_completed_saga_names_the_token_on_every_rowandtest_a_failed_saga_names_the_tokenfail on the actor ({'ops'} == {'human:admin@o'}), and the resume cases fail with aKeyErroronactor.tests/unit/test_erasure_export_restricted.py::test_the_exported_audit_row_names_the_token_not_the_body: fails onmain('dpo@y' == 'human:ops@x').test_audit_actor_falls_back_to_the_pipeline_actor_when_the_row_has_nonechecksaudit_actorunder the CLI's pipeline actor.test_the_cli_resume_reopens_from_the_fresh_census_and_reports_what_ranandtest_the_recovery_worker_hands_the_ledgers_residue_to_the_saga(tests/unit/test_erasure_resume_reopens_steps.py) assert that the CLI and worker resumes pass the ledger's actor to the resumed run.tests/integration/test_erasure.pyandtest_erasure_export.pynow expect the token's actor and find the requester in the subject.actor, and added 081 totest_schema_baseline.py.list_completed_requestsnow selectsactorandpurge, the columns itsLedgerRowtype names.make format lint typecheckpass locally, and so do the erasure, webhook, schema-baseline, analyzer-corpus, public-copy and doc-link tests. CI runs the rest ofmake test-unitand the integration suite.schemas/schema.sql: no ClickHouse was available here formake schema-dump; the change is the fresh dump CI's schema check printed for this branch (one column), applied as printed.tests/analyzer/shapes.txtis regenerated withpython -m tests.analyzer.corpus --write(the ledger reads now selectactor).tests/integration/test_erasure_ledger_actor_ch.pywrites ledger rows throughcheckpointand reads them back through all three resume reads.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 failing tests on
main, every caller ofrequest_row_templateandrun_saga, and the tokenless resume paths.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lintandmake typecheckpass locally;make test-unit(beyond the targeted tests) and the integration suite run in CI (see Tests).schemas/schema.sqlfrom CI's dump,tests/analyzer/shapes.txt; the reference docs are current.main; no merged migration is edited.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