maestro-flow 0.5.45 → 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 (116) hide show
  1. package/.agents/agents/ralph-executor.md +51 -6
  2. package/.agents/skills/maestro-ralph-v2/SKILL.md +124 -61
  3. package/.agents/skills/odyssey-debug/SKILL.md +338 -253
  4. package/.agents/skills/odyssey-improve/SKILL.md +367 -281
  5. package/.agents/skills/odyssey-planex/SKILL.md +490 -420
  6. package/.agents/skills/odyssey-review-test-fix/SKILL.md +336 -251
  7. package/.agents/skills/odyssey-ui/SKILL.md +332 -247
  8. package/.agy/agents/ralph-executor.md +53 -6
  9. package/.agy/skills/maestro-ralph-v2/SKILL.md +123 -61
  10. package/.agy/skills/odyssey-debug/SKILL.md +338 -253
  11. package/.agy/skills/odyssey-improve/SKILL.md +367 -281
  12. package/.agy/skills/odyssey-planex/SKILL.md +490 -420
  13. package/.agy/skills/odyssey-review-test-fix/SKILL.md +336 -251
  14. package/.agy/skills/odyssey-ui/SKILL.md +332 -247
  15. package/.claude/agents/ralph-executor.md +51 -6
  16. package/.claude/commands/maestro-ralph-v2.md +124 -61
  17. package/.claude/commands/odyssey-debug.md +352 -267
  18. package/.claude/commands/odyssey-improve.md +381 -295
  19. package/.claude/commands/odyssey-planex.md +504 -434
  20. package/.claude/commands/odyssey-review-test-fix.md +350 -265
  21. package/.claude/commands/odyssey-ui.md +346 -261
  22. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +3 -3
  23. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  24. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
  25. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  26. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +6 -0
  27. package/dashboard/dist-server/src/graph/kg/db/queries.js +141 -19
  28. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  29. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  30. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  31. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  32. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  33. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  34. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  35. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  36. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  37. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -2
  38. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  39. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
  40. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
  41. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
  42. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
  43. package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
  44. package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
  45. package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
  46. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
  47. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
  48. package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
  49. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
  50. package/dist/src/agents/api-explore/agent-loop.js +6 -5
  51. package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
  52. package/dist/src/agents/api-explore/config.d.ts +56 -0
  53. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  54. package/dist/src/agents/api-explore/config.js +34 -0
  55. package/dist/src/agents/api-explore/config.js.map +1 -1
  56. package/dist/src/agents/api-explore/llm.d.ts +5 -1
  57. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  58. package/dist/src/agents/api-explore/llm.js +10 -8
  59. package/dist/src/agents/api-explore/llm.js.map +1 -1
  60. package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
  61. package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
  62. package/dist/src/agents/api-explore/moa-cache.js +50 -0
  63. package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
  64. package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
  65. package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
  66. package/dist/src/agents/api-explore/moa-loop.js +43 -0
  67. package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
  68. package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
  69. package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
  70. package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
  71. package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
  72. package/dist/src/agents/api-explore/runner.d.ts +3 -0
  73. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  74. package/dist/src/agents/api-explore/runner.js +24 -7
  75. package/dist/src/agents/api-explore/runner.js.map +1 -1
  76. package/dist/src/agents/api-explore/session.d.ts +15 -0
  77. package/dist/src/agents/api-explore/session.d.ts.map +1 -1
  78. package/dist/src/agents/api-explore/session.js.map +1 -1
  79. package/dist/src/cli.js +1 -0
  80. package/dist/src/cli.js.map +1 -1
  81. package/dist/src/commands/explore.d.ts.map +1 -1
  82. package/dist/src/commands/explore.js +16 -1
  83. package/dist/src/commands/explore.js.map +1 -1
  84. package/dist/src/commands/moa.d.ts +3 -0
  85. package/dist/src/commands/moa.d.ts.map +1 -0
  86. package/dist/src/commands/moa.js +202 -0
  87. package/dist/src/commands/moa.js.map +1 -0
  88. package/dist/src/graph/kg/db/queries.d.ts +6 -0
  89. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  90. package/dist/src/graph/kg/db/queries.js +141 -19
  91. package/dist/src/graph/kg/db/queries.js.map +1 -1
  92. package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  93. package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  94. package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  95. package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  96. package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  97. package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  98. package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  99. package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  100. package/dist/src/graph/kg/extraction/orchestrator.js +2 -2
  101. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  102. package/dist/src/graph/kg/surface/hook-injector.js +1 -1
  103. package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
  104. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  105. package/dist/src/hooks/keyword-spec-injector.js +35 -0
  106. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  107. package/dist/src/hooks/spec-analytics.d.ts +1 -0
  108. package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
  109. package/dist/src/hooks/spec-analytics.js.map +1 -1
  110. package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
  111. package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
  112. package/dist/src/hooks/wiki-search-bridge.js +71 -0
  113. package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
  114. package/dist/src/utils/update-notices.js +12 -0
  115. package/dist/src/utils/update-notices.js.map +1 -1
  116. package/package.json +1 -1
@@ -14,254 +14,339 @@ allowed-tools:
14
14
  - view_file
15
15
  - write_to_file
16
16
  ---
17
- <base>@~/.maestro/workflows/odyssey-base.md</base>
18
-
19
- <purpose>
20
- archaeology → explore → multi-dimensional review → fix ALL findings → confirm → generalize → discover → persist. Zero-residual: every finding gets an action.
21
- </purpose>
22
-
23
- <boundary>
24
- **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
25
- **Out of scope:** Root cause debug → `/odyssey-debug` | Feature implementation → `/odyssey-planex` | UI visual optimization → `/odyssey-ui`
26
-
27
- **Exploration freedom:** Free within boundary — cross-dimension correlation, git history tracing, project-wide generalization scan. Fix ALL findings within fix_threshold (default: all).
28
- **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
29
- </boundary>
30
-
31
- <context>
32
- $ARGUMENTS
33
-
34
- **Target resolution:**
35
-
36
- | Input | Resolution |
37
- |-------|-----------|
38
- | File/dir path | Review those files |
39
- | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
40
- | Phase number | state.json → changed files |
41
- | PR number | `git diff main...HEAD` |
42
-
43
- **Flags:** `--dimensions <list>` subset of review dimensions | `--fix-threshold <level>` severity cutoff (default: all) | `--skip-fix` skip S_FIX+S_CONFIRM | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
44
-
45
- **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
46
- **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
47
-
48
- **session.json — review-specific fields:**
49
- ```json
50
- { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
51
- "patterns": [], "confirmation": null, "generalization_stats": null }
52
- ```
53
-
54
- **evidence.ndjson phases:** `archaeology|explore|review|fix|discovery|decision|self-iteration`
55
-
56
- **phase_goals[]:**
57
-
58
- | ID | Goal | done_when | phase | skip_when |
59
- |----|------|-----------|-------|-----------|
60
- | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
61
- | G2 | Explore context | explore.json populated | S_EXPLORE | — |
62
- | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
63
- | G4 | Pattern generalized | patterns[] >=1 | S_GENERALIZE | skip_generalize |
64
- | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
65
- | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
66
-
67
- **understanding.md — 8 sections:**
68
- 1. Target & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
69
- 4. Review Results ← S_REVIEW | 5. Fix & Confirmation ← S_FIX+S_CONFIRM
70
- 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER | 8. Learnings ← S_RECORD
71
-
72
- Specs: `maestro load --type spec --category review`
73
-
74
- **Knowledge Persistence categories (section 8):**
75
-
76
- | Category | Content | Follow-up |
77
- |----------|---------|-----------|
78
- | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `/spec-add review` |
79
- | Security finding | Vulnerability type + triggers + fix approach | `/spec-add debug` |
80
- | Architecture violation pattern | Violation + correct boundary + verification | `/spec-add arch` |
81
- | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
82
- </context>
83
-
84
- <invariants>
85
- All invariants defined in base.
86
- </invariants>
87
-
88
- <self_iteration>
89
- Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
90
- </self_iteration>
91
-
92
- <state_machine>
93
-
94
- <states>
95
- S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
96
- </states>
97
-
98
- <transitions>
99
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME_SESSION
100
- S_INTAKE → S_ARCHAEOLOGY : target resolvedA_INTAKE
101
- S_INTAKE → S_INTAKE : no target → ask_question
102
-
103
- S_ARCHAEOLOGY → S_EXPLORE : complete
104
- S_EXPLORE → S_REVIEW : complete
105
-
106
- S_REVIEW → S_FIX : !skip_fix AND findings
107
- S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
108
- S_REVIEW → S_RECORD : both skip
109
-
110
- S_FIX → S_CONFIRM : tier complete
111
- S_CONFIRM S_GENERALIZE : confirmed, !skip_generalize
112
- S_CONFIRM → S_RECORD : confirmed, skip_generalize
113
- S_CONFIRM → S_FIX : needs_rework
114
-
115
- S_GENERALIZE → S_DISCOVER : similar code found
116
- S_GENERALIZE → S_RECORD : no similar code
117
-
118
- S_DISCOVER → S_FIX : fixable sibling → cross_phase_loops++
119
- S_DISCOVER → S_REVIEW : new target, loops < max_loops → cross_phase_loops++
120
- S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops
121
- </transitions>
122
-
123
- <actions>
124
-
125
- ### A_INTAKE
126
- 1. Parse target + flags → file list. Create SESSION_DIR, derive phase_goals[]
127
- 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
128
- 3. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
129
-
130
- Commit: `"odyssey-review({slug}): INTAKE — parse target and load context"`
131
-
132
- ### A_RESUME_SESSION
133
- Glob latest session → read `session.json` → jump to `current_state`.
134
-
135
- ### A_ARCHAEOLOGY
136
- 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
137
-
138
- **Error handling:** If any archaeology agent fails (Timeline or Blame), log W003 and proceed with available results. If delegate fails, log W003 and proceed with local agent results only.
139
-
140
- `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
141
- - PURPOSE: Review recent modifications related to {target}
142
- - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
143
-
144
- Update section 2. Commit: `"odyssey-review({slug}): ARCHAEOLOGY — git history analysis"`
145
-
146
- ### A_EXPLORE
147
- Skip if no CLI tools (W006).
148
-
149
- `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
150
- - PURPOSE: Call chains, recent changes, error gaps, similar patterns
151
- - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
152
-
153
- Write `explore.json` + evidence phase=explore. Update section 3. Mark G2. Commit: `"odyssey-review({slug}): EXPLORE — codebase exploration"`
154
-
155
- ### A_REVIEW
156
- Spawn N parallel Agents, one per dimension:
157
- - **Correctness**: logic errors, boundary conditions, null/undefined, race conditions
158
- - **Security**: injection, XSS, CSRF, data exposure, auth bypass
159
- - **Performance**: hot paths, N+1, memory leaks, unnecessary recomputation
160
- - **Architecture**: layer violations, circular deps, interface contracts, SoC
161
-
162
- Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence phase=review. Write `review_result` + section 4 severity matrix. Mark G1.
163
-
164
- Commit: `"odyssey-review({slug}): REVIEW — multi-dimension review complete"`
165
-
166
- ### A_FIX
167
- Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`.
168
-
169
- ```
170
- for tier in [critical, high, medium, low].filter(>= threshold):
171
- for each unfixed candidate: read +/-20 lines → fix → evidence phase=fix
172
- re-review modified area (new findings append, continue; max 2 per tier)
173
- tier doneauto-commit
174
- ```
175
-
176
- Normal: ask_question per tier. `-y`: auto-fix all.
177
- Remaining > 0 → retry (max_fix_rounds = 5). Unchanged 2 rounds → classify each individually. After 5 rounds with remaining > 0 → escalate: Normal: ask_question (continue/accept/reclassify) | `-y`: classify remaining as `deferred`, proceed.
178
- Blanket "pre-existing" forbidden.
179
-
180
- Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`
181
-
182
- ### A_CONFIRM
183
- Run tests + `maestro delegate --role review --mode analysis` (`run_in_background: true`) for zero-residual review.
184
- - `remaining == 0 AND new == 0` confirmed, mark G3
185
- - Otherwise needs_reworkS_FIX
186
-
187
- Update `confirmation` + `remaining_actionable` + section 5.
188
-
189
- Commit: `"odyssey-review({slug}): CONFIRM — zero-residual verified"`
190
-
191
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
192
- Base shared_actions. Review overrides:
193
- - **A_GENERALIZE** pattern source: findings with severity >= medium
194
- - **A_RECORD** learnings per Knowledge Persistence table
195
-
196
- **Completion summary:**
197
- ```
198
- --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
199
- Target: {target} Dimensions: {dims}
200
- Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
201
- Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
202
- Issues: {N} created
203
- Decisions: {N} resolved, {M} pending, {K} deferred
204
- Learnings: {N} persisted
205
- Self-iter: {N} rounds across {M} stages
206
- Goals: {done}/{total} ({skipped} skipped)
207
- ---
208
- ```
209
-
210
- </actions>
211
-
212
- <appendix>
213
-
214
- ### `-y` review-specific points
215
-
216
- | Decision Point | Normal | `-y` |
217
- |---------------|--------|------|
218
- | S_FIX tier candidates | ask_question | auto-fix, deferred |
219
- | S_FIX re-review new findings | ask_question | auto-append |
220
- | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
221
-
222
- ### Goal Prompt convergence rules
223
-
224
- ```
225
- Stop when remaining_actionable == 0, confirmation == confirmed,
226
- generalization exhausted, phase_goals_all_done=true.
227
- Fix iterates by severity tier; each tier re-reviews modified area, new findings appended.
228
- Every finding must have action (fix/issue/decision). Decision pending must ask_question.
229
- ```
230
-
231
- </appendix>
232
-
233
- </state_machine>
234
-
235
- <error_codes>
236
- | Code | Severity | Condition | Recovery |
237
- |------|----------|-----------|----------|
238
- | E001 | error | No target specified | Provide target |
239
- | E002 | error | Target path not found | Check path |
240
- | W001 | warning | No git history | Proceed |
241
- | W002 | warning | Some dimension agents failed | Partial coverage |
242
- | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
243
- </error_codes>
244
-
245
- <success_criteria>
246
- - [ ] Session + 4 output files + prior knowledge searched
247
- - [ ] Archaeology + CLI review evidence phase=archaeology
248
- - [ ] CLI exploration explore.json + evidence phase=explore
249
- - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0)
250
- - [ ] Per-tier re-review gate; every unfixed finding individually classified
251
- - [ ] understanding.md sections 1-8 progressive
252
- - [ ] Fix + confirmed (unless --skip-fix)
253
- - [ ] Generalization + scan (unless --skip-generalize)
254
- - [ ] Discoveries classified; unfixed findings individually justified
255
- - [ ] phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
256
- - [ ] Completion summary
257
- </success_criteria>
258
-
259
- <next_step_routing>
260
- | Condition | Next |
261
- |-----------|------|
262
- | Deeper debug needed | `/odyssey-debug "<finding>"` |
263
- | Issues created | `/manage-issue list --source review-odyssey` |
264
- | Document pattern | `/learn-decompose <module>` |
265
- | Plan fixes | `/maestro-plan --gaps` |
266
- </next_step_routing>
267
- </output>
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
19
+ <purpose>
20
+ archaeology → explore → multi-dimensional review → fix ALL findings → confirm → generalize → discover → persist. Zero-residual: every finding gets an action.
21
+ </purpose>
22
+
23
+ <boundary>
24
+ **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
25
+ **Out of scope:** Root cause debug → `/odyssey-debug` | Feature implementation → `/odyssey-planex` | UI visual optimization → `/odyssey-ui`
26
+
27
+ **Exploration freedom:** Free within boundary — cross-dimension correlation, git history tracing, project-wide generalization scan. Fix ALL findings within fix_threshold (default: all).
28
+ **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
29
+ </boundary>
30
+
31
+ <context>
32
+ $ARGUMENTS
33
+
34
+ **Target resolution:**
35
+
36
+ | Input | Resolution |
37
+ |-------|-----------|
38
+ | File/dir path | Review those files |
39
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
40
+ | Phase number | state.json → changed files |
41
+ | PR number | `git diff main...HEAD` |
42
+
43
+ **Flags:** `--dimensions <list>` subset of review dimensions | `--fix-threshold <level>` severity cutoff (default: all) | `--skip-fix` skip S_FIX+S_CONFIRM | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
44
+
45
+ **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
46
+ **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
47
+
48
+ **session.json — review-specific fields:**
49
+ ```json
50
+ { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
51
+ "patterns": [], "confirmation": null, "generalization_stats": null }
52
+ ```
53
+
54
+ **evidence.ndjson phases:** `archaeology|explore|review|fix|discovery|decision|self-iteration`
55
+
56
+ **phase_goals[]:**
57
+
58
+ | ID | Goal | done_when | phase | skip_when |
59
+ |----|------|-----------|-------|-----------|
60
+ | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
61
+ | G2 | Explore context | explore.json populated | S_EXPLORE | — |
62
+ | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
63
+ | G4 | Pattern generalized | patterns[] >=1 | S_GENERALIZE | skip_generalize |
64
+ | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
65
+ | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
66
+
67
+ **understanding.md — 8 sections:**
68
+ 1. Target & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
69
+ 4. Review Results ← S_REVIEW | 5. Fix & Confirmation ← S_FIX+S_CONFIRM
70
+ 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER | 8. Learnings ← S_RECORD
71
+
72
+ Specs: `maestro load --type spec --category review`
73
+
74
+ **Knowledge Persistence categories (section 8):**
75
+
76
+ | Category | Content | Follow-up |
77
+ |----------|---------|-----------|
78
+ | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `/spec-add review` |
79
+ | Security finding | Vulnerability type + triggers + fix approach | `/spec-add debug` |
80
+ | Architecture violation pattern | Violation + correct boundary + verification | `/spec-add arch` |
81
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
82
+ </context>
83
+
84
+ <invariants>
85
+ All invariants defined in base.
86
+ 6. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "Zero remaining" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
87
+ </invariants>
88
+
89
+ <self_iteration>
90
+ Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
91
+ </self_iteration>
92
+
93
+ <state_machine>
94
+
95
+ <states>
96
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
97
+ </states>
98
+
99
+ <transitions>
100
+ S_INTAKE → S_INTAKE : -c + session found A_RESUME_SESSION
101
+ S_INTAKE → S_ARCHAEOLOGY : target resolved A_INTAKE
102
+ S_INTAKE → S_INTAKE : no target → ask_question
103
+
104
+ S_ARCHAEOLOGY → S_EXPLORE : complete
105
+ S_EXPLORE → S_REVIEW : complete
106
+
107
+ S_REVIEW → S_FIX : !skip_fix AND findings
108
+ S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
109
+ S_REVIEW → S_RECORD : both skip
110
+
111
+ S_FIX S_CONFIRM : tier complete
112
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
113
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
114
+ S_CONFIRM → S_FIX : needs_rework
115
+
116
+ S_GENERALIZE → S_DISCOVER : similar code found
117
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
118
+
119
+ S_DISCOVER → S_FIX : fixable sibling → cross_phase_loops++
120
+ S_DISCOVER → S_REVIEW : new target, loops < max_loops cross_phase_loops++
121
+ S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops
122
+ </transitions>
123
+
124
+ <actions>
125
+
126
+ ### A_INTAKE
127
+ 1. Parse target + flags file list. Create SESSION_DIR, derive phase_goals[]
128
+ 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
129
+ 3. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
130
+
131
+ Commit: `"odyssey-review({slug}): INTAKE — parse target and load context"`
132
+
133
+ ### A_RESUME_SESSION
134
+ Glob latest session → read `session.json` → jump to `current_state`.
135
+
136
+ ### A_ARCHAEOLOGY
137
+ 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
138
+
139
+ **Error handling:** If any archaeology agent fails (Timeline or Blame), log W003 and proceed with available results. If delegate fails, log W003 and proceed with local agent results only.
140
+
141
+ `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
142
+ - PURPOSE: Review recent modifications related to {target}
143
+ - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
144
+
145
+ Update section 2. Commit: `"odyssey-review({slug}): ARCHAEOLOGY — git history analysis"`
146
+
147
+ ### A_EXPLORE
148
+ Skip if no CLI tools (W006).
149
+
150
+ `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
151
+ - PURPOSE: Call chains, recent changes, error gaps, similar patterns
152
+ - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
153
+
154
+ Write `explore.json` + evidence phase=explore. Update section 3. Mark G2. Commit: `"odyssey-review({slug}): EXPLORE — codebase exploration"`
155
+
156
+ ### A_REVIEW
157
+ Spawn N parallel Agents, one per dimension:
158
+ - **Correctness**: logic errors, boundary conditions, null/undefined, race conditions
159
+ - **Security**: injection, XSS, CSRF, data exposure, auth bypass
160
+ - **Performance**: hot paths, N+1, memory leaks, unnecessary recomputation
161
+ - **Architecture**: layer violations, circular deps, interface contracts, SoC
162
+
163
+ Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence phase=review. Write `review_result` + section 4 severity matrix. Mark G1.
164
+
165
+ Commit: `"odyssey-review({slug}): REVIEW — multi-dimension review complete"`
166
+
167
+ ### A_FIX
168
+ Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`.
169
+
170
+ ```
171
+ for tier in [critical, high, medium, low].filter(>= threshold):
172
+ for each unfixed candidate: read +/-20 lines fix evidence phase=fix
173
+ re-review modified area (new findings append, continue; max 2 per tier)
174
+ tier done → auto-commit
175
+ ```
176
+
177
+ Normal: ask_question per tier. `-y`: auto-fix all.
178
+ Remaining > 0 → retry (max_fix_rounds = 5). Unchanged 2 rounds → classify each individually. After 5 rounds with remaining > 0 → escalate: Normal: ask_question (continue/accept/reclassify) | `-y`: classify remaining as `deferred`, proceed.
179
+ Blanket "pre-existing" forbidden.
180
+
181
+ Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`
182
+
183
+ ### A_CONFIRM
184
+ Run tests + `maestro delegate --role review --mode analysis` (`run_in_background: true`) for zero-residual review.
185
+ - `remaining == 0 AND new == 0` confirmed, mark G3
186
+ - Otherwise → needs_rework → S_FIX
187
+
188
+ Update `confirmation` + `remaining_actionable` + section 5.
189
+
190
+ Commit: `"odyssey-review({slug}): CONFIRM — zero-residual verified"`
191
+
192
+ ### A_GENERALIZE
193
+
194
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "zero remaining," or context pressure are NOT valid skip reasons.**
195
+
196
+ Pattern source: review findings with severity >= medium.
197
+
198
+ **Step 1 — 3-layer pattern extraction** from confirmed findings:
199
+
200
+ | Layer | Method | Targets |
201
+ |-------|--------|---------|
202
+ | Syntax | Build regex from fix diffs → Grep | Unchecked return values, deprecated API calls, missing type assertion, unhandled await |
203
+ | Semantic | Understand anti-pattern per dimension → Agent scan | Logic inversion in edge case, unhandled rejection, incomplete state machine transition |
204
+ | Structural | Find files with same handler/validator shape | Similar route handlers, parallel DTO validators, analogous test fixtures |
205
+
206
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
207
+
208
+ **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.
209
+
210
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
211
+
212
+ | Agent | Strategy | Scope |
213
+ |-------|----------|-------|
214
+ | Syntax grep | Grep regex from pattern signatures | Full project |
215
+ | Semantic scan | Per-dimension anti-pattern check | Related modules |
216
+ | Structural match | Find structurally similar files | Full project |
217
+ | Historical grep | `git log -S` for pattern signatures | Git history |
218
+
219
+ **Step 3 — Cross-layer dedup:** multi-layer hit boost | single-layer → `needs_review` | historically fixed → `regression_risk`
220
+
221
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
222
+
223
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
224
+ ```json
225
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
226
+ ```
227
+
228
+ **Transition guard:** `S_GENERALIZE S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G4 done.
229
+
230
+ Commit: `"odyssey-review({slug}): GENERALIZE — pattern scan complete"`
231
+
232
+ ### A_DISCOVER
233
+
234
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
235
+
236
+ 1. **Triage** each hit with ±10 lines context → classify:
237
+ - `bug` — same defect pattern confirmed in sibling code
238
+ - `risk` potential issue needing guard
239
+ - `safe` false positive (must log individual reason blanket "pre-existing" forbidden)
240
+
241
+ 2. **Route:**
242
+
243
+ | Classification | Action |
244
+ |---------------|--------|
245
+ | fixable sibling | Immediate fix → back to S_FIX, `cross_phase_loops++` |
246
+ | new target needing review | Route to S_REVIEW, `cross_phase_loops++` |
247
+ | risk + guard addable | Fix directly |
248
+ | risk + complex | Create issue |
249
+ | safe | Skip with logged per-item reason |
250
+
251
+ Normal: ask_question per hit | `-y`: auto-fix with template, create issue for rest
252
+
253
+ 3. **Cross-phase loops:** `loops >= max_loops` must log per-item reasons, advance to S_RECORD.
254
+
255
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G5 done.
256
+
257
+ Commit: `"odyssey-review({slug}): DISCOVER — sibling triage complete"`
258
+
259
+ ### A_RECORD
260
+
261
+ 1. Finalize understanding.md section 8 — learnings by Knowledge Persistence categories:
262
+ - Cross-dimension recurring pattern `/spec-add review`
263
+ - Security finding `/spec-add debug`
264
+ - Architecture violation pattern `/spec-add arch`
265
+ - Reusable generalization pattern `/spec-add coding`
266
+
267
+ 2. Mark G6 done. Pending decisions: Normal → ask_question | `-y` → skip (show deferred count).
268
+
269
+ 3. **Goal audit (hardened):**
270
+ - `done` → confirmed
271
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
272
+ - **Hard rule:** G4 and G5 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: ask_question | `-y`: record `failed`)
273
+ - `phase_goals_all_done = true` only when all goals pass this audit
274
+
275
+ 4. `current_state = "COMPLETED"`, emit completion summary.
276
+
277
+ **Completion summary:**
278
+ ```
279
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
280
+ Target: {target} Dimensions: {dims}
281
+ Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
282
+ Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
283
+ Issues: {N} created
284
+ Decisions: {N} resolved, {M} pending, {K} deferred
285
+ Learnings: {N} persisted
286
+ Self-iter: {N} rounds across {M} stages
287
+ Goals: {done}/{total} ({skipped} skipped)
288
+ ---
289
+ ```
290
+
291
+ Commit: `"odyssey-review({slug}): RECORD — summary and knowledge persistence"`
292
+
293
+ </actions>
294
+
295
+ <appendix>
296
+
297
+ ### `-y` review-specific points
298
+
299
+ | Decision Point | Normal | `-y` |
300
+ |---------------|--------|------|
301
+ | S_FIX tier candidates | ask_question | auto-fix, deferred |
302
+ | S_FIX re-review new findings | ask_question | auto-append |
303
+ | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
304
+ | A_DISCOVER hit routing | ask_question | auto-fix with template, create issue for rest |
305
+
306
+ ### Goal Prompt convergence rules
307
+
308
+ ```
309
+ Stop when remaining_actionable == 0, confirmation == confirmed,
310
+ generalization exhausted, phase_goals_all_done=true.
311
+ Fix iterates by severity tier; each tier re-reviews modified area, new findings appended.
312
+ Every finding must have action (fix/issue/decision). Decision pending must ask_question.
313
+ ```
314
+
315
+ </appendix>
316
+
317
+ </state_machine>
318
+
319
+ <error_codes>
320
+ | Code | Severity | Condition | Recovery |
321
+ |------|----------|-----------|----------|
322
+ | E001 | error | No target specified | Provide target |
323
+ | E002 | error | Target path not found | Check path |
324
+ | W001 | warning | No git history | Proceed |
325
+ | W002 | warning | Some dimension agents failed | Partial coverage |
326
+ | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
327
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
328
+ </error_codes>
329
+
330
+ <success_criteria>
331
+ - [ ] Session + 4 output files + prior knowledge searched
332
+ - [ ] Archaeology + CLI review → evidence phase=archaeology
333
+ - [ ] CLI exploration → explore.json + evidence phase=explore
334
+ - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0)
335
+ - [ ] Per-tier re-review gate; every unfixed finding individually classified
336
+ - [ ] understanding.md sections 1-8 progressive
337
+ - [ ] Fix + confirmed (unless --skip-fix)
338
+ - [ ] Generalization + scan (unless --skip-generalize)
339
+ - [ ] Discoveries classified; unfixed findings individually justified
340
+ - [ ] phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
341
+ - [ ] Completion summary
342
+ </success_criteria>
343
+
344
+ <next_step_routing>
345
+ | Condition | Next |
346
+ |-----------|------|
347
+ | Deeper debug needed | `/odyssey-debug "<finding>"` |
348
+ | Issues created | `/manage-issue list --source review-odyssey` |
349
+ | Document pattern | `/learn-decompose <module>` |
350
+ | Plan fixes | `/maestro-plan --gaps` |
351
+ </next_step_routing>
352
+ </output>