Commissioning State Machine
In a dairy factory, equipment doesn't just appear. It progresses: idea → spec → P&ID → procurement → in transit → in store → mechanically in place → electrically wired → controls proven → operating system. Each state has evidence. Each transition is deterministic. The commissioning engineer knows exactly where every piece stands.
Why would software be different?
The Job
When a venture has many data tables and no compass — scores plateau, interpretation is manual, and gaps never route to tasks — help it know where every table stands, detect gaps automatically, and route those gaps to executable work.
| Trigger Event | Current Failure | Desired Progress |
|---|---|---|
| 195 tables, no compass | No visibility into maturity — which tables are ready, which are stuck | Every table has a state. Every state has evidence. Every gap routes to a task. |
| Scores plateau | Manual interpretation, no systematic path to improvement | Algorithm detects gaps. Gaps become tasks. Tasks close gaps. |
| "Is this table done?" | Depends who you ask. No single source of truth. | State machine answers. Deterministic. Evidence-based. |
| New venture spins up | Each venture reinvents maturity tracking | Same 10-state progression. Same Factory Control Room. Same gap-to-task pipeline. |
The job: "I need to know where every data table stands — and have gaps turn into tasks automatically."
The hidden objection: "What if the algorithm is wrong?" The answer: the algorithm stays pure — no side effects, deterministic transitions, schema changes through migration workflow. The constitution protects the signal.
The Factory Metaphor
Matt's dairy factory experience maps directly. Equipment progresses through discrete states. Same model applies to every data table.
| Factory State | Dream Repo State | Conceptual Evidence |
|---|---|---|
| Idea | Idea (0) | Concept exists — the table is named and scoped |
| Spec | Schema (1) | Data structure defined — columns, types, constraints |
| P&ID | Migration (2) | Migration applied — structure lives in the system |
| Procurement | Data (3) | Seed data populated — table has initial content |
| In transit | Repository (4) | Data access layer exists — read/write operations defined |
| In store | Server Actions (5) | Server-side operations exposed — business logic callable |
| Mechanically in place | CRUD UI (6) | Human interface operable — operators can manage data |
| Electrically wired | ETL Pipeline (7) | Data pipeline connected — extraction and load verified |
| Controls proven | A2A API (8) | Machine interface exposed — agents can access programmatically |
| Operating system | E2E Tests (9) | End-to-end verification passes — full loop proven |
| Commissioned | Fully Commissioned (10) | Operational readiness — table is live and trusted |
Every table. Every venture. Same progression. The Factory Control Room shows the state of the whole system.
The 10-State Machine
| State | Name | Conceptual Evidence |
|---|---|---|
| 0 | Idea | Concept exists — table is named and scoped |
| 1 | Schema | Data structure defined |
| 2 | Migration | Migration applied |
| 3 | Data | Seed data populated |
| 4 | Repository | Data access layer exists |
| 5 | Server Actions | Server-side operations exposed |
| 6 | CRUD UI | Human interface operable |
| 7 | ETL Pipeline | Data pipeline connected |
| 8 | A2A API | Machine interface exposed |
| 9 | E2E Tests | End-to-end verification passes |
| 10 | Fully Commissioned | Operational readiness achieved |
Constitution: The algorithm must remain pure — no side effects. State transitions are deterministic. Schema changes flow through the migration workflow. The state machine observes; it does not mutate.
Gap Detection → Task Automation
The value isn't the state. It's what happens when a gap is detected.
Gap Detected → Algorithm Identifies Missing Evidence → Task Generated → Task Assigned → Gap Closed
| Gap Type | Detection | Task Routing |
|---|---|---|
| Table stuck at Schema | No migration evidence | Generate migration task |
| Table stuck at Repository | No data access layer | Generate repository task |
| Table stuck at CRUD UI | No human interface | Generate UI task |
| Table stuck at ETL | No pipeline connection | Generate ETL task |
| Table stuck at A2A | No machine interface | Generate API task |
Target: 80% of gaps route to tasks automatically. No manual interpretation. No "someone should fix that" — the system produces the task.
Capability Commissioning Table
A second entity — parallel to but distinct from the 10-state data table machine. This tracks product features (the commissioning dashboard) at L0-L4 maturity.
Write rule: All writes via Drizzle ORM + repository pattern only. The outer loop agent reads via Supabase MCP or REST endpoint — never writes directly.
// commissioning_capabilities — Drizzle schema
{
id: uuid PK
slug: text UNIQUE // kebab-case, matches dashboard row
feature_name: text
capability_enabled: text
prd_slug: text // links to PRD
claimed_level: enum // L0 | L1 | L2 | L3 | L4
evidence: jsonb // { receipts: [], test_results: [], usage: {} }
last_verified: timestamp
verified_by: text // agent name or human
updated_at: timestamp
}
Endpoint: GET /api/commissioning/status — machine-readable, LLM-friendly, A2A-compatible. The dashboard feature-matrix.md is the spec. This table is the reality. The diff is the work queue.
A2A path: This endpoint is the HTTP stub. When the A2A protocol is live, commissioning/status becomes a first-class agent task — any agent can query and post evidence through the same protocol.