Loading VIBA…

Try to Break It: Verifying AI-Generated Code With Falsification Tests

Try to Break It: Verifying AI-Generated Code With Falsification Tests

Try to Break It: Verifying AI-Generated Code With Falsification Tests

AI-generated code has a particular texture. It reads well, the names are consistent, and the tests it wrote for itself pass on the first run. That last part is the problem. When the same model writes the implementation and the tests, the tests tend to encode the model's assumptions rather than your requirements. Passing them tells you the code agrees with itself.

A more useful posture is falsification: instead of asking "does this work?", ask "what would have to be true for this to be wrong, and can I make that happen?" Here is how that plays out in practice.

Know the failure modes that survive a happy-path test

Most AI-generated code that breaks in production fails in a small number of predictable ways.

Silent fallbacks are the most common. A function catches an exception, logs nothing useful, and returns an empty list or a default object. Every caller downstream now treats a failure as a valid empty result. Imagine an inventory lookup that returns an empty array when the database is unreachable. The checkout page renders "out of stock" instead of erroring, and nobody notices for a week.

Invented interfaces come next. A model will confidently call a method that exists in a popular library but not in the version pinned in your lockfile, or that was renamed two major versions ago. It compiles in the model's imagination and fails in your CI.

Then there is mock leakage: tests that stub out the exact component under test, so the assertion verifies the stub. And boundary blindness: empty inputs, single-element collections, duplicate keys, negative numbers, and timestamps that cross a timezone boundary get far less attention than the middle of the range.

Write the test that should fail

Before reading the implementation, write the contract down as assertions. If a function claims to deduplicate a list, the interesting cases are an empty list, a one-element list, a list where every element is identical, and a list containing values that cannot be hashed. If a function calculates a discount, the interesting cases are a negative quantity, a zero price, and a rounding boundary such as 0.005.

Then ask the model to state its assumptions in plain language before you look at the code. Assumptions are where the bugs live. If it says "assumes the caller validates the currency," you have found an unverified dependency between two pieces of code, and you can decide whether to enforce it or document it.

One technique that costs almost nothing: temporarily delete the error handling. Remove the try/except blocks, remove the default parameter values, and run the suite again. If nothing fails, the error paths were never exercised, and you have no evidence about what happens when they run for real. That is software testing doing its actual job, producing information rather than reassurance.

Audit the seams, not the surface

You do not need to read every line of generated code. You do need to read the places where it touches the rest of your system.

Check the imports and the dependency diff. A new package added for one helper function is a supply chain decision, not a formatting detail. Check that raised error types match what callers actually catch, because a custom exception that nothing handles is a crash waiting for a trigger. Check serialization at the boundaries: date formats, decimal versus float for money, null versus absent fields. Check that a failed upstream call cannot be reported as success. A 500 that becomes a 200 with an empty body is the kind of defect that hides until reconciliation.

A quick pass over the diff looking for bare except clauses, functions that return None on every path, and defaults that only make sense on a developer laptop will catch a surprising share of real problems. This is the part of developer QA that is hardest to automate and easiest to skip.

Run several models as adversarial reviewers, and keep the approval yourself

A single model reviewing its own output tends to agree with itself. Give different models different jobs instead: one to hunt for security issues, one to trace data loss and partial writes, one to find missing test coverage. Different training and different framing surface different classes of defect.

That is the pattern VIBA is built around. You can run ChatGPT, Claude, Gemini and other models in one shared session, assign each one a role, approve the key steps yourself, and see the cost per agent as the work proceeds. Repo testing runs against the actual codebase rather than a pasted snippet, and ranked repair reports order findings by risk so you can decide what must be fixed before deployment and what can wait. UI testing and beta testing cover the behaviour that only appears when the application is actually running. For developer QA teams, the value is not that more agents exist, but that each one can be pointed at a different question.

Conclusion

Verification is not a ceremony you perform at the end of a build. It is an attempt to disprove your own work while it is still cheap to be wrong. If you cannot make the code fail on purpose, you have real evidence. If you can, you found the problem before your users did.

Ready to put multiple models to work on the same review? Start a session at https://viba.guru and assign the roles yourself.

See VIBA: https://viba.guru