[Backport] PS-2073: Validate GitHub pull request merge heads - #4253
Conversation
Backport of #4251. The CLI flag uses the urfave/cli v1 conventions retained on v3. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a00dfe-698c-730e-ae98-26abce2ae925
There was a problem hiding this comment.
This changes merge-ref checkout acceptance and retry behavior, which is above this review's L1 approval ceiling. I found no actionable issues in the v3 translation; it matches the merged v4 change apart from the expected urfave/cli v1 wiring.
Want to dig deeper?
Paste this into your agent to explore the findings from this review's Buildkite build:
Download the buildsworth logs from build 18003, then answer my questions about the findings.
Install the reading-buildsworth-logs skill to run this.
About buildsworth
Model: gpt-5.6-sol with xhigh thinking.
How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.
Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and L2 approval grant):
- L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
- L2 — Standard risk (new UI, additive API fields, refactors). Approved only when repository policy or a verified grant allows it; otherwise comment-only.
- L3 — High risk (auth, migrations, payments, secrets, perf-critical paths). Human review always required.
Description
This is the v3 backport of the already-merged Agent v4 fix in #4251.
It prevents the Agent from accepting a stale GitHub
refs/pull/<PR>/mergeafter the pull request head has been force-pushed. The companion server-side change that supplies the expected head commit has also merged in https://github.com/buildkite/buildkite/pull/30177.No Agent release or version change is included in this PR; releasing the fix remains a separate step.
Context
Changes
The behavior matches the merged v4 implementation. The bootstrap flag uses the urfave/cli v1 conventions retained by Agent v3.
Testing
internal/jobtests pass except the existing macOS setgid-preservation failure inTestUpdateGitMirrorCreatesFromRemoteMirrorAndKeepsCanonicalOrigingo tool gofumpt -extra -w .)Disclosures / Credits
Prepared and validated with Amp as a v3 translation of the merged v4 change.