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