DEV Community

davis
davis

Posted on Edited on

The agent said 100% mutation coverage. I reran it: 97.6%

 A coding agent implemented a limit order book in SystemVerilog for me. Forty minutes,
clean report: 25 directed tests, 10,000 random steps with zero mismatches, mutation
score 100%, coverage 98%, 100.4 MHz on an ECP5.

I reran everything. Nine out of ten numbers matched. One did not.

mutants   : 43
killed    : 41
survived  : 1     <- it reported 0
equivalent: 1
score     : 97.6% <- it reported 100%
Enter fullscreen mode Exit fullscreen mode

The surviving mutant forced cmd_busy to zero. I applied it by hand and ran the whole
suite: green. The tests really could not see it.

Why "looks covered" is not covered

That mutant means: while a multi-cycle TRADE is executing, a query must wait.

The suite did have a test where a command and a query were issued on the same cycle.
But both targeted the same order id, so the addresses were identical and the read
collision produced no wrong data.

It tested the shape, not the substance.

I added two tests:

  1. Command on order A, query order B (different addresses) - still not caught.
  2. Query issued during a TRADE - caught.
FAIL [D38 qry qty]: got=5 exp=77
FAIL [D38 qry level]: got=300 exp=400
Enter fullscreen mode Exit fullscreen mode

The query returned during the TRADE and got whatever order the TRADE was reading
(quantity 5, level 300) instead of the queried order (77, 400).

After that: 42 killed, 1 equivalent, 0 survived. That is what 100% looks like.

Where the gap actually came from

Not from the agent's ability to write RTL. From the places where my spec was vague:

What the spec said What happened
"TRADE ignores side" It decided "if there is a bid, take the bid"
"Fmax >= 100 MHz" It hit 100.01 MHz and stopped
"Mutation >= 90%" It stopped at 94%
"42/42 killed" (reported) 41/42 when I reran

Every vague sentence in a spec becomes a gap in the code, verbatim.

So I made acceptance executable

I extracted the workflow into a small template. The core is one script, grader.py.
It reads gates.json, runs each command, extracts the numbers with a regex, and
decides pass or fail.

{
  "id": "mutation",
  "cmd": "make mutate",
  "checks": [{"regex": "mutation score:\\s*([0-9.]+)%", "min": 100}]
}
Enter fullscreen mode Exit fullscreen mode
[PASS] lint          1.6s  OK no match (ok)
[PASS] sim         101.4s  OK 38/38; OK RANDOM: 10000 steps, 0 mismatches
[PASS] mutation    484.2s  OK 0 (max 0); OK 100.0 (min 100)
[PASS] coverage     24.9s  OK 97.5 (min 95)

RESULT: 4/4 passed
Enter fullscreen mode Exit fullscreen mode

The value is not automation. It is not taking the agent's word for it.

Three things worth keeping

  1. An agent's report is what it remembers, not what is true now. It runs once, records the numbers, keeps editing, and forgets to rerun.
  2. Test behaviour, not implementation. "Same cycle" and "different addresses" are two different equivalence classes; test only the first and the mutant survives.
  3. Every "should" in a spec needs an executable check. A "should" without a check becomes "the agent says it did".

Links

If you have a better way to get an agent to notice its own tests are toothless, I would
like to hear it. That is the part I have not solved.

Top comments (1)

Collapse
 
paragonaimag profile image
Paragon •

Your 97.6% rerun against the claimed 100% says it all — our YouTube click-through rate is 1.3% on 13,340 impressions, and the headline number never tells the whole story.