Skip to content

fix(review): pin PR code reads to the head SHA, not the default branch - #2100

Merged
mabry1985 merged 1 commit into
mainfrom
fix/review-head-pinned-reads
Jul 21, 2026
Merged

fix(review): pin PR code reads to the head SHA, not the default branch#2100
mabry1985 merged 1 commit into
mainfrom
fix/review-head-pinned-reads

Conversation

@mabry1985

Copy link
Copy Markdown
Member

Fixes the panel half of pr-reviewer-plugin#20. Pairs with github-plugin#22 (merged, v0.3.0), which adds the tool this uses.

The bug

The review panel reads PR files with github_read_file, whose ref is optional and defaults to the repo's default branch. Omit it and you read the code as it was before the PR — so the verifier "confirms" that symbols the PR adds don't exist, and a correct PR collects blocker findings.

Reproduced on #2088: the verifier reported goalDetailQuery missing from apps/web/src/lib/queries.ts. At the reviewed head 19c37f7a it is exported at line 90 — it read main.

#2094 shows it compounds: three re-reviews produced 8 → 9 → 11 findings about code the PR never touched. Recalled prior_findings re-seed each panel, so a wrong-ref finding breeds.

Why not just fix the prompt

Because that was already the fix, and it didn't hold:

  • review-finder: "Ref discipline: a plain github_read_file shows the DEFAULT branch … pass ref=<head SHA>"
  • verifier: the same rule
  • the recipe passed head_sha to all four finders and the verify step
  • there was even a test asserting the prompt says it

Every layer was correct and the reads still went to main. A rule the model must remember on each of ~40 tool calls isn't a guarantee — so this removes the choice.

The change

Both review seats now use github_read_pr_file (PR number + path), which takes no ref: the head SHA is resolved server-side from the PR, and a failed pinned read errors rather than falling back.

github_read_file stays available and is still the right tool for policy docs (CLAUDE.md/PROTO.md), which must be read at the base — a PR must not rewrite the rules it's judged by. The verifier also now fails closed: if it can't read a file at the PR head, the verdict is uncertain, never confirmed.

Test

27 passed (test_code_review_workflow.py, test_sdk_subagent_tools.py).

The old test asserted the prompt contained ref=<head SHA> — that assertion was passing while production emitted false blockers, which is the whole lesson. Replaced with assertions on the enforced behaviour: both seats hold github_read_pr_file, the finder is told never to use github_read_file for code context, and the verifier carries the fail-closed rule.

Deploy note

Vera (the QA reviewer) is pinned to base 0.104.5, so she picks this up on the next protoAgent release. Her re-gate is currently disabled (regate: false, pr-reviewer-plugin v0.7.1) so these false FAILs can't block merges in the meantime.

🤖 Generated with Claude Code

The review panel read PR files with `github_read_file`, whose `ref` is optional
and defaults to the repo's DEFAULT BRANCH. Omit it and you read the code as it
was BEFORE the PR — so the verifier "confirms" that symbols the PR ADDS don't
exist, and a correct PR collects blocker findings.

Observed on protoAgent#2088: the verifier reported `goalDetailQuery` missing
from apps/web/src/lib/queries.ts; it is exported at line 90 of the reviewed
head. #2094 drew 8 → 9 → 11 findings across three re-reviews about code the PR
never touched (recalled prior_findings re-seed each panel, so a wrong-ref
finding compounds).

Prompt-level discipline was ALREADY here and did not hold: both the
review-finder and verifier prompts said "pass ref=<head SHA>", the recipe passed
the SHA to every step, and the reads still went to main. A rule the model has to
remember on every call is not a guarantee.

Both review seats now use github-plugin's `github_read_pr_file` (v0.3.0), which
takes no ref at all — it resolves the head SHA server-side from the PR number.
`github_read_file` stays for policy docs, which must still be read at the base
(a PR must not rewrite the rules it is judged by), and the verifier now fails
closed: an unreadable head means "uncertain", never "confirmed".

Refs pr-reviewer-plugin#20, protoLabsAI/github-plugin#22.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mabry1985, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ecdbc8ba-ef82-42b5-8cc5-a28452115afa

📥 Commits

Reviewing files that changed from the base of the PR and between 4cd89f3 and 04ab9ff.

📒 Files selected for processing (2)
  • graph/subagents/config.py
  • tests/test_code_review_workflow.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/review-head-pinned-reads

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@protoreview protoreview 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.

QA panel review — PASS

code-review · head 04ab9ffffcd2 · formal

[review-synthesizer completed: workflow code-review:report]

The review panel identified no defects across the provided findings lists, and the verifier confirmed no issues. The overall risk is low as no correctness, security, or behavioral regressions were detected. There are no items to fix.

[]

@protoreview protoreview 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.

Promoting the PASS verdict for head 04ab9ffffcd2: all checks terminal-green, zero unresolved review threads. (approve-on-green)

@mabry1985
mabry1985 merged commit c9e9c47 into main Jul 21, 2026
9 of 10 checks passed
@mabry1985
mabry1985 deleted the fix/review-head-pinned-reads branch July 21, 2026 09:56
mabry1985 added a commit that referenced this pull request Jul 21, 2026
…, section order (#2108)

Release prep for the 25 commits sitting on main since v0.105.2.

CHANGELOG [Unreleased] was missing four user-facing changes and had **two
separate `### Fixed` sections**, which would have rolled into a malformed
release section. Merged them, reordered to Keep a Changelog's Added/Changed/Fixed,
and added entries for:

- the watch-tool gating (#2099) — a DEFAULT-OFF behavior change, so it gets an
  explicit "existing configs must set `watches.enabled: true`" note
- the PR-review head-SHA fix (#2100)
- the Tools-panel Filesystem group chips (#2084)
- the PWA theme-color fix (#2083)

ADRs and CI-internal commits are deliberately not listed — this repo cites ADRs
inline in the entry they belong to rather than as standalone lines.

`watches.enabled` shipped with NO documentation outside a commented block in the
example config, while simultaneously flipping the tools to default-off. Added
`## watches` to the configuration reference and a "Turn it on first" section to
the watches guide, both stating the three things the flag deliberately does not
do — it never deletes stored watches, the background poller keeps running, and
`goal.enabled` must ALSO be true because the tools ride inside the goal tool
group. Wording checked against the schema comment in `graph/config.py` and the
example config so the three don't drift.

Co-authored-by: GitHub CI <ci@example.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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