As AI agents increasingly take over the heavy lifting of software development—a practice known as agentic coding—we face a new bottleneck: code is being written faster than humans can possibly review it. Even worse, AI-generated code often suffers from "hallucinated" requirements or subtle logic errors that look plausible in isolation.
A new paper from researchers at Georgian Partners and Generative Models Inc. proposes a shift in how we test this agent-authored code. Instead of asking AI to test code by looking at the implementation, they suggest we should start with the specification.
TL;DR
Spec-Driven PBT is an agentic testing framework that derives program invariants from natural-language requirements (like PRDs) before ever looking at the code. Compared to traditional code-centric approaches, it finds a unique set of "workflow" bugs while writing 2.4x fewer tests, proving that the best way to catch AI errors is to anchor testing in the original intent, not the final implementation.
What Problem Does This Paper Address?
The current state-of-the-art for automated testing involves Property-Based Testing (PBT), where an agent identifies "invariants"—rules that should always be true (e.g., "a user can never see another user's private data")—and checks them against thousands of random inputs.
However, most current LLM-based PBT tools are Code-driven. They read the source code to figure out what to test. This creates a dangerous bias: if an AI agent implements a feature consistently but incorrectly, a code-driven tester will likely infer the wrong property from that code and give it a passing grade. This is known as the "Oracle Problem"—without an external source of truth, the tester is just a mirror of the buggy implementation.
Methods
The authors introduce Spec-Driven PBT, which enforces a strict "information boundary" during the testing process.
The workflow follows these steps:
- Understand the Spec: The agent reads the Product Requirements Document (PRD) and records semantic invariants in natural language without looking at the code.
- Inspect the System: Only then does the agent look at the implementation to find edge cases and boundary conditions that might falsify those invariants.
- Translate to Tests: The natural language invariants are converted into executable Python tests using the
Hypothesisframework. - Triage: The agent runs the tests, verifies failures, and generates bug reports.
By deriving the "oracle" (the source of truth) from the specification first, the agent avoids being biased by how the code happens to be written.
Datasets
The researchers evaluated their method on two primary testbeds:
- ViBench: A collection of 25 full-stack applications (e.g., clones of Instagram, GitHub, Discord) generated by AI agents from PRDs. Since these have no "ground truth" bug list, the authors used a blind LLM reviewer to validate findings.
- PBTBench: A secondary benchmark consisting of 100 problems with human-injected bugs, providing a ground-truth measure for recall.
Key Insights and Ideas
- The Power of Intent: Specifications record what the code meant to do. Invariants derived from them are not biased by implementation choices.
- Complementary Strengths: Spec-driven and Code-driven PBT find fundamentally different types of bugs.
- Spec-driven excels at finding State and Lifecycle errors (e.g., a "follow" request staying pending even after an account goes public).
- Code-driven excels at Input Handling and robustness (e.g., malformed quantities crashing a shopping cart).
- Efficiency over Volume: Spec-driven PBT is significantly more "surgical." It writes fewer tests but targets high-impact product workflows that code-only tools often ignore.
Key Results
The quantitative results highlight a massive efficiency gain for the spec-driven approach:
- Higher Yield: On ViBench, 34% of Spec-driven tests found at least one bug, compared to just 13% for the Code-driven baseline.
- Unique Discovery: Nearly 60% of the 169 total bugs were found by only one of the two methods. This suggests that for critical systems, using both approaches is necessary.
- Lower Overhead: Spec-driven PBT authored 2.4x fewer tests while finding a roughly equivalent number of total bugs, leading to faster test suite execution (35% faster median runtime).
Limitations and Future Work
The authors acknowledge several hurdles:
- Spec Quality: The method's effectiveness is directly tied to the quality and detail of the PRD. A "thin" or out-of-date specification will lead to poor testing.
- Validation: On the ViBench dataset, the lack of human-labeled ground truth means they rely on LLM-based review, though they performed manual validation on a subset to confirm accuracy.
- Non-Exhaustive: Like all PBT, a passing suite doesn't prove the code is perfect; it only proves the specific invariants held for the inputs tested.
The researchers see this as a stepping stone toward autoformalization pipelines, where informal requirements are systematically turned into checkable mathematical properties.
Summary updated