Key takeaways
- ✓Recall is the share of the bugs a reviewer finds: find 6 of 10 and recall is 60%. On a real team you can't compute it, because you never learn how many bugs there were. A review testbed plants the bugs on purpose and writes the answer key first, so the bottom of the fraction is known.
- ✓Every PR, clean or buggy, must pass CI. A PR with red CI never reaches a reviewer: the author fixes it first. So a planted bug only counts if CI stays green with it; that's the part of quality left to review.
- ✓Start from a healthy main. Harbor as it came failed all 18 tests of the tasks the lab took, 12 of them because of real bugs. A reviewer who spotted one of those would be scored as a false alarm, so the lab first applied the 18 fixes, one commit each, and built every PR on that.
- ✓One bug up close: a PR that adds a per-sync batch size (c20), with a bug planted that caps the setting at the destination's default with min() (c20-d1). The PR's own test asks for batches of 4, below the CRM's 100, so it passes. A hidden test sends 250 records at 200 and expects 200, then 50; the buggy version sends 100, 100, 50.
- ✓Each bug comes with a card (type, severity, what goes wrong, which lines) and a hidden test, the oracle, that passes on the clean PR and fails on the buggy one. The reviewer never sees it. Every change also has a clean twin, so a reviewer who flags everything is caught by its false alarms.
- ✓The test set: 77 changes in 58 families, 250 PRs (77 clean, 173 with one planted bug) across nine kinds of bug. 86% are under 200 changed lines, and 60% of the changed lines are tests. Five checks pass on every PR they apply to: CI 250/250, own tests 77/77, clean vs hidden tests 77/77, buggy vs hidden test 173/173, bug inside the diff 173/173.
- ✓Writing the bugs found four real bugs in the clean PRs, all with green CI, two of them in patches reworked by hand. Two are fixed; two stay as known issues, so a reviewer who flags them is scored as right.
How good is your code reviewer, a person or an AI? To answer that, you need to know how many bugs it missed, and on real pull requests you never do. This chapter builds the thing that makes the question answerable: a review testbed, a set of pull requests where every planted bug is known in advance, with an answer key written before anyone reviews.
The source is Lab 01 (The Review Testbed) of the code review labs, and the video is part 1 of "Hands-on AI code review". This chapter covers the testbed itself: healthy main, how one planted bug gets past CI, changes and their clean twins, the test set, and the checks on the answer key. The scripts are 00_setup.py (healthy main), 01_tour.py (the test set and one answer key), 02_check_answer_key.py and answer_key.py (the five checks), and pr.py (a PR the way a reviewer sees it). The same lab's mutation testing and "is 173 bugs enough?" are Chapter 2. The numbers come from the lab's recorded run (October 2026); nothing in this lab calls an AI model, and it's free to run.
Some words first
- Main is the shared version of the code.
- A pull request (PR) is a proposed change to main.
- CI (continuous integration) runs the tests and other automatic checks on every PR.
- Code review is someone, a person or an AI, reading the change and commenting on anything that looks wrong.
Tests only check the cases someone thought of. A reviewer can catch the rest. With AI writing more and more of the code, and an AI reviewer commenting on every PR, the question is how good that reviewer is.
Why plant bugs?
The number to measure is recall: the share of the bugs a reviewer finds. If the PRs hold 10 bugs and the reviewer finds 6, recall is 6 out of 10: 60%.
On a real team you can't count that. You hear about a missed bug only when it breaks something, and the ones that never break, you never hear about. Nobody knows the bottom of the fraction.
Airport security has the same problem, so inspectors hide a test item in a bag on purpose: they know it's there, so they know when it's missed. A review testbed does that for code: bugs planted on purpose, and an answer key written first.
Harbor, the practice app
Every PR changes one small practice app, Harbor (taken from Lab 01 of the coding-agent labs). Companies keep their data in a warehouse: big tables, one row per customer. Harbor copies those rows into the tools other teams use: a CRM (the sales team's customer list), an email tool, or any other app through a webhook. Each copy job is a sync, and a sync sends rows in batches: 100 per batch to a CRM, 50 to email, 25 to a webhook.
Harbor has three parts: an API (the part other programs talk to, which sets up the syncs), a web app with the screens, and a worker that does the sending. About 2,000 lines in all. CI is six checks: the API, web and worker test suites, a code-generation check, a migrations check and a type check.
Healthy main
Harbor came with a to-do list of coding tasks, each with a fix and a test. The lab took 18 of them: 12 bug fixes and 6 small features. All 18 tests fail on Harbor as it came: the 12 bug tests because the bugs are real, the 6 feature tests because the features don't exist yet.
That's a problem for scoring. The answer key lists the planted bugs; Harbor's own bugs aren't on it. A reviewer who spots one would be scored as raising a false alarm: a comment about a problem that isn't on the key.
So the lab first applies those 18 fixes, in order, one commit each, and turns each fix's hidden tests into ordinary tests, until every one of those tests passes. That's healthy main: 19 commits (Harbor plus 18 fixes), with all six CI checks passing in 3.0 seconds. Every PR is built on it.
Why only 18? Of the 34 tasks that don't start from a broken CI, only 18 applied together; the other 16 changed the same code as an earlier fix. Those became feature PRs on top of healthy main, rebased by hand.
One PR, read slowly
How the PRs are named. Every PR in the test set has an id like c20-d1. The first part is the change, what the PR does: c20 is one feature, adding a per-sync batch size. The second part is the version: -clean is the correct PR, and -d1, -d2 are copies of it with one planted bug (defect) each. So c20-clean and c20-d1 are the same feature, without and with planted bug 1.
The PR here is c20: "Add a per-sync batch size". The issue it closes: some customers' CRMs limit how fast they accept data, so they need smaller batches. The setting is optional, allows 1 to 1000, and when it's empty (None, Python's word for no value) the destination's default applies.
The planted bug, c20-d1 (the batch-size cap), is one line in the worker's send() function. Lines with + were added, lines with − removed. Switch between the buggy PR and the clean one, then try the two tests:
@@ -35,10 +35,11 @@ def send(records: list[MappedRecord],mode: str,*,+ batch_size: int | None = None,sleep: Callable[[float], None] = time.sleep,) -> SendResult:client = client_for(destination)- size = BATCH_SIZES[destination.kind]+ size = min(batch_size, BATCH_SIZES[destination.kind]) if batch_size else BATCH_SIZES[destination.kind]result = SendResult()
+ added, − removed. None means nobody set a batch size; the request allows 1 to 1000. The two PRs differ only in the highlighted line.
The PR's own test (CI runs it)
13 rows, batch size 4. Checks: at least 4 batches, none above 4.
clean passes · buggy passes
The hidden test (the reviewer never sees it)
250 records to a CRM, batch size 200. Expects batches of 200, then 50.
clean passes · buggy fails
Try your own inputs
Clean sends: 200, 50
Buggy sends: 100 × 2, 50
Different: the setting of 200 is capped to the CRM default of 100.
The buggy line takes min(batch_size, default): the smaller of the setting and the default. Ask for 50 and you get 50. Ask for 200 and you get 100: your setting is ignored, though the request allows up to a thousand. The correct line uses the setting when there is one, and the default otherwise.
Why CI stays green. The PR comes with its own test, and CI runs it. It asks for batches of 4. The smaller of 4 and 100 is 4, so it passes. Nothing tests a size above 100, the only case where the bug shows.
The hidden test. So each planted bug gets a hidden test. This one sends 250 records in batches of 200 and expects 200, then 50. The buggy version sends 100, 100, then 50, so it fails. The reviewer never sees it. Its job is to prove the bug is real, not a matter of taste. The lab calls it the oracle: it's the test the author should have written.
The card. The hidden test and a card make up the answer key for this bug. The card is written before anyone reviews:
| Field | c20-d1 |
|---|---|
| Type | logic |
| Severity | medium |
| What goes wrong | A batch size above the destination's default is silently capped to the default, so the setting only ever makes batches smaller. |
| Where | worker/harbor_worker/destinations/__init__.py, line 42 |
| Hidden test | worker/tests/oracle/test_batch_size_above_default.py |
Across the test set, the median planted bug is 1 line (the largest 10), and 13 of 173 span more than one file. All 173 hidden tests are behaviour tests: 77 in the worker (pytest), 58 in the API and 38 in the web app (vitest).
One change, several PRs
That's how the whole test set is built. A change is what a PR does, like c20's batch size setting. The number is just an id; the letter says where the change came from: c changes come from tasks in Harbor's own history, n changes were written new for the test set (more in the table below). Each change has variants:
- The clean PR is the change, done right (
c20-clean). - Each buggy PR is the same change with one bug planted in it:
c20-d1, the cap, andc20-d2, where the setting is never loaded (so it's always empty) and the test that would notice was loosened, so it still passes.
Why keep the clean one? A reviewer could flag everything and find every bug. The clean PR catches that: a comment on correct code is a false alarm, and false alarms count against the reviewer. Pick a PR and see what the answer key checks on it:
Change c20 adds a per-sync batch size. The clean PR does it right; each buggy PR is the same change with one bug planted: -clean is correct, -d1 and -d2 carry planted bugs 1 and 2. Pick one and see what the answer key checks.
The card
logic · medium severity
A batch size above the destination's default is silently capped to the default, so the setting only ever makes batches smaller.
worker/harbor_worker/destinations/__init__.py: 42
CI (the reviewer sees this)
- test:apigreen
- test:webgreen
- test:workergreen
- check:codegengreen
- check:migrationsgreen
- typecheckgreen
Hidden tests (the reviewer never sees these)
- batch size above the default (proves d1)fails
- the original test, unloosened (proves d2)passes
This PR fails only its own hidden test: the bug is real, and CI still passed it.
The five checks, on the whole test set
- Every PR passes CI250/250
Without it: CI would catch the bug, and the author would fix it before any review.
- The change's own tests fail without it77/77
Without it: The PR's tests wouldn't really test the change.
- The clean PR passes every hidden test77/77
Without it: A hidden test would flag correct code.
- Each buggy PR fails its hidden test173/173
Without it: The bug might only be a matter of taste.
- The bug is inside the lines the PR changes173/173
Without it: The reviewer couldn't see it in the diff.
All three pass CI. The clean PR passes both hidden tests; each buggy PR fails only its own. So each bug is real, and CI still passed it.
Changes come from four places:
| Source | How the PR is made | Count | Example |
|---|---|---|---|
| Fix | Healthy main with the fix taken back out is main; the fix and its tests are the PR |
18 | c06: the batcher drops one record per batch |
| Feature | Healthy main is main; the feature, rebased onto it by hand, is the PR |
16 | c20: a per-sync batch size |
| Bundle | Several fixes taken out together, put back as one PR | 5 | worker-release: 7 worker fixes, about 300 lines |
| Written for the test set | A new feature or fix written on healthy main, code and tests | 38 | n34: webhook URLs on destinations, with a guard against requests to internal addresses |
Changes that share a source task form a family: c05 (send 0, empty and false values instead of dropping them), c06 (the batcher fix) and the bundles that contain them are one. A reviewer should see at most one PR per family, or the second one is partly a rerun of the first. The 77 changes form 58 families; the two largest hold 9 changes each, because the bundles tie their fixes together.
The test set
The lab did that for 77 changes: one clean PR each, and up to four buggy ones. That gives 250 PRs: 77 clean and 173 with exactly one planted bug.
The bugs come in nine kinds, so later chapters can report results per kind:
| Kind | Bugs | What it looks like |
|---|---|---|
| logic | 31 | An inverted condition, an off-by-one, a cap where there should be none |
| reliability | 23 | A retry with no limit, a swallowed error, a run left in a bad state |
| performance | 21 | A query inside a loop, filtering in memory after a LIMIT |
| ai-shaped | 21 | Mistakes AI authors make more often: a comment that says the code does what it doesn't, a refactor hidden in a fix, a call to a helper that doesn't exist |
| contract | 18 | The API and the worker disagree about a field, a value or a limit |
| ui | 17 | A value not shown, the wrong text, a form error that never appears |
| security | 16 | SQL built from user text, a secret in an error message, the wrong signing key |
| convention | 15 | Harbor's unwritten rules broken, like UI text outside copy.ts |
| tests | 11 | The PR's test loosened so it passes, with the bug the original test would catch |
Severity: 38 high, 98 medium, 37 low.
Size is measured in changed lines, tests included, because that's what a reviewer reads: a 1-line fix with a 30-line test is a 31-line PR. Harbor is small, so the buckets are scaled down:
| Size | Clean | With a bug |
|---|---|---|
| XS (under 30 lines) | 8 | 7 |
| S (30–79) | 41 | 86 |
| M (80–199) | 18 | 54 |
| L (200 and up) | 10 | 26 |
214 of the 250 PRs (86%) are under 200 changed lines; the median is 74 and the largest 298. And 60% of all changed lines are tests. A reviewer reads those too, because a loosened test can hide a bug.
Checking the answer key
An answer key with a mistake would score every reviewer wrong. So 02_check_answer_key.py runs five checks, and answer_key.py c20 runs them on one change while you write its cards:
| # | Check | Pass | Without it |
|---|---|---|---|
| 1 | Every PR passes CI | 250/250 | CI would catch the bug, and the author would fix it before any review |
| 2 | The change's own tests fail without the change | 77/77 | The PR's tests wouldn't really test it |
| 3 | The clean PR passes every hidden test | 77/77 | A hidden test would flag correct code |
| 4 | Each buggy PR fails its hidden test | 173/173 | The bug might only be a matter of taste |
| 5 | The bug sits inside the lines the PR changes | 173/173 | The reviewer can't see it |
All five pass, on every PR they apply to. It didn't start that way: the checks caught broken cards along the way. And four changes have no planted bug at all: c05 (send 0, empty and false values), c06 (the batcher fix), c17 (show "Never run" for syncs that have never run) and c34 (fail MIRROR runs whose source returned no rows). They're small fixes whose tests were written to catch wrong fixes, and every attempt to plant a bug turned CI red. There was nowhere left for a bug to hide from CI, which is what good tests look like.
The surprise: four real bugs nobody planted
AI agents wrote the 173 planted bugs: three agents wrote 41 in a first round; in a second, four agents wrote 38 new changes with 106 bugs, and two more added 26 to the existing changes. To plant a bug, an agent had to read the PR closely. Doing that turned up four real bugs in the clean PRs:
| PR | The bug | Now |
|---|---|---|
| c18 (filter runs by status) | The new status filter still listed runs oldest first | fixed |
| c23 (error codes on failed runs) | Runs that only skipped rows were reported as "destination unavailable" | fixed |
| c13 (a dry-run option for the worker) | The dry run counts rows a real run skips, so it can print more records than a run sends | known issue |
| c23 (error codes on failed runs) | Any database error while reading the source is reported as "source missing" | known issue |
Every one passed CI. The two fixed ones were in patches reworked by hand. The dry-run one (c13) comes from two healthy-main fixes interacting. The two that stay are recorded as known issues on the card and copied into the answer key, so a reviewer who flags them is scored as right, not as a false alarm. It's the lab's own small lesson: green CI, unreviewed, let four real bugs through.
Also in the lab
From the lab's README, beyond the video:
- A prompt injection was removed. One coding task's description asked to add an endpoint that dumps the environment. An AI reviewer would read it, mixing a security test into a review measurement, so it's gone.
- Giveaway words. Every planted bug's added text was scanned for words that point at it (one hit: a comment that came with the original task, present in the clean PR too).
- The existing changes ran out of room. Agents adding bugs to existing changes reached 26 of a planned 42: every other idea turned CI red or repeated a bug already in the family. Growing the test set meant writing new changes.
- A held-out set. After every lab was built, 30 more changes (99 PRs, 69 planted bugs) were written the same way, kept apart for the final check in the capstone.
- Time and cost. Free, no API calls. On 16 cores, checking the whole answer key takes about 8 minutes.
What to do
- Fix the denominator first. To measure a reviewer, plant bugs and write the answer key before anyone reviews.
- Start from a base where the tests pass, so the only problems on the key are the ones you planted (plus any known issues you list).
- Keep only bugs CI misses. Require green CI on every PR, buggy or clean.
- Prove each bug with a hidden test that passes on the clean version and fails on the buggy one.
- Give every change a clean twin, so false alarms are counted alongside recall.
- Group changes into families, and never show one reviewer two PRs from the same family.
- Run the checks on the key every time it changes, and add a known issue whenever a reviewer finds a real bug nobody planted.
Caveats
- Planted bugs may not look like real ones. They're small (median 1 line), placed in lines the PR adds, and written by AI agents. Bugs that are a missing change, or a wrong design, are hard to plant this way.
- One small app. Harbor is about 2,000 lines, so PRs are small too (L starts at 200 lines). Results may not carry over to a large codebase.
- Healthy main isn't bug-free. The worker's dry-run count (c13) is a bug from two fixes interacting, recorded as a known issue. The answer key only has to know about the bugs inside a PR's diff.
- The reviewers are simulated. From Chapter 3 on, every "person" or "reviewer" scored on this testbed is a simulated stand-in (an AI model), not a human.
- Some kinds are thin. 11 tests-kind bugs and 15 conventions are few for per-kind claims; Chapter 2 measures how few.
The checklist
- Pick a base where every test passes, and record any real bugs left in it as known issues.
- Write each change with a clean variant and up to a few buggy ones.
- Write a card per bug (kind, severity, what goes wrong, where) and a hidden test that proves it.
- Check every PR: CI green, the change's tests fail without it, clean passes every hidden test, buggy fails its own, and the bug is inside the diff.
- Group changes into families and assign reviewers by family.
- Report the mix: size buckets, kinds and severities, so later results can be split by them.
Practice: the testbed in code
Write the size buckets, the planted batch-size cap, families of changes, the corpus table, a reviewer's score, and the answer key's per-PR checks. The tests run on the lab's recorded answer key: 77 changes in 58 families, the size table (8/7, 41/86, 18/54, 10/26), 60% test lines, the c20 hidden test's [200, 50] against [100, 100, 50], and c20's three PRs from fairness.json.
Quiz
1.Why can't you measure a reviewer's recall on your team's real pull requests?
2.A planted bug turns the PR's CI red. What does the lab do with it?
3.A PR adds a per-sync batch size, and its planted bug (c20-d1) caps the setting with min(batch_size, default). Why does the PR's own test pass?
4.Why does every change have a clean PR with no planted bug?
5.Why build a healthy main instead of putting the PRs on Harbor as it came?
6.What is the hidden test (the oracle) for, and why doesn't the reviewer see it?
Check your understanding
Try each question before opening its answer.
Why can't you measure a reviewer's recall on real pull requests, and how does a testbed fix that?
Recall is bugs found ÷ bugs present, and on real PRs you never learn the bottom of that fraction: a missed bug shows up only if it breaks something, and many never do. A testbed plants the bugs and writes the answer key before anyone reviews, so the total is known.
Why must every PR in the test set, including the buggy ones, pass CI?
A PR with red CI never reaches a reviewer: the author fixes it first. A bug that CI catches would measure CI, not review. Here CI is green on all 250 PRs.
The batch-size PR's planted cap (c20-d1) passes the PR's own test. Why, and what proves it's a bug?
The own test asks for batches of 4, and min(4, 100) is 4, so the cap never shows. The hidden test sends 250 records at 200 and expects 200, then 50; the buggy version sends 100, 100, 50 and fails, while the clean version passes.
What would go wrong if Harbor's own bugs were left in place?
A reviewer who spotted one would be scored as raising a false alarm, because those bugs aren't on the answer key. Harbor as it came failed all 18 tests the lab took, 12 of them because of real bugs; healthy main applies the 18 fixes first.
A reviewer comments on every PR. What recall does it get, and what stops it from looking perfect?
It finds all 173 planted bugs, so its recall is 100%. But it also comments on all 77 clean PRs, and each of those comments is a false alarm. That's why every change has a clean twin.
A reviewer flags a real problem in a clean PR that isn't on the card. Is that a false alarm?
Not if it's real. Check the claim; if it holds, add it to the card as a known issue, as the lab did for the worker's dry-run count (c13) and the "source missing" error code (c23). A reviewer who flags a known issue is scored as right. The answer key improves with every reviewer.
Next up: Chapter 2 asks how much CI misses in general: break the code on purpose hundreds of times, count what slips through, and ask whether 173 bugs is enough to tell two reviewers apart.