@mutagent/helix 0.1.0-alpha.14

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 (357) hide show
  1. package/.claude/skills/mutagent-helix/SKILL.md +113 -0
  2. package/.claude/skills/mutagent-helix/scripts/cli/codex-transcode.ts +143 -0
  3. package/.claude/skills/mutagent-helix/scripts/cli/doctor.ts +111 -0
  4. package/.claude/skills/mutagent-helix/scripts/cli/init.ts +382 -0
  5. package/.claude/skills/mutagent-helix/scripts/cli/run.sh +61 -0
  6. package/CLAUDE.md +193 -0
  7. package/LICENSE +201 -0
  8. package/NOTICE +22 -0
  9. package/README.md +209 -0
  10. package/assets/adl-loop.svg +162 -0
  11. package/assets/system-status.svg +422 -0
  12. package/bin/mutagent-cli.mjs +9950 -0
  13. package/bin/mutagent-helix.mjs +78 -0
  14. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/CLAUDE.md +28 -0
  15. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/SKILL.md +138 -0
  16. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/assets/templates/agentspec.yaml.tpl +247 -0
  17. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/frameworks/doc-pins.md +53 -0
  18. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/principles.md +91 -0
  19. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/requirements.yaml +295 -0
  20. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/workflows/orchestrator-protocol.md +302 -0
  21. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/doctor.ts +116 -0
  22. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/init.ts +230 -0
  23. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/run.sh +60 -0
  24. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/config/resolve-spec-dir.ts +199 -0
  25. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/contract/agentspec.schema.ts +455 -0
  26. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/setup/detect.ts +67 -0
  27. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/validate/validate-spec.ts +93 -0
  28. package/mutagent-agentspec/LICENSE +201 -0
  29. package/mutagent-agentspec/NOTICE +19 -0
  30. package/mutagent-agentspec/README.md +44 -0
  31. package/mutagent-builder/.claude/skills/mutagent-builder/SKILL.md +100 -0
  32. package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-architect.md +312 -0
  33. package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-engineer.md +357 -0
  34. package/mutagent-builder/.claude/skills/mutagent-builder/assets/templates/build-report.md.tpl +39 -0
  35. package/mutagent-builder/.claude/skills/mutagent-builder/references/principles.md +31 -0
  36. package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/build-protocol.md +61 -0
  37. package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/improve-handoff.md +23 -0
  38. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/cli/run.sh +60 -0
  39. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/handoff/validate-build-input.ts +72 -0
  40. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/sync-spec/check-sync-spec.ts +499 -0
  41. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/verify/spec-impl-coverage.ts +182 -0
  42. package/mutagent-builder/CLAUDE.md +25 -0
  43. package/mutagent-builder/README.md +26 -0
  44. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/README.md +192 -0
  45. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/SKILL.md +352 -0
  46. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-architect.md +256 -0
  47. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-engineer.md +344 -0
  48. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/diagnostics-analyzer.md +576 -0
  49. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/discovery.md +425 -0
  50. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.json.tpl +24 -0
  51. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.md.tpl +49 -0
  52. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/config.yaml.tpl +100 -0
  53. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/pr-body.md.tpl +56 -0
  54. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/report.html.tpl +327 -0
  55. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/README.md +27 -0
  56. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/iter-N-handover.md.tpl +125 -0
  57. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/self-diagnosis-contract.v0.1.0.yaml.tpl +234 -0
  58. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/spec.yaml.tpl +152 -0
  59. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/team.yaml.tpl +127 -0
  60. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/wave-N-dashboard.html.tpl +1712 -0
  61. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.1-nl-query.md +59 -0
  62. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.2-tier0-progress.md +58 -0
  63. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.3-analysis-progress.md +44 -0
  64. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.4-html-report.md +61 -0
  65. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.5-rca-detail.md +69 -0
  66. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.6-stale-warning.md +53 -0
  67. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.1-welcome.md +60 -0
  68. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.2-source-platform-picker.md +41 -0
  69. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.3-source-auth.md +75 -0
  70. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.4-target-picker.md +48 -0
  71. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.5-ask-tool.md +43 -0
  72. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.6-config-review.md +57 -0
  73. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.7-filter-defaults.md +52 -0
  74. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.8-first-run.md +59 -0
  75. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-findings.json +92 -0
  76. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-meta.json +47 -0
  77. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/adapter-strategy.md +75 -0
  78. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config-migration.md +84 -0
  79. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config.md +159 -0
  80. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/filter-search-matrix.md +66 -0
  81. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/harness-knowledge.md +22 -0
  82. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/memory-format.md +78 -0
  83. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/onboarding-decisions.yaml +187 -0
  84. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/operation-inventory.md +59 -0
  85. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/overview.md +167 -0
  86. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/reference.md +119 -0
  87. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/script-index.md +101 -0
  88. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-adapter-contract.md +93 -0
  89. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/claude-code-transcripts.md +66 -0
  90. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex-transcripts.md +78 -0
  91. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex.md +145 -0
  92. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/install-paths.md +57 -0
  93. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/langfuse.md +178 -0
  94. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/local-jsonl.md +55 -0
  95. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/openobserve.md +102 -0
  96. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/otel.md +63 -0
  97. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/cloud-rest.md +84 -0
  98. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-claude.md +65 -0
  99. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cloud-agent-sdk.md +92 -0
  100. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-codex.md +72 -0
  101. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cursor.md +108 -0
  102. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-mastra.md +77 -0
  103. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-opencode.md +70 -0
  104. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/apply-pr-comment-format.md +82 -0
  105. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/diagnostics.md +35 -0
  106. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/handover-contract.md +247 -0
  107. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/onboarding.md +300 -0
  108. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/orchestrator-protocol.md +1861 -0
  109. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rca.md +331 -0
  110. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rendering-anatomy.md +314 -0
  111. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/schedule-prep.md +100 -0
  112. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/scope-model.md +128 -0
  113. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/verification-methodology.md +174 -0
  114. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/aggregate/sort-findings.ts +0 -0
  115. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/blind-spots.ts +167 -0
  116. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/llm-sample.ts +681 -0
  117. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/doctor.ts +215 -0
  118. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/init.ts +1013 -0
  119. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/install-agents.ts +350 -0
  120. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/run.sh +61 -0
  121. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/shared-templates.ts +79 -0
  122. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/load.ts +392 -0
  123. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/resolve-credential.ts +120 -0
  124. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/schema.ts +641 -0
  125. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/validate.ts +134 -0
  126. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/build-diagnosis-context.ts +417 -0
  127. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/load-context.ts +105 -0
  128. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/contract/types.ts +166 -0
  129. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/build-render-input.ts +1964 -0
  130. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/corpus-severity.ts +172 -0
  131. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/dismissal-match.ts +270 -0
  132. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/rank-remedies.ts +75 -0
  133. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/install-hooks.sh +46 -0
  134. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/pre-push.sh +78 -0
  135. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/invocation/parse-brief.ts +188 -0
  136. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/match.ts +114 -0
  137. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/paths.ts +95 -0
  138. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/store.ts +535 -0
  139. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/types.ts +181 -0
  140. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/lint/template-inline-js.ts +267 -0
  141. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/append.ts +188 -0
  142. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/read.ts +218 -0
  143. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/platforms/entity-context.ts +686 -0
  144. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/read-unitf.ts +267 -0
  145. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/trace.ts +1078 -0
  146. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-adapter.ts +0 -0
  147. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-types.ts +213 -0
  148. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/persist-selections.ts +174 -0
  149. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/render.ts +3254 -0
  150. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/diagnose.ts +64 -0
  151. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/session.ts +167 -0
  152. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/caps.ts +345 -0
  153. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/deep-read-gate.ts +424 -0
  154. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/representative.ts +584 -0
  155. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/objection.ts +224 -0
  156. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/trajectory.ts +489 -0
  157. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/dispatch.ts +135 -0
  158. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/probe.ts +170 -0
  159. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/detect.ts +307 -0
  160. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/ensure-cli.ts +315 -0
  161. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/reconfigure.ts +77 -0
  162. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/verify-agents.ts +207 -0
  163. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/slicer.ts +166 -0
  164. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/claude-code.ts +17 -0
  165. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/codex.ts +11 -0
  166. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/langfuse.ts +17 -0
  167. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/local-jsonl.ts +12 -0
  168. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/otel.ts +12 -0
  169. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/index.ts +54 -0
  170. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/registry.ts +45 -0
  171. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/types.ts +86 -0
  172. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/stale-detector.ts +74 -0
  173. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/test/render-playwright.cli.ts +477 -0
  174. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/claude-code.ts +133 -0
  175. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/langfuse.ts +143 -0
  176. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0-scan.ts +423 -0
  177. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/completeness-check.ts +436 -0
  178. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/doc-refs.ts +190 -0
  179. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/finalize-gate.ts +417 -0
  180. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/findings-contract.ts +628 -0
  181. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/render-js-syntax.ts +188 -0
  182. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/report-checklist.yaml +217 -0
  183. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/trace-shape.ts +262 -0
  184. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/wave6-checklist.ts +326 -0
  185. package/mutagent-diagnostics/CLAUDE.md +41 -0
  186. package/mutagent-diagnostics/LICENSE +201 -0
  187. package/mutagent-diagnostics/NOTICE +18 -0
  188. package/mutagent-diagnostics/README.md +343 -0
  189. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/SKILL.md +548 -0
  190. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/audit-executor.md +169 -0
  191. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/dataset-builder.md +160 -0
  192. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/discovery.md +425 -0
  193. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/evaluator.md +1108 -0
  194. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/theme.css +213 -0
  195. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/wordmark.html +9 -0
  196. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/context-flow-lens.md +85 -0
  197. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/data-lens.md +47 -0
  198. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/decision-lens.md +48 -0
  199. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/methodology-critic-lens.md +53 -0
  200. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/trajectory-lens.md +44 -0
  201. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/build-review-interface.md +83 -0
  202. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/edd-loop.md +134 -0
  203. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/error-analysis.md +113 -0
  204. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-audit.md +154 -0
  205. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-stage.md +168 -0
  206. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/generate-synthetic-data.md +81 -0
  207. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/grounded-adjudication.md +221 -0
  208. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/memory-format.md +65 -0
  209. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/methodology.md +201 -0
  210. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/operation-inventory.md +197 -0
  211. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/validate-evaluator.md +125 -0
  212. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/workflows/orchestrator-protocol.md +300 -0
  213. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/write-judge-prompt.md +123 -0
  214. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/behavior-tree.schema.yaml +73 -0
  215. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/dataset.schema.yaml +66 -0
  216. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/edd-change-request.schema.yaml +114 -0
  217. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/eval-matrix.schema.yaml +74 -0
  218. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-graph.schema.yaml +69 -0
  219. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-profile.schema.yaml +49 -0
  220. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/methodology-review.schema.yaml +40 -0
  221. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/scorecard.schema.yaml +85 -0
  222. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/agent-dispatch.ts +0 -0
  223. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/aggregate-discover.ts +543 -0
  224. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/artifact-paths.ts +115 -0
  225. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/assemble-scorecard.ts +172 -0
  226. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-dataset.ts +186 -0
  227. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-evals.ts +93 -0
  228. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-review-ui.ts +393 -0
  229. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/check-method-router.ts +170 -0
  230. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/aggregate.ts +112 -0
  231. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/audit-run.ts +182 -0
  232. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/doctor.ts +211 -0
  233. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/dogfood.ts +133 -0
  234. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/init.ts +601 -0
  235. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/methodology-review.ts +122 -0
  236. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/prep.ts +295 -0
  237. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/profile-subject.ts +165 -0
  238. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/run.sh +56 -0
  239. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/variance-check.ts +105 -0
  240. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-eval.ts +248 -0
  241. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-quality-verdict.ts +285 -0
  242. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/codegen-evals.ts +173 -0
  243. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-project.ts +151 -0
  244. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-sampler.ts +267 -0
  245. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/load.ts +343 -0
  246. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/schema.ts +380 -0
  247. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/agentspec-evals.ts +85 -0
  248. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/dataset.ts +149 -0
  249. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-engine.ts +118 -0
  250. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-matrix.ts +577 -0
  251. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-types.ts +1074 -0
  252. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/flow-graph.ts +194 -0
  253. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/types.ts +303 -0
  254. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/validation.ts +193 -0
  255. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/derive-dataset.ts +152 -0
  256. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/determine-outcome.ts +219 -0
  257. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/diff-discriminate.ts +160 -0
  258. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/discover-criteria.ts +348 -0
  259. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/change-request.ts +232 -0
  260. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/edd-types.ts +210 -0
  261. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/variance-gate.ts +186 -0
  262. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/emit-completeness.ts +111 -0
  263. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/eval-engine.ts +160 -0
  264. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/evaluate.ts +333 -0
  265. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/flow-graph.ts +230 -0
  266. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-prompt-template.ts +253 -0
  267. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-provider.ts +135 -0
  268. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-grounding.ts +229 -0
  269. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-uniformity.ts +168 -0
  270. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/living-suite.ts +109 -0
  271. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-bundle.ts +203 -0
  272. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile-vocab.ts +64 -0
  273. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile.ts +106 -0
  274. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/mask.ts +138 -0
  275. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/materialize-dataset.ts +113 -0
  276. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/matrix-judge.ts +750 -0
  277. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/append.ts +215 -0
  278. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/read.ts +168 -0
  279. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/persist-eval-criteria.ts +232 -0
  280. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/prep-tasks.ts +125 -0
  281. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/profile-subject.ts +310 -0
  282. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/publish-report.ts +131 -0
  283. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/read-unitf-traces.ts +81 -0
  284. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-build-cards.ts +195 -0
  285. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-discover-report.ts +1640 -0
  286. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-eval-report.ts +3838 -0
  287. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-report.ts +212 -0
  288. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-credential.ts +110 -0
  289. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-ref.ts +98 -0
  290. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/result-verify.ts +129 -0
  291. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/route-failures.ts +330 -0
  292. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-deterministic.ts +367 -0
  293. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-evaluate.ts +719 -0
  294. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-judge.ts +155 -0
  295. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-pipeline.ts +175 -0
  296. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sample-traces.ts +210 -0
  297. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/self-audit.ts +387 -0
  298. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/source-map.ts +106 -0
  299. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/subject-profile.ts +134 -0
  300. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/substrate.ts +162 -0
  301. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sync-eval-criteria.ts +244 -0
  302. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/ui-slots.ts +119 -0
  303. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/unitf-to-evaltrace.ts +284 -0
  304. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/validate-judge.ts +358 -0
  305. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/variance-compare.ts +177 -0
  306. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/behavior-tree.yaml +140 -0
  307. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/eval-matrix.yaml +1270 -0
  308. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/methodology-review.yaml +105 -0
  309. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/audit.workflow.js +82 -0
  310. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/data-leak.workflow.js +236 -0
  311. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/variance.workflow.js +163 -0
  312. package/mutagent-evaluator/CLAUDE.md +45 -0
  313. package/mutagent-evaluator/LICENSE +201 -0
  314. package/mutagent-evaluator/NOTICE +23 -0
  315. package/mutagent-evaluator/README.md +88 -0
  316. package/mutagent-optimize/.claude/skills/mutagent-optimize/SKILL.md +287 -0
  317. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/contracts/amend-request.ts +503 -0
  318. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/improve-loop-run.ts +304 -0
  319. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state-cli.ts +300 -0
  320. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state.ts +440 -0
  321. package/mutagent-optimize/CLAUDE.md +49 -0
  322. package/mutagent-optimize/README.md +26 -0
  323. package/mutagent-orchestrator/CLAUDE.md +102 -0
  324. package/mutagent-orchestrator/README.md +20 -0
  325. package/mutagent-orchestrator/assets/agents/discovery.md +425 -0
  326. package/mutagent-orchestrator/assets/agents/dogfood-monitor.md +266 -0
  327. package/mutagent-orchestrator/assets/agents/monitor.md +258 -0
  328. package/mutagent-orchestrator/orchestrator.md +782 -0
  329. package/mutagent-orchestrator/references/MONITORING.md +209 -0
  330. package/mutagent-orchestrator/references/config-fields.md +132 -0
  331. package/mutagent-orchestrator/references/config-migration.md +132 -0
  332. package/mutagent-orchestrator/references/index-registry.md +92 -0
  333. package/mutagent-orchestrator/routing.yaml +391 -0
  334. package/mutagent-orchestrator/scripts/config-schema.ts +1010 -0
  335. package/mutagent-orchestrator/scripts/dispatch.ts +439 -0
  336. package/mutagent-orchestrator/scripts/dogfood/extract-feedback.ts +203 -0
  337. package/mutagent-orchestrator/scripts/dogfood/reconstruct-trajectory.ts +327 -0
  338. package/mutagent-orchestrator/scripts/dogfood/render-dogfood-report.ts +347 -0
  339. package/mutagent-orchestrator/scripts/dogfood/resolve-subagents.ts +160 -0
  340. package/mutagent-orchestrator/scripts/dogfood/run-report.ts +264 -0
  341. package/mutagent-orchestrator/scripts/dogfood/slack-thread.ts +106 -0
  342. package/mutagent-orchestrator/scripts/dogfood/types.ts +257 -0
  343. package/mutagent-orchestrator/scripts/eval-routing.ts +753 -0
  344. package/mutagent-orchestrator/scripts/gate.ts +219 -0
  345. package/mutagent-orchestrator/scripts/handover-contract.ts +362 -0
  346. package/mutagent-orchestrator/scripts/index/build-index.ts +351 -0
  347. package/mutagent-orchestrator/scripts/index/render-index.ts +110 -0
  348. package/mutagent-orchestrator/scripts/monitor/slack-notify.ts +111 -0
  349. package/mutagent-orchestrator/scripts/monitor/triggers.ts +162 -0
  350. package/mutagent-orchestrator/scripts/onboarding-check.ts +369 -0
  351. package/mutagent-orchestrator/scripts/render-roster.ts +308 -0
  352. package/mutagent-orchestrator/scripts/resolve-credential.ts +185 -0
  353. package/mutagent-orchestrator/scripts/resolve-paths.ts +114 -0
  354. package/mutagent-orchestrator/scripts/slack/format.ts +63 -0
  355. package/mutagent-orchestrator/scripts/slack/post.ts +115 -0
  356. package/mutagent-orchestrator/scripts/sync-index.ts +311 -0
  357. package/package.json +64 -0
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: mutagent-optimize
3
+ description: |
4
+ The ADL ⑤ IMPROVE stage: the closed, bounded, eval-driven optimize loop
5
+ (Build → Eval → Diagnose → Improve ↻). ONE command *optimize runs a confirm-once
6
+ → bounded auto-loop → one apply-gate at convergence. A sub-orchestration skill in
7
+ the shape of evaluator/diagnostics: the parent session owns the loop FSM + gates
8
+ and dispatches a BORROWED crew it does not itself execute — ai-engineer (WRITE),
9
+ ai-architect (VERIFY), evaluator (JUDGE, re-eval), diagnostics-analyzer (RCA).
10
+ optimize writes NOTHING itself: the WRITE delegates to ② builder, the JUDGE to
11
+ ③ evaluator, the RCA to ④ diagnostics, and the TRANSPORT to `mutagent-cli apply`
12
+ (a call OUT to the shared service, NOT a subcommand). Absorbs the retired
13
+ diagnostics apply-worker's target mechanics via that shared apply layer.
14
+ license: Apache-2.0
15
+ compatibility: Designed for Claude Code, Codex, Cursor, OpenCode and similar coding-agent runtimes; works with git, gh CLI, mutagent-cli, and Bun runtimes.
16
+ metadata:
17
+ author: mutagent
18
+ version: "0.1.0-alpha.0"
19
+ ---
20
+
21
+ # mutagent-optimize
22
+
23
+ The **ADL ⑤ IMPROVE** stage — the one owner of `*improve`. It conducts the closed
24
+ `Build → Eval → Diagnose → Improve ↻` loop and owns the apply-gate; it **delegates**
25
+ the WRITE to ② builder, the JUDGE to ③ evaluator, the RCA to ④ diagnostics, and the
26
+ TRANSPORT to the shared `mutagent-cli apply` service. It writes nothing itself.
27
+
28
+ ## §0 — Setup Detection
29
+
30
+ `mutagent-optimize` ships the loop FSM as a PURE decision model (`scripts/loop-state.ts`)
31
+ plus its one-shot CLI (`scripts/loop-state-cli.ts`) — the conducting session calls the CLI
32
+ between Task dispatches (§2·5). (`scripts/improve-loop-run.ts` is NOT the interactive runtime
33
+ — it is the unit-test harness + a future headless verification driver; see §2.) The crew is
34
+ BORROWED — sealed-sibling via a Helix handover: ai-engineer + ai-architect (from ②), evaluator
35
+ (③), diagnostics-analyzer (④). The parent session routes `*improve`/`*optimize` here through
36
+ Helix and READS the HandoverBundle on entry (`bundle.inputs[]` — the trace slice + manifest,
37
+ or the approved RemedyPacket — LOCATABLE relative paths), never re-fetching (single-collection-point).
38
+
39
+ ## §0.1 — Star-commands · LEAN · YAGNI
40
+
41
+ | Command | Kind | Owner | Binds | Purpose |
42
+ |---|---|---|---|---|
43
+ | `*optimize` | sub-orch loop | own (full) | the §2·5 conduct procedure + `scripts/loop-state-cli.ts` (decisions) + `scripts/loop-state.ts` (FSM) + Task-dispatched crew | THE stage: confirm-once → the session conducts the bounded auto-loop → one apply-gate at convergence. |
44
+
45
+ ```
46
+ *optimize <subject> [--goal eval-pass|criterion:<id>|delta:<n>|code-quality|"<free text>"] [--max-iters N] [--budget 30m] [--dry-run] [--html]
47
+ ```
48
+
49
+ > **`--goal code-quality`** is the CODE-TARGET goal (Wave-2 W2I1): the loop converges
50
+ > ONLY when BOTH the code subject's OWN test suite is green (a hard deterministic gate)
51
+ > AND the code-quality evaluator verdict passes. Neither alone converges. It is the
52
+ > default goal when the subject is a `code`-kind target (`global.targets[].subject: code`).
53
+
54
+ > **`--goal "<free text>"`** is a NATURAL-LANGUAGE goal (Wave-2 W2I10). The loop still
55
+ > needs an OBSERVABLE, unchanging yardstick, so free text is NOT run as-is — at Entry the
56
+ > SESSION INTERPRETS it into a measurable binary criterion, CONFIRMS it once, and FREEZES
57
+ > it (→ the frozen criterion becomes the yardstick). An UNFROZEN NL goal is **not
58
+ > goal-legal** (`assertGoalLegal` rejects it exactly like an unbounded goal), and a
59
+ > HEADLESS run — no human to confirm — REFUSES it (falls back to a structured goal or
60
+ > throws). Never runs unbounded. See §2·5 Entry (interpret → confirm → freeze).
61
+
62
+ ### Subject-kind → goal disambiguation (which goals apply to what)
63
+
64
+ The subject's KIND governs which goals are even applicable. `code-quality` is the ONLY
65
+ goal that touches a test suite / actual code, so it applies to `code` subjects and
66
+ NOWHERE else; every other subject-kind optimizes against EVALS.
67
+
68
+ | Subject kind | What it is | Applicable goals | `code-quality`? |
69
+ |---|---|---|---|
70
+ | **`code`** | actual source (a repo / package with its own test suite) | `code-quality` (the BOTH-gate: tests-green AND the quality verdict) — the default; eval goals also usable | **YES — only here** |
71
+ | **`agent`** | a markdown / platform agent (Claude Code `.md`, Codex, prompt-defined) | evals only — `eval-pass` · `criterion:<id>` · `delta:<n>` · a frozen NL criterion | **NEVER** (no code to test) |
72
+ | **`skill`** | a prompt / markdown-defined skill | evals only — same set as `agent` | **NEVER** (no code to test) |
73
+ | **`platform`** | a hosted / reconstruct-spec subject (non-code markdown) | evals only — same set as `agent` | **NEVER** (no code to test) |
74
+
75
+ > The **`code-quality` name is retained deliberately** — it is accurate precisely because
76
+ > it only ever applies to actual code. `assertGoalAllowedForSubject(goal, subjectKind)`
77
+ > code-enforces this: a `code-quality` goal on a non-code subject throws; all eval-based
78
+ > goals are valid for any subject. The session runs it at Entry via
79
+ > `loop-state-cli assert-goal-legal config.json --subject-kind <code|agent|skill|platform>`.
80
+
81
+ > **Net surface = `*optimize`.** Everything else earns its place or folds:
82
+ > - `*apply` / `*rollback` — **FOLDED internal**. The absorbed apply mechanics are a
83
+ > capability the loop calls at its promotion gate via the shared `mutagent-cli apply`
84
+ > service (caller a), NOT user-facing commands. Rollback is the revert branch of the
85
+ > same capability, reachable from a run's apply-audit.
86
+ > - `*variant` / `*promote` — **OUT OF SCOPE** (the separate #1085 variant bake-off).
87
+ > - `*status` — **OUT OF SCOPE** (loop state lives in `loop-state.json` + Helix `*status`).
88
+ >
89
+ > Helix's `*improve` route (`routing.yaml`) re-targets to `mutagent-optimize`; the
90
+ > utterances ("apply the fix", "next iteration", "loop back to build", "optimize") all
91
+ > map onto the one command.
92
+
93
+ ## §1 — Sub-orchestration dispatch (parent conducts · crew executes)
94
+
95
+ ```
96
+ optimize parent — owns loop FSM + gates + interaction; writes nothing
97
+ → ImproveHandover
98
+ ai-engineer #apply / #amend (WRITE — worktree-scoped)
99
+ ai-architect PROCEED|STEER|ABORT (VERIFY — read-only)
100
+ evaluator re-eval swing (JUDGE — EV-051 judge-only)
101
+ analyzer RCA on new failures (DIAGNOSE)
102
+ ```
103
+
104
+ Boundaries preserved verbatim: ai-engineer never mutates spec on an impl-amend;
105
+ ai-architect stays read-only; evaluator stays EV-051 judge-only; the parent never
106
+ writes source. Each borrowed cell's home-stage invariants carry into optimize unchanged.
107
+
108
+ ## §2 — The loop FSM (S0→S5 · deterministic · bounded)
109
+
110
+ `scripts/loop-state.ts` is the pure DECISION model (the FSM: bounded · goal-legal ·
111
+ variance-aware). Phases: **S1 Build → S2 Verify → S3 Eval → S4 Gate → [S5 Diagnose ↺]**.
112
+
113
+ > **Two runtimes — do not conflate.** The INTERACTIVE `*optimize` runtime is conducted by
114
+ > YOU, the top-level session (Model B — §2·5 below): only the session can Task-dispatch
115
+ > sub-agents, so the session conducts and calls the pure decisions one-shot via
116
+ > `scripts/loop-state-cli.ts`. `scripts/improve-loop-run.ts` is NOT the interactive runtime —
117
+ > it is the unit-test harness + a future HEADLESS *verification* driver (Model A / SimuLatte
118
+ > `sim-run`). Both drive the same FSM; the interactive one is a session procedure, not a script.
119
+
120
+ - **Transition gates (which stage moves to which):** S1→S2 always. **S2 verdict:** `PROCEED`→S3,
121
+ `STEER`→S1 (re-build with instructions), `ABORT`→stop (`aborted`). **S4 gate:** `PASS`→check
122
+ goal/terminators (may `converged`), `FAIL`→S5 diagnose→S1.
123
+ - **Termination gates (afkloop-legal — the loop refuses to run without them):** an OBSERVABLE
124
+ goal (`eval-pass` · `criterion:<id>` · `delta:<n>` · `code-quality` [code-target BOTH-gate] ·
125
+ a FROZEN natural-language goal [`nl` with `resolved.criterionIds[]` — an AND-set of ≥1 binary
126
+ criteria]) + hard terminators (`max-iters` ·
127
+ wallclock `budget` · `no-improvement` streak) + a scope envelope (worktree-scoped). Terminators:
128
+ `converged` · `no-improvement` · `max-iters` · `budget` · `aborted`. `assertGoalLegal` is
129
+ unchanged for a `code-quality` goal (bounded like the others); it additionally REJECTS an
130
+ UNFROZEN natural-language goal (an un-yardsticked free-text intent) exactly as it rejects an
131
+ unbounded field — so an NL goal only runs once frozen to a measurable criterion.
132
+ - **Variance-gate** — an iteration counts as improvement ONLY on a strict, above-noise gain that
133
+ does not regress variance; a sub-noise wobble is a plateau, not a win (decided by the CLI, not you).
134
+ - **Two nested gates** — the intra-loop transitions ARE the automatic progress-gate (each
135
+ iteration self-scores; no human); the real-world write on promotion IS the single human
136
+ apply-gate. "Ask once at entry + promote once at exit" — never ask-per-iteration.
137
+
138
+ ## §2·5 — RUNTIME CONDUCT: you (the session) conduct the loop (Model B — interactive)
139
+
140
+ **YOU are the conductor.** A sub-agent cannot spawn sub-agents, so the loop cannot be a
141
+ sub-agent or a TS `while` awaiting dispatches — the TOP-LEVEL SESSION runs it, exactly like
142
+ diagnostics runs its `orchestrator-protocol` inline in the parent. You Task-dispatch the crew
143
+ and shell `loop-state-cli.ts` for every decision (you never eyeball the variance-gate / terminators).
144
+
145
+ **Entry (once):**
146
+ 1. **Parse the goal.** `bun run scripts/loop-state-cli.ts parse-goal "<--goal arg>"` → a `Goal`.
147
+ The four structured shapes (`eval-pass` · `criterion:<id>` · `delta:<n>` · `code-quality`)
148
+ resolve directly. Any FREE-TEXT `--goal` resolves to an UNRESOLVED natural-language goal
149
+ (`{ kind: "nl", text }`) — not yet a runnable yardstick.
150
+ 2. **Interpret → confirm → freeze (natural-language goals only).** If the goal is `nl`, the
151
+ SESSION must turn the free text into a COMPOSITION of MEASURABLE BINARY criteria / measurable
152
+ metrics BEFORE the loop can run — this is AGENT reasoning at entry, NOT a code loop:
153
+ - **Interpret** — draft one or more binary, observable criteria that together capture the
154
+ intent (a real NL goal usually decomposes into a SET of binary decisions / measurable
155
+ metrics, not a single one; you MAY Task-dispatch the ③ evaluator's criterion-mining to help
156
+ draft them — that is session dispatch, not a code loop). Example: *"a concise, well-sourced
157
+ answer"* → `NL-1: "the output is ≤ 3 sentences"` **AND** `NL-2: "every claim cites a
158
+ source"`.
159
+ - **Confirm** — surface the drafted criteria in the SAME confirm-once Entry ASK (step 3;
160
+ the ONLY per-loop prompt, MODE-2) via `AskUserQuestion`: *"I read your goal “{text}” as
161
+ the binary criteria **{criteria}** (optimize until ALL pass, bounded by {maxIters}
162
+ iters / {budget})? Adjust the criteria, or pick a structured goal instead?"*
163
+ - **Freeze** — on confirm, `bun run scripts/loop-state-cli.ts freeze-goal config.json
164
+ --criterion <id> [--criterion <id> …]` (repeat the flag, or pass a comma list `--criterion
165
+ a,b`) → the goal becomes `{ kind: "nl", text, resolved: { criterionIds } }`, a concrete
166
+ AND-yardstick the loop runs against (met only when ALL listed criteria pass — each an
167
+ objective binary check). The raw text is kept for audit.
168
+ - **HEADLESS / no human** (SimuLatte / CI, no interactive confirm): an NL goal CANNOT be
169
+ safely confirmed → **fall back to a structured goal, or REFUSE** (the goal-legal gate in
170
+ step 4 throws on an unfrozen NL goal). NEVER run an unfrozen NL goal.
171
+ 3. **Confirm once** with the operator that the loop may run (MODE-2: this is the ONLY per-loop
172
+ prompt until promotion — for an NL goal it is the SAME ASK that confirms the frozen criterion
173
+ in step 2). Establish `runId`; make `.mutagent/optimize/runs/<runId>/`.
174
+ 4. Write `config.json` = `{ goal, maxIters, budgetMs, noImprovementStreak, noiseFloor }` and
175
+ `bun run scripts/loop-state-cli.ts assert-goal-legal config.json [--subject-kind <k>]` — if it
176
+ exits non-zero, the loop is NOT goal-legal (an unbounded field, an UNFROZEN NL goal, or a
177
+ `code-quality` goal on a non-code subject); surface the named problem and STOP (never run an
178
+ unbounded / un-yardsticked loop). Pass `--subject-kind` to also enforce subject-kind → goal.
179
+ 5. `bun run scripts/loop-state-cli.ts init > loop-state.json` (the cursor).
180
+
181
+ > **⚠️ FLAGGED-FOR-OPERATOR-SIGN-OFF (Wave-2 W2I1) — the code-subject inferred-goal confirm-ASK.**
182
+ > When `*optimize` is invoked on a `code`-kind subject WITHOUT an explicit `--goal`, the goal is
183
+ > INFERRED as `code-quality` (the BOTH-gate). Because that is an inference, the session SHOULD confirm
184
+ > it at Entry (the ONLY per-loop prompt). The wording below is a **DRAFT** — surfaced here for the
185
+ > operator to approve/adjust; it is NOT baked as a final prompt, and code never surfaces it (the
186
+ > SESSION raises the ASK via `AskUserQuestion`):
187
+ > > *"I'll optimize the code subject **{subject}**. Converged means BOTH: its own test suite is green
188
+ > > AND a code-quality evaluator verdict passes (bounded by {maxIters} iters / {budget}). Proceed with
189
+ > > this `code-quality` goal, or pick a different goal (eval-pass · criterion · delta)?"*
190
+ > Confirm-once at Entry only — never ask per iteration (MODE-2). Adjust before shipping as the default.
191
+
192
+ **Per round (repeat until a terminator):** track elapsed wall-ms yourself as `budgetMs_spent`.
193
+
194
+ > **ONE INTAKE SHAPE (Wave-2 W2I2).** `AmendRequest` is the SINGLE amend contract the loop intakes.
195
+ > BOTH amend dialects enter S1 through the `accept-amend` accept-gate — the evaluator's
196
+ > `EddChangeRequest` (eval→improve) and the diagnostics `Remedy` / RemedyPacket (diagnose→improve) — so
197
+ > the S1 handover is NEVER a raw dialect and the two shapes cannot drift at the operating level:
198
+ > `bun run scripts/loop-state-cli.ts accept-amend <input.json> --dialect <eval|diagnostics> [--subject <s>] [--brief]`
199
+ > (a diagnostics remedy needs `--subject`; `--brief` prints the NL S1 build brief; `--dialect amend`
200
+ > re-validates an already-unified amend). It is lossless (round-trip-proven) and fail-loud on a
201
+ > malformed handover. Contract + adapters: `scripts/contracts/amend-request.ts`.
202
+
203
+ 1. **S1 Build** — NORMALIZE the handover through `accept-amend` FIRST (→ an `AmendRequest`; use
204
+ `--brief` for the NL build brief), THEN Task-dispatch **ai-engineer** (`#apply`, worktree-scoped)
205
+ with that `AmendRequest`. It writes; it never mutates a spec on an impl-amend. (The first round has
206
+ no amend — an empty handover — so this normalization applies from the diagnose-carry round onward.)
207
+ 2. **S2 Verify** — Task-dispatch **ai-architect** (`#verify-remedy`) → read `PROCEED|STEER|ABORT`.
208
+ 3. **S3+S4 Eval+Gate** — Task-dispatch **evaluator** (re-eval swing, judge-only) → read the
209
+ `score` + the `GATE` verdict (`PASS|FAIL`) + any passed `criteria`.
210
+ 4. **Record** — `loop-state-cli record-iteration loop-state.json config.json --verify <v> --gate <g>
211
+ --score <n> --variance-regressed <true|false> --budget-ms <budgetMs_spent>` → **overwrite**
212
+ `loop-state.json` with the printed cursor (it applies the variance-gate + streak for you).
213
+ 5. **Decide** — `loop-state-cli check-terminators loop-state.json config.json --last-verify <v>
214
+ [--criteria c1,c2]`. **Exit 3 + a reason** (`converged`/`no-improvement`/`max-iters`/`budget`/
215
+ `aborted`) ⇒ STOP the loop → go to Promotion. **Exit 0 + `continue`** ⇒ keep going.
216
+ 6. **Next phase** (when continuing) — `loop-state-cli next-phase S4-gate --gate <PASS|FAIL>`. On
217
+ `S5-diagnose` (a FAIL gate) Task-dispatch **diagnostics-analyzer** (RCA) → NORMALIZE its `Remedy`
218
+ through the accept-gate (`accept-amend --dialect diagnostics --subject <s>` → an `AmendRequest`)
219
+ BEFORE it becomes the next round's S1 handover; NEVER carry the raw diagnose remedy. On `S1-build`
220
+ (a STEER) re-dispatch ai-engineer with the steer instructions.
221
+
222
+ **Code-target branch (Wave-2 W2I1 — a `code`-kind subject, `--goal code-quality`):** the round
223
+ shape is IDENTICAL (same S1→S5, same one opaque dispatch per phase, same PR-ORCH-01 discipline) —
224
+ only the crew's work and the recorded signals differ. Deltas, per phase:
225
+ 1. **S1 Build** — ai-engineer runs its **code-target TDD inner loop** (test-first → lint → typecheck
226
+ → build → **test** on the code subject). This inner loop is ai-engineer's OWN tool-loop — from
227
+ your view it is ONE opaque dispatch (ai-engineer spawns no sub-agents). It returns whether the
228
+ subject's OWN test suite is green (`testsGreen`), the hard deterministic half of the gate.
229
+ 2. **S2 Verify** — ai-architect `#verify-remedy` (code-subject rubric) confirms the applied change is
230
+ spec-faithful (def→impl cascade held), in-scope, non-destructive, and that the test suite it saw
231
+ is actually green (claimed-green-but-red ⇒ ABORT).
232
+ 3. **S3+S4 Eval+Gate** — the evaluator runs its **`#mode-judge-code-quality`** verdict (the (b) half
233
+ — a host-runtime, C-PIN, judge-only quality verdict → `PASS|FAIL`). You ALSO carry the
234
+ deterministic `testsGreen` from S1 into the record.
235
+ 4. **Record** — the SAME `record-iteration` call, additionally passing **`--tests-green <true|false>`**
236
+ (the S1 signal). The oracle stamps it on the cursor; the `code-quality` goal's `goalMet` ANDs it
237
+ with the quality verdict. NEITHER alone converges: a green suite with a FAIL quality verdict, or a
238
+ PASS quality verdict on a red suite, both keep looping (→ continue / no-improvement / max-iters /
239
+ budget as usual). **Do NOT pre-AND them yourself** — pass both signals; the oracle decides.
240
+ 5. **Decide / Next phase / Diagnose** — unchanged. The oracle stays consult-only; you never gain a
241
+ code path that dispatches agents.
242
+
243
+ **Promotion (once, on any terminator):**
244
+ - Only `converged` (an above-live measured improvement) is eligible to promote; `no-improvement` /
245
+ `budget` / `max-iters` / `aborted` STOP and promote **nothing**.
246
+ - Raise the **single human apply-gate** (`AskUserQuestion`). On approval, apply via the shared
247
+ transport per §3 (`mutagent-cli apply --dry-run` → `--commit`). This is the only real-world write.
248
+
249
+ > **Do NOT** build a TS `CrewBindings` object that `await`s Task dispatches — that is the wrong
250
+ > shape (an awaiting script is not the session; a sub-agent can't dispatch). The interactive "crew
251
+ > binding" IS this procedure. The TS harness (`improve-loop-run.ts`) exists only for unit tests +
252
+ > future headless verification.
253
+
254
+ ## §3 — Apply is a call OUT to the shared service (DC-1)
255
+
256
+ optimize does NOT own an apply subcommand. At the promotion gate it collects the human
257
+ approval (AskUserQuestion), THEN shells the shared transport:
258
+
259
+ ```
260
+ mutagent-cli apply --kind <code-pr|markdown|cloud-deploy|report-only> --target <root> ... --dry-run # preview
261
+ mutagent-cli apply ... --commit # write (after the gate)
262
+ mutagent-cli apply --rollback <apply-audit.json> # non-destructive revert
263
+ ```
264
+
265
+ The CLI holds NO approval logic — the gate is a skill-layer decision, once, before the
266
+ transport (mirrors `mutagent-cli trace`: dumb fetch; the skill decides). Every commit
267
+ emits `.mutagent/apply/<id>/apply-audit.json` proving the approved thing is the applied
268
+ thing.
269
+
270
+ ## §4 — Artifacts — `.mutagent/optimize/runs/<runId>/`
271
+
272
+ - `loop-state.json` — the FSM cursor: iteration · phase · per-iteration GATE · convergence
273
+ delta · budget spent (goal-legal).
274
+ - `iterations/<n>/` — the handover in, the amend/apply diff, the ai-architect verdict, the
275
+ re-eval scorecard.
276
+ - `apply-audit.json` — the absorbed dual-emit audit (stale-hash · transport · from/to ref ·
277
+ revert-token) — the rollback ledger (written by `mutagent-cli apply`).
278
+ - `optimize-report.html` — per-iteration score trajectory + termination reason + convergence
279
+ delta (opt-in via `--html`; a living, self-refreshing local report).
280
+
281
+ ## §5 — Ownership doctrine (resolves the split-brain)
282
+
283
+ ⑤ IMPROVE = mutagent-optimize: it conducts the loop and owns the gate; it delegates the
284
+ WRITE to ② builder, the JUDGE to ③ evaluator, the RCA to ④ diagnostics, and the TRANSPORT
285
+ to `mutagent-cli apply`. It writes nothing itself. (Replaces the three prior contradicting
286
+ surfaces: the builder `*improve` route, the diagnostics apply-worker, and the evaluator's
287
+ `*improve` EDD mode — the evaluator's EDD mode becomes optimize's re-eval ENGINE.)