Verification
Believe nothing that has not been attacked
- Module
- Module 03
- Deliverable
- revue-adversariale.md (findings filed by axis, verdicts confirmed, plausible or rejected, merge decision and result of the last round)
- Access
- preview
Before you read
- What you will be able to do
You have reviewers who did not write an agent's code look for what is wrong in it, you check your checks on known cases, sort the findings and know when to stop.
- What you will do
- Action 1: Ask two fresh agents the two questions
- Action 2: Break the line a test protects
- Action 3: Have an empty search find a known case
- Action 4: Compare what the reviewer received with the change
- Action 5: Settle a finding with a command
- Action 6: Write your merge rule and your stop rule
Then the exercise: Trois relecteurs sur un diff réel, un axe chacun, puis le tri de leurs constats (in French)
- Time
34 min reading, 90 min exercise
- Updated on
- Before you start
- Words used in this module
- agentA session you open, or a subagent that a session launches.
- changeThe set of commits an agent produced on its branch, and that the review examines.
- reviewerA fresh agent, meaning one with nothing of the history of the agent that wrote the code, tasked with looking for what is wrong in its result.
- findingWhat a reviewer claims to have found wrong, with the place in the code and its reason: a claim, as long as nobody has checked it.
- axisThe angle of search imposed on a reviewer. This module proposes three: correctness; security and data; reproducibility.
- adversarial reviewA review where each reviewer looks for what is wrong in a result, under an imposed axis, without seeing what the others find.
- checkAnything that tells you whether the code is good: a test, a search in the code, a screenshot, a review.
- check commandThe command that runs all the automatic checks of the repository: its tests, its type checking and its lint.
- false greenA check that passes although what it claims to verify is broken, or although it verified nothing.
- known caseA case whose answer you already know, on which you watch a check answer before believing it.
- mutationA modification that breaks the code on purpose, made to see whether a test fails.
- verdictWhat you decide about a finding: confirmed (a command reproduces it), plausible (argued, not reproduced) or rejected (refuted by a command).
- sortingThe work that gives each finding a verdict, with evidence, before believing it or passing it on.
- roundOne pass of reviewers over the change, then the sorting of their findings; fixes are made between two rounds.
- merge ruleThe description, written before launching the first reviewer, of what will block the merge: the confirmed findings, by axis or by what they break, and the fate of a plausible one you judge serious.
- stop ruleThe rule, written before launching the first reviewer, that says after which round you stop launching reviewers again.
The diff that looked right
An agent hands you three hundred lines of modified code. The tests pass. You open another session and ask it: "Is this good?". It answers yes, with two remarks on style. You merge. At no point did anyone look for what was wrong.
Before merging an agent's work, have fresh reviewers, who did not write it, look for what is wrong, then sort what they find: decide, with evidence, what is true.
An agent, here, is a session you open, or a subagent that a session launches. An agent is fresh when it starts with nothing of the history of the agent that wrote the code, the author agent. It is a session you have just opened, or a subagent you have just launched without passing it the author agent's conversation. A session of the author agent that is resumed is not fresh. Some software that runs agents gives a subagent a copy of the conversation that launches it: check in the documentation of yours what a subagent receives. A reviewer is a fresh agent, tasked with looking for what is wrong in the result of another.
What a reviewer reports is called a finding: what it claims to have found wrong, with the place in the code and its reason. A finding remains a claim as long as nobody has checked it. The reviewer's report is the answer it hands you, with its findings.
The change to review is the set of commits the author agent produced on its branch; the diff is
what git diff shows of it. If it has not yet committed its work, have it commit before the
review. The reviewer receives three things from you: the change, the description of the task (the
ticket, or the request the author agent had received) and your request. Like any session, it also
reads at startup, if your software has it do so, the project's instructions files (a CLAUDE.md or
an AGENTS.md, for example), and it can open any file of the repository. It does not see the
conversation that produced the code.
Two precautions follow from this. The author agent may have written its conclusions in a file that every session reads at startup. It can be one of the project's instructions files, or a memory: notes that the software running your agents keeps from one session to the next. If that file is not part of the change, remove those conclusions from it before the review. If it is part of it, tell the reviewer not to believe them. And if the author agent's session launches the reviewer, have it show you, before the launch, the request it writes for the reviewer: it must contain neither its conclusions, nor the reasons for its choices. Then read the reviewer's report yourself, without relying on the summary that session makes of it.
An adversarial review brings several reviewers together. Each one looks for what is wrong under an imposed axis, meaning an angle of search. This module proposes three. Correctness: does the code do what was asked, and nothing else? Security and data: what leaks, what comes in without being validated? Reproducibility: does the code work anywhere other than on the agent's side? No reviewer sees what the others find.
I am the author of this manual, and "I" always refers to my own practice. My evidence comes from my session logs, meaning the timestamped transcripts of my sessions. The references to a failure lead to this manual's failure log: pages that each tell of one real failure.
When this module is useless
Do not have code reviewed that you are going to throw away: a prototype, an exploration, a mock-up rewritten before anyone reads it. Having it reviewed costs sessions and time, for a result that will not be used. See whether it answers your question, then throw it away.
The criterion is simple: if the code will never be merged into a shared branch, like main, nor
run on data that matters, do not have it reviewed.
One trap, though: throwaway code often ends up being kept. The day you decide to keep it, have it reviewed like the rest, before merging it.
A green suite proves only what the tests check
A green check command, the one that runs the repository's automatic checks (tests, type checking, lint), proves one thing at best: what these checks verify still passes. It says nothing about what nobody verified. Yet that is where the defects hide in code you did not write: you do not know which cases the agent forgot. And if it also wrote the tests, its tests may forget the same cases. So do not merge on the strength of a green: have an agent's code reviewed by a judge that looks beyond the tests.
The question you ask the reviewer
Ask the reviewer to prove that the result is wrong, never to say whether it is good. "Is this good?" is a closed question, and its default answer is yes. An agent that is asked this question looks for reasons to approve, since that is what the question asks for. It hands you a polite opinion, a few remarks on style, and you feel that you have verified.
"Find three reasons why this diff does not do what it claims" calls for a list. What a diff claims to do is what the description of the task says about it. The reviewer no longer judges: it must find the places where the code is wrong. It will sometimes make up a reason to fill the list; the sorting, further down, serves to spot it.
Two rules go with the question:
- Forbid it to fix. A reviewer allowed to propose a fix starts writing code and stops searching. Its report contains findings, no fix. It modifies no file, except in its own copy of the repository (a separate folder, like a second clone). There it can break code on purpose to prove a finding: that is a mutation, described further on.
- Take a fresh agent. The agent that wrote the code will not refute it: its history contains the reasons for each of its choices, and it will defend them.
What I say here about the default answer, the reviewer that fixes and the author agent comes from my reviews; I did not measure it. My first adversarial reviews applied this principle with two axes: one reviewer looked for where the diff does not do what it claims, another looked for edge cases.
Action 1: Ask two fresh agents the two questions
Take the last change an agent handed you, still on its branch and not yet merged. Launch a fresh
agent, in a folder whose current branch is that of the change, so that it reads the modified code.
First check that git status --short outputs nothing in that folder. Give it the description of
the task and the command that shows the change, for example git diff main...ma-branche: with
three dots, git diff shows what ma-branche added since it left main. Ask it: "Is this good?
Do not modify any file." Then launch a second fresh agent, with the same description and the same
command. Ask it: "Do not modify any file. Start your answer with the identifier of the last commit
of this change, then with the number of files modified and the number of lines added and removed,
as git diff --stat counts them. Then find three reasons why this diff does not do what it claims,
each with its file and its line. Do not propose any fix." Compare the two answers. The second
request changes two things at once, the question and the format of the answer: the comparison does
not say which of the two makes the difference. The header of the second report will serve you,
further on, to check that it points to the right change. This trial decides no merge.
Expected result: Two answers side by side: an opinion on the first question; on the second, a report that starts with the commit and the numbers of files and lines, then findings with their file and their line. Compare what each one cites precisely, with file and line.
Still in this module:
- Why a check can lie
- One axis per reviewer
- Sort each finding: confirmed, plausible or rejected
- What blocks the merge, and when to stop
- In practice
That is about 4,402 words, and the exercise with its deliverable template.