maestro-flow 0.5.44 → 0.5.46

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 (126) hide show
  1. package/.agents/agents/ralph-executor.md +93 -0
  2. package/.agents/skills/maestro-ralph-cli/SKILL.md +21 -16
  3. package/.agents/skills/maestro-ralph-v2/SKILL.md +923 -0
  4. package/.agents/skills/odyssey-debug/SKILL.md +338 -253
  5. package/.agents/skills/odyssey-improve/SKILL.md +367 -281
  6. package/.agents/skills/odyssey-planex/SKILL.md +490 -420
  7. package/.agents/skills/odyssey-review-test-fix/SKILL.md +336 -251
  8. package/.agents/skills/odyssey-ui/SKILL.md +332 -247
  9. package/.agy/agents/ralph-executor.md +91 -0
  10. package/.agy/skills/maestro-ralph-cli/SKILL.md +21 -16
  11. package/.agy/skills/maestro-ralph-v2/SKILL.md +935 -0
  12. package/.agy/skills/odyssey-debug/SKILL.md +338 -253
  13. package/.agy/skills/odyssey-improve/SKILL.md +367 -281
  14. package/.agy/skills/odyssey-planex/SKILL.md +490 -420
  15. package/.agy/skills/odyssey-review-test-fix/SKILL.md +336 -251
  16. package/.agy/skills/odyssey-ui/SKILL.md +332 -247
  17. package/.claude/agents/ralph-executor.md +91 -0
  18. package/.claude/commands/maestro-ralph-cli.md +21 -16
  19. package/.claude/commands/maestro-ralph-v2.md +921 -0
  20. package/.claude/commands/odyssey-debug.md +352 -267
  21. package/.claude/commands/odyssey-improve.md +381 -295
  22. package/.claude/commands/odyssey-planex.md +504 -434
  23. package/.claude/commands/odyssey-review-test-fix.md +350 -265
  24. package/.claude/commands/odyssey-ui.md +346 -261
  25. package/.codex/skills/maestro-next/SKILL.md +1 -1
  26. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +3 -3
  27. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  28. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
  29. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  30. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +6 -0
  31. package/dashboard/dist-server/src/graph/kg/db/queries.js +141 -19
  32. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  33. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  34. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  35. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  36. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  37. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  38. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  39. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  40. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  41. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -2
  42. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  43. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
  44. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
  45. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
  46. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
  47. package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
  48. package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
  49. package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
  50. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
  51. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
  52. package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
  53. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
  54. package/dist/src/agents/api-explore/agent-loop.js +6 -5
  55. package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
  56. package/dist/src/agents/api-explore/config.d.ts +56 -0
  57. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  58. package/dist/src/agents/api-explore/config.js +34 -0
  59. package/dist/src/agents/api-explore/config.js.map +1 -1
  60. package/dist/src/agents/api-explore/llm.d.ts +5 -1
  61. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  62. package/dist/src/agents/api-explore/llm.js +10 -8
  63. package/dist/src/agents/api-explore/llm.js.map +1 -1
  64. package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
  65. package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
  66. package/dist/src/agents/api-explore/moa-cache.js +50 -0
  67. package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
  68. package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
  69. package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
  70. package/dist/src/agents/api-explore/moa-loop.js +43 -0
  71. package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
  72. package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
  73. package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
  74. package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
  75. package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
  76. package/dist/src/agents/api-explore/runner.d.ts +3 -0
  77. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  78. package/dist/src/agents/api-explore/runner.js +24 -7
  79. package/dist/src/agents/api-explore/runner.js.map +1 -1
  80. package/dist/src/agents/api-explore/session.d.ts +15 -0
  81. package/dist/src/agents/api-explore/session.d.ts.map +1 -1
  82. package/dist/src/agents/api-explore/session.js.map +1 -1
  83. package/dist/src/cli.js +1 -0
  84. package/dist/src/cli.js.map +1 -1
  85. package/dist/src/commands/explore.d.ts.map +1 -1
  86. package/dist/src/commands/explore.js +16 -1
  87. package/dist/src/commands/explore.js.map +1 -1
  88. package/dist/src/commands/moa.d.ts +3 -0
  89. package/dist/src/commands/moa.d.ts.map +1 -0
  90. package/dist/src/commands/moa.js +202 -0
  91. package/dist/src/commands/moa.js.map +1 -0
  92. package/dist/src/graph/kg/db/queries.d.ts +6 -0
  93. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  94. package/dist/src/graph/kg/db/queries.js +141 -19
  95. package/dist/src/graph/kg/db/queries.js.map +1 -1
  96. package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  97. package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  98. package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  99. package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  100. package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  101. package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  102. package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  103. package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  104. package/dist/src/graph/kg/extraction/orchestrator.js +2 -2
  105. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  106. package/dist/src/graph/kg/surface/hook-injector.js +1 -1
  107. package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
  108. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  109. package/dist/src/hooks/keyword-spec-injector.js +35 -0
  110. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  111. package/dist/src/hooks/spec-analytics.d.ts +1 -0
  112. package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
  113. package/dist/src/hooks/spec-analytics.js.map +1 -1
  114. package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
  115. package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
  116. package/dist/src/hooks/wiki-search-bridge.js +71 -0
  117. package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
  118. package/dist/src/utils/update-notices.js +12 -0
  119. package/dist/src/utils/update-notices.js.map +1 -1
  120. package/package.json +1 -1
  121. package/.agents/skills/maestro-ralph-agent/SKILL.md +0 -697
  122. package/.agents/skills/maestro-ralph-agent-execute/SKILL.md +0 -461
  123. package/.agy/skills/maestro-ralph-agent/SKILL.md +0 -696
  124. package/.agy/skills/maestro-ralph-agent-execute/SKILL.md +0 -457
  125. package/.claude/commands/maestro-ralph-agent-execute.md +0 -459
  126. package/.claude/commands/maestro-ralph-agent.md +0 -695
@@ -14,423 +14,493 @@ allowed-tools:
14
14
  ---
15
15
  <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
16
16
 
17
- <base>@~/.maestro/workflows/odyssey-base.md</base>
18
-
19
- <purpose>
20
- Requirement-to-delivery closed loop: parse requirement → define acceptance criteria →
21
- plan → execute → verify → fix gaps → iterate until ALL criteria pass.
22
- </purpose>
23
-
24
- <boundary>
25
- **In scope:** Single requirement delivery loop — from requirement parsing to all acceptance criteria passing + generalization.
26
- **Out of scope:** Multi-requirement orchestration → `/maestro-roadmap` | Deep debugging → `/odyssey-debug` | Code review → `/odyssey-review-test-fix` | UI optimization → `/odyssey-ui`
27
-
28
- **`--template <name>`:**
29
-
30
- | Template | Criteria pattern | Use case |
31
- |----------|-----------------|----------|
32
- | `feature` | User story acceptance + boundary tests + UI verification | New feature |
33
- | `bugfix` | Regression tests + root cause confirmation + boundary coverage | Bug fix |
34
- | `refactor` | Behavior preservation + performance baseline + API compatibility | Refactoring |
35
- | `migration` | Data consistency + rollback verification + performance comparison | Data/API migration |
36
- | `api-endpoint` | Request/response contract + error handling + permission checks | API development |
37
- </boundary>
38
-
39
- <context>
40
- $ARGUMENTS
41
-
42
- **Flags:**
43
-
44
- | Flag | Description | Default |
45
- |------|-------------|---------|
46
- | `--template <name>` | Predefined requirement template | — |
47
- | `--max-iterations N` | Max verify-fix cycles before escalation | 3 |
48
- | `--skip-generalize` | Skip S_GENERALIZE + S_DISCOVER | false |
49
- | `--auto` | CLI delegate calls without confirmation | false |
50
- | `--method agent\|cli\|auto` | Execution method | `auto` |
51
- | `--executor <tool>` | Explicit executor tool for CLI delegate | First enabled |
52
- | `--skip-verify` | Skip post-execution validation gate | false |
53
- | `--heartbeat` | Enable periodic progress heartbeat | false |
54
- | `-y` | Auto-confirm — decisions recorded as `deferred` | false |
55
- | `-c` | Resume most recent session | — |
56
-
57
- **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
58
- **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
59
-
60
- **session.json — planex-specific fields:**
61
- ```json
62
- { "requirement": "",
63
- "acceptance_criteria": [{"id":"AC1","criterion":"","verify_method":"test|grep|cli-review|manual","status":"pending","evidence":"","passed_at":null}],
64
- "plan": {"tasks":[{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[],"domain":"general","executor":"agent"}],"created_at":""},
65
- "execution_config": {"method":"auto","default_executor":"","domain_routing":{"frontend":"","backend":"","default":"agent"},"code_review_tool":"Skip","verification_tool":"Auto","confirmed":false},
66
- "iterations": [{"iteration":1,"started_at":"","completed_at":"","criteria_before":{"passed":0,"total":0},"criteria_after":{"passed":0,"total":0},"gaps_fixed":[],"files_modified":[]}],
67
- "current_iteration": 0,
68
- "patterns": [{"id":"P1","source":"AC1 fix","layer":"syntax|semantic|structural","signature":"","description":"","risk":"","fix_template":""}],
69
- "generalization_stats": "-> base shared_schemas" }
70
- ```
71
-
72
- **evidence.ndjson phases:** `planning|execution|verification|fix|decision|generalization|discovery|self-iteration`
73
-
74
- **understanding.md — 8 sections:**
75
- 1. Requirement & Criteria <- S_INTAKE | 2. Plan <- S_PLAN | 3. Execution <- S_EXECUTE
76
- 4. Verification <- S_VERIFY | 5. Fix Log <- S_FIX | 6. Generalization <- S_GENERALIZE
77
- 7. Discoveries <- S_DISCOVER | 8. Learnings <- S_RECORD
78
-
79
- **phase_goals[]:**
80
-
81
- | ID | Goal | done_when | phase | skip_when |
82
- |----|------|-----------|-------|-----------|
83
- | G1 | Acceptance criteria defined | >=1 criterion in acceptance_criteria[] | S_INTAKE | — |
84
- | G2 | Plan created | session.json.plan populated | S_PLAN | — |
85
- | G3 | Implementation complete | all plan tasks executed | S_EXECUTE | — |
86
- | G4 | All criteria pass | all acceptance_criteria[].status == passed | S_VERIFY | — |
87
- | G5 | Pattern generalized | patterns[] >=1 entry | S_GENERALIZE | skip_generalize |
88
- | G6 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
89
- | G7 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
90
-
91
- **Knowledge Persistence (written to understanding.md section 8):**
92
-
93
- | Category | Content | Follow-up |
94
- |----------|---------|-----------|
95
- | Multi-round fix cycle pattern | Problem scenario + fix iteration + final approach | `/spec-add debug` |
96
- | Reusable implementation pattern | Pattern + applicable scope + code template | `/spec-add coding` |
97
- | Acceptance criteria template | Standard template + verify_method suggestion | `/spec-add review` |
98
- | Generalization pattern | Signature + risk + fix template | `/spec-add coding` |
99
- </context>
100
-
101
- <invariants>
102
- Base execution_discipline #1-5.
103
- 6. **Acceptance criteria are sacred** — no "close enough", no manual override without explicit escalation
104
- </invariants>
105
-
106
- <self_iteration>
107
- Applies to: **S_PLAN, S_VERIFY, S_GENERALIZE**. Logic in base.
108
- </self_iteration>
109
-
110
- <state_machine>
111
-
112
- <states>
113
- S_INTAKE → S_PLAN → S_EXECUTE → S_VERIFY → S_FIX → S_GENERALIZE → S_DISCOVER → S_RECORD → END
114
- </states>
115
-
116
- <transitions>
117
- S_INTAKE → S_INTAKE : -c + session found (resume)
118
- S_INTAKE → S_PLAN : requirement + criteria defined
119
- S_INTAKE → S_INTAKE : no requirement ask_user
120
-
121
- S_PLAN → S_EXECUTE
122
- S_EXECUTE S_VERIFY
123
-
124
- S_VERIFY → S_GENERALIZE : all passed AND NOT skip_generalize
125
- S_VERIFY → S_RECORD : all passed AND skip_generalize
126
- S_VERIFY → S_FIX : some failed AND iteration < max
127
- S_VERIFY → S_PLAN : fundamental plan flaw → cross_phase_loops++ (replan). **Criteria preservation:** acceptance_criteria[] statuses are preserved; only plan.tasks[] are regenerated. Previously passed criteria retain `passed` status; failed criteria reset to `pending` for re-verification after new plan execution.
128
- S_VERIFY → S_RECORD : some failed AND iteration >= max (escalate)
129
-
130
- S_FIX → S_VERIFY (loop)
131
-
132
- S_GENERALIZE → S_DISCOVER : hits found
133
- S_GENERALIZE → S_RECORD : no hits
134
-
135
- S_DISCOVER → S_EXECUTE : discovery finds area needing same implementation → cross_phase_loops++
136
- S_DISCOVER → S_RECORD : triage complete AND remaining_actionable == 0
137
- S_DISCOVER → S_RECORD : loops >= max_loops log per-item reasons
138
-
139
- S_RECORD → END
140
- </transitions>
141
-
142
- <actions>
143
-
144
- ### A_INTAKE
145
-
146
- 1. Parse requirement and flags, generate slug, create SESSION_DIR
147
- 2. **Define acceptance criteria** — analyze requirement derive testable criteria. Each gets `verify_method`: test | grep | cli-review | manual
148
- - Normal: ask_user to confirm/edit
149
- - `-y`: auto-derive, record `{"phase":"decision","type":"criteria-confirmation","status":"deferred"}`
150
- 3. Search prior knowledge: `maestro search`, related sessions
151
- 4. Write session.json + understanding.md section 1. Mark G1 done. Emit Goal Prompt.
152
-
153
- Commit: `"odyssey-planex({slug}): INTAKE — parse requirement and define criteria"`
154
-
155
- ### A_PLAN
156
-
157
- 1. Decompose requirement into ordered tasks mapped to acceptance criteria
158
- 2. CLI-assisted planning (optional):
159
- ```bash
160
- maestro delegate "PURPOSE: Create implementation plan for: {requirement}
161
- TASK: Decompose into subtasks | Map to acceptance criteria | Identify dependencies
162
- MODE: analysis
163
- CONTEXT: @**/* | Criteria: {criteria_summary}
164
- EXPECTED: JSON [{task_id, title, description, criteria_refs, deps}]
165
- " --role analyze --mode analysis
166
- ```
167
- Run with `run_in_background: true`, wait for callback.
168
- 3. Write session.json.plan, append evidence (planning), update understanding.md section 2. Mark G2 done.
169
-
170
- Commit: `"odyssey-planex({slug}): PLAN — create execution plan"`
171
-
172
- ### A_EXECUTE
173
-
174
- #### Step 1: Execution Options Confirmation
175
-
176
- **Skip if** `-y` flag OR `--method` explicitly set OR `execution_config.confirmed == true` (resume).
177
-
178
- Load available tools: `maestro delegate-config show --json`.
179
-
180
- Present ask_user with 3 questions:
181
- 1. **Executor** Auto (domain routing) | delegate_subagent(all tasks) | specific CLI tool | Other (custom domain routing)
182
- 2. **Review** — Skip | {tool} review (git diff quality check)
183
- 3. **Verify** — Auto (delegate convergence + structure + anti-pattern check) | specific tool | Skip
184
-
185
- Parse response → write `execution_config` to session.json, set `confirmed: true`. `--skip-verify` overrides verification to `"Skip"`.
186
-
187
- #### Step 2: Executor Resolution
188
-
189
- Per-task domain routing (when method == "auto"):
190
-
191
- | Domain | Keywords / Patterns | Extensions |
192
- |--------|-------------------|------------|
193
- | frontend | UI, component, page, style, layout, CSS, view | .tsx/.jsx/.vue/.css/.html/.svelte |
194
- | backend | API, server, database, service, algorithm, worker | .go/.rs/.java/.py/.sql/.proto |
195
- | general | mixed, config, tests, unclear | .ts/.js/other |
196
-
197
- Resolution: `execution_config.domain_routing[domain]` → fallback `domain_routing.default` ("agent").
198
-
199
- #### Step 3: Task Execution
200
-
201
- Execute tasks per plan order. Independent tasks may run in parallel.
202
-
203
- **Agent path:**
204
- ```
205
- Spawn Agent with: task definition, acceptance criteria refs, prior task summaries, specs_content
206
- Agent implements verifies convergence auto-fix (max 3) returns result
207
- ```
208
-
209
- **CLI path:**
210
- ```bash
211
- maestro delegate "PURPOSE: Implement task ${task_id}: ${title}; success = criteria ${criteria_refs} satisfied
212
- TASK: ${description} | Read existing code first | Verify convergence criteria after changes
213
- MODE: write
214
- CONTEXT: @${scope}/**/* | Criteria: ${criteria_summary}
215
- EXPECTED: Working code changes, convergence evidence, summary of what was done
216
- CONSTRAINTS: Scope limited to task files | Follow project specs
217
-
218
- ## Acceptance Criteria (must satisfy)
219
- ${criteria_refs.map(ref => criteria[ref].criterion).join('\n')}
220
-
221
- ## Implementation Steps
222
- ${task.description}
223
-
224
- ## Project Specs
225
- ${specs_content}
226
-
227
- ## Prior Task Summaries
228
- ${prior_summaries}
229
- " --to ${resolved_executor} --mode write --id planex-${slug}-${task_id}
230
- ```
231
-
232
- Run with `run_in_background: true`, wait for callback.
233
-
234
- **Deviation Rule** — max 3 auto-fix attempts per task:
235
- 1. First attempt: normal dispatch
236
- 2. Retry: `--resume planex-${slug}-${task_id}` with simplified prompt
237
- 3. Final: fallback to Agent path
238
- 4. All 3 fail mark task `blocked`, record checkpoint, continue remaining tasks
239
-
240
- #### Step 4: Per-Task Evidence
241
-
242
- Per completed task:
243
- - Record evidence: `{"phase":"execution","type":"task-completed","task_id":"T1","executor":"agent|agy|...","files_modified":[],"summary":"","attempt":1}`
244
- - Update task status in session.json plan
245
-
246
- #### Step 5: Post-Execution Validation
247
-
248
- **Skip if** `execution_config.verification_tool == "Skip"` OR `--skip-verify` OR no completed tasks.
249
-
250
- **Check 1: Summary Consistency** — cross-check task status vs actual file changes (git diff).
251
-
252
- **Check 2: CLI Verification Gate** — delegate to external model:
253
- ```bash
254
- maestro delegate "PURPOSE: Verify execution output meets acceptance criteria; success = all criteria verified with file:line evidence
255
- TASK:
256
- 1. CONVERGENCE: For each criterion, read actual code, verify behavior exists, report status with evidence
257
- 2. EXISTENCE: Verify all expected files exist on disk
258
- 3. SUBSTANCE: Verify real implementation flag stubs, placeholders, TODO-only
259
- 4. ANTI-PATTERNS: Scan for TODO/FIXME/HACK, console.log debug, disabled tests
260
- MODE: analysis
261
- CONTEXT: @${modified_files}
262
- EXPECTED: JSON { convergence: [{criterion, status, evidence}], issues: [{type, file, line, severity}], overall: passed|gaps_found }
263
- CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line
264
-
265
- ## Acceptance Criteria (verify each)
266
- ${acceptance_criteria.map(c => c.criterion).join('\n')}
267
-
268
- ## Modified Files
269
- ${modified_files.join('\n')}
270
- " --to ${execution_config.verification_tool} --mode analysis
271
- ```
272
-
273
- Run with `run_in_background: true`, wait for callback.
274
-
275
- On result:
276
- - `overall == "passed"` → proceed to S_VERIFY with boosted confidence
277
- - `overall == "gaps_found"` → log findings, proceed to S_VERIFY
278
-
279
- **Check 3: Code Review** (if `execution_config.code_review_tool != "Skip"`):
280
- ```bash
281
- maestro delegate "Review git diff for correctness, style, bugs" --to ${code_review_tool} --mode analysis --rule analysis-review-code-quality
282
- ```
283
-
284
- #### Step 6: Completion
285
-
286
- Update understanding.md section 3. Mark G3 done.
287
-
288
- Commit: `"odyssey-planex({slug}): EXECUTE — implementation complete"`
289
-
290
- ### A_VERIFY
291
-
292
- Iron gate — every acceptance criterion checked objectively.
293
-
294
- **Verify each criterion by method:**
295
-
296
- | Method | Action |
297
- |--------|--------|
298
- | `test` | Run relevant tests, check pass/fail |
299
- | `grep` | Grep for expected pattern |
300
- | `cli-review` | `maestro delegate "PURPOSE: Verify criterion {criterion_id}: {criterion}\nTASK: Read implementation code \| Check behavior matches criterion \| Report pass/fail with file:line evidence\nMODE: analysis\nCONTEXT: @{relevant_files}\nEXPECTED: JSON {criterion_id, status: passed\|failed, evidence: [{file, line, detail}]}" --role review --mode analysis` |
301
- | `manual` | Normal: ask_user / `-y`: record `deferred` |
302
-
303
- Record per criterion: `{"phase":"verification","type":"criterion-check","criterion_id":"AC1","method":"","result":"passed|failed","evidence":"","iteration":N}`. Update acceptance_criteria[].status. Append to iterations[].
304
-
305
- Update understanding.md section 4 with pass/fail table.
306
-
307
- **Route:** all passed → mark G4 done → next state. Some failed + iteration < max → S_FIX. Some failed + iteration >= max → Normal: ask_user (continue/lower bar/accept) / `-y`: `deferred`, proceed S_RECORD.
308
-
309
- Commit: `"odyssey-planex({slug}): VERIFY — acceptance check"`
310
-
311
- ### A_FIX
312
-
313
- 1. Increment current_iteration
314
- 2. For each failed criterion: diagnose gap → targeted code fix
315
- 3. CLI fix review (optional):
316
- ```bash
317
- maestro delegate "PURPOSE: Review fixes for failing criteria; success = no regressions and fixes correct
318
- TASK: Check fix correctness | Verify no regressions on passing criteria | Report verdict with file:line evidence
319
- MODE: analysis
320
- CONTEXT: @{modified_files} | Passing: {passing} | Fixed: {fixed}
321
- EXPECTED: JSON {verdict: passed|concerns_found, regression_risk: low|medium|high, concerns: [{criterion_id, file, line, description}]}
322
- CONSTRAINTS: Read-only | Check ALL passing criteria for regressions
323
- " --role review --mode analysis
324
- ```
325
- 4. Append evidence (fix), update understanding.md section 5 → S_VERIFY
326
-
327
- Commit: `"odyssey-planex({slug}): FIX — targeted fix for failing criteria"`
328
-
329
- ### A_GENERALIZE
330
-
331
- Base shared_actions. Pattern source: implementation patterns.
332
-
333
- Commit: `"odyssey-planex({slug}): GENERALIZE — pattern scan complete"`
334
-
335
- ### A_DISCOVER
336
-
337
- Base shared_actions. Planex override: discovery finding needing same implementation → route back to S_EXECUTE (not S_FIX).
338
-
339
- Commit: `"odyssey-planex({slug}): DISCOVER — findings classified"`
340
-
341
- ### A_RECORD
342
-
343
- Base shared_actions. Planex additions:
344
- 1. Iteration summary: what worked, what needed rework, fix cycle patterns
345
- 2. Learnings structured per Knowledge Persistence table: problem scenario + fix iteration process + final approach + applicable scope
346
-
347
- **Completion summary:**
348
- ```
349
- --- PLANEX ODYSSEY COMPLETE ---
350
- Requirement: {requirement}
351
- Criteria: {passed}/{total} passed
352
- Iterations: {N} cycles
353
- Patterns: {patterns_extracted} ({by_layer} distribution)
354
- Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
355
- Issues: {N} created | Decisions: {N} resolved, {M} pending, {K} deferred
356
- Learnings: {N} spec entries
357
- Self-iter: {N} rounds across {M} stages
358
- Goals: {done}/{total} confirmed ({skipped} skipped)
359
- Status: {ALL_PASSED|PARTIAL|ESCALATED}
360
- ---
361
- ```
362
-
363
- Commit: `"odyssey-planex({slug}): RECORD session summary"`
364
-
365
- </actions>
366
-
367
- <appendix>
368
-
369
- ### `-y` planex-specific points
370
-
371
- | Decision Point | Normal | `-y` |
372
- |---------------|--------|------|
373
- | S_INTAKE criteria confirmation | ask_user | auto-derive, `deferred` |
374
- | S_EXECUTE execution options | ask_user | use defaults (auto/Skip/Auto), `confirmed: true` |
375
- | S_EXECUTE task blocked (3 retries) | ask_user: continue or stop | auto continue, log blocked |
376
- | S_VERIFY manual criterion | ask_user | `deferred` |
377
- | S_VERIFY max iteration reached | ask_user | auto accept, `deferred` |
378
-
379
- ### Goal Prompt convergence rules
380
-
381
- ```
382
- Exhaustive iteration: until all acceptance_criteria[*].status==passed
383
- AND phase_goals_all_done=true. Verify failure auto-triggers fix->re-verify loop.
384
- Each fix round re-verifies; new criterion violations continue fixing within max_iterations.
385
- No "close enough" all criteria must ALL pass.
386
- ```
387
-
388
- ### Iteration Model
389
-
390
- ```
391
- S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER → S_RECORD
392
- │ │
393
- some fail + iter < max no hits ─→ S_RECORD
394
-
395
- S_FIX ──→ S_VERIFY (loop)
396
- ```
397
-
398
- Max iterations (default 3) prevents infinite loops. Each iteration records criteria_before, gaps_fixed, criteria_after.
399
-
400
- </appendix>
401
-
402
- </state_machine>
403
-
404
- <error_codes>
405
- | Code | Severity | Condition | Recovery |
406
- |------|----------|-----------|----------|
407
- | E001 | error | No requirement provided | Provide requirement |
408
- | W001 | warning | No acceptance criteria derived | Manual definition needed |
409
- | W002 | warning | Max iterations reached, criteria still failing | Escalate to user |
410
- | W003 | warning | CLI review regression concern | Review before next iteration |
411
- </error_codes>
412
-
413
- <success_criteria>
414
- - [ ] Requirement parsed with >=1 acceptance criterion (verify_method assigned)
415
- - [ ] Plan tasks mapped to criteria; execution options confirmed
416
- - [ ] Tasks dispatched via resolved executor with deviation rule (max 3 retries)
417
- - [ ] Post-execution validation gate run (unless --skip-verify)
418
- - [ ] Every criterion verified per method; failing → targeted fix (not re-implementation)
419
- - [ ] Iteration count tracked and max respected; unfixed criteria individually classified
420
- - [ ] understanding.md sections 1-8 updated per phase; phase_goals G1-G7 audited
421
- - [ ] Generalization + discovery completed (unless --skip-generalize)
422
- - [ ] Quality Gate self-iteration triggered when insufficient
423
- - [ ] Goal Prompt displayed once after intake; `-y` mode: no blocking prompts
424
- - [ ] Session resumable via -c; completion summary output
425
- </success_criteria>
426
-
427
- <next_step_routing>
428
- | Condition | Next |
429
- |-----------|------|
430
- | All criteria passed | `/odyssey-review-test-fix <changed-files>` |
431
- | Max iterations, still failing | `/odyssey-debug "<failing criterion>"` |
432
- | Formal review | `/quality-review <phase>` |
433
- | Issues from discoveries | `/manage-issue list --source planex-odyssey` |
434
- | Pattern worth documenting | `/learn-decompose <module>` |
435
- </next_step_routing>
436
- </output>
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
19
+ <purpose>
20
+ Requirement-to-delivery closed loop: parse requirement → define acceptance criteria →
21
+ plan → execute → verify → fix gaps → iterate until ALL criteria pass.
22
+ </purpose>
23
+
24
+ <boundary>
25
+ **In scope:** Single requirement delivery loop — from requirement parsing to all acceptance criteria passing + generalization.
26
+ **Out of scope:** Multi-requirement orchestration → `/maestro-roadmap` | Deep debugging → `/odyssey-debug` | Code review → `/odyssey-review-test-fix` | UI optimization → `/odyssey-ui`
27
+
28
+ **`--template <name>`:**
29
+
30
+ | Template | Criteria pattern | Use case |
31
+ |----------|-----------------|----------|
32
+ | `feature` | User story acceptance + boundary tests + UI verification | New feature |
33
+ | `bugfix` | Regression tests + root cause confirmation + boundary coverage | Bug fix |
34
+ | `refactor` | Behavior preservation + performance baseline + API compatibility | Refactoring |
35
+ | `migration` | Data consistency + rollback verification + performance comparison | Data/API migration |
36
+ | `api-endpoint` | Request/response contract + error handling + permission checks | API development |
37
+ </boundary>
38
+
39
+ <context>
40
+ $ARGUMENTS
41
+
42
+ **Flags:**
43
+
44
+ | Flag | Description | Default |
45
+ |------|-------------|---------|
46
+ | `--template <name>` | Predefined requirement template | — |
47
+ | `--max-iterations N` | Max verify-fix cycles before escalation | 3 |
48
+ | `--skip-generalize` | Skip S_GENERALIZE + S_DISCOVER | false |
49
+ | `--auto` | CLI delegate calls without confirmation | false |
50
+ | `--method agent\|cli\|auto` | Execution method | `auto` |
51
+ | `--executor <tool>` | Explicit executor tool for CLI delegate | First enabled |
52
+ | `--skip-verify` | Skip post-execution validation gate | false |
53
+ | `--heartbeat` | Enable periodic progress heartbeat | false |
54
+ | `-y` | Auto-confirm — decisions recorded as `deferred` | false |
55
+ | `-c` | Resume most recent session | — |
56
+
57
+ **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
58
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
59
+
60
+ **session.json — planex-specific fields:**
61
+ ```json
62
+ { "requirement": "",
63
+ "acceptance_criteria": [{"id":"AC1","criterion":"","verify_method":"test|grep|cli-review|manual","status":"pending","evidence":"","passed_at":null}],
64
+ "plan": {"tasks":[{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[],"domain":"general","executor":"agent"}],"created_at":""},
65
+ "execution_config": {"method":"auto","default_executor":"","domain_routing":{"frontend":"","backend":"","default":"agent"},"code_review_tool":"Skip","verification_tool":"Auto","confirmed":false},
66
+ "iterations": [{"iteration":1,"started_at":"","completed_at":"","criteria_before":{"passed":0,"total":0},"criteria_after":{"passed":0,"total":0},"gaps_fixed":[],"files_modified":[]}],
67
+ "current_iteration": 0,
68
+ "patterns": [{"id":"P1","source":"AC1 fix","layer":"syntax|semantic|structural","signature":"","description":"","risk":"","fix_template":""}],
69
+ "generalization_stats": "-> base shared_schemas" }
70
+ ```
71
+
72
+ **evidence.ndjson phases:** `planning|execution|verification|fix|decision|generalization|discovery|self-iteration`
73
+
74
+ **understanding.md — 8 sections:**
75
+ 1. Requirement & Criteria <- S_INTAKE | 2. Plan <- S_PLAN | 3. Execution <- S_EXECUTE
76
+ 4. Verification <- S_VERIFY | 5. Fix Log <- S_FIX | 6. Generalization <- S_GENERALIZE
77
+ 7. Discoveries <- S_DISCOVER | 8. Learnings <- S_RECORD
78
+
79
+ **phase_goals[]:**
80
+
81
+ | ID | Goal | done_when | phase | skip_when |
82
+ |----|------|-----------|-------|-----------|
83
+ | G1 | Acceptance criteria defined | >=1 criterion in acceptance_criteria[] | S_INTAKE | — |
84
+ | G2 | Plan created | session.json.plan populated | S_PLAN | — |
85
+ | G3 | Implementation complete | all plan tasks executed | S_EXECUTE | — |
86
+ | G4 | All criteria pass | all acceptance_criteria[].status == passed | S_VERIFY | — |
87
+ | G5 | Pattern generalized | patterns[] >=1 entry | S_GENERALIZE | skip_generalize |
88
+ | G6 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
89
+ | G7 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
90
+
91
+ **Knowledge Persistence (written to understanding.md section 8):**
92
+
93
+ | Category | Content | Follow-up |
94
+ |----------|---------|-----------|
95
+ | Multi-round fix cycle pattern | Problem scenario + fix iteration + final approach | `/spec-add debug` |
96
+ | Reusable implementation pattern | Pattern + applicable scope + code template | `/spec-add coding` |
97
+ | Acceptance criteria template | Standard template + verify_method suggestion | `/spec-add review` |
98
+ | Generalization pattern | Signature + risk + fix template | `/spec-add coding` |
99
+ </context>
100
+
101
+ <invariants>
102
+ Base execution_discipline #1-5.
103
+ 6. **Acceptance criteria are sacred** — no "close enough", no manual override without explicit escalation
104
+ 7. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "All criteria passed" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
105
+ </invariants>
106
+
107
+ <self_iteration>
108
+ Applies to: **S_PLAN, S_VERIFY, S_GENERALIZE**. Logic in base.
109
+ </self_iteration>
110
+
111
+ <state_machine>
112
+
113
+ <states>
114
+ S_INTAKE → S_PLAN → S_EXECUTE → S_VERIFY → S_FIX → S_GENERALIZE → S_DISCOVER → S_RECORD → END
115
+ </states>
116
+
117
+ <transitions>
118
+ S_INTAKE → S_INTAKE : -c + session found (resume)
119
+ S_INTAKE → S_PLAN : requirement + criteria defined
120
+ S_INTAKE → S_INTAKE : no requirement → ask_user
121
+
122
+ S_PLAN S_EXECUTE
123
+ S_EXECUTE → S_VERIFY
124
+
125
+ S_VERIFY → S_GENERALIZE : all passed AND NOT skip_generalize
126
+ S_VERIFY → S_RECORD : all passed AND skip_generalize
127
+ S_VERIFY → S_FIX : some failed AND iteration < max
128
+ S_VERIFY → S_PLAN : fundamental plan flaw → cross_phase_loops++ (replan). **Criteria preservation:** acceptance_criteria[] statuses are preserved; only plan.tasks[] are regenerated. Previously passed criteria retain `passed` status; failed criteria reset to `pending` for re-verification after new plan execution.
129
+ S_VERIFY → S_RECORD : some failed AND iteration >= max (escalate)
130
+
131
+ S_FIX → S_VERIFY (loop)
132
+
133
+ S_GENERALIZE → S_DISCOVER : hits found
134
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
135
+
136
+ S_DISCOVER → S_EXECUTE : discovery finds area needing same implementation → cross_phase_loops++
137
+ S_DISCOVER → S_RECORD : triage complete AND remaining_actionable == 0
138
+ S_DISCOVER → S_RECORD : loops >= max_loops → log per-item reasons
139
+
140
+ S_RECORD → END
141
+ </transitions>
142
+
143
+ <actions>
144
+
145
+ ### A_INTAKE
146
+
147
+ 1. Parse requirement and flags, generate slug, create SESSION_DIR
148
+ 2. **Define acceptance criteria** — analyze requirement → derive testable criteria. Each gets `verify_method`: test | grep | cli-review | manual
149
+ - Normal: ask_user to confirm/edit
150
+ - `-y`: auto-derive, record `{"phase":"decision","type":"criteria-confirmation","status":"deferred"}`
151
+ 3. Search prior knowledge: `maestro search`, related sessions
152
+ 4. Write session.json + understanding.md section 1. Mark G1 done. Emit Goal Prompt.
153
+
154
+ Commit: `"odyssey-planex({slug}): INTAKE — parse requirement and define criteria"`
155
+
156
+ ### A_PLAN
157
+
158
+ 1. Decompose requirement into ordered tasks mapped to acceptance criteria
159
+ 2. CLI-assisted planning (optional):
160
+ ```bash
161
+ maestro delegate "PURPOSE: Create implementation plan for: {requirement}
162
+ TASK: Decompose into subtasks | Map to acceptance criteria | Identify dependencies
163
+ MODE: analysis
164
+ CONTEXT: @**/* | Criteria: {criteria_summary}
165
+ EXPECTED: JSON [{task_id, title, description, criteria_refs, deps}]
166
+ " --role analyze --mode analysis
167
+ ```
168
+ Run with `run_in_background: true`, wait for callback.
169
+ 3. Write session.json.plan, append evidence (planning), update understanding.md section 2. Mark G2 done.
170
+
171
+ Commit: `"odyssey-planex({slug}): PLAN — create execution plan"`
172
+
173
+ ### A_EXECUTE
174
+
175
+ #### Step 1: Execution Options Confirmation
176
+
177
+ **Skip if** `-y` flag OR `--method` explicitly set OR `execution_config.confirmed == true` (resume).
178
+
179
+ Load available tools: `maestro delegate-config show --json`.
180
+
181
+ Present ask_user with 3 questions:
182
+ 1. **Executor** — Auto (domain routing) | delegate_subagent(all tasks) | specific CLI tool | Other (custom domain routing)
183
+ 2. **Review** — Skip | {tool} review (git diff quality check)
184
+ 3. **Verify** — Auto (delegate convergence + structure + anti-pattern check) | specific tool | Skip
185
+
186
+ Parse response → write `execution_config` to session.json, set `confirmed: true`. `--skip-verify` overrides verification to `"Skip"`.
187
+
188
+ #### Step 2: Executor Resolution
189
+
190
+ Per-task domain routing (when method == "auto"):
191
+
192
+ | Domain | Keywords / Patterns | Extensions |
193
+ |--------|-------------------|------------|
194
+ | frontend | UI, component, page, style, layout, CSS, view | .tsx/.jsx/.vue/.css/.html/.svelte |
195
+ | backend | API, server, database, service, algorithm, worker | .go/.rs/.java/.py/.sql/.proto |
196
+ | general | mixed, config, tests, unclear | .ts/.js/other |
197
+
198
+ Resolution: `execution_config.domain_routing[domain]` → fallback `domain_routing.default` ("agent").
199
+
200
+ #### Step 3: Task Execution
201
+
202
+ Execute tasks per plan order. Independent tasks may run in parallel.
203
+
204
+ **Agent path:**
205
+ ```
206
+ Spawn Agent with: task definition, acceptance criteria refs, prior task summaries, specs_content
207
+ Agent implements → verifies convergence → auto-fix (max 3) → returns result
208
+ ```
209
+
210
+ **CLI path:**
211
+ ```bash
212
+ maestro delegate "PURPOSE: Implement task ${task_id}: ${title}; success = criteria ${criteria_refs} satisfied
213
+ TASK: ${description} | Read existing code first | Verify convergence criteria after changes
214
+ MODE: write
215
+ CONTEXT: @${scope}/**/* | Criteria: ${criteria_summary}
216
+ EXPECTED: Working code changes, convergence evidence, summary of what was done
217
+ CONSTRAINTS: Scope limited to task files | Follow project specs
218
+
219
+ ## Acceptance Criteria (must satisfy)
220
+ ${criteria_refs.map(ref => criteria[ref].criterion).join('\n')}
221
+
222
+ ## Implementation Steps
223
+ ${task.description}
224
+
225
+ ## Project Specs
226
+ ${specs_content}
227
+
228
+ ## Prior Task Summaries
229
+ ${prior_summaries}
230
+ " --to ${resolved_executor} --mode write --id planex-${slug}-${task_id}
231
+ ```
232
+
233
+ Run with `run_in_background: true`, wait for callback.
234
+
235
+ **Deviation Rule** max 3 auto-fix attempts per task:
236
+ 1. First attempt: normal dispatch
237
+ 2. Retry: `--resume planex-${slug}-${task_id}` with simplified prompt
238
+ 3. Final: fallback to Agent path
239
+ 4. All 3 fail → mark task `blocked`, record checkpoint, continue remaining tasks
240
+
241
+ #### Step 4: Per-Task Evidence
242
+
243
+ Per completed task:
244
+ - Record evidence: `{"phase":"execution","type":"task-completed","task_id":"T1","executor":"agent|agy|...","files_modified":[],"summary":"","attempt":1}`
245
+ - Update task status in session.json plan
246
+
247
+ #### Step 5: Post-Execution Validation
248
+
249
+ **Skip if** `execution_config.verification_tool == "Skip"` OR `--skip-verify` OR no completed tasks.
250
+
251
+ **Check 1: Summary Consistency** — cross-check task status vs actual file changes (git diff).
252
+
253
+ **Check 2: CLI Verification Gate** — delegate to external model:
254
+ ```bash
255
+ maestro delegate "PURPOSE: Verify execution output meets acceptance criteria; success = all criteria verified with file:line evidence
256
+ TASK:
257
+ 1. CONVERGENCE: For each criterion, read actual code, verify behavior exists, report status with evidence
258
+ 2. EXISTENCE: Verify all expected files exist on disk
259
+ 3. SUBSTANCE: Verify real implementation flag stubs, placeholders, TODO-only
260
+ 4. ANTI-PATTERNS: Scan for TODO/FIXME/HACK, console.log debug, disabled tests
261
+ MODE: analysis
262
+ CONTEXT: @${modified_files}
263
+ EXPECTED: JSON { convergence: [{criterion, status, evidence}], issues: [{type, file, line, severity}], overall: passed|gaps_found }
264
+ CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line
265
+
266
+ ## Acceptance Criteria (verify each)
267
+ ${acceptance_criteria.map(c => c.criterion).join('\n')}
268
+
269
+ ## Modified Files
270
+ ${modified_files.join('\n')}
271
+ " --to ${execution_config.verification_tool} --mode analysis
272
+ ```
273
+
274
+ Run with `run_in_background: true`, wait for callback.
275
+
276
+ On result:
277
+ - `overall == "passed"` → proceed to S_VERIFY with boosted confidence
278
+ - `overall == "gaps_found"` → log findings, proceed to S_VERIFY
279
+
280
+ **Check 3: Code Review** (if `execution_config.code_review_tool != "Skip"`):
281
+ ```bash
282
+ maestro delegate "Review git diff for correctness, style, bugs" --to ${code_review_tool} --mode analysis --rule analysis-review-code-quality
283
+ ```
284
+
285
+ #### Step 6: Completion
286
+
287
+ Update understanding.md section 3. Mark G3 done.
288
+
289
+ Commit: `"odyssey-planex({slug}): EXECUTE — implementation complete"`
290
+
291
+ ### A_VERIFY
292
+
293
+ Iron gate — every acceptance criterion checked objectively.
294
+
295
+ **Verify each criterion by method:**
296
+
297
+ | Method | Action |
298
+ |--------|--------|
299
+ | `test` | Run relevant tests, check pass/fail |
300
+ | `grep` | Grep for expected pattern |
301
+ | `cli-review` | `maestro delegate "PURPOSE: Verify criterion {criterion_id}: {criterion}\nTASK: Read implementation code \| Check behavior matches criterion \| Report pass/fail with file:line evidence\nMODE: analysis\nCONTEXT: @{relevant_files}\nEXPECTED: JSON {criterion_id, status: passed\|failed, evidence: [{file, line, detail}]}" --role review --mode analysis` |
302
+ | `manual` | Normal: ask_user / `-y`: record `deferred` |
303
+
304
+ Record per criterion: `{"phase":"verification","type":"criterion-check","criterion_id":"AC1","method":"","result":"passed|failed","evidence":"","iteration":N}`. Update acceptance_criteria[].status. Append to iterations[].
305
+
306
+ Update understanding.md section 4 with pass/fail table.
307
+
308
+ **Route:** all passed → mark G4 done → next state. Some failed + iteration < max → S_FIX. Some failed + iteration >= max → Normal: ask_user (continue/lower bar/accept) / `-y`: `deferred`, proceed S_RECORD.
309
+
310
+ Commit: `"odyssey-planex({slug}): VERIFY — acceptance check"`
311
+
312
+ ### A_FIX
313
+
314
+ 1. Increment current_iteration
315
+ 2. For each failed criterion: diagnose gap → targeted code fix
316
+ 3. CLI fix review (optional):
317
+ ```bash
318
+ maestro delegate "PURPOSE: Review fixes for failing criteria; success = no regressions and fixes correct
319
+ TASK: Check fix correctness | Verify no regressions on passing criteria | Report verdict with file:line evidence
320
+ MODE: analysis
321
+ CONTEXT: @{modified_files} | Passing: {passing} | Fixed: {fixed}
322
+ EXPECTED: JSON {verdict: passed|concerns_found, regression_risk: low|medium|high, concerns: [{criterion_id, file, line, description}]}
323
+ CONSTRAINTS: Read-only | Check ALL passing criteria for regressions
324
+ " --role review --mode analysis
325
+ ```
326
+ 4. Append evidence (fix), update understanding.md section 5 → S_VERIFY
327
+
328
+ Commit: `"odyssey-planex({slug}): FIX — targeted fix for failing criteria"`
329
+
330
+ ### A_GENERALIZE
331
+
332
+ **MANDATORY — executes unless `skip_generalize == true`. "All criteria passed" or context pressure are NOT valid skip reasons.**
333
+
334
+ Pattern source: implementation patterns from executed tasks.
335
+
336
+ **Step 1 — 3-layer pattern extraction** from implementation:
337
+
338
+ | Layer | Method | Targets |
339
+ |-------|--------|---------|
340
+ | Syntax | Build regex from implementation diffs → Grep | API contract patterns, validation shapes, error response format, config structure |
341
+ | Semantic | Understand implementation pattern → Agent scan | Similar feature needs elsewhere, analogous data flows, parallel business logic |
342
+ | Structural | Find modules with same structure / dependency shape | Parallel module structures, sibling endpoints, same-shape services |
343
+
344
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
345
+
346
+ **Thoroughness floor:** ALL 3 layers must be attempted and logged. Each layer records search method, scope, hit count in evidence phase=generalization. "No hits" requires all 3 layers to return 0 with logged evidence.
347
+
348
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
349
+
350
+ | Agent | Strategy | Scope |
351
+ |-------|----------|-------|
352
+ | Syntax grep | Grep regex from pattern signatures | Full project |
353
+ | Semantic scan | Implementation pattern check | Related modules |
354
+ | Structural match | Find structurally similar modules | Full project |
355
+ | Historical grep | `git log -S` for pattern signatures | Git history |
356
+
357
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
358
+
359
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
360
+
361
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
362
+ ```json
363
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
364
+ ```
365
+
366
+ **Transition guard:** `S_GENERALIZE → S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G5 done.
367
+
368
+ Commit: `"odyssey-planex({slug}): GENERALIZE — pattern scan complete"`
369
+
370
+ ### A_DISCOVER
371
+
372
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
373
+
374
+ 1. **Triage** each hit with ±10 lines context classify:
375
+ - `bug` area needing same implementation (missing feature parity)
376
+ - `risk` potential inconsistency or missing pattern application
377
+ - `safe` false positive (must log individual reason blanket "pre-existing" forbidden)
378
+
379
+ 2. **Route (planex-specific routes to S_EXECUTE, not S_FIX):**
380
+
381
+ | Classification | Action |
382
+ |---------------|--------|
383
+ | needs same implementation | Route to S_EXECUTE with new task, `cross_phase_loops++` |
384
+ | risk + guard addable | Fix directly |
385
+ | risk + complex | Create issue |
386
+ | safe | Skip with logged per-item reason |
387
+
388
+ Normal: ask_user per hit | `-y`: auto-route to execute, create issue for rest
389
+
390
+ 3. **Cross-phase loops:** `loops >= max_loops` → must log per-item reasons, advance to S_RECORD.
391
+
392
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G6 done.
393
+
394
+ Commit: `"odyssey-planex({slug}): DISCOVER — findings classified"`
395
+
396
+ ### A_RECORD
397
+
398
+ 1. Iteration summary: what worked, what needed rework, fix cycle patterns
399
+ 2. understanding.md section 8 — learnings by Knowledge Persistence categories:
400
+ - Multi-round fix cycle pattern → `/spec-add debug`
401
+ - Reusable implementation pattern → `/spec-add coding`
402
+ - Acceptance criteria template → `/spec-add review`
403
+ - Generalization pattern → `/spec-add coding`
404
+
405
+ 3. Mark G7 done. Pending decisions: Normal → ask_user | `-y` → skip (show deferred count).
406
+
407
+ 4. **Goal audit (hardened):**
408
+ - `done` confirmed
409
+ - `skipped` confirmed ONLY if corresponding `skip_when` flag is true
410
+ - **Hard rule:** G5 and G6 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: ask_user | `-y`: record `failed`)
411
+ - `phase_goals_all_done = true` only when all goals pass this audit
412
+
413
+ 5. `current_state = "COMPLETED"`, emit completion summary.
414
+
415
+ **Completion summary:**
416
+ ```
417
+ --- PLANEX ODYSSEY COMPLETE ---
418
+ Requirement: {requirement}
419
+ Criteria: {passed}/{total} passed
420
+ Iterations: {N} cycles
421
+ Patterns: {patterns_extracted} ({by_layer} distribution)
422
+ Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
423
+ Issues: {N} created | Decisions: {N} resolved, {M} pending, {K} deferred
424
+ Learnings: {N} spec entries
425
+ Self-iter: {N} rounds across {M} stages
426
+ Goals: {done}/{total} confirmed ({skipped} skipped)
427
+ Status: {ALL_PASSED|PARTIAL|ESCALATED}
428
+ ---
429
+ ```
430
+
431
+ Commit: `"odyssey-planex({slug}): RECORD session summary"`
432
+
433
+ </actions>
434
+
435
+ <appendix>
436
+
437
+ ### `-y` planex-specific points
438
+
439
+ | Decision Point | Normal | `-y` |
440
+ |---------------|--------|------|
441
+ | S_INTAKE criteria confirmation | ask_user | auto-derive, `deferred` |
442
+ | S_EXECUTE execution options | ask_user | use defaults (auto/Skip/Auto), `confirmed: true` |
443
+ | S_EXECUTE task blocked (3 retries) | ask_user: continue or stop | auto continue, log blocked |
444
+ | S_VERIFY manual criterion | ask_user | `deferred` |
445
+ | S_VERIFY max iteration reached | ask_user | auto accept, `deferred` |
446
+ | A_DISCOVER hit routing | ask_user | auto-route to execute, create issue for rest |
447
+
448
+ ### Goal Prompt convergence rules
449
+
450
+ ```
451
+ Exhaustive iteration: until all acceptance_criteria[*].status==passed
452
+ AND phase_goals_all_done=true. Verify failure auto-triggers fix->re-verify loop.
453
+ Each fix round re-verifies; new criterion violations continue fixing within max_iterations.
454
+ No "close enough" — all criteria must ALL pass.
455
+ ```
456
+
457
+ ### Iteration Model
458
+
459
+ ```
460
+ S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER → S_RECORD
461
+ │ │
462
+ some fail + iter < max 3-layer scan, 0 hits ─→ S_RECORD
463
+
464
+ S_FIX ──→ S_VERIFY (loop)
465
+ ```
466
+
467
+ Max iterations (default 3) prevents infinite loops. Each iteration records criteria_before, gaps_fixed, criteria_after.
468
+
469
+ </appendix>
470
+
471
+ </state_machine>
472
+
473
+ <error_codes>
474
+ | Code | Severity | Condition | Recovery |
475
+ |------|----------|-----------|----------|
476
+ | E001 | error | No requirement provided | Provide requirement |
477
+ | W001 | warning | No acceptance criteria derived | Manual definition needed |
478
+ | W002 | warning | Max iterations reached, criteria still failing | Escalate to user |
479
+ | W003 | warning | CLI review regression concern | Review before next iteration |
480
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
481
+ </error_codes>
482
+
483
+ <success_criteria>
484
+ - [ ] Requirement parsed with >=1 acceptance criterion (verify_method assigned)
485
+ - [ ] Plan tasks mapped to criteria; execution options confirmed
486
+ - [ ] Tasks dispatched via resolved executor with deviation rule (max 3 retries)
487
+ - [ ] Post-execution validation gate run (unless --skip-verify)
488
+ - [ ] Every criterion verified per method; failing → targeted fix (not re-implementation)
489
+ - [ ] Iteration count tracked and max respected; unfixed criteria individually classified
490
+ - [ ] understanding.md sections 1-8 updated per phase; phase_goals G1-G7 audited
491
+ - [ ] Generalization + discovery completed (unless --skip-generalize)
492
+ - [ ] Quality Gate self-iteration triggered when insufficient
493
+ - [ ] Goal Prompt displayed once after intake; `-y` mode: no blocking prompts
494
+ - [ ] Session resumable via -c; completion summary output
495
+ </success_criteria>
496
+
497
+ <next_step_routing>
498
+ | Condition | Next |
499
+ |-----------|------|
500
+ | All criteria passed | `/odyssey-review-test-fix <changed-files>` |
501
+ | Max iterations, still failing | `/odyssey-debug "<failing criterion>"` |
502
+ | Formal review | `/quality-review <phase>` |
503
+ | Issues from discoveries | `/manage-issue list --source planex-odyssey` |
504
+ | Pattern worth documenting | `/learn-decompose <module>` |
505
+ </next_step_routing>
506
+ </output>