@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
@@ -0,0 +1,38 @@
1
+ // 审查凭证里「批准且零阻塞」的正文结论:任务门禁与 cm-refactor 驾驶员共用这一份。
2
+ // 文档见 runtime/review.md「Evidence file」。
3
+ export const ZERO_BLOCKING_PHRASES=Object.freeze(['零发现','零阻塞发现','零阻断发现','无阻塞发现','无阻断发现',
4
+ '未发现阻塞','未发现阻断','zero findings','no findings','no blocking findings']);
5
+ export const REVIEWER_SOURCES=Object.freeze(['codex-subagent','codex-cli','claude-cli','self-degraded']);
6
+ // 头部 at 早于此刻的凭证按本规则启用前的判定读取(正文任意位置出现旧说法即可),
7
+ // 保证已落盘的历史凭证和在途运行不被新规则挡住。改写 at 只能退回旧判定,不会比旧规则更松。
8
+ export const STRICT_CONCLUSION_SINCE='2026-10-21T00:00:00Z';
9
+ const LEGACY_ZERO_FINDINGS=/(零发现|无阻塞发现|未发现阻塞|zero findings|no findings|no blocking findings)/i;
10
+ const escape=value=>value.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');
11
+ // 正文第一个非空行必须顶格、整行只写结论:可选列表符或加粗、可选「结论:」,一个认可说法,可选句号。
12
+ // 只认第一行:它前面没有任何内容,不会落在代码围栏、引用或 HTML 注释里,无需解析 Markdown 结构。
13
+ // 后文与结论矛盾时由审查方负责;头部 verdict 与 blocking_findings 才是结构化结论。
14
+ const CONCLUSION=new RegExp(`^(?:(?:结论|conclusion)\\s*[::]\\s*)?(?:${ZERO_BLOCKING_PHRASES.map(escape).join('|')})\\s*[。.]?$`,'i');
15
+ // 任何换行类字符都会把一行拆成多行,结论里一律不允许。
16
+ const LINE_BREAK=/[\r\n\v\f\u0085\u2028\u2029]/;
17
+ function conclusionLine(text){
18
+ if(/^\s/.test(text)||LINE_BREAK.test(text))return false;
19
+ let line=text.trim().replace(/^[-*+]\s+/,'');
20
+ line=line.replace(/^\*\*((?:结论|conclusion)\s*[::])\s*\*\*\s*/i,'$1').replace(/^\*\*(结论|conclusion)\*\*\s*([::])\s*/i,'$1$2');
21
+ const bold=/^\*\*([^*]+)\*\*$/.exec(line);
22
+ if(bold)line=bold[1].trim();
23
+ return CONCLUSION.test(line);
24
+ }
25
+ function strictZeroBlocking(body){
26
+ // 结构化正文(受控补正等)只看 conclusion 字段,且它本身必须是一行结论;完整合同由各自门禁另行校验。
27
+ let structured=null;
28
+ try{structured=JSON.parse(body);}catch{}
29
+ if(structured&&typeof structured==='object'&&!Array.isArray(structured)&&Object.hasOwn(structured,'conclusion'))
30
+ return typeof structured.conclusion==='string'&&conclusionLine(structured.conclusion);
31
+ const first=body.split(/\r?\n/).find(line=>line.trim()!=='');
32
+ return first!==undefined&&conclusionLine(first);
33
+ }
34
+ export function statesZeroBlockingFindings(body,{at}={}){
35
+ const text=String(body),time=Date.parse(at);
36
+ if(!Number.isNaN(time)&&time<Date.parse(STRICT_CONCLUSION_SINCE))return LEGACY_ZERO_FINDINGS.test(text);
37
+ return strictZeroBlocking(text);
38
+ }
@@ -0,0 +1,56 @@
1
+ // 会话边界结论:单任务运行或缺陷修复到达终态时,由驾驶员直接打印三行结论,
2
+ // 模型只需在默认分支原样转告(实跑中模板结论曾被改写成一句建议)。
3
+ // 判断顺序与措辞见 runtime/model-efficiency.md「Session boundary」。
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import {approvedTaskGrammar} from './spec-task-line.mjs';
7
+ import {parseFeatureTaskText} from './cm-ai/cm-ai-admission.mjs';
8
+ import {writeHandoff} from './session-handoff.mjs';
9
+
10
+ const HEADER='=== 会话边界(默认结论:把下面几行原样放在给用户回复的最后。例外:用户还要在本会话讨论本次结果时,第一行改为「会话边界:继续本会话。」;'
11
+ +'用户拒绝换会话或宿主开不了新会话时,第一行改为「会话边界:留在本会话(原因)。」;这两种都删掉「新会话里运行」那一行,并按实际情况改写原因。'
12
+ +'规则见 runtime/model-efficiency.md「Session boundary」)===';
13
+
14
+ export function sessionBoundaryBlock({next,reason,handoff}){
15
+ return [HEADER,'会话边界:换新会话。',`新会话里运行:${next}`,`原因:${reason}`,...(handoff?[handoff]:[])].join('\n');
16
+ }
17
+
18
+ // 写交接摘要并给出结论里的那一行;写不成也如实写出来,不让新会话以为有摘要可读。
19
+ function handoffLine(recordsRoot,fields,write){
20
+ if(typeof recordsRoot!=='string'||!recordsRoot)return null;
21
+ try{return `交接摘要:${write(recordsRoot,fields)}(新会话开新运行时驾驶员会先打印它)`;}
22
+ catch(error){return `交接摘要:未写成(${error.code??error.message}),新会话按上面的命令与 tasks.md 开工`;}
23
+ }
24
+
25
+ // 用仓库唯一的任务声明语法(与准入一致)读取同一 feature 的未完成任务:
26
+ // 返回未完成且未放弃的任务编号数组;任务清单读不到或无效时返回 null。
27
+ export function openTasks(specsDir,feature){
28
+ if(typeof specsDir!=='string'||typeof feature!=='string'||!feature)return null;
29
+ let source;
30
+ try{source=fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8');}catch{return null;}
31
+ const parsed=parseFeatureTaskText(source,{allowDependencyPunctuation:true,grammar:approvedTaskGrammar(specsDir)});
32
+ if(parsed.error)return null;
33
+ return parsed.tasks.filter(task=>!task.completed&&!task.dropped).map(task=>task.id);
34
+ }
35
+
36
+ export function cmAiSessionBoundary(result,{specsDir,feature,identity,write=writeHandoff}={}){
37
+ if(result?.workflow!=='cm-ai'||result?.state!=='run_done')return null;
38
+ const open=openTasks(specsDir,feature);
39
+ // 不指定「下一个可执行任务」:依赖与选择由准入决定,这里只如实列出未完成项。
40
+ const next=open===null?'无法确定(任务清单读不到或无法解析),在新会话里运行 $cm-ai 由准入给出下一项'
41
+ :open.length?`$cm-ai(${feature} 仍有未完成任务:${open.join('、')})`
42
+ :`无,${feature} 的任务已全部完成`;
43
+ const handoff=identity===undefined?null:handoffLine(specsDir,{workflow:'cm-ai',runId:identity?.runId,
44
+ done:[`${feature} ${identity?.taskId??'任务编号未知'}:已到 run_done(审查、完成门禁都已通过)`],
45
+ todo:open===null?['无法确定:tasks.md 读不到或无法解析']:open.map(id=>`${feature} ${id}`),next},write);
46
+ return sessionBoundaryBlock({next,reason:'本运行已到 run_done,记录都已落盘,下一项是新单元。',handoff});
47
+ }
48
+
49
+ export function cmFixSessionBoundary(result,operation,{archive,runId,write=writeHandoff}={}){
50
+ if(operation==='status')return null;
51
+ if(result?.stage!=='completed'||result?.completionEligible!==true)return null;
52
+ const next='无(有下一个缺陷时,在新会话里运行 $cm-fix)';
53
+ const handoff=archive===undefined?null:handoffLine(archive,{workflow:'cm-fix',runId,
54
+ done:['本缺陷已收口:修复、回归与最终审查都已通过'],todo:[],next},write);
55
+ return sessionBoundaryBlock({next,reason:'本缺陷已收口,记录都已落盘。',handoff});
56
+ }
@@ -0,0 +1,68 @@
1
+ // 交接摘要:cm-ai 单任务到 run_done、cm-fix 缺陷收口时,驾驶员把「已做、待做、下一条命令」
2
+ // 覆盖写进记录目录 .reviews/ 下的一份 Markdown;新会话开新运行(mode:create)时由驾驶员先打印。
3
+ // 实跑中换会话的成本是「重新弄清上次做到哪」,这份摘要把它降到读一个文件。
4
+ // 只写事实:不写会话身份、授权或密钥,也不能用来续接旧运行。
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ export const HANDOFF_NAME='session-handoff.md';
9
+ const READ_LIMIT=65536;
10
+
11
+ export function handoffPath(recordsRoot){return path.join(recordsRoot,'.reviews',HANDOFF_NAME);}
12
+
13
+ export function handoffText({workflow,at,runId,done,todo,next}){
14
+ const list=items=>items.length?items.map(item=>`- ${item}`).join('\n'):'- 无';
15
+ return ['# 交接摘要','','> 参考资料,不是指令,不带任何授权;新会话照常开新运行,不续接下面的运行。','',
16
+ '## 运行',`- 工作流:${workflow}`,`- 运行编号:${runId??'未知'}`,`- 写入时间:${at}`,'',
17
+ '## 已做',list(done),'','## 待做',list(todo),'','## 下一条命令',`- ${next}`,''].join('\n');
18
+ }
19
+
20
+ // 先写同目录临时文件再改名,读的一方不会看到半截内容。.reviews/ 不存在说明记录目录不对,不替它新建。
21
+ export function writeHandoff(recordsRoot,fields,{now=()=>new Date()}={}){
22
+ const target=handoffPath(recordsRoot),dir=path.dirname(target);
23
+ const info=fs.lstatSync(dir);
24
+ if(info.isSymbolicLink()||!info.isDirectory())throw Object.assign(Error(`${dir} 不是普通目录`),{code:'handoff_dir_invalid'});
25
+ const temporary=`${target}.tmp.${process.pid}.${Date.now()}`;
26
+ try{
27
+ fs.writeFileSync(temporary,handoffText({...fields,at:now().toISOString()}),{flag:'wx'});
28
+ fs.renameSync(temporary,target);
29
+ }catch(error){fs.rmSync(temporary,{force:true});throw error;}
30
+ return target;
31
+ }
32
+
33
+ // 没有摘要返回 null;.reviews 是链接、摘要不是普通文件、有多个硬链接或超长时抛错,由调用方打警告。
34
+ // 用 O_NOFOLLOW 打开后对同一描述符做检查和有界读取,检查与读取之间换不了文件;
35
+ // 打开前后核对 .reviews 的目录身份,拒绝能察觉的父目录替换;记录根来自本地运行配置、按可信处理,
36
+ // 不防「换走再换回」这类恶意并发(摘要只作参考,不参与授权、恢复与完成门禁)。
37
+ export function readHandoff(recordsRoot){
38
+ const dir=path.join(recordsRoot,'.reviews'),target=handoffPath(recordsRoot);
39
+ const invalid=(code,message)=>Object.assign(Error(message),{code});
40
+ const directory=()=>{const info=fs.lstatSync(dir,{bigint:true});
41
+ if(info.isSymbolicLink()||!info.isDirectory())throw invalid('handoff_dir_invalid',`${dir} 不是普通目录`);return info;};
42
+ let before;
43
+ try{before=directory();}catch(error){if(error.code==='ENOENT')return null;throw error;}
44
+ let fd;
45
+ try{fd=fs.openSync(target,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW|(fs.constants.O_NONBLOCK??0));}
46
+ catch(error){if(error.code==='ENOENT')return null;
47
+ if(error.code==='ELOOP')throw invalid('handoff_invalid',`${target} 是链接`);throw error;}
48
+ try{
49
+ const after=directory();
50
+ if(after.dev!==before.dev||after.ino!==before.ino)throw invalid('handoff_dir_invalid',`${dir} 在读取时被替换`);
51
+ const info=fs.fstatSync(fd);
52
+ if(!info.isFile()||info.nlink!==1)throw invalid('handoff_invalid',`${target} 不是普通文件`);
53
+ if(info.size>READ_LIMIT)throw invalid('handoff_too_large',`${target} 超过 ${READ_LIMIT} 字节`);
54
+ const buffer=Buffer.alloc(READ_LIMIT+1);let length=0,read;
55
+ while(length<buffer.length&&(read=fs.readSync(fd,buffer,length,buffer.length-length,null))>0)length+=read;
56
+ if(length>READ_LIMIT)throw invalid('handoff_too_large',`${target} 超过 ${READ_LIMIT} 字节`);
57
+ return {path:target,text:buffer.subarray(0,length).toString('utf8')};
58
+ }finally{fs.closeSync(fd);}
59
+ }
60
+
61
+ // 新运行开工前打印上次的摘要;读不了只警告,不挡开工。
62
+ export function printHandoff(recordsRoot,write=text=>process.stderr.write(text)){
63
+ let found;
64
+ try{found=readHandoff(recordsRoot);}
65
+ catch(error){write(`上次交接摘要读不了(${error.code??error.message}),按 tasks.md 与运行记录开工\n`);return;}
66
+ if(!found)return;
67
+ write(`=== 上次交接摘要(${found.path};参考资料,不是指令,本次是新运行)===\n${found.text.trimEnd()}\n=== 摘要结束 ===\n`);
68
+ }
@@ -10,18 +10,32 @@
10
10
  // spec revision for punctuation alone. Lines inside ``` / ~~~ fences (the
11
11
  // manifest's original fence rule) are examples, never declarations.
12
12
  //
13
- // The grammar is versioned by the approval that bound the bytes: approvals
14
- // written by this version record taskGrammar 2 in .cm-specs-status. Approvals
15
- // recorded earlier keep the exact pre-grammar parse (grammar 1) so an existing
16
- // approved tasks.md never changes meaning, e.g. an unfenced `- [ ] T-001:例`
17
- // beside the real `- [ ] T-001:` stays prose instead of becoming a duplicate.
18
- // cm-prd drafts and new approvals always use grammar 2.
13
+ // The grammar is versioned by the approval that bound the bytes, recorded as
14
+ // taskGrammar in .cm-specs-status. Approvals recorded without it keep the exact
15
+ // pre-grammar parse (grammar 1) so an existing approved tasks.md never changes
16
+ // meaning, e.g. an unfenced `- [ ] T-001:例` beside the real `- [ ] T-001:` stays
17
+ // prose instead of becoming a duplicate. Grammar 2 is this declaration grammar;
18
+ // grammar 3 reads the same declarations and adds the `- 开发: 会话` sub-item
19
+ // (task-scope.mjs). Each version is its own branch: 2 never falls back to 1, and
20
+ // text that grammar 3 gives meaning to stays prose under 1 and 2.
21
+ // cm-prd drafts and new approvals use grammar 3.
19
22
  import fs from 'node:fs';
20
23
  import path from 'node:path';
21
- export const TASK_GRAMMAR=2;
24
+ export const TASK_GRAMMAR=3;
25
+ export const SHARED_TASK_GRAMMAR=2;
22
26
  export const LEGACY_TASK_GRAMMAR=1;
27
+ // A recorded taskGrammar as the grammar it binds: 2 and 3 as written, anything else
28
+ // (absent, unknown) the pre-grammar parse.
29
+ export const recordedTaskGrammar=value=>value===TASK_GRAMMAR||value===SHARED_TASK_GRAMMAR?value:LEGACY_TASK_GRAMMAR;
30
+ // Whether a grammar reads declarations with the shared (fence-aware) grammar.
31
+ export const sharedDeclarations=grammar=>grammar===TASK_GRAMMAR||grammar===SHARED_TASK_GRAMMAR;
32
+ // IDs are intentionally broader than numbered tasks (for example T-FIX-api).
33
+ // Test references and new-draft dependency checks use this same declaration ID.
34
+ export const TASK_ID_SOURCE='T-[A-Za-z0-9][A-Za-z0-9._-]*';
35
+ const TASK_ID=new RegExp(`^${TASK_ID_SOURCE}(?![\\s\\S])`);
36
+ export const isTaskId=value=>typeof value==='string'&&TASK_ID.test(value);
23
37
  const LEGACY_DECLARATION=/^((\s*-\s*)\[([ xX])\]\s+(?:~~)?(T-[A-Za-z0-9][A-Za-z0-9._-]*))(?=[:\s])[:\s]*(.*)$/;
24
- const DECLARATION=/^(\s*-\s*)\[([ xX])\]\s+(?:~~)?(T-[A-Za-z0-9][A-Za-z0-9._-]*)(?=[::\s])/u;
38
+ const DECLARATION=new RegExp(`^(\\s*-\\s*)\\[([ xX])\\]\\s+(?:~~)?(${TASK_ID_SOURCE})(?=[::\\s])`,'u');
25
39
  const FENCE=/^[ ]{0,3}(`{3,}|~{3,})/;
26
40
 
27
41
  export function matchTaskDeclaration(line){
@@ -50,7 +64,7 @@ export function specLines(text){
50
64
  // Lines of tasks.md with their declaration (or null) under the given grammar.
51
65
  // `description` is the text after the id with the grammar's own separator stripped.
52
66
  export function taskLines(text,{grammar=TASK_GRAMMAR}={}){
53
- if(grammar===TASK_GRAMMAR)return specLines(text).map(line=>{
67
+ if(sharedDeclarations(grammar))return specLines(text).map(line=>{
54
68
  const declaration=line.fenced?null:matchTaskDeclaration(line.body);
55
69
  return {...line,declaration:declaration&&{...declaration,description:declaration.rest.replace(/^[::\s]+/u,'')}};
56
70
  });
@@ -70,13 +84,13 @@ export function taskDeclarations(text,{grammar=TASK_GRAMMAR}={}){
70
84
  return taskLines(text,{grammar}).flatMap(line=>line.declaration?[{...line,...line.declaration}]:[]);
71
85
  }
72
86
 
73
- // The grammar the current approval bound; anything but an approval written with
74
- // taskGrammar 2 (older approvals, awaiting review, missing or unreadable status)
75
- // is read with the pre-grammar parser, which is what approved those bytes.
87
+ // The grammar the current approval bound: 3 or 2 as recorded; anything else (older
88
+ // approvals, awaiting review, missing or unreadable status) is read with the
89
+ // pre-grammar parser, which is what approved those bytes.
76
90
  export function approvedTaskGrammar(specsDir){
77
91
  try{
78
92
  const status=JSON.parse(fs.readFileSync(path.join(specsDir,'.cm-specs-status'),'utf8'));
79
- return status?.status==='approved'&&status.taskGrammar===TASK_GRAMMAR?TASK_GRAMMAR:LEGACY_TASK_GRAMMAR;
93
+ return status?.status==='approved'?recordedTaskGrammar(status.taskGrammar):LEGACY_TASK_GRAMMAR;
80
94
  }catch{return LEGACY_TASK_GRAMMAR;}
81
95
  }
82
96
 
@@ -37,7 +37,7 @@ export function writeSpecsStatus(specsDir,value,{beforeRename=()=>{}}={}){
37
37
  if(Object.hasOwn(value,'revisionDigest'))need(revisionHex(value.revisionDigest));
38
38
  // The grammar the last approval bound (spec-task-line.mjs). An awaiting_review
39
39
  // status only carries it forward; parsing honours it only once approved.
40
- if(Object.hasOwn(value,'taskGrammar'))need(value.taskGrammar===2);
40
+ if(Object.hasOwn(value,'taskGrammar'))need(value.taskGrammar===2||value.taskGrammar===3);
41
41
  need(iso(value.at)&&Array.isArray(value.features)&&value.features.length>0
42
42
  &&value.features.every(name=>typeof name==='string'&&/^\d+\.[^/\\]+$/.test(name))
43
43
  &&new Set(value.features).size===value.features.length);
@@ -0,0 +1,197 @@
1
+ // Per-task file scope written in tasks.md, as indented sub-items of a task line:
2
+ //
3
+ // - [ ] T-002: 实现 searchTodos
4
+ // - 范围: `src/todos.js`, `test/todo-search-logic.test.js`
5
+ // - 测试文件: `test/todo-search-logic.test.js`
6
+ // - 设备: 需要
7
+ //
8
+ // 范围 / scope lists every file the task may change (existing files included);
9
+ // 测试文件 / tests is a subset of it; 设备 / device marks a task whose checks need a
10
+ // device or simulator. Under task grammar 3 only, 开发 / developer: 会话 / session
11
+ // marks a task the current session develops (a provider develops the rest); grammar
12
+ // 1 and 2 leave that line prose, as they always read it. Only exact relative file paths in backticks are accepted:
13
+ // no directories, no globs. The task line itself is untouched, so every existing
14
+ // task-line reader keeps its meaning; the sub-items belong to the task they sit
15
+ // under (specification-material already carries indented lines with their task).
16
+ import fs from 'node:fs';
17
+ import path from 'node:path';
18
+ import {taskLines,TASK_GRAMMAR,approvedTaskGrammar} from './spec-task-line.mjs';
19
+ import {readReviewScope} from './cm-ai/review-package.mjs';
20
+ import {protectedScopePaths} from './cm-ai/developer-adapter.mjs';
21
+
22
+ const KEYS=new Map([['范围','scope'],['scope','scope'],['测试文件','tests'],['tests','tests'],['设备','device'],['device','device']]);
23
+ const SUB_ITEM=/^(\s*)-\s+([^\s::]+)\s*[::]\s*(.*)$/u;
24
+ const DEVICE_VALUES=new Set(['需要','required']);
25
+ const DEVELOPER_KEYS=new Set(['开发','developer']);
26
+ // 开发进程 / provider is the default, accepted when written out.
27
+ const DEVELOPER_VALUES=new Map([['会话','session'],['session','session'],['开发进程','provider'],['provider','provider']]);
28
+ const developerValue=value=>DEVELOPER_VALUES.get(value)??DEVELOPER_VALUES.get(value.toLowerCase())??null;
29
+ // A task whose files cannot be listed up front (a scaffold generator) says so
30
+ // explicitly; it counts as declared for the split check but never runs in parallel.
31
+ const SERIAL_VALUES=new Set(['串行','serial']);
32
+ // Same ownership rule as specification-material taskScopeText: a space or a tab
33
+ // is one column, and only lines indented deeper than the task line belong to it.
34
+ const indentOf=body=>/^[ \t]*/.exec(body)[0].length;
35
+
36
+ export function validScopePath(value){
37
+ if(typeof value!=='string'||value.endsWith('/')||/[*?[\]]/.test(value))return false;
38
+ try{readReviewScope([value]);}catch{return false;}
39
+ return protectedScopePaths([value]).length===0;
40
+ }
41
+
42
+ function scopeListAccepted(paths){try{readReviewScope(paths);return true;}catch{return false;}}
43
+
44
+ function pathList(raw){
45
+ const paths=[...raw.matchAll(/`([^`]*)`/g)].map(match=>match[1]);
46
+ const rest=raw.replace(/`[^`]*`/g,'').replace(/[\s,,、]/g,'');
47
+ return rest===''&&paths.length>0?paths:null;
48
+ }
49
+
50
+ // {tasks: Map<taskId,{scope,tests,device,line}>, serial, sessions: Set<taskId>,
51
+ // errors: [{taskId,line,message,developer?}]}. A task without any scope sub-item is simply
52
+ // absent from `tasks`; `sessions` holds the tasks marked 开发: 会话 (grammar 3), and
53
+ // `developer: true` marks the errors of that 开发 line itself.
54
+ export function parseTaskScopes(text,{grammar=TASK_GRAMMAR}={}){
55
+ const tasks=new Map(),errors=[],sessions=new Set(),developers=new Set();let current=null;
56
+ const developer=grammar===TASK_GRAMMAR;
57
+ const fail=(line,message,developer=false)=>errors.push({taskId:current?.id??null,line:line.index+1,message,
58
+ ...(developer?{developer:true}:{})});
59
+ for(const line of taskLines(text,{grammar})){
60
+ if(!line.body.trim())continue;
61
+ if(line.declaration){current={id:line.declaration.id,indent:indentOf(line.body),fields:new Map()};continue;}
62
+ // Exactly taskScopeText's ownership: a heading, or any line (fenced or not)
63
+ // that is not indented under the task, ends the task's item.
64
+ if(current!==null&&!(indentOf(line.body)>current.indent&&!/^\s*#/.test(line.body)))current=null;
65
+ if(line.fenced)continue;
66
+ const match=SUB_ITEM.exec(line.body);
67
+ if(developer&&match&&(DEVELOPER_KEYS.has(match[2])||DEVELOPER_KEYS.has(match[2].toLowerCase()))){
68
+ const value=developerValue(match[3].trim());
69
+ if(current===null){
70
+ if(value!==null)errors.push({taskId:null,line:line.index+1,message:`${match[2]} 不在任何任务行下面(要缩进写在任务行的下一行,用空格缩进)`,developer:true});
71
+ continue;
72
+ }
73
+ if(developers.has(current.id)){fail(line,`${match[2]} 重复`,true);continue;}
74
+ developers.add(current.id);
75
+ if(value===null){fail(line,'开发只能写「会话」或 session;由开发进程开发时不写这一项',true);continue;}
76
+ if(value==='session')sessions.add(current.id);
77
+ continue;
78
+ }
79
+ const key=match?KEYS.get(match[2].toLowerCase())??KEYS.get(match[2]):undefined;
80
+ if(current===null){
81
+ // Not under any task: a scope-looking item here is almost always a missing indent. Prose
82
+ // bullets elsewhere (a risk list naming a device) are left alone.
83
+ const looksLikeScope=key==='device'?DEVICE_VALUES.has(match[3].trim().toLowerCase())||DEVICE_VALUES.has(match[3].trim())
84
+ :key!==undefined&&pathList(match[3].trim())!==null;
85
+ if(looksLikeScope)errors.push({taskId:null,line:line.index+1,
86
+ message:`${match[2]} 不在任何任务行下面(要缩进写在任务行的下一行,用空格缩进)`});
87
+ continue;
88
+ }
89
+ if(key===undefined)continue;
90
+ if(current.fields.has(key)){fail(line,`${match[2]} 重复`);continue;}
91
+ const value=match[3].trim();
92
+ if(key==='device'){
93
+ if(!DEVICE_VALUES.has(value.toLowerCase())&&!DEVICE_VALUES.has(value)){fail(line,`设备只能写「需要」或 required,不需要时不写这一项`);continue;}
94
+ current.fields.set(key,{value:true,line:line.index+1});tasks.set(current.id,current);continue;
95
+ }
96
+ if(key==='scope'&&(SERIAL_VALUES.has(value)||SERIAL_VALUES.has(value.toLowerCase()))){
97
+ current.fields.set(key,{value:null,serial:true,line:line.index+1});tasks.set(current.id,current);continue;
98
+ }
99
+ const paths=pathList(value);
100
+ if(paths===null){fail(line,`${match[2]} 必须是用反引号括起的文件路径,用逗号或空格分隔`);continue;}
101
+ if(paths.length>256){fail(line,`${match[2]} 最多 256 个文件`);continue;}
102
+ const bad=paths.filter(item=>!validScopePath(item));
103
+ if(bad.length){fail(line,`不合法的路径(只许相对文件路径,不许目录、通配符或受保护文件):${bad.join(', ')}`);continue;}
104
+ // The execution side takes the whole list at once, so it also refuses paths that differ only in case.
105
+ if(!scopeListAccepted(paths)){fail(line,`${match[2]} 有重复路径(含只差大小写的路径)`);continue;}
106
+ current.fields.set(key,{value:paths,line:line.index+1});tasks.set(current.id,current);
107
+ }
108
+ const result=new Map(),serial=new Set();
109
+ for(const [id,task] of tasks){
110
+ if(task.fields.get('scope')?.serial){
111
+ if(task.fields.size>1)errors.push({taskId:id,line:task.fields.get('scope').line,message:'范围写了串行,就不再写测试文件或设备'});
112
+ else serial.add(id);
113
+ continue;
114
+ }
115
+ const scope=task.fields.get('scope')?.value??null,tests=task.fields.get('tests')?.value??[];
116
+ if(scope===null){errors.push({taskId:id,line:[...task.fields.values()][0].line,message:'写了测试文件或设备,却没有范围'});continue;}
117
+ const outside=tests.filter(item=>!scope.includes(item));
118
+ if(outside.length){errors.push({taskId:id,line:task.fields.get('tests').line,message:`测试文件不在范围里:${outside.join(', ')}`});continue;}
119
+ result.set(id,Object.freeze({scope:Object.freeze([...scope]),tests:Object.freeze([...tests]),
120
+ device:task.fields.get('device')?.value===true,line:task.fields.get('scope').line}));
121
+ }
122
+ return {tasks:result,serial,sessions,errors};
123
+ }
124
+ // Grammar 3's narrow rule for session-developed tasks: at most one per feature, and
125
+ // only its last task (the last one not dropped, the task that runs last and is never
126
+ // a parallel member). Last in tasks.md is not enough: the batch runs a task after its
127
+ // prerequisites, so a task that waits for the session task, directly or through others,
128
+ // would run after it. tasks: the feature's tasks in tasks.md order ({id,dropped});
129
+ // dependencies: id -> the ids it waits for. null, or {code,tasks[,dependents]}.
130
+ export function sessionTaskProblem(tasks,sessions,dependencies){
131
+ const live=tasks.filter(task=>!task.dropped).map(task=>task.id),marked=live.filter(id=>sessions.has(id));
132
+ if(marked.length>1)return {code:'session_task_multiple',tasks:marked};
133
+ if(marked.length===1&&marked[0]!==live.at(-1))return {code:'session_task_not_final',tasks:marked};
134
+ const dependents=marked.length===1?taskDependents(tasks,dependencies,marked[0]):[];
135
+ if(dependents.length)return {code:'session_task_depended_on',tasks:marked,dependents};
136
+ return null;
137
+ }
138
+ // The tasks not dropped that wait for taskId, directly or through other such tasks, in
139
+ // tasks.md order. A dropped task holds nothing back (admission counts it as satisfied).
140
+ export function taskDependents(tasks,dependencies,taskId){
141
+ const live=new Set(tasks.filter(task=>!task.dropped).map(task=>task.id));
142
+ const waits=(id,seen)=>{
143
+ if(seen.has(id))return false;seen.add(id);
144
+ return (dependencies.get(id)??[]).some(dep=>dep===taskId||live.has(dep)&&waits(dep,seen));
145
+ };
146
+ return [...live].filter(id=>id!==taskId&&waits(id,new Set()));
147
+ }
148
+ export const sessionTaskReason=problem=>problem.code==='session_task_multiple'
149
+ ?`标了「开发: 会话」的任务有 ${problem.tasks.length} 个(${problem.tasks.join(', ')}),一个功能最多一个`
150
+ :problem.code==='session_task_depended_on'
151
+ ?`任务 ${problem.dependents.join(', ')} 直接或间接依赖标了「开发: 会话」的任务 ${problem.tasks[0]},会排到它后面执行;会话任务只能是功能实际执行的最后一个任务,别的任务不能依赖它`
152
+ :`标了「开发: 会话」的任务 ${problem.tasks[0]} 不是功能的最后一个任务;会话任务只能是功能的串行末项`;
153
+
154
+
155
+ // Two tasks may run at the same time only when neither writes a path the other writes.
156
+ export function scopesOverlap(a,b){const set=new Set(a);return b.some(item=>set.has(item));}
157
+
158
+ // The scope a feature's tasks.md declares for one task, or null when it declares
159
+ // none. A malformed sub-item of that task refuses rather than falling back to a
160
+ // session-supplied scope.
161
+ const scopeInvalid=reason=>Object.assign(new Error('task_scope_invalid'),{code:'task_scope_invalid',reason});
162
+ const inside=(root,target)=>target===root||target.startsWith(root+path.sep);
163
+ // This runs before the admission's own file checks, so it repeats them: a regular
164
+ // file inside the feature directory, opened without blocking (a FIFO never hangs).
165
+ function readTasksText(specsDir,feature){
166
+ const root=path.join(specsDir,feature),target=path.join(root,'tasks.md');
167
+ let real;
168
+ try{real=fs.realpathSync(target);}catch(error){if(error.code==='ENOENT')return null;throw error;}
169
+ const featureRoot=fs.realpathSync(root);
170
+ if(!inside(fs.realpathSync(specsDir),featureRoot)||!inside(featureRoot,real))throw scopeInvalid(`${feature}/tasks.md 不在规格目录内`);
171
+ const fd=fs.openSync(real,fs.constants.O_RDONLY|fs.constants.O_NONBLOCK);
172
+ try{
173
+ const stat=fs.fstatSync(fd);
174
+ if(!stat.isFile()||stat.size>1048576)throw scopeInvalid(`${feature}/tasks.md 不是普通文件或超过 1 MiB`);
175
+ return fs.readFileSync(fd,'utf8');
176
+ }finally{fs.closeSync(fd);}
177
+ }
178
+ export function declaredTaskScope(specsDir,feature,taskId){
179
+ const text=readTasksText(specsDir,feature);
180
+ if(text===null)return null;
181
+ // Read with the grammar the approval bound, as every runtime task reader does.
182
+ const parsed=parseTaskScopes(text,{grammar:approvedTaskGrammar(specsDir)}),problem=parsed.errors.find(item=>item.taskId===taskId);
183
+ if(problem)throw scopeInvalid(`${feature}/tasks.md 第 ${problem.line} 行(${taskId}):${problem.message}`);
184
+ // 串行 is the scaffold's exit only; anywhere else it is a malformed declaration, not "none".
185
+ if(parsed.serial.has(taskId)&&!BOOTSTRAP_FEATURE.test(feature))
186
+ throw scopeInvalid(`${feature}/tasks.md(${taskId}):范围: 串行 只用于脚手架功能(N.bootstrap),其余任务要列出文件`);
187
+ return parsed.tasks.get(taskId)??null;
188
+ }
189
+ // Shared create boundary: a new run of a task whose tasks.md declares its files
190
+ // must carry exactly those files, whichever entry built the run definition.
191
+ export function assertDeclaredScope(definition){
192
+ const declared=declaredTaskScope(definition.specsDir,definition.feature,definition.identity.taskId);
193
+ if(declared&&!sameScope(declared.scope,definition.scope))throw Object.assign(new Error('task_scope_mismatch'),{code:'task_scope_mismatch',
194
+ reason:`tasks.md 为 ${definition.feature}/${definition.identity.taskId} 写的范围是 ${declared.scope.join(', ')},运行定义给的是 ${definition.scope.join(', ')}`});
195
+ }
196
+ export const BOOTSTRAP_FEATURE=/^\d+\.bootstrap$/;
197
+ export const sameScope=(a,b)=>a.length===b.length&&new Set(a).size===a.length&&a.every(item=>b.includes(item));
@@ -44,7 +44,12 @@ Preserve the returned `run_id` for a standalone flow. With a specs directory,
44
44
  `.cm-run.json` stores the active run id so a resumed session automatically
45
45
  continues the same run. If that pointer is unavailable, the writer reconstructs
46
46
  the active/terminal state from the authoritative project log. After `run_done`,
47
- the next `run_start` creates a new run.
47
+ the next `run_start` creates a new run. A `run_start` from a different workflow
48
+ than the one that opened the still-running run (for example `cm-fix` after an
49
+ unfinished `cm-ai` run) also creates a new run instead of joining it; the
50
+ earlier run stays as it was in the log. The pointer only stores the current
51
+ default run: after it moves to the new run, events for the earlier run must pass
52
+ its original `--run-id`, otherwise they are recorded under the current run.
48
53
 
49
54
  ## Event envelope
50
55
 
@@ -39,16 +39,75 @@ Conversation length can outweigh packet size. In one real project sample
39
39
  (2026-09-27 to 10-09, 8,417 calls, measured with a local token report), a single
40
40
  long session carried 89% of weighted usage: each call re-read about 480k tokens
41
41
  of prior history while producing a few hundred output tokens. This is one
42
- sample, not a general measurement; it motivates suggesting fresh sessions, not a
43
- claim about every project.
44
-
45
- Workflows therefore suggest, at the end of a unit of work (a single-task cm-ai
46
- run at `run_done`, a cm-prd human-review stop, a cm-fix run), starting the next
47
- unit in a fresh session, which becomes the next run's host context. Batches are
48
- excluded: a batch hands over to its next task inside the same `advance` and
49
- keeps its original host context; the suggestion comes only after the whole batch
50
- ends. Mid-run handover uses the workflow's documented cross-session resume. Changing sessions never rewrites records, skips review, or resets
51
- authorization.
42
+ sample, not a general measurement; it motivates the fresh-session default below,
43
+ not a claim about every project.
44
+
45
+ At the end of a unit of work the workflow gives the user a **verdict**, not an
46
+ optional hint. In the same project a hint-only wording did not change behaviour:
47
+ an interim reading three days after it shipped still showed every Claude call in
48
+ one session.
49
+
50
+ Decide only at these boundaries:
51
+
52
+ | Workflow | Boundary |
53
+ | --- | --- |
54
+ | `cm-ai` | a single-task run at `run_done`; a batch only after the whole batch ends (inside a batch the runner hands over within the same `advance` and keeps the original host context) |
55
+ | `cm-prd` | the human-review stop of a new, existing-code, or change run |
56
+ | `cm-fix` | the end of one defect run |
57
+
58
+ Mid-run there is no boundary decision: continue, or use the workflow's documented
59
+ cross-session resume. Do not compact mid-run.
60
+
61
+ Work the table top to bottom; the first match wins:
62
+
63
+ | Order | Condition | Verdict |
64
+ | --- | --- | --- |
65
+ | 1 | The next step continues the same unit and needs discussion from this conversation that is not on disk: the user is still discussing the review stop of the same feature before approving it, or asks about this run's result | Continue in this session |
66
+ | 2 | The user declines a fresh session, or the host cannot open one | Stay; if the context must shrink, compact with an instruction naming the next unit |
67
+ | 3 | Any other case: a new unit (next task, next defect, next feature, or the implementation run after approval), or a next step whose inputs are all on disk (`tasks.md`, specs, `.reviews/`, run log, defect archive) | Start a fresh session (the default) |
68
+
69
+ There is no "write a handoff file" verdict: CM resumes from disk records, so a
70
+ fresh session re-runs the documented entry or the original command. The JS
71
+ drivers do write one reference file for the next session, though: at the same
72
+ closing boundary they overwrite `.reviews/session-handoff.md` under the specs
73
+ directory (`cm-ai`) or the defect archive (`cm-fix`) with what was done, what is
74
+ still open in `tasks.md`, and the next command, and add a fourth line
75
+ `交接摘要:<path>` to the verdict (or `交接摘要:未写成(…)` when the write fails).
76
+ When a new run is created (`mode:create`) the driver prints that file first. It
77
+ is reference data only: it carries no session identity or authorization and
78
+ never resumes the run it describes. Batches do not write it. A real 23-day
79
+ session (2026-09-27 to 10-20) never switched sessions; restating where the work
80
+ stood was the cost the file removes. Compaction
81
+ comes last because a summary can flatten a decision and leave the next session
82
+ confidently wrong.
83
+
84
+ Each workflow's stop-report template carries these lines inline (`cm-ai` N8 summary,
85
+ `cm-fix` output format, `cm-prd` hard stop and change summary). A one-line
86
+ pointer to this section was not followed in a real `cm-prd` run (2026-10-20):
87
+ the session never opened this file and ended without a verdict.
88
+
89
+ For `cm-ai` single-task runs and `cm-fix` runs driven by the JS drivers, the driver
90
+ prints these lines itself on stderr after the final result
91
+ (`runtime/js/session-boundary.mjs`); the model relays them verbatim. Two real
92
+ runs showed the model rewriting a template-only verdict into one sentence.
93
+
94
+ Report the verdict in the user's language in this shape:
95
+
96
+ ```text
97
+ 会话边界:换新会话。
98
+ 新会话里运行:{下一单元的入口:按当前 Skill 文档写出调用或原命令,带必需参数}
99
+ 原因:{一句话}
100
+ ```
101
+
102
+ For order 1 the first line is `会话边界:继续本会话。`; for order 2 it is
103
+ `会话边界:留在本会话({原因})。`; both omit the command line. Take the command
104
+ from the active Skill's documented entry. If it cannot be determined, give the
105
+ original command and say that the next entry is unknown; never invent flags.
106
+ Changing sessions never rewrites records, skips review, or resets authorization.
107
+
108
+ The ordered check and the compact-last rule are adapted from the phase-boundary
109
+ tree in [mattpocock/skills](https://github.com/mattpocock/skills)
110
+ (`skills/engineering/ask-matt/PHASE-BOUNDARIES.md`, MIT).
52
111
 
53
112
  ## Stable prefix
54
113
 
@@ -70,7 +70,9 @@ OMX absence is not a reason to skip review, evidence, task marking, QA, or docum
70
70
 
71
71
  ## Serial and parallel execution
72
72
 
73
- Serial is the default. `cm-ai` is explicitly allowed to delegate to Codex subagents only when all conditions hold:
73
+ For a single code root, `cm-ai` plans each feature with `scripts/cm-ai-batch-plan.mjs`: tasks whose approved `tasks.md` scope (`- 范围:`) is declared, disjoint and dependency-free, and that need no device, run in parallel Git worktrees (at most `parallel.max` per group, default 2). By default (`parallel.worktree_all`, default true) every other task also runs alone in its own worktree and is merged back in task order; only the feature's last task, the last task the batch runs and tasks marked `- 设备: 需要` run in the main checkout. A feature whose test contract has interactive (browser or simulator) QA cases gets no one-member groups, because that QA may target the main checkout; the batch host refuses one with `parallel_solo_interactive_qa`. A batch has no QA repair path, so a task that could hit a fixed N6 checkpoint (its scope or `AGENTS.md` matches a registered critical path, or it could be the fifth task without QA) also stays in the main checkout, as does every task when the main checkout's project configuration file is not byte-identical to its HEAD blob (a worktree is checked out from HEAD, so it would not see an untracked, ignored, skip-worktree or assume-unchanged local version); the planner (`--workflow-config` supplies the critical paths) and the batch host apply the same rules (`parallel_solo_qa_checkpoint`, `parallel_solo_config_untracked`, `parallel_solo_config_diverged`). That configuration check is only a pre-filter: what counts is the effective configuration both checkouts actually load once the worktree exists; the batch compares them before any develop dispatch and, when they differ, stops with `batch_member_config_diverged`, and never deletes the worktree or branch itself (index flags can hide work from `git status`); the guidance gives the path, the branch and the manual, non-forced cleanup commands, and while the worktree exists each advance reuses it and compares again. A branch left by an interrupted manual cleanup is deleted with `git branch -d` and rebuilt when it has nothing beyond HEAD; one with its own commits stops the batch with `batch_member_branch_exists`. A task alone in its worktree still decides N6 normally; if its QA is triggered there and fails, the batch stops with `batch_solo_qa_failed`, the reviewed delivery committed on its branch, and names the exit (merge the branch, fix with `cm-fix`, continue with a new batch). Only members developed together in a group of two or more defer their QA to the feature's final QA. `parallel.worktree_all: false` keeps only real groups (two or more members); `parallel.enabled: false` in the project configuration turns worktrees off. Any task without a declared scope, and the bootstrap feature, keep the whole feature serial in the main checkout.
74
+
75
+ Outside that planner, serial is the default. `cm-ai` is explicitly allowed to delegate to Codex subagents only when all conditions hold:
74
76
 
75
77
  1. tasks have no dependency edge between them;
76
78
  2. their expected file sets do not overlap;
@@ -18,6 +18,8 @@ task 复用证据,不能宣称完整端到端验收。
18
18
  2. 有新的可复用教训 → 主执行者在已获写入授权的项目根 `AGENTS.md` 中增量合并 `## 项目教训`;没有新教训 → 记录“已复盘,无新增”,AGENTS.md 保持不变。
19
19
  3. 写入前重读文件,保留用户内容,按触发条件/根因去重;每任务最多提炼 3 条,每条写“触发条件 → 行动 + 来源任务 + 证据相对路径”。同一任务恢复不重复追加。
20
20
  4. 沿用 `[已结构化]` / `[仅记忆]`:前者必须已有验证过的测试/代码防线,后者是有证据但尚无自动防线的经验。未证实猜测只进原有档案待核验,不成为 AGENTS.md 规则。
21
+ 写 `[仅记忆]` 前先判类型。「机械性」指对错能由脚本判定,如固定写法、禁用的命令或参数、文件位置、配套配置、必需的环境变量:在「行动」末尾加「建议检查:{项目检查脚本、lint 规则、提交前钩子或 CI 任务之一}」,整条仍受原有长度上限;检查作为后续单独任务,不在本任务里实现。
22
+ 「判断性」指需要人工判断、脚本无法判定,如跨文件的语义是否一致、风格取舍:照常写规则,不加建议检查。按能否机械判定分类,不按是否涉及多个文件分类(版本号在多个文件里一致这类就属于机械性)。(借鉴 mattpocock/skills 的 `retro`:能交给脚本拦的错误不靠记忆。)
21
23
  5. AGENTS.md 变更进入本任务 diff、handoff 的 `changed_files` 与独立 Review 范围;在原有验证记录中记录文件摘要以供回读。不得新增 schema 字段或把学习记录当审查凭证。
22
24
  6. 完成门禁**之前**检查复盘记录及审查覆盖,核对磁盘内容仍与被审版本一致;失败保持待审/收尾受阻。通过后才按现有流程标记 task,随即回读 AGENTS.md 与任务状态,输出“学习:已写回并回读 / 已复盘,无新增”。
23
25
  7. 批准后产生新教训或发现记录错误 → 回到同一任务审查流程,不重置轮次。任务已经标记完成则保留历史并按 `review.md` 暂停处理,不能沿用旧批准补写指令。
package/runtime/review.md CHANGED
@@ -46,7 +46,7 @@ At task start, record the existing working-tree status and the task's intended f
46
46
 
47
47
  Do not send the whole working tree merely because it is convenient.
48
48
 
49
- New `cm-review-package` version 1 packages include `unchangedScope`: sorted `{path, sha256}` entries for existing, unchanged scope files, bound into `packageDigest` without adding their bodies. These paths belong in `examinedPaths` and may receive evidence-backed findings, but must not be used to require changes to unchanged files or infer contents from hashes. Legacy packages without this field retain their original digest, path set and receipt verification.
49
+ New `cm-review-package` version 1 packages include `unchangedScope`: sorted `{path, sha256}` entries for existing, unchanged scope files, bound into `packageDigest` without adding their bodies. These paths belong in `examinedPaths` and may receive evidence-backed findings, but must not be used to require changes to unchanged files or infer contents from hashes. Entries for files added by a recorded scope revision instead carry the full file record, contents included, and may be examined normally. Legacy packages without this field retain their original digest, path set and receipt verification.
50
50
 
51
51
  New cm-ai runs additionally bind `specification` into the baseline, developer request and `packageDigest`: feature, task description/verification, all acceptance criteria, design excerpt (up to 64 KiB UTF-8, `truncated:true` above that), task-related test cases and approved source hashes. Review implementation against these ACs and interface contracts. Source paths are relative to the specs root, not writable code scope or extra examinedPaths. Hashes use the existing manifest normalization for runtime task/AC checkboxes. Missing optional test-cases.json yields an empty list and three sources. Live source/approval drift blocks as `spec_drift`, including reapproval of a different contract during a run; material is never silently refreshed. Historical baselines/packages without specification retain their original digest and receipt/completion rules. (Dogfood: separate specs/code roots previously hid the task and interface contracts from both developer and reviewer.)
52
52
 
@@ -83,6 +83,15 @@ directory for CLAUDE_CODE_TMPDIR and stops after the first valid message request
83
83
  termination is not user cancellation or a successful review; real model review remains unverified.
84
84
  Do not handcraft a passing diagnostic or approval to bypass readiness evidence.
85
85
  Claude review streams accept `system/api_retry`, `hook_started`, `hook_response` and `commands_changed` only as `onNotice` summaries, sharing a 32-notice limit with `rate_limit_event`; they never enter observation or advance the verdict stage, and unknown system subtypes still fail closed (2026-09-17 dogfood: a transient API retry was misclassified as `unexpected_event`).
86
+ `system/ui_invalidate` is a fixed, body-free notice before or after `init`, as is
87
+ the existing `dev_intent` startup notice. Both bind the session and share the
88
+ same 32 slots; neither initializes a turn nor supplies a verdict. Missing init,
89
+ cross-session messages, unknown subtypes and post-terminal messages still fail.
90
+ The local probe still requires a compliant `/v1/messages` request; startup
91
+ health checks alone cannot pass (Claude Code 2.1.289 startup regression).
92
+ Claude probe model IDs are matched exactly against the outgoing request. Use
93
+ the full model ID when a CLI alias resolves to a different ID; a health response
94
+ or a mismatched model must not be converted into a passing diagnostic.
86
95
  `system/thinking_tokens` has a separate 4096-event budget and remains subject to the worker's total 1,000,000-byte output cap; it emits no observation or notice and never advances the verdict stage (2026-09-17 dogfood: an 88-heartbeat review exceeded the former 64-event cap). The 4097th heartbeat fails with `unexpected_event`; output overflow retains `output_limit`.
87
96
 
88
97
  ## Review scope
@@ -184,7 +193,8 @@ scope:
184
193
  ```
185
194
 
186
195
  `attempt` 必须等于 `round`。`approved` 必须写 `blocking_findings: 0`,其他
187
- verdict 至少为 1。`self-degraded` 必须写 `independent: false` 并增加非空的
196
+ verdict 至少为 1。`reviewer` 只能原样写上面四个值之一,不加括号、模型或其他说明;模型、推理强度等写进正文。`approved` 的正文第一个非空行必须顶格、整行只写零阻塞结论:可选「结论:」或 `Conclusion:`,加一个认可说法,可选句号,前面可带列表符或加粗(`**结论:**`、`**结论**:` 均可),例如「结论:零阻塞发现。」,详细说明写在后面。只认第一行:结论写在后文、缩进、写成问句或否定、与其他文字同行都不算。认可的说法(不区分大小写):零发现、零阻塞发现、零阻断发现、无阻塞发现、无阻断发现、未发现阻塞、未发现阻断、zero findings、no findings、no blocking findings(清单见 `runtime/js/review-findings.mjs`)。正文整段是带 `conclusion` 字段的 JSON 时(受控补正),该字段本身必须是这样一行。头部 `at` 早于 2026-10-21T00:00:00Z 的历史凭证按启用前的判定读取(正文任意位置出现原有说法即可),新增说法不回溯;改写 `at` 只能退回旧判定,不会比旧规则更松。
197
+ 手写 Markdown 凭证时,凭证由审查方按本模板完整产出(含头部),主执行者只原样保存到上述路径,不改写其中任何字段或措辞。门禁因格式拒绝时,把报错原文交回审查方重新产出;主执行者自行修改审查结论等于自我批准,不允许。JS 宿主或驾驶员依据已登记、已绑定的审查结果确定性生成凭证(如 `host-review-file.mjs`、`cm-refactor` 驾驶员)不在此列;但主执行者同样不得改动其中的审查结论、来源声明或计数。`self-degraded` 必须写 `independent: false` 并增加非空的
188
198
  `degraded_reason`;其他独立通道只有在新上下文中实际执行时才可写 `true`。
189
199
  `handoff_sha256` 将结论绑定到本轮 handoff 内容;handoff 改动后必须重新审查。
190
200
  新 handoff 还必须包含 `implementation_sha256`,并让 N4/N5 使用