@aibyzero/cm-workflow 0.17.0 → 0.18.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 (372) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +27 -0
  3. package/CHANGELOG.md +230 -1
  4. package/CONTRIBUTING.md +47 -0
  5. package/README.md +21 -3
  6. package/THIRD_PARTY_NOTICES.md +13 -0
  7. package/VERSION +1 -1
  8. package/compat/claude-commands/cm-challenge.md +3 -0
  9. package/docs/architecture.md +40 -13
  10. package/docs/cm-control-policy-v2.md +127 -9
  11. package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
  12. package/docs/installation.md +310 -4
  13. package/docs/js-workflow-control.md +153 -16
  14. package/docs/live-evidence-drivers.md +28 -4
  15. package/docs/out-of-scope/README.md +25 -0
  16. package/docs/out-of-scope/background-supervisor.md +32 -0
  17. package/docs/reviewed-integration.md +48 -0
  18. package/docs/user-guide.md +50 -21
  19. package/install-codex.sh +331 -18
  20. package/install.ps1 +28 -2
  21. package/install.sh +321 -17
  22. package/package.json +2 -1
  23. package/runtime/js/cm-ai/batch-location.mjs +55 -0
  24. package/runtime/js/cm-ai/batch-plan.mjs +242 -0
  25. package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
  26. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
  27. package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
  28. package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
  29. package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
  30. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
  31. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
  32. package/runtime/js/cm-ai/codex-config.mjs +6 -2
  33. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
  34. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  35. package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
  36. package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
  37. package/runtime/js/cm-ai/control-policy.mjs +24 -6
  38. package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
  39. package/runtime/js/cm-ai/drive-core.mjs +236 -34
  40. package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
  41. package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
  42. package/runtime/js/cm-ai/effect-contract.mjs +11 -2
  43. package/runtime/js/cm-ai/execution-policy.mjs +3 -1
  44. package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
  45. package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
  46. package/runtime/js/cm-ai/execution-store.mjs +60 -17
  47. package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
  48. package/runtime/js/cm-ai/host-check.mjs +14 -6
  49. package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
  50. package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
  51. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
  52. package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
  53. package/runtime/js/cm-ai/host-replay.mjs +148 -0
  54. package/runtime/js/cm-ai/host-session.mjs +42 -9
  55. package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
  56. package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
  57. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
  58. package/runtime/js/cm-ai/host.mjs +1 -1
  59. package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
  60. package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
  61. package/runtime/js/cm-ai/live-evidence.mjs +28 -6
  62. package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
  63. package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
  64. package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
  65. package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
  66. package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
  67. package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
  68. package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
  69. package/runtime/js/cm-ai/review-package.mjs +79 -7
  70. package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
  71. package/runtime/js/cm-ai/review-presentation.mjs +177 -8
  72. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
  73. package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
  74. package/runtime/js/cm-ai/scope-revision.mjs +38 -0
  75. package/runtime/js/cm-ai/specification-material.mjs +2 -2
  76. package/runtime/js/cm-ai/task-runner.mjs +247 -41
  77. package/runtime/js/cm-ai/verification-auto.mjs +38 -0
  78. package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
  79. package/runtime/js/cm-ai/worker-claude.mjs +35 -13
  80. package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
  81. package/runtime/js/cm-ai/worker-codex.mjs +41 -7
  82. package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
  83. package/runtime/js/cm-fix/cause-package.mjs +46 -1
  84. package/runtime/js/cm-fix/command-correction.mjs +37 -0
  85. package/runtime/js/cm-fix/cooperative.mjs +12 -0
  86. package/runtime/js/cm-fix/dossier.mjs +8 -2
  87. package/runtime/js/cm-fix/execution.mjs +578 -100
  88. package/runtime/js/cm-fix/final-review.mjs +39 -8
  89. package/runtime/js/cm-fix/finish.mjs +15 -11
  90. package/runtime/js/cm-fix/host-review.mjs +65 -10
  91. package/runtime/js/cm-fix/host.mjs +35 -12
  92. package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
  93. package/runtime/js/cm-fix/metrics.mjs +18 -5
  94. package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
  95. package/runtime/js/cm-fix/regression.mjs +16 -7
  96. package/runtime/js/cm-fix/repair.mjs +29 -8
  97. package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
  98. package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
  99. package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
  100. package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
  101. package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
  102. package/runtime/js/cm-fix/review-verification.mjs +214 -0
  103. package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
  104. package/runtime/js/cm-fix/start.mjs +6 -3
  105. package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
  106. package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
  107. package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
  108. package/runtime/js/cm-prd/accepted-design.mjs +8 -0
  109. package/runtime/js/cm-prd/analysis.mjs +13 -9
  110. package/runtime/js/cm-prd/change.mjs +37 -16
  111. package/runtime/js/cm-prd/draft-save.mjs +13 -6
  112. package/runtime/js/cm-prd/draft.mjs +31 -3
  113. package/runtime/js/cm-prd/failed-correction.mjs +19 -3
  114. package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
  115. package/runtime/js/cm-prd/review-correction.mjs +6 -4
  116. package/runtime/js/cm-prd/review-disposition.mjs +7 -1
  117. package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
  118. package/runtime/js/cm-prd/self-check.mjs +125 -6
  119. package/runtime/js/cm-prd/session.mjs +30 -1
  120. package/runtime/js/cm-prd/summary.mjs +38 -17
  121. package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
  122. package/runtime/js/cm-prd/tree-digest.mjs +34 -0
  123. package/runtime/js/cm-prd/validation-reason.mjs +8 -4
  124. package/runtime/js/cm-security/scan.mjs +1 -1
  125. package/runtime/js/commander/decision.mjs +44 -0
  126. package/runtime/js/commander/dispatch-registry.mjs +110 -0
  127. package/runtime/js/commander/ledger.mjs +265 -0
  128. package/runtime/js/commander/preflight.mjs +107 -0
  129. package/runtime/js/notify-later.mjs +13 -0
  130. package/runtime/js/notify-send.mjs +6 -2
  131. package/runtime/js/notify.mjs +570 -63
  132. package/runtime/js/review-findings.mjs +38 -0
  133. package/runtime/js/session-boundary.mjs +56 -0
  134. package/runtime/js/session-handoff.mjs +68 -0
  135. package/runtime/js/spec-task-line.mjs +27 -13
  136. package/runtime/js/specs-status.mjs +1 -1
  137. package/runtime/js/task-scope.mjs +197 -0
  138. package/runtime/logging.md +6 -1
  139. package/runtime/model-efficiency.md +69 -10
  140. package/runtime/orchestration.md +3 -1
  141. package/runtime/project-learning.md +2 -0
  142. package/runtime/review.md +12 -2
  143. package/runtime/test-contract.md +1 -0
  144. package/scripts/ci-test-weights.json +3 -0
  145. package/scripts/cm-ai-admission.mjs +11 -5
  146. package/scripts/cm-ai-admission.test.mjs +23 -2
  147. package/scripts/cm-ai-batch-drive.mjs +79 -18
  148. package/scripts/cm-ai-batch-drive.test.mjs +169 -3
  149. package/scripts/cm-ai-batch-host.mjs +38 -9
  150. package/scripts/cm-ai-batch-host.test.mjs +27 -14
  151. package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
  152. package/scripts/cm-ai-batch-location.test.mjs +57 -0
  153. package/scripts/cm-ai-batch-plan.mjs +52 -0
  154. package/scripts/cm-ai-batch-plan.test.mjs +397 -0
  155. package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
  156. package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
  157. package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
  158. package/scripts/cm-ai-batch-run.mjs +483 -63
  159. package/scripts/cm-ai-batch-run.test.mjs +23 -4
  160. package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
  161. package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
  162. package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
  163. package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
  164. package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
  165. package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
  166. package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
  167. package/scripts/cm-ai-control-launch.test.mjs +21 -0
  168. package/scripts/cm-ai-control-policy.test.mjs +82 -0
  169. package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
  170. package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
  171. package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
  172. package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
  173. package/scripts/cm-ai-development-rework.test.mjs +423 -0
  174. package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
  175. package/scripts/cm-ai-drive.mjs +73 -17
  176. package/scripts/cm-ai-drive.test.mjs +37 -5
  177. package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
  178. package/scripts/cm-ai-host-fixture.mjs +9 -6
  179. package/scripts/cm-ai-host-protected.test.mjs +1 -1
  180. package/scripts/cm-ai-host.mjs +60 -19
  181. package/scripts/cm-ai-host.test.mjs +15 -0
  182. package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
  183. package/scripts/cm-ai-integration-independence.test.mjs +23 -0
  184. package/scripts/cm-ai-integration-launch.test.mjs +240 -0
  185. package/scripts/cm-ai-integration-preview.mjs +41 -0
  186. package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
  187. package/scripts/cm-ai-nested-execution.test.mjs +29 -1
  188. package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
  189. package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
  190. package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
  191. package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
  192. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
  193. package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
  194. package/scripts/cm-ai-review-failure.test.mjs +150 -5
  195. package/scripts/cm-ai-review-timeout.test.mjs +20 -0
  196. package/scripts/cm-ai-run.mjs +88 -21
  197. package/scripts/cm-ai-scope-revision.test.mjs +341 -0
  198. package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
  199. package/scripts/cm-ai-supersede.test.mjs +28 -0
  200. package/scripts/cm-ai-verification-auto.test.mjs +99 -0
  201. package/scripts/cm-announce-hook.mjs +35 -8
  202. package/scripts/cm-announce-hook.test.mjs +25 -0
  203. package/scripts/cm-challenge.test.mjs +61 -0
  204. package/scripts/cm-check-drive-files.mjs +2 -2
  205. package/scripts/cm-check-host.test.mjs +1 -1
  206. package/scripts/cm-check-runtime.sh +58 -1
  207. package/scripts/cm-claude-developer-worker.test.mjs +56 -7
  208. package/scripts/cm-claude-install-layout.test.mjs +1 -1
  209. package/scripts/cm-claude-probe.test.mjs +26 -0
  210. package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
  211. package/scripts/cm-claude-review-stream.test.mjs +49 -0
  212. package/scripts/cm-claude-worker.test.mjs +16 -0
  213. package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
  214. package/scripts/cm-codex-developer-worker.test.mjs +120 -0
  215. package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
  216. package/scripts/cm-codex-prompt-input.test.mjs +153 -0
  217. package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
  218. package/scripts/cm-commander-ledger.test.mjs +260 -0
  219. package/scripts/cm-commander-p2.test.mjs +295 -0
  220. package/scripts/cm-commander-preflight.mjs +84 -0
  221. package/scripts/cm-commander.mjs +116 -0
  222. package/scripts/cm-config-lock.mjs +35 -0
  223. package/scripts/cm-controlled-correction.test.mjs +10 -1
  224. package/scripts/cm-developer-failure-code.test.mjs +62 -0
  225. package/scripts/cm-display-task-id.test.mjs +41 -0
  226. package/scripts/cm-drive-liveness.test.mjs +83 -0
  227. package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
  228. package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
  229. package/scripts/cm-external-batch-host.test.mjs +12 -9
  230. package/scripts/cm-external-process-cleanup.test.mjs +128 -0
  231. package/scripts/cm-external-qa-fix.test.mjs +89 -7
  232. package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
  233. package/scripts/cm-failover.mjs +48 -10
  234. package/scripts/cm-failover.test.mjs +46 -0
  235. package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
  236. package/scripts/cm-fix-command-correction.mjs +17 -0
  237. package/scripts/cm-fix-command-correction.test.mjs +211 -0
  238. package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
  239. package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
  240. package/scripts/cm-fix-drive.mjs +33 -5
  241. package/scripts/cm-fix-drive.test.mjs +49 -0
  242. package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
  243. package/scripts/cm-fix-host-review.test.mjs +21 -9
  244. package/scripts/cm-fix-host.mjs +26 -8
  245. package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
  246. package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
  247. package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
  248. package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
  249. package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
  250. package/scripts/cm-fix-review-preflight.mjs +24 -0
  251. package/scripts/cm-fix-review-storage.test.mjs +233 -0
  252. package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
  253. package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
  254. package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
  255. package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
  256. package/scripts/cm-fix-review-verification.test.mjs +146 -0
  257. package/scripts/cm-fix-revision-transport.test.mjs +81 -0
  258. package/scripts/cm-fix-source-correction.test.mjs +296 -0
  259. package/scripts/cm-fix-test-type-correction.mjs +18 -0
  260. package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
  261. package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
  262. package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
  263. package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
  264. package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
  265. package/scripts/cm-fix-verification-recovery.mjs +33 -0
  266. package/scripts/cm-host-diagnostic.test.mjs +33 -0
  267. package/scripts/cm-host-liveness.test.mjs +150 -0
  268. package/scripts/cm-host-qa-executor.test.mjs +77 -0
  269. package/scripts/cm-host-replay.test.mjs +176 -0
  270. package/scripts/cm-host-stage-observer.test.mjs +41 -0
  271. package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
  272. package/scripts/cm-install-manifest.sh +351 -0
  273. package/scripts/cm-live-evidence.test.mjs +59 -1
  274. package/scripts/cm-log-event.mjs +61 -10
  275. package/scripts/cm-log-event.test.mjs +121 -1
  276. package/scripts/cm-matt-skills.mjs +576 -0
  277. package/scripts/cm-matt-skills.test.mjs +550 -0
  278. package/scripts/cm-notify-command.test.mjs +42 -10
  279. package/scripts/cm-notify.mjs +14 -10
  280. package/scripts/cm-notify.test.mjs +625 -75
  281. package/scripts/cm-patrol.mjs +4 -1
  282. package/scripts/cm-patrol.test.mjs +23 -5
  283. package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
  284. package/scripts/cm-prd-completion.test.mjs +56 -13
  285. package/scripts/cm-prd-design-phase.test.mjs +78 -8
  286. package/scripts/cm-prd-draft-save.test.mjs +12 -0
  287. package/scripts/cm-prd-draft.test.mjs +1 -1
  288. package/scripts/cm-prd-drive.mjs +13 -6
  289. package/scripts/cm-prd-drive.test.mjs +46 -2
  290. package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
  291. package/scripts/cm-prd-host.mjs +10 -5
  292. package/scripts/cm-prd-host.test.mjs +4 -2
  293. package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
  294. package/scripts/cm-prd-review-disposition.test.mjs +124 -8
  295. package/scripts/cm-prd-revision.test.mjs +1 -1
  296. package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
  297. package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
  298. package/scripts/cm-prd-self-check.test.mjs +105 -5
  299. package/scripts/cm-prd-session-recovery.test.mjs +5 -3
  300. package/scripts/cm-prd-summary.test.mjs +55 -3
  301. package/scripts/cm-prd-task-grouping.test.mjs +6 -6
  302. package/scripts/cm-prd-tree-digest.test.mjs +74 -0
  303. package/scripts/cm-refactor-drive.mjs +2 -1
  304. package/scripts/cm-refactor-drive.test.mjs +9 -0
  305. package/scripts/cm-release-smoke.sh +3 -15
  306. package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
  307. package/scripts/cm-skill-hints-exam.mjs +149 -0
  308. package/scripts/cm-skill-hints-install.test.mjs +168 -0
  309. package/scripts/cm-skill-hints.exam.json +706 -0
  310. package/scripts/cm-skill-hints.json +119 -0
  311. package/scripts/cm-skill-hints.mjs +669 -0
  312. package/scripts/cm-skill-hints.test.mjs +831 -0
  313. package/scripts/cm-skill-judge.mjs +181 -0
  314. package/scripts/cm-skill-judge.test.mjs +255 -0
  315. package/scripts/cm-specs-status.test.mjs +4 -2
  316. package/scripts/cm-start-check.mjs +208 -0
  317. package/scripts/cm-start-check.test.mjs +321 -0
  318. package/scripts/cm-task-gate.mjs +150 -29
  319. package/scripts/cm-task-gate.test.mjs +73 -1
  320. package/scripts/cm-task-id-grammar.test.mjs +66 -0
  321. package/scripts/cm-task-scope.test.mjs +308 -0
  322. package/scripts/cm-test-suite.mjs +109 -0
  323. package/scripts/cm-test-suite.test.mjs +162 -0
  324. package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
  325. package/scripts/cm-upgrade-compat.test.mjs +239 -0
  326. package/scripts/cm-workflow-config.mjs +12 -2
  327. package/scripts/fixtures/fix-verification-claude.mjs +44 -0
  328. package/scripts/fixtures/host-diagnostic.mjs +33 -0
  329. package/scripts/fixtures/reviewed-integration.mjs +202 -0
  330. package/scripts/scan-public-safety.py +1 -0
  331. package/scripts/session-boundary.test.mjs +170 -0
  332. package/scripts/test-npm-install.py +14 -3
  333. package/scripts/test-shell-compat.sh +2 -0
  334. package/scripts/validate-public-repo.py +1 -0
  335. package/scripts/validate-test-cases.mjs +3 -2
  336. package/skills/cm-ai/SKILL.md +5 -2
  337. package/skills/cm-ai/references/N4-review.md +2 -1
  338. package/skills/cm-ai/references/N6-qa-eval.md +3 -1
  339. package/skills/cm-ai/references/N8-finish.md +22 -0
  340. package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
  341. package/skills/cm-ai/references/js-host-recovery.md +79 -3
  342. package/skills/cm-ai/references/js-host.md +89 -17
  343. package/skills/cm-challenge/SKILL.md +65 -0
  344. package/skills/cm-challenge/evals/README.md +18 -0
  345. package/skills/cm-challenge/evals/trigger-cases.json +20 -0
  346. package/skills/cm-challenge/evals/trigger-config.json +28 -0
  347. package/skills/cm-challenge/references/examples.md +15 -0
  348. package/skills/cm-check/SKILL.md +5 -0
  349. package/skills/cm-check/references/js-host.md +2 -0
  350. package/skills/cm-fix/SKILL.md +12 -3
  351. package/skills/cm-fix/references/command-correction.md +67 -0
  352. package/skills/cm-fix/references/isolated-review.md +54 -0
  353. package/skills/cm-fix/references/js-host.md +62 -2
  354. package/skills/cm-fix/references/test-type-correction.md +72 -0
  355. package/skills/cm-fix/references/verification-recovery.md +114 -0
  356. package/skills/cm-idea/SKILL.md +2 -0
  357. package/skills/cm-idea/references/js-host.md +2 -0
  358. package/skills/cm-notify/SKILL.md +2 -0
  359. package/skills/cm-prd/SKILL.md +12 -8
  360. package/skills/cm-prd/references/brownfield.md +8 -1
  361. package/skills/cm-prd/references/change-mode.md +6 -0
  362. package/skills/cm-prd/references/greenfield.md +4 -0
  363. package/skills/cm-prd/references/js-host.md +4 -2
  364. package/skills/cm-prd/references/spec-self-check.md +5 -1
  365. package/skills/cm-refactor/SKILL.md +8 -0
  366. package/skills/cm-refactor/references/js-host.md +2 -0
  367. package/skills/cm-test/SKILL.md +4 -0
  368. package/templates/dashboard/dashboard.html +2 -2
  369. package/templates/pixel/cm-pixel.html +1 -1
  370. package/templates/pixel/cm-pixel.sh +1 -1
  371. package/templates/pixel/dev/template.html +1 -1
  372. package/templates/statusline/cm-statusline.sh +1 -1
@@ -20,11 +20,61 @@ const API_ERROR_CLASSES = Object.freeze({authentication_failed:'reviewer_auth_fa
20
20
  billing_error:'reviewer_billing_error', rate_limit:'reviewer_rate_limited',
21
21
  server_error:'reviewer_server_error', model_not_found:'reviewer_model_not_found'});
22
22
 
23
- export function createClaudeReviewStream(onEvent, onNotice = null) {
24
- let session = null, stage = 'init', value, noticeCount = 0, thinkingCount = 0, rejectedAttempts = 0;
23
+ // Diagnostic enums also name rejected CLI 2.1.x messages. They never extend the
24
+ // accepted stream grammar. Unknown strings, bodies and identifiers stay private.
25
+ const DIAGNOSTIC_TYPES = new Set(['system','assistant','user','result','rate_limit_event',
26
+ 'auth_status','keep_alive','stream_event','tool_progress','tool_use_summary']);
27
+ const DIAGNOSTIC_SUBTYPES = new Set(['init','dev_intent','ui_invalidate','thinking_tokens',
28
+ 'api_retry','hook_started','hook_response','commands_changed','compact_boundary','status',
29
+ 'task_started','task_progress','task_notification','files_persisted','hook_progress',
30
+ 'local_command_output','success','error_during_execution','error_max_turns',
31
+ 'error_max_budget_usd','error_max_structured_output_retries']);
32
+ const DIAGNOSTIC_ERRORS = new Set([...Object.keys(API_ERROR_CLASSES),'invalid_request',
33
+ 'invalid_request_error','api_error','overloaded_error','context_window_exceeded',
34
+ 'context_length_exceeded','prompt_too_long','authentication_error','permission_error',
35
+ 'not_found_error','rate_limit_error','request_too_large','unknown']);
36
+ const diagnosticEnum = (value, allowed) => typeof value !== 'string' ? 'absent'
37
+ : allowed.has(value) ? value : 'other';
38
+ const diagnosticLength = value => typeof value === 'string' ? Math.min(value.length,1_000_001) : 0;
39
+ const httpStatus = value => Number.isInteger(value) && value >= 100 && value <= 599 ? value : null;
40
+ function apiFailureDetail(message) {
41
+ const detail={apiErrorClass:diagnosticEnum(message.error,DIAGNOSTIC_ERRORS),
42
+ apiErrorClassLength:diagnosticLength(message.error),providerErrorClass:'absent',
43
+ httpStatus:httpStatus(message.api_error_status)??httpStatus(message.error_status)??httpStatus(message.status_code),
44
+ errorFlags:[],tokenBudget:null};
45
+ // Inspect only the bounded synthetic API error envelope, extracting fixed
46
+ // classifications and numeric token limits. Never return its original text.
47
+ const content=message.message?.content;
48
+ if(!Array.isArray(content)||content.length!==1||content[0]?.type!=='text'||typeof content[0].text!=='string')return detail;
49
+ const text=content[0].text;
50
+ const prefix=/^API Error: ([1-5][0-9]{2})(?:\s|$)/.exec(text.slice(0,32));
51
+ if(prefix&&detail.httpStatus===null)detail.httpStatus=Number(prefix[1]);
52
+ if(text.length>8192)return detail;
53
+ let errorText=text;
54
+ if(prefix){
55
+ try{
56
+ const body=JSON.parse(text.slice(prefix[0].length));
57
+ detail.providerErrorClass=diagnosticEnum(body?.error?.type,DIAGNOSTIC_ERRORS);
58
+ errorText=typeof body?.error?.message==='string'?body.error.message:'';
59
+ }catch{} // Non-JSON API errors still permit fixed, body-free flags below.
60
+ }
61
+ if(/\bprompt(?: is)? too long\b|\bprompt_too_long\b/i.test(errorText))detail.errorFlags.push('prompt_too_long');
62
+ if(/\bcontext_length_exceeded\b|\bcontext_window_exceeded\b/i.test(errorText))detail.errorFlags.push('context_length_exceeded');
63
+ const budget=/^prompt(?: is)? too long:\s*([0-9]{1,9}) tokens? > ([0-9]{1,9}) maximum\b/i.exec(errorText);
64
+ if(budget)detail.tokenBudget={inputTokens:Number(budget[1]),maximumTokens:Number(budget[2])};
65
+ return detail;
66
+ }
67
+
68
+ export function createClaudeReviewStream(onEvent, onNotice = null, allowedTools = []) {
69
+ const permitted=new Set(allowedTools);
70
+ let session = null, stage = 'init', value, noticeCount = 0, thinkingCount = 0, progressCount = 0, rejectedAttempts = 0, current = null;
25
71
  const pendingTools = new Map(), toolIds = new Set();
26
- const reject = (code, detail = null) => {
27
- stage = 'failed'; throw Object.assign(new Error(code), {code, ...(detail ? {detail} : {})});
72
+ const reject = (code, detail = null, check = code) => {
73
+ const failureDetail={version:1,check,stage,
74
+ eventType:diagnosticEnum(current?.type,DIAGNOSTIC_TYPES),eventTypeLength:diagnosticLength(current?.type),
75
+ eventSubtype:diagnosticEnum(current?.subtype,DIAGNOSTIC_SUBTYPES),eventSubtypeLength:diagnosticLength(current?.subtype),
76
+ noticeCount,thinkingCount,progressCount,...(check==='api_error'?apiFailureDetail(current):{})};
77
+ stage = 'failed'; throw Object.assign(new Error(code), {code, failureDetail, ...(detail ? {detail} : {})});
28
78
  };
29
79
  // Body-free summary of the message that broke the review boundary: which
30
80
  // check (k), message type (m), block type (b), tool name (t), is_error (e).
@@ -33,19 +83,26 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
33
83
  b: typeof block?.type === 'string' && /^[A-Za-z_]{1,32}$/.test(block.type) ? block.type : null,
34
84
  t: typeof tool === 'string' && /^[A-Za-z0-9_.:-]{1,64}$/.test(tool) ? tool : null,
35
85
  e: typeof isError === 'boolean' ? isError : null});
86
+ const startupNotice = subtype => {
87
+ if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
88
+ noticeCount++;
89
+ if (subtype === 'dev_intent') reportClaudeDevIntentNotice(onNotice);
90
+ else try { if (typeof onNotice === 'function') onNotice({kind:'claude_system_notice', subtype:'ui_invalidate'}); } catch {}
91
+ };
36
92
  return Object.freeze({
37
93
  accept(message) {
94
+ current=message;
38
95
  if (!message || typeof message !== 'object' || Array.isArray(message)) reject('invalid_event');
39
- if (stage === 'done' || stage === 'failed') reject('unexpected_event');
96
+ if (stage === 'done' || stage === 'failed') reject('unexpected_event',null,'terminal_stage');
40
97
  if (typeof message.session_id !== 'string' || !message.session_id.trim()
41
98
  || message.session_id.length > 256) reject('invalid_session');
42
99
  if (session !== null && session !== message.session_id) reject('session_mismatch');
43
100
  if (stage === 'init') {
44
- if (message.type === 'system' && message.subtype === 'dev_intent') {
45
- if (noticeCount >= 32) reject('unexpected_event');
46
- noticeCount++;
101
+ // CLI 2.1.289 emits UI invalidation before init. It has no review
102
+ // result and never initializes a turn; retain only its fixed subtype.
103
+ if (message.type === 'system' && ['dev_intent','ui_invalidate'].includes(message.subtype)) {
47
104
  session = message.session_id;
48
- reportClaudeDevIntentNotice(onNotice);
105
+ startupNotice(message.subtype);
49
106
  return;
50
107
  }
51
108
  if (message.type !== 'system' || message.subtype !== 'init') reject('missing_init');
@@ -56,26 +113,25 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
56
113
  return;
57
114
  }
58
115
  if (message.type === 'rate_limit_event') {
59
- if (noticeCount >= 32) reject('unexpected_event');
116
+ if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
60
117
  noticeCount++;
61
118
  reportClaudeRateLimitNotice(message.rate_limit_info, onNotice);
62
119
  return;
63
120
  }
64
121
  if (message.type === 'system') {
65
- if (message.subtype === 'dev_intent') {
66
- if (noticeCount >= 32) reject('unexpected_event');
67
- noticeCount++;
68
- reportClaudeDevIntentNotice(onNotice);
122
+ if (['dev_intent','ui_invalidate'].includes(message.subtype)) {
123
+ startupNotice(message.subtype);
69
124
  return;
70
125
  }
71
126
  if (message.subtype === 'thinking_tokens') {
72
127
  // Long reviews emit usage heartbeats; worker-claude also caps total output at 1 MB.
73
- if (thinkingCount >= 4096) reject('unexpected_event');
128
+ if (thinkingCount >= 4096) reject('unexpected_event',null,'thinking_limit');
74
129
  thinkingCount++;
75
130
  return;
76
131
  }
77
- if (!['api_retry','hook_started','hook_response','commands_changed'].includes(message.subtype)
78
- || noticeCount >= 32) reject('unexpected_event');
132
+ if (!['api_retry','hook_started','hook_response','commands_changed'].includes(message.subtype))
133
+ reject('unexpected_event',null,'unknown_system_subtype');
134
+ if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
79
135
  noticeCount++;
80
136
  // CLI notifications carry no verdict; never forward hook output or command bodies.
81
137
  const notice = {kind:'claude_system_notice', subtype:message.subtype};
@@ -86,13 +142,29 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
86
142
  try { if (typeof onNotice === 'function') onNotice(notice); } catch {}
87
143
  return;
88
144
  }
145
+ if (message.type === 'tool_progress') {
146
+ // A heartbeat belongs only to an already registered, permitted tool in
147
+ // this top-level review turn. Its result must still arrive separately.
148
+ if(stage!=='result')reject('unexpected_event',null,'tool_progress_stage');
149
+ if(message.parent_tool_use_id!==null)reject('unexpected_event',null,'tool_progress_parent');
150
+ if(typeof message.tool_use_id!=='string'||!pendingTools.has(message.tool_use_id))
151
+ reject('unexpected_event',null,'tool_progress_identity');
152
+ const name=pendingTools.get(message.tool_use_id);
153
+ if(message.tool_name!==name||(name!=='StructuredOutput'&&!permitted.has(name)))
154
+ reject('unexpected_event',null,'tool_progress_tool');
155
+ if(!Number.isSafeInteger(message.elapsed_time_seconds)||message.elapsed_time_seconds<0)
156
+ reject('unexpected_event',null,'tool_progress_elapsed');
157
+ if(progressCount>=4096)reject('unexpected_event',null,'tool_progress_limit');
158
+ progressCount++;
159
+ return;
160
+ }
89
161
  if (message.type === 'assistant') {
90
162
  // CLI 2.1.x reports an API failure as a synthetic assistant message with
91
163
  // a string error class, then an is_error result. Before any tool call it
92
164
  // carries no verdict: stop with the class so the user knows what to fix.
93
165
  if (typeof message.error === 'string' && message.parent_tool_use_id === null
94
166
  && message.message?.role === 'assistant' && toolIds.size === 0) {
95
- reject(Object.hasOwn(API_ERROR_CLASSES, message.error) ? API_ERROR_CLASSES[message.error] : 'reviewer_api_error');
167
+ reject(Object.hasOwn(API_ERROR_CLASSES, message.error) ? API_ERROR_CLASSES[message.error] : 'reviewer_api_error',null,'api_error');
96
168
  }
97
169
  if (message.parent_tool_use_id !== null || message.error != null
98
170
  || message.message?.role !== 'assistant') reject('unexpected_assistant');
@@ -136,7 +208,7 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
136
208
  || pendingTools.size !== 0) {
137
209
  reject('unexpected_tool_or_content', summary('user_content', 'user', content?.[0]));
138
210
  }
139
- if (noticeCount >= 32) reject('unexpected_event');
211
+ if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
140
212
  noticeCount++;
141
213
  try { if (typeof onNotice === 'function') onNotice({kind:'claude_system_notice', subtype:'synthetic_user'}); } catch {}
142
214
  return;
@@ -148,7 +220,7 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
148
220
  if (block?.type !== 'tool_result') reject('unexpected_tool_or_content', summary('user_content', 'user', block));
149
221
  if (!pendingTools.has(block.tool_use_id)) reject('unexpected_tool_or_content', summary('unknown_tool_result', 'user', block));
150
222
  const name = pendingTools.get(block.tool_use_id);
151
- if (name !== 'StructuredOutput' && block.is_error !== true) {
223
+ if (name !== 'StructuredOutput' && !permitted.has(name) && block.is_error !== true) {
152
224
  // A successful non-StructuredOutput tool is a real boundary break.
153
225
  reject('unexpected_tool_or_content', summary('tool_result_not_error', 'user', block, name, block.is_error));
154
226
  }
@@ -170,9 +242,10 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
170
242
  onEvent({event:'turn.completed', item_type:null});
171
243
  return;
172
244
  }
173
- reject('unexpected_event');
245
+ reject('unexpected_event',null,'unknown_message_type');
174
246
  },
175
247
  finish() {
248
+ current=null;
176
249
  if (stage !== 'done') reject('incomplete_result');
177
250
  return {status:'succeeded', value};
178
251
  },
@@ -1,5 +1,6 @@
1
1
  // Synthetic request capture only. No forwarding, review package, grant or task mutation.
2
2
  import fs from 'node:fs';
3
+ import {VERIFICATION_TOOLS} from '../cm-fix/review-verification-contract.mjs';
3
4
  import os from 'node:os';
4
5
  import path from 'node:path';
5
6
  import http from 'node:http';
@@ -39,20 +40,20 @@ export function createClaudeModelMarkerDetector(onMarker) {
39
40
  };
40
41
  }
41
42
 
42
- export function claudeProbeSandbox(temp,port) {
43
+ export function claudeProbeSandbox(temp,port,writeRoot=null) {
43
44
  if(!path.isAbsolute(temp)||!Number.isInteger(port)||port<1||port>65535)throw Error('invalid_probe');
44
45
  return `(version 1)(allow default)(deny network*)
45
46
  (allow network-outbound (remote ip "localhost:${port}"))
46
- (deny file-write*)(allow file-write* (subpath ${JSON.stringify(temp)}) (literal "/dev/null"))`;
47
+ (deny file-write*)(allow file-write* (subpath ${JSON.stringify(temp)}) (literal "/dev/null") ${writeRoot?`(subpath ${JSON.stringify(writeRoot)})`:""})`;
47
48
  }
48
49
 
49
- export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnProcess=spawn}) {
50
+ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnProcess=spawn,verification=null,verificationTransport=null}) {
50
51
  if(process.platform!=='darwin'||!fs.existsSync('/usr/bin/sandbox-exec')) {
51
52
  throw Object.assign(Error('unsupported_probe_isolation'),{code:'unsupported_probe_isolation'});
52
53
  }
53
54
  cwd=fs.realpathSync(cwd);
54
55
  if(!fs.statSync(cwd).isDirectory())throw Error('invalid_code_project');
55
- const fingerprint=claudeReviewFingerprint({cwd,model,effort,cli});
56
+ const fingerprint=claudeReviewFingerprint({cwd,model,effort,cli,verification});
56
57
  const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-claude-probe-')));
57
58
  const observations=[];
58
59
  const controller=new AbortController();let stoppedByProbe=false,modelMarker=null;
@@ -94,10 +95,11 @@ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnPro
94
95
  const checks={json:true,post:request.method==='POST',
95
96
  messages_endpoint:new URL(request.url,'http://127.0.0.1').pathname==='/v1/messages',
96
97
  model_matches:data.model===model,messages_array:Array.isArray(data.messages),
97
- tools_allowed:Array.isArray(tools)&&(tools.length===0
98
- ||(tools.length===1&&tools[0]?.name==='StructuredOutput')),
98
+ tools_allowed:Array.isArray(tools)&&(verification
99
+ ?VERIFICATION_TOOLS.every(name=>tools.some(t=>t.name===name))&&tools.every(t=>t.name==='StructuredOutput'||VERIFICATION_TOOLS.includes(t.name))
100
+ :tools.length===0||(tools.length===1&&tools[0]?.name==='StructuredOutput')),
99
101
  synthetic_auth:request.headers['x-api-key']==='cm-synthetic-local-probe'};
100
- safe={valid:Object.values(checks).every(Boolean),checks};
102
+ safe={valid:Object.values(checks).every(Boolean),checks:{...checks,...(verification?{tool_names:tools.map(t=>typeof t?.name==='string'?t.name.slice(0,80):'invalid').slice(0,16)}:{})}};
101
103
  }catch{}
102
104
  // Never retain raw request bodies, auth headers, local context or diagnostics.
103
105
  if(index<8)observations[index]=safe;
@@ -115,10 +117,10 @@ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnPro
115
117
  const preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:fingerprint};
116
118
  // Internal diagnostic bootstrap: same worker lifecycle, forced sink and synthetic prompt only.
117
119
  // This object is never returned as a passing receipt without examining the captured request.
118
- const worker=claudeWorker({cwd,model,effort,cli,preflight,timeoutMs:15000,
120
+ const worker=claudeWorker({cwd,model,effort,cli,preflight,timeoutMs:15000,verification,verificationTransport,
119
121
  spawnProcess:(command,args,options)=>{
120
122
  const child=spawnProcess('/usr/bin/sandbox-exec',
121
- ['-p',claudeProbeSandbox(temp,port),command,...args],{...options,env:{...options.env,
123
+ ['-p',claudeProbeSandbox(temp,port,verificationTransport?.cwd?path.dirname(verificationTransport.cwd):null),command,...args],{...options,env:{...options.env,
122
124
  ANTHROPIC_API_KEY:'cm-synthetic-local-probe',ANTHROPIC_BASE_URL:`http://127.0.0.1:${port}`,
123
125
  CLAUDE_CONFIG_DIR:temp,CLAUDE_CODE_TMPDIR:temp,
124
126
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:'1',TMPDIR:temp}});
@@ -8,11 +8,10 @@ import {readSpecsStatus,writeSpecsStatus} from '../specs-status.mjs';
8
8
  import {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
9
9
  import {buildManifest,verifyApprovedManifest} from '../../../scripts/cm-spec-manifest.mjs';
10
10
  import {outstandingFeatureQa,describeOutstandingQa} from './project-qa-gate.mjs';
11
- import {taskLines,taskDeclarations,approvedTaskGrammar,TASK_GRAMMAR,LEGACY_TASK_GRAMMAR} from '../spec-task-line.mjs';
11
+ import {taskLines,taskDeclarations,approvedTaskGrammar,recordedTaskGrammar,TASK_GRAMMAR,SHARED_TASK_GRAMMAR,LEGACY_TASK_GRAMMAR,TASK_ID_SOURCE,isTaskId} from '../spec-task-line.mjs';
12
12
  export {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
13
13
 
14
- export const DEPENDENCY=/^\s*-\s*(T-[A-Za-z0-9][A-Za-z0-9._-]*)\s+依赖\s+(.+)$/;
15
- const TASK_ID=/^T-[A-Za-z0-9][A-Za-z0-9._-]*$/;
14
+ export const DEPENDENCY=new RegExp(`^\\s*-\\s*(${TASK_ID_SOURCE})\\s+依赖\\s+(.+)$`);
16
15
  const ACCEPTANCE=/^\s*[-*]\s+(?:\[[ xX]\]\s+)?(?:\[(AC-\d{3,})\]|(AC-\d{3,}))(?=[:\s])/;
17
16
  const FEATURE=/^(\d+)\.(.+)$/;
18
17
  const TEST_CASE_VALIDATOR=fileURLToPath(new URL('../../../scripts/validate-test-cases.mjs',import.meta.url));
@@ -247,7 +246,7 @@ export function parseFeatureTaskText(source,{allowDependencyPunctuation=false,gr
247
246
  // Only cm-ai admission opts in; cm-prd self-check retains strict parsing.
248
247
  const required=dependency[2].split(/[,,]/).map(value=>value.trim()).filter(Boolean)
249
248
  .map(value=>allowDependencyPunctuation?value.replace(/[。..;;、\s]+$/u,''):value);
250
- if(!required.length||required.some(id=>!TASK_ID.test(id)))return invalid('dependencies_invalid',index);
249
+ if(!required.length||required.some(id=>!isTaskId(id)))return invalid('dependencies_invalid',index);
251
250
  dependencies.set(dependency[1],required);
252
251
  dependencyLocations.set(dependency[1],location(index));
253
252
  }
@@ -397,7 +396,7 @@ export function approveCmAiSpecs(options){
397
396
  try{
398
397
  const discovered=discoverFeatures(specsDir);
399
398
  if(discovered.error)return refuse(discovered.error);
400
- // An approval binds grammar 2 to every feature, including ones this change
399
+ // An approval binds a shared grammar (2 or 3) to every feature, including ones this change
401
400
  // did not touch. Refuse rather than silently re-reading bytes that an older
402
401
  // approval parsed differently (e.g. an unfenced `- [ ] T-001:例` becoming a
403
402
  // duplicate of the real T-001), and rather than keeping grammar 1, which
@@ -405,17 +404,22 @@ export function approveCmAiSpecs(options){
405
404
  // Moving from the pre-grammar parse must not change which lines are tasks
406
405
  // either (e.g. a unique `- [ ] T-099:示例` would become a pending task). The
407
406
  // status carries the last approval's grammar through cm-prd publication;
408
- // once a project is on grammar 2 there is nothing to reconcile.
407
+ // once a project is on grammar 2 or 3 there is nothing to reconcile.
409
408
  // No status at all means nothing was approved before: no earlier meaning to keep.
410
- const fromLegacy=status.kind==='valid'&&status.value.taskGrammar!==TASK_GRAMMAR;
409
+ const fromLegacy=status.kind==='valid'&&recordedTaskGrammar(status.value.taskGrammar)===LEGACY_TASK_GRAMMAR;
410
+ // Grammar 2 and 3 share declarations; 3 adds `- 开发: 会话`. The approval binds the
411
+ // grammar the publication carried (the cm-prd session's), so a grammar-2 draft never
412
+ // gains that meaning; with none carried (legacy, first approval) it binds 2, the
413
+ // grammar such drafts were written with.
414
+ const grammar=status.kind==='valid'&&!fromLegacy?status.value.taskGrammar:SHARED_TASK_GRAMMAR;
411
415
  for(const name of discovered.names){
412
416
  const source=fs.readFileSync(path.join(specsDir,name,'tasks.md'),'utf8');
413
- const parsed=parseFeatureTaskText(source,{allowDependencyPunctuation:true,grammar:TASK_GRAMMAR});
417
+ const parsed=parseFeatureTaskText(source,{allowDependencyPunctuation:true,grammar});
414
418
  if(parsed.error)return refuse('task_grammar_conflict',`${name}/tasks.md 第 ${parsed.detail.line} 行在新任务行语法下无效(${parsed.error}):`
415
419
  +`${parsed.detail.text}。此前的批准把它当作说明文字;把这类示例放进 \`\`\` 围栏或删去后再批准。`);
416
420
  if(!fromLegacy)continue;
417
421
  const view=grammar=>taskDeclarations(source,{grammar}).map(item=>({line:item.index+1,key:`${item.id}\0${item.completed}\0${item.body.trim()}`,text:item.body.trim()}));
418
- const legacy=view(LEGACY_TASK_GRAMMAR),current=view(TASK_GRAMMAR);
422
+ const legacy=view(LEGACY_TASK_GRAMMAR),current=view(grammar);
419
423
  const legacyKeys=new Set(legacy.map(item=>item.key)),currentKeys=new Set(current.map(item=>item.key));
420
424
  const differing=[...current.filter(item=>!legacyKeys.has(item.key)),...legacy.filter(item=>!currentKeys.has(item.key))]
421
425
  .sort((a,b)=>a.line-b.line);
@@ -426,7 +430,7 @@ export function approveCmAiSpecs(options){
426
430
  const specFiles=buildManifest(specsDir),at=new Date().toISOString();
427
431
  writeSpecsStatus(specsDir,{status:'approved',summaryDigest:status.value?.summaryDigest??null,at,
428
432
  features:discovered.names,specFiles,testCases:specFiles.filter(item=>item.path.endsWith('/test-cases.json')),
429
- approval:{response:options.approvalResponse,at},taskGrammar:TASK_GRAMMAR,
433
+ approval:{response:options.approvalResponse,at},taskGrammar:grammar,
430
434
  ...(status.value&&Object.hasOwn(status.value,'revisionDigest')?{revisionDigest:status.value.revisionDigest}:{})});
431
435
  }catch(error){return refuse(error.code??error.message);}
432
436
  return {projectResults:inspect()};
@@ -497,6 +501,8 @@ export function explainCmAiTaskSelection(admission,{feature,taskId,selection=nul
497
501
  }
498
502
 
499
503
  // Trusted caller selection is data bound by openControlRun, never message authority.
504
+ // A batch group may have one member (a task alone in its own worktree); every member,
505
+ // alone or not, must still be an eligible task of the feature.
500
506
  export function matchesCmAiTaskSelection(admission,feature,taskId,parallelSelection=null){
501
507
  if(parallelSelection===null)return admission.state==='ready'
502
508
  &&admission.nextTask?.feature===feature&&admission.nextTask.id===taskId;
@@ -506,7 +512,7 @@ export function matchesCmAiTaskSelection(admission,feature,taskId,parallelSelect
506
512
  &&admission.eligibleTasks?.some(task=>task.feature===feature&&task.id===taskId)===true;
507
513
  return admission.state==='ready'&&value?.version===1
508
514
  &&Object.keys(value).sort().join(',')==='group,version'&&Array.isArray(value.group)
509
- &&value.group.length>=2&&new Set(value.group).size===value.group.length
510
- &&value.group.every(id=>typeof id==='string'&&TASK_ID.test(id))&&value.group.includes(taskId)
515
+ &&value.group.length>=1&&new Set(value.group).size===value.group.length
516
+ &&value.group.every(isTaskId)&&value.group.includes(taskId)
511
517
  &&admission.eligibleTasks?.some(task=>task.feature===feature&&task.id===taskId)===true;
512
518
  }
@@ -67,18 +67,53 @@ const pendingAction=status=>status.state==='awaiting_spec_approval'?'spec_approv
67
67
  status.state==='fixture_completed'&&status.code==='qa_execution_unknown'?'reconcile':
68
68
  status.state==='fixture_completed'&&['qa_failed','qa_result_blocked'].includes(status.code)?'none':
69
69
  status.state==='fixture_completed'?'qa':'none';
70
+ // The class of a review that ended without a verdict (provider-review-observation.mjs
71
+ // REVIEWER_PROVIDER_FAILURES, e.g. reviewer_rate_limited), so a driver can act on it
72
+ // without parsing the reason text. Only a fixed-form class word is projected.
73
+ const REVIEW_FAILURE_CODES=new Set(['review_provider_failed','review_redispatch_limit']);
74
+ export const reviewFailureClass=status=>{
75
+ const inspection=status?.reviewInvocation?.result?.inspection,failure=inspection?.failure;
76
+ return ['pending_review','blocked'].includes(status?.state)&&REVIEW_FAILURE_CODES.has(status.code)
77
+ &&inspection?.kind==='cm-provider-review-failure'&&inspection.category==='provider'
78
+ &&typeof failure==='string'&&/^reviewer_[a-z_]{1,48}$/.test(failure)?failure:null;
79
+ };
80
+ const reviewInvocationId=status=>{const value=status?.reviewInvocation?.registration?.binding?.invocationId;
81
+ return typeof value==='string'&&/^[A-Za-z0-9_.:-]{1,128}$/.test(value)?value:null;};
82
+ // The exact stop a timed rate-limit retry may redispatch: same round (identity is
83
+ // checked by the caller), same reviewed package, the same failed invocation, and
84
+ // still the runner's automatic redispatch of a rate-limited review.
85
+ export const rateLimitStopMatches=(status,operation)=>status.packageDigest===operation.packageDigest
86
+ &&status.state==='pending_review'&&status.code==='review_provider_failed'&&reviewFailureClass(status)==='reviewer_rate_limited'
87
+ &&pendingAction(status)==='resume'&&reviewInvocationId(status)!==null
88
+ &&reviewInvocationId(status)===operation.expectedReviewStop.invocationId;
89
+ const staleRetry=(operation,status)=>freeze({...summary(operation,status,'rejected'),staleRetry:true,
90
+ reason:'状态已变,未自动重试:运行已不停在等待时那次审查限流(轮次、审查包、审查调用或状态变了),本次没有派发任何操作'});
91
+ // The class of a provider develop that ended on an API failure (worker-claude-developer.mjs,
92
+ // worker-codex-developer.mjs: developer_rate_limited, developer_server_error, ...), so a
93
+ // driver and the notice can name it without parsing text. Only a fixed-form class word.
94
+ export const developFailureClass=status=>{
95
+ const code=status?.calls?.at(-1)?.failureCode;
96
+ return ['blocked','unknown'].includes(status?.state)&&typeof code==='string'&&/^developer_[a-z_]{1,48}$/.test(code)?code:null;
97
+ };
70
98
  const summary=(operation,status,outcome)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
71
99
  requestDigest:digest(operation),identity:status.identity,outcome,state:status.state,code:status.code??null,
72
100
  packageDigest:status.packageDigest??null,pendingAction:pendingAction(status),
73
101
  ...(status.reviewReconciliation?{reviewReconciliation:status.reviewReconciliation}:{}),
102
+ ...(status.effectiveScope?{effectiveScope:status.effectiveScope}:{}),
103
+ ...(status.acceptedIntegrationDigest?{acceptedIntegrationDigest:status.acceptedIntegrationDigest}:{}),
74
104
  ...(status.developRedoRequired===true?{developRedoRequired:true}:{}),
75
105
  ...(status.documentationSyncPending===true?{documentationSyncPending:true}:{}),
76
106
  ...(status.reviewRedispatchStopRequired===true?{reviewRedispatchStopRequired:true}:{}),
107
+ ...(reviewFailureClass(status)!==null?{reviewFailure:reviewFailureClass(status),
108
+ ...(reviewInvocationId(status)?{reviewInvocationId:reviewInvocationId(status)}:{})}:{}),
77
109
  ...(typeof status.reviewAbandonRefusal==='string'?{reviewAbandonRefusal:status.reviewAbandonRefusal}:{}),
78
110
  ...(typeof status.reason==='string'?{reason:status.reason}:{}),
79
111
  ...(status.code==='handoff_exists'?{reason:REVIEWED_HANDOFF_HINT}:{}),
80
112
  ...(status.state==='blocked'&&status.calls?.at(-1)?.blockedReason!==undefined
81
- ?{blockedReason:status.calls.at(-1).blockedReason}:{})});
113
+ ?{blockedReason:status.calls.at(-1).blockedReason}:{}),
114
+ ...(['blocked','unknown'].includes(status.state)&&typeof status.calls?.at(-1)?.failureCode==='string'
115
+ ?{failureCode:status.calls.at(-1).failureCode}:{}),
116
+ ...(developFailureClass(status)!==null?{developFailure:developFailureClass(status)}:{})});
82
117
  const correctionSummary=(operation,status)=>status.code==='correction_review_required'
83
118
  ?summary(operation,status,'blocked'):null;
84
119
  // run_done is a project claim: every approved feature's latest mandatory QA must
@@ -97,11 +132,16 @@ function readOperation(raw) {
97
132
  const operation=json(raw),keys=['version','operation','requestId','identity'];
98
133
  if(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('packageDigest');
99
134
  if(['qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('testRunId');
100
- if(['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation?.operation))keys.push('reason');
135
+ if(['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','completion_rework','development_rework','revise_scope'].includes(operation?.operation))keys.push('reason');
101
136
  if(operation?.operation==='reconcile_review')keys.push('invocationId');
137
+ if(operation?.operation==='revise_scope')keys.push('scope');
138
+ // A driver's timed rate-limit retry (drive-core.mjs) names the review stop it
139
+ // waited for; the decision is refused unless the run is still exactly there.
140
+ if(operation?.operation==='decision'&&operation&&Object.hasOwn(operation,'expectedReviewStop'))keys.push('expectedReviewStop');
102
141
  shape(operation,keys);
142
+ if(Object.hasOwn(operation,'expectedReviewStop')){shape(operation.expectedReviewStop,['invocationId']);id(operation.expectedReviewStop.invocationId);}
103
143
  if(operation?.operation==='reconcile_review')id(operation.invocationId);
104
- need(operation.version===1&&['advance','start','status','decision','complete','qa','qa_result','context_refresh','finish','run_finalize','cancel','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo']
144
+ need(operation.version===1&&['advance','start','status','decision','complete','qa','qa_result','context_refresh','finish','run_finalize','cancel','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','completion_rework','development_rework','revise_scope']
105
145
  .includes(operation.operation));
106
146
  id(operation.requestId);validIdentity(operation.identity);
107
147
  if(operation.operation==='abandon_review')need(typeof operation.reason==='string'
@@ -110,6 +150,10 @@ function readOperation(raw) {
110
150
  if(operation.operation==='abandon_effect')need(typeof operation.reason==='string'
111
151
  &&operation.reason.trim().length>0&&Buffer.byteLength(operation.reason,'utf8')<=500
112
152
  &&!/[\r\n\0]/.test(operation.reason),'effect_abandon_reason_required');
153
+ if(operation.operation==='revise_scope')need(typeof operation.reason==='string'&&operation.reason.trim().length>0
154
+ &&Buffer.byteLength(operation.reason,'utf8')<=500&&!/[\r\n\0]/.test(operation.reason),'scope_revision_reason_required');
155
+ if(['completion_rework','development_rework'].includes(operation.operation))need(typeof operation.reason==='string'&&operation.reason.trim().length>0
156
+ &&Buffer.byteLength(operation.reason,'utf8')<=500&&!/[\r\n\0]/.test(operation.reason),`${operation.operation}_reason_required`);
113
157
  if(operation.operation==='develop_redo')need(typeof operation.reason==='string'
114
158
  &&operation.reason.trim().length>0&&Buffer.byteLength(operation.reason,'utf8')<=500
115
159
  &&!/[\r\n\0]/.test(operation.reason),'develop_redo_reason_required');
@@ -210,6 +254,9 @@ export function createCmAiConversationEntry(options) {
210
254
  if(options&&Object.hasOwn(options,'allowAbandonReview'))optionKeys.push('allowAbandonReview');
211
255
  if(options&&Object.hasOwn(options,'allowAbandonEffect'))optionKeys.push('allowAbandonEffect');
212
256
  if(options&&Object.hasOwn(options,'allowBootstrapReviewRecovery'))optionKeys.push('allowBootstrapReviewRecovery');
257
+ if(options&&Object.hasOwn(options,'allowCompletionRework'))optionKeys.push('allowCompletionRework');
258
+ if(options&&Object.hasOwn(options,'allowDevelopmentRework'))optionKeys.push('allowDevelopmentRework');
259
+ if(options&&Object.hasOwn(options,'allowScopeRevision'))optionKeys.push('allowScopeRevision');
213
260
  if(options&&Object.hasOwn(options,'allowDevelopRedo'))optionKeys.push('allowDevelopRedo');
214
261
  if(options&&Object.hasOwn(options,'holdRevision'))optionKeys.push('holdRevision');
215
262
  if(options&&Object.hasOwn(options,'featureSelection'))optionKeys.push('featureSelection');
@@ -222,6 +269,7 @@ export function createCmAiConversationEntry(options) {
222
269
  const runner=options.runner;
223
270
  const runnerKeys=['executeEffect','status','cancel','run'];
224
271
  if(runner&&Object.hasOwn(runner,'qaChangedFiles'))runnerKeys.push('qaChangedFiles');
272
+ if(runner&&Object.hasOwn(runner,'qaCompletionChecks'))runnerKeys.push('qaCompletionChecks');
225
273
  if(runner&&Object.hasOwn(runner,'verificationBlocks'))runnerKeys.push('verificationBlocks');
226
274
  if(runner&&Object.hasOwn(runner,'completionBlocks'))runnerKeys.push('completionBlocks');
227
275
  if(runner&&Object.hasOwn(runner,'reviewEffectIds'))runnerKeys.push('reviewEffectIds');
@@ -229,6 +277,7 @@ export function createCmAiConversationEntry(options) {
229
277
  if(runner&&Object.hasOwn(runner,'attachLearningEvidence'))runnerKeys.push('attachLearningEvidence');
230
278
  if(runner&&Object.hasOwn(runner,'inspectFixAssociation'))runnerKeys.push('inspectFixAssociation');
231
279
  if(runner&&Object.hasOwn(runner,'acceptCompletedFix'))runnerKeys.push('acceptCompletedFix');
280
+ if(runner&&Object.hasOwn(runner,'acceptReviewedIntegration'))runnerKeys.push('acceptReviewedIntegration');
232
281
  if(runner&&Object.hasOwn(runner,'attachQa'))runnerKeys.push('attachQa');
233
282
  if(runner&&Object.hasOwn(runner,'reviseQa'))runnerKeys.push('reviseQa');
234
283
  if(runner&&Object.hasOwn(runner,'supersedeEvidence'))runnerKeys.push('supersedeEvidence');
@@ -237,12 +286,16 @@ export function createCmAiConversationEntry(options) {
237
286
  if(runner&&Object.hasOwn(runner,'reconcileReview'))runnerKeys.push('reconcileReview');
238
287
  if(runner&&Object.hasOwn(runner,'abandonEffect'))runnerKeys.push('abandonEffect');
239
288
  if(runner&&Object.hasOwn(runner,'recoverBootstrapReview'))runnerKeys.push('recoverBootstrapReview');
289
+ if(runner&&Object.hasOwn(runner,'reworkCompletion'))runnerKeys.push('reworkCompletion');
290
+ if(runner&&Object.hasOwn(runner,'reworkDevelopment'))runnerKeys.push('reworkDevelopment');
291
+ if(runner&&Object.hasOwn(runner,'reviseScope'))runnerKeys.push('reviseScope');
240
292
  if(runner&&Object.hasOwn(runner,'redoDevelop'))runnerKeys.push('redoDevelop');
241
293
  if(runner&&Object.hasOwn(runner,'recoverCommit'))runnerKeys.push('recoverCommit');
242
294
  if(runner&&Object.hasOwn(runner,'interruptions'))runnerKeys.push('interruptions');
243
295
  if(runner&&Object.hasOwn(runner,'inspectBootstrapAdmission'))runnerKeys.push('inspectBootstrapAdmission');
244
296
  shape(runner,runnerKeys);
245
297
  if(Object.hasOwn(runner,'qaChangedFiles'))need(typeof runner.qaChangedFiles==='function');
298
+ if(Object.hasOwn(runner,'qaCompletionChecks'))need(typeof runner.qaCompletionChecks==='function');
246
299
  for(const name of ['executeEffect','status','cancel','run'])need(typeof runner[name]==='function');
247
300
  if(Object.hasOwn(runner,'completionBlocks'))need(typeof runner.completionBlocks==='function');
248
301
  if(Object.hasOwn(runner,'reviewEffectIds'))need(typeof runner.reviewEffectIds==='function');
@@ -268,6 +321,15 @@ export function createCmAiConversationEntry(options) {
268
321
  let bootstrapReviewRecoveryPermission=options.allowBootstrapReviewRecovery===true;
269
322
  need(options.allowDevelopRedo===undefined||typeof options.allowDevelopRedo==='boolean','invalid_input');
270
323
  let developRedoPermission=options.allowDevelopRedo===true;
324
+ need(options.allowCompletionRework===undefined||typeof options.allowCompletionRework==='boolean','invalid_input');
325
+ if(Object.hasOwn(runner,'reworkCompletion'))need(typeof runner.reworkCompletion==='function');
326
+ let completionReworkPermission=options.allowCompletionRework===true;
327
+ need(options.allowDevelopmentRework===undefined||typeof options.allowDevelopmentRework==='boolean','invalid_input');
328
+ if(Object.hasOwn(runner,'reworkDevelopment'))need(typeof runner.reworkDevelopment==='function');
329
+ // Elevated recovery is launch-only; wire options cannot grant it.
330
+ need(options.allowScopeRevision===undefined||typeof options.allowScopeRevision==='boolean','invalid_input');
331
+ if(Object.hasOwn(runner,'reviseScope'))need(typeof runner.reviseScope==='function');
332
+ // Elevated recovery is launch-only; wire options cannot grant it.
271
333
 
272
334
  const qaDecision=Object.hasOwn(options,'qaDecision')?json(options.qaDecision):null;
273
335
  const qaProvider=options.qaDecisionProvider??null;
@@ -375,11 +437,16 @@ export function createCmAiConversationEntry(options) {
375
437
  admissionReports.add(report);return report;
376
438
  }
377
439
  const initialStatus=runner.status();
440
+ // Checked before anything else, in this host that holds the run's writer
441
+ // lock for its lifetime: a stale timed retry dispatches nothing.
442
+ if(operation.operation==='decision'&&Object.hasOwn(operation,'expectedReviewStop')
443
+ &&!(sameIdentity(operation.identity,initialStatus.identity)&&rateLimitStopMatches(initialStatus,operation)))
444
+ return staleRetry(operation,initialStatus);
378
445
  const identity=json(initialStatus.identity);validIdentity(identity);
379
446
  need(sameTask(identity,ownerIdentity)&&identity.attempt>=ownerIdentity.attempt,'identity_mismatch');
380
447
  // Stable run-definition identity can query/control or resume the current
381
448
  // attempt. Package-bound mutations must name the current attempt exactly.
382
- const stableControl=['status','cancel','advance','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation.operation)
449
+ const stableControl=['status','cancel','advance','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','completion_rework','development_rework','revise_scope'].includes(operation.operation)
383
450
  &&sameIdentity(operation.identity,ownerIdentity);
384
451
  need(sameIdentity(operation.identity,identity)||stableControl,'identity_mismatch');
385
452
  if(operation.operation==='advance'){
@@ -496,6 +563,13 @@ export function createCmAiConversationEntry(options) {
496
563
  ...(qaExecutor.configuration?.plan?.dropped_task_cases?{droppedTaskCases:qaExecutor.configuration.plan.dropped_task_cases}:{}),
497
564
  ...(qaExecutor.configuration?.plan?.dropped_task_commands?{droppedTaskCommands:qaExecutor.configuration.plan.dropped_task_commands}:{}),
498
565
  ...(recovery?{previousTestRunId:recovery.testRunId}:{})});
566
+ // Only an executor whose plan declares reuseCheck receives the task
567
+ // checks; a package that no longer matches the code root yields null
568
+ // and the commands run as before.
569
+ let completionChecks=null;
570
+ if(qaExecutor.configuration?.plan?.commands?.some(item=>Object.hasOwn(item,'reuseCheck'))){
571
+ try{completionChecks=runner.qaCompletionChecks?.(result.packageDigest)??null;}catch{completionChecks=null;}
572
+ }
499
573
  const controller=new AbortController();pendingExecution=controller;
500
574
  let timer,timedOut=false;
501
575
  try{
@@ -508,7 +582,7 @@ export function createCmAiConversationEntry(options) {
508
582
  const executed=await Promise.race([Promise.resolve().then(()=>{
509
583
  notCancelled();
510
584
  need(!controller.signal.aborted,'cancelled');
511
- return qaExecutor.run(freeze(invocation),controller.signal);
585
+ return qaExecutor.run(freeze(completionChecks===null?invocation:{...invocation,completionChecks}),controller.signal);
512
586
  }),interrupted]);
513
587
  need(!controller.signal.aborted,'cancelled');
514
588
  // A run that moved on meanwhile (for example files in scope replaced):
@@ -588,6 +662,17 @@ export function createCmAiConversationEntry(options) {
588
662
  // V8: an interrupted step continues in the run (recorded); a void ends it.
589
663
  return summary(operation,boundStatus(result,identity),result.code==='effect_abandoned'?'abandoned':'recorded');
590
664
  }
665
+ if(operation.operation==='revise_scope'||operation.operation==='development_rework')
666
+ return summary(operation,{...runner.status(),code:operation.operation==='revise_scope'
667
+ ?'scope_revision_authorization_required':'development_rework_authorization_required'},'rejected');
668
+ if(operation.operation==='completion_rework'){
669
+ if(!completionReworkPermission)return summary(operation,{...runner.status(),code:'completion_rework_authorization_required'},'rejected');
670
+ completionReworkPermission=false;
671
+ const result=runner.reworkCompletion?.({allowed:true,reason:operation.reason})
672
+ ??{outcome:'rejected',code:'completion_rework_unavailable'};
673
+ if(result.outcome==='rejected')return summary(operation,{...runner.status(),code:result.code},'rejected');
674
+ return summary(operation,boundStatus(result,{...identity,attempt:2}),'recorded');
675
+ }
591
676
  if(operation.operation==='develop_redo'){
592
677
  if(!developRedoPermission)return summary(operation,{...runner.status(),
593
678
  code:'develop_redo_authorization_required'},'rejected');
@@ -838,7 +923,7 @@ export function createCmAiConversationEntry(options) {
838
923
  let token=null,operation=null;const epoch=cancellationEpoch;
839
924
  try{
840
925
  operation=readOperation(raw);
841
- if(!['status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation.operation)){
926
+ if(!['status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','completion_rework','development_rework','revise_scope'].includes(operation.operation)){
842
927
  token=Symbol(operation.operation);inFlightHandles.add(token);
843
928
  }
844
929
  const routed=await route(operation);
@@ -375,13 +375,17 @@ function recoverableCases(items,specsDir,environment,code='qa_rerun_not_blocked_
375
375
  return ['PASS','BLOCKED'].includes(logged.answered_verdict)
376
376
  &&(logged.answered_verdict!=='BLOCKED'||logged.host_declared_blocked===true);
377
377
  };
378
+ // A required cleanup the session answered without completing is the same host
379
+ // gap as a failed one; only the durable case row (blocked_reason, written with
380
+ // answered_verdict under recovery_rule 3) proves it, and the report must agree.
381
+ const skippedCleanup=row=>verdictRule&&row.cleanup!=='completed'&&blockedRows.get(row.id)?.blocked_reason==='cleanup';
378
382
  const eligible=row=>(
379
383
  row.kind==='logic'&&resolved(row)&&(row.staticVerdict==='INSUFFICIENT_EVIDENCE'
380
384
  // Blocked only by a mapped command without exit code, derived from the
381
385
  // recorded command rows; the executor's marker has to agree.
382
386
  ||row.staticVerdict==='SUPPORTED'&&mapped(row,unavailableCommand)&&row.commandUnavailable===true)
383
387
  ||row.kind==='browser'&&resolved(row)&&sessionVerdictOk(row)&&(typeof row.evidenceProblem==='string'&&row.evidenceProblem.length>0
384
- ||row.cleanup==='failed'||row.hostRequestTimeout===true||declaredInLog.has(row.id)&&row.hostDeclaredBlocked===true
388
+ ||row.cleanup==='failed'||skippedCleanup(row)||row.hostRequestTimeout===true||declaredInLog.has(row.id)&&row.hostDeclaredBlocked===true
385
389
  ||environment!=null&&row.environment!=null&&digest(row.environment)!==digest(environment))
386
390
  ||unavailableCommand(row));
387
391
  // A row BLOCKED only because the source changed during execution is recovered
@@ -50,6 +50,10 @@ export function configFingerprint(options) {
50
50
  }
51
51
 
52
52
  export function cleanEnvironment() {
53
- return Object.fromEntries(Object.entries(process.env).filter(([key]) =>
54
- ['PATH', 'HOME', 'USER', 'LOGNAME', 'TMPDIR', 'LANG', 'LC_ALL', 'CODEX_HOME'].includes(key)));
53
+ return {...Object.fromEntries(Object.entries(process.env).filter(([key]) =>
54
+ // CM_NOTIFY_OFF (runtime/js/notify.mjs) must survive, or a check or provider child
55
+ // that reaches the notice module would push from a run started silenced.
56
+ ['PATH', 'HOME', 'USER', 'LOGNAME', 'TMPDIR', 'LANG', 'LC_ALL', 'CODEX_HOME', 'CM_NOTIFY_OFF'].includes(key))),
57
+ // CM's own sessions are not a person typing: the skill-hints hook stays out of them.
58
+ CM_SKILL_HINTS: 'off'};
55
59
  }
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "type": "object",
3
3
  "additionalProperties": false,
4
- "required": ["outcome", "reason"],
4
+ "required": ["outcome", "reason", "requirements"],
5
5
  "properties": {
6
6
  "outcome": {"type": "string", "enum": ["implemented", "blocked"]},
7
- "reason": {"type": ["string", "null"]}
7
+ "reason": {"type": ["string", "null"]},
8
+ "requirements": {"type": ["array", "null"], "maxItems": 64, "items": {"type": "object", "additionalProperties": false, "required": ["requirement", "satisfied", "evidence", "run", "result"], "properties": {"requirement": {"type": "string"}, "satisfied": {"type": "boolean"}, "evidence": {"type": "string"}, "run": {"type": ["string", "null"], "enum": ["red", "baseline", null]}, "result": {"type": ["string", "null"], "enum": ["passed", "failed", null]}}}}
8
9
  }
9
10
  }