ealeng

Episode 06 of 12 · Less to review

Let tools catch it first: what free checks catch, and what they block

Ten free checks (stricter types, ESLint, ruff, mypy, Semgrep, a secret scanner, property and contract tests, browser flows, mutation testing) ran on the 250-PR test set. The nine that can fail a build exposed 19 of 173 planted bugs. With their default rules they'd block 69% of the clean PRs. A flag near a bug isn't a find (28 flagged, 19 exposed); tests written before the PR can't see what it adds; mutation testing is a pointer, not a gate; masking a flaky screenshot didn't help, fixing the clock did. Cut to the 11 rules that exposed a bug, blocks fall to 12%, and the AI reviewer's recall on what's left doesn't change.

Lab 05 · Let Tools Catch It First16 min read
Video transcript7:56

0:00Cold open

0:01

I turned on ten free checks: stricter types, linters, a security scanner, a secret scanner, and tests that run on every pull request.

0:10

No AI, no reviewer, nothing to pay per run. They ran on all two hundred and fifty pull requests from part one.

0:18

Nine of them can fail a build. Together, they exposed nineteen of the hundred and seventy-three planted bugs. About one in nine.

0:28

And with their default settings, they’d block sixty-nine percent of the clean pull requests, the ones with no planted bug.

0:36

So are tools useless for code review? Not quite. But every check has to earn its place.

0:42Intro

0:44

Hands-on AI code review. Part six.

0:47

Today: which bugs free tools catch before anyone reviews, and what they cost in blocked pull requests.

0:55Catches against blocks

0:56

I’m Valentina, a tech lead. In part five, checking AI findings bought only a small gain. The cheaper move is to catch bugs before anyone reviews.

1:07

A deterministic check gives the same answer for the same code. It costs nothing per run, and it never gets tired.

1:14

But a check that turns the build red on good pull requests is like a smoke alarm that goes off for toast. People take the battery out.

1:23

So every check gets two numbers: the planted bugs it catches, and the clean pull requests it would block.

1:30

And only new findings count. Each check runs on the pull request, and on its base, the code it starts from. I keep only what the pull request adds.

1:4101 · Every check

1:42

Here are all ten. Flagging near a bug means a new finding within three lines of it, that the bug’s clean twin doesn’t get. Most checks do that for a handful of bugs.

1:52

Look at ESLint. It flags near eleven planted bugs, and would block thirty-nine of the seventy-seven clean pull requests. Half of them.

2:03

Thirty-seven of those thirty-nine get a warning from a few strict typing rules. On clean pull requests, those rules raised three hundred and five new warnings, and exposed no bug at all.

2:15

And the secret scanner found nothing, because no planted bug was a leaked secret. Its one block is a fake password in a test.

2:2402 · Flagged near isn’t found

2:25

But a flag near a bug isn’t a find. In part three, a review comment on the right line could be about something else. Tools do that too.

2:34

So an AI read every catch, and labelled whether it exposes the bug: fixing what it says fixes the bug, or leads straight to it.

2:43

This one does. The type checker says a parameter called now is never used. That’s the clock the code should have used, instead of the real time.

2:52

This one doesn’t. It’s on part one’s bug, where the setting is never loaded. Ruff suggests a rewrite that wouldn’t even work on this kind of row.

3:01

Twenty-eight bugs had a flag nearby. Nineteen were exposed.

3:06

By type, conventions are the best covered: six of fifteen. Logic, security and UI bugs: none at all.

3:1403 · Tests written before the PR

3:16

Next, tests. I wrote them once, on healthy main, the way a team writes tests before any of these pull requests exist.

3:24

A property test checks a rule that should always hold, on many generated inputs. Like this one: every record is sent once, in order, within the batch limit.

3:34

They caught four bugs, all in pull requests meant to fix one of these rules. The clean fix passes, the buggy one doesn’t.

3:42

They also failed two clean pull requests, which change a rule on purpose. A property is a promise. When a pull request changes the promise, the test has to change with it.

3:54

The contract test runs one fixed round trip: the API creates a sync, the worker runs it, the API reads it back. It caught none of the eighteen contract bugs, where two parts disagree on a name or a shape.

4:0903 · Tests written before the PR

4:11

Here it is on part four’s bug, where the API saves the key “default”, and the worker reads defaultValue.

4:18

It passes. Look at the mappings it creates: no default at all. It was written before that field existed.

4:26

A test only knows the rules it was written for. It can’t check a new field, a new error code, or a new screen.

4:3404 · Testing the tests

4:35

Mutation testing tests the tests. It changes one line the pull request adds, say a less-than into a less-or-equal, and reruns the pull request’s own tests.

4:46

If they still pass, the mutant survived. No test pins that line.

4:51

Across almost three thousand mutants, survivors sat near a quarter of the planted bugs.

4:57

But they also sat on more than half of the clean pull requests. As a gate, it would block most of them.

5:04

As a pointer that says “look here”, it’s a hint: survivors sat near seven logic bugs, a type no other check exposed. Nobody checked whether they point at the bug itself.

5:1605 · Screenshots

5:17

Screenshots next. A browser takes a picture of the page, and compares it with the picture from the base.

5:24

First, how noisy is that? I took the same page twenty times, moving the browser’s clock six hours each time. Nothing else changed.

5:33

Every run was flagged. The page shows times like “thirty minutes ago”, and those change. So even a deterministic check is flaky if it reads the clock.

5:44

So I masked those times. Still every run flagged, and the largest change got slightly bigger.

5:51

Look at the mask. The text under it still sets the cell’s width, so the box grows and shrinks, and the last-run column shifts.

5:59

Fixing the browser’s clock removed the cause. None flagged.

6:04

And on the real pull requests? The browser checks exposed none of the seventeen UI bugs. A new column or badge is on a screen nobody wrote a check for.

6:1506 · What’s left for review

6:16

Back to the price. With every check that can fail a build on its default settings, sixty-nine percent of clean pull requests are blocked.

6:25

Cut down to the eleven rules that exposed a bug, plus the tests, it’s twelve percent. And still the same nineteen bugs exposed.

6:34

But I chose those rules after seeing the results. So that’s the best case, not what a team would get on new pull requests.

6:42

And the AI reviewer from part three? Its recall, the share of bugs it finds, is the same on what the tools leave as on all of them: sixty-six, eighty and eighty-eight percent, for its three budgets.

6:56

The tools take a thin slice: conventions, unused code, names that don’t exist. The reviewer finds those just as often as the rest, so the tools don’t take its easy finds. They catch a few for free.

7:10Back to Valentina

7:11

So, should tools catch it first? Yes, for what they’re good at. They’re free, they never get tired, and they take work off the reviewer.

7:19

But measure every rule: what it catches against what it blocks. Keep the few that earn their place, or run the rest on new code only. And when a check is flaky, fix the cause.

7:31

What this can’t tell me: on a codebase with no types and no tests, tools would probably catch more. These bugs were written to pass the build, and to be found by reading. And the labels are from an AI.

7:44

Next: making the pull request itself easier to review.

7:48Summary

7:49

Catch what’s free, block as little as you can, and measure both.Valentina: Thanks for watching!

Key takeaways

  • ✓Give every check two numbers: the planted bugs it catches (of 173) and the clean PRs it would block (of 77). A check that turns the build red on good PRs gets switched off, like a smoke alarm that goes off for toast.
  • ✓Count only what the PR adds. Run each check on the PR and on its base (the code it starts from), and keep the new findings, matched by rule, file and message, not by line. Healthy main already has 85 ESLint findings.
  • ✓A flag near a bug isn't a find. 28 bugs had a new finding within 3 lines; an AI labelled 19 of them as exposed (fixing what the tool says fixes the bug or leads straight to it). Conventions were the best covered, 6 of 15; logic, security and UI bugs: 0.
  • ✓With default rules, the nine checks that can fail a build would block 53 of 77 clean PRs (69%). ESLint alone blocks 39, mostly through a few strict typing rules that raised 305 new warnings on clean PRs and exposed no bug. Cut to the 11 rules that exposed a bug, plus the tests: 9 of 77 (12%), the same 19 exposed. That cut was chosen after seeing the results, so it's a best case.
  • ✓Tests written before the PR only know the rules they were written for. Property tests caught 4 bugs, all in PRs meant to fix one of their rules, and failed 2 clean PRs that changed a rule on purpose. The contract test caught none of the 18 contract bugs: they're about a field, error code or column the PR adds.
  • ✓Mutation testing changes one line the PR adds and reruns the PR's own tests; a survivor means no test pins that line. Survivors sat near 44 bugs, but also on 45 of 77 clean PRs. Use it as a pointer, not a gate.
  • ✓A deterministic check is flaky if it reads the clock. A screenshot diff flagged 19 of 19 runs of an unchanged page; masking the times still flagged 19 of 19, because the hidden text still set the cell's width. Fixing the browser's clock: 0 of 19.

Before anyone reviews a pull request, free tools can look at it: stricter types, linters, a security scanner, a secret scanner, and tests that run on every PR. This chapter turns on ten of them and runs them on all 250 PRs of the test set. The nine that can fail a build exposed 19 of the 173 planted bugs, about one in nine. With their default settings, they'd block 69% of the clean PRs. So are tools useless for code review? Not quite. But every check has to earn its place.

The source is Lab 05 of the code-review labs, "Let Tools Catch It First", recorded in October 2026: scripts 01_static.py (types, lint, Semgrep, secrets), 02_tests.py (property, contract and mutation tests), 03_browser.py (browser flows and screenshots) and 04_what_is_left.py (all checks together, and the AI reviewer on what's left). Every check is a real tool run on the corpus; the lab makes no model calls. Two things are AI: the labels of which catches expose a bug (an AI subagent read each one), and the reviewer in the last section, the AI stand-in from Chapter 3. No person reviewed these PRs. The PRs are the testbed from Chapter 1: Harbor, a made-up data-sync app (a GraphQL API, a Python worker and a web UI), with 173 PRs that carry one planted bug each and 77 clean twins, the same changes without the bug.

How the PRs are named. Each pull request has an id like c25-d1. The first part is the change: c25 is one feature, reading the minimum schedule from a setting instead of hard-coding 5 minutes. (c changes come from Harbor'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.

Catches against blocks

A deterministic check gives the same answer for the same code. It costs nothing per run, and it never gets tired. But a check that turns the build red on good PRs is like a smoke alarm that goes off for toast: people take the battery out, or learn to override it. So every check gets two numbers:

  • Bugs caught: of the 173 planted bugs.
  • Clean PRs blocked: of the 77 clean PRs, how many the check would turn red if it were required.

And only new findings count. Healthy main already has findings; ESLint reports 85 on it, mostly loose types. A team adopting a check fixes those once or checks only new code. So each check runs on the PR and on its base, the code the PR starts from, and keeps only what the PR adds. A finding is matched to the base by rule, file and message, not by line, because a PR moves lines.

The ten checks:

Check Tool What it adds over Harbor's CI
tsc TypeScript 5.9, stricter flags unchecked index access, unused locals and parameters, implicit returns
eslint ESLint 9, type-aware unsafe any, floating promises, non-null !, and Harbor's two written conventions
ruff ruff 0.14 pyflakes, bugbear, bandit, pylint, simplify
mypy mypy --strict the worker's types
semgrep Semgrep, p/default (1,073 rules) security and correctness patterns
secrets detect-secrets 1.5 keys and tokens anywhere in the repo
property Hypothesis, 6 properties rules that should always hold, written on main
contract API → database → worker → API one fixed round trip, written on main
browser Playwright, Chromium the main flows and screenshots
mutation the testbed's mutants (Chapter 2), the PR's own tests every line the PR adds, changed one way at a time

Every check

A check flags near a bug when the buggy PR has a new finding within 3 lines of the bug that the bug's clean twin doesn't get. For a test, it's simpler: it fails on the buggy PR and passes on the clean one.

Check Flags near a bug (of 173) Exposes it Would block a clean PR (of 77) Median s per PR
tsc 4 3 5 (6%) 1.6
eslint 11 8 39 (51%) 2.9
ruff 7 2 13 (17%) 0.0
mypy 2 2 4 (5%) 0.9
semgrep 2 1 2 (3%) 7.8
secrets 0 0 1 (1%) 2.6
property 4 4 2 (3%) 1.3
contract 0 0 0 0.4
browser 2 2 1 (1%) 1.7
mutation 44 not labelled 45 (58%) 9.4

Most checks flag a handful of bugs. Look at ESLint: it flags near 11 and would block 39 of the 77 clean PRs, half of them. 37 of those 39 get a warning from a few strict typing rules (no-unsafe-*), which flag every use of an untyped GraphQL result, something Harbor's code does everywhere. On clean PRs those rules raised 305 new warnings and exposed no bug at all. The secret scanner found nothing, because no planted bug was a leaked secret; its one block is a fake password in a test.

Try turning checks on and off. The presets are the lab's own runs:

Try it · Build your gateLab 05 · 173 planted bugs, 77 clean PRs · recorded runs

Turn checks on and off. A gate is a check that can fail the build. Only findings the PR adds count. Blocked: a clean PR (no planted bug) gets at least one new finding or failing test.

Lint and type rules:
Flagged near (of 173)
28
Exposed (of 173)
19
Clean PRs blocked (of 77)
53 · 69%
CI time per PR, in a row
19 s

Exposed, by type of bug

logic0/31
contract2/18
security0/16
reliability3/23
performance2/21
ui0/17
tests2/11
convention6/15
ai-shaped4/21

Most of ESLint's blocks come from a few strict typing rules (no-unsafe-*): 305 new warnings on clean PRs, and no bug exposed.

Flagged near: a new finding within 3 lines of the bug that its clean twin doesn't get (for a test: fails on the buggy PR, passes on the clean one). Exposed: an AI labelled the catch as pointing at the bug itself. CI time adds each check's median seconds per PR.

Flagged near isn't found

A flag near a bug isn't a find. In Chapter 3, a review comment on the right line could be about something else. Tools do that too: a style rule can fire on the bug's line and say nothing about the bug. So an AI read every catch and labelled whether it exposes the bug: fixing what the finding says fixes the bug, or leads straight to it. Otherwise it's just nearby.

This one exposes: the type checker says a parameter called now is never used. That's the clock the code should have used, instead of the real time. This one doesn't: on the testbed's bug where the batch-size setting is never loaded, ruff suggests a rewrite with row.get(), which wouldn't even work on this kind of database row. Judge a few yourself:

Try it · Flagged near, or found?Lab 05 · 8 of the 34 labelled catches

Each finding is new in the PR and within 3 lines of a planted bug. Read the bug and the message. Would fixing what the tool says fix the bug, or lead straight to it?

tsc · TS6133api/src/repo/runs.ts:58

“'now' is declared but its value is never read.”

The bug: A run's finish time is written with the machine's clock and toISOString(), so it ignores the clock passed in and comes back with milliseconds, unlike every other timestamp.

ruff · SIM401worker/harbor_worker/models.py:32

“Use `row.get("batch_size", None)` instead of an `if` block”

The bug: load_sync checks `"batch_size" in row`, which searches a sqlite3.Row's values, not its column names, so the batch size is always None. (Chapter 1's "setting never loaded" bug.)

ruff · F821worker/harbor_worker/schedule.py:16

“Undefined name `log`”

The bug: The invalid-value branch calls log.warning, but no `log` exists, so a typo in the minimum-schedule setting crashes the scheduler instead of falling back to 5.

ESLint · prefer-nullish-coalescingapi/src/repo/syncs.ts:41

“Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.”

The bug: Resuming a sync stores an empty string instead of NULL, so the API says the sync is active while the worker never schedules it again.

ESLint · react/jsx-no-literalsweb/src/components/DeleteSync.tsx:31

“Strings not allowed in JSX files: "Keep it"”

The bug: The cancel label is written into the component instead of copy.ts, so it can't be changed or translated with the rest of the UI text.

ruff · TRY003worker/harbor_worker/destinations/webhook.py:26

“Avoid specifying long messages outside the exception class”

The bug: A permanent webhook error is re-raised with the request headers in its message, so the partner's token ends up in error text, logs and the run's error column.

Semgrep · detect-non-literal-regexpweb/src/filtering.ts:7

“RegExp() called with a `query` function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) …”

The bug: The search box's text is turned into a regular expression, so typing ( or [ throws and takes the whole sync list down.

Semgrep · formatted-sql-queryworker/harbor_worker/runner.py:44

“Detected possible formatted SQL query. Use parameterized queries instead.”

The bug: Rows with a NULL key are counted with a second SELECT over the whole source table, so every run scans the table twice.

You agree with the label
0 of 0
Bugs flagged near (all gates)
28
Exposed
19

Labels by an AI subagent reading the code: of 34 catches, 22 expose their bug and 12 are just nearby. Treat them as one reader's call, not ground truth.

Of the 34 catches labelled, 22 exposed their bug and 12 were nearby. Counted by bug: 28 bugs had a flag nearby, 19 were exposed (11%, 95% interval 6–17%). By type:

Type Bugs A gate flags near it A gate exposes it + a mutant survives near it
logic 31 0 0 7
contract 18 3 2 7
security 16 2 0 4
reliability 23 4 3 12
performance 21 4 2 7
ui 17 1 0 3
tests 11 3 2 5
convention 15 6 6 7
ai-shaped 21 5 4 10
all 173 28 19 62

Conventions are the best covered: 6 of 15, from Harbor's two written rules ("throw a HarborError", "UI text lives in copy.ts") and unused variables. Other exposed catches: code that can't run (an undefined log, an attribute that doesn't exist, in branches CI never ran), an unused counts that an N+1 query bypassed, a forbidden non-null ! that crashes on an unknown id, and a search box that builds a regular expression from the user's text, so typing ( takes the list down. Logic, security and UI bugs: none at all.

Tests written before the PR

The property, contract and browser tests were written once, on healthy main, the way a team writes tests before any of these PRs exist.

A property test checks a rule that should always hold, on many generated inputs: for example, every record is sent once, in order, within the batch limit. The property tests caught 4 bugs: a failed batch counted as 1 row instead of its size, a backoff that still waits after the last attempt, days counted as 60 minutes, and a mapper that crashes on a dropped column. All four are in PRs meant to fix one of these rules: the clean fix passes, the buggy one doesn't. They also failed 2 clean PRs, which change a rule on purpose (c16, which stops sending email subscribers who have no address, and c25, which makes the minimum schedule a setting). A property is a promise. When a PR changes the promise, the test has to change with it, and a red build is the right prompt.

The contract test runs one fixed round trip: the API creates a sync, the worker runs it, the API reads it back. It caught none of the 18 contract bugs, where two parts disagree on a name or a shape. Take Chapter 4's bug, where the API saves the key default and the worker reads defaultValue. The contract test passes, because the mappings it creates have no default at all: it was written before that field existed. The other contract bugs are about a new error code, a new column, or inputs the test never uses.

The browser flows did the same: they caught 2 bugs, both contract bugs that break the whole list (the web asks for a field the API doesn't have), and none of the 17 UI bugs. A new column or badge is on a screen nobody wrote a check for. A test only knows the rules it was written for.

Testing the tests

Mutation testing tests the tests. It makes a mutant: one line the PR adds, changed one small way, say < into <=, or a statement deleted. Then it reruns the PR's own tests. If they still pass, the mutant survived: no test pins that line.

Across 2,937 mutants on 241 PRs, survivors sat near 44 of the 173 planted bugs (a quarter) that the clean twin didn't have. But they also sat on 45 of the 77 clean PRs (58%). As a gate, it would block most of them. As a pointer that says "look here", it's a hint: survivors sat near 7 logic bugs, a type no gate exposed. Nobody checked whether those survivors point at the bug itself. It's also the slowest check: 102 minutes of test runs for the corpus, 10 at a time.

Screenshots

A screenshot diff takes a picture of the page in a browser and compares it with the picture from the base. Here, any pixel off by more than 16 of 255 in a colour channel flags the page.

First, how noisy is that? The lab took the same page 20 times, moving the browser's clock 6 hours each time, and compared each run with the first. Nothing else changed. Every run was flagged: the page shows times like "30 minutes ago", and those change. So even a deterministic check is flaky if it reads the clock. Masking the times still flagged every run, and the largest change got slightly bigger:

Try it · A flaky screenshotLab 05 · same page, 20 runs, clock moved 6 h each
Show:
The sync list, relative times masked, run 1

The lab's own screenshots, cropped to the table. Switch runs and watch the “Last run” header and the pink mask.

Runs flagged (of 19)
19
Largest change, share of pixels
0.20%

The mask hides the text's pixels, not its width. "Succeeded 30 minutes ago" and "Succeeded 1 day ago" are different widths, so the masked box grows and shrinks and the column around it moves. The largest change got slightly bigger.

Each run compared with the first; any pixel off by more than 16 of 255 in a channel flags the page.

The text under the mask still sets the cell's width, so the box grows and shrinks and the last-run column shifts. Fixing the browser's clock (Playwright's page.clock) removed the cause: none flagged.

On the real PRs, with a fixed clock, screenshots didn't help either: no UI bug's page differed from its clean twin's (0 of 17). When the page differs from the base, it's because the feature changed it, and only someone who knows what the page should show can tell the bug from the feature.

What's left for review

Back to the price. With every check that can fail a build on its default settings, 53 of 77 clean PRs are blocked (69%), for about 19 seconds of checks per PR run one after another. Add mutation testing as a gate and it's 82%.

Cut down to the 11 rules that exposed a bug, plus the tests, it's 9 of 77 (12%), still exposing the same 19 bugs. But those rules were chosen after seeing the results. That's the best case, not what a team would get on new PRs.

And the AI reviewer from Chapter 3? Its recall, the share of planted bugs it finds, at each of its three budgets (quick, standard, careful: which model, and how hard it thinks):

Budget All 173 bugs The 19 the tools expose What's left (154)
quick 66% 13 of 19 (68%) 66% (57–74%)
standard 80% 15 of 19 (79%) 80% (74–86%)
careful 88% 17 of 19 (89%) 88% (82–92%)

Recall on what the tools leave is the same as on all of them. The tools take a thin slice: conventions, unused code, names that don't exist. The reviewer finds those just as often as the rest, so the tools don't take its easy finds and don't make it less useful. They catch a few for free, before any review, and those never cost a review comment. With 19 bugs, "the same" means no sign of a difference, not a proven equality.

Also in the lab

From the lab's README and checklist answers (its own run, October 2026), beyond the video:

  • Screenshots on PRs. The list page differed from the base on 6 of 20 clean PRs that touch the web app, 0 of 57 that don't, 5 of 17 with a UI bug and 12 of 156 with another bug.
  • Weak tests and missed bugs. Splitting changes at the median mutation score of their clean PR (85%), the stand-in's recall was 67% vs 67% (quick), 76% vs 84% (standard), 88% vs 87% (careful): no consistent relation, with intervals about ±9 points.
  • Tests bugs. For the 11 bugs that weaken a test so the bug passes, the buggy PR's mutation score dropped below its clean twin's on 4. On the daily-schedule fix with days counted as 60 minutes and the test's daily cases deleted (c08-d1), it went from 100% to 0%.
  • What went wrong while building it. The first contract test compared whole objects and blocked 2 clean PRs that added a mapping field; it now compares the fields main has, because additive changes aren't broken contracts. The secret scanner first flagged a hash in mypy's cache inside the checkout; caches now live outside. The first browser flow failed on healthy main, and a test that fails on main is a broken test.
  • Cost. No API calls. Tools take about 800 MB to install; mutation testing is most of the run time.

What to do

  • Measure every check on two numbers, bugs caught and clean PRs blocked, before making it required.
  • Count only new findings: compare with the base, or use the tool's baseline file.
  • Read the catches. A finding near a bug isn't a find until fixing what it says fixes the bug.
  • Keep the few rules that earn their place, and run the rest on new code only, or as warnings.
  • Write tests with the PR. Tests written earlier can't see a new field, error code or screen.
  • Use mutation testing as a pointer to thin tests, not as a gate.
  • When a check is flaky, fix the cause. Fix the clock instead of masking the pixels.

Caveats

  • The bugs were written to pass the build and to be found by reading. On a codebase with no types and no tests, tools would probably catch more.
  • The "exposes" labels are from an AI. Relabel before quoting; the video's reviewer called the two browser catches borderline.
  • The cut-down gate is a best case. Its 11 rules were picked after seeing which ones exposed a bug here.
  • No gate was enforced. "Would block" means a clean PR got a new finding or a failing test.
  • The reviewer is a stand-in. The recall numbers are Chapter 3's AI model, not people, from one run.
  • One machine. A fixed clock made screenshots stable on one machine; a CI fleet with different fonts may not be.

The checklist

  1. Run each candidate check on your recent PRs and their bases, and keep new findings only.
  2. Count, per rule, bugs it caught and clean PRs it would have blocked.
  3. Label the catches: does fixing the finding fix the bug, or is it just nearby?
  4. Require only the rules that catch more than they block; demote the rest to new-code-only warnings.
  5. Ask for tests with each PR that changes a rule, a field, an error or a screen; update properties when the promise changes.
  6. Report surviving mutants to the reviewer as "no test pins this line", not as a failure.
  7. Pin the clock (and other inputs) in screenshot and browser tests before trusting their diffs.

Practice: the scoring in code

Write the four pieces the lab's numbers rest on: keep the findings a PR adds, decide when a finding flags near a bug, price a set of required checks on the recorded per-PR results, and the screenshot diff. The tests expect the lab's numbers: 19 exposed and 53 of 77 blocked with every gate, 39 for ESLint alone, 9 after the cut, 82% with mutation testing, and a shrinking mask that still flags.

Try it · Practice in PythonRuns in your browser · ⌘/Ctrl + Enter to run
tools_practice.py60 lines

Quiz

Try it · Check your understanding0 of 6 answered
  1. 1.Why run every check on the PR's base as well as on the PR?

  2. 2.ESLint flagged 11 planted bugs and would block 39 of 77 clean PRs. What does the lab suggest?

  3. 3.Ruff flags a line next to the bug where 'batch_size in row' searches a database row's values, not its column names. It suggests row.get(...). Has it caught the bug?

  4. 4.A property test written on healthy main fails on a clean PR. Is it a false alarm?

  5. 5.Surviving mutants sat near 44 of 173 planted bugs and on 45 of 77 clean PRs. How should you use mutation testing?

  6. 6.Your screenshot diff flags an unchanged page. You mask the relative times and it still flags every run. Why, and what fixes it?

Check your understanding

Try each question before opening its answer.

Why does every check need two numbers, and what are they?

Bugs it catches (here, of 173 planted) and clean PRs it would block (of 77). A check that blocks good PRs gets switched off or overridden, so catching bugs isn't enough: ESLint flagged 11 bugs and would block 39 clean PRs.

Why compare each PR with its base, and why not match findings by line?

A stricter check also finds problems already on main (ESLint: 85), which aren't the PR's fault. Only what the PR adds counts. Findings are matched by rule, file and message, because a PR moves lines around.

A tool finding lands on the bug's line. Has the tool caught the bug?

Not necessarily. It exposes the bug only if fixing what it says fixes the bug or leads straight to it. 28 bugs were flagged nearby, 19 exposed: a "use ??" on a resume bug that ?? doesn't fix, SQL-injection warnings on a query whose bug is a second full-table scan.

Why did tests written on healthy main catch so little?

A test only knows the rules it was written for. Property tests caught 4 bugs, all in PRs meant to fix one of their rules. The contract test caught none of 18 contract bugs, which are about a field, error code or column the PR adds; the browser flows caught no UI bug, which sit on screens nobody wrote a check for.

Is mutation testing worth running?

As a pointer, yes: survivors sat near 44 bugs, including 7 logic bugs no gate exposed. As a gate, no: survivors were on 45 of 77 clean PRs. Use it to tell a reviewer where no test pins the code.

Your screenshot diff keeps flagging an unchanged page. What do you do?

Find the cause. Here it was the clock: relative times changed. Masking them still flagged 19 of 19 runs, because the hidden text still set the cell's width. Fixing the browser's clock: 0 of 19.

Tools exposed 11% of the bugs. Are they worth it, and do they change the AI reviewer's value?

Yes, for what they're good at: cut to the rules that exposed something, they'd block 12% of clean PRs (a best case) and cost seconds. The AI reviewer's recall on what they leave is the same as on all bugs (66, 80, 88%), so tools don't take its easy finds; they catch a few for free.

Next up: Chapter 7 pulls the other lever: making the pull request itself easier to review, by splitting it, reordering it and adding a walkthrough.

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.