fix(doctor): notice receipts destroyed after run.finished was audited - #264
Open
ophiocus wants to merge 2 commits into
Open
fix(doctor): notice receipts destroyed after run.finished was audited#264ophiocus wants to merge 2 commits into
ophiocus wants to merge 2 commits into
Conversation
verifyStoredReceipts only walked runs that still carry a receipt, so nulling one - or deleting the run row - silently shrank checked while ok stayed true (theam#226). The reverse question is now asked: every audited run.finished digest must still have a receipt behind it, reported as a distinct missingReceiptRunIds class so receipt-destroyed and never-audited stay distinguishable, with the runIds scope respected and the doctor message extended. The regression finishes a real run, nulls its receipt, and watches the doctor go red; deleting the row entirely trips the same wire. Closes theam#226 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #226 — credit to @Julian-Genuario for spotting the missing reverse question. Claimed in-thread with right of way offered; the courtesy window has passed, so here is the fix in the shape the claim promised.
The gap, closed
verifyStoredReceipts()proved every surviving receipt against the audit chain but never asked whether an auditedrun.finisheddigest still has a receipt behind it — soUPDATE runs SET receipt = null(or deleting the row) just shrankcheckedwhileokstayedtrue, exactly as the issue demonstrated.missingReceiptRunIdsclass — kept separate frominvalidRunIdsandunauditedRunIdsso "receipt destroyed" and "never audited" remain distinguishable stories, per the issue's point that in current code this state can only be an anomaly.runIdsscope is respected (asking about other runs stays clean), and the doctor's failure line now reports all three counts.The regression bites
The test finishes a real run through
/internal/runs/:id/result, confirmsok: true, then nulls the receipt — doctor goes red withmissingReceiptRunIds: [run.id]— and finally deletes the run row entirely, which trips the same wire because the audit trail outlives it. The "absence must fail loudly" shape, same family as the truncation disclosure above it in the suite.sandbox.test.ts: 40 tests, 0 failures; tsc clean.