# Software Factory

**Also known as:** AI software factory · Dark factory · Agentic delivery pipeline  
**Category:** AI Patterns (Model in the loop)  
**Complexity:** 5/5  
**Guide:** https://layra4.dev/architectures/ai/software-factory

*Specs go in, tested software comes out, and nobody reads the code.*

Spec-driven development still has a person check the diff. That stops working when agents write more code in a day than a team can read in a week. An AI software factory removes the step: agents plan, write, test and merge, and no person writes or reviews the code. It is also called a dark factory, after the factories that run with the lights off because nobody works on the floor.

So quality has to come from somewhere else. People write the specs. A separate set of end-to-end scenarios, kept where the agents cannot read them, decides whether a build ships. Every outside service is replaced by a fake that behaves like it, so the scenarios can run thousands of times without touching production.

> **In one sentence.** Once agents write all the code, quality can no longer come from reading it. It has to come from what people still control: the spec going in and the checks coming out.

## Origin (1969)

The name is old. Hitachi opened its Software Works in 1969 to build software like a production line, and Microsoft's Software Factories (2004) meant generating code from models. The agent version arrived in 2026, when StrongDM described a team whose rules were that no person writes or reviews code.

## The parts

### The intake

Specs that describe behaviour, written and approved by people. It is the only place human intent enters the line, so it is where review time goes.

- One spec per change, with testable criteria
- A bad idea rejected here costs a paragraph

### The line

Agents that plan, implement and fix in parallel, each in its own sandbox and branch. Nobody watches it run, so it needs hosted harnesses, a job queue and budgets, not a person at a keyboard.

- A disposable workspace per job
- A budget per job and per day

### Holdout scenarios

End-to-end user stories kept outside anything the agents can read. A build is scored on how many scenario runs a user would accept. The agents never see them, so they cannot write code that only passes the test.

- Written and changed by people only
- Scored as a pass rate over many runs, not one green tick

> scenario: an expired session refreshes without losing the unsent draft

### Service twins

Fakes of each outside service — sign-in provider, issue tracker, chat — that copy its API and its odd behaviour. Scenarios run against them as often as needed, with no rate limits, bills or risk to real data.

- Sit at the network edge, so the real code runs end to end
- Checked against the real service now and then, so they do not drift

## Design rules

### Move review to the two ends

People stop reading diffs, so put their time on the spec going in and the scenarios coming out. A team that skips both has not built a factory. It has stopped checking.

### Hide the exam from the students

If an agent can read a test, it will sooner or later change the code, or the test, until it passes. Keep the gating scenarios in a store the line cannot read, and change them only through human review.

### Fake the world, not the code

Mocks inside the code are written by the same agents and prove little. Twins of outside services sit behind the network boundary, so the code that ships is the code that was tested.

### Budget it like a production system

A factory spends tokens around the clock. Cap each job and each day, and track spend per shipped change, or one looping job costs more than an engineer.

## A factory, laid out

```
factory/
intake/                         # approved specs: the only human input to the line
line/                           # the agents' side: everything here is written by agents
  jobs/                         # one queued job per spec: plan, implement, fix
  harness.config.ts             # hosted harness: sandbox, tools, budget per job
twins/                          # fakes of each outside service, at the network edge
  identity/                     # copies the sign-in provider, quirks included
  tickets/                      # copies the issue tracker's API
scenarios/                      # holdout user stories; the line has no read access
gate.ts                         # runs scenarios on twins, ships above the bar
```

The line may write everything under line/ and nothing under scenarios/. That one permission is what makes the score mean something.

## Examples

### The gate: scenarios on twins, scored as a pass rate

```typescript
interface Scenario {
  id: string;
  story: string;                                // what the user does and expects
  check: (app: AppClient) => Promise<boolean>;
}

// Lives outside the agents' workspace. The line gets a score, never the scenarios.
export async function gate(build: Build, scenarios: Scenario[], twins: Twins) {
  const app = await deploy(build, { services: twins });   // fakes, not production
  const results: { id: string; ok: boolean }[] = [];
  for (const s of scenarios) {
    for (let i = 0; i < 20; i++) results.push({ id: s.id, ok: await s.check(app) });
  }
  const score = results.filter((r) => r.ok).length / results.length;

  if (score >= 0.95) return ship(build);
  const failed = scenarios.filter((s) => results.some((r) => r.id === s.id && !r.ok));
  return requeue(build.job, failed.map((s) => s.story));  // stories, not test code
}
```

Each scenario runs many times, because agent-built code can be flaky and one green run hides it. The line gets back the story that failed, not the check, so it fixes the behaviour rather than the test.

## When to use

- Agents write more code than people can review
- Correct behaviour can be checked from the outside, end to end
- Outside services can be faked faithfully

## When not to use

- You cannot yet say what correct looks like — build by hand first
- A mistake is costly and hard to catch in a test: payments, safety, compliance
- The volume of change does not justify the token spend

## Benefits

- Throughput is limited by specs and compute, not by reviewers
- Every change passes the same end-to-end bar
- Intent and checks are written down, not held in someone's head

## Costs

- Twins and scenarios are a large, ongoing build of their own
- Heavy, constant token spend
- Nobody knows the code well, which makes incidents slower to debug

## Pitfalls

- Letting the line read or edit the scenarios. The score climbs; the product does not improve.
- Twins that drift from the real service, so everything passes in the factory and fails in production.
- Treating a high pass rate as proof. It covers only the stories someone thought to write.

## Similar patterns, compared

A factory is built from two patterns in this category, and gets confused with both. The difference is where people still look.

### Software Factory vs Spec-Driven Development

Same input, different check: spec-driven development still has a person read the diff; a factory replaces that reading with hidden scenarios. — [Spec-Driven Development](https://layra4.dev/architectures/ai/spec-driven-development)

**What is genuinely the same**

- Work starts from a written, reviewed spec
- Agents do the implementing

**What actually differs**

- There a person reviews the code; here nobody does, and a score decides
- There one change moves at a time; here many jobs run unattended in parallel

**Pick Software Factory when:** Change arrives faster than people can review it, and you can afford the scenarios and twins that replace that review.

### Software Factory vs Multi-Agent Orchestration

Multi-agent splits one request across agents in one run; a factory is a standing pipeline that ships many changes, each with its own agents. — [Multi-Agent Orchestration](https://layra4.dev/architectures/ai/multi-agent)

**What is genuinely the same**

- Many agents work at once, each with its own context
- Something decides what runs and what is kept

**What actually differs**

- Multi-agent ends with the request; a factory has a queue that never empties
- There a model merges the results; here a test score accepts them

**Pick Software Factory when:** The unit of work is a whole change to ship, and it has to run without anyone watching.

## Related patterns

- [Spec-Driven Development](https://layra4.dev/architectures/ai/spec-driven-development) — its intake: the spec is the only human input
- [Evaluation Harness](https://layra4.dev/architectures/ai/eval-harness) — the scenarios are an eval suite the agents never see
- [Agent Harness](https://layra4.dev/architectures/ai/agent-harness) — the hosted harness each job runs in
- [Multi-Agent Orchestration](https://layra4.dev/architectures/ai/multi-agent) — how a single job splits its work
- [Human in the Loop](https://layra4.dev/architectures/ai/human-in-the-loop) — what stays: people approve specs, not diffs

## Further reading

- *The StrongDM Software Factory: Building software with AI* — StrongDM (2026) — The rules — no person writes or reviews code — plus holdout scenarios and service twins.
- *How StrongDM's AI team build serious software without even looking at the code* — Simon Willison (2026) — An outside read of the approach, including the cost and the open questions.
- *Software Factories* — Jack Greenfield & Keith Short (2004) — The earlier meaning: assembling applications from models, frameworks and generators.
