跪拜 Guibai
← All articles
Backend

AI Code Review Recall Put to a Blind Mutation Test: 13 of 20 Defects Caught

By AI入职记 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

AI code review tools now have a measurable recall ceiling: they catch about two-thirds of injected defects but systematically miss deleted defensive code and semantic-only numeric changes, so they can't replace diff review or tests for those classes. The experiment also gives other teams a copyable protocol for benchmarking their own AI review on synthetic defects.

Summary

A single-developer experiment measures how often AI code review actually catches injected defects. The author seeded 23 mutants into a 1,919-line Java/Spring project, ran existing unit tests to disqualify any that failed, and sent the surviving 20 files to Claude Sonnet with a frozen review prompt and no hint that defects existed. The AI caught 13, a 65% recall rate. Concurrency defects were all caught (4/4); security hit 3/4; null-boundary, exception, and resource categories each landed 2/4.

The missed defects cluster into a clear pattern: 5 of 7 misses were deletions or substitutions of a single defensive step, such as removing an empty-query guard or a cleanup callback. The code still compiles and looks valid. The AI caught structurally "shaped" anomalies — lock positions, volatile, new log lines, over-broad catches — but remained blind to absent code. A numeric change like `>=` to `>` was caught only because it carried semantic meaning; a status code 503 to 502 change was missed because both numbers are valid in isolation.

The 20 blind runs consumed about 1.65 million tokens (50k–154k per run), nearly triple the cost of the earlier precision baseline. The author offers five engineering rules: feed diffs rather than whole files, use tests to pre-filter mutants, rely on AI for concurrency and resource-path gaps, accept only line-numbered findings, and never combine the two corpora into an F1 score.

Takeaways
— Of 23 injected mutants, 20 survived unit tests and entered blind AI review; 13 were caught, a 65% recall rate.
— Concurrency defects were all caught (4/4); security caught 3/4; null-boundary, exception, and resource each caught 2/4.
— 5 of 7 missed defects were deletions or swaps of a single defensive step (empty-query guard, cleanup callback, catch clause, etc.).
— The 20 blind runs cost about 1.65 million tokens, 50k–154k per run, nearly triple the cost of the earlier precision baseline.
— Existing unit tests caught 3 of 23 mutants, all in the security category, because assertions matched those cases.
— The experiment protocol uses fixed-seed shuffling, frozen review prompt, one model, and mapping after judgment; temperature variance was not measured.
— Engineering advice: give AI diffs, not full files; let tests pre-filter mutants; use AI for concurrency, resource, and exception paths; accept only findings that map to line numbers and trigger conditions.
Conclusions

The misses follow a consistent cognitive failure: AI review is sensitive to code patterns and structural anomalies but blind to the absence of defensive lines that would have been visible in a diff.

The 65% recall and the earlier 50% precision come from different corpora, so the author correctly refuses to combine them into an F1 score; this limits practical utility for teams wanting a single quality number.

A single run with no temperature variation means the 65% is a point estimate with no variance; the author explicitly flags this, which makes the result more trustworthy than many AI benchmarks.

The fact that the same shape of defect (publishing before initialization) was caught once and missed once suggests pattern recognition in AI review is not a stable rule, so relying on it for critical concurrency bugs is risky.

Concepts & terms
Mutation testing
A technique that injects small artificial defects (mutants) into code to measure how well test suites or review processes detect them; used here to estimate AI code review recall.
Recall (in code review)
The fraction of known defects that a review process actually flags; here, 13 of 20 injected mutants caught, or 65%.
Ground truth
A known set of real defects used to evaluate a detector; absent in this personal project, so mutation testing substitutes with synthetic defects.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗