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,256 +14,341 @@ 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
- archaeology → explore → diagnose → fix & confirm → generalize → discover siblings → persist.
21
- Exhaustive iteration until root cause confirmed or INCONCLUSIVE.
22
- </purpose>
23
-
24
- <boundary>
25
- **In scope:** Single bug/issue full loop.
26
- **Out of scope:** Features → `/odyssey-planex` | Quality review → `/odyssey-review-test-fix` | UI → `/odyssey-ui` | Architecture → `/maestro-plan`
27
-
28
- **`--template <name>`:**
29
-
30
- | Template | Strategy | Use case |
31
- |----------|----------|----------|
32
- | `performance` | profiling → hot path → allocation → cache | Performance degradation |
33
- | `memory-leak` | heap snapshot → retention chain → lifecycle | Memory leaks |
34
- | `race-condition` | timeline → concurrent access → lock analysis | Race conditions |
35
- | `regression` | git bisect → diff analysis → boundary check | Regressions |
36
- | `crash` | stack trace → null chain → error propagation | Crashes / exceptions |
37
- </boundary>
38
-
39
- <context>
40
- $ARGUMENTS
41
-
42
- **Flags:** `--skip-fix` analysis-only | `--skip-generalize` quick fix | `--template <name>` | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
43
-
44
- **Session**: `.workflow/scratch/{YYYYMMDD}-debug-odyssey-{slug}/`
45
- **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
46
-
47
- **session.json — debug-specific fields:**
48
- ```json
49
- { "issue": "", "diagnosis_retries": 0, "root_cause": null, "confirmation": null,
50
- "patterns": [], "generalization_stats": null }
51
- ```
52
-
53
- **evidence.ndjson phases:** `archaeology|explore|diagnosis|discovery|decision|self-iteration`
54
- - `archaeology`: `sha`, `author`, `date`, `message`, `relevance`
55
- - `explore`: `category` (call_chain|recent_change|error_gap|similar_pattern), `detail`
56
- - `diagnosis`: `hypothesis`, `result` (confirmed|disproved|inconclusive)
57
- - `discovery`: `file`, `line`, `classification` (safe|risk|bug), `action` (fix|issue|decision|skip)
58
- - `decision`: `question`, `options`, `context`, `status`, `resolution`
59
- - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
60
-
61
- **explore.json**: `{call_chains, recent_changes, error_gaps, similar_patterns, cli_tool, timestamp}`
62
-
63
- **phase_goals[]:**
64
-
65
- | ID | Goal | done_when | phase | skip_when |
66
- |----|------|-----------|-------|-----------|
67
- | G1 | Root cause identified | phase=diagnosis result=confirmed | S_DIAGNOSE | — |
68
- | G2 | Explore context gathered | explore.json ≥1 category | S_EXPLORE | — |
69
- | G3 | Fix applied and confirmed | confirmation.overall == confirmed | S_CONFIRM | skip_fix |
70
- | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
71
- | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
72
- | G6 | Learnings persisted | spec entries created OR none actionable | S_RECORD | — |
73
-
74
- **understanding.md — 9 sections:**
75
- 1. Issue & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
76
- 4. Hypotheses ← S_DIAGNOSE | 5. Root Cause ← S_DIAGNOSE | 6. Fix & Confirmation ← S_FIX+S_CONFIRM
77
- 7. Generalization ← S_GENERALIZE | 8. Discoveries ← S_DISCOVER | 9. Learnings ← S_RECORD
78
-
79
- **Knowledge Persistence categories (§9):**
80
-
81
- | Category | Content | Follow-up |
82
- |----------|---------|-----------|
83
- | Recurring root cause pattern | Type + triggers + fix + detection | `/spec-add debug` |
84
- | Non-obvious workaround | Problem + steps + why obvious fix fails | `/spec-add learning` |
85
- | Architecture boundary violation | Violation + correct boundary + verification | `/spec-add arch` |
86
- | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
87
- </context>
88
-
89
- <invariants>
90
- 1. **Evidence append-only** — never delete or overwrite evidence.ndjson entries
91
- 2. **Phase goal tracking** — mark goal done/failed before transition; no silent skips
92
- </invariants>
93
-
94
- <self_iteration>
95
- Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
96
- </self_iteration>
97
-
98
- <state_machine>
99
-
100
- <states>
101
- S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_DIAGNOSE → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
102
- </states>
103
-
104
- <transitions>
105
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME_SESSION
106
- S_INTAKE → S_ARCHAEOLOGY : issue parsedA_INTAKE
107
- S_INTAKE → S_INTAKE : no issue, no session ask_user
108
-
109
- S_ARCHAEOLOGY → S_EXPLORE : complete
110
- S_EXPLORE → S_DIAGNOSE : complete
111
-
112
- S_DIAGNOSE → S_FIX : confirmed, !skip_fix
113
- S_DIAGNOSE → S_GENERALIZE : confirmed, skip_fix, !skip_generalize
114
- S_DIAGNOSE → S_RECORD : confirmed, skip_fix, skip_generalize
115
- S_DIAGNOSE → S_DIAGNOSE : all hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
116
- S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
117
-
118
- S_FIX → S_CONFIRM : fix implemented
119
- S_CONFIRM S_GENERALIZE : confirmed, !skip_generalize
120
- S_CONFIRM → S_RECORD : confirmed, skip_generalize
121
- S_CONFIRM → S_FIX : needs_rework
122
-
123
- S_GENERALIZE → S_DISCOVER : similar code found
124
- S_GENERALIZE → S_RECORD : no similar code
125
-
126
- S_DISCOVER → S_DIAGNOSE : new bug → cross_phase_loops++
127
- S_DISCOVER → S_FIX : same-pattern bug + fix_template, !skip_fix → cross_phase_loops++
128
- S_DISCOVER → S_RECORD : remaining_actionable == 0
129
- S_DISCOVER → S_RECORD : loops >= max_loops → log per-item reasons
130
-
131
- S_RECORD → END : complete
132
- </transitions>
133
-
134
- <actions>
135
-
136
- ### A_INTAKE
137
- 1. Parse arguments, generate slug, create SESSION_DIR
138
- 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
139
- 3. Derive `phase_goals[]` from flags
140
- 4. Write `session.json` + `understanding.md` §1, emit Goal Prompt
141
-
142
- Commit: `"odyssey-debug({slug}): INTAKE — parse target and load context"`
143
-
144
- ### A_RESUME_SESSION
145
- Glob latest session → read `session.json` → jump to `current_state`.
146
-
147
- ### A_ARCHAEOLOGY
148
- 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
149
-
150
- `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
151
- - PURPOSE: Review recent modifications related to {issue}
152
- - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
153
-
154
- Update §2. Commit: `"odyssey-debug({slug}): ARCHAEOLOGY — git history analysis"`
155
-
156
- ### A_EXPLORE
157
- Skip if no CLI tools (W006).
158
-
159
- `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
160
- - PURPOSE: Call chains, recent changes, error gaps, similar patterns
161
- - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
162
-
163
- Write `explore.json` + evidence phase=explore. Update §3. Mark G2. Commit: `"odyssey-debug({slug}): EXPLORE — codebase exploration"`
164
-
165
- ### A_DIAGNOSE
166
- 1. Hypotheses from evidence, ranked [HIGH]/[MEDIUM]/[LOW] → §4
167
- 2. Test eachevidence phase=diagnosis
168
- 3. Ambiguity → evidence phase=decision; Normal: ask_user | `-y`: defer
169
- 4. Confirmed`session.json.root_cause` + §5. Mark G1.
170
-
171
- Commit: `"odyssey-debug({slug}): DIAGNOSE — root cause confirmed"`
172
-
173
- ### A_ESCALATE_DIAGNOSIS
174
- `diagnosis_retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, → S_DIAGNOSE. >= 3: Normal → ask_user | `-y` → INCONCLUSIVE → S_RECORD.
175
-
176
- ### A_FIX
177
- 1. Present root cause + proposed fix. Normal: ask_user | `-y`: auto proceed
178
- 2. Implement fix, evidence phase=decision
179
-
180
- Commit: `"odyssey-debug({slug}): FIX — {summary}"`
181
-
182
- ### A_CONFIRM
183
- 1. Run covering tests
184
- 2. `maestro delegate --role review --mode analysis` (`run_in_background: true`):
185
- - EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk}
186
- 3. `session.json.confirmation`: `{test_result, cli_review, overall: "confirmed|needs_rework"}`
187
- 4. Update §6. `needs_rework` S_FIX. `confirmed` → mark G3.
188
-
189
- Commit: `"odyssey-debug({slug}): CONFIRM — fix verified"`
190
-
191
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
192
- Base shared_actions. Debug overrides:
193
- - **A_GENERALIZE** pattern source: root cause + fix
194
- - **A_RECORD** learnings per Knowledge Persistence table
195
-
196
- **Completion summary:**
197
- ```
198
- --- DEBUG ODYSSEY COMPLETE ---
199
- Issue: {issue}
200
- Root cause: {root_cause.hypothesis}
201
- Fix: {applied|skipped|inconclusive}
202
- Patterns: {patterns_extracted} ({by_layer})
203
- Scan hits: {total_hits} ({cross_layer_confirmed} confirmed)
204
- Issues: {N} created
205
- Decisions: {N} resolved, {M} pending, {K} deferred
206
- Learnings: {N} persisted
207
- Self-iter: {N} rounds across {M} stages
208
- Goals: {done}/{total} ({skipped} skipped)
209
- ---
210
- ```
211
-
212
- </actions>
213
-
214
- <appendix>
215
-
216
- ### `-y` debug-specific points
217
-
218
- | Decision Point | Normal | `-y` |
219
- |---------------|--------|------|
220
- | A_DIAGNOSE ambiguity | ask_user | deferred |
221
- | A_ESCALATE 3-strike | ask_user | INCONCLUSIVE |
222
- | A_FIX direction | ask_user | auto proceed |
223
-
224
- ### Goal Prompt convergence rules
225
-
226
- ```
227
- Stop when root cause confirmed (or INCONCLUSIVE), fix verified,
228
- generalization exhausted, phase_goals_all_done=true.
229
- All sibling bugs fixed or issued — no leftovers.
230
- ```
231
-
232
- </appendix>
233
-
234
- </state_machine>
235
-
236
- <error_codes>
237
- | Code | Severity | Condition | Recovery |
238
- |------|----------|-----------|----------|
239
- | E001 | error | No issue, no session | Provide issue or -c |
240
- | W001 | warning | No relevant git history | Proceed |
241
- | W002 | warning | 3 retries exhausted | INCONCLUSIVE |
242
- | W003 | warning | Partial archaeology agent failure (Timeline or Blame) | Proceed with available results, log failed agent |
243
- | W005 | warning | Pending decisions | Filter evidence phase=decision |
244
- | W006 | warning | No CLI tools | Skip explore |
245
- </error_codes>
246
-
247
- <success_criteria>
248
- - [ ] Session + 4 output files + prior knowledge searched
249
- - [ ] Archaeology + CLI review evidence phase=archaeology
250
- - [ ] CLI exploration → explore.json + evidence phase=explore
251
- - [ ] Hypotheses tested, root cause with evidence refs
252
- - [ ] understanding.md 9 sections progressive
253
- - [ ] Fix + confirmed (unless --skip-fix)
254
- - [ ] Generalization + scan (unless --skip-generalize)
255
- - [ ] Discoveries classified; unfixed findings individually justified
256
- - [ ] phase_goals + goal audit + resumable via -c
257
- - [ ] Completion summary
258
- </success_criteria>
259
-
260
- <next_step_routing>
261
- | Condition | Next |
262
- |-----------|------|
263
- | Discovery issues | `/manage-issue list --source debug-odyssey` |
264
- | Document pattern | `/learn-decompose <module>` |
265
- | Formal review | `/quality-review <phase>` |
266
- | Second opinion | `/learn-second-opinion <understanding.md>` |
267
- | Related question | `/learn-investigate "<question>"` |
268
- | Pending decisions | Filter evidence phase=decision status=pending |
269
- </next_step_routing>
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
19
+ <purpose>
20
+ archaeology → explore → diagnose → fix & confirm → generalize → discover siblings → persist.
21
+ Exhaustive iteration until root cause confirmed or INCONCLUSIVE.
22
+ </purpose>
23
+
24
+ <boundary>
25
+ **In scope:** Single bug/issue full loop.
26
+ **Out of scope:** Features → `/odyssey-planex` | Quality review → `/odyssey-review-test-fix` | UI → `/odyssey-ui` | Architecture → `/maestro-plan`
27
+
28
+ **`--template <name>`:**
29
+
30
+ | Template | Strategy | Use case |
31
+ |----------|----------|----------|
32
+ | `performance` | profiling → hot path → allocation → cache | Performance degradation |
33
+ | `memory-leak` | heap snapshot → retention chain → lifecycle | Memory leaks |
34
+ | `race-condition` | timeline → concurrent access → lock analysis | Race conditions |
35
+ | `regression` | git bisect → diff analysis → boundary check | Regressions |
36
+ | `crash` | stack trace → null chain → error propagation | Crashes / exceptions |
37
+ </boundary>
38
+
39
+ <context>
40
+ $ARGUMENTS
41
+
42
+ **Flags:** `--skip-fix` analysis-only | `--skip-generalize` quick fix | `--template <name>` | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
43
+
44
+ **Session**: `.workflow/scratch/{YYYYMMDD}-debug-odyssey-{slug}/`
45
+ **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
46
+
47
+ **session.json — debug-specific fields:**
48
+ ```json
49
+ { "issue": "", "diagnosis_retries": 0, "root_cause": null, "confirmation": null,
50
+ "patterns": [], "generalization_stats": null }
51
+ ```
52
+
53
+ **evidence.ndjson phases:** `archaeology|explore|diagnosis|discovery|decision|self-iteration`
54
+ - `archaeology`: `sha`, `author`, `date`, `message`, `relevance`
55
+ - `explore`: `category` (call_chain|recent_change|error_gap|similar_pattern), `detail`
56
+ - `diagnosis`: `hypothesis`, `result` (confirmed|disproved|inconclusive)
57
+ - `discovery`: `file`, `line`, `classification` (safe|risk|bug), `action` (fix|issue|decision|skip)
58
+ - `decision`: `question`, `options`, `context`, `status`, `resolution`
59
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
60
+
61
+ **explore.json**: `{call_chains, recent_changes, error_gaps, similar_patterns, cli_tool, timestamp}`
62
+
63
+ **phase_goals[]:**
64
+
65
+ | ID | Goal | done_when | phase | skip_when |
66
+ |----|------|-----------|-------|-----------|
67
+ | G1 | Root cause identified | phase=diagnosis result=confirmed | S_DIAGNOSE | — |
68
+ | G2 | Explore context gathered | explore.json ≥1 category | S_EXPLORE | — |
69
+ | G3 | Fix applied and confirmed | confirmation.overall == confirmed | S_CONFIRM | skip_fix |
70
+ | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
71
+ | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
72
+ | G6 | Learnings persisted | spec entries created OR none actionable | S_RECORD | — |
73
+
74
+ **understanding.md — 9 sections:**
75
+ 1. Issue & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
76
+ 4. Hypotheses ← S_DIAGNOSE | 5. Root Cause ← S_DIAGNOSE | 6. Fix & Confirmation ← S_FIX+S_CONFIRM
77
+ 7. Generalization ← S_GENERALIZE | 8. Discoveries ← S_DISCOVER | 9. Learnings ← S_RECORD
78
+
79
+ **Knowledge Persistence categories (§9):**
80
+
81
+ | Category | Content | Follow-up |
82
+ |----------|---------|-----------|
83
+ | Recurring root cause pattern | Type + triggers + fix + detection | `/spec-add debug` |
84
+ | Non-obvious workaround | Problem + steps + why obvious fix fails | `/spec-add learning` |
85
+ | Architecture boundary violation | Violation + correct boundary + verification | `/spec-add arch` |
86
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
87
+ </context>
88
+
89
+ <invariants>
90
+ 1. **Evidence append-only** — never delete or overwrite evidence.ndjson entries
91
+ 2. **Phase goal tracking** — mark goal done/failed before transition; no silent skips
92
+ 3. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "No findings" from prior phases, convergence signals, or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
93
+ </invariants>
94
+
95
+ <self_iteration>
96
+ Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
97
+ </self_iteration>
98
+
99
+ <state_machine>
100
+
101
+ <states>
102
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_DIAGNOSE → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
103
+ </states>
104
+
105
+ <transitions>
106
+ S_INTAKE → S_INTAKE : -c + session found A_RESUME_SESSION
107
+ S_INTAKE → S_ARCHAEOLOGY : issue parsedA_INTAKE
108
+ S_INTAKE → S_INTAKE : no issue, no session → ask_user
109
+
110
+ S_ARCHAEOLOGY → S_EXPLORE : complete
111
+ S_EXPLORE → S_DIAGNOSE : complete
112
+
113
+ S_DIAGNOSE → S_FIX : confirmed, !skip_fix
114
+ S_DIAGNOSE → S_GENERALIZE : confirmed, skip_fix, !skip_generalize
115
+ S_DIAGNOSE → S_RECORD : confirmed, skip_fix, skip_generalize
116
+ S_DIAGNOSE → S_DIAGNOSE : all hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
117
+ S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
118
+
119
+ S_FIX S_CONFIRM : fix implemented
120
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
121
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
122
+ S_CONFIRM → S_FIX : needs_rework
123
+
124
+ S_GENERALIZE → S_DISCOVER : similar code found
125
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
126
+
127
+ S_DISCOVER → S_DIAGNOSE : new bug → cross_phase_loops++
128
+ S_DISCOVER → S_FIX : same-pattern bug + fix_template, !skip_fix → cross_phase_loops++
129
+ S_DISCOVER → S_RECORD : remaining_actionable == 0
130
+ S_DISCOVER → S_RECORD : loops >= max_loops → log per-item reasons
131
+
132
+ S_RECORD → END : complete
133
+ </transitions>
134
+
135
+ <actions>
136
+
137
+ ### A_INTAKE
138
+ 1. Parse arguments, generate slug, create SESSION_DIR
139
+ 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
140
+ 3. Derive `phase_goals[]` from flags
141
+ 4. Write `session.json` + `understanding.md` §1, emit Goal Prompt
142
+
143
+ Commit: `"odyssey-debug({slug}): INTAKE — parse target and load context"`
144
+
145
+ ### A_RESUME_SESSION
146
+ Glob latest session → read `session.json` → jump to `current_state`.
147
+
148
+ ### A_ARCHAEOLOGY
149
+ 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
150
+
151
+ `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
152
+ - PURPOSE: Review recent modifications related to {issue}
153
+ - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
154
+
155
+ Update §2. Commit: `"odyssey-debug({slug}): ARCHAEOLOGY — git history analysis"`
156
+
157
+ ### A_EXPLORE
158
+ Skip if no CLI tools (W006).
159
+
160
+ `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
161
+ - PURPOSE: Call chains, recent changes, error gaps, similar patterns
162
+ - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
163
+
164
+ Write `explore.json` + evidence phase=explore. Update §3. Mark G2. Commit: `"odyssey-debug({slug}): EXPLORE — codebase exploration"`
165
+
166
+ ### A_DIAGNOSE
167
+ 1. Hypotheses from evidence, ranked [HIGH]/[MEDIUM]/[LOW] §4
168
+ 2. Test each → evidence phase=diagnosis
169
+ 3. Ambiguityevidence phase=decision; Normal: ask_user | `-y`: defer
170
+ 4. Confirmed → `session.json.root_cause` + §5. Mark G1.
171
+
172
+ Commit: `"odyssey-debug({slug}): DIAGNOSE — root cause confirmed"`
173
+
174
+ ### A_ESCALATE_DIAGNOSIS
175
+ `diagnosis_retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, → S_DIAGNOSE. >= 3: Normal → ask_user | `-y` → INCONCLUSIVE → S_RECORD.
176
+
177
+ ### A_FIX
178
+ 1. Present root cause + proposed fix. Normal: ask_user | `-y`: auto proceed
179
+ 2. Implement fix, evidence phase=decision
180
+
181
+ Commit: `"odyssey-debug({slug}): FIX — {summary}"`
182
+
183
+ ### A_CONFIRM
184
+ 1. Run covering tests
185
+ 2. `maestro delegate --role review --mode analysis` (`run_in_background: true`):
186
+ - EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk}
187
+ 3. `session.json.confirmation`: `{test_result, cli_review, overall: "confirmed|needs_rework"}`
188
+ 4. Update §6. `needs_rework` → S_FIX. `confirmed` → mark G3.
189
+
190
+ Commit: `"odyssey-debug({slug}): CONFIRM — fix verified"`
191
+
192
+ ### A_GENERALIZE
193
+
194
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "no findings," or context pressure are NOT valid skip reasons.**
195
+
196
+ Pattern source: confirmed root cause + applied fix.
197
+
198
+ **Step 1 3-layer pattern extraction:**
199
+
200
+ | Layer | Method | Targets |
201
+ |-------|--------|---------|
202
+ | Syntax | Build regex from fix diff → Grep | Missing `await`, unchecked null, wrong comparison, identical error-handling gap |
203
+ | Semantic | Understand anti-pattern that caused the bug → Agent scan | Same async-without-catch, same boundary assumption, race on shared state |
204
+ | Structural | Find files with same module shape / import graph | Sibling handlers, parallel service implementations, same-shape error handlers |
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 — a single-layer quick grep does NOT satisfy.
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 | Anti-pattern understanding → scan same bug class | Related modules |
216
+ | Structural match | Find structurally similar files to buggy file | 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 §7 + 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-debug({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
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
+ | bug + fix_template applicable | Immediate fix → back to S_FIX |
246
+ | bug + cross-module or no template | Create issue (fix suggestion + impact) |
247
+ | risk + guard addable directly | Fix directly |
248
+ | risk + complex | Create issue |
249
+ | safe | Skip with logged per-item reason |
250
+
251
+ Normal: ask_user per hit | `-y`: auto-fix bugs with fix_template, create issue for rest
252
+
253
+ 3. **Cross-phase loops:** `cross_phase_loops++` on fix/diagnose return. `loops >= max_loops` → must log per-item reasons.
254
+
255
+ 4. Append evidence phase=discovery. Update understanding.md §8. Mark G5 done.
256
+
257
+ Commit: `"odyssey-debug({slug}): DISCOVER sibling triage complete"`
258
+
259
+ ### A_RECORD
260
+
261
+ 1. Finalize understanding.md §9 — learnings by Knowledge Persistence categories:
262
+ - Recurring root cause pattern → `/spec-add debug`
263
+ - Non-obvious workaround `/spec-add learning`
264
+ - Architecture boundary violation `/spec-add arch`
265
+ - Reusable generalization pattern `/spec-add coding`
266
+
267
+ 2. Mark G6 done. Pending decisions: Normal → ask_user | `-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_user | `-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
+ --- DEBUG ODYSSEY COMPLETE ---
280
+ Issue: {issue}
281
+ Root cause: {root_cause.hypothesis}
282
+ Fix: {applied|skipped|inconclusive}
283
+ Patterns: {patterns_extracted} ({by_layer})
284
+ Scan hits: {total_hits} ({cross_layer_confirmed} confirmed)
285
+ Issues: {N} created
286
+ Decisions: {N} resolved, {M} pending, {K} deferred
287
+ Learnings: {N} persisted
288
+ Self-iter: {N} rounds across {M} stages
289
+ Goals: {done}/{total} ({skipped} skipped)
290
+ ---
291
+ ```
292
+
293
+ Commit: `"odyssey-debug({slug}): RECORD — summary and knowledge persistence"`
294
+
295
+ </actions>
296
+
297
+ <appendix>
298
+
299
+ ### `-y` debug-specific points
300
+
301
+ | Decision Point | Normal | `-y` |
302
+ |---------------|--------|------|
303
+ | A_DIAGNOSE ambiguity | ask_user | deferred |
304
+ | A_ESCALATE 3-strike | ask_user | INCONCLUSIVE |
305
+ | A_FIX direction | ask_user | auto proceed |
306
+ | A_DISCOVER hit routing | ask_user | auto-fix bugs with template, create issue for rest |
307
+
308
+ ### Goal Prompt convergence rules
309
+
310
+ ```
311
+ Stop when root cause confirmed (or INCONCLUSIVE), fix verified,
312
+ generalization exhausted, phase_goals_all_done=true.
313
+ All sibling bugs fixed or issued — no leftovers.
314
+ ```
315
+
316
+ </appendix>
317
+
318
+ </state_machine>
319
+
320
+ <error_codes>
321
+ | Code | Severity | Condition | Recovery |
322
+ |------|----------|-----------|----------|
323
+ | E001 | error | No issue, no session | Provide issue or -c |
324
+ | W001 | warning | No relevant git history | Proceed |
325
+ | W002 | warning | 3 retries exhausted | INCONCLUSIVE |
326
+ | W003 | warning | Partial archaeology agent failure (Timeline or Blame) | Proceed with available results, log failed agent |
327
+ | W005 | warning | Pending decisions | Filter evidence phase=decision |
328
+ | W006 | warning | No CLI tools | Skip explore |
329
+ | W007 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
330
+ </error_codes>
331
+
332
+ <success_criteria>
333
+ - [ ] Session + 4 output files + prior knowledge searched
334
+ - [ ] Archaeology + CLI review → evidence phase=archaeology
335
+ - [ ] CLI exploration → explore.json + evidence phase=explore
336
+ - [ ] Hypotheses tested, root cause with evidence refs
337
+ - [ ] understanding.md 9 sections progressive
338
+ - [ ] Fix + confirmed (unless --skip-fix)
339
+ - [ ] Generalization + scan (unless --skip-generalize)
340
+ - [ ] Discoveries classified; unfixed findings individually justified
341
+ - [ ] phase_goals + goal audit + resumable via -c
342
+ - [ ] Completion summary
343
+ </success_criteria>
344
+
345
+ <next_step_routing>
346
+ | Condition | Next |
347
+ |-----------|------|
348
+ | Discovery issues | `/manage-issue list --source debug-odyssey` |
349
+ | Document pattern | `/learn-decompose <module>` |
350
+ | Formal review | `/quality-review <phase>` |
351
+ | Second opinion | `/learn-second-opinion <understanding.md>` |
352
+ | Related question | `/learn-investigate "<question>"` |
353
+ | Pending decisions | Filter evidence phase=decision status=pending |
354
+ </next_step_routing>