Repository navigation
[CI] Harden Gemini review triggers and prepare read-only PR diff/head-file context (Stack 2/5) - #41852
Closed
damccorm wants to merge 1 commit into
Conversation
This was referenced Dec 1, 2026
Contributor
Author
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.
Context: I found I was getting much better results from my local agent than I was from the review bot. This tries to fix the problem, but I expect we'll want to do more hill climbing from here
Overall Change (Gemini Code Review Overhaul)
Splits draft PR #41844 into 5 small, focused, independently valid stacked PRs that replace the single-pass
web_fetch-based review workflow with a hardened, two-pass Hunter → Verifier review agent operating over read-only local context (repo/+pr_context/):web_fetchon the PR URL with no checkout, nogrep_searchacross callers/subclasses, no diff-hunk orcommit_idvalidation, nodry_runtesting mode, and single-pass JSON output — leading to missed bugs on non-trivial PRs and occasional hallucinated false positives.pr.diff, exact 1-basedpr.numbered.diff,valid_lines.json, boundedhead_files/,incremental.diff,checks.json, git log/static checks, and$RUNNER_TEMP-isolatedthreads.json), pin.github/gemini_review_guide.mdin system memory under a random per-run filename, run Pass 1 (high-recall Adversarial Hunter) → Pass 2 (high-precision Skeptical Verifier & JSON Formatter) → optional Pass 2b (JSON syntax repair), validate single-/multi-line same-hunk placement pinned tohead_sha, and add aworkflow_dispatchdry_runmode.workflow_dispatchwithdry_run=trueacross a representative sample of 10 open Java, Python, Go, YAML, runner, and I/O PRs—comparing the bot's output against independent blind reviews without posting comments—including a clean PR check to verify precision (0 false positives). Also verified workflow lint, license, whitespace, and security checks (beam_PreCommit_GHA,beam_PreCommit_RAT,beam_PreCommit_Whitespace, andzizmor).What This PR Changes (
2/5)Hardens trigger/concurrency controls and adds the trusted base checkout plus core read-only PR context fetching in
.github/workflows/gemini_code_review.yml(+331 / -8):/gemini reviewcomments onauthor_association(OWNER,MEMBER,COLLABORATOR,CONTRIBUTOR) or PR author (github.event.issue.user.login == github.event.comment.user.login).concurrency.grouptogemini-code-review-<pr_number>so duplicate triggers across event types/actors coalesce cleanly.retries: 3on read-onlyactions/github-script@v9steps (Check for existing Gemini review from draftandPrepare read-only PR context) to guard against transient GitHub API HTTP500s (keepingretries: 0on review posting).Checkout trusted base branch): Checks out only the trusted base branch intorepo/(fetch-depth: 50,persist-credentials: false), never untrusted PR code.Prepare read-only PR context): Writespr_context/containing:head_sha.txt— pinned PR head commit SHA.valid_lines.json— per-fileRIGHT/LEFTdiff hunk[start, end]ranges.java_line_length.txt— added Java lines exceeding 100 columns (excludingimport,package, and URLs) as a deterministic Spotless heuristic whengoogle-java-formatis absent.pr.diff(with fallback to assembling per-file patches on HTTP 406) andpr.numbered.diff(every hunk line prefixed with exact 1-based[L<old>|R<new>]line numbers to prevent off-by-1 line references).head_files/<path>— bounded (max 40 files, 250 KB/file, non-binary, path-traversal-guarded) full head-SHA text contents of modified/added files.changed_files.txtandmetadata.json.Clean up temporary review files,if: always()): Removespr_context/,.gemini/, prompt files, and raw Gemini output files on runner exit.Standalone safety: Keeps the existing
Run Gemini Enterprise Code Review AgentandPost PR Review to GitHubsteps unchanged, so the workflow remains completely functional if merged before PRs 3–5.