Repository navigation
ci: move AI code review into the team account; keep a thin trigger - #6375
Merged
Merged
Conversation
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
marked this pull request as ready for review
October 6, 2026 21:25
aviruthen
approved these changes
Oct 6, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ymlcarries 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
claude-code-actionwith the prompt inlineid-token: writeto assume a role that can only start and poll that one buildpublic,internal), as a matrixThe collaborator gate and manual-approval environment are unchanged, byte for byte.
Posting identity. The
reviewjob hands its run-scopedGITHUB_TOKENto the build, so the review and the commit status are posted asgithub-actions[bot]. The job's permissions are exactly what that needs:pull-requests: writeandstatuses: 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, neverREQUEST_CHANGES).Internal mode writes its report to the team's account and sets an
ai-review/internalcommit 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 isfailurewhen the internal review has a high-severity finding; a maintainer then relays anything actionable on the PR. The build itself still succeeds, so thereview (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/internalstatus appears in the merge box; it is not a required status.Repo settings needed before merge
AI_REVIEW_TRIGGER_ROLE: the trigger role ARN (maintainers have it).AI_REVIEW_PROJECT: the review build project name.CODE_REVIEW_ROLEbecomes 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/internalstatus 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 fromgithub-actions[bot]appears, and theai-review/internalstatus is set on the head commit.Supersedes #6295 and #6177.
no linked issue: CI infrastructure change.