buildanything 2.0.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +9 -1
- package/README.md +57 -61
- package/agents/a11y-architect.md +2 -0
- package/agents/briefing-officer.md +172 -0
- package/agents/business-model.md +14 -12
- package/agents/code-architect.md +6 -1
- package/agents/code-reviewer.md +3 -2
- package/agents/code-simplifier.md +12 -4
- package/agents/design-brand-guardian.md +19 -0
- package/agents/design-critic.md +16 -11
- package/agents/design-inclusive-visuals-specialist.md +2 -0
- package/agents/design-ui-designer.md +17 -0
- package/agents/design-ux-architect.md +15 -0
- package/agents/design-ux-researcher.md +102 -7
- package/agents/engineering-ai-engineer.md +2 -0
- package/agents/engineering-backend-architect.md +2 -0
- package/agents/engineering-data-engineer.md +2 -0
- package/agents/engineering-devops-automator.md +2 -0
- package/agents/engineering-frontend-developer.md +13 -0
- package/agents/engineering-mobile-app-builder.md +2 -0
- package/agents/engineering-rapid-prototyper.md +15 -2
- package/agents/engineering-security-engineer.md +2 -0
- package/agents/engineering-senior-developer.md +13 -0
- package/agents/engineering-sre.md +2 -0
- package/agents/engineering-technical-writer.md +2 -0
- package/agents/feature-intel.md +8 -7
- package/agents/ios-app-review-guardian.md +2 -0
- package/agents/ios-foundation-models-specialist.md +2 -0
- package/agents/ios-product-reality-auditor.md +292 -0
- package/agents/ios-storekit-specialist.md +2 -0
- package/agents/ios-swift-architect.md +1 -0
- package/agents/ios-swift-search.md +1 -0
- package/agents/ios-swift-ui-design.md +7 -4
- package/agents/marketing-app-store-optimizer.md +2 -0
- package/agents/planner.md +6 -1
- package/agents/pr-test-analyzer.md +3 -2
- package/agents/product-feedback-synthesizer.md +62 -0
- package/agents/product-owner.md +163 -0
- package/agents/product-reality-auditor.md +216 -0
- package/agents/product-spec-writer.md +176 -0
- package/agents/refactor-cleaner.md +9 -1
- package/agents/security-reviewer.md +2 -1
- package/agents/silent-failure-hunter.md +2 -1
- package/agents/swift-build-resolver.md +2 -0
- package/agents/swift-reviewer.md +2 -1
- package/agents/tech-feasibility.md +5 -3
- package/agents/testing-api-tester.md +2 -0
- package/agents/testing-evidence-collector.md +24 -0
- package/agents/testing-performance-benchmarker.md +2 -0
- package/agents/testing-reality-checker.md +2 -1
- package/agents/visual-research.md +7 -5
- package/bin/adapters/scribe-tool.ts +4 -2
- package/bin/adapters/write-lease-tool.ts +1 -1
- package/bin/buildanything-runtime.ts +20 -107
- package/bin/graph-index.js +24 -0
- package/bin/graph-index.ts +340 -0
- package/bin/mcp-servers/graph-mcp.js +26 -0
- package/bin/mcp-servers/graph-mcp.ts +481 -0
- package/bin/mcp-servers/orchestrator-mcp.js +26 -0
- package/bin/mcp-servers/orchestrator-mcp.ts +361 -0
- package/bin/setup.js +272 -111
- package/commands/build.md +424 -177
- package/commands/idea-sweep.md +2 -2
- package/commands/setup.md +15 -4
- package/commands/ux-review.md +3 -3
- package/commands/verify.md +3 -0
- package/docs/migration/phase-graph.yaml +573 -157
- package/hooks/design-md-lint +4 -0
- package/hooks/design-md-lint.ts +295 -0
- package/hooks/pre-tool-use.ts +37 -6
- package/hooks/record-mode-transitions.ts +63 -6
- package/hooks/subagent-start.ts +3 -2
- package/package.json +3 -1
- package/protocols/agent-prompt-authoring.md +165 -0
- package/protocols/architecture-schema.md +10 -3
- package/protocols/cleanup.md +4 -0
- package/protocols/decision-log.md +8 -4
- package/protocols/design-md-authoring.md +520 -0
- package/protocols/design-md-spec.md +362 -0
- package/protocols/fake-data-detector.md +1 -1
- package/protocols/ios-fake-data-detector.md +65 -0
- package/protocols/ios-phase-branches.md +128 -43
- package/protocols/launch-readiness.md +9 -5
- package/protocols/metric-loop.md +1 -1
- package/protocols/page-spec-schema.md +234 -0
- package/protocols/product-spec-schema.md +354 -0
- package/protocols/sprint-tasks-schema.md +53 -0
- package/protocols/state-schema.json +38 -3
- package/protocols/state-schema.md +32 -2
- package/protocols/verify.md +29 -1
- package/protocols/web-phase-branches.md +246 -76
- package/skills/ios/ios-bootstrap/SKILL.md +1 -1
- package/src/graph/ids.ts +86 -0
- package/src/graph/index.ts +32 -0
- package/src/graph/parser/architecture.ts +603 -0
- package/src/graph/parser/component-manifest.ts +268 -0
- package/src/graph/parser/decisions-jsonl.ts +407 -0
- package/src/graph/parser/design-md-pass2.ts +253 -0
- package/src/graph/parser/design-md.ts +477 -0
- package/src/graph/parser/page-spec.ts +496 -0
- package/src/graph/parser/product-spec.ts +930 -0
- package/src/graph/parser/screenshot.ts +342 -0
- package/src/graph/parser/sprint-tasks.ts +317 -0
- package/src/graph/storage/index.ts +1154 -0
- package/src/graph/types.ts +432 -0
- package/src/graph/util/dhash.ts +84 -0
- package/src/lrr/aggregator.ts +105 -10
- package/src/orchestrator/hooks/context-header.ts +34 -10
- package/src/orchestrator/hooks/token-accounting.ts +25 -14
- package/src/orchestrator/mcp/cycle-counter.ts +2 -1
- package/src/orchestrator/mcp/scribe.ts +27 -16
- package/src/orchestrator/mcp/write-lease.ts +30 -13
- package/src/orchestrator/phase4-shared-context.ts +20 -4
- package/protocols/visual-dna.md +0 -185
package/commands/build.md
CHANGED
|
@@ -19,34 +19,61 @@ Exception: Brainstorming in Phase 1 Step 1.0 and Step 1.3 uses an INTERNAL Brain
|
|
|
19
19
|
<HARD-GATE>
|
|
20
20
|
SUBAGENT_TYPE REQUIRED.
|
|
21
21
|
|
|
22
|
-
Every Agent tool call MUST include a `subagent_type` field unless the dispatch is explicitly marked INTERNAL (inline role-string). INTERNAL dispatches are
|
|
22
|
+
Every Agent tool call MUST include a `subagent_type` field unless the dispatch is explicitly marked INTERNAL (inline role-string). INTERNAL dispatches are orchestrator helpers: Brainstorm Facilitator, Research Synthesizer, Design Doc Writer, Prereq Collector, Task DAG Validator, Refs Indexer, Briefing Officer, PM chapter, LRR Aggregator, Completion Report, Verify scaffolding dispatcher.
|
|
23
23
|
|
|
24
|
-
Missing `subagent_type` on a non-INTERNAL dispatch is a HARD-GATE violation. The orchestrator rejects dispatches that don't name a specific agent. If you catch yourself typing `description: "..."` without a `subagent_type:` line alongside it, STOP and look up the right agent from the dispatch
|
|
24
|
+
Missing `subagent_type` on a non-INTERNAL dispatch is a HARD-GATE violation. The orchestrator rejects dispatches that don't name a specific agent. If you catch yourself typing `description: "..."` without a `subagent_type:` line alongside it, STOP and look up the right agent from the per-phase dispatch tables further down in this file.
|
|
25
25
|
</HARD-GATE>
|
|
26
26
|
|
|
27
27
|
<HARD-GATE>
|
|
28
28
|
ARTIFACT WRITER-OWNER RULE.
|
|
29
29
|
|
|
30
|
-
Every shared artifact has ONE concurrent writer at any instant. The writer-owner table
|
|
30
|
+
Every shared artifact has ONE concurrent writer at any instant. The writer-owner table below defines which phase writes which file. Before any file write, the orchestrator verifies the current phase is the rightful writer. Non-owning phase writes are a HARD-GATE violation. For parallel-batch phases (e.g., Phase 4), intra-phase dispatches MUST NOT race on the same file — writes either target disjoint per-dispatch filenames OR route through an orchestrator-scribe handler (see `decisions.jsonl` handling below).
|
|
31
31
|
|
|
32
32
|
Live downstream docs (read across Phase 3+):
|
|
33
33
|
- `CLAUDE.md` — P1 writer (then auto-loaded into every subagent)
|
|
34
|
-
- `design-doc.md` (PRD) — P1 writer
|
|
35
|
-
- `
|
|
36
|
-
- `
|
|
37
|
-
- `
|
|
38
|
-
- `
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
44
|
-
- `
|
|
34
|
+
- `docs/plans/design-doc.md` (PRD) — P1 writer
|
|
35
|
+
- `docs/plans/product-spec.md` — P1 writer (Step 1.6), product-spec-writer writer
|
|
36
|
+
- `docs/plans/architecture.md` — P2 writer
|
|
37
|
+
- `docs/plans/sprint-tasks.md` — P2 writer
|
|
38
|
+
- `docs/plans/quality-targets.json` — P2 writer
|
|
39
|
+
- `docs/plans/phase-2-contracts/*.md` — P2 writer (per-architect post-debate contract files)
|
|
40
|
+
- `docs/plans/visual-dna-preview.md` — P2 writer, design-brand-guardian writer, ios-swift-ui-design writer (directional DNA preview at Gate 2)
|
|
41
|
+
- `DESIGN.md` — P3 writers: design-brand-guardian (Pass 1 at Step 3.0, both modes); design-ui-designer (Pass 2 at Step 3.4, web); ios-swift-ui-design (Pass 2 at Step 3.2-ios, iOS). Replaces former visual-dna.md + visual-design-spec.md pair (web) and ios-design-board.md (iOS). Repo root.
|
|
42
|
+
- `docs/plans/component-manifest.md` — P3 writer (web, HARD-GATE import source)
|
|
43
|
+
- `docs/plans/design-references.md` — visual-research writer (web, Step 3.1)
|
|
44
|
+
- `docs/plans/design-references/**` — visual-research writer (web, screenshots harvested by visual-research subagents)
|
|
45
|
+
- `docs/plans/dna-persona-check.md` — design-ux-researcher writer (web, Step 3.2b)
|
|
46
|
+
- `docs/plans/ux-architecture.md` — P3 writer (web)
|
|
47
|
+
- `docs/plans/ux-flow-validation.md` — design-ux-researcher writer (web, Step 3.3b)
|
|
48
|
+
- `docs/plans/inclusive-visuals-audit.md` — P3 writer (web)
|
|
49
|
+
- `docs/plans/a11y-design-review.md` — P3 writer, a11y-architect writer (web, Step 3.7)
|
|
50
|
+
- `docs/plans/page-specs/*.md` — P3 writer, design-ux-architect writer (web, Step 3.3 — per-screen wireframes + layout specs)
|
|
51
|
+
- `docs/plans/refs.json` — P2 writer, P3 writer (P3 extends after visual spec lands)
|
|
52
|
+
- `docs/plans/decisions.jsonl` — orchestrator-scribe ONLY via `scribe_decision` MCP tool (subagents return `deviation_row` objects; the orchestrator forwards each row through the MCP, which owns ID allocation and atomic append)
|
|
53
|
+
- `docs/plans/learnings.jsonl` — P5 writer, P7 writer
|
|
54
|
+
- `docs/plans/evidence/*.json` — P5 writer (P4 contributes per-task, P6/P7 readers)
|
|
55
|
+
- `docs/plans/evidence/*.md` — P5 writer, design-brand-guardian writer (brand-drift findings, fake-data-audit)
|
|
56
|
+
- `docs/plans/evidence/**/*.json` — P4 writer, P5 writer, P6 writer (nested per-task/per-run evidence JSON)
|
|
57
|
+
- `docs/plans/evidence/**/*.md` — P4 writer, P5 writer (nested per-task/per-run evidence markdown)
|
|
58
|
+
- `docs/plans/evidence/**/*.png` — P3 writer, P4 writer, P5 writer (screenshots: Playwright, SwiftUI Preview, Maestro, design-reference)
|
|
59
|
+
- `docs/plans/evidence/**/*.{txt,har}` — P4 writer, P5 writer (smoke-test HAR captures, DOM snapshots)
|
|
60
|
+
- `docs/plans/evidence/lrr/*.json` — code-reviewer writer, security-reviewer writer, engineering-sre writer, a11y-architect writer, design-brand-guardian writer, pr-test-analyzer writer (5 chapter verdicts + 1 sub-verdict)
|
|
61
|
+
- `docs/plans/evidence/lrr-aggregate.json` — phase-6-aggregator writer (Aggregator only)
|
|
62
|
+
- `docs/plans/evidence/lrr-incomplete.json` — phase-6-aggregator writer (file-completeness checkpoint)
|
|
63
|
+
- `docs/plans/evidence/lrr-routing.json` — phase-6-aggregator writer (BLOCK routing via decided_by)
|
|
64
|
+
- `docs/plans/evidence/reality-check-manifest.json` — testing-reality-checker writer (evidence-sweep manifest)
|
|
65
|
+
- `docs/plans/.build-state.json` — orchestrator writer (every phase boundary)
|
|
66
|
+
- `docs/plans/.build-state.md` — auto-rendered-view writer (regenerated from .build-state.json on every update)
|
|
67
|
+
- `docs/plans/.task-outputs/[task-id].json` — P4 writer (per-task output)
|
|
68
|
+
- `docs/plans/build-log.md` — every-phase writer (append on transition)
|
|
69
|
+
- `docs/plans/.active-learnings.md` — P0 writer (top-3 cross-run learnings for Phase 4 implementer briefings)
|
|
70
|
+
- `docs/plans/ios-verify-report.md` — P5 writer (iOS verify twin)
|
|
71
|
+
- `docs/plans/ios-ux-review-report.md` — P5 writer (iOS ux-review twin)
|
|
45
72
|
|
|
46
73
|
Phase-internal scaffolding (lives in `docs/plans/phase1-scratch/` after Gate 1, never read by P3+):
|
|
47
74
|
- `idea-draft.md`, `feature-intel.md`, `tech-feasibility.md`, `ux-research.md`, `business-model.md`, `findings-digest.md`, `suggested-questions.md`, `user-decisions.md`, `prereqs.json`
|
|
48
75
|
|
|
49
|
-
Phase 4 implementers never reference Phase 1 raw research files. They are SPENT after
|
|
76
|
+
Phase 4 implementers never reference Phase 1 raw research files. They are SPENT after the Product Spec step (Step 1.6). The product spec is the LAST consumer of raw research. After Step 1.6, research insights survive in `product-spec.md`, `design-doc.md`, and `CLAUDE.md`.
|
|
50
77
|
</HARD-GATE>
|
|
51
78
|
|
|
52
79
|
> **Default-deny (Stage 2+):** Once Stage 2 of the SDK migration activates, any `Write|Edit` tool call targeting a path absent from this table will be denied by the `PreToolUse` hook with message `"path not in writer-owner table — please add to phase-graph.yaml or route through scribe MCP"`. This is a pre-announcement; actual hook wiring ships in Task 2.1.3.
|
|
@@ -54,7 +81,7 @@ Phase 4 implementers never reference Phase 1 raw research files. They are SPENT
|
|
|
54
81
|
<HARD-GATE>
|
|
55
82
|
CONTEXT HEADER — RENDER ONCE, HOIST AS STABLE PREFIX.
|
|
56
83
|
|
|
57
|
-
Every phase uses a CONTEXT header prepended to dispatch prompts. The orchestrator MUST render this header ONCE at the start of each phase by reading `.build-state.json` (and `
|
|
84
|
+
Every phase uses a CONTEXT header prepended to dispatch prompts. The orchestrator MUST render this header ONCE at the start of each phase by reading `.build-state.json` (and `DESIGN.md` `## Overview > ### Brand DNA` for web, Phase 4+) and resolving all values into concrete strings. The rendered header is then reused verbatim for every dispatch in that phase.
|
|
58
85
|
|
|
59
86
|
DO NOT paste `{read from .build-state.json}` placeholders into dispatch prompts. DO NOT re-read state files per dispatch. The values do not change within a phase.
|
|
60
87
|
|
|
@@ -63,7 +90,7 @@ DO NOT paste `{read from .build-state.json}` placeholders into dispatch prompts.
|
|
|
63
90
|
CONTEXT:
|
|
64
91
|
project_type: <resolved value>
|
|
65
92
|
phase: <current phase number>
|
|
66
|
-
dna: <resolved from
|
|
93
|
+
dna: <resolved from DESIGN.md `## Overview > ### Brand DNA` (7 axis values only, ~100 tokens) — INCLUDE only if project_type=web AND phase >= 4>
|
|
67
94
|
ios_features: <resolved from .build-state.json — INCLUDE only if project_type=ios>
|
|
68
95
|
|
|
69
96
|
TASK:
|
|
@@ -71,7 +98,7 @@ TASK:
|
|
|
71
98
|
|
|
72
99
|
**Rendering procedure** (run once per phase boundary):
|
|
73
100
|
1. Read `docs/plans/.build-state.json`. Extract `project_type`, `ios_features`.
|
|
74
|
-
2. If `project_type=web` AND phase >= 4: read `
|
|
101
|
+
2. If `project_type=web` AND phase >= 4: read `DESIGN.md` and extract the DNA summary (first 5 lines or the `## Summary` section). Otherwise omit the `dna` field.
|
|
75
102
|
3. If `project_type=ios`: include `ios_features`. Otherwise omit.
|
|
76
103
|
4. Substitute all values into the template above. Store the result as `rendered_context_header`.
|
|
77
104
|
5. For every dispatch in this phase, prepend `rendered_context_header` — do NOT re-read or re-interpolate.
|
|
@@ -111,6 +138,8 @@ Increment after each agent returns (parallel dispatch of 6 agents = +6). Reset t
|
|
|
111
138
|
|
|
112
139
|
**Compaction checkpoint format:** At every phase boundary, check `dispatch_count` in `docs/plans/.build-state.json`. If >= 8: save ALL state (current phase, task statuses, metric loop scores, decisions) to `docs/plans/.build-state.json` and regenerate `.build-state.md` as the rendered view. Reset `dispatch_count` to 0. TodoWrite does NOT survive compaction — rebuild it from the JSON state file on resume. See `protocols/state-schema.md` for the full schema and rendering contract.
|
|
113
140
|
|
|
141
|
+
Phase 4 context pressure: With 20+ tasks, compact returns accumulate ~30-40K tokens in the orchestrator's context. The compaction checkpoint (dispatch_count >= 8) is the primary relief valve. If Phase 4 has more than 15 tasks, force a compaction checkpoint after every wave transition regardless of dispatch_count.
|
|
142
|
+
|
|
114
143
|
**Cumulative-cost banner at phase boundaries:** When announcing a phase transition (e.g. "Phase N complete — proceeding to Phase N+1"), prefix the message with `[Cost so far: $X.XX • Y tokens]`. Source the values from the last-appended entry in `docs/plans/build-log.md`'s token-accounting lines (fields `cumulative_usd=...` plus the sum of `input_tokens=...` + `output_tokens=...`), written by `src/orchestrator/hooks/token-accounting.ts` (see module for exact schema). If the build-log has no token-accounting entries yet, omit the prefix rather than guessing.
|
|
115
144
|
|
|
116
145
|
Input: $ARGUMENTS
|
|
@@ -162,13 +191,9 @@ The 7-check verification gate is called by Phase 2 (architecture check), Phase 4
|
|
|
162
191
|
|
|
163
192
|
### Refs-Not-Pastes Rule
|
|
164
193
|
|
|
165
|
-
For Phase 3+ agents, the orchestrator passes REFS to live downstream docs (`design-doc.md`, `architecture.md`, `
|
|
166
|
-
|
|
167
|
-
**refs.json mutation invalidates sprint-context hash (Stage 6 / task 6.3.2).** Any orchestrator update to `docs/plans/refs.json` (Phase 2 Refs Indexer initial write, Phase 3 extension after `visual-design-spec.md` lands, or any subsequent correction) MUST be IMMEDIATELY followed by a `state_save` call that sets `.build-state.json.current_sprint_context_hash = null`. This invalidates the cached Phase 4 sprint-scoped shared-context block so the next subagent dispatch re-renders with fresh references. See `src/orchestrator/phase4-shared-context.ts#shouldInvalidate` for how the hash is consulted at render time. Skipping this invalidation causes Phase 4 implementers to read stale anchor indices — a silent correctness failure.
|
|
168
|
-
|
|
169
|
-
### Complexity Routing (Advisory)
|
|
194
|
+
For Phase 3+ agents, the orchestrator passes REFS to live downstream docs (`design-doc.md`, `architecture.md`, `DESIGN.md`, `sprint-tasks.md`, `quality-targets.json`, `decisions.jsonl`) — NOT pasted content. The orchestrator reads `docs/plans/refs.json` (produced by the Phase 2 Refs Indexer), resolves the task topic against the flat anchor index, and passes a short ref list to the agent. The agent uses the Read tool to pull refs it needs. This keeps orchestrator context lean and lets the agent widen its view on demand. Phase 1-2 agents still receive full documents because the architecture anchors don't exist yet.
|
|
170
195
|
|
|
171
|
-
|
|
196
|
+
**refs.json mutation invalidates sprint-context hash (Stage 6 / task 6.3.2).** Any orchestrator update to `docs/plans/refs.json` (Phase 2 Refs Indexer initial write, Phase 3 extension after `DESIGN.md` lands, or any subsequent correction) MUST be IMMEDIATELY followed by a `state_save` call that sets `.build-state.json.current_sprint_context_hash = null`. This invalidates the cached Phase 4 sprint-scoped shared-context block so the next subagent dispatch re-renders with fresh references. See `src/orchestrator/phase4-shared-context.ts#shouldInvalidate` for how the hash is consulted at render time. Skipping this invalidation causes Phase 4 implementers to read stale anchor indices — a silent correctness failure.
|
|
172
197
|
|
|
173
198
|
### Mode-Specific Tool Stacks
|
|
174
199
|
|
|
@@ -181,23 +206,27 @@ Mode-specific tool stacks, per-phase branches, and persona rules live in separat
|
|
|
181
206
|
When a later phase finds a problem whose root cause lives earlier, control flows BACKWARD to the authoring phase. The orchestrator codifies these edges so problems are fixed where they were introduced, not patched locally.
|
|
182
207
|
|
|
183
208
|
```
|
|
184
|
-
PROBLEM FOUND AT
|
|
185
|
-
|
|
186
|
-
Gate 1 (human says "no")
|
|
187
|
-
Gate 2 (human says "no")
|
|
188
|
-
|
|
189
|
-
Phase 5 Audit (
|
|
190
|
-
Phase 5 Audit (
|
|
191
|
-
Phase
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Phase 6 LRR
|
|
195
|
-
|
|
209
|
+
PROBLEM FOUND AT ROUTES BACK TO
|
|
210
|
+
──────────────────────────────────────────────────────────────────────────────────
|
|
211
|
+
Gate 1 (human says "no") → Phase 1 Step 1.0 with feedback
|
|
212
|
+
Gate 2 (human says "no") → Phase 2 with feedback
|
|
213
|
+
phase-3.step-3.2b-DNA-persona-mismatch → phase-3.step-3.0
|
|
214
|
+
Phase 5 Audit (code issue) → Phase 4 target task
|
|
215
|
+
Phase 5 Audit (design issue) → Phase 3 target step
|
|
216
|
+
Phase 5 Audit (spec issue) → phase-2
|
|
217
|
+
phase-5-dogfood-classified → target_phase-per-classified-findings.json
|
|
218
|
+
phase-5-dogfood-feedback-synthesizer → phase-4.target-task
|
|
219
|
+
Phase 6 LRR BLOCK (⭐⭐) → authoring-phase (per decisions.jsonl.decided_by)
|
|
220
|
+
LRR-BLOCK-decided_by==architect → phase-2
|
|
221
|
+
LRR-BLOCK-decided_by==design-brand-guardian-or-phase-3-writer → phase-3
|
|
222
|
+
Phase 6 LRR NEEDS_WORK (code) → Phase 4 target feature (via BO re-planning)
|
|
223
|
+
LRR-NEEDS_WORK-code-level → phase-4.target-task
|
|
224
|
+
phase-6-LRR-NEEDS_WORK-structural → phase-2-or-phase-3
|
|
196
225
|
```
|
|
197
226
|
|
|
198
227
|
The ⭐⭐ star rule: when the LRR Aggregator receives a BLOCK verdict, it reads the `related_decision_id` on the blocker, looks up that row in `decisions.jsonl`, finds which phase authored the decision (the `decided_by` field), and re-opens that phase with the finding as input. Infrastructure already exists (decision IDs, author tracking) — wired here.
|
|
199
228
|
|
|
200
|
-
**Re-entry halt rule (Stage 4 A7).** Before dispatching any backward routing (LRR BLOCK
|
|
229
|
+
**Re-entry halt rule (Stage 4 A7).** Before dispatching any backward routing (LRR BLOCK to Phase N re-open, Reality Checker BLOCK to Phase M re-entry, Gate "no" to Phase 1/2 re-entry, etc.), check `.build-state.json.backward_routing_count` AND the per-target-phase variant `.build-state.json.backward_routing_count_by_target_phase[<N>]`. If the new (post-increment) value of EITHER counter for the target phase would exceed `max_cycles` (currently 2, from `phase-graph.yaml:routing.max_cycles`) — i.e., on the attempted third backward iteration — the orchestrator MUST halt and escalate to the user instead of dispatching. The Stage 4 `cycle_counter_check` MCP is the authoritative enforcer at runtime — it increments atomically and returns `escalate_to_user` once the new value exceeds `max_cycles`. This prose documents the behavior for the markdown-mode rollback path and for human readers.
|
|
201
230
|
|
|
202
231
|
**Phase-entry `in_flight_backward_edge` clear (Stage 4 A3 / task 4.3.3).** On the FIRST `state_save` after any phase entry — whether forward progression or backward-edge re-entry — the orchestrator MUST explicitly set `.build-state.json.in_flight_backward_edge = null`. This is the "successful landing" signal that closes the atomic crash-seam opened by `cycle_counter_check` (which writes `in_flight_backward_edge` in the same atomic state_save that increments the counter). If the runtime crashes between edge dispatch and landing, `--resume` in `bin/buildanything-runtime.ts` observes a stale `in_flight_backward_edge` (age > 60s) and decrements the counter (see task 4.3.4). See `src/orchestrator/mcp/cycle-counter.ts#clearInFlightEdge` for the runtime primitive.
|
|
203
232
|
|
|
@@ -207,11 +236,49 @@ The ⭐⭐ star rule: when the LRR Aggregator receives a BLOCK verdict, it reads
|
|
|
207
236
|
|
|
208
237
|
Phase 0 is thin. No agent dispatch. No human input. Instant. The orchestrator reads state files and applies universal checks.
|
|
209
238
|
|
|
239
|
+
### Step 0.0 — Dependency Pre-flight
|
|
240
|
+
|
|
241
|
+
Run **before anything else** — before resume detection, before state reads. No agent dispatch. Takes under 10 seconds.
|
|
242
|
+
|
|
243
|
+
**Check 1 — Orchestrator MCP** (HARD STOP if missing)
|
|
244
|
+
|
|
245
|
+
Attempt to call the `state_read` MCP tool (server: `orchestrator`). If the tool is absent or returns a connection error:
|
|
246
|
+
|
|
247
|
+
> **STOP. Do not proceed.**
|
|
248
|
+
> The orchestrator MCP server is not connected. It powers state saves, cycle-counter rails, and decision scribing — the pipeline cannot run without it.
|
|
249
|
+
> Fix: run `/buildanything:setup`, then **restart Claude Code** (MCP servers spawn on session start). After restarting, re-run your `/buildanything:build` command.
|
|
250
|
+
|
|
251
|
+
**Check 2 — Graph MCP** (HARD STOP if missing)
|
|
252
|
+
|
|
253
|
+
Attempt to call the `graph_list_features` MCP tool (server: `graph`). Apply the same HARD STOP as Check 1 if unavailable.
|
|
254
|
+
|
|
255
|
+
**Check 3 — CLI tools** (run via Bash)
|
|
256
|
+
|
|
257
|
+
| Tool | Command | On failure |
|
|
258
|
+
|------|---------|------------|
|
|
259
|
+
| `tsx` | `which tsx` | HARD STOP — run `/buildanything:setup` |
|
|
260
|
+
| `agent-browser` | `which agent-browser` | WARN only — Phase 5 browser automation degrades |
|
|
261
|
+
| `maestro` | `which maestro` | WARN only — iOS E2E flows will be skipped |
|
|
262
|
+
|
|
263
|
+
**Check 4 — iOS MCP servers** (WARN only)
|
|
264
|
+
|
|
265
|
+
Run `claude mcp list`. Check for `xcodebuildmcp` and `apple-docs`. If either is absent:
|
|
266
|
+
|
|
267
|
+
> ⚠ iOS MCP servers not configured. iOS builds will fail at Phase -1. Run `/buildanything:setup` (idempotent — safe to re-run) to install them, then restart Claude Code.
|
|
268
|
+
|
|
269
|
+
Do NOT stop for missing iOS MCPs. Log the warning and continue.
|
|
270
|
+
|
|
271
|
+
**On HARD STOP:** Print the diagnostic above. Do not write `.build-state.json`. Do not proceed.
|
|
272
|
+
|
|
273
|
+
**On WARN-only issues:** Append a `dependency_warning` entry to `docs/plans/build-log.md` (create it if it doesn't exist), then continue to the resume check.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
210
277
|
**Resuming?** If the input contains `--resume` OR if context was just compacted (SessionStart hook fired with active state):
|
|
211
278
|
1. Read `docs/plans/.build-state.json` (source of truth) — verify it exists and has a `resume_point` field. Fall back to reading `docs/plans/.build-state.md` (rendered view) if the JSON file is missing but the markdown exists (graceful migration path from pre-W1-2 builds).
|
|
212
279
|
If neither exists, OR neither has a Resume Point, warn the user: 'No previous build state found. Starting fresh.' Then proceed to Step 0.1 as a new build.
|
|
213
280
|
2. Re-read this file and all protocol files in `protocols/`.
|
|
214
|
-
3. Re-read live downstream docs: `docs/plans/sprint-tasks.md`, `docs/plans/architecture.md`, `docs/plans/design-doc.md`, `
|
|
281
|
+
3. Re-read live downstream docs: `docs/plans/sprint-tasks.md`, `docs/plans/architecture.md`, `docs/plans/design-doc.md`, `DESIGN.md` (if exists), `CLAUDE.md`.
|
|
215
282
|
4. Read `docs/plans/decisions.jsonl` if it exists (top 5 most recent rows, filtered to the current phase and upstream phases). Pass short row fields + `ref` anchors into Phase 0 rehydration context — not the full row prose. See `protocols/decision-log.md`.
|
|
216
283
|
5. Rebuild TodoWrite from the state file (TodoWrite does NOT survive compaction or session breaks).
|
|
217
284
|
6. Reset `dispatches_since_save` to 0 (fresh context window).
|
|
@@ -231,7 +298,7 @@ Scan for existing context:
|
|
|
231
298
|
| Context Level | What You Have | What Happens |
|
|
232
299
|
|---|---|---|
|
|
233
300
|
| **Full design** | Design doc with decisions, scope, tech stack, data models | Skip Phase 1. Feed design into Phase 2. |
|
|
234
|
-
| **Decision brief** | An idea-sweep brief with verdicts and
|
|
301
|
+
| **Decision brief** | An idea-sweep brief with verdicts and product definition | Phase 1 skips Step 1.1 research (already done). Brainstorming refines the brief into a design. |
|
|
235
302
|
| **Partial context** | Some notes, conversation, rough sketch | Phase 1 runs fully. Feed context into brainstorming + research. |
|
|
236
303
|
| **Raw idea** | One-line build request, no prior work | Phase 1 runs fully from scratch. |
|
|
237
304
|
|
|
@@ -239,6 +306,8 @@ Scan for existing context:
|
|
|
239
306
|
|
|
240
307
|
Scan the build request AND any context from Step 0.1 for iOS signals. Keywords: **iOS, iPhone, iPad, SwiftUI, Swift, App Store, TestFlight, Xcode, Apple, Liquid Glass, watchOS, visionOS, SwiftData, HIG**.
|
|
241
308
|
|
|
309
|
+
To avoid false positives (e.g., a web app mentioning "Apple Pay" or "Sign in with Apple"), require at least 2 iOS keywords OR 1 keyword + existing Swift/Xcode files before triggering the iOS confirmation prompt.
|
|
310
|
+
|
|
242
311
|
| Signal | Action |
|
|
243
312
|
|---|---|
|
|
244
313
|
| iOS keywords present in prompt | Confirm with user: "This looks like an iOS app — confirm? [y/n]" |
|
|
@@ -282,7 +351,7 @@ Phase 4 implementer dispatch reads `.active-learnings.md` and injects its conten
|
|
|
282
351
|
|
|
283
352
|
0. Create `docs/plans/` directory if it doesn't exist (greenfield projects won't have it).
|
|
284
353
|
1. Create a TodoWrite checklist with Phases 0-7.
|
|
285
|
-
2. Write `docs/plans/.build-state.json` per the schema in `protocols/state-schema.md`. Required top-level fields: `project_type`, `phase`, `step`, `input`, `context_level`, `prerequisites`, `dispatch_count`, `last_save_phase`, `autonomous`, `session_id`, `session_started`, `completed_tasks[]`, `metric_loop_scores[]`, `decisions_next_id` (object keyed by phase number — see Phase 4 orchestrator-scribe handler), `resume_point { phase, step, completed_tasks, git_branch }`. Then regenerate `docs/plans/.build-state.md` from the JSON as a **read-only rendered view**.
|
|
354
|
+
2. Write `docs/plans/.build-state.json` per the schema in `protocols/state-schema.md`. Required top-level fields: `project_type`, `phase`, `step`, `input`, `context_level`, `prerequisites`, `dispatch_count`, `last_save_phase`, `autonomous`, `session_id`, `session_started`, `completed_tasks[]`, `metric_loop_scores[]`, `decisions_next_id` (object keyed by phase number — see Phase 4 orchestrator-scribe handler), `resume_point { phase, step, completed_tasks, git_branch }`, `backward_routing_count_by_target_phase` (object), `feature_delegation_plan_path`, `current_wave`, `completed_features[]`, `feature_acceptance{}`, `feature_briefs{}`. See `protocols/state-schema.md` for the complete and authoritative field list. This inline list is a summary. Then regenerate `docs/plans/.build-state.md` from the JSON as a **read-only rendered view**.
|
|
286
355
|
3. Go to Phase 1 (or Phase 2 if context level is "Full design").
|
|
287
356
|
|
|
288
357
|
**NO prereq collection in Phase 0.** Stack isn't decided yet. Prereqs move to Step 1.5, after Gate 1. Asking for creds before the stack is picked means asking for wrong creds or re-asking on rejection.
|
|
@@ -295,7 +364,7 @@ Phase 4 implementer dispatch reads `.active-learnings.md` and injects its conten
|
|
|
295
364
|
|
|
296
365
|
**If `project_type=ios` AND no `.xcodeproj` exists:** follow `protocols/ios-phase-branches.md` §Phase -1 — iOS Bootstrap. Otherwise skip entirely.
|
|
297
366
|
|
|
298
|
-
iOS structural changes are out of scope for this orchestrator migration
|
|
367
|
+
iOS structural changes are out of scope for this orchestrator migration.
|
|
299
368
|
|
|
300
369
|
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
301
370
|
|
|
@@ -331,13 +400,13 @@ Call the Agent tool 4 times in a single message. Each gets the build request + `
|
|
|
331
400
|
|
|
332
401
|
**CONTEXT header:** Render `rendered_context_header` for phase 1 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 1 research prompt below.
|
|
333
402
|
|
|
334
|
-
1. Description: "Feature intel" — subagent_type: `feature-intel` — Prompt: "[CONTEXT header above] Extract competitor feature matrix for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Walk 5-10 rivals. Return must-haves (features present in >=80% of rivals — table stakes) + stand-outs (features unique to individual rivals — differentiation opportunities), sorted by competitor. Save to `docs/plans/phase1-scratch/feature-intel.md`."
|
|
403
|
+
1. Description: "Feature intel" — agent_type: `feature-intel` — subagent_type: `feature-intel` — Prompt: "[CONTEXT header above] Extract competitor feature matrix for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Walk 5-10 rivals. Return must-haves (features present in >=80% of rivals — table stakes) + stand-outs (features unique to individual rivals — differentiation opportunities), sorted by competitor. Save to `docs/plans/phase1-scratch/feature-intel.md`."
|
|
335
404
|
|
|
336
|
-
2. Description: "Tech feasibility" — subagent_type: `tech-feasibility` — Prompt: "[CONTEXT header above] Evaluate hard technical problems (Solved/Hard/Unsolved), build-vs-buy decisions,
|
|
405
|
+
2. Description: "Tech feasibility" — agent_type: `tech-feasibility` — subagent_type: `tech-feasibility` — Prompt: "[CONTEXT header above] Evaluate hard technical problems (Solved/Hard/Unsolved), build-vs-buy decisions, stack validation for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Verify APIs and libraries from the draft exist and are maintained. Save to `docs/plans/phase1-scratch/tech-feasibility.md`. Report with a Technical Verdict."
|
|
337
406
|
|
|
338
|
-
3. Description: "UX research" — subagent_type: `design-ux-researcher` — Prompt: "[CONTEXT header above] Analyze target persona, jobs-to-be-done, current alternatives, and behavioral barriers for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Save to `docs/plans/phase1-scratch/ux-research.md`. Report with a User Verdict."
|
|
407
|
+
3. Description: "UX research" — agent_type: `design-ux-researcher` — subagent_type: `design-ux-researcher` — Prompt: "[CONTEXT header above] Analyze target persona, jobs-to-be-done, current alternatives, and behavioral barriers for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Save to `docs/plans/phase1-scratch/ux-research.md`. Report with a User Verdict."
|
|
339
408
|
|
|
340
|
-
4. Description: "Business model" — subagent_type: `business-model` — Prompt: "[CONTEXT header above] Light-touch revenue/channels/unit-economics analysis for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Surface product-impact conclusions only — which features the business model requires, which channels gate the feature set. Do not write full financial modeling. Save to `docs/plans/phase1-scratch/business-model.md`."
|
|
409
|
+
4. Description: "Business model" — agent_type: `business-model` — subagent_type: `business-model` — Prompt: "[CONTEXT header above] Light-touch revenue/channels/unit-economics analysis for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Surface product-impact conclusions only — which features the business model requires, which channels gate the feature set. Do not write full financial modeling. Save to `docs/plans/phase1-scratch/business-model.md`."
|
|
341
410
|
|
|
342
411
|
### Step 1.2 — RESEARCH DIGEST (context protection)
|
|
343
412
|
|
|
@@ -391,7 +460,7 @@ Write TWO outputs.
|
|
|
391
460
|
OUTPUT 1 — `docs/plans/design-doc.md` — **THE PRD** (authoritative product document). Header MUST begin with `# [Product Name] — PRD`. Structure:
|
|
392
461
|
- Product — what it is, core value prop, success criteria
|
|
393
462
|
- User — persona, JTBD, hard constraints
|
|
394
|
-
- Scope —
|
|
463
|
+
- Scope — Features in scope (must-haves + chosen stand-outs), explicit Out-of-Scope boundary
|
|
395
464
|
- Tech Stack — chosen stack with 1-line rationale
|
|
396
465
|
- Data Model — shape of core entities
|
|
397
466
|
- Decisions — links to `decisions.jsonl` rows
|
|
@@ -411,7 +480,7 @@ OUTPUT 2 — `CLAUDE.md` (project root, NOT `docs/plans/`). <200-line product br
|
|
|
411
480
|
[Stack choices with 1-line rationale for each]
|
|
412
481
|
|
|
413
482
|
## Scope
|
|
414
|
-
[What's in
|
|
483
|
+
[What's in scope vs. deferred. Hard boundaries.]
|
|
415
484
|
|
|
416
485
|
## Rules
|
|
417
486
|
[Project-specific hard rules derived from the product and user context.]
|
|
@@ -464,6 +533,32 @@ Output: `docs/plans/phase1-scratch/prereqs.json` with shape `{supabase_url, supa
|
|
|
464
533
|
|
|
465
534
|
---
|
|
466
535
|
|
|
536
|
+
### Step 1.6 — PRODUCT SPEC
|
|
537
|
+
|
|
538
|
+
Call the Agent tool — description: "Product spec" — agent_type: `product-spec-writer` — subagent_type: `product-spec-writer` — prompt: "[CONTEXT header above] Write `docs/plans/product-spec.md` following the structure in `protocols/product-spec-schema.md`. Read ALL of these via your Read tool before writing (do NOT expect pasted content):
|
|
539
|
+
- `docs/plans/design-doc.md` — PRD: features, persona, JTBD, value prop, scope, tech stack
|
|
540
|
+
- `docs/plans/phase1-scratch/findings-digest.md` — research synthesis
|
|
541
|
+
- `docs/plans/phase1-scratch/ux-research.md` — behavioral patterns, pain points
|
|
542
|
+
- `docs/plans/phase1-scratch/feature-intel.md` — competitive matrix, table-stakes vs differentiators
|
|
543
|
+
- `docs/plans/phase1-scratch/business-model.md` — revenue model implications
|
|
544
|
+
- `docs/plans/phase1-scratch/tech-feasibility.md` — technical constraints, rate limits, API limitations
|
|
545
|
+
- `docs/plans/phase1-scratch/user-decisions.md` — user's product decisions from informed brainstorm
|
|
546
|
+
This is the LAST step that reads raw research files. Every actionable insight must survive in product-spec.md in structured, queryable form. Commit: 'feat: product spec'."
|
|
547
|
+
|
|
548
|
+
#### Step 1.6.idx — Slice 1 graph index
|
|
549
|
+
|
|
550
|
+
After `product-spec-writer` returns and `docs/plans/product-spec.md` is on disk, index it into the build graph. Slice 1 graph index — required for downstream agents.
|
|
551
|
+
|
|
552
|
+
Run via the Bash tool:
|
|
553
|
+
|
|
554
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/product-spec.md`
|
|
555
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
556
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. Downstream agents (BO, PO, implementers) require the graph — do not proceed without a successful index.
|
|
557
|
+
|
|
558
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
467
562
|
## Phase 2: Plan / Architect — TEAM of 6 + sequence
|
|
468
563
|
|
|
469
564
|
**Goal**: Convert the PRD into a concrete architecture and ordered task list with explicit dependencies. Every architect receives the PRD (design-doc.md) + the Research Digest + its domain's raw research file (hybrid routing).
|
|
@@ -484,6 +579,8 @@ The 6 architects design as a TEAM — not 6 isolated subagents. Cross-domain con
|
|
|
484
579
|
|
|
485
580
|
**On re-entry from LRR backward routing:** If Phase 2 is being re-opened via the re-entry dispatch template (Step 6.3), skip team creation if the original `phase-2-architects` team is still live from this build; otherwise recreate it. Pass the re-entry payload (`{blocking_finding, prior_output: "docs/plans/architecture.md", decision_row}`) into the dispatch prompt of the architect(s) whose domain matches `decision_row.author` — only those architects re-run, not all 6. The re-dispatched architect revises its `docs/plans/phase-2-contracts/<name>.md` in place, SendMessages peers on any contract boundary it now changes, and the synthesizer re-runs once to re-stitch `architecture.md`. Do NOT redo unaffected domains.
|
|
486
581
|
|
|
582
|
+
After the synthesizer re-stitches `architecture.md`, re-run the Refs Indexer (Step 2.3 dispatch #4) to update `docs/plans/refs.json` with fresh anchors, and re-run the DAG Validator (Step 2.3 dispatch #3) to verify sprint-tasks.md still references valid architecture sections. Invalidate the sprint-context hash per the refs.json mutation rule.
|
|
583
|
+
|
|
487
584
|
**Step 2.2a — Create the team.**
|
|
488
585
|
|
|
489
586
|
Call `TeamCreate` with `team_name: "phase-2-architects"`. This team scopes the SendMessage channel for the 6 architects below. Capture the team id in `.build-state.json` for teardown.
|
|
@@ -509,6 +606,7 @@ CROSS-CHECK PAIRINGS (mandatory — if your design touches one of these boundari
|
|
|
509
606
|
- Security ↔ Backend on auth flow (token storage, refresh, session model, authz gates)
|
|
510
607
|
- Accessibility ↔ Frontend on component patterns (primitives, focus management, landmark structure)
|
|
511
608
|
- Performance ↔ Backend+Data on query shapes (N+1 risk, indexing strategy, bundle impact of data layer choices)
|
|
609
|
+
- Security ↔ Frontend on client-side auth (token storage location, CSRF protection, input sanitization, secure cookie flags)
|
|
512
610
|
|
|
513
611
|
COORDINATION RULES:
|
|
514
612
|
- Plain text in your output file is INVISIBLE to teammates. If a contract boundary intersects another architect's domain, you MUST `SendMessage` to that peer using the exact `name` from the roster above. Do not assume they will read your file.
|
|
@@ -524,17 +622,17 @@ Per-architect dispatches:
|
|
|
524
622
|
**CONTEXT header:** Render `rendered_context_header` for phase 2 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 2 architect prompt below.
|
|
525
623
|
|
|
526
624
|
|
|
527
|
-
1. Description: "Backend architecture" — subagent_type: `engineering-backend-architect` — team_name: `phase-2-architects` — name: `backend-architect` — Prompt: "[CONTEXT header above] Design system architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude services, data models, API contracts, database schema, integration points. Respect stack choices from PRD.\n\n[paste shared team brief above]"
|
|
625
|
+
1. Description: "Backend architecture" — agent_type: `engineering-backend-architect` — subagent_type: `engineering-backend-architect` — team_name: `phase-2-architects` — name: `backend-architect` — Prompt: "[CONTEXT header above] Design system architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude services, data models, API contracts, database schema, integration points. Respect stack choices from PRD. Map per-feature Business Rules and States to specific endpoints, persistence schemas, and validation logic — every State the product spec defines must have a backend behavior.\n\n[paste shared team brief above]"
|
|
528
626
|
|
|
529
|
-
2. Description: "Frontend architecture" — subagent_type: `engineering-frontend-developer` — team_name: `phase-2-architects` — name: `frontend-architect` — Prompt: "[CONTEXT header above] Design frontend architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude component hierarchy, layout strategy, responsive approach, state management, routing. Align UX with the persona from research.\n\n[paste shared team brief above]"
|
|
627
|
+
2. Description: "Frontend architecture" — agent_type: `engineering-frontend-developer` — subagent_type: `engineering-frontend-developer` — team_name: `phase-2-architects` — name: `frontend-architect` — Prompt: "[CONTEXT header above] Design frontend architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude component hierarchy, layout strategy, responsive approach, state management, routing. Align UX with the persona from research. Map the Screen Inventory to your component hierarchy — every screen the product spec lists must have a routable view, and per-feature States must drive the component-state matrix.\n\n[paste shared team brief above]"
|
|
530
628
|
|
|
531
|
-
3. Description: "Data engineering" — subagent_type: `engineering-data-engineer` — team_name: `phase-2-architects` — name: `data-engineer` — Prompt: "[CONTEXT header above] Design data architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nInclude ETL/ELT patterns, schema versioning, query patterns, indexing strategy, data lineage, migration plan.\n\n[paste shared team brief above]"
|
|
629
|
+
3. Description: "Data engineering" — agent_type: `engineering-data-engineer` — subagent_type: `engineering-data-engineer` — team_name: `phase-2-architects` — name: `data-engineer` — Prompt: "[CONTEXT header above] Design data architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nInclude ETL/ELT patterns, schema versioning, query patterns, indexing strategy, data lineage, migration plan. Per-feature data requirements from the product spec drive your schema — derived fields, denormalizations, and access patterns must serve specific feature flows.\n\n[paste shared team brief above]"
|
|
532
630
|
|
|
533
|
-
4. Description: "Security architecture" — subagent_type: `engineering-security-engineer` — team_name: `phase-2-architects` — name: `security-engineer` — Prompt: "[CONTEXT header above] Security review. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\nCover auth model, input validation, secrets management, threat model, dependency hygiene.
|
|
631
|
+
4. Description: "Security architecture" — agent_type: `engineering-security-engineer` — subagent_type: `engineering-security-engineer` — team_name: `phase-2-architects` — name: `security-engineer` — Prompt: "[CONTEXT header above] Security review. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nCover auth model, input validation, secrets management, threat model, dependency hygiene. Use the product spec's ## Permissions & Roles section to drive your auth model — roles in the product spec must map to enforceable permissions in the architecture.\n\n[paste shared team brief above]"
|
|
534
632
|
|
|
535
|
-
5. Description: "A11y constraints" — subagent_type: `a11y-architect` — team_name: `phase-2-architects` — name: `accessibility-auditor` — Prompt: "[CONTEXT header above] Accessibility-driven architecture constraints. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`\nIdentify WCAG 2.2 AA requirements that affect component choice, navigation structure, form patterns, focus management, landmark regions.\n\n[paste shared team brief above]"
|
|
633
|
+
5. Description: "A11y constraints" — agent_type: `a11y-architect` — subagent_type: `a11y-architect` — team_name: `phase-2-architects` — name: `accessibility-auditor` — Prompt: "[CONTEXT header above] Accessibility-driven architecture constraints. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`\nIdentify WCAG 2.2 AA requirements that affect component choice, navigation structure, form patterns, focus management, landmark regions. Per-feature Persona Constraints (e.g., \"user scans, doesn't read\", \"operator on a phone in the field\") drive component-level a11y constraints.\n\n[paste shared team brief above]"
|
|
536
634
|
|
|
537
|
-
6. Description: "Performance constraints" — subagent_type: `testing-performance-benchmarker` — team_name: `phase-2-architects` — name: `performance-benchmarker` — Prompt: "[CONTEXT header above] Define quality targets for this build. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nWrite `docs/plans/quality-targets.json` covering bundle budget, LCP, TTI, API p95, Lighthouse scores. Use per-Scope budgets
|
|
635
|
+
6. Description: "Performance constraints" — agent_type: `testing-performance-benchmarker` — subagent_type: `testing-performance-benchmarker` — team_name: `phase-2-architects` — name: `performance-benchmarker` — Prompt: "[CONTEXT header above] Define quality targets for this build. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (## App Overview, ## Screen Inventory, ## Permissions & Roles, per-feature behavioral sections — feature behaviors are the source of truth your architecture must support)\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nWrite `docs/plans/quality-targets.json` covering bundle budget, LCP, TTI, API p95, Lighthouse scores. Use per-Scope budgets: Marketing 500KB / Product 300KB / Dashboard 400KB / Internal 200KB gzipped. Per-feature critical-path performance derives from the product spec's Happy Path latency expectations.\n\n[paste shared team brief above]"
|
|
538
636
|
|
|
539
637
|
**Step 2.2c — Wait for all 6 teammates to idle**, then proceed to synthesis. The `docs/plans/phase-2-contracts/*.md` files now contain post-debate positions (initial draft plus any SendMessage-driven revisions). The orchestrator does NOT read these files — the synthesizer below does.
|
|
540
638
|
|
|
@@ -548,9 +646,9 @@ Four sequential dispatches.
|
|
|
548
646
|
|
|
549
647
|
**CONTEXT header:** Reuse `rendered_context_header` from phase 2 (already rendered above). Prepend to Step 2.3 synthesizer + sprint-breakdown prompts.
|
|
550
648
|
|
|
551
|
-
1. Description: "Implementation blueprint" — subagent_type: `code-architect` — Prompt: "[CONTEXT header above] Implementation blueprint. Read the PRD via your Read tool: `docs/plans/design-doc.md`. Read all 6 post-debate architect positions via your own Read tool from `docs/plans/phase-2-contracts/`:\n - `backend-architect.md`\n - `frontend-architect.md`\n - `data-engineer.md`\n - `security-engineer.md`\n - `accessibility-auditor.md`\n - `performance-benchmarker.md`\n\nThese files are the authoritative team positions AFTER any SendMessage-driven revisions — the architects already cross-checked each other's contract boundaries, so you can stitch without re-debating. Your job is to assemble, not
|
|
649
|
+
1. Description: "Implementation blueprint" — agent_type: `code-architect` — subagent_type: `code-architect` — Prompt: "[CONTEXT header above] Implementation blueprint. Read the PRD via your Read tool: `docs/plans/design-doc.md`. Read the product spec: `docs/plans/product-spec.md` (Screen Inventory + per-feature behavioral sections — your blueprint's file-and-build-order list must cover every feature in the spec). Read all 6 post-debate architect positions via your own Read tool from `docs/plans/phase-2-contracts/`:\n - `backend-architect.md`\n - `frontend-architect.md`\n - `data-engineer.md`\n - `security-engineer.md`\n - `accessibility-auditor.md`\n - `performance-benchmarker.md`\n\nThese files are the authoritative team positions AFTER any SendMessage-driven revisions — the architects already cross-checked each other's contract boundaries, so you can stitch without re-debating. Your job is to assemble the 6 positions into a coherent architecture. Where positions conflict OUTSIDE the 5 mandatory cross-check pairings, flag the contradiction explicitly in `architecture.md` under a `### Unresolved Tensions` section and pick the safer default. Do not silently absorb contradictions. Include specific files to create/modify, build sequence, dependency order. Write `docs/plans/architecture.md` with stable section anchors per `protocols/architecture-schema.md`. Required top-level sections: Overview, Frontend, Backend, Data Model, Security, Infrastructure, Scope, Out of Scope. Scope to the boundary from the PRD. Every API endpoint heading in the Backend section MUST include feature attribution annotations — e.g. `**POST /api/orders** (provides: order-placement)` — using the feature kebab names from `product-spec.md`. These annotations are required for the graph indexer to emit cross-feature dependency edges."
|
|
552
650
|
|
|
553
|
-
2. Description: "Sprint breakdown" — subagent_type: `planner` — Prompt: "[CONTEXT header above] Break this architecture into ordered, atomic tasks. Each task needs: description, acceptance criteria, **dependencies** (list of task IDs this depends on), size (S/M/L), **Behavioral Test** field for every UI task (concrete interaction: 'Navigate to [page], click [element], verify [outcome]') or curl-based acceptance test for API tasks. Read these files via your Read tool before starting:\n - ARCHITECTURE: `docs/plans/architecture.md`\n - PRD: `docs/plans/design-doc.md`\
|
|
651
|
+
2. Description: "Sprint breakdown" — agent_type: `planner` — subagent_type: `planner` — Prompt: "[CONTEXT header above] Break this architecture into ordered, atomic tasks. Each task needs: description, acceptance criteria, **dependencies** (list of task IDs this depends on), size (S/M/L), **Behavioral Test** field for every UI task (concrete interaction: 'Navigate to [page], click [element], verify [outcome]') or curl-based acceptance test for API tasks, **Feature** — the exact feature name from product-spec.md (e.g. 'Order Placement', 'Auth') that must match a `## Feature: X` heading in product-spec.md (use '—' for infrastructure tasks that don't belong to a specific feature), **Screens** — comma-separated screen names from the product-spec Screen Inventory (e.g. 'Catalog, Product Detail') that must match screen names in product-spec.md (use '—' for backend-only tasks). Read these files via your Read tool before starting:\n - ARCHITECTURE: `docs/plans/architecture.md`\n - PRODUCT SPEC: `docs/plans/product-spec.md` (per-feature behavioral sections — every feature in the spec must have at least one task, and per-feature acceptance criteria become Behavioral Test field values)\n - PRD: `docs/plans/design-doc.md`\nSave to `docs/plans/sprint-tasks.md`. The table must have these columns in order: Task ID, Title, Size, Dependencies, Behavioral Test, Owns Files, Implementing Phase, Feature, Screens. Dependencies field is load-bearing — Phase 4 uses it to batch independent tasks in parallel. Each task's Behavioral Test field SHOULD reference a specific feature acceptance criterion from the product spec (e.g., \"User can submit form with valid email; submitted form appears in admin dashboard within 5s\" — derived from product-spec.md's Happy Path or per-state criteria)."
|
|
554
652
|
|
|
555
653
|
3. Description: "Task DAG validator" — INTERNAL inline role-string — Prompt: "You are the Task DAG Validator. Read `docs/plans/sprint-tasks.md`. Validate for DAG correctness:
|
|
556
654
|
- No circular dependencies
|
|
@@ -565,12 +663,42 @@ Report any violations. If clean, return PASS. If violations, return a list of fi
|
|
|
565
663
|
- `docs/plans/architecture.md`
|
|
566
664
|
- `docs/plans/sprint-tasks.md`
|
|
567
665
|
- `docs/plans/quality-targets.json`
|
|
568
|
-
- `
|
|
666
|
+
- `DESIGN.md` (if it exists yet — Phase 3 extends refs.json after it writes this file)
|
|
569
667
|
|
|
570
668
|
For each doc, extract section anchors into a flat index. Schema: `[{\"anchor\": \"design-doc.md#persona\", \"topic\": \"user persona\", \"file_path\": \"docs/plans/design-doc.md\"}, ...]`. This index is consumed by the Phase 4 Briefing Officer for per-task context maps. Do NOT include Phase 1 scratch files — they are SPENT."
|
|
571
669
|
|
|
572
670
|
**Architecture Metric Loop (callable service):** Run the Metric Loop Protocol (`protocols/metric-loop.md`) on `architecture.md`. Define a metric: coverage of PRD requirements, specificity, consistency across the 6 architects, and **simplicity** — is this the simplest architecture that meets the requirements? Could any service, abstraction, or dependency be eliminated? Penalize over-engineering. Max 3 iterations.
|
|
573
671
|
|
|
672
|
+
#### Step 2.3.1.idx — Architecture graph index
|
|
673
|
+
|
|
674
|
+
After `code-architect` returns from the Implementation Blueprint dispatch (#1 above) AND the Architecture Metric Loop exits with `architecture.md` on disk, index it into the build graph. Slice 4 graph index — required for downstream agents.
|
|
675
|
+
|
|
676
|
+
Run via the Bash tool:
|
|
677
|
+
|
|
678
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/architecture.md`
|
|
679
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
680
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. Downstream agents require the graph — do not proceed without a successful index.
|
|
681
|
+
|
|
682
|
+
#### Step 2.3.2.idx — Sprint tasks graph index
|
|
683
|
+
|
|
684
|
+
After `planner` returns from the Sprint Breakdown dispatch (#2 above) AND the Task DAG Validator (#3 above) returns PASS, index `sprint-tasks.md` into the build graph. Slice 4 graph index — best-effort.
|
|
685
|
+
|
|
686
|
+
Run via the Bash tool:
|
|
687
|
+
|
|
688
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/sprint-tasks.md`
|
|
689
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
690
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. Downstream agents require the graph — do not proceed without a successful index.
|
|
691
|
+
|
|
692
|
+
#### Step 2.3.4.idx — Decisions re-index (end of Phase 2)
|
|
693
|
+
|
|
694
|
+
After the four Step 2.3 dispatches complete and the orchestrator finishes routing the 4 Phase 2 `deviation_row` objects through `scribe_decision`, re-index `decisions.jsonl` so the Slice 4 fragment reflects every Phase 2 decision before the LRR aggregator or feedback synthesizer can read it. Skip silently if `docs/plans/decisions.jsonl` does not exist (no decisions written yet).
|
|
695
|
+
|
|
696
|
+
Run via the Bash tool:
|
|
697
|
+
|
|
698
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/decisions.jsonl`
|
|
699
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
700
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. The decisions graph fragment must be current before downstream consumers query it.
|
|
701
|
+
|
|
574
702
|
**Architecture decisions:** The Implementation Blueprint synthesizer returns 4 `deviation_row` objects (or a `phase_2_decisions` array of row objects) in its structured result — one per cross-cutting Phase 2 decision (API contract, persistence layer, auth model, framework choice). The orchestrator forwards each row through the `scribe_decision` MCP tool (see Phase 4 "Orchestrator-scribe dispatch"); the MCP allocates `D-2-<seq>` IDs and atomically appends to `docs/plans/decisions.jsonl`. Author = `architect`. Each row carries a `ref` anchor pointing into `architecture.md` per `protocols/decision-log.md`. Total: 4 rows.
|
|
575
703
|
|
|
576
704
|
**Writes:** `docs/plans/architecture.md`, `docs/plans/sprint-tasks.md`, `docs/plans/quality-targets.json`, `docs/plans/refs.json`. Decision rows (4) flow through the orchestrator's `scribe_decision` MCP calls.
|
|
@@ -608,90 +736,127 @@ Update TodoWrite and `.build-state.json`.
|
|
|
608
736
|
<HARD-GATE>
|
|
609
737
|
UI/UX IS THE PRODUCT. This phase is a full peer to Architecture and Build — not a footnote, not an afterthought. Do NOT skip, compress, or rush this phase for any reason.
|
|
610
738
|
|
|
611
|
-
Phase 4 WILL NOT START without `
|
|
739
|
+
Phase 4 WILL NOT START without `DESIGN.md` (Pass 1 + Pass 2 complete). If the artifact does not exist, return here.
|
|
612
740
|
</HARD-GATE>
|
|
613
741
|
|
|
614
742
|
**Mode-specific branch files drive Phase 3 in detail:**
|
|
615
743
|
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 3 (HIG + App Store + screenlane harvest → iOS Design Board, SwiftUI Preview QA loop).
|
|
616
|
-
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 3 — this file contains the NEW structure with steps 3.0-3.7 covering Visual DNA Selection (Brand Guardian as DNA owner at 3.0), Visual Research, Component Library Mapping, UX Architecture, Visual Design Spec, Inclusive Visuals Check, Style Guide Implementation (wrapped in Design Critic metric loop), and A11y Design Review. See
|
|
744
|
+
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 3 — this file contains the NEW structure with steps 3.0-3.7 covering Visual DNA Selection (Brand Guardian as DNA owner at 3.0), Visual Research, Component Library Mapping, UX Architecture, Visual Design Spec, Inclusive Visuals Check, Style Guide Implementation (wrapped in Design Critic metric loop), and A11y Design Review. See the Component Library Mapping step in that protocol for the component library strategy.
|
|
745
|
+
|
|
746
|
+
**Phase 3 branch-file dispatch table (subagent_type references for SSOT lint):**
|
|
747
|
+
- Step 3.0 Visual DNA Selection: agent_type: `design-brand-guardian` — subagent_type: `design-brand-guardian` (web)
|
|
748
|
+
- Step 3.1 Visual Research (2 parallel): agent_type: `visual-research` — subagent_type: `visual-research` (web, competitive-audit + inspiration-mining)
|
|
749
|
+
- Step 3.2 Component Library Mapping: agent_type: `design-ui-designer` — subagent_type: `design-ui-designer` (web)
|
|
750
|
+
- Step 3.2b DNA Persona Check: agent_type: `design-ux-researcher` — subagent_type: `design-ux-researcher` (web, may route to 3.0)
|
|
751
|
+
- Step 3.3 UX Architecture: agent_type: `design-ux-architect` — subagent_type: `design-ux-architect` (web)
|
|
752
|
+
- Step 3.5 Inclusive Visuals Check: agent_type: `design-inclusive-visuals-specialist` — subagent_type: `design-inclusive-visuals-specialist` (web)
|
|
753
|
+
- Step 3.2-ios iOS Design Board: agent_type: `ios-swift-ui-design` — subagent_type: `ios-swift-ui-design` (iOS)
|
|
617
754
|
|
|
618
|
-
**Phase 3 write discipline:** Phase 3 is the writer for `
|
|
755
|
+
**Phase 3 write discipline:** Phase 3 is the writer for `DESIGN.md` (web) and extends `docs/plans/refs.json` to cover the visual spec anchors once it lands. Phase 3 does NOT write to `architecture.md` or `sprint-tasks.md` — those are Phase 2's.
|
|
619
756
|
|
|
620
757
|
<HARD-GATE>
|
|
621
758
|
LRR BLOCK backward edge: `LRR BLOCK authoring=Phase 3 → back to Phase 3`. The ⭐⭐ star rule routes BLOCK findings via Aggregator decisions.jsonl `decided_by` lookup; if `decided_by == design-brand-guardian` or any Phase 3 writer, the build re-opens Phase 3 with the finding as input.
|
|
622
759
|
</HARD-GATE>
|
|
623
760
|
|
|
624
|
-
**On re-entry from LRR backward routing:** When Phase 3 is re-opened via the re-entry dispatch template (Step 6.3), the orchestrator passes the re-entry payload (`{blocking_finding, prior_output: "
|
|
761
|
+
**On re-entry from LRR backward routing:** When Phase 3 is re-opened via the re-entry dispatch template (Step 6.3), the orchestrator passes the re-entry payload (`{blocking_finding, prior_output: "DESIGN.md", decision_row}`) into the specific Phase 3 step named by `decision_row.author`. That step revises the prior output to address `blocking_finding` only — DESIGN.md Pass 1 (Step 3.0), component manifest (Step 3.2), or DESIGN.md Pass 2 (Step 3.4) — and emits a new decision_row. Unaffected steps are NOT re-run. Mode-specific branch files (`protocols/web-phase-branches.md` / `protocols/ios-phase-branches.md`) define which step owns which `decided_by` value.
|
|
625
762
|
|
|
626
763
|
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
627
764
|
|
|
628
765
|
---
|
|
629
766
|
|
|
630
|
-
## Phase 4: Build —
|
|
767
|
+
## Phase 4: Build — THREE-TIER FEATURE-BASED EXECUTION
|
|
631
768
|
|
|
632
769
|
<HARD-GATE>
|
|
633
|
-
Before starting Phase 4: Phase 2 must be approved, Phase 3 must have produced the design artifact
|
|
770
|
+
Before starting Phase 4: Phase 2 must be approved, Phase 3 must have produced the design artifact (`DESIGN.md` — Pass 1 + Pass 2 complete; broken-refs lint == 0), and `docs/plans/page-specs/` must contain at least one file (web). You MUST call the Agent tool for EVERY task. No exceptions.
|
|
634
771
|
</HARD-GATE>
|
|
635
772
|
|
|
636
|
-
**Goal**: Scaffold project
|
|
773
|
+
**Goal**: Scaffold project, then execute sprint tasks organized by FEATURE with product adherence checked per-feature during build. Three tiers: Product Owner (product quality) → Briefing Officers (task planning per feature) → Execution Agents (code). The orchestrator drives all dispatches — PO and BO are planning agents that write artifacts to disk.
|
|
637
774
|
|
|
638
775
|
**Mode-specific branch:**
|
|
639
|
-
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 4
|
|
640
|
-
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 4
|
|
641
|
-
|
|
642
|
-
|
|
776
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 4 for scaffold details and execution agent prompts.
|
|
777
|
+
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 4 for scaffold details and execution agent prompts.
|
|
778
|
+
|
|
779
|
+
**Phase 4 dispatch table (subagent_type references for SSOT lint):**
|
|
780
|
+
- Product Owner (planning): agent_type: `product-owner` — subagent_type: `product-owner`
|
|
781
|
+
- Product Owner (acceptance): agent_type: `product-owner` — subagent_type: `product-owner`
|
|
782
|
+
- Briefing Officer (per feature): agent_type: `briefing-officer` — subagent_type: `briefing-officer`
|
|
783
|
+
- Web UI (S/M): agent_type: `engineering-frontend-developer` — subagent_type: `engineering-frontend-developer`
|
|
784
|
+
- Web UI (L): agent_type: `engineering-senior-developer` — subagent_type: `engineering-senior-developer`
|
|
785
|
+
- Web backend: agent_type: `engineering-backend-architect` — subagent_type: `engineering-backend-architect` OR `engineering-senior-developer`
|
|
786
|
+
- Web AI/ML: agent_type: `engineering-ai-engineer` — subagent_type: `engineering-ai-engineer`
|
|
787
|
+
- iOS UI planner: agent_type: `ios-swift-ui-design` — subagent_type: `ios-swift-ui-design`
|
|
788
|
+
- iOS UI impl: agent_type: `engineering-senior-developer` — subagent_type: `engineering-senior-developer`, `engineering-mobile-app-builder`
|
|
789
|
+
- iOS Foundation Models: agent_type: `ios-foundation-models-specialist` — subagent_type: `ios-foundation-models-specialist`
|
|
790
|
+
- iOS StoreKit: agent_type: `ios-storekit-specialist` — subagent_type: `ios-storekit-specialist`
|
|
791
|
+
- iOS Swift review: agent_type: `swift-reviewer` — subagent_type: `swift-reviewer`
|
|
792
|
+
- Security review: agent_type: `security-reviewer` — subagent_type: `security-reviewer`
|
|
793
|
+
- Cleanup: agent_type: `code-simplifier` — subagent_type: `code-simplifier`, `refactor-cleaner`
|
|
794
|
+
- Code review: agent_type: `code-reviewer` — subagent_type: `code-reviewer`, `silent-failure-hunter`
|
|
795
|
+
|
|
796
|
+
### Step 4.0 — Scaffold (unchanged)
|
|
643
797
|
|
|
644
798
|
Scaffolding is project skeleton + design system + acceptance test stubs. Three sequential dispatches (full details in the mode-specific branch file):
|
|
645
799
|
|
|
646
|
-
**CONTEXT header:** Render `rendered_context_header` for phase 4 per the canonical template (see CONTEXT HEADER HARD-GATE above). Includes `dna` field for web projects. Prepend to every Phase 4
|
|
800
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 4 per the canonical template (see CONTEXT HEADER HARD-GATE above). Includes `dna` field for web projects. Prepend to every Phase 4 prompt below.
|
|
647
801
|
|
|
648
|
-
1. Description: "Project scaffolding" — subagent_type: `engineering-rapid-prototyper` — mode: "bypassPermissions" — prompt per branch file
|
|
802
|
+
1. Description: "Project scaffolding" — agent_type: `engineering-rapid-prototyper` — subagent_type: `engineering-rapid-prototyper` — mode: "bypassPermissions" — prompt per branch file.
|
|
649
803
|
|
|
650
|
-
2. Description: "Design system setup" — subagent_type: `engineering-frontend-developer` — mode: "bypassPermissions" — prompt per branch file.
|
|
804
|
+
2. Description: "Design system setup" — agent_type: `engineering-frontend-developer` — subagent_type: `engineering-frontend-developer` — mode: "bypassPermissions" — prompt per branch file. Implements design tokens from `DESIGN.md`.
|
|
651
805
|
|
|
652
|
-
3. Description: "Scaffold acceptance tests" — INTERNAL inline role-string — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Scaffold acceptance tests from sprint-tasks.md. Use Page Object Model.
|
|
806
|
+
3. Description: "Scaffold acceptance tests" — INTERNAL inline role-string — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Scaffold acceptance tests from sprint-tasks.md. Use Page Object Model. For every task with a Behavioral Test field, create a Playwright test stub (web) or Maestro flow stub (iOS). Stubs must FAIL right now. Commit: 'test: scaffold acceptance tests from sprint tasks'."
|
|
653
807
|
|
|
654
|
-
**Scaffold verification:** Run the Verify Protocol
|
|
808
|
+
**Scaffold verification:** Run the Verify Protocol with `scope: static` (checks 1-3 and 6 only: Build, Type-Check, Lint, Diff Review). Test stubs are designed to fail at this point — do not run checks 4, 5, or 7 until after task implementation.
|
|
655
809
|
|
|
656
|
-
### Step 4.1
|
|
810
|
+
### Step 4.1 — Product Owner: Feature Planning
|
|
657
811
|
|
|
658
|
-
|
|
812
|
+
Dispatch the Product Owner in planning mode. It reads the full artifact set via graph queries, groups tasks by feature, sequences features into dependency-ordered waves, and writes a delegation plan.
|
|
659
813
|
|
|
660
|
-
|
|
814
|
+
Call the Agent tool — description: "Product Owner: feature planning" — agent_type: `product-owner` — subagent_type: `product-owner` — prompt: "[CONTEXT header above] MODE: planning.
|
|
661
815
|
|
|
662
|
-
|
|
816
|
+
Read these artifacts via graph queries:
|
|
817
|
+
- `docs/plans/product-spec.md` — feature list, cross-feature interactions, screen inventory
|
|
818
|
+
- `docs/plans/sprint-tasks.md` — task breakdown with dependencies
|
|
819
|
+
- `docs/plans/architecture.md` — cross-feature API contracts, shared data entities
|
|
820
|
+
- `docs/plans/page-specs/*.md` — screen assignments per feature
|
|
821
|
+
- `docs/plans/quality-targets.json` — NFRs
|
|
663
822
|
|
|
664
|
-
|
|
823
|
+
Produce `docs/plans/feature-delegation-plan.json` per the schema in `agents/product-owner.md`. For each feature: list assigned tasks (from sprint-tasks.md), write a product_context summary (~100-200 tokens: persona constraints, key business rules, critical error scenarios, competitive differentiators), extract cross-feature contracts, list page-spec refs (web: `page-specs/*.md` paths; iOS: `DESIGN.md` section anchors). Sequence features into waves by dependency order."
|
|
665
824
|
|
|
666
|
-
|
|
825
|
+
Output: `docs/plans/feature-delegation-plan.json`. Update `.build-state.json`: set `feature_delegation_plan_path`, initialize `current_wave: 1`, `completed_features: []`, `feature_acceptance: {}`.
|
|
667
826
|
|
|
668
|
-
|
|
827
|
+
### Step 4.2 — Wave Execution (repeat for each wave)
|
|
669
828
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
component variants → component-manifest.md#[category]
|
|
676
|
-
auth model → architecture.md#auth
|
|
677
|
-
data schema → architecture.md#data-model
|
|
678
|
-
sibling task deps → sprint-tasks.md#[dep-id-1], #[dep-id-2]
|
|
679
|
-
prior decisions → decisions.jsonl rows [row-id-1], [row-id-2]
|
|
680
|
-
quality targets → quality-targets.json (full file)
|
|
681
|
-
```
|
|
829
|
+
Read `feature-delegation-plan.json`. For each wave, execute all features. Features within a wave are independent and their Briefing Officers can be dispatched in parallel.
|
|
830
|
+
|
|
831
|
+
#### 4.2.a — Briefing Officer dispatch (one per feature, parallel within wave)
|
|
832
|
+
|
|
833
|
+
For each feature in the current wave, dispatch a Briefing Officer. If the wave has multiple independent features, dispatch all BOs in ONE message (parallel).
|
|
682
834
|
|
|
683
|
-
|
|
835
|
+
Call the Agent tool — description: "Briefing Officer: [feature name]" — agent_type: `briefing-officer` — subagent_type: `briefing-officer` — mode: "bypassPermissions" — prompt: "[CONTEXT header above] FEATURE DELEGATION from Product Owner:
|
|
684
836
|
|
|
685
|
-
|
|
837
|
+
Feature: [feature name]
|
|
838
|
+
Product context: [paste product_context from delegation plan]
|
|
839
|
+
Cross-feature contracts: [paste contracts from delegation plan]
|
|
840
|
+
Assigned tasks: [paste task IDs]
|
|
841
|
+
Page spec refs: [paste page_spec_refs from delegation plan]
|
|
686
842
|
|
|
687
|
-
|
|
843
|
+
Read the full feature spec via graph query. Read task rows from `docs/plans/sprint-tasks.md`. Read page specs, architecture, component manifest, visual design spec for this feature's screens.
|
|
688
844
|
|
|
689
|
-
|
|
690
|
-
- UI tasks: `subagent_type: engineering-frontend-developer` (S/M) or `subagent_type: engineering-senior-developer` (L)
|
|
691
|
-
- Backend tasks: `subagent_type: engineering-backend-architect` (L) or `subagent_type: engineering-senior-developer` (M)
|
|
692
|
-
- Hard / complex / cross-cutting tasks: `subagent_type: engineering-senior-developer`
|
|
845
|
+
Write `docs/plans/feature-briefs/[feature].md` per the schema in `agents/briefing-officer.md`. For each task: specify agent type, skills, structured context payload (layout, components, API contract, error states, business rules, persona constraints), and acceptance criteria."
|
|
693
846
|
|
|
694
|
-
|
|
847
|
+
Output: `docs/plans/feature-briefs/[feature].md`. Update `.build-state.json.feature_briefs[feature]` with the path.
|
|
848
|
+
|
|
849
|
+
#### 4.2.b — Task execution (orchestrator reads BO brief, dispatches per task)
|
|
850
|
+
|
|
851
|
+
After the Briefing Officer writes the feature brief, the orchestrator reads it and executes each task. Tasks within a feature are executed in DAG-parallel batches (topological ordering from the Dependencies field — independent siblings run in parallel, yielding ~30-50% wall-clock saving). The per-task pipeline is unchanged in structure — only the input to the execution agent changes.
|
|
852
|
+
|
|
853
|
+
**For each task in the feature brief:**
|
|
854
|
+
|
|
855
|
+
**1. Implementer dispatch** — The orchestrator reads the task's execution spec from the feature brief and pastes the structured context directly into the execution agent's prompt. See mode-specific branch file (`protocols/web-phase-branches.md` §Phase 4 or `protocols/ios-phase-branches.md` §Phase 4) for the exact prompt template.
|
|
856
|
+
|
|
857
|
+
Call the Agent tool — description: "[task-id] [task name]" — agent_type: [from BO brief] — subagent_type: [from BO brief] — mode: "bypassPermissions" — prompt: "[CONTEXT header above].
|
|
858
|
+
|
|
859
|
+
[Paste the full structured context payload from the feature brief — TASK, FEATURE CONTEXT, PAGE LAYOUT, COMPONENTS, API CONTRACT, ERROR STATES, BUSINESS RULES, SKILLS ASSIGNED, ACCEPTANCE. See branch file for exact format.]
|
|
695
860
|
|
|
696
861
|
## Prior Learnings
|
|
697
862
|
[paste contents of `docs/plans/.active-learnings.md` if it exists, otherwise omit this section]
|
|
@@ -699,56 +864,72 @@ Call the Agent tool — description: "[task-id] [task name]" — subagent_type p
|
|
|
699
864
|
## Deviation Reporting
|
|
700
865
|
If your implementation deviates from the planned architecture, return a `deviation_row` object per the schema in `protocols/decision-log.md`. If no deviation, return `deviation_row: null`. Do NOT write `decisions.jsonl` directly.
|
|
701
866
|
|
|
702
|
-
Implement fully with real code and tests. Commit: 'feat: [task]'. Report what you built, files changed, and test results.
|
|
867
|
+
Implement fully with real code and tests. Commit: 'feat: [task]'. Report what you built, files changed, and test results."
|
|
868
|
+
|
|
869
|
+
**2. Per-task security review (auth/PII tasks only)** — unchanged from prior design.
|
|
870
|
+
|
|
871
|
+
Call the Agent tool — description: "Security review for [task-id]" — agent_type: `security-reviewer` — subagent_type: `security-reviewer` — prompt: "[CONTEXT header above] Review changed files from [task-id] for security issues. Scope: auth logic, input validation, secrets handling, dependency hygiene, OWASP Top 10 for web (or iOS Keychain / ATS / data protection for iOS). Return blocking findings only — 80%+ confidence threshold. Files to review: [list from implementer's changeset]."
|
|
872
|
+
|
|
873
|
+
**3. Senior Dev cleanup** — unchanged. Two-pass, changeset-scoped.
|
|
874
|
+
|
|
875
|
+
1. Call the Agent tool — description: "Simplify [task-id]" — agent_type: `code-simplifier` — subagent_type: `code-simplifier` — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Simplify changed files from [task-id]. Remove dead code, unused imports, redundant abstractions. Do NOT add features. Do NOT change architecture. Do NOT touch files outside the changeset. Files: [list]."
|
|
703
876
|
|
|
704
|
-
|
|
705
|
-
**[ORCHESTRATOR: Include the "On Re-entry" section below ONLY when this is a re-entry dispatch from LRR backward routing. For normal Phase 4 execution, OMIT it.]**
|
|
877
|
+
2. If TS/JS task: Call the Agent tool — description: "Refactor [task-id]" — agent_type: `refactor-cleaner` — subagent_type: `refactor-cleaner` — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Run knip/depcheck/ts-prune on changed files from [task-id]. Changeset only. Files: [list]."
|
|
706
878
|
|
|
707
|
-
|
|
879
|
+
**4. Per-task code review (parallel pair)** — unchanged.
|
|
708
880
|
|
|
709
|
-
|
|
881
|
+
Call the Agent tool 2 times in one message:
|
|
710
882
|
|
|
711
|
-
|
|
883
|
+
1. Description: "Code review for [task-id]" — agent_type: `code-reviewer` — subagent_type: `code-reviewer` — Prompt: "[CONTEXT header above] Review changed files from [task-id]. 80%+ confidence threshold. Changeset only. Files: [list]."
|
|
712
884
|
|
|
713
|
-
|
|
885
|
+
2. Description: "Silent failure hunt for [task-id]" — agent_type: `silent-failure-hunter` — subagent_type: `silent-failure-hunter` — Prompt: "[CONTEXT header above] Hunt silent failures in changed files from [task-id]. Files: [list]."
|
|
714
886
|
|
|
715
|
-
|
|
887
|
+
**5. Metric Loop** — unchanged. Authoritative behavioral check per `protocols/metric-loop.md`. Max 5 iterations.
|
|
716
888
|
|
|
717
|
-
|
|
889
|
+
**6. Verify Service** — unchanged. Static checks only (type-check, lint, build). Max 2 fix attempts.
|
|
718
890
|
|
|
719
|
-
|
|
891
|
+
**7. After each task completes** — Update TodoWrite and `.build-state.json`. Write summary to `docs/plans/.task-outputs/[task-id].json`.
|
|
720
892
|
|
|
721
|
-
|
|
893
|
+
**8. Orchestrator-scribe** — After all tasks in a feature complete, collect deviation_rows and forward through `scribe_decision` MCP. Same mechanics as before.
|
|
722
894
|
|
|
723
|
-
|
|
895
|
+
### Step 4.3 — Product Owner: Feature Acceptance
|
|
724
896
|
|
|
725
|
-
|
|
897
|
+
After all tasks for a feature complete, dispatch the Product Owner in acceptance mode. It checks whether the built feature matches the product spec.
|
|
726
898
|
|
|
727
|
-
Call the Agent tool
|
|
899
|
+
Call the Agent tool — description: "Product Owner: accept [feature name]" — agent_type: `product-owner` — subagent_type: `product-owner` — prompt: "[CONTEXT header above] MODE: acceptance. FEATURE: [feature name].
|
|
728
900
|
|
|
729
|
-
|
|
901
|
+
Read the feature's acceptance criteria and business rules via graph query. Read the feature's page spec(s) from `docs/plans/page-specs/`. Use agent-browser (web) or XcodeBuildMCP + Maestro (iOS) to verify the built feature.
|
|
730
902
|
|
|
731
|
-
|
|
903
|
+
Check: (1) Does the feature implement the product spec's happy path? (2) Are business rules correct? (3) Are error states from the product spec handled? (4) Does the layout match the page spec? (5) Does component usage match the manifest?
|
|
732
904
|
|
|
733
|
-
|
|
905
|
+
Write verdict: ACCEPTED or NEEDS_REVISION with specific findings citing product-spec sections."
|
|
734
906
|
|
|
735
|
-
|
|
907
|
+
**Verdict routing:**
|
|
908
|
+
- `ACCEPTED` → mark feature complete in `.build-state.json.feature_acceptance`. Proceed.
|
|
909
|
+
- `NEEDS_REVISION` → orchestrator re-dispatches the Briefing Officer for this feature with the findings. BO writes an updated brief targeting only the failing tasks. Orchestrator re-executes those tasks. Max 2 revision cycles per feature. After 2nd NEEDS_REVISION: interactive → present findings to user. Autonomous → accept with gap note in build-log.md AND append a structured gap entry to `.build-state.json.feature_acceptance[feature].gaps[]` with shape `{finding, severity, accepted_at_cycle}`. The Phase 6 LRR Eng-Quality chapter reads these gaps as input evidence.
|
|
736
910
|
|
|
737
|
-
|
|
911
|
+
### Step 4.4 — Wave Transition
|
|
738
912
|
|
|
739
|
-
|
|
913
|
+
After all features in the current wave are ACCEPTED:
|
|
740
914
|
|
|
741
|
-
|
|
915
|
+
1. Update `.build-state.json`: add features to `completed_features`, increment `current_wave`.
|
|
916
|
+
2. Handle shared file mutations: if any BO flagged shared file changes needed by the next wave, apply them now. The orchestrator identifies shared files from BO cross-feature contract fields. For each shared file flagged by multiple features in the next wave, dispatch a single `code-architect` agent to reconcile the mutations before wave execution begins. Do NOT let multiple BOs independently modify the same shared file.
|
|
917
|
+
3. Run a quick Verify Protocol (static checks) to confirm the wave didn't break anything.
|
|
918
|
+
4. Proceed to next wave. Repeat Steps 4.2-4.4.
|
|
742
919
|
|
|
743
|
-
|
|
920
|
+
After all waves complete, Phase 4 is done.
|
|
744
921
|
|
|
745
|
-
|
|
922
|
+
#### Step 4.4.idx — Decisions re-index (end of wave)
|
|
746
923
|
|
|
747
|
-
|
|
924
|
+
After each wave's deviation rows have been routed through `scribe_decision` (per the Orchestrator-scribe dispatch below), re-index `decisions.jsonl` so the Slice 4 fragment reflects every wave-level decision before the next wave's BOs query open decisions. Skip silently if `docs/plans/decisions.jsonl` does not exist.
|
|
748
925
|
|
|
749
|
-
|
|
926
|
+
Run via the Bash tool:
|
|
750
927
|
|
|
751
|
-
|
|
928
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/decisions.jsonl`
|
|
929
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
930
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. The next wave's BOs require current decision data.
|
|
931
|
+
|
|
932
|
+
**Writes:** source code, `docs/plans/.task-outputs/`, `docs/plans/feature-delegation-plan.json`, `docs/plans/feature-briefs/*.md`. Deviation rows flow through the orchestrator's `scribe_decision` MCP calls.
|
|
752
933
|
|
|
753
934
|
<HARD-GATE>
|
|
754
935
|
DECISIONS.JSONL — ORCHESTRATOR-SCRIBE ONLY via `scribe_decision` MCP. Only the orchestrator may cause appends to `docs/plans/decisions.jsonl`, and it does so exclusively by invoking the `scribe_decision` MCP tool. Any dispatch prompt asking a subagent to write this file is a bug. The orchestrator itself MUST NOT Write or Edit the file directly. Subagents return `deviation_row` objects in their structured result; the orchestrator forwards them through the MCP, which owns ID allocation and atomic append.
|
|
@@ -756,87 +937,125 @@ DECISIONS.JSONL — ORCHESTRATOR-SCRIBE ONLY via `scribe_decision` MCP. Only the
|
|
|
756
937
|
|
|
757
938
|
#### Orchestrator-scribe dispatch (route deviation rows through `scribe_decision` MCP)
|
|
758
939
|
|
|
759
|
-
Runs after
|
|
940
|
+
Runs after each feature's tasks complete. Same mechanics as before:
|
|
760
941
|
|
|
761
|
-
1.
|
|
762
|
-
2. For each row, invoke
|
|
763
|
-
3.
|
|
764
|
-
4. Regenerate `.build-state.md
|
|
942
|
+
1. Collect non-null `deviation_row` from each subagent return.
|
|
943
|
+
2. For each row, invoke `scribe_decision` MCP. One call per row.
|
|
944
|
+
3. MCP allocates `decision_id`, stamps timestamp, validates, atomically appends.
|
|
945
|
+
4. Regenerate `.build-state.md`.
|
|
765
946
|
|
|
766
|
-
**On resume:**
|
|
947
|
+
**On resume:** scribe MCP reconstructs its ID allocator by scanning `decisions.jsonl`. The `decisions_next_id` field in `.build-state.json` is deprecated (scribe owns ID allocation).
|
|
767
948
|
|
|
768
949
|
<HARD-GATE>
|
|
769
|
-
LRR NEEDS_WORK backward edge: `LRR NEEDS_WORK (code-level) → back to Phase 4 target
|
|
950
|
+
LRR NEEDS_WORK backward edge: `LRR NEEDS_WORK (code-level) → back to Phase 4 target feature`. The Aggregator classifies the finding and routes to the specific feature's Briefing Officer via `related_decision_id` lookup. The BO re-plans the affected task(s), orchestrator re-executes. Product-level issues route to the Product Owner, who re-delegates to the relevant BO.
|
|
770
951
|
</HARD-GATE>
|
|
771
952
|
|
|
772
|
-
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
953
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above. Feature-level state (`completed_features`, `current_wave`, `feature_acceptance`, `feature_briefs`) survives compaction — all planning artifacts are on disk.
|
|
773
954
|
|
|
774
955
|
---
|
|
775
956
|
|
|
776
|
-
## Phase 5: Audit —
|
|
957
|
+
## Phase 5: Audit — Track A (engineering reality) + Track B (product reality) + cross-cutting
|
|
777
958
|
|
|
778
959
|
<HARD-GATE>
|
|
779
960
|
Before starting Phase 5: run the Verify Protocol (7 checks) one more time. All checks must pass before expensive audit agents fire.
|
|
780
961
|
</HARD-GATE>
|
|
781
962
|
|
|
782
|
-
**Goal**: Surface quality issues before Launch Review.
|
|
963
|
+
**Goal**: Surface quality issues before Launch Review. Phase 5 runs in three layers: Track A audits the engineering envelope (API / perf / a11y / security / brand drift), Track B audits the built product against `product-spec.md` per-feature (states, transitions, business rules, happy path, persona constraints, wiring, manifest coverage), and Cross-cutting checks (E2E user journeys, autonomous dogfood, fake-data detector) catch what neither track anticipates. Findings from all three layers route through one Feedback Synthesizer (Step 5.4) and one Fix loop (Step 5.5).
|
|
783
964
|
|
|
784
965
|
**Mode-specific branch:**
|
|
785
|
-
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 5
|
|
966
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 5 for iOS-adapted Track A/B + cross-cutting (XcodeBuildMCP + Maestro execution surface). Steps 5.1–5.3 are defined in the iOS protocol; Steps 5.4–5.5 below are shared.
|
|
786
967
|
- `project_type=web`: continue below.
|
|
787
968
|
|
|
788
|
-
### Step 5.1 —
|
|
969
|
+
### Step 5.1 — Track A: Engineering Reality (5 parallel auditors, ONE message)
|
|
789
970
|
|
|
790
971
|
Read the NFRs from `docs/plans/quality-targets.json`. Pass the relevant targets to each audit agent so they have concrete thresholds, not generic checks.
|
|
791
972
|
|
|
792
|
-
**CONTEXT header:** Render `rendered_context_header` for phase 5 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every
|
|
973
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 5 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Step 5.X dispatch prompt below.
|
|
974
|
+
|
|
975
|
+
Call the Agent tool 5 times in one message:
|
|
976
|
+
|
|
977
|
+
1. Description: "API testing" — agent_type: `testing-api-tester` — subagent_type: `testing-api-tester` — Prompt: "[CONTEXT header above] Comprehensive API validation: all endpoints, edge cases, error responses, auth flows. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for performance and reliability thresholds. Report findings with severity counts."
|
|
978
|
+
|
|
979
|
+
2. Description: "Performance audit" — agent_type: `testing-performance-benchmarker` — subagent_type: `testing-performance-benchmarker` — Prompt: "[CONTEXT header above] Measure response times, identify bottlenecks, flag performance issues. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for performance thresholds. Bundle size per-Scope budgets apply (Marketing 500KB / Product 300KB / Dashboard 400KB / Internal 200KB gzipped). Report benchmarks AGAINST these targets, not generic metrics."
|
|
793
980
|
|
|
794
|
-
|
|
981
|
+
3. Description: "A11y audit" — agent_type: `a11y-architect` — subagent_type: `a11y-architect` — Prompt: "[CONTEXT header above] WCAG 2.2 AA runtime compliance audit on all interfaces. Check screen reader, keyboard nav, contrast, focus order, touch targets (>=44px), reduced-motion variants. Report issues with severity (Critical/Serious/Moderate/Minor)."
|
|
795
982
|
|
|
796
|
-
|
|
983
|
+
4. Description: "Security audit" — agent_type: `engineering-security-engineer` — subagent_type: `engineering-security-engineer` — Prompt: "[CONTEXT header above] Security review at app level: auth, input validation, data exposure, dependency vulnerabilities. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for security thresholds. Report findings with severity."
|
|
797
984
|
|
|
798
|
-
|
|
985
|
+
5. Description: "Brand Guardian drift check" — agent_type: `design-brand-guardian` — subagent_type: `design-brand-guardian` — Prompt: "[CONTEXT header above] You are the Phase 5 drift check. Read DESIGN.md (the DNA card locked at Phase 3.0) + the actually-built pages via Playwright screenshots under docs/plans/evidence/. Score whether Phase 4 implementers stayed true to the DNA or drifted away from it. Specifically check: does the built Character axis match the DNA? Does Density match? Is Material consistent? Is Motion aligned? Report drift count and specific elements. Save findings to docs/plans/evidence/brand-drift.md. Note: this is a drift check only — the Phase 6 LRR Brand Guardian chapter does the verdict. You do NOT issue a pass/fail here, only surface findings."
|
|
799
986
|
|
|
800
|
-
|
|
987
|
+
### Step 5.2 — Track B: Product Reality (parallel per-feature, ONE message)
|
|
801
988
|
|
|
802
|
-
|
|
989
|
+
Track B audits the built app against `product-spec.md` on a per-feature basis. Each feature gets its own auditor; all auditors run in parallel.
|
|
803
990
|
|
|
804
|
-
|
|
991
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 5 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Step 5.X dispatch prompt below.
|
|
805
992
|
|
|
806
|
-
|
|
993
|
+
**Feature enumeration:** Before dispatch, query the graph for the full feature inventory:
|
|
807
994
|
|
|
808
|
-
|
|
995
|
+
- Call `mcp__plugin_buildanything_graph__graph_list_features` (no arguments) to get the full feature inventory. Returns an array of `{id, label, kebab_anchor}` for every feature in the indexed product-spec. The orchestrator OWNS this enumeration — auditors never enumerate themselves.
|
|
996
|
+
- If the call fails, STOP. Log `TRACK B BLOCKED: graph_list_features failed` to `docs/plans/build-log.md` and report the error. The graph must be indexed correctly before Track B can run.
|
|
809
997
|
|
|
810
|
-
|
|
998
|
+
**Zero-feature gate:** If feature enumeration returns zero features, STOP. This indicates either the graph indexer is broken or `product-spec.md` has no recognizable `## Feature:` sections — neither is a Phase 5 problem. Log `TRACK B BLOCKED: zero features enumerated` to `docs/plans/build-log.md` and route the build back to Step 1.6 (product-spec-writer) via the standard backward-routing template. Do NOT proceed with Cross-cutting (Step 5.3) on a feature-less Track B run.
|
|
811
999
|
|
|
812
|
-
|
|
1000
|
+
**Dispatch:** Call the Agent tool N times in ONE message — one per `feature_id`:
|
|
813
1001
|
|
|
814
|
-
|
|
1002
|
+
- Description: "Product Reality Audit: {feature_label}"
|
|
1003
|
+
- agent_type: product-reality-auditor — subagent_type: product-reality-auditor
|
|
1004
|
+
- Prompt: "[CONTEXT header above] Audit feature_id: {feature_id}. Follow your Cognitive Protocol (ABSORB → QUERY → SYNTHESIZE → EXECUTE → CLASSIFY → SCORE → WRITE). Write evidence to docs/plans/evidence/product-reality/{feature_id}/. Report manifest of evidence paths back."
|
|
815
1005
|
|
|
816
|
-
|
|
1006
|
+
**Post-dispatch verification:** After all Track B auditors return, verify each feature has the four evidence files (`tests-generated.md`, `results.json`, `findings.json`, `coverage.json`) AND that each JSON file parses as valid JSON. If any feature is missing a file or has a malformed JSON file, log `TRACK B EVIDENCE MISSING/MALFORMED: {feature_id}: {path}` to `docs/plans/build-log.md` and re-dispatch that feature's auditor once (this distinguishes the retry from the first attempt). If the second attempt still fails, emit a synthetic finding with `target_phase: 1, target_task_or_step: "1.6"` (the auditor failing twice on the same feature is a strong signal the spec for that feature is malformed) and let it route through the existing spec-gap path at Step 5.4.
|
|
1007
|
+
|
|
1008
|
+
**Note on the metric loop:** The Metric Loop callable service is no longer wired as a primary Phase 5 step. It can still be invoked ad-hoc by Track A audit fixes via Step 5.5 if a single check class needs iterative tightening, but the structured per-feature audit replaces the orchestrator-improvised eval cases that the previous Step 5.2 (Eval Harness → Metric Loop) drove.
|
|
1009
|
+
|
|
1010
|
+
### Step 5.3 — Cross-cutting (3 parallel, ONE message)
|
|
817
1011
|
|
|
818
1012
|
Call the Agent tool 3 times in one message:
|
|
819
1013
|
|
|
820
|
-
1. Description: "E2E runner" — INTERNAL inline role-string — mode: "bypassPermissions" — Prompt: "Run Playwright E2E test generation, execution, and stability check per `protocols/web-phase-branches.md` Phase 5 E2E steps (generate and run E2E tests for User Journeys, 3 mandatory iterations for flakiness detection). Report results + artifact paths. Records results to `docs/plans/evidence/e2e/iter-3-results.json`."
|
|
1014
|
+
1. Description: "E2E runner" — INTERNAL inline role-string — mode: "bypassPermissions" — Prompt: "Run Playwright E2E test generation, execution, and stability check per `protocols/web-phase-branches.md` Phase 5 E2E steps (generate and run E2E tests for User Journeys, 3 mandatory iterations for flakiness detection). Report results + artifact paths. Records results to `docs/plans/evidence/e2e/iter-3-results.json`. Scope: multi-feature User Journeys ONLY (login → browse → buy, signup → onboarding → first-action). Single-feature happy paths are covered by Track B per-feature auditors at Step 5.2 — do NOT duplicate. Additionally, read the `## Cross-Feature Interactions` section from `docs/plans/product-spec.md`. For each cross-feature rule (e.g., 'Auth → Checkout: user must be authenticated'), generate a targeted E2E test that verifies the rule holds. These are NOT user journeys — they are specific behavioral contracts between features."
|
|
821
1015
|
|
|
822
|
-
2. Description: "Dogfood the app" —
|
|
1016
|
+
2. Description: "Dogfood the app" — agent_type: `testing-evidence-collector` — subagent_type: `testing-evidence-collector`
|
|
823
1017
|
|
|
824
|
-
3. Description: "Fake-data detector" —
|
|
1018
|
+
3. Description: "Fake-data detector" — agent_type: `silent-failure-hunter` — subagent_type: `silent-failure-hunter` — mode: "bypassPermissions" — Prompt: "Run the Fake Data Detector Protocol (`protocols/fake-data-detector.md`). Static analysis: grep for Math.random() in business data paths, hardcoded API responses, setTimeout faking async, placeholder text. Dynamic analysis: inspect HAR files from `docs/plans/evidence/` for missing real API calls, static responses, absent WebSocket traffic. Write findings to `docs/plans/evidence/fake-data-audit.md` with file:line refs and severity."
|
|
825
1019
|
|
|
826
1020
|
### Step 5.4 — Feedback Synthesizer
|
|
827
1021
|
|
|
828
1022
|
The Dogfood findings used to dead-end. Now route them to fix loops.
|
|
829
1023
|
|
|
830
|
-
|
|
1024
|
+
**Pre-dispatch: finding count check.**
|
|
1025
|
+
Before dispatching the synthesizer, count total findings across all 5 input streams:
|
|
1026
|
+
- Count lines in each `evidence/product-reality/*/findings.json`
|
|
1027
|
+
- Count findings in `evidence/dogfood/findings.md` (count `### Finding` headings or JSON array length)
|
|
1028
|
+
- Count entries in `evidence/track-a/*.json`
|
|
1029
|
+
- Count failures in `evidence/e2e/iter-3-results.json`
|
|
1030
|
+
- Count findings in `evidence/fake-data-audit.md`
|
|
1031
|
+
|
|
1032
|
+
If total findings ≤ 40: dispatch the synthesizer as a single pass (existing behavior below).
|
|
1033
|
+
|
|
1034
|
+
If total findings > 40: split into two sequential dispatches:
|
|
1035
|
+
- **Pass 1 (mechanical routing):** Track B findings (pre-routed, validate only) + Track A findings (static routing) + E2E failures (route to phase 4) + fake-data findings (route to phase 4). These require minimal graph queries. Output: `docs/plans/evidence/dogfood/classified-findings-pass1.json`.
|
|
1036
|
+
- **Pass 2 (graph-heavy classification):** Dogfood findings only (need full graph-based classification). Input includes pass-1 output for dedup. Output: merge pass-1 + pass-2 into final `docs/plans/evidence/dogfood/classified-findings.json`.
|
|
1037
|
+
|
|
1038
|
+
Call the Agent tool — description: "Synthesize all findings" — agent_type: `product-feedback-synthesizer` — subagent_type: `product-feedback-synthesizer` — Prompt: "[CONTEXT header above] Interpret findings from Track A, Track B, and Cross-cutting streams. Inputs:
|
|
1039
|
+
|
|
1040
|
+
- `docs/plans/evidence/dogfood/findings.md` — autonomous exploration findings, each requires classification + routing
|
|
1041
|
+
- `docs/plans/evidence/product-reality/*/findings.json` — one per feature (web uses agent-browser evidence; iOS uses XcodeBuildMCP + Maestro evidence). Each Track B finding ALREADY CARRIES `target_phase` and `target_task_or_step` set by the product-reality-auditor. VALIDATE these against the graph (same `graph_query_dependencies` walk used for dogfood findings) and pass through if valid; only re-route if validation fails (e.g., the targeted task no longer exists in the task DAG).
|
|
1042
|
+
- E2E test failures: `docs/plans/evidence/e2e/iter-3-results.json` — failures that persisted through 3 Playwright iterations. For each, set `source: "e2e"`, classify severity, route to `target_phase: 4`.
|
|
1043
|
+
- Fake-data findings: `docs/plans/evidence/fake-data-audit.md` — hardcoded/mock data in production paths. For each, set `source: "fake-data"`, classify severity, route to `target_phase: 4`.
|
|
1044
|
+
- Track A audit findings: `docs/plans/evidence/brand-drift.md`, `docs/plans/evidence/track-a/*.json` (API contract, performance, a11y, security). Web uses Playwright/Lighthouse; iOS uses XcodeBuildMCP/Instruments. These are engineering-focused findings. For each Track A finding, set `source: "track-a"`, classify severity, and route: API/perf/security findings → `target_phase: 4` (implementation fix); a11y findings → `target_phase: 4` (implementation fix); brand-drift findings → `target_phase: 3` (design fix, re-run Brand Guardian at Step 3.0).
|
|
1045
|
+
|
|
1046
|
+
For each finding, ensure it ends up classified with:
|
|
831
1047
|
- Code-level bug (broken feature, failing logic, fake data) → `target_phase: 4`, assign to the specific task that owns the affected file
|
|
832
1048
|
- Visual/design issue (styling drift, missing state, a11y gap) → `target_phase: 3`, assign to the Phase 3 step that owns the relevant artifact
|
|
833
1049
|
- Structural/architecture issue (missing feature, wrong data flow, API mismatch) → `target_phase: 2`, assign to the architecture section
|
|
1050
|
+
- Spec-gap (acceptance criteria too vague, persona constraint not measurable) → `target_phase: 1, target_task_or_step: "1.6"`
|
|
1051
|
+
|
|
1052
|
+
Output: `docs/plans/evidence/dogfood/classified-findings.json` with shape `[{finding_id, source: \"dogfood\" | \"product-reality\" | \"track-a\" | \"e2e\" | \"fake-data\", severity, target_phase, target_task_or_step, description, evidence_ref, related_decision_id?: string}, ...]`. The `source` field distinguishes the five input streams. The file also carries a footer object with: `graph_used: boolean` (false if any graph call failed and grep fallback ran), `re_routed_findings: [{finding_id, original_target, new_target, reason}, ...]` (Track B findings whose routing the synthesizer overrode after graph validation failed — empty array if none), `source_counts: {dogfood: N, product_reality: M, track_a: P, e2e: N, fake_data: N}` (count by input stream). This file is read by the Phase 5 fix loop and by the Phase 6 LRR Aggregator for backward routing."
|
|
834
1053
|
|
|
835
|
-
|
|
1054
|
+
### Step 5.5 — Fix loop
|
|
836
1055
|
|
|
837
|
-
|
|
1056
|
+
For each CRITICAL/HIGH classified finding, dispatch the appropriate fix agent based on `target_phase`. Max 2 fix cycles. Routing template at the bottom of this file ("Re-entry dispatch template"). Findings with `target_phase: 1, target_task_or_step: "1.6"` route back to `product-spec-writer` to tighten the spec, which re-triggers Track B for the affected feature on the next loop.
|
|
838
1057
|
|
|
839
|
-
**Writes:** `docs/plans/evidence/*.json`, `docs/plans/evidence/fake-data-audit.md`, `docs/plans/evidence/dogfood/classified-findings.json`, `docs/plans/learnings.jsonl` (reality sweep writes PITFALL/PATTERN rows — see `protocols/decision-log.md` for the Dissent Log Revisit Pass path).
|
|
1058
|
+
**Writes:** `docs/plans/evidence/*.json`, `docs/plans/evidence/fake-data-audit.md`, `docs/plans/evidence/dogfood/classified-findings.json`, `docs/plans/evidence/product-reality/*/{tests-generated.md, results.json, findings.json, coverage.json, screenshots/}`, `docs/plans/learnings.jsonl` (reality sweep writes PITFALL/PATTERN rows — see `protocols/decision-log.md` for the Dissent Log Revisit Pass path).
|
|
840
1059
|
|
|
841
1060
|
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
842
1061
|
|
|
@@ -848,6 +1067,16 @@ Output: `docs/plans/evidence/dogfood/classified-findings.json` with shape `[{fin
|
|
|
848
1067
|
|
|
849
1068
|
Split from old Phase 6. Old 6.4 (Reality Check) and 6.5 (LRR) merged and restructured. Reality Checker keeps its evidence sweep role only — the combined verdict authority moved to the LRR Aggregator.
|
|
850
1069
|
|
|
1070
|
+
#### Step 6.0.idx — Decisions re-index (pre-LRR backfill)
|
|
1071
|
+
|
|
1072
|
+
Before dispatching the Reality Checker (Step 6.0) and the LRR chapter judges (Step 6.1), re-index `decisions.jsonl` so the Slice 4 fragment reflects any decisions appended since the last Phase 4 wave transition. The aggregator's backward-routing walk at Step 6.2 (the ⭐⭐ star rule) reads the indexed fragment via `graph_query_decisions` — running this once here catches any drift from hand-edits or out-of-band scribe writes. Skip silently if `docs/plans/decisions.jsonl` does not exist.
|
|
1073
|
+
|
|
1074
|
+
Run via the Bash tool:
|
|
1075
|
+
|
|
1076
|
+
- Command: `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/decisions.jsonl`
|
|
1077
|
+
- On exit 0: log success to `docs/plans/build-log.md` and continue.
|
|
1078
|
+
- On non-zero exit: STOP. Log the error to `docs/plans/build-log.md` and report the failure. The LRR aggregator's backward-routing walk requires current decision data.
|
|
1079
|
+
|
|
851
1080
|
### Step 6.0 — Reality Check (evidence sweep + dissent log revisit pass)
|
|
852
1081
|
|
|
853
1082
|
Reality Checker runs its existing evidence sweep per `commands/build.md` precondition list. Writes the manifest to `docs/plans/evidence/reality-check-manifest.json`. Does NOT issue a combined verdict.
|
|
@@ -859,12 +1088,12 @@ REQUIRED EVIDENCE FOR ALL PROJECTS:
|
|
|
859
1088
|
- `docs/plans/.build-state.json` exists, contains current build session id, contains a recent `VERIFY: PASS` line from this session.
|
|
860
1089
|
|
|
861
1090
|
REQUIRED EVIDENCE FOR `project_type=web`:
|
|
862
|
-
- `docs/plans/evidence/eval-harness/baseline.json` (non-empty)
|
|
863
|
-
- `docs/plans/evidence/eval-harness/final.json` (non-empty)
|
|
864
1091
|
- `docs/plans/evidence/e2e/iter-3-results.json` (non-empty)
|
|
865
1092
|
- `docs/plans/evidence/dogfood/findings.md` (non-empty)
|
|
866
1093
|
- `docs/plans/evidence/dogfood/classified-findings.json` (non-empty)
|
|
867
1094
|
- `docs/plans/evidence/fake-data-audit.md` (non-empty)
|
|
1095
|
+
- `docs/plans/evidence/product-reality/*/coverage.json` — at least one per feature in product-spec.md (non-empty); a missing file for any feature listed in product-spec.md is itself a BLOCK
|
|
1096
|
+
- `docs/plans/evidence/product-reality/*/findings.json` (one per feature; may be an empty array `[]` if no failures)
|
|
868
1097
|
- `docs/plans/evidence/manifest.json`
|
|
869
1098
|
|
|
870
1099
|
REQUIRED EVIDENCE FOR `project_type=ios`:
|
|
@@ -879,7 +1108,7 @@ If any required file does not exist or is empty, do NOT dispatch Reality Checker
|
|
|
879
1108
|
|
|
880
1109
|
**CONTEXT header:** Render `rendered_context_header` for phase 6 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 6 prompt below (Reality Checker + the 5 LRR chapters).
|
|
881
1110
|
|
|
882
|
-
Call the Agent tool — description: "Evidence sweep" — subagent_type: `testing-reality-checker` — Prompt: "[CONTEXT header above] You are the Reality Checker — evidence-sweep role only. Default verdict: NONE. You receive evidence by FILE PATH only — never by paste. Use Read and Glob tools to verify each file exists, is non-empty, was modified within this build session, contains no placeholder strings ('TODO', 'PLACEHOLDER', 'TBD', 'FIXME', 'XXX').
|
|
1111
|
+
Call the Agent tool — description: "Evidence sweep" — agent_type: `testing-reality-checker` — subagent_type: `testing-reality-checker` — Prompt: "[CONTEXT header above] You are the Reality Checker — evidence-sweep role only. Default verdict: NONE. You receive evidence by FILE PATH only — never by paste. Use Read and Glob tools to verify each file exists, is non-empty, was modified within this build session, contains no placeholder strings ('TODO', 'PLACEHOLDER', 'TBD', 'FIXME', 'XXX').
|
|
883
1112
|
|
|
884
1113
|
Evidence paths to verify: [orchestrator pastes the precondition list per project_type].
|
|
885
1114
|
|
|
@@ -902,31 +1131,31 @@ Dispatch 5 chapter judges in parallel. Each receives fresh context, its own evid
|
|
|
902
1131
|
|
|
903
1132
|
Call the Agent tool 5 times in ONE message. Note: the Eng-Quality chapter dispatches `code-reviewer` as primary, with a parallel `pr-test-analyzer` sub-dispatch for test-coverage adequacy evidence that feeds into the Eng-Quality verdict file.
|
|
904
1133
|
|
|
905
|
-
1. Description: "LRR Eng-Quality chapter" — subagent_type: `code-reviewer` — Prompt: "[CONTEXT header above] You are the Eng-Quality chapter of the Launch Readiness Review. Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
1134
|
+
1. Description: "LRR Eng-Quality chapter" — agent_type: `code-reviewer` — subagent_type: `code-reviewer` — Prompt: "[CONTEXT header above] You are the Eng-Quality chapter of the Launch Readiness Review. Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
906
1135
|
|
|
907
|
-
Read: `docs/plans/architecture.md`, `docs/plans/design-doc.md` (PRD
|
|
1136
|
+
Read: `docs/plans/architecture.md`, `docs/plans/design-doc.md` (PRD), `docs/plans/sprint-tasks.md`, `docs/plans/.task-outputs/`, `protocols/verify.md` check outputs from `.build-state.json`, test results from Phase 4 and 5, `docs/plans/evidence/product-reality/*/coverage.json` (Track B per-feature coverage). Also read `docs/plans/decisions.jsonl` for cross-chapter context.
|
|
908
1137
|
|
|
909
|
-
Requirements coverage is
|
|
1138
|
+
Requirements coverage is sourced from Phase 5 Track B evidence — do NOT recompute. Read every `docs/plans/evidence/product-reality/*/coverage.json` (one per feature). Aggregate the per-feature `coverage_pct` and `status` fields into a single `requirements_coverage[]` array on your verdict, one entry per feature with `{feature_id, feature_label, status, coverage_pct, blocker_summary}` where `blocker_summary` is a short string distilling `missing_states + broken_transitions + unenforced_rules + persona_constraint_violations` from coverage.json. Any `MISSING` status is a BLOCK finding. Any `PARTIAL` is CONCERNS at minimum. If a `coverage.json` file is missing for a feature listed in product-spec.md, that itself is a BLOCK finding (Track B did not run for that feature — pipeline integrity issue).
|
|
910
1139
|
|
|
911
|
-
Before writing the final verdict, spawn a parallel subagent dispatch: description: 'LRR test coverage adequacy' — subagent_type: `pr-test-analyzer` — prompt: 'You are a test-coverage auditor for the Eng-Quality LRR chapter. Read the test files under tests/, task-outputs/, and behavioral-test stub detector output. Evaluate: (1) do declared behavioral tests have non-stub bodies, (2) does coverage match the PR diff scope, (3) are edge cases covered, (4) are any tests flaky markers set. Return a JSON summary with test_coverage_score (0-100), stub_flagged_count, edge_case_gap_count, recommendations[]. Save to docs/plans/evidence/lrr/eng-quality-coverage.json.' Read the resulting eng-quality-coverage.json and fold its findings into your verdict.
|
|
1140
|
+
Before writing the final verdict, spawn a parallel subagent dispatch: description: 'LRR test coverage adequacy' — agent_type: `pr-test-analyzer` — subagent_type: `pr-test-analyzer` — prompt: 'You are a test-coverage auditor for the Eng-Quality LRR chapter. Read the test files under tests/, task-outputs/, and behavioral-test stub detector output. Evaluate: (1) do declared behavioral tests have non-stub bodies, (2) does coverage match the PR diff scope, (3) are edge cases covered, (4) are any tests flaky markers set. Return a JSON summary with test_coverage_score (0-100), stub_flagged_count, edge_case_gap_count, recommendations[]. Save to docs/plans/evidence/lrr/eng-quality-coverage.json.' Read the resulting eng-quality-coverage.json and fold its findings into your verdict.
|
|
912
1141
|
|
|
913
|
-
Evaluate code quality + test coverage adequacy + architecture conformance + requirements coverage TOGETHER (single coherent view — merged from old Eng + QA chapters). Check: do declared behavioral tests actually exercise the features? Are there stub-flagged tests? Do tests match task acceptance criteria? Does the built code match architecture MUSTs? Are
|
|
1142
|
+
Evaluate code quality + test coverage adequacy + architecture conformance + requirements coverage TOGETHER (single coherent view — merged from old Eng + QA chapters). Check: do declared behavioral tests actually exercise the features? Are there stub-flagged tests? Do tests match task acceptance criteria? Does the built code match architecture MUSTs? Are features all COVERED?
|
|
914
1143
|
|
|
915
|
-
Write verdict to `docs/plans/evidence/lrr/eng-quality.json` per `protocols/launch-readiness.md` schema. Fields: `chapter=eng-quality`, `verdict` (PASS|CONCERNS|BLOCK), `override_blocks_launch` (false unless BLOCK), `evidence_files_read` (non-empty, MUST include eng-quality-coverage.json), `findings[]` (each with `severity`, `description`, `evidence_ref`, `related_decision_id` if blocker ties to a decisions.jsonl row), `requirements_coverage[]` (
|
|
1144
|
+
Write verdict to `docs/plans/evidence/lrr/eng-quality.json` per `protocols/launch-readiness.md` schema. Fields: `chapter=eng-quality`, `verdict` (PASS|CONCERNS|BLOCK), `override_blocks_launch` (false unless BLOCK), `evidence_files_read` (non-empty, MUST include eng-quality-coverage.json), `findings[]` (each with `severity`, `description`, `evidence_ref`, `related_decision_id` if blocker ties to a decisions.jsonl row), `requirements_coverage[]` (shape per the Track B aggregation paragraph above — `{feature_id, feature_label, status, coverage_pct, blocker_summary}`), `follow_up_spawned=false`, `follow_up_findings=null`. Eng-Quality CANNOT spawn follow-ups."
|
|
916
1145
|
|
|
917
|
-
2. Description: "LRR Security chapter" — subagent_type: `security-reviewer` — Prompt: "[CONTEXT header above] You are the Security chapter of the LRR. Read: `docs/plans/evidence/fake-data-audit.md`, Phase 5 security audit output (from Step 5.1)
|
|
1146
|
+
2. Description: "LRR Security chapter" — agent_type: `security-reviewer` — subagent_type: `security-reviewer` — Prompt: "[CONTEXT header above] You are the Security chapter of the LRR. Read: `docs/plans/evidence/fake-data-audit.md`, Phase 5 security audit output (from Step 5.1). Also read `docs/plans/decisions.jsonl` for context.
|
|
918
1147
|
|
|
919
1148
|
Evaluate auth model, input validation, secrets management, dependency vulnerabilities. Write verdict to `docs/plans/evidence/lrr/security.json` per schema. Fields: `chapter=security`, `verdict`, `override_blocks_launch`, `evidence_files_read` (non-empty), `findings[]` (with `related_decision_id` when applicable), `follow_up_spawned` (boolean), `follow_up_findings` (null or typed object).
|
|
920
1149
|
|
|
921
1150
|
Security MAY spawn ONE read-only follow-up investigation, but ONLY if verdict would be BLOCK — NOT on suspicion. This is tightened from current behavior. Follow-up: read-only, Read/Grep/Glob only, max 15 tool calls, self-report tool_calls_used. See `protocols/launch-readiness.md` for follow-up flow."
|
|
922
1151
|
|
|
923
|
-
3. Description: "LRR SRE chapter" — subagent_type: `engineering-sre` — Prompt: "[CONTEXT header above] You are the SRE chapter of the LRR. Read: performance-audit outputs from Phase 5 (Step 5.1 performance auditor
|
|
1152
|
+
3. Description: "LRR SRE chapter" — agent_type: `engineering-sre` — subagent_type: `engineering-sre` — Prompt: "[CONTEXT header above] You are the SRE chapter of the LRR. Read: performance-audit outputs from Phase 5 (Step 5.1 performance auditor), Performance Benchmarker evidence, NFRs from `docs/plans/quality-targets.json` and `docs/plans/sprint-tasks.md`, reliability checks. Also read `docs/plans/decisions.jsonl` for context.
|
|
924
1153
|
|
|
925
1154
|
Evaluate whether the build meets NFR targets (response time, load handling, error rates) and is production-ready under load. Bundle-size budget violations (>25% over Scope budget) auto-block. Write verdict to `docs/plans/evidence/lrr/sre.json` per schema.
|
|
926
1155
|
|
|
927
1156
|
SRE MAY spawn ONE read-only follow-up investigation, but ONLY if verdict would be BLOCK. Same caps as Security."
|
|
928
1157
|
|
|
929
|
-
4. Description: "LRR A11y chapter" — subagent_type: `a11y-architect` — Prompt: "[CONTEXT header above] You are the A11y chapter of the LRR (NEW SEAT in this panel — closes the biggest coverage gap). Read: Phase 5 a11y audit output (from Step 5.1), WCAG 2.2 AA runtime check, per-page accessibility findings, `docs/plans/quality-targets.json` a11y section.
|
|
1158
|
+
4. Description: "LRR A11y chapter" — agent_type: `a11y-architect` — subagent_type: `a11y-architect` — Prompt: "[CONTEXT header above] You are the A11y chapter of the LRR (NEW SEAT in this panel — closes the biggest coverage gap). Read: Phase 5 a11y audit output (from Step 5.1), WCAG 2.2 AA runtime check, per-page accessibility findings, `docs/plans/quality-targets.json` a11y section.
|
|
930
1159
|
|
|
931
1160
|
Scoring rules:
|
|
932
1161
|
- PASS if zero Serious + zero Critical findings
|
|
@@ -935,11 +1164,11 @@ Scoring rules:
|
|
|
935
1164
|
|
|
936
1165
|
Write verdict to `docs/plans/evidence/lrr/a11y.json` per schema. A11y CANNOT spawn follow-ups."
|
|
937
1166
|
|
|
938
|
-
5. Description: "LRR Brand Guardian chapter" — subagent_type: `design-brand-guardian` — Prompt: "[CONTEXT header above] You are the Brand Guardian chapter of the LRR (REPLACES the old Design mechanical check — real taste judgment, not a 15-line mechanical gate). Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
1167
|
+
5. Description: "LRR Brand Guardian chapter" — agent_type: `design-brand-guardian` — subagent_type: `design-brand-guardian` — Prompt: "[CONTEXT header above] You are the Brand Guardian chapter of the LRR (REPLACES the old Design mechanical check — real taste judgment, not a 15-line mechanical gate). Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
939
1168
|
|
|
940
|
-
Read: `
|
|
1169
|
+
Read: `DESIGN.md` (full file — `## Overview > ### Brand DNA` is the locked 7-axis card from Phase 3.0; YAML tokens are what Phase 4 was supposed to honor; `## Do's and Don'ts` are the explicit guardrails), `docs/plans/design-references.md`, Playwright screenshots under `docs/plans/evidence/` matching production pages, Phase 3.6 Design Critic final score from `.build-state.json`.
|
|
941
1170
|
|
|
942
|
-
Evaluate DRIFT: did the built product stay true to
|
|
1171
|
+
Evaluate DRIFT: did the built product stay true to DESIGN.md (DNA + tokens + guardrails)? Score the gap on 7 DNA axes (Scope, Density, Character, Material, Motion, Type, Copy) + 5 craft dimensions (whitespace rhythm, visual hierarchy, motion coherence, color harmony, typographic refinement). Cite specific elements ('the hero padding at landing.tsx:42 is 32px but DNA calls for Airy density — should be 48px+') — never vague ('needs polish').
|
|
943
1172
|
|
|
944
1173
|
Write verdict to `docs/plans/evidence/lrr/brand-guardian.json` per schema. Fields per protocol. Brand Guardian CANNOT spawn follow-ups."
|
|
945
1174
|
|
|
@@ -947,7 +1176,7 @@ Write verdict to `docs/plans/evidence/lrr/brand-guardian.json` per schema. Field
|
|
|
947
1176
|
|
|
948
1177
|
### Step 6.1a — PM coverage fold-in
|
|
949
1178
|
|
|
950
|
-
PM coverage is a sub-input of the Eng-Quality chapter — evaluated inline within the Eng-Quality dispatch at Step 6.1 above against `design-doc.md`
|
|
1179
|
+
PM coverage is a sub-input of the Eng-Quality chapter — evaluated inline within the Eng-Quality dispatch at Step 6.1 above against `design-doc.md` scope and emitted as a `requirements_coverage[]` field on `eng-quality.json`. The LRR Aggregator runs exactly once. Chapter count stays 5.
|
|
951
1180
|
|
|
952
1181
|
### Step 6.2 — LRR Aggregator (sequential, after all 5 chapter files exist)
|
|
953
1182
|
|
|
@@ -1012,6 +1241,8 @@ On re-entry from LRR BLOCK:
|
|
|
1012
1241
|
blocking_finding: {chapter, finding_id, severity, description, related_decision_id, related_files}
|
|
1013
1242
|
prior_output: path to the phase's previous artifact
|
|
1014
1243
|
decision_row: the row from decisions.jsonl containing original reasoning + authorship
|
|
1244
|
+
cycle_number: current backward-routing cycle count for this target phase (from .build-state.json.backward_routing_count_by_target_phase)
|
|
1245
|
+
downstream_phases_affected: list of phases that consume this phase's output (e.g., Phase 2 re-entry affects Phases 3, 4, 5, 6)
|
|
1015
1246
|
TASK for the re-opened phase:
|
|
1016
1247
|
Revise prior_output to address blocking_finding. Do NOT redo unaffected work. Emit a new decision_row documenting the revision rationale.
|
|
1017
1248
|
```
|
|
@@ -1045,15 +1276,15 @@ Do not loop forever.
|
|
|
1045
1276
|
|
|
1046
1277
|
**CONTEXT header:** Render `rendered_context_header` for phase 7 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 7 prompt below.
|
|
1047
1278
|
|
|
1048
|
-
1. Description: "Technical Writer" — subagent_type: `engineering-technical-writer` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Write project docs: README with setup/architecture/usage, API docs if applicable, deployment notes. The README is the first thing a new developer reads — optimize for that reader. Commit: 'docs: project documentation'. Deployment target per the PRD (Vercel/Netlify/Railway/Fly.io/etc.) — include the deploy flow specific to that target in the README."
|
|
1279
|
+
1. Description: "Technical Writer" — agent_type: `engineering-technical-writer` — subagent_type: `engineering-technical-writer` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Write project docs: README with setup/architecture/usage, API docs if applicable, deployment notes. The README is the first thing a new developer reads — optimize for that reader. Commit: 'docs: project documentation'. Deployment target per the PRD (Vercel/Netlify/Railway/Fly.io/etc.) — include the deploy flow specific to that target in the README."
|
|
1049
1280
|
|
|
1050
1281
|
2. Documentation Metric Loop: Run the Metric Loop Protocol (callable service) on documentation. Define a metric based on completeness and whether a new developer could follow the README end-to-end. Max 3 iterations.
|
|
1051
1282
|
|
|
1052
|
-
3. Description: "App Store Optimizer" (iOS only, conditional on ship) — subagent_type: `marketing-app-store-optimizer` — Prompt per `protocols/ios-phase-branches.md` §Phase 7 (asc-* flow — app name, subtitle, keywords, description, screenshots, privacy labels). Prepend CONTEXT header above. Skip entirely for web.
|
|
1283
|
+
3. Description: "App Store Optimizer" (iOS only, conditional on ship) — agent_type: `marketing-app-store-optimizer` — subagent_type: `marketing-app-store-optimizer` — Prompt per `protocols/ios-phase-branches.md` §Phase 7 (asc-* flow — app name, subtitle, keywords, description, screenshots, privacy labels). Prepend CONTEXT header above. Skip entirely for web.
|
|
1053
1284
|
|
|
1054
|
-
4. Description: "Deploy" — subagent_type: `engineering-devops-automator` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Deploy the app to the target from the PRD (`docs/plans/design-doc.md#tech-stack`). Run pre-deploy checks: build, env vars, secrets. Execute deploy. Verify the deployed URL returns 200 and serves the built app (not the placeholder). Report deploy URL and any smoke-test findings."
|
|
1285
|
+
4. Description: "Deploy" — agent_type: `engineering-devops-automator` — subagent_type: `engineering-devops-automator` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Deploy the app to the target from the PRD (`docs/plans/design-doc.md#tech-stack`). Run pre-deploy checks: build, env vars, secrets. Execute deploy. Verify the deployed URL returns 200 and serves the built app (not the placeholder). Report deploy URL and any smoke-test findings."
|
|
1055
1286
|
|
|
1056
|
-
5. Description: "Completion Report" — INTERNAL inline role-string — Prompt: "[CONTEXT header above] You are the Completion Report writer. Draw verification surface from the LRR Aggregator's structured output (`docs/plans/evidence/lrr-aggregate.json`)
|
|
1287
|
+
5. Description: "Completion Report" — INTERNAL inline role-string — Prompt: "[CONTEXT header above] You are the Completion Report writer. Draw verification surface from THREE sources: the LRR Aggregator's structured output (`docs/plans/evidence/lrr-aggregate.json`), the Reality Checker evidence manifest (`docs/plans/evidence/reality-check-manifest.json`), and the build state (`docs/plans/.build-state.json` — for backward-routing counts and mode transitions per state-schema v2). Do NOT draw from orchestrator summary prose. Present:
|
|
1057
1288
|
|
|
1058
1289
|
```
|
|
1059
1290
|
BUILD COMPLETE
|
|
@@ -1077,6 +1308,22 @@ Remaining: [any NEEDS WORK items from lrr-routing.json]
|
|
|
1077
1308
|
| LRR follow-ups spawned | count | — |
|
|
1078
1309
|
| LRR triggered rule | rule number 1-6 | — |
|
|
1079
1310
|
|
|
1311
|
+
```
|
|
1312
|
+
QUALITY METRICS (from .build-state.json schema v2)
|
|
1313
|
+
================================================
|
|
1314
|
+
Backward routing: <total> events
|
|
1315
|
+
by target phase: <\"2\": N, \"3\": N, \"4\": N>
|
|
1316
|
+
top decisions re-opened: <decision_id: N> (up to 3)
|
|
1317
|
+
|
|
1318
|
+
Mode transitions: <count> (autonomous ↔ interactive)
|
|
1319
|
+
<if count > 0: list each transition timestamp + direction>
|
|
1320
|
+
|
|
1321
|
+
Interpretation:
|
|
1322
|
+
- Backward routing count is a quality signal — fewer means Phase 1-3 caught issues earlier.
|
|
1323
|
+
- A target phase appearing 3+ times suggests structural rework (re-architect or re-design); investigate the related decisions.
|
|
1324
|
+
- Mode transitions ≥ 2 in autonomous mode indicates the build hit a manual-review threshold — review the LRR rule that triggered.
|
|
1325
|
+
```
|
|
1326
|
+
|
|
1080
1327
|
If there's a Verification Gap (declared != passing, or stub-flagged > 0), surface a top-level 'Verification Gap' section BEFORE writing the report to disk. Ask user: 'Write Completion Report with this verification gap surfaced? [YES/NO]'. In autonomous mode: write but flag prominently.
|
|
1081
1328
|
|
|
1082
1329
|
Create final commit. Mark all TodoWrite items complete. Update `.build-state.json`: 'Phase: 7 COMPLETE'."
|