@aibyzero/cm-workflow 0.10.5

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 (448) hide show
  1. package/.codex-plugin/plugin.json +30 -0
  2. package/AGENTS.md +74 -0
  3. package/CONTRIBUTING.md +62 -0
  4. package/LICENSE +21 -0
  5. package/README.md +263 -0
  6. package/SECURITY.md +49 -0
  7. package/THIRD_PARTY_NOTICES.md +29 -0
  8. package/VERSION +1 -0
  9. package/agents/cm-backend-agent.md +34 -0
  10. package/agents/cm-contract-agent.md +34 -0
  11. package/agents/cm-database-agent.md +34 -0
  12. package/agents/cm-frontend-agent.md +33 -0
  13. package/agents/cm-miniprogram-agent.md +33 -0
  14. package/agents/cm-ui-agent.md +34 -0
  15. package/assets/docs/command-picker-mobile.svg +56 -0
  16. package/assets/docs/command-picker.svg +56 -0
  17. package/assets/docs/user-guide-hero-mobile.svg +35 -0
  18. package/assets/docs/user-guide-hero.svg +36 -0
  19. package/assets/readme/delivery-flow.svg +86 -0
  20. package/assets/readme/hero.svg +77 -0
  21. package/assets/readme/recovery-record.svg +73 -0
  22. package/assets/readme/test-evidence.svg +64 -0
  23. package/compat/claude-commands/cm-ai.md +3 -0
  24. package/compat/claude-commands/cm-check.md +3 -0
  25. package/compat/claude-commands/cm-fix.md +3 -0
  26. package/compat/claude-commands/cm-idea.md +3 -0
  27. package/compat/claude-commands/cm-init.md +3 -0
  28. package/compat/claude-commands/cm-prd.md +3 -0
  29. package/compat/claude-commands/cm-refactor.md +3 -0
  30. package/compat/claude-commands/cm-test.md +3 -0
  31. package/docs/architecture.md +155 -0
  32. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a1-handoff.json +57 -0
  33. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a2-handoff.json +58 -0
  34. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-r1.md +121 -0
  35. package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-a1-handoff.json +56 -0
  36. package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-r1.md +100 -0
  37. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a1-handoff.json +61 -0
  38. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a2-handoff.json +63 -0
  39. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r1.md +58 -0
  40. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r2.md +55 -0
  41. package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-a1-handoff.json +65 -0
  42. package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-r1.md +88 -0
  43. package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r1.md +33 -0
  44. package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r2.md +31 -0
  45. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a1-handoff.json +56 -0
  46. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a2-handoff.json +85 -0
  47. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r1.md +53 -0
  48. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r2.md +80 -0
  49. package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-a1-handoff.json +35 -0
  50. package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-r1.md +33 -0
  51. package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r1.md +30 -0
  52. package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r2.md +16 -0
  53. package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-a1-handoff.json +40 -0
  54. package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-r1.md +30 -0
  55. package/docs/fixes/20260729-windows-cp1252-log-output.md +65 -0
  56. package/docs/fixes/20260804-manifest-runtime-checkbox-drift.md +67 -0
  57. package/docs/fixes/20260806-model-call-boundary-identity.md +80 -0
  58. package/docs/fixes/20260807-prelanding-integrity.md +58 -0
  59. package/docs/fixes/20260826-openai-compatible-depth-fixture.md +39 -0
  60. package/docs/fixes/20260903-cm-js-n1n2-admission-r1.md +64 -0
  61. package/docs/fixes/20260903-cm-js-n1n2-admission-successor.md +83 -0
  62. package/docs/fixes/20260903-s4c1b-v3-cancel-throw.md +89 -0
  63. package/docs/fixes/20260904-f01-codex-dual-failure-terminal.md +89 -0
  64. package/docs/fixes/20260907-wip-triage-log.md +44 -0
  65. package/docs/installation.md +202 -0
  66. package/docs/js-workflow-control.md +1010 -0
  67. package/docs/sample-prd/prd-funding-rate-alert.md +42 -0
  68. package/docs/sample-specs/docs//351/234/200/346/261/202/347/244/272/344/276/213.md +24 -0
  69. package/docs/user-guide.md +526 -0
  70. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/README.md +19 -0
  71. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.excalidraw +3650 -0
  72. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.mp4 +0 -0
  73. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.png +0 -0
  74. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.spec.json +223 -0
  75. package/install-codex.sh +184 -0
  76. package/install.ps1 +206 -0
  77. package/install.sh +244 -0
  78. package/package.json +58 -0
  79. package/runtime/external-expert.md +302 -0
  80. package/runtime/js/cm-ai/accepted-fix.mjs +28 -0
  81. package/runtime/js/cm-ai/claude-developer-adapter.mjs +6 -0
  82. package/runtime/js/cm-ai/claude-review-adapter.mjs +16 -0
  83. package/runtime/js/cm-ai/claude-review-stream.mjs +53 -0
  84. package/runtime/js/cm-ai/claude-tool-preview.mjs +107 -0
  85. package/runtime/js/cm-ai/cm-ai-admission.mjs +353 -0
  86. package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +217 -0
  87. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +538 -0
  88. package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +119 -0
  89. package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +172 -0
  90. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +320 -0
  91. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +107 -0
  92. package/runtime/js/cm-ai/code-projects.mjs +85 -0
  93. package/runtime/js/cm-ai/codex-config.mjs +48 -0
  94. package/runtime/js/cm-ai/codex-developer-adapter.mjs +5 -0
  95. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +6 -0
  96. package/runtime/js/cm-ai/codex-developer-output.schema.json +37 -0
  97. package/runtime/js/cm-ai/codex-review-adapter.mjs +73 -0
  98. package/runtime/js/cm-ai/contracts.mjs +156 -0
  99. package/runtime/js/cm-ai/developer-adapter.mjs +93 -0
  100. package/runtime/js/cm-ai/durable-runner-state.mjs +504 -0
  101. package/runtime/js/cm-ai/effect-contract.mjs +102 -0
  102. package/runtime/js/cm-ai/execution-platform.mjs +7 -0
  103. package/runtime/js/cm-ai/execution-store.mjs +211 -0
  104. package/runtime/js/cm-ai/fix-code-association.mjs +40 -0
  105. package/runtime/js/cm-ai/gate-bridge.mjs +25 -0
  106. package/runtime/js/cm-ai/host-bootstrap.mjs +170 -0
  107. package/runtime/js/cm-ai/host-check.mjs +89 -0
  108. package/runtime/js/cm-ai/host-conversation-execution.mjs +125 -0
  109. package/runtime/js/cm-ai/host-documentation.mjs +40 -0
  110. package/runtime/js/cm-ai/host-handoff.mjs +71 -0
  111. package/runtime/js/cm-ai/host-project-execution.mjs +58 -0
  112. package/runtime/js/cm-ai/host-qa-executor.mjs +238 -0
  113. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +131 -0
  114. package/runtime/js/cm-ai/host-qa-fix.mjs +30 -0
  115. package/runtime/js/cm-ai/host-qa-policy.mjs +70 -0
  116. package/runtime/js/cm-ai/host-review-authority.mjs +36 -0
  117. package/runtime/js/cm-ai/host-review-file.mjs +56 -0
  118. package/runtime/js/cm-ai/host-role-routing.mjs +41 -0
  119. package/runtime/js/cm-ai/host-session.mjs +96 -0
  120. package/runtime/js/cm-ai/host-tool-bridge.mjs +53 -0
  121. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +45 -0
  122. package/runtime/js/cm-ai/host.mjs +20 -0
  123. package/runtime/js/cm-ai/index.mjs +7 -0
  124. package/runtime/js/cm-ai/provider-review-observation.mjs +86 -0
  125. package/runtime/js/cm-ai/qa-fix-definition.mjs +21 -0
  126. package/runtime/js/cm-ai/review-evidence-file.mjs +38 -0
  127. package/runtime/js/cm-ai/review-package.mjs +426 -0
  128. package/runtime/js/cm-ai/review-result.schema.json +40 -0
  129. package/runtime/js/cm-ai/review-runner.mjs +35 -0
  130. package/runtime/js/cm-ai/task-commit-codec.mjs +54 -0
  131. package/runtime/js/cm-ai/task-commit.mjs +201 -0
  132. package/runtime/js/cm-ai/task-owner.mjs +97 -0
  133. package/runtime/js/cm-ai/task-runner.mjs +766 -0
  134. package/runtime/js/cm-ai/tool-preview.mjs +205 -0
  135. package/runtime/js/cm-ai/worker-claude.mjs +104 -0
  136. package/runtime/js/cm-ai/worker-codex-developer.mjs +124 -0
  137. package/runtime/js/cm-ai/worker-codex.mjs +143 -0
  138. package/runtime/js/cm-check/host.mjs +101 -0
  139. package/runtime/js/cm-fix/baseline.mjs +70 -0
  140. package/runtime/js/cm-fix/cause-evidence.mjs +24 -0
  141. package/runtime/js/cm-fix/cause-invocation.mjs +40 -0
  142. package/runtime/js/cm-fix/cause-package.mjs +68 -0
  143. package/runtime/js/cm-fix/dossier.mjs +140 -0
  144. package/runtime/js/cm-fix/execution.mjs +1549 -0
  145. package/runtime/js/cm-fix/final-review-evidence.mjs +20 -0
  146. package/runtime/js/cm-fix/final-review.mjs +156 -0
  147. package/runtime/js/cm-fix/finish.mjs +124 -0
  148. package/runtime/js/cm-fix/handoff.mjs +64 -0
  149. package/runtime/js/cm-fix/host-review.mjs +38 -0
  150. package/runtime/js/cm-fix/host.mjs +96 -0
  151. package/runtime/js/cm-fix/investigation.mjs +25 -0
  152. package/runtime/js/cm-fix/layout.mjs +17 -0
  153. package/runtime/js/cm-fix/learning-writeback.mjs +86 -0
  154. package/runtime/js/cm-fix/learning.mjs +31 -0
  155. package/runtime/js/cm-fix/metrics.mjs +75 -0
  156. package/runtime/js/cm-fix/progress.mjs +64 -0
  157. package/runtime/js/cm-fix/protected-edits.mjs +95 -0
  158. package/runtime/js/cm-fix/qa-source.mjs +58 -0
  159. package/runtime/js/cm-fix/red-test.mjs +92 -0
  160. package/runtime/js/cm-fix/regression-evidence.mjs +64 -0
  161. package/runtime/js/cm-fix/regression.mjs +41 -0
  162. package/runtime/js/cm-fix/repair.mjs +95 -0
  163. package/runtime/js/cm-fix/reproduce.mjs +54 -0
  164. package/runtime/js/cm-fix/retrospective.mjs +41 -0
  165. package/runtime/js/cm-fix/review-baseline.mjs +47 -0
  166. package/runtime/js/cm-fix/start.mjs +49 -0
  167. package/runtime/js/cm-fix/test-author.mjs +63 -0
  168. package/runtime/js/cm-fix/visual.mjs +72 -0
  169. package/runtime/js/cm-fix/walkthrough.mjs +126 -0
  170. package/runtime/js/cm-idea/session.mjs +79 -0
  171. package/runtime/js/cm-init/draft-generation.mjs +66 -0
  172. package/runtime/js/cm-init/draft-inspection.mjs +70 -0
  173. package/runtime/js/cm-init/project-analysis.mjs +60 -0
  174. package/runtime/js/cm-init/project-scan.mjs +55 -0
  175. package/runtime/js/cm-init/review-evidence.mjs +80 -0
  176. package/runtime/js/cm-prd/accepted-design.mjs +46 -0
  177. package/runtime/js/cm-prd/analysis.mjs +260 -0
  178. package/runtime/js/cm-prd/change.mjs +268 -0
  179. package/runtime/js/cm-prd/correction-check.mjs +49 -0
  180. package/runtime/js/cm-prd/design-risk.mjs +30 -0
  181. package/runtime/js/cm-prd/disposition-plan.mjs +33 -0
  182. package/runtime/js/cm-prd/draft-save.mjs +122 -0
  183. package/runtime/js/cm-prd/draft.mjs +70 -0
  184. package/runtime/js/cm-prd/materials.mjs +48 -0
  185. package/runtime/js/cm-prd/review-correction.mjs +158 -0
  186. package/runtime/js/cm-prd/review-disposition.mjs +96 -0
  187. package/runtime/js/cm-prd/review-findings.mjs +36 -0
  188. package/runtime/js/cm-prd/review-host.mjs +48 -0
  189. package/runtime/js/cm-prd/review-preparation.mjs +49 -0
  190. package/runtime/js/cm-prd/review-publication.mjs +56 -0
  191. package/runtime/js/cm-prd/self-check.mjs +75 -0
  192. package/runtime/js/cm-prd/session.mjs +74 -0
  193. package/runtime/js/cm-prd/summary.mjs +133 -0
  194. package/runtime/js/cm-refactor/host.mjs +2 -0
  195. package/runtime/js/cm-refactor/records.mjs +86 -0
  196. package/runtime/js/cm-refactor/workflow.mjs +478 -0
  197. package/runtime/js/cm-test/declared-command.mjs +32 -0
  198. package/runtime/js/cm-test/host.mjs +319 -0
  199. package/runtime/js/cm-test/logic-results.mjs +39 -0
  200. package/runtime/js/cm-test/recovery.mjs +58 -0
  201. package/runtime/js/cm-test/session.mjs +56 -0
  202. package/runtime/js/cm-test/source-snapshot.mjs +136 -0
  203. package/runtime/logging.md +207 -0
  204. package/runtime/model-efficiency.md +201 -0
  205. package/runtime/orchestration.md +113 -0
  206. package/runtime/project-context.md +43 -0
  207. package/runtime/project-learning.md +49 -0
  208. package/runtime/review.md +140 -0
  209. package/runtime/steelman-review.md +111 -0
  210. package/runtime/task-gates.md +283 -0
  211. package/runtime/task-handoff.schema.json +103 -0
  212. package/runtime/test-contract.md +212 -0
  213. package/runtime/workflow-config.md +118 -0
  214. package/runtime/workflow-routing.md +82 -0
  215. package/scripts/cm-ai-admission.mjs +50 -0
  216. package/scripts/cm-ai-admission.test.mjs +38 -0
  217. package/scripts/cm-ai-batch-host.mjs +77 -0
  218. package/scripts/cm-ai-batch-host.test.mjs +155 -0
  219. package/scripts/cm-ai-batch-run.mjs +136 -0
  220. package/scripts/cm-ai-batch-run.test.mjs +128 -0
  221. package/scripts/cm-ai-bootstrap.test.mjs +228 -0
  222. package/scripts/cm-ai-fix-integration.test.mjs +233 -0
  223. package/scripts/cm-ai-host.mjs +175 -0
  224. package/scripts/cm-ai-host.test.mjs +368 -0
  225. package/scripts/cm-ai-multi-root.test.mjs +289 -0
  226. package/scripts/cm-ai-nested-execution.test.mjs +313 -0
  227. package/scripts/cm-ai-run.mjs +293 -0
  228. package/scripts/cm-ai-run.test.mjs +336 -0
  229. package/scripts/cm-check-entry.mjs +120 -0
  230. package/scripts/cm-check-host.mjs +29 -0
  231. package/scripts/cm-check-host.test.mjs +71 -0
  232. package/scripts/cm-check-runtime.ps1 +69 -0
  233. package/scripts/cm-check-runtime.sh +910 -0
  234. package/scripts/cm-claude-probe.test.mjs +54 -0
  235. package/scripts/cm-claude-review-stream.test.mjs +45 -0
  236. package/scripts/cm-claude-worker.test.mjs +92 -0
  237. package/scripts/cm-codex-developer-adapter.test.mjs +85 -0
  238. package/scripts/cm-codex-developer-worker.test.mjs +128 -0
  239. package/scripts/cm-codex-review-progress.test.mjs +96 -0
  240. package/scripts/cm-execution-platform.test.mjs +47 -0
  241. package/scripts/cm-fix-cause-invocation.test.mjs +72 -0
  242. package/scripts/cm-fix-cause-package.test.mjs +68 -0
  243. package/scripts/cm-fix-code-association.test.mjs +55 -0
  244. package/scripts/cm-fix-entry.mjs +132 -0
  245. package/scripts/cm-fix-execution.test.mjs +63 -0
  246. package/scripts/cm-fix-final-review.test.mjs +124 -0
  247. package/scripts/cm-fix-host-review-assembly.test.mjs +34 -0
  248. package/scripts/cm-fix-host-review.test.mjs +261 -0
  249. package/scripts/cm-fix-host-sequence.test.mjs +26 -0
  250. package/scripts/cm-fix-host.mjs +89 -0
  251. package/scripts/cm-fix-host.test.mjs +105 -0
  252. package/scripts/cm-fix-learning-writeback.test.mjs +73 -0
  253. package/scripts/cm-fix-learning.test.mjs +66 -0
  254. package/scripts/cm-fix-metrics.test.mjs +58 -0
  255. package/scripts/cm-fix-no-existing-tests.test.mjs +92 -0
  256. package/scripts/cm-fix-observation-dossier.test.mjs +452 -0
  257. package/scripts/cm-fix-progress.test.mjs +45 -0
  258. package/scripts/cm-fix-protected-edits.test.mjs +54 -0
  259. package/scripts/cm-fix-qa-source.test.mjs +206 -0
  260. package/scripts/cm-fix-red-owner.test.mjs +143 -0
  261. package/scripts/cm-fix-red-test.test.mjs +38 -0
  262. package/scripts/cm-fix-regression.test.mjs +57 -0
  263. package/scripts/cm-fix-repair-owner.test.mjs +370 -0
  264. package/scripts/cm-fix-repair.test.mjs +68 -0
  265. package/scripts/cm-fix-reproduce.test.mjs +31 -0
  266. package/scripts/cm-fix-retrospective.test.mjs +46 -0
  267. package/scripts/cm-fix-review-baseline.test.mjs +54 -0
  268. package/scripts/cm-fix-review-recovery.test.mjs +197 -0
  269. package/scripts/cm-fix-test-author.test.mjs +105 -0
  270. package/scripts/cm-fix-visual-bare.test.mjs +171 -0
  271. package/scripts/cm-fix-walkthrough.test.mjs +45 -0
  272. package/scripts/cm-host-check.test.mjs +113 -0
  273. package/scripts/cm-host-documentation.test.mjs +45 -0
  274. package/scripts/cm-host-handoff.test.mjs +58 -0
  275. package/scripts/cm-host-qa-executor.test.mjs +156 -0
  276. package/scripts/cm-host-qa-policy.test.mjs +59 -0
  277. package/scripts/cm-host-review-authority.test.mjs +60 -0
  278. package/scripts/cm-host-role-routing.test.mjs +33 -0
  279. package/scripts/cm-idea-entry.mjs +104 -0
  280. package/scripts/cm-idea-host.mjs +144 -0
  281. package/scripts/cm-idea-host.test.mjs +75 -0
  282. package/scripts/cm-idea-recovery.test.mjs +90 -0
  283. package/scripts/cm-init-analysis-host.test.mjs +50 -0
  284. package/scripts/cm-init-draft-generation.test.mjs +52 -0
  285. package/scripts/cm-init-draft-inspection.test.mjs +41 -0
  286. package/scripts/cm-init-entry.mjs +170 -0
  287. package/scripts/cm-init-host.mjs +284 -0
  288. package/scripts/cm-init-host.test.mjs +231 -0
  289. package/scripts/cm-init-project-analysis.test.mjs +47 -0
  290. package/scripts/cm-init-project-scan.test.mjs +41 -0
  291. package/scripts/cm-init-revision-host.test.mjs +61 -0
  292. package/scripts/cm-init-session.test.mjs +122 -0
  293. package/scripts/cm-log-event.mjs +538 -0
  294. package/scripts/cm-log-event.py +133 -0
  295. package/scripts/cm-log-event.test.mjs +70 -0
  296. package/scripts/cm-openai-compatible-call.py +661 -0
  297. package/scripts/cm-prd-analysis.test.mjs +67 -0
  298. package/scripts/cm-prd-completion.test.mjs +190 -0
  299. package/scripts/cm-prd-design-phase.test.mjs +296 -0
  300. package/scripts/cm-prd-draft-save.test.mjs +63 -0
  301. package/scripts/cm-prd-draft.test.mjs +39 -0
  302. package/scripts/cm-prd-entry.mjs +245 -0
  303. package/scripts/cm-prd-host.mjs +273 -0
  304. package/scripts/cm-prd-host.test.mjs +169 -0
  305. package/scripts/cm-prd-materials.test.mjs +41 -0
  306. package/scripts/cm-prd-review-claim.test.mjs +42 -0
  307. package/scripts/cm-prd-review-disposition.test.mjs +196 -0
  308. package/scripts/cm-prd-review-gate.mjs +194 -0
  309. package/scripts/cm-prd-review-gate.py +26 -0
  310. package/scripts/cm-prd-review-host.test.mjs +30 -0
  311. package/scripts/cm-prd-review-preparation.test.mjs +69 -0
  312. package/scripts/cm-prd-review-publication.test.mjs +95 -0
  313. package/scripts/cm-prd-revision.test.mjs +32 -0
  314. package/scripts/cm-prd-self-check.test.mjs +23 -0
  315. package/scripts/cm-prd-sources.test.mjs +76 -0
  316. package/scripts/cm-prd-timing.py +272 -0
  317. package/scripts/cm-refactor-entry.mjs +145 -0
  318. package/scripts/cm-refactor-host.mjs +26 -0
  319. package/scripts/cm-refactor-host.test.mjs +201 -0
  320. package/scripts/cm-review-dependency-snapshot.test.mjs +67 -0
  321. package/scripts/cm-review-inventory.test.mjs +109 -0
  322. package/scripts/cm-spec-manifest.mjs +104 -0
  323. package/scripts/cm-spec-manifest.py +26 -0
  324. package/scripts/cm-task-gate.mjs +879 -0
  325. package/scripts/cm-task-gate.py +312 -0
  326. package/scripts/cm-task-gate.test.mjs +202 -0
  327. package/scripts/cm-test-declared-command.test.mjs +18 -0
  328. package/scripts/cm-test-entry.mjs +231 -0
  329. package/scripts/cm-test-host.mjs +40 -0
  330. package/scripts/cm-test-host.test.mjs +169 -0
  331. package/scripts/cm-test-logic-results.test.mjs +26 -0
  332. package/scripts/cm-test-session.test.mjs +138 -0
  333. package/scripts/cm-usage-report.py +516 -0
  334. package/scripts/cm-workflow-config.mjs +463 -0
  335. package/scripts/cm-workflow-config.test.mjs +181 -0
  336. package/scripts/cm-workflow.mjs +36 -0
  337. package/scripts/cm-workflow.test.mjs +51 -0
  338. package/scripts/cm_workflow_config.py +52 -0
  339. package/scripts/fixtures/claude-review-process.mjs +35 -0
  340. package/scripts/fixtures/codex-review-process.mjs +22 -0
  341. package/scripts/fixtures/prd-review-gate-python-oracle.py +320 -0
  342. package/scripts/fixtures/spec-manifest-python-oracle.py +172 -0
  343. package/scripts/scan-public-safety.py +117 -0
  344. package/scripts/test-cm-log-event.py +1213 -0
  345. package/scripts/test-cm-openai-compatible-call.py +1185 -0
  346. package/scripts/test-cm-prd-review-gate.py +272 -0
  347. package/scripts/test-cm-prd-timing.py +168 -0
  348. package/scripts/test-cm-usage-report.py +584 -0
  349. package/scripts/test-npm-install.py +171 -0
  350. package/scripts/test-scan-public-safety.py +76 -0
  351. package/scripts/test-shell-compat.sh +365 -0
  352. package/scripts/test-spec-manifest.py +263 -0
  353. package/scripts/test-task-gate.py +46 -0
  354. package/scripts/test-workflow-config.py +30 -0
  355. package/scripts/validate-public-repo.py +245 -0
  356. package/scripts/validate-test-cases.mjs +71 -0
  357. package/scripts/validate-test-cases.py +27 -0
  358. package/scripts/validate-test-cases.test.mjs +36 -0
  359. package/skills/cm-ai/SKILL.md +137 -0
  360. package/skills/cm-ai/references/N1-init.md +108 -0
  361. package/skills/cm-ai/references/N2-enter-feature.md +38 -0
  362. package/skills/cm-ai/references/N3-execute-task.md +123 -0
  363. package/skills/cm-ai/references/N4-review.md +103 -0
  364. package/skills/cm-ai/references/N5-mark-done.md +117 -0
  365. package/skills/cm-ai/references/N6-qa-eval.md +102 -0
  366. package/skills/cm-ai/references/N7-context.md +23 -0
  367. package/skills/cm-ai/references/N8-finish.md +103 -0
  368. package/skills/cm-ai/references/js-host.md +126 -0
  369. package/skills/cm-backend-engineer/SKILL.md +100 -0
  370. package/skills/cm-check/SKILL.md +52 -0
  371. package/skills/cm-check/references/js-host.md +44 -0
  372. package/skills/cm-contract-engineer/SKILL.md +136 -0
  373. package/skills/cm-database-engineer/SKILL.md +89 -0
  374. package/skills/cm-devops-engineer/SKILL.md +137 -0
  375. package/skills/cm-doc-syncer/SKILL.md +150 -0
  376. package/skills/cm-finance-expert/SKILL.md +85 -0
  377. package/skills/cm-fix/SKILL.md +199 -0
  378. package/skills/cm-fix/references/cross-boundary-debugging.md +44 -0
  379. package/skills/cm-fix/references/js-host.md +135 -0
  380. package/skills/cm-frontend-engineer/SKILL.md +127 -0
  381. package/skills/cm-idea/SKILL.md +55 -0
  382. package/skills/cm-idea/references/domains/trading.md +97 -0
  383. package/skills/cm-idea/references/example-prd.md +92 -0
  384. package/skills/cm-idea/references/idea-to-prd.md +282 -0
  385. package/skills/cm-idea/references/js-host.md +63 -0
  386. package/skills/cm-init/SKILL.md +191 -0
  387. package/skills/cm-init/references/js-host.md +123 -0
  388. package/skills/cm-miniprogram-engineer/SKILL.md +141 -0
  389. package/skills/cm-miniprogram-engineer/references/platform-readiness.md +58 -0
  390. package/skills/cm-miniprogram-engineer/references/release-checklist.md +59 -0
  391. package/skills/cm-prd/SKILL.md +548 -0
  392. package/skills/cm-prd/references/brownfield.md +13 -0
  393. package/skills/cm-prd/references/change-mode.md +145 -0
  394. package/skills/cm-prd/references/context-scope.md +62 -0
  395. package/skills/cm-prd/references/greenfield.md +80 -0
  396. package/skills/cm-prd/references/js-change-recovery.md +57 -0
  397. package/skills/cm-prd/references/js-host.md +98 -0
  398. package/skills/cm-prd/references/phase-timing.md +68 -0
  399. package/skills/cm-prd/references/spec-self-check.md +22 -0
  400. package/skills/cm-product-manager/SKILL.md +83 -0
  401. package/skills/cm-qa-engineer/SKILL.md +142 -0
  402. package/skills/cm-refactor/SKILL.md +236 -0
  403. package/skills/cm-refactor/references/js-batch.md +75 -0
  404. package/skills/cm-refactor/references/js-host.md +78 -0
  405. package/skills/cm-test/SKILL.md +288 -0
  406. package/skills/cm-test/references/js-host.md +118 -0
  407. package/skills/cm-ui-engineer/SKILL.md +105 -0
  408. package/skills/codebase-context/SKILL.md +489 -0
  409. package/skills/darwin-skill/NOTICE.md +26 -0
  410. package/skills/darwin-skill/README.md +272 -0
  411. package/skills/darwin-skill/SKILL.md +492 -0
  412. package/skills/darwin-skill/references/runtime-neutrality.md +68 -0
  413. package/skills/darwin-skill/references/skilllens-evidence.md +142 -0
  414. package/skills/darwin-skill/scripts/screenshot.mjs +71 -0
  415. package/skills/darwin-skill/templates/result-card-dark.html +698 -0
  416. package/skills/darwin-skill/templates/result-card-white.html +444 -0
  417. package/skills/darwin-skill/templates/result-card.html +616 -0
  418. package/skills/external-expert/SKILL.md +250 -0
  419. package/templates/arch-reference.md +68 -0
  420. package/templates/auto-update/cm-announce.sh +19 -0
  421. package/templates/auto-update/cm-update.sh +274 -0
  422. package/templates/cm-workflow.yml +52 -0
  423. package/templates/dashboard/dashboard.html +153 -0
  424. package/templates/dashboard/serve.sh +10 -0
  425. package/templates/hooks/pre-commit-cm-task-check +67 -0
  426. package/templates/pixel/cm-pixel.html +388 -0
  427. package/templates/pixel/cm-pixel.sh +212 -0
  428. package/templates/pixel/dev/README.md +20 -0
  429. package/templates/pixel/dev/atlas-preview.png +0 -0
  430. package/templates/pixel/dev/build.py +55 -0
  431. package/templates/pixel/dev/sheets/roguelikeChar_transparent.png +0 -0
  432. package/templates/pixel/dev/sheets/roguelikeCity_tilemap.png +0 -0
  433. package/templates/pixel/dev/sheets/roguelikeIndoor_transparent.png +0 -0
  434. package/templates/pixel/dev/template.html +388 -0
  435. package/templates/pixel/serve.sh +12 -0
  436. package/templates/refactor/cm-refactor-denies.json +14 -0
  437. package/templates/rules/backend-api.md +36 -0
  438. package/templates/rules/coding-style.md +44 -0
  439. package/templates/rules/database.md +27 -0
  440. package/templates/rules/finance.md +32 -0
  441. package/templates/rules/frontend.md +32 -0
  442. package/templates/rules/git-workflow.md +25 -0
  443. package/templates/rules/miniprogram.md +31 -0
  444. package/templates/rules/security.md +31 -0
  445. package/templates/rules/smart-contract.md +28 -0
  446. package/templates/rules/testing.md +36 -0
  447. package/templates/statusline/cm-statusline.sh +73 -0
  448. package/templates/ui-lens/cm-ui-lens-extract.mjs +55 -0
@@ -0,0 +1,211 @@
1
+ // S3a local synthetic durable record store. No dispatch or task authority.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { randomUUID,createHash } from 'node:crypto';
5
+ import { DatabaseSync } from 'node:sqlite';
6
+ import { need,shape,id,hex,json,digest,freeze } from './effect-contract.mjs';
7
+ import { isSupportedExecutionPlatform } from './execution-platform.mjs';
8
+
9
+ const MiB=1024*1024,STATE_LIMIT=16*MiB,PHYSICAL_LIMIT=32*MiB,APP_ID=0x434d5831;
10
+ const PROTOCOL_SQL='CREATE TABLE protocol(version INTEGER NOT NULL CHECK(version=1))';
11
+ const kinds=new Set(['intent','result','cancel','commit-intent','commit-result','finalized']);
12
+ const seal=value=>freeze({...value,revision:digest(value)});
13
+ const sameInode=(a,b)=>a.dev===b.dev && a.ino===b.ino;
14
+ function syncPath(p) {
15
+ const fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
16
+ try{fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
17
+ }
18
+ function directory(p,create=false,privateMode=true) {
19
+ if(!fs.existsSync(p)) {
20
+ need(create,'store_missing');
21
+ try{fs.mkdirSync(p,{mode:0o700});syncPath(p);syncPath(path.dirname(p));}
22
+ catch(error){if(error.code!=='EEXIST')throw error;}
23
+ }
24
+ const stat=fs.lstatSync(p);
25
+ need(stat.isDirectory() && !stat.isSymbolicLink(),'unsupported_path');
26
+ need(!privateMode || (stat.mode&0o077)===0,'store_permissions');return stat;
27
+ }
28
+ function regular(p,limit) {
29
+ const s=fs.lstatSync(p);
30
+ need(s.isFile() && !s.isSymbolicLink() && s.nlink===1,'unsupported_file');
31
+ need((s.mode&0o077)===0,'store_permissions');need(s.size<=limit,'limit_exceeded');return s;
32
+ }
33
+ function readState(p) {
34
+ const before=regular(p,STATE_LIMIT),fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
35
+ try {
36
+ need(sameInode(before,fs.fstatSync(fd)),'snapshot_changed');
37
+ const bytes=fs.readFileSync(fd);need(bytes.length<=STATE_LIMIT,'limit_exceeded');
38
+ const after=fs.fstatSync(fd);
39
+ need(sameInode(before,fs.lstatSync(p)) && before.size===after.size && before.mtimeMs===after.mtimeMs
40
+ && before.ctimeMs===after.ctimeMs && bytes.length===after.size,'snapshot_changed');
41
+ const raw=bytes.toString('utf8'),value=JSON.parse(raw);
42
+ // Compare original bytes: replacement decoding must never repair corruption.
43
+ need(Buffer.from(JSON.stringify(value)+'\n').equals(bytes),'store_corrupt');return value;
44
+ }finally{fs.closeSync(fd);}
45
+ }
46
+ function validateState(raw,options) {
47
+ const v=json(raw,STATE_LIMIT);shape(v,['version','identity','fingerprints','records','revision']);
48
+ need(v.version===1,'store_version');
49
+ need(digest(v.identity)===digest(options.identity),'identity_mismatch');
50
+ need(digest(v.fingerprints)===digest(options.fingerprints),'fingerprint_mismatch');
51
+ need(Array.isArray(v.records) && v.records.length<=1024,'limit_exceeded');
52
+ let previous=null;const ids=new Set();
53
+ for(const [index,r] of v.records.entries()) {
54
+ shape(r,['version','seq','id','kind','payload','previousDigest','digest']);
55
+ need(r.version===1,'store_version');need(r.seq===index+1 && r.previousDigest===previous,'store_corrupt');
56
+ id(r.id);need(!ids.has(r.id) && kinds.has(r.kind),'store_corrupt');ids.add(r.id);json(r.payload,MiB);
57
+ const {digest:checksum,...data}=r;hex(checksum);need(digest(data)===checksum,'store_corrupt');previous=checksum;
58
+ }
59
+ const {revision,...data}=v;hex(revision);need(digest(data)===revision,'store_corrupt');return v;
60
+ }
61
+ function runBytes(dir) {
62
+ let total=0;
63
+ for(const name of fs.readdirSync(dir)) {
64
+ need(name==='state.json' || /^\.state\.[a-f0-9-]{36}\.tmp$/.test(name),'store_unknown_file');
65
+ total+=regular(path.join(dir,name),STATE_LIMIT).size;
66
+ }
67
+ need(total<=PHYSICAL_LIMIT,'limit_exceeded');return total;
68
+ }
69
+ function atomicState(dir,value) {
70
+ const bytes=Buffer.from(JSON.stringify(value)+'\n');need(bytes.length<=STATE_LIMIT,'limit_exceeded');
71
+ need(runBytes(dir)+bytes.length<=PHYSICAL_LIMIT,'limit_exceeded');
72
+ const tmp=path.join(dir,`.state.${randomUUID()}.tmp`);let fd,renamed=false;
73
+ try {
74
+ fd=fs.openSync(tmp,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,0o600);
75
+ fs.writeFileSync(fd,bytes);fs.fsyncSync(fd);fs.closeSync(fd);fd=undefined;
76
+ fs.renameSync(tmp,path.join(dir,'state.json'));renamed=true;syncPath(dir);
77
+ }catch(error) {
78
+ if(renamed)need(false,'store_write_unknown');throw error;
79
+ }finally{if(fd!==undefined)fs.closeSync(fd);}
80
+ }
81
+ const readyPath=p=>path.join(path.dirname(p),'writer-ready.json');
82
+ const activeWriters=new Set();
83
+ function noJournal(p) {
84
+ try{fs.lstatSync(p+'-journal');}catch(error){if(error.code==='ENOENT')return;throw error;}
85
+ need(false,'retained_journal');
86
+ }
87
+ function databaseDigest(p,fd) {
88
+ const before=regular(p,64*1024);
89
+ need(sameInode(before,fs.fstatSync(fd)),'store_ownership');
90
+ const buffer=Buffer.alloc(before.size+1);let size=0;
91
+ while(size<buffer.length){const n=fs.readSync(fd,buffer,size,buffer.length-size,size);if(!n)break;size+=n;}
92
+ const bytes=buffer.subarray(0,size),after=fs.fstatSync(fd);
93
+ need(sameInode(before,fs.lstatSync(p)) && bytes.length===before.size && before.size===after.size
94
+ && before.mtimeMs===after.mtimeMs && before.ctimeMs===after.ctimeMs,'store_ownership');
95
+ return createHash('sha256').update(bytes).digest('hex');
96
+ }
97
+ function readiness(p,fd) {
98
+ const marker=readyPath(p),inode=regular(marker,1024),v=readState(marker);
99
+ shape(v,['version','protocol','databaseDigest']);
100
+ need(Object.keys(v).join('|')==='version|protocol|databaseDigest'
101
+ && v.version===1 && v.protocol==='cm-writer-ready','store_version');hex(v.databaseDigest);
102
+ need(v.databaseDigest===databaseDigest(p,fd),'store_version');
103
+ need(sameInode(inode,fs.lstatSync(marker)),'store_ownership');return inode;
104
+ }
105
+ function publishReadiness(p,inspectionFd) {
106
+ noJournal(p);
107
+ const bytes=Buffer.from(JSON.stringify({version:1,protocol:'cm-writer-ready',databaseDigest:databaseDigest(p,inspectionFd)})+'\n');
108
+ const fd=fs.openSync(readyPath(p),fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,0o600);
109
+ try{fs.writeFileSync(fd,bytes);fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
110
+ syncPath(path.dirname(p));
111
+ }
112
+ function acquireWriter(p,create) {
113
+ let created=false,db,certificate,inspectionFd,key;
114
+ const release=()=>{
115
+ try{if(db?.isOpen)db.close();}finally{
116
+ if(inspectionFd!==undefined){fs.closeSync(inspectionFd);inspectionFd=undefined;}
117
+ if(key!==undefined){activeWriters.delete(key);key=undefined;}
118
+ }
119
+ };
120
+ try {
121
+ if(!fs.existsSync(p)) {
122
+ need(create && fs.readdirSync(path.dirname(p)).length===0,'store_missing');
123
+ try{const fd=fs.openSync(p,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,0o600);
124
+ created=true;try{fs.fsyncSync(fd);}finally{fs.closeSync(fd);}syncPath(path.dirname(p));
125
+ }catch(error){if(error.code!=='EEXIST')throw error;}
126
+ }
127
+ const inode=regular(p,64*1024);need(created || inode.size>0,'store_incomplete');
128
+ const candidateKey=`${inode.dev}:${inode.ino}`;need(!activeWriters.has(candidateKey),'store_busy');
129
+ key=candidateKey;activeWriters.add(key);
130
+ // POSIX close(any fd on this DB) drops ALL process locks. Keep this one
131
+ // inspection descriptor until AFTER SQLite closes, including failure paths.
132
+ inspectionFd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
133
+ noJournal(p);
134
+ if(!created) {
135
+ // An O_EXCL loser must NEVER open an incompletely initialized native DB.
136
+ certificate=readiness(p,inspectionFd);fs.fsyncSync(inspectionFd);syncPath(readyPath(p));syncPath(path.dirname(p));
137
+ }
138
+ db=new DatabaseSync(p,{timeout:0,allowExtension:false});
139
+ db.exec('PRAGMA busy_timeout=0; PRAGMA trusted_schema=OFF; PRAGMA synchronous=EXTRA');
140
+ // F_FULLFSYNC is macOS-specific. Linux keeps SQLite's native sync plus the
141
+ // mandatory file/parent fsync below; unsupported sync must still fail closed.
142
+ if(process.platform==='darwin')db.exec('PRAGMA fullfsync=ON');
143
+ if(created) {
144
+ db.exec(`BEGIN IMMEDIATE; PRAGMA application_id=${APP_ID}; PRAGMA user_version=1;
145
+ ${PROTOCOL_SQL}; INSERT INTO protocol VALUES(1); COMMIT;`);
146
+ fs.fsyncSync(inspectionFd);syncPath(path.dirname(p));
147
+ }
148
+ db.exec('BEGIN IMMEDIATE');
149
+ need(db.prepare('PRAGMA application_id').get().application_id===APP_ID
150
+ && db.prepare('PRAGMA user_version').get().user_version===1,'store_version');
151
+ need(db.prepare('PRAGMA journal_mode').get().journal_mode==='delete','store_version');
152
+ // No filtered internal objects or schema-compatible guesses in this v1 protocol.
153
+ const tables=db.prepare('SELECT name,type,tbl_name,sql FROM sqlite_master').all();
154
+ need(tables.length===1 && tables[0].name==='protocol' && tables[0].type==='table'
155
+ && tables[0].tbl_name==='protocol' && tables[0].sql===PROTOCOL_SQL,'store_version');
156
+ const rows=db.prepare('SELECT version FROM protocol').all();need(rows.length===1 && rows[0].version===1,'store_version');
157
+ if(created)publishReadiness(p,inspectionFd);
158
+ const current=readiness(p,inspectionFd);
159
+ need(!certificate || sameInode(certificate,current),'store_ownership');
160
+ return {db,inode:regular(p,64*1024),certificate:current,inspectionFd,release};
161
+ }catch(error){release();if(error.errcode===5)need(false,'store_busy');throw error;}
162
+ }
163
+ export function openExecutionStore(input) {
164
+ const options=json(input);shape(options,['specsRoot','identity','fingerprints','create']);
165
+ shape(options.identity,['repositoryId','runId']);Object.values(options.identity).forEach(id);
166
+ shape(options.fingerprints,['workflow','config','inputs']);Object.values(options.fingerprints).forEach(hex);
167
+ need(typeof options.create==='boolean' && typeof options.specsRoot==='string'
168
+ && path.isAbsolute(options.specsRoot) && path.resolve(options.specsRoot)===options.specsRoot,'unsupported_path');
169
+ need(isSupportedExecutionPlatform(),'unsupported_platform');
170
+ need(!fs.lstatSync(options.specsRoot).isSymbolicLink(),'unsupported_path');
171
+ const root=fs.realpathSync(options.specsRoot);directory(root,false,false);
172
+ const reviews=path.join(root,'.reviews'),execution=path.join(reviews,'.execution');
173
+ directory(reviews,options.create,false);directory(execution,options.create);
174
+ const lockPath=path.join(execution,'writer.sqlite'),{db,inode,certificate,inspectionFd,release}=acquireWriter(lockPath,options.create);
175
+ let closed=false,poisoned=false,dir;
176
+ const close=()=>{if(!closed){closed=true;release();}};
177
+ try {
178
+ dir=path.join(execution,options.identity.runId);
179
+ if(options.create) {need(!fs.existsSync(dir),'store_exists');fs.mkdirSync(dir,{mode:0o700});syncPath(dir);syncPath(execution);}
180
+ const directories=[reviews,execution,dir].map(p=>({p,inode:directory(p,false,p!==reviews)}));
181
+ const guard=()=>{
182
+ need(!closed,'store_closed');need(!poisoned,'store_poisoned');
183
+ for(const d of directories)need(sameInode(d.inode,directory(d.p,false,d.p!==reviews)),'snapshot_changed');
184
+ need(db.isOpen && db.isTransaction && sameInode(inode,regular(lockPath,64*1024)),'store_ownership');
185
+ need(sameInode(certificate,readiness(lockPath,inspectionFd)),'store_ownership');noJournal(lockPath);
186
+ };
187
+ const statePath=path.join(dir,'state.json');
188
+ if(options.create)atomicState(dir,seal({version:1,identity:options.identity,fingerprints:options.fingerprints,records:[]}));
189
+ const snapshot=()=>{
190
+ need(!closed,'store_closed');need(!poisoned,'store_poisoned');
191
+ try{guard();runBytes(dir);return validateState(readState(statePath),options);}catch(error){poisoned=true;throw error;}
192
+ };
193
+ snapshot();
194
+ const append=input=>{
195
+ need(!closed,'store_closed');need(!poisoned,'store_poisoned');
196
+ const v=json(input,MiB+1024);shape(v,['id','kind','payload','expectedRevision']);
197
+ id(v.id);hex(v.expectedRevision);need(kinds.has(v.kind));json(v.payload,MiB);
198
+ const current=snapshot(),existing=current.records.find(r=>r.id===v.id);
199
+ if(existing){need(existing.kind===v.kind && digest(existing.payload)===digest(v.payload),'record_conflict');return current;}
200
+ need(v.expectedRevision===current.revision,'revision_mismatch');
201
+ need(current.records.length<1024,'limit_exceeded');
202
+ const record={version:1,seq:current.records.length+1,id:v.id,kind:v.kind,payload:v.payload,
203
+ previousDigest:current.records.at(-1)?.digest??null};
204
+ const {revision:oldRevision,...data}=current;
205
+ const next=validateState(seal({...data,records:[...current.records,{...record,digest:digest(record)}]}),options);
206
+ try{guard();atomicState(dir,next);}catch(error){poisoned=true;throw error;}
207
+ return next;
208
+ };
209
+ return Object.freeze({snapshot,append,close});
210
+ }catch(error){close();throw error;}
211
+ }
@@ -0,0 +1,40 @@
1
+ // Content composition only. This does not authenticate a review or clear a gate.
2
+ import {captureReviewBaseline,readReviewBaseline,readReviewPackage} from './review-package.mjs';
3
+ import {digest,json,need} from './effect-contract.mjs';
4
+
5
+ const inventoryFile=({contentBase64,...metadata})=>metadata;
6
+ const sameFile=(a,b)=>digest(a===null?null:inventoryFile(a))===digest(b===null?null:inventoryFile(b));
7
+
8
+ export function composeFixCode({baseline,parentPackage,fixPackages}){
9
+ const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
10
+ need(Array.isArray(fixPackages)&&fixPackages.length>0&&fixPackages.length<=2,'fix_chain_invalid');
11
+ const fixes=fixPackages.map(readReviewPackage);
12
+ need(parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
13
+ &&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
14
+ for(const fix of fixes)need(fix.rootDigest===parent.rootDigest&&fix.identity.repositoryId===parent.identity.repositoryId
15
+ &&fix.identity.runId!==parent.identity.runId,'fix_parent_binding_mismatch');
16
+ need(new Set(fixes.map(fix=>fix.identity.runId)).size===fixes.length,'fix_chain_invalid');
17
+ const expected=new Map(base.files.map(file=>[file.path,file]));
18
+ const apply=pkg=>{
19
+ for(const change of pkg.changes){
20
+ need(sameFile(expected.get(change.path)??null,change.before),'fix_before_mismatch');
21
+ if(change.after===null)expected.delete(change.path);else expected.set(change.path,change.after);
22
+ }
23
+ };
24
+ apply(parent);fixes.forEach(apply);
25
+ const files=[...expected.values()].sort((a,b)=>a.path<b.path?-1:a.path>b.path?1:0);
26
+ // Use the same canonical inventory for live association and journal replay.
27
+ return {base,parent,fixes,files:base.version===1?files:files.map(inventoryFile)};
28
+ }
29
+
30
+ export function inspectFixCodeAssociation({root,specsRoot,baseline,parentPackage,fixPackage,fixPackages}){
31
+ const {base,parent,fixes,files}=composeFixCode({baseline,parentPackage,fixPackages:fixPackages??[fixPackage]});
32
+ const current=captureReviewBaseline({root,...(specsRoot===undefined?{}:{specsRoot}),identity:parent.identity,version:base.version,
33
+ ...(base.codeProjectPaths?{codeProjectPaths:base.codeProjectPaths}:{}),
34
+ scope:[...new Set([...parent.scope,...fixes.flatMap(fix=>fix.scope)])],requirements:base.requirements});
35
+ need(current.rootDigest===base.rootDigest,'fix_parent_binding_mismatch');
36
+ const compared=base.version===1?current.files:current.files.map(inventoryFile);
37
+ need(digest(compared)===digest(files),'fix_current_code_unexplained');
38
+ return json({version:1,kind:'cm-fix-code-association',parentPackageDigest:parent.packageDigest,
39
+ fixPackageDigest:fixes.at(-1).packageDigest,currentFilesDigest:digest(compared)});
40
+ }
@@ -0,0 +1,25 @@
1
+ // Pure S2b comparison only. This is not the Python gate and cannot write tasks.
2
+ import { digest,need,shape,id,json,validIdentity } from './effect-contract.mjs';
3
+ import { reviewResult } from './review-runner.mjs';
4
+ export function checkCompletion({receipt,registered,execution,reviewPackage,identity}) {
5
+ const r=json(receipt);validIdentity(identity);
6
+ shape(r,['version','kind','id','identity','packageDigest','baseIdentity','artifactDigest',
7
+ 'requirementsDigest','checksDigest','execution','route','result','receiptDigest']);
8
+ need(r.version===1 && r.kind==='cm-review-receipt','receipt_version');
9
+ need(registered!==undefined && digest(r)===digest(json(registered)),'unregistered_receipt');
10
+ const {receiptDigest,...data}=r;need(digest(data)===receiptDigest,'invalid_receipt');
11
+ need(digest(r.identity)===digest(identity) && digest(reviewPackage.identity)===digest(identity),'receipt_identity');
12
+ for(const field of ['packageDigest','baseIdentity','artifactDigest','requirementsDigest','checksDigest'])
13
+ need(r[field]===reviewPackage[field],'receipt_package_mismatch');
14
+ const executionKeys=['invocationId','contextId','provider','requestedModel','effectiveModel','channel','started','terminal','requestDigest','resultDigest'];
15
+ const hostAuthorized=r.execution?.channel==='host-authorized';
16
+ shape(r.execution,[...executionKeys,...(hostAuthorized?['providerThreadId']:[])]);
17
+ need(['fixture','host-authorized'].includes(r.execution.channel),'execution_mismatch');
18
+ if(hostAuthorized)id(r.execution.providerThreadId);
19
+ need(r.id===r.execution.invocationId && r.execution.started===true && r.execution.terminal==='succeeded'
20
+ && digest(r.execution)===digest(json(execution)),'execution_mismatch');
21
+ const result=reviewResult(r.result,reviewPackage);
22
+ need(r.execution.resultDigest===digest(result) && result.verdict==='approved','review_not_approved');
23
+ need(reviewPackage.checks.length>0 && reviewPackage.checks.every(c=>c.outcome==='passed' && c.exitCode===0),'checks_not_passed');
24
+ return json({outcome:'eligible',receiptDigest});
25
+ }
@@ -0,0 +1,170 @@
1
+ // Approved 0.bootstrap instruction task, inside the original develop effect.
2
+ // A factory capability owns only init's fixed paths; never a developer grant.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import {createHash} from 'node:crypto';
6
+ import {cmInitRuleTargets,generateCmInitDraft,validateCmInitSelection} from '../cm-init/draft-generation.mjs';
7
+ import {inspectCmInitDraft,readCmInitSource} from '../cm-init/draft-inspection.mjs';
8
+ import {replaceSessionFile} from '../cm-prd/session.mjs';
9
+ import {readReviewSourceFiles,readReviewBaseline} from './review-package.mjs';
10
+ import {inspectCmAiBootstrapTask} from './cm-ai-admission.mjs';
11
+ import {readProjectInstructionContext,createCmAiTaskLearningApplication,createCmAiTaskLearningRetrospective} from './cm-ai-context-refresh.mjs';
12
+ import {validateDeveloperScope,readDeveloperRequest} from './developer-adapter.mjs';
13
+ import {digest,json,shape,need,freeze,validIdentity,hex,requestFor,terminalFor} from './effect-contract.mjs';
14
+
15
+ const capabilities=new WeakMap();
16
+ const categories=['commands','globs','file_references','constraint_preservation','rule_applicability'];
17
+ const sha=bytes=>bytes===null?null:createHash('sha256').update(bytes).digest('hex');
18
+ const same=(a,b)=>need(digest(a)===digest(b),'bootstrap_binding_changed');
19
+ const canonical=root=>need(typeof root==='string'&&path.isAbsolute(root)&&fs.realpathSync(root)===root
20
+ &&fs.lstatSync(root).isDirectory(),'bootstrap_root_invalid');
21
+
22
+ export function readBootstrapEvidence(raw,configuration,identity){
23
+ const value=json(raw);
24
+ shape(value,['version','workflow','phase','identity','invocationId','configurationDigest','files','contextFiles','evidenceDigest']);
25
+ need(value.version===1&&value.workflow==='cm-ai'&&value.phase==='bootstrap_instructions','bootstrap_evidence_invalid');
26
+ validIdentity(value.identity);same(value.identity,identity);same(value.configurationDigest,digest(configuration));
27
+ need(typeof value.invocationId==='string'&&value.invocationId.length>0,'bootstrap_evidence_invalid');
28
+ need(Array.isArray(value.files)&&value.files.length===configuration.instructionPaths.length,'bootstrap_evidence_invalid');
29
+ same(value.files.map(file=>file.path),configuration.instructionPaths);
30
+ for(const file of value.files){shape(file,['path','beforeSha256','afterSha256']);
31
+ if(file.beforeSha256!==null)hex(file.beforeSha256);hex(file.afterSha256);}
32
+ need(Array.isArray(value.contextFiles),'bootstrap_evidence_invalid');
33
+ for(const file of value.contextFiles){shape(file,['scope','path','sha256']);need(file.scope==='project','bootstrap_evidence_invalid');hex(file.sha256);}
34
+ for(const file of value.files)need(value.contextFiles.some(item=>item.path===file.path&&item.sha256===file.afterSha256),'bootstrap_context_missing');
35
+ const {evidenceDigest,...body}=value;same(evidenceDigest,digest(body));return value;
36
+ }
37
+
38
+ // Journal validation consumes data only. Callback provenance is checked at
39
+ // construction by bootstrapConfiguration, never inferred from this descriptor.
40
+ export function validateBootstrapReviewPackage(pkg,evidence,configuration,identity,writeback){
41
+ const value=readBootstrapEvidence(evidence,configuration,identity);
42
+ for(const file of value.files){
43
+ const change=pkg.changes.find(item=>item.path===file.path);
44
+ const expected=file.path==='AGENTS.md'&&writeback.outcome==='written'?writeback.agentsFile.sha256:file.afterSha256;
45
+ need(change?.after?.sha256===expected&&pkg.scope.includes(file.path),'bootstrap_review_mismatch');
46
+ }
47
+ return value;
48
+ }
49
+
50
+ export function bootstrapConfiguration(capability,{root,identity,scope,feature}){
51
+ const configuration=capabilities.get(capability);need(configuration,'bootstrap_capability_required');
52
+ same(configuration.codeProject,root);same(configuration.identity, {...identity,attempt:1});
53
+ same(configuration.scope,scope);need(feature==='0.bootstrap','bootstrap_task_required');return configuration;
54
+ }
55
+
56
+ export function createHostBootstrap({definition,workflowRoot,selection,bridge,allowWrite}){
57
+ const data=json(definition);validIdentity(data.identity);need(data.identity.attempt===1&&data.feature==='0.bootstrap','bootstrap_task_required');
58
+ canonical(data.codeProject);canonical(data.specsDir);canonical(workflowRoot);
59
+ need(typeof bridge?.call==='function'&&typeof allowWrite==='boolean','bootstrap_configuration_invalid');
60
+ // Construction is non-writing and may occur during resume. Only the runner's
61
+ // validated original empty baseline permits an in-progress scaffold below.
62
+ const selected=inspectCmAiBootstrapTask({specsDir:data.specsDir,codeProject:data.codeProject,taskId:data.identity.taskId},true);
63
+ const mode=selected.mode,choice=mode==='scaffold'?null:validateCmInitSelection(selection);
64
+ const instructionPaths=mode==='scaffold'?[]:cmInitRuleTargets(choice);
65
+ need(Array.isArray(data.scope)&&new Set(data.scope).size===data.scope.length
66
+ &&instructionPaths.every(file=>data.scope.includes(file)),'bootstrap_scope_required');
67
+ const businessScope=data.scope.filter(file=>!instructionPaths.includes(file));
68
+ if(businessScope.length)validateDeveloperScope(businessScope);
69
+ for(const file of instructionPaths){const target=path.join(data.codeProject,file);
70
+ need(target!==data.specsDir&&!target.startsWith(data.specsDir+path.sep),'bootstrap_specs_overlap');}
71
+ const bootstrapRequirements={specsRoot:data.specsDir,feature:data.feature,
72
+ files:readReviewSourceFiles(data.specsDir,['0.bootstrap/requirements.md','0.bootstrap/design.md'])};
73
+ const policyDigest=digest(instructionPaths.slice(2).map(file=>{
74
+ const relative='templates/rules/'+path.basename(file);return [relative,sha(readCmInitSource(workflowRoot,relative))];}));
75
+ const configuration=json({version:1,mode,codeProject:data.codeProject,specsDir:data.specsDir,feature:data.feature,
76
+ identity:data.identity,scope:data.scope,businessScope,instructionPaths,workflowRoot,selection:choice,policyDigest,bootstrapRequirements});
77
+ const used=new Set();
78
+ const admission=baseline=>{
79
+ const original=readReviewBaseline(baseline);
80
+ same(original.bootstrapRequirements,bootstrapRequirements);
81
+ if(mode==='scaffold')need(original.files.length===0,'bootstrap_original_not_empty');
82
+ return inspectCmAiBootstrapTask({specsDir:data.specsDir,codeProject:data.codeProject,taskId:data.identity.taskId},mode==='scaffold').admission;
83
+ };
84
+ const capability={configuration,inspectAdmission:admission,
85
+ assertWriteAuthorized(){need(allowWrite,'bootstrap_write_authorization_required');},
86
+ async run(request,control,develop,{previous=null,previousWriteback=null,baseline}={}){
87
+ need(allowWrite,'bootstrap_write_authorization_required');
88
+ need(!control.signal.aborted,'cancelled');
89
+ same({...request.identity,attempt:1},data.identity);same(request.payload.scope,data.scope);
90
+ need(!used.has(request.invocationId),'bootstrap_dispatch_unknown');
91
+ const currentAdmission=admission(baseline);
92
+ need(currentAdmission.nextTask?.feature===data.feature&&currentAdmission.nextTask.id===request.identity.taskId,'bootstrap_task_required');
93
+ const prior=previous===null?null:readBootstrapEvidence(previous,configuration,{...request.identity,attempt:request.identity.attempt-1});
94
+ if(mode==='instructions')need(request.identity.attempt===1?prior===null:prior!==null,'bootstrap_prior_evidence_required');
95
+ const originals=instructionPaths.map(file=>({path:file,bytes:readCmInitSource(data.codeProject,file)}));
96
+ for(const file of originals){
97
+ const expected=file.path==='AGENTS.md'&&prior!==null&&previousWriteback?.outcome==='written'
98
+ ?previousWriteback.agentsFile.sha256:prior?.files.find(item=>item.path===file.path).afterSha256??null;
99
+ need(sha(file.bytes)===expected,'bootstrap_instruction_conflict');
100
+ }
101
+ used.add(request.invocationId);
102
+ const current=()=>{
103
+ canonical(data.codeProject);
104
+ for(const file of originals)need(sha(readCmInitSource(data.codeProject,file.path))===sha(file.bytes),'bootstrap_instruction_conflict');
105
+ };
106
+ let response=null;
107
+ if(businessScope.length){
108
+ const {requestDigest,...body}=request;
109
+ const scoped=requestFor({...body,payload:{...request.payload,scope:businessScope,
110
+ requirements:[...request.payload.requirements,...bootstrapRequirements.files]}});
111
+ readDeveloperRequest(scoped,request.provider);
112
+ response=terminalFor(await develop(scoped,control),scoped);
113
+ if(response.status!=='succeeded')return terminalFor(response,request);
114
+ }
115
+ if(mode==='scaffold'){
116
+ need(response!==null,'bootstrap_business_scope_required');
117
+ // The scaffold still cannot create project instructions. Native workers
118
+ // enforce this; the host also rejects an inconsistent synthetic result.
119
+ need(readProjectInstructionContext(data.codeProject).length===0,'bootstrap_instruction_conflict');
120
+ return terminalFor(response,request);
121
+ }
122
+ current();need(!control.signal.aborted,'cancelled');
123
+ const draft=await generateCmInitDraft({project:data.codeProject,workflowRoot,selection:choice},{signal:control.signal,
124
+ generate:(payload,signal)=>bridge.call('init_generate',{...payload,bootstrap:{identity:request.identity,
125
+ invocationId:request.invocationId,requirements:[...request.payload.requirements,...bootstrapRequirements.files],
126
+ priorReview:request.payload.priorReview}},signal)});
127
+ need(draft.status==='draft_generated'&&draft.inspection.status==='structurally_checked','bootstrap_generation_blocked');
128
+ const verified=json(await bridge.call('init_verify',{project:data.codeProject,selection:choice,documents:draft.documents,
129
+ inspection:draft.inspection,categories,learningInput:request.payload.learningInput,
130
+ instructions:'Verify every generated instruction against the approved bootstrap selection and current project. Do not write files, install or dispatch providers. Return {checks,constraintChanges,application,retrospective}; checks use status/evidence. Application and retrospective use the original developer Learning response fields. Unverified assertions block. This is host verification, not independent Review.'},control.signal));
131
+ shape(verified,['checks','constraintChanges','application','retrospective']);shape(verified.checks,categories);
132
+ for(const check of Object.values(verified.checks)){shape(check,['status','evidence']);
133
+ need(['verified','not_applicable'].includes(check.status)&&typeof check.evidence==='string'&&check.evidence.trim(),'bootstrap_verification_blocked');}
134
+ need(Array.isArray(verified.constraintChanges)&&verified.constraintChanges.length===0,'bootstrap_constraint_confirmation_required');
135
+ const learning=request.payload.learningInput;
136
+ need(learning?.feature==='0.bootstrap','bootstrap_learning_required');
137
+ shape(verified.application,['status','note']);shape(verified.retrospective,['status','candidates','reason']);
138
+ const binding={feature:learning.feature,identity:request.identity,learningDigest:learning.learningDigest};
139
+ const application=createCmAiTaskLearningApplication({...binding,...verified.application});
140
+ const retrospective=createCmAiTaskLearningRetrospective({...binding,...verified.retrospective});
141
+ current();need(!control.signal.aborted,'cancelled');
142
+ same(inspectCmInitDraft({project:data.codeProject,documents:draft.documents}).changes,draft.inspection.changes);
143
+ // All targets are prechecked before the first write. Interruption stays in
144
+ // the runner's original unknown develop effect, never an automatic retry.
145
+ for(const document of draft.documents){
146
+ need(!control.signal.aborted,'cancelled');canonical(data.codeProject);
147
+ let parent=data.codeProject;
148
+ for(const part of document.path.split('/').slice(0,-1)){
149
+ parent=path.join(parent,part);try{fs.mkdirSync(parent,{mode:0o700});}catch(error){if(error.code!=='EEXIST')throw error;}
150
+ canonical(parent);
151
+ }
152
+ const before=originals.find(file=>file.path===document.path).bytes;
153
+ replaceSessionFile(data.codeProject,document.path,before===null?null:new TextDecoder('utf8',{fatal:true}).decode(before),document.content);
154
+ }
155
+ const after=inspectCmInitDraft({project:data.codeProject,documents:draft.documents});
156
+ need(after.status==='structurally_checked'&&after.changes.every(file=>file.action==='unchanged'),'bootstrap_write_unknown');
157
+ const contextFiles=readProjectInstructionContext(data.codeProject).map(({content,...file})=>file);
158
+ // Optional module rules must be reachable through the generated entry.
159
+ const evidenceBody={version:1,workflow:'cm-ai',phase:'bootstrap_instructions',identity:request.identity,
160
+ invocationId:request.invocationId,configurationDigest:digest(configuration),
161
+ files:instructionPaths.map(file=>{const change=draft.inspection.changes.find(item=>item.path===file);
162
+ return {path:file,beforeSha256:change.beforeSha256,afterSha256:change.afterSha256};}),contextFiles};
163
+ const bootstrap=readBootstrapEvidence({...evidenceBody,evidenceDigest:digest(evidenceBody)},configuration,request.identity);
164
+ return terminalFor({version:1,invocationId:request.invocationId,contextId:request.contextId,provider:request.provider,
165
+ effectiveModel:response?.effectiveModel??'host-bootstrap',status:'succeeded',accepted:true,
166
+ ...(response?.providerThreadId?{providerThreadId:response.providerThreadId}:{}),
167
+ result:{outcome:'implemented',application,retrospective,bootstrap}},request);
168
+ }};
169
+ freeze(capability);capabilities.set(capability,configuration);return capability;
170
+ }
@@ -0,0 +1,89 @@
1
+ // Runs host-configured, already-authorized project checks. Commands may execute
2
+ // project code; specsRoot opts into Codex's native sandbox for that subprocess.
3
+ // Without specsRoot this preserves the existing direct host-check behavior.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import {spawn} from 'node:child_process';
7
+ import {types} from 'node:util';
8
+ import {cleanEnvironment,specsPermissionArgs} from './codex-config.mjs';
9
+ import {json,shape,need,id,text,validCallTimeout,validIdentity} from './effect-contract.mjs';
10
+
11
+ export function createHostCheck({cwd,commands,timeoutMs=60000,specsRoot=null,outputIncludes=null,onOutput=null}){
12
+ need(path.isAbsolute(cwd)&&fs.realpathSync(cwd)===cwd&&fs.statSync(cwd).isDirectory());
13
+ validCallTimeout(timeoutMs);
14
+ need(onOutput===null||typeof onOutput==='function');
15
+ if(outputIncludes!==null){text(outputIncludes);need(Buffer.byteLength(outputIncludes)<=1000&&!outputIncludes.includes('\0'));}
16
+ const signature=outputIncludes===null?null:Buffer.from(outputIncludes);
17
+ const selected=json(commands,32*1024),ids=new Set();
18
+ need(Array.isArray(selected)&&selected.length>0&&selected.length<=32);
19
+ for(const item of selected){
20
+ shape(item,['id','command']);id(item.id);need(!ids.has(item.id));ids.add(item.id);
21
+ need(Array.isArray(item.command)&&item.command.length>0);
22
+ for(const arg of item.command){text(arg);need(!arg.includes('\0'));}
23
+ }
24
+ return async(raw,{signal})=>{
25
+ shape(raw,['identity']);validIdentity(raw.identity);
26
+ need(process.platform!=='win32','process_tree_unsupported');
27
+ const results=[];
28
+ for(const item of selected){
29
+ let signatureMatched=false;
30
+ need(!signal.aborted,'cancelled');
31
+ const result=await new Promise(resolve=>{
32
+ let child;
33
+ try{
34
+ const protectedArgs=specsRoot===null?null:specsPermissionArgs({cwd,specsRoot});
35
+ child=spawn(protectedArgs===null?item.command[0]:'codex',protectedArgs===null?item.command.slice(1):
36
+ ['sandbox','-P','cm-specs','--include-managed-config','-C',cwd,...protectedArgs,'--',...item.command],{cwd,env:cleanEnvironment(),
37
+ shell:false,detached:true,stdio:['ignore','pipe','pipe']});
38
+ }
39
+ catch{resolve({outcome:'unavailable',exitCode:null,evidence:'host check: spawn_failed'});return;}
40
+ let failure=null,cleanup,bytes=0;
41
+ const kill=name=>{
42
+ if(!Number.isInteger(child.pid)||child.pid<=0)return false;
43
+ try{process.kill(-child.pid,name);return true;}
44
+ catch(error){if(error.code!=='ESRCH')failure??='cleanup_failed';return false;}
45
+ };
46
+ const clean=()=>cleanup??=(kill('SIGTERM')
47
+ ?new Promise(done=>setTimeout(()=>{kill('SIGKILL');done();},1000)):Promise.resolve());
48
+ const stop=reason=>{failure??=reason;clean();};
49
+ const abort=()=>stop('cancelled');
50
+ signal.addEventListener('abort',abort,{once:true});
51
+ const timer=setTimeout(()=>stop('timeout'),timeoutMs);
52
+ if(signal.aborted)abort();
53
+ for(const [streamName,stream] of [['stdout',child.stdout],['stderr',child.stderr]]){
54
+ let tail=Buffer.alloc(0);
55
+ stream.on('data',chunk=>{
56
+ bytes+=chunk.length;if(bytes>4*1024*1024){stop('output_limit');return;}
57
+ if(onOutput){
58
+ try{
59
+ const returned=onOutput({stream:streamName,chunk:Buffer.from(chunk)});
60
+ if(types.isPromise(returned))Promise.prototype.then.call(returned,()=>{},()=>{});
61
+ need(returned===undefined);
62
+ }
63
+ catch{stop('output_capture_failed');return;}
64
+ }
65
+ if(signature&&!signatureMatched){
66
+ const joined=Buffer.concat([tail,chunk]);signatureMatched=joined.includes(signature);
67
+ tail=joined.subarray(Math.max(0,joined.length-signature.length+1));
68
+ }
69
+ });
70
+ stream.on('error',()=>stop('output_read_failed'));
71
+ }
72
+ child.once('error',()=>{failure??='spawn_failed';});
73
+ child.once('exit',clean);
74
+ child.once('close',async(code,exitSignal)=>{
75
+ clearTimeout(timer);signal.removeEventListener('abort',abort);await clean();
76
+ // Keep evidence stable across repeated checks. Raw output can contain
77
+ // credentials and nondeterministic timing; do not put it in review data.
78
+ if(failure||exitSignal||!Number.isInteger(code))resolve({outcome:'unavailable',exitCode:null,
79
+ evidence:`host check: ${failure??'signal_exit'}`});
80
+ else resolve({outcome:code===0?'passed':'failed',exitCode:code,evidence:`host check exited ${code}`});
81
+ });
82
+ });
83
+ need(!signal.aborted,'cancelled');
84
+ results.push({...item,...result,...(signature?{signatureMatched}:{})});
85
+ if(result.outcome!=='passed')break;
86
+ }
87
+ return json(results);
88
+ };
89
+ }