Repository navigation
fix(repair): retry state-repo pushes on concurrent-writer rejection - #711
Conversation
A shallow state checkout fetches a racing writer's push with --depth=1, so the new remote head shares no local ancestry. pushCommit's recovery then ran git merge-base through runGit, which threw and escaped every publish retry loop (spam scanner runs 29701094002 and 29702697623). Probe the merge base non-fatally and defer disjoint-history races to the caller's bounded rebuild-on-remote-head retry path. Also safelist log and merge-base in redacted command display so future failures name the action.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c28770bcb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| console.log( | ||
| `No common Git base with ${remote}/${branch} after a lost push race; deferring to a remote-head rebuild`, | ||
| ); | ||
| return false; |
There was a problem hiding this comment.
Preserve concurrent files before rebuilding broad paths
When a shallow checkout loses a push race and the remote writer changed a different child of a published directory, this return sends execution to rebuildPublishCommit, which removes each entire publish path and checks it out from the stale source commit (src/repair/git-publish.ts:1743-1749). This can delete accepted concurrent state: for example, .github/workflows/repair-publish-results.yml:197 publishes all of results, and the spam scanner publishes all of results/spam-audit, so an unrelated result added by the racing writer is absent from the rebuilt commit and is removed on the next push. The no-common-base recovery needs to preserve remote children outside the local diff rather than replacing directory snapshots wholesale.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 7:27 PM ET / 23:27 UTC. Summary Reproducibility: yes. in source: the supplied shallow-checkout race test gives a concrete reproduction shape, but the submitted evidence does not show an after-fix run that exercises a concurrent sibling beneath the same published directory. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Preserve fetched remote children outside the local publish diff during no-common-base recovery, add a same-directory concurrent-writer regression test, and provide redacted evidence from a real shallow state-repository publish run before merge. Do we have a high-confidence way to reproduce the issue? Yes in source: the supplied shallow-checkout race test gives a concrete reproduction shape, but the submitted evidence does not show an after-fix run that exercises a concurrent sibling beneath the same published directory. Is this the best way to solve the issue? No: returning to a broad directory rebuild avoids the merge-base exception but does not preserve remote files outside the local diff, so the fallback needs a non-destructive reapplication strategy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d7e01ce59f9d. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…penclaw#711) A shallow state checkout fetches a racing writer's push with --depth=1, so the new remote head shares no local ancestry. pushCommit's recovery then ran git merge-base through runGit, which threw and escaped every publish retry loop (spam scanner runs 29701094002 and 29702697623). Probe the merge base non-fatally and defer disjoint-history races to the caller's bounded rebuild-on-remote-head retry path. Also safelist log and merge-base in redacted command display so future failures name the action.
Problem
The spam scanner workflow failed twice on 2026-07-19 while publishing its audit to the state repo:
Both logs show the same shape: the state push loses a race to a concurrent workflow (
error: failed to push some refs to 'https://github.com/openclaw/clawsweeper-state'), and then the publish aborts withRoot cause
publishMainCommitalready has bounded, jittered retry loops for lost push races. The failure is in the recovery path itself: after the rejected push,pushCommitfetches the new remote head and plans sweep-status/ledger merges, which runsgit merge-base <local> <remote>throughrunGitwithoutallowFailure.Production state checkouts are shallow, and
fetchPublishRemotedeliberately preserves that with--depth=1. A depth-1 fetch of the racing writer's tip records it as a new shallow boundary, so it shares no visible ancestry with local HEAD.merge-baseexits 1 with no output,runGitthrows, and the exception escapes every retry loop. The metrics line from the failed runs (merge-base:1, displayed as the anonymousgit command) confirms exactly this sequence.Fix
In
pushCommit's post-rejection recovery, probe the merge base withspawnGitinstead ofrunGit. When there is no common base (the shallow-race signature), log it and returnfalseinstead of throwing. The caller's existing bounded retry loop (maxAttempts, jittered backoff,Git publish failure:diagnostic preserved) then falls through torebuildPublishCommit, which re-applies the publish directly on the fetched remote head - that path never needs shared ancestry (its merge base is the source commit's parent, always local). Genuine auth/network push failures behave as before, and the reconcile-records no-common-base publish still fails closed.Also adds
logandmerge-baseto the redaction display safelist so future failures name the failing git action instead ofgit command.All callers of the shared helper benefit: every workflow publishing through
repair:publish-main(spam-scanner, sweep, repair-publish-results, comment-router, cluster intake/worker, self-heal, finalize-open-prs, commit-review, proof-nudges, issue-implementation intake, conflict self-heal) plus in-process users ofpublishMainCommit.Validation
publishMainCommit survives a shallow-checkout push race without a common Git basereproduces production exactly: shallow (depth-1) checkout, concurrent two-commit remote push,theirsstrategy. Without the fix it fails with the production error (Git publish failure: phase=push ... error=git command <redacted-args> exited 1); with the fix it publishes both the local and the concurrent changes.pnpm run build:allplus the fulltest/repair/git-publish.test.tssuite.pnpm run checklocally (one pre-existing host-specific failure: the immutable-ledger server-merge test fails identically on unmodifiedmainon macOS becauseincludeIf.gitdirdoes not match the symlinked tmpdir realpath; unrelated to this diff).Internal-only reliability fix; no changelog entry.