ealeng

Episode 01 of 12 · The testbed

Green CI, still a bug: a review testbed with planted bugs

How good is your code reviewer, person or AI? On real pull requests you can't count the bugs it missed. So build a testbed: 250 pull requests on a small practice app, 173 of them with one bug planted on purpose, every one passing CI, each bug proven by a hidden test and written into an answer key before anyone reviews. One PR read line by line, the clean twin that catches a reviewer who flags everything, the five checks that keep the key honest, and the four real bugs nobody planted.

Lab 01 · The Review Testbed16 min read
Video transcript9:39

0:00Cold open

0:01

This pull request, a proposed change to our app, adds one setting: how many records to send in each batch.

0:08

Today, a CRM always gets batches of a hundred. With the setting, a customer can pick anything from one to a thousand.

0:16

All six automatic checks, called CI, are green. The tests, the types, everything.

0:22

But look at this line. Ask for batches of two hundred, and it quietly sends one hundred.

0:28

A hidden test proves it. It passes on the correct version, and fails on this one.

0:34

I have a hundred and seventy-three pull requests like this. How many would your reviewer catch?

0:41Intro

0:43

Hands-on AI code review. Part one.

0:46

Today: a set of pull requests where every planted bug is known in advance.

0:52Meet Valentina

0:53

I’m Valentina, a tech lead. First, some context on how code changes.

0:58

Our code lives in one shared version, called main. Every change arrives as a pull request: a proposal to change main.

1:07

Before it’s merged, two things look at it. First CI, which runs the tests automatically.

1:13

Then code review. A person, or an AI, reads the change, and comments on anything that looks wrong.

1:20

On this pull request, a good reviewer would leave a comment like this one.

1:24

Tests only check the cases someone thought of. A reviewer can catch the rest.

1:29

AI now writes most of our code, and an AI reviewer comments on every pull request. So my question is: how good is it?

1:39Why plant bugs?

1:40

The number I want is called recall: the share of the bugs a reviewer finds.

1:45

Say the pull requests hold ten bugs, and the reviewer finds six. Recall is six out of ten: sixty percent.

1:53

On a real team, you can’t count that. You hear about a missed bug only when it breaks something.

1:58

The ones that never break, you never hear about. So nobody knows the bottom of the fraction: how many bugs there were.

2:06

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.

2:15

A review testbed does that for code: bugs planted on purpose, and an answer key written before anyone reviews.

2:2301 · Harbor

2:25

All these pull requests change one small practice app, called Harbor.

2:29

Companies keep their data in a warehouse: big tables, like this one, with one row per customer.

2:36

Harbor copies those rows into the tools other teams use. A CRM, which is the sales team’s customer list. An email tool. Or any other app, through a webhook.

2:47

Each of those copy jobs is called a sync. A sync sends the rows in batches, not one at a time. A CRM gets a hundred rows per batch.

2:57

That fixed default is what our pull request wants to make adjustable.

3:01

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 two thousand lines in all.

3:1501 · Healthy main

3:16

Harbor came with a to-do list of coding tasks, each with a fix and a test. I took eighteen of them: twelve bug fixes and six small features. All eighteen tests fail on Harbor as it came.

3:28

The twelve bug tests fail because the bugs are real. The six feature tests fail because the features don’t exist yet.

3:36

That’s a problem for scoring. The answer key lists the bugs I planted. Harbor’s own bugs aren’t on it.

3:43

So a reviewer who spots one of them would be scored as raising a false alarm: a comment about a problem that isn’t on the key.

3:52

So first, I applied those eighteen changes, one commit each, until all of those tests pass.

3:58

I call that healthy main. Every pull request is built on it.

4:0302 · Reading the diff

4:04

Now let’s read that pull request slowly. This is the function in the worker that sends records to a destination.

4:11

Lines with a plus were added. Lines with a minus were removed.

4:16

This added line is the new setting, batch size. None, Python’s word for no value, means nobody set it.

4:23

This removed line was the old behavior: the size was always the destination’s default.

4:29

And this is its replacement. If a batch size is set, it takes the smaller of two numbers: the setting, or the default.

4:37

Say you ask for fifty. The smaller of fifty and a hundred is fifty. That works.

4:43

Now ask for two hundred. The smaller of two hundred and a hundred is a hundred. Your setting is ignored, though the request allows up to a thousand.

4:53

The correct version simply uses the setting when there is one, and the default otherwise.

4:5902 · Why CI stays green

5:01

So why doesn’t CI catch it? The pull request comes with its own test.

5:05

It asks for batches of four. The smaller of four and a hundred is four. So the test passes.

5:11

Nobody tested a size above a hundred. And that’s the only case where the bug shows.

5:17

So for each planted bug, there’s a hidden test. This one sends two hundred and fifty records, in batches of two hundred.

5:25

It expects two hundred, then fifty. The buggy version sends a hundred, a hundred, then fifty. So it fails.

5:33

The reviewer never sees this test. Its job is to prove the bug is real, not a matter of taste.

5:39

The hidden test and a card make up the answer key for this bug. The card says what kind of bug it is, how serious, and what goes wrong.

5:4802 · Why CI stays green

5:50

Let’s check this change for real. This command runs CI, then the hidden tests, on each of its pull requests.

5:58

There are three: the clean one, and two with a different bug each. One of them is the cap we just read.

6:04

CI is green on all three. The clean one passes both hidden tests.

6:08

Each buggy one fails just its own hidden test. So each bug is real, and CI still passed it.

6:1603 · One change, several PRs

6:17

That’s how the whole test set is built. It starts from a change, like this batch size setting.

6:23

The clean pull request is the change, done right.

6:26

Each buggy pull request is the same change, with one bug planted in it. Here, the cap we just read.

6:33

And here, the setting is never loaded, so it’s always empty. The test that would notice was loosened, so it still passes.

6:41

Why keep the clean one? A reviewer could flag everything, and find every bug. The clean pull request catches that: a comment on correct code is a false alarm, and false alarms count against the reviewer.

6:5503 · The test set

6:57

I did that for seventy-seven changes: one clean pull request each, and up to four buggy ones.

7:03

That gives two hundred and fifty pull requests. A hundred and seventy-three of them have exactly one planted bug. The rest are clean.

7:12

The bugs come in nine kinds. Logic mistakes, like the cap. Security holes. Tests loosened so a bug passes.

7:20

And mistakes AI authors make more often, like a comment that says the code does something it doesn’t.

7:26

Most pull requests are under two hundred changed lines. Harbor is small, so its changes are too.

7:33

And more than half the changed lines are tests. A reviewer reads those too, because a loosened test can hide a bug.

7:4104 · Checking the answer key

7:42

An answer key with a mistake would score every reviewer wrong. So five checks run on every pull request.

7:49

One: every pull request passes CI. Otherwise CI would catch the bug, and the author would fix it before any review.

7:57

Two: the change’s own tests fail without the change. Otherwise they don’t really test it.

8:03

Three: the clean pull request passes every hidden test. Otherwise a hidden test would flag correct code.

8:10

Four: each buggy pull request fails its hidden test. Otherwise the bug might only be a matter of taste.

8:16

Five: the bug sits inside the lines the pull request changes. Otherwise the reviewer can’t see it.

8:23

Today, all five pass, on every pull request they apply to.

8:2904 · The surprise

8:30

But here’s what surprised me. AI agents wrote the bugs for me, and to plant one, an agent had to read the pull request closely.

8:39

Doing that turned up four real bugs, in the clean pull requests. Nobody had planted them.

8:45

Like this one: a new filter that still listed runs oldest first.

8:50

Every one of the four passed CI. Two were in patches I’d reworked by hand.

8:55

Two are fixed now. The other two stay, marked as known issues, so a reviewer who flags them is scored as right.

9:03Back to Valentina

9:05

So here’s what I have: two hundred and fifty pull requests, every planted bug known, and every one passing CI.

9:12

And a reminder of why review matters: green CI let four real bugs through.

9:17

In part two, I ask how much CI misses in general. I break the code on purpose, hundreds of times, and count what slips through.

9:26

And whether a hundred and seventy-three bugs is enough to tell two reviewers apart.

9:32Summary

9:33

Every planted bug known in advance. Now we can count.Valentina: Thanks for watching!

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:

Try it · One planted bug, up closeLab 01 · c20-d1 · worker/harbor_worker/destinations/__init__.py
@@ -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

Destination (default batch):
200
250

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, and c20-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:

Try it · One change, three PRsLab 01 · results/fairness.json · change c20

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.

Changed lines
89
Of them tests
61
Bug lines in the diff
1

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

  1. Pick a base where every test passes, and record any real bugs left in it as known issues.
  2. Write each change with a clean variant and up to a few buggy ones.
  3. Write a card per bug (kind, severity, what goes wrong, where) and a hidden test that proves it.
  4. 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.
  5. Group changes into families and assign reviewers by family.
  6. 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.

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

Quiz

Try it · Check your understanding0 of 6 answered
  1. 1.Why can't you measure a reviewer's recall on your team's real pull requests?

  2. 2.A planted bug turns the PR's CI red. What does the lab do with it?

  3. 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. 4.Why does every change have a clean PR with no planted bug?

  5. 5.Why build a healthy main instead of putting the PRs on Harbor as it came?

  6. 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.

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.