maestro-flow 0.3.3 → 0.3.5

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.
Files changed (75) hide show
  1. package/.claude/commands/quality-business-test.md +110 -0
  2. package/.codex/skills/maestro-init/SKILL.md +167 -167
  3. package/.codex/skills/maestro-phase-add/SKILL.md +154 -154
  4. package/.codex/skills/maestro-phase-transition/SKILL.md +173 -173
  5. package/.codex/skills/maestro-verify/SKILL.md +566 -566
  6. package/.codex/skills/manage-codebase-rebuild/SKILL.md +5 -5
  7. package/.codex/skills/manage-codebase-refresh/SKILL.md +5 -5
  8. package/.codex/skills/manage-issue/SKILL.md +7 -7
  9. package/.codex/skills/manage-issue-analyze/SKILL.md +7 -7
  10. package/.codex/skills/manage-issue-discover/SKILL.md +503 -503
  11. package/.codex/skills/manage-issue-execute/SKILL.md +9 -9
  12. package/.codex/skills/manage-issue-plan/SKILL.md +8 -8
  13. package/.codex/skills/manage-learn/SKILL.md +7 -7
  14. package/.codex/skills/manage-memory/SKILL.md +72 -72
  15. package/.codex/skills/manage-memory-capture/SKILL.md +86 -86
  16. package/.codex/skills/manage-status/SKILL.md +2 -2
  17. package/.codex/skills/quality-business-test/SKILL.md +223 -0
  18. package/.codex/skills/quality-debug/SKILL.md +5 -5
  19. package/.codex/skills/quality-integration-test/SKILL.md +544 -544
  20. package/.codex/skills/quality-refactor/SKILL.md +6 -6
  21. package/.codex/skills/quality-retrospective/SKILL.md +10 -10
  22. package/.codex/skills/quality-review/SKILL.md +408 -408
  23. package/.codex/skills/quality-sync/SKILL.md +6 -6
  24. package/.codex/skills/quality-test/SKILL.md +5 -5
  25. package/.codex/skills/quality-test-gen/SKILL.md +447 -447
  26. package/.codex/skills/spec-add/SKILL.md +5 -5
  27. package/.codex/skills/spec-load/SKILL.md +5 -5
  28. package/.codex/skills/spec-map/SKILL.md +5 -5
  29. package/.codex/skills/spec-setup/SKILL.md +2 -2
  30. package/chains/_intent-map.json +6 -0
  31. package/chains/_router.json +14 -0
  32. package/chains/full-lifecycle.json +15 -0
  33. package/chains/quality-loop.json +16 -1
  34. package/chains/singles/business-test.json +26 -0
  35. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.d.ts +4 -0
  36. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js +47 -1
  37. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js.map +1 -1
  38. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +16 -2
  39. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  40. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.d.ts +1 -1
  41. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js +25 -9
  42. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js.map +1 -1
  43. package/dashboard/dist-server/src/agents/cli-agent-runner.d.ts +3 -0
  44. package/dashboard/dist-server/src/agents/cli-agent-runner.js +78 -61
  45. package/dashboard/dist-server/src/agents/cli-agent-runner.js.map +1 -1
  46. package/dashboard/dist-server/src/agents/cli-history-store.d.ts +14 -1
  47. package/dashboard/dist-server/src/agents/cli-history-store.js +24 -2
  48. package/dashboard/dist-server/src/agents/cli-history-store.js.map +1 -1
  49. package/dashboard/dist-server/src/commands/delegate.js +142 -6
  50. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  51. package/dist/src/agents/cli-agent-runner.d.ts +3 -0
  52. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  53. package/dist/src/agents/cli-agent-runner.js +72 -46
  54. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  55. package/dist/src/agents/cli-history-store.d.ts +14 -1
  56. package/dist/src/agents/cli-history-store.d.ts.map +1 -1
  57. package/dist/src/agents/cli-history-store.js +24 -2
  58. package/dist/src/agents/cli-history-store.js.map +1 -1
  59. package/dist/src/commands/delegate.d.ts.map +1 -1
  60. package/dist/src/commands/delegate.js +65 -5
  61. package/dist/src/commands/delegate.js.map +1 -1
  62. package/dist/src/commands/install-backend.d.ts.map +1 -1
  63. package/dist/src/commands/install-backend.js +5 -2
  64. package/dist/src/commands/install-backend.js.map +1 -1
  65. package/dist/src/mcp/delegate-channel-relay.d.ts.map +1 -1
  66. package/dist/src/mcp/delegate-channel-relay.js +7 -2
  67. package/dist/src/mcp/delegate-channel-relay.js.map +1 -1
  68. package/dist/src/mcp/server.js +1 -1
  69. package/dist/src/mcp/server.js.map +1 -1
  70. package/dist/src/tools/index.d.ts +1 -6
  71. package/dist/src/tools/index.d.ts.map +1 -1
  72. package/dist/src/tools/index.js +1 -451
  73. package/dist/src/tools/index.js.map +1 -1
  74. package/package.json +3 -2
  75. package/templates/business-test-report.json +68 -0
@@ -1,566 +1,566 @@
1
- ---
2
- name: maestro-verify
3
- description: Goal-Backward 3-layer verification via CSV wave pipeline. Staged parallel waves check Truths, Artifacts, and Wiring with anti-pattern scan and Nyquist test coverage audit. Replaces maestro-verify command.
4
- argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--skip-tests] [--skip-antipattern]\""
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- ## Auto Mode
9
-
10
- When `--yes` or `-y`: Auto-confirm check decomposition, skip interactive validation, use defaults for layer detection.
11
-
12
- # Maestro Verify (CSV Wave)
13
-
14
- ## Usage
15
-
16
- ```bash
17
- $maestro-verify "3"
18
- $maestro-verify -c 4 "3 --skip-tests"
19
- $maestro-verify -y "3 --skip-antipattern"
20
- $maestro-verify --continue "verify-phase3-20260318"
21
- ```
22
-
23
- **Flags**:
24
- - `-y, --yes`: Skip all confirmations (auto mode)
25
- - `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
26
- - `--continue`: Resume existing session
27
-
28
- **Output Directory**: `.workflow/.csv-wave/{session-id}/`
29
- **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `verification.json` (structured verification output) + `validation.json` (test coverage output, if Nyquist ran)
30
-
31
- ---
32
-
33
- ## Overview
34
-
35
- Wave-based 3-layer Goal-Backward verification using `spawn_agents_on_csv`. Decomposes verification into staged parallel checks across three waves: truth + artifact existence (Wave 1), artifact substance + wiring (Wave 2), anti-pattern scan + Nyquist audit (Wave 3).
36
-
37
- **Core workflow**: Load Phase Artifacts -> Establish Must-Haves -> Decompose Checks -> Staged Parallel Verification -> Aggregate + Fix Plans
38
-
39
- **Core principle**: Task completion != Goal achievement. A task marked complete may contain stubs/placeholders. This verifier checks that goals are actually achieved.
40
-
41
- ```
42
- +-------------------------------------------------------------------------+
43
- | VERIFICATION CSV WAVE WORKFLOW |
44
- +-------------------------------------------------------------------------+
45
- | |
46
- | Phase 1: Phase Resolution -> CSV |
47
- | +-- Resolve phase directory from arguments |
48
- | +-- Load index.json, plan.json, TASK-*.json, summaries |
49
- | +-- Establish must-haves (truths, artifacts, key links) |
50
- | +-- Decompose into check tasks per layer |
51
- | +-- Assign waves based on layer dependencies |
52
- | +-- Generate tasks.csv with one row per check |
53
- | +-- User validates check breakdown (skip if -y) |
54
- | |
55
- | Phase 2: Wave Execution Engine |
56
- | +-- Wave 1: Truth Checks + Artifact Existence (parallel) |
57
- | | +-- Truth agents verify observable behaviors |
58
- | | +-- Artifact-exist agents check L1 (file exists on disk) |
59
- | | +-- Discoveries shared via board (gap patterns, stubs) |
60
- | | +-- Results: status + evidence + gaps_found per check |
61
- | +-- Wave 2: Artifact Substance + Wiring (parallel) |
62
- | | +-- Substance agents check L2 (real impl, not stub) |
63
- | | +-- Wiring agents check L3 (imported + used) |
64
- | | +-- Needs truth context from wave 1 |
65
- | | +-- Results: status + evidence + gaps_found per check |
66
- | +-- Wave 3: Anti-Pattern Scan + Nyquist Audit (parallel) |
67
- | | +-- Anti-pattern agent scans modified files (skip if flagged) |
68
- | | +-- Nyquist agent maps requirements to tests (skip if flagged) |
69
- | | +-- Needs artifact context from wave 2 |
70
- | | +-- Results: antipatterns[] + coverage gaps |
71
- | +-- discoveries.ndjson shared across all waves (append-only) |
72
- | |
73
- | Phase 3: Results Aggregation |
74
- | +-- Export results.csv |
75
- | +-- Build verification.json (must_haves, gaps, antipatterns, fixes) |
76
- | +-- Build validation.json (if Nyquist ran) |
77
- | +-- Generate context.md with all findings |
78
- | +-- Auto-create issues for gaps + blocker anti-patterns |
79
- | +-- Generate fix plans (cluster related gaps) |
80
- | +-- Update phase index.json with verification status |
81
- | +-- Display summary with next steps |
82
- | |
83
- +-------------------------------------------------------------------------+
84
- ```
85
-
86
- ---
87
-
88
- ## CSV Schema
89
-
90
- ### tasks.csv (Master State)
91
-
92
- ```csv
93
- id,title,description,layer,phase_dir,check_type,deps,context_from,wave,status,findings,gaps_found,fix_plan,error
94
- "1","Truth: User can see existing messages","Verify observable behavior: user can see existing messages by checking supporting artifacts, API calls, and render logic.","truth",".workflow/phases/03-chat/","observable_behavior","","","1","","","","",""
95
- "2","Truth: User can send new messages","Verify observable behavior: user can send new messages by checking form submission, API POST, and state update.","truth",".workflow/phases/03-chat/","observable_behavior","","","1","","","","",""
96
- "3","Artifact Exists: src/components/Chat.tsx","Check L1 existence: verify file src/components/Chat.tsx exists on disk.","artifact",".workflow/phases/03-chat/","exists","","","1","","","","",""
97
- "4","Artifact Exists: src/api/chat.ts","Check L1 existence: verify file src/api/chat.ts exists on disk.","artifact",".workflow/phases/03-chat/","exists","","","1","","","","",""
98
- "5","Artifact Substance: src/components/Chat.tsx","Check L2 substance: verify src/components/Chat.tsx has real implementation (not stub/placeholder). Minimum logic threshold, no placeholder markers.","artifact",".workflow/phases/03-chat/","substance","3","3","2","","","","",""
99
- "6","Artifact Substance: src/api/chat.ts","Check L2 substance: verify src/api/chat.ts has real implementation (not stub/placeholder).","artifact",".workflow/phases/03-chat/","substance","4","4","2","","","","",""
100
- "7","Wiring: Chat.tsx -> /api/chat","Check L3 wiring: verify Chat.tsx imports and calls /api/chat endpoints. Check import statements and actual usage beyond imports.","wiring",".workflow/phases/03-chat/","import_usage","3;4","3;4","2","","","","",""
101
- "8","Anti-Pattern Scan","Scan all modified files for TODO/FIXME/XXX/HACK, placeholder content, empty returns, log-only functions, hardcoded test data, disabled tests. Categorize as Blocker/Warning/Info.","antipattern",".workflow/phases/03-chat/","pattern_scan","1;2;5;6;7","1;2;5;6;7","3","","","","",""
102
- "9","Nyquist Test Coverage Audit","Map requirements to test files. Classify each as COVERED/PARTIAL/MISSING. Detect test framework, run coverage if available.","nyquist",".workflow/phases/03-chat/","test_coverage","1;2;5;6;7","1;2;5;6;7","3","","","","",""
103
- ```
104
-
105
- **Columns**:
106
-
107
- | Column | Phase | Description |
108
- |--------|-------|-------------|
109
- | `id` | Input | Unique task identifier (string) |
110
- | `title` | Input | Short check title |
111
- | `description` | Input | Detailed verification instructions for this check |
112
- | `layer` | Input | Verification layer: truth/artifact/wiring/antipattern/nyquist |
113
- | `phase_dir` | Input | Phase directory path (e.g., `.workflow/phases/03-chat/`) |
114
- | `check_type` | Input | Specific check type: observable_behavior/exists/substance/import_usage/pattern_scan/test_coverage |
115
- | `deps` | Input | Semicolon-separated dependency task IDs |
116
- | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
117
- | `wave` | Computed | Wave number (1 = truths + existence, 2 = substance + wiring, 3 = antipattern + nyquist) |
118
- | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
119
- | `findings` | Output | Key verification findings summary (max 500 chars) |
120
- | `gaps_found` | Output | JSON array of gap descriptions: `[{"id":"GAP-001","type":"missing_feature","severity":"critical","description":"...","fix_direction":"..."}]` |
121
- | `fix_plan` | Output | Suggested fix actions for identified gaps |
122
- | `error` | Output | Error message if failed |
123
-
124
- ### Per-Wave CSV (Temporary)
125
-
126
- Each wave generates `wave-{N}.csv` with extra `prev_context` column.
127
-
128
- ---
129
-
130
- ## Output Artifacts
131
-
132
- | File | Purpose | Lifecycle |
133
- |------|---------|-----------|
134
- | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
135
- | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
136
- | `results.csv` | Final export of all task results | Created in Phase 3 |
137
- | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
138
- | `context.md` | Human-readable verification report | Created in Phase 3 |
139
- | `verification.json` | Structured verification output for downstream | Created in Phase 3 |
140
- | `validation.json` | Nyquist test coverage output (if ran) | Created in Phase 3 |
141
-
142
- ---
143
-
144
- ## Session Structure
145
-
146
- ```
147
- .workflow/.csv-wave/verify-{phase}-{date}/
148
- +-- tasks.csv
149
- +-- results.csv
150
- +-- discoveries.ndjson
151
- +-- context.md
152
- +-- verification.json
153
- +-- validation.json (if Nyquist ran)
154
- +-- wave-{N}.csv (temporary)
155
- ```
156
-
157
- ---
158
-
159
- ## Implementation
160
-
161
- ### Session Initialization
162
-
163
- ```javascript
164
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
165
-
166
- // Parse flags
167
- const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
168
- const continueMode = $ARGUMENTS.includes('--continue')
169
- const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
170
- const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 4
171
-
172
- // Parse verify-specific flags
173
- const skipTests = $ARGUMENTS.includes('--skip-tests')
174
- const skipAntipattern = $ARGUMENTS.includes('--skip-antipattern')
175
-
176
- // Clean phase text
177
- const phaseArg = $ARGUMENTS
178
- .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+|--skip-tests|--skip-antipattern/g, '')
179
- .trim()
180
-
181
- const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
182
- const sessionId = `verify-phase${phaseArg}-${dateStr}`
183
- const sessionFolder = `.workflow/.csv-wave/${sessionId}`
184
-
185
- Bash(`mkdir -p ${sessionFolder}`)
186
- ```
187
-
188
- ---
189
-
190
- ### Phase 1: Phase Resolution -> CSV
191
-
192
- **Objective**: Resolve phase, load artifacts, establish must-haves, decompose into check tasks, generate tasks.csv.
193
-
194
- **Decomposition Rules**:
195
-
196
- 1. **Phase resolution**: Resolve `{phaseArg}` to `.workflow/phases/{NN}-{slug}/`
197
- 2. **Artifact loading**: Read from phase directory:
198
- - `index.json` -- success_criteria (ground truth for verification)
199
- - `plan.json` -- original plan with task_ids
200
- - All `.task/TASK-{NNN}.json` -- task definitions with convergence.criteria
201
- - All `.summaries/TASK-{NNN}-summary.md` -- execution results
202
- - `uat.md` (if exists) -- human UAT gaps to incorporate
203
-
204
- 3. **Must-have establishment** (priority order):
205
- - **success_criteria from index.json** -- primary contract
206
- - **convergence.criteria from task JSON** -- per-task completion criteria
207
- - **Derived from phase goal** -- fallback: derive 3-7 observable behaviors
208
-
209
- 4. **Must-have decomposition** into 3 layers:
210
- - **Truths**: Observable behaviors (e.g., "User can see existing messages")
211
- - **Artifacts**: Concrete file paths that must exist and be substantive
212
- - **Key Links**: Critical wiring between artifacts (e.g., "Chat.tsx imports /api/chat")
213
-
214
- 5. **Check task generation**: For each must-have, generate check rows:
215
-
216
- | Layer | Check Types | Wave |
217
- |-------|-------------|------|
218
- | truth | observable_behavior | 1 |
219
- | artifact (exists) | exists | 1 |
220
- | artifact (substance) | substance | 2 |
221
- | wiring | import_usage | 2 |
222
- | antipattern | pattern_scan | 3 (skip if `--skip-antipattern`) |
223
- | nyquist | test_coverage | 3 (skip if `--skip-tests`) |
224
-
225
- 6. **Wave computation**: Assign waves based on layer dependency chain:
226
- - Wave 1: truth + artifact/exists (no predecessors, parallel)
227
- - Wave 2: artifact/substance + wiring (need existence confirmation from wave 1)
228
- - Wave 3: antipattern + nyquist (need substance/wiring context from wave 2)
229
-
230
- 7. **Specs loading**: `specs_content = maestro spec load --category validation`
231
-
232
- 8. **CSV generation**: One row per check task.
233
-
234
- **User validation**: Display check breakdown (skip if AUTO_YES).
235
-
236
- ---
237
-
238
- ### Phase 2: Wave Execution Engine
239
-
240
- **Objective**: Execute verification checks wave-by-wave via spawn_agents_on_csv.
241
-
242
- #### Wave 1: Truth Checks + Artifact Existence (Parallel)
243
-
244
- 1. Read master `tasks.csv`
245
- 2. Filter rows where `wave == 1` AND `status == pending`
246
- 3. No prev_context needed (wave 1 has no predecessors)
247
- 4. Write `wave-1.csv`
248
- 5. Execute:
249
-
250
- ```javascript
251
- spawn_agents_on_csv({
252
- csv_path: `${sessionFolder}/wave-1.csv`,
253
- id_column: "id",
254
- instruction: buildVerifyInstruction(sessionFolder, "wave1"),
255
- max_concurrency: maxConcurrency,
256
- max_runtime_seconds: 600,
257
- output_csv_path: `${sessionFolder}/wave-1-results.csv`,
258
- output_schema: {
259
- type: "object",
260
- properties: {
261
- id: { type: "string" },
262
- status: { type: "string", enum: ["completed", "failed"] },
263
- findings: { type: "string" },
264
- gaps_found: { type: "string" },
265
- fix_plan: { type: "string" },
266
- error: { type: "string" }
267
- },
268
- required: ["id", "status", "findings"]
269
- }
270
- })
271
- ```
272
-
273
- 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
274
- 7. Delete `wave-1.csv`
275
-
276
- **Truth check agent protocol**:
277
- - For each truth, identify supporting artifacts
278
- - Check artifact existence and substance indicators
279
- - Check wiring indicators (import/usage grep)
280
- - Determine truth status: VERIFIED / FAILED / UNCERTAIN
281
- - Report gaps for FAILED truths with severity and fix direction
282
-
283
- **Artifact existence agent protocol**:
284
- - Check file exists on disk via `ls` or `stat`
285
- - If missing, report gap with severity=critical
286
- - If exists, note file size and basic structure for wave 2
287
-
288
- #### Wave 2: Artifact Substance + Wiring (Parallel)
289
-
290
- 1. Read master `tasks.csv`
291
- 2. Filter rows where `wave == 2` AND `status == pending`
292
- 3. Check deps -- if all wave 1 existence checks failed for a given artifact, skip substance check
293
- 4. Build `prev_context` from wave 1 findings:
294
- ```
295
- [Task 1: Truth: User can see messages] VERIFIED - Chat.tsx renders message list from API response
296
- [Task 3: Artifact Exists: Chat.tsx] completed - file exists, 142 lines
297
- ...
298
- ```
299
- 5. Write `wave-2.csv` with `prev_context` column
300
- 6. Execute `spawn_agents_on_csv` for substance + wiring agents
301
- 7. Merge results into master `tasks.csv`
302
- 8. Delete `wave-2.csv`
303
-
304
- **Substance check agent protocol**:
305
- - Files under ~10 lines of real logic -> STUB
306
- - Contains "placeholder", "coming soon", "TODO: implement" -> STUB
307
- - Real implementation with business logic -> SUBSTANTIVE
308
-
309
- **Wiring check agent protocol**:
310
- - `grep -r "import.*{artifact_name}" src/` -- check imported
311
- - `grep -r "{artifact_name}" src/ | grep -v "import"` -- check used beyond import
312
- - Status: WIRED / ORPHANED / NOT_WIRED
313
-
314
- #### Wave 3: Anti-Pattern Scan + Nyquist Audit (Parallel)
315
-
316
- 1. Read master `tasks.csv`
317
- 2. Filter rows where `wave == 3` AND `status == pending`
318
- 3. If `--skip-antipattern`: mark antipattern task as `skipped`
319
- 4. If `--skip-tests`: mark nyquist task as `skipped`
320
- 5. Build `prev_context` from wave 1 + wave 2 findings
321
- 6. Write `wave-3.csv` with `prev_context` column
322
- 7. Execute `spawn_agents_on_csv` for remaining tasks
323
- 8. Merge results into master `tasks.csv`
324
- 9. Delete `wave-3.csv`
325
-
326
- **Anti-pattern scan agent protocol**:
327
- - Extract modified files from task summaries
328
- - Scan for: TODO/FIXME/XXX/HACK, placeholder content, empty returns, log-only functions, hardcoded test data, disabled tests
329
- - Categorize: Blocker (prevents goal) / Warning (incomplete) / Info (notable)
330
- - Report as JSON array in gaps_found
331
-
332
- **Nyquist audit agent protocol**:
333
- - Detect test framework (jest, vitest, pytest, etc.)
334
- - Map requirements (must-haves) to test files
335
- - Classify: COVERED / PARTIAL / MISSING
336
- - Run coverage command if available
337
- - Report gaps and coverage percentage
338
-
339
- ---
340
-
341
- ### Phase 3: Results Aggregation
342
-
343
- **Objective**: Generate final results, fix plans, and human-readable report.
344
-
345
- 1. Read final master `tasks.csv`
346
- 2. Export as `results.csv`
347
- 3. **Aggregate must_haves** from all check results:
348
-
349
- ```json
350
- {
351
- "truths": [
352
- { "claim": "User can see existing messages", "status": "verified", "evidence": "Chat.tsx renders from /api/chat GET" }
353
- ],
354
- "artifacts": [
355
- { "path": "src/components/Chat.tsx", "status": "exists", "substantive": true }
356
- ],
357
- "key_links": [
358
- { "from": "Chat.tsx -> /api/chat", "status": "wired" }
359
- ]
360
- }
361
- ```
362
-
363
- 4. **Collect all gaps** from all tasks' `gaps_found` columns + UAT gaps (if uat.md exists)
364
- 5. **Generate fix plans**: Cluster related gaps -> generate plan per cluster -> order by dependency
365
- 6. **Build verification.json**:
366
-
367
- ```json
368
- {
369
- "phase": "<phase>",
370
- "status": "passed|gaps_found|human_needed",
371
- "verified_at": "<ISO>",
372
- "verifier": "csv-wave-verifier",
373
- "must_haves": { "truths": [...], "artifacts": [...], "key_links": [...] },
374
- "gaps": [...],
375
- "antipatterns": [...],
376
- "fix_plans": [...],
377
- "human_verification": [...],
378
- "coverage_score": 0.85
379
- }
380
- ```
381
-
382
- 7. **Build validation.json** (if Nyquist ran):
383
-
384
- ```json
385
- {
386
- "phase": "<phase>",
387
- "status": "passed|gaps_found",
388
- "validated_at": "<ISO>",
389
- "test_framework": "vitest",
390
- "coverage": { "statements": 80, "branches": 72, "functions": 85, "lines": 78 },
391
- "requirement_coverage": [
392
- { "requirement": "REQ-001", "tests": ["auth.spec.ts"], "status": "covered" }
393
- ],
394
- "gaps": [...]
395
- }
396
- ```
397
-
398
- 8. **Generate context.md**:
399
-
400
- ```markdown
401
- # Verification Report -- Phase {phase}
402
-
403
- ## Summary
404
- - Truths: {verified}/{total} verified
405
- - Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
406
- - Wiring: {links_wired}/{links_total} key links
407
- - Anti-patterns: {blocker_count} blockers, {warning_count} warnings
408
- - Nyquist: {coverage_pct}% coverage ({skipped|status})
409
-
410
- ## Overall Status: **{status}**
411
-
412
- ## Must-Have Truths
413
- ### {truth_claim}
414
- Status: {VERIFIED|FAILED|UNCERTAIN}
415
- Evidence: {evidence}
416
-
417
- ## Artifact Checks
418
- | Path | Exists | Substantive | Wired | Status |
419
- |------|--------|-------------|-------|--------|
420
-
421
- ## Key Links
422
- | Link | Status | Evidence |
423
-
424
- ## Gaps
425
- | ID | Type | Severity | Description | Fix Direction |
426
-
427
- ## Anti-Patterns
428
- | File:Line | Pattern | Severity | Description |
429
-
430
- ## Fix Plans
431
- ### {cluster_name}
432
- Objective: {objective}
433
- Tasks: {task_list}
434
- Issue Refs: {issue_ids}
435
-
436
- ## Nyquist Coverage
437
- {requirement_coverage_table}
438
- ```
439
-
440
- 9. **Overall status determination**:
441
-
442
- | Condition | Status |
443
- |-----------|--------|
444
- | All truths VERIFIED, all artifacts pass L1-L3, all key links WIRED, no blockers | passed |
445
- | Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, or blocker found | gaps_found |
446
- | All automated checks pass but human verification items remain | human_needed |
447
-
448
- 10. **Auto-create issues** from gaps + blocker anti-patterns (same ID generation as verify workflow: ISS-YYYYMMDD-NNN)
449
-
450
- 11. **Archive previous verification artifacts** before writing to phase directory:
451
- - If `verification.json` or `validation.json` exists in phase dir, move to `.history/`
452
-
453
- 12. **Copy output files** to phase directory:
454
- - `verification.json` -> `{phase_dir}/verification.json`
455
- - `validation.json` -> `{phase_dir}/validation.json` (if generated)
456
-
457
- 13. **Update phase index.json** with verification status and timestamps.
458
-
459
- 14. **Display summary**:
460
-
461
- ```
462
- === VERIFICATION RESULTS ===
463
- Phase: {phase_name}
464
-
465
- Goal-Backward: {verified_count}/{total_truths} truths verified
466
- Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
467
- Wiring: {links_wired}/{links_total} key links
468
- Anti-patterns: {blocker_count} blockers, {warning_count} warnings
469
- Nyquist: {coverage_pct}% coverage ({SKIPPED|status})
470
-
471
- Gaps: {gap_count}
472
- Critical: {critical_count}
473
- High: {high_count}
474
- Medium: {medium_count}
475
- Low: {low_count}
476
-
477
- Fix Plans: {fix_plan_count} generated
478
- Issues Created: {issue_count}
479
- Human Verification: {human_items} items
480
-
481
- Files:
482
- {session_folder}/verification.json
483
- {session_folder}/validation.json (if generated)
484
- {phase_dir}/verification.json
485
- {phase_dir}/validation.json (if generated)
486
- ```
487
-
488
- 15. **Next step routing**:
489
-
490
- | Result | Suggestion |
491
- |--------|------------|
492
- | All passed, no gaps | `$maestro-review "{phase}"` for code review |
493
- | Critical gaps found | `$maestro-debug` for investigation |
494
- | Minor gaps only | `$maestro-plan "{phase} --gaps"` -> `$maestro-execute` -> re-run `$maestro-verify` |
495
- | Low test coverage | `$maestro-test-gen "{phase}"` to generate missing tests |
496
- | Human verification needed | `$maestro-test "{phase}"` for interactive UAT |
497
-
498
- ---
499
-
500
- ## Shared Discovery Board Protocol
501
-
502
- ### Standard Discovery Types
503
-
504
- | Type | Dedup Key | Data Schema | Description |
505
- |------|-----------|-------------|-------------|
506
- | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
507
- | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
508
- | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
509
- | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
510
- | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
511
-
512
- ### Domain Discovery Types
513
-
514
- | Type | Dedup Key | Data Schema | Description |
515
- |------|-----------|-------------|-------------|
516
- | `verification_gap` | `data.gap_id` | `{gap_id, layer, severity, description}` | Verification gap found |
517
- | `stub_detected` | `data.file` | `{file, line, marker, content}` | Stub/placeholder file detected |
518
- | `broken_wiring` | `data.from+data.to` | `{from, to, expected, actual}` | Broken integration link |
519
- | `antipattern` | `data.location` | `{location, pattern, severity}` | Anti-pattern instance |
520
- | `test_gap` | `data.requirement` | `{requirement, status, suggested_test}` | Missing test coverage |
521
-
522
- ### Protocol
523
-
524
- 1. **Read** `{session_folder}/discoveries.ndjson` before own check
525
- 2. **Skip covered**: If discovery of same type + dedup key exists, skip
526
- 3. **Write immediately**: Append findings as found
527
- 4. **Append-only**: Never modify or delete
528
- 5. **Deduplicate**: Check before writing
529
-
530
- ```bash
531
- echo '{"ts":"<ISO>","worker":"{id}","type":"verification_gap","data":{"gap_id":"GAP-001","layer":"truth","severity":"critical","description":"User cannot send messages - form handler is a stub"}}' >> {session_folder}/discoveries.ndjson
532
- ```
533
-
534
- ---
535
-
536
- ## Error Handling
537
-
538
- | Error | Resolution |
539
- |-------|------------|
540
- | Phase directory not found | Abort with error: "Phase {N} not found" |
541
- | No execution results found | Abort with error: "No completed tasks found -- run execute first" |
542
- | No summaries found | Warn, proceed with task file analysis only |
543
- | No success_criteria in index.json | Derive must-haves from phase goal (fallback) |
544
- | Truth check agent timeout | Mark as failed, continue remaining checks |
545
- | Substance check on missing artifact | Auto-skip (dep failed), mark as skipped |
546
- | Anti-pattern scan disabled | Mark as skipped, note in context.md |
547
- | Nyquist audit disabled | Mark as skipped, note in context.md |
548
- | Test framework not detected | Skip coverage calculation, warn user |
549
- | CSV parse error | Validate format, show line number |
550
- | discoveries.ndjson corrupt | Ignore malformed lines |
551
- | Continue mode: no session found | List available sessions |
552
-
553
- ---
554
-
555
- ## Core Rules
556
-
557
- 1. **Start Immediately**: First action is session initialization, then Phase 1
558
- 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
559
- 3. **CSV is Source of Truth**: Master tasks.csv holds all state
560
- 4. **Context Propagation**: prev_context built from master CSV, not from memory
561
- 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
562
- 6. **Skip on Failure**: If artifact existence check failed, skip its substance/wiring checks
563
- 7. **Respect Skip Flags**: `--skip-tests` and `--skip-antipattern` mark wave 3 tasks as skipped, not removed
564
- 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
565
- 9. **DO NOT STOP**: Continuous execution until all waves complete
566
- 10. **Goal-Backward**: Verify goals are achieved, not just tasks completed
1
+ ---
2
+ name: maestro-verify
3
+ description: Goal-Backward 3-layer verification via CSV wave pipeline. Staged parallel waves check Truths, Artifacts, and Wiring with anti-pattern scan and Nyquist test coverage audit. Replaces maestro-verify command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--skip-tests] [--skip-antipattern]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm check decomposition, skip interactive validation, use defaults for layer detection.
11
+
12
+ # Maestro Verify (CSV Wave)
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $maestro-verify "3"
18
+ $maestro-verify -c 4 "3 --skip-tests"
19
+ $maestro-verify -y "3 --skip-antipattern"
20
+ $maestro-verify --continue "verify-phase3-20260318"
21
+ ```
22
+
23
+ **Flags**:
24
+ - `-y, --yes`: Skip all confirmations (auto mode)
25
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
26
+ - `--continue`: Resume existing session
27
+
28
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
29
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `verification.json` (structured verification output) + `validation.json` (test coverage output, if Nyquist ran)
30
+
31
+ ---
32
+
33
+ ## Overview
34
+
35
+ Wave-based 3-layer Goal-Backward verification using `spawn_agents_on_csv`. Decomposes verification into staged parallel checks across three waves: truth + artifact existence (Wave 1), artifact substance + wiring (Wave 2), anti-pattern scan + Nyquist audit (Wave 3).
36
+
37
+ **Core workflow**: Load Phase Artifacts -> Establish Must-Haves -> Decompose Checks -> Staged Parallel Verification -> Aggregate + Fix Plans
38
+
39
+ **Core principle**: Task completion != Goal achievement. A task marked complete may contain stubs/placeholders. This verifier checks that goals are actually achieved.
40
+
41
+ ```
42
+ +-------------------------------------------------------------------------+
43
+ | VERIFICATION CSV WAVE WORKFLOW |
44
+ +-------------------------------------------------------------------------+
45
+ | |
46
+ | Phase 1: Phase Resolution -> CSV |
47
+ | +-- Resolve phase directory from arguments |
48
+ | +-- Load index.json, plan.json, TASK-*.json, summaries |
49
+ | +-- Establish must-haves (truths, artifacts, key links) |
50
+ | +-- Decompose into check tasks per layer |
51
+ | +-- Assign waves based on layer dependencies |
52
+ | +-- Generate tasks.csv with one row per check |
53
+ | +-- User validates check breakdown (skip if -y) |
54
+ | |
55
+ | Phase 2: Wave Execution Engine |
56
+ | +-- Wave 1: Truth Checks + Artifact Existence (parallel) |
57
+ | | +-- Truth agents verify observable behaviors |
58
+ | | +-- Artifact-exist agents check L1 (file exists on disk) |
59
+ | | +-- Discoveries shared via board (gap patterns, stubs) |
60
+ | | +-- Results: status + evidence + gaps_found per check |
61
+ | +-- Wave 2: Artifact Substance + Wiring (parallel) |
62
+ | | +-- Substance agents check L2 (real impl, not stub) |
63
+ | | +-- Wiring agents check L3 (imported + used) |
64
+ | | +-- Needs truth context from wave 1 |
65
+ | | +-- Results: status + evidence + gaps_found per check |
66
+ | +-- Wave 3: Anti-Pattern Scan + Nyquist Audit (parallel) |
67
+ | | +-- Anti-pattern agent scans modified files (skip if flagged) |
68
+ | | +-- Nyquist agent maps requirements to tests (skip if flagged) |
69
+ | | +-- Needs artifact context from wave 2 |
70
+ | | +-- Results: antipatterns[] + coverage gaps |
71
+ | +-- discoveries.ndjson shared across all waves (append-only) |
72
+ | |
73
+ | Phase 3: Results Aggregation |
74
+ | +-- Export results.csv |
75
+ | +-- Build verification.json (must_haves, gaps, antipatterns, fixes) |
76
+ | +-- Build validation.json (if Nyquist ran) |
77
+ | +-- Generate context.md with all findings |
78
+ | +-- Auto-create issues for gaps + blocker anti-patterns |
79
+ | +-- Generate fix plans (cluster related gaps) |
80
+ | +-- Update phase index.json with verification status |
81
+ | +-- Display summary with next steps |
82
+ | |
83
+ +-------------------------------------------------------------------------+
84
+ ```
85
+
86
+ ---
87
+
88
+ ## CSV Schema
89
+
90
+ ### tasks.csv (Master State)
91
+
92
+ ```csv
93
+ id,title,description,layer,phase_dir,check_type,deps,context_from,wave,status,findings,gaps_found,fix_plan,error
94
+ "1","Truth: User can see existing messages","Verify observable behavior: user can see existing messages by checking supporting artifacts, API calls, and render logic.","truth",".workflow/phases/03-chat/","observable_behavior","","","1","","","","",""
95
+ "2","Truth: User can send new messages","Verify observable behavior: user can send new messages by checking form submission, API POST, and state update.","truth",".workflow/phases/03-chat/","observable_behavior","","","1","","","","",""
96
+ "3","Artifact Exists: src/components/Chat.tsx","Check L1 existence: verify file src/components/Chat.tsx exists on disk.","artifact",".workflow/phases/03-chat/","exists","","","1","","","","",""
97
+ "4","Artifact Exists: src/api/chat.ts","Check L1 existence: verify file src/api/chat.ts exists on disk.","artifact",".workflow/phases/03-chat/","exists","","","1","","","","",""
98
+ "5","Artifact Substance: src/components/Chat.tsx","Check L2 substance: verify src/components/Chat.tsx has real implementation (not stub/placeholder). Minimum logic threshold, no placeholder markers.","artifact",".workflow/phases/03-chat/","substance","3","3","2","","","","",""
99
+ "6","Artifact Substance: src/api/chat.ts","Check L2 substance: verify src/api/chat.ts has real implementation (not stub/placeholder).","artifact",".workflow/phases/03-chat/","substance","4","4","2","","","","",""
100
+ "7","Wiring: Chat.tsx -> /api/chat","Check L3 wiring: verify Chat.tsx imports and calls /api/chat endpoints. Check import statements and actual usage beyond imports.","wiring",".workflow/phases/03-chat/","import_usage","3;4","3;4","2","","","","",""
101
+ "8","Anti-Pattern Scan","Scan all modified files for TODO/FIXME/XXX/HACK, placeholder content, empty returns, log-only functions, hardcoded test data, disabled tests. Categorize as Blocker/Warning/Info.","antipattern",".workflow/phases/03-chat/","pattern_scan","1;2;5;6;7","1;2;5;6;7","3","","","","",""
102
+ "9","Nyquist Test Coverage Audit","Map requirements to test files. Classify each as COVERED/PARTIAL/MISSING. Detect test framework, run coverage if available.","nyquist",".workflow/phases/03-chat/","test_coverage","1;2;5;6;7","1;2;5;6;7","3","","","","",""
103
+ ```
104
+
105
+ **Columns**:
106
+
107
+ | Column | Phase | Description |
108
+ |--------|-------|-------------|
109
+ | `id` | Input | Unique task identifier (string) |
110
+ | `title` | Input | Short check title |
111
+ | `description` | Input | Detailed verification instructions for this check |
112
+ | `layer` | Input | Verification layer: truth/artifact/wiring/antipattern/nyquist |
113
+ | `phase_dir` | Input | Phase directory path (e.g., `.workflow/phases/03-chat/`) |
114
+ | `check_type` | Input | Specific check type: observable_behavior/exists/substance/import_usage/pattern_scan/test_coverage |
115
+ | `deps` | Input | Semicolon-separated dependency task IDs |
116
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
117
+ | `wave` | Computed | Wave number (1 = truths + existence, 2 = substance + wiring, 3 = antipattern + nyquist) |
118
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
119
+ | `findings` | Output | Key verification findings summary (max 500 chars) |
120
+ | `gaps_found` | Output | JSON array of gap descriptions: `[{"id":"GAP-001","type":"missing_feature","severity":"critical","description":"...","fix_direction":"..."}]` |
121
+ | `fix_plan` | Output | Suggested fix actions for identified gaps |
122
+ | `error` | Output | Error message if failed |
123
+
124
+ ### Per-Wave CSV (Temporary)
125
+
126
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column.
127
+
128
+ ---
129
+
130
+ ## Output Artifacts
131
+
132
+ | File | Purpose | Lifecycle |
133
+ |------|---------|-----------|
134
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
135
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
136
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
137
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
138
+ | `context.md` | Human-readable verification report | Created in Phase 3 |
139
+ | `verification.json` | Structured verification output for downstream | Created in Phase 3 |
140
+ | `validation.json` | Nyquist test coverage output (if ran) | Created in Phase 3 |
141
+
142
+ ---
143
+
144
+ ## Session Structure
145
+
146
+ ```
147
+ .workflow/.csv-wave/verify-{phase}-{date}/
148
+ +-- tasks.csv
149
+ +-- results.csv
150
+ +-- discoveries.ndjson
151
+ +-- context.md
152
+ +-- verification.json
153
+ +-- validation.json (if Nyquist ran)
154
+ +-- wave-{N}.csv (temporary)
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Implementation
160
+
161
+ ### Session Initialization
162
+
163
+ ```javascript
164
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
165
+
166
+ // Parse flags
167
+ const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
168
+ const continueMode = $ARGUMENTS.includes('--continue')
169
+ const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
170
+ const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 4
171
+
172
+ // Parse verify-specific flags
173
+ const skipTests = $ARGUMENTS.includes('--skip-tests')
174
+ const skipAntipattern = $ARGUMENTS.includes('--skip-antipattern')
175
+
176
+ // Clean phase text
177
+ const phaseArg = $ARGUMENTS
178
+ .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+|--skip-tests|--skip-antipattern/g, '')
179
+ .trim()
180
+
181
+ const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
182
+ const sessionId = `verify-phase${phaseArg}-${dateStr}`
183
+ const sessionFolder = `.workflow/.csv-wave/${sessionId}`
184
+
185
+ Bash(`mkdir -p ${sessionFolder}`)
186
+ ```
187
+
188
+ ---
189
+
190
+ ### Phase 1: Phase Resolution -> CSV
191
+
192
+ **Objective**: Resolve phase, load artifacts, establish must-haves, decompose into check tasks, generate tasks.csv.
193
+
194
+ **Decomposition Rules**:
195
+
196
+ 1. **Phase resolution**: Resolve `{phaseArg}` to `.workflow/phases/{NN}-{slug}/`
197
+ 2. **Artifact loading**: Read from phase directory:
198
+ - `index.json` -- success_criteria (ground truth for verification)
199
+ - `plan.json` -- original plan with task_ids
200
+ - All `.task/TASK-{NNN}.json` -- task definitions with convergence.criteria
201
+ - All `.summaries/TASK-{NNN}-summary.md` -- execution results
202
+ - `uat.md` (if exists) -- human UAT gaps to incorporate
203
+
204
+ 3. **Must-have establishment** (priority order):
205
+ - **success_criteria from index.json** -- primary contract
206
+ - **convergence.criteria from task JSON** -- per-task completion criteria
207
+ - **Derived from phase goal** -- fallback: derive 3-7 observable behaviors
208
+
209
+ 4. **Must-have decomposition** into 3 layers:
210
+ - **Truths**: Observable behaviors (e.g., "User can see existing messages")
211
+ - **Artifacts**: Concrete file paths that must exist and be substantive
212
+ - **Key Links**: Critical wiring between artifacts (e.g., "Chat.tsx imports /api/chat")
213
+
214
+ 5. **Check task generation**: For each must-have, generate check rows:
215
+
216
+ | Layer | Check Types | Wave |
217
+ |-------|-------------|------|
218
+ | truth | observable_behavior | 1 |
219
+ | artifact (exists) | exists | 1 |
220
+ | artifact (substance) | substance | 2 |
221
+ | wiring | import_usage | 2 |
222
+ | antipattern | pattern_scan | 3 (skip if `--skip-antipattern`) |
223
+ | nyquist | test_coverage | 3 (skip if `--skip-tests`) |
224
+
225
+ 6. **Wave computation**: Assign waves based on layer dependency chain:
226
+ - Wave 1: truth + artifact/exists (no predecessors, parallel)
227
+ - Wave 2: artifact/substance + wiring (need existence confirmation from wave 1)
228
+ - Wave 3: antipattern + nyquist (need substance/wiring context from wave 2)
229
+
230
+ 7. **Specs loading**: `specs_content = maestro spec load --category validation`
231
+
232
+ 8. **CSV generation**: One row per check task.
233
+
234
+ **User validation**: Display check breakdown (skip if AUTO_YES).
235
+
236
+ ---
237
+
238
+ ### Phase 2: Wave Execution Engine
239
+
240
+ **Objective**: Execute verification checks wave-by-wave via spawn_agents_on_csv.
241
+
242
+ #### Wave 1: Truth Checks + Artifact Existence (Parallel)
243
+
244
+ 1. Read master `tasks.csv`
245
+ 2. Filter rows where `wave == 1` AND `status == pending`
246
+ 3. No prev_context needed (wave 1 has no predecessors)
247
+ 4. Write `wave-1.csv`
248
+ 5. Execute:
249
+
250
+ ```javascript
251
+ spawn_agents_on_csv({
252
+ csv_path: `${sessionFolder}/wave-1.csv`,
253
+ id_column: "id",
254
+ instruction: buildVerifyInstruction(sessionFolder, "wave1"),
255
+ max_concurrency: maxConcurrency,
256
+ max_runtime_seconds: 600,
257
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
258
+ output_schema: {
259
+ type: "object",
260
+ properties: {
261
+ id: { type: "string" },
262
+ status: { type: "string", enum: ["completed", "failed"] },
263
+ findings: { type: "string" },
264
+ gaps_found: { type: "string" },
265
+ fix_plan: { type: "string" },
266
+ error: { type: "string" }
267
+ },
268
+ required: ["id", "status", "findings"]
269
+ }
270
+ })
271
+ ```
272
+
273
+ 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
274
+ 7. Delete `wave-1.csv`
275
+
276
+ **Truth check agent protocol**:
277
+ - For each truth, identify supporting artifacts
278
+ - Check artifact existence and substance indicators
279
+ - Check wiring indicators (import/usage grep)
280
+ - Determine truth status: VERIFIED / FAILED / UNCERTAIN
281
+ - Report gaps for FAILED truths with severity and fix direction
282
+
283
+ **Artifact existence agent protocol**:
284
+ - Check file exists on disk via `ls` or `stat`
285
+ - If missing, report gap with severity=critical
286
+ - If exists, note file size and basic structure for wave 2
287
+
288
+ #### Wave 2: Artifact Substance + Wiring (Parallel)
289
+
290
+ 1. Read master `tasks.csv`
291
+ 2. Filter rows where `wave == 2` AND `status == pending`
292
+ 3. Check deps -- if all wave 1 existence checks failed for a given artifact, skip substance check
293
+ 4. Build `prev_context` from wave 1 findings:
294
+ ```
295
+ [Task 1: Truth: User can see messages] VERIFIED - Chat.tsx renders message list from API response
296
+ [Task 3: Artifact Exists: Chat.tsx] completed - file exists, 142 lines
297
+ ...
298
+ ```
299
+ 5. Write `wave-2.csv` with `prev_context` column
300
+ 6. Execute `spawn_agents_on_csv` for substance + wiring agents
301
+ 7. Merge results into master `tasks.csv`
302
+ 8. Delete `wave-2.csv`
303
+
304
+ **Substance check agent protocol**:
305
+ - Files under ~10 lines of real logic -> STUB
306
+ - Contains "placeholder", "coming soon", "TODO: implement" -> STUB
307
+ - Real implementation with business logic -> SUBSTANTIVE
308
+
309
+ **Wiring check agent protocol**:
310
+ - `grep -r "import.*{artifact_name}" src/` -- check imported
311
+ - `grep -r "{artifact_name}" src/ | grep -v "import"` -- check used beyond import
312
+ - Status: WIRED / ORPHANED / NOT_WIRED
313
+
314
+ #### Wave 3: Anti-Pattern Scan + Nyquist Audit (Parallel)
315
+
316
+ 1. Read master `tasks.csv`
317
+ 2. Filter rows where `wave == 3` AND `status == pending`
318
+ 3. If `--skip-antipattern`: mark antipattern task as `skipped`
319
+ 4. If `--skip-tests`: mark nyquist task as `skipped`
320
+ 5. Build `prev_context` from wave 1 + wave 2 findings
321
+ 6. Write `wave-3.csv` with `prev_context` column
322
+ 7. Execute `spawn_agents_on_csv` for remaining tasks
323
+ 8. Merge results into master `tasks.csv`
324
+ 9. Delete `wave-3.csv`
325
+
326
+ **Anti-pattern scan agent protocol**:
327
+ - Extract modified files from task summaries
328
+ - Scan for: TODO/FIXME/XXX/HACK, placeholder content, empty returns, log-only functions, hardcoded test data, disabled tests
329
+ - Categorize: Blocker (prevents goal) / Warning (incomplete) / Info (notable)
330
+ - Report as JSON array in gaps_found
331
+
332
+ **Nyquist audit agent protocol**:
333
+ - Detect test framework (jest, vitest, pytest, etc.)
334
+ - Map requirements (must-haves) to test files
335
+ - Classify: COVERED / PARTIAL / MISSING
336
+ - Run coverage command if available
337
+ - Report gaps and coverage percentage
338
+
339
+ ---
340
+
341
+ ### Phase 3: Results Aggregation
342
+
343
+ **Objective**: Generate final results, fix plans, and human-readable report.
344
+
345
+ 1. Read final master `tasks.csv`
346
+ 2. Export as `results.csv`
347
+ 3. **Aggregate must_haves** from all check results:
348
+
349
+ ```json
350
+ {
351
+ "truths": [
352
+ { "claim": "User can see existing messages", "status": "verified", "evidence": "Chat.tsx renders from /api/chat GET" }
353
+ ],
354
+ "artifacts": [
355
+ { "path": "src/components/Chat.tsx", "status": "exists", "substantive": true }
356
+ ],
357
+ "key_links": [
358
+ { "from": "Chat.tsx -> /api/chat", "status": "wired" }
359
+ ]
360
+ }
361
+ ```
362
+
363
+ 4. **Collect all gaps** from all tasks' `gaps_found` columns + UAT gaps (if uat.md exists)
364
+ 5. **Generate fix plans**: Cluster related gaps -> generate plan per cluster -> order by dependency
365
+ 6. **Build verification.json**:
366
+
367
+ ```json
368
+ {
369
+ "phase": "<phase>",
370
+ "status": "passed|gaps_found|human_needed",
371
+ "verified_at": "<ISO>",
372
+ "verifier": "csv-wave-verifier",
373
+ "must_haves": { "truths": [...], "artifacts": [...], "key_links": [...] },
374
+ "gaps": [...],
375
+ "antipatterns": [...],
376
+ "fix_plans": [...],
377
+ "human_verification": [...],
378
+ "coverage_score": 0.85
379
+ }
380
+ ```
381
+
382
+ 7. **Build validation.json** (if Nyquist ran):
383
+
384
+ ```json
385
+ {
386
+ "phase": "<phase>",
387
+ "status": "passed|gaps_found",
388
+ "validated_at": "<ISO>",
389
+ "test_framework": "vitest",
390
+ "coverage": { "statements": 80, "branches": 72, "functions": 85, "lines": 78 },
391
+ "requirement_coverage": [
392
+ { "requirement": "REQ-001", "tests": ["auth.spec.ts"], "status": "covered" }
393
+ ],
394
+ "gaps": [...]
395
+ }
396
+ ```
397
+
398
+ 8. **Generate context.md**:
399
+
400
+ ```markdown
401
+ # Verification Report -- Phase {phase}
402
+
403
+ ## Summary
404
+ - Truths: {verified}/{total} verified
405
+ - Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
406
+ - Wiring: {links_wired}/{links_total} key links
407
+ - Anti-patterns: {blocker_count} blockers, {warning_count} warnings
408
+ - Nyquist: {coverage_pct}% coverage ({skipped|status})
409
+
410
+ ## Overall Status: **{status}**
411
+
412
+ ## Must-Have Truths
413
+ ### {truth_claim}
414
+ Status: {VERIFIED|FAILED|UNCERTAIN}
415
+ Evidence: {evidence}
416
+
417
+ ## Artifact Checks
418
+ | Path | Exists | Substantive | Wired | Status |
419
+ |------|--------|-------------|-------|--------|
420
+
421
+ ## Key Links
422
+ | Link | Status | Evidence |
423
+
424
+ ## Gaps
425
+ | ID | Type | Severity | Description | Fix Direction |
426
+
427
+ ## Anti-Patterns
428
+ | File:Line | Pattern | Severity | Description |
429
+
430
+ ## Fix Plans
431
+ ### {cluster_name}
432
+ Objective: {objective}
433
+ Tasks: {task_list}
434
+ Issue Refs: {issue_ids}
435
+
436
+ ## Nyquist Coverage
437
+ {requirement_coverage_table}
438
+ ```
439
+
440
+ 9. **Overall status determination**:
441
+
442
+ | Condition | Status |
443
+ |-----------|--------|
444
+ | All truths VERIFIED, all artifacts pass L1-L3, all key links WIRED, no blockers | passed |
445
+ | Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, or blocker found | gaps_found |
446
+ | All automated checks pass but human verification items remain | human_needed |
447
+
448
+ 10. **Auto-create issues** from gaps + blocker anti-patterns (same ID generation as verify workflow: ISS-YYYYMMDD-NNN)
449
+
450
+ 11. **Archive previous verification artifacts** before writing to phase directory:
451
+ - If `verification.json` or `validation.json` exists in phase dir, move to `.history/`
452
+
453
+ 12. **Copy output files** to phase directory:
454
+ - `verification.json` -> `{phase_dir}/verification.json`
455
+ - `validation.json` -> `{phase_dir}/validation.json` (if generated)
456
+
457
+ 13. **Update phase index.json** with verification status and timestamps.
458
+
459
+ 14. **Display summary**:
460
+
461
+ ```
462
+ === VERIFICATION RESULTS ===
463
+ Phase: {phase_name}
464
+
465
+ Goal-Backward: {verified_count}/{total_truths} truths verified
466
+ Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
467
+ Wiring: {links_wired}/{links_total} key links
468
+ Anti-patterns: {blocker_count} blockers, {warning_count} warnings
469
+ Nyquist: {coverage_pct}% coverage ({SKIPPED|status})
470
+
471
+ Gaps: {gap_count}
472
+ Critical: {critical_count}
473
+ High: {high_count}
474
+ Medium: {medium_count}
475
+ Low: {low_count}
476
+
477
+ Fix Plans: {fix_plan_count} generated
478
+ Issues Created: {issue_count}
479
+ Human Verification: {human_items} items
480
+
481
+ Files:
482
+ {session_folder}/verification.json
483
+ {session_folder}/validation.json (if generated)
484
+ {phase_dir}/verification.json
485
+ {phase_dir}/validation.json (if generated)
486
+ ```
487
+
488
+ 15. **Next step routing**:
489
+
490
+ | Result | Suggestion |
491
+ |--------|------------|
492
+ | All passed, no gaps | `$quality-review "{phase}"` for code review |
493
+ | Critical gaps found | `$quality-debug` for investigation |
494
+ | Minor gaps only | `$maestro-plan "{phase} --gaps"` -> `$maestro-execute` -> re-run `$maestro-verify` |
495
+ | Low test coverage | `$quality-test-gen "{phase}"` to generate missing tests |
496
+ | Human verification needed | `$quality-test "{phase}"` for interactive UAT |
497
+
498
+ ---
499
+
500
+ ## Shared Discovery Board Protocol
501
+
502
+ ### Standard Discovery Types
503
+
504
+ | Type | Dedup Key | Data Schema | Description |
505
+ |------|-----------|-------------|-------------|
506
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
507
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
508
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
509
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
510
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
511
+
512
+ ### Domain Discovery Types
513
+
514
+ | Type | Dedup Key | Data Schema | Description |
515
+ |------|-----------|-------------|-------------|
516
+ | `verification_gap` | `data.gap_id` | `{gap_id, layer, severity, description}` | Verification gap found |
517
+ | `stub_detected` | `data.file` | `{file, line, marker, content}` | Stub/placeholder file detected |
518
+ | `broken_wiring` | `data.from+data.to` | `{from, to, expected, actual}` | Broken integration link |
519
+ | `antipattern` | `data.location` | `{location, pattern, severity}` | Anti-pattern instance |
520
+ | `test_gap` | `data.requirement` | `{requirement, status, suggested_test}` | Missing test coverage |
521
+
522
+ ### Protocol
523
+
524
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own check
525
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
526
+ 3. **Write immediately**: Append findings as found
527
+ 4. **Append-only**: Never modify or delete
528
+ 5. **Deduplicate**: Check before writing
529
+
530
+ ```bash
531
+ echo '{"ts":"<ISO>","worker":"{id}","type":"verification_gap","data":{"gap_id":"GAP-001","layer":"truth","severity":"critical","description":"User cannot send messages - form handler is a stub"}}' >> {session_folder}/discoveries.ndjson
532
+ ```
533
+
534
+ ---
535
+
536
+ ## Error Handling
537
+
538
+ | Error | Resolution |
539
+ |-------|------------|
540
+ | Phase directory not found | Abort with error: "Phase {N} not found" |
541
+ | No execution results found | Abort with error: "No completed tasks found -- run execute first" |
542
+ | No summaries found | Warn, proceed with task file analysis only |
543
+ | No success_criteria in index.json | Derive must-haves from phase goal (fallback) |
544
+ | Truth check agent timeout | Mark as failed, continue remaining checks |
545
+ | Substance check on missing artifact | Auto-skip (dep failed), mark as skipped |
546
+ | Anti-pattern scan disabled | Mark as skipped, note in context.md |
547
+ | Nyquist audit disabled | Mark as skipped, note in context.md |
548
+ | Test framework not detected | Skip coverage calculation, warn user |
549
+ | CSV parse error | Validate format, show line number |
550
+ | discoveries.ndjson corrupt | Ignore malformed lines |
551
+ | Continue mode: no session found | List available sessions |
552
+
553
+ ---
554
+
555
+ ## Core Rules
556
+
557
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
558
+ 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
559
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
560
+ 4. **Context Propagation**: prev_context built from master CSV, not from memory
561
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
562
+ 6. **Skip on Failure**: If artifact existence check failed, skip its substance/wiring checks
563
+ 7. **Respect Skip Flags**: `--skip-tests` and `--skip-antipattern` mark wave 3 tasks as skipped, not removed
564
+ 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
565
+ 9. **DO NOT STOP**: Continuous execution until all waves complete
566
+ 10. **Goal-Backward**: Verify goals are achieved, not just tasks completed