// The 12 harness-ready sections — shared by server (seeding, reset) and client (done detection). export const SECTION_TEMPLATES = [ { key: "meta", title: "Header & Metadata", hint: "Status, owner, reviewers, last-updated, and links to the PRD and Scope. Pin real dates and names — no TODOs.", starter: `| Field | Value |\n|---|---|\n| Status | DRAFT |\n| Owner | |\n| Reviewers | |\n| Last updated | |\n| Implements | PRD vX, Scope vX |\n| Repo | |`, }, { key: "context", title: "Context & Background", hint: "One paragraph: why this exists, what exists today (link it), what breaks. A stranger must not need the conversation.", starter: "**Why:** \n\n**What exists today:** \n\n**What breaks / what's demanded:** (cite FR ids from the PRD)", }, { key: "arch", title: "Architecture Overview", hint: "One diagram a stranger AND an agent can navigate — Mermaid preferred. Pin the exact stack versions below it.", starter: "```mermaid\nflowchart LR\n Client[Client / UI] --> API[API Layer]\n API --> Core[Domain Core]\n Core --> DB[(Datastore)]\n```\n\n**Stack (pinned):** language , framework , DB ", }, { key: "layout", title: "Directory / Module Layout", hint: "Agents navigate by path. Give the target tree up front so every task lands in a known place.", starter: "```\nrepo/\n├── app/\n│ ├── api/ # route handlers, no business logic\n│ ├── core/ # domain logic\n│ └── models/ # data models & schemas\n└── tests/ # mirrors app/\n```", }, { key: "components", title: "Component Contracts", hint: "Per component: responsibility, typed interface, dependencies, and failure modes — what breaks, who retries, what the user sees.", starter: "### Component A\n- **Responsibility:** \n- **Interface:** signature(args: Type) -> Type\n- **Depends on:** \n- **Failure mode:** what happens when it breaks, who retries, what the user sees", }, { key: "data", title: "Data Model & API Contracts", hint: "Schemas in full — types, nullability, indexes. Contracts get frozen and versioned; include migration + rollback strategy.", starter: "```sql\nCREATE TABLE example (\n id TEXT PRIMARY KEY,\n created_at TIMESTAMPTZ NOT NULL DEFAULT now()\n);\n```\n\n**API contract:** OpenAPI/JSON Schema at — frozen.\n**Events:** names, payloads, delivery semantics.", }, { key: "orchestration", title: "Orchestration (Build Harness)", hint: "How the build is orchestrated: master plan, atomic task schema (id/reads/writes/acceptance/blocked_by), the loop, state file, human checkpoints.", starter: "- **Master plan:** PLAN.md — numbered milestones, each ends demonstrable\n- **Task schema:** id, reads, writes, acceptance command, blocked_by\n- **Loop:** spec → decompose → generate → verify → commit or block\n- **State:** STATE.json with todo / in_progress / done / blocked\n- **Human checkpoints:** PR review per milestone; manual review for ", }, { key: "nfr", title: "Non-Functional Requirements", hint: "Every -ility paired with how it's verified. \"p95 < 200 ms\", not \"fast\".", starter: "| Dimension | Requirement | How verified |\n|---|---|---|\n| Performance | p95 < ms | |\n| Reliability | | |\n| Security | | |\n| Observability | | |", }, { key: "testing", title: "Testing Strategy & Gate", hint: "Unit / integration / E2E mapped to story ids. Define the single CI command that is the definition of done.", starter: "- **Unit:** coverage target , exclusions \n- **Integration:** real vs mocked \n- **E2E:** maps to US ids \n- **Gate:** CI green on command before any task is done", }, { key: "decisions", title: "Decision Log (ADRs)", hint: "Record why, not just what: context, options, decision, consequences. Prevents re-litigating choices.", starter: "| Decision | Alternatives | Why chosen | ADR |\n|---|---|---|---|\n| | | | ADR-001 |", }, { key: "risks", title: "Risks & Open Questions", hint: "Every open question gets an owner and a resolve-by date. Nothing open on the critical path.", starter: "- **Risk:** → Mitigation: \n- **Open question:** — Owner: , resolve by: ", }, { key: "tasks", title: "Milestone → Task Map", hint: "The export surface: this table IS the harness's input. Task id, spec section, FR ref, deliverable files, acceptance command.", starter: "| Task | Spec section | FR | Deliverable | Acceptance check |\n|---|---|---|---|---|\n| T-01 | § | FR- | | command passes |", }, ]; // A section counts as done when it holds more than the bare scaffold. export const isSectionDone = (content) => { const c = (content ?? "").replace(/\s+/g, " ").trim(); if (c.length < 60) return false; for (const t of SECTION_TEMPLATES) { if (c === t.starter.replace(/\s+/g, " ").trim()) return false; } return true; };