SDCourse overview

Section 7 · Lesson 4

Compile the Product — One Spec, Many Targets

Stop maintaining twin codebases that drift apart. Treat the spec as IR, generate Go, Rust, and UI skins from one source of truth, and engineer determinism so every artifact is repeatable.

"There is only one source of truth. Code is an emitted artifact.

The same product, many times over

Multiple versions of one product — different platforms, different performance tiers — start as identical twins and quietly become strangers. A bug fix lands in one. A feature is forgotten in the other. That drift is a one-way ticket to a maintenance nightmare.

Go and Rust were twins — for a week

A Go service gets a high-performance twin in Rust. For a week they match. Then the codebases diverge: unique bugs, unique features, two products that only look similar on the surface. Double the work, double the mental overhead, double the chance of catastrophe.

Stop rewriting. Start compiling the product.

The mental model changes: you are not maintaining two codebases. You are compiling one product for different targets. In spec-driven development the specification is the asset. Code is a temporary artifact emitted from that source of truth. Update the spec; regenerate everything.

Spec in, artifacts out

One authoritative spec feeds a generation layer that acts like a compiler. Out the other end: a Go service, a Rust service, a Flutter UI — implementations that are guaranteed to behave identically from a functional point of view. You compile the product, not just the code.

The LLVM analogy

LLVM uses a common intermediate representation to generate machine code for many CPUs. In SDD the spec is that IR, and the targets are platforms or languages. Same idea, scaled to the product.

What must never change

The whole scheme falls apart without discipline about what can differ and what cannot. Three pillars: functional invariants (core behaviour), contract invariants (how the system talks to the world), and quality invariants (performance and reliability that every variant must meet — no exceptions).

Four steps to identical twins

Write a spec with no language-specific details — pure intent. Freeze the API contract, for example with OpenAPI. Create separate, comparable implementation plans for each target. Benchmark both with the same controlled harness so you are comparing apples to apples.

The what is identical. Only the how differs.

Plan A for Go might use a standard HTTP library and goroutines. Plan B for Rust might use a different web framework and an async runtime. Libraries and runtimes are free to change. The functional spec and the API contract are not.

The same split for interfaces

Be ruthless: core flows, validation, and accessibility are functional — they cannot change. Layout, colour, and styling are aesthetic — they can vary as themes or skins on the same behaviour. Pull tokens and component structure from a design source of truth such as the Figma API so variants follow intended design, not someone’s interpretation.

Determinism is engineered, not wished

Reliable, repeatable, predictable results do not appear by hoping. You build them: stable inputs (versioned spec, pinned dependencies), stable pipelines (repeatable generation steps), stable outputs (every artifact traceable to the exact spec version that created it).

The number is one

In a true spec-driven system there is one source of truth — not two drifting codebases, not a spec plus some code. Just one. That is how you eliminate the chaos. If the spec is the most valuable asset, the code you spend so much energy writing is an emitted artifact — regenerated, not patched in parallel.

Week one

A Go service and a high-performance Rust twin — identical for a week.

The drift

Two distinct products: unique bugs, unique features, double the maintenance, and twice the chance something goes wrong.

Spec as compiler

One spec in. Many implementations out. The generation layer is the compiler.

Spec

Source of truth

Pure intent — language-agnostic, versioned, the real source code of the product.

Generation

Compiler

A repeatable pipeline that emits implementations from the spec, the way a compiler emits machine code from IR.

Artifacts

Targets

Go service, Rust service, Flutter UI — different how, identical functional behaviour.

Loading Product compiler…

LLVM

LLVM IR is the common intermediate form; backends emit machine code for many CPUs.

SDD

The spec is the IR of the product; generation backends emit Go, Rust, Flutter, and other targets.

Three unbreakable pillars

Functional

Core behaviour that every variant must share — critical user journeys and exact error handling.

Contract

How the system talks to the outside world — API shape, fields, and status codes, frozen in OpenAPI.

Quality

Performance and reliability every generated variant must hit — for example a P95 latency budget. No exceptions.

Executable guardrails →

Four steps to identical twins

  1. 1

    Write pure intent

    A spec with no language-specific details — behaviour, not libraries.

  2. 2

    Freeze the contract

    Lock the API solid with OpenAPI so every target speaks the same shape.

  3. 3

    Plan each target

    Separate, comparable implementation plans — different stacks, same spec and contract.

  4. 4

    Benchmark together

    The same controlled harness for every variant so you compare apples to apples.

Go and Rust — same what, different how

Plan A — Go

Standard HTTP library and goroutines

A familiar, concurrent service that still must satisfy the frozen contract and quality budget.

Plan B — Rust

A different web framework and an async runtime

A high-performance twin. Technologies change; functional spec and API contract do not.

Functional (cannot change)

Core user flows, validation rules, accessibility — behaviour that cannot change between skins.

Aesthetic (may vary)

Layout, colour palette, styling — free to vary as themes on the same core behaviour.

Pull design tokens and component structure from a design source of truth such as the Figma API so UI variants follow intended design — not a remembered screenshot.

Engineer determinism

You cannot wish for repeatable builds. You construct them.

Stable inputs

Versioned spec. Pinned dependencies. No exceptions.

Stable pipelines

Generation steps that are repeatable and consistent every run.

Stable outputs

Every artifact traceable to the exact spec version that created it.

Verification gates (Section 6 · Lesson 2) →

Practice

Check your understanding

A few minutes of recall now saves rereading later.

0 of 4 answered
  1. 1.In multi-target SDD, the primary asset is…

  2. 2.In the LLVM analogy, the spec is…

  3. 3.A contract invariant is…

  4. 4.Which of these may vary between UI skins?