maestro-flow-one 0.1.0

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/maestro-flow.js +730 -0
  4. package/claude/maestro-flow/SKILL.md +239 -0
  5. package/claude/maestro-flow/chains/templates.json +256 -0
  6. package/claude/maestro-flow/commands/learn/decompose.md +176 -0
  7. package/claude/maestro-flow/commands/learn/follow.md +167 -0
  8. package/claude/maestro-flow/commands/learn/investigate.md +221 -0
  9. package/claude/maestro-flow/commands/learn/retro.md +303 -0
  10. package/claude/maestro-flow/commands/learn/second-opinion.md +167 -0
  11. package/claude/maestro-flow/commands/lifecycle/amend.md +300 -0
  12. package/claude/maestro-flow/commands/lifecycle/analyze.md +126 -0
  13. package/claude/maestro-flow/commands/lifecycle/brainstorm.md +100 -0
  14. package/claude/maestro-flow/commands/lifecycle/composer.md +354 -0
  15. package/claude/maestro-flow/commands/lifecycle/execute.md +114 -0
  16. package/claude/maestro-flow/commands/lifecycle/fork.md +86 -0
  17. package/claude/maestro-flow/commands/lifecycle/init.md +78 -0
  18. package/claude/maestro-flow/commands/lifecycle/learn.md +140 -0
  19. package/claude/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  20. package/claude/maestro-flow/commands/lifecycle/merge.md +61 -0
  21. package/claude/maestro-flow/commands/lifecycle/overlay.md +178 -0
  22. package/claude/maestro-flow/commands/lifecycle/plan.md +138 -0
  23. package/claude/maestro-flow/commands/lifecycle/player.md +404 -0
  24. package/claude/maestro-flow/commands/lifecycle/quick.md +56 -0
  25. package/claude/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  26. package/claude/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  27. package/claude/maestro-flow/commands/lifecycle/update.md +176 -0
  28. package/claude/maestro-flow/commands/lifecycle/verify.md +90 -0
  29. package/claude/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  30. package/claude/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  31. package/claude/maestro-flow/commands/manage/harvest.md +94 -0
  32. package/claude/maestro-flow/commands/manage/issue-discover.md +77 -0
  33. package/claude/maestro-flow/commands/manage/issue.md +73 -0
  34. package/claude/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  35. package/claude/maestro-flow/commands/manage/knowhow.md +77 -0
  36. package/claude/maestro-flow/commands/manage/learn.md +67 -0
  37. package/claude/maestro-flow/commands/manage/status.md +51 -0
  38. package/claude/maestro-flow/commands/manage/wiki.md +62 -0
  39. package/claude/maestro-flow/commands/milestone/audit.md +68 -0
  40. package/claude/maestro-flow/commands/milestone/complete.md +75 -0
  41. package/claude/maestro-flow/commands/milestone/release.md +96 -0
  42. package/claude/maestro-flow/commands/quality/auto-test.md +124 -0
  43. package/claude/maestro-flow/commands/quality/debug.md +115 -0
  44. package/claude/maestro-flow/commands/quality/refactor.md +55 -0
  45. package/claude/maestro-flow/commands/quality/retrospective.md +78 -0
  46. package/claude/maestro-flow/commands/quality/review.md +108 -0
  47. package/claude/maestro-flow/commands/quality/sync.md +51 -0
  48. package/claude/maestro-flow/commands/quality/test.md +103 -0
  49. package/claude/maestro-flow/commands/spec/add.md +49 -0
  50. package/claude/maestro-flow/commands/spec/load.md +51 -0
  51. package/claude/maestro-flow/commands/spec/remove.md +51 -0
  52. package/claude/maestro-flow/commands/spec/setup.md +51 -0
  53. package/claude/maestro-flow/commands/wiki/connect.md +62 -0
  54. package/claude/maestro-flow/commands/wiki/digest.md +69 -0
  55. package/codex/maestro-flow/SKILL.md +505 -0
  56. package/codex/maestro-flow/chains/templates.json +256 -0
  57. package/codex/maestro-flow/commands/learn/decompose.md +113 -0
  58. package/codex/maestro-flow/commands/learn/follow.md +83 -0
  59. package/codex/maestro-flow/commands/learn/investigate.md +83 -0
  60. package/codex/maestro-flow/commands/learn/retro.md +83 -0
  61. package/codex/maestro-flow/commands/learn/second-opinion.md +86 -0
  62. package/codex/maestro-flow/commands/lifecycle/amend.md +300 -0
  63. package/codex/maestro-flow/commands/lifecycle/analyze.md +483 -0
  64. package/codex/maestro-flow/commands/lifecycle/brainstorm.md +397 -0
  65. package/codex/maestro-flow/commands/lifecycle/composer.md +213 -0
  66. package/codex/maestro-flow/commands/lifecycle/execute.md +318 -0
  67. package/codex/maestro-flow/commands/lifecycle/fork.md +98 -0
  68. package/codex/maestro-flow/commands/lifecycle/init.md +134 -0
  69. package/codex/maestro-flow/commands/lifecycle/learn.md +80 -0
  70. package/codex/maestro-flow/commands/lifecycle/link-coordinate.md +257 -0
  71. package/codex/maestro-flow/commands/lifecycle/merge.md +69 -0
  72. package/codex/maestro-flow/commands/lifecycle/overlay.md +119 -0
  73. package/codex/maestro-flow/commands/lifecycle/plan.md +460 -0
  74. package/codex/maestro-flow/commands/lifecycle/player.md +323 -0
  75. package/codex/maestro-flow/commands/lifecycle/quick.md +124 -0
  76. package/codex/maestro-flow/commands/lifecycle/roadmap.md +468 -0
  77. package/codex/maestro-flow/commands/lifecycle/ui-design.md +135 -0
  78. package/codex/maestro-flow/commands/lifecycle/update.md +176 -0
  79. package/codex/maestro-flow/commands/lifecycle/verify.md +468 -0
  80. package/codex/maestro-flow/commands/manage/codebase-rebuild.md +347 -0
  81. package/codex/maestro-flow/commands/manage/codebase-refresh.md +66 -0
  82. package/codex/maestro-flow/commands/manage/harvest.md +91 -0
  83. package/codex/maestro-flow/commands/manage/issue-discover.md +431 -0
  84. package/codex/maestro-flow/commands/manage/issue.md +75 -0
  85. package/codex/maestro-flow/commands/manage/knowhow-capture.md +110 -0
  86. package/codex/maestro-flow/commands/manage/knowhow.md +95 -0
  87. package/codex/maestro-flow/commands/manage/learn.md +137 -0
  88. package/codex/maestro-flow/commands/manage/status.md +76 -0
  89. package/codex/maestro-flow/commands/manage/wiki.md +55 -0
  90. package/codex/maestro-flow/commands/milestone/audit.md +87 -0
  91. package/codex/maestro-flow/commands/milestone/complete.md +91 -0
  92. package/codex/maestro-flow/commands/milestone/release.md +70 -0
  93. package/codex/maestro-flow/commands/quality/auto-test.md +547 -0
  94. package/codex/maestro-flow/commands/quality/debug.md +334 -0
  95. package/codex/maestro-flow/commands/quality/refactor.md +151 -0
  96. package/codex/maestro-flow/commands/quality/retrospective.md +292 -0
  97. package/codex/maestro-flow/commands/quality/review.md +364 -0
  98. package/codex/maestro-flow/commands/quality/sync.md +111 -0
  99. package/codex/maestro-flow/commands/quality/test.md +498 -0
  100. package/codex/maestro-flow/commands/spec/add.md +101 -0
  101. package/codex/maestro-flow/commands/spec/load.md +77 -0
  102. package/codex/maestro-flow/commands/spec/remove.md +69 -0
  103. package/codex/maestro-flow/commands/spec/setup.md +75 -0
  104. package/codex/maestro-flow/commands/wiki/connect.md +73 -0
  105. package/codex/maestro-flow/commands/wiki/digest.md +87 -0
  106. package/package.json +24 -0
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: maestro-update
3
+ description: Interactive workflow migration — detect version, preview changes, apply upgrades
4
+ argument-hint: "[--dry-run] [--force]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Detect the current `.workflow/` schema version, show available migrations, and interactively apply them step-by-step. Uses a migration registry that supports incremental version upgrades (e.g., 1.0 → 2.0 → 3.0).
16
+
17
+ Each migration step is previewed before execution. The user confirms each step in a loop.
18
+ </purpose>
19
+
20
+ <context>
21
+ $ARGUMENTS — optional flags.
22
+
23
+ **Flags:**
24
+ - `--dry-run` -- Preview migration plan without executing
25
+ - `--force` -- Skip confirmation prompts (apply all pending migrations)
26
+
27
+ **Migration registry:** `src/migrations/`
28
+ - Each migration is a standalone file (e.g., `v1-to-v2.ts`) exporting a `MigrationDef`
29
+ - All migrations are registered via `src/migrations/index.ts`
30
+ - Registry auto-chains: detects current version → walks chain → applies in order
31
+ - To add a new migration: create `src/migrations/v{N}-to-v{N+1}.ts`, register in `index.ts`
32
+
33
+ **CLI runner:** `src/migrations/run.ts`
34
+ - Executable entrypoint: `npx tsx src/migrations/run.ts [root] [--dry-run] [--force] [--json]`
35
+ - Outputs JSON (with `--json`) or human-readable text
36
+
37
+ **State version source:** `.workflow/state.json` → `version` field
38
+ </context>
39
+
40
+ <execution>
41
+
42
+ ### Step 1: Detect Current State
43
+
44
+ ```
45
+ 1. Read .workflow/state.json
46
+ 2. Extract version field (default "1.0" if missing)
47
+ 3. Display:
48
+
49
+ === Maestro Workflow Update ===
50
+ Project: {project_name}
51
+ Version: {version}
52
+ Location: {.workflow/ path}
53
+ ```
54
+
55
+ ### Step 2: Dry-Run Preview
56
+
57
+ Run the migration CLI in dry-run + JSON mode to get the full plan:
58
+
59
+ ```bash
60
+ npx tsx src/migrations/run.ts "$(pwd)" --dry-run --json
61
+ ```
62
+
63
+ Parse the JSON output. If status is `up-to-date`:
64
+ ```
65
+ Already up to date (v{version})
66
+ ```
67
+ → EXIT
68
+
69
+ Otherwise display the migration plan:
70
+ ```
71
+ Pending Migrations ({N} step(s)):
72
+
73
+ 1. [v{from} → v{to}] {name}
74
+ {description}
75
+
76
+ 2. [v{from} → v{to}] {name}
77
+ {description}
78
+ ```
79
+
80
+ If `--dry-run` flag was passed by user → display plan and EXIT.
81
+
82
+ ### Step 3: Interactive Confirmation Loop
83
+
84
+ For each migration step (unless `--force`):
85
+
86
+ ```
87
+ LOOP for step_index = 1 to N:
88
+
89
+ Display:
90
+ --- Step {step_index}/{N}: {name} ---
91
+ Version: v{from} → v{to}
92
+
93
+ Changes:
94
+ {description, indented}
95
+
96
+ IF NOT --force:
97
+ AskUserQuestion: "Apply this migration?"
98
+ Options: [yes / skip / abort]
99
+
100
+ - "yes" → proceed to Step 4 (execute)
101
+ - "skip" → WARN "Skipping may break the migration chain"
102
+ continue to next step
103
+ - "abort" → display summary of what was applied so far → EXIT
104
+
105
+ IF --force:
106
+ → proceed to Step 4 (execute)
107
+ ```
108
+
109
+ ### Step 4: Execute Single Migration
110
+
111
+ ```
112
+ 1. Create backup:
113
+ Bash: cp .workflow/state.json .workflow/state.json.backup-v{from}-{timestamp}
114
+
115
+ 2. Run migration:
116
+ Bash: npx tsx src/migrations/run.ts "$(pwd)" --json
117
+
118
+ NOTE: The runner executes ALL pending migrations. For step-by-step control,
119
+ read state.json, call the migration function directly, or use the runner
120
+ which stops on first failure.
121
+
122
+ 3. Parse result JSON and display:
123
+
124
+ {status_icon} Step {N} completed: {name}
125
+ Summary: {summary}
126
+ Changes:
127
+ - {change_1}
128
+ - {change_2}
129
+ - ...
130
+
131
+ 4. If failed:
132
+ Display: "Migration failed: {summary}"
133
+ Display: "Backup available at: {backup_path}"
134
+ Display: "Restore with: cp {backup_path} .workflow/state.json"
135
+ → EXIT
136
+
137
+ 5. Continue loop to next step
138
+ ```
139
+
140
+ ### Step 5: Summary
141
+
142
+ After all steps completed (or user aborted):
143
+
144
+ ```
145
+ === Migration Complete ===
146
+ Applied: {applied_count} / {total_count} migration(s)
147
+ Skipped: {skipped_count}
148
+ Version: v{original} → v{final}
149
+ Backup: .workflow/state.json.backup-v{original}-{timestamp}
150
+
151
+ Next steps:
152
+ /manage-status -- Verify project state
153
+ /maestro -- Continue workflow
154
+ ```
155
+
156
+ </execution>
157
+
158
+ <error_codes>
159
+ | Code | Severity | Condition | Recovery |
160
+ |------|----------|-----------|----------|
161
+ | E001 | error | .workflow/state.json not found | Run /maestro-init first |
162
+ | E002 | error | state.json parse error | Check file for corruption |
163
+ | E003 | error | Migration function failed | Restore from backup |
164
+ | W001 | warning | Skipped migration may break version chain | Re-run /maestro-update later |
165
+ | W002 | warning | tsx not available | Install tsx: npm i -D tsx |
166
+ </error_codes>
167
+
168
+ <success_criteria>
169
+ - [ ] Current version detected from state.json
170
+ - [ ] Dry-run preview shows full migration plan without execution
171
+ - [ ] Each step confirmed interactively (unless --force)
172
+ - [ ] Backup created before each migration
173
+ - [ ] Migration executed and result displayed with change list
174
+ - [ ] Abort stops cleanly with partial summary
175
+ - [ ] Summary shows applied/skipped counts and version change
176
+ </success_criteria>
@@ -0,0 +1,468 @@
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
+ <purpose>
9
+ 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).
10
+
11
+ **Core workflow**: Load Phase Artifacts -> Establish Must-Haves -> Decompose Checks -> Staged Parallel Verification -> Aggregate + Fix Plans
12
+
13
+ **Core principle**: Task completion != Goal achievement. A task marked complete may contain stubs/placeholders. This verifier checks that goals are actually achieved.
14
+
15
+ ```
16
+ +-------------------------------------------------------------------------+
17
+ | VERIFICATION CSV WAVE WORKFLOW |
18
+ +-------------------------------------------------------------------------+
19
+ | |
20
+ | Phase 1: Phase Resolution -> CSV |
21
+ | +-- Resolve phase directory from arguments |
22
+ | +-- Load index.json, plan.json, TASK-*.json, summaries |
23
+ | +-- Establish must-haves (truths, artifacts, key links) |
24
+ | +-- Decompose into check tasks per layer |
25
+ | +-- Assign waves based on layer dependencies |
26
+ | +-- Generate tasks.csv with one row per check |
27
+ | +-- User validates check breakdown (skip if -y) |
28
+ | |
29
+ | Phase 2: Wave Execution Engine |
30
+ | +-- Wave 1: Truth Checks + Artifact Existence (parallel) |
31
+ | | +-- Truth agents verify observable behaviors |
32
+ | | +-- Artifact-exist agents check L1 (file exists on disk) |
33
+ | | +-- Discoveries shared via board (gap patterns, stubs) |
34
+ | | +-- Results: status + evidence + gaps_found per check |
35
+ | +-- Wave 2: Artifact Substance + Wiring (parallel) |
36
+ | | +-- Substance agents check L2 (real impl, not stub) |
37
+ | | +-- Wiring agents check L3 (imported + used) |
38
+ | | +-- Needs truth context from wave 1 |
39
+ | | +-- Results: status + evidence + gaps_found per check |
40
+ | +-- Wave 3: Anti-Pattern Scan + Nyquist Audit (parallel) |
41
+ | | +-- Anti-pattern agent scans modified files (skip if flagged) |
42
+ | | +-- Nyquist agent maps requirements to tests (skip if flagged) |
43
+ | | +-- Needs artifact context from wave 2 |
44
+ | | +-- Results: antipatterns[] + coverage gaps |
45
+ | +-- discoveries.ndjson shared across all waves (append-only) |
46
+ | |
47
+ | Phase 3: Results Aggregation |
48
+ | +-- Export results.csv |
49
+ | +-- Build verification.json (must_haves, gaps, antipatterns, fixes) |
50
+ | +-- Build validation.json (if Nyquist ran) |
51
+ | +-- Generate context.md with all findings |
52
+ | +-- Auto-create issues for gaps + blocker anti-patterns |
53
+ | +-- Generate fix plans (cluster related gaps) |
54
+ | +-- Update phase index.json with verification status |
55
+ | +-- Display summary with next steps |
56
+ | |
57
+ +-------------------------------------------------------------------------+
58
+ ```
59
+ </purpose>
60
+
61
+ <context>
62
+ ```bash
63
+ $maestro-verify "3"
64
+ $maestro-verify -c 4 "3 --skip-tests"
65
+ $maestro-verify -y "3 --skip-antipattern"
66
+ $maestro-verify --continue "20260318-verify-P3-auth"
67
+ ```
68
+
69
+ **Flags**:
70
+ - `-y, --yes`: Skip all confirmations (auto mode)
71
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
72
+ - `--continue`: Resume existing session
73
+
74
+ When `--yes` or `-y`: Auto-confirm check decomposition, skip interactive validation, use defaults for layer detection.
75
+
76
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
77
+ **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)
78
+ </context>
79
+
80
+ <csv_schema>
81
+
82
+ ### tasks.csv (Master State)
83
+
84
+ ```csv
85
+ id,title,description,layer,phase_dir,check_type,deps,context_from,wave,status,findings,gaps_found,fix_plan,error
86
+ "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/scratch/plan-chat-2026/","observable_behavior","","","1","","","","",""
87
+ "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/scratch/plan-chat-2026/","observable_behavior","","","1","","","","",""
88
+ "3","Artifact Exists: src/components/Chat.tsx","Check L1 existence: verify file src/components/Chat.tsx exists on disk.","artifact",".workflow/scratch/plan-chat-2026/","exists","","","1","","","","",""
89
+ "4","Artifact Exists: src/api/chat.ts","Check L1 existence: verify file src/api/chat.ts exists on disk.","artifact",".workflow/scratch/plan-chat-2026/","exists","","","1","","","","",""
90
+ "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/scratch/plan-chat-2026/","substance","3","3","2","","","","",""
91
+ "6","Artifact Substance: src/api/chat.ts","Check L2 substance: verify src/api/chat.ts has real implementation (not stub/placeholder).","artifact",".workflow/scratch/plan-chat-2026/","substance","4","4","2","","","","",""
92
+ "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/scratch/plan-chat-2026/","import_usage","3;4","3;4","2","","","","",""
93
+ "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/scratch/plan-chat-2026/","pattern_scan","1;2;5;6;7","1;2;5;6;7","3","","","","",""
94
+ "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/scratch/plan-chat-2026/","test_coverage","1;2;5;6;7","1;2;5;6;7","3","","","","",""
95
+ ```
96
+
97
+ **Columns**:
98
+
99
+ | Column | Phase | Description |
100
+ |--------|-------|-------------|
101
+ | `id` | Input | Unique task identifier (string) |
102
+ | `title` | Input | Short check title |
103
+ | `description` | Input | Detailed verification instructions for this check |
104
+ | `layer` | Input | Verification layer: truth/artifact/wiring/antipattern/nyquist |
105
+ | `phase_dir` | Input | Target directory path (e.g., `.workflow/scratch/plan-chat-2026/`) |
106
+ | `check_type` | Input | Specific check type: observable_behavior/exists/substance/import_usage/pattern_scan/test_coverage |
107
+ | `deps` | Input | Semicolon-separated dependency task IDs |
108
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
109
+ | `wave` | Computed | Wave number (1 = truths + existence, 2 = substance + wiring, 3 = antipattern + nyquist) |
110
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
111
+ | `findings` | Output | Key verification findings summary (max 500 chars) |
112
+ | `gaps_found` | Output | JSON array of gap descriptions: `[{"id":"GAP-001","type":"missing_feature","severity":"critical","description":"...","fix_direction":"..."}]` |
113
+ | `fix_plan` | Output | Suggested fix actions for identified gaps |
114
+ | `error` | Output | Error message if failed |
115
+
116
+ ### Per-Wave CSV (Temporary)
117
+
118
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column.
119
+
120
+ ### Output Artifacts
121
+
122
+ | File | Purpose | Lifecycle |
123
+ |------|---------|-----------|
124
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
125
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
126
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
127
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
128
+ | `context.md` | Human-readable verification report | Created in Phase 3 |
129
+ | `verification.json` | Structured verification output for downstream | Created in Phase 3 |
130
+ | `validation.json` | Nyquist test coverage output (if ran) | Created in Phase 3 |
131
+
132
+ ### Session Structure
133
+
134
+ ```
135
+ .workflow/.csv-wave/{YYYYMMDD}-verify-P{N}-{slug}/
136
+ +-- tasks.csv
137
+ +-- results.csv
138
+ +-- discoveries.ndjson
139
+ +-- context.md
140
+ +-- verification.json
141
+ +-- validation.json (if Nyquist ran)
142
+ +-- wave-{N}.csv (temporary)
143
+ ```
144
+ </csv_schema>
145
+
146
+ <invariants>
147
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
148
+ 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
149
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
150
+ 4. **Context Propagation**: prev_context built from master CSV, not from memory
151
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
152
+ 6. **Skip on Failure**: If artifact existence check failed, skip its substance/wiring checks
153
+ 7. **Respect Skip Flags**: `--skip-tests` and `--skip-antipattern` mark wave 3 tasks as skipped, not removed
154
+ 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
155
+ 9. **DO NOT STOP**: Continuous execution until all waves complete
156
+ 10. **Goal-Backward**: Verify goals are achieved, not just tasks completed
157
+ </invariants>
158
+
159
+ <execution>
160
+
161
+ ### Session Initialization
162
+
163
+ **Parse from `$ARGUMENTS`**:
164
+
165
+ | Variable | Source | Default |
166
+ |----------|--------|---------|
167
+ | `AUTO_YES` | `--yes` or `-y` | false |
168
+ | `continueMode` | `--continue` | false |
169
+ | `maxConcurrency` | `--concurrency N` or `-c N` | 4 |
170
+ | `skipTests` | `--skip-tests` | false |
171
+ | `skipAntipattern` | `--skip-antipattern` | false |
172
+ | `phaseArg` | remaining text after flag removal | — |
173
+
174
+ **Session path** (UTC+8 date prefix): `.workflow/.csv-wave/{YYYYMMDD}-verify-P{phaseArg}-{phaseSlug}/`
175
+
176
+ Create session directory.
177
+
178
+ ### Phase 1: Phase Resolution -> CSV
179
+
180
+ **Objective**: Resolve phase, load artifacts, establish must-haves, decompose into check tasks, generate tasks.csv.
181
+
182
+ **Decomposition Rules**:
183
+
184
+ 1. **Phase resolution**: Resolve `{phaseArg}` via artifact registry in `state.json` to `.workflow/scratch/{YYYYMMDD}-{type}-{slug}/`
185
+ 2. **Artifact loading**: Read from phase directory:
186
+ - `index.json` -- success_criteria (ground truth for verification)
187
+ - `plan.json` -- original plan with task_ids
188
+ - All `.task/TASK-{NNN}.json` -- task definitions with convergence.criteria
189
+ - All `.summaries/TASK-{NNN}-summary.md` -- execution results
190
+ - `uat.md` (if exists) -- human UAT gaps to incorporate
191
+
192
+ 3. **Must-have establishment** (priority order):
193
+ - **success_criteria from index.json** -- primary contract
194
+ - **convergence.criteria from task JSON** -- per-task completion criteria
195
+ - **Derived from phase goal** -- fallback: derive 3-7 observable behaviors
196
+
197
+ 4. **Must-have decomposition** into 3 layers:
198
+ - **Truths**: Observable behaviors (e.g., "User can see existing messages")
199
+ - **Artifacts**: Concrete file paths that must exist and be substantive
200
+ - **Key Links**: Critical wiring between artifacts (e.g., "Chat.tsx imports /api/chat")
201
+
202
+ 5. **Check task generation**: For each must-have, generate check rows:
203
+
204
+ | Layer | Check Types | Wave |
205
+ |-------|-------------|------|
206
+ | truth | observable_behavior | 1 |
207
+ | artifact (exists) | exists | 1 |
208
+ | artifact (substance) | substance | 2 |
209
+ | wiring | import_usage | 2 |
210
+ | antipattern | pattern_scan | 3 (skip if `--skip-antipattern`) |
211
+ | nyquist | test_coverage | 3 (skip if `--skip-tests`) |
212
+
213
+ 6. **Wave computation**: Assign waves based on layer dependency chain:
214
+ - Wave 1: truth + artifact/exists (no predecessors, parallel)
215
+ - Wave 2: artifact/substance + wiring (need existence confirmation from wave 1)
216
+ - Wave 3: antipattern + nyquist (need substance/wiring context from wave 2)
217
+
218
+ 7. **Specs loading**: `specs_content = maestro spec load --category quality`
219
+
220
+ 8. **CSV generation**: One row per check task.
221
+
222
+ **User validation**: Display check breakdown (skip if AUTO_YES).
223
+
224
+ ### Phase 2: Wave Execution Engine
225
+
226
+ **Objective**: Execute verification checks wave-by-wave via spawn_agents_on_csv.
227
+
228
+ #### Wave 1: Truth Checks + Artifact Existence (Parallel)
229
+
230
+ Filter `wave == 1 && status == pending` from master CSV. No prev_context (no predecessors). Write `wave-1.csv`.
231
+
232
+ ```javascript
233
+ spawn_agents_on_csv({
234
+ csv_path: `${sessionFolder}/wave-1.csv`,
235
+ id_column: "id",
236
+ instruction: buildVerifyInstruction(sessionFolder, "wave1"),
237
+ max_concurrency: maxConcurrency,
238
+ max_runtime_seconds: 3600,
239
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
240
+ output_schema: { id, status: ["completed"|"failed"], findings, gaps_found, fix_plan, error }
241
+ // required: id, status, findings
242
+ })
243
+ ```
244
+
245
+ Merge results into master `tasks.csv`, delete `wave-1.csv`.
246
+
247
+ **Truth check agent**: Identify supporting artifacts, check existence + substance + wiring indicators. Status: VERIFIED / FAILED / UNCERTAIN. Report gaps for FAILED with severity + fix direction.
248
+
249
+ **Artifact existence agent**: Check file on disk. Missing = gap (severity=critical). Exists = note size + structure for wave 2.
250
+
251
+ #### Wave 2: Artifact Substance + Wiring (Parallel)
252
+
253
+ Filter `wave == 2 && status == pending`. Skip substance check if all wave 1 existence checks failed for that artifact. Build `prev_context` from wave 1 findings (format: `[Task N: Title] status - summary`). Write `wave-2.csv`, execute `spawn_agents_on_csv`, merge results, delete temp CSV.
254
+
255
+ **Substance check agent**: <10 lines real logic or contains placeholder markers ("placeholder", "coming soon", "TODO: implement") = STUB. Otherwise SUBSTANTIVE.
256
+
257
+ **Wiring check agent**: Grep for import statements + actual usage beyond imports. Status: WIRED / ORPHANED / NOT_WIRED.
258
+
259
+ #### Wave 3: Anti-Pattern Scan + Nyquist Audit (Parallel)
260
+
261
+ Filter `wave == 3 && status == pending`. Mark as `skipped` per skip flags (`--skip-antipattern`, `--skip-tests`). Build `prev_context` from wave 1 + wave 2 findings. Write `wave-3.csv`, execute `spawn_agents_on_csv`, merge results, delete temp CSV.
262
+
263
+ **Anti-pattern scan agent**: Extract modified files from task summaries. Scan for TODO/FIXME/XXX/HACK, placeholder content, empty returns, log-only functions, hardcoded test data, disabled tests. Categorize: Blocker / Warning / Info. Report as JSON array in `gaps_found`.
264
+
265
+ **Nyquist audit agent**: Detect test framework, map requirements to test files, classify COVERED / PARTIAL / MISSING. Run coverage if available. Report gaps + coverage percentage.
266
+
267
+ ### Phase 3: Results Aggregation
268
+
269
+ **Objective**: Generate final results, fix plans, and human-readable report.
270
+
271
+ 1. Read final master `tasks.csv`
272
+ 2. Export as `results.csv`
273
+ 3. **Aggregate must_haves** from all check results:
274
+
275
+ ```json
276
+ {
277
+ "truths": [
278
+ { "claim": "User can see existing messages", "status": "verified", "evidence": "Chat.tsx renders from /api/chat GET" }
279
+ ],
280
+ "artifacts": [
281
+ { "path": "src/components/Chat.tsx", "status": "exists", "substantive": true }
282
+ ],
283
+ "key_links": [
284
+ { "from": "Chat.tsx -> /api/chat", "status": "wired" }
285
+ ]
286
+ }
287
+ ```
288
+
289
+ 4. **Collect all gaps** from all tasks' `gaps_found` columns + UAT gaps (if uat.md exists)
290
+ 5. **Generate fix plans**: Cluster related gaps -> generate plan per cluster -> order by dependency
291
+ 6. **Build verification.json**:
292
+
293
+ ```json
294
+ {
295
+ "phase": "<phase>",
296
+ "status": "passed|gaps_found|human_needed",
297
+ "verified_at": "<ISO>",
298
+ "verifier": "csv-wave-verifier",
299
+ "must_haves": { "truths": [...], "artifacts": [...], "key_links": [...] },
300
+ "gaps": [...],
301
+ "antipatterns": [...],
302
+ "fix_plans": [...],
303
+ "human_verification": [...],
304
+ "coverage_score": 0.85
305
+ }
306
+ ```
307
+
308
+ 7. **Build validation.json** (if Nyquist ran):
309
+
310
+ ```json
311
+ {
312
+ "phase": "<phase>",
313
+ "status": "passed|gaps_found",
314
+ "validated_at": "<ISO>",
315
+ "test_framework": "vitest",
316
+ "coverage": { "statements": 80, "branches": 72, "functions": 85, "lines": 78 },
317
+ "requirement_coverage": [
318
+ { "requirement": "REQ-001", "tests": ["auth.spec.ts"], "status": "covered" }
319
+ ],
320
+ "gaps": [...]
321
+ }
322
+ ```
323
+
324
+ 8. **Generate context.md**:
325
+
326
+ ```markdown
327
+ # Verification Report -- Phase {phase}
328
+
329
+ ## Summary
330
+ - Truths: {verified}/{total} verified
331
+ - Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
332
+ - Wiring: {links_wired}/{links_total} key links
333
+ - Anti-patterns: {blocker_count} blockers, {warning_count} warnings
334
+ - Nyquist: {coverage_pct}% coverage ({skipped|status})
335
+
336
+ ## Overall Status: **{status}**
337
+
338
+ ## Must-Have Truths
339
+ ### {truth_claim}
340
+ Status: {VERIFIED|FAILED|UNCERTAIN}
341
+ Evidence: {evidence}
342
+
343
+ ## Artifact Checks
344
+ | Path | Exists | Substantive | Wired | Status |
345
+ |------|--------|-------------|-------|--------|
346
+
347
+ ## Key Links
348
+ | Link | Status | Evidence |
349
+
350
+ ## Gaps
351
+ | ID | Type | Severity | Description | Fix Direction |
352
+
353
+ ## Anti-Patterns
354
+ | File:Line | Pattern | Severity | Description |
355
+
356
+ ## Fix Plans
357
+ ### {cluster_name}
358
+ Objective: {objective}
359
+ Tasks: {task_list}
360
+ Issue Refs: {issue_ids}
361
+
362
+ ## Nyquist Coverage
363
+ {requirement_coverage_table}
364
+ ```
365
+
366
+ 9. **Overall status determination**:
367
+
368
+ | Condition | Status |
369
+ |-----------|--------|
370
+ | All truths VERIFIED, all artifacts pass L1-L3, all key links WIRED, no blockers | passed |
371
+ | Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, or blocker found | gaps_found |
372
+ | All automated checks pass but human verification items remain | human_needed |
373
+
374
+ 10. **Auto-create issues** from gaps + blocker anti-patterns (ID format: `ISS-YYYYMMDD-NNN`).
375
+
376
+ 11. **Archive previous artifacts**: Move existing `verification.json`/`validation.json` in phase dir to `.history/`.
377
+
378
+ 12. **Copy outputs** to phase directory: `verification.json`, `validation.json` (if generated).
379
+
380
+ 13. **Update phase index.json** with verification status and timestamps.
381
+
382
+ 14. **Display summary**: Phase name, truths verified/total, artifacts L1-L3, wiring status, anti-pattern counts, Nyquist coverage, gaps by severity, fix plan count, issues created, human verification items, output file paths.
383
+
384
+ 15. **Post-verify Knowledge Inquiry** (before next step routing):
385
+
386
+ | Signal | Prompt User | Spec Category |
387
+ |--------|-------------|---------------|
388
+ | Anti-pattern blockers found | "Update `quality-rules.md`?" | `quality` via `/spec-add` |
389
+ | Constraint/wiring violations | "Update `architecture-constraints.md`?" | `arch` via `/spec-add` |
390
+ | Recurring Nyquist coverage gaps | "Add to `test-conventions.md`?" | `test` via `/spec-add` |
391
+
392
+ On user confirm, append `<spec-entry>` to matching category file.
393
+
394
+ 16. **Next step routing**:
395
+
396
+ | Result | Suggestion |
397
+ |--------|------------|
398
+ | All passed, no gaps | `$quality-review "{phase}"` for code review |
399
+ | Critical gaps found | `$quality-debug` for investigation |
400
+ | Minor gaps only | `$maestro-plan "{phase} --gaps"` -> `$maestro-execute` -> re-run `$maestro-verify` |
401
+ | Low test coverage | `$quality-auto-test "{phase}"` to generate missing tests |
402
+ | Human verification needed | `$quality-test "{phase}"` for interactive UAT |
403
+
404
+ ### Shared Discovery Board Protocol
405
+
406
+ #### Standard Discovery Types
407
+
408
+ | Type | Dedup Key | Data Schema | Description |
409
+ |------|-----------|-------------|-------------|
410
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
411
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
412
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
413
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
414
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
415
+
416
+ #### Domain Discovery Types
417
+
418
+ | Type | Dedup Key | Data Schema | Description |
419
+ |------|-----------|-------------|-------------|
420
+ | `verification_gap` | `data.gap_id` | `{gap_id, layer, severity, description}` | Verification gap found |
421
+ | `stub_detected` | `data.file` | `{file, line, marker, content}` | Stub/placeholder file detected |
422
+ | `broken_wiring` | `data.from+data.to` | `{from, to, expected, actual}` | Broken integration link |
423
+ | `antipattern` | `data.location` | `{location, pattern, severity}` | Anti-pattern instance |
424
+ | `test_gap` | `data.requirement` | `{requirement, status, suggested_test}` | Missing test coverage |
425
+
426
+ #### Protocol
427
+
428
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own check
429
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
430
+ 3. **Write immediately**: Append findings as found
431
+ 4. **Append-only**: Never modify or delete
432
+ 5. **Deduplicate**: Check before writing
433
+
434
+ ```bash
435
+ 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
436
+ ```
437
+ </execution>
438
+
439
+ <error_codes>
440
+
441
+ | Error | Resolution |
442
+ |-------|------------|
443
+ | Phase directory not found | Resolve via state.json artifact registry; abort if not found |
444
+ | No execution results found | Abort with error: "No completed tasks found -- run execute first" |
445
+ | No summaries found | Warn, proceed with task file analysis only |
446
+ | No success_criteria in index.json | Derive must-haves from phase goal (fallback) |
447
+ | Truth check agent timeout | Mark as failed, continue remaining checks |
448
+ | Substance check on missing artifact | Auto-skip (dep failed), mark as skipped |
449
+ | Anti-pattern scan disabled | Mark as skipped, note in context.md |
450
+ | Nyquist audit disabled | Mark as skipped, note in context.md |
451
+ | Test framework not detected | Skip coverage calculation, warn user |
452
+ | CSV parse error | Validate format, show line number |
453
+ | discoveries.ndjson corrupt | Ignore malformed lines |
454
+ | Continue mode: no session found | List available sessions |
455
+ </error_codes>
456
+
457
+ <success_criteria>
458
+ - [ ] Session folder created with valid tasks.csv
459
+ - [ ] All 3 waves executed in order (with skip flags respected)
460
+ - [ ] verification.json produced with must_haves, gaps, antipatterns
461
+ - [ ] validation.json produced (if Nyquist ran)
462
+ - [ ] context.md produced with full report
463
+ - [ ] Fix plans generated for gap clusters
464
+ - [ ] Issues auto-created for gaps + blocker anti-patterns
465
+ - [ ] Output files copied to phase directory
466
+ - [ ] Phase index.json updated with verification status
467
+ - [ ] discoveries.ndjson append-only throughout
468
+ </success_criteria>