@aibyzero/cm-workflow 0.17.1 → 0.19.0

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/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +23 -0
  3. package/CHANGELOG.md +242 -0
  4. package/README.md +20 -3
  5. package/THIRD_PARTY_NOTICES.md +13 -0
  6. package/VERSION +1 -1
  7. package/compat/claude-commands/cm-challenge.md +3 -0
  8. package/docs/architecture.md +11 -0
  9. package/docs/cm-control-policy-v2.md +127 -9
  10. package/docs/installation.md +310 -4
  11. package/docs/js-workflow-control.md +150 -15
  12. package/docs/live-evidence-drivers.md +28 -4
  13. package/docs/out-of-scope/README.md +25 -0
  14. package/docs/out-of-scope/background-supervisor.md +32 -0
  15. package/docs/reviewed-integration.md +48 -0
  16. package/docs/user-guide.md +50 -21
  17. package/install-codex.sh +331 -18
  18. package/install.ps1 +28 -2
  19. package/install.sh +321 -17
  20. package/package.json +2 -1
  21. package/runtime/js/autonomy.mjs +152 -0
  22. package/runtime/js/cm-ai/batch-location.mjs +55 -0
  23. package/runtime/js/cm-ai/batch-plan.mjs +242 -0
  24. package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
  25. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
  26. package/runtime/js/cm-ai/claude-review-stream.mjs +83 -14
  27. package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
  28. package/runtime/js/cm-ai/cm-ai-admission.mjs +56 -17
  29. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
  30. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
  31. package/runtime/js/cm-ai/codex-config.mjs +6 -2
  32. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
  33. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  34. package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
  35. package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
  36. package/runtime/js/cm-ai/control-policy.mjs +21 -4
  37. package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
  38. package/runtime/js/cm-ai/drive-core.mjs +115 -11
  39. package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
  40. package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
  41. package/runtime/js/cm-ai/effect-contract.mjs +11 -2
  42. package/runtime/js/cm-ai/execution-policy.mjs +3 -1
  43. package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
  44. package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
  45. package/runtime/js/cm-ai/execution-store.mjs +60 -17
  46. package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
  47. package/runtime/js/cm-ai/host-check.mjs +11 -5
  48. package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
  49. package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
  50. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
  51. package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
  52. package/runtime/js/cm-ai/host-replay.mjs +148 -0
  53. package/runtime/js/cm-ai/host-session.mjs +1 -1
  54. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
  55. package/runtime/js/cm-ai/host.mjs +1 -1
  56. package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
  57. package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
  58. package/runtime/js/cm-ai/live-evidence.mjs +28 -6
  59. package/runtime/js/cm-ai/operator-guidance.mjs +9 -2
  60. package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
  61. package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
  62. package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
  63. package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
  64. package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
  65. package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
  66. package/runtime/js/cm-ai/review-package.mjs +79 -7
  67. package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
  68. package/runtime/js/cm-ai/review-presentation.mjs +177 -8
  69. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
  70. package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
  71. package/runtime/js/cm-ai/scope-revision.mjs +38 -0
  72. package/runtime/js/cm-ai/specification-material.mjs +2 -2
  73. package/runtime/js/cm-ai/task-runner.mjs +242 -39
  74. package/runtime/js/cm-ai/verification-auto.mjs +38 -0
  75. package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
  76. package/runtime/js/cm-ai/worker-claude.mjs +35 -13
  77. package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
  78. package/runtime/js/cm-ai/worker-codex.mjs +41 -7
  79. package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
  80. package/runtime/js/cm-fix/cause-package.mjs +46 -1
  81. package/runtime/js/cm-fix/command-correction.mjs +37 -0
  82. package/runtime/js/cm-fix/cooperative.mjs +12 -0
  83. package/runtime/js/cm-fix/dossier.mjs +8 -2
  84. package/runtime/js/cm-fix/execution.mjs +578 -100
  85. package/runtime/js/cm-fix/final-review.mjs +39 -8
  86. package/runtime/js/cm-fix/finish.mjs +15 -11
  87. package/runtime/js/cm-fix/host-review.mjs +65 -10
  88. package/runtime/js/cm-fix/host.mjs +35 -12
  89. package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
  90. package/runtime/js/cm-fix/metrics.mjs +18 -5
  91. package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
  92. package/runtime/js/cm-fix/regression.mjs +16 -7
  93. package/runtime/js/cm-fix/repair.mjs +29 -8
  94. package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
  95. package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
  96. package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
  97. package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
  98. package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
  99. package/runtime/js/cm-fix/review-verification.mjs +214 -0
  100. package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
  101. package/runtime/js/cm-fix/start.mjs +6 -3
  102. package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
  103. package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
  104. package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
  105. package/runtime/js/cm-prd/accepted-design.mjs +8 -0
  106. package/runtime/js/cm-prd/analysis.mjs +13 -9
  107. package/runtime/js/cm-prd/change.mjs +37 -16
  108. package/runtime/js/cm-prd/draft-save.mjs +13 -6
  109. package/runtime/js/cm-prd/draft.mjs +31 -3
  110. package/runtime/js/cm-prd/failed-correction.mjs +19 -3
  111. package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
  112. package/runtime/js/cm-prd/review-correction.mjs +6 -4
  113. package/runtime/js/cm-prd/review-disposition.mjs +7 -1
  114. package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
  115. package/runtime/js/cm-prd/self-check.mjs +125 -6
  116. package/runtime/js/cm-prd/session.mjs +30 -1
  117. package/runtime/js/cm-prd/summary.mjs +11 -5
  118. package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
  119. package/runtime/js/cm-prd/tree-digest.mjs +34 -0
  120. package/runtime/js/cm-prd/validation-reason.mjs +8 -4
  121. package/runtime/js/cm-security/scan.mjs +1 -1
  122. package/runtime/js/commander/decision.mjs +44 -0
  123. package/runtime/js/commander/dispatch-registry.mjs +110 -0
  124. package/runtime/js/commander/ledger.mjs +265 -0
  125. package/runtime/js/commander/preflight.mjs +107 -0
  126. package/runtime/js/notify-later.mjs +13 -0
  127. package/runtime/js/notify-send.mjs +6 -2
  128. package/runtime/js/notify.mjs +581 -65
  129. package/runtime/js/review-findings.mjs +38 -0
  130. package/runtime/js/session-boundary.mjs +56 -0
  131. package/runtime/js/session-handoff.mjs +68 -0
  132. package/runtime/js/spec-task-line.mjs +27 -13
  133. package/runtime/js/specs-status.mjs +5 -4
  134. package/runtime/js/task-scope.mjs +197 -0
  135. package/runtime/logging.md +6 -1
  136. package/runtime/model-efficiency.md +69 -10
  137. package/runtime/orchestration.md +3 -1
  138. package/runtime/project-learning.md +2 -0
  139. package/runtime/review.md +3 -2
  140. package/runtime/test-contract.md +1 -0
  141. package/scripts/ci-test-weights.json +3 -0
  142. package/scripts/cm-ai-admission.mjs +21 -7
  143. package/scripts/cm-ai-admission.test.mjs +171 -3
  144. package/scripts/cm-ai-batch-drive.mjs +79 -18
  145. package/scripts/cm-ai-batch-drive.test.mjs +169 -3
  146. package/scripts/cm-ai-batch-host.mjs +38 -9
  147. package/scripts/cm-ai-batch-host.test.mjs +6 -5
  148. package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
  149. package/scripts/cm-ai-batch-location.test.mjs +57 -0
  150. package/scripts/cm-ai-batch-plan.mjs +52 -0
  151. package/scripts/cm-ai-batch-plan.test.mjs +397 -0
  152. package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
  153. package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
  154. package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
  155. package/scripts/cm-ai-batch-run.mjs +471 -57
  156. package/scripts/cm-ai-batch-run.test.mjs +23 -4
  157. package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
  158. package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
  159. package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
  160. package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
  161. package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
  162. package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
  163. package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
  164. package/scripts/cm-ai-control-launch.test.mjs +21 -0
  165. package/scripts/cm-ai-control-policy.test.mjs +14 -0
  166. package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
  167. package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
  168. package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
  169. package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
  170. package/scripts/cm-ai-development-rework.test.mjs +423 -0
  171. package/scripts/cm-ai-drive.mjs +73 -17
  172. package/scripts/cm-ai-drive.test.mjs +34 -2
  173. package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
  174. package/scripts/cm-ai-host.mjs +60 -19
  175. package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
  176. package/scripts/cm-ai-integration-independence.test.mjs +23 -0
  177. package/scripts/cm-ai-integration-launch.test.mjs +240 -0
  178. package/scripts/cm-ai-integration-preview.mjs +41 -0
  179. package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
  180. package/scripts/cm-ai-nested-execution.test.mjs +29 -1
  181. package/scripts/cm-ai-operator-guidance.test.mjs +16 -1
  182. package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
  183. package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
  184. package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
  185. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
  186. package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
  187. package/scripts/cm-ai-review-failure.test.mjs +150 -5
  188. package/scripts/cm-ai-run.mjs +88 -21
  189. package/scripts/cm-ai-scope-revision.test.mjs +341 -0
  190. package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
  191. package/scripts/cm-ai-supersede.test.mjs +28 -0
  192. package/scripts/cm-ai-verification-auto.test.mjs +99 -0
  193. package/scripts/cm-announce-hook.mjs +35 -8
  194. package/scripts/cm-announce-hook.test.mjs +25 -0
  195. package/scripts/cm-autonomy.mjs +94 -0
  196. package/scripts/cm-autonomy.test.mjs +162 -0
  197. package/scripts/cm-challenge.test.mjs +61 -0
  198. package/scripts/cm-check-drive-files.mjs +1 -1
  199. package/scripts/cm-check-runtime.sh +60 -1
  200. package/scripts/cm-claude-developer-worker.test.mjs +56 -7
  201. package/scripts/cm-claude-install-layout.test.mjs +1 -1
  202. package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
  203. package/scripts/cm-claude-review-stream.test.mjs +13 -0
  204. package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
  205. package/scripts/cm-codex-developer-worker.test.mjs +120 -0
  206. package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
  207. package/scripts/cm-codex-prompt-input.test.mjs +153 -0
  208. package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
  209. package/scripts/cm-commander-ledger.test.mjs +260 -0
  210. package/scripts/cm-commander-p2.test.mjs +295 -0
  211. package/scripts/cm-commander-preflight.mjs +84 -0
  212. package/scripts/cm-commander.mjs +116 -0
  213. package/scripts/cm-config-lock.mjs +35 -0
  214. package/scripts/cm-controlled-correction.test.mjs +10 -1
  215. package/scripts/cm-developer-failure-code.test.mjs +62 -0
  216. package/scripts/cm-display-task-id.test.mjs +41 -0
  217. package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
  218. package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
  219. package/scripts/cm-external-batch-host.test.mjs +4 -3
  220. package/scripts/cm-external-process-cleanup.test.mjs +128 -0
  221. package/scripts/cm-external-qa-fix.test.mjs +89 -7
  222. package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
  223. package/scripts/cm-failover.mjs +48 -10
  224. package/scripts/cm-failover.test.mjs +46 -0
  225. package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
  226. package/scripts/cm-fix-command-correction.mjs +17 -0
  227. package/scripts/cm-fix-command-correction.test.mjs +211 -0
  228. package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
  229. package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
  230. package/scripts/cm-fix-drive.mjs +33 -5
  231. package/scripts/cm-fix-drive.test.mjs +49 -0
  232. package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
  233. package/scripts/cm-fix-host-review.test.mjs +21 -9
  234. package/scripts/cm-fix-host.mjs +26 -8
  235. package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
  236. package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
  237. package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
  238. package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
  239. package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
  240. package/scripts/cm-fix-review-preflight.mjs +24 -0
  241. package/scripts/cm-fix-review-storage.test.mjs +233 -0
  242. package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
  243. package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
  244. package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
  245. package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
  246. package/scripts/cm-fix-review-verification.test.mjs +146 -0
  247. package/scripts/cm-fix-revision-transport.test.mjs +81 -0
  248. package/scripts/cm-fix-source-correction.test.mjs +296 -0
  249. package/scripts/cm-fix-test-type-correction.mjs +18 -0
  250. package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
  251. package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
  252. package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
  253. package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
  254. package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
  255. package/scripts/cm-fix-verification-recovery.mjs +33 -0
  256. package/scripts/cm-host-qa-executor.test.mjs +77 -0
  257. package/scripts/cm-host-replay.test.mjs +176 -0
  258. package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
  259. package/scripts/cm-install-manifest.sh +351 -0
  260. package/scripts/cm-live-evidence.test.mjs +59 -1
  261. package/scripts/cm-log-event.mjs +61 -10
  262. package/scripts/cm-log-event.test.mjs +121 -1
  263. package/scripts/cm-matt-skills.mjs +576 -0
  264. package/scripts/cm-matt-skills.test.mjs +550 -0
  265. package/scripts/cm-notify-command.test.mjs +42 -10
  266. package/scripts/cm-notify.mjs +14 -10
  267. package/scripts/cm-notify.test.mjs +581 -59
  268. package/scripts/cm-patrol.mjs +4 -1
  269. package/scripts/cm-patrol.test.mjs +23 -5
  270. package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
  271. package/scripts/cm-prd-completion.test.mjs +56 -13
  272. package/scripts/cm-prd-design-phase.test.mjs +78 -8
  273. package/scripts/cm-prd-draft-save.test.mjs +12 -0
  274. package/scripts/cm-prd-draft.test.mjs +1 -1
  275. package/scripts/cm-prd-drive.mjs +13 -6
  276. package/scripts/cm-prd-drive.test.mjs +45 -1
  277. package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
  278. package/scripts/cm-prd-host.mjs +10 -5
  279. package/scripts/cm-prd-host.test.mjs +4 -2
  280. package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
  281. package/scripts/cm-prd-review-disposition.test.mjs +124 -8
  282. package/scripts/cm-prd-revision.test.mjs +1 -1
  283. package/scripts/cm-prd-self-check-revision.test.mjs +1 -1
  284. package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
  285. package/scripts/cm-prd-self-check.test.mjs +105 -5
  286. package/scripts/cm-prd-summary.test.mjs +24 -3
  287. package/scripts/cm-prd-task-grouping.test.mjs +6 -6
  288. package/scripts/cm-prd-tree-digest.test.mjs +74 -0
  289. package/scripts/cm-refactor-drive.mjs +2 -1
  290. package/scripts/cm-refactor-drive.test.mjs +9 -0
  291. package/scripts/cm-release-smoke.sh +1 -1
  292. package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
  293. package/scripts/cm-skill-hints-exam.mjs +149 -0
  294. package/scripts/cm-skill-hints-install.test.mjs +168 -0
  295. package/scripts/cm-skill-hints.exam.json +706 -0
  296. package/scripts/cm-skill-hints.json +119 -0
  297. package/scripts/cm-skill-hints.mjs +669 -0
  298. package/scripts/cm-skill-hints.test.mjs +831 -0
  299. package/scripts/cm-skill-judge.mjs +181 -0
  300. package/scripts/cm-skill-judge.test.mjs +255 -0
  301. package/scripts/cm-specs-status.test.mjs +4 -2
  302. package/scripts/cm-start-check.mjs +323 -0
  303. package/scripts/cm-start-check.test.mjs +406 -0
  304. package/scripts/cm-task-gate.mjs +150 -29
  305. package/scripts/cm-task-gate.test.mjs +73 -1
  306. package/scripts/cm-task-id-grammar.test.mjs +66 -0
  307. package/scripts/cm-task-scope.test.mjs +308 -0
  308. package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
  309. package/scripts/cm-upgrade-compat.test.mjs +239 -0
  310. package/scripts/cm-workflow-config.mjs +12 -2
  311. package/scripts/fixtures/fix-verification-claude.mjs +44 -0
  312. package/scripts/fixtures/reviewed-integration.mjs +202 -0
  313. package/scripts/scan-public-safety.py +1 -0
  314. package/scripts/session-boundary.test.mjs +170 -0
  315. package/scripts/test-npm-install.py +14 -3
  316. package/scripts/test-shell-compat.sh +2 -0
  317. package/scripts/validate-public-repo.py +4 -0
  318. package/scripts/validate-test-cases.mjs +3 -2
  319. package/skills/cm-ai/SKILL.md +5 -2
  320. package/skills/cm-ai/references/N3-execute-task.md +1 -1
  321. package/skills/cm-ai/references/N4-review.md +2 -1
  322. package/skills/cm-ai/references/N6-qa-eval.md +3 -1
  323. package/skills/cm-ai/references/N8-finish.md +22 -0
  324. package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
  325. package/skills/cm-ai/references/js-host-recovery.md +79 -3
  326. package/skills/cm-ai/references/js-host.md +82 -16
  327. package/skills/cm-challenge/SKILL.md +65 -0
  328. package/skills/cm-challenge/evals/README.md +18 -0
  329. package/skills/cm-challenge/evals/trigger-cases.json +20 -0
  330. package/skills/cm-challenge/evals/trigger-config.json +28 -0
  331. package/skills/cm-challenge/references/examples.md +15 -0
  332. package/skills/cm-check/SKILL.md +5 -0
  333. package/skills/cm-check/references/js-host.md +2 -0
  334. package/skills/cm-fix/SKILL.md +12 -3
  335. package/skills/cm-fix/references/command-correction.md +67 -0
  336. package/skills/cm-fix/references/isolated-review.md +54 -0
  337. package/skills/cm-fix/references/js-host.md +62 -2
  338. package/skills/cm-fix/references/test-type-correction.md +72 -0
  339. package/skills/cm-fix/references/verification-recovery.md +114 -0
  340. package/skills/cm-idea/SKILL.md +2 -0
  341. package/skills/cm-idea/references/js-host.md +2 -0
  342. package/skills/cm-notify/SKILL.md +2 -0
  343. package/skills/cm-prd/SKILL.md +14 -9
  344. package/skills/cm-prd/references/brownfield.md +8 -1
  345. package/skills/cm-prd/references/change-mode.md +8 -1
  346. package/skills/cm-prd/references/greenfield.md +4 -0
  347. package/skills/cm-prd/references/js-change-recovery.md +14 -0
  348. package/skills/cm-prd/references/js-host.md +4 -2
  349. package/skills/cm-prd/references/spec-self-check.md +5 -1
  350. package/skills/cm-refactor/SKILL.md +8 -0
  351. package/skills/cm-refactor/references/js-host.md +2 -0
  352. package/skills/cm-test/SKILL.md +4 -0
  353. package/templates/dashboard/dashboard.html +2 -2
  354. package/templates/pixel/cm-pixel.html +1 -1
  355. package/templates/pixel/cm-pixel.sh +1 -1
  356. package/templates/pixel/dev/template.html +1 -1
  357. package/templates/statusline/cm-statusline.sh +1 -1
@@ -0,0 +1,193 @@
1
+ // Real owner/driver and local checks; reviewer output is synthetic protocol
2
+ // evidence, never independent review of this implementation. No Codex sandbox.
3
+ import test from 'node:test';
4
+ import assert from 'node:assert/strict';
5
+ import fs from 'node:fs';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ import {spawn,spawnSync} from 'node:child_process';
9
+ import {fileURLToPath} from 'node:url';
10
+ import {buildManifest} from './cm-spec-manifest.mjs';
11
+ import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
12
+ import {digest,JOURNAL_PAYLOAD_LIMIT,developCheckpointReserve} from '../runtime/js/cm-ai/effect-contract.mjs';
13
+ import {readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
14
+ import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
15
+ import {readRunJournal,developPreview} from './cm-ai-drive.mjs';
16
+ const DRIVER=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
17
+ const HOST=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
18
+ const REVIEWER=fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url));
19
+ const developValue={outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
20
+ retrospective:{status:'no_new_lesson',candidates:[],reason:null}};
21
+ const policy={version:2,development:'conversation',bootstrap:'disabled',qa:'disabled',qaFix:'disabled'};
22
+ const size=value=>Buffer.byteLength(JSON.stringify(value??null));
23
+ const CONTENT='//'+'x'.repeat(594000)+'\n';
24
+ function fixture(t,{scope=['target.mjs'],runId='drive-gaps-run',files={}}={}){
25
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-drive-gaps-')));
26
+ t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
27
+ const specsDir=path.join(root,'specs5'),codeProject=path.join(root,'app'),feature='1.work';
28
+ const identity={repositoryId:'drive-gaps',runId,taskId:'T-001',attempt:1};
29
+ fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
30
+ for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
31
+ fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: fixture\n');
32
+ fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
33
+ fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
34
+ for(const [file,content] of Object.entries(files)){
35
+ fs.mkdirSync(path.dirname(path.join(codeProject,file)),{recursive:true});
36
+ fs.writeFileSync(path.join(codeProject,file),content);fs.chmodSync(path.join(codeProject,file),0o644);
37
+ }
38
+ const config=path.join(root,'run.json');
39
+ fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope,requirements:['requirements.md']}));
40
+ const answers=path.join(root,'answers');fs.mkdirSync(answers);
41
+ // create requires a bound review configuration; reviewer() replaces it with the
42
+ // same model and a real preflight, so the durable fingerprint is unchanged.
43
+ fs.writeFileSync(path.join(root,'review.json'),JSON.stringify({model:'fixture',preflight:{}}));
44
+ const bin=path.join(root,'bin');fs.mkdirSync(bin);
45
+ const env={...process.env,PATH:bin+path.delimiter+process.env.PATH,CM_WORKFLOW_HOME:path.join(root,'home'),
46
+ CM_WORKFLOW_LOG_HOME:path.join(root,'logs')};
47
+ const write=(name,value)=>fs.writeFileSync(path.join(answers,name),JSON.stringify(value));
48
+ const content=(name,bytes)=>fs.writeFileSync(path.join(answers,name),bytes);
49
+ const develop=(edits,name='develop.json')=>write(name,{status:'succeeded',value:developValue,edits});
50
+ const plan=(extra={})=>{const file=path.join(root,`plan-${Math.random().toString(36).slice(2)}.json`);
51
+ const value={config:'run.json',mode:'create',hostContext:'drive-host-a',
52
+ permissions:[],answers:'answers',checks:[{id:'noop',command:[process.execPath,'-e','0']}],...extra};
53
+ if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config','review.json'];
54
+ fs.writeFileSync(file,JSON.stringify(value));
55
+ return file;};
56
+ const drive=(file,operation,timeout=60000,umask=null)=>umask===null
57
+ ?spawnSync(process.execPath,[DRIVER,'--plan',file,operation],{encoding:'utf8',timeout,env})
58
+ :spawnSync('/bin/sh',['-c',`umask ${umask}; exec "$0" "$@"`,process.execPath,DRIVER,'--plan',file,operation],{encoding:'utf8',timeout,env});
59
+ const store=path.join(specsDir,'.reviews','.execution',runId,'state.json');
60
+ const reviewer=verdict=>{
61
+ let fake=fs.readFileSync(REVIEWER,'utf8');
62
+ if(verdict==='changes_requested')fake=fake.replace("verdict:'approved'","verdict:data.reviewPackage.identity.attempt===1?'changes_requested':'approved'")
63
+ .replace('findings:[]',"findings:data.reviewPackage.identity.attempt===1?[{id:'F1',severity:'P2',path:'"+scope[0]+"',message:'Revise',evidence:'Fixture finding'}]:[]");
64
+ fs.writeFileSync(path.join(bin,'codex'),fake,{mode:0o700});
65
+ fs.writeFileSync(path.join(root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,
66
+ cli_model:'fixture',prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture'})}}));
67
+ };
68
+ reviewer('approved');
69
+ return {root,specsDir,codeProject,config,answers,bin,env,identity,write,content,develop,plan,drive,store,reviewer};
70
+ }
71
+ const result=run=>JSON.parse(run.stdout).result;
72
+ const records=f=>JSON.parse(fs.readFileSync(f.store,'utf8')).records;
73
+
74
+ function capacityFixture(t){
75
+ const f=fixture(t,{files:{'target.mjs':'export const value = 1;\n'}});
76
+ fs.writeFileSync(path.join(f.root,'control.json'),JSON.stringify(policy));
77
+ f.content('target.txt',CONTENT);f.develop({'target.mjs':'target.txt'});
78
+ return f;
79
+ }
80
+ // SIGKILL the actual owner after its persisted reply, before host_close. Resume
81
+ // must release the stale writer and replay the same records without redoing work.
82
+ function developAndKill(f,{enabled=true}={}){
83
+ return new Promise((resolve,reject)=>{
84
+ const args=['serve','--config',f.config,'--mode','create','--host-context','drive-host-a',
85
+ ...(enabled?['--control-config',path.join(f.root,'control.json')]:['--allow-development']),
86
+ '--review-config',path.join(f.root,'review.json')];
87
+ const child=spawn(process.execPath,[HOST,...args],{env:f.env,stdio:['pipe','pipe','pipe']});
88
+ let buffer='',stderr='',reply=null,failed=null;
89
+ const timer=setTimeout(()=>{failed=new Error('capacity owner timed out');child.kill('SIGKILL');},30000);
90
+ const send=row=>child.stdin.write(JSON.stringify(row)+'\n');
91
+ child.stderr.on('data',chunk=>{stderr+=chunk;});
92
+ child.on('error',error=>{clearTimeout(timer);reject(error);});
93
+ child.stdout.on('data',chunk=>{
94
+ buffer+=chunk;
95
+ try{let index;while((index=buffer.indexOf('\n'))>=0){
96
+ const line=buffer.slice(0,index);buffer=buffer.slice(index+1);if(!line)continue;const row=JSON.parse(line);
97
+ if(row.type==='host_ready')send({version:enabled?2:1,operation:'start',requestId:'capacity',identity:f.identity});
98
+ if(row.type==='host_request'){
99
+ let result;
100
+ if(row.kind==='develop'){fs.writeFileSync(path.join(f.codeProject,'target.mjs'),CONTENT);result={status:'succeeded',value:developValue};}
101
+ else{
102
+ assert.equal(row.kind,'check');
103
+ const command=[process.execPath,'--check',path.join(f.codeProject,'target.mjs')];
104
+ const checked=spawnSync(command[0],command.slice(1),{encoding:'utf8',timeout:3000});assert.equal(checked.status,0,checked.stderr);
105
+ result=[{id:'noop',command,outcome:'passed',exitCode:0,evidence:'Actual isolated syntax check passed'}];
106
+ }
107
+ send({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
108
+ }
109
+ if(row.requestId==='capacity'&&row.result){reply=row.result;child.kill('SIGKILL');}
110
+ }}catch(error){failed=error;child.kill('SIGKILL');}
111
+ });
112
+ child.on('close',(code,signal)=>{clearTimeout(timer);
113
+ if(failed)reject(failed);else if(!reply)reject(new Error('owner exited without reply: '+stderr));
114
+ else {assert.equal(signal,'SIGKILL');resolve(reply);}
115
+ });
116
+ });
117
+ }
118
+
119
+ test('review-capacity: eligible 800 KB-class delivery exceeds inline reserve, survives owner kill, review and completion',async t=>{
120
+ const f=capacityFixture(t),developed=await developAndKill(f);
121
+ t.diagnostic(JSON.stringify({state:developed.state,code:developed.code,reason:developed.reason}));
122
+ assert.equal(developed.state,'awaiting_review',JSON.stringify(developed));
123
+ const developedRows=records(f),material=developedRows.at(-1),checkpoint=material.payload.checkpoint;
124
+ assert.equal(material.payload.packageMaterial,true);
125
+ assert.equal(material.payload.type,'effect-checkpoint');
126
+ const pkg=checkpoint.reviewPackage,fullPackageBytes=JSON.stringify(pkg);
127
+ const reserve=developCheckpointReserve({examinedPathsBytes:size(reviewPaths(pkg)),receiptsBytes:size(checkpoint.receipts),
128
+ callsBytes:size(checkpoint.calls),writebackBytes:size(checkpoint.learningResult?.writeback)});
129
+ assert(size(material.payload)>JOURNAL_PAYLOAD_LIMIT-reserve);
130
+ assert(size(material.payload)<=JOURNAL_PAYLOAD_LIMIT);
131
+ assert.equal(Buffer.from(pkg.changes.find(c=>c.path==='target.mjs').after.contentBase64,'base64').toString(),CONTENT);
132
+ t.diagnostic(JSON.stringify({developBytes:size(material.payload),reserve,budget:JOURNAL_PAYLOAD_LIMIT-reserve}));
133
+ const resume={mode:'resume',controlConfig:'control.json',checks:undefined};
134
+ const status=f.drive(f.plan(resume),'status');assert.equal(status.status,0,status.stderr);
135
+ assert.equal(result(status).state,'awaiting_review');assert.deepEqual(records(f),developedRows);
136
+ const approved=f.drive(f.plan({...resume,packageDigest:developed.packageDigest}),'decision');
137
+ assert.equal(approved.status,0,approved.stderr);assert.equal(result(approved).state,'approved',approved.stdout);
138
+ const completed=f.drive(f.plan({...resume,packageDigest:developed.packageDigest,
139
+ checks:[{id:'noop',command:[process.execPath,'--check',path.join(f.codeProject,'target.mjs')]}]}),'complete');
140
+ assert.equal(completed.status,0,completed.stderr);assert.equal(result(completed).state,'fixture_completed',completed.stdout);
141
+ const completedRows=records(f),refs=completedRows.filter(row=>row.payload.packageRef);
142
+ assert(refs.length>=2);
143
+ for(const row of refs){assert.equal(row.payload.checkpoint.reviewPackage,null);
144
+ assert.deepEqual(row.payload.packageRef,{recordId:material.id,recordDigest:material.digest,packageDigest:pkg.packageDigest});}
145
+ for(const row of completedRows)assert(size(row.payload)<=JOURNAL_PAYLOAD_LIMIT);
146
+ assert.deepEqual(completedRows.slice(0,developedRows.length),developedRows);
147
+ const restored=readRunnerHistory(completedRows,completedRows[0].payload.config,3);
148
+ assert.equal(JSON.stringify(restored.state.reviewPackage),fullPackageBytes);
149
+ const final=f.drive(f.plan(resume),'status');assert.equal(final.status,0,final.stderr);
150
+ assert.equal(result(final).state,'fixture_completed');assert.deepEqual(records(f),completedRows);
151
+ t.diagnostic(JSON.stringify({maxPayloadBytes:Math.max(...completedRows.map(row=>size(row.payload))),referenceCount:refs.length}));
152
+ const damaged=structuredClone(completedRows),row=damaged.findLast(entry=>entry.payload.packageRef);
153
+ row.payload.packageRef.recordDigest='0'.repeat(64);
154
+ for(let i=0;i<damaged.length;i++){const {digest:discard,...body}=damaged[i];body.previousDigest=i?damaged[i-1].digest:null;damaged[i]={...body,digest:digest(body)};}
155
+ assert.throws(()=>readRunnerHistory(damaged,completedRows[0].payload.config,3),{code:'checkpoint_package_material_invalid'});
156
+ // Replay refuses the stored representation for a run that is not eligible. The
157
+ // prefix ends at the material checkpoint, so no later packageRef can fail first.
158
+ const forged=structuredClone(developedRows);forged[0].payload.config.controlPolicy.development='provider';
159
+ for(let i=0;i<forged.length;i++){const {digest:discard,...body}=forged[i];body.previousDigest=i?forged[i-1].digest:null;forged[i]={...body,digest:digest(body)};}
160
+ assert.throws(()=>readRunnerHistory(forged,forged[0].payload.config,3),{code:'checkpoint_package_material_invalid'});
161
+ });
162
+
163
+ test('review-capacity: ineligible legacy run with the identical delivery still blocks develop_package_too_large',async t=>{
164
+ const f=capacityFixture(t),blocked=await developAndKill(f,{enabled:false});
165
+ assert.equal(blocked.state,'blocked');assert.equal(blocked.code,'develop_package_too_large');
166
+ const [,bytes,budget]=/checkpoint would be (\d+) bytes, above (\d+)/.exec(blocked.reason).map(Number);
167
+ assert(bytes>budget&&bytes<=JOURNAL_PAYLOAD_LIMIT);
168
+ assert(records(f).every(row=>!Object.hasOwn(row.payload,'packageMaterial')&&!Object.hasOwn(row.payload,'packageRef')));
169
+ const restored=readRunnerHistory(records(f),records(f)[0].payload.config,3);
170
+ assert.equal(restored.state.code,'develop_package_too_large');
171
+ t.diagnostic(JSON.stringify({bytes,budget,code:blocked.code}));
172
+ });
173
+
174
+ test('review-capacity: resume driver and owner admit the same large eligible delivery',t=>{
175
+ const f=capacityFixture(t);
176
+ const created=f.drive(f.plan({controlConfig:'control.json'}),'status');assert.equal(created.status,0,created.stderr);
177
+ const started=f.drive(f.plan({mode:'resume',controlConfig:'control.json'}),'start');
178
+ assert.equal(started.status,0,started.stderr);assert.equal(result(started).state,'awaiting_review',started.stdout);
179
+ assert.equal(records(f).at(-1).payload.packageMaterial,true);
180
+ // The driver budgets an already archived package as a reference, so its digest
181
+ // must reach the preview from the real journal, not only exist in the store.
182
+ const definition=JSON.parse(fs.readFileSync(f.config,'utf8')),journal=readRunJournal(definition);
183
+ const archived=[records(f).at(-1).payload.checkpoint.reviewPackage.packageDigest];
184
+ assert.equal(journal.packageMaterialEnabled,true);assert.deepEqual(journal.archivedPackageDigests,archived);
185
+ assert.deepEqual(developPreview({definition,journal}).archivedPackageDigests,archived);
186
+ });
187
+
188
+
189
+ test('review-capacity: create driver and owner also admit the same eligible delivery without an existing journal',t=>{
190
+ const f=capacityFixture(t),started=f.drive(f.plan({controlConfig:'control.json'}),'start');
191
+ assert.equal(started.status,0,started.stderr);assert.equal(result(started).state,'awaiting_review',started.stdout);
192
+ assert.equal(records(f).at(-1).payload.packageMaterial,true);
193
+ });
@@ -12,6 +12,7 @@ import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
12
12
  import {createHostQaExecutor} from '../runtime/js/cm-ai/host-qa-executor.mjs';
13
13
  import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
14
14
  import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
15
+ import {markImplicitQaDecision} from '../runtime/js/cm-ai/implicit-qa-decision.mjs';
15
16
 
16
17
  const policy={version:2,development:'conversation',bootstrap:'disabled',qa:'run',qaFix:'disabled'};
17
18
  const cli=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
@@ -105,6 +106,26 @@ test('v1 recovery retains its original no-target and fingerprint behavior',async
105
106
  assert.equal(f.snapshot().records.find(row=>row.payload.type==='specification-rebound').payload.record.reason,'Legacy explicit reason.');
106
107
  });
107
108
 
109
+ test('regression: a v2 run created before the implicit QA decision still resumes in its original form',async t=>{
110
+ const f=fixture(t);
111
+ // 修复前没有 workflow 配置的 v2 运行:没有 workflow、执行器,也没有 QA 判定。
112
+ delete f.execution.configuration.workflow;delete f.execution.qaExecutor;delete f.execution.qaDecisionProvider;
113
+ const original={...f.execution};
114
+ const created=await openControlRun(f.definition,'create',original);created.close();
115
+ const provider={timeoutMs:1000,decide:()=>{throw new Error('must not assess');}};
116
+ const implicit={...original,qaDecisionProvider:markImplicitQaDecision(provider)};
117
+ const resumed=await openControlRun(f.definition,'resume',implicit);resumed.close();
118
+ // 没有隐式标记的判定不能借这条兼容路径改变指纹。
119
+ await assert.rejects(openControlRun(f.definition,'resume',{...original,qaDecisionProvider:{...provider}}),/fingerprint_mismatch/);
120
+ // 修复后新建的运行带着隐式判定的指纹,按新形式正常恢复。
121
+ const g=fixture(t);
122
+ delete g.execution.configuration.workflow;delete g.execution.qaExecutor;
123
+ g.execution.qaDecisionProvider=markImplicitQaDecision({timeoutMs:1000,decide:()=>{throw new Error('must not assess');}});
124
+ const fresh=await openControlRun(g.definition,'create',g.execution);fresh.close();
125
+ const again=await openControlRun(g.definition,'resume',g.execution);again.close();
126
+ await assert.rejects(openControlRun(g.definition,'resume',(({qaDecisionProvider,...rest})=>rest)(g.execution)),/fingerprint_mismatch/);
127
+ });
128
+
108
129
  test('target file rejects unknown fields, malformed targets, symlinks and hardlinks',async t=>{
109
130
  const f=fixture(t),target=await initialize(f),file=path.join(f.root,'target.json');
110
131
  fs.writeFileSync(file,JSON.stringify(target));assert.deepEqual(readLaunchControlFile(file),target);
@@ -29,6 +29,20 @@ test('control choices are strict and cannot turn data presence into execution pe
29
29
  {...policy,qaFix:'auto'},{...policy,qa:'skip'},{...policy,bootstrap:'yes'}])assert.throws(()=>readControlPolicy(value));
30
30
  assert.deepEqual(readControlPolicy({...policy,qa:'run',qaFix:'manual'}).qaFix,'manual');
31
31
  });
32
+ test('verification is an optional policy choice that keeps older policies byte-identical',()=>{
33
+ // Absent is the policy every earlier run saved; its digest must not move.
34
+ assert.equal(digest(readControlPolicy(policy)),digest(policy));
35
+ assert.deepEqual(readControlPolicy({...policy,verification:'precheck'}),{...policy,verification:'precheck'});
36
+ assert.deepEqual(readControlPolicy({...policy,verification:'disabled'}),{...policy,verification:'disabled'});
37
+ assert.deepEqual(readControlPolicy({...policy,verification:'auto'}),{...policy,verification:'auto'});
38
+ for(const verification of ['on',true,null,'','PRECHECK','AUTO'])
39
+ assert.throws(()=>readControlPolicy({...policy,verification}),{code:'invalid_input'});
40
+ // The choice is part of the saved run: a launch cannot add or drop it.
41
+ assert.throws(()=>assertControlEntry(snapshot(),{...policy,verification:'precheck'}),{code:'fingerprint_mismatch'});
42
+ const saved={revision:digest('a'),records:[{payload:{type:'init',config:{controlPolicy:{...policy,verification:'precheck'}}}}]};
43
+ assert.throws(()=>assertControlEntry(saved,policy),{code:'fingerprint_mismatch'});
44
+ assertControlEntry(saved,{...policy,verification:'precheck'});
45
+ });
32
46
  test('policy file rejects duplicate keys, invalid UTF8 and symbolic links',t=>{
33
47
  const root=temp(t),file=path.join(root,'control.json');
34
48
  fs.writeFileSync(file,JSON.stringify(policy));assert.deepEqual(readControlPolicyFile(file),policy);