Skip to content

[CI] Add commit_id pinning, diff-hunk validation, and dry_run mode to Gemini review posting (Stack 4/5) - #41854

Closed
damccorm wants to merge 1 commit into
users/damccorm/gemini-review-3-context-enrichmentfrom
users/damccorm/gemini-review-4-posting-and-dry-run
Closed

damccorm wants to merge 1 commit into
users/damccorm/gemini-review-3-context-enrichmentfrom
users/damccorm/gemini-review-4-posting-and-dry-run

Conversation

@damccorm

@damccorm damccorm commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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/):

  • Problem: The existing workflow uses web_fetch on the PR URL with no checkout, no grep_search across callers/subclasses, no diff-hunk or commit_id validation, no dry_run testing mode, and single-pass JSON output — leading to missed bugs on non-trivial PRs and occasional hallucinated false positives.
  • Solution: Pre-fetch read-only PR context (pr.diff, exact 1-based pr.numbered.diff, valid_lines.json, bounded head_files/, incremental.diff, checks.json, git log/static checks, and $RUNNER_TEMP-isolated threads.json), pin .github/gemini_review_guide.md in 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 to head_sha, and add a workflow_dispatch dry_run mode.
  • End-to-end verification: Evaluated iteratively using workflow_dispatch with dry_run=true across 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, and zizmor).

What This PR Changes (4/5)

Upgrades Post PR Review to GitHub and adds a non-posting dry_run testing mode in .github/workflows/gemini_code_review.yml (+161 / -26):

  • workflow_dispatch dry_run input (type: boolean, default: false):
    • Appends -dry-run to concurrency.group when dry_run is enabled so test dispatches never cancel live PR reviews.
    • Executes the full JSON parsing and diff-hunk validation pipeline, prints a clearly delimited preview of commit_id, reviewBody, and all validated inline comments (plus a collapsible ::group::Dry-run reviewPayload JSON block and a Markdown summary in $GITHUB_STEP_SUMMARY), and returns without calling github.rest.pulls.createReview.
  • Reliable inline review posting:
    • Pins commit_id from pr_context/head_sha.txt on both primary and fallback review submissions.
    • Validates every inline comment's line and side against pr_context/valid_lines.json; routes out-of-hunk comments to ## 💬 Additional Findings (Outside Diff Hunks) instead of causing the entire createReview API call to fail.
    • Supports validated multi-line comments (start_line < line, start_side === side, both inside the same hunk) while preserving single-line suggestion blocks when start_line === line && start_side === side.
    • Emits an explicit core.warning with the exact SyntaxError message if JSON.parse fails instead of silently swallowing the error.
    • Keeps retries: 0 on this write step to avoid duplicate posted reviews.

Standalone safety: Consumes pr_context/head_sha.txt and pr_context/valid_lines.json produced by PR 2/5 and works cleanly with either the existing web_fetch agent or PR 5/5's two-pass agent.

@damccorm

damccorm commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Consolidated into the 2-PR stack (#41851 and #41860) with review feedback incorporated.

@damccorm damccorm closed this Dec 1, 2026
@damccorm
damccorm removed this pull request from stack #41857 December 1, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build size/m M: 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant