- ai
- scoring
- sarif
AI Code Reviewers Need Ground Truth Too
An AI reviewer that sounds sure is not one that is right. If it writes SARIF, it can be scored against labeled ground truth on your machine, no vendor trust needed.
4 min read
The pull request has a green check and a friendly comment from the AI reviewer: “No security issues found.” The one on the next repository has forty comments, each written with the same calm confidence, and half of them are about code that cannot be reached. Both reviewers sound certain. At most one of them is right, and from the comments alone you cannot tell which.
AI code review arrived fast. Measurement did not keep up. Most of what a team knows about its AI reviewer comes from the vendor’s demo, a handful of findings someone remembers, and a general feeling. That is not how anyone would choose a scanner, and an AI reviewer is a scanner with better prose.
A finding is a finding
Strip away the chat interface and an AI reviewer does what every static analyzer does: it points at a place in the code and says “this is a weakness of this kind”. If it can say that in SARIF, the open standard for static analysis results, it can be graded exactly like any other tool.
That is the whole point of a tool-agnostic benchmark. BenchProctor does not care how a finding was produced. Each case in the corpus is labeled vulnerable or safe in a separate answer key, the tool’s SARIF is matched against it, and the result is arithmetic.
The formatting trap
Language models are inventive about where they put a CWE. One writes it into the rule ID. Another tucks it into a
property bag or a tag like external/cwe/cwe-089. Another references a CWE taxonomy. A strict scorer would punish
all of that as a miss, and you would end up measuring the reviewer’s formatting, not its judgment.
BenchProctor’s scorer looks in all of those places and recovers the CWE from wherever the tool wrote it. If a tool reports no CWE at all, there is a filename-only mode, clearly labeled, because it rewards over-flagging and should never be anyone’s default.
Grade the judgment, not the formatting. A model that found the bug should not lose points for where it wrote the CWE.
The flag-everything trick
The cheapest way to look thorough is to flag everything. An overeager reviewer catches every real vulnerability, and also buries the team in noise on safe code. A score that counts only what was caught will call that reviewer excellent.
BenchProctor scores with Youden’s J: the true-positive rate minus the false-positive rate. Flag every case and both rates are 100%, so J is exactly zero. Flag nothing and both are 0%, so J is zero again. Only a reviewer that tells vulnerable code from safe code moves the needle. Vulnerable and safe cases come in equal numbers, so neither verdict is the safe bet.
The headline score is averaged per weakness class, so a reviewer that is excellent at one large class cannot hide that it is blind to another. The flat aggregate is reported beside it, for comparison. We have written about why one score hides the gap.
0
score of a tool that flags every case
1
standard-library Python file, the whole scorer
0
dependencies, accounts or uploads needed
Testing a model fairly
A language model brings three problems a rules engine does not, and each has a plain answer.
It is not deterministic. Run the same reviewer twice and the findings can differ. So run it more than once and report every run, not the best one. Record the model version, the prompt and the settings next to each score; a result you cannot reproduce is an anecdote.
It may have read the test. Anything that has been public for years may sit in a model’s training data. A suite whose files never change hands an advantage to any model that has seen them, and nobody can say how large that advantage is. BenchProctor draws each release fresh from its own seed, with the same languages, classes, difficulty and scoring rules and different code, which is why we argued that the age of an answer key matters.
It may read the answers. An agent with file access can wander. Point the reviewer at the test code only, and keep the answer key outside anything it can open. In BenchProctor the labels live in a separate file for exactly this reason; nothing in a test file’s name says what it is.
Nobody has to be trusted
The strongest property of the setup is the one that has nothing to do with AI. The answer key is a public file. The scorer is a single standard-library Python file you can read in one sitting. You run it on your machine, against your own SARIF, with no account and nothing uploaded. If you doubt a label, you can open the case and read it.
That changes the conversation with any vendor, human or model. You do not have to believe a slide. You can ask for the SARIF, or produce it yourself, and compute the score in a minute.
AI reviewers will keep getting better, and the good ones deserve a number that proves it. The way to get that number is the same as it has always been: labeled cases, public arithmetic and a result anyone can reproduce.
Score your reviewer the same way you would score any scanner: start at benchproctor.com.