Skip to content

fix(maintainers): prevent duplicate merges after ambiguous responses - #132173

Merged
steipete merged 3 commits into
mainfrom
steipete/nervous-noether-25bde8
Aug 29, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/nervous-noether-25bde8

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

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 OPEN read, 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-merge still 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-run to reconcile an uncertain attempt without issuing a second merge. An OPEN read, 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.

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.ts

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:

node scripts/run-vitest.mjs test/scripts/pr-merge-outcome.test.ts test/scripts/test-projects.test.ts

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.log without a durable outcome record, including an empty file, blocks fresh dispatch without erasing evidence.

node scripts/check-changed.mjs -- scripts/AGENTS.md scripts/pr-lib/merge-outcome.sh test/scripts/pr-merge-outcome.test.ts test/scripts/test-projects.test.ts

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-clean with 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-run invocations 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.

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.
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 22:41
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 8:20 PM ET / August 29, 2026, 00:20 UTC.

ClawSweeper review

What this changes

This 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 provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: ff7d2d69f9b46130142bdd19d29a77e392c9b36f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent owner-boundary design and focused regression coverage; it awaits completion of exact-head CI rather than a code repair.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless supplies an isolated real-Git recovery trace and focused owner-boundary test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless supplies an isolated real-Git recovery trace and focused owner-boundary test evidence.
Evidence reviewed 6 items Intent precedes the remote mutation: The merge owner writes a retained intent before invoking the GitHub merge command, so a failed response leaves evidence that blocks a second submission.
Reconciliation is the sole recovery path: A retained record is checked against direct PR/main observations; an OPEN state without an accepted auto/queue request stops rather than authorizing another dispatch.
Regression coverage exercises the reported ordering: The focused owner-boundary suite includes the applied-502 plus OPEN recovery case, receipt mismatch rejection before comments/cleanup, rebase/queue receipts, and retained-output compatibility cases.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally changes ambiguous-dispatch recovery into a fail-closed operator reconciliation path; maintainers should accept that a crash after intent recording may require manual investigation rather than an automated retry.
  • Complete next step (P2) - No discrete repair is indicated; the remaining action is ordinary exact-head CI completion and maintainer landing review.
Agent review details

Security

None.

PR surface

Tests -9, Docs +8, Other +89. Total +88 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 6 955 964 -9
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 4 350 261 +89
Total 11 1313 1225 +88

Review metrics

Metric Value Why it matters
Production versus test delta tooling +344/-258 (net +86); tests and test support +961/-967 (net -6); guidance +8 The tooling growth establishes a durable receipt lifecycle while removing prior polling, retry, and cleanup paths; the focused test move remains net-negative.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #132138
Summary: This PR explicitly targets the open native merge-replay report and its tests cover the stated ambiguous-response recovery ordering.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept fail-closed reconciliation (recommended)
    Retain the documented operator-reconciliation requirement after an ambiguous request, avoiding the former duplicate remote mutation.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This is a bounded correctness repair for maintainers' native landing workflow, without evidence of a user-runtime outage.
  • merge-risk: 🚨 compatibility: Existing maintainer recovery behavior changes from retrying an uncertain merge request to stopping for explicit reconciliation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless supplies an isolated real-Git recovery trace and focused owner-boundary test evidence.

Evidence

What I checked:

  • Intent precedes the remote mutation: The merge owner writes a retained intent before invoking the GitHub merge command, so a failed response leaves evidence that blocks a second submission. (scripts/pr-lib/merge.sh:479, ff7d2d69f9b4)
  • Reconciliation is the sole recovery path: A retained record is checked against direct PR/main observations; an OPEN state without an accepted auto/queue request stops rather than authorizing another dispatch. (scripts/pr-lib/merge-outcome.sh:124, ff7d2d69f9b4)
  • Regression coverage exercises the reported ordering: The focused owner-boundary suite includes the applied-502 plus OPEN recovery case, receipt mismatch rejection before comments/cleanup, rebase/queue receipts, and retained-output compatibility cases. (test/scripts/pr-merge-outcome.test.ts:519, ff7d2d69f9b4)
  • Current main does not already contain this change: Current main lacks the new outcome owner and differs in both wrapper files; the PR head is not an ancestor of current main. (scripts/pr-lib/merge.sh:353, d53f57c3d250)
  • Git contract checked directly: The installed Git help documents merge-tree's explicit merge-base option, update-ref no-deref CAS form, and force-with-lease deletion guard used by the outcome and cleanup paths.
  • Feature history: The merge wrapper history includes the focused outcome sequence and earlier maintainer-workflow changes; the current head's final fixture correction is dated 2026-08-28T17:11:42-07:00. (scripts/pr-lib/merge.sh:348, ff7d2d69f9b4)

Likely related people:

  • Peter Steinberger: The merge-wrapper history includes earlier work by Peter Steinberger as well as the focused outcome-recovery sequence on this branch. (role: recent merge-workflow contributor; confidence: high; commits: 0e1afb2e8c16, 9b1180d46372, 218cd854029a; files: scripts/pr-lib/merge.sh, scripts/pr-lib/merge-outcome.sh)
  • Vincent Koc: Recent merge-wrapper history includes the Crabbox proof integration that remains called by the changed merge owner. (role: adjacent merge-infrastructure contributor; confidence: medium; commits: d3a5f2333e60; files: scripts/pr-lib/merge.sh)

Rank-up moves

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

  • Wait for the in-progress exact-head checks to complete before the normal maintainer landing decision.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-28T22:49:52.349Z sha 9b1180d :: needs changes before merge. :: [P2] Validate rebase receipts before marking them complete
  • reviewed 2026-08-28T23:42:02.909Z sha 218cd85 :: needs maintainer review before merge. :: none

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.
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@steipete steipete self-assigned this Aug 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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.ts

Initial 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.ts

Receipt/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.ts

Final 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.ts

Final correction gates passed after installing the native worktree's pinned dependencies. Prior full changed gates, Bash syntax, source-following ShellCheck and git diff --check also passed.

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 openclaw/ci-gate, with no independent approval rule. Normal native prepare/merge will be used, without admin bypass. The completed declaration fix and both original main commits remain untouched; no release, runtime schema/configuration, dependency source, declaration resource-policy/nested-timeout or WhatsApp changes.

@steipete
steipete merged commit cb5d89b into main Aug 29, 2026
162 checks passed
@steipete
steipete deleted the steipete/nervous-noether-25bde8 branch August 29, 2026 00:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

[Bug]: Native merge retry can create an empty duplicate squash after HTTP 502

1 participant