ci(governance): bot-allowlist for low-risk dep/CI chore PRs#131
Conversation
…n approval Adds a bot-allowlist branch to the "Require Human Approval" gate. A PR is auto-approved (required=0 humans) only when ALL of the following are true: - Author is dependabot[bot], renovate[bot], or chitcommit - PR has label 'dependencies' or 'chore', OR title starts with 'chore(deps):' / 'chore(ci):' - Only files touched are: package.json, pnpm-lock.yaml, package-lock.json, .github/workflows/security-gates.yml, .github/dependabot.yml - No reviewer has requested changes - All other check runs on the head SHA are green (CodeQL, gates, Dependency Audit, Secret Scan, claude-review, etc.) Otherwise the original 1-human-approval requirement applies. Job name unchanged so branch protection rules continue to match. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@coderabbitai review Please evaluate:
|
|
Warning Review limit reached
More reviews will be available in 22 minutes and 3 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Code Review — ci(governance): bot-allowlist for low-risk dep/CI chore PRsOverall: Solid intent and good defense-in-depth layering (author + label/title + file-allowlist + no-changes-requested + all-checks-green). A few correctness/security issues need addressing before merge. Bugs / Correctness1. The workflow will almost always require human approval anyway (missing re-trigger) The governance workflow only fires on Fix: add a 2. const selfJobName = 'Require Human Approval'; // never matches a check run name
const selfCheckName = 'PR Governance Check'; // correctGitHub Actions creates check runs named after the job's 3. Reviews list is not paginated const { data: reviews } = await github.rest.pulls.listReviews({ owner, repo, pull_number });
const reviews = await github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number, per_page: 100 });Security Concerns4. Allowing bot-authored changes to 5.
6. Any PR from an allowed author with a Minor / Nits
Summary
The core design is sound. Fix the trigger gap and pagination issues before merge, and reconsider |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8c8f65709
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const checksAllGreen = otherChecks.length > 0 && otherChecks.every(c => | ||
| c.status === 'completed' && (c.conclusion === 'success' || c.conclusion === 'neutral' || c.conclusion === 'skipped') |
There was a problem hiding this comment.
Re-run or wait before requiring green sibling checks
For an otherwise allowlisted bot PR, this evaluates checksAllGreen while the governance job is still running; any sibling check run such as Portfolio Hardening Check or another CI workflow that is still queued/in_progress makes this false and immediately falls back to requiring a human approval. Since this workflow only triggers on pull_request, it will not automatically re-evaluate when those checks later complete, so low-risk dependency/CI PRs can remain blocked despite all checks eventually passing.
Useful? React with 👍 / 👎.
| const checkRuns = await github.paginate(github.rest.checks.listForRef, { | ||
| owner, repo, ref: headSha, per_page: 100, | ||
| }); |
There was a problem hiding this comment.
Include commit statuses before waiving approval
When an allowlisted bot PR has required legacy commit status contexts (for example an external CI or coverage service), this only reads GitHub Check Runs and never reads commit statuses despite the comment and new statuses: read permission. In that context a failed or pending status is invisible here, so allowlistMatch can waive the human approval solely because all check runs are green.
Useful? React with 👍 / 👎.
| const { data: reviews } = await github.rest.pulls.listReviews({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.payload.pull_request.number | ||
| owner, repo, pull_number, | ||
| }); |
There was a problem hiding this comment.
Paginate reviews before trusting latest review states
On bot PRs with more than the first page of reviews, this single listReviews call can miss later review records, including a later CHANGES_REQUESTED from a reviewer. Because the allowlist then treats hasChangesRequested as false, a dependency/CI PR can have the human approval waived even though a reviewer has an outstanding change request.
Useful? React with 👍 / 👎.
Summary
Adds a bot-allowlist branch to the Require Human Approval job in
.github/workflows/governance.yml. Low-risk dependency / CI-chore PRs can satisfy the gate without a human approval when ALL of the following match:dependabot[bot],renovate[bot], orchitcommitdependenciesorchore, OR title starts withchore(deps):/chore(ci):package.json,pnpm-lock.yaml,package-lock.json,.github/workflows/security-gates.yml,.github/dependabot.ymlIf any criterion fails, the original
required = 1human-approval rule applies (unchanged).Job name kept as
Require Human Approvalso branch protection rules continue to match. Workflow permissions extended withchecks: read+statuses: readso the script can inspect sibling check runs.This PR itself is not allowlist-eligible (touches governance) and requires the standard 1 human approval to bootstrap the policy.
Test plan
chore(deps):PR with only lockfile/manifest changes should pass the gate with 0 human approvals once other checks go green🤖 Generated with Claude Code