Skip to content

fix(pr): recover failed async direct merges - #168378

Merged
steipete merged 1 commit into
mainfrom
fix/w13-a1
Oct 10, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/w13-a1

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A PR could become permanently unlandable through scripts/pr after a routine race on a busy main. In that case, the immediate REST squash goes through the async merge endpoint and GitHub accepts it, returning a request UUID. The status poll then reports a terminal failed result, "Base branch was modified. Review and try the merge again.", with no merge commit. The retained outcome records accepted: true.

From that state:

  • merge-run reconciliation stops with "async direct merge did not complete; no resubmission".
  • merge-recover --confirmed-operator-recovery refuses because ordinary recovery requires an unaccepted intent.

The PR stays OPEN, CLEAN and green, with no sanctioned path to land it. This happened live on #168232. The synchronous form of the same provider rejection (HTTP 405 base-modified) already has a qualified recovery route (recovery.providerRejection). The async form introduced in 38ed3ed never got one.

Why This Change Was Made

merge-recover <PR> <OUTCOME_OID> --confirmed-operator-recovery now also admits one specific accepted intent: an immediate REST intent with a retained UUID, asyncMerge.status: "failed" and a null SHA, on the unchanged head and method. Before admission it re-reads the async result authoritatively for that UUID and requires it to be byte-identical. It then runs fresh ordinary OPEN-head admission with every existing gate.

The successor intent records recovery.asyncFailure through the existing CAS ancestry, mirroring providerRejection/staleHeadRetirement. The load-time validator also checks that the predecessor matches.

Everything else stays refused: pending, enqueued, missing or expired, SHA-bearing, changed-head and replacement-head results. Outcome refs are never cleared, and there is no automatic resubmission. merge-rest.mjs additionally rejects an unmerged async result that carries a commit SHA.

Production +30/−5. It covers the admission predicate, the authoritative re-read, provenance, and ancestry validation.

User Impact

Maintainers can recover a merge that GitHub definitively failed with one explicit, audited command, instead of leaving a green PR stranded or bypassing the tooling.

Evidence

  • The new regression in test/scripts/pr-merge-rest.test.ts fails on main at recovery admission and passes with the fix.
  • The test covers successful recovery with retained asyncFailure ancestry, plus eight refusal cases: pending, enqueued, expired, SHA-bearing, changed result, changed head, replacement head, and failed checks.
  • The scripts/pr owner suite passes, 109 tests (remote, isolated HOME).
  • node scripts/check-changed.mjs passes formatting, typecheck and the selected guards. Its global dead-export scan flags three unchanged symbols on main (isPollVoteEchoText, PUBLIC_SESSION_ENTRY_SCRIPT, isClaudeLikeLiveAgent), which are unrelated to this diff.
  • scripts/AGENTS.md merge-outcome doctrine is updated with the new route.

Allow explicitly confirmed recovery of an accepted, terminally failed direct REST merge only after an authoritative result reread and fresh ordinary admission. Retain the exact async failure and prior outcome through existing CAS ancestry; keep pending, expired, SHA-bearing, and changed-head outcomes fenced.
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 10, 2026 10:02
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR allows explicit recovery of terminally failed async direct merges while preserving fresh admission checks and retained outcome history.

Example: GitHub request 630b9d5e-3f2a-4f7e-8b0c-2d5f9a8c1e42 reports failed with no commit after main advances.

  • Before: Reconciliation refuses resubmission, and explicit recovery rejects the accepted intent.
  • After: Explicit recovery rereads the failed result, checks the unchanged prepared head, and records a new attempt with predecessor ancestry.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful lifecycle coverage; demonstrated behavior remains at the simulated-transport boundary.
Proof confidence 🦐 gold shrimp (3/6) The supplied MEMBER authorship exemption applies to ordinary contributor proof; reported tests exercise production recovery and real Git persistence with simulated GitHub transport, without a supplied live recovery trace. The additive qualification preserves existing outcome records, and the regression covers predecessor preservation and successor reload, establishing a no-migration case.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A definitively failed async merge leaves maintainers unable to land an unchanged, otherwise eligible PR through the sanctioned recovery command.
Reason: The change restores an existing operator-recovery contract without adding configuration, a competing owner, or automatic resubmission.

Merge readiness

✅ Ready for maintainer review

This PR fixes a source-confirmed merge-recovery dead end and remains useful; no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 5e71f085720964aeb799529aae9dabf21f2c4343

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show the new recovery command completing against a real failed GitHub async request through the protected writer.
Agent review details

How this fits together

The maintainer merge tooling consumes prepared PR evidence and GitHub observations, dispatches head-pinned merges, and retains outcomes and captures in private Git history.

flowchart TD
  A[Operator recovery command] --> B[Retained outcome validation]
  B --> C[Authoritative async result]
  C --> D[Fresh merge admission]
  D --> E[Successor outcome CAS]
  E --> F[Pinned merge dispatch]
  F --> G[Receipt reconciliation]
Loading

Technical review

Best possible solution:

Keep the focused recovery exception in the existing merge owner, preserving explicit operator confirmation, fresh admission, and exact outcome ancestry.

Do we have a high-confidence way to reproduce the issue?

Pinned main source establishes the dead end, and the author reports the new regression failing before the fix and passing afterward; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the existing recovery owner with a narrowly qualified terminal-failure exception rather than clearing uncertainty records or adding automatic retries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0aee279a71af.

Provenance checked

  • Accepted-intent recovery restriction changes intended behavior with a stated reason (87f971b: Explicit recovery originally required an unaccepted immediate intent so uncertain dispatch could not silently become retry authority.)
  • Async response and retained lifecycle keeps the original intent (38ed3ed: Retain the request UUID before polling and reconcile failures without automatic resubmission; completion still requires independent PR and tree verification.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 87f971b adds scripts/pr-lib/merge.sh:370 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 87f971b8906d; files: scripts/pr-lib/merge.sh)
  • Vincent Koc: Raw commit 38ed3ed adds scripts/pr-lib/merge-rest.mjs:633 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 38ed3ed9ab42; files: scripts/pr-lib/merge-rest.mjs)

PR surface

Tests +70, Docs +1, Other +25. Total +96 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 70 0 +70
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 3 30 5 +25
Total 5 101 5 +96

Review metrics

Metric Value Why it matters
Production versus tests Production +30/-5; tests +70/-0 The growth supports a narrow recovery transition, strict response validation, and real-Git lifecycle regression coverage.

Labels

Label changes:

  • add P2: A bounded maintainer-tooling defect strands otherwise landable PRs without affecting the application runtime.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A bounded maintainer-tooling defect strands otherwise landable PRs without affecting the application runtime.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Optionally provide redacted terminal output from the native recovery command completing a retained failed async request through the protected writer.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 10, 2026, 6:09 AM ET / 10:09 UTC.

@steipete
steipete merged commit 1a6709e into main Oct 10, 2026
164 of 169 checks passed
@steipete
steipete deleted the fix/w13-a1 branch October 10, 2026 10:33
@steipete

Copy link
Copy Markdown
Contributor Author

Landed at the exact reviewed head 5e71f085720964aeb799529aae9dabf21f2c4343 as 1a6709e.

The only red shard on run 38043527834 was checks-node-compact-small-2-1. There, test/scripts/pr-wrappers.test.ts > accepts scoped GC in either flag order failed with ERR_MODULE_NOT_FOUND for scripts/lib/managed-cleanup-handoff.mts. This was a merge race on main:

The test fails the same way on clean main 0aee279, and this PR doesn't touch either file. The fixture fix is now on main as a5b1703.

Proof for this change:

  • A fresh Codex autoreview found nothing actionable at P2 ("patch is correct", 0.9).
  • The new regression fails on main at recovery admission.
  • The scripts/pr owner suite passed with 109 tests, including eight refusal cases.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
Allow explicitly confirmed recovery of an accepted, terminally failed direct REST merge only after an authoritative result reread and fresh ordinary admission. Retain the exact async failure and prior outcome through existing CAS ancestry; keep pending, expired, SHA-bearing, and changed-head outcomes fenced.
RomneyDa pushed a commit that referenced this pull request Oct 20, 2026
Allow explicitly confirmed recovery of an accepted, terminally failed direct REST merge only after an authoritative result reread and fresh ordinary admission. Retain the exact async failure and prior outcome through existing CAS ancestry; keep pending, expired, SHA-bearing, and changed-head outcomes fenced.

Backport note: #178170 carried this change's async-failure admission
check and tests (through #169595/#169739 conflict context) without the
async_failure declaration, recovery selection, intent recording, and
outcome validation, so every merge-run under set -u exited with
"async_failure: unbound variable". The merge.sh conflict keeps the
release form without the retired ClawSweeper review gate; the test
file keeps the post-#169595 expectations already on the branch.

(cherry picked from commit 1a6709e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant