Skip to content

ci(main-guard): stop accusing merged PRs of being direct pushes - #759

Merged
thinkclay merged 1 commit into
mainfrom
fix/747-main-guard-race
Sep 15, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/747-main-guard-race

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

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


🤖 Generated with Claude Code

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]>
@thinkclay
thinkclay merged commit 5fa50e7 into main Sep 15, 2026
9 checks passed
@thinkclay
thinkclay deleted the fix/747-main-guard-race branch September 15, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct push to main: ac49dbd0

1 participant