Skip to content

Allow on.bots Apps to check out same-repository PRs on edited events - #72403

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-checkout-pr-branch-permissions
Oct 27, 2026
Merged

pelikhan merged 6 commits into
mainfrom
copilot/fix-checkout-pr-branch-permissions

Conversation

Copilot AI commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

PR body edits by an on.bots App fail checkout because Apps report collaborator permission none. This blocks body-only re-review unless the workflow pushes an empty commit.

  • Authorization: Allow pull_request and pull_request_target edited events for explicitly allow-listed bots, retaining Bot sender identity and matching runtime/head/base repository-ID checks.
  • Boundaries: Preserve write-or-higher permission requirements for unlisted bots, fork PRs, and unsupported actions.
  • Coverage and documentation: Add regression cases for allowed edits and rejected identities/provenance; document body-edit filtering and update the security contract.

Copilot AI changed the title [WIP] Fix checkout PR branch permissions for edited event Allow on.bots Apps to check out same-repository PRs on edited events Oct 27, 2026
Copilot AI requested a review from pelikhan October 27, 2026 10:57
@pelikhan
pelikhan marked this pull request as ready for review October 27, 2026 11:31
Copilot AI max review requested due to automatic review settings October 27, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_request and pull_request_target edits 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

Comment thread specs/security-architecture-spec.md Outdated
- **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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

Generated from Design Decision Gate 🏗️ · opus55 · ~12 AIC · ⌖ ~38 AIC · ◇ ~4 AIC · ⊞ 1.9K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · haiku45 · ~6 AIC · ⌖ ~11 AIC · ◇ ~3 AIC · ⊞ 8.9K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #72403

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Remove the unused payload.changes test 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]";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ponytail: mockContext.payload.changes is never read by this path or asserted here; delete this unused fixture line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-27T11:59:38Z
review_event: REQUEST_CHANGES
top_themes: [overbroad edited-event trust bypass; body-only contract not enforced]
files_reviewed: [actions/setup/js/checkout_pr_branch.cjs, actions/setup/js/checkout_pr_branch.test.cjs, docs/src/content/docs/reference/checkout.md, specs/security-architecture-spec.md]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread actions/setup/js/checkout_pr_branch.cjs Outdated
(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()))) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cjs trusts allow-listed bots for any edited action, not just body edits. Enforcement relies entirely on an optional workflow-level if: github.event.changes.body filter documented in checkout.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:484 and specs/workflow-security/CommentTriggeredPRCheckout.tla were not updated to reflect the new allow-listed edited path. 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 changes payload 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.md correctly 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

Comment thread actions/setup/js/checkout_pr_branch.cjs Outdated
(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()))) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (specs/security-architecture-spec.md:1016): Update validation mapping, model and README; also update specs/compiler-threat-detection-spec.md:97 and changelog to reflect new edited allow-listed path. - Allow on.bots Apps to check out same-repository PRs on edited events #72403 (comment)
  3. Review (actions/setup/js/checkout_pr_branch.test.cjs:424): Delete unused mockContext.payload.changes fixture line. - Allow on.bots Apps to check out same-repository PRs on edited events #72403 (comment)
  4. Review (actions/setup/js/checkout_pr_branch.cjs:324): Trusts every PR edit, not just body edits. Require changes to contain only body or explicitly document the broader trust. - Allow on.bots Apps to check out same-repository PRs on edited events #72403 (comment)
  5. Review (actions/setup/js/checkout_pr_branch.cjs:324): Condition trusts any edited action from allow-listed bot, not just body edits. Check context.payload.changes?.body to enforce body-only scope. - Allow on.bots Apps to check out same-repository PRs on edited events #72403 (comment)
  6. Review (actions/setup/js/checkout_pr_branch.test.cjs:421): Add test for missing context.payload.changes to document current any-edit trust behavior and force intentional updates if gating is added later. - Allow on.bots Apps to check out same-repository PRs on edited events #72403 (comment)

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

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~14 AIC · ⌖ ~9 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

if (
(context.eventName === "pull_request" || context.eventName === "pull_request_target") &&
typeof context.payload.action === "string" &&
TRUSTED_BOT_PR_ACTIONS.includes(context.payload.action) &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot insn't part of the trusted bot actions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Merged the latest main via make merge-main (merge commit ac81d60). The requested body-only gate, missing/non-body/mixed-edit cases, validation mapping, TLA model/README, compiler-threat mapping, and changelog are already present in 29c0133; the body fixture is used by the positive test. make fmt, make lint, and make agent-report-progress passed (248 impacted JS tests). I couldn't resolve the review threads with the available GitHub tools; their existing Copilot replies are substantive.

Copilot AI requested a review from pelikhan October 27, 2026 16:04
@pelikhan
pelikhan merged commit 67d345e into main Oct 27, 2026
16 checks passed
@github-actions
github-actions Bot deleted the copilot/fix-checkout-pr-branch-permissions branch November 4, 2026 02:03
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

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.

Checkout PR branch refuses an on.bots App's pull_request edited event, so a body-only fix can't be re-reviewed

4 participants