feat(review): reuse completed findings across pushes via --reuse-from - #1146
Open
nitishagar wants to merge 1 commit into
Open
feat(review): reuse completed findings across pushes via --reuse-from#1146nitishagar wants to merge 1 commit into
nitishagar wants to merge 1 commit into
Conversation
Review-gate loops (review, fix, push, review again) re-review the whole --from..--to range every round even though most files are byte-identical between pushes; iterative PRs burn a full review's tokens per push. The reuse machinery already existed for crash recovery (--resume reuses fingerprint-matched completed items), but resume requires the same refs and a local session store, so a moved --to or an ephemeral CI runner cannot use it. Add an opt-in --reuse-from <file> that takes a previous run's JSON output as the reuse source: items whose content fingerprint (sha256 of mode, paths and diff text) matches a completed item in the source are reused with their previous comments instead of re-reviewed, and are recorded in coverage.reused and review_item_reused events. Changed files fail the fingerprint match by construction and are reviewed fresh, so a moved --to is fine. A missing, unreadable, malformed, wrong-schema or different-repository source degrades to today's full review with a warning; --resume keeps its strict crash-recovery semantics and cannot be combined with --reuse-from or --preview. Fixes alibaba#854
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s). |
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.
Summary
Adds an opt-in
--reuse-from <file>flag toocr reviewthat takes a previous run's JSON output as a reuse source: items whose content fingerprint matches a completed item in that source are reused (previous comments carried over, recorded incoverage.reusedandreview_item_reusedevents) instead of re-reviewed, so review-gate loops stop re-reviewing byte-identical files on every push.Fixes #854 (implementing the
--reuse-fromhalf the issue narrowed to on 2026-08-20; the relax-ValidateOptionshalf was explicitly dropped there and--resumesemantics are untouched by this PR).Background
--resumealready implements fingerprint reuse (sha256(mode \0 oldPath \0 newPath \0 diffText)), but it is strict crash recovery: the resumed session's--from/--tomust match exactly and the session store must exist locally. In a PR gate loop the head moves every push and CI runners are ephemeral, so resume can never apply — every round re-reviews the full range (the issue measures 19 gate rounds at ~2M tokens each, the majority on byte-identical files).How it works
cmd/opencodereview/reuse_from.go) reads the previous run's--format jsonoutput — the manifest (coverage fingerprints + repository identity) and the flat comment list, both already published by every run — and synthesizes aResumeStatefor the existing reuse engine inapplyResume.--tois therefore fine — untouched files keep byte-identical diffs.[ocr] WARNINGand today's full review — never a hard error.--resumekeeps its strict semantics (ValidateOptions/ValidateResumenever fire on the reuse path);--reuse-fromis mutually exclusive with--resumeand--preview.[ocr] Reuse <id>: reusing N file(s), reviewing M file(s)andresume.resumed_fromcarries thereuse:<run_id>source in JSON output.A CI workflow can wire this by uploading the result JSON of each run and passing it to the next push's review — the reference GitHub Action flow already uploads that artifact.
Testing
make check,make test(race), andmake coverage(91.0% ≥ 90) green. New tests cover the loader gate matrix (unreadable/invalid JSON/nil manifest/schema mismatch/wrong repo/empty-vs-empty identity), the moved---toheadline scenario (unchanged file reused with its comments, changed file reviewed fresh), mode-mismatch structural exclusion, all-reused (dispatched == 0), mutual exclusions, and an end-to-end wiring test (mutation-verified: deleting the wiring fails the test) asserting zero LLM calls for a fully-reused run and warning+full-review for a degraded source.loadReuseState,sameRepositoryIdentity, andapplyResumeat 100% line coverage.