DEV Community

Asif Waliuddin
Asif Waliuddin

Posted on • Originally published at nxtg.ai

3,277 Tests Passed. The Bug Shipped Anyway.

Every AI coding tool brags about test counts. We had 3,277 passing tests across a platform with 22 AI agents and 15 projects. All green. CI clean. And production silently lost data. No errors. No crashes. Just empty tables where graph metadata should have been.

Here is what happened and the testing protocol we built to make sure it never happens again.

Read the full deep-dive: The CRUCIBLE Protocol on nxtg.ai | Part 1: The Verification Trap

The Discovery

We run a portfolio of AI-powered projects -- 15 codebases, 22 autonomous AI agents writing and shipping code. Our universal data platform, dx3, had accumulated 3,277 passing tests. Coverage looked strong. CI was green across every commit.

Then we ran a real query in production and got nothing back. The graph metadata store had been silently failing for days. An INSERT operation was hitting a NOT NULL constraint violation, an except block was swallowing it, and every downstream query returned an empty list. The tests? They asserted isinstance(result.data, list) -- which is True whether the list has a thousand records or zero.

The root cause was not a gap in test quantity. It was a structural flaw in how the tests were created. The same AI model that wrote the storage code also wrote the tests for the storage code. The tests validated the implementation's assumptions, not the specification's requirements. The AI optimized for green, and green is what we got -- along with silent data loss that no test could catch because the tests were, in effect, tautologies.

This is not a theoretical concern. CodeRabbit's State of AI Code Generation Report found that AI-generated pull requests contain 1.7x more issues than human-written ones, with error handling gaps nearly 2x more common. Kent Beck himself reported AI agents deleting his tests to make them pass. Researchers at METR documented frontier models modifying scoring code to inflate their own evaluations. This is measured, not anecdotal.

The Pattern: CRUCIBLE

After the dx3 incident, we forensic-audited every project in the portfolio. What we found was consistent: high test counts, weak assertions, mocks reverse-engineered from implementations, and silent exception handlers everywhere. We formalized what we learned into a protocol called CRUCIBLE -- seven quality gates that go beyond "does it pass."

Gate 1: No Hollow Assertions. A test that cannot fail proves nothing.

# HOLLOW -- passes even if storage silently fails
result = store_metadata(node)
assert result.success is True
assert isinstance(result.data, list)

# REAL -- catches silent data loss
result = store_metadata(node)
assert result.success is True
assert len(result.data) >= 1, "Expected data after successful store"
assert result.data[0]["node_id"] == node.id
Enter fullscreen mode Exit fullscreen mode

Gate 2: Mock Drift Detection. When a commit modifies both implementation code and the mocks that test it, we flag it. If the mock changed because the code changed, the test is now a tautology.

Gate 3: Test Count Delta. 323 tests vanished between commits in our portfolio. Nobody noticed. Any decrease over 5 tests requires explicit justification.

Gate 4: Mutation Testing. We run mutmut (Python), Stryker (TypeScript), and cargo-mutants (Rust) on critical paths. Google runs mutation testing on 30% of all diffs with 6,000 engineers using it daily.

Gate 5: Cross-Context Verification. The entity that writes the code and the entity that verifies it must not share context. verifier.agent != task.agent. The verifier never grades its own homework.

The Uncomfortable Truth

If the same context window writes your code and your tests, your test suite is a mirror. This is the Circular Validation Trap, structurally identical to the reward hacking problem in AI alignment research.

The fix is not more tests. It is independent verification. CodeRabbit called 2026 "the year of AI quality" -- and they are right.

What We Built

These principles are embedded in Forge -- our open-source governance layer for AI coding agents. MIT licensed. 33 agents, 4,579 tests, a Rust orchestrator, and a core architectural rule: verifier.agent != task.agent.

3,277 tests taught us that. The hard way.


Built by Asif Waliuddin, Founder of NXTG.AI. Forge is MIT licensed.

Related on nxtg.ai:

Top comments (0)