maestro-flow 0.5.46 → 0.5.47

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 (237) hide show
  1. package/.agents/skills/domain-add/SKILL.md +9 -0
  2. package/.agents/skills/learn-decompose/SKILL.md +12 -0
  3. package/.agents/skills/learn-follow/SKILL.md +41 -0
  4. package/.agents/skills/learn-investigate/SKILL.md +14 -0
  5. package/.agents/skills/learn-second-opinion/SKILL.md +14 -0
  6. package/.agents/skills/maestro-amend/SKILL.md +11 -0
  7. package/.agents/skills/maestro-companion/SKILL.md +11 -0
  8. package/.agents/skills/maestro-composer/SKILL.md +11 -0
  9. package/.agents/skills/maestro-guard/SKILL.md +25 -0
  10. package/.agents/skills/maestro-init/SKILL.md +28 -0
  11. package/.agents/skills/maestro-overlay/SKILL.md +11 -0
  12. package/.agents/skills/maestro-player/SKILL.md +11 -0
  13. package/.agents/skills/maestro-quick/SKILL.md +29 -0
  14. package/.agents/skills/maestro-swarm-workflow/SKILL.md +25 -0
  15. package/.agents/skills/maestro-tools-execute/SKILL.md +29 -0
  16. package/.agents/skills/maestro-tools-register/SKILL.md +29 -0
  17. package/.agents/skills/maestro-ui-codify/SKILL.md +11 -0
  18. package/.agents/skills/maestro-universal-workflow/SKILL.md +59 -0
  19. package/.agents/skills/maestro-update/SKILL.md +38 -0
  20. package/.agents/skills/manage-codebase-rebuild/SKILL.md +29 -0
  21. package/.agents/skills/manage-drift-realign/SKILL.md +12 -0
  22. package/.agents/skills/manage-harvest/SKILL.md +30 -6
  23. package/.agents/skills/manage-issue/SKILL.md +23 -0
  24. package/.agents/skills/manage-issue-discover/SKILL.md +28 -0
  25. package/.agents/skills/manage-kg-extractors/SKILL.md +27 -1
  26. package/.agents/skills/manage-knowhow/SKILL.md +26 -0
  27. package/.agents/skills/manage-knowhow-capture/SKILL.md +24 -0
  28. package/.agents/skills/manage-knowledge-audit/SKILL.md +13 -0
  29. package/.agents/skills/manage-status/SKILL.md +22 -0
  30. package/.agents/skills/manage-wiki/SKILL.md +28 -0
  31. package/.agents/skills/odyssey-improve/SKILL.md +50 -0
  32. package/.agents/skills/odyssey-planex/SKILL.md +46 -0
  33. package/.agents/skills/odyssey-review-test-fix/SKILL.md +50 -0
  34. package/.agents/skills/odyssey-ui/SKILL.md +50 -0
  35. package/.agents/skills/quality-auto-test/SKILL.md +12 -0
  36. package/.agents/skills/quality-debug/SKILL.md +11 -0
  37. package/.agents/skills/quality-refactor/SKILL.md +11 -0
  38. package/.agents/skills/quality-retrospective/SKILL.md +11 -0
  39. package/.agents/skills/quality-review/SKILL.md +11 -0
  40. package/.agents/skills/quality-sync/SKILL.md +10 -0
  41. package/.agents/skills/quality-test/SKILL.md +12 -0
  42. package/.agents/skills/security-audit/SKILL.md +11 -0
  43. package/.agents/skills/spec-add/SKILL.md +27 -0
  44. package/.agents/skills/spec-load/SKILL.md +25 -0
  45. package/.agents/skills/spec-remove/SKILL.md +26 -0
  46. package/.agents/skills/spec-setup/SKILL.md +30 -0
  47. package/.agy/skills/domain-add/SKILL.md +9 -0
  48. package/.agy/skills/learn-decompose/SKILL.md +12 -0
  49. package/.agy/skills/learn-follow/SKILL.md +41 -0
  50. package/.agy/skills/learn-investigate/SKILL.md +14 -0
  51. package/.agy/skills/learn-second-opinion/SKILL.md +14 -0
  52. package/.agy/skills/maestro-amend/SKILL.md +11 -0
  53. package/.agy/skills/maestro-companion/SKILL.md +11 -0
  54. package/.agy/skills/maestro-composer/SKILL.md +11 -0
  55. package/.agy/skills/maestro-guard/SKILL.md +25 -0
  56. package/.agy/skills/maestro-init/SKILL.md +28 -0
  57. package/.agy/skills/maestro-overlay/SKILL.md +11 -0
  58. package/.agy/skills/maestro-player/SKILL.md +11 -0
  59. package/.agy/skills/maestro-quick/SKILL.md +29 -0
  60. package/.agy/skills/maestro-swarm-workflow/SKILL.md +25 -0
  61. package/.agy/skills/maestro-tools-execute/SKILL.md +29 -0
  62. package/.agy/skills/maestro-tools-register/SKILL.md +29 -0
  63. package/.agy/skills/maestro-ui-codify/SKILL.md +11 -0
  64. package/.agy/skills/maestro-universal-workflow/SKILL.md +59 -0
  65. package/.agy/skills/maestro-update/SKILL.md +38 -0
  66. package/.agy/skills/manage-codebase-rebuild/SKILL.md +29 -0
  67. package/.agy/skills/manage-drift-realign/SKILL.md +12 -0
  68. package/.agy/skills/manage-harvest/SKILL.md +30 -6
  69. package/.agy/skills/manage-issue/SKILL.md +23 -0
  70. package/.agy/skills/manage-issue-discover/SKILL.md +28 -0
  71. package/.agy/skills/manage-kg-extractors/SKILL.md +27 -1
  72. package/.agy/skills/manage-knowhow/SKILL.md +26 -0
  73. package/.agy/skills/manage-knowhow-capture/SKILL.md +24 -0
  74. package/.agy/skills/manage-knowledge-audit/SKILL.md +13 -0
  75. package/.agy/skills/manage-status/SKILL.md +22 -0
  76. package/.agy/skills/manage-wiki/SKILL.md +28 -0
  77. package/.agy/skills/odyssey-improve/SKILL.md +50 -0
  78. package/.agy/skills/odyssey-planex/SKILL.md +46 -0
  79. package/.agy/skills/odyssey-review-test-fix/SKILL.md +50 -0
  80. package/.agy/skills/odyssey-ui/SKILL.md +50 -0
  81. package/.agy/skills/quality-auto-test/SKILL.md +12 -0
  82. package/.agy/skills/quality-debug/SKILL.md +11 -0
  83. package/.agy/skills/quality-refactor/SKILL.md +11 -0
  84. package/.agy/skills/quality-retrospective/SKILL.md +11 -0
  85. package/.agy/skills/quality-review/SKILL.md +11 -0
  86. package/.agy/skills/quality-sync/SKILL.md +10 -0
  87. package/.agy/skills/quality-test/SKILL.md +12 -0
  88. package/.agy/skills/security-audit/SKILL.md +11 -0
  89. package/.agy/skills/spec-add/SKILL.md +27 -0
  90. package/.agy/skills/spec-load/SKILL.md +25 -0
  91. package/.agy/skills/spec-remove/SKILL.md +26 -0
  92. package/.agy/skills/spec-setup/SKILL.md +30 -0
  93. package/.claude/commands/domain-add.md +9 -0
  94. package/.claude/commands/learn-decompose.md +12 -0
  95. package/.claude/commands/learn-follow.md +41 -0
  96. package/.claude/commands/learn-investigate.md +14 -0
  97. package/.claude/commands/learn-second-opinion.md +14 -0
  98. package/.claude/commands/maestro-amend.md +11 -0
  99. package/.claude/commands/maestro-companion.md +11 -0
  100. package/.claude/commands/maestro-composer.md +11 -0
  101. package/.claude/commands/maestro-guard.md +25 -0
  102. package/.claude/commands/maestro-init.md +28 -0
  103. package/.claude/commands/maestro-overlay.md +11 -0
  104. package/.claude/commands/maestro-player.md +11 -0
  105. package/.claude/commands/maestro-quick.md +29 -0
  106. package/.claude/commands/maestro-swarm-workflow.md +25 -0
  107. package/.claude/commands/maestro-tools-execute.md +29 -0
  108. package/.claude/commands/maestro-tools-register.md +29 -0
  109. package/.claude/commands/maestro-ui-codify.md +11 -0
  110. package/.claude/commands/maestro-universal-workflow.md +59 -0
  111. package/.claude/commands/maestro-update.md +38 -0
  112. package/.claude/commands/manage-codebase-rebuild.md +29 -0
  113. package/.claude/commands/manage-drift-realign.md +12 -0
  114. package/.claude/commands/manage-harvest.md +30 -6
  115. package/.claude/commands/manage-issue-discover.md +28 -0
  116. package/.claude/commands/manage-issue.md +23 -0
  117. package/.claude/commands/manage-kg-extractors.md +27 -1
  118. package/.claude/commands/manage-knowhow-capture.md +24 -0
  119. package/.claude/commands/manage-knowhow.md +26 -0
  120. package/.claude/commands/manage-knowledge-audit.md +13 -0
  121. package/.claude/commands/manage-status.md +22 -0
  122. package/.claude/commands/manage-wiki.md +28 -0
  123. package/.claude/commands/odyssey-improve.md +50 -0
  124. package/.claude/commands/odyssey-planex.md +46 -0
  125. package/.claude/commands/odyssey-review-test-fix.md +50 -0
  126. package/.claude/commands/odyssey-ui.md +50 -0
  127. package/.claude/commands/quality-auto-test.md +12 -0
  128. package/.claude/commands/quality-debug.md +11 -0
  129. package/.claude/commands/quality-refactor.md +11 -0
  130. package/.claude/commands/quality-retrospective.md +11 -0
  131. package/.claude/commands/quality-review.md +11 -0
  132. package/.claude/commands/quality-sync.md +10 -0
  133. package/.claude/commands/quality-test.md +12 -0
  134. package/.claude/commands/security-audit.md +11 -0
  135. package/.claude/commands/spec-add.md +27 -0
  136. package/.claude/commands/spec-load.md +25 -0
  137. package/.claude/commands/spec-remove.md +26 -0
  138. package/.claude/commands/spec-setup.md +30 -0
  139. package/.codex/skills/codify-to-knowhow/SKILL.md +2 -0
  140. package/.codex/skills/domain-add/SKILL.md +26 -0
  141. package/.codex/skills/domain-discover/SKILL.md +46 -0
  142. package/.codex/skills/domain-list/SKILL.md +29 -0
  143. package/.codex/skills/learn-decompose/SKILL.md +2 -0
  144. package/.codex/skills/learn-follow/SKILL.md +34 -0
  145. package/.codex/skills/learn-investigate/SKILL.md +33 -0
  146. package/.codex/skills/learn-retro/SKILL.md +33 -0
  147. package/.codex/skills/learn-second-opinion/SKILL.md +30 -0
  148. package/.codex/skills/maestro-amend/SKILL.md +11 -0
  149. package/.codex/skills/maestro-companion/SKILL.md +11 -0
  150. package/.codex/skills/maestro-composer/SKILL.md +11 -0
  151. package/.codex/skills/maestro-guard/SKILL.md +25 -0
  152. package/.codex/skills/maestro-help/SKILL.md +2 -0
  153. package/.codex/skills/maestro-init/SKILL.md +16 -0
  154. package/.codex/skills/maestro-learn/SKILL.md +2 -0
  155. package/.codex/skills/maestro-overlay/SKILL.md +1 -0
  156. package/.codex/skills/maestro-player/SKILL.md +2 -0
  157. package/.codex/skills/maestro-quick/SKILL.md +17 -0
  158. package/.codex/skills/maestro-tools-execute/SKILL.md +31 -0
  159. package/.codex/skills/maestro-tools-register/SKILL.md +29 -0
  160. package/.codex/skills/maestro-ui-codify/SKILL.md +2 -0
  161. package/.codex/skills/maestro-update/SKILL.md +38 -0
  162. package/.codex/skills/manage-codebase-rebuild/SKILL.md +2 -0
  163. package/.codex/skills/manage-codebase-refresh/SKILL.md +11 -0
  164. package/.codex/skills/manage-drift-realign/SKILL.md +2 -0
  165. package/.codex/skills/manage-harvest/SKILL.md +30 -8
  166. package/.codex/skills/manage-issue/SKILL.md +24 -0
  167. package/.codex/skills/manage-issue-discover/SKILL.md +2 -0
  168. package/.codex/skills/manage-knowhow/SKILL.md +26 -0
  169. package/.codex/skills/manage-knowhow-capture/SKILL.md +23 -0
  170. package/.codex/skills/manage-learn/SKILL.md +2 -0
  171. package/.codex/skills/manage-status/SKILL.md +22 -0
  172. package/.codex/skills/manage-wiki/SKILL.md +28 -0
  173. package/.codex/skills/odyssey-debug/SKILL.md +44 -0
  174. package/.codex/skills/odyssey-improve/SKILL.md +49 -0
  175. package/.codex/skills/odyssey-planex/SKILL.md +44 -0
  176. package/.codex/skills/odyssey-review-test-fix/SKILL.md +48 -0
  177. package/.codex/skills/odyssey-ui/SKILL.md +49 -0
  178. package/.codex/skills/quality-auto-test/SKILL.md +2 -0
  179. package/.codex/skills/quality-debug/SKILL.md +2 -0
  180. package/.codex/skills/quality-refactor/SKILL.md +2 -0
  181. package/.codex/skills/quality-retrospective/SKILL.md +2 -0
  182. package/.codex/skills/quality-review/SKILL.md +2 -0
  183. package/.codex/skills/quality-sync/SKILL.md +24 -0
  184. package/.codex/skills/quality-test/SKILL.md +2 -0
  185. package/.codex/skills/security-audit/SKILL.md +30 -0
  186. package/.codex/skills/spec-add/SKILL.md +28 -0
  187. package/.codex/skills/spec-load/SKILL.md +26 -0
  188. package/.codex/skills/spec-map/SKILL.md +1 -0
  189. package/.codex/skills/spec-remove/SKILL.md +28 -0
  190. package/.codex/skills/spec-setup/SKILL.md +28 -0
  191. package/.codex/skills/wiki-connect/SKILL.md +11 -0
  192. package/.codex/skills/wiki-digest/SKILL.md +11 -0
  193. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js +3 -1
  194. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js.map +1 -1
  195. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +5 -0
  196. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +25 -1
  197. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  198. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +4 -0
  199. package/dashboard/dist-server/src/graph/kg/db/queries.js +35 -19
  200. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  201. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +19 -11
  202. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  203. package/dist/src/agents/api-explore/config.d.ts +11 -1
  204. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  205. package/dist/src/agents/api-explore/config.js +17 -16
  206. package/dist/src/agents/api-explore/config.js.map +1 -1
  207. package/dist/src/agents/api-explore/index.js +4 -4
  208. package/dist/src/agents/api-explore/index.js.map +1 -1
  209. package/dist/src/agents/api-explore/llm.d.ts +2 -0
  210. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  211. package/dist/src/agents/api-explore/llm.js +16 -4
  212. package/dist/src/agents/api-explore/llm.js.map +1 -1
  213. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  214. package/dist/src/agents/api-explore/runner.js +16 -12
  215. package/dist/src/agents/api-explore/runner.js.map +1 -1
  216. package/dist/src/commands/explore.d.ts.map +1 -1
  217. package/dist/src/commands/explore.js +19 -2
  218. package/dist/src/commands/explore.js.map +1 -1
  219. package/dist/src/commands/install.js +7 -28
  220. package/dist/src/commands/install.js.map +1 -1
  221. package/dist/src/commands/moa.d.ts.map +1 -1
  222. package/dist/src/commands/moa.js +17 -2
  223. package/dist/src/commands/moa.js.map +1 -1
  224. package/dist/src/commands/search.d.ts.map +1 -1
  225. package/dist/src/commands/search.js +2 -0
  226. package/dist/src/commands/search.js.map +1 -1
  227. package/dist/src/graph/kg/db/queries.d.ts +4 -0
  228. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  229. package/dist/src/graph/kg/db/queries.js +35 -19
  230. package/dist/src/graph/kg/db/queries.js.map +1 -1
  231. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  232. package/dist/src/graph/kg/extraction/orchestrator.js +19 -11
  233. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  234. package/dist/src/hooks/plugins/explore-plugin.d.ts.map +1 -1
  235. package/dist/src/hooks/plugins/explore-plugin.js +3 -2
  236. package/dist/src/hooks/plugins/explore-plugin.js.map +1 -1
  237. package/package.json +1 -1
@@ -36,12 +36,35 @@ $ARGUMENTS -- subcommand + options. Parse first token as subcommand.
36
36
  **State files:**
37
37
  - `.workflow/issues/issues.jsonl` -- active issues (one JSON per line)
38
38
  - `.workflow/issues/issue-history.jsonl` -- archived/closed issues
39
+
40
+ **Output boundary**: ALL file writes MUST target `.workflow/issues/issues.jsonl`, `.workflow/issues/issue-history.jsonl`, or `.workflow/issues/` directory only. NEVER modify source code or files outside these paths.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Schema compliance** — every issue record MUST conform to the canonical issue.json template schema
45
+ 2. **ID uniqueness** — issue IDs (ISS-XXXXXXXX-NNN) MUST be unique across issues.jsonl and issue-history.jsonl
46
+ 3. **Close moves to history** — `close` subcommand MUST move the record from issues.jsonl to issue-history.jsonl, NEVER delete without archiving
47
+ 4. **Bidirectional links** — `link` subcommand MUST create references in both the issue and the linked task
48
+ 5. **Confirmation on destructive ops** — `close` and bulk `update` MUST require user confirmation unless `-y` flag is set
49
+ 6. **Append-only audit** — NEVER overwrite existing issue records; updates MUST preserve all prior fields and add `updated_at` timestamp
50
+ </invariants>
51
+
41
52
  <execution>
42
53
  Parse subcommand from first token of $ARGUMENTS.
43
54
  Follow '~/.maestro/workflows/issue.md' completely.
44
55
 
56
+ ### Phase Gates (MANDATORY, BLOCKING)
57
+
58
+ **GATE 1: Parse → Execute** (Subcommand routing)
59
+ - REQUIRED: Subcommand parsed and validated against valid set (create/list/status/update/close/link).
60
+ - REQUIRED: `.workflow/issues/` directory exists (auto-create with empty issues.jsonl if missing).
61
+ - BLOCKED if E_NO_SUBCOMMAND or E_INVALID_SUBCOMMAND.
62
+
63
+ **GATE 2: Execute → Write** (For mutating subcommands: create/update/close/link)
64
+ - REQUIRED: Issue data validated against issue.json template schema.
65
+ - REQUIRED: For `close`: resolution text provided.
66
+ - REQUIRED: For `link`: target task ID resolved and exists.
67
+ - BLOCKED if schema validation fails or target references unresolvable.
45
68
  </execution>
46
69
 
47
70
  <completion>
@@ -47,8 +47,19 @@ $ARGUMENTS -- optional. Parse first token to determine mode.
47
47
  ### Pre-load specs
48
48
  1. **Debug specs**: Run `maestro load --type spec --category debug` to load known antipatterns, root causes, and gotchas. Informs discovery perspectives with prior findings.
49
49
  2. Optional — proceed without if unavailable.
50
+
51
+ **Output boundary**: ALL file writes MUST target `.workflow/issues/issues.jsonl` or `.workflow/issues/discoveries/{SESSION_ID}/` only. NEVER modify source code or files outside these paths.
50
52
  </context>
51
53
 
54
+ <invariants>
55
+ 1. **Read-only analysis** — discovery agents MUST NOT modify source code; only `.workflow/issues/` is writable
56
+ 2. **Source tagging** — MUST set `source: "discover"` on every issues.jsonl row so concurrent writers (e.g. `manage-harvest`) can be distinguished and deduplicated
57
+ 3. **Dedup before write** — MUST check existing issues.jsonl for duplicates before appending new findings
58
+ 4. **Session traceability** — every discovery run MUST produce a session directory under `.workflow/issues/discoveries/` with full agent outputs
59
+ 5. **Schema compliance** — every issue row MUST conform to the canonical issue.json template schema
60
+ 6. **Idempotent re-run** — repeated execution with same scope and prompt MUST NOT create duplicate issues
61
+ </invariants>
62
+
52
63
  <execution>
53
64
  Determine mode from $ARGUMENTS:
54
65
  - No arguments or empty → interactive selection via ask_question
@@ -56,6 +67,23 @@ Determine mode from $ARGUMENTS:
56
67
  - First token is `by-prompt` → prompt-driven mode, remaining tokens are the user prompt
57
68
 
58
69
  Follow '~/.maestro/workflows/issue-discover.md' completely.
70
+
71
+ ### Phase Gates (MANDATORY, BLOCKING)
72
+
73
+ **GATE 1: Mode Selection → Analysis** (Steps 1-2 → Steps 3-8)
74
+ - REQUIRED: Mode correctly determined from arguments (multi-perspective or by-prompt).
75
+ - REQUIRED: `.workflow/issues/` directory exists (auto-create if missing).
76
+ - BLOCKED if E_NO_PROJECT (`.workflow/` missing) or E_EMPTY_PROMPT (by-prompt without text).
77
+
78
+ **GATE 2: Analysis → Issue Creation** (Steps 8-9 → Steps 10-11)
79
+ - REQUIRED: All perspectives analyzed (multi-perspective) or dimensions explored (by-prompt).
80
+ - REQUIRED: Findings deduplicated against existing issues.jsonl.
81
+ - BLOCKED if E_DISCOVERY_FAILED (all agents returned no results).
82
+
83
+ **GATE 3: Issue Creation → Completion** (Steps 11-12)
84
+ - REQUIRED: Issues appended to issues.jsonl with correct schema and `source: "discover"`.
85
+ - REQUIRED: Discovery session directory created with full agent outputs.
86
+ - BLOCKED if schema validation fails on any issue record.
59
87
  </execution>
60
88
 
61
89
  <error_codes>
@@ -40,6 +40,8 @@ $ARGUMENTS -- optional flags.
40
40
 
41
41
  **Output:** `.workflow/kg/extractors.yaml` — declarative rules for PluginEngine.
42
42
 
43
+ **Output boundary**: ALL file writes MUST target `.workflow/kg/extractors.yaml` only. NEVER modify source code or files outside this path. `--scan-only` MUST NOT write any files.
44
+
43
45
  **Rule format:**
44
46
  ```yaml
45
47
  version: 1
@@ -68,6 +70,16 @@ plugins:
68
70
 
69
71
  <execution>
70
72
 
73
+ <invariants>
74
+ 1. **Read-only source code** — agents MUST only read source files for pattern discovery; NEVER modify source code
75
+ 2. **Scan-only safety** — `--scan-only` MUST stop after Phase 2 summary; NEVER write extractors.yaml
76
+ 3. **Append preservation** — `--append` MUST preserve existing rules in extractors.yaml; default (overwrite) MUST warn (W003) if file exists
77
+ 4. **Min-count threshold** — patterns with fewer occurrences than `--min-count` MUST be excluded unless explicitly overridden
78
+ 5. **User confirmation** — each pattern group MUST be confirmed/edited/skipped by user before writing (Phase 3, Step 2)
79
+ 6. **Schema compliance** — generated extractors.yaml MUST conform to version 1 PluginEngine schema with required fields (id, languages, mode, rules)
80
+ 7. **Validation mandatory** — MUST run `maestro kg index` after writing to verify new symbols are extractable
81
+ </invariants>
82
+
71
83
  ### Phase 1: Discover patterns
72
84
 
73
85
  Spawn **3 parallel agents** to scan the codebase:
@@ -80,7 +92,21 @@ Spawn **3 parallel agents** to scan the codebase:
80
92
 
81
93
  Each agent returns: `[{pattern_type, regex_evidence, file_count, sample_matches: [{file, line, code}]}]`
82
94
 
83
- **Gate:** If all 3 agents return empty results → E002 (abort). If at least 1 agent succeeds, proceed with partial results (log W001 for failed agents).
95
+ ### Phase Gates (MANDATORY, BLOCKING)
96
+
97
+ **GATE 1: Discovery → Generation** (Phase 1 → Phase 2)
98
+ - REQUIRED: At least 1 of 3 agents returned valid pattern results.
99
+ - BLOCKED if all 3 agents return empty results (E002).
100
+
101
+ **GATE 2: Generation → Write** (Phase 2 → Phase 3)
102
+ - REQUIRED: At least 1 pattern meets `--min-count` threshold.
103
+ - REQUIRED: User confirmed pattern groups via ask_question.
104
+ - BLOCKED if `--scan-only` is set — stop after summary.
105
+
106
+ **GATE 3: Write → Validation** (Phase 3 → KG Index)
107
+ - REQUIRED: extractors.yaml written with valid schema.
108
+ - REQUIRED: `maestro kg index` executed to verify extraction.
109
+ - BLOCKED if schema validation fails on generated YAML.
84
110
 
85
111
  ### Phase 2: Generate rules
86
112
 
@@ -23,6 +23,8 @@ Arguments: $ARGUMENTS
23
23
 
24
24
  Dual store architecture (paths, formats, index) defined in workflow knowhow.md.
25
25
 
26
+ **Output boundary**: Workflow store writes MUST target `.workflow/knowhow/` only. System store writes MUST target `~/.claude/projects/*/memory/` only. NEVER modify source code or files outside these paths.
27
+
26
28
  **Subcommands:**
27
29
  - `list` — List entries from both stores (default if no arguments)
28
30
  - `search <query>` — Full-text search across both stores
@@ -43,8 +45,32 @@ Dual store architecture (paths, formats, index) defined in workflow knowhow.md.
43
45
 
44
46
  <execution>
45
47
  Follow '~/.maestro/workflows/knowhow.md' Part A (KnowHow Management) completely.
48
+
49
+ ### Phase Gates (MANDATORY, BLOCKING)
50
+
51
+ **GATE 1: Parse → Execute** (Subcommand routing)
52
+ - REQUIRED: Subcommand parsed from first token (list/search/view/edit/delete/prune).
53
+ - REQUIRED: Both store paths resolved (workflow + system).
54
+ - BLOCKED if E001 (no memory stores found) or invalid subcommand.
55
+
56
+ **GATE 2: Execute → Mutate** (For destructive subcommands: delete/prune/edit)
57
+ - REQUIRED: Target entry/file resolved and exists (E002 if not found).
58
+ - REQUIRED: MEMORY.md protected from deletion (E004 — use `edit` instead).
59
+ - REQUIRED: For `prune`: at least one filter provided (E003).
60
+ - REQUIRED: User confirmation before delete/prune unless `--confirm` flag set.
61
+ - BLOCKED if target unresolvable or confirmation denied.
46
62
  </execution>
47
63
 
64
+ <invariants>
65
+ 1. **MEMORY.md protected** — NEVER delete MEMORY.md; only editable via `edit` subcommand
66
+ 2. **MEMORY.md line limit** — MUST warn (W003) when MEMORY.md exceeds 200 lines; content beyond 200 lines will be truncated at load
67
+ 3. **Confirmation on destructive ops** — `delete` and `prune` MUST require user confirmation unless `--confirm` flag is set
68
+ 4. **Store isolation** — `prune` operates on workflow store only; NEVER prune system memory files
69
+ 5. **Reference integrity** — `delete` MUST check for references from other entries before removing; warn if orphaned references would result
70
+ 6. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview destructive operations only
71
+ 7. **Index consistency** — after delete/prune, workflow index MUST be updated to reflect removals
72
+ </invariants>
73
+
48
74
  <error_codes>
49
75
  | Code | Severity | Description | Stage |
50
76
  |------|----------|-------------|-------|
@@ -43,11 +43,35 @@ $ARGUMENTS — type token + description + optional flags.
43
43
  | No args | — | — | ask_question (10 options) |
44
44
 
45
45
  **Output**: `.workflow/knowhow/{PREFIX}-{YYYYMMDD}-{slug}.md` with YAML frontmatter (title, description, type, category, created, tags, source, lang, status)
46
+
47
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` only. NEVER modify source code or files outside this path.
46
48
  </context>
47
49
 
50
+ <invariants>
51
+ 1. **Description required** — every entry MUST have a `description` field in frontmatter (under 120 chars) for search indexing
52
+ 2. **Tags language match** — tags MUST match content language (Chinese content → Chinese tags, English → English)
53
+ 3. **ID uniqueness** — generated file names ({PREFIX}-{YYYYMMDD}-{slug}.md) MUST be unique; NEVER overwrite existing entries
54
+ 4. **Frontmatter completeness** — YAML frontmatter MUST include: title, description, type, category, created, tags, status
55
+ 5. **Type-specific validation** — each type MUST populate all its required fields before writing (template needs code block, recipe needs steps, etc.)
56
+ 6. **Idempotent naming** — same content captured twice MUST produce same slug, enabling dedup detection
57
+ </invariants>
58
+
48
59
  <execution>
49
60
  Follow '~/.maestro/workflows/knowhow.md' completely.
50
61
 
62
+ ### Phase Gates (MANDATORY, BLOCKING)
63
+
64
+ **GATE 1: Type Detection → Content Collection** (Type routing → Content extraction)
65
+ - REQUIRED: Type detected from first token or selected via ask_question.
66
+ - REQUIRED: Type maps to a valid prefix (KNW-/TPL-/RCP-/REF-/DCS-/TIP-/AST-/BLP-/DOC-/INS-).
67
+ - BLOCKED if type unresolvable after interactive prompt.
68
+
69
+ **GATE 2: Content Collection → Write** (Content extraction → File write)
70
+ - REQUIRED: All type-specific required fields populated (e.g., template needs code block, recipe needs steps).
71
+ - REQUIRED: `description` field generated or provided (under 120 chars).
72
+ - REQUIRED: Tags generated in correct language matching content.
73
+ - BLOCKED if required fields missing after user prompt (E002/E003).
74
+
51
75
  **Description rule**: Every entry MUST have a `description` field in frontmatter — a one-line summary (under 120 chars) for search results. WikiIndexer uses priority chain: `description > content[:240]`. Use `--description` flag value if provided; otherwise auto-generate from content.
52
76
 
53
77
  **Tags language rule**: Tags must match content language. Chinese content → Chinese tags (如 `认证,令牌,刷新`). English content → English tags. Mixed → bilingual.
@@ -37,8 +37,21 @@ Arguments: $ARGUMENTS
37
37
  **互斥规则:** `--interactive`、`--mark`、`--delete`、`--purge` 四选一,同时传入多个 → E006。
38
38
 
39
39
  Flag 全集、scope 对应的扫描路径、Stage 步骤、检测算法定义在 workflow knowledge-audit.md。
40
+
41
+ **Output boundary**: ALL file writes MUST target `.workflow/specs/`, `.workflow/knowhow/`, `.workflow/.trash/knowledge-audit-{timestamp}/`, `.workflow/issues/`, or audit report files (`audit-report-*.md`, `audit-log.jsonl`). NEVER modify source code files.
40
42
  </context>
41
43
 
44
+ <invariants>
45
+ 1. **Code-as-Truth** — 代码是唯一真理源;spec/knowhow 声明 MUST 与代码实际行为一致;每个 finding 的 evidence MUST 包含代码引用(文件:行号)
46
+ 2. **Backup before mutate** — MUST create backup tarball in `.workflow/.trash/` before any file modification (E005 if backup fails)
47
+ 3. **Deprecate over delete** — 文本存储首选 `status="deprecated"` 保留历史;NEVER 物理删除 spec/knowhow 文件
48
+ 4. **Purge 仅 artifact** — `--purge` MUST NOT 作用于 spec/knowhow scope (E004)
49
+ 5. **Rescue before delete** — 未 harvest 的 artifact 删除前 MUST 强制提示先跑 `/manage-harvest` (W002)
50
+ 6. **Conflict marker sync** — deprecate/delete 执行时如果目标条目有 conflict-marker,MUST 同步调用 `maestro spec conflict clear` 清除标记
51
+ 7. **Mutual exclusion** — `--interactive`/`--mark`/`--delete`/`--purge` 四选一;同时传入多个 MUST trigger E006
52
+ 8. **Dry-run safety** — `--dry-run` MUST NOT write any files; `--purge` 与 `--dry-run` 互斥 (E003)
53
+ </invariants>
54
+
42
55
  <execution>
43
56
  Follow `~/.maestro/workflows/knowledge-audit.md` Stages 1-8 in order.
44
57
 
@@ -23,12 +23,34 @@ $ARGUMENTS (no arguments required)
23
23
  - `.workflow/roadmap.md` -- milestone and phase structure
24
24
  - `.workflow/scratch/*/plan.json` -- plan metadata (via artifact registry paths)
25
25
  - `.workflow/scratch/*/.task/TASK-*.json` -- individual task statuses
26
+
27
+ **Output boundary**: Read-only command. MUST NOT write any files. All output is displayed to the user via text.
26
28
  </context>
27
29
 
30
+ <invariants>
31
+ 1. **Read-only** — MUST NOT write or modify any files; this is a pure display command
32
+ 2. **Graceful degradation** — missing roadmap.md, plan.json, or task files MUST NOT cause failure; display available data and note missing sections
33
+ 3. **State accuracy** — progress percentages MUST be calculated from actual task statuses, NEVER estimated or inferred
34
+ 4. **Wiki health optional** — wiki health score display MUST degrade gracefully if wiki is unavailable
35
+ 5. **Complete dashboard** — MUST include: milestone progress, phase status, task counts, active work, and next-step suggestions
36
+ </invariants>
37
+
28
38
  <execution>
29
39
  Follow '~/.maestro/workflows/status.md' completely.
30
40
 
31
41
  Next-step decision table defined in workflow status.md Step 5.
42
+
43
+ ### Phase Gates (MANDATORY, BLOCKING)
44
+
45
+ **GATE 1: Load → Render** (State loading → Dashboard display)
46
+ - REQUIRED: `.workflow/` exists and `state.json` is readable (E001/E002 if not).
47
+ - REQUIRED: Project state loaded with milestone and artifact registry.
48
+ - BLOCKED if state.json missing or corrupt (E002).
49
+
50
+ **GATE 2: Render → Route** (Dashboard → Next-step suggestions)
51
+ - REQUIRED: Per-phase progress calculated from actual task statuses.
52
+ - REQUIRED: Dashboard rendered with progress bars and status table.
53
+ - BLOCKED if state parsing fails entirely.
32
54
  </execution>
33
55
 
34
56
  <error_codes>
@@ -42,13 +42,41 @@ $ARGUMENTS — subcommand and optional flags.
42
42
  - `--format brief|full` — (digest) Output format
43
43
  - `--recent N` — (digest) Scope to N most recent entries
44
44
  - `--create-issues` — (digest) Create issues for identified knowledge gaps
45
+
46
+ **Output boundary**: File writes MUST target `.workflow/wiki/`, `.workflow/knowhow/`, or `.workflow/issues/issues.jsonl` (when `--create-issues`) only. NEVER modify source code or files outside these paths. `--dry-run` overrides `--fix` — no writes when both are set.
45
47
  </context>
46
48
 
49
+ <invariants>
50
+ 1. **Dry-run precedence** — `--dry-run` MUST override `--fix` when both are passed; preview only, no writes
51
+ 2. **Read-only by default** — without `--fix` or `--create-issues`, all subcommands MUST be read-only
52
+ 3. **Confirmation on fixes** — `--fix` MUST show preview of changes before applying; auto-apply only when explicitly set
53
+ 4. **Graph integrity** — `connect` MUST NOT create circular link chains; validate graph acyclicity for parent-child relationships
54
+ 5. **Threshold enforcement** — `--min-similarity` MUST be respected; NEVER suggest connections below the threshold
55
+ 6. **Subcommand isolation** — each subcommand routes to its own workflow file; NEVER cross-execute subcommand logic
56
+ </invariants>
57
+
47
58
  <execution>
48
59
  **Subcommand routing:**
49
60
  - `health|search|cleanup|stats` → Follow `~/.maestro/workflows/wiki-manage.md` completely.
50
61
  - `connect` → Follow `~/.maestro/workflows/wiki-connect.md` completely (Stages 1-6).
51
62
  - `digest` → Follow `~/.maestro/workflows/wiki-digest.md` completely (Stages 1-8).
63
+
64
+ ### Phase Gates (MANDATORY, BLOCKING)
65
+
66
+ **GATE 1: Parse → Load** (Subcommand routing → Wiki data loading)
67
+ - REQUIRED: Subcommand parsed and validated (health/search/cleanup/stats/connect/digest).
68
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
69
+ - BLOCKED if E003 (invalid subcommand) or E001.
70
+
71
+ **GATE 2: Load → Execute** (Wiki data → Subcommand execution)
72
+ - REQUIRED: Wiki data loaded via `maestro wiki` CLI.
73
+ - REQUIRED: At least one wiki entry exists (E002 if none).
74
+ - BLOCKED if wiki data loading fails entirely.
75
+
76
+ **GATE 3: Execute → Write** (For mutating operations: cleanup --fix, connect --fix, digest --create-issues)
77
+ - REQUIRED: Preview of changes shown to user.
78
+ - REQUIRED: `--dry-run` NOT set (overrides `--fix`).
79
+ - BLOCKED if preview generation fails or user declines.
52
80
  </execution>
53
81
 
54
82
  <error_codes>
@@ -52,6 +52,8 @@ $ARGUMENTS
52
52
  **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
53
53
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
54
54
 
55
+ **Output boundary**: ALL file writes MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write artifacts outside these paths.
56
+
55
57
  **session.json — improve-specific fields:**
56
58
  ```json
57
59
  { "target": "", "dimensions": [], "baseline_metrics": {},
@@ -105,6 +107,54 @@ All invariants (evidence append-only, session-as-state, phase goal tracking, aut
105
107
  Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
106
108
  </self_iteration>
107
109
 
110
+ <execution>
111
+ Follow base execution discipline completely. Actions defined in state_machine below.
112
+
113
+ ### Phase Gates (MANDATORY, BLOCKING)
114
+
115
+ **GATE 1: INTAKE → SURVEY**
116
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized with baseline_metrics.
117
+ - REQUIRED: phase_goals[] derived from flags.
118
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
119
+
120
+ **GATE 2: SURVEY → AUDIT**
121
+ - REQUIRED: Current state survey completed — dependency audit, complexity scan, test coverage map, error handling scan.
122
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
123
+ - BLOCKED if: survey incomplete — all 4 scan types must be attempted.
124
+
125
+ **GATE 3: AUDIT → DIAGNOSE**
126
+ - REQUIRED: All dimension agents completed (or --dimensions subset), findings merged with severity classification.
127
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
128
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
129
+
130
+ **GATE 4: DIAGNOSE → FIX**
131
+ - REQUIRED: Root causes identified for all critical/high findings with evidence.
132
+ - REQUIRED: diagnoses[] written, understanding.md §4 updated, G3 marked done.
133
+ - BLOCKED if: hypotheses failed 3 times without escalation decision (A_ESCALATE_DIAGNOSIS).
134
+
135
+ **GATE 5: FIX → VERIFY**
136
+ - REQUIRED: ALL findings within fix_threshold fixed by severity tier (critical → high → medium → low).
137
+ - REQUIRED: Per-fix evidence phase=fix logged.
138
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
139
+
140
+ **GATE 6: VERIFY → GENERALIZE**
141
+ - REQUIRED: Tests pass, metrics re-captured, before/after comparison logged.
142
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
143
+ - BLOCKED if: needs_rework → route back to S_FIX.
144
+
145
+ **GATE 7: GENERALIZE → DISCOVER**
146
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
147
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
148
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
149
+
150
+ **GATE 8: DISCOVER → RECORD**
151
+ - REQUIRED: All hits triaged with per-item classification and reason.
152
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
153
+ - REQUIRED: G6 marked done.
154
+ - BLOCKED if: unclassified hits remain.
155
+
156
+ </execution>
157
+
108
158
  <state_machine>
109
159
 
110
160
  <states>
@@ -57,6 +57,8 @@ $ARGUMENTS
57
57
  **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
58
58
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
59
59
 
60
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_EXECUTE and S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
61
+
60
62
  **session.json — planex-specific fields:**
61
63
  ```json
62
64
  { "requirement": "",
@@ -108,6 +110,50 @@ Base execution_discipline #1-5.
108
110
  Applies to: **S_PLAN, S_VERIFY, S_GENERALIZE**. Logic in base.
109
111
  </self_iteration>
110
112
 
113
+ <execution>
114
+ Follow base execution discipline completely. Actions defined in state_machine below.
115
+
116
+ ### Phase Gates (MANDATORY, BLOCKING)
117
+
118
+ **GATE 1: INTAKE → PLAN**
119
+ - REQUIRED: Requirement parsed, >=1 acceptance criterion defined with verify_method assigned.
120
+ - REQUIRED: session.json initialized, understanding.md §1 written, G1 marked done.
121
+ - BLOCKED if: no requirement provided (E001) or zero criteria derived (W001).
122
+
123
+ **GATE 2: PLAN → EXECUTE**
124
+ - REQUIRED: Plan tasks decomposed with criteria_refs mapping each task to acceptance criteria.
125
+ - REQUIRED: session.json.plan populated, understanding.md §2 updated, G2 marked done.
126
+ - BLOCKED if: plan has zero tasks or unmapped criteria.
127
+
128
+ **GATE 3: EXECUTE → VERIFY**
129
+ - REQUIRED: All plan tasks executed (or marked blocked after 3 retries per deviation rule).
130
+ - REQUIRED: execution_config confirmed, per-task evidence logged, understanding.md §3 updated, G3 marked done.
131
+ - BLOCKED if: tasks still pending execution.
132
+
133
+ **GATE 4: VERIFY → FIX / GENERALIZE**
134
+ - REQUIRED: Every acceptance criterion verified by its assigned method (test/grep/cli-review/manual).
135
+ - REQUIRED: Per-criterion evidence logged with pass/fail status and iteration count.
136
+ - BLOCKED if: verification incomplete — all criteria must be checked before routing decision.
137
+ - Route: all passed → GENERALIZE (or RECORD if skip_generalize). Some failed + iteration < max → FIX.
138
+
139
+ **GATE 5: FIX → VERIFY**
140
+ - REQUIRED: current_iteration incremented, targeted fixes applied for each failed criterion.
141
+ - REQUIRED: Fix evidence logged, understanding.md §5 updated.
142
+ - BLOCKED if: no fix attempted for failing criteria.
143
+
144
+ **GATE 6: GENERALIZE → DISCOVER**
145
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
146
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
147
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
148
+
149
+ **GATE 7: DISCOVER → RECORD**
150
+ - REQUIRED: All hits triaged with per-item classification and reason.
151
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
152
+ - REQUIRED: G6 marked done.
153
+ - BLOCKED if: unclassified hits remain.
154
+
155
+ </execution>
156
+
111
157
  <state_machine>
112
158
 
113
159
  <states>
@@ -45,6 +45,8 @@ $ARGUMENTS
45
45
  **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
46
46
  **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
47
47
 
48
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
49
+
48
50
  **session.json — review-specific fields:**
49
51
  ```json
50
52
  { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
@@ -90,6 +92,54 @@ All invariants defined in base.
90
92
  Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
91
93
  </self_iteration>
92
94
 
95
+ <execution>
96
+ Follow base execution discipline completely. Actions defined in state_machine below.
97
+
98
+ ### Phase Gates (MANDATORY, BLOCKING)
99
+
100
+ **GATE 1: INTAKE → ARCHAEOLOGY**
101
+ - REQUIRED: Target resolved to file list, SESSION_DIR created, session.json initialized.
102
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
103
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
104
+
105
+ **GATE 2: ARCHAEOLOGY → EXPLORE**
106
+ - REQUIRED: Git history analysis completed (timeline + blame agents), evidence phase=archaeology logged.
107
+ - REQUIRED: understanding.md §2 updated.
108
+ - BLOCKED if: both archaeology agents failed AND delegate failed (partial results via W003 are acceptable).
109
+
110
+ **GATE 3: EXPLORE → REVIEW**
111
+ - REQUIRED: explore.json written with call_chains/recent_changes/error_gaps/similar_patterns (or W006 skip logged).
112
+ - REQUIRED: Evidence phase=explore logged, understanding.md §3 updated, G2 marked done.
113
+ - BLOCKED if: exploration started but not completed (W006 skip is acceptable, incomplete is not).
114
+
115
+ **GATE 4: REVIEW → FIX**
116
+ - REQUIRED: All dimension agents completed, findings merged with severity classification.
117
+ - REQUIRED: review_result written to session.json, understanding.md §4 with severity matrix, G1 marked done.
118
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
119
+
120
+ **GATE 5: FIX → CONFIRM**
121
+ - REQUIRED: Current severity tier fully addressed — all findings in tier fixed or individually classified.
122
+ - REQUIRED: Per-fix evidence phase=fix logged, auto-commit per tier.
123
+ - BLOCKED if: tier incomplete — no partial tier advancement.
124
+
125
+ **GATE 6: CONFIRM → GENERALIZE**
126
+ - REQUIRED: Tests pass, remaining_actionable == 0, new findings == 0.
127
+ - REQUIRED: confirmation written, understanding.md §5 updated, G3 marked done.
128
+ - BLOCKED if: needs_rework → route back to S_FIX.
129
+
130
+ **GATE 7: GENERALIZE → DISCOVER**
131
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
132
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G4 marked done.
133
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
134
+
135
+ **GATE 8: DISCOVER → RECORD**
136
+ - REQUIRED: All hits triaged with per-item classification and reason.
137
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
138
+ - REQUIRED: G5 marked done.
139
+ - BLOCKED if: unclassified hits remain.
140
+
141
+ </execution>
142
+
93
143
  <state_machine>
94
144
 
95
145
  <states>
@@ -41,6 +41,8 @@ $ARGUMENTS
41
41
  **Session**: `.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`
42
42
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
43
43
 
44
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
45
+
44
46
  **session.json — ui-specific fields:**
45
47
  ```json
46
48
  { "target": "", "dimensions": [],
@@ -89,6 +91,54 @@ $ARGUMENTS
89
91
  Applies to: **S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE**. Logic in base.
90
92
  </self_iteration>
91
93
 
94
+ <execution>
95
+ Follow base execution discipline completely. Actions defined in state_machine below.
96
+
97
+ ### Phase Gates (MANDATORY, BLOCKING)
98
+
99
+ **GATE 1: INTAKE → SURVEY**
100
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized.
101
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
102
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
103
+
104
+ **GATE 2: SURVEY → AUDIT**
105
+ - REQUIRED: Design system inventory + current state analysis completed.
106
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
107
+ - BLOCKED if: survey incomplete — token scan and styling analysis must both be attempted.
108
+
109
+ **GATE 3: AUDIT → DIVERGE**
110
+ - REQUIRED: All 6 dimension agents completed (or --dimensions subset), findings merged with severity classification.
111
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
112
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
113
+
114
+ **GATE 4: DIVERGE → FIX**
115
+ - REQUIRED: Both parallel agents (Polish + Delight) completed, ideas consolidated with audit findings.
116
+ - REQUIRED: diverge_result written, understanding.md §4 updated, G3 marked done.
117
+ - BLOCKED if: divergent exploration not attempted.
118
+
119
+ **GATE 5: FIX → VERIFY**
120
+ - REQUIRED: ALL findings/ideas within fix_threshold fixed by priority tier.
121
+ - REQUIRED: Per-fix evidence phase=fix logged.
122
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
123
+
124
+ **GATE 6: VERIFY → GENERALIZE**
125
+ - REQUIRED: Tests pass (lint, unit, visual regression), delegate verification completed.
126
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
127
+ - BLOCKED if: needs_rework → route back to S_FIX.
128
+
129
+ **GATE 7: GENERALIZE → DISCOVER**
130
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
131
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
132
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
133
+
134
+ **GATE 8: DISCOVER → RECORD**
135
+ - REQUIRED: All hits triaged with per-item classification and reason.
136
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
137
+ - REQUIRED: G6 marked done.
138
+ - BLOCKED if: unclassified hits remain.
139
+
140
+ </execution>
141
+
92
142
  <state_machine>
93
143
 
94
144
  <states>
@@ -51,8 +51,20 @@ Flags, artifact context resolution, and output formats defined in workflow auto-
51
51
  - Browse: `maestro search --category test`
52
52
  - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
53
53
  4. All are optional — proceed without if unavailable.
54
+
55
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-auto-test-P{N}-{slug}/` or `.workflow/state.json` only. Source code modifications are limited to test files generated by this command. NEVER modify existing production source code.
54
56
  </context>
55
57
 
58
+ <invariants>
59
+ 1. **Test code isolation** — generated tests MUST be written to test directories following existing project conventions. NEVER modify production source code to make tests pass.
60
+ 2. **RED-GREEN integrity** — tests MUST be written to fail first (RED), then verified to pass against implementation (GREEN). NEVER write tests that pass trivially or assert nothing.
61
+ 3. **Layer ordering is strict** — L0→L3 execution is sequential and fail-fast. NEVER skip a layer or run L2 before L1 passes.
62
+ 4. **Existing tests are sacred** — NEVER modify, delete, or overwrite existing test files. New tests are additive only.
63
+ 5. **Convergence requires evidence** — pass rate and confidence score MUST be computed from actual execution results. NEVER infer or estimate pass rates without running tests.
64
+ 6. **Iteration has bounds** — outer iteration MUST NOT exceed `--max-iter` (default 5). Inner test_defect fix MUST NOT exceed 3 attempts per scenario before escalating.
65
+ 7. **Traceability is mandatory for spec source** — when route=spec, every test scenario MUST trace back to a REQ-*.md requirement. Untraceable tests are flagged.
66
+ </invariants>
67
+
56
68
  <execution>
57
69
  Follow '~/.maestro/workflows/auto-test.md' completely.
58
70
 
@@ -50,8 +50,19 @@ Each artifact's type determines its outputs at `.workflow/{a.path}/`:
50
50
  - Role knowledge: `maestro search --category debug` → select relevant → `maestro load --type knowhow --id`
51
51
 
52
52
  **Output**: `DEBUG_DIR = .workflow/scratch/{YYYYMMDD}-debug-P{N}-{slug}/` (P{N} = phase number when phase-scoped; omit for standalone). Output directory rules defined in workflow debug.md Step 4.
53
+
54
+ **Output boundary**: ALL file writes MUST target `DEBUG_DIR` or `.workflow/state.json` only. NEVER modify source code, test files, or other artifacts outside these paths during investigation.
53
55
  </context>
54
56
 
57
+ <invariants>
58
+ 1. **Investigation is read-only on source** — debug MUST NOT modify source code, test files, or execution artifacts. Diagnosis produces understanding.md, evidence.ndjson, and reports only.
59
+ 2. **Root cause requires reproduction** — NEVER declare a root cause confirmed without evidence (code trace, log entry, or reproduction steps). Hypothesis without evidence stays "suspected".
60
+ 3. **Evidence is append-only** — evidence.ndjson entries MUST only be appended, NEVER modified or deleted. Each entry is an immutable observation.
61
+ 4. **Confidence is multi-factor** — root cause confidence MUST use the multi-factor scoring model (Step 7.0). NEVER use bare high/medium/low without dimensional breakdown.
62
+ 5. **Prior investigations are consulted** — when related debug artifacts exist, check understanding.md for prior root causes. NEVER re-investigate an already-confirmed root cause without new symptoms.
63
+ 6. **Fix direction is not fix execution** — debug produces `fix_direction` and `affected_files` but NEVER applies fixes. Fix execution belongs to plan→execute cycle.
64
+ </invariants>
65
+
55
66
  <execution>
56
67
  Follow '~/.maestro/workflows/debug.md' completely.
57
68
 
@@ -38,8 +38,19 @@ If not provided, prompt user for scope.
38
38
  - Browse: `maestro search --category coding`
39
39
  - Identify task-relevant entries, then load: `maestro load --type knowhow --id <id1> [id2...]`
40
40
  4. All are optional — proceed without if unavailable.
41
+
42
+ **Output boundary**: Refactoring modifies source files within the declared scope only. Ancillary outputs (reflection-log.md) MUST target `.workflow/scratch/{YYYYMMDD}-refactor-{slug}/`. NEVER modify files outside the confirmed scope without re-confirmation.
41
43
  </context>
42
44
 
45
+ <invariants>
46
+ 1. **Plan before change** — NEVER apply refactoring changes without a confirmed plan. Every modification traces to a plan item.
47
+ 2. **Behavioral equivalence** — refactoring MUST preserve existing behavior. All tests MUST pass after each individual change, not just at the end.
48
+ 3. **Scope is locked after confirmation** — once the user confirms the refactoring plan, do NOT expand scope to include additional files or changes without re-confirmation.
49
+ 4. **Incremental verification** — each discrete refactoring step MUST be verified (tests run) before proceeding to the next. NEVER batch multiple unrelated changes into a single verification.
50
+ 5. **No feature creep** — refactoring MUST NOT add new functionality, change APIs, or alter public interfaces. If a beneficial API change is discovered, log it as a recommendation, do NOT apply it.
51
+ 6. **Rollback safety** — if any test fails after a refactoring step, revert that specific change before attempting alternatives. NEVER proceed with failing tests.
52
+ </invariants>
53
+
43
54
  <execution>
44
55
  Follow '~/.maestro/workflows/refactor.md' completely.
45
56
 
@@ -40,8 +40,19 @@ Arguments: $ARGUMENTS
40
40
  - `--lens <name>` — Restrict to specific lens (technical|process|quality|decision); default: all four
41
41
 
42
42
  Modes (scan/single/range/all) and storage paths defined in workflow retrospective.md Argument Shape and Stages 1-7.
43
+
44
+ **Output boundary**: ALL file writes MUST target the phase's retrospective directory (`.workflow/scratch/{YYYYMMDD}-retrospective-P{N}/`), `.workflow/state.json`, `.workflow/issues.jsonl`, or `.workflow/specs/` (append-only). NEVER modify source code, verification.json, review.json, plan.json, or other existing artifacts.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Source artifacts are read-only** — NEVER modify verification.json, review.json, plan.json, or any execution artifact. Retrospective reads these for analysis only.
49
+ 2. **Stable insight IDs** — `INS-{8hex}` MUST be deterministic from `hash(phase_num + lens + title)`. Re-runs MUST NOT create duplicate insights.
50
+ 3. **Routing requires confirmation** — unless `-y` flag is set, every external write (issues.jsonl, spec entry, knowhow capture) MUST be confirmed by user before execution.
51
+ 4. **Lens independence** — each lens agent (technical/process/quality/decision) operates independently. One lens's findings MUST NOT suppress or override another's.
52
+ 5. **Append-only for specs** — learnings.md entries are appended as `<spec-entry>` blocks. NEVER overwrite or restructure existing entries.
53
+ 6. **Archive before overwrite** — if retrospective.json already exists for a phase, the existing file MUST be archived before writing a new version.
54
+ </invariants>
55
+
45
56
  <execution>
46
57
  Follow `~/.maestro/workflows/retrospective.md` Stages 1–8 in order.
47
58