Skip to content

fix(pr): auto-merge refuses PRs whose only failing checks are superseded cancelled runs - #171192

Merged
steipete merged 1 commit into
mainfrom
steipete/automerge-superseded-cancellations
Oct 13, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/automerge-superseded-cancellations

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: scripts/pr merge-run <pr> --auto-merge refuses to land a PR after openclaw/ci-gate passes when the only non-passing checks are cancelled runs that a newer run of the same check already replaced on that head.

User Impact

Maintainers using the default --auto-merge handoff no longer get stuck on MERGEABLE/UNSTABLE PRs whose only red entries are superseded same-lane cancellations, such as a draft opened ClawSweeper Dispatch run after ready_for_review, or Labeler. On 2026-10-13, 8 of 80 recently merged final heads were in this state (for example #170738, #170733, #170675, #170627). Any other UNSTABLE head still refuses, as before.

Why This Change Was Made

GitHub's status rollup and merge state keep counting cancelled runs that a newer run of the same workflow, event and job replaced on the same head. The CI watcher (classifyRollup in scripts/watch-pr-ci.mts) already keeps only the newest run per check and treats this case as green, so admission reuses it instead of adding a second classifier.

For MERGEABLE/UNSTABLE, --auto-merge now picks the immediate squash route only after one fresh scripts/watch-pr-ci.mjs --completion rollup --once pass at the exact prepared head reports GREEN. That pass also requires the head's ci.yml run to have succeeded. An unsuperseded failure, hidden or paginated checks, missing run identity, a pending check, a moved head, or a watcher error all keep refusing. The watcher gains an opt-in --once flag: one observation without waiting, where --timeout only bounds that pass's reads.

This is a one-shot admission check, not part of the pinned admission snapshot. GitHub still enforces required checks when the merge is sent, the merge request is pinned to the exact head, and the final stability re-read still pins the UNSTABLE status. Pinning the rollup would mean extending the Octopool-allowlisted landing snapshot query and the saved merge-outcome format. Accepted edge case: a new non-required failure on the same head in the seconds between the check and the merge is not rechecked. The watcher's existing auto-response exclusion applies unchanged. Both points are documented in docs/reference/scripts/merge-admission.md.

The cross-lane ClawSweeper case (comments and reviews cancelling PR-head runs) is handled separately in #170831.

Evidence

  • New regression cases in test/scripts/pr-merge-hosted.test.ts run the real merge-run --auto-merge and the real watcher against a stubbed gh. Refused: a lone cancellation, a newer run that also failed, and an unfinished ci.yml run, each with no merge sent and no saved outcome. Admitted: a superseded-only head, as one exact-head immediate squash with no auto request. pnpm test test/scripts/pr-merge-hosted.test.ts --maxWorkers=1 -t "native superseded-only UNSTABLE merge handoff": 4 passed, about 50s locally under heavy host load.
  • Full files pass locally: pr-merge-hosted.test.ts 25/25 (135s), pr-merge-admission.test.ts 72/72 (417s, load average around 40), watch-pr-ci.test.ts 264/264 (237s), including the new --once parsing and single-pass cases.
  • Real data: classifyRollup classifies the final heads of fix(ci): keep targeted type checks when docs are deleted #170738, fix(ci): preserve remote proof failures without forced local checks #170733, fix: prevent false failure warnings after reply retries #170675 and fix(gateway): show thinking off when Claude defaults to off #170627 as GREEN. Their only non-passing contexts are superseded dispatch/label pull_request_target cancellations.
  • Format, oxlint, script erasability, tsgo:scripts, tsgo:test:root, ShellCheck, a Bash 3.2 syntax check, and git diff --check all pass. Codex autoreview found no issues on the final diff.

…merge

GitHub's statusCheckRollup and mergeStateStatus keep cancelled runs that a
newer run of the same workflow/event/job name superseded on the same head
(pull_request_target lanes such as ClawSweeper Dispatch draft `opened` runs
after `ready_for_review`, and Labeler). After openclaw/ci-gate passes, those
PRs are MERGEABLE/UNSTABLE and --auto-merge admission refused them.

--auto-merge now selects the immediate squash route for MERGEABLE/UNSTABLE
only after one fresh scripts/watch-pr-ci.mjs --completion rollup --once pass
at the exact prepared head exits GREEN. The watcher's classifyRollup stays
the single supersession owner and the pass also requires the attached ci.yml
run to succeed; any unsuperseded failure, hidden or paginated context, missing
run identity, pending check, moved head, or watcher error keeps refusing.

The watcher gains an opt-in --once flag: one attach and one watch observation
without waiting, with --timeout bounding only that pass's evidence reads.

This is a one-shot admission predicate, not a pinned snapshot fact: required
checks stay server-enforced at dispatch, the exact-head mutation pins the
head, and the final stability reread pins the UNSTABLE projection. Pinning
rollup contexts would extend the Octopool-allowlisted landing snapshot and
the retained-outcome schema. Accepted edge case, documented in
merge-admission.md: a new non-required failure on the same head between the
pass and dispatch is not rechecked.

Measured 2026-10-13: 8 of 80 recently merged final heads (e.g. #170738,
#170733, #170675, #170627) had only superseded same-lane cancellations;
classifyRollup classifies all four examples GREEN.
@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 13, 2026 17:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T17:04:44.688071Z 7aebf07 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S labels Oct 13, 2026
@steipete
steipete merged commit 8aee8ad into main Oct 13, 2026
164 of 166 checks passed
@steipete
steipete deleted the steipete/automerge-superseded-cancellations branch October 13, 2026 17:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…merge (openclaw#171192)

GitHub's statusCheckRollup and mergeStateStatus keep cancelled runs that a
newer run of the same workflow/event/job name superseded on the same head
(pull_request_target lanes such as ClawSweeper Dispatch draft `opened` runs
after `ready_for_review`, and Labeler). After openclaw/ci-gate passes, those
PRs are MERGEABLE/UNSTABLE and --auto-merge admission refused them.

--auto-merge now selects the immediate squash route for MERGEABLE/UNSTABLE
only after one fresh scripts/watch-pr-ci.mjs --completion rollup --once pass
at the exact prepared head exits GREEN. The watcher's classifyRollup stays
the single supersession owner and the pass also requires the attached ci.yml
run to succeed; any unsuperseded failure, hidden or paginated context, missing
run identity, pending check, moved head, or watcher error keeps refusing.

The watcher gains an opt-in --once flag: one attach and one watch observation
without waiting, with --timeout bounding only that pass's evidence reads.

This is a one-shot admission predicate, not a pinned snapshot fact: required
checks stay server-enforced at dispatch, the exact-head mutation pins the
head, and the final stability reread pins the UNSTABLE projection. Pinning
rollup contexts would extend the Octopool-allowlisted landing snapshot and
the retained-outcome schema. Accepted edge case, documented in
merge-admission.md: a new non-required failure on the same head between the
pass and dispatch is not rechecked.

Measured 2026-10-13: 8 of 80 recently merged final heads (e.g. openclaw#170738,
openclaw#170733, openclaw#170675, openclaw#170627) had only superseded same-lane cancellations;
classifyRollup classifies all four examples GREEN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant