Skip to content

feat: add review queue and PR fixer GitHub Actions - #874

Merged
Gkrumbach07 merged 3 commits into
mainfrom
feat/review-queue-and-pr-fixer
Mar 10, 2026
Merged

Gkrumbach07 merged 3 commits into
mainfrom
feat/review-queue-and-pr-fixer

Conversation

@Gkrumbach07

Copy link
Copy Markdown
Contributor

Summary

  • Review Queue (pr-merge-review.yml): renamed from "PR Merge Review", updated prompt for type classification and sub-agent evaluation, removed unused SESSION_RESULT env var
  • PR Fixer (pr-fixer.yml): new workflow with 4 triggers:
    • agent-managed label added to a PR (immediate)
    • @ambient-fix comment from collaborator/member/owner (immediate)
    • Schedule: every 4 hours weekdays for all agent-managed PRs with recent activity
    • Manual: workflow_dispatch with PR number

How they work

  • Review Queue runs daily, creates an Ambient session that evaluates all open PRs and generates a prioritized queue
  • PR Fixer fires off Ambient sessions to fix individual PRs (rebase, address feedback, lint, test, push)
  • Batch scheduled job finds agent-managed PRs updated in last 4h, spawns parallel sessions (fire-and-forget)

Dependencies

Test plan

  • Manually trigger Review Queue via workflow_dispatch
  • Add agent-managed label to a test PR and verify PR Fixer triggers
  • Comment @ambient-fix on a PR and verify it triggers
  • Verify batch schedule finds agent-managed PRs correctly

🤖 Generated with Claude Code

- Rename PR Merge Review to Review Queue with updated prompt
  for type classification and sub-agent evaluation
- Add PR Fixer workflow with 4 triggers:
  - Label: agent-managed label added to PR (immediate)
  - Comment: @ambient-fix from collaborators (immediate)
  - Schedule: every 4 hours weekdays for agent-managed PRs
  - Manual: workflow_dispatch with PR number
- Batch job finds agent-managed PRs with recent activity,
  fires off parallel Ambient sessions (no wait)
- Remove unused SESSION_RESULT env var

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Gkrumbach07 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2897ea7c-1ec5-4064-bc73-5adae1e290fc

📥 Commits

Reviewing files that changed from the base of the PR and between 709faec and 0c49de6.

📒 Files selected for processing (1)
  • .github/workflows/pr-fixer.yml

Walkthrough

This pull request introduces a new GitHub Actions workflow for automated PR fixing with multiple trigger modes (labeled events, issue comments, scheduled runs, manual dispatch), alongside renaming and updating the existing PR review workflow. The new workflow coordinates single-PR fixes, batch discovery, and parallel processing.

Changes

Cohort / File(s) Summary
PR Fixer Workflow
.github/workflows/pr-fixer.yml
New workflow with three jobs: fix-single handles direct PR fixes via pull_request_target events or issue comments; fix-batch discovers recently updated agent-managed PRs on a weekday schedule; fix-each processes discovered PRs in parallel. Uses ambient-action v0.0.2 with configurable API credentials and includes session tracking and summary emission.
Review Queue Workflow
.github/workflows/pr-merge-review.yml
Workflow renamed from "PR Merge Review" to "Review Queue" with updated prompt to generate prioritized review queue with classification and ranking. Removed SESSION_RESULT environment variable; updated step and summary header naming to reflect new functionality.

Sequence Diagram(s)

sequenceDiagram
    actor Trigger
    participant GHA as GitHub Actions
    participant Batch as fix-batch Job
    participant Single as fix-single Job
    participant Matrix as fix-each Job
    participant API as ambient-action API
    participant Output as Workflow Output

    Trigger->>GHA: Manual dispatch / PR labeled / Schedule / Comment `@ambient-fix`
    
    alt Single Fix Path
        GHA->>Single: Trigger (PR event or `@ambient-fix` comment)
        Single->>Single: Determine PR number
        Single->>API: Invoke ambient-action with PR + prompt
        API-->>Single: Session created
        Single->>Output: Emit session summary (name, UID, phase)
    else Batch Fix Path
        GHA->>Batch: Trigger (scheduled on weekdays)
        Batch->>Batch: gh pr list: find agent-managed PRs<br/>updated in last 4 hours
        Batch->>Batch: Filter via Python to get eligible PRs
        Batch->>Output: Output JSON array of PR numbers
        Output->>Matrix: Matrix input (PR list)
        Matrix->>API: Parallel invocations of ambient-action<br/>(wait=false for each PR)
        API-->>Matrix: Sessions created (non-blocking)
        Matrix->>Output: Emit per-PR session summary
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding two new GitHub Actions workflows (Review Queue and PR Fixer), which directly match the changeset.
Description check ✅ Passed The description is directly related to the changeset, detailing the Review Queue workflow updates and the new PR Fixer workflow with specific trigger modes, behavior, and dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/review-queue-and-pr-fixer

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 and usage tips.

@Gkrumbach07
Gkrumbach07 marked this pull request as ready for review March 10, 2026 18:06
@github-actions

Copy link
Copy Markdown
Contributor

Claude Code Review

Summary

PR 874 introduces two GitHub Actions workflows: a renamed/updated Review Queue workflow and a new PR Fixer workflow. The Review Queue changes are minimal and clean. The PR Fixer is well-structured with good authorization guards on the @ambient-fix comment path, but has three notable issues worth addressing before merge.

Blocker Issues: None.

Critical Issues

1. pull_request_target label trigger has no authorization check

File: .github/workflows/pr-fixer.yml, lines 6-7 and fix-single job if condition (line 30)

The pull_request_target trigger fires with full write-context secrets when the agent-managed label is added. The issue_comment path correctly guards authorization by checking author_association against MEMBER/OWNER/COLLABORATOR, but the labeled path has no equivalent check. Any GitHub user with Triage role can add the agent-managed label to any PR (including fork PRs) and trigger an authenticated ambient session spending org resources.

Standard violated: security-standards.md - authorization check must be performed before resource access.

Suggested fix: Add an actor check to the labeled branch of the if condition, or add a guard step that verifies the labeler has sufficient permissions before calling the ambient action.

Major Issues

1. fix-each matrix missing fail-fast: false

File: .github/workflows/pr-fixer.yml, strategy block in fix-each job

GitHub matrix default is fail-fast: true, so if the ambient action fails for one PR, all other in-progress PR fix jobs are cancelled. For a batch maintenance workflow, each PR should be treated independently. Add fail-fast: false to the strategy block.

2. Python date-parse fallback silently expands batch scope

File: .github/workflows/pr-fixer.yml, fix-batch step

The Python script uses except Exception: active.append(pr['number']) when date parsing fails, meaning a PR with a malformed updatedAt is included in the batch rather than skipped, potentially triggering unexpected sessions. Log the parse failure and skip the PR instead.

3. Workflow-level permissions instead of job-level (least privilege)

File: .github/workflows/pr-fixer.yml, lines 23-25

Permissions are declared at workflow level granting contents: read and pull-requests: read to all jobs. Only fix-batch needs pull-requests: read to call gh pr list. The fix-single and fix-each jobs use AMBIENT_BOT_TOKEN, not GITHUB_TOKEN. Move the permissions block to job level on fix-batch only.

Standard violated: Least-privilege principle per security-standards.md.

Minor Issues

  1. No max-parallel cap on fix-each - With --limit 20 on gh pr list, up to 20 parallel sessions could be spawned simultaneously on the scheduled run. Consider max-parallel: 5 to throttle resource usage.

Positive Highlights

  • Strong authorization guard on @ambient-fix comments: checking author_association against MEMBER/OWNER/COLLABORATOR is exactly right and prevents abuse from external contributors.
  • Clean three-job structure (fix-single, fix-batch, fix-each) is easy to follow and correctly gates fix-each on fix-batch having non-empty output.
  • Sensible timeout-minutes on all jobs prevents runaway sessions from consuming runner minutes indefinitely.
  • pr-merge-review.yml cleanup is tidy, removing the unused SESSION_RESULT env var and aligning naming across step labels and summary headers.

Recommendations

  1. (Critical) Add an actor/sender authorization check to the pull_request_target labeled path before merge.
  2. (Major) Add fail-fast: false to the fix-each matrix strategy.
  3. (Major) Change the Python date-parse fallback from append to skip/warn.
  4. (Major) Move permissions to job level for fix-batch only.
  5. (Minor) Add max-parallel: 5 to throttle batch session concurrency.

Reviewed by Claude Code against .claude/context/security-standards.md, .claude/patterns/k8s-client-usage.md, and .claude/context/backend-development.md.

pull_request_target runs in the base branch context which is a
security concern. pull_request is sufficient since we only need
the PR number to pass to the Ambient session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pr-fixer.yml:
- Around line 31-39: The workflow allows privileged runs (pull_request_target
and issue_comment flows) to act on forked PRs; update the conditional
expressions that gate the Ambient fixer (the pull_request_target and
issue_comment branches currently checking github.event_name and
github.event.issue.pull_request) to also verify the PR comes from the same
repository by requiring github.event.pull_request.head.repo.full_name ==
github.repository (or equivalent same-repo check) before passing the PR number
to privileged steps; apply the same same-repo guard to the other duplicated
condition blocks referenced in the diff so forked PRs cannot trigger the
privileged fixer.
- Around line 13-14: The workflow's schedule uses the cron entry '0 8,12,16,20 *
* 1-5' which creates a 12-hour overnight gap while the selector still only looks
back 4 hours; update the schedule cron to cover the overnight run (for example
change to '0 0,4,8,12,16,20 * * 1-5' or '0 0/4 * * 1-5') and/or increase the
selector lookback from 4 hours to at least 12 hours so no weekday PR activity is
missed (apply the same change to the second identical schedule block
referenced).
- Around line 98-132: The batch selector currently re-queues PRs updated by the
fixer itself (PRS/NEEDS_WORK) and never checks for an active fixer session (note
wait:'false'), so update the selection loop to skip PRs whose most-recent
activity was performed by the workflow actor and to skip PRs with an in-progress
fixer run: for each PR number in PRS, call gh pr view <num> (or gh api to fetch
timeline/last commit author) to obtain the last-updater identity and compare it
to the GITHUB_ACTOR/bot user and skip if they match, and also query recent
workflow runs/check-runs for the PR to detect an in-progress fixer session and
skip those PRs before adding them to NEEDS_WORK.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8289ca90-9d6d-41e6-89f7-bf2f9c214ccf

📥 Commits

Reviewing files that changed from the base of the PR and between 9e7a2cd and 709faec.

📒 Files selected for processing (2)
  • .github/workflows/pr-fixer.yml
  • .github/workflows/pr-merge-review.yml

Comment thread .github/workflows/pr-fixer.yml Resolved
Comment thread .github/workflows/pr-fixer.yml Resolved
Comment thread .github/workflows/pr-fixer.yml Resolved
- Skip fork PRs on label trigger (check head.repo.fork)
- Skip fork PRs on issue_comment trigger (gh pr view isCrossRepository)
- Skip fork PRs in batch selector
- Fix schedule gap: run every 4 hours including overnight (*/4)
- Anti-churn: skip PRs whose last comment has <!-- pr-fixer-bot --> marker
  (prevents fixer from re-processing its own output)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Gkrumbach07
Gkrumbach07 merged commit 44a12da into main Mar 10, 2026
6 checks passed
@Gkrumbach07
Gkrumbach07 deleted the feat/review-queue-and-pr-fixer branch March 10, 2026 19:18
@mergify

mergify Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

🧪 CI Insights

Here's what we observed from your CI run for 0c49de6.

🟢 All jobs passed!

But CI Insights is watching 👀

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.

1 participant