ci: add trusted-contributor AI PR review#45
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 380258c190
ℹ️ 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".
| echo "author=${{ github.event.pull_request.user.login }}" | ||
| echo "base_ref=${{ github.event.pull_request.base.ref }}" | ||
| echo "head_repo=${{ github.event.pull_request.head.repo.full_name }}" | ||
| echo "head_ref=${{ github.event.pull_request.head.ref }}" |
There was a problem hiding this comment.
Quote PR branch refs before writing them to the shell
When a PR branch contains shell metacharacters such as $(...), this interpolation is placed inside a double-quoted shell command, so Bash still performs command substitution; GitHub documents that most special characters are valid in branch names and need shell escaping. Because this runs before the trust gate, and trusted runs later execute trusted/.github/ai_pr_review.py with the Anthropic/approver secrets, a malicious branch name can rewrite that script and exfiltrate secrets; pass the ref through an environment variable or otherwise single-quote/escape it instead of inlining it into run.
Useful? React with 👍 / 👎.
| if root is None: | ||
| return 0.0 |
There was a problem hiding this comment.
Persist prior spend before enforcing the daily cap
In the Actions workflow there is no step that sets AGENT_PRIOR_COST_USD or restores a cached brain.db, so in CI this branch returns 0.0 on every run. That makes the advertised daily cap effectively per-run only: multiple PR reviews in the same day can cumulatively exceed $10.00 without the pre-check ever skipping until a single review exceeds the cap by itself.
Useful? React with 👍 / 👎.
| if verdict == "clean": | ||
| add_label(repo, pr, token, PASS_LABEL) |
There was a problem hiding this comment.
Remove the pass label when a later review blocks
If a PR first gets a clean review, this branch adds ai-review-passed; on a later synchronize run with P0 findings, the non-clean path only skips auto-approval and never removes that existing label. The PR can therefore keep advertising a passed AI review after the current review found blockers, which is misleading for humans or any automation that keys off the label.
Useful? React with 👍 / 👎.
Summary
ai-review-passed, and approve only when there are zero P0 findings.Safety
git diff; it is not executed with secrets.AI_REVIEW_TRUSTED_AUTHORS.AI_REVIEW_APPROVER_TOKEN; without it the workflow still reviews/comments but skips approval.Required config
AI_REVIEW_TRUSTED_AUTHORS.ANTHROPIC_API_KEYfor AI review.AI_REVIEW_APPROVER_TOKENfor trusted-author approve.Test plan
.github/ai_pr_review.pydry-run with a clean mocked review from the source template.