@aibyzero/cm-workflow 0.13.3 → 0.15.2

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 (99) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +41 -0
  3. package/README.md +34 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/js-workflow-control.md +55 -0
  7. package/docs/user-guide.md +3 -0
  8. package/package.json +1 -1
  9. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +1 -0
  10. package/runtime/js/cm-ai/cm-ai-admission.mjs +53 -22
  11. package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +4 -5
  12. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +40 -17
  13. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +103 -23
  14. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +8 -4
  15. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +5 -2
  16. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  17. package/runtime/js/cm-ai/developer-adapter.mjs +17 -5
  18. package/runtime/js/cm-ai/durable-runner-state.mjs +7 -2
  19. package/runtime/js/cm-ai/effect-contract.mjs +8 -1
  20. package/runtime/js/cm-ai/execution-store.mjs +25 -5
  21. package/runtime/js/cm-ai/host-check.mjs +20 -1
  22. package/runtime/js/cm-ai/host-conversation-execution.mjs +5 -4
  23. package/runtime/js/cm-ai/host-documentation.mjs +2 -2
  24. package/runtime/js/cm-ai/host-qa-executor.mjs +46 -24
  25. package/runtime/js/cm-ai/host-qa-policy.mjs +3 -1
  26. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +41 -3
  27. package/runtime/js/cm-ai/qa-environment.mjs +22 -0
  28. package/runtime/js/cm-ai/task-runner.mjs +1 -0
  29. package/runtime/js/cm-ai/worker-claude-developer.mjs +2 -1
  30. package/runtime/js/cm-fix/cause-package.mjs +3 -1
  31. package/runtime/js/cm-fix/dossier.mjs +7 -2
  32. package/runtime/js/cm-fix/reproduce.mjs +26 -5
  33. package/runtime/js/cm-fix/visual.mjs +3 -2
  34. package/runtime/js/cm-fix/walkthrough.mjs +2 -1
  35. package/runtime/js/cm-init/draft-generation.mjs +3 -2
  36. package/runtime/js/cm-init/draft-inspection.mjs +17 -3
  37. package/runtime/js/cm-init/review-evidence.mjs +1 -1
  38. package/runtime/js/cm-prd/summary.mjs +6 -8
  39. package/runtime/js/cm-security/finalize.mjs +164 -0
  40. package/runtime/js/cm-test/host.mjs +2 -2
  41. package/runtime/js/specs-status.mjs +66 -0
  42. package/runtime/project-context.md +4 -1
  43. package/scripts/cm-ai-admission.mjs +46 -7
  44. package/scripts/cm-ai-admission.test.mjs +50 -0
  45. package/scripts/cm-ai-batch-host.mjs +72 -10
  46. package/scripts/cm-ai-batch-host.test.mjs +128 -4
  47. package/scripts/cm-ai-batch-run.mjs +366 -17
  48. package/scripts/cm-ai-batch-run.test.mjs +222 -13
  49. package/scripts/cm-ai-bootstrap.test.mjs +3 -2
  50. package/scripts/cm-ai-host.mjs +38 -21
  51. package/scripts/cm-ai-host.test.mjs +68 -4
  52. package/scripts/cm-ai-nested-execution.test.mjs +1 -1
  53. package/scripts/cm-ai-run.mjs +25 -15
  54. package/scripts/cm-ai-run.test.mjs +48 -0
  55. package/scripts/cm-blocked-reason.test.mjs +104 -0
  56. package/scripts/cm-capability-gate.test.mjs +179 -0
  57. package/scripts/cm-check-update.mjs +5 -2
  58. package/scripts/cm-check-update.test.mjs +21 -0
  59. package/scripts/cm-codex-developer-adapter.test.mjs +70 -0
  60. package/scripts/cm-fix-cause-package.test.mjs +18 -1
  61. package/scripts/cm-fix-execution.test.mjs +31 -0
  62. package/scripts/cm-fix-host-review.test.mjs +2 -1
  63. package/scripts/cm-fix-host.test.mjs +2 -1
  64. package/scripts/cm-fix-observation-dossier.test.mjs +2 -0
  65. package/scripts/cm-fix-qa-source.test.mjs +1 -3
  66. package/scripts/cm-fix-reproduce.test.mjs +53 -2
  67. package/scripts/cm-fix-review-recovery.test.mjs +4 -3
  68. package/scripts/cm-host-check.test.mjs +22 -0
  69. package/scripts/cm-host-qa-executor.test.mjs +302 -3
  70. package/scripts/cm-host-qa-policy.test.mjs +34 -0
  71. package/scripts/cm-init-draft-generation.test.mjs +24 -3
  72. package/scripts/cm-init-draft-inspection.test.mjs +80 -0
  73. package/scripts/cm-init-host.mjs +2 -2
  74. package/scripts/cm-init-host.test.mjs +3 -1
  75. package/scripts/cm-init-session.test.mjs +37 -0
  76. package/scripts/cm-log-event.mjs +28 -7
  77. package/scripts/cm-prd-design-phase.test.mjs +2 -1
  78. package/scripts/cm-prd-host.test.mjs +3 -2
  79. package/scripts/cm-prd-session-recovery.test.mjs +5 -4
  80. package/scripts/cm-qa-environment.test.mjs +30 -0
  81. package/scripts/cm-security.mjs +12 -4
  82. package/scripts/cm-security.test.mjs +109 -0
  83. package/scripts/cm-specs-status.test.mjs +130 -0
  84. package/scripts/cm-workflow-config.mjs +4 -0
  85. package/scripts/test-shell-compat.sh +0 -0
  86. package/skills/cm-ai/references/N1-init.md +22 -15
  87. package/skills/cm-ai/references/N5-mark-done.md +5 -2
  88. package/skills/cm-ai/references/N6-qa-eval.md +9 -4
  89. package/skills/cm-ai/references/js-host.md +25 -0
  90. package/skills/cm-fix/SKILL.md +5 -4
  91. package/skills/cm-fix/references/js-host.md +13 -0
  92. package/skills/cm-idea/SKILL.md +2 -0
  93. package/skills/cm-init/references/runtime-declaration.md +2 -0
  94. package/skills/cm-prd/SKILL.md +9 -8
  95. package/skills/cm-prd/references/spec-self-check.md +1 -0
  96. package/skills/cm-security/SKILL.md +14 -7
  97. package/skills/cm-security/references/scan-contract.md +45 -1
  98. package/skills/cm-test/references/js-host.md +4 -3
  99. package/templates/dashboard/dashboard.html +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.13.3",
3
+ "version": "0.15.2",
4
4
  "description": "Spec-driven product development workflow for Codex: external research, PRD, implementation, read-only feature testing, review, QA, fixes, refactors, and documentation.",
5
5
  "author": {
6
6
  "name": "cm-workflow maintainers",
package/CHANGELOG.md CHANGED
@@ -7,6 +7,47 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.15.2 — 2026-09-19
11
+
12
+ - **同 feature 并行开发现在可用**:`parallel` 字段此前只存在于代码,没有任何文档或 Skill 提过它,而执行规则要求「不发明字段」,功能因此从入口够不着。现补齐 `docs/js-workflow-control.md` 的「并行组」一节(字段形状、五条约束与失败码、工作树与分支命名、串行合并、QA 延后、review 前置),并在 `cm-ai` N1 增加提议规则:只对 scope 全为新建文件、互不重叠、无依赖路径的同 feature 任务成组,组不起来就串行,不为组而组。
13
+ - **并行提速的真实范围**:当前会话模式下成员的开发请求逐个应答,重叠的是 runner 推进与各自的独立审查进程,不是写代码本身。文档与规则均写明这一点,避免按成倍提速预期使用。
14
+ - **修复链式依赖被并发执行**:并行组的依赖校验此前只看直接边,`A → B → C` 时 `{A, C}` 会被放行并发开发。两者在各自工作树基于 `HEAD` 创建、看不到彼此产物,而组内 scope 本就不重叠,Git 也不会报冲突,错误不会暴露。改为按依赖图的传递闭包判定。
15
+ - **修复保留的 WIP 分支挡住后续批次**(**升级注意**):成员被阻断时会有意保留分支作为证据,但分支名不含 `batchId`,那个名字被永久占住,同一任务的任何后续批次都在 `git worktree add -b` 处报 `batch_worktree_failed`,换 `batchId` 也绕不开,只能手工删分支。分支名改为 `cm/{batchId 前 8 字符}/{feature}/{taskId}`。**升级前创建、尚未收口的并行批次恢复时会报 `batch_worktree_mismatch`,请用旧版本收尾该批次**;`parallel` 此前无文档,预期不存在这类在途批次。
16
+ - **QA 环境补齐桌面与后端/CLI/库形态**:`kind`/`carrier` 此前只有 web/app/miniprogram,而 cm-prd 与用户确认的交付形态包含桌面与多端,并另行承认「纯本地工具、库等无部署形态的项目」。这些项目要开 QA 只能谎报 `web`+`browser`,而该字段会进 QA 执行配置并随每个用例请求下发。新增 `desktop`→`app-window`、`service`→`cli`/`http-api`、`library`→`none`。同一张取值表原本在四个模块里逐字重复,现抽为 `runtime/js/cm-ai/qa-environment.mjs` 单一来源,并修掉四份拷贝共有的隐患:`kind` 传 `__proto__` 时解析到 `Object.prototype` 而抛 TypeError,现用 `Object.hasOwn` 判否。
17
+ - **METRICS 增加「执行方式」列**:记录该任务是串行执行还是并行组成员(`并行:组内{N}个`),否则无法区分耗时变化来自并行还是任务本身。看板模板同步适配列位。
18
+ - **文档补两处契约坑**:`preflight --review-model` 必须是 CLI 实际写进请求体的完整模型 id,别名会以 `model_matches:false` 判失败而回执不给期望值;`check` 回复的 `result` 就是检查数组本身,不套 `{status,value}`,用错会以 `invalid_input` 停在 `reconcile` 且重试无效。
19
+
20
+ ## 0.15.1 — 2026-09-19
21
+
22
+ - **cm-security 接入统一运行日志合同**:`cm-security` 此前从未引用 `runtime/logging.md`,cm-check 第 3 组「共用运行日志与统一 writer」因此判 failed。该断链自 0.12.0 引入安全扫描时就存在——同一个 commit 把 `cm-security` 写进了检查清单,却没给新建的 Skill 加上引用。现补齐引用,并明确落盘时机:范围与安全边界确认后写 `run_start`,`--finalize` 返回终态后写 `run_done`,只记录扫描范围、结论词、发现数量、覆盖率与报告路径;工具原始输出、密钥原文、源码片段与 findings 正文不进日志,`BLOCKED` 同样收尾。这是文本约定补齐,扫描逻辑与报告门禁未变,只读边界不变。无 specs 目录时仍按既有设计只写全局镜像。
23
+ - **版本标志按安装模式解析**:`cm-check-update.mjs` 此前只看根目录有没有 `VERSION` 文件就判定「这是源码仓库」。Claude 兼容安装的根目录就是 `~/.claude`,那里任何与 CM 无关的 `VERSION` 都会顶替 `templates/cm-VERSION` 成为当前版本;若其版本号更高,降级守卫会抛错并让整个 cm-check 返回 `blocked`。现改为优先读当前 runtime 自己的标志,仅在该标志缺失时(源码仓库与 tarball 没有 `templates/cm-VERSION`)才回退到根 `VERSION`,Codex 路径行为不变。同时对齐 `runtime/project-context.md` 的工作流根校验——`install.sh` 只写 `templates/cm-VERSION`,从不往安装目录写根 `VERSION`,原先要求根 `VERSION` 的规则在所有 claude-compat 安装上都无法满足。
24
+
25
+ ## 0.15.0 — 2026-09-19
26
+
27
+ - 浏览器验收能力改为启动时断言:开启 QA,且规格含阻塞 browser 用例或被 `policies.tests` 选中的 browser 用例时,`cm-ai-host` 与 `cm-ai-batch-host` 必须显式给 `--browser-qa available|unavailable`;因任务未完成而延后的适用用例也计入。`unavailable` 以 `browser_capability_unavailable` 拒绝启动,错误 JSON 仍只输出 code;使用者需换到具备浏览器能力的会话,或调整验收范围并重新审批规格。不命中时给该参数报 `invalid_arguments`。这是**声明不是探测**,声明不持久化,创建与恢复均须重新声明。
28
+ - **配置兼容性变更**:共享配置加载器现在要求 `policies.tests` 含 `browser` 时,`roles.browser_qa.adapter` 必须为 `browser`。此前可用的显式 `browser_qa: {adapter: local, model: none, source: local}` 配合默认测试策略(包含 browser),升级后会被拒绝,影响所有使用共享配置加载器的入口。需要浏览器 QA 的使用者应将适配器改为 `browser`(保留 `model: none, source: local`),或删除该角色覆盖以继承默认 browser 角色;不需要浏览器 QA 时,应将 `policies.tests` 显式设为如 `[logic, commands]`。省略整个 browser_qa 角色仍可继承默认值;移除策略中的 browser 不会排除阻塞 browser 用例,相关验收范围仍需明确处理。
29
+ - 统一 `.cm-specs-status` 读写:cm-prd 使用共享原子 writer;cm-ai 新增 `--approve --approval-response`,只放行指定准入原因,禁止 `--yes` 写审批位,写后重跑准入。审批沿用原 `summaryDigest`(缺失为 null),兼容读取旧文件并在下次写入去掉 `via` 等自由字段;cm-idea 明确保持在 specs 上游。
30
+
31
+ - `cm-security` 新增报告门禁 `--finalize --scan ... --review ...`:严格校验逐路径复核输入,机械补齐漏报、重验复核窗口漂移并保留扫描窗口证据,统一在项目外生成报告并给出四种结论之一。无发现且覆盖为 FULL 仍是 `REVIEWED_PARTIAL`,不存在「干净」的结论词;模型不能传入 `result`、`coverage` 或 `aiReview`。报告原样保留通过校验的分析结论与修复建议,stdout 只含摘要字段。
32
+ - 批次首次推进要求 Git 主工作区干净(含未跟踪文件);否则以 `batch_main_dirty` 列出脏文件,在任务启动及创建工作树之前阻断。串行任务在 `start_next_task` 交接前自动提交,`batch_handoff.task_commit` 记录 SHA(无改动为 null)。并行组先合并 ready 成员,再保存终态成员 WIP、移除工作树并保留分支;通过 `batch_member_blocked` 日志恢复一次性的 generation 2 串行降级。
33
+ - 开发者结构化输出模式(Codex 两个 schema 与 Claude 提案 schema)新增可空 `reason`,`validateClaudeProposal` 同步放行该键:此前模式为 `additionalProperties:false` 且不含该键,CLI 派发下模型无法给出 blocked 原因,落盘功能在真实路径上等同未生效。`validateDeveloperValue` 将任意 outcome 下的 `reason: null` 归一为缺省,`implemented` 带非空 reason 仍按 `invalid_result` 拒绝。
34
+ - 开发结果 `blocked` 的可选 `reason` 以 `blockedReason` 持久化到开发调用记录:字符串 trim 后非空、至多 1000 UTF-8 字节,禁止 NUL 及除换行、制表符外的 C0 控制字符。终态仍为 `failed/result:null`,入口仍为 `blocked/failed`,重试与结果摘要语义不变;并行成员日志及 WIP 提交正文保留原因。旧日志无该字段照常回放;含新字段的日志会被旧运行时按未知键拒绝,不做版本协商。契约拆分明确告知调用方与实现方:抛错占位体是预期状态,不应等待或据此 blocked。
35
+ - 批次入口支持 `bundle.batch.parallel`:通过 `eligibleTasks` / 受信 `parallelSelection` 绑定并行准入与恢复,`parallelMember` 将成员 QA 延后到主分支串行末任务;成员工作树逐个执行审查预检并缓存,恢复时仅复用匹配凭证,预检失败则整组在 start 前阻断。新增 `--protected-config` 与逐任务 `--allow-provider-development` 授权,按成员工作树的项目声明派发 CLI 写码,并复用配置执行合并后检查。
36
+ - 执行存储锁改为运行级,不同 runId 可独立持锁;创建新运行时先探测旧布局锁,成功释放后继续,失败返回 `store_busy`,旧文件不迁移、不改写。
37
+ 恢复已有运行时,缺少本运行 `writer.sqlite` 返回 `store_layout_legacy`,须用旧版本收尾或退休该 runId;已有运行级锁则正常恢复。
38
+
39
+ ## 0.14.0 — 2026-09-18
40
+
41
+ - 第 32 步:`cm-fix` 按描述未复现后先做最多 3 个场景或 15 分钟的单维度复现探索;档案新增复现尝试,JS 结果兼容旧记录并校验尝试结论,观测闭环要求至少一条尝试。
42
+ - 第 33 步:`cm-ai` 准入新增只读 `--print-run-definition` 直接生成运行定义(`--scope` 必填),`invalid_config` 点名多余/缺失字段、版本与文件类型,usage 与文档说明键集精确且参与摘要绑定。
43
+ - 第 34 步:受保护检查证据仅追加白名单测试计数摘要,同标签保留首次、最多 8 条、总长不超过 200 字符;不记录原始输出、凭证、路径或耗时,无计数及 unavailable 行为保持不变。
44
+
45
+ ## 0.13.4 — 2026-09-18
46
+
47
+ - 第 29 步:`cm-init` 机械核验配置草稿的运行时五字段与所选预设一致,不符时阻断;从模板新建配置时按版本控制与 UI 模块事实裁剪 delivery/tests,并对不适用的默认策略给出非阻塞 warning,已有配置仍保留无关字段。
48
+ - 第 30 步:修复 `cm-ai` N6 中途 QA 提前执行未完成任务用例;延后用例写入日志与报告,命令按选中逻辑用例映射,显式恢复可用新 testRunId 绑定更新后的计划。`five_tasks_without_qa` 不再把已收尾 feature 缺失的 N6 历史行计为当前积压。第 30b 步:中途用例全部延后且无可调度命令时,以单条 `no-applicable-cases` BLOCKED 行显式报告空计划。
49
+ - 第 31 步:`cm-ai` 单任务 resume 新增 `--rerun-blocked-qa`,显式授权后仅将最新已完成的纯宿主/环境证据 BLOCKED 记为 superseded,并在最多三轮内全量重跑;保留原 QA 决策、开发/审查和任务状态,QA complete 同步 N6 状态镜像。
50
+
10
51
  ## 0.13.3 — 2026-09-17
11
52
 
12
53
  - 第 28 步:`cm-runtime` 无参数在 TTY 中进入范围、工具/写码方、确认三问向导,复用安装器提问与既有 set/decision 日志,完成后显示有效配置;非 TTY 退出 2。安装器、向导与诊断共用系统语言中英文文案,机器字段不变;会话无参数按对话语言提问,文档与帮助同步。
package/README.md CHANGED
@@ -17,6 +17,39 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.15.2**
21
+
22
+ - **同 feature 并行开发现在可用**:无依赖、改动文件互不重叠的任务可分组,各自在独立 Git 工作树开发,再串行合并回主分支,成员 QA 延后到该 feature 最后一个任务统一执行。此前这个能力只存在于代码里、没有文档,从正常入口用不到。需要注意的是:当前会话模式下写代码仍是逐个进行,并行重叠的是审查与流程开销,不要按成倍提速预期。
23
+ - **升级注意**:并行成员分支改名为 `cm/{批次前缀}/{feature}/{任务号}`。此前被阻断的成员会留下不带批次前缀的分支并永久占住名字,导致同一任务再也跑不了批次。升级前创建、尚未跑完的并行批次请用旧版本收尾。
24
+ - **QA 环境支持桌面与后端/CLI/库项目**:此前只能填 Web / App / 小程序,纯后端或命令行项目要开 QA 只能谎报成网页。现在可以如实声明。
25
+ - **METRICS 新增「执行方式」列**:区分任务是串行跑的还是并行组成员,这样才能看出并行到底省了多少时间。
26
+
27
+ **0.15.1**
28
+
29
+ - **cm-security 现在会记运行日志**:安全扫描开跑与收尾各写一条运行日志(范围、结论词、发现数量、覆盖率、报告路径),与其余主流程命令一致;扫描逻辑、报告门禁与只读边界均未改动。此前 `cm-security` 是唯一没接入运行日志合同的主流程命令,`cm-check` 会因此报一处断链。
30
+ - **修复 Claude 安装下的版本号误判**:`~/.claude` 是 Claude Code 自己的主目录,那里出现与 CM 无关的 `VERSION` 文件时,`cm-check` 会把它当成 CM 版本——轻则版本号报错,该文件版本号更高时 `cm-check` 会直接返回 `blocked` 跑不下去。现按安装模式读取版本标志,Claude 安装认 `templates/cm-VERSION`,源码仓库仍认根 `VERSION`。
31
+
32
+ **0.15.0**
33
+
34
+ - **兼容性变更(升级前必读)**:旧布局执行存储恢复时返回 `store_layout_legacy`,请用旧版本收尾或退休该 `runId`,旧文件不会自动迁移;显式将 `roles.browser_qa.adapter` 设为非 `browser` 却沿用含 `browser` 的默认测试策略会被拒绝,需要浏览器 QA 时请改为 `browser`(保留 `model: none, source: local`)或删除角色覆盖以继承默认值,不需要时请显式将 `policies.tests` 设为如 `[logic, commands]`,阻塞 browser 用例仍须另行处理验收范围并重新审批;含新字段的运行日志会被旧版本按未知键拒绝,请用 0.15.0 或兼容该字段的后续版本继续运行,不要用旧版本回放这类日志。
35
+ - **同 feature 并行开发**:无依赖任务可在各自工作树中并行开发,再串行合并到主分支,成员 QA 延后到末任务统一执行;批次会自动提交与合并,首次推进前请保持 Git 主工作区干净(含未跟踪文件),被阻塞成员的 WIP 与原因会保留。
36
+ - **规格审批位统一写入**:`cm-prd` 与 `cm-ai` 共用 `.cm-specs-status` 原子写入入口,模型不再手拼审批文件;`cm-ai` 新增 `--approve --approval-response`,记录审批后重新核验准入,`--yes` 不能代替审批。
37
+ - **cm-security 报告门禁**:新增 `--finalize --scan ... --review ...`,由代码校验逐路径复核、补齐漏报并判定报告结论,模型不再自述最终状态;无发现且扫描覆盖为 FULL 时仍为 `REVIEWED_PARTIAL`,报告保留通过校验的分析与修复建议。
38
+ - **浏览器验收能力提前声明**:开启 QA 且规格需要浏览器验收时,单任务与批次入口在启动或恢复时要求显式传入 `--browser-qa available|unavailable`,不再等到最后一步才暴露能力缺失;不可用时请换到具备浏览器能力的会话,或调整验收范围并重新审批规格,这是能力声明,并非自动探测。
39
+ - **开发阻塞原因可追溯**:开发结果 `blocked` 的可选 `reason` 现在能从 CLI 结构化输出落盘为 `blockedReason`,并保留在并行成员日志和 WIP 提交正文中,恢复排查时可查看具体原因。
40
+
41
+ **0.14.0**
42
+
43
+ - **运行定义不再手写**:`cm-ai` 准入新增只读 `--print-run-definition`,把它已经解析出的 specs/代码根、feature 与任务直接生成为合法运行定义(`--scope` 必填,因为"本任务允许改哪些文件"是框架推不出来的唯一一项);`invalid_config` 改为点名多余/缺失字段、版本与文件类型。
44
+ - **N6 QA 更贴合实际进度**:feature 未完成时只执行已完成任务的用例,其余记入 `deferred_cases` 延后到 feature 收尾;`five_tasks_without_qa` 不再把已收尾 feature 的历史计为积压;QA 因宿主或环境证据问题整体 BLOCKED 时可用 `--rerun-blocked-qa` 显式重跑一轮,QA 结束同步写回状态镜像。
45
+ - **审查证据更可判**:受保护检查的证据追加测试计数(`host check exited 0 (tests 27, pass 27, fail 0)`),原始输出仍不进入审查数据。
46
+ - **cm-fix 先复现再修**:按描述未复现时不直接进观测闭环,先沿输入值、前置状态、时序、环境、规模五个维度单维度构造场景,上限 3 个场景或 15 分钟,命中即作为红灯测试骨架;缺陷档案新增复现尝试记录。
47
+ - **cm-init 配置核验**:机械核验配置草稿与所选运行时预设一致,并按版本控制与 UI 模块事实裁剪新建配置的 delivery/tests。
48
+
49
+ **0.13.4**
50
+
51
+ - **第二轮真项目 dogfood 修复**:在 specs 与代码分离的真实项目上再跑一遍 `cm-init → cm-prd → cm-ai`(Codex 写码、Claude CLI 独立审查、feature 收尾 QA)并修复沿路暴露的 3 处运行时缺陷——`cm-init` 现在机械核验配置草稿与所选运行时预设一致并按项目事实裁剪新建配置的 delivery/tests;`cm-ai` 的 N6 在 feature 未完成时只执行已完成任务的用例、其余记入 `deferred_cases`,`five_tasks_without_qa` 不再把已收尾 feature 的历史计为积压;QA 因宿主/环境证据问题整体 BLOCKED 时可用 `--rerun-blocked-qa` 显式重跑一轮,QA 结束同步写回状态镜像。详见[更新日志](CHANGELOG.md)。
52
+
20
53
  **0.13.3**
21
54
 
22
55
  - **`cm-runtime` 直接敲就是向导**:不带参数运行时按编号三问——改哪一层(当前项目 / 用户级默认)→ 手上有哪个 AI(只有 Codex / 只有 Claude / 两个都有)→ 谁写代码,预览后确认才写入,然后回显有效配置;非终端环境只打印用法并退出 2,脚本化仍用 `show` / `set` / `unset --user`。
@@ -101,7 +134,7 @@ $cm-check
101
134
 
102
135
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
103
136
 
104
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.13.3 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
137
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.15.2 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
105
138
 
106
139
  ## 升级旧版本
107
140
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.3
1
+ 0.15.2
@@ -73,7 +73,7 @@ Install or upgrade with the same command:
73
73
  npx @aibyzero/cm-workflow@latest install
74
74
  ```
75
75
 
76
- To pin a version, use `npx @aibyzero/cm-workflow@0.13.3 install` from outside
76
+ To pin a version, use `npx @aibyzero/cm-workflow@0.15.2 install` from outside
77
77
  the CM Workflow source checkout (for example, your home directory). Inside a
78
78
  checkout with the same package name and version, npm can select the local
79
79
  uninstalled package and report `cm-workflow: command not found`.
@@ -239,6 +239,8 @@ constraintChanges必须空;application/retrospective沿原Learning字段。此
239
239
  ```
240
240
 
241
241
  scope 和 requirements 是相对代码根的已有 runner 输入,不是额外写入授权。
242
+ 键必须恰好如示例,不得新增字段(已声明的多代码根模式仅允许原有可选 `codeProjects`);定义参与摘要绑定,擅加字段会使同一次 run 的摘要漂移并导致 resume 失败。
243
+ 用准入生成器产出定义(`--scope` 必填,填写相对代码根、逗号分隔的允许修改文件;`--requirements` 可选,省略时为空数组):`node scripts/cm-ai-admission.mjs --specs-dir /absolute/specs --code-project /absolute/code --print-run-definition --scope src/login.js --requirements requirements.md > run.json`。
242
244
 
243
245
  ```bash
244
246
  node scripts/cm-ai-run.mjs serve --config /absolute/run.json --mode create
@@ -313,6 +315,13 @@ host-context 必须是真实当前会话身份;宿主将其排除出独立审
313
315
  宿主读取适用指令并用真实工具修改获准文件,再返回原开发输出。
314
316
  - `check`:payload 包含代码根、任务身份、scope、requirements;宿主实际执行检查,
315
317
  返回原检查数组 `[{id,command,outcome,exitCode,evidence}]`,不能用静态判断填通过。
318
+ 该数组**就是 host_result 的 `result` 本身**,不套 `{status,value}`——那是 develop 的形状,
319
+ 用错会以 `invalid_input` 停在 `reconcile` 且重试无效。审查包另外要求数组非空、且每条
320
+ `outcome` 为 `passed` 并且 `exitCode` 为 0,否则以 `checks_not_passed` 判未通过:
321
+
322
+ ```json
323
+ {"type":"host_result","sessionId":"from-request","callId":"from-request","requestDigest":"from-request","result":[{"id":"test","command":["npm","test"],"outcome":"passed","exitCode":0,"evidence":"实际输出摘要"}]}
324
+ ```
316
325
 
317
326
  这两类请求现在附带原配置解析器产生的 `route`(coder / tester)。每次实际角色边界
318
327
  重新读代码项目配置,并通过原日志写入器记录 `decision/route`;配置错误记录脱敏 error,
@@ -410,6 +419,9 @@ JS 通过现有通道发出固定请求,结果由原组件校验:
410
419
 
411
420
  ```bash
412
421
  # 只启动本机合成 sink 和只读 CLI 探测,不请求真实模型;输出保存为 review.json。
422
+ # --review-model 必须是 CLI 实际写进请求体的完整模型 id,不能用 sonnet 这类别名:
423
+ # 探测按字面比对,别名会以 request_checks 里的 model_matches:false 判失败,
424
+ # 而回执只给布尔值、不给期望值,仅看输出无法推断该填什么。
413
425
  node scripts/cm-ai-host.mjs preflight --config /absolute/run.json --review-model model-name
414
426
  # 携带配置但不授权审查:开发和检查完成后等待授权。
415
427
  node scripts/cm-ai-host.mjs serve --config /absolute/run.json --mode create \
@@ -886,6 +898,7 @@ JS 只校验声明及身份一致性,不证明测试目录已全面调查;
886
898
 
887
899
  `scripts/cm-ai-batch-run.mjs` 导出 `createCmAiBatch({configuration, executionFor, logHome})`。
888
900
  configuration 固定为 `{version:1, repositoryId, batchId, specsDir, codeProject, tasks}`,
901
+ 另有可选 `parallel`(见下节「并行组」)和可选 `codeProjects`。
889
902
  tasks 每项为 `{feature, taskId, scope, requirements}`;首项是本批次起点,之后按原
890
903
  admission 返回的下一任务推进。根路径须规范绝对路径,未列入批准清单的下一任务停止,
891
904
  不推测 scope。`executionFor` 只由可信宿主提供,负责零副作用地组装每任务执行适配器,
@@ -903,6 +916,48 @@ admission 返回的下一任务推进。根路径须规范绝对路径,未列
903
916
  不伪造一条父run_done,也不把这项本地接线当作完整产品宿主/真实provider验收。
904
917
  当前实现仍要求Node24.14+与原执行/平台能力;Linux准入已适配但缺原生端到端证据,原生Windows未接,独立CLI见下文。
905
918
 
919
+ ### 并行组
920
+
921
+ 可选 `parallel` 是「任务 key 数组」的数组,每个内层数组是一组同时开发的任务,
922
+ key 形如 `1.work/T-001`,与 `tasks` 的 `feature/taskId` 一致。省略该字段即全部串行。
923
+
924
+ 每组必须同时满足,任一不满足整批拒绝启动:
925
+
926
+ | 约束 | 失败码 |
927
+ | --- | --- |
928
+ | 每组 2–4 个任务,成员不重复、不跨组复用 | `invalid_parallel_group` |
929
+ | 组内全部任务属于同一 feature | `parallel_feature_mismatch` |
930
+ | 组内任意两任务之间不存在依赖路径(按 `tasks.md` 依赖图的传递闭包判定) | `parallel_dependency_conflict` |
931
+ | 组内各任务 `scope` 两两不含相同路径 | `parallel_scope_overlap` |
932
+ | 该 feature 最后一个未 DROPPED 的任务不得进组,且必须在 `tasks` 内 | `parallel_final_task_excluded` |
933
+
934
+ 末任务被排除,是因为成员 QA 会延后到它那里统一执行。
935
+
936
+ **执行方式。** 每个成员分到一个 Git 工作树与独立分支,由调度器创建:
937
+
938
+ - 工作树:`{codeProject}/../.cm-worktrees/{batchId 前 8 个字符}/{taskId}`
939
+ - 分支:`cm/{feature 去掉数字前缀}/{taskId}`,从 `HEAD` 创建
940
+
941
+ 启动前对整组跑一次 `check-parallel-write`。成员各自完成开发、检查与审查后在自己
942
+ 分支提交,再由调度器按任务顺序逐个 `git merge --no-ff` 合回主 checkout——**合并是串行的**,
943
+ 合并完成后移除该成员工作树。首次推进前主工作区必须干净(含未跟踪文件),否则整批停止
944
+ 并列出文件;被阻断的成员保留其 WIP 提交与原因,不自动丢弃。
945
+
946
+ **QA 延后。** 成员的 N6 自动记为 `skipped`(`reason: parallel_member_deferred`,固定评分 4),
947
+ 不逐任务跑 QA;整个 feature 的 QA 在末任务触发一次,覆盖合并后的结果。
948
+
949
+ **并行的边界。** 当前会话通道一次只接一个工具调用,成员的开发请求按序排队,
950
+ 第二个成员的 `develop` 只在第一个被应答之后才发出。真正重叠的是成员 runner 的状态推进
951
+ 与各自的独立审查进程,**不是写代码本身**;使用者不应据此预期成倍提速。要让编码真正并发,
952
+ 需要为成员配置各自的 provider 开发派发,而不是依赖当前会话。
953
+
954
+ **前置条件。** 并行成员会在各自工作树里单独跑一次 review preflight,因此 `--review-config`
955
+ 是并行的硬前置:缺它整批立即以 `review_preflight_failed` 停止,一行代码都不会开发。
956
+ 串行批次没有这个要求。
957
+
958
+ **提议方。** 由 N1 决定哪些任务成组,规则见 `skills/cm-ai/references/js-host.md` 第 3.1 条。
959
+ 组不起来就省略该字段,正常串行;不为组而组。
960
+
906
961
  ### 当前会话多任务 CLI
907
962
 
908
963
  `scripts/cm-ai-batch-host.mjs` 将同一个当前会话通道接到上述 createCmAiBatch,
@@ -341,6 +341,8 @@ $cm-test ~/code/my-app 用户登录
341
341
  $cm-fix ~/projects/my-app-specs ~/code/my-app 登录成功后仍然停留在登录页
342
342
  ```
343
343
 
344
+ 按描述未复现时,`$cm-fix` 会先按输入、状态、时序、环境、规模逐次改变一个维度主动探索,最多 3 个场景或 15 分钟(先到为准);命中场景用作红灯测试骨架,到上限仍未复现才进入观测闭环,档案记录全部复现尝试。
345
+
344
346
  `$cm-fix` 会先建立可复现的红灯测试,再定位根因、做最小修复、回归并审查。跨服务、异步或偶现问题会在本地记录最小观测、调用链和假设;仅在无法稳定复现时才进入“观测中”,证据到手后按原 slug 续跑。已可复现的问题则带着证据链走正常七步。若调查发现实际需要新增行为或改变契约,应退出修复流,改走 `$cm-prd --change`。
345
347
 
346
348
  </details>
@@ -565,6 +567,7 @@ $cm-security {项目路径} --semgrep-rules {外部本地规则文件} --osv-db
565
567
  优先级:**项目 > 用户级默认 > 未声明**。项目没有 `runtimes.available` 才读取用户文件;
566
568
  显式项目角色字段覆盖用户预设的角色默认值,矛盾配置报字段路径并阻断。
567
569
  `cm-init` 遇到用户默认直接继承、报告 `来源: 用户级默认`,两级都没有才询问。
570
+ 配置草稿的运行时五字段必须与所选预设一致;新建配置时还按项目事实裁剪 delivery/tests(local/none 用 branch 或 diff,无 frontend/miniprogram 去掉 browser,未裁剪则给出非阻塞 warning),已有配置只更新运行时五字段。
568
571
 
569
572
  | 预设 | 写代码 | 审代码 |
570
573
  | --- | --- | --- |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.13.3",
3
+ "version": "0.15.2",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -30,6 +30,7 @@
30
30
  "blocked"
31
31
  ]
32
32
  },
33
+ "reason": {"type": ["string", "null"]},
33
34
  "application": {
34
35
  "type": "object",
35
36
  "additionalProperties": false,
@@ -1,9 +1,10 @@
1
- // Read-only N1/N2 admission for the fixed cm-ai workflow. It never writes project state.
1
+ // N1/N2 inspection is read-only; explicit approval uses the shared status writer.
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { spawnSync } from 'node:child_process';
6
6
  import { fileURLToPath } from 'node:url';
7
+ import {readSpecsStatus,writeSpecsStatus} from '../specs-status.mjs';
7
8
  import {buildManifest,verifyManifest} from '../../../scripts/cm-spec-manifest.mjs';
8
9
 
9
10
  const TASK=/^\s*-\s*\[([ xX])\]\s+(?:~~)?(T-[A-Za-z0-9][A-Za-z0-9._-]*)(?=[:\s])[:\s]*(.*)$/;
@@ -33,22 +34,24 @@ export function inspectCmAiQaTaskContext({specsDir,codeProject,feature,taskId})
33
34
  const fail=code=>{throw Object.assign(new Error(code),{code});};
34
35
  if(!['ready','complete'].includes(admission.state))fail(admission.reason);
35
36
  const discovered=discoverFeatures(admission.specsDir);if(discovered.error)fail(discovered.error);
36
- const completed=[];let selected=null;
37
+ const completed=[],pendingFeatures=[];let selected=null;
37
38
  for(const name of discovered.names){
38
39
  const parsed=readFeature(admission.specsDir,name);if(parsed.error)fail(parsed.error);
39
40
  if(name===feature)selected=parsed.tasks;
41
+ if(parsed.tasks.some(task=>!task.completed&&!task.dropped))pendingFeatures.push(name);
40
42
  for(const task of parsed.tasks)if(task.completed&&!task.dropped)completed.push({feature:name,id:task.id});
41
43
  }
42
- if(!selected?.some(task=>task.id===taskId&&task.completed&&!task.dropped))fail('qa_not_ready');
44
+ // Plan construction happens before task completion; decisions still bind a completed task.
45
+ if(!selected||(taskId!==undefined&&!selected.some(task=>task.id===taskId&&task.completed&&!task.dropped)))fail('qa_not_ready');
43
46
  const pending=selected.filter(task=>!task.completed&&!task.dropped).length;
44
- return frozen({completed,pending,mergeEligible:pending===1&&admission.nextTask?.feature===feature});
47
+ return frozen({completed,pendingFeatures,pending,mergeEligible:pending===1&&admission.nextTask?.feature===feature});
45
48
  }
46
49
 
47
50
  // Admission's public feature summary stops at the selected feature. Count all
48
51
  // approved features with the same parser before treating a task as the last one.
49
- export function isFinalCmAiTask({specsDir,codeProject,feature,taskId}) {
52
+ export function isFinalCmAiTask({specsDir,codeProject,feature,taskId,parallelSelection=null}) {
50
53
  const admission=inspectCmAiAdmission({specsDir,codeProject});
51
- if(admission.state!=='ready'||admission.nextTask.feature!==feature||admission.nextTask.id!==taskId)
54
+ if(!matchesCmAiTaskSelection(admission,feature,taskId,parallelSelection))
52
55
  throw Object.assign(new Error('documentation_admission_required'),{code:'documentation_admission_required'});
53
56
  const discovered=discoverFeatures(admission.specsDir);
54
57
  if(discovered.error)throw Object.assign(new Error(discovered.error),{code:discovered.error});
@@ -67,7 +70,7 @@ function frozen(value){
67
70
  }
68
71
 
69
72
  function result(base,state,reason,extra={}){
70
- return frozen({...base,state,reason,features:[],nextTask:null,warnings:[],...extra});
73
+ return frozen({...base,state,reason,features:[],nextTask:null,eligibleTasks:[],warnings:[],...extra});
71
74
  }
72
75
 
73
76
  function directory(value){
@@ -82,18 +85,6 @@ function approvalIntent(response,assumeYes){
82
85
  return typeof response==='string'&&response.trim()==='开始'?'explicit':'not_approval';
83
86
  }
84
87
 
85
- function readStatus(specsDir){
86
- const target=path.join(specsDir,'.cm-specs-status');
87
- if(!fs.existsSync(target))return {kind:'missing'};
88
- try{
89
- const specsRoot=fs.realpathSync(specsDir),realTarget=fs.realpathSync(target);
90
- if(!contained(specsRoot,realTarget))return {kind:'invalid'};
91
- const value=JSON.parse(fs.readFileSync(realTarget,'utf8'));
92
- if(value===null||typeof value!=='object'||Array.isArray(value)||!['approved','awaiting_review'].includes(value.status))
93
- return {kind:'invalid'};
94
- return {kind:'valid',value};
95
- }catch{return {kind:'invalid'};}
96
- }
97
88
 
98
89
  function contained(root,target){
99
90
  const relative=path.relative(root,target);
@@ -331,7 +322,9 @@ function selectTask(specsDir,names){
331
322
  return dependency&&(dependency.completed||dependency.dropped);
332
323
  }));
333
324
  if(!eligible)return {error:'dependencies_not_ready',features,warnings};
334
- return {features,warnings,nextTask:{feature:name,id:eligible.id,description:eligible.description}};
325
+ return {features,warnings,nextTask:{feature:name,id:eligible.id,description:eligible.description},
326
+ eligibleTasks:pending.filter(task=>(parsed.dependencies.get(task.id)||[]).every(id=>byId.get(id)?.completed))
327
+ .map(task=>({feature:name,id:task.id}))};
335
328
  }
336
329
  return {features,warnings,nextTask:null};
337
330
  }
@@ -340,6 +333,32 @@ export function inspectCmAiAdmission(options){
340
333
  return admissionFor(options);
341
334
  }
342
335
 
336
+ // The CLI supplies every code project so no project can be skipped before writing.
337
+ export function approveCmAiSpecs(options){
338
+ const projects=options.codeProjects??[options.codeProject];
339
+ const inspect=()=>projects.map(codeProject=>inspectCmAiAdmission({...options,codeProject}));
340
+ const projectResults=inspect();
341
+ const refuse=approveRefused=>({projectResults,approveRefused});
342
+ if(options.assumeYes)return refuse('assume_yes_not_allowed');
343
+ if(typeof options.approvalResponse!=='string'||!options.approvalResponse.trim())
344
+ return refuse('approval_response_required');
345
+ const allowed=new Set(['approval_write_required','spec_features_changed','test_cases_changed']);
346
+ const rejected=projectResults.find(item=>item.state!=='awaiting_spec_approval'
347
+ ||item.approvalIntent!=='explicit'||!allowed.has(item.reason));
348
+ if(rejected)return refuse(rejected.approvalIntent!=='explicit'?'explicit_approval_required':rejected.reason);
349
+ const specsDir=projectResults[0].specsDir,status=readSpecsStatus(specsDir);
350
+ if(status.kind==='invalid')return refuse('spec_status_invalid');
351
+ try{
352
+ const discovered=discoverFeatures(specsDir);
353
+ if(discovered.error)return refuse(discovered.error);
354
+ const specFiles=buildManifest(specsDir),at=new Date().toISOString();
355
+ writeSpecsStatus(specsDir,{status:'approved',summaryDigest:status.value?.summaryDigest??null,at,
356
+ features:discovered.names,specFiles,testCases:specFiles.filter(item=>item.path.endsWith('/test-cases.json')),
357
+ approval:{response:options.approvalResponse,at}});
358
+ }catch(error){return refuse(error.code??error.message);}
359
+ return {projectResults:inspect()};
360
+ }
361
+
343
362
  function admissionFor(options,inProgressBootstrap=null){
344
363
  const input=options&&typeof options==='object'&&!Array.isArray(options)?options:{};
345
364
  const specsDir=directory(input.specsDir),codeProject=directory(input.codeProject);
@@ -348,7 +367,7 @@ function admissionFor(options,inProgressBootstrap=null){
348
367
  if(!codeProject)return result(base,'blocked','code_project_missing');
349
368
  const discovered=discoverFeatures(specsDir);
350
369
  if(discovered.error)return result(base,'blocked',discovered.error);
351
- const status=readStatus(specsDir);
370
+ const status=readSpecsStatus(specsDir);
352
371
  if(status.kind==='invalid')return result(base,'blocked','spec_status_invalid');
353
372
  if(status.kind==='missing'||status.value.status==='awaiting_review'){
354
373
  const reason=base.approvalIntent==='explicit'?'approval_write_required':'spec_approval_required';
@@ -371,5 +390,17 @@ function admissionFor(options,inProgressBootstrap=null){
371
390
  if(selection.error)return result(base,'blocked',selection.error,{features:selection.features,warnings:selection.warnings,
372
391
  ...(selection.detail?{detail:selection.detail}:{})});
373
392
  if(!selection.nextTask)return result(base,'complete','all_tasks_terminal',{features:selection.features,warnings:selection.warnings});
374
- return result(base,'ready','task_selected',{features:selection.features,nextTask:selection.nextTask,warnings:selection.warnings});
393
+ return result(base,'ready','task_selected',{features:selection.features,nextTask:selection.nextTask,eligibleTasks:selection.eligibleTasks,warnings:selection.warnings});
394
+ }
395
+
396
+ // Trusted caller selection is data bound by openControlRun, never message authority.
397
+ export function matchesCmAiTaskSelection(admission,feature,taskId,parallelSelection=null){
398
+ if(parallelSelection===null)return admission.state==='ready'
399
+ &&admission.nextTask?.feature===feature&&admission.nextTask.id===taskId;
400
+ const value=parallelSelection;
401
+ return admission.state==='ready'&&value?.version===1
402
+ &&Object.keys(value).sort().join(',')==='group,version'&&Array.isArray(value.group)
403
+ &&value.group.length>=2&&new Set(value.group).size===value.group.length
404
+ &&value.group.every(id=>typeof id==='string'&&TASK_ID.test(id))&&value.group.includes(taskId)
405
+ &&admission.eligibleTasks?.some(task=>task.feature===feature&&task.id===taskId)===true;
375
406
  }
@@ -2,7 +2,7 @@
2
2
  import {createHash} from 'node:crypto';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import {inspectCmAiAdmission} from './cm-ai-admission.mjs';
5
+ import {inspectCmAiAdmission,matchesCmAiTaskSelection} from './cm-ai-admission.mjs';
6
6
  import {arrayItems,digest,freeze,hex,json,need,shape,text,validIdentity,validTaskLearningInput} from './effect-contract.mjs';
7
7
 
8
8
  const BASELINE_RULES=['coding-style.md','testing.md','security.md'];
@@ -65,7 +65,7 @@ export function inspectCmAiContextRefresh(input,{admission:trustedAdmission=null
65
65
  if(trustedAdmission!==null)need(input.feature==='0.bootstrap'
66
66
  &&admission.specsDir===input.specsDir&&admission.codeProject===input.codeProject,'context_invalid');
67
67
  if(!['ready','complete'].includes(admission.state))return freeze({state:admission.state,reason:admission.reason,
68
- nextTask:null,contextDigest:null,contextFiles:[]});
68
+ nextTask:null,eligibleTasks:[],contextDigest:null,contextFiles:[]});
69
69
  need(admission.features.some(item=>item.name===input.feature),'context_invalid');
70
70
  const featureNames=admission.state==='complete'?admission.features.map(item=>item.name):[input.feature];
71
71
  const files=featureNames.flatMap(feature=>['requirements.md','design.md','tasks.md'].map(name=>
@@ -74,7 +74,7 @@ export function inspectCmAiContextRefresh(input,{admission:trustedAdmission=null
74
74
  files.push(...projectFiles(input.codeProject,input.applicableAgentFiles));
75
75
  const contextFiles=files.map(file=>file.metadata).sort((left,right)=>
76
76
  left.scope.localeCompare(right.scope)||left.path.localeCompare(right.path));
77
- return freeze({state:admission.state,reason:admission.reason,nextTask:admission.nextTask,
77
+ return freeze({state:admission.state,reason:admission.reason,nextTask:admission.nextTask,eligibleTasks:admission.eligibleTasks??[],
78
78
  contextDigest:digest({version:1,files:contextFiles}),contextFiles});
79
79
  }
80
80
 
@@ -83,8 +83,7 @@ export function inspectCmAiTaskLearningInput(input,authority={}) {
83
83
  text(input.feature);const identity=json(input.identity);validIdentity(identity);
84
84
  const refresh=inspectCmAiContextRefresh({specsDir:input.specsDir,codeProject:input.codeProject,
85
85
  feature:input.feature,applicableAgentFiles:input.applicableAgentFiles},authority);
86
- need(refresh.state==='ready'&&refresh.nextTask?.feature===input.feature
87
- &&refresh.nextTask.id===identity.taskId,'learning_context_invalid');
86
+ need(matchesCmAiTaskSelection(refresh,input.feature,identity.taskId,authority.parallelSelection??null),'learning_context_invalid');
88
87
  const agentPaths=new Set(['AGENTS.md',...arrayItems(input.applicableAgentFiles)]);
89
88
  const selected=refresh.contextFiles.filter(file=>file.scope==='specs'?file.path==='LESSONS.md':
90
89
  file.scope==='project'&&agentPaths.has(file.path));
@@ -1,5 +1,5 @@
1
1
  // Fixed Codex-host entry for the existing cm-ai admission and V3 task runner.
2
- import {inspectCmAiAdmission} from './cm-ai-admission.mjs';
2
+ import {inspectCmAiAdmission,matchesCmAiTaskSelection} from './cm-ai-admission.mjs';
3
3
  import {inspectCmAiContextRefresh,inspectCmAiTaskLearningInput} from './cm-ai-context-refresh.mjs';
4
4
  import {findCmAiQaDecision,inspectCmAiQaDecision,inspectCmAiQaResult,recordCmAiQaDecision,
5
5
  latestCmAiQaRun,recordCmAiQaRun,inspectCmAiQaRecovery} from './cm-ai-qa-log.mjs';
@@ -31,7 +31,9 @@ const pendingAction=status=>status.state==='awaiting_spec_approval'?'spec_approv
31
31
  status.state==='fixture_completed'?'qa':'none';
32
32
  const summary=(operation,status,outcome)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
33
33
  requestDigest:digest(operation),identity:status.identity,outcome,state:status.state,code:status.code??null,
34
- packageDigest:status.packageDigest??null,pendingAction:pendingAction(status)});
34
+ packageDigest:status.packageDigest??null,pendingAction:pendingAction(status),
35
+ ...(status.state==='blocked'&&status.calls?.at(-1)?.blockedReason!==undefined
36
+ ?{blockedReason:status.calls.at(-1).blockedReason}:{})});
35
37
  const correctionSummary=(operation,status)=>status.code==='correction_review_required'
36
38
  ?summary(operation,status,'blocked'):null;
37
39
 
@@ -126,10 +128,12 @@ export function createCmAiConversationEntry(options) {
126
128
  if(options&&Object.hasOwn(options,'qaDecisionProvider'))optionKeys.push('qaDecisionProvider');
127
129
  if(options&&Object.hasOwn(options,'qaExecutor'))optionKeys.push('qaExecutor');
128
130
  if(options&&Object.hasOwn(options,'rerunUnknownQa'))optionKeys.push('rerunUnknownQa');
131
+ if(options&&Object.hasOwn(options,'rerunBlockedQa'))optionKeys.push('rerunBlockedQa');
129
132
  if(options&&Object.hasOwn(options,'qaLogHome'))optionKeys.push('qaLogHome');
130
133
  if(options&&Object.hasOwn(options,'applicableAgentFiles'))optionKeys.push('applicableAgentFiles');
131
134
  if(options&&Object.hasOwn(options,'documentationResult'))optionKeys.push('documentationResult');
132
135
  if(options&&Object.hasOwn(options,'documentationProvider'))optionKeys.push('documentationProvider');
136
+ if(options&&Object.hasOwn(options,'parallelSelection'))optionKeys.push('parallelSelection');
133
137
  shape(options,optionKeys);
134
138
  if(Object.hasOwn(options,'developmentAttempt'))need([1,2].includes(options.developmentAttempt),'invalid_development_attempt');
135
139
  text(options.specsDir);text(options.codeProject);text(options.feature);
@@ -169,11 +173,15 @@ export function createCmAiConversationEntry(options) {
169
173
  let pendingQa=null;
170
174
  let qaExecutor=null,pendingExecution=null,cancellationEpoch=0;
171
175
  let rerunUnknownQa=options.rerunUnknownQa??false;need(typeof rerunUnknownQa==='boolean');
176
+ let rerunBlockedQa=options.rerunBlockedQa??false;need(typeof rerunBlockedQa==='boolean');
177
+ need(!(rerunUnknownQa&&rerunBlockedQa),'qa_recovery_authorization_required');
172
178
  if(Object.hasOwn(options,'qaExecutor')){
173
179
  shape(options.qaExecutor,['mode','caseCount','timeoutMs','run',
174
- ...(Object.hasOwn(options.qaExecutor,'configuration')?['configuration']:[])]);
175
- const {run,...config}=options.qaExecutor;
176
- need(typeof run==='function');qaExecutor={...json(config),run};
180
+ ...(Object.hasOwn(options.qaExecutor,'configuration')?['configuration']:[]),
181
+ ...(Object.hasOwn(options.qaExecutor,'prepare')?['prepare']:[])]);
182
+ const {run,prepare,...config}=options.qaExecutor;
183
+ need(typeof run==='function'&&(prepare===undefined||typeof prepare==='function'));
184
+ qaExecutor={...json(config),run,...(prepare?{prepare}:{})};
177
185
  need(['commands','browser','all'].includes(config.mode)&&Number.isSafeInteger(config.caseCount)&&config.caseCount>0);
178
186
  need(Number.isInteger(config.timeoutMs)&&config.timeoutMs>=1&&config.timeoutMs<=3600000);
179
187
  }
@@ -266,6 +274,14 @@ export function createCmAiConversationEntry(options) {
266
274
  notCancelled();
267
275
  result=await call('qa',result.packageDigest);
268
276
  if(result.outcome==='recorded'&&result.code==='qa_triggered'&&qaExecutor!==null){
277
+ // The host is constructed before N5 marks the task complete. Freeze the
278
+ // execution plan only now, then retain it throughout this invocation.
279
+ if(qaExecutor.prepare){
280
+ const prepared=json(qaExecutor.prepare());shape(prepared,['mode','caseCount','configuration']);
281
+ need(['commands','browser','all'].includes(prepared.mode)
282
+ &&Number.isSafeInteger(prepared.caseCount)&&prepared.caseCount>0,'qa_plan_invalid');
283
+ qaExecutor={...qaExecutor,...prepared};
284
+ }
269
285
  notCancelled();
270
286
  need(pendingExecution===null,'qa_execution_pending');
271
287
  const binding={specsDir:options.specsDir,feature:options.feature,identity:result.identity,packageDigest:result.packageDigest};
@@ -280,13 +296,17 @@ export function createCmAiConversationEntry(options) {
280
296
  if(recovery===null)return summary(operation,{...runner.status(),code:'qa_execution_unknown'},'blocked');
281
297
  previous=null;
282
298
  }
299
+ if(rerunBlockedQa){
300
+ need(previous!==null,'qa_rerun_not_blocked_by_evidence');
301
+ recovery=inspectCmAiQaRecovery(binding,{blocked:true,environment:qaExecutor.configuration?.environment});
302
+ }
283
303
  let testRunId=previous?.testRunId;
284
304
  const accepted=runner.status().acceptedQaFix;
285
305
  const repaired=previous?.status==='failed'&&accepted?.testRunId===previous.testRunId;
286
- if(previous===null||repaired){
287
- // Later rounds require an original completed child accepted by the
288
- // parent journal. Unknown executions and unrepaired failures stop.
289
- const qaRound=recovery?.qaRound??(repaired?accepted.qaRound+1:1);
306
+ if(previous===null||repaired||rerunBlockedQa){
307
+ // Later rounds require an accepted completed repair or explicit
308
+ // evidence-only BLOCKED recovery. Unknown and unrepaired FAIL stop.
309
+ const qaRound=recovery?recovery.qaRound+(rerunBlockedQa?1:0):(repaired?accepted.qaRound+1:1);
290
310
  need(qaRound>=1&&qaRound<=3,'qa_round_invalid');
291
311
  testRunId=`qa-${digest(recovery?{...binding,previousTestRunId:recovery.testRunId}:
292
312
  repaired?{...binding,qaRound,repair:accepted.evidenceDigest}:binding).slice(0,48)}`;
@@ -295,11 +315,14 @@ export function createCmAiConversationEntry(options) {
295
315
  const logInput={...invocation,...(Object.hasOwn(options,'qaLogHome')?{logHome:options.qaLogHome}:{})};
296
316
  notCancelled();
297
317
  if(recovery){
298
- need(qaExecutor.mode===recovery.mode&&qaExecutor.caseCount===recovery.caseCount,'qa_execution_mismatch');
299
- recordCmAiQaRun({...logInput,testRunId:recovery.testRunId,phase:'abandoned'});
300
- rerunUnknownQa=false;
318
+ recordCmAiQaRun({...logInput,testRunId:recovery.testRunId,mode:recovery.mode,
319
+ caseCount:recovery.caseCount,qaRound:recovery.qaRound,phase:rerunBlockedQa?'superseded':'abandoned',
320
+ ...(rerunBlockedQa?{expectedEnvironment:qaExecutor.configuration?.environment??null}:{})});
321
+ rerunUnknownQa=false;rerunBlockedQa=false;
301
322
  }
302
- recordCmAiQaRun({...logInput,phase:'start',...(recovery?{previousTestRunId:recovery.testRunId}:{})});
323
+ recordCmAiQaRun({...logInput,phase:'start',
324
+ deferredCases:qaExecutor.configuration?.plan?.deferred_cases??[],
325
+ ...(recovery?{previousTestRunId:recovery.testRunId}:{})});
303
326
  const controller=new AbortController();pendingExecution=controller;
304
327
  let timer,timedOut=false;
305
328
  try{
@@ -466,7 +489,8 @@ export function createCmAiConversationEntry(options) {
466
489
  pendingAction:fixHandoff.status==='authorization_required'?'fix_authorization':
467
490
  fixHandoff.status==='dispatch_required'?'fix_dispatch':'none'});
468
491
  }
469
- return summary(operation,{...status,code},'verified');
492
+ return freeze({...summary(operation,{...status,code},'verified'),
493
+ ...(code==='qa_result_blocked'&&rerunBlockedQa?{pendingAction:'qa'}:{})});
470
494
  }
471
495
  if(operation.operation==='context_refresh'){
472
496
  const status=boundStatus(runner.status(),identity);
@@ -538,8 +562,7 @@ export function createCmAiConversationEntry(options) {
538
562
  deduplicated:result.deduplicated,degraded:result.degraded});
539
563
  }
540
564
  need(['start','resume'].includes(operation.operation),'invalid_input');
541
- need(admission.state==='ready'&&admission.nextTask?.feature===options.feature
542
- &&admission.nextTask.id===identity.taskId,'task_mismatch');
565
+ need(matchesCmAiTaskSelection(admission,options.feature,identity.taskId,options.parallelSelection??null),'task_mismatch');
543
566
  const status=boundStatus(runner.status(),identity);
544
567
  const developable=['ready','changes_requested'].includes(status.state)||retryDeveloper(status);
545
568
  const repeatable=operation.operation==='start'&&status.state==='awaiting_review';
@@ -551,7 +574,7 @@ export function createCmAiConversationEntry(options) {
551
574
  return summary(operation,{...status,code:'provider_development_authorization_required'},'awaiting');
552
575
  const learningInput=inspectCmAiTaskLearningInput({specsDir:options.specsDir,codeProject:options.codeProject,
553
576
  feature:options.feature,identity,applicableAgentFiles:applicableAgentFiles??[]},
554
- {admission:runner.inspectBootstrapAdmission?.()??null});
577
+ {admission:runner.inspectBootstrapAdmission?.()??null,parallelSelection:options.parallelSelection??null});
555
578
  // Keep rejected effects immutable. A run-wide rejection count gives each
556
579
  // corrected result a new effect id without changing the provider attempt.
557
580
  const rejectedValues=status.calls.filter(call=>call.terminal==='failed'