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
@@ -24,12 +24,34 @@ $ARGUMENTS (no arguments required)
24
24
  - `.workflow/roadmap.md` -- milestone and phase structure
25
25
  - `.workflow/scratch/*/plan.json` -- plan metadata (via artifact registry paths)
26
26
  - `.workflow/scratch/*/.task/TASK-*.json` -- individual task statuses
27
+
28
+ **Output boundary**: Read-only command. MUST NOT write any files. All output is displayed to the user via text.
27
29
  </context>
28
30
 
31
+ <invariants>
32
+ 1. **Read-only** — MUST NOT write or modify any files; this is a pure display command
33
+ 2. **Graceful degradation** — missing roadmap.md, plan.json, or task files MUST NOT cause failure; display available data and note missing sections
34
+ 3. **State accuracy** — progress percentages MUST be calculated from actual task statuses, NEVER estimated or inferred
35
+ 4. **Wiki health optional** — wiki health score display MUST degrade gracefully if wiki is unavailable
36
+ 5. **Complete dashboard** — MUST include: milestone progress, phase status, task counts, active work, and next-step suggestions
37
+ </invariants>
38
+
29
39
  <execution>
30
40
  Follow '~/.maestro/workflows/status.md' completely.
31
41
 
32
42
  Next-step decision table defined in workflow status.md Step 5.
43
+
44
+ ### Phase Gates (MANDATORY, BLOCKING)
45
+
46
+ **GATE 1: Load → Render** (State loading → Dashboard display)
47
+ - REQUIRED: `.workflow/` exists and `state.json` is readable (E001/E002 if not).
48
+ - REQUIRED: Project state loaded with milestone and artifact registry.
49
+ - BLOCKED if state.json missing or corrupt (E002).
50
+
51
+ **GATE 2: Render → Route** (Dashboard → Next-step suggestions)
52
+ - REQUIRED: Per-phase progress calculated from actual task statuses.
53
+ - REQUIRED: Dashboard rendered with progress bars and status table.
54
+ - BLOCKED if state parsing fails entirely.
33
55
  </execution>
34
56
 
35
57
  <error_codes>
@@ -43,13 +43,41 @@ $ARGUMENTS — subcommand and optional flags.
43
43
  - `--format brief|full` — (digest) Output format
44
44
  - `--recent N` — (digest) Scope to N most recent entries
45
45
  - `--create-issues` — (digest) Create issues for identified knowledge gaps
46
+
47
+ **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.
46
48
  </context>
47
49
 
50
+ <invariants>
51
+ 1. **Dry-run precedence** — `--dry-run` MUST override `--fix` when both are passed; preview only, no writes
52
+ 2. **Read-only by default** — without `--fix` or `--create-issues`, all subcommands MUST be read-only
53
+ 3. **Confirmation on fixes** — `--fix` MUST show preview of changes before applying; auto-apply only when explicitly set
54
+ 4. **Graph integrity** — `connect` MUST NOT create circular link chains; validate graph acyclicity for parent-child relationships
55
+ 5. **Threshold enforcement** — `--min-similarity` MUST be respected; NEVER suggest connections below the threshold
56
+ 6. **Subcommand isolation** — each subcommand routes to its own workflow file; NEVER cross-execute subcommand logic
57
+ </invariants>
58
+
48
59
  <execution>
49
60
  **Subcommand routing:**
50
61
  - `health|search|cleanup|stats` → Follow `~/.maestro/workflows/wiki-manage.md` completely.
51
62
  - `connect` → Follow `~/.maestro/workflows/wiki-connect.md` completely (Stages 1-6).
52
63
  - `digest` → Follow `~/.maestro/workflows/wiki-digest.md` completely (Stages 1-8).
64
+
65
+ ### Phase Gates (MANDATORY, BLOCKING)
66
+
67
+ **GATE 1: Parse → Load** (Subcommand routing → Wiki data loading)
68
+ - REQUIRED: Subcommand parsed and validated (health/search/cleanup/stats/connect/digest).
69
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
70
+ - BLOCKED if E003 (invalid subcommand) or E001.
71
+
72
+ **GATE 2: Load → Execute** (Wiki data → Subcommand execution)
73
+ - REQUIRED: Wiki data loaded via `maestro wiki` CLI.
74
+ - REQUIRED: At least one wiki entry exists (E002 if none).
75
+ - BLOCKED if wiki data loading fails entirely.
76
+
77
+ **GATE 3: Execute → Write** (For mutating operations: cleanup --fix, connect --fix, digest --create-issues)
78
+ - REQUIRED: Preview of changes shown to user.
79
+ - REQUIRED: `--dry-run` NOT set (overrides `--fix`).
80
+ - BLOCKED if preview generation fails or user declines.
53
81
  </execution>
54
82
 
55
83
  <error_codes>
@@ -50,6 +50,8 @@ $ARGUMENTS
50
50
  **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
51
51
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
52
52
 
53
+ **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.
54
+
53
55
  **session.json — improve-specific fields:**
54
56
  ```json
55
57
  { "target": "", "dimensions": [], "baseline_metrics": {},
@@ -103,6 +105,54 @@ All invariants (evidence append-only, session-as-state, phase goal tracking, aut
103
105
  Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
104
106
  </self_iteration>
105
107
 
108
+ <execution>
109
+ Follow base execution discipline completely. Actions defined in state_machine below.
110
+
111
+ ### Phase Gates (MANDATORY, BLOCKING)
112
+
113
+ **GATE 1: INTAKE → SURVEY**
114
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized with baseline_metrics.
115
+ - REQUIRED: phase_goals[] derived from flags.
116
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
117
+
118
+ **GATE 2: SURVEY → AUDIT**
119
+ - REQUIRED: Current state survey completed — dependency audit, complexity scan, test coverage map, error handling scan.
120
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
121
+ - BLOCKED if: survey incomplete — all 4 scan types must be attempted.
122
+
123
+ **GATE 3: AUDIT → DIAGNOSE**
124
+ - REQUIRED: All dimension agents completed (or --dimensions subset), findings merged with severity classification.
125
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
126
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
127
+
128
+ **GATE 4: DIAGNOSE → FIX**
129
+ - REQUIRED: Root causes identified for all critical/high findings with evidence.
130
+ - REQUIRED: diagnoses[] written, understanding.md §4 updated, G3 marked done.
131
+ - BLOCKED if: hypotheses failed 3 times without escalation decision (A_ESCALATE_DIAGNOSIS).
132
+
133
+ **GATE 5: FIX → VERIFY**
134
+ - REQUIRED: ALL findings within fix_threshold fixed by severity tier (critical → high → medium → low).
135
+ - REQUIRED: Per-fix evidence phase=fix logged.
136
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
137
+
138
+ **GATE 6: VERIFY → GENERALIZE**
139
+ - REQUIRED: Tests pass, metrics re-captured, before/after comparison logged.
140
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
141
+ - BLOCKED if: needs_rework → route back to S_FIX.
142
+
143
+ **GATE 7: GENERALIZE → DISCOVER**
144
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
145
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
146
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
147
+
148
+ **GATE 8: DISCOVER → RECORD**
149
+ - REQUIRED: All hits triaged with per-item classification and reason.
150
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
151
+ - REQUIRED: G6 marked done.
152
+ - BLOCKED if: unclassified hits remain.
153
+
154
+ </execution>
155
+
106
156
  <state_machine>
107
157
 
108
158
  <states>
@@ -55,6 +55,8 @@ $ARGUMENTS
55
55
  **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
56
56
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
57
57
 
58
+ **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.
59
+
58
60
  **session.json — planex-specific fields:**
59
61
  ```json
60
62
  { "requirement": "",
@@ -106,6 +108,50 @@ Base execution_discipline #1-5.
106
108
  Applies to: **S_PLAN, S_VERIFY, S_GENERALIZE**. Logic in base.
107
109
  </self_iteration>
108
110
 
111
+ <execution>
112
+ Follow base execution discipline completely. Actions defined in state_machine below.
113
+
114
+ ### Phase Gates (MANDATORY, BLOCKING)
115
+
116
+ **GATE 1: INTAKE → PLAN**
117
+ - REQUIRED: Requirement parsed, >=1 acceptance criterion defined with verify_method assigned.
118
+ - REQUIRED: session.json initialized, understanding.md §1 written, G1 marked done.
119
+ - BLOCKED if: no requirement provided (E001) or zero criteria derived (W001).
120
+
121
+ **GATE 2: PLAN → EXECUTE**
122
+ - REQUIRED: Plan tasks decomposed with criteria_refs mapping each task to acceptance criteria.
123
+ - REQUIRED: session.json.plan populated, understanding.md §2 updated, G2 marked done.
124
+ - BLOCKED if: plan has zero tasks or unmapped criteria.
125
+
126
+ **GATE 3: EXECUTE → VERIFY**
127
+ - REQUIRED: All plan tasks executed (or marked blocked after 3 retries per deviation rule).
128
+ - REQUIRED: execution_config confirmed, per-task evidence logged, understanding.md §3 updated, G3 marked done.
129
+ - BLOCKED if: tasks still pending execution.
130
+
131
+ **GATE 4: VERIFY → FIX / GENERALIZE**
132
+ - REQUIRED: Every acceptance criterion verified by its assigned method (test/grep/cli-review/manual).
133
+ - REQUIRED: Per-criterion evidence logged with pass/fail status and iteration count.
134
+ - BLOCKED if: verification incomplete — all criteria must be checked before routing decision.
135
+ - Route: all passed → GENERALIZE (or RECORD if skip_generalize). Some failed + iteration < max → FIX.
136
+
137
+ **GATE 5: FIX → VERIFY**
138
+ - REQUIRED: current_iteration incremented, targeted fixes applied for each failed criterion.
139
+ - REQUIRED: Fix evidence logged, understanding.md §5 updated.
140
+ - BLOCKED if: no fix attempted for failing criteria.
141
+
142
+ **GATE 6: GENERALIZE → DISCOVER**
143
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
144
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
145
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
146
+
147
+ **GATE 7: DISCOVER → RECORD**
148
+ - REQUIRED: All hits triaged with per-item classification and reason.
149
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
150
+ - REQUIRED: G6 marked done.
151
+ - BLOCKED if: unclassified hits remain.
152
+
153
+ </execution>
154
+
109
155
  <state_machine>
110
156
 
111
157
  <states>
@@ -43,6 +43,8 @@ $ARGUMENTS
43
43
  **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
44
44
  **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
45
45
 
46
+ **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.
47
+
46
48
  **session.json — review-specific fields:**
47
49
  ```json
48
50
  { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
@@ -88,6 +90,54 @@ All invariants defined in base.
88
90
  Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
89
91
  </self_iteration>
90
92
 
93
+ <execution>
94
+ Follow base execution discipline completely. Actions defined in state_machine below.
95
+
96
+ ### Phase Gates (MANDATORY, BLOCKING)
97
+
98
+ **GATE 1: INTAKE → ARCHAEOLOGY**
99
+ - REQUIRED: Target resolved to file list, SESSION_DIR created, session.json initialized.
100
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
101
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
102
+
103
+ **GATE 2: ARCHAEOLOGY → EXPLORE**
104
+ - REQUIRED: Git history analysis completed (timeline + blame agents), evidence phase=archaeology logged.
105
+ - REQUIRED: understanding.md §2 updated.
106
+ - BLOCKED if: both archaeology agents failed AND delegate failed (partial results via W003 are acceptable).
107
+
108
+ **GATE 3: EXPLORE → REVIEW**
109
+ - REQUIRED: explore.json written with call_chains/recent_changes/error_gaps/similar_patterns (or W006 skip logged).
110
+ - REQUIRED: Evidence phase=explore logged, understanding.md §3 updated, G2 marked done.
111
+ - BLOCKED if: exploration started but not completed (W006 skip is acceptable, incomplete is not).
112
+
113
+ **GATE 4: REVIEW → FIX**
114
+ - REQUIRED: All dimension agents completed, findings merged with severity classification.
115
+ - REQUIRED: review_result written to session.json, understanding.md §4 with severity matrix, G1 marked done.
116
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
117
+
118
+ **GATE 5: FIX → CONFIRM**
119
+ - REQUIRED: Current severity tier fully addressed — all findings in tier fixed or individually classified.
120
+ - REQUIRED: Per-fix evidence phase=fix logged, auto-commit per tier.
121
+ - BLOCKED if: tier incomplete — no partial tier advancement.
122
+
123
+ **GATE 6: CONFIRM → GENERALIZE**
124
+ - REQUIRED: Tests pass, remaining_actionable == 0, new findings == 0.
125
+ - REQUIRED: confirmation written, understanding.md §5 updated, G3 marked done.
126
+ - BLOCKED if: needs_rework → route back to S_FIX.
127
+
128
+ **GATE 7: GENERALIZE → DISCOVER**
129
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
130
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G4 marked done.
131
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
132
+
133
+ **GATE 8: DISCOVER → RECORD**
134
+ - REQUIRED: All hits triaged with per-item classification and reason.
135
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
136
+ - REQUIRED: G5 marked done.
137
+ - BLOCKED if: unclassified hits remain.
138
+
139
+ </execution>
140
+
91
141
  <state_machine>
92
142
 
93
143
  <states>
@@ -39,6 +39,8 @@ $ARGUMENTS
39
39
  **Session**: `.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`
40
40
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
41
41
 
42
+ **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.
43
+
42
44
  **session.json — ui-specific fields:**
43
45
  ```json
44
46
  { "target": "", "dimensions": [],
@@ -87,6 +89,54 @@ $ARGUMENTS
87
89
  Applies to: **S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE**. Logic in base.
88
90
  </self_iteration>
89
91
 
92
+ <execution>
93
+ Follow base execution discipline completely. Actions defined in state_machine below.
94
+
95
+ ### Phase Gates (MANDATORY, BLOCKING)
96
+
97
+ **GATE 1: INTAKE → SURVEY**
98
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized.
99
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
100
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
101
+
102
+ **GATE 2: SURVEY → AUDIT**
103
+ - REQUIRED: Design system inventory + current state analysis completed.
104
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
105
+ - BLOCKED if: survey incomplete — token scan and styling analysis must both be attempted.
106
+
107
+ **GATE 3: AUDIT → DIVERGE**
108
+ - REQUIRED: All 6 dimension agents completed (or --dimensions subset), findings merged with severity classification.
109
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
110
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
111
+
112
+ **GATE 4: DIVERGE → FIX**
113
+ - REQUIRED: Both parallel agents (Polish + Delight) completed, ideas consolidated with audit findings.
114
+ - REQUIRED: diverge_result written, understanding.md §4 updated, G3 marked done.
115
+ - BLOCKED if: divergent exploration not attempted.
116
+
117
+ **GATE 5: FIX → VERIFY**
118
+ - REQUIRED: ALL findings/ideas within fix_threshold fixed by priority tier.
119
+ - REQUIRED: Per-fix evidence phase=fix logged.
120
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
121
+
122
+ **GATE 6: VERIFY → GENERALIZE**
123
+ - REQUIRED: Tests pass (lint, unit, visual regression), delegate verification completed.
124
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
125
+ - BLOCKED if: needs_rework → route back to S_FIX.
126
+
127
+ **GATE 7: GENERALIZE → DISCOVER**
128
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
129
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
130
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
131
+
132
+ **GATE 8: DISCOVER → RECORD**
133
+ - REQUIRED: All hits triaged with per-item classification and reason.
134
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
135
+ - REQUIRED: G6 marked done.
136
+ - BLOCKED if: unclassified hits remain.
137
+
138
+ </execution>
139
+
90
140
  <state_machine>
91
141
 
92
142
  <states>
@@ -52,8 +52,20 @@ Flags, artifact context resolution, and output formats defined in workflow auto-
52
52
  - Browse: `maestro search --category test`
53
53
  - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
54
54
  4. All are optional — proceed without if unavailable.
55
+
56
+ **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.
55
57
  </context>
56
58
 
59
+ <invariants>
60
+ 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.
61
+ 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.
62
+ 3. **Layer ordering is strict** — L0→L3 execution is sequential and fail-fast. NEVER skip a layer or run L2 before L1 passes.
63
+ 4. **Existing tests are sacred** — NEVER modify, delete, or overwrite existing test files. New tests are additive only.
64
+ 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.
65
+ 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.
66
+ 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.
67
+ </invariants>
68
+
57
69
  <execution>
58
70
  Follow '~/.maestro/workflows/auto-test.md' completely.
59
71
 
@@ -48,8 +48,19 @@ Each artifact's type determines its outputs at `.workflow/{a.path}/`:
48
48
  - Role knowledge: `maestro search --category debug` → select relevant → `maestro load --type knowhow --id`
49
49
 
50
50
  **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.
51
+
52
+ **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.
51
53
  </context>
52
54
 
55
+ <invariants>
56
+ 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.
57
+ 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".
58
+ 3. **Evidence is append-only** — evidence.ndjson entries MUST only be appended, NEVER modified or deleted. Each entry is an immutable observation.
59
+ 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.
60
+ 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.
61
+ 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.
62
+ </invariants>
63
+
53
64
  <execution>
54
65
  Follow '~/.maestro/workflows/debug.md' completely.
55
66
 
@@ -36,8 +36,19 @@ If not provided, prompt user for scope.
36
36
  - Browse: `maestro search --category coding`
37
37
  - Identify task-relevant entries, then load: `maestro load --type knowhow --id <id1> [id2...]`
38
38
  4. All are optional — proceed without if unavailable.
39
+
40
+ **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.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Plan before change** — NEVER apply refactoring changes without a confirmed plan. Every modification traces to a plan item.
45
+ 2. **Behavioral equivalence** — refactoring MUST preserve existing behavior. All tests MUST pass after each individual change, not just at the end.
46
+ 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.
47
+ 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.
48
+ 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.
49
+ 6. **Rollback safety** — if any test fails after a refactoring step, revert that specific change before attempting alternatives. NEVER proceed with failing tests.
50
+ </invariants>
51
+
41
52
  <execution>
42
53
  Follow '~/.maestro/workflows/refactor.md' completely.
43
54
 
@@ -38,8 +38,19 @@ Arguments: $ARGUMENTS
38
38
  - `--lens <name>` — Restrict to specific lens (technical|process|quality|decision); default: all four
39
39
 
40
40
  Modes (scan/single/range/all) and storage paths defined in workflow retrospective.md Argument Shape and Stages 1-7.
41
+
42
+ **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.
41
43
  </context>
42
44
 
45
+ <invariants>
46
+ 1. **Source artifacts are read-only** — NEVER modify verification.json, review.json, plan.json, or any execution artifact. Retrospective reads these for analysis only.
47
+ 2. **Stable insight IDs** — `INS-{8hex}` MUST be deterministic from `hash(phase_num + lens + title)`. Re-runs MUST NOT create duplicate insights.
48
+ 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.
49
+ 4. **Lens independence** — each lens agent (technical/process/quality/decision) operates independently. One lens's findings MUST NOT suppress or override another's.
50
+ 5. **Append-only for specs** — learnings.md entries are appended as `<spec-entry>` blocks. NEVER overwrite or restructure existing entries.
51
+ 6. **Archive before overwrite** — if retrospective.json already exists for a phase, the existing file MUST be archived before writing a new version.
52
+ </invariants>
53
+
43
54
  <execution>
44
55
  Follow `~/.maestro/workflows/retrospective.md` Stages 1–8 in order.
45
56
 
@@ -54,8 +54,19 @@ Each artifact's type determines its outputs at `.workflow/{a.path}/`:
54
54
  - Role knowledge: `maestro search --category review` → select relevant → `maestro load --type knowhow --id`
55
55
 
56
56
  **Output**: `REVIEW_DIR = .workflow/scratch/{YYYYMMDD}-review-P{N}-{slug}/` (P{N} = phase number, enables directory-level identification as state.json fallback)
57
+
58
+ **Output boundary**: ALL file writes MUST target `REVIEW_DIR` or `.workflow/state.json` only. NEVER modify source code, execution artifacts, or files outside these paths.
57
59
  </context>
58
60
 
61
+ <invariants>
62
+ 1. **Review is read-only on source** — NEVER modify source code, test files, or execution artifacts. Review produces reports only.
63
+ 2. **Findings require evidence** — every finding MUST reference file:line and include a code snippet or concrete description. No vague or unanchored findings.
64
+ 3. **Verdict is data-driven** — NEVER change verdict severity to accommodate user preference without new evidence. Verdicts flow from findings, not negotiation.
65
+ 4. **Dimension independence** — each review dimension produces findings independently. One dimension's results MUST NOT suppress or override another's.
66
+ 5. **Prior review delta** — when a prior review.json exists for the same phase, findings MUST be compared. Do NOT re-report already-resolved findings as new.
67
+ 6. **Spec conflict integrity** — if code contradicts a spec entry, flag via `maestro spec conflict mark`. NEVER silently accept the contradiction or edit the spec inline.
68
+ </invariants>
69
+
59
70
  <execution>
60
71
  Follow '~/.maestro/workflows/review.md' completely.
61
72
 
@@ -25,8 +25,18 @@ $ARGUMENTS -- optional flags:
25
25
  - `--full` -- Complete resync of all tracked files (ignores git diff, rebuilds all docs)
26
26
  - `--since <commit|HEAD~N>` -- Diff since specific commit (default: last sync timestamp)
27
27
  - `--dry-run` -- Show what would be updated without writing changes
28
+
29
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/`, `.workflow/state.json`, or `doc-index.json` only. NEVER modify source code or files outside `.workflow/`. `--dry-run` MUST suppress all writes.
28
30
  </context>
29
31
 
32
+ <invariants>
33
+ 1. **Source code is read-only** — sync reads source files to generate documentation. NEVER modify source code, test files, or any non-documentation files.
34
+ 2. **Dry-run is side-effect-free** — when `--dry-run` is set, NO file writes occur. Report only what would change.
35
+ 3. **Impact trace before refresh** — NEVER regenerate a doc file without first tracing which source changes affect it via doc-index.json. Untargeted full-refresh requires explicit `--full` flag.
36
+ 4. **Idempotent sync** — running sync twice with the same diff MUST produce identical results. State.json timestamp prevents redundant re-runs.
37
+ 5. **Incremental by default** — without `--full`, only changed components are refreshed. NEVER silently expand to a full rebuild.
38
+ </invariants>
39
+
30
40
  <execution>
31
41
  Follow '~/.maestro/workflows/sync.md' completely.
32
42
 
@@ -24,8 +24,20 @@ UAT-style conversational testing for a completed phase. Interactive scenario wal
24
24
  Phase or task: $ARGUMENTS (optional)
25
25
 
26
26
  Flags, artifact context resolution, and output directory format defined in workflow test.md.
27
+
28
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-test-P{N}-{slug}/`, `.workflow/state.json`, or `.workflow/issues.jsonl` only. NEVER modify source code or execution artifacts outside these paths. `--frontend-verify` additionally writes `e2e-results.json` to the same scratch directory.
27
29
  </context>
28
30
 
31
+ <invariants>
32
+ 1. **UAT is observational** — test execution observes behavior and records results. NEVER modify source code during testing. Source fixes belong to debug→plan→execute cycle.
33
+ 2. **Severity is inferred, not asked** — severity MUST be inferred from user's natural language description of issues. NEVER explicitly ask the user to assign severity levels.
34
+ 3. **One scenario at a time** — tests MUST be presented individually for user verification. NEVER batch-present multiple scenarios or assume outcomes.
35
+ 4. **Evidence before verdict** — UAT confidence MUST be scored with the 4-dimension factor model from actual test results. NEVER emit a verdict without running the readiness gate.
36
+ 5. **Existing UAT is resumable** — when uat.md exists for the target phase, offer resume. NEVER silently overwrite prior test progress.
37
+ 6. **Frontend-verify is deterministic** — `--frontend-verify` mode uses browser assertions with concrete pass/fail per criterion. NEVER treat "no response" or timeout as pass.
38
+ 7. **Auto-fix has bounds** — `--auto-fix` gap-fix loop MUST NOT exceed 2 iterations. Persistent failures escalate to debug, not infinite retry.
39
+ </invariants>
40
+
29
41
  <execution>
30
42
  **Mode select:** `--frontend-verify` → 走下方 **Frontend Verify Mode**(确定性浏览器 smoke,**不是**对话式 UAT);否则 Follow '~/.maestro/workflows/test.md' completely.
31
43
 
@@ -32,8 +32,19 @@ $ARGUMENTS — Parse tier and scope:
32
32
  | quick | ✓ | ✓ | — | — | — | — |
33
33
  | standard | ✓ | ✓ | ✓ | ✓ | — | — |
34
34
  | deep | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
35
+
36
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-security-audit-{tier}-{slug}/` or `.workflow/state.json` only. NEVER modify source code, configuration files, or dependencies. Audit is read-only analysis.
35
37
  </context>
36
38
 
39
+ <invariants>
40
+ 1. **Audit is read-only** — NEVER modify source code, configuration, dependencies, or CI/CD files during audit. Security audit produces reports only.
41
+ 2. **Findings require file:line evidence** — every finding MUST reference a specific file:line location and include the vulnerable code pattern. No vague or category-only findings.
42
+ 3. **Severity NEVER downgraded without justification** — if a finding matches a known OWASP category, its severity follows OWASP guidance. Downgrading requires documented rationale (e.g., compensating control exists).
43
+ 4. **Tier coverage is mandatory** — all scan phases required by the selected tier MUST complete. NEVER skip a tier-required phase silently; failures are logged as W00x warnings.
44
+ 5. **False positive marking requires evidence** — marking a finding as false positive MUST include the compensating control or code path that prevents exploitation. NEVER dismiss findings without counter-evidence.
45
+ 6. **Secrets are never logged** — if secrets are discovered, report their location (file:line) and type but NEVER include the actual secret value in the report output.
46
+ </invariants>
47
+
37
48
  <execution>
38
49
 
39
50
  ### Phase Gates (MANDATORY, BLOCKING)
@@ -44,9 +44,36 @@ Scope-to-directory mapping, category-to-file mapping, and entry format defined i
44
44
  ```
45
45
  </context>
46
46
 
47
+ <invariants>
48
+ 1. **Idempotent append** — duplicate entry ID MUST be rejected (E003-level check on title + category match before write)
49
+ 2. **Category validation** — category MUST be one of: coding, arch, quality, debug, test, review, learning, ui. Invalid category → E003
50
+ 3. **Scope isolation** — writes target ONLY the scope-resolved directory; project scope NEVER writes to global (~/.maestro/specs/), global scope NEVER writes to project (.workflow/specs/)
51
+ 4. **Confirmation gate** — MUST AskUserQuestion before appending entry (unless -y flag); NEVER write without user confirmation in interactive mode
52
+ 5. **Entry format invariance** — all entries MUST use `<spec-entry>` closed-tag format with id, keywords, and category attributes
53
+ 6. **Output boundary** — ALL file writes MUST target the scope-resolved specs directory (.workflow/specs/, ~/.maestro/specs/, .workflow/collab/specs/, or .workflow/collab/{uid}/specs/) and optionally .workflow/knowhow/ for --ref mode. NEVER modify source code or files outside these paths
54
+ </invariants>
55
+
47
56
  <execution>
48
57
  Follow '~/.maestro/workflows/specs-add.md' completely.
49
58
 
59
+ ### Phase Gates (MANDATORY, BLOCKING)
60
+
61
+ **GATE 1: Parse → Validate**
62
+ - REQUIRED: Category and content both parsed from arguments.
63
+ - REQUIRED: Category is a valid value (coding, arch, quality, debug, test, review, learning, ui).
64
+ - REQUIRED: Scope resolved to a valid directory path.
65
+ - BLOCKED if: E001 (missing args), E003 (invalid category), E004 (invalid scope), E005 (personal scope without uid).
66
+
67
+ **GATE 2: Validate → Format**
68
+ - REQUIRED: Specs directory exists for the resolved scope.
69
+ - REQUIRED: No duplicate entry with identical title + category already present in target file.
70
+ - BLOCKED if: E002 (specs not initialized).
71
+
72
+ **GATE 3: Format → Write**
73
+ - REQUIRED: `<spec-entry>` block formatted with id, keywords, category attributes.
74
+ - REQUIRED: User confirmation via AskUserQuestion (unless -y flag).
75
+ - BLOCKED if: user declines confirmation — abort without writing.
76
+
50
77
  **Confirmation gate**: Unless -y flag is passed, after formatting the `<spec-entry>` block but before appending to the target file, AskUserQuestion showing the formatted entry, target file path, and scope. Proceed only on user confirm.
51
78
  </execution>
52
79
 
@@ -57,8 +57,33 @@ When loading entries with `ref` attribute, only the summary is shown with a load
57
57
  Use the load command to read the full referenced document.
58
58
  </context>
59
59
 
60
+ <invariants>
61
+ 1. **Read-only** — NEVER modify, create, or delete any spec files during load. This command is purely a read operation
62
+ 2. **Output to context only** — loaded specs are injected into the conversation context; NEVER write loaded content to new files or modify existing files
63
+ 3. **Scope layering** — global scope MUST merge both ~/.maestro/specs/ and .workflow/specs/; project scope loads .workflow/specs/ only; team adds .workflow/collab/specs/; personal adds .workflow/collab/{uid}/specs/
64
+ 4. **Category primary doc** — when --category is specified, the primary category doc MUST be loaded in full before cross-file matching
65
+ 5. **Entry-level filtering** — --keyword filtering operates at `<spec-entry>` level via keywords attribute, NOT at file level; unmatched entries in a matching file are excluded
66
+ 6. **Output boundary** — this command produces NO file writes. All output is conversation-context injection only
67
+ </invariants>
68
+
60
69
  <execution>
61
70
  Follow '~/.maestro/workflows/specs-load.md' completely.
71
+
72
+ ### Phase Gates (MANDATORY, BLOCKING)
73
+
74
+ **GATE 1: Parse → Discover**
75
+ - REQUIRED: Arguments parsed — at least one of --category or --keyword is provided, or empty args triggers full load.
76
+ - REQUIRED: Scope resolved (default: global+project merged).
77
+ - BLOCKED if: invalid scope value or invalid category value.
78
+
79
+ **GATE 2: Discover → Load**
80
+ - REQUIRED: At least one spec directory exists in the resolved scope chain.
81
+ - BLOCKED if: E001 — .workflow/specs/ not initialized AND no global specs available. Warn and abort.
82
+
83
+ **GATE 3: Load → Display**
84
+ - REQUIRED: Spec files read and entries parsed.
85
+ - REQUIRED: Keyword filtering applied if --keyword was provided.
86
+ - BLOCKED if: no readable spec files found in any scope layer.
62
87
  </execution>
63
88
 
64
89
  <error_codes>
@@ -31,8 +31,34 @@ $ARGUMENTS -- expects `<entry-id>` (e.g., `spec-learnings-003`, `spec-coding-con
31
31
  - `--cascade` — When the target spec is a ref-type entry (created via `spec-add --ref` and linked to a knowhow document), also delete the referenced knowhow file. Without this flag, ref-type removal leaves an orphan knowhow file.
32
32
  </context>
33
33
 
34
+ <invariants>
35
+ 1. **Confirmation required** — MUST AskUserQuestion before deletion (unless -y flag); NEVER remove entries silently
36
+ 2. **Referential integrity** — before removing, check if other spec entries reference the target entry; warn user if references exist
37
+ 3. **Cascade explicit** — ref-type entries MUST NOT cascade-delete the linked knowhow file unless --cascade is explicitly passed; default leaves orphan knowhow intact
38
+ 4. **Atomic removal** — use `maestro wiki remove-entry` for atomic operation; NEVER manually edit spec files to remove entries
39
+ 5. **Index consistency** — wiki index MUST be auto-updated after removal; stale index entries are a hard failure
40
+ 6. **Output boundary** — file modifications MUST target ONLY the spec container file (.workflow/specs/*.md) and optionally the referenced knowhow file (.workflow/knowhow/*) when --cascade is used. NEVER modify source code or files outside these paths
41
+ </invariants>
42
+
34
43
  <execution>
35
44
  Follow '~/.maestro/workflows/specs-remove.md' completely.
45
+
46
+ ### Phase Gates (MANDATORY, BLOCKING)
47
+
48
+ **GATE 1: Parse → Lookup**
49
+ - REQUIRED: Entry ID parsed from arguments.
50
+ - BLOCKED if: E001 — no entry ID provided.
51
+
52
+ **GATE 2: Lookup → Confirm**
53
+ - REQUIRED: .workflow/specs/ directory exists.
54
+ - REQUIRED: Entry found in wiki index as a spec sub-node.
55
+ - REQUIRED: Entry content loaded for user preview.
56
+ - BLOCKED if: E002 (specs not initialized), E003 (entry not found), E004 (wrong type).
57
+
58
+ **GATE 3: Confirm → Remove**
59
+ - REQUIRED: User confirmed removal via AskUserQuestion (unless -y flag).
60
+ - REQUIRED: If --cascade and entry has ref attribute, user additionally confirmed knowhow file deletion.
61
+ - BLOCKED if: user declines — abort without modification.
36
62
  </execution>
37
63
 
38
64
  <error_codes>