self-evolving-workflow 0.0.0-stage → 0.1.3

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 (173) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +90 -2
  3. package/dist/agent-memory-prompts.d.ts +13 -0
  4. package/dist/agent-memory-prompts.js +55 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +6 -0
  7. package/dist/closeout.d.ts +105 -0
  8. package/dist/closeout.js +479 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/common.d.ts +9 -0
  12. package/dist/common.js +42 -0
  13. package/dist/context-envelope.d.ts +59 -0
  14. package/dist/context-envelope.js +23 -0
  15. package/dist/host-adapters.d.ts +34 -0
  16. package/dist/host-adapters.js +151 -0
  17. package/dist/http.d.ts +3 -0
  18. package/dist/http.js +90 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.js +13 -0
  21. package/dist/knowledge-cli.d.ts +183 -0
  22. package/dist/knowledge-cli.js +654 -0
  23. package/dist/knowledge-reads.d.ts +71 -0
  24. package/dist/knowledge-reads.js +193 -0
  25. package/dist/memory.d.ts +97 -0
  26. package/dist/memory.js +250 -0
  27. package/dist/retrospective.d.ts +57 -0
  28. package/dist/retrospective.js +248 -0
  29. package/dist/search.d.ts +36 -0
  30. package/dist/search.js +112 -0
  31. package/dist/skill-addition.d.ts +25 -0
  32. package/dist/skill-addition.js +89 -0
  33. package/dist/skill-design.d.ts +96 -0
  34. package/dist/skill-design.js +226 -0
  35. package/dist/skill-replay.d.ts +55 -0
  36. package/dist/skill-replay.js +451 -0
  37. package/dist/skill-route.d.ts +30 -0
  38. package/dist/skill-route.js +75 -0
  39. package/dist/transcript-evidence.d.ts +3 -0
  40. package/dist/transcript-evidence.js +58 -0
  41. package/dist/upstream/chunker.d.ts +24 -0
  42. package/dist/upstream/chunker.js +96 -0
  43. package/dist/upstream/file-protocol.d.ts +45 -0
  44. package/dist/upstream/file-protocol.js +117 -0
  45. package/dist/upstream/frontmatter.d.ts +47 -0
  46. package/dist/upstream/frontmatter.js +86 -0
  47. package/dist/upstream/graph-search.d.ts +33 -0
  48. package/dist/upstream/graph-search.js +67 -0
  49. package/dist/upstream/l1-extraction.d.ts +26 -0
  50. package/dist/upstream/l1-extraction.js +405 -0
  51. package/dist/upstream/llm.d.ts +8 -0
  52. package/dist/upstream/llm.js +1 -0
  53. package/dist/upstream/merge.d.ts +50 -0
  54. package/dist/upstream/merge.js +153 -0
  55. package/dist/upstream/prompts.d.ts +53 -0
  56. package/dist/upstream/prompts.js +185 -0
  57. package/dist/upstream/search-utils.d.ts +34 -0
  58. package/dist/upstream/search-utils.js +55 -0
  59. package/dist/upstream/slug.d.ts +26 -0
  60. package/dist/upstream/slug.js +103 -0
  61. package/dist/upstream/template.d.ts +29 -0
  62. package/dist/upstream/template.js +80 -0
  63. package/dist/upstream/tokenize.d.ts +4 -0
  64. package/dist/upstream/tokenize.js +29 -0
  65. package/dist/wiki-change.d.ts +76 -0
  66. package/dist/wiki-change.js +299 -0
  67. package/dist/wiki-entry.d.ts +26 -0
  68. package/dist/wiki-entry.js +93 -0
  69. package/dist/wiki-ingest.d.ts +12 -0
  70. package/dist/wiki-ingest.js +126 -0
  71. package/dist/wiki-migration.d.ts +16 -0
  72. package/dist/wiki-migration.js +268 -0
  73. package/dist/wiki-tokens.d.ts +1 -0
  74. package/dist/wiki-tokens.js +46 -0
  75. package/dist/wiki.d.ts +103 -0
  76. package/dist/wiki.js +330 -0
  77. package/dist/workflow-cli.d.ts +2 -0
  78. package/dist/workflow-cli.js +258 -0
  79. package/dist/workflow-install.d.ts +36 -0
  80. package/dist/workflow-install.js +148 -0
  81. package/dist/workflow-knowledge.d.ts +16 -0
  82. package/dist/workflow-knowledge.js +24 -0
  83. package/dist/workflow-mcp.d.ts +2 -0
  84. package/dist/workflow-mcp.js +144 -0
  85. package/dist/workflow-names.d.ts +4 -0
  86. package/dist/workflow-names.js +18 -0
  87. package/dist/workflow-runtime.d.ts +622 -0
  88. package/dist/workflow-runtime.js +627 -0
  89. package/dist/workflow-skills.d.ts +48 -0
  90. package/dist/workflow-skills.js +141 -0
  91. package/package.json +76 -4
  92. package/skills/ew-odyssey/SKILL.md +237 -0
  93. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  94. package/skills/ew-odyssey/references/odyssey-base-codex.md +3 -0
  95. package/skills/ew-odyssey/references/odyssey-base.md +278 -0
  96. package/skills/ew-odyssey/references/odyssey-debug.codex.md +305 -0
  97. package/skills/ew-odyssey/references/odyssey-debug.md +283 -0
  98. package/skills/ew-odyssey/references/odyssey-defensive.codex.md +395 -0
  99. package/skills/ew-odyssey/references/odyssey-defensive.md +369 -0
  100. package/skills/ew-odyssey/references/odyssey-improve.codex.md +270 -0
  101. package/skills/ew-odyssey/references/odyssey-improve.md +248 -0
  102. package/skills/ew-odyssey/references/odyssey-planex.codex.md +352 -0
  103. package/skills/ew-odyssey/references/odyssey-planex.md +312 -0
  104. package/skills/ew-odyssey/references/odyssey-review.codex.md +283 -0
  105. package/skills/ew-odyssey/references/odyssey-review.md +251 -0
  106. package/skills/ew-odyssey/references/odyssey-security.md +249 -0
  107. package/skills/ew-odyssey/references/odyssey-ui.codex.md +294 -0
  108. package/skills/ew-odyssey/references/odyssey-ui.md +250 -0
  109. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +105 -0
  110. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +121 -0
  111. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +93 -0
  112. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +104 -0
  113. package/skills/ew-odyssey/references/prepare/odyssey-review.md +98 -0
  114. package/skills/ew-odyssey/references/prepare/odyssey-security.md +94 -0
  115. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +87 -0
  116. package/skills/ew-orchestrate/SKILL.md +236 -0
  117. package/skills/ew-orchestrate/references/auto-policy.md +165 -0
  118. package/skills/ew-orchestrate/references/companion-route.md +52 -0
  119. package/skills/ew-orchestrate/references/ew-orchestrate.md +27 -0
  120. package/skills/ew-orchestrate/references/goal.md +53 -0
  121. package/skills/ew-orchestrate/references/knowledge-route.md +163 -0
  122. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +36 -0
  123. package/skills/ew-orchestrate/references/planning.md +137 -0
  124. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +62 -0
  125. package/skills/ew-orchestrate/steps/ew-analyze/references/boundary-grill.md +50 -0
  126. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +59 -0
  127. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +42 -0
  128. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +401 -0
  129. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +32 -0
  130. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +9 -0
  131. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +71 -0
  132. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +69 -0
  133. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +373 -0
  134. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +102 -0
  135. package/skills/ew-orchestrate/steps/ew-plan/references/boundary-grill.md +50 -0
  136. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +51 -0
  137. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  138. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +278 -0
  139. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +44 -0
  140. package/skills/ew-orchestrate/steps/ew-review/references/odyssey-base-codex.md +3 -0
  141. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +76 -0
  142. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +283 -0
  143. package/skills/ew-skill-design/SKILL.md +28 -0
  144. package/skills/ew-skill-design/references/package-contract.md +28 -0
  145. package/skills/ew-skill-design/references/validation.md +7 -0
  146. package/skills/team-swarm/SKILL.md +231 -0
  147. package/skills/team-swarm/references/mcp-coordination.md +10 -0
  148. package/skills/team-swarm/roles/analyst/role.md +181 -0
  149. package/skills/team-swarm/roles/ant/role.md +149 -0
  150. package/skills/team-swarm/roles/coordinator/commands/converge.md +154 -0
  151. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +134 -0
  152. package/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
  153. package/skills/team-swarm/roles/coordinator/role.md +228 -0
  154. package/skills/team-swarm/roles/scorer/role.md +150 -0
  155. package/skills/team-swarm/scripts/aco.py +646 -0
  156. package/skills/team-swarm/scripts/pheromone.py +144 -0
  157. package/skills/team-swarm/scripts/scoring.py +111 -0
  158. package/skills/team-swarm/scripts/test_aco.py +606 -0
  159. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  160. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  161. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  162. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  163. package/skills/team-swarm/specs/swarm-protocol.md +123 -0
  164. package/skills/workflow-closeout/SKILL.md +10 -0
  165. package/skills/workflow-evolve/SKILL.md +79 -0
  166. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  167. package/skills/workflow-evolve/references/auto-loop.md +20 -0
  168. package/skills/workflow-evolve/references/history-review.md +14 -0
  169. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +76 -0
  170. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  171. package/skills/workflow-evolve/scripts/evolve-loop.mjs +259 -0
  172. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  173. package/workflows/index.json +23 -0
@@ -0,0 +1,312 @@
1
+ ---
2
+ name: ew-odyssey-planex
3
+ prepare: odyssey-planex
4
+ session-mode: inherited
5
+ ---
6
+
7
+ # Workflow: Odyssey Planex
8
+
9
+ Single requirement delivery loop — requirement parsing → acceptance criteria → plan → execute → verify → generalize.
10
+
11
+ ---
12
+
13
+ ## State Chain
14
+
15
+ ```
16
+ S_INTAKE → S_PLAN → S_EXECUTE → S_VERIFY → S_FIX → [back-half]
17
+ ```
18
+
19
+ FIX↔VERIFY loop until all criteria pass. Back-half: `S_GENERALIZE → S_DISCOVER → S_RECORD → END` (see [shared phases](odyssey-base.md) §Shared Back-Half).
20
+
21
+ ---
22
+
23
+ ## Boundary
24
+
25
+ **In scope:** Single requirement delivery loop — requirement parsing → all acceptance criteria passing + generalization.
26
+ **Out of scope:** Multi-requirement orchestration → `/ew-orchestrate --goal roadmap` | Deep debugging → `--mode debug` | Code review → `--mode review` | UI optimization → `--mode ui`
27
+
28
+ ---
29
+
30
+ ## Context
31
+
32
+ ### `--template <name>`
33
+
34
+ | Template | Criteria pattern | Use case |
35
+ |----------|-----------------|----------|
36
+ | `feature` | User story acceptance + boundary tests + UI verification | New feature |
37
+ | `bugfix` | Regression tests + root cause confirmation + boundary coverage | Bug fix |
38
+ | `refactor` | Behavior preservation + performance baseline + API compatibility | Refactoring |
39
+ | `migration` | Data consistency + rollback verification + performance comparison | Data/API migration |
40
+ | `api-endpoint` | Request/response contract + error handling + permission checks | API development |
41
+
42
+ ### Target Resolution
43
+
44
+ Requirement parsed from `<intent>`.
45
+
46
+ ### Session Fields
47
+
48
+ ```json
49
+ { "requirement": "",
50
+ "acceptance_criteria": [{"id":"AC1","criterion":"","verify_method":"test|grep|cli-review|manual","status":"pending","evidence":"","passed_at":null}],
51
+ "plan": {"tasks":[{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[],"domain":"general","executor":"agent"}],"created_at":""},
52
+ "execution_config": {"method":"auto","default_executor":"","domain_routing":{"frontend":"","backend":"","default":"agent"},"code_review_tool":"Skip","verification_tool":"Auto","confirmed":false},
53
+ "iterations": [{"iteration":1,"started_at":"","completed_at":"","criteria_before":{"passed":0,"total":0},"criteria_after":{"passed":0,"total":0},"gaps_fixed":[],"files_modified":[]}],
54
+ "current_iteration": 0,
55
+ "patterns": [], "generalization_stats": null }
56
+ ```
57
+
58
+ ### evidence.ndjson Phases
59
+
60
+ `planning|execution|verification|fix|decision|generalization|discovery|self-iteration`
61
+
62
+ ### phase_goals[]
63
+
64
+ | ID | Goal | done_when | phase | skip_when |
65
+ |----|------|-----------|-------|-----------|
66
+ | G1 | Acceptance criteria defined | ≥1 criterion in acceptance_criteria[] | S_INTAKE | — |
67
+ | G2 | Plan created | session.json.plan populated | S_PLAN | — |
68
+ | G3 | Implementation complete | all plan tasks executed | S_EXECUTE | — |
69
+ | G4 | All criteria pass | all acceptance_criteria[].status == passed | S_VERIFY | — |
70
+ | G5 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
71
+ | G6 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
72
+ | G7 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
73
+
74
+ ### understanding.md — 8 Sections
75
+
76
+ 1. Requirement & Criteria
77
+ 2. Plan
78
+ 3. Execution
79
+ 4. Verification
80
+ 5. Fix Log
81
+ 6. Generalization
82
+ 7. Discoveries
83
+ 8. Learnings
84
+
85
+ ---
86
+
87
+ ## State Machine
88
+
89
+ ### Transitions
90
+
91
+ ```
92
+ S_PLAN → S_EXECUTE
93
+ S_EXECUTE → S_VERIFY
94
+ S_VERIFY → S_GENERALIZE : all passed AND !skip_generalize
95
+ S_VERIFY → S_RECORD : all passed AND skip_generalize
96
+ S_VERIFY → S_FIX : some failed AND iteration < max
97
+ S_VERIFY → S_PLAN : fundamental plan flaw → cross_phase_loops++ (replan). Criteria preservation: acceptance_criteria[] statuses preserved; only plan.tasks[] regenerated. Passed criteria retain `passed`; failed criteria reset to `pending` for re-verification.
98
+ S_VERIFY → S_RECORD : some failed AND iteration >= max (escalate)
99
+ S_FIX → S_VERIFY (loop)
100
+ ```
101
+
102
+ Discover routes to S_EXECUTE (not FIX): area needing same implementation → new task, `cross_phase_loops++`.
103
+
104
+ ### Actions
105
+
106
+ **A_INTAKE extra** — Define acceptance criteria: analyze requirement → derive testable criteria, each with `verify_method` (test|grep|cli-review|manual). Normal: request_user_input to confirm/edit | `-y`: auto-derive, record `{"phase":"decision","type":"criteria-confirmation","status":"deferred"}`. Mark G1.
107
+
108
+ **GATE: criteria-defined** — ≥1 criterion in `acceptance_criteria[]`, each with a testable `criterion` and assigned `verify_method` (test|grep|cli-review|manual); confirmed by user or auto-derived with deferred confirmation under `-y`; G1 marked.
109
+
110
+ **A_PLAN** — (1) Decompose requirement into ordered tasks mapped to acceptance criteria. (2) CLI-assisted planning (optional):
111
+ ```bash
112
+ evolve delegate "PURPOSE: Create implementation plan for: {requirement}
113
+ TASK: Decompose into subtasks | Map to acceptance criteria | Identify dependencies
114
+ MODE: analysis
115
+ CONTEXT: @**/* | Criteria: {criteria_summary}
116
+ EXPECTED: JSON [{task_id, title, description, criteria_refs, deps}]
117
+ " --role analyze --mode analysis
118
+ ```
119
+ Run `run_in_background: true`, wait for callback. (3) Write `session.json.plan`, append evidence (planning), update §2. Mark G2.
120
+
121
+ Commit: `"odyssey-planex({slug}): PLAN — requirement decomposed into tasks"`
122
+
123
+ **A_EXECUTE** —
124
+
125
+ - **Step 1 — Execution Options Confirmation.** Skip if `-y` OR `--method` explicitly set OR `execution_config.confirmed == true` (resume). Load tools: `the Codex or Agy executables available to the host`. request_user_input 3 questions: Executor (Auto domain routing | Agent all | specific CLI | custom) / Review (Skip | {tool}) / Verify (Auto | specific tool | Skip). Parse → write `execution_config`, set `confirmed: true`. `--skip-verify` overrides verification to `"Skip"`.
126
+
127
+ - **Step 2 — Executor Resolution** (method == "auto"): domain routing — frontend (UI/component/page/style, .tsx/.jsx/.vue/.css/.html/.svelte) | backend (API/server/db/service, .go/.rs/.java/.py/.sql/.proto) | general (mixed/config/tests, .ts/.js/other). Resolution: `execution_config.domain_routing[domain]` → fallback `.default` ("agent").
128
+
129
+ - **Step 3 — Task Execution** per plan order (independent tasks may parallelize). **Agent path:** spawn Agent with task definition + criteria refs + prior task summaries + specs_content → implement → verify convergence → auto-fix (max 3) → return. **CLI path:**
130
+ ```bash
131
+ evolve delegate "PURPOSE: Implement task ${task_id}: ${title}; success = criteria ${criteria_refs} satisfied
132
+ TASK: ${description} | Read existing code first | Verify convergence criteria after changes
133
+ MODE: write
134
+ CONTEXT: @${scope}/**/* | Criteria: ${criteria_summary}
135
+ EXPECTED: Working code changes, convergence evidence, summary of what was done
136
+ CONSTRAINTS: Scope limited to task files | Follow project specs
137
+
138
+ ## Acceptance Criteria (must satisfy)
139
+ ${criteria_refs.map(ref => criteria[ref].criterion).join('\n')}
140
+
141
+ ## Implementation Steps
142
+ ${task.description}
143
+
144
+ ## Project Specs
145
+ ${specs_content}
146
+
147
+ ## Prior Task Summaries
148
+ ${prior_summaries}
149
+ " --to ${resolved_executor} --mode write --id planex-${slug}-${task_id}
150
+ ```
151
+ Run `run_in_background: true`, wait for callback. **Deviation Rule (MANDATORY hard limit — max 3 retries per task):** first attempt normal dispatch → retry `--resume planex-${slug}-${task_id}` simplified → fallback to Agent path → all 3 fail → mark task `blocked`, checkpoint, continue remaining. NEVER exceed 3 attempts on a single task.
152
+
153
+ - **Step 4 — Per-Task Evidence:** `{"phase":"execution","type":"task-completed","task_id":"T1","executor":"...","files_modified":[],"summary":"","attempt":1}`; update task status.
154
+
155
+ - **Step 5 — Post-Execution Validation.** Skip if `verification_tool == "Skip"` OR `--skip-verify` OR no completed tasks. **Check 1** Summary Consistency (task status vs git diff). **Check 2** CLI Verification Gate:
156
+ ```bash
157
+ evolve delegate "PURPOSE: Verify execution output meets acceptance criteria; success = all criteria verified with file:line evidence
158
+ TASK:
159
+ 1. CONVERGENCE: For each criterion, read actual code, verify behavior exists, report status with evidence
160
+ 2. EXISTENCE: Verify all expected files exist on disk
161
+ 3. SUBSTANCE: Verify real implementation — flag stubs, placeholders, TODO-only
162
+ 4. ANTI-PATTERNS: Scan for TODO/FIXME/HACK, console.log debug, disabled tests
163
+ MODE: analysis
164
+ CONTEXT: @${modified_files}
165
+ EXPECTED: JSON { convergence: [{criterion, status, evidence}], issues: [{type, file, line, severity}], overall: passed|gaps_found }
166
+ CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line
167
+
168
+ ## Acceptance Criteria (verify each)
169
+ ${acceptance_criteria.map(c => c.criterion).join('\n')}
170
+
171
+ ## Modified Files
172
+ ${modified_files.join('\n')}
173
+ " --to ${execution_config.verification_tool} --mode analysis
174
+ ```
175
+ Run `run_in_background: true`. `overall == "passed"` → proceed to S_VERIFY with boosted confidence; `gaps_found` → log findings, proceed. **Check 3** Code Review (if `code_review_tool != "Skip"`): `evolve delegate "Review git diff for correctness, style, bugs" --to ${code_review_tool} --mode analysis --rule analysis-review-code-quality`.
176
+
177
+ - **Step 6 — Completion:** update §3. Mark G3.
178
+
179
+ **GATE: plan-executed** — all plan tasks executed (`completed`) or explicitly `blocked` after 3 retries with logged evidence; per-task execution evidence recorded; post-execution validation (convergence, existence, substance, anti-patterns) completed unless `--skip-verify`; G3 marked.
180
+
181
+ Commit: `"odyssey-planex({slug}): EXECUTE — task implementation complete"`
182
+
183
+ **A_VERIFY** — Iron gate; verify each criterion by method:
184
+
185
+ | Method | Action |
186
+ |--------|--------|
187
+ | `test` | Run relevant tests, check pass/fail |
188
+ | `grep` | Grep for expected pattern |
189
+ | `cli-review` | `evolve delegate "PURPOSE: Verify criterion {id}: {criterion}\nTASK: Read implementation \| Check behavior \| Report pass/fail with file:line\nMODE: analysis\nCONTEXT: @{relevant_files}\nEXPECTED: JSON {criterion_id, status, evidence}" --role review --mode analysis` |
190
+ | `manual` | Normal: request_user_input / `-y`: record `deferred` |
191
+
192
+ Record per criterion: `{"phase":"verification","type":"criterion-check","criterion_id":"AC1","method":"","result":"passed|failed","evidence":"","iteration":N}`. Update `acceptance_criteria[].status`. Append to `iterations[]`. Update §4 pass/fail table. **Route:** all passed → mark G4 → next. Some failed + iteration < max → S_FIX. Some failed + iteration >= max → Normal: request_user_input (continue/lower bar/accept) / `-y`: `deferred`, proceed S_RECORD.
193
+
194
+ **GATE: all-criteria-passed** — every `acceptance_criteria[].status == passed` with recorded evidence and `passed_at`, verified by the declared `verify_method`; iterations logged in `iterations[]`; if max iterations exceeded, criteria may be `deferred` only with explicit user consent (or `-y` auto-accept); G4 marked.
195
+
196
+ Commit: `"odyssey-planex({slug}): VERIFY — criteria verification iteration {N}"`
197
+
198
+ **A_FIX** — (1) Increment `current_iteration`. (2) For each failed criterion: diagnose gap → targeted code fix (not re-implementation). (3) CLI fix review (optional): `evolve delegate` review fixes for regressions, EXPECTED `{verdict, regression_risk, concerns}`. (4) Append evidence (fix), update §5 → S_VERIFY.
199
+
200
+ Commit: `"odyssey-planex({slug}): FIX — iteration {N} gap fixes"`
201
+
202
+ ---
203
+
204
+ ## Generalize Source
205
+
206
+ Implementation patterns from executed tasks (API contract shapes, validation shapes, error response format, config structure).
207
+
208
+ ---
209
+
210
+ ## Iteration Model
211
+
212
+ ```
213
+ S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER → S_RECORD
214
+ │ │
215
+ some fail + iter < max 3-layer scan, 0 hits ─→ S_RECORD
216
+ ▼
217
+ S_FIX ──→ S_VERIFY (loop)
218
+ ```
219
+
220
+ Max iterations (default 3) prevents infinite loops.
221
+
222
+ ---
223
+
224
+ ## Knowledge Persistence (§8)
225
+
226
+ Include verified reusable findings in the Run summary and harvest the completed Session through Agent Memory closeout.
227
+
228
+
229
+ | Category | Content | Follow-up |
230
+ |----------|---------|-----------|
231
+ | Multi-round fix cycle pattern | Problem scenario + fix iteration + final approach | `stage spec → debug` |
232
+ | Reusable implementation pattern | Pattern + applicable scope + code template | `stage spec → coding` |
233
+ | Acceptance criteria template | Standard template + verify_method suggestion | `stage spec → review` |
234
+ | Generalization pattern | Signature + risk + fix template | `stage spec → coding` |
235
+
236
+ ---
237
+
238
+ ## Completion Summary
239
+
240
+ ```
241
+ --- PLANEX ODYSSEY COMPLETE ---
242
+ Requirement: {requirement}
243
+ Criteria: {passed}/{total} passed
244
+ Iterations: {N} cycles
245
+ Patterns: {patterns_extracted} ({by_layer} distribution)
246
+ Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
247
+ Issues: {N} created | Decisions: {N} resolved, {M} pending, {K} deferred
248
+ Learnings: {N} spec entries
249
+ Self-iter: {N} rounds across {M} stages
250
+ Goals: {done}/{total} confirmed ({skipped} skipped)
251
+ Status: {ALL_PASSED|PARTIAL|ESCALATED}
252
+ ---
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Mode `-y` Points
258
+
259
+ | Decision Point | Normal | `-y` |
260
+ |---------------|--------|------|
261
+ | S_INTAKE criteria | request_user_input | auto-derive `deferred` |
262
+ | S_EXECUTE options | request_user_input | defaults (auto/Skip/Auto) `confirmed:true` |
263
+ | S_EXECUTE task blocked | request_user_input | auto continue, log blocked |
264
+ | S_VERIFY manual criterion | request_user_input | `deferred` |
265
+ | S_VERIFY max iteration | request_user_input | auto accept `deferred` |
266
+ | A_DISCOVER routing | request_user_input | auto-route to execute, issue for rest |
267
+
268
+ ---
269
+
270
+ ## Phase Gates
271
+
272
+ - **Audit gate** (PLAN+EXECUTE): plan tasks mapped to criteria; all tasks executed or blocked after 3 retries.
273
+ - **FIX gate:** current severity tier fully addressed. Per-fix evidence phase=fix logged. Auto-commit per tier.
274
+ - **VERIFY gate:** every criterion verified by its method. confirmation written, understanding.md updated, verify goal marked. needs_rework → route back to FIX.
275
+
276
+ ---
277
+
278
+ ## Error Codes
279
+
280
+ | Code | Severity | Condition | Recovery |
281
+ |------|----------|-----------|----------|
282
+ | E001 | error | No requirement | Provide requirement or -c |
283
+ | W007 | warning | CLI review regression concern | Review before next iteration |
284
+
285
+ ---
286
+
287
+ ## Success Criteria
288
+
289
+ - [ ] Requirement parsed; session + output files created; acceptance criteria defined
290
+ - [ ] Plan decomposed into tasks mapped to acceptance criteria
291
+ - [ ] All tasks executed (or blocked after 3 retries); execution evidence logged
292
+ - [ ] understanding.md sections written progressively (§1–§8)
293
+ - [ ] Criteria verified by method (test/grep/cli-review/manual); fix loop if needed
294
+ - [ ] Multi-layer generalization + discovery triage (unless --skip-generalize)
295
+ - [ ] phase_goals derived, tracked, and hardened-audited; goal_mode injected via prepare goal:true
296
+ - [ ] Session resumable via -c; completion summary emitted
297
+ - [ ] Status: ALL_PASSED / PARTIAL / ESCALATED
298
+
299
+ ---
300
+
301
+ ## Next Step Routing
302
+
303
+ | Condition | Next |
304
+ |-----------|------|
305
+ | Discovery issues created | `Open the follow-up findings in the project issue tracker` |
306
+ | Deeper debug needed | `/ew-odyssey <finding> --mode debug` |
307
+ | Formal review of changes | `/ew-odyssey <changed-files> --mode review` |
308
+ | UI-related findings | `/ew-odyssey <component> --mode ui` |
309
+ | Document pattern | `Review the module and stage the reusable method via Agent Memory closeout` |
310
+ | Second opinion | `evolve delegate "<review prompt>" --mode analysis` |
311
+ | Reusable pattern to persist | `stage spec → coding` |
312
+ | Pending decisions | Filter evidence phase=decision status=pending |
@@ -0,0 +1,283 @@
1
+ <!-- session-mode: inherited -->
2
+
3
+ # Workflow: Odyssey Review (Codex)
4
+
5
+ Codex-adapted: uses `spawn_agents_on_csv`, `request_user_input`, `update_plan`.
6
+
7
+ ## State Chain
8
+
9
+ ```
10
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → [back-half]
11
+ ```
12
+
13
+ Back-half: `S_GENERALIZE → S_DISCOVER → S_RECORD → END` (see [shared Codex phases](odyssey-base-codex.md)).
14
+
15
+ ---
16
+
17
+ ## Boundary
18
+
19
+ **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
20
+ **Out of scope:** Root cause debug → `--mode debug` | Feature implementation → `--mode planex` | UI visual optimization → `--mode ui`. Zero-residual applies (fix ALL findings within fix_threshold, default all).
21
+
22
+ ---
23
+
24
+ ## Target Resolution
25
+
26
+ | Input | Resolution |
27
+ |-------|-----------|
28
+ | File/dir path | Review those files |
29
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
30
+ | Phase number | state.json → changed files |
31
+ | PR number | `git diff main...HEAD` |
32
+
33
+ ---
34
+
35
+ ## Session Fields
36
+
37
+ ```json
38
+ { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
39
+ "patterns": [], "confirmation": null, "generalization_stats": null }
40
+ ```
41
+
42
+ ---
43
+
44
+ ## evidence.ndjson Phases
45
+
46
+ `archaeology|explore|review|fix|discovery|decision|self-iteration`
47
+
48
+ ---
49
+
50
+ ## phase_goals[]
51
+
52
+ | ID | Goal | done_when | phase | skip_when |
53
+ |----|------|-----------|-------|-----------|
54
+ | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
55
+ | G2 | Explore context | explore.json populated | S_EXPLORE | — |
56
+ | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
57
+ | G4 | Pattern generalized | patterns[] ≥1 | S_GENERALIZE | skip_generalize |
58
+ | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
59
+ | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
60
+
61
+ `update_plan({ plan: [{ step: "G1: review", status: "pending" }, ..., { step: "G6: record", status: "pending" }] })`(按上方 gate 表初始化 G1-G6 步骤清单)
62
+
63
+ ---
64
+
65
+ ## understanding.md — 8 Sections
66
+
67
+ 1. Target & Scope
68
+ 2. Archaeology
69
+ 3. Exploration
70
+ 4. Review Results
71
+ 5. Fix & Confirmation
72
+ 6. Generalization
73
+ 7. Discoveries
74
+ 8. Learnings
75
+
76
+ Specs: `agent-memory wiki constraints --category review`.
77
+
78
+ ---
79
+
80
+ ## State Machine — Transitions
81
+
82
+ ```
83
+ S_ARCHAEOLOGY → S_EXPLORE : complete
84
+ S_EXPLORE → S_REVIEW : complete
85
+ S_REVIEW → S_FIX : !skip_fix AND findings
86
+ S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
87
+ S_REVIEW → S_RECORD : both skip
88
+ S_FIX → S_CONFIRM : tier complete
89
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
90
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
91
+ S_CONFIRM → S_FIX : needs_rework
92
+ ```
93
+
94
+ Discover routes: fixable sibling → S_FIX; new target needing review → S_REVIEW (loops < max_loops).
95
+
96
+ ---
97
+
98
+ ## Actions
99
+
100
+ ### A_ARCHAEOLOGY
101
+
102
+ Generate `archaeology.csv` with 2 rows for parallel agents:
103
+
104
+ ```csv
105
+ id,title,description,target,deps,status,findings,error
106
+ "1","Timeline","Run git log --oneline -20 -- {files} for target files. Identify recent changes, authors, and change frequency. Return JSON: [{commit_sha, date, author, message, files_changed}]","{target}","","","",""
107
+ "2","Blame","Run git blame -L {region} on top 3 files by change frequency. Identify ownership patterns and recent modifications. Return JSON: [{file, line_range, author, commit_sha, date, content_summary}]","{target}","","","",""
108
+ ```
109
+
110
+ ```javascript
111
+ spawn_agents_on_csv({
112
+ csv_path: `${sessionFolder}/archaeology.csv`,
113
+ id_column: "id",
114
+ instruction: "You are performing git archaeology on target code. Read 'description' for your specific task and 'target' for the files to analyze. Use git commands to gather evidence. Write findings as a concise summary.",
115
+ max_concurrency: 2,
116
+ max_runtime_seconds: 3600,
117
+ output_csv_path: `${sessionFolder}/archaeology-results.csv`,
118
+ output_schema: { id, status: ["completed"|"failed"], findings, error }
119
+ })
120
+ ```
121
+
122
+ Evidence phase=archaeology.
123
+
124
+ `evolve delegate --role analyze --mode analysis` (`run_in_background: true`):
125
+ - PURPOSE: review recent modifications related to {target}
126
+ - EXPECTED: JSON `[{commit_sha, risk_level, analysis, could_cause_issue, explanation}]`
127
+
128
+ Update §2 (Archaeology).
129
+
130
+ If an archaeology agent fails, log W003 and proceed with available results.
131
+
132
+ ### A_EXPLORE
133
+
134
+ Skip if no CLI tools (W006).
135
+
136
+ `evolve delegate --role explore --mode analysis` (`run_in_background: true`):
137
+ - PURPOSE: call chains, recent changes, error gaps, similar patterns
138
+ - EXPECTED: JSON `{call_chains, recent_changes, error_gaps, similar_patterns}`
139
+
140
+ Write `explore.json` + evidence phase=explore. Update §3 (Exploration). Mark G2. `update_plan`(G2 → completed)
141
+
142
+ **GATE: discovery-complete** — archaeology/explore evidence logged, understanding.md §2-§3 updated, G2 marked (W003 partial / W006 skip acceptable).
143
+
144
+ ### A_REVIEW
145
+
146
+ Generate `review-dimensions.csv` with 4 dimension rows:
147
+
148
+ ```csv
149
+ id,dimension,focus,target,deps,status,findings_json,error
150
+ "1","Correctness","Logic errors, boundary conditions, null/undefined handling, race conditions, type mismatches, off-by-one errors, missing error handling","{target}","","","",""
151
+ "2","Security","Injection vulnerabilities, XSS, CSRF, data exposure, auth bypass, insecure defaults, secret leakage, path traversal","{target}","","","",""
152
+ "3","Performance","Hot paths, N+1 queries, memory leaks, unnecessary recomputation, missing caching, blocking operations, large allocations","{target}","","","",""
153
+ "4","Architecture","Layer violations, circular dependencies, interface contract breaks, separation of concerns, abstraction leaks, coupling issues","{target}","","","",""
154
+ ```
155
+
156
+ ```javascript
157
+ spawn_agents_on_csv({
158
+ csv_path: `${sessionFolder}/review-dimensions.csv`,
159
+ id_column: "id",
160
+ instruction: "You are reviewing code for a specific dimension. Read 'dimension' and 'focus' columns for your review scope. Read 'target' for the files to review. Scan target files thoroughly, identify issues matching your dimension. Return findings_json as a JSON array: [{title, severity, file, line, description, suggestion, cwe}]. Severity levels: critical, high, medium, low.",
161
+ max_concurrency: 4,
162
+ max_runtime_seconds: 3600,
163
+ output_csv_path: `${sessionFolder}/review-results.csv`,
164
+ output_schema: { id, status: ["completed"|"failed"], findings_json, error }
165
+ })
166
+ ```
167
+
168
+ Merge all dimension findings → evidence phase=review. Write `review_result` + §4 severity matrix. Mark G1. `update_plan`(G1 → completed)
169
+
170
+ **GATE: all-dimensions-reviewed** — all 4 dimension agents (correctness, security, performance, architecture) completed, findings merged into review_result with severity classification, evidence phase=review logged, §4 severity matrix written, G1 marked. Zero dimensions reviewed is BLOCKED (W002 partial with ≥1 dimension allowed).
171
+
172
+ ### A_FIX
173
+
174
+ Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`:
175
+ ```
176
+ for tier in [critical, high, medium, low].filter(>= threshold):
177
+ for each unfixed candidate: read ±20 lines → fix → evidence phase=fix
178
+ re-review modified area (new findings → append, continue; max 2 per tier)
179
+ tier done → auto-commit
180
+ ```
181
+ Normal: `request_user_input` per tier | `-y`: auto-fix all. Remaining > 0 → retry (**MANDATORY hard limit: max_fix_rounds = 5**). Unchanged 2 rounds → classify each individually. After 5 rounds remaining > 0 → escalate: Normal: `request_user_input` (continue/accept/reclassify) | `-y`: classify remaining as `deferred`, proceed. **No partial-tier advancement** — a tier is complete only when every finding is fixed or individually classified. Blanket "pre-existing" forbidden. Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`.
182
+
183
+ ### A_CONFIRM
184
+
185
+ Run tests + `evolve delegate --role review --mode analysis` (`run_in_background: true`) zero-residual review. `remaining == 0 AND new == 0` → confirmed, mark G3 `update_plan`(G3 → completed); otherwise → needs_rework → S_FIX. Update `confirmation` + `remaining_actionable` + §5.
186
+
187
+ **GATE: zero-remaining** — exhaustive fix applied tier-by-tier, `remaining_actionable == 0` (or all remaining individually classified as deferred after 5-round escalation), tests pass, CLI re-review confirms no new findings, confirmation + §5 written, G3 marked. `needs_rework` routes back to FIX; skippable only when `skip_fix == true`.
188
+
189
+ ---
190
+
191
+ ## Generalize Source
192
+
193
+ Review findings with severity >= medium.
194
+
195
+ **Discover routing:** fixable sibling → S_FIX; new target → S_REVIEW.
196
+
197
+ ---
198
+
199
+ ## Knowledge Persistence (§8)
200
+
201
+ Include verified reusable findings in the Run summary and harvest the completed Session through Agent Memory closeout.
202
+
203
+
204
+ | Category | Content | Follow-up |
205
+ |----------|---------|-----------|
206
+ | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `stage spec → review` |
207
+ | Security finding | Vulnerability type + triggers + fix approach | `stage spec → debug` |
208
+ | Architecture violation pattern | Violation + correct boundary + verification | `stage spec → arch` |
209
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `stage spec → coding` |
210
+
211
+ ---
212
+
213
+ ## Completion Summary
214
+
215
+ ```
216
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
217
+ Target: {target} Dimensions: {dims}
218
+ Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
219
+ Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
220
+ Issues: {N} created
221
+ Decisions: {N} resolved, {M} pending, {K} deferred
222
+ Learnings: {N} persisted
223
+ Self-iter: {N} rounds across {M} stages
224
+ Goals: {done}/{total} ({skipped} skipped)
225
+ ---
226
+ ```
227
+
228
+ ---
229
+
230
+ ## `-y` Decision Points
231
+
232
+ | Decision Point | Normal | `-y` |
233
+ |---------------|--------|------|
234
+ | S_FIX tier candidates | `request_user_input` | auto-fix `deferred` |
235
+ | S_FIX re-review new findings | `request_user_input` | auto-append |
236
+ | S_CONFIRM needs_rework | `request_user_input` | auto proceed |
237
+ | A_DISCOVER routing | `request_user_input` | auto-fix w/ template, issue for rest |
238
+
239
+ ---
240
+
241
+ ## Mode-Specific Phase Gates
242
+
243
+ - **Discovery gate** (ARCHAEOLOGY/EXPLORE): evidence logged, understanding.md updated. Archaeology partial via W003 acceptable; explore W006 skip acceptable.
244
+ - **Audit gate** (REVIEW): all dimension agents completed, findings merged. Zero dimensions reviewed is BLOCKED (W002 partial allowed).
245
+ - **FIX gate:** current severity tier fully addressed. Per-fix evidence logged. Auto-commit per tier. No partial-tier advancement.
246
+ - **CONFIRM gate:** tests pass; `remaining_actionable == 0` and new findings == 0; confirmation written. needs_rework → route back to FIX.
247
+
248
+ ---
249
+
250
+ ## Error Codes (review-specific)
251
+
252
+ | Code | Severity | Condition | Recovery |
253
+ |------|----------|-----------|----------|
254
+ | W003 | warning | Archaeology agent failure | Proceed with available results |
255
+ | W006 | warning | No CLI tools | Skip explore |
256
+
257
+ ---
258
+
259
+ ## Success Criteria (review-specific)
260
+
261
+ - [ ] Session + 4 output files + prior knowledge searched
262
+ - [ ] Archaeology + CLI review → evidence
263
+ - [ ] CLI exploration → explore.json
264
+ - [ ] All 4 dimensions reviewed with findings merged
265
+ - [ ] understanding.md 8 sections progressive
266
+ - [ ] Exhaustive fix by severity tier + confirmed (unless --skip-fix)
267
+ - [ ] Generalization + scan (unless --skip-generalize)
268
+ - [ ] Discoveries classified; unfixed findings individually justified
269
+ - [ ] phase_goals + goal audit + resumable via -c
270
+ - [ ] Completion summary
271
+
272
+ ---
273
+
274
+ ## Next Step Routing (review-specific)
275
+
276
+ | Condition | Next |
277
+ |-----------|------|
278
+ | Discovery issues | `Open the follow-up findings in the project issue tracker` |
279
+ | Document pattern | `Review the module and stage the reusable method via Agent Memory closeout` |
280
+ | Debug root cause | `$ew-odyssey <issue> --mode debug` |
281
+ | Second opinion | `evolve delegate "<review prompt>" --mode analysis` |
282
+ | Related question | `Use an Evolve analyze step for the question` |
283
+ | Pending decisions | Filter evidence phase=decision status=pending |