maestro-flow 0.5.3 → 0.5.31

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 (259) hide show
  1. package/.agents/skills/learn-follow/SKILL.md +114 -114
  2. package/.agents/skills/learn-investigate/SKILL.md +138 -139
  3. package/.agents/skills/learn-second-opinion/SKILL.md +105 -109
  4. package/.agents/skills/maestro/SKILL.md +2 -10
  5. package/.agents/skills/maestro-amend/SKILL.md +152 -152
  6. package/.agents/skills/maestro-analyze/SKILL.md +201 -252
  7. package/.agents/skills/maestro-blueprint/SKILL.md +175 -190
  8. package/.agents/skills/maestro-brainstorm/SKILL.md +196 -200
  9. package/.agents/skills/maestro-collab/SKILL.md +159 -159
  10. package/.agents/skills/maestro-companion/SKILL.md +517 -517
  11. package/.agents/skills/maestro-composer/SKILL.md +173 -164
  12. package/.agents/skills/maestro-execute/SKILL.md +169 -170
  13. package/.agents/skills/maestro-fork/SKILL.md +97 -96
  14. package/.agents/skills/maestro-grill/SKILL.md +161 -162
  15. package/.agents/skills/maestro-guard/SKILL.md +93 -92
  16. package/.agents/skills/maestro-impeccable/SKILL.md +296 -253
  17. package/.agents/skills/maestro-init/SKILL.md +117 -118
  18. package/.agents/skills/maestro-merge/SKILL.md +73 -66
  19. package/.agents/skills/maestro-milestone-audit/SKILL.md +4 -10
  20. package/.agents/skills/maestro-milestone-complete/SKILL.md +6 -7
  21. package/.agents/skills/maestro-milestone-release/SKILL.md +122 -131
  22. package/.agents/skills/maestro-next/SKILL.md +241 -245
  23. package/.agents/skills/maestro-overlay/SKILL.md +176 -166
  24. package/.agents/skills/maestro-plan/SKILL.md +211 -197
  25. package/.agents/skills/maestro-player/SKILL.md +167 -167
  26. package/.agents/skills/maestro-quick/SKILL.md +69 -63
  27. package/.agents/skills/maestro-ralph/SKILL.md +2 -36
  28. package/.agents/skills/maestro-ralph-beta/SKILL.md +861 -872
  29. package/.agents/skills/maestro-ralph-execute/SKILL.md +234 -234
  30. package/.agents/skills/maestro-roadmap/SKILL.md +159 -172
  31. package/.agents/skills/maestro-swarm-workflow/SKILL.md +229 -250
  32. package/.agents/skills/maestro-tools-execute/SKILL.md +108 -103
  33. package/.agents/skills/maestro-tools-register/SKILL.md +148 -143
  34. package/.agents/skills/maestro-ui-codify/SKILL.md +103 -86
  35. package/.agents/skills/maestro-universal-workflow/SKILL.md +534 -547
  36. package/.agents/skills/maestro-update/SKILL.md +109 -106
  37. package/.agents/skills/manage-codebase-rebuild/SKILL.md +73 -71
  38. package/.agents/skills/manage-harvest/SKILL.md +83 -81
  39. package/.agents/skills/manage-issue/SKILL.md +59 -60
  40. package/.agents/skills/manage-issue-discover/SKILL.md +70 -68
  41. package/.agents/skills/manage-kg-extractors/SKILL.md +130 -0
  42. package/.agents/skills/manage-knowhow/SKILL.md +70 -66
  43. package/.agents/skills/manage-knowhow-capture/SKILL.md +79 -69
  44. package/.agents/skills/manage-knowledge-audit/SKILL.md +91 -74
  45. package/.agents/skills/manage-status/SKILL.md +52 -42
  46. package/.agents/skills/manage-wiki/SKILL.md +69 -58
  47. package/.agents/skills/odyssey-debug/SKILL.md +445 -459
  48. package/.agents/skills/odyssey-improve/SKILL.md +477 -491
  49. package/.agents/skills/odyssey-planex/SKILL.md +576 -587
  50. package/.agents/skills/odyssey-review-test-fix/SKILL.md +400 -413
  51. package/.agents/skills/odyssey-ui/SKILL.md +431 -448
  52. package/.agents/skills/quality-auto-test/SKILL.md +140 -123
  53. package/.agents/skills/quality-debug/SKILL.md +145 -106
  54. package/.agents/skills/quality-refactor/SKILL.md +91 -53
  55. package/.agents/skills/quality-retrospective/SKILL.md +109 -63
  56. package/.agents/skills/quality-review/SKILL.md +141 -114
  57. package/.agents/skills/quality-sync/SKILL.md +74 -38
  58. package/.agents/skills/quality-test/SKILL.md +133 -103
  59. package/.agents/skills/security-audit/SKILL.md +217 -166
  60. package/.agents/skills/spec-add/SKILL.md +66 -59
  61. package/.agents/skills/spec-load/SKILL.md +68 -68
  62. package/.agents/skills/spec-remove/SKILL.md +42 -42
  63. package/.agents/skills/spec-setup/SKILL.md +38 -41
  64. package/.agy/skills/learn-follow/SKILL.md +114 -114
  65. package/.agy/skills/learn-investigate/SKILL.md +138 -139
  66. package/.agy/skills/learn-second-opinion/SKILL.md +105 -109
  67. package/.agy/skills/maestro/SKILL.md +2 -10
  68. package/.agy/skills/maestro-amend/SKILL.md +152 -152
  69. package/.agy/skills/maestro-analyze/SKILL.md +201 -252
  70. package/.agy/skills/maestro-blueprint/SKILL.md +175 -190
  71. package/.agy/skills/maestro-brainstorm/SKILL.md +196 -200
  72. package/.agy/skills/maestro-collab/SKILL.md +159 -159
  73. package/.agy/skills/maestro-companion/SKILL.md +517 -517
  74. package/.agy/skills/maestro-composer/SKILL.md +173 -164
  75. package/.agy/skills/maestro-execute/SKILL.md +169 -170
  76. package/.agy/skills/maestro-fork/SKILL.md +97 -96
  77. package/.agy/skills/maestro-grill/SKILL.md +161 -162
  78. package/.agy/skills/maestro-guard/SKILL.md +93 -92
  79. package/.agy/skills/maestro-impeccable/SKILL.md +296 -253
  80. package/.agy/skills/maestro-init/SKILL.md +117 -118
  81. package/.agy/skills/maestro-merge/SKILL.md +73 -66
  82. package/.agy/skills/maestro-milestone-audit/SKILL.md +4 -10
  83. package/.agy/skills/maestro-milestone-complete/SKILL.md +6 -7
  84. package/.agy/skills/maestro-milestone-release/SKILL.md +122 -131
  85. package/.agy/skills/maestro-next/SKILL.md +241 -245
  86. package/.agy/skills/maestro-overlay/SKILL.md +176 -166
  87. package/.agy/skills/maestro-plan/SKILL.md +211 -197
  88. package/.agy/skills/maestro-player/SKILL.md +167 -167
  89. package/.agy/skills/maestro-quick/SKILL.md +69 -63
  90. package/.agy/skills/maestro-ralph/SKILL.md +2 -36
  91. package/.agy/skills/maestro-ralph-beta/SKILL.md +861 -872
  92. package/.agy/skills/maestro-ralph-execute/SKILL.md +234 -234
  93. package/.agy/skills/maestro-roadmap/SKILL.md +159 -172
  94. package/.agy/skills/maestro-swarm-workflow/SKILL.md +229 -250
  95. package/.agy/skills/maestro-tools-execute/SKILL.md +108 -103
  96. package/.agy/skills/maestro-tools-register/SKILL.md +148 -143
  97. package/.agy/skills/maestro-ui-codify/SKILL.md +103 -86
  98. package/.agy/skills/maestro-universal-workflow/SKILL.md +534 -547
  99. package/.agy/skills/maestro-update/SKILL.md +109 -106
  100. package/.agy/skills/manage-codebase-rebuild/SKILL.md +73 -71
  101. package/.agy/skills/manage-harvest/SKILL.md +83 -81
  102. package/.agy/skills/manage-issue/SKILL.md +59 -60
  103. package/.agy/skills/manage-issue-discover/SKILL.md +70 -68
  104. package/.agy/skills/manage-kg-extractors/SKILL.md +130 -0
  105. package/.agy/skills/manage-knowhow/SKILL.md +70 -66
  106. package/.agy/skills/manage-knowhow-capture/SKILL.md +79 -69
  107. package/.agy/skills/manage-knowledge-audit/SKILL.md +91 -74
  108. package/.agy/skills/manage-status/SKILL.md +52 -42
  109. package/.agy/skills/manage-wiki/SKILL.md +69 -58
  110. package/.agy/skills/odyssey-debug/SKILL.md +445 -459
  111. package/.agy/skills/odyssey-improve/SKILL.md +477 -491
  112. package/.agy/skills/odyssey-planex/SKILL.md +576 -587
  113. package/.agy/skills/odyssey-review-test-fix/SKILL.md +400 -413
  114. package/.agy/skills/odyssey-ui/SKILL.md +431 -448
  115. package/.agy/skills/quality-auto-test/SKILL.md +140 -123
  116. package/.agy/skills/quality-debug/SKILL.md +145 -106
  117. package/.agy/skills/quality-refactor/SKILL.md +91 -53
  118. package/.agy/skills/quality-retrospective/SKILL.md +109 -63
  119. package/.agy/skills/quality-review/SKILL.md +141 -114
  120. package/.agy/skills/quality-sync/SKILL.md +74 -38
  121. package/.agy/skills/quality-test/SKILL.md +133 -103
  122. package/.agy/skills/security-audit/SKILL.md +217 -166
  123. package/.agy/skills/spec-add/SKILL.md +66 -59
  124. package/.agy/skills/spec-load/SKILL.md +68 -68
  125. package/.agy/skills/spec-remove/SKILL.md +42 -42
  126. package/.agy/skills/spec-setup/SKILL.md +38 -41
  127. package/.claude/commands/learn-follow.md +127 -127
  128. package/.claude/commands/learn-investigate.md +151 -152
  129. package/.claude/commands/learn-second-opinion.md +118 -122
  130. package/.claude/commands/maestro-amend.md +164 -164
  131. package/.claude/commands/maestro-analyze.md +215 -266
  132. package/.claude/commands/maestro-blueprint.md +189 -204
  133. package/.claude/commands/maestro-brainstorm.md +209 -213
  134. package/.claude/commands/maestro-collab.md +172 -172
  135. package/.claude/commands/maestro-companion.md +531 -531
  136. package/.claude/commands/maestro-composer.md +188 -179
  137. package/.claude/commands/maestro-execute.md +183 -184
  138. package/.claude/commands/maestro-fork.md +111 -110
  139. package/.claude/commands/maestro-grill.md +175 -176
  140. package/.claude/commands/maestro-guard.md +103 -102
  141. package/.claude/commands/maestro-impeccable.md +311 -268
  142. package/.claude/commands/maestro-init.md +130 -131
  143. package/.claude/commands/maestro-merge.md +87 -80
  144. package/.claude/commands/maestro-milestone-audit.md +4 -10
  145. package/.claude/commands/maestro-milestone-complete.md +6 -7
  146. package/.claude/commands/maestro-milestone-release.md +136 -145
  147. package/.claude/commands/maestro-next.md +253 -257
  148. package/.claude/commands/maestro-overlay.md +188 -178
  149. package/.claude/commands/maestro-plan.md +225 -211
  150. package/.claude/commands/maestro-player.md +182 -182
  151. package/.claude/commands/maestro-quick.md +83 -77
  152. package/.claude/commands/maestro-ralph-beta.md +875 -886
  153. package/.claude/commands/maestro-ralph-execute.md +247 -247
  154. package/.claude/commands/maestro-ralph.md +2 -36
  155. package/.claude/commands/maestro-roadmap.md +173 -186
  156. package/.claude/commands/maestro-swarm-workflow.md +243 -264
  157. package/.claude/commands/maestro-tools-execute.md +122 -117
  158. package/.claude/commands/maestro-tools-register.md +162 -157
  159. package/.claude/commands/maestro-ui-codify.md +117 -100
  160. package/.claude/commands/maestro-universal-workflow.md +548 -561
  161. package/.claude/commands/maestro-update.md +122 -119
  162. package/.claude/commands/maestro.md +2 -10
  163. package/.claude/commands/manage-codebase-rebuild.md +87 -85
  164. package/.claude/commands/manage-harvest.md +97 -95
  165. package/.claude/commands/manage-issue-discover.md +83 -81
  166. package/.claude/commands/manage-issue.md +72 -73
  167. package/.claude/commands/manage-kg-extractors.md +128 -0
  168. package/.claude/commands/manage-knowhow-capture.md +92 -82
  169. package/.claude/commands/manage-knowhow.md +83 -79
  170. package/.claude/commands/manage-knowledge-audit.md +105 -88
  171. package/.claude/commands/manage-status.md +62 -52
  172. package/.claude/commands/manage-wiki.md +82 -71
  173. package/.claude/commands/odyssey-debug.md +459 -473
  174. package/.claude/commands/odyssey-improve.md +491 -505
  175. package/.claude/commands/odyssey-planex.md +590 -601
  176. package/.claude/commands/odyssey-review-test-fix.md +414 -427
  177. package/.claude/commands/odyssey-ui.md +445 -462
  178. package/.claude/commands/quality-auto-test.md +153 -136
  179. package/.claude/commands/quality-debug.md +159 -120
  180. package/.claude/commands/quality-refactor.md +105 -67
  181. package/.claude/commands/quality-retrospective.md +123 -77
  182. package/.claude/commands/quality-review.md +155 -128
  183. package/.claude/commands/quality-sync.md +88 -52
  184. package/.claude/commands/quality-test.md +147 -117
  185. package/.claude/commands/security-audit.md +230 -179
  186. package/.claude/commands/spec-add.md +77 -70
  187. package/.claude/commands/spec-load.md +78 -78
  188. package/.claude/commands/spec-remove.md +55 -55
  189. package/.claude/commands/spec-setup.md +49 -52
  190. package/dist/src/cli.js +1 -1
  191. package/dist/src/cli.js.map +1 -1
  192. package/dist/src/commands/kg.d.ts.map +1 -1
  193. package/dist/src/commands/kg.js +11 -5
  194. package/dist/src/commands/kg.js.map +1 -1
  195. package/dist/src/graph/kg/extraction/code/code-extractor.d.ts +2 -0
  196. package/dist/src/graph/kg/extraction/code/code-extractor.d.ts.map +1 -1
  197. package/dist/src/graph/kg/extraction/code/code-extractor.js +32 -3
  198. package/dist/src/graph/kg/extraction/code/code-extractor.js.map +1 -1
  199. package/dist/src/graph/kg/extraction/code/plugin-engine.d.ts +35 -0
  200. package/dist/src/graph/kg/extraction/code/plugin-engine.d.ts.map +1 -0
  201. package/dist/src/graph/kg/extraction/code/plugin-engine.js +573 -0
  202. package/dist/src/graph/kg/extraction/code/plugin-engine.js.map +1 -0
  203. package/dist/src/graph/kg/extraction/code/plugin-types.d.ts +95 -0
  204. package/dist/src/graph/kg/extraction/code/plugin-types.d.ts.map +1 -0
  205. package/dist/src/graph/kg/extraction/code/plugin-types.js +5 -0
  206. package/dist/src/graph/kg/extraction/code/plugin-types.js.map +1 -0
  207. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  208. package/dist/src/graph/kg/extraction/orchestrator.js +17 -5
  209. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  210. package/dist/src/graph/kg/schema.sql +16 -11
  211. package/dist/src/graph/kg/surface/cli.d.ts.map +1 -1
  212. package/dist/src/graph/kg/surface/cli.js +153 -56
  213. package/dist/src/graph/kg/surface/cli.js.map +1 -1
  214. package/dist/src/hooks/workspace.d.ts +4 -2
  215. package/dist/src/hooks/workspace.d.ts.map +1 -1
  216. package/dist/src/hooks/workspace.js +6 -2
  217. package/dist/src/hooks/workspace.js.map +1 -1
  218. package/package.json +91 -91
  219. package/workflows/analyze.md +25 -49
  220. package/workflows/auto-test.md +699 -699
  221. package/workflows/blueprint.md +403 -431
  222. package/workflows/brainstorm.md +54 -195
  223. package/workflows/business-test.md +570 -570
  224. package/workflows/claude-instructions.md +23 -51
  225. package/workflows/codex-instructions.md +27 -77
  226. package/workflows/coding-philosophy.md +69 -69
  227. package/workflows/command-authoring.md +823 -823
  228. package/workflows/debug.md +43 -98
  229. package/workflows/delegate-usage.md +39 -241
  230. package/workflows/execute.md +4 -53
  231. package/workflows/grill.md +12 -56
  232. package/workflows/harvest.md +22 -68
  233. package/workflows/init.md +148 -148
  234. package/workflows/instruction-authoring-guide.md +97 -0
  235. package/workflows/issue-execute.md +110 -110
  236. package/workflows/issue-gaps-analyze.codex.md +260 -260
  237. package/workflows/issue-gaps-analyze.md +216 -216
  238. package/workflows/issue-plan.md +110 -110
  239. package/workflows/issue.md +338 -346
  240. package/workflows/knowhow.md +0 -32
  241. package/workflows/learn.md +277 -277
  242. package/workflows/maestro-chain-execute.md +20 -20
  243. package/workflows/refactor.md +22 -44
  244. package/workflows/retrospective.md +16 -65
  245. package/workflows/review.md +446 -486
  246. package/workflows/roadmap.md +35 -132
  247. package/workflows/skill-authoring.md +265 -265
  248. package/workflows/spec-generate.md +470 -470
  249. package/workflows/specs-remove.md +104 -104
  250. package/workflows/sync.md +11 -41
  251. package/workflows/test-gen.md +226 -226
  252. package/workflows/test.md +385 -475
  253. package/workflows/ui-design.md +391 -391
  254. package/workflows/ui-style.md +199 -199
  255. package/workflows/wiki-connect.md +151 -151
  256. package/workflows/wiki-digest.md +178 -178
  257. package/workflows/wiki-manage.md +109 -109
  258. package/workflows/cli-tools-usage.md +0 -252
  259. package/workflows/delegate-protocol.codex.md +0 -65
@@ -1,473 +1,459 @@
1
- ---
2
- name: odyssey-debug
3
- description: Long-running debug cycle — archaeology, diagnosis, fix, confirmation, generalization, discovery, and knowledge persistence
4
- argument-hint: "<issue> [--skip-fix] [--skip-generalize] [--auto] [-y] [-c]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - Bash
10
- - Glob
11
- - Grep
12
- - Agent
13
- - AskUserQuestion
14
- ---
15
- <purpose>
16
- Closed-loop deep debugging: archaeology (what changed) → explore (call chains, error gaps) → diagnose (hypothesis-driven) → fix & confirm → generalize (举一反三) → discover siblings → persist learnings.
17
-
18
- Unlike `quality-debug` (fast fix), this treats every bug as a learning signal — digs into git history before hypotheses, confirms fixes with CLI review, scans for siblings of the root cause.
19
-
20
- Core philosophy:
21
- - **Archaeology before hypothesis**look at what changed before guessing why
22
- - **Fix one, find many** a single bug reveals a class of bugs
23
- - **Decision journal** human-judgment items recorded, not lost
24
- - **CLI-assisted review** — delegate for second-opinion analysis
25
-
26
- **三句哲学约束(穷尽迭代):**
27
- 1. **零遗留** — 根因必须确认到底,修复必须验证通过,泛化必须扫描穷尽
28
- 2. **穷尽迭代** 假设失败不放弃:扩范围换视角升级工具,直到根因确认或明确 INCONCLUSIVE
29
- 3. **改进即标准** 修复后重新确认同区域无新问题,泛化发现的同类 bug 全部处理
30
-
31
- Entry: `/odyssey-debug "issue"` (full cycle) | `-c` (resume) | `--skip-fix` (analysis-only)
32
- </purpose>
33
-
34
- <boundary>
35
- **范围内:** 单一 bug/issue 的完整闭环 — 考古 → 探索 → 诊断 → 修复 → 确认 → 泛化同类 → 沉淀
36
- **范围外:** 新功能开发 → `/odyssey-planex` | 代码质量审查 → `/odyssey-review-test-fix` | UI 视觉优化 → `/odyssey-ui` | 架构重设计 → `/maestro-plan`
37
- **探索自由度:** 边界内自由探索 — 可追踪任意调用链、分析任意历史、测试任意假设。泛化阶段可扫描全项目寻找同类问题。
38
- **模板支持:** `--template <name>` 从预定义调查策略启动,跳过假设生成直接进入针对性诊断:
39
-
40
- | Template | 调查策略 | 适用场景 |
41
- |----------|---------|---------|
42
- | `performance` | profiling → hot path → allocation → cache | 性能劣化 |
43
- | `memory-leak` | heap snapshot → retention chain → lifecycle | 内存泄漏 |
44
- | `race-condition` | timeline concurrent access → lock analysis | 竞态条件 |
45
- | `regression` | git bisect diff analysis boundary check | 回归问题 |
46
- | `crash` | stack trace → null chain → error propagation | 崩溃/异常 |
47
- </boundary>
48
-
49
- <execution_discipline>
50
- **三条铁律(所有阶段适用):**
51
-
52
- 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
53
- - 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-debug({slug}): {phase} — {摘要}"`
54
- - session.json / evidence.ndjson 为运行时状态,不纳入 commit
55
- - 确保每个阶段的进展可回溯、可恢复
56
-
57
- 2. **有把握才改** 仅修改自己有把握的内容;不确定的记录决策等人判断
58
- - 有把握 → 直接修改代码,commit
59
- - 需要决策 记录 `evidence.ndjson {"phase":"decision","status":"pending"}` 不改代码
60
- - 禁止猜测性修改,宁可多记录一条 decision 也不冒险改错
61
-
62
- 3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
63
- - 关键判断用不同 `--role`(analyze / review / explore)获取多视角
64
- - 修复前后各做一次 CLI review 确认
65
- - 不同阶段可调用不同工具,综合多方意见再行动
66
- </execution_discipline>
67
-
68
- <context>
69
- $ARGUMENTS — issue description and optional flags.
70
-
71
- **Flags:** `--skip-fix` analysis-only | `--skip-generalize` quick fix | `--template <name>` 预定义策略 | `--auto` no delegate confirmation | `-y` auto-confirm all decisions | `-c` resume last session
72
-
73
- **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-debug-odyssey-{slug}/`
74
-
75
- **Output 4 files:**
76
- ```
77
- SESSION_DIR/
78
- ├── session.json # state + confirmation + patterns + phase_goals
79
- ├── evidence.ndjson # append-only evidence trail (phase field distinguishes origin)
80
- ├── explore.json # structured CLI exploration snapshot
81
- └── understanding.md # evolving narrative — 9 sections
82
- ```
83
-
84
- **session.json schema:**
85
- ```json
86
- {
87
- "session_id": "debug-odyssey-{YYYYMMDD-HHmmss}", "issue": "",
88
- "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
89
- "current_state": "S_INTAKE", "diagnosis_retries": 0,
90
- "root_cause": null, "patterns": [], "confirmation": null,
91
- "phase_goals": [], "phase_goals_all_done": false, "self_iteration_log": [],
92
- "generalization_stats": null,
93
- "cross_phase_loops": 0, "max_loops": 3,
94
- "created_at": "", "updated_at": ""
95
- }
96
- ```
97
-
98
- **evidence.ndjson — unified trail:**
99
- ```json
100
- {"ts":"","phase":"archaeology|explore|diagnosis|discovery|decision|self-iteration","type":"","source":"","content":"","note":""}
101
- ```
102
- Phase-specific fields:
103
- - `archaeology`: `sha`, `author`, `date`, `message`, `relevance` (high|medium|low)
104
- - `explore`: `category` (call_chain|recent_change|error_gap|similar_pattern), `detail`
105
- - `diagnosis`: `hypothesis`, `result` (confirmed|disproved|inconclusive)
106
- - `discovery`: `file`, `line`, `classification` (safe|risk|bug), `action` (fix|issue|decision|skip)
107
- - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
108
- - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
109
-
110
- **explore.json schema:**
111
- ```json
112
- {
113
- "call_chains": [{"entry":"","chain":["file:line"]}],
114
- "recent_changes": [{"file":"","commits":[{"sha":"","message":"","date":""}]}],
115
- "error_gaps": [{"file":"","line":0,"description":""}],
116
- "similar_patterns": [{"file":"","line":0,"description":""}],
117
- "cli_tool": "", "timestamp": ""
118
- }
119
- ```
120
-
121
- **phase_goals[] auto-derived from flags:**
122
-
123
- | ID | Goal | done_when | phase | skip_when |
124
- |----|------|-----------|-------|-----------|
125
- | G1 | Root cause identified | evidence.ndjson has phase=diagnosis result=confirmed | S_DIAGNOSE | — |
126
- | G2 | Explore context gathered | explore.json ≥1 category populated | S_EXPLORE | — |
127
- | G3 | Fix applied and confirmed | confirmation.overall == confirmed | S_CONFIRM | skip_fix |
128
- | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
129
- | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
130
- | G6 | Learnings persisted | spec entries created OR no actionable learnings | S_RECORD | |
131
-
132
- When `flags[skip_when] == true` → auto set `status: "skipped"`, `completion_confirmed: true`.
133
-
134
- **understanding.md — 9 sections (written by owning phase):**
135
- 1. Issue & Scope ← S_INTAKE | 2. Archaeology Summary ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
136
- 4. Hypotheses & Testing ← S_DIAGNOSE | 5. Root Cause ← S_DIAGNOSE | 6. Fix & Confirmation ← S_FIX+S_CONFIRM
137
- 7. Generalization S_GENERALIZE | 8. Discoveries & Decisions ← S_DISCOVER | 9. Learnings ← S_RECORD
138
-
139
- ### Pre-load(可选,缺失不阻塞)
140
-
141
- | 层级 | 命令 | 作用 |
142
- |------|------|------|
143
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,作为所有分析的上下文 |
144
- | Wiki search | `maestro search "<issue keywords>" --json` | 先前调查、相关决策(取 top 5) |
145
- | Specs + tools | `maestro spec load --category debug --keyword "<symptom>"` | 已知 issue/workaround + 可发现的 knowhow 工具 |
146
- | Role knowledge | `maestro search --category debug` → 选相关 → `maestro wiki load <id>` | 累积领域知识 |
147
- | Prior sessions | `Glob(".workflow/scratch/*-debug-odyssey-*")` | 相关 odyssey 会话 |
148
-
149
- ### Knowledge Persistence(S_RECORD 中写入产出文件)
150
-
151
- S_RECORD 阶段将可沉淀知识 **写入 understanding.md §9 Learnings**,按以下分类结构化:
152
-
153
- | 分类 | 写入内容 | 后续建议命令 |
154
- |------|---------|-------------|
155
- | 反复根因模式 | 模式描述 + 触发条件 + 修复模板 | `/spec-add debug "..."` |
156
- | 非显而易见 workaround | 问题场景 + 解决方案 + 适用范围 | `/spec-add learning "..."` |
157
- | 架构边界违反 | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
158
- | 可复用泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
159
-
160
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
161
- </context>
162
-
163
- <self_iteration>
164
- **Quality Gate (适用: S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE)**
165
-
166
- | 维度 | sufficient | insufficient |
167
- |------|-----------|-------------|
168
- | Coverage | 已知相关文件/模块均已分析 | 遗漏 grep/git log 可发现的目标 |
169
- | Depth | ≥80% 发现有 file:line 级证据 | 多数仅泛泛描述 |
170
- | Actionability | 每条结论有具体后续动作 | 仅"建议关注"类无操作性结论 |
171
-
172
- **规则:** 阶段完成 评估 3 维度 任一 insufficient → 重入(每阶段最多 2 轮)。
173
- - Round 1: 扩范围 增加目录、git log depth ×2、增加 delegate 角度
174
- - Round 2: 换视角 不同 CLI tool、反向追踪、手动 code reading
175
-
176
- **退出:** sufficient 推进 | 2 轮上限 → 记录 gap 继续。记录至 `evidence.ndjson` + `session.json.self_iteration_log[]`.
177
- </self_iteration>
178
-
179
- <state_machine>
180
-
181
- <states>
182
- S_INTAKE 解析问题、加载上下文、检查/恢复 session PERSIST: session.json + understanding.md §1
183
- S_ARCHAEOLOGY — 考古:git history + CLI 分析 PERSIST: evidence.ndjson (archaeology) + understanding.md §2
184
- S_EXPLORE — CLI 探索:调用链、错误间隙、相似模式 PERSIST: explore.json + evidence.ndjson (explore) + understanding.md §3
185
- S_DIAGNOSE 假设驱动根因分析 PERSIST: evidence.ndjson (diagnosis|decision) + understanding.md §4-5
186
- S_FIX — 实现修复 (skip_fix 时跳过) PERSIST: code changes + evidence.ndjson (decision)
187
- S_CONFIRM — 测试 + CLI review 双重确认 (skip_fix 时跳过) PERSIST: session.json.confirmation + understanding.md §6
188
- S_GENERALIZE 举一反三:提取 pattern,扫描相似代码 PERSIST: session.json.patterns + understanding.md §7
189
- S_DISCOVER — 评估发现,创建 issue / 记录决策 PERSIST: evidence.ndjson (discovery|decision) + understanding.md §8
190
- S_RECORD — 知识沉淀 + 目标审计 PERSIST: understanding.md §9 + spec entries
191
- </states>
192
-
193
- <transitions>
194
- S_INTAKES_INTAKE : -c + session found → A_RESUME_SESSION
195
- S_INTAKES_ARCHAEOLOGY : issue parsed → A_INTAKE
196
- S_INTAKES_INTAKE : no issue, no session → AskUserQuestion
197
-
198
- S_ARCHAEOLOGYS_EXPLORE : A_ARCHAEOLOGY complete
199
- S_EXPLORE S_DIAGNOSE : A_EXPLORE complete
200
-
201
- S_DIAGNOSES_FIX : root cause confirmed, !skip_fix
202
- S_DIAGNOSES_GENERALIZE : root cause confirmed, skip_fix, !skip_generalize
203
- S_DIAGNOSE → S_RECORD : root cause confirmed, skip_fix, skip_generalize
204
- S_DIAGNOSE → S_DIAGNOSE : all hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
205
- S_DIAGNOSE S_RECORD : all hypotheses failed, retries >= 3 → mark INCONCLUSIVE
206
-
207
- S_FIX → S_CONFIRM : fix implemented
208
- S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
209
- S_CONFIRM → S_RECORD : confirmed, skip_generalize
210
- S_CONFIRM → S_FIX : needs_rework
211
-
212
- S_GENERALIZE S_DISCOVER : similar code found
213
- S_GENERALIZE → S_RECORD : no similar code
214
-
215
- S_DISCOVER S_DIAGNOSE : discovery finds new bug worth investigating, loops < max_loops → cross_phase_loops++
216
- S_DISCOVER S_FIX : discovery finds same-pattern bug, fix template applies, loops < max_loops → cross_phase_loops++
217
- S_DISCOVER → S_RECORD : triage complete OR loops >= max_loops (剩余项 → issue/decision)
218
-
219
- S_RECORD → END : A_RECORD complete
220
- </transitions>
221
-
222
- <actions>
223
-
224
- ### A_INTAKE
225
- 1. Parse arguments: issue description, flags
226
- 2. Generate slug, create `SESSION_DIR`
227
- 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
228
- 4. Derive `phase_goals[]` from flags (apply `skip_when`)
229
- 5. Write `session.json` + `understanding.md` §1
230
- 6. Emit Goal Prompt (see Appendix)
231
-
232
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): INTAKE — 目标解析与上下文加载"`
233
-
234
- ### A_RESUME_SESSION
235
- Find latest session via Glob read `session.json` → display summary → jump to `current_state`.
236
-
237
- ### A_ARCHAEOLOGY
238
- **Git archaeology (2 parallel Agents):**
239
-
240
- | Agent | Task |
241
- |-------|------|
242
- | Timeline | `git log --oneline -20 -- {files}` → change timeline |
243
- | Blame | Top 3 suspicious files: `git blame -L {region}` → critical paths |
244
-
245
- Append findings to `evidence.ndjson` (phase: "archaeology").
246
-
247
- **CLI-assisted change review:**
248
- ```bash
249
- maestro delegate "PURPOSE: Review recent modifications related to: {issue}
250
- TASK: Analyze intent behind changes | Identify risky modifications | Flag potential bug sources
251
- MODE: analysis
252
- CONTEXT: @{relevant_files} | Git log: {top_10_commits}
253
- EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
254
- CONSTRAINTS: Focus on behavioral changes, not formatting
255
- " --role analyze --mode analysis
256
- ```
257
- Run_in_background, STOP, wait for callback. Append results to evidence.
258
-
259
- Update `understanding.md` §2.
260
-
261
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): ARCHAEOLOGY — git 考古分析"`
262
-
263
- ### A_EXPLORE
264
- Skip if no enabled CLI tools (W006).
265
-
266
- ```bash
267
- maestro delegate "PURPOSE: Gather codebase evidence for: {issue}
268
- TASK: Trace call chains | Find recent changes | Identify error gaps | Check similar patterns
269
- MODE: analysis
270
- CONTEXT: @**/*
271
- EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
272
- CONSTRAINTS: Max 20 entries/category | Symptom-related code paths
273
- Symptoms: {issue} Archaeology hints: {suspicious_commits}
274
- " --role explore --mode analysis
275
- ```
276
- Run_in_background, STOP, wait for callback.
277
-
278
- Parse → write `explore.json` + append `evidence.ndjson` (phase: "explore"). Update §3. Mark G2 done.
279
-
280
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): EXPLORE 代码探索完成"`
281
-
282
- ### A_DIAGNOSE
283
- 1. **Form hypotheses** from evidence (archaeology + explore), ranked [HIGH]/[MEDIUM]/[LOW] → §4
284
- 2. **Test each** (rank order): design test execute append evidence (phase: "diagnosis")
285
- 3. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: AskUserQuestion | `-y`: defer
286
- 4. **Root cause**: confirmed → `session.json.root_cause` + §5. Mark G1 done.
287
-
288
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): DIAGNOSE — 根因确认"`
289
-
290
- ### A_ESCALATE_DIAGNOSIS
291
- Increment `diagnosis_retries`. If < 3: broaden scope via `maestro delegate --role analyze` (same delegate format), form new hypotheses, return to S_DIAGNOSE. If >= 3: Normal → AskUserQuestion (broaden/new/INCONCLUSIVE) | `-y` auto INCONCLUSIVE, proceed to S_RECORD. See Appendix: `-y` behavior.
292
-
293
- ### A_FIX
294
- 1. Present root cause + proposed fix. Normal: AskUserQuestion | `-y`: auto proceed (see Appendix)
295
- 2. Implement fix
296
- 3. Record in evidence (phase: "decision")
297
-
298
- 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-debug({slug}): FIX — {修复摘要}"`
299
-
300
- ### A_CONFIRM
301
- 1. **Tests**: auto-detect framework, run covering tests
302
- 2. **CLI fix review**:
303
- ```bash
304
- maestro delegate "PURPOSE: Review fix for: {issue}
305
- TASK: Verify correctness | Check regressions | Assess completeness | Review edge cases
306
- MODE: analysis
307
- CONTEXT: @{modified_files} | Root cause: {summary} | Diff: {git_diff}
308
- EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk}
309
- CONSTRAINTS: Focus on correctness, not style
310
- " --role review --mode analysis
311
- ```
312
- Run_in_background, STOP, wait for callback.
313
-
314
- 3. Write `session.json.confirmation`: `{test_result, cli_review, overall: "confirmed|needs_rework", timestamp}`
315
- 4. Update §6. `needs_rework` → S_FIX. `confirmed` → mark G3 done, advance.
316
-
317
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): CONFIRM — 修复验证"`
318
-
319
- ### A_GENERALIZE
320
- 举一反三: multi-layer pattern extraction 4-agent scan cross-layer dedup → iterative deepening.
321
-
322
- **Pattern extraction** from root cause + fix:
323
-
324
- | Layer | Method | Example |
325
- |-------|--------|---------|
326
- | Syntax | Regex patterns (direct Grep) | `eval(`, missing `await`, unclosed resource |
327
- | Semantic | Anti-pattern description (Agent-driven) | Unhandled async errors, unvalidated input |
328
- | Structural | Architecture-level (file/module similarity) | Same import structure, missing override |
329
-
330
- Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template}]`
331
-
332
- **4-agent parallel codebase scan:**
333
-
334
- | Agent | Strategy | Input | Scope |
335
- |-------|----------|-------|-------|
336
- | Syntax grep | Grep syntax-layer regex | P*.signature | Full project |
337
- | Semantic scan | Understand + check anti-pattern | P*.description | Related modules |
338
- | Structural match | Find structurally similar files | Buggy file structure | Full project |
339
- | Historical grep | `git log -S "{pattern}"` | P*.signature | Full git history |
340
-
341
- Returns: `[{pattern_id, file, line, context, risk_level, layer, confidence}]`
342
-
343
- **Cross-layer dedup**: same file:line multi-layer hit → boost confidence | single-layer → `needs_review` | historical hit on fixed record → `regression_risk`
344
-
345
- **Iterative deepening**: module with ≥3 hits → targeted deep scan (max 1 round).
346
-
347
- **Quality Gate** (self-iteration) → if insufficient, expand and re-scan.
348
-
349
- Write §7 + `session.json.generalization_stats`: `{patterns_extracted, total_hits, cross_layer_confirmed, regression_risks, by_layer, deepening_triggered}`. Mark G4 done.
350
-
351
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): GENERALIZE — 泛化扫描完成"`
352
-
353
- ### A_DISCOVER
354
- 1. **Triage** each hit: read ±10 lines context → classify `safe`/`risk`/`bug`
355
- 2. **Route**: see Appendix `-y` behavior table. Append evidence (phase: "discovery" + "decision")
356
- 3. Update §8. Mark G5 done.
357
-
358
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): DISCOVER — 发现分类完成"`
359
-
360
- ### A_RECORD
361
- 1. Finalize `understanding.md` §9
362
- 2. **Write learnings** to understanding.md §9: Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
363
- 3. Mark G6 done. Process pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count)
364
- 4. **Goal audit**: all `completion_confirmed` true → `phase_goals_all_done = true`. Any false: Normal → AskUserQuestion (回退/跳过/接受) | `-y` → auto accept
365
- 5. **Completion**: `current_state = "COMPLETED"`, emit summary:
366
- ```
367
- --- DEBUG ODYSSEY COMPLETE ---
368
- Issue: {issue}
369
- Root cause: {root_cause.hypothesis}
370
- Fix: {applied|skipped|inconclusive}
371
- Patterns: {patterns_extracted} ({by_layer} distribution)
372
- Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
373
- Issues: {N} created
374
- Decisions: {N} resolved, {M} pending, {K} deferred
375
- Learnings: {N} spec entries persisted
376
- Self-iter: {N} quality gate rounds across {M} stages
377
- Goals: {done}/{total} confirmed ({skipped} skipped)
378
- ---
379
- ```
380
-
381
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): RECORD — 会话总结与知识沉淀"`
382
-
383
- </actions>
384
-
385
- <appendix>
386
-
387
- ### Goal Prompt Template
388
-
389
- **时机守卫:仅在 A_INTAKE 完成后显示一次。A_RECORD 完成时禁止重新显示。**
390
-
391
- ```
392
- 📋 Debug Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
393
-
394
- /goal 穷尽迭代:直到根因确认(或明确 INCONCLUSIVE)且修复验证通过
395
- 且泛化扫描穷尽(所有 hits 已分类处理)且 phase_goals_all_done=true 才停。
396
- 假设失败时扩范围→换视角→升级工具,不轻易放弃。
397
- 泛化发现的同类 bug 全部修复或创建 issue,不允许遗留。
398
- 遇到 phase=decision pending 必须 AskUserQuestion,不得自行 resolve。
399
- ```
400
-
401
- Odyssey 输出提示词后继续执行不阻塞。`/goal` 由用户任意时刻输入。
402
-
403
- ### `-y` Auto-Confirm Behavior
404
-
405
- | Decision Point | Normal | `-y` mode |
406
- |---------------|--------|-----------|
407
- | A_DIAGNOSE ambiguity | AskUserQuestion blocks | record `deferred`, best-effort continue |
408
- | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
409
- | A_FIX direction | AskUserQuestion confirm | auto proceed with suggested fix |
410
- | A_DISCOVER bug triage | AskUserQuestion route | auto create issue |
411
- | A_DISCOVER ambiguous | AskUserQuestion batch | all `deferred` |
412
- | A_RECORD decisions | AskUserQuestion per-item | skip, show deferred count |
413
- | A_RECORD goal audit | AskUserQuestion 3-way | auto accept current state |
414
-
415
- `deferred` items shown as "待决策" in completion summary; recoverable via `-c`.
416
-
417
- ### Phase Goal Lifecycle
418
-
419
- `pending done (confirmed=true)` normal | `pending skipped (confirmed=true)` flags/manual | `pending failed (confirmed=false)` INCONCLUSIVE
420
-
421
- `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
422
-
423
- </appendix>
424
-
425
- </state_machine>
426
-
427
- <error_codes>
428
- | Code | Severity | Condition | Recovery |
429
- |------|----------|-----------|----------|
430
- | E001 | error | No issue and no session to resume | Provide issue or use -c |
431
- | E003 | error | Resume but no session found | Start new session |
432
- | E004 | error | Delegate execution failed | Retry or proceed without CLI |
433
- | W001 | warning | No relevant git history | Proceed with limited context |
434
- | W002 | warning | All hypotheses inconclusive after 3 retries | INCONCLUSIVE |
435
- | W003 | warning | Generalization scan 0 hits | Skip discovery |
436
- | W004 | warning | Delegate parse failed | Use raw output |
437
- | W005 | warning | Pending decisions unresolved | Filter evidence.ndjson phase=decision |
438
- | W006 | warning | CLI exploration skipped (no tools) | Proceed without explore.json |
439
- </error_codes>
440
-
441
- <success_criteria>
442
- - [ ] Session directory created with 4 output files
443
- - [ ] Prior knowledge searched (maestro search + sessions + architecture)
444
- - [ ] Git archaeology (log + blame) + CLI change review, evidence.ndjson phase=archaeology
445
- - [ ] CLI exploration, explore.json written, evidence phase=explore
446
- - [ ] Hypotheses formed from archaeology + explore, tested and logged phase=diagnosis
447
- - [ ] Root cause declared with evidence refs
448
- - [ ] understanding.md tracks all 9 sections progressively
449
- - [ ] Fix implemented + confirmed with test + CLI review (unless --skip-fix)
450
- - [ ] Multi-layer patterns (syntax/semantic/structural) extracted (unless --skip-generalize)
451
- - [ ] 4-agent scan + cross-layer dedup + iterative deepening for ≥3 hits/module
452
- - [ ] Discoveries classified and routed (fix/issue/decision/skip)
453
- - [ ] Decision journal: all human-judgment items in evidence.ndjson phase=decision
454
- - [ ] phase_goals derived from flags, skip_when applied, each phase marks its goal
455
- - [ ] Goal audit in A_RECORD unmet goals surfaced, phase_goals_all_done set correctly
456
- - [ ] Goal Prompt displayed once after session creation
457
- - [ ] `-y`: all decisions auto-resolve/defer, deferred count in summary
458
- - [ ] State saved at each transition (resumable via -c)
459
- - [ ] Quality Gate self-iteration when insufficient, logged in self_iteration_log
460
- - [ ] Spec entries persisted for reusable learnings
461
- - [ ] Completion summary with all stats
462
- </success_criteria>
463
-
464
- <next_step_routing>
465
- | Condition | Next step |
466
- |-----------|-----------|
467
- | Issues from discoveries | `/manage-issue list --source debug-odyssey` |
468
- | Pattern worth documenting | `/learn-decompose <module>` |
469
- | Fix needs formal review | `/quality-review <phase>` |
470
- | Second opinion on root cause | `/learn-second-opinion <understanding.md>` |
471
- | Related question | `/learn-investigate "<question>"` |
472
- | Decisions still pending | Filter evidence.ndjson phase=decision status=pending |
473
- </next_step_routing>
1
+ ---
2
+ name: odyssey-debug
3
+ description: Long-running debug cycle — archaeology, diagnosis, fix, confirmation, generalization, discovery, and knowledge persistence
4
+ argument-hint: "<issue> [--skip-fix] [--skip-generalize] [--auto] [-y] [-c]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ Closed-loop deep debugging: archaeology → explore → diagnose → fix & confirm → generalize → discover siblings → persist.
17
+ Treats every bug as a learning signal with exhaustive iteration until root cause confirmed or INCONCLUSIVE.
18
+ </purpose>
19
+
20
+ <boundary>
21
+ **范围内:** 单一 bug/issue 的完整闭环考古 探索 诊断 修复 → 确认 → 泛化同类 → 沉淀
22
+ **范围外:** 新功能开发 → `/odyssey-planex` | 代码质量审查 `/odyssey-review-test-fix` | UI 视觉优化 `/odyssey-ui` | 架构重设计 `/maestro-plan`
23
+ **探索自由度:** 边界内自由探索可追踪任意调用链、分析任意历史、测试任意假设。泛化阶段可扫描全项目寻找同类问题。
24
+ **模板支持:** `--template <name>` 从预定义调查策略启动,跳过假设生成直接进入针对性诊断:
25
+
26
+ | Template | 调查策略 | 适用场景 |
27
+ |----------|---------|---------|
28
+ | `performance` | profilinghot path allocation → cache | 性能劣化 |
29
+ | `memory-leak` | heap snapshot → retention chain → lifecycle | 内存泄漏 |
30
+ | `race-condition` | timeline → concurrent access → lock analysis | 竞态条件 |
31
+ | `regression` | git bisect diff analysis → boundary check | 回归问题 |
32
+ | `crash` | stack trace → null chain → error propagation | 崩溃/异常 |
33
+ </boundary>
34
+
35
+ <execution_discipline>
36
+ **三条铁律(所有阶段适用):**
37
+
38
+ 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
39
+ - 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-debug({slug}): {phase} — {摘要}"`
40
+ - session.json / evidence.ndjson 为运行时状态,不纳入 commit
41
+ - 确保每个阶段的进展可回溯、可恢复
42
+
43
+ 2. **有把握才改** 仅修改自己有把握的内容;不确定的记录决策等人判断
44
+ - 有把握直接修改代码,commit
45
+ - 需要决策记录 `evidence.ndjson {"phase":"decision","status":"pending"}` 不改代码
46
+ - 禁止猜测性修改,宁可多记录一条 decision 也不冒险改错
47
+
48
+ 3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
49
+ - 关键判断用不同 `--role`(analyze / review / explore)获取多视角
50
+ - 修复前后各做一次 CLI review 确认
51
+ - 不同阶段可调用不同工具,综合多方意见再行动
52
+ </execution_discipline>
53
+
54
+ <context>
55
+ $ARGUMENTS — issue description and optional flags.
56
+
57
+ **Flags:** `--skip-fix` analysis-only | `--skip-generalize` quick fix | `--template <name>` 预定义策略 | `--auto` no delegate confirmation | `-y` auto-confirm all decisions | `-c` resume last session
58
+
59
+ **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-debug-odyssey-{slug}/`
60
+
61
+ **Output — 4 files:**
62
+ ```
63
+ SESSION_DIR/
64
+ ├── session.json # state + confirmation + patterns + phase_goals
65
+ ├── evidence.ndjson # append-only evidence trail (phase field distinguishes origin)
66
+ ├── explore.json # structured CLI exploration snapshot
67
+ └── understanding.md # evolving narrative — 9 sections
68
+ ```
69
+
70
+ **session.json schema:**
71
+ ```json
72
+ {
73
+ "session_id": "debug-odyssey-{YYYYMMDD-HHmmss}", "issue": "",
74
+ "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
75
+ "current_state": "S_INTAKE", "diagnosis_retries": 0,
76
+ "root_cause": null, "patterns": [], "confirmation": null,
77
+ "phase_goals": [], "phase_goals_all_done": false, "self_iteration_log": [],
78
+ "generalization_stats": null,
79
+ "cross_phase_loops": 0, "max_loops": 3,
80
+ "created_at": "", "updated_at": ""
81
+ }
82
+ ```
83
+
84
+ **evidence.ndjson — unified trail:**
85
+ ```json
86
+ {"ts":"","phase":"archaeology|explore|diagnosis|discovery|decision|self-iteration","type":"","source":"","content":"","note":""}
87
+ ```
88
+ Phase-specific fields:
89
+ - `archaeology`: `sha`, `author`, `date`, `message`, `relevance` (high|medium|low)
90
+ - `explore`: `category` (call_chain|recent_change|error_gap|similar_pattern), `detail`
91
+ - `diagnosis`: `hypothesis`, `result` (confirmed|disproved|inconclusive)
92
+ - `discovery`: `file`, `line`, `classification` (safe|risk|bug), `action` (fix|issue|decision|skip)
93
+ - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
94
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
95
+
96
+ **explore.json schema:**
97
+ ```json
98
+ {
99
+ "call_chains": [{"entry":"","chain":["file:line"]}],
100
+ "recent_changes": [{"file":"","commits":[{"sha":"","message":"","date":""}]}],
101
+ "error_gaps": [{"file":"","line":0,"description":""}],
102
+ "similar_patterns": [{"file":"","line":0,"description":""}],
103
+ "cli_tool": "", "timestamp": ""
104
+ }
105
+ ```
106
+
107
+ **phase_goals[] auto-derived from flags:**
108
+
109
+ | ID | Goal | done_when | phase | skip_when |
110
+ |----|------|-----------|-------|-----------|
111
+ | G1 | Root cause identified | evidence.ndjson has phase=diagnosis result=confirmed | S_DIAGNOSE | — |
112
+ | G2 | Explore context gathered | explore.json ≥1 category populated | S_EXPLORE | — |
113
+ | G3 | Fix applied and confirmed | confirmation.overall == confirmed | S_CONFIRM | skip_fix |
114
+ | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
115
+ | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
116
+ | G6 | Learnings persisted | spec entries created OR no actionable learnings | S_RECORD | — |
117
+
118
+ When `flags[skip_when] == true` → auto set `status: "skipped"`, `completion_confirmed: true`.
119
+
120
+ **understanding.md — 9 sections (written by owning phase):**
121
+ 1. Issue & Scope ← S_INTAKE | 2. Archaeology Summary ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
122
+ 4. Hypotheses & Testing ← S_DIAGNOSE | 5. Root Cause ← S_DIAGNOSE | 6. Fix & Confirmation ← S_FIX+S_CONFIRM
123
+ 7. Generalization S_GENERALIZE | 8. Discoveries & Decisions ← S_DISCOVER | 9. Learnings ← S_RECORD
124
+
125
+ ### Pre-load(可选,缺失不阻塞)
126
+
127
+ | 层级 | 命令 | 作用 |
128
+ |------|------|------|
129
+ | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,作为所有分析的上下文 |
130
+ | Wiki search | `maestro search "<issue keywords>" --json` | 先前调查、相关决策(取 top 5) |
131
+ | Specs + tools | `maestro spec load --category debug --keyword "<symptom>"` | 已知 issue/workaround + 可发现的 knowhow 工具 |
132
+ | Role knowledge | `maestro search --category debug` → 选相关 `maestro wiki load <id>` | 累积领域知识 |
133
+ | Prior sessions | `Glob(".workflow/scratch/*-debug-odyssey-*")` | 相关 odyssey 会话 |
134
+
135
+ ### Knowledge Persistence(S_RECORD 中写入产出文件)
136
+
137
+ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §9 Learnings**,按以下分类结构化:
138
+
139
+ | 分类 | 写入内容 | 后续建议命令 |
140
+ |------|---------|-------------|
141
+ | 反复根因模式 | 模式描述 + 触发条件 + 修复模板 | `/spec-add debug "..."` |
142
+ | 非显而易见 workaround | 问题场景 + 解决方案 + 适用范围 | `/spec-add learning "..."` |
143
+ | 架构边界违反 | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
144
+ | 可复用泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
145
+
146
+ **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
147
+ </context>
148
+
149
+ <self_iteration>
150
+ **Quality Gate (适用: S_ARCHAEOLOGY, S_EXPLORE, S_DIAGNOSE, S_GENERALIZE)**
151
+
152
+ | 维度 | sufficient | insufficient |
153
+ |------|-----------|-------------|
154
+ | Coverage | 已知相关文件/模块均已分析 | 遗漏 grep/git log 可发现的目标 |
155
+ | Depth | ≥80% 发现有 file:line 级证据 | 多数仅泛泛描述 |
156
+ | Actionability | 每条结论有具体后续动作 | "建议关注"类无操作性结论 |
157
+
158
+ **规则:** 阶段完成 评估 3 维度 任一 insufficient 重入(每阶段最多 2 轮)。
159
+ - Round 1: 扩范围 — 增加目录、git log depth ×2、增加 delegate 角度
160
+ - Round 2: 换视角 不同 CLI tool、反向追踪、手动 code reading
161
+
162
+ **退出:** 全 sufficient → 推进 | 2 轮上限 → 记录 gap 继续。记录至 `evidence.ndjson` + `session.json.self_iteration_log[]`.
163
+ </self_iteration>
164
+
165
+ <state_machine>
166
+
167
+ <states>
168
+ S_INTAKE — 解析问题、加载上下文、检查/恢复 session PERSIST: session.json + understanding.md §1
169
+ S_ARCHAEOLOGY — 考古:git history + CLI 分析 PERSIST: evidence.ndjson (archaeology) + understanding.md §2
170
+ S_EXPLORE — CLI 探索:调用链、错误间隙、相似模式 PERSIST: explore.json + evidence.ndjson (explore) + understanding.md §3
171
+ S_DIAGNOSE — 假设驱动根因分析 PERSIST: evidence.ndjson (diagnosis|decision) + understanding.md §4-5
172
+ S_FIX — 实现修复 (skip_fix 时跳过) PERSIST: code changes + evidence.ndjson (decision)
173
+ S_CONFIRM — 测试 + CLI review 双重确认 (skip_fix 时跳过) PERSIST: session.json.confirmation + understanding.md §6
174
+ S_GENERALIZE — 举一反三:提取 pattern,扫描相似代码 PERSIST: session.json.patterns + understanding.md §7
175
+ S_DISCOVER — 评估发现,创建 issue / 记录决策 PERSIST: evidence.ndjson (discovery|decision) + understanding.md §8
176
+ S_RECORD — 知识沉淀 + 目标审计 PERSIST: understanding.md §9 + spec entries
177
+ </states>
178
+
179
+ <transitions>
180
+ S_INTAKE → S_INTAKE : -c + session found → A_RESUME_SESSION
181
+ S_INTAKE → S_ARCHAEOLOGY : issue parsed → A_INTAKE
182
+ S_INTAKE S_INTAKE : no issue, no session AskUserQuestion
183
+
184
+ S_ARCHAEOLOGY S_EXPLORE : A_ARCHAEOLOGY complete
185
+ S_EXPLORE S_DIAGNOSE : A_EXPLORE complete
186
+
187
+ S_DIAGNOSE S_FIX : root cause confirmed, !skip_fix
188
+ S_DIAGNOSE → S_GENERALIZE : root cause confirmed, skip_fix, !skip_generalize
189
+ S_DIAGNOSE S_RECORD : root cause confirmed, skip_fix, skip_generalize
190
+ S_DIAGNOSE S_DIAGNOSE : all hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
191
+ S_DIAGNOSE → S_RECORD : all hypotheses failed, retries >= 3 → mark INCONCLUSIVE
192
+
193
+ S_FIX → S_CONFIRM : fix implemented
194
+ S_CONFIRMS_GENERALIZE : confirmed, !skip_generalize
195
+ S_CONFIRMS_RECORD : confirmed, skip_generalize
196
+ S_CONFIRMS_FIX : needs_rework
197
+
198
+ S_GENERALIZES_DISCOVER : similar code found
199
+ S_GENERALIZE S_RECORD : no similar code
200
+
201
+ S_DISCOVERS_DIAGNOSE : discovery finds new bug worth investigating, loops < max_loops → cross_phase_loops++
202
+ S_DISCOVERS_FIX : discovery finds same-pattern bug, fix template applies, loops < max_loops → cross_phase_loops++
203
+ S_DISCOVER → S_RECORD : triage complete OR loops >= max_loops (剩余项 → issue/decision)
204
+
205
+ S_RECORD END : A_RECORD complete
206
+ </transitions>
207
+
208
+ <actions>
209
+
210
+ ### A_INTAKE
211
+ 1. Parse arguments: issue description, flags
212
+ 2. Generate slug, create `SESSION_DIR`
213
+ 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
214
+ 4. Derive `phase_goals[]` from flags (apply `skip_when`)
215
+ 5. Write `session.json` + `understanding.md` §1
216
+ 6. Emit Goal Prompt (see Appendix)
217
+
218
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): INTAKE — 目标解析与上下文加载"`
219
+
220
+ ### A_RESUME_SESSION
221
+ Find latest session via Glob → read `session.json` → display summary → jump to `current_state`.
222
+
223
+ ### A_ARCHAEOLOGY
224
+ **Git archaeology (2 parallel Agents):**
225
+
226
+ | Agent | Task |
227
+ |-------|------|
228
+ | Timeline | `git log --oneline -20 -- {files}` change timeline |
229
+ | Blame | Top 3 suspicious files: `git blame -L {region}` → critical paths |
230
+
231
+ Append findings to `evidence.ndjson` (phase: "archaeology").
232
+
233
+ **CLI-assisted change review:**
234
+ ```bash
235
+ maestro delegate "PURPOSE: Review recent modifications related to: {issue}
236
+ TASK: Analyze intent behind changes | Identify risky modifications | Flag potential bug sources
237
+ MODE: analysis
238
+ CONTEXT: @{relevant_files} | Git log: {top_10_commits}
239
+ EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
240
+ CONSTRAINTS: Focus on behavioral changes, not formatting
241
+ " --role analyze --mode analysis
242
+ ```
243
+ Run_in_background, STOP, wait for callback. Append results to evidence.
244
+
245
+ Update `understanding.md` §2.
246
+
247
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): ARCHAEOLOGY — git 考古分析"`
248
+
249
+ ### A_EXPLORE
250
+ Skip if no enabled CLI tools (W006).
251
+
252
+ ```bash
253
+ maestro delegate "PURPOSE: Gather codebase evidence for: {issue}
254
+ TASK: Trace call chains | Find recent changes | Identify error gaps | Check similar patterns
255
+ MODE: analysis
256
+ CONTEXT: @**/*
257
+ EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
258
+ CONSTRAINTS: Max 20 entries/category | Symptom-related code paths
259
+ Symptoms: {issue} Archaeology hints: {suspicious_commits}
260
+ " --role explore --mode analysis
261
+ ```
262
+ Run_in_background, STOP, wait for callback.
263
+
264
+ Parse write `explore.json` + append `evidence.ndjson` (phase: "explore"). Update §3. Mark G2 done.
265
+
266
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): EXPLORE — 代码探索完成"`
267
+
268
+ ### A_DIAGNOSE
269
+ 1. **Form hypotheses** from evidence (archaeology + explore), ranked [HIGH]/[MEDIUM]/[LOW] → §4
270
+ 2. **Test each** (rank order): design test → execute → append evidence (phase: "diagnosis")
271
+ 3. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: AskUserQuestion | `-y`: defer
272
+ 4. **Root cause**: confirmed `session.json.root_cause` + §5. Mark G1 done.
273
+
274
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): DIAGNOSE 根因确认"`
275
+
276
+ ### A_ESCALATE_DIAGNOSIS
277
+ Increment `diagnosis_retries`. If < 3: broaden scope via `maestro delegate --role analyze` (same delegate format), form new hypotheses, return to S_DIAGNOSE. If >= 3: Normal → AskUserQuestion (broaden/new/INCONCLUSIVE) | `-y` → auto INCONCLUSIVE, proceed to S_RECORD. See Appendix: `-y` behavior.
278
+
279
+ ### A_FIX
280
+ 1. Present root cause + proposed fix. Normal: AskUserQuestion | `-y`: auto proceed (see Appendix)
281
+ 2. Implement fix
282
+ 3. Record in evidence (phase: "decision")
283
+
284
+ 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-debug({slug}): FIX {修复摘要}"`
285
+
286
+ ### A_CONFIRM
287
+ 1. **Tests**: auto-detect framework, run covering tests
288
+ 2. **CLI fix review**:
289
+ ```bash
290
+ maestro delegate "PURPOSE: Review fix for: {issue}
291
+ TASK: Verify correctness | Check regressions | Assess completeness | Review edge cases
292
+ MODE: analysis
293
+ CONTEXT: @{modified_files} | Root cause: {summary} | Diff: {git_diff}
294
+ EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk}
295
+ CONSTRAINTS: Focus on correctness, not style
296
+ " --role review --mode analysis
297
+ ```
298
+ Run_in_background, STOP, wait for callback.
299
+
300
+ 3. Write `session.json.confirmation`: `{test_result, cli_review, overall: "confirmed|needs_rework", timestamp}`
301
+ 4. Update §6. `needs_rework` S_FIX. `confirmed` → mark G3 done, advance.
302
+
303
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): CONFIRM — 修复验证"`
304
+
305
+ ### A_GENERALIZE
306
+ 举一反三: multi-layer pattern extraction → 4-agent scan → cross-layer dedup → iterative deepening.
307
+
308
+ **Pattern extraction** from root cause + fix:
309
+
310
+ | Layer | Method | Example |
311
+ |-------|--------|---------|
312
+ | Syntax | Regex patterns (direct Grep) | `eval(`, missing `await`, unclosed resource |
313
+ | Semantic | Anti-pattern description (Agent-driven) | Unhandled async errors, unvalidated input |
314
+ | Structural | Architecture-level (file/module similarity) | Same import structure, missing override |
315
+
316
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template}]`
317
+
318
+ **4-agent parallel codebase scan:**
319
+
320
+ | Agent | Strategy | Input | Scope |
321
+ |-------|----------|-------|-------|
322
+ | Syntax grep | Grep syntax-layer regex | P*.signature | Full project |
323
+ | Semantic scan | Understand + check anti-pattern | P*.description | Related modules |
324
+ | Structural match | Find structurally similar files | Buggy file structure | Full project |
325
+ | Historical grep | `git log -S "{pattern}"` | P*.signature | Full git history |
326
+
327
+ Returns: `[{pattern_id, file, line, context, risk_level, layer, confidence}]`
328
+
329
+ **Cross-layer dedup**: same file:line multi-layer hit → boost confidence | single-layer → `needs_review` | historical hit on fixed record → `regression_risk`
330
+
331
+ **Iterative deepening**: module with ≥3 hits → targeted deep scan (max 1 round).
332
+
333
+ **Quality Gate** (self-iteration) → if insufficient, expand and re-scan.
334
+
335
+ Write §7 + `session.json.generalization_stats`: `{patterns_extracted, total_hits, cross_layer_confirmed, regression_risks, by_layer, deepening_triggered}`. Mark G4 done.
336
+
337
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): GENERALIZE 泛化扫描完成"`
338
+
339
+ ### A_DISCOVER
340
+ 1. **Triage** each hit: read ±10 lines context → classify `safe`/`risk`/`bug`
341
+ 2. **Route**: see Appendix `-y` behavior table. Append evidence (phase: "discovery" + "decision")
342
+ 3. Update §8. Mark G5 done.
343
+
344
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): DISCOVER — 发现分类完成"`
345
+
346
+ ### A_RECORD
347
+ 1. Finalize `understanding.md` §9
348
+ 2. **Write learnings** to understanding.md §9: 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
349
+ 3. Mark G6 done. Process pending decisions: Normal AskUserQuestion | `-y` → skip (show deferred count)
350
+ 4. **Goal audit**: all `completion_confirmed` true → `phase_goals_all_done = true`. Any false: Normal → AskUserQuestion (回退/跳过/接受) | `-y` → auto accept
351
+ 5. **Completion**: `current_state = "COMPLETED"`, emit summary:
352
+ ```
353
+ --- DEBUG ODYSSEY COMPLETE ---
354
+ Issue: {issue}
355
+ Root cause: {root_cause.hypothesis}
356
+ Fix: {applied|skipped|inconclusive}
357
+ Patterns: {patterns_extracted} ({by_layer} distribution)
358
+ Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
359
+ Issues: {N} created
360
+ Decisions: {N} resolved, {M} pending, {K} deferred
361
+ Learnings: {N} spec entries persisted
362
+ Self-iter: {N} quality gate rounds across {M} stages
363
+ Goals: {done}/{total} confirmed ({skipped} skipped)
364
+ ---
365
+ ```
366
+
367
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-debug({slug}): RECORD — 会话总结与知识沉淀"`
368
+
369
+ </actions>
370
+
371
+ <appendix>
372
+
373
+ ### Goal Prompt Template
374
+
375
+ **时机守卫:仅在 A_INTAKE 完成后显示一次。A_RECORD 完成时禁止重新显示。**
376
+
377
+ ```
378
+ 📋 Debug Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
379
+
380
+ /goal 穷尽迭代:直到根因确认(或明确 INCONCLUSIVE)且修复验证通过
381
+ 且泛化扫描穷尽(所有 hits 已分类处理)且 phase_goals_all_done=true 才停。
382
+ 假设失败时扩范围→换视角→升级工具,不轻易放弃。
383
+ 泛化发现的同类 bug 全部修复或创建 issue,不允许遗留。
384
+ 遇到 phase=decision 的 pending 必须 AskUserQuestion,不得自行 resolve。
385
+ ```
386
+
387
+ Odyssey 输出提示词后继续执行不阻塞。`/goal` 由用户任意时刻输入。
388
+
389
+ ### `-y` Auto-Confirm Behavior
390
+
391
+ | Decision Point | Normal | `-y` mode |
392
+ |---------------|--------|-----------|
393
+ | A_DIAGNOSE ambiguity | AskUserQuestion blocks | record `deferred`, best-effort continue |
394
+ | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
395
+ | A_FIX direction | AskUserQuestion confirm | auto proceed with suggested fix |
396
+ | A_DISCOVER bug triage | AskUserQuestion route | auto create issue |
397
+ | A_DISCOVER ambiguous | AskUserQuestion batch | all `deferred` |
398
+ | A_RECORD decisions | AskUserQuestion per-item | skip, show deferred count |
399
+ | A_RECORD goal audit | AskUserQuestion 3-way | auto accept current state |
400
+
401
+ `deferred` items shown as "待决策" in completion summary; recoverable via `-c`.
402
+
403
+ ### Phase Goal Lifecycle
404
+
405
+ `pending done (confirmed=true)` normal | `pending → skipped (confirmed=true)` flags/manual | `pending failed (confirmed=false)` INCONCLUSIVE
406
+
407
+ `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
408
+
409
+ </appendix>
410
+
411
+ </state_machine>
412
+
413
+ <error_codes>
414
+ | Code | Severity | Condition | Recovery |
415
+ |------|----------|-----------|----------|
416
+ | E001 | error | No issue and no session to resume | Provide issue or use -c |
417
+ | E003 | error | Resume but no session found | Start new session |
418
+ | E004 | error | Delegate execution failed | Retry or proceed without CLI |
419
+ | W001 | warning | No relevant git history | Proceed with limited context |
420
+ | W002 | warning | All hypotheses inconclusive after 3 retries | INCONCLUSIVE |
421
+ | W003 | warning | Generalization scan 0 hits | Skip discovery |
422
+ | W004 | warning | Delegate parse failed | Use raw output |
423
+ | W005 | warning | Pending decisions unresolved | Filter evidence.ndjson phase=decision |
424
+ | W006 | warning | CLI exploration skipped (no tools) | Proceed without explore.json |
425
+ </error_codes>
426
+
427
+ <success_criteria>
428
+ - [ ] Session directory created with 4 output files
429
+ - [ ] Prior knowledge searched (maestro search + sessions + architecture)
430
+ - [ ] Git archaeology (log + blame) + CLI change review, evidence.ndjson phase=archaeology
431
+ - [ ] CLI exploration, explore.json written, evidence phase=explore
432
+ - [ ] Hypotheses formed from archaeology + explore, tested and logged phase=diagnosis
433
+ - [ ] Root cause declared with evidence refs
434
+ - [ ] understanding.md tracks all 9 sections progressively
435
+ - [ ] Fix implemented + confirmed with test + CLI review (unless --skip-fix)
436
+ - [ ] Multi-layer patterns (syntax/semantic/structural) extracted (unless --skip-generalize)
437
+ - [ ] 4-agent scan + cross-layer dedup + iterative deepening for ≥3 hits/module
438
+ - [ ] Discoveries classified and routed (fix/issue/decision/skip)
439
+ - [ ] Decision journal: all human-judgment items in evidence.ndjson phase=decision
440
+ - [ ] phase_goals derived from flags, skip_when applied, each phase marks its goal
441
+ - [ ] Goal audit in A_RECORD — unmet goals surfaced, phase_goals_all_done set correctly
442
+ - [ ] Goal Prompt displayed once after session creation
443
+ - [ ] `-y`: all decisions auto-resolve/defer, deferred count in summary
444
+ - [ ] State saved at each transition (resumable via -c)
445
+ - [ ] Quality Gate self-iteration when insufficient, logged in self_iteration_log
446
+ - [ ] Spec entries persisted for reusable learnings
447
+ - [ ] Completion summary with all stats
448
+ </success_criteria>
449
+
450
+ <next_step_routing>
451
+ | Condition | Next step |
452
+ |-----------|-----------|
453
+ | Issues from discoveries | `/manage-issue list --source debug-odyssey` |
454
+ | Pattern worth documenting | `/learn-decompose <module>` |
455
+ | Fix needs formal review | `/quality-review <phase>` |
456
+ | Second opinion on root cause | `/learn-second-opinion <understanding.md>` |
457
+ | Related question | `/learn-investigate "<question>"` |
458
+ | Decisions still pending | Filter evidence.ndjson phase=decision status=pending |
459
+ </next_step_routing>