GH-5263: fix(autopilot): merging stage attempts to merge draft PRs and ignores CHANGES_REQUESTED reviews — burns attempts, trips breaker, and only the draft flag prevents merging over a reviewer - #5264
Merged
Conversation
…-requested review The merge path never checked draft status or review state, so a PR drafted by the founder-review-flow (or one carrying an unresolved CHANGES_REQUESTED review) sailed straight into a blind merge attempt every tick — a guaranteed GitHub 405 that burned MergeAttempts and fed the per-PR circuit breaker for what was a deliberate, healthy hold (PR#5258, 2026-08-30). Since this repo has no branch protection, the draft flag was also the only thing stopping an outstanding changes-requested review from being merged over the reviewer's objection. handleMerging now holds (plain return, no attempt, no breaker feed, no alert) on either signal and resumes automatically once the PR is marked ready or the review is superseded/dismissed. (GH-5263)
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
Post-merge review verdict: APPROVE-w-notesVerified adversarially at origin/main; build + autopilot suite green.
Notes (both pre-existing in the reused review logic, filed as follow-up):
|
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.
Summary
Automated PR created by Pilot for task GH-5263.
Closes #5263
Changes
GitHub Issue GH-5263: fix(autopilot): merging stage attempts to merge draft PRs and ignores CHANGES_REQUESTED reviews — burns attempts, trips breaker, and only the draft flag prevents merging over a reviewer
Problem
Live incident 2026-08-30 ~13:47-13:52Z, founder box, PR#5258. The autopilot merging stage attempted to merge a DRAFT PR three times, failed each time with GitHub 405 "Pull Request is still a draft", and tripped the per-PR circuit breaker — producing a failure alert for what is actually a healthy, deliberately-held PR.
Ledger evidence (autopilot_pr_state + daemon.log): stage=merging, "merge attempt 3 failed: ... status 405 ... still a draft"; log sequence per attempt is "verifyCIBeforeMerge: CI passed" → "handleMerging: merge failed" → "autopilot stage failed", then "per-PR circuit breaker open" every tick after.
Context: PR#5258 had green CI, then received a REQUEST-CHANGES review (2026-08-29 17:20Z) which spawned revision issue #5261 and converted the PR to draft. When #5261 began executing (13:47Z), the controller re-processed PR#5258 and went straight to merging.
Two defects
The merge path never checks draft status. verifyCIBeforeMerge passes and handleMerging calls the merge API blind; every attempt is a guaranteed 405 that burns the attempt budget and feeds the breaker. A draft is a deliberate hold — it should park the PR (no attempts, no breaker feed, no failure alert), and resume automatically when the PR is marked ready.
The merge path never checks review state. On this repo (no branch protection) the ONLY thing that stopped a PR with an outstanding REQUEST-CHANGES review from auto-merging was the draft flag that the revision flow happens to set. If a REQUEST-CHANGES review lands without the revision flow drafting the PR (race, manual review without the trigger phrase, revision-spawn failure), the next green tick merges over the reviewer's objection. The merge gate should treat an outstanding changes-requested review as a hold until re-review or dismissal, independent of draft state.
Fix shape
In the merging stage (and ideally as a pre-check in verifyCIBeforeMerge's caller):
Acceptance
Refs