Repository navigation
Gate standard merge on the newest pull_request Check run - #3
Merged
Merged
Conversation
mapringg
force-pushed
the
gate-merge-on-newest-pr-check
branch
from
November 16, 2026 20:54
44c82c1 to
047e5cd
Compare
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
standard mergerefused when anyCheckrun on the head commit was not green. GitHub keeps every run per commit. So one run cancelled bycancel-in-progress, or one skipped on a draft orclosedevent, blocked the merge forever. Two adopting repos had to drop cancellation or add a side workflow because of this.The gate now counts only
Checkruns frompull_requestworkflow runs on the exact head commit, and the newest run decides:pull_requestrun of the workflow that holdsCheckwhose latest attempt started last (run_started_at, then the higher run id). A re-run moves that time forward. A run that waits in a concurrency group has that time before itsCheckrun exists. So an older success cannot stand in for a newer run.retry:. When both reads show the same completed attempt, that attempt ended before the check runs were read, so theCheckthat GitHub lists for its check suite belongs to that attempt or was carried into it.pull_requestworkflow run on the head commit is unfinished in either workflow read, the gate refuses withwait:. This covers a workflow whoseCheckrun does not exist yet, which the gate cannot otherwise tell apart from a workflow withoutCheck. It also covers a re-run that carries a greenCheckfrom an earlier attempt. So a merge waits for everypull_requestworkflow on the head, not only the one that holdsCheck. After that,successmerges, and any other conclusion refuses and names it. Older cancelled or skipped runs do not block.pushorpull_request_targetrun on the same commit no longer counts.Checkrun must start after the lastready_for_reviewevent. The gate reads the start time of theCheckrun itself, because a re-run of failed jobs copies that time from the earlier attempt.gh apiread projects only the fields the gate uses with--jq, and the output buffer is 256 MiB.The README now says that
pr-sizeneeds bothissues: writeandpull-requests: write. It also gives the recommended CItypesandconcurrencywithcancel-in-progress: true. The release is 0.5.3, on top of the 0.5.2 hook fix.Evidence
The old and new
mergeDecisionran on live runs from public repos. The new side read them through the same--jqfilters that the source uses. Each repo's aggregate job was read asCheck. This repo has no CI runs of its own to replay.Check ... concluded cancelledCheck ... concluded skippedready_for_reviewrun greenCheck ... concluded skipped... the newest on 4b6fe8b, concluded failure.ready_for_reviewat 05:42:31... started at 2026-11-11T05:41:31Z, before the pull request left draft at 2026-11-11T05:42:31Z.pull_requestrun cancelled,pushrun on the same commit... the newest on 5926a2a, concluded cancelled.Two independent verifier rounds ran adversarial cases through the CLI against a fake
gh. Its fake pipes each page through realjqwith the--jqfilter that the source passes.Before: at 44c82c1,
32 cases, 4 mismatches. A rerun that started between the reads merged. A re-run that was queued or in progress and carried a greenCheckmerged. 106 workflow runs at about 12 KB each failed withspawnSync gh ENOBUFS. At 047e5cd,10 fresh cases, 1 mismatches. A newer queued run of a second workflow that holdsCheckwas ignored, so an older greenCheckmerged.After: at this head,
32 cases, 0 mismatchesand10 fresh cases, 0 mismatches. All 42 cases are also intest/merge.test.mjs.node --testgives 193 pass and 0 fail, andtsc --checkJs --strictis clean. On nodejs/node 6c7c893, the workflow run response is 276,922 bytes in full and 5,708 bytes projected for 23 runs.Merge Danger
Door: two-way
Blast Radius: merges.
standard mergenow makes fourgh apireads afterpr view. With a fine-grained token, the workflow runs read needsactions: read. Everypull_requestworkflow run on the head must finish before a merge, including jobs afterCheckand workflows withoutCheck. A greenCheckwith a later failing job in the same run still merges, as before. A repo whose CI does not run onready_for_reviewhas to runCheckagain after a draft becomes ready, and the refusal message says so.