Repository navigation
Allow on.bots Apps to check out same-repository PRs on edited events - #72403
Conversation
Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The new allow-listed edit checkout path is still marked unsupported in validation evidence and omitted from the formal model, leaving the policy inconsistent with its supporting artifacts.
1 open issue
What changed in this PR
Enables body-only re-review loops by allowing Apps listed in on.bots to check out same-repository PRs on edited events, addressing #72320 without requiring an empty commit.
Changes:
- Extends checkout authorization for
pull_requestandpull_request_targetedits while retaining identity, repository, and permission safeguards. - Adds regression tests for allowed edits and rejected allowlist, identity, and provenance cases.
- Documents body-edit filtering and updates the checkout security contract.
| File | Description |
|---|---|
specs/security-architecture-spec.md |
Defines the allow-listed bot exception for edited PR events. |
docs/src/content/docs/reference/checkout.md |
Explains body-only checkout and edit filtering. |
actions/setup/js/checkout_pr_branch.test.cjs |
Tests allowed edits and permission-check fallbacks. |
actions/setup/js/checkout_pr_branch.cjs |
Adds the allowlist-gated edited authorization path. |
Review effort: Max
| - **Permission floor** (all PR checkout paths except the two same-repository bot cases below): the actor MUST hold write-or-higher repository permission. For centralized command or label dispatches where the runtime actor is `github-actions[bot]`, the platform-set `sender.type` MUST be `Bot`, a command/label marker MUST be present, and the originating `aw_context.actor` MUST be a different identity with write-or-higher permission. Missing or inconsistent identity metadata MUST fail closed before permission lookup. | ||
| - **Same-repository bot PR events**: `pull_request` or `pull_request_target` `opened`, `synchronize`, `ready_for_review`, or `reopened` events MAY bypass the collaborator-permission lookup only when `sender.type == "Bot"`, `sender.login` matches the triggering actor, and the positive runtime repository ID, PR head repository ID, and PR base repository ID are equal. `ready_for_review` and `reopened` are lifecycle events, not evidence of a branch push; they are trusted only as explicitly allowed event actions under the same Bot identity and same-repository provenance checks. Missing or inconsistent identity or repository metadata, forked PRs, and all other event actions, including `labeled`, MUST NOT use this exception and MUST satisfy the permission floor. | ||
| - **Permission floor** (all PR checkout paths except the same-repository bot cases below): the actor MUST hold write-or-higher repository permission. For centralized command or label dispatches where the runtime actor is `github-actions[bot]`, the platform-set `sender.type` MUST be `Bot`, a command/label marker MUST be present, and the originating `aw_context.actor` MUST be a different identity with write-or-higher permission. Missing or inconsistent identity metadata MUST fail closed before permission lookup. | ||
| - **Same-repository bot PR events**: `pull_request` or `pull_request_target` `opened`, `synchronize`, `ready_for_review`, or `reopened` events MAY bypass the collaborator-permission lookup only when `sender.type == "Bot"`, `sender.login` matches the triggering actor, and the positive runtime repository ID, PR head repository ID, and PR base repository ID are equal. `edited` events MAY also use this exception under the same identity and repository checks, but only when the actor is explicitly listed in `on.bots` (the App slug and its `[bot]` form are equivalent). `ready_for_review` and `reopened` are lifecycle events, not evidence of a branch push; they are trusted only as explicitly allowed event actions under the same Bot identity and same-repository provenance checks. Missing or inconsistent identity or repository metadata, forked PRs, unlisted actors on `edited` events, and all other event actions, including `labeled`, MUST NOT use this exception and MUST satisfy the permission floor. |
There was a problem hiding this comment.
Updated RS-05a validation, the TLA model/README, compiler-threat-detection mapping, and changelogs for the allow-listed body-only edited path. The v1.1.6 formal revalidation remains explicitly pending because Z3 and the pinned TLC tools are unavailable here. Commit 29c0133.
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
What this change does: It lets explicitly allow-listed bots check out same-repository PRs on edited events. It adds regression coverage and documents the boundary.
Nice to have:
- Remove the unused
payload.changestest fixture. It does not affect this path or any assertion.
Verdict: Ship.
Lean: -1 lines possible.
Generated by ✂️ Ponytail Reviewer for #72403 · codex · gpt56 · ~12 AIC · ⌖ ~6 AIC · ⊞ 14.8K
Comment /ponytail to run again
| describe.each(["pull_request", "pull_request_target"])("allow-listed bot edited events on %s", eventName => { | ||
| beforeEach(() => { | ||
| mockContext.eventName = eventName; | ||
| mockContext.actor = "automation[bot]"; |
There was a problem hiding this comment.
Ponytail: mockContext.payload.changes is never read by this path or asserted here; delete this unused fixture line.
There was a problem hiding this comment.
The changes fixture is now read by the body-only authorization gate and is needed for the positive case, so I retained it and added negative cases for missing and non-body/mixed change payloads. Commit 29c0133.
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Changes requested
The allow-listed bot exception is broader than the documented body-only use case: every pull_request edited action bypasses the collaborator permission floor because the trust gate does not validate payload.changes. Restrict this path to body-only edits, or revise the contract and tests to explicitly support all edit types.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| (context.eventName === "pull_request" || context.eventName === "pull_request_target") && | ||
| typeof context.payload.action === "string" && | ||
| TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) && | ||
| (TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) || (context.payload.action === "edited" && isAllowedBot(actor, parseAllowedBots()))) && |
There was a problem hiding this comment.
The new allow-listed edited bypass trusts every PR edit, not just body edits, so title/base-branch changes from the bot skip the collaborator permission floor and can launch privileged checkout flows unexpectedly. The documentation frames this as a body-only loop, but context.payload.changes is never checked. Require changes to contain only body (or explicitly document and test the broader trust) and add negative cases for title/base edits.
💡 Why this matters
A workflow subscribing to pull_request edited can be triggered by non-body edits; those events currently receive the same checkout exception as a body edit. This makes the authorization boundary depend on every caller remembering an external if: filter rather than enforcing the stated body-only condition at the trust gate.
There was a problem hiding this comment.
The exception now requires an allow-listed sender and a non-null object-valued changes.body with no other changed fields; title/base and mixed edits retain the permission check. Commit 29c0133.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd — requesting changes on a trust-boundary scope gap and two documentation/spec follow-ups.
📋 Key Themes & Highlights
Key Themes
- Scope gap between intent and implementation: The PR is framed as enabling "body-only review loops," but
checkout_pr_branch.cjstrusts allow-listed bots for anyeditedaction, not just body edits. Enforcement relies entirely on an optional workflow-levelif: github.event.changes.bodyfilter documented incheckout.md, which is easy for workflow authors to omit. Worth deciding explicitly whether the validator itself should narrow the trust to body-only edits, or whether the docs/PR description should be updated to describe the actual (broader) trust boundary. - Unresolved prior feedback: A previous reviewer flagged that
specs/security-architecture-spec-validation.md:484andspecs/workflow-security/CommentTriggeredPRCheckout.tlawere not updated to reflect the new allow-listededitedpath. That feedback appears not yet addressed in this diff. - Test coverage is strong for the explicit negative cases (fork PRs, unlisted bots, mismatched repo IDs, wrong sender type) — one additional case around
changespayload shape would make the current trust boundary explicit and regression-proof.
Positive Highlights
- ✅ Comprehensive 12-scenario negative test matrix preserving the existing permission floor for unlisted bots and fork PRs
- ✅ Security spec (
security-architecture-spec.md) prose update is clear and consistent with the code change - ✅ Docs addition in
checkout.mdcorrectly surfaces the body-edit filtering recommendation to workflow authors
See inline comments for specifics. Investigation was bounded to the pre-fetched diff and directly referenced files (check_permissions_utils.cjs, trigger_parser.go, validation spec, TLA spec) — no deep cross-cutting trace was needed given the diff's small, well-contained size.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~87 AIC · ⌖ ~19 AIC · ⊞ 10.2K
Comment /matt to run again
| (context.eventName === "pull_request" || context.eventName === "pull_request_target") && | ||
| typeof context.payload.action === "string" && | ||
| TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) && | ||
| (TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) || (context.payload.action === "edited" && isAllowedBot(actor, parseAllowedBots()))) && |
There was a problem hiding this comment.
[/diagnosing-bugs] This condition trusts any edited action from an allow-listed bot, not just body edits. The PR description and docs frame this as a "body-only review loop" fix, but edited also fires for title changes, base-branch changes, etc. — none of which are checked here against context.payload.changes.
💡 Root-cause framing
The actual bug is "Apps report permission none on body-only edits"; the fix as written is broader: "Apps bypass permission checks on any edit." If the intent really is body-only, the validator itself should check context.payload.changes?.body !== undefined rather than relying solely on workflow authors adding an if: filter (which is optional and easy to omit/forget).
If the broader edited surface is intentional (any edit from a trusted, allow-listed, same-repo Bot sender is fine), consider updating the PR description/docs to say so explicitly, since right now the code's actual trust boundary is wider than what's documented as the design goal.
@copilot please address this.
There was a problem hiding this comment.
The checkout gate now checks that changes contains only a valid body field before allowing an allow-listed bot edit; other edit types retain the collaborator permission floor. Commit 29c0133.
| expect(mockExec.getExecOutput).not.toHaveBeenCalledWith("git", expect.arrayContaining(["fetch"]), expect.anything()); | ||
| }); | ||
|
|
||
| describe.each(["pull_request", "pull_request_target"])("allow-listed bot edited events on %s", eventName => { |
There was a problem hiding this comment.
[/tdd] Good coverage of the positive case and 12 negative branches — this is solid regression protection for the new exception. One gap: there's no test asserting behavior when context.payload.changes is missing entirely (e.g., an edited action fired without a changes payload, which can happen for non-body metadata edits). Since the code doesn't inspect changes at all, this would currently pass through as trusted, which is exactly the scope-widening risk flagged on the .cjs change.
💡 Suggested test
it("should check out even when changes.body is absent (documents current any-edit trust)", async () => {
delete mockContext.payload.changes;
await runScript();
expect(mockCore.setOutput).toHaveBeenCalledWith("checkout_pr_success", "true");
});Adding this test documents the current (broad) behavior explicitly, so if changes.body gating is added later, the test will force an intentional update rather than silently passing.
@copilot please address this.
There was a problem hiding this comment.
Missing context.payload.changes is now covered as a negative case: checkout falls back to the collaborator permission check rather than trusting the edit. Commit 29c0133.
|
@copilot address the following outstanding work in one pass:
Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI. Sous-chef state: 70f0a4817b304801d64bcd72184cc6bade9832e90ed987e82dfb0e09982486a2
|
…pr-branch-permissions Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
| if ( | ||
| (context.eventName === "pull_request" || context.eventName === "pull_request_target") && | ||
| typeof context.payload.action === "string" && | ||
| TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) && |
There was a problem hiding this comment.
@copilot insn't part of the trusted bot actions?
There was a problem hiding this comment.
Yes—Copilot can be trusted as a bot when the workflow lists its actor in on.bots. The edited-event checkout exception is not granted automatically: it still requires a body-only changes payload, Bot sender identity matching the actor, and matching same-repository IDs. Other edit types retain the collaborator permission check.
…pr-branch-permissions Co-authored-by: pelikhan <[email protected]>
Merged the latest |
|
🎉 This pull request is included in a new release. Release: |

PR body edits by an
on.botsApp fail checkout because Apps report collaborator permissionnone. This blocks body-only re-review unless the workflow pushes an empty commit.pull_requestandpull_request_targeteditedevents for explicitly allow-listed bots, retaining Bot sender identity and matching runtime/head/base repository-ID checks.editedevent, so a body-only fix can't be re-reviewed #72320