๐Ÿ› fix: PR identity credits each commit to the push that brought it

Merged
AL
1mo ago
+213-59

The P-06 sandbox proof found a bypass in the PR identity check.

  • What happened: in sandbox PR #8, an agent commit pushed with the owner's login correctly failed on opened. Then Cubic edited the PR description. The edited run had no new commits to check, so it passed and replaced the failing status. Any later edit or reopen could clear a failed identity check.
  • The fix: the check now reads GitHub's record of the pushes to the PR's branch (GET /repos/{repo}/activity?ref=...), oldest first. Each push is credited with the PR commits it first brought (compare from its before, or from the base for branch creations and force pushes). Every commit that claims the agent must have been pushed by the agent, on every run, whatever started it.
  • Commits not recorded yet: GitHub may record a push a moment after the run starts. Such commits are credited to whoever opened or pushed, for those events. When neither applies, the check fails closed.
  • Checked against the real sandbox PRs: run as if a bot had edited them, PR #8 fails with "AlokBansal8 pushed b77b7d9, which claims AthyaBot" and AthyaBot's own PR #3 passes.

pnpm check: 327 tests pass.

๐Ÿค– Generated with Claude Code


Summary by cubic

Fixes the PR identity check bypass where a later run, such as an edit or reopen, could clear a failed status: previously only the commits brought by the current event were checked, so a run with no new commits passed and replaced the failure. The check now reads GitHub's record of the pushes to the branch and credits each commit to the push that first brought it, so agent commits pushed with another account's login fail on every run whatever started it.

  • Pushes page by their Link header's cursor, and each push's compare is read across every page, so no commit is left uncredited.
  • Pull requests with no commits claiming the agent skip the push record entirely.
  • Commits GitHub has not recorded yet are credited to whoever opened or pushed, and the check fails closed when no record says who pushed.