Repository navigation
fix(merge-gate): merge stacked PRs through merge-async - #17
Merged
Merged
Conversation
GitHub refuses `gh pr merge` for a PR in a native stack. When gh reports
that, merge-gate PUTs pulls/{n}/merge-async with the head SHA it already
verified, polls the job for up to ~60s, and still takes the verdict from
the PR read-back.
A 4xx on the request (head moved) or a failed job is merge-failed. A 5xx,
a garbled body, a poll error, an unknown status, a timeout, or a job that
reports merged before the PR does is merge-unverified (exit 1), because
GitHub may still merge it. opening-a-pr step 4 now says to wait on
gh pr view before rerunning --merge. Non-stacked merges keep the gh pr
merge path. The only text change there: the read-back-failed detail now
carries gh's stderr.
Tested: bun run test (187 pass), bun run typecheck, bun scripts/check-port.ts,
bun test ./scripts/check-port.test.ts. Fake-gh CLI cases cover the merge-async
paths above plus the merge-commit method for mergeCommitBranches heads.
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.
Why
GitHub refuses
gh pr mergefor a PR in a native stack (gh-stack), somerge-gate --mergecould not land any stack layer. The REST merge endpoint refuses too. Onlymerge-asyncworks, as seen live on nagringa-dev/hubdeia #1 and #2.What changed
GhGateGitHub.mergefalls back toPUT pulls/{n}/merge-asyncwhen gh reports the stack error. It sends the head SHA the gate already pinned, polls the job, and still decides from the PR read-back.merge-failed. A job that may still land (5xx, poll error, unknown status, timeout, or "merged" before the PR shows it) ismerge-unverified.opening-a-prstep 4 now says to wait ongh pr viewbefore rerunning--mergeaftermerge-unverified.Scope
base-not-trunkrefuses the rest).Tradeoffs
gh pr mergepath stays the default. If GitHub rewords the error, the gate fails safe withmerge-failed.Blast Radius
Every agent merge runs through this. Verdict shape and exit codes are unchanged. The non-stacked path changes one detail string: the read-back-failed case now includes gh's stderr. This touches
skills/poteto-mode/scripts/merge-gate/**, which the merge policy marks human-only, so it needs the owner's approval.Verification
bun run test: 187 pass. New fake-gh CLI rows cover async success, multi-poll, merge-commit method, failed job, 409 head rejection, 502 request, poll error, unknown status, missing uuid, and a failed read-back.bun run typecheckandbun scripts/check-port.tsare clean.