Key takeaways
- ✓Route by tiers, not yes or no: auto-approve (the checks still run, nobody reads), an AI review with a quick human look, a full review, and two reviewers by rule for migrations, the schema and input validation. Every "person" here is Chapter 3's careful AI stand-in, and review minutes are a formula.
- ✓Set the budget before you look at thresholds, and make it two numbers: a rate (at most 2 escaped bugs per 100 PRs) and a rule (no high-severity bug auto-approved). Here they disagree: the rate allows 30% auto-approve with the best score, the rule allows none.
- ✓Ask whether a signal can tell a buggy PR from its clean twin. Paths, packages and importers are identical for twins, so within a change they score exactly 0.50, a coin flip. Only signals that read or run the code see the bug: the quick AI stand-in's bug comments score 0.77 against the twin, the free checks 0.57.
- ✓A learned score (0.76) mostly learned to trust the AI pre-review (weight +1.14 per standard deviation, everything about paths and size near zero). Without that signal it falls to 0.61. Put a cheap AI pre-review in front of the router and weight it heavily.
- ✓A score earns its keep against chance: auto-approving 30% of the ranked PRs, 14 buggy PRs slip through unread with the learned score, 20 with size alone, 25 with a random router. At a 1-in-10 bug rate that's about a third of all PRs auto-approved, within 2 per 100.
- ✓Your bug rate moves the answer as much as the score does. At 1 in 20, the learned score can auto-approve at least half of all PRs within budget; at 1 in 5, nothing fits, and even full review everywhere lets 2.1 per 100 through. Measure it before you set a threshold.
- ✓A router built on shape rewards splitting. When Chapter 7's agent split PRs into stacks, bugs on the auto-approve path went from 1 to 11 of 68, and 23 left the two-reviewer path because the migration moved to another part. Score each part with the whole stack's signals and give it the stack's tier.
Not every pull request needs a person to read it. A typo fix in a test probably doesn't; a database migration probably does. So teams want a router: a rule that sends each pull request (PR) to the right depth of review, and lets the safest ones through without anyone reading them. This chapter builds one from a risk score, runs all 250 PRs of the test set through it, and counts the bugs that get through. The main finding: the signal that tells a buggy PR from a safe one is a cheap AI pre-review, not the PR's size or paths. And a router that trusts size can be fooled by splitting a PR, with nobody trying to fool it.
The source is Lab 08 of the code-review labs, "Not Every PR Needs a Human", recorded in October 2026: scripts 01_signals.py (which signals say risky), 02_score.py (a hand-set score and a learned one), 03_route.py (route every PR, count what gets through) and 04_gaming.py (the same PRs split into stacks). The lab makes no model calls: every review, check and verdict comes from earlier labs (Chapters 1–7). And no person reviewed anything. "A person" here is Chapter 3's AI stand-in at its careful budget, and review minutes are a formula. The PRs are the testbed from Chapter 1: Harbor, a made-up data-sync app, 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 n19-d1. The first part is the change: n19 is one feature, skipping records that haven't changed since the last run. (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; so n19-clean and n19-d1 are the same feature, without and with planted bug 1.
A score that looks sensible, and a bug that skips review
Start with the story the video opens with. n19-d1 is the skip-unchanged-records feature with a serious bug: the worker saves its "already delivered" state whenever anything was sent, so records from a batch that failed are remembered as delivered and never sent again. A simple risk score built from the PR's shape (its size, how much of it is tests, how many parts of the app it touches, which paths) gives it 5 points. It also touches a database migration, so a path rule sends it to two reviewers.
Now split the same change into a stack of two smaller PRs, the way Chapter 7's agent does. The part with the bug has no migration and is mostly tests. It scores −1, below the cut, and is auto-approved. Nobody reads it. Smaller looked safer. The rest of the chapter asks which signals actually tell a risky PR from a safe one, and comes back to this split at the end.
Four tiers and a budget
The router sends each PR down one of four paths. The lab simulates each person with an AI stand-in from Chapter 3:
| Tier | Who looks | Simulated here by |
|---|---|---|
| 0, auto-approve | nobody; the automatic checks still run | Chapter 6's cut-down gate only |
| 1, AI review + a quick look | an AI reviews, then a person skims for 3 minutes | the gate + the standard stand-in |
| 2, full review | one person | the gate + the careful stand-in |
| 3, two reviewers | two people, for migrations, the schema and input validation | the gate + careful + standard |
A score decides tiers 0–2 by rank: the lowest share is auto-approved, the top quarter gets a full review, the middle the AI review. Tier 3 is a rule, not a score: 110 of the 250 PRs touch a migration, the schema or validation and always get two reviewers. The other 140 are ranked.
Two placeholders matter. The careful stand-in found 88% of the planted bugs in Chapter 3, so "a person" here is as good as that; real people may be better or worse. The quick look is assumed to add nothing to the AI review. Minutes are changed lines at an assumed 500 lines an hour (a commonly quoted reading rate), with at least 5 minutes for a full review.
The budget is set before looking at any threshold, and it's two numbers:
- A rate: at most 2 escaped bugs per 100 PRs. An escaped bug is one no tier catches, not even a full review.
- A rule: no high-severity bug auto-approved, ever. 38 of the 173 planted bugs are high severity.
Set the budget afterwards and it becomes whatever the chosen threshold happens to give. Set first, it's a decision the team can defend.
Which signals say risky?
The lab computes eight signals per PR:
- Size: changed code lines.
- Test share: the share of changed lines that are tests.
- Packages: how many parts of the app it touches (the database, the API, the worker, the web app, the schema).
- Sensitive paths: migrations, the schema, validation, URLs and destinations (the code that sends data out).
- Importers (the lab calls it blast radius): how many files import the changed code.
- Unprotected lines: the share of mutants (small deliberate changes to a line the PR adds, from Chapter 2) that the PR's own tests let survive.
- Free checks: findings from Chapter 6's cut-down gate.
- AI pre-review: how many bug comments the cheapest AI stand-in (the quick budget from Chapter 3) left on the PR.
To compare signals, the lab uses one number, the AUC: pick a buggy PR and a clean one at random; how often does the signal rank the buggy one higher? Ties count half. 0.50 is a coin flip, 1.00 is perfect. A router only needs ranking, because tiers are cut by rank, so AUC is the right question.
The lab asks it twice. Once over all PRs, and once within a change: each buggy PR against its own clean twin (173 pairs).
| Signal | AUC, buggy vs clean (95% interval) | AUC against its clean twin |
|---|---|---|
| AI pre-review | 0.76 (0.69–0.82) | 0.77 |
| size | 0.58 (0.55–0.61) | 0.56 |
| unprotected lines | 0.58 (0.53–0.62) | 0.50 |
| free checks | 0.57 (0.54–0.60) | 0.57 |
| importers | 0.55 (0.52–0.58) | 0.50 |
| packages | 0.54 (0.51–0.56) | 0.50 |
| two-reviewer paths | 0.53 (0.50–0.55) | 0.50 |
| sensitive paths | 0.51 (0.49–0.54) | 0.50 |
| test share | 0.43 (0.40–0.46) | 0.42 |
The intervals come from resampling whole changes, since a change's versions aren't independent. Size, packages, importers and sensitive paths are all barely better than a coin flip, between 0.51 and 0.58. One signal stands out: the cheap AI pre-review, at 0.76.
The twin column says why. A buggy PR and its clean twin touch the same files, so they have the same paths, packages and importers. Those signals tie on every pair: exactly 0.50. They can say which changes would hurt if they had a bug; they can't find the buggy version. Size and test share move a little only because some planted bugs add a line or delete a test, a quirk of how the test set was built. Only signals that read or run the code can tell twins apart: the AI pre-review, and a little, the free checks. Switch the views:
AUC: pick a buggy PR and a clean one at random; how often does the signal rank the buggy one higher? 0.50 is a coin flip (the line), 1.00 is perfect.
Over all PRs, everything about the PR's shape is barely better than a coin flip (0.51 to 0.58). The cheap AI pre-review stands out at 0.76. The thin line is a 95% interval from resampling changes.
Sensitive paths saying almost nothing (0.51) is a finding about this app: Harbor's bugs are spread across the code, not concentrated in migrations and destinations.
A score from all signals
Next, the lab combines all eight signals, including the AI pre-review, in two ways:
- Points set by hand (the lab calls it the readable score), with weights written down before looking at any result, and a reason for every point. For example,
n38-d2(capping how many rows a sync sends per run, with the cap applied by loading the whole table into memory) gets 18 points: +2 for 70 code lines, +4 for 5 packages, +2 for a migration, +3 for 14 importers, +2 because its tests let 34% of mutants survive, +2 for a gate finding, +4 for 2 AI bug comments, −1 because half or more of it is tests. - A learned score: a logistic regression (a model that learns one weight per signal) fit on some families of changes and tested on others. Testing on a twin of a training PR would be testing on the training set, so whole families are held out.
| Score | AUC, on changes it never saw (95% interval) |
|---|---|
| size only | 0.58 (0.55–0.61) |
| points set by hand | 0.67 (0.64–0.71) |
| learned, without the AI pre-review | 0.61 (0.57–0.65) |
| learned | 0.76 (0.70–0.82) |
The learned score beats the hand-set points by +0.08 (+0.04 to +0.12). But look at what it learned. Its weights per standard deviation: AI pre-review +1.14, free checks +0.32, test share −0.18, unprotected lines +0.12, and everything about paths and size near zero. It leans mostly on the AI pre-review, and it's no better than that signal on its own (0.76). Without it, it falls to 0.61.
Some of what it learned is the test set, not risk. The negative weight on test share comes partly from planted bugs that delete a test. It's also exactly the signal an author controls: add test lines, get waved through.
Route every PR
Now route all 250. Auto-approve the lowest 30% of the 140 ranked PRs. How many buggy PRs slip through, unread?
| Router | Buggy PRs auto-approved (of 173) | High-severity among them (of 38) | Bugs escaping at any tier | Escaped per 100 PRs | Minutes per PR |
|---|---|---|---|---|---|
| random (mean of 50 shuffles) | 25.2 | 3.8 | 24% | 2.4 | 13.3 |
| size only | 20 | 4 | 22% | 2.2 | 14.0 |
| points set by hand | 19 | 3 | 21% | 2.1 | 13.3 |
| learned | 14 | 2 | 17% | 1.7 | 12.6 |
| no routing (everyone reviewed) | 0 | 0 | 10% | 1.0 | 16.6 |
A score earns its keep against chance. At the same share, the learned score sends 14 buggy PRs down the unreviewed path, size 20, a random router 25. Full review everywhere still misses 10% of bugs, the careful stand-in's misses, so routing adds escapes on top of a floor.
"Per 100 PRs" needs a guess: how many real PRs have a bug. The test set has a bug in 69% of its PRs; real teams have far fewer. So the lab measures the share of bugs that escape and converts it at an assumed prevalence, by default 1 PR in 10: escaped per 100 PRs = 100 × prevalence × escaped share. At 1 in 10, the learned score at 30% stays within the budget of 2, and about a third of all PRs (34%) are auto-approved, because the score mostly picks clean ones, with 24% fewer review minutes than no routing. The largest shares within the rate budget: 30% of the ranked PRs for the learned score, 20% for the hand-set points (19% of all PRs, 18% fewer minutes) and 20% for size only (16% of all, 14% fewer).
But the second rule, no high-severity bug auto-approved? No score meets it with any auto-approve at all. Even at 10%, one serious bug gets through with every score. Take the three that reach auto-approve with the hand-set points at 30%:
c02-d1: a fix that makes deleting a missing sync return an error also deletes the sync's destination when no other sync uses it, which nobody asked for.c08-d2: a fix that makes daily schedules run again writes its start time in the wrong timestamp format, which crashes the scheduler on its next tick.c35-d2: a fix that marks crashed runs FAILED updates every run of that sync, rewriting its whole history.
Each scores 1 point: small, mostly tests, outside the sensitive paths. They look as safe as any small change. In the whole test set, 16 of the 38 high-severity bugs sit outside the two-reviewer paths, and 11 outside every sensitive path. With no auto-approve at all, routing still saves 12–18% of the minutes by sending the middle of the ranking to the AI tier, at 1.1–1.2 escaped per 100 PRs.
Try every router and share:
110 PRs touch a migration, the schema or validation and always get two reviewers. The other 140 are ranked by a score: the lowest share is auto-approved, the top quarter gets a full review, the middle an AI review and a quick look. Budget, set first: at most 2 escaped bugs per 100 PRs, and no high-severity bug auto-approved.
Escaped bugs per 100 PRs, learned, 1 in 10 PRs buggy
✓ Rate: 1.7 escaped per 100 PRs is within the budget of 2.
✗ Rule: 2 high-severity bugs reach auto-approve.
Bugs escaping at any tier: 17% of 173 (no routing: 10%). Review minutes: 12.6 a PR against 16.6 with no routing (24% fewer).
Simulated: the AI review is the standard stand-in, a person the careful stand-in (88% of bugs in Chapter 3), two people both. Minutes are changed lines at an assumed 500 lines an hour. “Per 100 PRs” is the share of bugs that escape times the assumed bug rate; the test set itself has a bug in 69% of its PRs.
The bug rate matters
All of that assumed 1 PR in 10 has a bug. Change the guess and the answer changes:
| Bug rate | No routing, escaped per 100 PRs | Learned score: largest auto-approve within 2 per 100 |
|---|---|---|
| 1 in 20 | 0.5 | 70% of ranked PRs, the top of the sweep (50% of all PRs), 1.9 per 100 |
| 1 in 10 | 1.0 | 30% of ranked PRs (34% of all), 1.7 per 100 |
| 1 in 5 | 2.1 | none: even reviewing everything is over budget |
At 1 in 20, all three scores fit at the sweep's largest share, 70% of the ranked PRs; for the learned score that's half of all PRs. At 1 in 5, nothing fits. Your bug rate moves the answer as much as the score does. Measure it, from bugs traced back to PRs after merge plus what review finds, before you set a threshold.
Smaller looks safer
Back to the opening, and its shape score: size, test share, packages, paths and importers, without the AI pre-review (the free checks and the AI review would need re-running per part). Chapter 7's agent split 93 of the larger PRs into stacks, each part passing CI. 68 of those PRs hold a bug. With the cut that auto-approves 30% of the ranked PRs (a score below 0):
| Arrives as | Auto-approve | AI review + quick look | Two reviewers |
|---|---|---|---|
| whole PR | 1 (1%) | 23 (34%) | 44 (65%) |
| a stack, each part routed alone | 11 (16%) | 36 (53%) | 21 (31%) |
Routed whole, one of those bugs is auto-approved. Routed part by part, eleven are. And 23 bugs leave the two-reviewer path: the rule looks for the migration file, and the split put the migration in one part and the code that depends on it in another. For n19-d1, the whole PR (203 changed lines) scores 5 and goes to two reviewers because of its migration. Its second part, "Skip unchanged records and add forget-state CLI", is 143 lines: 16 code lines in runner.py and cli.py next to 127 lines of tests. It scores −1:
One change: skip records that haven't changed since the last run. Its planted bug (high severity): state is saved whenever anything was sent, so records from a failed batch are remembered as delivered and never sent again. The score here is shape only (size, tests, packages, paths, importers; no AI pre-review). Below 0 auto-approves.
- db/migrations.lock
- db/migrations/0004_sync_state.sql
- worker/harbor_worker/state.py
- worker/harbor_worker/runner.py← the bug
- worker/harbor_worker/cli.py
- worker/tests/test_skip_unchanged.py
Shape score
- +3 76 code lines
- +1 2 packages
- +2 touches a migration
- -1 63% of it is tests
= 5 points
→ two reviewers
It touches a migration, so the path rule sends it to two reviewers, whatever its score.
Where the 68 bugs in the 93 split PRs go: whole pr
Routed whole, 1 of the 68 bugs reaches auto-approve.
Nobody was cheating. The agent was making review easier: in Chapter 7, the AI stand-in found more bugs in the largest PRs when they arrived as stacks. The router read smaller as safer. The fix: a stack-aware router scores each part with the whole stack's signals (its total size, all its paths, the rule if any part triggers it) and gives every part the stack's tier. That's the "whole PR" row: splitting stops changing routing, and reviewers still get the smaller parts. It needs tooling that knows which PRs form a stack; independent small PRs for one feature are a stack the router can't see.
Which signals survive splitting? The ones about behaviour, not shape. The free checks and the AI review run per part and still see the bug.
Also in the lab
From the lab's README and checklist answers (its own run, October 2026), beyond the video:
- High-severity bugs by signal. They touch more packages (2.4 against 1.8 for clean PRs) and sit in the two-reviewer paths more often (58% against 40%), but not reliably enough for a path rule to protect them.
- At 50% auto-approve with the hand-set points, six high-severity bugs reach auto-approve: the three above, plus two webhook security bugs (a partner token leaked in an error message, and the signing secret sent in clear when no token is set) and an uncapped Retry-After that can make the worker sleep for a day.
- A zero target needs an interval. 0 of 38 high-severity bugs escaping in this test set is consistent with up to 9% (95% interval 0–9%).
- A stronger pre-review is the obvious next step: the careful stand-in found 88% of bugs against the quick one's 66%, at about 3.4¢ a PR (3.36¢ in Chapter 3). The lab leaves it as an exercise.
- What went wrong while building it. Importers first ignored files the PR also changed, so
runner.pyimporting a changedstate.pycounted for nothing; it now counts every importer but the file itself. The roadmap's "author" signal was dropped: every PR has the same author, an agent. Chapter 5's proofs ran on a 40-PR sample only, so they can't route 250 PRs. And the plan was to pick one threshold per score, but the rule and the rate disagree, so the lab reports both.
What to do
- Write the budget down first: a rate of escaped bugs per 100 PRs, and a rule for what may never be auto-approved.
- Measure your bug rate before converting "share of bugs that escape" into "per 100 PRs".
- Test every signal against twins or close equivalents: does it see the bug, or only the PR's shape?
- Put a cheap AI pre-review in front of the router, and weight it heavily in a score you can read.
- Compare every router with a random one at the same auto-approve share.
- Score stacks, not parts, and make path rules follow the stack, not the file.
- If a serious bug must never get through unread, don't auto-approve, or find a signal that sees those bugs.
Caveats
- The reviewers are AI stand-ins. "A person" is the careful stand-in, the quick look is assumed to add nothing, and nobody measured what real people catch.
- Minutes are a formula: changed lines at an assumed 500 an hour. Tests are most of the changed lines and people read them faster, so the minutes are a sketch.
- The bug rate is a guess. Every "per 100 PRs" depends on it, and real bugs may score differently from planted ones.
- Twins are artificial. Real PRs don't come in pairs, but twins isolate the question cleanly: does the signal see the bug, or the PR's shape?
- One run, one test set. The learned weights partly fit how this test set was built, such as planted bugs that delete a test.
- The gaming result uses the shape score. A score with the AI pre-review would need the pre-review re-run per part, which the lab didn't do.
The checklist
- Set the budget: escaped bugs per 100 PRs, and which bugs may never be auto-approved.
- Estimate your bug rate from bugs traced back to merged PRs, plus what review finds.
- Compute AUC per signal, overall and, where you can, against near-identical clean changes.
- Build a readable score around the signals that see the bug, with a reason for every point.
- Sweep the auto-approve share and count escaped bugs, high-severity ones and minutes, against a random router.
- Pick the largest share that meets both budget numbers, or none.
- Route stacks as a whole, and recheck routing when your PR habits change.
Practice: the router in code
Write the pieces the lab's numbers rest on: the AUC, the AUC against each PR's clean twin, the hand-set points (and their shape-only half), the tier rule, and the conversion to escaped bugs per 100 PRs. The tests use the lab's recorded signals for all 250 PRs and expect its numbers: 0.76 for the AI pre-review overall and 0.77 against the twin, 0.50 for importers against the twin, 18 points for the row-cap PR, and 5 → −1 for the split PR.
Quiz
1.Why set the escaped-bug budget before choosing an auto-approve threshold?
2.Within a change, a buggy PR and its clean twin get the same number of importers. What AUC does that signal score against the twin, and why does it matter?
3.The learned score reaches AUC 0.76. What did it mostly learn?
4.Auto-approving 30% of the ranked PRs, how many buggy PRs slip through unread with the learned score, size alone and a random router?
5.A team auto-approves with the learned score and wants no high-severity bug to reach auto-approve. What does the lab say?
6.Chapter 7's agent split a PR that touches a migration into a stack of two. The part with the bug has no migration and scores −1. What happens, and what fixes it?
Check your understanding
Try each question before opening its answer.
What are the four tiers, and who stands in for the people?
Auto-approve (the checks run, nobody reads), an AI review plus a quick human look, a full review, and two reviewers by rule for migrations, the schema and validation. No person reviewed anything: the AI review is the standard stand-in, "a person" is the careful stand-in (88% of bugs in Chapter 3), and minutes are changed lines at an assumed 500 an hour.
Why does the number of importers score exactly 0.50 against the clean twin, while the AI pre-review scores 0.77?
Importers are a property of the files, and a buggy PR touches the same files as its clean twin, so the two always tie. The AI pre-review reads the code, and the planted bug changes the code, so it can comment on one twin and not the other.
The learned score beats the hand-set points by 0.08 AUC. Would you deploy it?
Not as learned. It mostly learned to trust one signal, the cheap AI pre-review, and it's no better than that signal alone (0.76). Some of its other weights fit how the test set was built. Deploy the insight instead: an AI pre-review in front of the router, weighted heavily, in a score you can read.
At 30% auto-approve, the learned score lets 14 buggy PRs through and a random router 25. What does the score buy, and what doesn't it?
It buys a better choice of which PRs skip review: 11 fewer bugs on the unreviewed path, and 1.7 instead of 2.4 escaped per 100 PRs at a 1-in-10 bug rate. It doesn't buy safety: 14 still get through, 2 of them high-severity.
Why report escaped bugs per 100 PRs at an assumed bug rate instead of measuring it on the test set?
69% of the test set's PRs have a planted bug; real PRs have far fewer. The share of bugs that escape is a property of the router; per 100 PRs is that share times the bug rate. At 1 in 20 the learned score fits with half of all PRs auto-approved; at 1 in 5 nothing fits.
No score kept every high-severity bug off the auto-approve path. What would?
A signal that sees the bug rather than the PR's shape, such as a stronger AI pre-review, or less auto-approve. The serious bugs that got through, like a sync deletion that also deletes its destination, were small, mostly tests and outside the sensitive paths.
Splitting PRs moved 10 more bugs to auto-approve. Was the agent gaming the router?
No. It was making review easier and never saw the router. But a router that reads smaller as safer rewards splitting, and a path rule that follows files loses the migration when it moves to another part (23 bugs left the two-reviewer path). Score the stack, not the part.
Next up: Chapter 10, automation bias: when an AI reviews first, do people trust it too much, and miss what it missed?