Merge queue: bound subprocess calls and re-check PR state at merge time - #130
Merged
Conversation
…e, so one hung process can't wedge a repo's merges Two defects compounded in the field: a drafted PR passed every gate (drafts report mergeable: MERGEABLE), so the auto-merge loop re-enqueued it endlessly, and with no timeout on git/gh subprocesses one stalled call wedged the SerialQueue for its repo until app restart. - git-client: simple-git inactivity timeout (5 min block) + GIT_TERMINAL_PROMPT=0, so stalled or prompting git calls settle instead of hanging forever - merge: 2-min timeout on gh calls; prStatus now reports isDraft - merge-queue: preMergeGate() re-reads the PR as the job leaves the queue — draft/closed always skip (new "not-mergeable" result); loop-originated jobs also re-verify checks are still green, closing the enqueue-time/merge-time race. Manual merges keep their human-override semantics. - templates: auto-merge-when-green skips drafts and flags its jobs for merge-time verification Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the merge-queue wedge observed in the field (three green PRs stalled in one day, each unblocked only by a direct API merge) and the draft-PR retry loop that set it up.
The two defects
mergeable: MERGEABLE, and nothing in the queue or the auto-merge loop readisDraft— so a drafted PR was enqueued, rejected by GitHub's API, had its badge cleared, and was re-enqueued on the next loop tick, forever, with a base-update push on every pass.git/ghcall stalled on a dead connection or credential prompt never settles, and the SerialQueue (which chains on settle) wedges for that repo until app restart.The fix
GIT_TERMINAL_PROMPT=0.ghcalls;prStatusnow reportsisDraft.preMergeGate()re-reads the PR the moment a job leaves the queue. Draft/closed always skip (newnot-mergeableresult). Loop-originated jobs (verifyChecksGreen) also re-verify checks are still green, closing the race between enqueue-time verdict and merge-time reality (the same invariant Bors/merge-train designs enforce). Manual button/shim merges keep their human-override semantics — red checks don't block an explicit human "merge".Verification
preMergeGatecases (draft, closed, merged, red/pending checks, transientUNKNOWNmergeability).git fetchto a blackhole IP through the exactgitForconfig was killed at 2.1s (block timeout reached), settling its promise — which is what advances the SerialQueue.Note: a currently-running app instance keeps its wedged in-memory queue; this protects after restart on the new build.
🤖 Generated with Claude Code