Skip to content

Add grumpy-reviewer agentic PR-review workflow - #16616

Merged
bodhish merged 3 commits into
developfrom
amjithtitus09-grumpy-reviewer-workflow
Jul 31, 2026
Merged

Add grumpy-reviewer agentic PR-review workflow#16616
bodhish merged 3 commits into
developfrom
amjithtitus09-grumpy-reviewer-workflow

Conversation

@amjithtitus09

@amjithtitus09 amjithtitus09 commented Jul 31, 2026

Copy link
Copy Markdown
Member

What this does

Adds a GitHub Agentic Workflow (gh-aw) that runs a grumpy senior code reviewer on pull requests and leaves grumpy-but-constructive inline review comments on the PR's changed lines. Tone and reviewing standards are delegated to the imported grumpy-reviewer agent (taken verbatim from github/gh-aw).

When it runs

  • Automatically on every PR: opened, reopened, and synchronize (new commits pushed).
  • Manual runs: workflow_dispatch.
  • Guarded with if: ${{ github.repository == 'ohcnetwork/care_fe' }} so it only runs on the upstream repo (like daily-playwright-improver.md).

Community / fork PR support

Uses pull_request_target (matching thank-you-note.md) so the Copilot engine credentials are available even for fork PRs — a plain pull_request trigger from a fork does not expose secrets/the Copilot token. roles: all is set so external contributors' PRs are actually reviewed (the default role gate would otherwise skip non-write contributors).

This is safe because of gh-aw's safe-outputs model: the agent job runs read-only (permissions: read-all) and can only emit structured review comments that separate, permission-scoped jobs apply. The base repo and the PR head are checked out (the imported grumpy-reviewer agent uses read/search local-file tools, so the changed files must be on disk), but the agent never executes untrusted PR code — it only reads files and calls the GitHub MCP + Copilot inference inside gh-aw's network-firewalled sandbox. Because it's a pull_request_target workflow that checks out PR content, the compiler emits an advisory "pwn request" warning; it's accepted here because no untrusted code is run and every write is confined to the isolated safe-output jobs. All repo/PR content is treated as untrusted input in the prompt.

Authentication (PAT)

The Copilot engine authenticates inference with a COPILOT_GITHUB_TOKEN repository Actions secret. This must be a fine-grained PAT with:

  • Account permissions → Copilot Requests: Read (the only permission needed — no repo scopes)
  • an owner account that holds an active Copilot license

Reading the PR diff and posting review comments do not use this PAT — those run on the built-in Actions GITHUB_TOKEN; gh-aw injects the needed write scopes (pull-requests: write) into the separate safe-output jobs while the agent job stays read-only (permissions: read-all).

Alternative (not used here): if the org enables centralized Copilot billing, permissions: copilot-requests: write lets it run on the Actions token with no PAT.

Configuration

  • permissions: read-all
  • imports: [ .github/agents/grumpy-reviewer.agent.md ]
  • tools.github.toolsets: [default]
  • checkout enabled (base ref + PR head) — required so the imported agent can read changed files locally
  • safe-outputs:
    • create-pull-request-review-comment (max 10, focused on changed lines)
    • submit-pull-request-review (max 1, COMMENT event — non-blocking consolidated summary)
    • missing-tool: create-issue: true
  • Default engine (copilot) — engine: omitted, matching the other workflows.

Files

  • .github/agents/grumpy-reviewer.agent.md — reviewer persona (imported verbatim).
  • .github/workflows/grumpy-reviewer.md — the workflow source.
  • .github/workflows/grumpy-reviewer.lock.yml — compiled output (gh aw compile, v0.80.9).
  • .github/aw/actions-lock.json — additive pin for the setup action the new lock references (does not touch existing pins).

Validated via gh aw compile (0 errors; 1 advisory pull_request_target+checkout "pwn request" warning, addressed above). No app build/test run — this is workflow config only.

Testing

Exercised with gh aw trial against a temporary private host repo (simulating github.repository = ohcnetwork/care_fe, triggered with a real PR context). Verified:

  • Compiles and installs with the imported agent resolved; the lock is in sync with the source.
  • Activation gate passes — setup, agentic run-info, daily-usage cache, and token-guardrail steps all succeed.
  • In the compiled agent job, the base repo is checked out first (actions/checkout, persist-credentials: false) and the PR head is fetched after, so the PR-branch git fetch runs inside a valid git repo. This fixes an earlier fatal: not a git repository failure that was caused by checkout: false.

The only step that can't be exercised without credentials is Copilot inference: gh-aw validates COPILOT_GITHUB_TOKEN up front and stops the run if it's unset (Error: None of the following secrets are set: COPILOT_GITHUB_TOKEN). A full end-to-end trial — where the agent posts grumpy review comments, captured as safe-outputs without touching the real PR — just needs that secret set on the trial/host repo.

Follow-up / requirement

Set the COPILOT_GITHUB_TOKEN repo secret (fine-grained PAT, Copilot Requests: Read, Copilot-licensed owner) on ohcnetwork/care_fe before this can post reviews. If it isn't configured yet, add it as a follow-up.

Add a gh-aw agentic workflow that automatically runs a grumpy senior
code reviewer on every pull request (opened/reopened/synchronize) plus
manual dispatch, leaving grumpy-but-constructive inline review comments
on the PR's changed lines.

- .github/agents/grumpy-reviewer.agent.md: the reviewer persona (imported
  verbatim from github/gh-aw).
- .github/workflows/grumpy-reviewer.md: pull_request_target + workflow_dispatch,
  guarded to ohcnetwork/care_fe, permissions read-all, imports the agent,
  github default toolset, and create-pull-request-review-comment /
  submit-pull-request-review safe-outputs. Uses roles: all so community/fork
  PRs are reviewed, with checkout disabled to avoid pwn-request exposure.
- .github/workflows/grumpy-reviewer.lock.yml: compiled output (gh aw compile).
- .github/aw/actions-lock.json: additive pin for the setup action the lock uses.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: 346b2c0e0bcc
@amjithtitus09
amjithtitus09 requested review from a team and Copilot July 31, 2026 12:45
@github-actions

Copy link
Copy Markdown

⚠️ Merge Checklist Incomplete

Thank you for your contribution! To help us review your PR efficiently, please complete the merge checklist in your PR description.

Your PR will be reviewed once you have marked the appropriate checklist items.

To update the checklist:

  • Change - [ ] to - [x] for completed items
  • Only check items that are relevant to your PR
  • Leave items unchecked if they don't apply

The checklist helps ensure code quality, testing coverage, and documentation are properly addressed.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a grumpy reviewer agent, its pull-request workflow declaration, and a generated execution workflow. The workflow validates activation, runs sandboxed Copilot review, processes bounded outputs, tracks usage, and detects threats.

Changes

Grumpy reviewer automation

Layer / File(s) Summary
Reviewer contract and workflow declaration
.github/agents/grumpy-reviewer.agent.md, .github/workflows/grumpy-reviewer.md, .github/aw/actions-lock.json
Defines the reviewer persona, review scope, comment limits, security rules, workflow triggers, permissions, and pinned setup action.
Activation and preparation
.github/workflows/grumpy-reviewer.lock.yml
Adds generated metadata, dependency manifests, trigger gating, validation, prompt generation, and activation artifacts.
Sandboxed review execution
.github/workflows/grumpy-reviewer.lock.yml
Runs Copilot CLI with firewall and MCP gateway setup, safe-output handling, error detection, log processing, and artifact collection.
Results, usage, and threat handling
.github/workflows/grumpy-reviewer.lock.yml
Processes review conclusions, usage limits, no-op and failure states, threat detection, enterprise host settings, and safe-output artifacts.

Suggested reviewers: jacobjeevan, bodhish

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the addition of the grumpy-reviewer agentic PR-review workflow.
Description check ✅ Passed The description clearly explains the workflow, security model, files, validation, and required secret, but omits the template sections and merge checklist.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch amjithtitus09-grumpy-reviewer-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ⏭️ Skipped

No test-related files were changed in this PR.

Tests are skipped when changes don't affect:

  • tests/**
  • src/**
  • package.json
  • playwright.config.ts

Run: #10549

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 282d2f8
Status: ✅  Deploy successful!
Preview URL: https://8a99a559.care-preview-a7w.pages.dev
Branch Preview URL: https://amjithtitus09-grumpy-reviewe.care-preview-a7w.pages.dev

View logs

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.

Pull request overview

Adds a new GitHub Agentic Workflows (gh-aw) PR-review automation that runs on pull_request_target and posts inline review comments via safe-outputs, using an imported “grumpy reviewer” persona.

Changes:

  • Introduces a new agentic workflow definition to review only changed lines and emit safe, structured PR review comments.
  • Adds the compiled gh-aw lock workflow for the new reviewer workflow.
  • Updates the gh-aw actions lockfile to pin the setup action referenced by the compiled workflow.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/grumpy-reviewer.md New gh-aw workflow source defining triggers, scope, tools, and safe-outputs for grumpy PR reviews.
.github/workflows/grumpy-reviewer.lock.yml Compiled gh-aw workflow output (generated by gh aw compile) that implements the reviewer pipeline.
.github/aw/actions-lock.json Adds a pinned entry for github/gh-aw-actions/setup@v0.80.9 used by the compiled workflow.
.github/agents/grumpy-reviewer.agent.md Adds the imported reviewer persona prompt (verbatim) for tone/standards.

Comment on lines +2 to +6
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.
Comment on lines +30 to +33
# No local clone is needed: the agent reads the PR diff and changed files through
# the GitHub API. Disabling checkout removes the "pwn request" attack surface that
# comes from checking out untrusted fork code under pull_request_target.
checkout: false
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/grumpy-reviewer.lock.yml:
- Line 1517: Update the safe_outputs job condition in grumpy-reviewer.lock.yml
to gate on needs.detection.outputs.detection_success == 'true' instead of
needs.detection.result == 'success'. Preserve the existing cancellation and
agent-result checks so warning or failure verdicts block safe outputs.
- Around line 1036-1039: Update the concurrency configuration for the
grumpy-reviewer workflow by removing cancel-in-progress while retaining queue:
max, so the settings are accepted together. Keep the existing concurrency group
unchanged.

In @.github/workflows/grumpy-reviewer.md:
- Around line 46-47: Add issues: write to the conclusion job’s permissions in
the workflow configuration, preserving the existing contents and pull-requests
permissions so issue-report handlers can create issues when using GITHUB_TOKEN.
- Around line 30-33: Update the workflow compiler/output associated with
checkout: false so the generated grumpy-reviewer.lock.yml no longer performs
GitHub-script checkouts during activation or before Copilot runs. Regenerate the
lockfile and verify it contains no checkout steps, keeping the documented
no-local-clone behavior consistent with the generated workflow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5ad58972-f83c-40a4-bcc4-db9640fbac7a

📥 Commits

Reviewing files that changed from the base of the PR and between 7f94541 and 6ead936.

📒 Files selected for processing (4)
  • .github/agents/grumpy-reviewer.agent.md
  • .github/aw/actions-lock.json
  • .github/workflows/grumpy-reviewer.lock.yml
  • .github/workflows/grumpy-reviewer.md

Comment on lines +1036 to +1039
concurrency:
group: "gh-aw-conclusion-grumpy-reviewer"
cancel-in-progress: false
queue: max

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.

🩺 Stability & Availability | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

GitHub Actions concurrency queue key supported workflow syntax

💡 Result:

In GitHub Actions, the concurrency key is used to define a concurrency group that limits the number of concurrent executions for a workflow or a specific job [1][2]. Workflow Syntax You can define concurrency at the workflow level or the job level [2]. The syntax supports two main configurations: Simple Syntax If you only need to define the concurrency group name, you can use the following format: concurrency: <group_name> Detailed Syntax For more control, such as enabling cancel-in-progress or managing queueing, use the object-based syntax: concurrency: group: <group_name> cancel-in-progress: <boolean_or_expression> queue: <single | max> Key Configuration Options group: A string or expression that defines the concurrency group. It can include context variables like github, inputs, and vars [1][3]. cancel-in-progress: A boolean (default false) that determines whether to cancel currently running jobs or workflows in the same group when a new one is triggered [4][3]. It also accepts expressions to conditionally cancel runs [4]. queue: Controls how pending jobs are handled [1][4]. single (default): At most one job or workflow run can be pending in the group [1][4]. max: Allows up to 100 pending jobs or workflows in the group [1][2]. When the queue is full, any additional runs are canceled [1][4]. Important Considerations Expression Contexts: When using expressions for the concurrency group, you are limited to the github, inputs, and vars contexts [1][3]. Fallback Values: If your group name relies on event-specific properties (e.g., github.head_ref, which is only available for pull_request events), use a fallback value (e.g., ${{ github.head_ref || github.run_id }}) to avoid syntax errors when the workflow is triggered by other events [5].

Citations:


🌐 Web query:

"concurrency.queue" "GitHub Actions"

💡 Result:

In GitHub Actions, the concurrency.queue key is an optional configuration property used to manage how pending workflow runs or jobs behave when they are part of a concurrency group [1][2]. It was introduced to allow multiple runs to queue sequentially rather than being limited to the default behavior of having only one pending run [1][2]. Key details regarding concurrency.queue include: Allowed Values: - single: The default behavior, where only one pending run is allowed per concurrency group [1][2]. - max: Enables the queuing of multiple pending runs (up to 100) per concurrency group [1]. Constraints: - Conflict with cancel-in-progress: You cannot set queue: max while also having cancel-in-progress: true [3][2]. This combination is invalid because a concurrency group cannot simultaneously queue waiting runs and cancel ones in progress [2]. Usage: The queue property can be defined at both the workflow and job levels within the concurrency block [2]. By enabling queue: max, you can ensure that workflows or jobs execute in order against shared resources or environments, rather than having newer runs cancel existing pending ones [1].

Citations:


Remove cancel-in-progress when using queue: max.

concurrency.queue is supported, but GitHub Actions rejects queue: max when cancel-in-progress is also set. If this workflow needs queued runs, keep queue: max and remove cancel-in-progress: false; otherwise set queue: single or omit queue.
[low_effort_and_high_reward

🧰 Tools
🪛 actionlint (1.7.12)

[error] 1039-1039: unexpected key "queue" for "concurrency" section. expected one of "cancel-in-progress", "group"

(syntax-check)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/grumpy-reviewer.lock.yml around lines 1036 - 1039, Update
the concurrency configuration for the grumpy-reviewer workflow by removing
cancel-in-progress while retaining queue: max, so the settings are accepted
together. Keep the existing concurrency group unchanged.

Source: Linters/SAST tools

- activation
- agent
- detection
if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success'

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Compare safe_outputs gating conditions across generated gh-aw workflows.
fd -g '*.lock.yml' .github/workflows --exec rg -n -B 4 -A 4 'detection.outputs.success|detection.result' {} \;

Repository: ohcnetwork/care_fe

Length of output: 4950


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== lock files =="
git ls-files '.github/workflows/*.lock.yml' '.github/workflows/*.yml' | sed -n '1,120p'

echo
echo "== grumpy review detection section =="
sed -n '1368,1528p' .github/workflows/grumpy-reviewer.lock.yml | cat -n | sed 's/^/grumpy-reviewer.lock.yml:/'

echo
echo "== parsed detection outputs setting occurrences =="
rg -n "parse_results|GH_AW_DETECTION|DETECTION_|detection_success|safe_outputs|Parse threat detection results|safe-outputs|safe outputs" .github/workflows -g '*.lock.yml' -g '*.yml' | sed -n '1,220p'

Repository: ohcnetwork/care_fe

Length of output: 27156


Use the detection verdict output for safe outputs.

In grumpy-reviewer.lock.yml, the detection steps can fail but keep continue-on-error: true, so the detection job can report success while steps.detection_conclusion.outputs.success is false. Gate safe_outputs on needs.detection.outputs.detection_success == 'true' like the other generated workflows, so warning/failure verdicts block safe outputs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/grumpy-reviewer.lock.yml at line 1517, Update the
safe_outputs job condition in grumpy-reviewer.lock.yml to gate on
needs.detection.outputs.detection_success == 'true' instead of
needs.detection.result == 'success'. Preserve the existing cancellation and
agent-result checks so warning or failure verdicts block safe outputs.

Comment thread .github/workflows/grumpy-reviewer.md
Comment thread .github/workflows/grumpy-reviewer.md
Declare `copilot-requests: write` and narrow the agent job to read-only
scopes (contents/pull-requests/issues: read). This makes the Copilot
engine run on the built-in Actions GITHUB_TOKEN via centralized org
billing, so no COPILOT_GITHUB_TOKEN personal access token secret is
needed. Requires the org to have centralized Copilot billing enabled.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: fa13e0e45481
Copilot AI review requested due to automatic review settings July 31, 2026 12:51

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.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.github/workflows/grumpy-reviewer.md:57

  • missing-tool.create-issue: true implies the workflow will open issues when a tool is missing, but this workflow only grants issues: read (and relies on GITHUB_TOKEN per the PR description). In that configuration, issue creation will fail unless a separate PAT secret (e.g. GH_AW_GITHUB_TOKEN) is configured, which contradicts the “no PAT required” claim.
    allowed-events: [COMMENT]
  missing-tool:
    create-issue: true

.github/workflows/grumpy-reviewer.md:43

  • The comment above checkout: false claims untrusted fork code is never checked out, but the compiled workflow does fetch the PR branch (see grumpy-reviewer.lock.yml step “Checkout PR branch”). This is misleading for threat modeling; please reword to reflect the actual behavior (fetching PR content/branch without executing it).
# No local clone is needed: the agent reads the PR diff and changed files through
# the GitHub API. Disabling checkout removes the "pwn request" attack surface that
# comes from checking out untrusted fork code under pull_request_target.
checkout: false

.github/agents/grumpy-reviewer.agent.md:21

  • This persona says it will “point out every issue, no matter how small”, which directly conflicts with the workflow’s instructions to prioritize and avoid nitpicks (and with the 10-comment cap). That contradiction can lead to worse review signal; align the persona with the workflow’s prioritization guidance.
- **Sarcastic and grumpy** - You're not mean, but you're definitely not cheerful
- **Experienced** - You've seen it all and have strong opinions based on decades of experience
- **Thorough** - You point out every issue, no matter how small
- **Specific** - You explain exactly what's wrong and why
- **Begrudging** - Even when code is good, you acknowledge it reluctantly
- **Concise** - Say the minimum words needed to make your point

Drop `copilot-requests: write` and restore `permissions: read-all` so
the Copilot engine authenticates inference with the COPILOT_GITHUB_TOKEN
repo secret (a fine-grained PAT with "Copilot Requests: Read"). Reading
the PR and posting review comments still run on the built-in Actions
GITHUB_TOKEN via the safe-output jobs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: fc1cded0f41f
Copilot AI review requested due to automatic review settings July 31, 2026 14:06

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.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (2)

.github/workflows/grumpy-reviewer.md:39

  • The comment above checkout: false implies fork PR code is never checked out under pull_request_target, but the compiled workflow still has a “Checkout PR branch” step in grumpy-reviewer.lock.yml. That’s an important security detail—this wording can lead maintainers to assume the pwn-request surface is eliminated when it isn’t. Please update the comment to match the compiled behavior (or change the workflow config if you truly need zero checkouts).
# No local clone is needed: the agent reads the PR diff and changed files through
# the GitHub API. Disabling checkout removes the "pwn request" attack surface that
# comes from checking out untrusted fork code under pull_request_target.
checkout: false

.github/workflows/grumpy-reviewer.md:53

  • With this running on every PR open/sync, missing-tool.create-issue: true can spam the repo with issues if the model requests a tool outside the allowlist (even once per PR). Consider disabling automatic issue creation here and relying on workflow logs / a single consolidated review comment instead.
  missing-tool:
    create-issue: true

@bodhish
bodhish merged commit cb27e0e into develop Jul 31, 2026
22 of 25 checks passed
@bodhish
bodhish deleted the amjithtitus09-grumpy-reviewer-workflow branch July 31, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants