Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions .github/workflows/grumpy-reviewer.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 20 additions & 18 deletions .github/workflows/grumpy-reviewer.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
---
description: >
Grumpy senior code reviewer that automatically reviews the changed lines of
every pull request (including community/fork PRs) and leaves grumpy-but-
constructive inline review comments. Tone and reviewing standards are
delegated to the imported grumpy-reviewer agent.
every same-repository pull request and leaves grumpy-but-constructive inline
review comments. Tone and reviewing standards are delegated to the imported
grumpy-reviewer agent.
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
# Allow any contributor's pull request — including those from forks — to be
# reviewed. `pull_request_target` runs in the base-repository context, so the
# Copilot engine credentials are available even for fork PRs (a plain
# `pull_request` trigger would not expose them). The default role gate
# ([admin, maintainer, write]) would otherwise skip external contributors, so
# `all` is required to actually review community PRs. This is safe because the
# agent runs read-only via the safe-outputs pattern: it can only emit
# structured review comments that separate, permission-scoped jobs apply, so
# untrusted PR content can never gain write access to the repository.
roles: all
# Only run on the upstream repository. Forks don't have the Copilot engine
# credentials configured, so runs on forks would otherwise fail loudly and spam
# fork maintainers. This condition short-circuits every job cleanly (workflow
# shows as skipped, no error) on any repo other than ohcnetwork/care_fe.
if: ${{ github.repository == 'ohcnetwork/care_fe' }}
# Only run on the upstream repository, and only for pull requests whose branch
# lives in that same repository (i.e. NOT from a fork). Two reasons:
# 1. Forks don't have the Copilot engine credentials configured, so runs on a
# fork repo would fail loudly and spam fork maintainers.
# 2. Fork PRs carry untrusted content: the GitHub MCP server's integrity
# policy refuses to hand a fork PR's diff to the agent ("lower integrity
# than agent requires"), so the review can't be produced anyway. Skipping
# such PRs here — rather than starting the engine and letting it fail — is a
# clean no-op (the workflow shows as skipped, no billed run, no error
# issue) instead of a spurious "missing data" failure.
# `pull_request_target` runs in the base-repository context, so a same-repo PR's
# author already has write access; the default role gate ([admin, maintainer,
# write]) covers them without needing `roles: all`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is the roles revert safe for bot-authored same-repo PRs?

The comment asserts a same-repo PR author "already has write access", but that is only reliably true for humans. Same-repo branches are also pushed by app/bot actors — the Copilot coding agent (which authored this very PR, head copilot/feat14322home-page-redesign) and Renovate. The recompiled lock adds a pre_activation job that gates on check_membership.cjs with admin,maintainer,write, and a GitHub App bot actor does not generally resolve to a repository collaborator permission level.

If that check resolves false, the reviewer silently skips exactly the PRs that most benefit from review — and the skip is invisible (no failure, no comment), which is the same failure mode this PR is fixing, just quieter.

The fork gate alone fixes #16669; dropping roles: all is a separate change riding along. Worth either keeping roles: all (the fork gate now makes it harmless, since untrusted heads never activate) or confirming a bot-authored same-repo PR still passes check_membership before merging.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dropping roles: all swaps one silent failure mode for another: the membership gate now runs against github.actor, and PRs opened by bots/apps (this very PR was authored by the Copilot app) are not guaranteed to resolve to admin/maintainer/write. When that check says no, the run is silently skipped with zero output — which is exactly the kind of thing someone will spend an afternoon debugging six months from now. Worth confirming the bot actors you care about actually pass check_membership.

if: >
${{ github.repository == 'ohcnetwork/care_fe' &&
(github.event.pull_request == null ||
github.event.pull_request.head.repo.full_name == github.repository) }}
# The Copilot engine authenticates inference with the COPILOT_GITHUB_TOKEN repo
# secret — a fine-grained PAT whose owner has a Copilot license and only the
# "Copilot Requests: Read" account permission (no repo scopes). Reading the PR
Expand Down
Loading