self-evolving-workflow 0.0.0-stage → 0.1.4

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 (375) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +195 -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 +473 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/codex-memory.d.ts +24 -0
  12. package/dist/codex-memory.js +217 -0
  13. package/dist/common.d.ts +16 -0
  14. package/dist/common.js +52 -0
  15. package/dist/context-envelope.d.ts +59 -0
  16. package/dist/context-envelope.js +23 -0
  17. package/dist/host-adapters.d.ts +34 -0
  18. package/dist/host-adapters.js +151 -0
  19. package/dist/http.d.ts +3 -0
  20. package/dist/http.js +90 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.js +13 -0
  23. package/dist/knowledge-cli.d.ts +198 -0
  24. package/dist/knowledge-cli.js +761 -0
  25. package/dist/knowledge-reads.d.ts +72 -0
  26. package/dist/knowledge-reads.js +201 -0
  27. package/dist/memory-config.d.ts +44 -0
  28. package/dist/memory-config.js +204 -0
  29. package/dist/memory-evidence.d.ts +13 -0
  30. package/dist/memory-evidence.js +40 -0
  31. package/dist/memory-history.d.ts +46 -0
  32. package/dist/memory-history.js +432 -0
  33. package/dist/memory.d.ts +96 -0
  34. package/dist/memory.js +362 -0
  35. package/dist/retrospective.d.ts +57 -0
  36. package/dist/retrospective.js +240 -0
  37. package/dist/search.d.ts +36 -0
  38. package/dist/search.js +112 -0
  39. package/dist/skill-addition.d.ts +25 -0
  40. package/dist/skill-addition.js +89 -0
  41. package/dist/skill-design.d.ts +96 -0
  42. package/dist/skill-design.js +226 -0
  43. package/dist/skill-replay.d.ts +55 -0
  44. package/dist/skill-replay.js +448 -0
  45. package/dist/skill-route.d.ts +30 -0
  46. package/dist/skill-route.js +75 -0
  47. package/dist/transcript-evidence.d.ts +3 -0
  48. package/dist/transcript-evidence.js +58 -0
  49. package/dist/upstream/chunker.d.ts +24 -0
  50. package/dist/upstream/chunker.js +96 -0
  51. package/dist/upstream/file-protocol.d.ts +45 -0
  52. package/dist/upstream/file-protocol.js +117 -0
  53. package/dist/upstream/frontmatter.d.ts +47 -0
  54. package/dist/upstream/frontmatter.js +86 -0
  55. package/dist/upstream/graph-search.d.ts +33 -0
  56. package/dist/upstream/graph-search.js +67 -0
  57. package/dist/upstream/l1-extraction.d.ts +26 -0
  58. package/dist/upstream/l1-extraction.js +405 -0
  59. package/dist/upstream/llm.d.ts +8 -0
  60. package/dist/upstream/llm.js +1 -0
  61. package/dist/upstream/merge.d.ts +50 -0
  62. package/dist/upstream/merge.js +153 -0
  63. package/dist/upstream/prompts.d.ts +53 -0
  64. package/dist/upstream/prompts.js +181 -0
  65. package/dist/upstream/search-utils.d.ts +34 -0
  66. package/dist/upstream/search-utils.js +55 -0
  67. package/dist/upstream/slug.d.ts +26 -0
  68. package/dist/upstream/slug.js +103 -0
  69. package/dist/upstream/template.d.ts +29 -0
  70. package/dist/upstream/template.js +80 -0
  71. package/dist/upstream/tokenize.d.ts +4 -0
  72. package/dist/upstream/tokenize.js +29 -0
  73. package/dist/wiki-change.d.ts +76 -0
  74. package/dist/wiki-change.js +299 -0
  75. package/dist/wiki-entry.d.ts +26 -0
  76. package/dist/wiki-entry.js +93 -0
  77. package/dist/wiki-ingest.d.ts +12 -0
  78. package/dist/wiki-ingest.js +126 -0
  79. package/dist/wiki-migration.d.ts +16 -0
  80. package/dist/wiki-migration.js +268 -0
  81. package/dist/wiki-tokens.d.ts +1 -0
  82. package/dist/wiki-tokens.js +46 -0
  83. package/dist/wiki.d.ts +103 -0
  84. package/dist/wiki.js +330 -0
  85. package/dist/workflow-cli.d.ts +2 -0
  86. package/dist/workflow-cli.js +319 -0
  87. package/dist/workflow-install.d.ts +37 -0
  88. package/dist/workflow-install.js +148 -0
  89. package/dist/workflow-knowledge.d.ts +18 -0
  90. package/dist/workflow-knowledge.js +32 -0
  91. package/dist/workflow-mcp.d.ts +2 -0
  92. package/dist/workflow-mcp.js +137 -0
  93. package/dist/workflow-names.d.ts +4 -0
  94. package/dist/workflow-names.js +31 -0
  95. package/dist/workflow-runtime.d.ts +735 -0
  96. package/dist/workflow-runtime.js +747 -0
  97. package/dist/workflow-skills.d.ts +48 -0
  98. package/dist/workflow-skills.js +141 -0
  99. package/docs/images/impeccable-skill.png +0 -0
  100. package/docs/images/workflow-overview.png +0 -0
  101. package/docs/images/workflow-skills.png +0 -0
  102. package/package.json +77 -4
  103. package/skills/ew-impeccable/LICENSE +191 -0
  104. package/skills/ew-impeccable/NOTICE.md +19 -0
  105. package/skills/ew-impeccable/SKILL.md +91 -0
  106. package/skills/ew-impeccable/UPSTREAM.md +23 -0
  107. package/skills/ew-impeccable/reference/adapt.md +314 -0
  108. package/skills/ew-impeccable/reference/adapt.native.md +60 -0
  109. package/skills/ew-impeccable/reference/android.md +46 -0
  110. package/skills/ew-impeccable/reference/animate.md +91 -0
  111. package/skills/ew-impeccable/reference/audit.md +138 -0
  112. package/skills/ew-impeccable/reference/audit.native.md +141 -0
  113. package/skills/ew-impeccable/reference/bolder.md +35 -0
  114. package/skills/ew-impeccable/reference/clarify.md +96 -0
  115. package/skills/ew-impeccable/reference/colorize.md +88 -0
  116. package/skills/ew-impeccable/reference/craft-floor.md +44 -0
  117. package/skills/ew-impeccable/reference/craft.md +5 -0
  118. package/skills/ew-impeccable/reference/critique.md +808 -0
  119. package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
  120. package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
  121. package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
  122. package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
  123. package/skills/ew-impeccable/reference/delight.md +72 -0
  124. package/skills/ew-impeccable/reference/distill.md +113 -0
  125. package/skills/ew-impeccable/reference/doctor.md +56 -0
  126. package/skills/ew-impeccable/reference/document.md +418 -0
  127. package/skills/ew-impeccable/reference/extract.md +68 -0
  128. package/skills/ew-impeccable/reference/harden.md +338 -0
  129. package/skills/ew-impeccable/reference/hooks.md +113 -0
  130. package/skills/ew-impeccable/reference/init.md +133 -0
  131. package/skills/ew-impeccable/reference/ios.md +51 -0
  132. package/skills/ew-impeccable/reference/layout.md +86 -0
  133. package/skills/ew-impeccable/reference/live-setup.md +102 -0
  134. package/skills/ew-impeccable/reference/live.md +326 -0
  135. package/skills/ew-impeccable/reference/new-work.md +209 -0
  136. package/skills/ew-impeccable/reference/onboard.md +236 -0
  137. package/skills/ew-impeccable/reference/operate.md +61 -0
  138. package/skills/ew-impeccable/reference/optimize.md +260 -0
  139. package/skills/ew-impeccable/reference/overdrive.md +127 -0
  140. package/skills/ew-impeccable/reference/polish.md +105 -0
  141. package/skills/ew-impeccable/reference/quieter.md +101 -0
  142. package/skills/ew-impeccable/reference/routing.md +20 -0
  143. package/skills/ew-impeccable/reference/shape.md +59 -0
  144. package/skills/ew-impeccable/reference/typeset.md +82 -0
  145. package/skills/ew-impeccable/reference/visualize.md +46 -0
  146. package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
  147. package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
  148. package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
  149. package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
  150. package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
  151. package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
  152. package/skills/ew-impeccable/scripts/context.mjs +1521 -0
  153. package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
  154. package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
  155. package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
  156. package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
  157. package/skills/ew-impeccable/scripts/detect.mjs +30 -0
  158. package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
  159. package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
  160. package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
  161. package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
  162. package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
  163. package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
  164. package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
  165. package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
  166. package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
  167. package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  168. package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
  169. package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
  170. package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
  171. package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
  172. package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
  173. package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
  174. package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
  175. package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
  176. package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
  177. package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
  178. package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
  179. package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
  180. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
  181. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
  182. package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
  183. package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
  184. package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
  185. package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
  186. package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
  187. package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
  188. package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
  189. package/skills/ew-impeccable/scripts/hook.mjs +79 -0
  190. package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
  191. package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
  192. package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
  193. package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
  194. package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
  195. package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
  196. package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
  197. package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
  198. package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
  199. package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
  200. package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
  201. package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
  202. package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
  203. package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
  204. package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
  205. package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
  206. package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
  207. package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
  208. package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
  209. package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
  210. package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
  211. package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
  212. package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
  213. package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
  214. package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
  215. package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
  216. package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
  217. package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
  218. package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
  219. package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
  220. package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
  221. package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
  222. package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
  223. package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
  224. package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
  225. package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
  226. package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
  227. package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
  228. package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
  229. package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
  230. package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
  231. package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
  232. package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
  233. package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
  234. package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
  235. package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
  236. package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
  237. package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
  238. package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
  239. package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
  240. package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
  241. package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
  242. package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
  243. package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
  244. package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
  245. package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
  246. package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
  247. package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
  248. package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
  249. package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
  250. package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
  251. package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
  252. package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
  253. package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
  254. package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
  255. package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
  256. package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
  257. package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  258. package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
  259. package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
  260. package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
  261. package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
  262. package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
  263. package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
  264. package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
  265. package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
  266. package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
  267. package/skills/ew-impeccable/scripts/live.mjs +334 -0
  268. package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
  269. package/skills/ew-impeccable/scripts/palette.mjs +628 -0
  270. package/skills/ew-impeccable/scripts/pin.mjs +352 -0
  271. package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
  272. package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
  273. package/skills/ew-knowledge/SKILL.md +35 -0
  274. package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
  275. package/skills/ew-knowledge/references/knowledge-route.md +73 -0
  276. package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
  277. package/skills/ew-odyssey/SKILL.md +106 -0
  278. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  279. package/skills/ew-odyssey/references/odyssey-base.md +104 -0
  280. package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
  281. package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
  282. package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
  283. package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
  284. package/skills/ew-odyssey/references/odyssey-review.md +233 -0
  285. package/skills/ew-odyssey/references/odyssey-security.md +231 -0
  286. package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
  287. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
  288. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
  289. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
  290. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
  291. package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
  292. package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
  293. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
  294. package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
  295. package/skills/ew-orchestrate/SKILL.md +89 -0
  296. package/skills/ew-orchestrate/references/auto-policy.md +66 -0
  297. package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
  298. package/skills/ew-orchestrate/references/companion-route.md +40 -0
  299. package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
  300. package/skills/ew-orchestrate/references/goal.md +51 -0
  301. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
  302. package/skills/ew-orchestrate/references/planning.md +54 -0
  303. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
  304. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
  305. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
  306. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
  307. package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
  308. package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
  309. package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
  310. package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
  311. package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
  312. package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
  313. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
  314. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
  315. package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
  316. package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
  317. package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
  318. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
  319. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
  320. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
  321. package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
  322. package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
  323. package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
  324. package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
  325. package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
  326. package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
  327. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
  328. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
  329. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  330. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
  331. package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
  332. package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
  333. package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
  334. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
  335. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
  336. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
  337. package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
  338. package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
  339. package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
  340. package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
  341. package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
  342. package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
  343. package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
  344. package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
  345. package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
  346. package/skills/ew-skill-design/SKILL.md +30 -0
  347. package/skills/ew-skill-design/references/package-contract.md +40 -0
  348. package/skills/ew-skill-design/references/validation.md +21 -0
  349. package/skills/team-swarm/SKILL.md +68 -0
  350. package/skills/team-swarm/references/mcp-coordination.md +14 -0
  351. package/skills/team-swarm/roles/analyst/role.md +181 -0
  352. package/skills/team-swarm/roles/ant/role.md +149 -0
  353. package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
  354. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  355. package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
  356. package/skills/team-swarm/roles/coordinator/role.md +170 -0
  357. package/skills/team-swarm/roles/scorer/role.md +150 -0
  358. package/skills/team-swarm/scripts/aco.py +646 -0
  359. package/skills/team-swarm/scripts/pheromone.py +144 -0
  360. package/skills/team-swarm/scripts/scoring.py +111 -0
  361. package/skills/team-swarm/scripts/test_aco.py +606 -0
  362. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  363. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  364. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  365. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  366. package/skills/team-swarm/specs/swarm-protocol.md +119 -0
  367. package/skills/workflow-evolve/SKILL.md +64 -0
  368. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  369. package/skills/workflow-evolve/references/auto-loop.md +23 -0
  370. package/skills/workflow-evolve/references/history-review.md +15 -0
  371. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
  372. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  373. package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
  374. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  375. package/workflows/index.json +33 -0
@@ -0,0 +1,264 @@
1
+ # Workflow: Odyssey Debug
2
+
3
+ Follow [shared phases](odyssey-base.md) and [runtime adapters](runtime-adapters.md) for parallel agents, structured prompts, and metadata.
4
+
5
+ ## State Chain
6
+
7
+ ```
8
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_DIAGNOSE → S_FIX → S_CONFIRM → [back-half]
9
+ ```
10
+
11
+ Back-half: `S_GENERALIZE → S_DISCOVER → S_RECORD → END` (see [shared phases](odyssey-base.md)).
12
+
13
+ ---
14
+
15
+ ## Boundary
16
+
17
+ **In scope:** Multi-iteration bug-hunt and generalization campaigns — symptom → root cause → fix → confirm → generalize → discover adjacent defects.
18
+ **Out of scope:** Bounded orchestration-chain diagnosis or simple <=2-file fixes → `ew-orchestrate` (`ew-debug` / `ew-companion`) | Features → `--mode planex` | Quality review → `--mode review` | UI → `--mode ui`
19
+
20
+ ---
21
+
22
+ ## `--template <name>`
23
+
24
+ Template strategies are defined in [the selected mode preparation](prepare/odyssey-debug.md) §Input Interpretation — that is the canonical wording.
25
+
26
+ ---
27
+
28
+ ## Target Resolution
29
+
30
+ Issue description parsed from `<intent>`.
31
+
32
+ ---
33
+
34
+ ## Session Fields
35
+
36
+ ```json
37
+ { "issue": "", "diagnosis_retries": 0, "root_cause": null, "confirmation": null,
38
+ "patterns": [], "generalization_stats": null }
39
+ ```
40
+
41
+ ---
42
+
43
+ ## evidence.ndjson Phases
44
+
45
+ `archaeology|explore|diagnosis|discovery|decision|self-iteration`
46
+
47
+ - `archaeology`: `sha`, `author`, `date`, `message`, `relevance`
48
+ - `explore`: `category` (call_chain|recent_change|error_gap|similar_pattern), `detail`
49
+ - `diagnosis`: `hypothesis`, `result` (confirmed|disproved|inconclusive)
50
+ - `discovery`: `file`, `line`, `classification` (safe|risk|bug), `action` (fix|issue|decision|skip)
51
+ - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
52
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
53
+
54
+ ---
55
+
56
+ ## explore.json
57
+
58
+ ```json
59
+ {"call_chains": [], "recent_changes": [], "error_gaps": [], "similar_patterns": [], "cli_tool": "", "timestamp": ""}
60
+ ```
61
+
62
+ ---
63
+
64
+ ## phase_goals[]
65
+
66
+ | ID | Goal | done_when | phase | skip_when |
67
+ |----|------|-----------|-------|-----------|
68
+ | G1 | Root cause identified | phase=diagnosis result=confirmed | S_DIAGNOSE | — |
69
+ | G2 | Explore context gathered | explore.json ≥1 category | S_EXPLORE | — |
70
+ | G3 | Fix applied and confirmed | confirmation.overall == confirmed | S_CONFIRM | skip_fix |
71
+ | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
72
+ | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
73
+ | G6 | Learnings persisted | spec entries created OR none actionable | S_RECORD | — |
74
+
75
+ ---
76
+
77
+ ## understanding.md — 9 Sections
78
+
79
+ 1. Issue & Scope
80
+ 2. Archaeology
81
+ 3. Exploration
82
+ 4. Hypotheses
83
+ 5. Root Cause
84
+ 6. Fix & Confirmation
85
+ 7. Generalization
86
+ 8. Discoveries
87
+ 9. Learnings
88
+
89
+ ---
90
+
91
+ ## State Machine — Transitions
92
+
93
+ ```
94
+ S_ARCHAEOLOGY → S_EXPLORE : complete
95
+ S_EXPLORE → S_DIAGNOSE : complete
96
+ S_DIAGNOSE → S_FIX : confirmed, !skip_fix
97
+ S_DIAGNOSE → S_GENERALIZE : confirmed, skip_fix, !skip_generalize
98
+ S_DIAGNOSE → S_RECORD : confirmed, skip_fix, skip_generalize
99
+ S_DIAGNOSE → S_DIAGNOSE : all hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
100
+ S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
101
+ S_FIX → S_CONFIRM : fix implemented
102
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
103
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
104
+ S_CONFIRM → S_FIX : needs_rework
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Actions
110
+
111
+ ### A_ARCHAEOLOGY
112
+
113
+ Run 2 parallel subagents (always join before advancing — see [runtime adapters](runtime-adapters.md)):
114
+ - **Timeline**: `git log --oneline -20 -- {files}`
115
+ - **Blame**: top 3 files `git blame -L {region}`
116
+
117
+ Evidence phase=archaeology.
118
+
119
+ `evolve delegate "PURPOSE: review recent modifications related to {issue}. EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]" --to codex --mode analysis`
120
+
121
+ Update §2 (Archaeology).
122
+
123
+ If an archaeology agent fails, log W003 and proceed with available results.
124
+
125
+ ### A_EXPLORE
126
+
127
+ Skip if no CLI tools (W006).
128
+
129
+ `evolve delegate "PURPOSE: trace call chains, recent changes, error gaps, and similar patterns for {issue}. EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}" --to codex --mode analysis`
130
+
131
+ Write `explore.json` + evidence phase=explore. Update §3 (Exploration). Mark G2.
132
+
133
+ **GATE: discovery-complete** — archaeology/explore evidence logged, understanding.md §2-§3 updated, G2 marked (W003 partial / W006 skip acceptable).
134
+
135
+ ### A_DIAGNOSE
136
+
137
+ 1. Generate hypotheses from evidence, ranked [HIGH]/[MEDIUM]/[LOW] → §4.
138
+ 2. Test each hypothesis → evidence phase=diagnosis.
139
+ 3. Ambiguity → evidence phase=decision:
140
+ - Normal: structured prompt
141
+ - `-y`: defer
142
+ 4. Confirmed → `session.json.root_cause` + §5 (Root Cause). Mark G1.
143
+
144
+ **GATE: diagnosis-confirmed** — all hypotheses tested with evidence, root cause confirmed with reproduction or code/log evidence (or INCONCLUSIVE after 3-strike), understanding.md §4-§5 written. Zero hypotheses tested is BLOCKED.
145
+
146
+ ### A_ESCALATE_DIAGNOSIS
147
+
148
+ `diagnosis_retries++`.
149
+
150
+ - **retries < 3**: `evolve delegate "Analyze failed hypotheses for {issue} and propose new root-cause hypotheses with file:line evidence" --to codex --mode analysis`, generate new hypotheses, → S_DIAGNOSE.
151
+ - **retries >= 3**:
152
+ - Normal: structured prompt
153
+ - `-y`: INCONCLUSIVE → S_RECORD
154
+
155
+ ### A_FIX
156
+
157
+ 1. Present root cause + proposed fix.
158
+ - Normal: structured prompt
159
+ - `-y`: auto proceed
160
+ 2. Implement fix, evidence phase=decision.
161
+
162
+ ### A_CONFIRM
163
+
164
+ 1. Run covering tests.
165
+ 2. `evolve delegate "PURPOSE: review the fix for {issue} against covering tests and diff. EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk}" --to codex --mode analysis`
166
+ 3. `session.json.confirmation`:
167
+ ```json
168
+ {"test_result": "", "cli_review": {}, "overall": "confirmed|needs_rework"}
169
+ ```
170
+ 4. Update §6 (Fix & Confirmation).
171
+ - `needs_rework` → S_FIX
172
+ - `confirmed` → mark G3
173
+
174
+ **GATE: fix-confirmed** — fix implemented and tests pass, CLI review done, `confirmation.overall` set, understanding.md §6 written, G3 marked. `needs_rework` routes back to FIX; skippable only when `skip_fix == true`.
175
+
176
+ ---
177
+
178
+ ## Generalize Source
179
+
180
+ Confirmed root cause + applied fix.
181
+
182
+ **Thoroughness floor:** ALL 3 layers (syntax/semantic/structural) must be attempted and logged.
183
+
184
+ **Discover routing:** `bug` → back to S_FIX; new bug → S_DIAGNOSE.
185
+
186
+ ---
187
+
188
+ ## Knowledge Persistence (§9)
189
+
190
+ Include verified reusable findings in the Run summary and harvest the completed Session through `evolve workflows show knowledge` (`evolve closeout session` → `evolve wiki propose`).
191
+
192
+ | Category | Content | Follow-up |
193
+ |----------|---------|-----------|
194
+ | Recurring root cause pattern | Type + triggers + fix + detection | `evolve closeout session` → `evolve wiki propose` (`category: debug`) |
195
+ | Non-obvious workaround | Problem + steps + why obvious fix fails | `evolve closeout session` → `evolve wiki propose` (`category: debug`) |
196
+ | Architecture boundary violation | Violation + correct boundary + verification | `evolve closeout session` → `evolve wiki propose` (`category: arch`) |
197
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `evolve closeout session` → `evolve wiki propose` (`category: coding`) |
198
+
199
+ ---
200
+
201
+ ## Completion Summary
202
+
203
+ ```
204
+ --- DEBUG ODYSSEY COMPLETE ---
205
+ Issue: {issue}
206
+ Root cause: {root_cause.hypothesis}
207
+ Fix: {applied|skipped|inconclusive}
208
+ Patterns: {patterns_extracted} ({by_layer})
209
+ Scan hits: {total_hits} ({cross_layer_confirmed} confirmed)
210
+ Issues: {N} created
211
+ Decisions: {N} resolved, {M} pending, {K} deferred
212
+ Learnings: {N} persisted
213
+ Self-iter: {N} rounds across {M} stages
214
+ Goals: {done}/{total} ({skipped} skipped)
215
+ ---
216
+ ```
217
+
218
+ ---
219
+
220
+ ## `-y` Decision Points
221
+
222
+ | Decision Point | Normal | `-y` |
223
+ |---------------|--------|------|
224
+ | A_DIAGNOSE ambiguity | structured prompt | deferred |
225
+ | A_ESCALATE 3-strike | structured prompt | INCONCLUSIVE |
226
+ | A_FIX direction | structured prompt | auto proceed |
227
+
228
+ ---
229
+
230
+ ## Mode-Specific Phase Gates
231
+
232
+ - **Discovery gate** (ARCHAEOLOGY/EXPLORE): evidence for the phase logged, understanding.md updated, discovery goal marked. Archaeology partial via W003 acceptable; explore W006 skip acceptable.
233
+ - **Audit gate** (DIAGNOSE): hypotheses ranked and tested with evidence, root cause confirmed or escalated (`diagnosis-confirmed`). Zero hypotheses tested is BLOCKED.
234
+ - **FIX gate:** fix targets confirmed root cause (not symptom), with `evidence phase=fix` logged; escalate via `S_ESCALATE_DIAGNOSIS` if unresolved after 3 attempts.
235
+ - **CONFIRM gate:** tests pass; CLI review done; `confirmation.overall == "confirmed"`, understanding.md §6 written, verify goal marked. `needs_rework` routes back to FIX (`fix-confirmed`).
236
+
237
+ ---
238
+
239
+ ## Error Codes (debug-specific)
240
+
241
+ | Code | Severity | Condition | Recovery |
242
+ |------|----------|-----------|----------|
243
+ | E001 | error | No issue, no session | Provide issue or -c |
244
+ | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
245
+ | W006 | warning | No CLI tools | Skip explore |
246
+
247
+ ---
248
+
249
+ ## Success Criteria (debug-specific)
250
+
251
+ - [ ] Session + 4 output files + prior knowledge searched
252
+ - [ ] Archaeology + CLI review → evidence
253
+ - [ ] CLI exploration → explore.json
254
+ - [ ] Hypotheses tested, root cause with evidence refs
255
+ - [ ] understanding.md 9 sections progressive
256
+ - [ ] Fix + confirmed (unless --skip-fix)
257
+ - [ ] Generalization + scan (unless --skip-generalize)
258
+ - [ ] Discoveries classified; unfixed findings individually justified
259
+ - [ ] phase_goals + goal audit + resumable via -c
260
+ - [ ] Completion summary
261
+
262
+ ---
263
+
264
+ See [shared base](odyssey-base.md) for generic follow-up routing (`Next Step Routing`). Formal post-fix review: `/ew-odyssey <changed-files> --mode review`.
@@ -0,0 +1,351 @@
1
+ # Workflow: Odyssey Defensive
2
+
3
+ Read-only defensive-programming risk audit — business-anchor driven + local slicing + bidirectional propagation. Identify critical business sinks → backward-slice to defensive nodes → scan 8 defensive patterns → identify failure→value transformations → forward-propagate to sinks → classify exception semantics → score `R = S × P × B × H` → severity matrix report with full propagation chains → generalize defensive patterns. Follow [shared phases](odyssey-base.md) and [runtime adapters](runtime-adapters.md).
4
+
5
+ Core judgment (§19):
6
+
7
+ > Defensive Code + Failure Suppression + Semantic Transformation + Critical Propagation = Defensive Programming Risk
8
+
9
+ ---
10
+
11
+ ## State Chain
12
+
13
+ ```
14
+ S_INTAKE → S_ANCHOR → S_SLICE → S_SCAN → S_PROPAGATE → S_REPORT → [back-half]
15
+ ```
16
+
17
+ Back-half: `S_GENERALIZE → S_DISCOVER → S_RECORD → END` (see [shared phases](odyssey-base.md) §Shared Back-Half).
18
+
19
+ **No S_FIX / S_CONFIRM** — this mode is read-only. Findings route to `--mode improve` (fix defensive defect) or `--mode debug` (root-cause).
20
+
21
+ ---
22
+
23
+ ## Boundary
24
+
25
+ **In scope:** Business-anchor identification → local business-flow recovery → backward slicing → 8-pattern defensive-node scan → failure→value transformation identification → forward propagation to business sinks → constraint/default consistency check → exception semantic classification → risk scoring → severity matrix with full propagation chains → generalize defensive patterns.
26
+ **Out of scope:** Fixing defensive defects → `--mode improve` | Root-cause debug → `--mode debug` | Multi-dimensional general review → `--mode review` | Security vulnerability audit → `--mode security` | UI visual optimization → `--mode ui`. Read-only invariant applies: NEVER modify source code.
27
+
28
+ ---
29
+
30
+ ## Target Resolution
31
+
32
+ | Input | Resolution |
33
+ |-------|-----------|
34
+ | File/dir path | Audit those files |
35
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` — defensive patterns introduced/modified in diff |
36
+ | Session/Run ID or commit range | Evolve Run artifacts / `git diff <base>..<head>` |
37
+ | PR number | `git diff main...HEAD` |
38
+
39
+ ---
40
+
41
+ ## Session Fields
42
+
43
+ ```json
44
+ { "target": "", "tier": "standard", "sink_depth": "all",
45
+ "anchors": {"critical_vars": [], "sink_layers": {"level_1": [], "level_2": [], "level_3": []}},
46
+ "scan_result": {"by_pattern": {}, "candidates": []},
47
+ "propagation": {"confirmed_chains": [], "risky_sinks": [], "q4_hidden": 0},
48
+ "audit_result": {"findings": [], "risk_matrix": {}},
49
+ "findings_count": {},
50
+ "generalization_stats": null }
51
+ ```
52
+
53
+ ---
54
+
55
+ ## evidence.ndjson Phases
56
+
57
+ `anchor|slice|scan|propagate|report|discovery|decision|self-iteration`
58
+
59
+ Phase-specific extension fields:
60
+
61
+ - `anchor`: `category` (critical_var|business_sink|data_flow), `var_name`, `importance` (high|medium|low)
62
+ - `slice`: `anchor_var`, `source_chain`, `passes_default` (bool), `passes_except` (bool), `auto_corrected` (bool), `multiple_sources` (bool)
63
+ - `scan`: `pattern` (broad_catch|exception_swallow|default|null_fallback|auto_correct|silent_convert|dup_constraint|dup_default), `file`, `line`, `original_failure_type`, `snippet`
64
+ - `propagate`: `finding_ref`, `state_transform` (Exception→None|Exception→Empty|Exception→Numeric|Missing→Default|Invalid→Corrected|MultiErr→SingleState), `sink_layer` (1|2|3), `sink_name`, `reaches_critical_sink` (bool), `q4_downstream_aware` (bool), `scores` {S, P, B, H}, `risk_level` (Critical|High|Medium|Low), `exception_class` (A|B|C|D)
65
+ - `report`: `finding_ref`, `risk_level`, `remediation`
66
+
67
+ ---
68
+
69
+ ## phase_goals[]
70
+
71
+ | ID | Goal | done_when | phase | skip_when |
72
+ |----|------|-----------|-------|-----------|
73
+ | G1 | Anchors identified | critical_vars ≥1 AND sink_layers.level_1 ≥1 | S_ANCHOR | — |
74
+ | G2 | Slice completed | every critical_var has a source_chain | S_SLICE | — |
75
+ | G3 | Scan completed (all tier patterns) | all tier-required patterns scanned | S_SCAN | — |
76
+ | G4 | Propagation verified | every candidate has reaches_critical_sink + scores + exception_class | S_PROPAGATE | — |
77
+ | G5 | Report produced | risk_matrix with full propagation chains + scores | S_REPORT | — |
78
+ | G6 | Pattern generalized | patterns[] ≥1 | S_GENERALIZE | skip_generalize |
79
+ | G7 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
80
+ | G8 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
81
+
82
+ ---
83
+
84
+ ## understanding.md — 9 Sections
85
+
86
+ 1. Target & Scope & Tier
87
+ 2. Business Anchors (critical-variable table + sink layering)
88
+ 3. Local Business Flow (three-layer map: business-semantic ↔ software-component ↔ code-implementation)
89
+ 4. Defensive Nodes (8-pattern scan results, bucketed by pattern)
90
+ 5. Failure→Value Transformations (§7 six transformation types)
91
+ 6. Propagation Chains (forward chains + sink-hit verdicts + Q4 signals)
92
+ 7. Constraint & Default Consistency (§10 cross-module aggregation)
93
+ 8. Risk Matrix & Exception Classification (R=S×P×B×H scores + A/B/C/D + §14 standard report entries)
94
+ 9. Generalization & Discoveries & Learnings
95
+
96
+ Specs: `evolve wiki constraints --category coding` (defensive-programming patterns).
97
+
98
+ ---
99
+
100
+ ## State Machine — Transitions
101
+
102
+ ```
103
+ S_ANCHOR → S_SLICE : complete (anchors identified)
104
+ S_SLICE → S_SCAN : complete (source chains traced)
105
+ S_SCAN → S_PROPAGATE : all tier patterns scanned
106
+ S_PROPAGATE → S_REPORT : all candidates scored + sink verdict
107
+ S_REPORT → S_GENERALIZE : report produced, !skip_generalize
108
+ S_REPORT → S_RECORD : report produced, skip_generalize
109
+ ```
110
+
111
+ Discover routes: sibling module with same defensive anti-pattern → S_SCAN (re-scan expanded scope, loops < max_loops); newly discovered critical propagation chain → evidence phase=decision, recommend `--mode improve`.
112
+
113
+ ---
114
+
115
+ ## Actions
116
+
117
+ ### A_INTAKE extra
118
+
119
+ Tier resolution: parse `--tier` (default: standard) and `--sink-depth` (default: all). Record tier + applicable scan patterns + sink-layer focus to `session.json`.
120
+
121
+ ### A_ANCHOR
122
+
123
+ (§3 step — determine business-critical anchors.)
124
+
125
+ 1. Identify business-critical outputs (objective / constraint / decision / state / response / DB write / control quantity / model prediction / optimization result / ...).
126
+ 2. Build the **critical-variable table**: `| variable | business meaning | source | usage location | importance |`.
127
+ 3. **Sink layering** (§8 three-tier sinks):
128
+ - **Level 1 (high risk):** business decision / control command / objective function / constraint check / model training / optimization algorithm / core DB state / financial amount / security permission.
129
+ - **Level 2 (medium risk):** computation result / report output / intermediate model / API response / cache.
130
+ - **Level 3 (low risk):** log / UI display / temp file / debug info.
131
+ 4. Write `anchors.json` (critical_vars + sink_layers) + evidence phase=anchor. Update §2. Mark G1.
132
+
133
+ **GATE: anchor-identified** — critical_vars ≥1 AND sink_layers.level_1 ≥1. Evidence phase=anchor logged. §2 updated. BLOCKED if no critical vars / no level-1 sink (E002).
134
+
135
+ Commit: `"odyssey-defensive({slug}): ANCHOR — {N} anchors, {M} level-1 sinks"`
136
+
137
+ ### A_SLICE
138
+
139
+ (§4-§5 — recover local business flow + backward slice from critical results.)
140
+
141
+ 1. For each critical_var, recover its **local business flow** — three-layer map: business-semantic layer ↔ software-component layer ↔ code-implementation layer (e.g. `DesignManager → SimulationAdapter → ResultParser → Evaluator → Optimizer` ↔ `objective() → evaluate() → run_simulation() → solver.run()`).
142
+ 2. **Backward slice** from each critical_var, answering the 7 questions: (1) where does it originate? (2) does it pass a default value? (3) any type conversion? (4) any exception handling? (5) any auto-correction? (6) multiple possible sources? (7) intermediate-state substitution?
143
+ 3. Write evidence phase=slice (one source_chain per anchor) + §3 three-layer map. Mark G2.
144
+
145
+ **GATE: slice-complete** — every critical_var has a source_chain; §3 three-layer map written. Slice tool unavailability is logged as W001, and SCAN results back-fill the chain.
146
+
147
+ Commit: `"odyssey-defensive({slug}): SLICE — {N} chains traced"`
148
+
149
+ ### A_SCAN
150
+
151
+ (§6 — scan defensive-code nodes. Full 8-pattern parallel agents; quick tier covers P1-P4 only.)
152
+
153
+ | # | Pattern | Scan signals (AST/Grep) | §ref |
154
+ |---|---------|-------------------------|------|
155
+ | P1 | broad_catch | `except:`, `except Exception:` | 6.1 |
156
+ | P2 | exception_swallow | `except ...: pass`, `except ...: return None`, `return {}`, `return 0` | 6.2 |
157
+ | P3 | default | `.get(k, v)`, `getattr(o, x, d)`, `v or default` | 6.3 |
158
+ | P4 | null_fallback | `if x is None: return None` / `return {}` | 6.4 |
159
+ | P5 | auto_correct | `max(x, lo)`, `min(x, hi)`, `min(max(x, lo), hi)` (clamp) | 6.5 |
160
+ | P6 | silent_convert | `try: x = float(x) except: x = 0` | 6.6 |
161
+ | P7 | dup_constraint | cross-module same variable, divergent constraints (`< 10`, `<= 12`, `>= 15`) | 6.7 |
162
+ | P8 | dup_default | cross-module same config, divergent defaults (`temperature = 25 / 20 / 293.15`) | 6.8 |
163
+
164
+ Run N parallel subagents (one per pattern; join all before advancing — see [runtime adapters](runtime-adapters.md)). Each scans the target files using AST analysis when available or Grep pattern scanning with the signals above (log W001 if AST is unavailable). Each returns `[{pattern, file, line, original_failure_type, snippet, surrounding_context}]`.
165
+
166
+ P7/P8 require **cross-module aggregation**: full-repo grep for the same variable name → compare constraints/defaults across modules → flag unit / business-meaning / duplication / conflict inconsistencies (§10).
167
+
168
+ Merge all findings → evidence phase=scan. Write `scan_result.by_pattern` + `scan_result.candidates`. Update §4 (per-pattern buckets) + §7 (consistency). Mark G3.
169
+
170
+ **GATE: scan-complete** — all tier-required scan patterns completed with structured findings, merged per-pattern. Evidence phase=scan logged per pattern. Tier-required pattern not attempted is BLOCKED (W001 AST unavailable / W002 cross-module aggregation failure are warnings, not blocks).
171
+
172
+ Commit: `"odyssey-defensive({slug}): SCAN — {tier} tier, {N} candidates across {M} patterns"`
173
+
174
+ ### A_PROPAGATE
175
+
176
+ (§7-§10 — the core phase. Identify failure→value transformations → forward propagation → sink verdict → consistency → exception classification → risk scoring.)
177
+
178
+ 1. For each scan candidate, identify the **failure→value state transformation** (§7 six types):
179
+
180
+ | Transformation | Signature |
181
+ |---------------|-----------|
182
+ | Exception → None | exception swallowed → `None` propagates |
183
+ | Exception → Empty | exception → `{}` / `[]` |
184
+ | Exception → Numeric | exception → `0` (HIGH risk) |
185
+ | Missing → Default | missing key → `mass = 0` |
186
+ | Invalid → Corrected | `temperature = -100` → clamp → `0` |
187
+ | MultiErr → SingleState | ConvergenceError + FileNotFoundError + LicenseError + TypeError → `None` (异常语义坍缩) |
188
+
189
+ 2. **Forward propagation**: Defensive Node → Forward Propagation → does it reach a Critical Business Sink? (`Defensive Node ↓ Forward Propagation ↓ Critical Business Sink?`)
190
+
191
+ 3. **Sink verdict** (three-tier) + **Q4 signal** (§18): "can the downstream still know the upstream error occurred?" — `不能` (cannot) = high-risk signal, MUST be flagged.
192
+
193
+ 4. **Constraint/default consistency check** (§10): cross-module same variable — are units / business meaning / duplication / conflict inconsistent? Flag `Constraint Inconsistency` / `Default Inconsistency`.
194
+
195
+ 5. **Exception semantic classification** (§9): classify each swallowed exception as:
196
+
197
+ | Class | Examples | Recommended handling |
198
+ |------|----------|---------------------|
199
+ | A — business illegal | design var out-of-bounds, illegal input, geometric infeasible, rule conflict | reject / penalty / retry |
200
+ | B — numerical/algorithm | SolverConvergenceError, NumericalOverflow, SingularMatrix | retry / penalty / fallback solver |
201
+ | C — system environment | LicenseError, FileNotFoundError, PermissionError, OutOfMemory | NEVER silent degrade |
202
+ | D — program defect | TypeError, AttributeError, KeyError, IndexError | expose error, do NOT convert to normal result |
203
+
204
+ 6. **Risk scoring** `R = S × P × B × H` (§12):
205
+ - **S** = defensive-code severity (e.g. `except Exception: pass` = high)
206
+ - **P** = propagation range (local log = low; reaches optimizer = high)
207
+ - **B** = business criticality (level-3 sink = low; level-1 sink = high)
208
+ - **H** = error-hiding degree (downstream unaware = high)
209
+
210
+ Map to final level (§13):
211
+ - **Critical** — defensive logic directly alters a critical business decision (e.g. `Simulation Error → mass=0 → Optimization Objective`).
212
+ - **High** — error hidden and enters core computation but does not directly decide the business result.
213
+ - **Medium** — unreasonable fallback / default / duplicate constraint, but propagation limited.
214
+ - **Low** — local defensive code with near-zero impact on critical results (e.g. temp-file cleanup failure, log write failure).
215
+
216
+ Rule: only `reaches_critical_sink == true` may be High+; findings reaching only level-3 sinks default to Low.
217
+
218
+ 7. Write `propagation.confirmed_chains` + `propagation.risky_sinks` + `propagation.q4_hidden` count + evidence phase=propagate. Update §5 / §6 / §7 / §8. Mark G4.
219
+
220
+ **GATE: propagation-verified** — every scan candidate has `reaches_critical_sink` verdict + failure→value transformation type + Q4 signal + four-dimensional score (S/P/B/H) + risk level + exception class (A/B/C/D). No-score / no-sink-verdict candidate is BLOCKED (W003 per-item `needs_review` acceptable only when truly undecidable, with a per-item reason).
221
+
222
+ Commit: `"odyssey-defensive({slug}): PROPAGATE — {N} chains, {M} reach critical sink, {K} Q4-hidden"`
223
+
224
+ ### A_REPORT
225
+
226
+ (§12-§14 — risk scoring formalized + standard report format.)
227
+
228
+ 1. Produce a finding per candidate using the **§14 standard report format**:
229
+
230
+ ```
231
+ DEF-NNN
232
+ Risk level: Critical | High | Medium | Low
233
+ Defensive location: file:line
234
+ Trigger pattern: broad_catch | exception_swallow | default | ...
235
+ Original failure: SimulationSystemError
236
+ State transform: Exception → {} → mass = 0
237
+ Full propagation: solver.run() → except Exception → return {} → result.get("mass", 0) → objective() → optimizer
238
+ Business impact: simulation error converted to mass=0; optimizer may pick the failed design as optimal.
239
+ Remediation: distinguish DesignInfeasibleError (penalty) vs SimulationSystemError (raise).
240
+ ```
241
+
242
+ 2. Build the **severity matrix** (Critical / High / Medium / Low) with file:line references, full propagation chains, Q4 signals, and remediation for every finding.
243
+ 3. Compute summary statistics: counts per level, per pattern, per exception class, Q4-hidden total.
244
+ 4. Write §8 (risk matrix + exception classification + standard report entries) + `session.json.audit_result` + `session.json.findings_count`. Evidence phase=report. Mark G5.
245
+
246
+ **GATE: report-produced** — severity matrix with §14 standard report entries for every finding; summary statistics computed; §8 written; `audit_result` populated; read-only invariant verified (zero source modifications in session).
247
+
248
+ Commit: `"odyssey-defensive({slug}): REPORT — {C}C/{H}H/{M}M/{L}L matrix"`
249
+
250
+ ---
251
+
252
+ ## Generalize Source
253
+
254
+ Critical/High findings that propagate to a level-1 sink + cross-module duplicate defensive patterns (dup_constraint / dup_default) + recurring failure→value transformation signatures.
255
+
256
+ **Discover routing:** sibling module with the same defensive anti-pattern → S_SCAN (re-scan expanded scope); newly discovered critical propagation chain → evidence phase=decision, recommend `--mode improve`; needs root-cause → `--mode debug`.
257
+
258
+ ---
259
+
260
+ ## Knowledge Persistence (§9)
261
+
262
+ Include verified reusable findings in the Run summary and harvest the completed Session through `evolve workflows show knowledge` (`evolve closeout session` → `evolve wiki propose`).
263
+
264
+ | Category | Content | Follow-up |
265
+ |----------|---------|-----------|
266
+ | Failure→Value transformation pattern | transformation signature + trigger + detection pattern + fix template | `evolve closeout session` → `evolve wiki propose` (`category: coding`) |
267
+ | 异常语义坍缩 (exception semantic collapse) | multi-exception → single-state signature + business consequence + detection | `evolve closeout session` → `evolve wiki propose` (`category: coding`) |
268
+ | Constraint/default inconsistency | variable + per-location values + unit/meaning conflict + resolution | `evolve closeout session` → `evolve wiki propose` (`category: arch`) |
269
+ | Critical propagation chain | sink + chain + hiding mechanism + remediation strategy | `evolve closeout session` → `evolve wiki propose` (`category: debug`) |
270
+
271
+ ---
272
+
273
+ ## Completion Summary
274
+
275
+ ```
276
+ --- DEFENSIVE ODYSSEY COMPLETE ---
277
+ Target: {target}
278
+ Tier: {tier}
279
+ Anchors: {N} critical vars, {M} level-1 sinks
280
+ Patterns: P1:{n1} P2:{n2} P3:{n3} P4:{n4} P5:{n5} P6:{n6} P7:{n7} P8:{n8}
281
+ Candidates: {N} defensive nodes
282
+ Chains: {N} propagated, {M} reach critical sink
283
+ Risk: {C}C / {H}H / {M}M / {L}L
284
+ Q4-hidden: {N} findings where downstream cannot detect upstream error
285
+ Exception: A:{a} B:{b} C:{c} D:{d}
286
+ Patterns: {count} ({by_layer})
287
+ Scan hits: {total} ({cross_layer_confirmed} confirmed)
288
+ Issues: {N} created
289
+ Decisions: {N} resolved, {M} pending, {K} deferred
290
+ Learnings: {N} persisted
291
+ Self-iter: {N} rounds across {M} stages
292
+ Cross-loops: {N}
293
+ Goals: {done}/{total} ({skipped} skipped)
294
+ ---
295
+ ```
296
+
297
+ ---
298
+
299
+ ## `-y` Decision Points
300
+
301
+ | Decision Point | Normal | `-y` |
302
+ |---------------|--------|------|
303
+ | A_ANCHOR critical-variable importance | structured prompt | auto-classify by semantic layer |
304
+ | A_SCAN false-positive dismissal | structured prompt | Dismiss only with recorded counter-evidence. Keep unresolved candidates as deferred. |
305
+ | A_PROPAGATE sink-hit ambiguity | structured prompt | auto-mark worst-case High |
306
+ | A_REPORT risk-level downgrade | structured prompt | Downgrade only with documented counter-evidence. Keep the current severity or risk level when the decision is deferred. |
307
+ | A_DISCOVER routing | structured prompt | Record a deferred discovery with evidence. Route issue creation and improve work through an explicit follow-up. |
308
+ | Ambiguous items | structured prompt | all `deferred` |
309
+
310
+ ---
311
+
312
+ ## Mode-Specific Phase Gates
313
+
314
+ - **Anchor gate** (S_ANCHOR): critical_vars ≥1 AND level-1 sink present. Evidence phase=anchor logged. §2 updated. BLOCKED if no critical vars / no level-1 sink.
315
+ - **Scan gate** (S_SCAN): all tier-required patterns completed. Per-pattern evidence logged. Findings merged per-pattern. Tier-required pattern missing is BLOCKED (W001/W002 partial allowed).
316
+ - **Propagation gate** (S_PROPAGATE): every candidate has reaches_critical_sink + four-dimensional score + state transformation + Q4 signal + exception class. No-score candidate = BLOCKED or per-item W003.
317
+ - **Report gate** (S_REPORT): severity matrix with §14 standard report entries + full propagation chains + remediation. §8 written. Read-only invariant verified (zero source modifications).
318
+
319
+ ---
320
+
321
+ ## Error Codes (defensive-specific)
322
+
323
+ | Code | Severity | Condition | Recovery |
324
+ |------|----------|-----------|----------|
325
+ | E001 | error | No target / scope provided | Provide target or -c |
326
+ | E002 | error | No critical vars / no level-1 sink found | Verify target has business-critical output |
327
+ | W001 | warning | AST tool unavailable | Scan via Grep, note coverage gap |
328
+ | W002 | warning | Cross-module aggregation failed (no symbol table) | Local-only constraint/default check, note limitation |
329
+ | W003 | warning | Candidate undecidable for sink/score | Per-item `needs_review`, do not BLOCK |
330
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD |
331
+ | W005 | warning | Pending decisions | Filter evidence phase=decision |
332
+
333
+ ---
334
+
335
+ ## Success Criteria (defensive-specific)
336
+
337
+ - [ ] Target resolved; tier + sink-depth determined; session + 4 output files + prior knowledge searched
338
+ - [ ] S_ANCHOR: critical-variable table + sink layering (§2) with ≥1 level-1 sink
339
+ - [ ] S_SLICE: per-critical-var source_chain + three-layer business-flow map (§3)
340
+ - [ ] S_SCAN: all tier-required 8 patterns scanned, bucketed per-pattern (§4/§7)
341
+ - [ ] S_PROPAGATE: every candidate has state transformation + sink verdict + Q4 signal + four-dimensional score + exception class (§5/§6/§8)
342
+ - [ ] S_REPORT: severity matrix + full propagation chains + remediation, in §14 standard report format (§8)
343
+ - [ ] understanding.md 9 sections written progressively (§1–§9)
344
+ - [ ] Read-only invariant maintained — zero source code modifications
345
+ - [ ] Multi-layer generalization + discovery triage (unless --skip-generalize)
346
+ - [ ] phase_goals derived, tracked, and hardened-audited; goal_mode injected via prepare goal:true
347
+ - [ ] Session resumable via -c; completion summary emitted
348
+
349
+ ---
350
+
351
+ See [shared base](odyssey-base.md) for generic follow-up routing (`Next Step Routing`). Related transitions: `/ew-odyssey <finding> --mode improve` (fix defensive defects), `/ew-odyssey <finding> --mode debug` (root cause), `/ew-odyssey <target> --mode defensive --tier deep` (deep tier).