fix(publish): coordinate every state branch writer#724
Merged
Conversation
Contributor
Author
|
@clawsweeper review |
Contributor
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This was referenced Jul 20, 2026
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.
Summary
statebranch with the existing state-publish leaseProblem
Exact-result publishers and ordinary state writers advance the same
statebranch. The exact publisher lease introduced in the recent publication repairs only fenced exact publishers; comment-router, action-ledger, sweep-status, and apply-status writes could still advancestateoutside that lease.In production after #723, exact publishers successfully acquired and renewed the lease, then repeatedly lost their expected state SHA while those ordinary writers advanced
state. New publishers queued behind the lease holder, timed out, and filled publication capacity. The sampled failures were not GitHub authentication failures: no 401/403 signature was present.Causal proof
29769864078acquired and renewed the state-publish lease around 2026-07-20 19:00:29Zstatereforigin/mainshowed an ordinary state writer did not wait for an exact publisher leaseorigin/main; with this patch the watchdog removed that exact owner OID in about 220 msPR #712's synchronous recovery/history-fetch work amplified the later capacity stall, but it did not introduce the shared-writer race. PR #711's broad no-common-base replacement path remains a separate correctness risk and is intentionally not changed here.
Implementation
statemutations inwithStatePublishMutationLeaseValidation
Crabbox Docker proof
Provider:
local-containerusing Docker-backed Crabbox and Node 24.cbx_8326f7aa23ea(amber-crayfish): pristineorigin/mainfailed all three causal cases; the patch passed ordinary-writer serialization, terminated-owner cleanup, and immutable server-merge coordinationcbx_da0a05d5fee7(amber-prawn): main retained the terminated owner's lease after about five seconds; the patch removed it in about 220 mscbx_af0df260d8b5(jade-hermit):pnpm run build:repair,pnpm run lint:repair, and all 54test/repair/git-publish.test.tstests passed (79.5 seconds)Local focused proof
pnpm run build:repairpnpm run lint:repairpnpm run lint:scriptspnpm exec oxfmt --check src/repair/git-publish.ts test/repair/git-publish.test.tsgit diff --checkBaseline noise
An aggregate Crabbox
pnpm run checkcompleted all builds and all four lint groups, then hit unrelated CRLF fixtures copied from the Windows worktree into Linux (pipefail\r/$'\r') and downstream sweep-workflow assertions. This patch does not touch those scripts or line-ending policy. The authoritative changed publication suite is clean: 54/54 tests on Linux Crabbox.The Linux-only immutable server-merge test also has a pre-existing native-Windows
includeIf gitdirpath failure on pristine main; the Docker-backed Linux proof passes.Risks and rollout
Attribution and related work
This builds on Peter's state correctness and reconciliation work in #714 and #716, and on the publication lease work in #722 and #723. It preserves those repairs while closing the remaining unfenced-writer gap. Related incident work: #711, #712, #713, #715, #720, #721, #722, and #723.
Codex review closeout
codex review --uncommittedNo actionable change-induced defects were found. Targeted state publish lease tests passed.codex review --base origin/mainThe diff consistently fences state-branch mutations with the lease and adds targeted coverage for ordinary writers and terminated owners. No actionable correctness issues were identified.