The Query Persists. The Plan Doesn't.

Adam Chlipala's SQL analogy explains spec-driven development better than anything written since Codd — and it hands us the roadmap. The query is the spec, the generated code is a disposable plan, and the whole argument rests on one uncomfortable sentence: we still have to check the output.

Here is a pain every engineer who has touched an AI code generator knows intimately, before we mention any product, tool, or vendor:

You generated the code. It was almost right. You hand-tuned it. And then you committed the hand-tuned output to version control — because deep down you know that if you deleted it, nothing left in your repo could regenerate it. The prompt is gone, the model has moved on, and your actual specification — the thing you wanted — exists nowhere except as residue inside a file you no longer dare to touch.

You are version-controlling the output of a computation because you have no way to persist the input. Sit with that. Database people fixed this problem fifty years ago.

The analogy, stated properly

Adam Chlipala — MIT Conner Professor, CSAIL Programming Logic and Verification group, the person whose Fiat Cryptography verification machinery ships inside Chrome and BoringSSL’s TLS stack — wrote the sharpest thing anyone has written about AI code generation. It appeared on his Substack, Structure and Guarantees, on 2026-08-18, under the title “Automatic Programming Should Be More Like SQL” (link). The title itself is Chlipala’s own in-text restatement of his thesis, and it is worth quoting his framing directly, because database engineers will recognize it instantly:

we save the SQL queries in version control… but we don’t put the query plans in version control… exactly the information that makes remaining code generation sufficiently predictable

That is the whole insight. The query is small, durable, and meaningful. The plan — the query engine’s chosen execution strategy — is large, disposable, and regenerated at will. Nobody grieves a query plan. And when the engine picks a different join order after a statistics update:

It’s OK if we get a different one each time!

The reason it’s OK is the part everyone skips. It’s OK because two guarantees hold at the same time: the semantics are exact (SQL has a formal meaning; a plan either implements the query or it doesn’t), and the engine is trusted (decades of hardening, checkable against the standard). Different plan, same meaning — always.

Four mappings, and you understand the architecture

Chlipala’s analogy doesn’t just explain the pain. Mapped 1:1 onto a spec-first build system, it teaches the entire architecture in one table:

SQL world Spec-first world The concrete artifact
The query The CBRL spec — requirements with acceptance criteria, the durable statement of intent Your .cbrl source, in version control
The (disposable) query plan The brew output — generated code, tests, prompts What the generators emit; delete it any time
The persisted index The pinned Vintage — a sealed, content-addressed bundle (Ed25519-signed, recipes/vintage.ts) The content-hash pin your re-brew resolves through
Trust in the query engine Comparator verdicts — machine-checked evidence the output honors the spec StateVerdict / TransitionVerdict / InvariantVerdict

If you have ever argued about “prompt engineering” versus “spec engineering,” this table ends the argument. Prompts are query plans: emissions of an engine at a point in time. The spec is the query. Pin the vintage, not the plan.

The whole lifecycle on one line — spec, lint, generate, run, compare, seal, and the regenerate loop that makes plans disposable:

Brewed-change lifecycle: CBRL spec → criteria-lint → generate → run → compare (verdicts) → seal (Ed25519 Vintage) → regenerate, with the re-brew loop back to generate

The turn: why SQL gets away with it

Here is where Chlipala’s piece stops being a nice analogy and becomes a roadmap. SQL can treat plans as disposable because of the two guarantees above. Software generation today has neither:

And this is precisely the gap Chlipala names. His third quote is our thesis in an MIT professor’s mouth:

We still have to check the output. The role of a trustworthy code generator is to make that practical.

The missing layers he calls for are not hypothetical. They are two specific things:

  1. Exact-enough semantics for the parts that matter. Lint the requirement statements themselves — ambiguous, untestable, or contradictory criteria get rejected before generation. In our stack that layer exists: the criteria linter (lint/criteria-lint.ts) is, in our measured experience, the cheapest quality intervention in the entire pipeline.
  2. Evidence instead of trust. After generation, don’t review 25,000 diff lines — check verdicts. Comparator verdicts (the FR-13/14/15 evidence gate: state reached, transitions honored, invariants held) are the stand-in for “the engine is trusted.” You don’t trust the generator; you check the output, practically.

The gap between SQL’s world and ours is not conceptual. It is two engineering layers, and they are buildable today.

Run it yourself: the pin-and-regenerate demo

The claim “the plan is disposable” is testable in about four commands against a brewed project:

  1. Brew once, pin the Vintage. The brew seals its output bundle — requirements, tests, prompts, decisions — into a content-addressed, Ed25519-sealed Vintage, and the linker records the content-hash pin (pinnedVintageHash in brewery-v2/linker.ts). Note the pin. This is content-hash pinning: the address is the artifact’s digest, sealed and signed — not a pointer into mutable state.
  2. Delete the generated code. All of it. The plans are disposable; that’s the claim under test.
  3. Re-brew from the pinned Vintage. The linker resolves the recorded content hash, re-runs generation from the sealed inputs, and produces a fresh plan. Different model temperature, different join order, different code.
  4. Watch the verdicts re-confirm. The comparator re-runs the evidence gate and the verdicts come back: StateVerdict: reached, TransitionVerdict: honored, InvariantVerdict: held. The new plan, re-checked against the same query.

Different plan, same meaning.

One honesty note, in the section itself rather than a footer: what the demo demonstrates is verdict re-confirmation, not a proof of semantic equivalence between the two plans — no equivalence checker for generated programs exists in the stack yet (the conformance module, conformance/, is the closest thing to one). That limitation is exactly Chlipala’s third quote pointed back at us: we still have to check the output, and the role of a trustworthy generator is to make that practical. Verdicts make it practical. They don’t make it a proof. Yet.

The sequel is already written

Databases didn’t start with trusted engines. They started with a formal data model, then built forty years of machinery — linters for the query language, plans as evidence, seals over every persisted artifact — until “trust the engine” became an earned property instead of a hope. Automatic programming is at the beginning of that same road, and for the first time the next layer is specified precisely enough to build.

The query persists. The plan doesn’t. Everything else is engineering.

Sources