Repository navigation
fix(merge-queue): merge the winner directly when auto-merge doesn't fire - #10786
Conversation
PR Summary by QodoMerge queue winners directly when GitHub auto-merge stalls
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Stalled winners can miss the merge fallback
|
| if (winner && winner === stickyWinner) { | ||
| const gateAgeMs = Date.now() - new Date(getGateStatus(winner.pullRequest).createdAt).getTime(); | ||
| if (gateAgeMs > AUTO_MERGE_GRACE_MS) await mergeStuckWinner(winner.pullRequest); |
There was a problem hiding this comment.
1. Stalled winners can miss the merge fallback 🐞 Bug ≡ Correctness
main calls mergeStuckWinner only for a sticky winner, but it demotes that winner once its gate is 15 minutes old before reaching the new fallback check. If no reconcile runs between minutes 2 and 15, the next run revokes the turn without attempting the merge; the workflow documents 20–40-minute schedule gaps and the gate status does not trigger another run.
Agent Prompt
## Issue description
A stalled winner is demoted before the fallback runs if the next reconcile occurs more than 15 minutes after its gate succeeded. Documented schedule delays can skip the entire 2–15-minute fallback window.
## Fix Focus Areas
- .github/scripts/merge-queue.js[726-758]
## Recommended Fix
For an open winner with a successful gate and a settled master, attempt the SHA-pinned fallback before applying the 15-minute demotion, even when the first subsequent reconcile is late. Preserve the existing demotion behavior if the merge is refused.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
GitHub's auto-merge doesn't reliably wake up from the
merge-queue/turnsuccess status (posted withGITHUB_TOKEN), so a PR whose turn comes long after its last CircleCI status can sit "merging now" until the 15m timeout revokes it.Now, once a turn is older than 2m and the PR is still open, the reconcile squash-merges it itself — pinned to the granted head sha, using the PR's auto-merge commit message. Failures are logged; the 15m revoke still applies.
Requires a new repo secret
MERGE_QUEUE_MERGE_TOKEN: a bit-core member's fine-grained token (contents + pull-requests write), since master's push restriction excludesGITHUB_TOKEN. Without it, the fallback logs the refusal and behavior is unchanged.