Skip to content

ci: move AI code review into the team account; keep a thin trigger - #6375

Merged
jam-jee merged 2 commits into
masterfrom
feat/ai-review-thin-trigger
Oct 7, 2026
Merged

jam-jee merged 2 commits into
masterfrom
feat/ai-review-thin-trigger

Conversation

@jam-jee

@jam-jee jam-jee commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Goal: keep the AI code review's prompts, model settings, knowledge-base configuration and review logic out of this public repository, leaving only a trigger here.

Problem

ai-code-review.yml carries the whole review: the prompt, the model id, the tool allow/deny lists and a walkthrough of the security controls. Changing any of it needs a public PR, and the Action logs show the model's reasoning.

What changed

Before After
The workflow runs claude-code-action with the prompt inline The workflow starts a review build in the SageMaker team's infrastructure and waits for its status
Needs a Bedrock role Needs id-token: write to assume a role that can only start and poll that one build
One review Two builds per PR (public, internal), as a matrix

The collaborator gate and manual-approval environment are unchanged, byte for byte.

Posting identity. The review job hands its run-scoped GITHUB_TOKEN to the build, so the review and the commit status are posted as github-actions[bot]. The job's permissions are exactly what that needs: pull-requests: write and statuses: write. The token expires when the job ends; the job waits for the build, so it lives exactly as long as the review.

Public mode posts one review with inline comments (event COMMENT, never REQUEST_CHANGES).

Internal mode writes its report to the team's account and sets an ai-review/internal commit status on the head commit. It posts no comment, and the status carries no findings or counts, so contributors are not notified about something they cannot open. The status is failure when the internal review has a high-severity finding; a maintainer then relays anything actionable on the PR. The build itself still succeeds, so the review (internal) check reflects only whether the review ran.

If a newer commit arrives while a build runs, the runner sees the PR has moved and posts nothing, so stale reviews do not land.

Backwards compatibility

Compatible: same trigger events and paths, same check name. The review comment format changes (one review with inline comments). A new ai-review/internal status appears in the merge box; it is not a required status.

Repo settings needed before merge

  • Secret AI_REVIEW_TRIGGER_ROLE: the trigger role ARN (maintainers have it).
  • Variable AI_REVIEW_PROJECT: the review build project name.
  • Secret CODE_REVIEW_ROLE becomes unused and can be removed after merge.

Tests

The review runner has its own unit tests in the team's infrastructure package. Both modes were run end to end against #6273 and #6372 from the team account (public review posted, internal report written, ai-review/internal status set, re-run on the same commit skipped).

Manual verification

After the settings are in place, push a commit to a PR touching sagemaker-core/ and confirm both matrix jobs go green, one review from github-actions[bot] appears, and the ai-review/internal status is set on the head commit.

Supersedes #6295 and #6177.

no linked issue: CI infrastructure change.

The review itself (model invocation, prompt, tooling, comment posting) now
runs as a CodeBuild project in the SageMaker team's AWS account. This
workflow is reduced to a trigger: after the existing collaborator /
manual-approval gate, it assumes a narrowly scoped role via OIDC, starts
the review build once per mode (public, internal) with the PR number and
head/base SHAs, and polls until the build finishes, failing the check if
the build did not succeed.

Why:
- Prompts, model selection, knowledge-base configuration and the review
  scripts no longer live in the public repo, so they can change without a
  public PR and cannot be influenced by PR content.
- The workflow needs no `pull-requests: write` permission; the runner
  posts review comments with its own credentials.
- No PR code is checked out in the pull_request_target context at all.

Repo settings: secret `AI_REVIEW_TRIGGER_ROLE` and variable
`AI_REVIEW_PROJECT` are required. Secret `CODE_REVIEW_ROLE` is no longer
used by this workflow.

Supersedes #6295.
Hand the run-scoped GITHUB_TOKEN to the review build so the runner posts
the public review and the internal commit status as github-actions[bot].
The job grants exactly pull-requests: write and statuses: write for that;
the token expires when the job (which waits for the build) ends.
@jam-jee
jam-jee marked this pull request as ready for review October 6, 2026 21:25
@jam-jee
jam-jee deployed to auto-approve October 6, 2026 23:40 — with GitHub Actions Active
@jam-jee
jam-jee merged commit 29968ef into master Oct 7, 2026
6 checks passed
@jam-jee
jam-jee deleted the feat/ai-review-thin-trigger branch October 7, 2026 18:34

This branch was successfully deployed

1 active deployment
auto-approve — d9787d8a Deployed Oct 6, 2026 by jam-jee via wait-for-approval #1644
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.

2 participants