Repository navigation
CRW-622: cancel-safe receipt publish (PublishContext + late withdrawal) - #579
Merged
Merged
Conversation
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The coordinator refreshed the base. The only conflict was in docs/port-cxc/known-defects.md, where both sides appended lines at the same place (1 block(s)); both sets are kept, dev's lines first, then this branch's.
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.
What this changes
crw pabcd receipt testcould publish a success receipt after its invocation had been cancelled. Theexisting late-cancellation check (added by the preceding receipt-interrupt fix, pull request #548) sits
before the receipt directory work and before
crwdir.Publish; a cancellation that landed while the receiptwas encoded, written, fsynced and renamed was never seen, and the command printed the receipt path and
exited 0. The oracle has no such window in its recorded interrupt (its process died at the deferred SIGINT
before its single in-place
writeFileSync), and it has no withdrawal at all.This PR:
crwdir.PublishContext(ctx, finalPath, data). It runs the existingpublishwith its step hook andreturns
ctx.Err()at the rename step, the last point at which the publish can still be skipped, so thedeferred cleanup removes the temp file and no final file appears.
Publish,Renameand their sixother production callers are unchanged.
PublishContext(context.Background()when the run options carry nocontext); a clean cancellation maps to the existing refusal
receipt test: the command did not run to completion (interrupted); no receipt written, exit code 1. Acancellation joined with a failed temp removal is reported as it happened instead, so a stranded
temporary file is never hidden behind "no receipt written".
rename-step check, the receipt this run published is unlinked (its absence is fine) and the same refusal
is returned. The withdrawal removes only the bytes this run wrote, so a receipt another invocation for
the same session published in the meantime is left alone; a withdrawal that fails returns its
unlinkerror rather than the refusal, so a surviving receipt is never reported as absent either.
removeReceiptand uses onereceiptInterruptedconstant for therefusal at all three sites.
Acceptance criteria
context.Canceled; an uncancelledPublishContextwrites the same bytes and mode asPublish.text, exit 1, nothing published, and the post-publish check does not run).
invocation replaced in the meantime survives, and when the withdrawal itself fails the
unlinkerroris returned instead of the refusal.
refusal.
corpus replay pass.
Oracle source ported
plugins/codexclaw/components/pabcd-state/src/receipt-cli.tsat v0.2.40 (3c1459ac), lines 115-185:the forced
rmSync, the blockingspawnSync, the in-placewriteFileSyncat line 184. The oracle hasno signal handler and no withdrawal; the port's interruption handling is the intentionally-changed part
recorded with the preceding fix.
26e47fe2:internal/pabcd/crwdir/atomic.go(publish, its step hookand deferred cleanup) and
internal/pabcd/cli/receipt.go(receiptLateCancelHook, the late check, thepublish call).
Commands and results
Red first, on base
26e47fe2before the implementation:go test -count=1 ./internal/pabcd/crwdir ./internal/pabcd/clifails to build against the missingpublishContext,PublishContext,receiptBeforePublishHook,receiptAfterPublishHookandreceiptInterrupted.Green, on the final head:
go test -count=1 ./internal/pabcd/crwdir ./internal/pabcd/cli ./internal/harness-> ok.Behavioural sensitivity evidence (disposable local edits, reverted before any commit; each makes exactly
its test fail):
Publishinstead ofPublishContextctx.Err()returnPublishContextcancellation tests fail witherr = <nil>errors.IsaloneThe full battery on the head (
ci validate,ci pluginwith no digest change,ci contracts, thecomplete cxc replay,
make lint,go veton linux and darwin,CGO_ENABLED=0 go build ./...,gofmt -l,git diff --check) and the hosted CI run are cited in the delivery handoff.Corpus classification
Fixtures that reach this issue's units (the receipt CLI's publish path; entry point
crw pabcd receipt test, driven as a cli step by the replayer):cli-help__receipt__{dash_h,dashdash_help,test_dashdash_help,word_help}crw pabcd receipt … --helpcli__receipt__not_at_phase_c_refused_plaincrw pabcd receipt testrefusal before publicationcli__receipt__failing_command_recordedcrw pabcd receipt testinside the P→A→B→C pipelinecli__orchestrate__split_cwd_cycle_closes_on_real_commit_receiptcli__orchestrate__bound_c_to_d_requires_test_receiptcli__evidence__resolve_with_receiptcrw evidence resolve(reads a receipt file, never publishes one)The cancellation window itself has no recorded fixture: the recorder has no signal or cancellation
scenario, which is also why the preceding fix records none. The new Go tests are its evidence, and
contract/notes/cxc/CRW-622.jsonregisters no claim (identical: [],intentionally-changed: [])because this PR makes no fixture pass that an earlier issue does not already own.
Review findings on this PR
meantime at the same fixed path. Fixed in
26a84c826: the withdrawal removes the receipt only whilethe bytes on disk are still the ones this run wrote, with
TestReceiptPublishCancellationLeavesAnotherInvocationsReceipt.plain refusal, hiding the leftover file. Fixed in the same commit through
receiptPublishRefusal, withTestReceiptPublishCancellationWithAStrandedTempFileIsReported.the review policy anticipates.
Diff size
346 added and 7 deleted lines (353 changed): implementation 117, tests 227, documentation 9. No generated
data is committed.
Defects
The defect this PR fixes is port-introduced, not an oracle defect. It is recorded as one
port: fixedline in
docs/port-cxc/known-defects.mdnaming the tests that pin it. No other defect was found whileporting this window.
Base and conflicts
The branch is based on
26e47fe2. Dev has moved since; a local merge check against the fetched dev tipshows the only conflict is the append-only section of
docs/port-cxc/known-defects.md(no code conflict,and the merged tree builds with these tests passing in a scratch checkout that was removed afterwards).
The append-only union is the coordinator's merge-lane step.
Out of scope
No change to
Publish/Renameor their other callers; no other path gains cancellability; no hook,skill,
.codex-pluginor recorded fixture change; no merge, release, install or live-state action.