Spec-First Pipeline

intent-driven OpenSpec schema Β· "the spec is the durable artifact; the code is the side effect"

ONRAMPS & PREREQUISITES β€” upstream of the change loop, run once or as-needed (human answers, agent writes) πŸ‘€ /init β†’ openspec/project.md (constitution β€” ONCE per project) πŸ‘€ /mentalmodel <topic> β†’ docs/models/ (before a NEW layer / component / decision) Read project.md before ANY planning or code Β· ADRs immutable once accepted Β· writes to openspec/ and adr/ are human-gated β‘  SEED PIPELINE β€” interactive Socratic interviews Β· human answers, agent writes Β· MAY write openspec/ new feature 0 Β· /diagnose (six-move loop) Diagnose bug onramp structural β†’ /new ≀2 files β†’ hotfix-<id> 1 πŸ‘€ Architect interview New Β· Inversion interview β†’ scaffold writes proposal.md /new 2 πŸ‘€ interview Grill-Me interrogate proposal β†’ acceptance checks /grill 3 πŸ‘€ interview Β· user chooses Reconcile vs project.md Β· ADRs drift / contradiction /reconcile 4 πŸ‘€ HUMAN GATE Β· accepts ADR-Grill (3Β½) accepted ADRs β†’ adr/ (immutable) /adr-grill 5 πŸ€– autonomous emit Emit specs Β· design adr-manifest Β· tasks /emit Β· validate --strict β‘‘ AUTONOMOUS BUILD LOOP β€” dispatch-loop.sh routes on machine-readable verdicts Β· one task/session Β· SPEC FROZEN: agents can't write openspec/ 6 Dispatch πŸ€– Contractor builds ONE task's code emits COMMIT_MSG: 7 Β· Review πŸ€– independent runs tests VERDICT β†’ approve βœ“ 10 Commit βš™ dispatch-loop.sh tick box + git commit agent NEVER ticks ↻ next open task in tasks.md all tasks committed β†’ blocker 8 Fix πŸ€– Fixer repairs only the blocking feedback re-emits COMMIT_MSG: re-review Β· ≀3 rounds 4th blocker 9 Escalate πŸ€– fix the SPEC, not the code (Fable) tasks.md / spec.md structural_blocker Β· needs_adjudication β›” HARD STOP β†’ human dispatch-loop.sh exits 125 β‘’ IMPROVEMENT BACKLOG β€” reviewers collect improvements along the way; curate once, then refine each item through the SAME loop 11 Triage (Curator) πŸ€– emits TRIAGE: json actionable/obsolete/deferred βš™ script rewrites backlog 12 Refine each item reuses dispatch β†’ review β†’ fix β†’ commit cap: 50 passes β†’ HARD STOP ↻ per open item backlog empty β†’ β‘£ ACCEPTANCE & ARCHIVE β€” per CHANGE Β· user-observable gate, then human archive 13 Β· Verify πŸ‘€ gate observe only PASS / FAIL PASS βœ“ 14 πŸ‘€ HUMAN / loop-archive Archive delta specs β†’ specs/ /opsx:archive βœ“ change archived FAIL spec-shaped FAIL β†’ /escalate Β· bug-shaped FAIL β†’ /diagnose reopens upstream β€” NEVER an inline fix; a FAIL can re-open already-committed tasks OFF-PIPELINE (not in the linear flow) /contract-coverage-critic β€” independent critic reconstructs βˆ€-obligations, flags coverage gaps as un-ratified grill-input. HUMAN-GATED only β€” never wired into the loop.

Who acts (four actors)

  • πŸ‘€ Human β€” answers interviews, accepts ADRs, archives, pushes
  • 🟒 Agent Β· interview β€” Socratic; human answers, agent writes (steps 1–4, 13)
  • 🟣 Agent Β· autonomous β€” loop roles, emit a machine-readable line (6–9, 11–12)
  • βš™ Script β€” dispatch-loop.sh: state, git, ticking, routing (step 10); never judges

Decision points & branches

  • Diagnose: ≀2 files β†’ hotfix path Β· else structural β†’ /new
  • Review (4-way): approveβ†’commit Β· blockerβ†’fix Β· structural_blocker / needs_adjudication β†’ hard stop
  • Fix cap: 3 rounds, then Escalate the spec β†’ hard stop
  • Verify: PASSβ†’archive Β· FAILβ†’escalate (spec) or diagnose (bug)

Guardrails / hard rules

  • Spec frozen before any code; loop agents can't write openspec/
  • ADRs immutable & human-accepted; adr/ + push are human-only
  • Agent never ticks its own acceptance β€” the script does, on the verdict
  • Backlog cap 50 passes; hard stops exit 125 for a human