Skip to content

ci: add trusted-contributor AI PR review#15

Merged
shawnmuggle merged 2 commits into
mainfrom
chore/trusted-ai-pr-review
Jul 5, 2026
Merged

ci: add trusted-contributor AI PR review#15
shawnmuggle merged 2 commits into
mainfrom
chore/trusted-ai-pr-review

Conversation

@shawnmuggle

Copy link
Copy Markdown
Member

Summary

  • Add a remote GitHub Actions AI PR reviewer for trusted Rozo contributors.
  • Trigger on PR open/update/reopen/ready-for-review and on trusted comments on PRs.
  • Comment P0/P1/P2 findings, label clean PRs with ai-review-passed, and approve only when there are zero P0 findings.

Safety

  • Executes the review script from the default branch checkout only.
  • PR code is fetched only for git diff; it is not executed with secrets.
  • Trusted authors are configured outside the repo file via AI_REVIEW_TRUSTED_AUTHORS.
  • Auto-approve requires separate AI_REVIEW_APPROVER_TOKEN; without it the workflow still reviews/comments but skips approval.

Required config

  • Variable: AI_REVIEW_TRUSTED_AUTHORS.
  • Secret: ANTHROPIC_API_KEY for AI review.
  • Secret: AI_REVIEW_APPROVER_TOKEN for trusted-author approve.

Test plan

  • Parsed workflow YAML locally from the source template.
  • Ran .github/ai_pr_review.py dry-run with a clean mocked review from the source template.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ea1ab89fd

ℹ️ 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 }}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Stop interpolating head_ref into bash

In the pull_request path this writes the PR branch name directly into the generated shell script before Bash executes it. GitHub allows branch names with shell metacharacters such as $, so a branch like feat$(curl${IFS}...) can run arbitrary commands in this step before the trusted gate while GH_TOKEN is present. Pass these event fields through env/JSON and write them with printf/Python instead of interpolating them into shell.

Useful? React with 👍 / 👎.

Comment thread .github/ai_pr_review.py
A section whose only content is `_None._` (case-insensitive) is empty.
"""
findings: dict[str, list[str]] = {"P0": [], "P1": [], "P2": []}
matches = list(_SECTION_RE.finditer(review_md))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fail closed on malformed model output

Here a response with no matching headings leaves matches empty and returns zero findings, and verdict_from_findings then treats that as clean; the same happens for P0 text that is not a bullet. If Claude is truncated, refuses, or otherwise deviates from the requested format, the workflow can label and auto-approve without a valid review. Treat missing/malformed required sections as a failed or skipped review instead.

Useful? React with 👍 / 👎.

Comment thread .github/ai_pr_review.py
)
else:
set_output("trusted_auto_approve", "skipped-author")
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear the pass label when a later review blocks

After a PR has once been labeled ai-review-passed, a later synchronize run with P0 findings only reaches this skipped-p0 output and never removes the existing label. The PR will still display the pass label next to a blocking AI review, so the label's status is backwards until someone removes it manually; remove PASS_LABEL on non-clean verdicts.

Useful? React with 👍 / 👎.

@shawnmuggle shawnmuggle merged commit 78d9dd8 into main Jul 5, 2026
1 check passed
@shawnmuggle shawnmuggle deleted the chore/trusted-ai-pr-review branch July 5, 2026 05:35
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