Repository navigation
fix(maintainers): prevent duplicate merges after ambiguous responses - #132173
Conversation
Retain exact native merge intent across process-lock recovery and record completion before comments or cleanup. Reconcile uncertain outcomes without replaying a mutation. Fixes #132138.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 8:20 PM ET / August 29, 2026, 00:20 UTC. ClawSweeper reviewWhat this changesThis PR records and reconciles native GitHub merge attempts in a retained Git ref so recovery after an ambiguous response cannot submit the same prepared pull request twice. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer handling. The introduced durable receipt prevents the demonstrated replay path, the prior rebase-receipt finding is covered by the current head, and no new blocking defect surfaced; exact-head CI is still in progress. Priority: P2 Review scores
Verification
How this fits togetherThe maintainer merge wrapper submits a reviewed pull request to GitHub, then records completion, comments, and cleans up branches. This change keeps merge outcome state independently of the disposable process lock so recovery can reconcile an uncertain remote request safely. flowchart LR
A[Reviewed pull request] --> B[Merge wrapper]
B --> C[Durable outcome record]
C --> D[GitHub merge request]
D --> E[Authoritative PR and main read]
E --> F[Receipt reconciliation]
F --> G[Comment and cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceTests -9, Docs +8, Other +89. Total +88 across 11 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one retained outcome owner at the merge boundary, preserve its fail-closed reconciliation semantics, and land only after the exact head has completed its required CI gates. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: the focused suite models the applied-response/OPEN/recovered-lock ordering through the real merge owner and asserts that the second invocation does not mutate again. This read-only review did not execute the suite. Is this the best way to solve the issue? Yes. Recording remote-dispatch intent at the merge owner, independently of the process lock, is the narrower durable fix than inferring remote completion from local lock recovery or retrying after an OPEN read. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d53f57c3d250. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Bind rebase and queue results to the retained source fork base, verify merge content as well as ancestry, and align routing regressions with the split test owners. Addresses the review and CI failures for #132173.
|
Land-ready review for ff7d2d6. Exact-head CI run 33222825239 completed successfully. The latest ClawSweeper review covers this head with no actionable finding; its exact-head CI Rank-up move is satisfied. The earlier rebase-receipt finding is addressed. Fresh isolated full-candidate and final fixture-only autoreviews were scoped-clean at the configured P0 threshold; this is not an all-priority certification. The intended compatibility tradeoff is accepted: a retained uncertain intent requires operator reconciliation, even if the process crashed before sending the request. It never silently becomes another merge submission. This is one common-Git-directory outcome owner, not fleet-wide exactly-once or an atomic GitHub base precondition. Receipt verification precedes comment/audit/cleanup; normal/admin/auto/queue routes share it. Removed paths include success-only polling, post-error auto re-arm/fallback, blind comment retries and unconditional remote deletion. Production/tooling net +86 establishes that missing durable ownership boundary; tests/support net -6, guidance +8. Proof executed: node scripts/run-vitest.mjs test/scripts/pr-merge.test.ts test/scripts/pr-merge-outcome.test.ts test/scripts/pr-operation-lock.test.ts test/scripts/pr-wrappers.test.ts test/scripts/plain-gh.test.ts test/scripts/pr-review-artifact-validation.test.ts test/scripts/pr-crabbox-merge-bypass.test.tsInitial focused candidate: 223 passed; one Linux-only zombie test skipped on macOS. node scripts/run-vitest.mjs test/scripts/pr-merge-outcome.test.ts test/scripts/test-projects.test.tsReceipt/routing correction: 391 passed (70 outcome, 321 routing). Original-owner applied-502 regression and upgrade/rebase negative cases were demonstrated failing before their fixes. GIT_AUTHOR_DATE=2000-01-01T00:00:00Z GIT_COMMITTER_DATE=2000-01-01T00:00:00Z node scripts/run-vitest.mjs test/scripts/pr-merge-outcome.test.tsFinal same-second fixture correction: 70 passed; the exact prefix case failed before correction under this same clock. Distinct main-advance metadata and ancestry assertions correct the fixture without weakening production checks. node scripts/check-changed.mjs -- test/scripts/pr-merge-outcome.test.tsFinal correction gates passed after installing the native worktree's pinned dependencies. Prior full changed gates, Bash syntax, source-following ShellCheck and Live read-only recovery used the actual candidate wrapper twice in a disposable repo, with a deny-write GitHub adapter and the historical source head: two successful confirmations, eight real metadata reads, zero attempted GitHub mutations, retained receipt and an explicit empty-squash warning. No live 502 injection or queue/rebase mutation is claimed; those boundaries use real disposable Git repositories with injected transport faults. No private transcripts or routing identifiers are published. CI history is retained in the PR body. The first run caught corrected routing expectations. The second caught the fixture collision above, the UI graph overflow subsequently fixed by the native-assets PR's shard split, and a gateway settled-ownership timeout. The gateway target passed both local attempts, and the exact original 26-file order passed all 325 tests on its CI main parent. An isolated-file attempt had a different root-work teardown failure that also passed in the full shard. Neither gateway cause is established; a separate diagnostic follow-up retains both failures. No gateway source, timeout or assertion was changed. Final Linux CI is green. Native review artifacts bind this exact head. Live main rules require linear history and |
|
Merged via squash.
|
…penclaw#132173) * fix(maintainers): prevent duplicate merges after ambiguous responses Retain exact native merge intent across process-lock recovery and record completion before comments or cleanup. Reconcile uncertain outcomes without replaying a mutation. Fixes openclaw#132138. * fix(maintainers): validate rebase merge receipts Bind rebase and queue results to the retained source fork base, verify merge content as well as ancestry, and align routing regressions with the split test owners. Addresses the review and CI failures for openclaw#132173. * test(maintainers): distinguish cherry-picked fixture commits
Closes #132138 — native retry can create an empty duplicate squash after an ambiguous merge response.
Additional instructions
This same-repository branch remains editable by maintainers. AI-assisted implementation and independent review.
What Problem This Solves
Fixes an issue where maintainers retrying the native landing workflow could create an empty duplicate squash when the previous request returned an error after its patch had already reached main.
The observed declaration-completion landing produced the five-file patch commit, an HTTP 502, an
OPENread, then an empty recorded merge commit after exact native process-lock recovery. This PR leaves that completed fix and main history unchanged.Why This Change Was Made
Process ownership and remote completion are different facts. The native merge owner now records an exact repository/PR/head dispatch intent in a private Git ref before submission, verifies completion through direct PR/main observations and method-appropriate Git evidence, and retains a merge receipt before audits, comments, or cleanup. Normal squash/merge reconstruct the actual landed-parent tree; rebase/queue verify the aggregate reviewed delta from the unique retained source fork base against the historical landed tree. Git objects are structurally retained, not merely named in a text sidecar.
Normal, admin, explicit auto-merge, and implicit queue paths share the outcome owner. This removes the old success-only polling, ambiguous auto re-arm/fallback paths, blind comment POST retries, and unconditional remote branch deletion. Existing review, prepared-head, required-CI, draft, attribution, and bounded admin checks remain. A clean PR requested with
--auto-mergestill selects immediate pinned squash before any dispatch.The tooling state lives under
refs/openclaw/pr-merge-outcomes/<PR>, independently of the process lock and disposable worktree. No OpenClaw runtime database, schema, dependency, or configuration surface changes. The completed declaration/resource-policy/nested-timeout and WhatsApp lanes are not part of this diff.User Impact
Maintainers can repeat
merge-runto reconcile an uncertain attempt without issuing a second merge. AnOPENread, elapsed time, process death, changed head, partial application, or later revert cannot silently make it retryable. A no-net-change squash is refused without claiming that the PR completed; a confirmed historical empty squash is reported as an anomaly without rewriting history.Confirmed merge state survives a failed comment/audit/cleanup and missing prepare artifacts. Comment response loss never triggers another POST; delayed recovery reports completion work pending rather than deleting a recreated branch. Normal uninterrupted cleanup uses an exact-head Git lease and accepts authoritative branch absence.
This intentionally fails closed: unresolved dispatches require explicit operator reconciliation outside the automatic path, including a crash after intent recording but before the request actually leaves the process. Auto/queue acceptance is reported as pending, not merged. This is a common-Git-directory fence, not fleet-wide exactly-once execution; stable rereads do not add a GitHub expected-base precondition. Git leases cannot distinguish same-SHA branch recreation.
Evidence
Regression and focused checks
The checked-in applied-502 regression was executed against a disposable copy of the original merge owner: it failed because two mutations occurred after exact lock recovery. The repaired path performs one. Other cases cover crashes at intent/dispatch/receipt, missing worktrees, structural retention through Git GC, corrupt/mismatched records, valid successor CAS, stale ordinary reads versus direct observations, changed head/base, partial/reverted content, queue/auto/admin behavior, lost comments, and advanced/absent remote branches.
The initial complete focused candidate passed 223 tests, with one Linux-only zombie test skipped on macOS. After the CI and review follow-ups below, final full owner/routing proof passed 391 tests: 70 native outcome tests and 321 routing tests:
The two upgrade regressions first failed because the previous candidate issued a new mutation despite an older wrapper's reserved output capture. Both now pass: an existing
.local/merge-output.logwithout a durable outcome record, including an empty file, blocks fresh dispatch without erasing evidence.Final changed-file typechecks, formatting, lint, and policy guards passed. Bash syntax and source-following ShellCheck passed. Fresh isolated Codex autoreview of the final uncommitted candidate returned
scoped-cleanwith no accepted/actionable findings at the configured P0 review threshold. The lead separately reviewed the complete owner flow, dependency contracts, regressions, and upgrade boundary.CI and review follow-up
The first exact-head CI run caught two routing expectations left behind by the test-owner split. The expectations now match the router's semantic owners and actual workflow references; three additional cases protect selection of the native outcome tests.
The ClawSweeper rebase-receipt finding and Rank-up move are addressed. Real Git tests now exercise two source commits editing the same line, rewritten commit identities, unrelated main advancement, explicit and queued rebase, and mismatched receipts stopping before comment/cleanup. They also prove why neither the final rebased parent nor recorded main is a valid substitute for the unique source fork base. Normal merge now validates content as well as ancestry. Missing/multiple fork bases fail closed; no commit-count heuristic or inferred queue merge policy is used.
The second CI run exposed a same-second Git identity collision in the cherry-picked-prefix fixture: identical trees, parents, messages, identities, and timestamps made its supposed independent main commit the source commit itself. A fixed-clock run reproduced the failure. Main advances now carry distinct commit metadata, and the regression asserts the intended source fork before exercising recovery. All 70 outcome tests passed with both Git timestamps fixed to the same second; production receipt validation was unchanged. Independent review of this correction is scoped-clean at P0.
That run also encountered the oversized UI test graph, repaired on main by the native-assets PR including the shard split, and a gateway settled-ownership timeout. The gateway target passed in a complete-file reproduction and the original 26-file order passed all 325 tests on the exact CI main parent. The isolated file did expose a different first-test teardown failure (root-work count 1 rather than 0), which passed in the full shard. Neither gateway failure has an established cause; both are retained as a separate diagnostic follow-up, not claimed fixed here. No limits, waits or assertions were weakened.
Final exact-head CI completed successfully for
ff7d2d69f9b46130142bdd19d29a77e392c9b36f, including the native owner and gateway shards. The latest ClawSweeper review covers this exact head with no actionable finding; its remaining exact-head CI Rank-up move is satisfied.Live read-only recovery
The candidate native wrapper was copied into a disposable Git repository with a synthetic retained intent for the exact historical head. Its GitHub executable allowed only the exact repository and PR/main read queries; every other operation was denied. Two actual
scripts/pr merge-runinvocations both returned 0, confirmed the existing recorded merge, retained the receipt, and warned about the empty squash. They required no original worktree and attempted zero GitHub mutations across eight reads.This is live GitHub observation/recovery proof, not live 502 injection or an auto/queue mutation test. Mutation failures and Git leases are exercised against isolated real Git remotes and injected GitHub responses. Upstream GitHub CLI expected-head/dispatch behavior and Git merge-tree/CAS/lease contracts were inspected directly. Cache or GitHub internal transaction causation is not asserted.
Change size: production/tooling +344/−258 (net +86); tests and test support +961/−967 (net −6); operator guidance +8. The production growth establishes durable remote-outcome ownership and structural receipt retention that the old process lock could not provide, while deleting the old polling and duplicate mutation paths. No new runtime config/env/schema surface. No private task transcripts, credentials, routing identifiers, or proof assets are committed.