Loading VIBA…

The Sandbox Is Lying: Verifying AI-Generated Code Against Production Reality

The Sandbox Is Lying: Verifying AI-Generated Code Against Production Reality

The Sandbox Is Lying: Verifying AI-Generated Code Against Production Reality

Most AI-generated code that breaks in production passed every test it shipped with. That is not a paradox. When the same model writes the implementation and then writes the tests, both inherit one picture of the world: tidy types, stable configuration, a single user moving through a page one request at a time. The tests confirm the assumptions instead of challenging them. Verifying AI-written code before deploy is mostly the work of finding those shared assumptions and asking whether they hold where the code is actually going to run.

That reframes developer QA around environment fidelity rather than green checkmarks, and it is where multi-agent collaboration earns its keep.

Assumptions cluster in five places

Data shape. Development fixtures are polite. Production data has nulls where the schema says not-null, empty strings, mixed-case emails, unicode names, duplicate keys, and fields that are present but thousands of characters long. An AI-drafted parser usually assumes the documented type. Imagine a cursor-based pagination helper that assumes IDs increase monotonically. It works in a fixture table with five rows and skips records in a table written by concurrent inserts.

Configuration. Defaults copied from an example are the most smuggled-in assumption in generated code: a thirty-second timeout, a localhost fallback, a feature flag that does not exist in production. If the code has a default, ask who set it and whether it matches the deployed environment.

Time. Timezone handling, daylight saving boundaries, and sorting by a timestamp column that contains ties. Any function comparing dates deserves a fixed clock in its test rather than whatever the machine says.

Concurrency. Code that reads, decides, then writes is where generated logic looks correct and behaves badly. Two requests racing through the same check produce a state nobody designed.

Dependencies. The runtime version, the library version, and the shape of a third-party response that changed after the model's training data. Generated code often calls an API as documented rather than as it behaves today.

Give each agent a different question, not the same one

Running one prompt through three models and comparing answers is useful, but it is a weak form of review, because every model is still answering the question you already thought to ask. A sharper structure is to give each agent a distinct job inside one shared session.

VIBA lets you run several models — ChatGPT, Claude, Gemini and others — in one session, assign each a role, approve the key steps yourself, and see the cost per agent. That last part matters more than it sounds: it turns review capacity into a budgeting decision. You can spend one model on the unglamorous question of configuration drift instead of buying a fourth opinion about naming style.

A workable division of labour looks like this. One agent drafts. A second is told to list every assumption the implementation makes about its environment, and to add nothing else. A third gets the repository and traces what actually reaches this code at runtime: which callers, which payloads, which flags. A fourth produces plausible production failures that are missing from the test suite. You approve the critique before anyone acts on it.

The point is not that the second model is smarter. It is that it has not read the first model's confident summary of its own work.

Tests that survive contact with production

You do not need production access to verify against production reality. You need artefacts that carry real shapes into the test suite, and this is where classic software testing discipline still applies — just with a new source of code.

Capture one representative payload from a real request, strip anything sensitive, and check it in as a fixture. Contract tests against that payload catch more than pages of hand-written assertions. Run a risk-bearing path at realistic scale at least once: a query tested against fifty rows tells you nothing about the query plan at fifty thousand.

Where the code touches money, dates, or permissions, build small matrices. For example, you could run the same request as an anonymous visitor, a signed-in user, and an administrator, then assert on the response shape as well as the status code. Render the interface in two locales and check whether the layout collapses under a longer string.

Integrated testing beats isolated unit testing here. Repo testing exercises the path the way the application reaches it, with real imports and real configuration, while UI testing checks what a person actually experiences once the generated code is wired in. Beta testing a narrow cohort turns a subset of users into an evidence source, and ranked repair reports let you fix failures in order of severity instead of in the order an agent happened to notice them.

Make sign-off a decision with evidence attached

A signature on a release should mean something specific: this person knows which assumption is riskiest and what was done about it. Before approving, write one sentence naming the assumption that would cause the most damage if it were wrong, and one sentence of evidence about it. If those sentences are hard to produce, verification is not finished, regardless of what the test runner says.

Human approval at key steps is not a brake on AI tools; it is what makes them safe to use at speed. The goal is not to review everything. It is to review the right thing before the deploy button, not after.

If you want to see how role-based agents and per-agent cost tracking fit into that workflow, start at https://www.viba.guru, where you can run several models in one session and keep the final decision in your hands.

See VIBA: https://www.viba.guru