NOTE 006 / AI-DRIVEN DEVELOPMENT / 2026-11 / 10 MIN READ
A sampler, not a gate: running AI code review that never comes back clean
Abstract. An AI code reviewer is stochastic: run it again on the same diff and it reports new issues, run it from another person's session with different framing and it reports more. Reviewing until the report is clean therefore never ends, and a better prompt does not change that. From a recent platform build done with AI-driven development, we describe what does help: a stopping rule, independence over prompt quality, a verification filter in front of a colleague's attention, small units of review, and fixes carried per value rather than per document. We also give the cost, and the part a human can still control.
Where this comes from
Over several months a small team built a bring-your-own-cloud database platform with AI-driven development: an AI model wrote most of the services, console, tests, specifications and reviews. This note is about the part that did not behave as we expected: review.
Two conditions shaped everything. The first is that one author wrote all of it. The same model wrote the code, its tests, its specification and its review, so nothing in that chain is independent of anything else. A green test run proves that the implementation and the tests agree with each other. It does not prove that either of them is right.
The second condition is that the code was greenfield. Changing an existing codebase with AI is comfortable, because the surrounding code shows what a change should look like. Here a reviewer had nothing to compare a change against except the specification written just before it, and a person reading two thousand lines of generated code finds naming and style, not the bug. We tried that, repeatedly.
A review is one more artifact produced by the author. It is often very useful, but it is not an independent check, and treating it as a gate leads to a specific failure.
The review that never runs dry
We ran each of our two review commands three times over our own branches, six runs over the same work. Every run found something worth fixing. By the end only a few low-severity findings were left untouched. Then a colleague ran their own review on the same branch, and it reported three high-severity findings that none of the six runs had raised.
The obvious reading is that our reviewer was not good enough and a better prompt would have caught them. We think that is wrong. A model writing a review samples from a distribution of plausible observations about the diff, and each run draws a different sample. Some defects are drawn often, some rarely, and one run's report is a sample of the defects, not the list of them. A colleague's run changes the wording, the loaded context and the machine, so it draws from a shifted distribution. That is why it was worth more than our seventh run would have been.
Two consequences follow. First, "review until clean" does not converge. There is always another sample, fixes create new surface to comment on, and a model asked to find problems will find some. Second, prompt engineering works on the wrong axis: a sharper prompt moves the distribution, it does not turn a sampler into an exhaustive check. We chose not to invest in making the reviewer better, and to invest in the process around it.
Five things that do help
1. A stopping rule
If review cannot end by running out of findings, it has to end by rule. A colleague reached the same conclusion independently and wrote the rule into the project's instructions for the AI. Triage every finding before fixing it: fix now, ticket, or won't fix. Only confirmed correctness, security or data-loss bugs are fixed now; style remarks, "consider" suggestions and speculative edge cases are ticketed or dropped. After fixing, re-review only the fix commits, not the whole branch. Stop after two rounds, or as soon as a round has no confirmed high-severity finding. The merge gate is a green test suite plus one bug-focused review, with one reviewer per workflow step, never several stacked.
Our development lifecycle has a similar rule elsewhere. The order is implement, simplify, review, fix, test, then commit, and simplification never runs again after the review fixes. What gets committed is what was reviewed; a second clean-up would produce a diff nobody has looked at.
A stopping rule can feel like giving up on findings. It is the opposite: an admission that findings never run out, and a decision about which of them are worth a round.
2. Independence, not a better prompt
The sampling result says what to vary: who runs the review, how it is framed, and what it is checked against.
The strongest independence comes from an oracle the model did not write: a live run against real infrastructure, which finds bugs on which the code and the specification agree and are both wrong, and mutation, which checks tests that share an author with the code by breaking the behaviour on purpose. Our companion note, "The model wrote the tests too", covers both in depth.
3. A hard filter in front of a colleague's attention
A sampler produces candidates. Sent straight to a colleague, they make the colleague the filter, and attention is the scarcest resource in the process. So every finding is verified before it is posted, and what cannot be verified is dropped.
Our branch-wide review command makes this a separate phase. For each finding it traces the failure path through every layer to what a user would see, because the first-pass consequence is often wrong even when the defect is real. It searches for a defeater: the guard, retry, lock or later check that would stop the failure. It reproduces the failure when that is cheap, for example on a throwaway database for a question about SQL semantics. And it separates defects from opinions, since behaviour the specification mandates is not a defect. Every posted finding states how it was verified, reproduced or traced. There is no third option.
The same command caps its output: zero to three blocking findings, five in rare cases, zero to four non-blocking ones, never more than six in total. It states that zero comments is a common correct outcome, and that a finding in doubt is dropped.
Verification is necessary but not sufficient. We once posted a long review comment in which every fact had been verified, and its reader deleted it as way off: what it described was already planned for a later phase and blocked nothing that day. We had posted it because verifying it had taken real effort. Sunk verification cost is not a reason to spend a colleague's attention. The bar we use now is three questions, in order. Is this already planned, or documented as deliberate? Does it block a merge, a test, a person or a customer today? Would fixing it now change anything that happens now?
One more filter: separate what can be measured from what must be judged. AI-written code tends towards comments that restate the code, and those go stale and mislead; one review found four false documentation claims in a single package. Our review command now counts comment density mechanically for every file before any reviewing agent runs, against fixed thresholds such as more than half of the non-blank lines. The model never estimates the count. It only judges which comments to cut and which carry an invariant or a measured figure.
4. Small units of review
Reviewers find more per line in a small diff than in a large one. This is old knowledge about human review: SmartBear's large study of peer review at Cisco recommends fewer than 200 to 400 lines at a time, as defect finding drops beyond that. We saw the same shape with AI reviewers: the same review command found more per line in a diff of about 400 lines than in one of about 2,000. A long context window does not remove the effect.
The unit that works for us is the commit, not the pull request. Small stacked pull requests were reviewable, but the rebasing and retargeting never stopped. One large branch with a pile of commits was worse: nothing in it could be read on its own, so only a model could review it. The Linux kernel settled this long ago: a change goes out as an ordered series of patches, each one logical change that builds and runs on its own, so a reviewer can verify each patch and git bisect can split the series anywhere. A large pull request is fine if it reads like that.
5. Fixes that propagate per value
A single change in our process touches several documents: a decision record, a design, a task list and a specification. They state the same values, such as a timeout or a field name. A reviewer finds an inconsistency, the fix lands in one document, and the other three still state the old value. The next review reads all four and reports the disagreement as new problems.
On one change that touched only documents, the second review run returned 71 findings, one of them critical. Nearly all of them were a single mistake: the first run's fixes had been made in one document and never carried into the others, and the reviewer reported that one mistake back to us many times over. The fixing pass works per document. The problem is per value.
The remedy is mechanical rather than a matter of judgement: extract every decided value from the change and check that every document agrees, after each fix pass rather than once at the end. It is first on our list of tools to build, and it does not exist yet.
What it costs, and what a human still controls
On this build a review cycle cost roughly half a day to a day of a ticket that took two to four days. Most of it is fixed overhead, not proportional to the diff: review agents re-reading the same files, the report rewritten, a full test run each time. So we now implement a batch, often several tickets, run simplify, review and fix once over the lot, and still commit one commit per ticket. That turned seven planned cycles into four, projected to save two to four days against a hard deadline. It does not reduce a human reviewer's time, and we have not yet measured the review half end to end.
Batching pulls against small units, so each batch is still committed before the next starts: one review over four batches would land on the large-diff side of the curve.
| Lever | What it buys | What it costs |
|---|---|---|
| Running the same reviewer again | More findings, without converging | One full cycle per run |
| An independent reviewer or oracle | Different findings, including ones the author cannot see | A colleague's session, or a live environment |
| A stopping rule | A review that ends | Accepting known low-severity findings |
| A verification filter and caps | Fewer comments, each one true and relevant | Author time per finding |
| Small units | More found per line | More fixed overhead per line |
| A per-value consistency check | No repeated findings across documents | A mechanical pass after every fix (not built yet) |
| Batching | Fewer cycles | Larger diffs per review |
We summed up the trade-off in an internal message while working it out: design pull requests read separately by a human are the controllable step; code pull requests reviewed by AI from team members give less control, but they always raise findings. Some things we cannot control, but some we can.
So the process we are moving to puts the human where a human is strong. A design is reviewed before any implementation exists, not for correctness but against six fixed questions. Is this the problem we actually have? What else was considered, and why was it dropped? What breaks if this is wrong, and how far does it reach? What observable evidence would prove it works? Which earlier decision does it contradict? What does it make harder later? About twenty minutes, no code read. Code review then becomes sampled, filtered and bounded, and the evidence the design asked for is attached before merge.
Open questions, and what we would do differently
- We would adopt a stopping rule on the first day, not after each branch had already been reviewed six times.
- The sampling result rests on six runs plus one independent run over a few branches. We do not know how fast each additional run's yield falls. A review mode that runs several passes with varied framing, deduplicates them and reports when new findings stopped would measure it. It is proposed, not built.
- Much of the tooling is also only proposed: the per-value check, mutation testing over a diff's assertions, scenarios turned into failing tests that a human agrees before implementation, and a replay proving every commit builds and passes. The six design questions and the commit discipline are not yet agreed as a team.
- The colleague's rule allows one reviewer per step, while our sampling result says an independent reviewer finds what repetition does not. Our reading is that one independent sample at the merge gate beats several runs of the same reviewer. How many independent samples are worth their cost is open.
- Greenfield work has no baseline to review against. We would build an end-to-end walking skeleton first, so every later change lands against something that already runs.