Three boxes labelled dev, QA and production. A zip archive moves between them carrying a pipeline definition and a Python script with its model name and generation time. A red cross sits over a second path where the script is regenerated by a model on the production side.

A few weeks ago I promoted a pipeline from QA to production and it failed its own data-quality check on the first run. QA had been green for nine days. Nothing in the source had changed. The pipeline definition was identical, I diffed it twice.

What had changed was the script. The data-quality rules on that pipeline were written by a model from a plain-English instruction, and my promotion step regenerated them on the production box. The instruction and the model name were the same ones QA had used. The run was nine days later. The QA version checked that a trade date was not in the future. The production version checked that it was not in the future and not a weekend. Fair enough, except the feed includes Saturday settlements, and the model had no way to know that.

Nobody had reviewed the production script, because nobody knew there was one. We thought we had reviewed it in QA.

Generated code is an artifact, not a function of its prompt

The mental model that got me was treating the prompt as the source of truth. Store the instruction, and the script is just a cache you can rebuild any time. That’s how I had built it, and it’s how most agent-driven tooling I’ve looked at still behaves.

It’s wrong because the thing it’s imitating works for a reason that doesn’t carry over. Rebuilding a jar from source on the production host is fine, and plenty of shops do it, because the compiler hands you the same bytecode from the same source every time. Regenerating a script from a prompt looks like the same move. It isn’t. A model is a compiler with a random seed and a release schedule you don’t control, so two runs from the same prompt are two programs that most of the time happen to agree.

So the rule I landed on is old and boring: whatever you tested is what you move, and you keep a record of where it came from. The only new part is that the thing being moved was written by something that can’t tell you why it chose the weekend check.

What travels, and what doesn’t

The unit I promote now is a tap, the script that pulls a data feed, together with the pipeline that consumes it. The pipeline is where the generated code lives: every AI-written data-quality and transformation script, along with the model that wrote it and when. The export is one archive holding the tap script and its incremental state, the pipeline definition, the validation schemas, and those scripts.

Restoring that archive on the next environment makes those scripts the live scripts. No model is called. Production runs the bytes QA ran, and the restore result says so, script by script: imported, kept, or regenerated, with the reason. Regenerated only happens when the archive has no record of a script, or when the instruction or source schema on the target doesn’t match what the script was written for. If you want a fresh generation anyway, there’s a flag, and you have to type it.

Secret values stay out of the archive; it lists only the names it needs. So do destination data and run history, because what dev did is not evidence about production.

Promotion is a pull request

Scripts live in Git, one branch per environment. An agent saves a tap in dev, it’s committed on the dev branch and pinned to that commit. Promotion to QA is a pull request from dev to qa, so a human sees the diff where humans already look at diffs. The restore on QA then finds the same bytes at the head of the branch and commits nothing.

The agent should know where it is standing

Each install carries a label: dev, qa, production. The UI header shows it, red for production and amber for anything else. The archive records where it was exported from, and restoring it under a different label adds a warning naming both. The restore still goes ahead. The warning is for whoever reads the log a week later.

Agents get the label too. A connected agent is told which environment it’s on before it does anything, and every tool call that changes or removes something answers with the environment it changed. When Claude Code says “deleted pipeline vendor_prices on production” and I was expecting dev, I know in the same sentence. On production, the agent asks a person before any change.

I have three nearly identical MCP server entries in my config, one per environment, each with its own scoped key. It looks like clutter and I’ve stopped minding.

Why this matters for approvals

In the last post I argued that an approval prompt with no evidence in it is just a permission prompt. Evidence from a rehearsal run is only worth something if the thing you rehearsed is the thing that ships. A promotion step that quietly regenerates code voids every approval before it. The diff in the QA pull request and the numbers on the evidence card were about a script that never ran in production.

Agents can write the pipeline now. The discipline we’re still building is treating what they write as code that gets committed, reviewed, and then promoted as the same bytes that passed the tests.

Promote the script, and keep the prompt around for the next time you need to write one.


Todd Fearn is the founder of Datris.ai, an open-source, agent-native data platform built on the Model Context Protocol, and he runs IData Corporation, a data engineering consultancy for financial services firms. He has spent about thirty years building production data infrastructure inside institutions like Goldman Sachs, Bridgewater Associates, Deutsche Bank, and Freddie Mac.