Repository navigation
ci(main-guard): stop accusing merged PRs of being direct pushes - #759
Merged
Merged
Conversation
The guard asked `commits/{sha}/pulls` whether a commit belongs to a merged
PR and treated an empty list as proof of a direct push. That index is
eventually consistent and this workflow starts seconds after the merge, so
an empty list also means "not indexed yet".
#747 is what that looks like. PR #746 merged at 16:42:57Z; the guard ran at
16:43:00Z, three seconds later, read `[]`, and filed an issue against its own
squash commit. The same endpoint returns `#746` today. A backstop that can
accuse a properly-merged PR is a backstop people learn to ignore, which costs
more than the direct push it exists to catch.
Two checks now, ordered so the ordinary path stays instant:
1. `pulls/{n}.merge_commit_sha` — written as part of the merge, never stale.
Requiring it to equal this SHA is what makes reading the trailing `(#n)`
safe: a direct push can end its subject with any number, but only the real
merge commit of PR n matches.
2. The commit index as before, but polled (0/5/10/20/30s) instead of believed
on the first read. It still covers merges whose message carries no PR
number, and the waiting is only spent on commits that already failed (1).
Probed against real SHAs rather than trusting a green run:
real squash of #746 PASS (via referenced PR)
real squash of #721 PASS (via referenced PR)
spoofed (#746), fake sha FAIL -> would file an issue
real merge, no (#n) PASS (via commit index)
real commit, no (#n) PASS (via commit index)
The third is the one that matters: the `merge_commit_sha` equality is what
keeps check 1 from being a free pass for anyone who appends `(#746)`.
Closes #747
Co-Authored-By: Claude Opus 5 <[email protected]>
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.
The guard asked
commits/{sha}/pullswhether a commit belongs to a mergedPR and treated an empty list as proof of a direct push. That index is
eventually consistent and this workflow starts seconds after the merge, so
an empty list also means "not indexed yet".
#747 is what that looks like. PR #746 merged at 16:42:57Z; the guard ran at
16:43:00Z, three seconds later, read
[], and filed an issue against its ownsquash commit. The same endpoint returns
#746today. A backstop that canaccuse a properly-merged PR is a backstop people learn to ignore, which costs
more than the direct push it exists to catch.
Two checks now, ordered so the ordinary path stays instant:
pulls/{n}.merge_commit_sha— written as part of the merge, never stale.Requiring it to equal this SHA is what makes reading the trailing
(#n)safe: a direct push can end its subject with any number, but only the real
merge commit of PR n matches.
on the first read. It still covers merges whose message carries no PR
number, and the waiting is only spent on commits that already failed (1).
Probed against real SHAs rather than trusting a green run:
real squash of #746 PASS (via referenced PR)
real squash of #721 PASS (via referenced PR)
spoofed (#746), fake sha FAIL -> would file an issue
real merge, no (#n) PASS (via commit index)
real commit, no (#n) PASS (via commit index)
The third is the one that matters: the
merge_commit_shaequality is whatkeeps check 1 from being a free pass for anyone who appends
(#746).Closes #747
🤖 Generated with Claude Code