When Mostly-Right AI Code Fails in Production

The Probability Pixie: Tiny Errors, Perfect Confidence
When Mostly-Right AI Code Fails in Production

AI-generated code rarely announces its mistakes. It does not usually crash on contact with the repository or produce an error message that points to the exact line of failure. More often, it delivers something that looks right, passes a quick review, and quietly carries a small defect into the next stage.

That is the Probability Pixie.

The Pixie is the monster of mostly-correct output. Its gift is a world where 94% accuracy feels like 100% until you are standing in the remaining 6%, trying to understand how an apparently ordinary change produced a serious result.

Language models make this danger easy to forget. They do not look up an answer and report what they found. They predict likely next tokens based on patterns in their training. That process can produce useful code, clear explanations, and good suggestions. It can also produce an answer that sounds certain because certainty is part of the style, not because the underlying claim was checked.

Pattern completion is not truth. The Pixie appears when a team forgets that distinction.

You can usually spot it after someone says, "I spot-checked a few and they looked fine." That is the Pixie's calling card. A handful of successful examples feels like evidence that the whole system is sound. It is not. Spot checks are useful for finding obvious failures. They are weak protection against the quiet edge case that matters.

The compounding math makes the problem worse. If each step in an AI pipeline is 94% accurate and you chain five steps, the end-to-end accuracy is about 73%. Chain ten steps and it drops below 54%. Each individual step can look acceptable while the complete workflow becomes unreliable. The dust accumulates.

These failures are rarely dramatic. A financial calculation is off by a fraction of a percent. Search results are relevant but sorted in the wrong order. A timestamp is correct in one timezone and wrong in another. A parser handles the normal input and misreads a boundary value. The output remains plausible, which is exactly why it survives review.

Plausibility is the Pixie's camouflage.

The answer is not to ban AI-generated code. The answer is to stop treating generated code as verified code. Every function still needs a human who understands what it is supposed to do, the assumptions it makes, and the ways it can fail.

That means writing tests before or alongside the implementation. Not asking the same model to generate a test suite and then calling the result independent verification. AI-generated tests tend to follow the happy path because the happy path is easy to describe. Edge cases require someone to know which assumptions are dangerous.

Write those cases by hand. Test empty input, malformed input, missing data, timezone boundaries, rounding, permission failures, retries, duplicate requests, and unexpected ordering. The right list depends on the function, but the principle is stable: tests should encode human knowledge of what could go wrong.

For critical paths, the standard should be higher. Financial calculations, security logic, migrations, and data-integrity code deserve line-by-line human review. That review may feel slow. The inconvenience is the point. It creates a deliberate pause between plausible output and system behavior.

Guardrails also help. Keep validation close to the boundary where bad data enters. Use types and constraints that make invalid states difficult to represent. Log decisions that would otherwise be invisible. Make failures loud enough that a reviewer cannot mistake them for normal output.

The Probability Pixie is not one bad suggestion. It is an operating condition. You do not defeat it once and move on. You build a process that assumes small errors will appear, then make sure those errors have fewer places to hide.

The dust is always settling. Review the code anyway.

>