Repository navigation
Description
Problem
In a PR review-gate loop (review → fix → push → review again), every round re-reviews the entire --from <merge-base> --to <head> range. The GitHub Actions posting helper already avoids re-posting duplicate comments (scripts/github-actions/post-review-comments.js, IoU-based incremental overlap dedupe), but the expensive part — the LLM re-reviewing files the new push did not touch — has no reuse path. On one iterative PR we measured 19 gate rounds at roughly 2M tokens per round; the large majority of that spend was files that were byte-identical between rounds.
The building blocks already exist, but are locked to same-range crash recovery
- Every review item has a content fingerprint:
sha256(mode + oldPath + newPath + diffText)(internal/agent/agent.go,reviewItemFingerprint). A file untouched by a new push keeps a byte-identical per-file diff against the same merge-base, hence the same fingerprint. --resume <session-id>already reuses fingerprint-matched completed items (applyResume→RecordReviewItemReused), and the run manifest already has acoverage.reusedbucket for exactly this.- But
ResumeState.ValidateOptions(internal/session/resume.go) requires the resumed session's--from/--toto match the current run exactly, so the moment a new commit is pushed (--tomoves) resume refuses, and the whole range is re-reviewed. Resume also needs the local session store, which an ephemeral CI runner has already thrown away.
Prior art: this is table stakes for PR reviewers
qodo-ai/pr-agent has incremental review (/review -i), and its design maps cleanly onto what is missing here (all verified against pr_agent/tools/pr_reviewer.py and pr_agent/git_providers/github_provider.py):
- State lives in the PR, not on the runner.
get_previous_reviewfinds the bot's last review comment by its header prefix; no server-side storage is needed. - Delta detection:
get_commit_rangesplits the PR's commit list at the previous review's timestamp →first_new_commit/last_seen_commit. - Scope = files touched by the new commits:
unreviewed_files_mapis the union ofcommit.filesover the new range (merge commits from the default branch skipped);get_files()returns only those in incremental mode — i.e. file-granularity increments, exactly the granularity OCR's fingerprints already encode. - Safety: no previous review → automatic fall back to full review; optional thresholds (
minimal_commits_for_incremental_review,minimal_minutes_for_incremental_review) gate auto-triggered incremental runs; the review output marks where the increment starts ("Starting from commit …").
CodeRabbit likewise reviews each push incrementally rather than re-reviewing the full PR every time.
Proposal
Two composable pieces:
-
Cross-push reuse for range mode. Allow resuming with the same
--frombut a moved--to(either by relaxingValidateOptions, or under a distinct flag so classic resume semantics stay strict). Selection stays exactly as today — compute the currentmerge-base..new-headdiff and each item's fingerprint; items whose fingerprint matches a completed item in the reuse source are recorded asreused(with their previous comments, asapplyResumealready does), everything else is reviewed fresh. The fingerprint definition makes this safe by construction: any change to a file's diff — including base drift after a rebase, since the diff text changes — invalidates the match and forces a fresh review. -
An ephemeral-CI-friendly reuse source. Accept a previous run's output as the reuse source (e.g.
--reuse-from <ocr-result.json>) instead of requiring the local session store. The JSON result and manifest already carry everything needed: per-item fingerprints incoverage.completedand per-file comments. The reference GitHub Actions flow already uploads that artifact and stamps the producing run id into the sticky summary (<!-- ocr-summary-run:… -->), so a workflow can locate the previous artifact the same way pr-agent locates its previous review comment — from the PR itself.
Mirroring pr-agent's safety behavior: no reuse source (or an unusable one) → silently fall back to today's full review; reused items are already visible in the manifest's coverage.reused, so a consumer can always tell a reused verdict from a fresh one.
Happy to work on this if the direction sounds right — starting with piece 1, which is small and keeps the current CLI surface.
Activity
Fanzzzd commentedon Aug 12, 2026
One more motivating datapoint, from this repository's own dogfooding:
.github/workflows/ocr-review.ymltriggers onpull_request_target: types: [opened]only — a PR is reviewed exactly once, when it is opened, and never again onsynchronize. On a PR that is reworked after review (e.g. #823, which was substantially restructured after its only OCR run), the standing verdict describes a head that no longer exists.That trigger choice is the other horn of the same dilemma this issue is about: re-reviewing the full range on every push is too expensive to enable, so the workflow doesn't re-review at all — trading stale verdicts for cost. Cross-push reuse is what would dissolve the dilemma: with unchanged files reused, a
synchronize-triggered re-review costs roughly one changed file's worth of tokens, which makes keeping verdicts current affordable — here and in every downstream review-gate setup.Airport233 commentedon Aug 13, 2026
I don’t really see it that way. OCR's review conclusion for a file doesn't just depend on that file's own diff — it also depends on whatever other context the agent dynamically reads at the time. The context beyond the diff is dynamic, so you need to consider whether the reviewed file's content still fits with other context that may have changed. A fingerprint can only tell you whether the file itself has changed compared to the last version. It can't guarantee that an unchanged file is still correct within the project, and the validity of existing review comments on that file might shift too.
Fanzzzd commentedon Aug 14, 2026
That's a fair point, and worth being precise about: a reused verdict is the round-N verdict for that file, not a fresh judgment against the current tree — the fingerprint proves the diff didn't change, nothing more.
What makes the trade-off workable in practice: the files whose context actually moved are exactly the ones re-reviewed fresh; the manifest already separates
coverage.reusedfromcompleted, so inherited verdicts are always distinguishable; and the match could be tightened by folding in the rule/runtime config hashes the manifest already records, with an explicit fresh full pass available before merge. And the realistic alternative today isn't "always fresh" — it's full-cost re-review or, as with theopened-only trigger, no re-review at all.But you're right that this should be opt-in and clearly labeled, never silent.
feat(session): support incremental resume when head commit moves (ali…
Airport233 commentedon Aug 17, 2026
Never questioned the precision of single-file fingerprint matching. But that's a different question from what I raised — matching precisely only proves the file's own diff hasn't changed, not that its old verdict still holds up in a context that has since changed. Two different levels of correctness.
Also, from what I can tell, resume's original intent in OCR isn't reusing prior work in a normal review flow — it's resuming after an abnormal interruption, same from/to, picking up where a crashed run left off. Repurposing it for cross-push reuse feels like using it for something it was never built for.
Fanzzzd commentedon Aug 20, 2026
Agreed on both points. Resume should stay strict crash-recovery — dropping the "relax
ValidateOptions" half of the proposal; shipping reviewers all treat incremental as a separately-named mode with full review as the fallback (CodeRabbit, pr-agent/review -i). Cross-push reuse, if ever wanted, would be the--reuse-fromopt-in only.And yes — a fingerprint match proves the diff didn't change, not that the verdict still holds in changed context. The honest framing is an opt-in cache with known staleness, with the manifest's rule/runtime config hashes folded into the match key — the way build caches hash declared context (Bazel action keys, Turborepo).
feat(review): reuse completed findings across pushes via --reuse-from
feat(review): reuse completed findings across pushes via --reuse-from
feat(review): reuse completed findings across pushes via --reuse-from
feat(review): reuse completed findings across pushes via --reuse-from