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
@@ -46,10 +46,39 @@ tool: true
46
46
  ---
47
47
  Step content...
48
48
  ```
49
+
50
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` (tool documents) and `.workflow/specs/` (ref entries) only. NEVER modify source code or files outside these paths.
49
51
  </context>
50
52
 
53
+ <invariants>
54
+ 1. **Schema validation** — tool knowhow document MUST include `tool: true`, `category`, `keywords/tags`, and `summary` in YAML frontmatter; missing fields → reject write
55
+ 2. **No duplicate names** — tool title MUST be unique within its category; duplicate detection → E002 warning with overwrite/optimize confirmation
56
+ 3. **Category required** — every tool MUST declare exactly one category from: coding, test, review, arch, debug; empty category → E003
57
+ 4. **Confirmation gate** — MUST request_user_input before writing knowhow document and spec ref entry; NEVER persist without user confirmation
58
+ 5. **Promote is in-place** — promote mode MUST update existing knowhow frontmatter; NEVER recreate the document
59
+ 6. **Output boundary** — ALL file writes MUST target `.workflow/knowhow/` (tool documents) and `.workflow/specs/` (ref entries) only. NEVER modify source code or files outside these paths
60
+ 7. **Description format** — first line after `### Title` MUST state "Use when ..." (usage timing); this is critical for ref entry summary visibility
61
+ </invariants>
62
+
51
63
  <execution>
52
64
 
65
+ ### Phase Gates (MANDATORY, BLOCKING)
66
+
67
+ **GATE 1: Parse → Gather**
68
+ - REQUIRED: Mode determined (extract/generate/optimize/promote) from argument parsing.
69
+ - REQUIRED: For optimize/promote modes, target tool/document exists and is loadable.
70
+ - BLOCKED if: empty args without user response to request_user_input.
71
+
72
+ **GATE 2: Gather → Write**
73
+ - REQUIRED: Tool name, category, and usage timing confirmed.
74
+ - REQUIRED: Steps extracted or generated (extract: ≥1 step, generate: user-confirmed scope).
75
+ - REQUIRED: User confirmed via request_user_input (title, category, keywords, summary, step count).
76
+ - BLOCKED if: E001 (`.workflow/specs/` not initialized), E003 (no category), user cancels.
77
+
78
+ **GATE 3: Write → Verify**
79
+ - REQUIRED: Knowhow document written with `tool: true` frontmatter (or updated in-place for promote).
80
+ - BLOCKED if: write failed or spec add returned error.
81
+
53
82
  ### Step 1: Intent Detection
54
83
 
55
84
  Parse $ARGUMENTS to determine mode:
@@ -61,6 +61,8 @@ $maestro-ui-codify "src/styles" --output-dir .workflow/packages --overwrite -y
61
61
  **Output Directory**: `.workflow/.csv-wave/{session-id}/`
62
62
  **Core Output**: `tasks.csv` (master state) + `results.csv` (final)
63
63
  **Package Output**: `{output-dir}/{package-name}/` with design-tokens.json, layout-templates.json, animation-tokens.json, preview.html, preview.css, knowhow-manifest.json
64
+
65
+ **Output boundary**: ALL file writes MUST target `.workflow/.csv-wave/{session-id}/` (wave state), `{output-dir}/{package-name}/` (reference package), `.workflow/knowhow/` (knowledge assets), and `.workflow/specs/` (spec entries). NEVER modify source code files in the scanned directory.
64
66
  </context>
65
67
 
66
68
  <csv_schema>
@@ -27,10 +27,38 @@ $ARGUMENTS — optional flags.
27
27
  - `--setup-only` -- Skip schema migration, run only the setup for current version
28
28
 
29
29
  **Version source:** `.workflow/state.json` → `version` field
30
+
31
+ **Output boundary**: ALL file writes MUST target `.workflow/state.json` (version bump), `.workflow/state.json.backup-*` (backup), and `.workflow/` config files touched by version-specific setup. NEVER modify source code or `src/migrations/` files.
30
32
  </context>
31
33
 
34
+ <invariants>
35
+ 1. **Backup before migration** — a timestamped backup of `.workflow/state.json` MUST be created before any schema migration runs; NEVER execute migration without backup
36
+ 2. **Idempotent** — running update when already on latest version MUST be a no-op (display "up to date"); NEVER re-apply migrations
37
+ 3. **Confirmation before execute** — migration diff MUST be displayed and user MUST confirm via request_user_input before execution (unless `--force`); NEVER silently apply schema changes
38
+ 4. **Migration diff always visible** — even with `--force`, the migration diff MUST be displayed for audit visibility; NEVER skip diff display
39
+ 5. **Restore path on failure** — if migration fails, the backup restore command MUST be displayed; NEVER leave user without recovery instructions
40
+ 6. **Sequential migration** — all intermediate version steps MUST be applied in order by the schema registry; NEVER skip intermediate versions
41
+ </invariants>
42
+
32
43
  <execution>
33
44
 
45
+ ### Phase Gates (MANDATORY, BLOCKING)
46
+
47
+ **GATE 1: Detect → Check**
48
+ - REQUIRED: Current version read from `.workflow/state.json`.
49
+ - BLOCKED if: state.json missing or unreadable (E001).
50
+
51
+ **GATE 2: Check → Execute**
52
+ - REQUIRED: Dry-run migration check completed; target version identified.
53
+ - REQUIRED: User confirmation via request_user_input (unless `--force`).
54
+ - BLOCKED if: already up to date (display message and exit) or user cancels.
55
+
56
+ **GATE 3: Execute → Summary**
57
+ - REQUIRED: Backup created at `.workflow/state.json.backup-v{current}-{timestamp}`.
58
+ - REQUIRED: Schema migration completed successfully.
59
+ - REQUIRED: Version-specific setup doc followed (if exists).
60
+ - BLOCKED if: migration failed — display restore command and exit.
61
+
34
62
  ### Step 1: Detect Version
35
63
 
36
64
  ```
@@ -68,6 +96,16 @@ Display version change, backup path, next steps.
68
96
 
69
97
  </execution>
70
98
 
99
+ <error_codes>
100
+ | Code | Severity | Condition | Recovery |
101
+ |------|----------|-----------|----------|
102
+ | E001 | error | `.workflow/state.json` missing or unreadable | Run `$maestro-init` first |
103
+ | E002 | error | Migration script execution failed | Display backup restore command |
104
+ | E003 | error | Version-specific setup doc not found | Skip setup, display manual steps |
105
+ | W001 | warning | Already up to date | No action needed |
106
+ | W002 | warning | Setup doc unavailable for target version | Continue without setup |
107
+ </error_codes>
108
+
71
109
  <success_criteria>
72
110
  - [ ] Version detected, schema migration run, setup doc followed
73
111
  - [ ] --setup-only, --dry-run, --force flags handled
@@ -74,6 +74,8 @@ When `--yes` or `-y`: Auto-confirm rebuild (implies --force), skip all prompts.
74
74
  **Output Directory**: `.workflow/.csv-wave/{session-id}/`
75
75
  **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
76
76
  **Target**: `.workflow/codebase/` (doc-index.json, tech-registry/, feature-maps/)
77
+
78
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/`, `.workflow/state.json`, or `.workflow/project.md` (Tech Stack section only). NEVER modify source code or files outside these paths.
77
79
  </context>
78
80
 
79
81
  <csv_schema>
@@ -22,8 +22,19 @@ $manage-codebase-refresh "--since 3d --deep"
22
22
  **Flags**:
23
23
  - `--since <date>` -- Override change detection window (ISO date or relative like `3d`)
24
24
  - `--deep` -- Force deeper re-scan even for minor changes
25
+
26
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/` (doc files, doc-index.json) and `.workflow/state.json` (codebase_last_refreshed timestamp) only. NEVER modify source code or files outside these paths.
25
27
  </context>
26
28
 
29
+ <invariants>
30
+ 1. **Incremental only** — MUST NOT clear or rebuild .workflow/codebase/; for full rebuild use `$manage-codebase-rebuild`
31
+ 2. **Change-driven** — MUST only update doc entries affected by detected git changes; NEVER refresh unchanged docs
32
+ 3. **Baseline resolution** — MUST resolve change baseline via --since flag > state.json timestamp > 7-day fallback; NEVER scan entire history
33
+ 4. **Doc-index alignment** — doc-index.json timestamps MUST be updated for every refreshed entry
34
+ 5. **KG impact awareness** — if knowledge-graph.json exists, MUST run kg diff-wiki and log affected wiki entries as warnings
35
+ 6. **No-op safety** — if no changes detected (W001), MUST exit cleanly without modifying any files
36
+ </invariants>
37
+
27
38
  <execution>
28
39
 
29
40
  ### Step 1: Validate Preconditions
@@ -81,6 +81,8 @@ $manage-drift-realign --continue "20260624-drift-realign"
81
81
  **Core Output**: `tasks.csv` + `results.csv` + `discoveries.ndjson` + `context.md`
82
82
  **Report Output**: `.workflow/.drift-realign/drift-report-{date}.md` + `drift-log.jsonl`
83
83
 
84
+ **Output boundary**: ALL file writes MUST target `.workflow/` metadata files (specs, codebase docs, roadmap.md, state.json, issues.jsonl) or `.workflow/.trash/drift-realign-{timestamp}/` (backups) or `.workflow/.drift-realign/` (session details). NEVER modify source code files.
85
+
84
86
  **State files read**:
85
87
  - `.workflow/state.json` — project state + artifact registry
86
88
  - `.workflow/roadmap.md` — milestone/phase roadmap
@@ -34,6 +34,8 @@ $ARGUMENTS — session-id, path, or empty for scan mode.
34
34
  - `--prune` — State hygiene mode: classify artifacts, graduate harvested → knowhow, archive from state.json, prune accumulated_context
35
35
  - `--age N` — Graduation age threshold in days (default: 14). Used with `--prune`
36
36
 
37
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/`, `.workflow/specs/`, `.workflow/issues/`, `.workflow/wiki/`, `.workflow/harvest/`, or `.workflow/state.json` only. NEVER modify source code, source artifacts, or files outside these paths.
38
+
37
39
  **Source registry:**
38
40
  | Source | Scan Path | Key Files |
39
41
  |--------|-----------|-----------|
@@ -47,17 +49,37 @@ $ARGUMENTS — session-id, path, or empty for scan mode.
47
49
  | learning | `.workflow/specs/` | learnings.md |
48
50
  </context>
49
51
 
52
+ <invariants>
53
+ 1. **Read-only until routing** — extraction and classification happen in-memory; no files written until Stage 6
54
+ 2. **Never modify source artifacts** — harvest is purely extractive; source files remain untouched
55
+ 3. **Dedup before write** — MUST check harvest-log.jsonl and existing stores before each write to prevent duplicates
56
+ 4. **Source tagging** — MUST set `source: "harvest"` on every issues.jsonl row so concurrent writers can be distinguished
57
+ 5. **Conflict pre-check on spec routing** — when routing to spec, MUST compare against existing specs with same keywords/category; set `confidence="low"` and log conflict note if semantic conflict detected
58
+ 6. **Provenance tracking** — every routed item MUST be logged in harvest-log.jsonl with fragment ID, target store, and timestamp
59
+ 7. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview only
60
+ </invariants>
61
+
50
62
  <execution>
51
63
  Follow '~/.maestro/workflows/harvest.md' Stages 1–8 (standard mode) or Stage 9 (`--prune` mode).
52
64
 
53
- **Key invariants:**
54
- 1. **Read-only until Stage 6** — extraction/classification in-memory only
55
- 2. **Dedup before write** check harvest-log.jsonl + existing stores
56
- 3. **Stable fragment IDs** `HRV-{8 hex}` from `hash(source_id + content_hash)`
57
- 4. **Never modify source artifacts** purely extractive
58
- 5. **Confidence filtering** below threshold logged but not routed
59
- 6. **Spec format enforcement** — all spec routing must use `<spec-entry>` closed-tag format with `title`, `description`, `keywords`, `date`, `source="harvest"` attributes
60
- 7. **Conflict pre-check on spec routing** when routing to spec, compare new entry against existing specs with same keywords/category. If semantic conflict detected, set `confidence="low"` on the new entry and log conflict note. Use `maestro spec conflict mark` if contradiction is clear
65
+ ### Phase Gates (MANDATORY, BLOCKING)
66
+
67
+ **GATE 1: Discovery → Extraction** (Stages 1-3 Stage 4)
68
+ - REQUIRED: Source artifacts discovered and mode resolved (scan/session/path).
69
+ - REQUIRED: User selected artifact(s) to harvest (or auto-selected via session/path mode, or `-y`).
70
+ - BLOCKED if no harvestable artifacts found (W001) or invalid source (E004/E005).
71
+
72
+ **GATE 2: Extraction Routing** (Stage 4 Stage 5-6)
73
+ - REQUIRED: All files in selected artifacts loaded and parsed.
74
+ - REQUIRED: Knowledge fragments extracted with category, confidence, and tags.
75
+ - REQUIRED: Fragments filtered by `--min-confidence`.
76
+ - BLOCKED if extraction produces zero fragments.
77
+
78
+ **GATE 3: Routing → Write** (Stage 6 → Stage 7-8)
79
+ - REQUIRED: Routing classification applied (auto or forced by `--to`).
80
+ - REQUIRED: Dedup check passed against harvest-log.jsonl and existing stores.
81
+ - REQUIRED: If `--dry-run`: preview displayed, no files written — GATE blocks further writes.
82
+ - BLOCKED if dedup check fails or store paths unresolvable.
61
83
 
62
84
  **Routing rules:**
63
85
  - Universal design patterns → `coding` or `arch` category
@@ -29,10 +29,34 @@ $manage-issue "link ISS-20260318-001 --task TASK-003"
29
29
  ```
30
30
 
31
31
  **Subcommands**: `create`, `list`, `status`, `update`, `close`, `link`.
32
+
33
+ **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.
32
34
  </context>
33
35
 
36
+ <invariants>
37
+ 1. **Schema compliance** — every issue record MUST conform to the canonical issue.json template schema
38
+ 2. **ID uniqueness** — issue IDs (ISS-XXXXXXXX-NNN) MUST be unique across issues.jsonl and issue-history.jsonl
39
+ 3. **Close moves to history** — `close` subcommand MUST move the record from issues.jsonl to issue-history.jsonl, NEVER delete without archiving
40
+ 4. **Bidirectional links** — `link` subcommand MUST create references in both the issue and the linked task
41
+ 5. **Confirmation on destructive ops** — `close` and bulk `update` MUST require user confirmation unless `-y` flag is set
42
+ 6. **Append-only audit** — NEVER overwrite existing issue records; updates MUST preserve all prior fields and add `updated_at` timestamp
43
+ </invariants>
44
+
34
45
  <execution>
35
46
 
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Parse → Execute** (Subcommand routing)
50
+ - REQUIRED: Subcommand parsed and validated against valid set (create/list/status/update/close/link).
51
+ - REQUIRED: `.workflow/issues/` directory exists (auto-create with empty issues.jsonl if missing).
52
+ - BLOCKED if E_NO_SUBCOMMAND or E_INVALID_SUBCOMMAND.
53
+
54
+ **GATE 2: Execute → Write** (For mutating subcommands: create/update/close/link)
55
+ - REQUIRED: Target issue exists for update/close/link operations.
56
+ - REQUIRED: User confirmation for close operations (unless -y).
57
+ - REQUIRED: For link: both issue and task validated before any writes.
58
+ - BLOCKED if target not found or confirmation denied.
59
+
36
60
  ### Step 1: Parse Subcommand
37
61
 
38
62
  Extract first token as subcommand. Valid: `create`, `list`, `status`, `update`, `close`, `link`.
@@ -72,6 +72,8 @@ When `--yes` or `-y`: Auto-confirm perspective selection, skip interactive valid
72
72
 
73
73
  **Output Directory**: `.workflow/.csv-wave/{session-id}/`
74
74
  **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + issues appended to `.workflow/issues/issues.jsonl`
75
+
76
+ **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.
75
77
  </context>
76
78
 
77
79
  <csv_schema>
@@ -32,10 +32,36 @@ $manage-knowhow "prune --before 2026-01-01 --type tip --dry-run"
32
32
  - `--before <date>` / `--after <date>` — Date filters for prune
33
33
  - `--dry-run` — Preview prune without deleting (default for prune — use `--execute` to actually delete)
34
34
  - `--execute` — Required to actually perform prune deletions (prune defaults to dry-run)
35
+
36
+ **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.
35
37
  </context>
36
38
 
39
+ <invariants>
40
+ 1. **MEMORY.md protected** — NEVER delete MEMORY.md; only editable via `edit` subcommand
41
+ 2. **MEMORY.md line limit** — MUST warn (W003) when MEMORY.md exceeds 200 lines; content beyond 200 lines will be truncated at load
42
+ 3. **Confirmation on destructive ops** — `delete` and `prune` MUST require user confirmation unless `--confirm` flag is set
43
+ 4. **Store isolation** — `prune` operates on workflow store only; NEVER prune system memory files
44
+ 5. **Reference integrity** — `delete` MUST check for references from other entries before removing; warn if orphaned references would result
45
+ 6. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview destructive operations only
46
+ 7. **Index consistency** — after delete/prune, workflow index MUST be updated to reflect removals
47
+ </invariants>
48
+
37
49
  <execution>
38
50
 
51
+ ### Phase Gates (MANDATORY, BLOCKING)
52
+
53
+ **GATE 1: Parse → Execute** (Subcommand routing)
54
+ - REQUIRED: Subcommand parsed from first token (list/search/view/edit/delete/prune).
55
+ - REQUIRED: Both store paths resolved (workflow + system).
56
+ - BLOCKED if E001 (no memory stores found) or invalid subcommand.
57
+
58
+ **GATE 2: Execute → Mutate** (For destructive subcommands: delete/prune/edit)
59
+ - REQUIRED: Target entry/file resolved and exists (E002 if not found).
60
+ - REQUIRED: MEMORY.md protected from deletion (E004 — use `edit` instead).
61
+ - REQUIRED: For `prune`: at least one filter provided (E003).
62
+ - REQUIRED: User confirmation before delete/prune unless `--confirm` flag set.
63
+ - BLOCKED if target unresolvable or confirmation denied.
64
+
39
65
  ### Step 1: Resolve Store Paths
40
66
 
41
67
  - **Workflow store**: `.workflow/knowhow/` (entries: `KNW-*.md`, `TIP-*.md`, `TPL-*.md`, `RCP-*.md`, `REF-*.md`, `DCS-*.md`, indexed in `.workflow/wiki-index.json`)
@@ -33,10 +33,33 @@ $manage-knowhow-capture "decision Use PostgreSQL over MongoDB --status accepted"
33
33
  - `--code-paths <paths>` — Related source paths for asset/blueprint (comma-separated)
34
34
  - `--description <desc>` — One-line description for search results (falls back to content[:240])
35
35
  - `--category <cat>` — Spec category for agent discovery (coding, arch, test, debug, review, learning)
36
+
37
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` only. NEVER modify source code or files outside this path.
36
38
  </context>
37
39
 
40
+ <invariants>
41
+ 1. **Description required** — every entry MUST have a `description` field in frontmatter (under 120 chars) for search indexing
42
+ 2. **Tags language match** — tags MUST match content language (Chinese content → Chinese tags, English → English)
43
+ 3. **ID uniqueness** — generated file names ({PREFIX}-{YYYYMMDD}-{slug}.md) MUST be unique; NEVER overwrite existing entries
44
+ 4. **Frontmatter completeness** — YAML frontmatter MUST include: title, description, type, category, created, tags, status
45
+ 5. **Type-specific validation** — each type MUST populate all its required fields before writing (template needs code block, recipe needs steps, etc.)
46
+ 6. **Idempotent naming** — same content captured twice MUST produce same slug, enabling dedup detection
47
+ </invariants>
48
+
38
49
  <execution>
39
50
 
51
+ ### Phase Gates (MANDATORY, BLOCKING)
52
+
53
+ **GATE 1: Type Detection → Content Collection** (Type routing → Content extraction)
54
+ - REQUIRED: Type detected from first token or selected via request_user_input.
55
+ - REQUIRED: Type maps to a valid prefix (KNW-/TPL-/RCP-/REF-/DCS-/TIP-/AST-/BLP-/DOC-/INS-).
56
+ - BLOCKED if type unresolvable after interactive prompt.
57
+
58
+ **GATE 2: Content Collection → Write** (Content extraction → File write)
59
+ - REQUIRED: All type-specific required fields populated (e.g., template needs code block, recipe needs steps).
60
+ - REQUIRED: Description generated or provided (under 120 chars).
61
+ - BLOCKED if required fields missing after prompt.
62
+
40
63
  ### Step 1: Validate
41
64
 
42
65
  Verify `.workflow/` exists (E001). Create `.workflow/knowhow/` if missing.
@@ -44,6 +44,8 @@ $manage-learn "\"Zod v4 breaks z.object().strict() API\" --category gotcha --tag
44
44
  **Storage**:
45
45
  - `.workflow/specs/learnings.md` — append-only store (shared with `quality-retrospective`)
46
46
  - Index auto-maintained by WikiIndexer (no manual index file needed)
47
+
48
+ **Output boundary**: ALL file writes MUST target `.workflow/specs/learnings.md` only. NEVER modify source code or files outside this path. Bootstrap (creating `.workflow/specs/` directory and `learnings.md`) is the only exception.
47
49
  </context>
48
50
 
49
51
  <invariants>
@@ -22,10 +22,32 @@ Reads from:
22
22
  - `.workflow/scratch/*/index.json` — per-phase metadata and progress (resolved via state.json artifact registry)
23
23
  - `.workflow/scratch/*/.task/TASK-*.json` — individual task statuses (resolved via state.json artifact registry)
24
24
  - `.workflow/wiki-index.json` — unified wiki graph index (entry counts, health)
25
+
26
+ **Output boundary**: Read-only command. MUST NOT write any files. All output is displayed to the user via text.
25
27
  </context>
26
28
 
29
+ <invariants>
30
+ 1. **Read-only** — MUST NOT write or modify any files; this is a pure display command
31
+ 2. **Graceful degradation** — missing roadmap.md, plan.json, or task files MUST NOT cause failure; display available data and note missing sections
32
+ 3. **State accuracy** — progress percentages MUST be calculated from actual task statuses, NEVER estimated or inferred
33
+ 4. **Wiki health optional** — wiki health score display MUST degrade gracefully if wiki is unavailable
34
+ 5. **Complete dashboard** — MUST include: milestone progress, phase status, task counts, active work, and next-step suggestions
35
+ </invariants>
36
+
27
37
  <execution>
28
38
 
39
+ ### Phase Gates (MANDATORY, BLOCKING)
40
+
41
+ **GATE 1: Load → Render** (State loading → Dashboard display)
42
+ - REQUIRED: `.workflow/` exists and `state.json` is readable (E001/E002 if not).
43
+ - REQUIRED: Project state loaded with milestone and artifact registry.
44
+ - BLOCKED if state.json missing or corrupt (E002).
45
+
46
+ **GATE 2: Render → Route** (Dashboard → Next-step suggestions)
47
+ - REQUIRED: Dashboard sections rendered with available data.
48
+ - REQUIRED: Next-step suggestion computed from state decision table.
49
+ - BLOCKED: never — graceful degradation for missing sections.
50
+
29
51
  ### Step 1: Validate Project
30
52
 
31
53
  Verify `.workflow/` exists (E001) and `state.json` is present (E002).
@@ -28,10 +28,38 @@ $ARGUMENTS — subcommand and optional flags.
28
28
  - `--type <type>` — Filter: spec, knowhow, note, issue
29
29
  - `--fix` — Auto-fix issues during cleanup
30
30
  - `--json` — JSON output
31
+
32
+ **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.
31
33
  </context>
32
34
 
35
+ <invariants>
36
+ 1. **Dry-run precedence** — `--dry-run` MUST override `--fix` when both are passed; preview only, no writes
37
+ 2. **Read-only by default** — without `--fix` or `--create-issues`, all subcommands MUST be read-only
38
+ 3. **Confirmation on fixes** — `--fix` MUST show preview of changes before applying; auto-apply only when explicitly set
39
+ 4. **Graph integrity** — `connect` MUST NOT create circular link chains; validate graph acyclicity for parent-child relationships
40
+ 5. **Threshold enforcement** — `--min-similarity` MUST be respected; NEVER suggest connections below the threshold
41
+ 6. **Subcommand isolation** — each subcommand routes to its own workflow file; NEVER cross-execute subcommand logic
42
+ </invariants>
43
+
33
44
  <execution>
34
45
  Follow '~/.maestro/workflows/wiki-manage.md' completely.
46
+
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Parse → Load** (Subcommand routing → Wiki data loading)
50
+ - REQUIRED: Subcommand parsed and validated (health/search/cleanup/stats).
51
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
52
+ - BLOCKED if E003 (invalid subcommand) or E001.
53
+
54
+ **GATE 2: Load → Execute** (Wiki data → Subcommand execution)
55
+ - REQUIRED: Wiki data loaded via `maestro wiki` CLI.
56
+ - REQUIRED: At least one wiki entry exists (E002 if none).
57
+ - BLOCKED if wiki data loading fails entirely.
58
+
59
+ **GATE 3: Execute → Report** (For cleanup --fix only)
60
+ - REQUIRED: Preview of changes displayed to user.
61
+ - REQUIRED: User confirmation before applying fixes.
62
+ - BLOCKED if user declines fixes.
35
63
  </execution>
36
64
 
37
65
  <error_codes>
@@ -70,6 +70,8 @@ $ARGUMENTS
70
70
  4. Hypotheses ← S_DIAGNOSE | 5. Root Cause ← S_DIAGNOSE | 6. Fix & Confirmation ← S_FIX+S_CONFIRM
71
71
  7. Generalization ← S_GENERALIZE | 8. Discoveries ← S_DISCOVER | 9. Learnings ← S_RECORD
72
72
 
73
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-debug-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.
74
+
73
75
  **Knowledge Persistence categories (§9):**
74
76
 
75
77
  | Category | Content | Follow-up |
@@ -120,6 +122,48 @@ Base execution_discipline applies. Debug additions:
120
122
  Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
121
123
  </self_iteration>
122
124
 
125
+ <execution>
126
+ Follow base execution discipline completely. Actions defined in state_machine below.
127
+
128
+ ### Phase Gates (MANDATORY, BLOCKING)
129
+
130
+ **GATE 1: INTAKE → ARCHAEOLOGY**
131
+ - REQUIRED: Issue parsed, SESSION_DIR created, session.json initialized with phase_goals[].
132
+ - BLOCKED if: no issue and no session (E001).
133
+
134
+ **GATE 2: ARCHAEOLOGY → EXPLORE**
135
+ - REQUIRED: Git history analysis completed (timeline + blame agents), evidence phase=archaeology logged.
136
+ - REQUIRED: understanding.md §2 updated.
137
+ - BLOCKED if: both archaeology agents AND delegate failed (partial results via W003 are acceptable).
138
+
139
+ **GATE 3: EXPLORE → DIAGNOSE**
140
+ - REQUIRED: explore.json written (or W006 skip logged), evidence phase=explore logged, G2 marked done.
141
+ - BLOCKED if: exploration started but not completed.
142
+
143
+ **GATE 4: DIAGNOSE → FIX**
144
+ - REQUIRED: Root cause confirmed with evidence refs, session.json.root_cause written, G1 marked done.
145
+ - BLOCKED if: hypotheses failed 3 times without escalation decision.
146
+
147
+ **GATE 5: FIX → CONFIRM**
148
+ - REQUIRED: Fix implemented with evidence phase=fix logged.
149
+ - BLOCKED if: no fix attempted.
150
+
151
+ **GATE 6: CONFIRM → GENERALIZE**
152
+ - REQUIRED: Tests pass, CLI review completed, confirmation overall == confirmed, G3 marked done.
153
+ - BLOCKED if: needs_rework → route back to S_FIX.
154
+
155
+ **GATE 7: GENERALIZE → DISCOVER**
156
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
157
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G4 marked done.
158
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
159
+
160
+ **GATE 8: DISCOVER → RECORD**
161
+ - REQUIRED: All hits triaged with per-item classification and reason.
162
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged, G5 marked done.
163
+ - BLOCKED if: unclassified hits remain.
164
+
165
+ </execution>
166
+
123
167
  <state_machine>
124
168
 
125
169
  <states>
@@ -45,6 +45,8 @@ $ARGUMENTS
45
45
  **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
46
46
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
47
47
 
48
+ **Output boundary**: ALL session artifacts 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 session artifacts outside these paths.
49
+
48
50
  **session.json — improve-specific fields:**
49
51
  ```json
50
52
  { "target": "", "dimensions": [], "baseline_metrics": {},
@@ -128,6 +130,53 @@ Base invariants apply. Additional: baseline metrics captured before any fix; eve
128
130
  Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
129
131
  </self_iteration>
130
132
 
133
+ <execution>
134
+ Follow base execution discipline completely. Actions defined in state_machine below.
135
+
136
+ ### Phase Gates (MANDATORY, BLOCKING)
137
+
138
+ **GATE 1: INTAKE → SURVEY**
139
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized with baseline_metrics.
140
+ - REQUIRED: phase_goals[] derived from flags.
141
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
142
+
143
+ **GATE 2: SURVEY → AUDIT**
144
+ - REQUIRED: Current state survey completed — dependency audit, complexity scan.
145
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
146
+ - BLOCKED if: survey incomplete — both scan types must be attempted.
147
+
148
+ **GATE 3: AUDIT → DIAGNOSE**
149
+ - REQUIRED: All dimension agents completed (or --dimensions subset), findings merged with severity classification.
150
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
151
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
152
+
153
+ **GATE 4: DIAGNOSE → FIX**
154
+ - REQUIRED: Root causes identified for all critical/high findings with evidence.
155
+ - REQUIRED: diagnoses[] written, understanding.md §4 updated, G3 marked done.
156
+ - BLOCKED if: hypotheses failed 3 times without escalation decision.
157
+
158
+ **GATE 5: FIX → VERIFY**
159
+ - REQUIRED: ALL findings within fix_threshold fixed by severity tier (critical → high → medium → low).
160
+ - REQUIRED: Per-fix evidence phase=fix logged.
161
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
162
+
163
+ **GATE 6: VERIFY → GENERALIZE**
164
+ - REQUIRED: Tests pass, metrics re-captured, before/after comparison logged.
165
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
166
+ - BLOCKED if: needs_rework → route back to S_FIX.
167
+
168
+ **GATE 7: GENERALIZE → DISCOVER**
169
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
170
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
171
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
172
+
173
+ **GATE 8: DISCOVER → RECORD**
174
+ - REQUIRED: All hits triaged with per-item classification and reason.
175
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged, G6 marked done.
176
+ - BLOCKED if: unclassified hits remain.
177
+
178
+ </execution>
179
+
131
180
  <state_machine>
132
181
 
133
182
  <states>
@@ -51,6 +51,8 @@ $ARGUMENTS
51
51
  **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
52
52
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
53
53
 
54
+ **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.
55
+
54
56
  **session.json -- planex-specific fields:**
55
57
  ```json
56
58
  { "requirement": "",
@@ -131,6 +133,48 @@ id,title,description,task_type,criterion_refs,deps,wave,status,findings,evidence
131
133
  - Wave 2: Generalization agents (syntax-grep, semantic-scan, structural-match, historical-grep) -- parallel
132
134
  </csv_schema>
133
135
 
136
+ <execution>
137
+ Follow base execution discipline completely. Actions defined in state_machine below.
138
+
139
+ ### Phase Gates (MANDATORY, BLOCKING)
140
+
141
+ **GATE 1: INTAKE → PLAN**
142
+ - REQUIRED: Requirement parsed, >=1 acceptance criterion defined with verify_method assigned.
143
+ - REQUIRED: session.json initialized, understanding.md §1 written, G1 marked done.
144
+ - BLOCKED if: no requirement provided (E001) or zero criteria derived (W001).
145
+
146
+ **GATE 2: PLAN → EXECUTE**
147
+ - REQUIRED: Plan tasks decomposed with criteria_refs mapping each task to acceptance criteria.
148
+ - REQUIRED: session.json.plan populated, understanding.md §2 updated, G2 marked done.
149
+ - BLOCKED if: plan has zero tasks or unmapped criteria.
150
+
151
+ **GATE 3: EXECUTE → VERIFY**
152
+ - REQUIRED: All plan tasks executed (or marked blocked after 3 retries per deviation rule).
153
+ - REQUIRED: execution_config confirmed, per-task evidence logged, understanding.md §3 updated, G3 marked done.
154
+ - BLOCKED if: tasks still pending execution.
155
+
156
+ **GATE 4: VERIFY → FIX / GENERALIZE**
157
+ - REQUIRED: Every acceptance criterion verified by its assigned method (test/grep/cli-review/manual).
158
+ - REQUIRED: Per-criterion evidence logged with pass/fail status and iteration count.
159
+ - BLOCKED if: verification incomplete — all criteria must be checked before routing decision.
160
+
161
+ **GATE 5: FIX → VERIFY**
162
+ - REQUIRED: current_iteration incremented, targeted fixes applied for each failed criterion.
163
+ - REQUIRED: Fix evidence logged, understanding.md §5 updated.
164
+ - BLOCKED if: no fix attempted for failing criteria.
165
+
166
+ **GATE 6: GENERALIZE → DISCOVER**
167
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
168
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
169
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
170
+
171
+ **GATE 7: DISCOVER → RECORD**
172
+ - REQUIRED: All hits triaged with per-item classification and reason.
173
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged, G6 marked done.
174
+ - BLOCKED if: unclassified hits remain.
175
+
176
+ </execution>
177
+
134
178
  <state_machine>
135
179
 
136
180
  <states>
@@ -39,6 +39,8 @@ $ARGUMENTS
39
39
  **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
40
40
  **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md` (sections 1-8)
41
41
 
42
+ **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.
43
+
42
44
  **session.json — review-specific fields:**
43
45
  ```json
44
46
  { "target": "", "dimensions": [], "review_result": { "remaining_actionable": 0 },
@@ -111,6 +113,52 @@ id,title,description,task_type,dimension,deps,wave,status,findings,evidence,erro
111
113
  | 3 | Generalization (syntax-grep, semantic-scan, structural-match, historical-grep) | 4 agents |
112
114
  </csv_schema>
113
115
 
116
+ <execution>
117
+ Follow base execution discipline completely. Actions defined in state_machine below.
118
+
119
+ ### Phase Gates (MANDATORY, BLOCKING)
120
+
121
+ **GATE 1: INTAKE → ARCHAEOLOGY**
122
+ - REQUIRED: Target resolved to file list, SESSION_DIR created, session.json initialized.
123
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
124
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
125
+
126
+ **GATE 2: ARCHAEOLOGY → EXPLORE**
127
+ - REQUIRED: Git history analysis completed (timeline + blame agents), evidence phase=archaeology logged.
128
+ - REQUIRED: understanding.md §2 updated.
129
+ - BLOCKED if: both archaeology agents failed AND delegate failed.
130
+
131
+ **GATE 3: EXPLORE → REVIEW**
132
+ - REQUIRED: explore.json written, evidence phase=explore logged, G2 marked done.
133
+ - BLOCKED if: exploration started but not completed.
134
+
135
+ **GATE 4: REVIEW → FIX**
136
+ - REQUIRED: All dimension agents completed, findings merged with severity classification.
137
+ - REQUIRED: review_result written to session.json, understanding.md §4 with severity matrix, G1 marked done.
138
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
139
+
140
+ **GATE 5: FIX → CONFIRM**
141
+ - REQUIRED: Current severity tier fully addressed — all findings in tier fixed or individually classified.
142
+ - REQUIRED: Per-fix evidence phase=fix logged, auto-commit per tier.
143
+ - BLOCKED if: tier incomplete — no partial tier advancement.
144
+
145
+ **GATE 6: CONFIRM → GENERALIZE**
146
+ - REQUIRED: Tests pass, remaining_actionable == 0, new findings == 0.
147
+ - REQUIRED: confirmation written, understanding.md §5 updated, G3 marked done.
148
+ - BLOCKED if: needs_rework → route back to S_FIX.
149
+
150
+ **GATE 7: GENERALIZE → DISCOVER**
151
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
152
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G4 marked done.
153
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
154
+
155
+ **GATE 8: DISCOVER → RECORD**
156
+ - REQUIRED: All hits triaged with per-item classification and reason.
157
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged, G5 marked done.
158
+ - BLOCKED if: unclassified hits remain.
159
+
160
+ </execution>
161
+
114
162
  <state_machine>
115
163
 
116
164
  <states>