Skip to content

security-guidance: take the next baseline before the Stop review - #7167

Draft
mhegazy wants to merge 1 commit into
mainfrom
mhegazy/sg-baseline-before-review
Draft

mhegazy wants to merge 1 commit into
mainfrom
mhegazy/sg-baseline-before-review

Conversation

@mhegazy

@mhegazy mhegazy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Before: after a finding, the Stop hook takes the baseline for the next Stop when the review has ended. A change made while the review runs, by an edit tool or a command, is in that baseline but in no review. It happens when the next turn is at work while the review of the last one is still running.

After: the baseline is taken before the changes are read. A change before it is in this review, a change after it is in the next one.

How

  • The snapshot and the list of untracked files are taken once the Stop hook has something reviewable to review. The changes are then listed a second time, so everything in the snapshot is in the review.
  • The baseline is stored only with a finding, as before, and only if no newer one is there. A prompt, or another Stop review, may have stored one while this review ran.
  • New files in the review are added to the stored list, so they do not look new again.

Implications

  • Every Stop with a reviewable change now takes the snapshot, not only one with a finding. The Stop hook runs in the background: 145 to 175 ms in a small repository, 1.07 to 1.23 s with 40,000 files (Linux, medians). The prompt hook is unchanged.
  • Each such Stop leaves one more unreferenced commit object in the repository, as a prompt already does.
  • Not changed: files changed by a command in a turn that ends without a Stop.

Not a regression: the released versions tried, from 2.0.0 to 2.0.20, do the same.

Tests

Scenario 2.0.20 main this PR Linux macOS Windows x64 Windows ARM64
Real session, command or edit in the next turn while a review with a finding runs (2) missed (hooks driven directly, Linux) missed reviewed, nothing reviewed twice run run run run
Real session, clean review, three plain turns not run all reviewed once the same run run run run
Real session, quick next turn, edit after a finding turn, plain turn not run all reviewed all reviewed run not run not run not run
tests/test_baseline_after_review.py not run 20 of 20 run run run, 6 that need a shell-script git skipped run, the same 6 skipped
Plugin suite, failures not on main 0 run, 2,351 passed run, 2,300 passed run, the same 16 fail on main run, the same 16
Regression scenarios (gateway, managed MCP, commit only) not run 21 of 21 21 of 21 run not run not run not run
Stop hook killed (SIGKILL, SIGTERM, 24 points, 20,000 files) not run no lock or temporary file left the same run not run not run not run

The sessions use a scripted model. No version bump.


Generated by Claude Code

After a finding, the Stop hook stores a new baseline for the next Stop. It took that
snapshot when the review had ended, so a change made while the review ran was in the
baseline but in no review. The snapshot is now taken before the changes are read, and
is stored unless a newer baseline is already there.
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.

2 participants