You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(source-control): gh pr merge arms auto-merge instead of queueing when merge state is UNKNOWN #6953
On a branch protected by a merge queue, gh pr merge run while GitHub still reports mergeStateStatus: UNKNOWN (just after a push or a ready flip) enables auto-merge instead of adding the PR to the merge queue. Nothing lands until the state settles and auto-merge fires, and a caller that assumes "queued" reports the wrong thing.
Observed
While landing the Claude Code v2.1.265..v2.1.296 changelog PRs, several merges turned into armed auto-merge; landing workers had to disarm and requeue them.
Expected
The PR-landing steps (/source-control:pull-request landing and any merge helper) wait until mergeStateStatus is known before calling gh pr merge, and then confirm the result (queued vs auto-merge armed) instead of assuming it.
Thanks for the report. Understood: gh pr merge called while mergeStateStatus is still UNKNOWN (right after a push or a ready flip) arms auto-merge instead of adding the PR to the merge queue, and this was observed repeatedly while landing the v2.1.265..v2.1.296 changelog PRs, requiring manual disarm/requeue. The ask is for the merge step to wait until mergeStateStatus settles before calling gh pr merge, and then confirm whether the PR was queued or auto-merge was armed rather than assuming.
This looks related to #6630 (confirming the PR actually entered the merge queue after merge) and the now-closed #5953 (babysit --auto misreporting auto-merge as queued), but addresses a distinct root cause: the race against an unsettled mergeStateStatus rather than post-merge reporting. Worth checking those for overlap when scoping the fix.
The report is otherwise complete — no missing information needed from my side.
Decision recorded. The owner approved going with independently verified recommendations on 2026-10-13. Two researchers worked this issue separately (code and history; upstream docs and owner intent), and a judge reconciled them.
Is a pre-merge settle step needed, or is detection after the merge call enough? → A pre-merge step is needed. gh pr merge on a merge-queue base turns on auto-merge whenever required checks have not yet passed, and UNKNOWN means GitHub cannot yet say whether they have. Before any gh pr merge on a merge-queue base, re-read mergeStateStatus at the pinned head until it is no longer UNKNOWN. Call merge only on CLEAN; otherwise hold and report. Apply this on both the 4.2 path and the 4.2.1 path.
Basis: gh pr merge --help, gh 2.102.0 (2026-09-30), run this session: 'If required checks have not yet passed, auto-merge will be enabled. If required checks have passed, the pull request will be added to the merge queue.'; fix(source-control): gh pr merge arms auto-merge instead of queueing when merge state is UNKNOWN #6953 intake-triage comment 2026-10-11T03:41 (the race against an unsettled mergeStateStatus is a distinct root cause)
Recommendation: Rebase #7075 onto main and add a pre-merge settle step to it: poll mergeStateStatus at the pinned head while it reads UNKNOWN, and merge only on CLEAN. Apply the step on both 4.2 and 4.2.1. Keep the 4.2.2 post-merge confirmation. Then close #6953 as a duplicate of #6630 when #7075 merges.
Where sources disagreed, decided by: Rule 4 (current gh CLI manual: auto-merge is armed whenever required checks have not passed) over rule 5 (the record's 'close now, covered by #6678/#7075').
Admission to an agent lane stays with the work-class rules and owner ratification.
Closing as a duplicate of #6630. #7075 merged and added the pre-merge step: before any merge call on a merge-queue base, it polls mergeStateStatus at the pinned head while it reads UNKNOWN, and merges or enqueues only on CLEAN. That covers this issue's race.
Activity
github-actions commentedon Oct 11, 2026
Thanks for the report. Understood:
gh pr mergecalled whilemergeStateStatusis stillUNKNOWN(right after a push or a ready flip) arms auto-merge instead of adding the PR to the merge queue, and this was observed repeatedly while landing the v2.1.265..v2.1.296 changelog PRs, requiring manual disarm/requeue. The ask is for the merge step to wait untilmergeStateStatussettles before callinggh pr merge, and then confirm whether the PR was queued or auto-merge was armed rather than assuming.This looks related to #6630 (confirming the PR actually entered the merge queue after merge) and the now-closed #5953 (babysit
--automisreporting auto-merge as queued), but addresses a distinct root cause: the race against an unsettledmergeStateStatusrather than post-merge reporting. Worth checking those for overlap when scoping the fix.The report is otherwise complete — no missing information needed from my side.
Automated triage. A maintainer reviews it.
kyle-sexton commentedon Oct 13, 2026
Decision recorded. The owner approved going with independently verified recommendations on 2026-10-13. Two researchers worked this issue separately (code and history; upstream docs and owner intent), and a judge reconciled them.
Basis: origin/main plugins/source-control/skills/pull-request/reference/merge.md:44-64 (4.2, no CLEAN wait) vs :66-104 (4.2.1 CLEAN gate); gh pr view 7075 (OPEN draft, CONFLICTING); gh pr diff 7075 (4.2.2 runs after gh pr merge; armed-auto-merge warning; hold on 'not queued and not CLEAN')
Basis: gh pr merge --help, gh 2.102.0 (2026-09-30), run this session: 'If required checks have not yet passed, auto-merge will be enabled. If required checks have passed, the pull request will be added to the merge queue.'; fix(source-control): gh pr merge arms auto-merge instead of queueing when merge state is UNKNOWN #6953 intake-triage comment 2026-10-11T03:41 (the race against an unsettled mergeStateStatus is a distinct root cause)
Basis: AGENTS.md (a small fix in the same plugin goes into the PR; marking ready is a stop); gh issue view 6630 (OPEN)
Recommendation: Rebase #7075 onto main and add a pre-merge settle step to it: poll mergeStateStatus at the pinned head while it reads UNKNOWN, and merge only on CLEAN. Apply the step on both 4.2 and 4.2.1. Keep the 4.2.2 post-merge confirmation. Then close #6953 as a duplicate of #6630 when #7075 merges.
Where sources disagreed, decided by: Rule 4 (current gh CLI manual: auto-merge is armed whenever required checks have not passed) over rule 5 (the record's 'close now, covered by #6678/#7075').
Admission to an agent lane stays with the work-class rules and owner ratification.
This was generated by AI.
Merge origin/main into fix/6630-merge-confirm-queue-entry
kyle-sexton commentedon Oct 13, 2026
Closing as a duplicate of #6630. #7075 merged and added the pre-merge step: before any merge call on a merge-queue base, it polls mergeStateStatus at the pinned head while it reads UNKNOWN, and merges or enqueues only on CLEAN. That covers this issue's race.