gha-pr-merge-ref-shows-upstream-changeslisted
Install: claude install-skill wan-huiyan/agent-traffic-control
# GHA `pull_request` Event Uses Merge-Ref, Not Head-Ref
## Problem
You push a commit to a PR branch at T0. CI starts running at T0+10s. A
sibling PR merges to main at T0+5s. Your CI run **sees the sibling's
changes mixed into your branch** and fails on something neither side
introduced alone.
Most confusingly: locally on the exact same commit SHA, every check
passes. `gh run view <N> --json headSha` reports your SHA correctly.
`git show <SHA>:<file>` shows your file is clean. But CI failed on that
SHA citing duplicates / conflicts / violations that aren't there.
## Context / Trigger Conditions
- CI failure on a `pull_request` event (NOT `push`)
- Failure cites a violation in a file you didn't touch in your last push
- The same SHA passes the same check locally
- `gh run view <N> --json headSha` matches your local HEAD
- `git fetch origin main && git rev-list --left-right --count origin/main...HEAD`
shows main is ahead by 1+ commits since your push
- The failure message references identifiers / strings present in main
but not in your branch (e.g. "duplicate ID `X`" where `X` was added
to main by a PR that merged seconds before your CI ran)
- You're in a dense parallel-PR window (multiple PRs merging within
minutes — release day, mass-merge sweep, several agents shipping
concurrently)
## Root cause
GitHub Actions, when triggered by `pull_request: [opened, synchronize,
reopened, ...]`, checks out a SYNTHETIC ref called `refs/pull/<N>/merge`.
This ref is the **3-