Key takeaways
- ✓Generate, then verify. Instead of making the reviewer stricter (and missing more), put a check after it that tries to show each finding is wrong. Only findings that survive reach a person. A check is a classifier of findings: what matters is how much more often it drops wrong findings than right ones.
- ✓A second opinion from the same model is a weak check. The refuter dropped 5 of 31 findings that match nothing (16%) and 2 of 75 right ones (3%), never said unsure, and let 26 of the 31 through. Precision went from 71% to 74%.
- ✓A proof is a new test and a fix: the test must fail on the PR with a failing assertion and pass once the fix is in, and the fix may not touch any test. It proved 69 of 75 right findings (92%), but also 22 of the 31 that match nothing (71%). Precision went to 76%, noise from 0.78 to 0.55 findings per PR, and no planted bug was lost; the intervals overlap, so even that gain may be luck of the sample.
- ✓Check your checker. The first proof harness looked like the best filter, 81% precision, because fix edits had to match the file byte for byte and the model copied lines 2 spaces too deep. 70 edits matched nothing (68 only by indentation), 5 planted bugs were lost and recall fell 17 points. Allowing a whitespace-only difference, still matching once, took proven findings from 69 to 91.
- ✓A test proves behaviour, not wrongness. Of the 31 findings that match nothing, an AI labeller called 10 real bugs and 16 preferences; the proof check kept 8 and 12. A test that asserts PARTIAL runs should email the owner, with a fix that does it, passes, but the PR asked for failed runs only.
- ✓A proof of a real bug can fix the wrong side. Run each proof on the clean twin (the same change without the planted bug): 60 of 63 passed there. Two proofs of a field-mapping bug (`n33-d1`: the API saves a default under the key `default`, the worker reads `defaultValue`) seeded the buggy key and changed the worker to accept it; on the clean twin they fail.
- ✓Each check costs 2–3.5 cents per PR, about as much as the review itself (2.9 cents). The filtering gain here is small; the bigger value is the conversation: 'this input does this' instead of 'I think this is a bug', and a fair proof can stay as a regression test.
An AI reviewer writes findings, and some are wrong. This chapter puts a check between the reviewer and the person who reads its comments: a second AI that tries to refute each finding, and a proof check that must back each one with a failing test. It measures what each check lets through, how a bug in the check itself looked like the best result, and what a passing proof does and doesn't prove.
The source is Lab 04 (Prove It or Drop It) of the code-review labs, scripts 01_refute.py, 02_reproduce.py and 03_pipeline.py, recorded in October 2026; the video uses that run's results, and every number here matches the lab's README and recorded checks. The findings come from Chapter 4: Lab 03's agentic reviewer, three runs pooled, on Lab 02's sample of 40 pull requests (PRs) from the testbed of Chapter 1, 30 of them with a planted bug. Everything is an AI: the reviewer and both checks are gpt-5.4-mini at low effort, an AI judge matched each finding to the answer key, and an AI labelled the findings that match nothing. No person reviewed these PRs. "The person" below is whoever would read the findings.
How the PRs are named. Each pull request has an id like n33-d1. The first part is the change: n33 is one feature, adding default values to field mappings. (c changes come from the app's own history, n changes were written for the test set.) The second part is the version: -clean is the correct PR, and -d1, -d2 are copies of it with one planted bug each; so n33-clean and n33-d1 are the same feature, without and with planted bug 1.
Generate, then verify
A finding is one comment that says: this is a bug. Over three runs, the reviewer wrote 106. The answer key lists every known bug in each PR; an AI judge matched each finding to it:
| A finding that | Findings |
|---|---|
| describes the planted bug | 68 |
| matches a known issue | 7 |
| matches nothing | 31 |
The 75 that match something are right. The share of findings that are right is precision: 75 of 106, 71%.
The reviewer could be made stricter, but then it misses more, as PR-Agent did in Chapter 4. Instead, put a check after it: a second pass that takes each finding and tries to show it's wrong. Only the ones that survive reach a person. Think of a newspaper: the reporter writes the story, and a fact-checker tries to knock down each claim before it prints.
A check can be wrong in two ways: drop a right finding (the person never sees a real bug) or keep a wrong one (the person reads noise). What matters is the gap between how often it drops wrong findings and how often it drops right ones. A check that drops both at the same rate makes the review shorter, not better.
Check 1: try to refute it
The first check is a second opinion: another gpt-5.4-mini, with read access to the repo, tries to show the finding is wrong. To refute, it must quote code.
| Finding matches | Findings | confirmed | unsure | refuted |
|---|---|---|---|---|
| the planted bug | 68 | 66 | 0 | 2 |
| a known issue | 7 | 7 | 0 | 0 |
| nothing | 31 | 26 | 0 | 5 |
It refuted 16% of unmatched findings (5 of 31; 95% interval 7–33%) and 3% of right ones (2 of 75; 1–9%). The gap is in the right direction, and small: 26 of the 31 still get through. It never once said "unsure". The same model at the same effort mostly agrees with itself: a finding that sounded right to the reviewer tends to sound right to the checker. The two right findings it refuted were lost to the person, but other findings pointed at the same bugs.
Check 2: prove it with a test
The second check wants evidence, not an argument. A model writes a proof: a new test, and a fix. It counts as proven when:
- the test fails on the PR, with a failing assertion (an import error or a missing file doesn't count);
- the test passes once the fix is applied.
The rules, checked before anything runs: the test is a new file in a test folder, the fix may not touch any test (so it can't pass by editing the test), and each fix edit must match exactly one place in the code. The model gets up to two tries per finding.
Why the fix? A test can fail because of a typo, a missing fixture or another bug. If one targeted change to the code makes it pass, the failure is about that change.
| Finding matches | Findings | proven | unsure | not a bug |
|---|---|---|---|---|
| the planted bug | 68 | 63 | 5 | 0 |
| a known issue | 7 | 6 | 1 | 0 |
| nothing | 31 | 22 | 6 | 3 |
It proved 92% of the right findings (69 of 75). Good. But it also proved 71% of the findings that match nothing: 22 of 31. Hold on to that.
What reaches the person
A policy decides which findings reach the person. On the same 106 findings and 40 PRs:
| Policy | Kept | Precision (95% CI) | Planted bugs found | Noise per PR | Right findings dropped |
|---|---|---|---|---|---|
| everything (no check) | 106 | 71% (61–79%) | 27/30 | 0.78 | 0 |
| not refuted | 99 | 74% (64–81%) | 27/30 | 0.65 | 2 |
| proven | 91 | 76% (66–83%) | 27/30 | 0.55 | 6 |
| proven, first harness | 69 | 81% (70–89%) | 22/30 | 0.33 | 19 |
Noise is findings that match nothing, per PR. "Planted bugs found" counts a planted bug as found if at least one kept finding describes it. (It's 27 here, not Chapter 4's 28, because this lab checks only bug findings, not nits.)
Only proven findings: precision 71% → 76%, noise down 30%, and no planted bug lost. But the intervals overlap, so even that gain may be luck of the sample. And "no bug lost" leans on redundancy: "proven" dropped 6 right findings, and each of those bugs had another finding from another run. With one run, those would have been misses.
Pick a policy and watch the 106 findings:
Only findings with a proof: a new test that fails on the PR and passes once the model's fix is applied.
n36-d2
c18-d2
n17-d2
n13-clean
n22-d1
n05-d2
n27-d2
n11-clean
c16-d2
n32-d4
worker-release-d2
c17-clean
n20-clean
n31-d3
c38-d2
n26-d2
c20-d2
n33-d1
n29-d3
c23-clean
n02-d2
c19-clean
n09-d2
c02-d1
c28-d1
n15-clean
n24-d2
n37-clean
n30-d2
n18-clean
n34-d2
n19-d3
n10-d2
n16-d1
n28-d3
n23-d2
c35-d3
n25-d2
c27-d3
c22-clean
describes the planted buga known issuematches nothingdroppedred box: a planted bug the reviewer found, now lost
Each box is one PR, named by its change (c20, n33…) and version: -clean is the correct PR, -d1, -d2… the same PR with one planted bug. Hover a box for what the PR does.
Precision: kept findings that match the answer key, ÷ kept findings (95% interval 66–83%). Noise: kept findings that match nothing, per PR. Planted bugs found vs no check, paired: +0.
The lab also tried "proven or unsure" (103 kept, 73%) and "proven or confirmed by either check" (105 kept, 71%): looser, and almost no filtering.
Check your checker: the first harness
The first version of the proof check scored 81%, the best filter of all. But it lost 5 planted bugs.
A fix is a list of edits: find this text, replace it with that. The first harness required the find text to match the file byte for byte. The model kept copying lines with the wrong indentation, usually 2 spaces too deep (it strips the line-number gutter by hand). So 70 fix edits matched nothing, 68 of them only because of indentation, and those proofs were thrown out whether the finding was right or not. On 5 planted bugs, every try was rejected:
| PR | What it does | Its planted bug |
|---|---|---|
n09-d2 |
adds updateSync to edit a sync |
an unknown id crashes with a TypeError instead of NOT_FOUND |
c02-d1 |
makes deleting an unknown sync return NOT_FOUND | deleting a sync also deletes its destination when no other sync uses it |
n34-d2 |
gives webhook destinations their own URL | the URL is checked trimmed but saved with its spaces |
n28-d3 |
makes the sync form usable with a screen reader | one label is written into the component instead of the shared copy |
n23-d2 |
adds a run history table | the Failed column shows the rows synced |
These 5 vanished: recall fell 17 points (paired, −30 to −3). It threw out right findings too (19 of them), but it happened to throw out a bigger share of the unmatched ones, so what was left looked cleaner.
It was caught because all 5 lost bugs were lost the same way. The fix: an edit may differ from the file only in leading whitespace, and must still match exactly once; it's then re-indented to the file's. Proven findings went from 69 to 91. A check's own failures can look like selectivity: look at why things were dropped, not just how many.
A test proves behaviour, not wrongness
Back to the 22 proven findings that match nothing. An AI subagent read all 31 unmatched findings against the code, without seeing the checks' verdicts, and labelled each one:
- real: a defect under realistic input;
- spec: the code does what the PR says, and the reviewer wanted something else (a preference);
- wrong: the code doesn't do that.
| The finding is | Findings | Kept by "not refuted" | Kept by "proven" |
|---|---|---|---|
| real | 10 | 10 | 8 |
| spec (a preference) | 16 | 13 | 12 |
| wrong | 5 | 3 | 2 |
The proof check keeps 80% of the real ones and 75% of the preferences: it can't tell them apart. Of the 22 proofs, the labeller called 7 fair, 12 a test of the reviewer's preference, and 3 contrived (they build a state the app can't produce, like a sync id the API never makes).
One example. A PR emails a sync's owner "on the first failed run after one that didn't fail". The reviewer said PARTIAL runs, where only some records got through, should email too. So the proof's test asserts that a partial run sends an email, and its fix adds PARTIAL to the condition. The test fails on the PR and passes with the fix: proven. But the PR asked for failed runs; whether partial ones should email is a product choice, not a bug. A test proves what the code does. It can't prove that's wrong.
Real bug
a defect under realistic input
8 of 10 kept
Preference
the code does what the PR says; the reviewer wanted something else
12 of 16 kept
Wrong
the code doesn't do that
2 of 5 kept
The proof check keeps 8 of 10 real bugs and 12 of 16 preferences. Of the 22 proofs, 7 are fair, 12 encode the reviewer's preference, and 3 build a state the app can't reach. A test proves behaviour, not wrongness.
Labels by an AI subagent that read the code, blind to the checks' verdicts. No person reviewed these PRs.
The 10 real ones include 2 planted bugs the matcher missed and 8 findings of 5 unplanted bugs, such as a hostname with a trailing dot (billing.internal.) that gets past the SSRF check (the check that blocks requests to internal addresses). Counting them as right, precision is 80% with no check and 85% with "proven". But these labels are an AI's reading, not a measurement.
Proven, on the wrong side
Even a real bug can be proven the wrong way. Remember Chapter 4's cross-file bug, n33-d1, in the PR that adds default values to field mappings: the API saves a mapping's default under the key default, and the worker reads defaultValue. Three proofs passed. One fixes the API. The other two change the worker to accept default.
How do you catch that? With the PR's clean twin from Chapter 1: the same change without the planted bug, where the API saves defaultValue. A fair test of the bug should pass there.
The PR adds default values to field mappings. The planted bug: the API saves a mapping's default under the key default, and the worker reads defaultValue. This proof's test puts a mapping with the key default in the database and asks the worker to read it. Its fix, in worker/harbor_worker/models.py, makes the worker accept default.
def test_load_sync_preserves_mapping_defaults(conn):
add_sync(
conn,
mappings=[
{"sourceColumn": "plan", "destinationField": "Plan", "default": "free"},
],
)
sync = load_sync(conn, "syn_1")
assert sync.mappings[0].default_value == "free"
assert map_row({"plan": None}, sync.mappings) == {"Plan": "free"}Run it on the PR first, then with the fix.
Outputs from running the recorded proof with pytest on three copies. Across all planted bugs, 60 of 63 proofs passed on their clean twin; the three that didn't are these two and one c35-d3 proof (a PR that fails crashed runs, with a planted bug that stores the full traceback) that demands an exact error text the correct code doesn't produce.
60 of 63 proofs of planted bugs passed on their clean twin. The 3 that didn't: the two worker-side proofs of the field-mapping bug, which test the bug's data rather than the right behaviour, and one proof for c35-d3 (a PR that marks crashed runs FAILED, with a planted bug that stores the full traceback as the run's error) that demands the error text be exactly mapping exploded when the correct code stores ValueError: mapping exploded (a right finding with an over-specified test). Without a known-good version, a proof's wrong expectation is much harder to spot.
Does checking pay?
| Per finding | Per PR | |
|---|---|---|
| The reviewer (3 runs) | 2.9¢ | |
| Refute | 0.85¢ | 2.25¢ |
| Reproduce (prove) | 1.31¢ | 3.47¢ |
Each check costs about what the review itself cost, and both are small next to a minute of a person's reading. A proof takes a median of 11 seconds per finding (it runs a test twice); refute, 5. The whole lab cost $4.19, including the first harness's run and pilots.
On this reviewer, the filtering gain is small: 71% to 76%, with overlapping intervals. The reviewer was already fairly precise, so there wasn't much to remove. The bigger value of a proof is in the conversation. Instead of "I think this is a bug", the author gets "this input does this": the person checks whether the expected behaviour is right, not whether the bug exists. A person still decides if it's wrong, and a fair proof can stay as a regression test, so the bug can't come back.
Also in the lab
From the lab's README, beyond the video:
- The model reused existing test file names, which the rules reject: 11 times in the full run, even after the brief asked for
test_found_<name>files. - A test of a test can't be proven this way. For "this test doesn't test what it claims", the fix belongs in the test, and the rules forbid editing tests.
- Failure or error needed the runner's own summary. A crash inside the code under test can be the bug, so it counts as a failure; a file that can't be collected or loaded is an error.
- The roadmap's third check, "run it" (a script that shows a slow query or unbounded retry), is folded into the proof: a test can count queries or attempts.
What to do
- Put a check after a high-recall reviewer rather than making the reviewer stricter, and measure the check like a classifier: drop rate on right findings against drop rate on wrong ones.
- Ask for evidence, not an argument. A test that fails on the PR and passes with a fix beats a second opinion from the same model.
- Guard the proof with rules: a new test file, a failing assertion (not an error), no edits to tests, each fix edit matching once.
- Check your checker. Look at why findings were dropped. A check that drops findings for a mechanical reason ("fix text not in the file") is measuring its harness.
- Run proofs on a known-good version (the clean twin, or the base branch) to catch tests of the bug's data.
- Show the proof with the finding, and let a person judge whether the behaviour it pins down is wrong.
Caveats
- Everything is an AI. The reviewer, both checks, the judge that matched findings to the answer key, and the labels of unmatched findings. No person reviewed these PRs; relabel before quoting the real/spec/wrong split.
- The same model checks its own kind. Whether a different model or more effort would refute more is not measured here.
- One reviewer, already fairly precise. A noisier reviewer leaves more for a check to remove.
- "No bug lost" depends on three runs. Each planted bug had several findings; with one run, the 6 right findings "proven" dropped could have been misses.
- Small samples. 31 unmatched findings; the precision intervals overlap across all working policies.
- Planted bugs contradict the PR description by design. Real bugs are rarely that clear, so 92% proven may not carry over.
The checklist
- Count each check's drops by truth: right findings dropped against wrong findings dropped, with intervals.
- Report precision, recall, noise per PR and right findings dropped for each policy, on the same findings.
- Prove with a new test and a fix, under rules the harness checks before anything runs.
- Match fix edits ignoring leading whitespace, still exactly once, and log every rejection with its reason.
- Run each proof of a known bug on the clean version; a failure there means it tests the wrong thing.
- Label a sample of unmatched findings as real, preference or wrong, and see what each check keeps.
- Measure cost per PR for each check next to the review itself.
Practice: the checks in code
Write the policies, the drop rates and the metrics on the lab's 106 recorded verdicts, the indentation-tolerant match that fixed the first harness, and the rule for when a proof counts. The tests expect the lab's numbers: 2 of 75 and 5 of 31 refuted; 71%, 74% and 76% precision; the first harness's 81%, 22 of 30 and 19 right findings dropped; the 5 lost bugs; the real fix for the delete-sync bug (c02-d1) that was 2 spaces too deep; and the field-mapping proof (n33-d1) that fails on its clean twin.
Quiz
1.Why put a check after the reviewer instead of making the reviewer stricter?
2.The refuter drops 16% of findings that match nothing and 3% of right ones. What does that say?
3.Why does a proof need the fix as well as the failing test?
4.The first proof harness gave 81% precision; the fixed one 76%. Which do you report?
5.The proof check kept 8 of 10 real bugs and 12 of 16 preferences among the unmatched findings. What does a passing proof show?
6.A proof of the field-mapping bug (the API saves a default under `default`, the worker reads `defaultValue`) fails on the PR, passes with its fix, and fails on the clean twin. What happened?
Check your understanding
Try each question before opening its answer.
Why check findings after the reviewer instead of tuning the reviewer to write fewer?
A stricter reviewer drops findings before anyone looks, and right ones go with the wrong ones (PR-Agent in Chapter 4 had the best precision and less recall). A check looks at one finding at a time, can read the repo or run a test, and leaves evidence. Here the reviewer found 27 of 30 planted bugs in 106 findings, and the checks kept all 27.
How do you judge whether a check is good?
Treat it as a classifier of findings: compare how often it drops wrong findings with how often it drops right ones. The refuter dropped 16% of unmatched findings and 3% of right ones: the right direction, but 26 of 31 unmatched still got through. Then look at precision, noise per PR and planted bugs found for each policy, with intervals.
What does a proof have to do to count?
A new test file in a test folder that fails on the PR with a failing assertion, not an error, and passes once a fix is applied that doesn't touch any test, with each fix edit matching one place in the code. The fix ties the failure to the finding.
The first harness had the best precision, 81%. What was wrong with it?
It required fix edits to match the file byte for byte, and the model copied lines 2 spaces too deep: 70 edits matched nothing, 68 only by indentation. Every try on 5 planted bugs was rejected, recall fell 17 points, and dropping a bigger share of unmatched findings made the rest look cleaner. Matching that ignores leading whitespace, still exactly once, took proven findings from 69 to 91 and precision to 76%.
A finding is proven. Is it a bug?
Not necessarily. A proof shows what the code does, not that it's wrong. The proof check kept 12 of 16 findings an AI labelled as preferences, like a test that PARTIAL runs should email the owner when the PR asked only for failed runs. A person, or the PR description, decides whether the behaviour is wrong.
How can a proof of a real bug still be wrong, and how do you catch it?
It can test the bug's data instead of the right behaviour. Two proofs of the field-mapping bug (n33-d1), where the API saves a default under "default" and the worker reads "defaultValue", seeded the buggy key "default" and fixed the worker to accept it. Running each proof on the clean twin (the same change without the bug) catches this: 60 of 63 passed there, and these two failed.
Next up: Chapter 6 catches bugs before any reviewer looks, with tools that cost nothing to run: let tools catch it first.