buildanything 2.0.0 → 2.1.1
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 +371 -158
- 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 +112 -27
- 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 +234 -64
- 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
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# product-spec.md Schema
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Step 1.6's product-spec-writer emits `docs/plans/product-spec.md` with stable section anchors so that Phase 2 architects, Phase 2 planner, Phase 3 UX architect, Phase 4 Product Owner, and Phase 4 Briefing Officers can receive content-addressed refs instead of pasted content. This document defines the required structure, anchor convention, format rules, validation checklist, and product-type variations.
|
|
6
|
+
|
|
7
|
+
## Required Top-Level Sections
|
|
8
|
+
|
|
9
|
+
The product spec MUST contain these top-level headings, in this order:
|
|
10
|
+
|
|
11
|
+
- `# Product Spec`
|
|
12
|
+
- `## App Overview`
|
|
13
|
+
- `## Screen Inventory`
|
|
14
|
+
- `## Permissions & Roles`
|
|
15
|
+
- `## Cross-Feature Interactions`
|
|
16
|
+
|
|
17
|
+
Then, one `## Feature: {Name}` section per feature in the PRD scope.
|
|
18
|
+
|
|
19
|
+
### App Overview
|
|
20
|
+
|
|
21
|
+
Two parts, both required.
|
|
22
|
+
|
|
23
|
+
**Part 1 — Grounding paragraph.** One paragraph: what this app is and core value proposition. Not a restatement of the PRD — a grounding paragraph that any engineer can read in 10 seconds to understand the product.
|
|
24
|
+
|
|
25
|
+
**Part 2 — Persona Table.** A table listing every persona the product serves. One row flagged `(primary)` next to its name. Required columns: `Persona`, `Role`, `Primary JTBD`, `Relationship to Other Personas`.
|
|
26
|
+
|
|
27
|
+
Format:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
| Persona | Role | Primary JTBD | Relationship to Other Personas |
|
|
31
|
+
|---------|------|--------------|--------------------------------|
|
|
32
|
+
| Buyer (primary) | End consumer placing orders | Find a trusted seller and complete a purchase fast | Buys from Seller; rates Seller post-transaction |
|
|
33
|
+
| Seller | Independent merchant fulfilling orders | Receive, fulfill, and get paid for orders without manual chasing | Sells to Buyer; notified by Buyer order events |
|
|
34
|
+
| Admin | Platform operator handling disputes | Resolve disputes between Buyer and Seller without losing trust on either side | Mediates Buyer ↔ Seller |
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Rules:
|
|
38
|
+
- ≥ 1 row required. A single-persona product still uses the table — name the one persona explicitly.
|
|
39
|
+
- Exactly one row carries `(primary)` after the name.
|
|
40
|
+
- Persona names defined here are the canonical identifiers used in every per-feature `Persona Constraints` block. Do not introduce a persona name in a feature that does not appear in this table.
|
|
41
|
+
- Pull persona enumeration directly from `ux-research.md` (Persona Enumeration section). If `ux-research.md` lists N personas, this table has N rows.
|
|
42
|
+
|
|
43
|
+
Anchors: `product-spec.md#app-overview` (top-level grounding paragraph + table), `product-spec.md#app-overview/personas` (the table specifically, for refs.json indexing).
|
|
44
|
+
|
|
45
|
+
### Screen Inventory
|
|
46
|
+
|
|
47
|
+
Complete list of every screen in the app with a one-line description. Format:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
| Screen | Description | Features |
|
|
51
|
+
|--------|-------------|----------|
|
|
52
|
+
| Login | Email/password + social auth | Auth |
|
|
53
|
+
| Dashboard | KPI cards, activity feed, charts | Dashboard, Notifications |
|
|
54
|
+
| Checkout (3 screens) | Cart review → Shipping → Confirmation | Checkout |
|
|
55
|
+
| Settings | Profile, notifications, billing, security tabs | Settings |
|
|
56
|
+
| Admin Panel | User management, analytics | Admin |
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This is the master list. Per-feature sections reference screens from this inventory.
|
|
60
|
+
|
|
61
|
+
### Permissions & Roles
|
|
62
|
+
|
|
63
|
+
Define every role in the system and what each can access. Format:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
| Role | Can Do | Cannot Do |
|
|
67
|
+
|------|--------|-----------|
|
|
68
|
+
| Anonymous | View public pages, sign up | Access dashboard, place orders |
|
|
69
|
+
| User | CRUD own resources, checkout | Manage other users, view admin |
|
|
70
|
+
| Admin | All user actions + manage users, view analytics | Delete system config |
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If the product has no roles beyond "authenticated user," say so explicitly: "Single role: authenticated user. No admin or public access."
|
|
74
|
+
|
|
75
|
+
### Cross-Feature Interactions
|
|
76
|
+
|
|
77
|
+
A dependency map showing how features connect. Where an interaction crosses a persona boundary (one persona's action triggers another persona's experience), call this out explicitly with `(Persona) → (Persona)` notation. This is critical for marketplaces and other multi-sided products — without it, the seller-side and buyer-side experiences diverge silently.
|
|
78
|
+
|
|
79
|
+
Format:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
- Auth → Checkout: user must be authenticated to check out
|
|
83
|
+
- Order Placement (Buyer) → Order Notification (Seller): seller notified within 60s when buyer submits order
|
|
84
|
+
- Order Fulfillment (Seller) → Order Status (Buyer): buyer sees status update when seller marks shipped
|
|
85
|
+
- Dispute (Buyer or Seller) → Mediation (Admin): admin queue receives dispute when either party files
|
|
86
|
+
- Checkout → Inventory: stock check at cart review and at submit
|
|
87
|
+
- Dashboard → Settings: display preferences read from user settings
|
|
88
|
+
- Notifications → Auth, Checkout, Dashboard: triggered by events in each
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Every dependency must be bidirectional — if A depends on B, B's feature section must mention A under its own interactions. Persona-crossing interactions must appear in BOTH personas' feature sections.
|
|
92
|
+
|
|
93
|
+
## Required Per-Feature Sections
|
|
94
|
+
|
|
95
|
+
Every `## Feature: {Name}` section MUST contain these subsections, in this order:
|
|
96
|
+
|
|
97
|
+
### States
|
|
98
|
+
Flat list of all states this feature can be in. Minimum 3: a loaded state, an empty/initial state, and an error state. Include meta-states as relevant: loading, stale, offline, permission-denied, disabled. The first entry is the initial state.
|
|
99
|
+
|
|
100
|
+
Format: `States: initial (initial), loading, loaded, empty, error, stale`
|
|
101
|
+
|
|
102
|
+
### Transitions
|
|
103
|
+
Table of valid state changes.
|
|
104
|
+
|
|
105
|
+
Format:
|
|
106
|
+
```
|
|
107
|
+
| From → To | Trigger | Preconditions | Side Effects |
|
|
108
|
+
|-----------|---------|---------------|--------------|
|
|
109
|
+
| initial → loading | Page mount | User authenticated | Fetch GET /api/orders |
|
|
110
|
+
| loading → loaded | API 200 | Response has ≥1 item | Render list |
|
|
111
|
+
| loading → empty | API 200 | Response has 0 items | Show empty state |
|
|
112
|
+
| loading → error | API 4xx/5xx or timeout | — | Show error message |
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Data Requirements
|
|
116
|
+
Per-state data needs. What data is displayed, where it comes from, what shape it has.
|
|
117
|
+
|
|
118
|
+
Format:
|
|
119
|
+
```
|
|
120
|
+
- loaded: list of orders [{id, status, total, created_at, items[]}] from GET /api/orders
|
|
121
|
+
- empty: no data needed, static copy
|
|
122
|
+
- error: error message string from API response or "Something went wrong. Please try again."
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Failure Modes
|
|
126
|
+
Per-transition failures. What can go wrong, what the user sees (exact copy), what they can do, what the system does.
|
|
127
|
+
|
|
128
|
+
Format:
|
|
129
|
+
```
|
|
130
|
+
- Network failure during checkout submit →
|
|
131
|
+
User sees: "We couldn't process your order. Please check your connection and try again."
|
|
132
|
+
User can: Retry (button), go back to cart
|
|
133
|
+
System: Log error, do NOT create partial order
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Business Rules
|
|
137
|
+
Bullet list with concrete values. Every rule has a number or a `[DECISION NEEDED]` flag.
|
|
138
|
+
|
|
139
|
+
### Happy Path
|
|
140
|
+
Numbered steps. Each step: what the user sees, what they can do, what happens.
|
|
141
|
+
|
|
142
|
+
### Persona Constraints
|
|
143
|
+
Which personas this feature serves and what research findings shaped its design for each. Every constraint MUST attribute to a specific persona named in the App Overview persona table. Cite specific findings from `ux-research.md` and `feature-intel.md`.
|
|
144
|
+
|
|
145
|
+
Rules:
|
|
146
|
+
- One constraint block per persona that uses this feature.
|
|
147
|
+
- Persona names must match the App Overview table verbatim (including `(primary)` flag where applicable).
|
|
148
|
+
- If a feature serves multiple personas, list a constraint block per persona — even if some constraints overlap, attribute each to the persona it shapes the design for.
|
|
149
|
+
- If a feature serves only one persona, name it explicitly. Do not leave persona attribution implicit.
|
|
150
|
+
|
|
151
|
+
Format (multi-persona example — marketplace order placement):
|
|
152
|
+
```
|
|
153
|
+
- Persona: Buyer (primary) — time-poor, scans, doesn't read [ux-research.md]
|
|
154
|
+
Constraint: keep checkout to 3 steps max — competitors average 5+ [feature-intel.md]
|
|
155
|
+
Constraint: show progress indicator at top of each step — persona abandons flows without visible progress [ux-research.md]
|
|
156
|
+
- Persona: Seller — needs visibility into pending orders to plan fulfillment [ux-research.md]
|
|
157
|
+
Constraint: notification within 60s of order placed — sellers report losing time-sensitive orders to slower competitors [ux-research.md]
|
|
158
|
+
Constraint: order detail must include buyer-supplied notes verbatim — fulfillment errors traced to truncated notes in v0 [ux-research.md]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Empty/Loading/Error States
|
|
162
|
+
What the user sees in each non-happy state. Include specific copy and call-to-action for empty states.
|
|
163
|
+
|
|
164
|
+
### Acceptance Criteria
|
|
165
|
+
Testable statements using checkbox format. Each starts with "Verify that..."
|
|
166
|
+
|
|
167
|
+
Format:
|
|
168
|
+
```
|
|
169
|
+
- [ ] Verify that checkout completes in 3 steps or fewer
|
|
170
|
+
- [ ] Verify that discount code validates without page reload
|
|
171
|
+
- [ ] Verify that out-of-stock items show inline notification, not a generic error page
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Optional Per-Feature Sections
|
|
175
|
+
|
|
176
|
+
Include based on product type. Omit if not applicable — do not stub empty sections.
|
|
177
|
+
|
|
178
|
+
- **Notification Triggers** — channel (email/push/in-app), timing (immediate/delayed/batched), content summary, opt-out mechanism. Required for: SaaS with user accounts, marketplaces, mobile apps.
|
|
179
|
+
- **Technical Constraints & Integrations** — third-party services this feature depends on (payment processor, geocoding API, email provider, analytics), rate limits, SDK requirements, authentication method for each. Required for: features that call external APIs or use third-party SDKs.
|
|
180
|
+
- **Copy Direction** — tone examples for CTAs, errors, empty states, confirmations specific to this feature. Required for: consumer-facing products, marketplaces.
|
|
181
|
+
- **Offline Behavior** — what's cached, what degrades, what's blocked. Required for: mobile apps, PWAs.
|
|
182
|
+
- **Multi-User Scenarios** — concurrent access, conflict resolution, real-time sync. Required for: collaborative tools, marketplaces, multi-tenant SaaS.
|
|
183
|
+
- **Performance Expectations** — latency targets per interaction. Required for: search-heavy products, real-time dashboards, e-commerce checkout.
|
|
184
|
+
- **Inter-Screen Data Flow** — what state carries from this feature's screens to other screens (URL params, local storage, context providers, server session). What data this feature reads that another feature writes, and vice versa. Required for: multi-screen flows, features that share state.
|
|
185
|
+
|
|
186
|
+
## Anchor Naming Convention
|
|
187
|
+
|
|
188
|
+
Anchors follow `product-spec.md#{feature}/{section}` format for refs.json indexing.
|
|
189
|
+
|
|
190
|
+
Rules:
|
|
191
|
+
- Feature names are kebab-case: `checkout`, `user-dashboard`, `admin-settings`
|
|
192
|
+
- Section names are kebab-case: `states`, `transitions`, `data-requirements`, `failure-modes`, `business-rules`, `happy-path`, `persona-constraints`, `empty-states`, `acceptance-criteria`
|
|
193
|
+
- Full anchor example: `product-spec.md#checkout/business-rules`
|
|
194
|
+
- Top-level sections use flat anchors: `product-spec.md#app-overview`, `product-spec.md#screen-inventory`, `product-spec.md#permissions`, `product-spec.md#cross-feature`
|
|
195
|
+
- Anchors must be stable across regeneration — same inputs produce same anchors
|
|
196
|
+
|
|
197
|
+
The Refs Indexer (Phase 2.2) parses these anchors into `refs.json` alongside architecture and PRD anchors.
|
|
198
|
+
|
|
199
|
+
## Product-Type Variations
|
|
200
|
+
|
|
201
|
+
| Section | Web SaaS | Dashboard/Analytics | API/Dev Tool | iOS/Mobile | CLI | Marketplace |
|
|
202
|
+
|---------|----------|-------------------|-------------|-----------|-----|-------------|
|
|
203
|
+
| States | Required | Required | Omit (use request lifecycle) | Required + app lifecycle | Omit (use exit codes) | Required × 2 roles |
|
|
204
|
+
| Transitions | Required | Required (lighter) | Required (request/response) | Required + background states | Required (command flow) | Required × 2 roles |
|
|
205
|
+
| Data Requirements | Required | Required (heavy) | Required (request/response shapes) | Required + cache strategy | Required (stdin/stdout) | Required × 2 roles |
|
|
206
|
+
| Failure Modes | Required | Required | Required (error codes) | Required + offline failures | Required (exit codes) | Required × 2 roles |
|
|
207
|
+
| Happy Path | Required | Required | Required (request examples) | Required | Required (command examples) | Required × 2 roles |
|
|
208
|
+
| Business Rules | Required | Light | Required (rate limits, quotas) | Required | Light | Required (both sides) |
|
|
209
|
+
| Empty States | Required | Required | N/A | Required | N/A | Required × 2 roles |
|
|
210
|
+
| Notification Triggers | Optional | Optional | N/A | Required | N/A | Required |
|
|
211
|
+
| Offline Behavior | Optional | N/A | N/A | Required | N/A | Optional |
|
|
212
|
+
| Multi-User Scenarios | Optional | Optional | Optional | Optional | N/A | Required |
|
|
213
|
+
| Performance | Optional | Required | Required | Optional | Optional | Optional |
|
|
214
|
+
|
|
215
|
+
## Validation Checklist
|
|
216
|
+
|
|
217
|
+
Step 1.7 runs these checks. Failure sends the spec back to the product-spec-writer with specific gaps.
|
|
218
|
+
|
|
219
|
+
**Mechanical checks (no LLM, ~0 tokens):**
|
|
220
|
+
1. Every feature in `design-doc.md` scope has a `## Feature: {Name}` section
|
|
221
|
+
2. Every feature section has all 9 required subsections (States through Acceptance Criteria, including Persona Constraints)
|
|
222
|
+
3. Every States list has ≥ 3 entries
|
|
223
|
+
4. Every Transitions table has ≥ 1 row
|
|
224
|
+
5. No banned vague phrases: "appropriate," "as needed," "standard," "graceful," "configurable," "reasonable," "properly," "adequate"
|
|
225
|
+
6. All `[DECISION NEEDED]` tags are well-formed: `[DECISION NEEDED: question | Suggest: value]` or `[DECISION NEEDED: question]`
|
|
226
|
+
7. Permissions & Roles section exists and is non-empty
|
|
227
|
+
8. Cross-Feature Interactions section exists and is non-empty
|
|
228
|
+
9. Screen Inventory section exists and is non-empty
|
|
229
|
+
10. Every acceptance criterion starts with "Verify that"
|
|
230
|
+
11. App Overview persona table has ≥ 1 row, each persona has a role and JTBD, exactly one persona is flagged `(primary)`, and the `Relationship to Other Personas` column is filled for each row
|
|
231
|
+
12. Every feature's Persona Constraints attributes each constraint to a named persona that appears in the App Overview persona table (no orphan persona names, no implicit attribution)
|
|
232
|
+
13. For multi-persona products: every Cross-Feature Interactions entry that crosses a persona boundary uses the `(Persona) → (Persona)` annotation
|
|
233
|
+
|
|
234
|
+
**State machine checks (mechanical, ~0 tokens):**
|
|
235
|
+
14. Every state in a States list appears in at least one Transitions row (no orphan states)
|
|
236
|
+
15. Every Transitions row references states that exist in the States list
|
|
237
|
+
16. No transition has empty preconditions (every transition requires something to be true, even if it's just "user clicks button")
|
|
238
|
+
17. Error states have at least one outgoing transition (recovery path) OR are marked terminal
|
|
239
|
+
18. The initial state is explicitly identified in the States list (first entry or marked with "(initial)")
|
|
240
|
+
|
|
241
|
+
## Worked Example: Marketplace Order Placement (Buyer + Seller)
|
|
242
|
+
|
|
243
|
+
This example illustrates the multi-persona pattern. App Overview persona table for this hypothetical product would include at minimum `Buyer (primary)` and `Seller`. The feature below is order placement, which originates with the Buyer but has direct downstream effects on the Seller (notification, fulfillment queue) — so its `Persona Constraints` block has entries for both personas, and the top-level `Cross-Feature Interactions` map records the persona-crossing edge.
|
|
244
|
+
|
|
245
|
+
```markdown
|
|
246
|
+
## Feature: Checkout
|
|
247
|
+
|
|
248
|
+
### States
|
|
249
|
+
States: empty-cart (initial), cart-review, entering-shipping, confirming, processing, completed, failed
|
|
250
|
+
|
|
251
|
+
### Transitions
|
|
252
|
+
| From → To | Trigger | Preconditions | Side Effects |
|
|
253
|
+
|-----------|---------|---------------|--------------|
|
|
254
|
+
| empty-cart → cart-review | Add first item | User authenticated | Cart created in local storage |
|
|
255
|
+
| cart-review → entering-shipping | Click "Continue to Shipping" | Cart has ≥ 1 in-stock item | Validate inventory via GET /api/inventory/check |
|
|
256
|
+
| cart-review → empty-cart | Remove last item | — | Clear cart from local storage |
|
|
257
|
+
| entering-shipping → confirming | Submit shipping form | All required fields valid, address verified | Calculate tax via POST /api/tax/calculate |
|
|
258
|
+
| confirming → processing | Click "Place Order" | — | POST /api/orders, disable button, show spinner |
|
|
259
|
+
| processing → completed | API 201 | Order created | Show confirmation, send email, clear cart |
|
|
260
|
+
| processing → failed | API 4xx/5xx or 30s timeout | — | Show error message, re-enable "Place Order" |
|
|
261
|
+
| failed → processing | Click "Try Again" | Poll GET /api/orders/{id} confirms no order exists | Retry POST /api/orders |
|
|
262
|
+
| failed → cart-review | Click "Review Cart" | — | Navigate back, cart preserved |
|
|
263
|
+
| any → cart-review | Click browser back / breadcrumb | — | State preserved, no data loss |
|
|
264
|
+
|
|
265
|
+
### Data Requirements
|
|
266
|
+
- cart-review: cart items [{id, name, price, quantity, image_url}] from local storage, inventory status from GET /api/inventory/check
|
|
267
|
+
- entering-shipping: saved addresses from GET /api/user/addresses (if any), country list static
|
|
268
|
+
- confirming: order summary {items, subtotal, shipping, tax, discount, total} computed client-side, tax from API
|
|
269
|
+
- processing: no new data, spinner only
|
|
270
|
+
- completed: order {id, estimated_delivery, email} from POST /api/orders response
|
|
271
|
+
- failed: error message from API response body
|
|
272
|
+
- empty-cart: no data, static copy
|
|
273
|
+
|
|
274
|
+
### Failure Modes
|
|
275
|
+
- Inventory check fails (item out of stock after carting) →
|
|
276
|
+
User sees: "'{item name}' is no longer available. We've updated your cart."
|
|
277
|
+
User can: Continue with remaining items, or go back to browse
|
|
278
|
+
System: Remove item from cart, recalculate total
|
|
279
|
+
|
|
280
|
+
- Shipping address validation fails →
|
|
281
|
+
User sees: Inline field errors ("Enter a valid ZIP code")
|
|
282
|
+
User can: Correct fields and resubmit
|
|
283
|
+
System: No API call until client-side validation passes
|
|
284
|
+
|
|
285
|
+
- Payment processing fails →
|
|
286
|
+
User sees: "We couldn't process your payment. Please check your card details and try again."
|
|
287
|
+
User can: Retry, change payment method, go back to cart
|
|
288
|
+
System: Log failure reason, do NOT create partial order, do NOT charge card
|
|
289
|
+
|
|
290
|
+
- Network failure during order submit →
|
|
291
|
+
User sees: "Connection lost. Your cart is saved — try again when you're back online."
|
|
292
|
+
User can: Retry when connection restores
|
|
293
|
+
System: Cart persisted in local storage, no server-side state created
|
|
294
|
+
|
|
295
|
+
- 30s timeout during processing →
|
|
296
|
+
User sees: "This is taking longer than expected. Please wait or try again."
|
|
297
|
+
User can: Wait (spinner continues) or click "Try Again"
|
|
298
|
+
System: If order was created server-side, poll GET /api/orders/{id} to confirm before retrying
|
|
299
|
+
|
|
300
|
+
### Business Rules
|
|
301
|
+
- Discount codes: one per order, validated in real-time via POST /api/discounts/validate, shows adjusted total immediately
|
|
302
|
+
- Tax: calculated by jurisdiction based on shipping address, displayed at confirmation step
|
|
303
|
+
- Inventory: checked at cart-review entry AND at order submit — stale cart items removed with notification
|
|
304
|
+
- Minimum order: [DECISION NEEDED: Is there a minimum order value? Suggest: no minimum]
|
|
305
|
+
- Shipping: [DECISION NEEDED: Free shipping threshold? Suggest: free over $50, flat $5.99 under]
|
|
306
|
+
- Order timeout: 30 seconds before showing timeout message
|
|
307
|
+
- Cart persistence: local storage, survives browser close, expires after 7 days
|
|
308
|
+
- Pricing display: [DECISION NEEDED: Include tax in displayed prices or show separately? Common options: tax-exclusive (US standard) or tax-inclusive (EU standard)]
|
|
309
|
+
|
|
310
|
+
### Happy Path
|
|
311
|
+
1. User is on cart-review screen. Sees: item list with names, prices, quantities, images. Subtotal displayed. Can: edit quantities (inline +/- buttons), remove items, apply discount code, click "Continue to Shipping."
|
|
312
|
+
2. User clicks "Continue to Shipping." Sees: shipping form with saved addresses (if any) or empty form. Required fields: name, street, city, state, ZIP, country. Can: select saved address or enter new one.
|
|
313
|
+
3. User submits shipping. Sees: order confirmation screen with full summary — items, subtotal, shipping cost, tax, discount (if applied), total. Can: edit any section (back navigation preserves all data), click "Place Order."
|
|
314
|
+
4. User clicks "Place Order." Sees: button disabled, spinner. Waits up to 10 seconds.
|
|
315
|
+
5. Order succeeds. Sees: confirmation page with order ID, estimated delivery date, "A confirmation email has been sent to {email}." Can: click "Continue Shopping" or view order in account.
|
|
316
|
+
|
|
317
|
+
### Persona Constraints
|
|
318
|
+
- Persona: Buyer (primary) — time-poor, scans, doesn't read [ux-research.md]
|
|
319
|
+
Constraint: checkout must complete in 3 steps — competitors average 5+ steps; research shows each additional step loses ~10% of users [feature-intel.md]
|
|
320
|
+
Constraint: show progress indicator at top of each step — persona abandons flows without visible progress [ux-research.md]
|
|
321
|
+
Constraint: real-time discount validation — competitors require page reload, this is a key differentiator [feature-intel.md]
|
|
322
|
+
- Persona: Seller — needs immediate visibility into incoming orders to plan fulfillment [ux-research.md]
|
|
323
|
+
Constraint: order notification fires within 60s of buyer's `processing → completed` transition — sellers in interviews reported losing time-sensitive orders to faster-notifying competitors [ux-research.md]
|
|
324
|
+
Constraint: order payload to seller includes buyer-supplied notes verbatim (no truncation) — fulfillment errors traced to truncated notes in v0 research [ux-research.md]
|
|
325
|
+
|
|
326
|
+
### Empty/Loading/Error States
|
|
327
|
+
- Empty cart: "Your cart is empty. Browse our products to find something you'll love." CTA: "Start Shopping" button linking to product catalog.
|
|
328
|
+
- Loading (inventory check): Skeleton cards matching item layout, no spinner.
|
|
329
|
+
- Loading (tax calculation): Subtotal visible, tax line shows "Calculating..." with shimmer.
|
|
330
|
+
- Loading (order processing): "Place Order" button disabled, inline spinner, "Processing your order..." text.
|
|
331
|
+
- Error (generic): "Something went wrong. Please try again." with "Retry" button. Never a full-page error — always inline within the checkout flow.
|
|
332
|
+
|
|
333
|
+
### Performance Expectations
|
|
334
|
+
- Cart page load: < 1s TTI (Time to Interactive) on 4G connection
|
|
335
|
+
- Discount code validation: < 500ms API response, show inline spinner during request
|
|
336
|
+
- Tax calculation: < 1s API response, show shimmer placeholder during calculation
|
|
337
|
+
- Order submission: < 10s to confirmation, show spinner, timeout message at 30s
|
|
338
|
+
|
|
339
|
+
### Notification Triggers
|
|
340
|
+
- Order placed → Email (immediate): order confirmation with item summary, order ID, estimated delivery, tracking link
|
|
341
|
+
- Payment failed → Email (immediate): retry prompt with direct link to payment page, cart preserved
|
|
342
|
+
- Cart abandoned (7 days) → Email (delayed, 24h after last activity): reminder with cart contents and direct link to resume
|
|
343
|
+
|
|
344
|
+
### Acceptance Criteria
|
|
345
|
+
- [ ] Verify that checkout completes in 3 steps (cart review, shipping, confirmation)
|
|
346
|
+
- [ ] Verify that user can navigate back to any previous step without losing entered data
|
|
347
|
+
- [ ] Verify that discount code validates in real-time without page reload
|
|
348
|
+
- [ ] Verify that out-of-stock items detected during checkout show inline notification with item name
|
|
349
|
+
- [ ] Verify that payment failure shows specific error message with retry option, not a generic error page
|
|
350
|
+
- [ ] Verify that cart persists across browser close and is recoverable
|
|
351
|
+
- [ ] Verify that order confirmation displays order ID and sends confirmation email
|
|
352
|
+
- [ ] Verify that the "Place Order" button is disabled during processing to prevent double-submit
|
|
353
|
+
- [ ] Verify that 30s timeout during processing shows timeout message with retry option
|
|
354
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Sprint Tasks Schema
|
|
2
|
+
|
|
3
|
+
Schema for `docs/plans/sprint-tasks.md` — the pipe-delimited markdown table produced by the planner agent (Step 2.3.2) and parsed by `src/graph/parser/sprint-tasks.ts`.
|
|
4
|
+
|
|
5
|
+
## Columns (required, in order)
|
|
6
|
+
|
|
7
|
+
| # | Column | Format | Rules |
|
|
8
|
+
|---|--------|--------|-------|
|
|
9
|
+
| 1 | Task ID | `T-{N}` (e.g. `T-1`, `T-2`) | Must not be empty. No duplicates (case-insensitive). |
|
|
10
|
+
| 2 | Title | Free text | Human-readable task description. |
|
|
11
|
+
| 3 | Size | `S`, `M`, or `L` | Case-insensitive; parser normalizes to uppercase. |
|
|
12
|
+
| 4 | Dependencies | Comma-separated Task IDs | e.g. `T-1, T-3`. Use `—` for none. Phase 4 uses this to batch independent tasks in parallel. |
|
|
13
|
+
| 5 | Behavioral Test | Concrete testable interaction | UI: `Navigate to X, click Y, verify Z`. API: curl-based. Should reference a product-spec acceptance criterion. |
|
|
14
|
+
| 6 | Owns Files | Comma-separated file paths | Files this task creates or modifies. Use `—` for none. |
|
|
15
|
+
| 7 | Implementing Phase | Phase identifier | e.g. `phase-4-frontend`, `phase-4-backend`. |
|
|
16
|
+
| 8 | Feature | Exact feature name from `product-spec.md` | Must match a `## Feature: X` heading. Use `—` for infrastructure tasks. Parser generates graph ID via kebab-case: `Order Placement` → `feature__order-placement`. |
|
|
17
|
+
| 9 | Screens | Comma-separated screen names | From the product-spec Screen Inventory. Use `—` for backend-only tasks. Parser generates IDs via kebab-case: `Catalog` → `screen__catalog`. |
|
|
18
|
+
|
|
19
|
+
## Validation Rules
|
|
20
|
+
|
|
21
|
+
The parser enforces these rules and rejects the table on any violation:
|
|
22
|
+
|
|
23
|
+
1. Table must have **exactly 9 columns**.
|
|
24
|
+
2. All 9 column headers must be present (matched case-insensitively).
|
|
25
|
+
3. **Task ID** must not be empty.
|
|
26
|
+
4. **Task ID** must not be duplicated (case-insensitive comparison).
|
|
27
|
+
5. **Size** must be one of `S`, `M`, `L`.
|
|
28
|
+
|
|
29
|
+
The DAG validator (Step 2.3, dispatch #3) additionally checks:
|
|
30
|
+
- No circular dependencies.
|
|
31
|
+
- All Task IDs referenced in Dependencies exist.
|
|
32
|
+
- Every UI task has a Behavioral Test; every API task has a curl-based test.
|
|
33
|
+
|
|
34
|
+
## Graph Edges Emitted Per Row
|
|
35
|
+
|
|
36
|
+
| Relation | Condition | Source | Target |
|
|
37
|
+
|----------|-----------|--------|--------|
|
|
38
|
+
| `task_implements_feature` | Feature is not `—` | `task__{task-id}` | `feature__{kebab-name}` |
|
|
39
|
+
| `task_touches_screen` | Per screen when Screens is not `—` | `task__{task-id}` | `screen__{kebab-name}` |
|
|
40
|
+
| `task_depends_on` | Per dependency in Dependencies | `task__{task-id}` | `task__{dep-id}` |
|
|
41
|
+
|
|
42
|
+
## Example Row
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
| T-3 | Implement product catalog grid | M | T-1, T-2 | Navigate to /catalog, verify 12 product cards render with images and prices | src/components/CatalogGrid.tsx, src/api/products.ts | phase-4-frontend | Product Browsing | Catalog, Product Detail |
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## References
|
|
49
|
+
|
|
50
|
+
- **Parser:** `src/graph/parser/sprint-tasks.ts`
|
|
51
|
+
- **Planner prompt:** `commands/build.md` Step 2.3, dispatch #2 ("Sprint breakdown")
|
|
52
|
+
- **DAG validator:** `commands/build.md` Step 2.3, dispatch #3 ("Task DAG validator")
|
|
53
|
+
- **Graph index command:** `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/sprint-tasks.md`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$comment": "Schema version migration table: schema_version 1 = Stages 1-3; schema_version 2 = Stage 4 (adds backward_routing_count, backward_routing_count_by_target_phase, in_flight_backward_edge, mode_transitions); schema_version 3 = Stage 5 (adds lrr_cycle_state); schema_version 4 = Stage 6 (adds current_sprint_context_hash). --- Runtime validation rules (not encodable in JSON Schema, require code): Rule 5 — step prefix must match current phase number; Rule 6 — mode/autonomous consistency (mode==='autonomous' iff autonomous===true); Rule 7 — iOS fields gating (app_name, bundle_id, xcodeproj_path, ios_features, phase_progress.phase_minus_1 exist iff project_type==='ios'); Rule 10 — pending/in-progress disjoint (in_progress_task.task_id not in pending_tasks or completed_tasks); Rule 11 — resume_point.phase/step must not be ahead of top-level phase/step; Rule 12 — timestamps monotonic (session_last_saved >= session_started).",
|
|
3
|
+
"$comment": "Schema version migration table: schema_version 1 = Stages 1-3; schema_version 2 = Stage 4 (adds backward_routing_count, backward_routing_count_by_target_phase, in_flight_backward_edge, mode_transitions); schema_version 3 = Stage 5 (adds lrr_cycle_state); schema_version 4 = Stage 6 (adds current_sprint_context_hash), schema_version 5 = Stage 7 (adds feature_delegation_plan_path, current_wave, completed_features, feature_acceptance, feature_briefs). --- Runtime validation rules (not encodable in JSON Schema, require code): Rule 5 — step prefix must match current phase number; Rule 6 — mode/autonomous consistency (mode==='autonomous' iff autonomous===true); Rule 7 — iOS fields gating (app_name, bundle_id, xcodeproj_path, ios_features, phase_progress.phase_minus_1 exist iff project_type==='ios'); Rule 10 — pending/in-progress disjoint (in_progress_task.task_id not in pending_tasks or completed_tasks); Rule 11 — resume_point.phase/step must not be ahead of top-level phase/step; Rule 12 — timestamps monotonic (session_last_saved >= session_started).",
|
|
4
4
|
"title": ".build-state.json",
|
|
5
5
|
"description": "Typed source of truth for BuildAnything build state. Validated by the PreToolUse schema lint hook (W2-2). additionalProperties: false enforces fail-closed per A8 SSOT rule.",
|
|
6
6
|
"type": "object",
|
|
@@ -229,8 +229,8 @@
|
|
|
229
229
|
"schema_version": {
|
|
230
230
|
"type": "integer",
|
|
231
231
|
"minimum": 1,
|
|
232
|
-
"maximum":
|
|
233
|
-
"description": "Currently
|
|
232
|
+
"maximum": 5,
|
|
233
|
+
"description": "Currently 5 (Stage 7). Bumped to 2 at Stage 4, 3 at Stage 5, 4 at Stage 6, 5 at Stage 7."
|
|
234
234
|
},
|
|
235
235
|
"project_type": {
|
|
236
236
|
"type": "string",
|
|
@@ -349,6 +349,11 @@
|
|
|
349
349
|
"items": { "$ref": "#/$defs/blocker" },
|
|
350
350
|
"description": "Open blockers. Omitted when empty."
|
|
351
351
|
},
|
|
352
|
+
"decisions_pruned_at_phase0": {
|
|
353
|
+
"type": "boolean",
|
|
354
|
+
"default": false,
|
|
355
|
+
"description": "Set to true after Phase 0 archives stale decision rows from previous builds"
|
|
356
|
+
},
|
|
352
357
|
"decisions_next_id": {
|
|
353
358
|
"type": "object",
|
|
354
359
|
"additionalProperties": { "type": "integer", "minimum": 0 },
|
|
@@ -383,6 +388,36 @@
|
|
|
383
388
|
"current_sprint_context_hash": {
|
|
384
389
|
"type": "string",
|
|
385
390
|
"description": "Stage 6+ (schema_version >= 4). Hash of sprint-scoped shared context; triggers re-render only on sprint boundary."
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
"feature_delegation_plan_path": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"$comment": "Stage 7+ (schema_version >= 5). Populated at Phase 4 Step 4.1 by product-owner agent.",
|
|
396
|
+
"description": "Stage 7+ (schema_version >= 5). Path to feature-delegation-plan.json written by Product Owner in Phase 4 Step 4.1."
|
|
397
|
+
},
|
|
398
|
+
"current_wave": {
|
|
399
|
+
"type": "integer",
|
|
400
|
+
"minimum": 1,
|
|
401
|
+
"$comment": "Stage 7+ (schema_version >= 5). Initialized to 1 at Step 4.1; incremented by orchestrator at Step 4.4.",
|
|
402
|
+
"description": "Stage 7+ (schema_version >= 5). Current wave number in the feature-delegation plan."
|
|
403
|
+
},
|
|
404
|
+
"completed_features": {
|
|
405
|
+
"type": "array",
|
|
406
|
+
"items": { "type": "string" },
|
|
407
|
+
"$comment": "Stage 7+ (schema_version >= 5). Append-only. Set by orchestrator after product-owner ACCEPTED verdict.",
|
|
408
|
+
"description": "Stage 7+ (schema_version >= 5). Feature names accepted by Product Owner."
|
|
409
|
+
},
|
|
410
|
+
"feature_acceptance": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"additionalProperties": { "type": "string", "enum": ["ACCEPTED", "NEEDS_REVISION", "PENDING"] },
|
|
413
|
+
"$comment": "Stage 7+ (schema_version >= 5). Written by orchestrator after each product-owner acceptance dispatch (Step 4.3).",
|
|
414
|
+
"description": "Stage 7+ (schema_version >= 5). Product Owner acceptance verdict per feature."
|
|
415
|
+
},
|
|
416
|
+
"feature_briefs": {
|
|
417
|
+
"type": "object",
|
|
418
|
+
"additionalProperties": { "type": "string" },
|
|
419
|
+
"$comment": "Stage 7+ (schema_version >= 5). Written by orchestrator after each briefing-officer dispatch (Step 4.2.a).",
|
|
420
|
+
"description": "Stage 7+ (schema_version >= 5). Map of feature name to feature brief file path (docs/plans/feature-briefs/{feature}.md)."
|
|
386
421
|
}
|
|
387
422
|
}
|
|
388
423
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
| 2 | Stage 4 | `backward_routing_count` (newly typed), `backward_routing_count_by_target_phase`, `in_flight_backward_edge`, `mode_transitions[]` | A7 forward-reject on `schema_version > MAX_SUPPORTED_SCHEMA_VERSION`; A3 stale-edge decrement on `--resume` |
|
|
17
17
|
| 3 | Stage 5 | `lrr_cycle_state` (object; interior fields loose-typed pending Stage 5 iteration — see "Fields added at v3" below) | `BUILDANYTHING_SDK_LRR=false` reverts to markdown aggregator; `lrr_cycle_state` becomes an ignored field on the orchestrator read path (additive-only, no data loss on downgrade) |
|
|
18
18
|
| 4 | Stage 6 | `current_sprint_context_hash` | `BUILDANYTHING_SDK_SPRINT_CONTEXT=false` (web) and/or `BUILDANYTHING_SDK_SPRINT_CONTEXT_IOS=false` (iOS parity gate) reverts Phase 4 to per-task refs re-send; `current_sprint_context_hash` becomes an ignored field on the orchestrator read path (additive-only, no data loss on downgrade) |
|
|
19
|
+
| 5 | Stage 7 | `feature_delegation_plan_path`, `current_wave`, `completed_features`, `feature_acceptance`, `feature_briefs` | Feature-level fields are additive and optional; a Stage 6 runtime reading a Stage 7 state file with `schema_version` downgraded to `4` will ignore these fields without data loss on the read path |
|
|
19
20
|
|
|
20
21
|
**A7 forward-reject rule.** When `bin/buildanything-runtime.ts` reads `.build-state.json` at session start, if `schema_version > MAX_SUPPORTED_SCHEMA_VERSION`, the runtime refuses to proceed and emits a clear error pointing to the compat matrix (`docs/migration/sdk-host-compat.md`). This is the A7 defense against silent schema drift — an old runtime must never silently ignore fields a newer runtime persisted. See **Task 4.5.2** for the runtime implementation (out of scope for this prose-only update).
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
|
|
24
25
|
```jsonc
|
|
25
26
|
{
|
|
26
|
-
"schema_version":
|
|
27
|
+
"schema_version": 5,
|
|
27
28
|
"project_type": "ios",
|
|
28
29
|
"phase": 6,
|
|
29
30
|
"step": "6.4",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
|
|
54
55
|
| Field | Type | Required | Notes |
|
|
55
56
|
|---|---|---|---|
|
|
56
|
-
| `schema_version` | integer | yes | Currently `
|
|
57
|
+
| `schema_version` | integer | yes | Currently `5`; see version table above. Bumped on each Shape-B migration stage. |
|
|
57
58
|
| `project_type` | enum | yes | `"ios"` or `"web"`. Drives mode-branch routing. |
|
|
58
59
|
| `phase` | integer | yes | Current phase, one of `-1, 0, 1, 2, 3, 4, 5, 6, 7`. |
|
|
59
60
|
| `step` | string | yes | Dotted step identifier within the phase (e.g., `"5.3b"`, `"6.4"`). |
|
|
@@ -80,6 +81,11 @@
|
|
|
80
81
|
| `resume_point` | object | yes | `{phase, step, autonomous, completed_summary, git_branch}`. Snapshot used by Phase-0 resume logic. |
|
|
81
82
|
| `verification` | object | yes | `{last_verify_result, last_verify_timestamp}`. `last_verify_result` is one of `"PRODUCTION_READY"`, `"NEEDS_WORK"`, `"BLOCKED"`, or `null`. |
|
|
82
83
|
| `blockers` | array | no | Open blockers. Each: `{id, description, surfaced_at, type}`. Type is `"build"`, `"design"`, `"dep"`, or `"external"`. |
|
|
84
|
+
| `decisions_pruned_at_phase0` | boolean | no | Default `false`. Set to `true` after Phase 0 archives stale decision rows. |
|
|
85
|
+
|
|
86
|
+
### Decision Log Pruning (Phase 0)
|
|
87
|
+
|
|
88
|
+
At Phase 0, if `docs/plans/decisions.jsonl` exists and contains rows from a previous `session_id`, archive them: copy the file to `docs/plans/decisions.jsonl.prev`, then filter `decisions.jsonl` to retain only rows matching the current `session_id`. Set `decisions_pruned_at_phase0: true`. This prevents unbounded growth across builds while preserving history in the `.prev` file. The LRR Aggregator's star rule only needs current-build decisions for backward routing.
|
|
83
89
|
|
|
84
90
|
### Fields added at v2 (Stage 4)
|
|
85
91
|
|
|
@@ -118,6 +124,22 @@ These fields are present only when `schema_version >= 4`. They support the Shape
|
|
|
118
124
|
|
|
119
125
|
**SSOT note.** Kiro-owned `protocols/state-schema.json` is authoritative: `properties.current_sprint_context_hash` (string) is already declared, `schema_version.maximum` is already `4`, and the top-level `$comment` migration table already lists Stage 6. This prose mirrors that shape; any future interior fields (should the sprint-context module persist more than a hash) will be documented by tightening this entry alongside a JSON Schema update.
|
|
120
126
|
|
|
127
|
+
### Fields added at v5 (Stage 7)
|
|
128
|
+
|
|
129
|
+
These fields are present only when `schema_version >= 5`. They support the three-tier feature delegation architecture in Phase 4 — Product Owner planning, Briefing Officer per-feature briefs, and wave-based execution with acceptance gates.
|
|
130
|
+
|
|
131
|
+
| Field | Type | Required | Added in | Notes |
|
|
132
|
+
|---|---|---|---|---|
|
|
133
|
+
| `feature_delegation_plan_path` | string | no | v5 | Path to `docs/plans/feature-delegation-plan.json`. Set at Step 4.1. |
|
|
134
|
+
| `current_wave` | integer | no | v5 | Current wave being executed (1-indexed). Set at Step 4.1, incremented at Step 4.4. |
|
|
135
|
+
| `completed_features` | string[] | no | v5 | Feature names that have been ACCEPTED by the Product Owner. |
|
|
136
|
+
| `feature_acceptance` | object | no | v5 | Map of feature name → verdict (`ACCEPTED`, `NEEDS_REVISION`, `IN_PROGRESS`). |
|
|
137
|
+
| `feature_briefs` | object | no | v5 | Map of feature name → path to feature brief file (`docs/plans/feature-briefs/{feature}.md`). |
|
|
138
|
+
|
|
139
|
+
**v5 migration concern — none in wild.** As of this task, Stage 7 has not shipped. No `.build-state.json` files with `schema_version: 5` exist outside development probes. The runtime will be bumped to `5` as part of Stage 7 activation, not here.
|
|
140
|
+
|
|
141
|
+
**v5 rollback semantics.** All five fields are additive and optional. A Stage 6 runtime reading a Stage 7 state file with `schema_version` downgraded to `4` will ignore these fields without data loss on the read path. Phase 4 simply reverts to the flat per-task execution model without feature-level delegation.
|
|
142
|
+
|
|
121
143
|
## Rendering contract
|
|
122
144
|
|
|
123
145
|
`.build-state.md` is regenerated from `.build-state.json` on every state change by the orchestrator's state-save routine. It is a view, not a source. The rendering is deterministic: same JSON in → same markdown out.
|
|
@@ -152,6 +174,10 @@ Direct writes to `.build-state.json` are prohibited — a partial write leaves u
|
|
|
152
174
|
|
|
153
175
|
This section is the authoritative write contract. Other protocol/command files that say "write to `.build-state.json`" mean "via this protocol."
|
|
154
176
|
|
|
177
|
+
### Compaction Safety Net
|
|
178
|
+
|
|
179
|
+
The PreCompact hook is a prompt-level reminder (type: "prompt"), not a hard command. As defense-in-depth, the `session-start` hook reads `.build-state.json` on every session start and rebuilds TodoWrite from it. If compaction fires without the orchestrator saving state first, the session-start recovery path restores from the last checkpoint. This is a safety net, not a substitute for the orchestrator honoring compaction checkpoints.
|
|
180
|
+
|
|
155
181
|
## Validation rules
|
|
156
182
|
|
|
157
183
|
A well-formed `.build-state.json` must satisfy:
|
|
@@ -170,3 +196,7 @@ A well-formed `.build-state.json` must satisfy:
|
|
|
170
196
|
12. **Timestamps monotonic** — `session_last_saved >= session_started`.
|
|
171
197
|
|
|
172
198
|
The Wave 2 `PreToolUse` schema lint hook (W2-2) validates every Write|Edit to `.build-state.json` against these rules and denies writes that fail.
|
|
199
|
+
|
|
200
|
+
## Consumers — non-orchestrator readers of state
|
|
201
|
+
|
|
202
|
+
- **Step 7.1.5 Completion Report** (`commands/build.md`) reads `backward_routing_count`, `backward_routing_count_by_target_phase`, and `mode_transitions[]` to surface end-of-build quality signals. See `commands/build.md` Step 7.1.5 for the report template.
|
package/protocols/verify.md
CHANGED
|
@@ -47,6 +47,27 @@ The agent runs these checks in order, stopping on the first FAIL:
|
|
|
47
47
|
ONE AGENT, ONE PASS: The orchestrator spawns exactly ONE agent for the entire verification. This is a single Agent tool call, not 6 separate agents. The agent runs each check as a sequential shell command and evaluates the result before proceeding.
|
|
48
48
|
</HARD-GATE>
|
|
49
49
|
|
|
50
|
+
**Scope macros** (the caller selects which subset of the 7 checks to run):
|
|
51
|
+
|
|
52
|
+
| Scope | Checks included |
|
|
53
|
+
|-------|-----------------|
|
|
54
|
+
| `full` | All 7 checks (default) |
|
|
55
|
+
| `build` | Check 1 only |
|
|
56
|
+
| `types` | Check 2 only |
|
|
57
|
+
| `lint` | Check 3 only |
|
|
58
|
+
| `test` | Check 4 only |
|
|
59
|
+
| `security` | Check 5 only |
|
|
60
|
+
| `diff` | Check 6 only |
|
|
61
|
+
| `behavioral` | Check 7 only |
|
|
62
|
+
| `static` | Checks 1, 2, 3, 6 (build, types, lint, diff — no test/security/behavioral) |
|
|
63
|
+
| `ci` | Checks 1, 2, 3, 4 (build, types, lint, test — no security/diff/behavioral) |
|
|
64
|
+
|
|
65
|
+
The `static` macro is the standard Phase 6 post-metric-loop scope — the metric loop owns behavioral evaluation, so Phase 6 verify skips checks 4 (test), 5 (security), and 7 (behavioral).
|
|
66
|
+
|
|
67
|
+
The `ci` macro is for CI pipeline integration — it runs the four deterministic, automatable checks and skips security (often handled by separate CI tooling), diff review (no uncommitted changes in CI), and behavioral (requires a running app).
|
|
68
|
+
|
|
69
|
+
If no scope is specified, default to `full`.
|
|
70
|
+
|
|
50
71
|
## Step 2b — Test stub detector
|
|
51
72
|
|
|
52
73
|
After running the Test check in Step 2, AND after running it as PASS, the orchestrator MUST run the test-stub detector. The detector greps every test file in the project's test directory and fails the verification if any file matches a stub pattern.
|
|
@@ -105,10 +126,15 @@ exit $EXIT
|
|
|
105
126
|
|
|
106
127
|
## Step 3: Handle Result
|
|
107
128
|
|
|
108
|
-
**On PASS:**
|
|
129
|
+
**On PASS:** Return `VERIFY: PASS (N/N)` to the caller via stdout. State persistence is the orchestrator's responsibility (`.build-state.json.verification` is Reality Checker's field, not the gate's). Proceed to next phase.
|
|
109
130
|
|
|
110
131
|
**On FAIL:** Read the failure reason and spawn a targeted fix agent:
|
|
111
132
|
|
|
133
|
+
**Fix-agent dispatch mode (SDK-gated — matches `commands/build.md:946`):**
|
|
134
|
+
|
|
135
|
+
- **`BUILDANYTHING_SDK=on` (default):** dispatch the fix agent through `claude-agent-sdk` with `maxTurns: 15`. This is a hard safety rail preventing runaway remediation loops. If a fix exceeds 15 turns, the orchestrator flags to user (interactive mode) or logs a warning and fails the verify (autonomous mode) — do NOT let the subagent churn indefinitely.
|
|
136
|
+
- **`BUILDANYTHING_SDK=off`:** fall back to Agent tool dispatch with a self-reported 15-tool-call cap (surfaced via `tool_calls_used` in the agent's return). Same enforcement policy as SDK mode.
|
|
137
|
+
|
|
112
138
|
| Failed Check | Fix Strategy |
|
|
113
139
|
|-------------|-------------|
|
|
114
140
|
| Build / Type-Check / Lint | Run the Build-Fix Protocol (`protocols/build-fix.md`). It isolates the first error, fixes it, rebuilds, detects cascade resolution, and reverts bad fixes automatically. |
|
|
@@ -119,6 +145,8 @@ exit $EXIT
|
|
|
119
145
|
|
|
120
146
|
After the fix agent completes, re-run verification from Step 2.
|
|
121
147
|
|
|
148
|
+
**Token accounting (Stage 3 G3):** each fix-agent dispatch emits a cost line to `docs/plans/build-log.md` via `src/orchestrator/hooks/token-accounting-emitter.ts`. Under `BUILDANYTHING_SDK=on`, the emitter subscribes to SDK `usage` messages automatically. Under markdown fallback, the orchestrator writes the line using the subagent's self-reported token count. Verify's fix loop is a known cost hotspot and must be attributed to the parent phase.
|
|
149
|
+
|
|
122
150
|
<HARD-GATE>
|
|
123
151
|
MAX 3 FIX ATTEMPTS: If verification fails 3 times on the same phase:
|
|
124
152
|
- **Interactive mode:** present the failure history to the user. Ask for direction.
|