The Factory — optimal build process
The Factory — optimal build process
The progressive pipeline every delivery flows through: spec with acceptance criteria, design instantiated from KB knowledge, build under architecture rules, test pyramid, DoD gate, CI, review, deploy via the edge seam, and retro that feeds learnings back into the KB. Each stage is gated; failures loop back to the cheapest stage that can fix them.
Pipeline
flowchart TD
A[Intake: plain-language ask] --> B[SPEC: military-spec acceptance criteria]
B --> C[Design: instantiate kb patterns / frameworks / decisions]
C --> D[Build: dual-deployment rules, env-selected stores, outbox]
D --> E[Test pyramid: unit → API-contract mock layer → Playwright]
E --> F{DoD gate: dod_gate.py + dsl_drift}
F -- fail --> D
F -- pass --> G[CI green: compile --check, unit, functional]
G --> H[Review: adversarial vs Linear ACs]
H -- changes requested --> D
H -- approved --> I[Merge → deploy via edge seam]
I --> J[Retro: learner-retro extracts learnings]
J --> K[KB updated: rules / ACs / DoD at L1 → L3]
K -.-> C
Stage rules
| stage | gate | failure loops back to |
|---|---|---|
| Intake | ask restated as testable ACs | — |
| SPEC | military-spec: precise, one-sentence ACs | Intake |
| Design | every choice cites a kb: entry or records a new decision | SPEC |
| Build | host-agnostic handlers, env-only config, store adapters, outbox for side effects | Design |
| Test pyramid | unit at base, API-contract-identical mock, Playwright functional on top, all in CI | Build |
| DoD gate | dod_gate.py + dsl_drift.py pass | Build |
| CI | green before review | any stage |
| Review | adversarial review vs Linear ACs; merge on green CI | Build |
| Deploy | via seam (local runner default, edge adapter production) | — |
| Retro | learner-retro, progressive discipline (evidence thresholds, caps, decay) | feeds Design next time |
Non-negotiables
- Progressivity: no stage skips its gate; a failure returns to the earliest stage that owns the cause, not the latest.
- The KB is both input and output: design reads
machine/*.dsl; retro writes learnings back under evidence thresholds. - Human effort is measured at review: interventions, rework requests, and clarifications are retro inputs, not overhead.
- Secrets never enter the pipeline artifacts (SEC-01); infra is Terraform, never dashboard click-ops (except one-time vendor enablement).
Anti-patterns
- Big-bang builds with gates only at the end — failures compound.
- Retro entries without evidence thresholds — KB bloat and drift.
- Deploying around the seam (direct provider calls in product code).
- Treating review comments as noise instead of retro input.
Sources
- factory/AGENTS.md, factory/ai-harness (dod_gate.py, dsl_drift.py, delivery chain)
- knowledge-base/skills/learner-retro/SKILL.md (retro loop)
- knowledge-base/frameworks/* (build-stage rules)
- factory/infra/cloudflare/kb-site/ (edge seam deployment)