Blog

· 9 min read

How AI proves it's done: specs with IDs, gates and mutation testing

A checkbox ticked by the same agent that wrote the code proves nothing. How I use specs with IDs, gates, an independent verifier and mutation testing to demand proof.

  • ia
  • qualidade
  • testes
  • gates
  • mutation-testing
  • metodo

In the first scorecard I made of my method on Kravva, the gates dimension scored 2 out of 10 and the verifiable criteria dimension scored 3. The reason was simple and embarrassing: CI only ran the build, and each task's checklist was ticked by the same agent that had written the code. The AI said "done", and I had no way to disagree without redoing its work.

This post goes deeper into the second rule of the main article: AI does not certify itself. I'll show the whole mechanism, from the checkbox to mutation testing, with numbers from my projects and with what didn't work. The scorecard is my own self-assessment, not an external audit, and it measures the pipeline, not results in production.

Mandatory evidence: the checkbox needs a command

The first change was the cheapest. A checkbox only counts as done with three things recorded: the exact command, the exit code and a summary of the result. "I tested it and it works" doesn't count. A real test command, with exit 0 and a summary of what passed, does.

When closing a task requires pasting a command that actually ran, the shortest path becomes running the command.

On Blippy the evidence is audited too

On Blippy I turned the rule into a gate. Each task has a row in docs/processo/EVIDENCIAS.md with task, criterion, command, exit code, result and date. The evidence gate fails in three cases: a ticked checkbox with no row, a row with no exit code, and tautological evidence. If the recorded command is echo ok or true, the gate rejects it, because those commands always pass and prove nothing.

There is also an ordering rule, in the task execution skill: declare the verifiable before coding. The task is born with a Verificável: field holding the proof command. The reasoning is written in the skill itself: declaring it after implementing means picking the proof the code already passes.

Executable specs: the criterion carries an ID

Per-task evidence still leaves a hole. Who guarantees the test checks the right behavior? On critical surfaces, I write the criterion first, with a stable ID, and the test carries the same ID.

On Kravva the prefixes are RBAC (permissions), PAG (payment), PALP (predictions), PONT (scoring) and LGPD (Brazil's data protection law). On Blippy they are AUTHZ, PRIV, MEDIA, DATA, GW and PROTO. The format is given/when/then, the same one used in behavior tests. A real Kravva criterion, simplified:

### PAG-001: Invalid signature
GIVEN a payload received from the provider
WHEN the HMAC signature does not match the secret
THEN the API rejects the request
  and no transaction or access is created.

Here the signature is an HMAC that the payment provider sends along with the payload. The matching test has the ID in its title. This is the title of a real test (I broke the line to fit and left out the body):

it('PAG-001: given a missing HMAC signature, when the HTTP edge
    receives the webhook, then it rejects without touching transaction or access',
  async () => { /* ... */ })

A criterion can have several tests. PAG-001 has four, one for each way of forging the signature. Besides the test, each ID becomes a row in an evidence table: ID, test file, command, exit code, result, date. Two rules complete the design:

  • IDs are never reused. A criterion that goes away stays as REMOVIDO (removed) with the reason. The ID keeps pointing to the same concept forever.
  • The test mirrors the ID literally, so a text search links spec, test and evidence.

The traceability gate and its honesty

A script checks all of this on every push and in CI. On Kravva it requires a test title with the same ID, rejects a duplicated ID with different text, validates the evidence table and compares legacy gaps against a baseline that only goes down. The last run I recorded: 42 criteria linked to 82 test titles, with zero legacy gaps. On Blippy there are 30 criteria (AUTHZ 12, PRIV 9, MEDIA 4, DATA 3, GW 1, PROTO 1), on the same principle.

The most important part is what the gate does not guarantee. It proves there is a test with that ID. It doesn't prove the test asserts anything useful. An expect(true).toBe(true) with PAG-001 in the title would pass. The gate's documentation says this in plain words: it is a safety net against forgetting, not a certificate of correctness.

This limitation is the same one Birgitta Böckeler, from Thoughtworks, points out in her analysis of SDD tools, when she talks about a false sense of control. The whole second half of this post exists to close that gap.

What writing the specs revealed

The strongest argument for writing the criterion before the code came for free. While writing the payment and scoring specs on Kravva, on July 30, 2026, the process found real defects:

  • the webhook's payment confirmation ran outside a transaction;
  • a provider redelivery that aborted halfway left a payment without the matching pass;
  • the access table had no uniqueness constraint, so the same active access could exist twice (this became a migration with a unique index);
  • a match that became terminal without a score (cancelled, abandoned, postponed) kept the points from an earlier final result.

They showed up because, to write "GIVEN a redelivery WHEN processing fails THEN no payment is left without a pass", I had to look the failure case in the face. The spec worked as a review before it became a test.

Independent verifier: whoever wrote it doesn't give the verdict

For critical blocks, the final verification isn't done by the author. A fresh-context subagent, never the same one that implemented it, gets the block's IDs and tries to falsify each one: it inverts an assertion, removes a check, and sees whether any test notices. If no test complains, the test was decorative.

The verifier returns a verdict: approved, approved with caveat, or rejected. A high or critical finding keeps the phase open and can't be deleted. In the payment stage, for example, the verdict was "approved with caveat" and produced a follow-up: the "already paid, no access" case, from PAG-003.

Two caveats. The skill states that the verifier does not replace human review. And, since October 2026, verification is done by a different model from the one that implemented, to reduce the risk of the same blind spot showing up on both sides.

Mutation testing: proving assertion strength

Falsifying by hand works, but it doesn't scale. On Blippy I automated the idea with mutation testing: a tool (Stryker) changes the code on purpose, creating mutants, and runs the tests. If the tests keep passing, the mutant survived, and that is mechanical proof of a weak assertion.

I applied it to two pure modules of the protocol package, permissions and ID generation, where the cost is low and the risk is high. The result: 96.48% of mutants killed (137 of 142), with a minimum threshold of 85% in the gate.

The detail I like most is the negative test of the gate itself. There is a --weaken mode that swaps strong assertions for toBeDefined(). With the tests weakened on purpose, the score drops to 71.83% and the gate fails with exit 1. A gate that never fails in a test doesn't convince me, so it has to prove it knows how to fail.

The sentence that sums up why this is worth more than the alternative: a surviving mutant is mechanical proof of a weak assertion, while a second LLM agreeing is a correlated opinion. Important: mutation testing runs only on Blippy, on pure modules. Not on Kravva yet.

Ratchet or zero baseline: it depends on the ground

There are two ways to handle debt in a gate, and I used both.

On Kravva, a ratchet. The project already existed when the gates arrived. The backend lint had 205 legacy errors. Instead of pretending it was clean or postponing CI until everything was cleaned up, the gate came in with a baseline: the current number is the ceiling, and it can only go down. Raising the baseline to make CI pass is forbidden by AGENTS.md. CI started protecting new code, and the old debt became visible.

On Blippy, a zero baseline. The project was born with the gates, so there was no legacy to protect. Any violation fails. The only exception is a waiver: a deadline of at most 30 days, a reason, an owning task and a cap of 10 active waivers. At the last measurement, no waiver was active.

The rule of thumb: brownfield calls for a ratchet, greenfield calls for zero. A zero baseline on legacy code paralyzes the team, and a ratchet on a new project is a license to be born with debt.

Blippy's gate rings

The earlier a gate fails, the cheaper the fix. That's why I organized the gates in rings, from fastest to most complete:

RingWhen it runsWhat it runs
1agent hook, on every edited file (2 s cap)structural rules with ast-grep
2pre-commit (10 s cap)gitleaks on what was staged; Prettier and ESLint applying fixes
3pre-push (120 s cap)format, lint, types, tests, boundaries, protocol, design system, docs, traceability, evidence, waivers
4pull request CIring 3, plus semgrep, gitleaks on the history, integration and mutation; no bypass allowed
5nightlyload and dependency scanning (planned)

Across the whole history, the last recorded gitleaks scan found 0 leaks in 409 commits, and the gate was tested with a fake credential to prove it fails. Semgrep, for its part, has already flagged practices of mine: a CI Action pinned to a moving tag instead of a SHA, math/rand in a fuzz test, and pnpm without a supply chain policy. All three were fixed: SHA pinned, a local number generator and a supply chain policy in pnpm.

What didn't work

This isn't a finished system. The failures that taught me the most:

  • Green CI, red deploy. On Blippy, the types ring ran tsc --noEmit, and the production build ran vue-tsc -b. A file passed one and failed the other. I logged it as pending and learned that the gate has to run the same command as the deploy.
  • False task closure. A UI task was marked as done, and I caught in review that part of the screen (a native select in an overlay) was still in the old pattern. The task's preload now mentions the missing component. Human review caught it, not a gate.
  • Escambo, with light gates. Escambo had only lint, types and a 57-line architecture check. Six packages closed in one day, and the planning method was good. Two months later, running the app end to end with seven personas, core bugs showed up in features marked as finished, such as the owner of an offer who couldn't counter a proposal. Planning well doesn't replace proving.

Takeaways

  • A checkbox only closes with command, exit code and summary. On Blippy, tautological evidence like echo ok fails, and the verifiable is declared before coding.
  • Criteria with stable IDs (given/when/then) on critical surfaces, the same ID in the test title, and a gate that rejects a criterion without a test. It proves the link, not assertion strength.
  • Writing the specs found real defects in payment and scoring before any test ran.
  • Whoever wrote it doesn't verify it: a fresh-context subagent and, since Oct 2026, a different model. For assertion strength, mutation testing with a threshold and a negative test of the gate itself.
  • Legacy calls for a ratchet that only goes down, a new project calls for a zero baseline with short waivers. A good gate fails early and runs the same command as the deploy.

Continue the series: how I develop with AI, mockup as specification, runner and /goal (coming soon) and SDD in practice (coming soon).

Written by Maycon Liborio, full stack developer. If this helped you or you disagree with something, reach out on LinkedIn.

More posts

Maycon Liborio

São José dos Campos, SP, Brazil

© 2026 · Handmade with Nuxt, modern CSS and zero UI libraries. Data generated from my master profile on every build.

esc

Go to

Projects

Posts

Actions

↑↓ navigate↵ open/ or ⌘K toggles