Repository navigation
fix(review): leak-free incremental review (three-dot diff + git log --no-merges) - #735
Conversation
|
if we just filter the file list, does this mean we still get the wrong diff for those files? can we just always do the three-dot diff? |
|
Good catch on both. Q1 — yes, the file-list filter is only a partial fix. It drops files that are purely from the base-merge, but for a file the PR authored and the base-merge also touched, the Q2 — yes, always three-dot is leak-free and simpler. If we want to keep the trivial-skip and be leak-free, the precise incremental is "authored commits since last review, excluding the merge commits": git log --no-merges --numstat --format= "$LAST_REVIEW_SHA..$HEAD_SHA"Base-merge churn lives in the merge commit, which My lean: if simplicity wins, go always-three-dot and delete the filter; if the skip optimization is worth keeping, switch to |
|
did we originally add this because of issues when there are conflicts orsone other corner case? otherwise always having the three dot diff everywhere seems much better; try to simplify everywhere |
|
ah, sorry, this is the incremental commits since the last merge. yes, off commands for both the (accurate) incremental commits and the total three dot diff |
…l compare The incremental pre-flight (step 1) computed "what changed since my last review" with a two-endpoint `gh api compare/$LAST_REVIEW_SHA...$HEAD_SHA`. The `A...B` symmetric-difference range includes every commit reachable from B but not A, so a `Merge branch '<default>'` commit between the two review points dragged the entire merged-in base delta into the compare — code the PR never authored — skewing the trivial-vs-substantive call and the model's reading. This was the original form of the incremental check; it was never added to handle conflicts or any corner case. Rather than filter the leaked range, drop it: the diff to read is always the PR's three-dot `gh pr diff` surface (merge-base->head), which base-merge commits never enter. The compare call now lists only the new commits' SHAs/messages to gauge what was pushed since the last review; its `.files` totals (which leak) are no longer read. Closes #734 Co-Authored-By: Claude <[email protected]>
41a61d6 to
d8407dc
Compare
|
On the history: no — the two-endpoint compare wasn't added for conflicts or any corner case. It's the original form of the incremental check (introduced with the incremental-skip heuristic itself), and So I went with always three-dot and simplified, per your steer. Pushed:
The one thing this gives up vs. an exact incremental count: the trivial-skip now judges "is the new push trivial?" from the commit list plus the three-dot diff rather than a precise per-push line total. A precise leak-free count would need |
|
note the comment I followed up with please |
Per maintainer steer, retain both signals: the accurate incremental (commits + per-file counts since last review, --no-merges so base-merge churn never counts) for the trivial-skip decision, and the three-dot gh pr diff for the review surface. --no-merges counts overlapping files correctly, which the dropped compare's .files totals did not. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
You're right — your follow-up asked for both, and I'd only kept the three-dot diff. Fixed: step 1 now reads both leak-free signals.
This drops the leaky |
tend-agent
left a comment
There was a problem hiding this comment.
The three-dot review surface (signal 1) is correctly leak-free. But the incremental signal still leaks base-merge churn — the same bug this PR set out to fix.
--no-merges only drops the merge commit itself. The base branch's own commits that the merge pulls in are ordinary non-merge commits, and they're reachable from $HEAD_SHA but not from $LAST_REVIEW_SHA, so they sit inside the A..B range and their --numstat churn is summed. The trivial-skip threshold then counts the whole merged-in base delta as "the new push", which is exactly the false-substantive classification the PR is trying to kill.
Reproduction
PR forks at c0, authors own work 1 (last reviewed), then main advances with unrelated churn, then the PR does git merge main and adds a 1-line follow-up:
$ git log --no-merges --numstat --format='%h %s' "$LAST_REVIEW..$HEAD"
822f44e pr: tiny follow-up
1 0 prfile.txt
3fd64ea main: big unrelated churn # <- base commit, leaked in
1 0 bigbasefile.txt
5 0 shared.txt
Actual incremental work is 1 line; the command reports 7, six of which are base churn. A larger base advance trivially blows past the ~20-line trivial threshold. The leak is identical in shape to the old compare/A...B — both include everything between merge-base and head when A is an ancestor of B (the normal case).
To actually exclude the merged-in commits you have to drop everything reachable from the base, e.g. git log --no-merges "$LAST_REVIEW_SHA..$HEAD_SHA" --not <base> (verified: this isolates just the PR's own follow-up). The catch is naming <base> reliably in the review checkout — it's refs/pull/N/merge at fetch-depth: 0, so origin/<base> isn't guaranteed to be a local ref, and the /head conflict-fallback checkout isn't a merge commit at all. Given that, the earlier "just always three-dot and drop the incremental" option may be the simpler correct path here — the incremental can't be made leak-free as cheaply as the description claims.
…E_SHA) git log --no-merges A..B still summed base-branch commits that a base merge pulled in — they're reachable from HEAD but not from the last review, so they sit in the A..B range and --no-merges only drops the merge commit itself, not those non-merge base commits. Exclude everything reachable from the base tip so the incremental isolates the PR's own authored work. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Caught a real leak in my own last commit and fixed it in 8773133.
Fix: also exclude everything reachable from the base tip. Base churn is always an ancestor of the base tip; the PR's own commits never are — so Both signals the maintainer asked for are now leak-free: the accurate incremental ( Verified reproPR forks at |
|
thanks! could you also log why we missed the 2nd message of mine above? did the agent check for any follow-up comments before returning? |
|
Checked the session log for the run that posted that reply (run Timeline (all UTC, from the session trace):
So the miss wasn't a misread — your second message simply didn't exist yet when the agent looked, and it never looked again. It spent ~4 minutes on the edit/commit/push and then posted straight from the context it had loaded at 14:28. This is exactly the case the Recheck Before Posting guard in the The guard is prompt-only, so it relies on the agent remembering to do it. If you'd like, I can propose a tightening to the bundled skill — e.g. make the pre-post re-fetch an explicit gate after any push/edit sequence rather than general advice — but since the rule already exists I held off on opening a PR unprompted. Say the word and I'll send it. |
Release 0.1.9. Version bump, lockfile sync, and CHANGELOG. Ships 6 commits since 0.1.8: ### Improved - `review` skill runs a `/code-review` pass alongside its manual checks, effort scaled to how core the change is ([#741](#741)) - Default harness timeout rises from 60 minutes to 3 hours ([#739](#739)) - `running-in-ci` recheck guard catches a new directive, not just a duplicate ([#738](#738)) - Both Claude harnesses update to claude-code 2.1.195 ([#740](#740)) ### Fixed - Incremental PR review no longer leaks the base-merge delta (three-dot diff + `git log --no-merges`) ([#735](#735)) ### Documentation - A composite-action comment drops a disproved security claim ([#737](#737)) The `0.1.9` tag is pushed after this merges. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…ole PR in view (#1368) A follow-up review re-reviewed the whole PR at full depth. The session knew what was new — the preflight listed the commits pushed since its last review, and it read every earlier bot review — but used that only to skip trivial pushes and to dedup findings. Steps 3–5 read `gh pr diff` and ran the `code-review` second pass over the whole PR, so every non-trivial push bought a fresh whole-PR pass. On a consumer PR a 7+/4− prose push was handed to the second pass as "merge-base → head, core, cover every angle". A fresh pass over a few hundred lines nearly always finds something, which is the structural half of the self-review churn #1366 addressed from the other side, and it is what gives a human author new findings on already-reviewed code after every push. This was a side effect rather than a decision. Before #735 a follow-up read a two-endpoint compare of the new commits. That compare leaked base-branch churn after a `Merge main`, and #735 fixed the leak by making the three-dot PR diff the review surface and cutting the incremental down to a `--numstat` listing for the trivial-skip gate. The incremental is now the delta file `post` already writes when the head moves mid-review: the same leak-free commit selection (`--no-merges`, `--not <base>`), with each commit's patch and the `base merge:` list, plus the line counts the trivial gate reads. `_write_delta` serves both cases and `_write_incremental` is gone. The skill asks for a follow-up the way a person returning to a PR reviews it: the new commits get the close read, with the whole PR's diff and the earlier reviews in view — whether the push answers what was raised, and whether the PR still holds together with it in. Code the earlier review covered isn't audited line by line again, though a problem noticed in it still counts. The second pass is pointed at the new commits and handed the PR's diff and the earlier reviews as context; `references/re-targeting.md`'s mid-review re-run does the same with its delta. Two fixes ride along, both found by reviewing what the narrower focus leans on. A draft-mode review no longer bases an incremental once the PR is ready: it was the lighter pass, and an incremental over it would let the push before `ready_for_review` be reviewed on its own and approved, after which the queued `ready_for_review` run skips because a review already stands at the head. And the delta's `base merge:` list now excludes the base branch's own merge commits, which a repo landing PRs as merges would otherwise list one by one for the reviewer to `--cc`. What it gives up: the second look a full re-audit gave code no later push touches. A force-push or `ready_for_review` still gets a full review. No behavioural eval ran. `test_start_records_one_snapshot_and_prepares_the_incremental` now asserts the patch is present and base churn absent, and two new tests cover the ride-along fixes; both fail without them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
Problem
The
reviewskill's incremental pre-flight (step 1) computed "what changed since my last review" with a two-endpointgh api compare/$LAST_REVIEW_SHA...$HEAD_SHA. TheA...Bsymmetric-difference range includes every commit reachable fromBbut notA, so when aMerge branch '<default>'commit lands between the two review points, the compare drags in the entire merged-in base delta — none of which is the PR's own work. The incremental review then anchored its trivial-vs-substantive decision and the model's reading on that leaked diff, critiquing code the PR never authored.Reported and maintainer-confirmed in max-sixty/worktrunk#3246.
This two-endpoint compare was the original form of the incremental check — it was never added to handle conflicts or any corner case. The
...range just happens to leak base-merges.Solution
Keep both signals the incremental check needs, with both made leak-free against base-merges:
gh pr diff(merge-base→head), which base-merge commits never enter. This is the same diff step 3 (the full-review path) already used; step 1 now uses it too.git log --no-merges --numstatover$LAST_REVIEW_SHA..$HEAD_SHA, giving the commits and per-file line counts pushed since the last review for the trivial-skip heuristic.--no-mergesdrops any base-merge commit, so its churn never counts — and unlike the old compare's.filestotals, files touched by both the PR and a base-merge are counted correctly. The review checkout isfetch-depth: 0, so the range is present locally.This replaces the leaky two-endpoint compare (and its earlier partial file-list jq filter, which still mis-counted overlapping files) — the trivial-skip stays accurate and the review surface stays leak-free.
Testing
No pytest harness covers skill prose; the bug was reproduced and maintainer-confirmed upstream. The change is a doc/recipe edit — the three-dot
gh pr diffis merge-base→head by construction andgit log --no-mergesexcludes the merge commit, so base-merge churn cannot enter either.Closes #734 — automated triage