Skip to content
Ryan Pratama

Finding Decades-Old Bugs with Agentic Property-Based Testing

3 min readTesting · AI · Software Engineering · Open SourceAI-written

Most discussions around AI in software development focus on writing features faster. But recently, Alp Keles published a fascinating piece on the Datadog Engineering Blog detailing Ephyra, an open source research framework written in Rust. Ephyra pairs autonomous coding agents with property-based testing to generate test cases. Across 26 mature, battle-tested open source projects, it found 535 previously unknown bugs, including a 24-year-old memory safety flaw in OCaml, a 21-year-old parsing bug in PostgreSQL, and a 13-year-old database corruption issue in SQLite.

As someone building full-stack web applications, I spend a lot of time writing tests, and this approach feels fundamentally different from the usual autocomplete tools.

The Generator Bottleneck

Property-based testing (PBT) has long been one of the most reliable ways to find edge-case failures. Instead of asserting that add(2, 2) equals 4, you define an invariant: a rule that must hold true for all inputs. For example, sorting a list must preserve its length and element count, or a SQL query partitioned by ternary logic should yield identical combined rows.

The testing engine generates hundreds of pseudorandom inputs to break the invariant. When it succeeds, a built-in shrinker reduces the failing case down to the smallest possible input that reproduces the error.

The problem with PBT has never been the concept; it has always been the investment required to build input generators. Crafting generators that produce syntactically valid yet structurally complex inputs—such as valid ASTs, stateful database queries, or nested network payloads—demands deep domain expertise and tedious maintenance. Most teams simply do not have the time to build them, so PBT remains confined to compilers, database engines, and cryptography.

Shifting the Burden to Agents

Ephyra solves this generator bottleneck by splitting the labor cleanly:

  1. The human defines the property: Engineers write the invariants that the system must never violate.
  2. The agent writes and mutates the generators: An LLM agent iteratively writes generator code, runs tests against the target system, reads coverage data, and expands the generator's vocabulary to hit deeper branches.
  3. The framework executes and shrinks: When an invariant breaks, Ephyra minimizes the offending input down to a clean reproducer.

In testing SQLite, Ephyra's agent expanded the generator over 37 rounds, increasing coverage of SQLite's instrumented counters from 35.9% to 74.1% and surfacing 26 distinct bugs. In PostgreSQL, it found an exponential memory explosion in query parsing where nested BETWEEN clauses caused work to double at each level:

sql
SET statement_timeout = '100ms';
SELECT 1 WHERE (((true BETWEEN true AND false)
  BETWEEN true AND false)
  BETWEEN true AND false); -- doubling memory at every level

At 20 levels of nesting, parsing this query required 1.5 GB of RAM; at 26 levels, it demanded nearly 100 GB before timeouts could intervene.

The Right Division of Labor

Using LLMs to generate standard unit tests often creates a false sense of security. When an agent writes both the test inputs and the expected outputs, it frequently encodes its own flawed assumptions into the assertions. You end up with green test suites that verify nothing meaningful.

Ephyra gets the division of labor right. Humans are good at specifying high-level contracts ("this operation must be idempotent", "partitioned query outputs must equal the unfiltered sum"). Machines are good at exhaustive, adversarial fuzzing. By having the agent focus solely on producing varied, valid inputs while a rigid deterministic invariant checks the outcome, you eliminate the risk of hallucinated assertions.

This is where AI in developer tooling provides actual value: not replacing specification and thought, but automating the painstaking exploration of edge cases.

Enjoyed the read? Share it with someone.

More writing