Toward automated verification of unreviewed AI-generated code
TL;DR Highlight
Property and mutation tests let an agent verify its own code without line-by-line review.
Who Should Read
A backend developer spending too much time reviewing AI-written code line by line.
Core Mechanics
- Shift from reviewing to verifying
- Review means reading code line by line.
- Verification means confirming correctness through review, machine-enforced constraints, or both.
- Four constraints on the coding agent
- The agent solved a simplified FizzBuzz and iteratively checked it against predefined, human-reviewed constraints.
- They are property tests, mutation testing, no side effects, and type checking plus linting.
- Property tests define the requirement space
- Instead of one input, they check a property against 100 semi-random values.
- They also cover no exceptions and sufficiently low latency.
- Mutation testing blocks extra code
- It is normally used to grow a test suite.
- If the tests are assumed correct, it can restrict the code instead.
- For example, if replacing print with print(None) still passes, a leftover side effect exists.
- Treat the output like compiled code
- The author is starting to think maintainability and readability do not matter in this context.
- Invalid-but-passing programs can remain but are hard to hit by accident.
- Reading is still cheaper for now
- The author says the setup overhead currently exceeds the cost of just reading the code.
- It is a baseline to chip away at as agents and tooling improve.
Community Reactions
- Objection: who writes the tests?
- One commenter said passing tests only help if you can trust the tests.
- Another cited the test oracle problem, saying correct tests are as hard as correct answers.
- FizzBuzz may not scale
- Commenters said real systems have many processes with side effects, so no side effects is a heavy constraint.
- They said property tests do not cover temporal properties.
- One asked how to fix a 3am outage in code you never read.
- Experience: good tests did not make code converge
- A commenter said Anthropic's agent C compiler attempt had thousands of good tests but fixing one bug created another.
- Experience: 41% of about 100 AI-built repos had raw secrets
- The commenter found Supabase service_role keys and hardcoded API keys, which tests do not catch.
- Opinion: treat AI like a junior engineer
- Static analysis and linters can mitigate the risk.
- One commenter said they correct it about 10% of the time over the past 6 months.
How to Apply
- Add property tests to an agent-written function
- Today, pick a pure function and write three Hypothesis property tests.
- Include a no-exceptions test and output rules for input ranges.
- Run mutmut after tests pass
- Run mutmut on a module whose tests already pass.
- For each surviving mutant, add a test or delete the unneeded code.
- Add a verification gate to the agent loop
- State in the agent instructions that work is done only when tests, mutation testing, type checks and lint all pass.
- Review the constraint files yourself first and forbid the agent from editing them.
Try It
# Paste into Claude Code (simplified version of the article's method)
Implement a Python function that satisfies {{function requirements}}.
Rules:
1. First write Hypothesis property tests and do not change them until I review them.
2. Include a test that no exceptions are raised and a test that latency is sufficiently low.
3. The implementation must have no side effects (print, files, network, global state).
4. After implementing, run pytest, mutmut run, mypy and ruff.
5. If any mutant survives, remove unneeded code or propose a test to me.
6. Repeat until everything passes and summarize the results.Terminology
Related Papers
Gemini 4 Neon is the new #1 on the Models Engineering Index
Gemini 4 Neon ranks first on the Models Engineering Index with 68.0, combining multiple benchmarks.
LLMs can read and write executables byte by byte from a hex dump
Given only a hex dump and no tools, an LLM analyzed, patched and wrote working executables.
Claude was trained on protein sequences at scale
Next-amino-acid tests on obscure proteins show only the latest Claude models predict them
Remembered as Brief: Stored Preferences SilentlyRemove Decision-Critical Information
A stored 'keep it short' preference silently drops warnings; listing must-know points first restores content.
All AI-generated code should be Open Source
A blog argues AI-generated code should be open source; most HN commenters disagreed.
What thousands of conversations look like inside a language model
Mapping Qwen3-1.7B states showed Chinese sitting apart from English, while German and Croatian overlapped it.
AI, activity, and outcomes in software engineering
AI sped up writing code, but shipping speed did not rise as much, says a talk
LLMs Play Zachtronics' TIS-100
16 LLMs played TIS-100 and set 133 new Pareto frontier points across 18 puzzles