pi-maestro-flow 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +18 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -5
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -2
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,557 @@
1
+ # ⚠️ DEPRECATED — Merged into execute.md (E2.7)
2
+
3
+ Verification is now a built-in gate in `execute.md` step E2.7. This file is kept for reference only.
4
+
5
+ ---
6
+
7
+ # Verify Workflow
8
+
9
+ Dual verification: Goal-Backward structural verification + Nyquist test coverage validation.
10
+
11
+ ---
12
+
13
+ ## Iron Law
14
+
15
+ **NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE IN THIS MESSAGE.**
16
+
17
+ Before any success/completion claim:
18
+ 1. IDENTIFY — What command proves this claim?
19
+ 2. RUN — Execute the FULL command (fresh, in this message — never cite prior runs)
20
+ 3. READ — Read FULL output, check exit code, count failures
21
+ 4. VERIFY — Does the output actually confirm the claim?
22
+ 5. ONLY THEN — Make the claim, with evidence inline
23
+
24
+ ---
25
+
26
+ ## Forbidden Wording
27
+
28
+ These phrases are BANNED in verification reports and completion claims:
29
+ - "Should work now"
30
+ - "Probably passes"
31
+ - "Seems correct"
32
+ - "Looks good"
33
+ - "I'm confident that..."
34
+ - "Based on my review, this is complete"
35
+ - Any expression of satisfaction BEFORE running verification commands
36
+
37
+ Replace with evidence: `"Tests pass: 42/42 green (exit 0)"`, `"All 5 truths VERIFIED with file:line evidence"`.
38
+
39
+ ---
40
+
41
+ ## Red Flags — These Thoughts Mean STOP
42
+
43
+ If you catch yourself thinking any of these, STOP and run verification first:
44
+
45
+ - "I just wrote this code, it definitely works"
46
+ - "The changes are too small to break anything"
47
+ - "I already verified this earlier in the conversation"
48
+ - "The tests passed before, they'll pass now"
49
+ - "I can see from the code that it's correct"
50
+ - "Let me just mark this complete and move on"
51
+
52
+ All of these mean: **run the verification command NOW, read the output, then report**.
53
+
54
+ ---
55
+
56
+ ## Rationalization Table
57
+
58
+ | Excuse | Why It's Wrong |
59
+ |--------|----------------|
60
+ | "I just made a one-line change" | One-line changes cause the most insidious bugs |
61
+ | "Tests passed earlier" | Code changed since then — earlier results are stale |
62
+ | "I can read the code is correct" | Reading is not running — subtle runtime errors are invisible in code review |
63
+ | "The build succeeded" | Build success ≠ functional correctness |
64
+ | "It works for the happy path" | Edge cases, error paths, and boundary conditions need verification too |
65
+ | "Verification would take too long" | Skipping verification costs more time when bugs surface later |
66
+ | "The agent said it's done" | Agent reports are claims, not evidence — verify independently |
67
+
68
+ ---
69
+
70
+ ## Prerequisites
71
+
72
+ - Phase execution completed (or partially completed)
73
+ - `.task/TASK-*.json` files exist with execution results
74
+ - `.summaries/TASK-*-summary.md` files exist
75
+
76
+ ---
77
+
78
+ ## Scope Resolution
79
+
80
+ ```
81
+ Input: [phase] argument OR --dir <path>
82
+
83
+ Worktree scope check: if .workflow/worktree-scope.json exists, reject phases not in scope.owned_phases.
84
+
85
+ Resolve PLAN_DIRS and VERIFY_MODE by input type:
86
+ --dir <path> → single mode, PLAN_DIRS=[path], output into plan dir
87
+ no arguments → milestone mode, collect completed execute artifacts for current milestone from state.json
88
+ numeric arg → phase mode, collect completed execute artifacts for that phase from state.json
89
+
90
+ If no matching artifacts found: ERROR E001.
91
+ Milestone mode creates output dir: .workflow/scratch/{YYYYMMDD}-verify-{milestone_slug}/
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Flag Processing
97
+
98
+ | Flag | Effect |
99
+ |------|--------|
100
+ | `--skip-tests` | Skip V2 (Nyquist test coverage), only run Goal-Backward verification |
101
+ | `--skip-antipattern` | Skip anti-pattern scan step |
102
+
103
+ ---
104
+
105
+ ## V0: Load Project Specs
106
+
107
+ ```
108
+ specs_content = maestro spec load --category review
109
+ ```
110
+
111
+ Pass specs_content to verifier agent as quality standards context.
112
+
113
+ ---
114
+
115
+ ## V0.5: Tech Stack Constraint Validation
116
+
117
+ **Purpose:** Validate that modified files comply with project tech stack constraints before running expensive goal-backward verification.
118
+
119
+ **Skip if** specs_content contains no tech stack or constraint definitions.
120
+
121
+ ### Step 1: Extract Constraints from Specs
122
+
123
+ ```
124
+ Extract from specs_content into constraints object:
125
+ allowed_libs[] ← "tech_stack" / "technology" sections
126
+ disallowed_imports[] ← "constraints" / "disallowed" / "forbidden" sections
127
+ required_patterns[] ← "required_patterns" / "conventions" sections
128
+
129
+ If no allowed_libs and no disallowed_imports found: skip to V1.
130
+ ```
131
+
132
+ ### Step 2: Collect Modified Files
133
+
134
+ ```
135
+ Collect modified_files from task summaries ("Files Modified" sections).
136
+ Fallback: git diff --name-only HEAD~{tasks_completed} -- "*.ts" "*.tsx" "*.js" "*.jsx" "*.py" "*.java" "*.go"
137
+ Deduplicate, exclude node_modules and test/spec files.
138
+ ```
139
+
140
+ ### Step 3: Scan Imports Against Constraints
141
+
142
+ ```
143
+ For each modified file, extract import statements (language-aware: TS/JS, Python, Go, Java).
144
+
145
+ Check each import against constraints:
146
+ disallowed_imports match → violation {id: "CV-{NNN}", type: "disallowed_import", severity: "high", file, line, import, constraint, fix_direction}
147
+ allowed_libs allowlist defined + external package not listed → violation {id: "CV-{NNN}", type: "unlisted_dependency", severity: "medium", file, line, import, constraint, fix_direction}
148
+ ```
149
+
150
+ ### Step 4: Check Required Patterns
151
+
152
+ ```
153
+ For each required_pattern, scan matching files (by file_glob) for pattern.regex.
154
+ Missing match → violation {id: "CV-{NNN}", type: "missing_required_pattern", severity: pattern.severity || "medium", file, constraint, fix_direction}
155
+ ```
156
+
157
+ ### Step 5: Report
158
+
159
+ ```
160
+ Report constraint_violations count and details: [{severity}] {file}:{line} - {constraint}
161
+ If none: "V0.5: All modified files comply with tech stack constraints"
162
+ ```
163
+
164
+ The `constraint_violations[]` array is included in the final `verification.json` output in V3 aggregation.
165
+
166
+ ---
167
+
168
+ ## V0.8: CLI Supplementary Verification (optional)
169
+
170
+ **Purpose:** Use external CLI tool for broad anti-pattern and completeness scan as a supplementary signal before structural verification. Results feed into V1 as pre-collected evidence.
171
+
172
+ **Skip if** no enabled CLI tools.
173
+
174
+ ```
175
+ IF no CLI tools enabled: skip to V1
176
+
177
+ # Collect modified files list from task summaries
178
+ modified_files_list = modified_files.join(", ")
179
+
180
+ Bash({
181
+ command: 'maestro delegate "PURPOSE: Pre-verify code completeness and anti-patterns in modified files
182
+ TASK: Check for TODO/FIXME/HACK markers | Detect stub implementations (empty functions, placeholder returns) | Verify imports are used | Check for console.log/print debug statements left behind
183
+ MODE: analysis
184
+ CONTEXT: @${modified_files as glob pattern}
185
+ EXPECTED: JSON { anti_patterns: [{ type, file, line, description, severity }], completeness_flags: [{ file, issue, severity }] }
186
+ CONSTRAINTS: Only scan the listed modified files | severity = blocker|warning|info
187
+ " --role analyze --mode analysis',
188
+ run_in_background: true
189
+ })
190
+ ```
191
+
192
+ **On callback:**
193
+ ```
194
+ cli_verify = maestro delegate output <id>
195
+ Parse JSON result
196
+
197
+ # Merge into constraint_violations for V3 aggregation
198
+ For each anti_pattern with severity == "blocker":
199
+ Append to constraint_violations as { id: "CLI-AP-{NNN}", type: "cli_anti_pattern", ... }
200
+
201
+ Pass cli_verify.completeness_flags as supplementary context to V1 verification
202
+ ```
203
+
204
+ ---
205
+
206
+ ## V1: Goal-Backward Verification
207
+
208
+ **Purpose:** Verify execution results match phase goals through 3-layer structural checking.
209
+
210
+ ### Step 1: Load Artifacts
211
+
212
+ Read from phase directory:
213
+ - index.json -- success_criteria (the ground truth for verification)
214
+ - plan.json -- original plan with task_ids and approach
215
+ - All `.task/TASK-{NNN}.json` files -- task definitions with convergence.criteria
216
+ - All `.summaries/TASK-{NNN}-summary.md` files -- execution results and outputs
217
+ - `uat.md` (if exists) -- human UAT gaps to incorporate into verification
218
+
219
+ Build a verification context object mapping:
220
+ - success_criteria -> what must be verified
221
+ - tasks + summaries -> evidence of completion
222
+
223
+ **Load UAT human findings** (if available):
224
+ ```
225
+ If ${PHASE_DIR}/uat.md exists, parse "Gaps" section into uat_gaps[]:
226
+ {id: "GAP-UAT-{NNN}", type: "human_verified_failure", severity, description, fix_direction}
227
+ ```
228
+ These `uat_gaps` are merged into the final `gaps[]` in V3 aggregation.
229
+
230
+ ### Step 2: Establish Must-Haves
231
+
232
+ Priority order:
233
+ 1. **success_criteria from index.json** -- primary contract, each criterion is a testable truth
234
+ 2. **convergence.criteria from task JSON** -- per-task completion criteria
235
+ 3. **Derived from phase goal** -- fallback: derive 3-7 observable behaviors from roadmap phase goal
236
+
237
+ For each must-have, decompose into 3 layers:
238
+ - **Truths**: observable behaviors (e.g., "User can see existing messages")
239
+ - **Artifacts**: concrete file paths that must exist and be substantive (e.g., `src/components/Chat.tsx`)
240
+ - **Key Links**: critical wiring between artifacts (e.g., "Chat.tsx imports and calls /api/chat GET")
241
+
242
+ ### Step 3: Verify Observable Truths (Layer 1)
243
+
244
+ For each truth, determine if the codebase enables it:
245
+
246
+ | Status | Meaning |
247
+ |--------|---------|
248
+ | VERIFIED | All supporting artifacts pass, wiring intact |
249
+ | FAILED | Artifact missing, stub, or unwired |
250
+ | UNCERTAIN | Needs human verification (visual, real-time, external service) |
251
+
252
+ For each truth: identify supporting artifacts -> check artifact existence and substance -> check wiring -> determine truth status.
253
+
254
+ ### Step 4: Verify Artifacts (Layer 2)
255
+
256
+ For each artifact identified in must-haves, check at 3 levels:
257
+
258
+ | Level | Check | Status |
259
+ |-------|-------|--------|
260
+ | L1: Exists | File exists on disk | MISSING if not |
261
+ | L2: Substantive | File has real implementation (not stub/placeholder) | STUB if too small or has placeholder markers |
262
+ | L3: Wired | File is imported AND used by other modules | ORPHANED if exists but unused |
263
+
264
+ **Substance check**: Files under ~10 lines of real logic, or containing "placeholder", "coming soon", "TODO: implement" are flagged as STUB.
265
+
266
+ **Wiring check**:
267
+ ```bash
268
+ # Check if artifact is imported
269
+ grep -r "import.*{artifact_name}" src/ --include="*.ts" --include="*.tsx" --include="*.py"
270
+ # Check if artifact is used (beyond import)
271
+ grep -r "{artifact_name}" src/ --include="*.ts" --include="*.tsx" --include="*.py" | grep -v "import"
272
+ ```
273
+
274
+ | Exists | Substantive | Wired | Status |
275
+ |--------|-------------|-------|--------|
276
+ | yes | yes | yes | VERIFIED |
277
+ | yes | yes | no | ORPHANED |
278
+ | yes | no | - | STUB |
279
+ | no | - | - | MISSING |
280
+
281
+ ### Step 5: Verify Key Links (Layer 3)
282
+
283
+ For each key link (component A -> component B via mechanism):
284
+
285
+ | Pattern | Check | Status |
286
+ |---------|-------|--------|
287
+ | Component -> API | fetch/axios call to API path, response used | WIRED / PARTIAL / NOT_WIRED |
288
+ | API -> Database | DB query on model, result returned | WIRED / PARTIAL / NOT_WIRED |
289
+ | Form -> Handler | onSubmit with real implementation (not console.log) | WIRED / STUB / NOT_WIRED |
290
+ | State -> Render | State variable appears in JSX/template | WIRED / NOT_WIRED |
291
+ | Event -> Handler | Event listener with real handler logic | WIRED / STUB / NOT_WIRED |
292
+
293
+ Record status and evidence (file:line references) for each key link.
294
+
295
+ ### Build must_haves
296
+
297
+ ```
298
+ must_haves = {
299
+ truths: [
300
+ { claim: "success_criterion text", status: "verified" | "failed", evidence: "..." }
301
+ ],
302
+ artifacts: [
303
+ { path: "file/path", status: "exists" | "missing", substantive: true | false }
304
+ ],
305
+ key_links: [
306
+ { from: "ComponentA -> ServiceB -> ModelC", status: "wired" | "broken" }
307
+ ]
308
+ }
309
+ ```
310
+
311
+ ### Identify gaps
312
+
313
+ ```
314
+ Collect gaps from failed truths, missing/stub artifacts, and broken links.
315
+ Each gap: {id: "GAP-{NNN}", type: "missing_feature"|"incomplete_implementation"|"broken_integration",
316
+ severity: "critical"|"high"|"medium"|"low", description, fix_direction}
317
+ ```
318
+
319
+ ### Auto-create Issues from Gaps
320
+
321
+ ```
322
+ For each gap, create an issue in .workflow/issues/issues.jsonl:
323
+ id: "ISS-{YYYYMMDD}-{NNN}" (auto-incrementing from existing today's IDs)
324
+ Fields: title (gap.description truncated 100 chars), status: "registered",
325
+ priority: severity_to_priority(gap.severity), severity, source: "verification",
326
+ phase_ref: PHASE_NUM, gap_ref: gap.id, description, fix_direction,
327
+ context: {location, suggested_fix, notes}, tags[], affected_components[],
328
+ feedback[], issue_history[], created_at, updated_at, resolved_at: null, resolution: null
329
+ Back-reference: gap.issue_id = issue_id
330
+ ```
331
+
332
+ ### Write verification.json
333
+
334
+ ```
335
+ Write ${PHASE_DIR}/verification.json:
336
+ {
337
+ "phase": PHASE_NUM,
338
+ "status": gaps.length > 0 ? "gaps_found" : "passed",
339
+ "verified_at": now(),
340
+ "verifier": "workflow-verifier",
341
+ "must_haves": must_haves,
342
+ "gaps": gaps
343
+ }
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Anti-Pattern Scan
349
+
350
+ **Skip if `--skip-antipattern` flag is set.**
351
+
352
+ Extract files modified in this phase from task summaries. For each file:
353
+
354
+ | Pattern | Search | Severity |
355
+ |---------|--------|----------|
356
+ | TODO/FIXME/XXX/HACK | `grep -n "TODO\|FIXME\|XXX\|HACK"` | Warning |
357
+ | Placeholder content | `grep -n -i "placeholder\|coming soon\|will be here"` | Blocker |
358
+ | Empty returns | `grep -n "return null\|return {}\|return \[\]\|=> {}"` | Warning |
359
+ | Log-only functions | Functions containing only console.log/print | Warning |
360
+ | Hardcoded test data | `grep -n "hardcoded\|dummy\|fake\|mock"` | Warning |
361
+ | Disabled tests | `grep -n "skip\|xit\|xdescribe\|@disabled"` | Warning |
362
+
363
+ Categorize: Blocker (prevents goal) | Warning (incomplete) | Info (notable).
364
+
365
+ Write anti-patterns into verification.json `antipatterns[]` array.
366
+
367
+ ### Auto-create Issues from Blocker Anti-Patterns
368
+
369
+ ```
370
+ For each Blocker anti-pattern, create an issue in .workflow/issues/issues.jsonl:
371
+ id: "ISS-{YYYYMMDD}-{NNN}" (auto-incrementing from existing today's IDs)
372
+ Fields: title: "Anti-pattern: {pattern_name}", status: "registered",
373
+ priority: 1, severity: "critical", source: "antipattern",
374
+ phase_ref: PHASE_NUM, description, fix_direction,
375
+ context: {location: pattern.file_line}, tags: ["antipattern"]
376
+ Back-reference: pattern.issue_id = issue_id
377
+ ```
378
+
379
+ ---
380
+
381
+ ## V2: Nyquist Test Coverage (skip if `--skip-tests`)
382
+
383
+ **Purpose:** Ensure test coverage meets requirements through the Nyquist sampling principle.
384
+
385
+ ### Step 1: Detect Test Infrastructure
386
+
387
+ ```bash
388
+ find . -name "jest.config.*" -o -name "vitest.config.*" -o -name "pytest.ini" -o -name "pyproject.toml" 2>/dev/null | head -10
389
+ find . \( -name "*.test.*" -o -name "*.spec.*" -o -name "test_*" \) -not -path "*/node_modules/*" 2>/dev/null | head -40
390
+ ```
391
+
392
+ ### Step 2: Build Requirement-to-Test Map
393
+
394
+ For each success criterion / must-have truth:
395
+ - Search for test files covering the behavior
396
+ - Match by filename, imports, test descriptions
397
+
398
+ ### Step 3: Gap Classification
399
+
400
+ | Status | Criteria |
401
+ |--------|----------|
402
+ | COVERED | Test exists, targets behavior, runs green |
403
+ | PARTIAL | Test exists but failing or incomplete |
404
+ | MISSING | No test found for this requirement |
405
+
406
+ ### Step 4: Spawn Auditor Agent (if gaps found)
407
+
408
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Spawn workflow-nyquist-auditor agent with gap list, test infrastructure, and phase context.
409
+ Agent generates missing tests and returns:
410
+ - GAPS FILLED -> record new tests
411
+ - PARTIAL -> record resolved, escalate remainder
412
+ - ESCALATE -> move to manual-only
413
+
414
+ ### Step 5: Generate validation.json
415
+
416
+ ```
417
+ Write ${PHASE_DIR}/validation.json:
418
+ {
419
+ "phase": PHASE_NUM,
420
+ "status": uncovered.length > 0 ? "gaps_found" : "passed",
421
+ "validated_at": now(),
422
+ "test_framework": test_framework,
423
+ "coverage": { statements, branches, functions, lines },
424
+ "requirement_coverage": [
425
+ { "requirement": "REQ-001", "tests": ["auth.spec.ts"], "status": "covered" },
426
+ { "requirement": "REQ-002", "tests": [], "status": "uncovered" }
427
+ ],
428
+ "gaps": [
429
+ {
430
+ "requirement": "REQ-002",
431
+ "description": "No tests for login endpoint",
432
+ "suggested_test": "auth.login.spec.ts"
433
+ }
434
+ ]
435
+ }
436
+ ```
437
+
438
+ If coverage below threshold, log warning (W001).
439
+
440
+ ---
441
+
442
+ ## Fix Plan Generation
443
+
444
+ If gaps exist from any verification layer:
445
+
446
+ 1. **Cluster related gaps**: API stub + component unwired -> "Wire frontend to backend". Multiple missing -> "Complete core implementation". Wiring only -> "Connect existing components".
447
+
448
+ 2. **Generate plan per cluster**: Objective, 2-3 tasks (files/action/verify each), re-verify step. Keep focused: single concern per plan.
449
+
450
+ 3. **Order by dependency**: Fix missing -> fix stubs -> fix wiring -> verify.
451
+
452
+ Enrich each fix_plan with issue_ids[] collected from its related_gaps' issue references.
453
+
454
+ Write fix plans into verification.json `fix_plans[]` array.
455
+
456
+ ---
457
+
458
+ ## V3: Aggregate Results and Report
459
+
460
+ ### Aggregate All Verification Results
461
+
462
+ Combine goal-backward, constraint validation, anti-pattern scan, and Nyquist results:
463
+
464
+ **Overall status determination:**
465
+ - **passed**: All truths VERIFIED, all artifacts pass L1-L3, all key links WIRED, no blocker anti-patterns, no high/critical constraint violations
466
+ - **gaps_found**: Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, blocker found, or high/critical constraint violation detected
467
+ - **human_needed**: All automated checks pass but human verification items remain
468
+
469
+ **Score**: `verified_truths / total_truths`
470
+
471
+ **Archive previous verification artifacts** before writing:
472
+ ```
473
+ If any of ["verification.json", "validation.json"] exist in ${PHASE_DIR}:
474
+ Move each to ${PHASE_DIR}/.history/{name}-{YYYY-MM-DDTHH-mm-ss}.{ext}
475
+ ```
476
+
477
+ Write verification.json:
478
+ - `must_haves[]` -- list of criteria with pass/fail status, evidence, and layer results
479
+ - `gaps[]` -- unmet criteria with severity, layer, and suggested remediation (includes uat_gaps from Step 1 if available)
480
+ - `constraint_violations[]` -- tech stack violations with severity, file:line, and fix direction (from V0.5)
481
+ - `antipatterns[]` -- detected anti-patterns with severity and file:line
482
+ - `fix_plans[]` -- clustered fix plans for gap closure
483
+ - `human_verification[]` -- items needing manual testing
484
+ - `coverage_score` -- percentage of criteria met
485
+
486
+ ### Update index.json
487
+
488
+ ```
489
+ Set index.json.status = "verifying", updated_at = now()
490
+ Set index.json.verification = {status, verified_at, must_haves summary, gaps} from verification.json
491
+ If validation.json exists: set index.json.validation = {status, test_coverage, gaps} from validation.json
492
+ ```
493
+
494
+ ### Report Format
495
+
496
+ ```
497
+ === VERIFICATION RESULTS ===
498
+ Phase: {phase_name}
499
+
500
+ Goal-Backward: {verified_count}/{total_truths} truths verified
501
+ Artifacts: {artifact_verified}/{artifact_total} (L1-L3)
502
+ Wiring: {links_wired}/{links_total} key links
503
+ Constraints: {constraint_violation_count} violations ({high_count} high, {medium_count} medium)
504
+ Anti-patterns: {blocker_count} blockers, {warning_count} warnings
505
+ Nyquist: {coverage_pct}% coverage ({skip_tests ? "SKIPPED" : status})
506
+
507
+ Gaps: {gap_count}
508
+ Critical: {critical_count}
509
+ Important: {important_count}
510
+ Minor: {minor_count}
511
+
512
+ Fix Plans: {fix_plan_count} generated
513
+ Human Verification: {human_items} items
514
+
515
+ Files:
516
+ {artifact_dir}/verification.json
517
+ {artifact_dir}/validation.json (if generated)
518
+
519
+ Next steps:
520
+ {suggested_next_command}
521
+ ```
522
+
523
+ ### Next Step Routing
524
+
525
+ | Result | Suggestion |
526
+ |--------|------------|
527
+ | All passed, no gaps | Skill({ skill: "quality-review", args: "{phase}" }) for code review, then Skill({ skill: "quality-test" }) for UAT |
528
+ | Critical gaps found | Skill({ skill: "quality-debug" }) for investigation |
529
+ | Minor gaps only | Skill({ skill: "maestro-plan", args: "--gaps" }) -> Skill({ skill: "maestro-execute" }) |
530
+ | Low test coverage | Skill({ skill: "quality-auto-test", args: "{phase}" }) to generate missing tests |
531
+ | Human verification needed | Skill({ skill: "quality-test", args: "{phase}" }) for interactive UAT |
532
+
533
+ **Gap-fix loop**: `verify -> plan --gaps -> execute -> verify` repeats until all gaps are closed or user accepts remaining gaps.
534
+
535
+ ---
536
+
537
+ ## Error Handling
538
+
539
+ | Error | Action |
540
+ |-------|--------|
541
+ | Phase directory not found | Abort: "Phase {phase} not found." |
542
+ | No execution results | Abort: "No completed tasks found. Run /workflow:execute first." |
543
+ | No summaries found | Warn, proceed with task file analysis only; flag verification.json as [LOW CONFIDENCE] (partial, summaries missing) |
544
+ | Test framework not detected | Skip coverage calculation, warn user |
545
+ | Coverage command fails | Log error, proceed with requirement mapping only; flag validation.json coverage as [LOW CONFIDENCE] (partial, coverage command failed) |
546
+ | Verifier agent fails | Retry once, then write partial verification.json; flag verification.json as [LOW CONFIDENCE] (partial, verifier agent failed) |
547
+
548
+ ---
549
+
550
+ ## State Updates
551
+
552
+ | When | Field | Value |
553
+ |------|-------|-------|
554
+ | V1 start | index.json.status | "verifying" |
555
+ | V1 complete | index.json.verification | Verification results |
556
+ | V2 complete | index.json.validation | Validation results |
557
+ | V3 complete | index.json.updated_at | Current timestamp |