@aibyzero/cm-workflow 0.15.0 → 0.15.3

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.15.0",
3
+ "version": "0.15.3",
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,26 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.15.3 — 2026-09-20
11
+
12
+ - **cm-check 在 Claude 安装上可以拿到 PASSED**:第 1 组查 `.codex-plugin/plugin.json`、第 7 组查根 `VERSION` 与根 `README.md`,三者都是 Codex 插件模式的产物,claude-compat 安装本就不该有(`install.sh` 只写 `templates/cm-VERSION`)。此前这两组只能判 blocked,健康的 Claude 安装永远停在 BLOCKED。现按安装模式分流:控制器推出 `installMode` 并下发给语义检查,语义结果新增 `not_applicable` 状态,仅第 1、7 组可用且必须写明缺的是哪个产物、为何本模式不该有;汇总时它既不算失败也不算阻塞。本模式确实拥有的产物证据不足仍记 blocked,不得借它放行。
13
+ - **修复 cm-check 报告的版本号在 Claude 安装上恒为 null**:结果中的 `version` 此前固定读根 `VERSION`,而 claude-compat 安装没有该文件。现按模式读取,claude-compat 读 `templates/cm-VERSION`。报告另附 `installMode`。
14
+
15
+ ## 0.15.2 — 2026-09-19
16
+
17
+ - **同 feature 并行开发现在可用**:`parallel` 字段此前只存在于代码,没有任何文档或 Skill 提过它,而执行规则要求「不发明字段」,功能因此从入口够不着。现补齐 `docs/js-workflow-control.md` 的「并行组」一节(字段形状、五条约束与失败码、工作树与分支命名、串行合并、QA 延后、review 前置),并在 `cm-ai` N1 增加提议规则:只对 scope 全为新建文件、互不重叠、无依赖路径的同 feature 任务成组,组不起来就串行,不为组而组。
18
+ - **并行提速的真实范围**:当前会话模式下成员的开发请求逐个应答,重叠的是 runner 推进与各自的独立审查进程,不是写代码本身。文档与规则均写明这一点,避免按成倍提速预期使用。
19
+ - **修复链式依赖被并发执行**:并行组的依赖校验此前只看直接边,`A → B → C` 时 `{A, C}` 会被放行并发开发。两者在各自工作树基于 `HEAD` 创建、看不到彼此产物,而组内 scope 本就不重叠,Git 也不会报冲突,错误不会暴露。改为按依赖图的传递闭包判定。
20
+ - **修复保留的 WIP 分支挡住后续批次**(**升级注意**):成员被阻断时会有意保留分支作为证据,但分支名不含 `batchId`,那个名字被永久占住,同一任务的任何后续批次都在 `git worktree add -b` 处报 `batch_worktree_failed`,换 `batchId` 也绕不开,只能手工删分支。分支名改为 `cm/{batchId 前 8 字符}/{feature}/{taskId}`。**升级前创建、尚未收口的并行批次恢复时会报 `batch_worktree_mismatch`,请用旧版本收尾该批次**;`parallel` 此前无文档,预期不存在这类在途批次。
21
+ - **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` 判否。
22
+ - **METRICS 增加「执行方式」列**:记录该任务是串行执行还是并行组成员(`并行:组内{N}个`),否则无法区分耗时变化来自并行还是任务本身。看板模板同步适配列位。
23
+ - **文档补两处契约坑**:`preflight --review-model` 必须是 CLI 实际写进请求体的完整模型 id,别名会以 `model_matches:false` 判失败而回执不给期望值;`check` 回复的 `result` 就是检查数组本身,不套 `{status,value}`,用错会以 `invalid_input` 停在 `reconcile` 且重试无效。
24
+
25
+ ## 0.15.1 — 2026-09-19
26
+
27
+ - **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 目录时仍按既有设计只写全局镜像。
28
+ - **版本标志按安装模式解析**:`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 安装上都无法满足。
29
+
10
30
  ## 0.15.0 — 2026-09-19
11
31
 
12
32
  - 浏览器验收能力改为启动时断言:开启 QA,且规格含阻塞 browser 用例或被 `policies.tests` 选中的 browser 用例时,`cm-ai-host` 与 `cm-ai-batch-host` 必须显式给 `--browser-qa available|unavailable`;因任务未完成而延后的适用用例也计入。`unavailable` 以 `browser_capability_unavailable` 拒绝启动,错误 JSON 仍只输出 code;使用者需换到具备浏览器能力的会话,或调整验收范围并重新审批规格。不命中时给该参数报 `invalid_arguments`。这是**声明不是探测**,声明不持久化,创建与恢复均须重新声明。
package/README.md CHANGED
@@ -17,6 +17,23 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.15.3**
21
+
22
+ - **`/cm-check` 在 Claude 版安装上不再假报 BLOCKED**:有两组检查查的是 Codex 插件专属文件,Claude 版安装本来就没有,此前只能算「查不了」,于是健康的安装也永远拿不到 PASSED。现在按安装方式区分:不属于本安装方式的产物记为「不适用」,而真正证据不足的仍然照常阻塞——不是靠放水换来的通过。
23
+ - 顺带修掉 cm-check 报告里的版本号在 Claude 版安装上总是空的问题。
24
+
25
+ **0.15.2**
26
+
27
+ - **同 feature 并行开发现在可用**:无依赖、改动文件互不重叠的任务可分组,各自在独立 Git 工作树开发,再串行合并回主分支,成员 QA 延后到该 feature 最后一个任务统一执行。此前这个能力只存在于代码里、没有文档,从正常入口用不到。需要注意的是:当前会话模式下写代码仍是逐个进行,并行重叠的是审查与流程开销,不要按成倍提速预期。
28
+ - **升级注意**:并行成员分支改名为 `cm/{批次前缀}/{feature}/{任务号}`。此前被阻断的成员会留下不带批次前缀的分支并永久占住名字,导致同一任务再也跑不了批次。升级前创建、尚未跑完的并行批次请用旧版本收尾。
29
+ - **QA 环境支持桌面与后端/CLI/库项目**:此前只能填 Web / App / 小程序,纯后端或命令行项目要开 QA 只能谎报成网页。现在可以如实声明。
30
+ - **METRICS 新增「执行方式」列**:区分任务是串行跑的还是并行组成员,这样才能看出并行到底省了多少时间。
31
+
32
+ **0.15.1**
33
+
34
+ - **cm-security 现在会记运行日志**:安全扫描开跑与收尾各写一条运行日志(范围、结论词、发现数量、覆盖率、报告路径),与其余主流程命令一致;扫描逻辑、报告门禁与只读边界均未改动。此前 `cm-security` 是唯一没接入运行日志合同的主流程命令,`cm-check` 会因此报一处断链。
35
+ - **修复 Claude 安装下的版本号误判**:`~/.claude` 是 Claude Code 自己的主目录,那里出现与 CM 无关的 `VERSION` 文件时,`cm-check` 会把它当成 CM 版本——轻则版本号报错,该文件版本号更高时 `cm-check` 会直接返回 `blocked` 跑不下去。现按安装模式读取版本标志,Claude 安装认 `templates/cm-VERSION`,源码仓库仍认根 `VERSION`。
36
+
20
37
  **0.15.0**
21
38
 
22
39
  - **兼容性变更(升级前必读)**:旧布局执行存储恢复时返回 `store_layout_legacy`,请用旧版本收尾或退休该 `runId`,旧文件不会自动迁移;显式将 `roles.browser_qa.adapter` 设为非 `browser` 却沿用含 `browser` 的默认测试策略会被拒绝,需要浏览器 QA 时请改为 `browser`(保留 `model: none, source: local`)或删除角色覆盖以继承默认值,不需要时请显式将 `policies.tests` 设为如 `[logic, commands]`,阻塞 browser 用例仍须另行处理验收范围并重新审批;含新字段的运行日志会被旧版本按未知键拒绝,请用 0.15.0 或兼容该字段的后续版本继续运行,不要用旧版本回放这类日志。
@@ -122,7 +139,7 @@ $cm-check
122
139
 
123
140
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
124
141
 
125
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.15.0 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
142
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.15.3 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
126
143
 
127
144
  ## 升级旧版本
128
145
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.0
1
+ 0.15.3
@@ -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.15.0 install` from outside
76
+ To pin a version, use `npx @aibyzero/cm-workflow@0.15.3 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`.
@@ -315,6 +315,13 @@ host-context 必须是真实当前会话身份;宿主将其排除出独立审
315
315
  宿主读取适用指令并用真实工具修改获准文件,再返回原开发输出。
316
316
  - `check`:payload 包含代码根、任务身份、scope、requirements;宿主实际执行检查,
317
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
+ ```
318
325
 
319
326
  这两类请求现在附带原配置解析器产生的 `route`(coder / tester)。每次实际角色边界
320
327
  重新读代码项目配置,并通过原日志写入器记录 `decision/route`;配置错误记录脱敏 error,
@@ -412,6 +419,9 @@ JS 通过现有通道发出固定请求,结果由原组件校验:
412
419
 
413
420
  ```bash
414
421
  # 只启动本机合成 sink 和只读 CLI 探测,不请求真实模型;输出保存为 review.json。
422
+ # --review-model 必须是 CLI 实际写进请求体的完整模型 id,不能用 sonnet 这类别名:
423
+ # 探测按字面比对,别名会以 request_checks 里的 model_matches:false 判失败,
424
+ # 而回执只给布尔值、不给期望值,仅看输出无法推断该填什么。
415
425
  node scripts/cm-ai-host.mjs preflight --config /absolute/run.json --review-model model-name
416
426
  # 携带配置但不授权审查:开发和检查完成后等待授权。
417
427
  node scripts/cm-ai-host.mjs serve --config /absolute/run.json --mode create \
@@ -888,6 +898,7 @@ JS 只校验声明及身份一致性,不证明测试目录已全面调查;
888
898
 
889
899
  `scripts/cm-ai-batch-run.mjs` 导出 `createCmAiBatch({configuration, executionFor, logHome})`。
890
900
  configuration 固定为 `{version:1, repositoryId, batchId, specsDir, codeProject, tasks}`,
901
+ 另有可选 `parallel`(见下节「并行组」)和可选 `codeProjects`。
891
902
  tasks 每项为 `{feature, taskId, scope, requirements}`;首项是本批次起点,之后按原
892
903
  admission 返回的下一任务推进。根路径须规范绝对路径,未列入批准清单的下一任务停止,
893
904
  不推测 scope。`executionFor` 只由可信宿主提供,负责零副作用地组装每任务执行适配器,
@@ -905,6 +916,48 @@ admission 返回的下一任务推进。根路径须规范绝对路径,未列
905
916
  不伪造一条父run_done,也不把这项本地接线当作完整产品宿主/真实provider验收。
906
917
  当前实现仍要求Node24.14+与原执行/平台能力;Linux准入已适配但缺原生端到端证据,原生Windows未接,独立CLI见下文。
907
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
+
908
961
  ### 当前会话多任务 CLI
909
962
 
910
963
  `scripts/cm-ai-batch-host.mjs` 将同一个当前会话通道接到上述 createCmAiBatch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.15.0",
3
+ "version": "0.15.3",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -14,6 +14,7 @@ import {findCmAiQaDecision,readCmAiQaRunRound,reportFile} from './cm-ai-qa-log.m
14
14
  import {captureReviewBaseline} from './review-package.mjs';
15
15
  import {writeCmAiQaStatus} from './cm-ai-run-finalizer.mjs';
16
16
  import {digest,freeze,hex,id,json,need,shape,text,validCallTimeout,validIdentity} from './effect-contract.mjs';
17
+ import {isQaEnvironmentCarrier,QA_ENVIRONMENT_SCOPES} from './qa-environment.mjs';
17
18
 
18
19
  const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
19
20
  const order={ 'cm-default':['logic','commands','browser'],
@@ -126,9 +127,8 @@ export function createHostQaExecutor(options) {
126
127
  }
127
128
  shape(configuration.environment,['kind','carrier','target','scope']);
128
129
  const environment=configuration.environment;
129
- need(['local','test'].includes(environment.scope),'qa_environment_required');text(environment.target);
130
- const carriers={web:['browser'],app:['ios-simulator','android-emulator','device'],miniprogram:['wechat-devtools','device']};
131
- need(carriers[environment.kind]?.includes(environment.carrier),'qa_environment_required');
130
+ need(QA_ENVIRONMENT_SCOPES.includes(environment.scope),'qa_environment_required');text(environment.target);
131
+ need(isQaEnvironmentCarrier(environment.kind,environment.carrier),'qa_environment_required');
132
132
  const describe=plan=>{
133
133
  need(!plan.cases.some(item=>ids.has(item.id)),'qa_id_conflict');
134
134
  // One missing-command item keeps an empty invocation from passing as zero tests.
@@ -0,0 +1,22 @@
1
+ // Single source of truth for QA / visual / walkthrough environment carriers.
2
+ // Previously duplicated verbatim in four modules; a new delivery form had to be
3
+ // added in every copy or the validators silently diverged.
4
+ // The list follows the delivery forms cm-prd confirms with the user
5
+ // (skills/cm-prd/references/greenfield.md), plus the backend, CLI and library
6
+ // projects cm-prd already recognises as having no deployment form.
7
+ export const QA_ENVIRONMENT_CARRIERS=Object.freeze({
8
+ web:Object.freeze(['browser']),
9
+ app:Object.freeze(['ios-simulator','android-emulator','device']),
10
+ miniprogram:Object.freeze(['wechat-devtools','device']),
11
+ desktop:Object.freeze(['app-window']),
12
+ service:Object.freeze(['cli','http-api']),
13
+ library:Object.freeze(['none']),
14
+ });
15
+ export const QA_ENVIRONMENT_SCOPES=Object.freeze(['local','test']);
16
+ // Validation only: nothing downstream branches on kind/carrier, the pair travels
17
+ // with each case request as declared provenance.
18
+ // hasOwn keeps an inherited key such as __proto__ from resolving to Object.prototype,
19
+ // which made the previous duplicated lookups throw instead of rejecting the value.
20
+ export function isQaEnvironmentCarrier(kind,carrier){
21
+ return Object.hasOwn(QA_ENVIRONMENT_CARRIERS,kind)&&QA_ENVIRONMENT_CARRIERS[kind].includes(carrier);
22
+ }
@@ -9,6 +9,10 @@ import {need,shape,json,digest} from '../cm-ai/effect-contract.mjs';
9
9
  const directories=['skills','runtime','agents','compat/claude-commands','templates','scripts','.codex-plugin'];
10
10
  const topFiles=['VERSION','README.md','package.json','install.sh','install.ps1','install-codex.sh','install-codex.ps1'];
11
11
  const optionalIds=['statusline','updater','subagents','isolated_review','external_browser'];
12
+ // Groups 1 and 7 inspect the Codex plugin manifest, the root VERSION and the root README.
13
+ // A Claude-compatible installation legitimately owns none of them, so only these two may be
14
+ // waived as not_applicable; every other group must still reach a real verdict.
15
+ const modeScopedChecks=new Set([1,7]);
12
16
  const nonempty=value=>typeof value==='string'&&value.trim().length>0;
13
17
  function snapshot(root){
14
18
  need(fs.realpathSync(root)===root,'check_source_path_changed');
@@ -51,6 +55,9 @@ export function createCmCheckHost(raw,{call}){
51
55
  const baseline=capture(),skill=readCmInitSource(root,'skills/cm-check/SKILL.md').toString('utf8');
52
56
  const checklist=skill.split('\n').filter(line=>/^[1-8]\. \*\*/.test(line));
53
57
  need(checklist.length===8&&checklist.every((line,index)=>line.startsWith(`${index+1}. `)),'check_checklist_invalid');
58
+ // The mechanical checker already distinguishes the installation mode; derive it from the
59
+ // same marker so the assessor is told which mode it is in instead of inferring it.
60
+ const installMode=fs.existsSync(path.join(root,'.codex-plugin/plugin.json'))?'plugin':'claude-compat';
54
61
  const windows=path.join(root,'scripts/cm-check-runtime.ps1');
55
62
  const response=json(await call('check_runtime',{invocation,
56
63
  windows:{script:windows,args:invocation.args},
@@ -63,16 +70,19 @@ export function createCmCheckHost(raw,{call}){
63
70
  semanticChecked:false,completionAuthorized:false};return status();}
64
71
  stage='semantic';
65
72
  const assessment=json(await call('check_semantic',{workflowRoot:root,project:invocation.project,sourceDigest:baseline.digest,
66
- scope:{directories,files:topFiles},checklist,optionalIds,
67
- instructions:'Read the original eight cm-check semantic groups and relevant local files in this scope. Reuse actual mechanical findings; do not rerun it or its tests. No business testing, file writes, installs, provider calls, private directories or secrets. Return {sourceDigest,checks:[{id:1..8,status:passed|failed|blocked,evidence:[{path:workflow-relative,line:positive integer}],findings:[specific reproducible issue or evidence gap]}],optional:[{id,status:configured|degraded|unknown,reason}]}. Cover every group and optional id exactly once. Passed requires actual cited evidence and no findings; failed requires cited reproducible defects. Missing ability/evidence is blocked, not passed. Optional tools may be degraded, never core failures. No invented executions. Evidence refers to existing local text; missing targets are described with their referring file/line. Compatibility aliases are not private Codex calls. This is current-host semantic assessment, not independent review or completion approval.'},controller.signal));
73
+ scope:{directories,files:topFiles},checklist,optionalIds,installMode,
74
+ instructions:'Read the original eight cm-check semantic groups and relevant local files in this scope. Reuse actual mechanical findings; do not rerun it or its tests. No business testing, file writes, installs, provider calls, private directories or secrets. Return {sourceDigest,checks:[{id:1..8,status:passed|failed|blocked|not_applicable,evidence:[{path:workflow-relative,line:positive integer}],findings:[specific reproducible issue or evidence gap]}],optional:[{id,status:configured|degraded|unknown,reason}]}. installMode names this installation: only a group the checklist itself splits by mode may be not_applicable, and only for the artefacts the other mode owns; state in findings which artefact does not exist in this mode and why. not_applicable never covers an artefact this mode does own, and never substitutes for blocked when evidence is merely missing. Cover every group and optional id exactly once. Passed requires actual cited evidence and no findings; failed requires cited reproducible defects. Missing ability/evidence is blocked, not passed. Optional tools may be degraded, never core failures. No invented executions. Evidence refers to existing local text; missing targets are described with their referring file/line. Compatibility aliases are not private Codex calls. This is current-host semantic assessment, not independent review or completion approval.'},controller.signal));
68
75
  need(!controller.signal.aborted,'cancelled');current(baseline);
69
76
  shape(assessment,['sourceDigest','checks','optional']);need(assessment.sourceDigest===baseline.digest,'check_assessment_stale');
70
77
  need(Array.isArray(assessment.checks)&&assessment.checks.length===8&&new Set(assessment.checks.map(row=>row.id)).size===8,'check_coverage_incomplete');
71
78
  for(const row of assessment.checks){
72
79
  shape(row,['id','status','evidence','findings']);
73
- need(Number.isInteger(row.id)&&row.id>=1&&row.id<=8&&['passed','failed','blocked'].includes(row.status)
80
+ need(Number.isInteger(row.id)&&row.id>=1&&row.id<=8&&['passed','failed','blocked','not_applicable'].includes(row.status)
74
81
  &&Array.isArray(row.evidence)&&Array.isArray(row.findings)&&row.findings.every(nonempty),'check_result_invalid');
75
82
  need(row.status==='passed'?row.findings.length===0&&row.evidence.length>0:row.findings.length>0,'check_result_invalid');
83
+ // Only the groups the checklist splits by installation mode may be waived, so a
84
+ // missing artefact elsewhere still has to be reported as blocked.
85
+ need(row.status!=='not_applicable'||modeScopedChecks.has(row.id),'check_result_invalid');
76
86
  if(row.status==='failed')need(row.evidence.length>0,'check_evidence_required');
77
87
  for(const evidence of row.evidence){
78
88
  shape(evidence,['path','line']);const file=baseline.files[evidence.path];
@@ -85,7 +95,8 @@ export function createCmCheckHost(raw,{call}){
85
95
  for(const row of assessment.optional){shape(row,['id','status','reason']);
86
96
  need(optionalIds.includes(row.id)&&['configured','degraded','unknown'].includes(row.status)&&nonempty(row.reason),'check_optional_invalid');}
87
97
  result={overall:assessment.checks.some(row=>row.status==='failed')?'FAILED':assessment.checks.some(row=>row.status==='blocked')?'BLOCKED':'PASSED',
88
- version:readCmInitSource(root,'VERSION')?.toString('utf8').trim()??null,mechanical,
98
+ version:(readCmInitSource(root,installMode==='plugin'?'VERSION':'templates/cm-VERSION')
99
+ ?.toString('utf8').trim())??null,installMode,mechanical,
89
100
  source:'current_host_semantic_report',sourceDigest:baseline.digest,checks:[...assessment.checks].sort((a,b)=>a.id-b.id),optional:assessment.optional,
90
101
  findingsCount:assessment.checks.filter(row=>row.status==='failed').reduce((sum,row)=>sum+row.findings.length,0),
91
102
  semanticChecked:true,completionAuthorized:false};
@@ -4,6 +4,7 @@ import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import {createHash} from 'node:crypto';
6
6
  import {digest,json,need,shape,text,validCallTimeout} from '../cm-ai/effect-contract.mjs';
7
+ import {isQaEnvironmentCarrier,QA_ENVIRONMENT_SCOPES} from '../cm-ai/qa-environment.mjs';
7
8
 
8
9
  export const isVisual=config=>config?.kind==='visual';
9
10
  export function visualConfiguration(config){
@@ -12,8 +13,8 @@ export function visualConfiguration(config){
12
13
  need(path.isAbsolute(config.cwd)&&fs.realpathSync(config.cwd)===config.cwd,'unsupported_path');
13
14
  if(config.testFiles)need(Array.isArray(config.testFiles)&&config.testFiles.length===0,'fix_visual_test_files_invalid');
14
15
  shape(config.environment,['scope','kind','carrier','target']);
15
- need(['local','test'].includes(config.environment.scope)&&({web:['browser'],app:['ios-simulator','android-emulator','device'],
16
- miniprogram:['wechat-devtools','device']})[config.environment.kind]?.includes(config.environment.carrier),'fix_visual_environment_required');text(config.environment.target);
16
+ need(QA_ENVIRONMENT_SCOPES.includes(config.environment.scope)
17
+ &&isQaEnvironmentCarrier(config.environment.kind,config.environment.carrier),'fix_visual_environment_required');text(config.environment.target);
17
18
  for(const list of [config.steps,config.expected]){need(Array.isArray(list)&&list.length>0&&list.length<=32,'fix_visual_steps_required');list.forEach(text);}
18
19
  need(config.expected.every(value=>!value.includes('[需确认]')),'fix_visual_expectation_unconfirmed');
19
20
  inspectVisualCarrier(config.before);return config;
@@ -3,6 +3,7 @@
3
3
  import {createHostCheck} from '../cm-ai/host-check.mjs';
4
4
  import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
5
5
  import {digest,hex,id,json,need,shape,text,validCallTimeout,validIdentity} from '../cm-ai/effect-contract.mjs';
6
+ import {isQaEnvironmentCarrier,QA_ENVIRONMENT_SCOPES} from '../cm-ai/qa-environment.mjs';
6
7
 
7
8
  export function readFixWalkthrough(raw,cwd){
8
9
  const config=json(raw,64*1024);
@@ -22,7 +23,7 @@ export function readFixWalkthrough(raw,cwd){
22
23
  if(flow.kind==='browser'){
23
24
  shape(config.environment,['kind','carrier','target','scope']);
24
25
  const {kind,carrier,target,scope}=config.environment;text(target);
25
- need(['local','test'].includes(scope)&&({web:['browser'],app:['ios-simulator','android-emulator','device'],miniprogram:['wechat-devtools','device']})[kind]?.includes(carrier),'walkthrough_environment_required');
26
+ need(QA_ENVIRONMENT_SCOPES.includes(scope)&&isQaEnvironmentCarrier(kind,carrier),'walkthrough_environment_required');
26
27
  }
27
28
  }
28
29
  return config;
@@ -15,6 +15,7 @@ import {inspectDeclaredTestCommand} from './declared-command.mjs';
15
15
  import {inspectCmTestRecovery} from './recovery.mjs';
16
16
  import {collectBranchImpact,assertBranchComparison,inspectImpactAnalysis} from './branch-impact.mjs';
17
17
  import {inside,canonicalFuture,selectReportDirectory,snapshotSource,sourceChanges,readSourceFiles,checkSourceEvidence} from './source-snapshot.mjs';
18
+ import {isQaEnvironmentCarrier} from '../cm-ai/qa-environment.mjs';
18
19
 
19
20
  const nonempty=value=>typeof value==='string'&&value.trim().length>0;
20
21
  const read=file=>{
@@ -41,8 +42,7 @@ export function createCmTestHost(raw,{call,session=null}){
41
42
  const runId=session?.context?.runId??`test-${randomUUID()}`,reportDir=selectReportDirectory(admission,runId);
42
43
  if(config.environment!==null){
43
44
  shape(config.environment,['scope','kind','carrier','target']);
44
- const carriers={web:['browser'],app:['ios-simulator','android-emulator','device'],miniprogram:['wechat-devtools','device']};
45
- need(carriers[config.environment.kind]?.includes(config.environment.carrier)&&nonempty(config.environment.target),
45
+ need(isQaEnvironmentCarrier(config.environment.kind,config.environment.carrier)&&nonempty(config.environment.target),
46
46
  'cm_test_environment_invalid');
47
47
  }
48
48
  const controller=new AbortController();let stage='ready',result=null,reason=null,logFile=null;
@@ -6,7 +6,10 @@ This contract is shared by every CM workflow skill. Resolve paths from the activ
6
6
 
7
7
  1. Let `SKILL_DIR` be the directory containing the active CM `SKILL.md`.
8
8
  2. The workflow root is normally `SKILL_DIR/../..`.
9
- 3. Verify the candidate root contains `VERSION`, `templates/`, and `runtime/` before using it.
9
+ 3. Verify the candidate root contains `templates/` and `runtime/`, plus the version marker of its
10
+ installation mode: `VERSION` for a Codex plugin or a source checkout, `templates/cm-VERSION` for a
11
+ Claude-compatible installation. `install.sh` writes only the latter, so a Claude installation root
12
+ has no `VERSION`; a file with that name there does not belong to CM.
10
13
  4. If a user explicitly provides `CM_WORKFLOW_HOME`, prefer it after the same verification.
11
14
  5. Do not hardcode `~/.codex/plugins/cache`, `~/.agents/skills`, or `~/.claude` as the workflow root.
12
15
 
@@ -127,9 +127,17 @@ export function createCmAiBatch({configuration,executionFor,logHome,runtime='cod
127
127
  }
128
128
  return {rows,current:[...plans.keys()].find(key=>!done.has(key)),stopped,code,done,ready,merging,blocked};
129
129
  }
130
+ // The batch prefix goes into the branch as well, not only into the worktree path.
131
+ // A blocked member keeps its branch on purpose (its WIP is evidence), and without a
132
+ // per-batch segment that name would block every later batch touching the same task.
133
+ // It is the second segment rather than a suffix: refs/heads/cm/work/T-001 and
134
+ // refs/heads/cm/work/T-001/<batch> cannot coexist, so a suffix would still collide
135
+ // with branches left by earlier versions. Git rejects ".." and a trailing dot in a
136
+ // ref component while batchId allows dots, so the segment normalises them.
137
+ const batchSegment=config.batchId.slice(0,8).replace(/\./g,'-');
130
138
  const location=key=>{const definition=plans.get(key);return {
131
139
  worktree:path.resolve(config.codeProject,'..','.cm-worktrees',config.batchId.slice(0,8),definition.identity.taskId),
132
- branch:`cm/${definition.feature.replace(/^\d+\./,'')}/${definition.identity.taskId}`};};
140
+ branch:`cm/${batchSegment}/${definition.feature.replace(/^\d+\./,'')}/${definition.identity.taskId}`};};
133
141
  function verifyMerged(row){
134
142
  const definition=plans.get(row.from_key),state=JSON.parse(fs.readFileSync(path.join(config.specsDir,'.reviews','.execution',definition.identity.runId,'state.json'),'utf8'));
135
143
  const {revision,...body}=state;
@@ -425,7 +433,14 @@ function validateGroups(config,plans){
425
433
  need(!parsed.error,'parallel_task_invalid');
426
434
  const ids=new Set(group.map(key=>plans.get(key).identity.taskId));
427
435
  need([...ids].every(id=>parsed.tasks.some(task=>task.id===id&&!task.dropped)),'parallel_task_invalid');
428
- need([...ids].every(id=>(parsed.dependencies.get(id)??[]).every(dep=>!ids.has(dep))),'parallel_dependency_conflict');
436
+ // Direct edges are not enough: with A -> B -> C, a group of {A, C} has no direct edge
437
+ // between its members while A still needs C. Walk the whole prerequisite closure.
438
+ const reaches=(from,target,seen=new Set())=>{
439
+ if(seen.has(from))return false;seen.add(from);
440
+ const deps=parsed.dependencies.get(from)??[];
441
+ return deps.includes(target)||deps.some(dep=>reaches(dep,target,seen));
442
+ };
443
+ need([...ids].every(id=>[...ids].every(other=>other===id||!reaches(id,other))),'parallel_dependency_conflict');
429
444
  const ordered=parsed.tasks.filter(task=>!task.dropped),last=ordered.at(-1);
430
445
  need(last&&!ids.has(last.id)&&plans.has(`${feature}/${last.id}`),'parallel_final_task_excluded');
431
446
  const paths=new Set();
@@ -29,6 +29,30 @@ test('serial fallback resumes from log and automatically commits its completed t
29
29
  test('final serial task commits durably and commit information survives resume',()=>batchFixture('final-commit'));
30
30
  test('dirty batch entry lists files and creates no member worktrees',()=>batchFixture('parallel-dirty'));
31
31
 
32
+ test('parallel groups reject transitive prerequisites, not just direct edges',()=>{
33
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-transitive-')));
34
+ const specs=path.join(root,'specs'),code=path.join(root,'code'),feature='1.work';
35
+ fs.mkdirSync(path.join(specs,feature),{recursive:true});fs.mkdirSync(code);
36
+ fs.writeFileSync(path.join(code,'req.md'),'# r\n');
37
+ // T-009 <- T-005 <- T-003 <- T-001; T-007 is unrelated.
38
+ fs.writeFileSync(path.join(specs,feature,'tasks.md'),
39
+ '- [ ] T-001: a\n- [ ] T-003: b\n- [ ] T-005: c\n- [ ] T-007: d\n- [ ] T-009: final\n\n'+
40
+ '- T-003 依赖 T-001\n- T-005 依赖 T-003\n- T-009 依赖 T-005\n');
41
+ const task=(taskId,scope)=>({feature,taskId,scope:[scope],requirements:['req.md']});
42
+ const tasks=[task('T-001','a.js'),task('T-003','b.js'),task('T-005','c.js'),task('T-007','e.js'),task('T-009','d.js')];
43
+ let batchId=0;
44
+ const build=group=>createCmAiBatch({configuration:{version:1,repositoryId:'r',batchId:`transitive-${++batchId}`,
45
+ specsDir:specs,codeProject:code,parallel:[group],tasks},executionFor:async()=>({}),logHome:path.join(root,'log')});
46
+ for(const group of [[`${feature}/T-003`,`${feature}/T-001`], // direct edge
47
+ [`${feature}/T-005`,`${feature}/T-001`], // one hop away
48
+ [`${feature}/T-009`,`${feature}/T-001`]]){ // two hops away
49
+ assert.throws(()=>build(group),error=>error.code==='parallel_dependency_conflict',group.join(' + '));
50
+ }
51
+ // An unrelated pair still forms a group.
52
+ assert.ok(build([`${feature}/T-007`,`${feature}/T-001`]));
53
+ fs.rmSync(root,{recursive:true,force:true});
54
+ });
55
+
32
56
  test('task commit subjects are single-line and bounded while bodies preserve descriptions',()=>{
33
57
  const cases=[
34
58
  ['简短任务','T-001: 简短任务'],
@@ -243,7 +267,15 @@ async function batchFixture(mode,options={}){
243
267
  if(mode==='parallel-resume'){assert(interrupted);const before=[...calls];result=await open().handle({operation:'advance',requestId:'resume-parallel'});assert.deepEqual(calls.slice(0,before.length),before);}
244
268
  if(mode==='parallel-conflict'){
245
269
  assert.equal(result.code,'merge_conflict',JSON.stringify(result));assert.equal(git(codeProject,['rev-parse','HEAD']),conflictHead);
246
- for(const task of ['T-001','T-002'])assert(fs.existsSync(path.join(root,'.cm-worktrees',config.batchId.slice(0,8),task)));return;
270
+ for(const task of ['T-001','T-002'])assert(fs.existsSync(path.join(root,'.cm-worktrees',config.batchId.slice(0,8),task)));
271
+ // Kept member branches are namespaced per batch, so a later batch of the same
272
+ // tasks does not collide with the WIP branches this one leaves behind.
273
+ const segment=config.batchId.slice(0,8).replace(/\./g,'-');
274
+ const heads=git(codeProject,['for-each-ref','--format=%(refname:short)','refs/heads/cm']).split('\n').filter(Boolean);
275
+ assert.deepEqual(heads.sort(),[`cm/${segment}/work/T-001`,`cm/${segment}/work/T-002`]);
276
+ for(const name of heads)git(codeProject,['check-ref-format','--branch',name]);
277
+ for(const task of ['T-001','T-002'])assert.throws(()=>git(codeProject,['rev-parse','--verify',`refs/heads/cm/work/${task}`]));
278
+ return;
247
279
  }
248
280
  if(mode==='qa-resume'){
249
281
  assert.equal(result.code,'qa_decision_required');assert.deepEqual(calls,['T-001']);
@@ -75,3 +75,61 @@ test('coverage, evidence, stale source/config, core findings and cancellation pr
75
75
  if(mode==='failed')assert.equal(value.result.findingsCount,1);
76
76
  }
77
77
  });
78
+
79
+ test('a Claude-compatible installation waives only the Codex-owned halves and still reaches PASSED',{timeout:5000},async t=>{
80
+ const f=fixture(t);
81
+ // A claude-compat installation: no .codex-plugin manifest, the version marker is templates/cm-VERSION.
82
+ fs.mkdirSync(path.join(f.dir,'templates'),{recursive:true});
83
+ fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),'9.9.9\n');
84
+ let seenMode=null;
85
+ const host=createCmCheckHost(f.input,{call:async(kind,payload)=>{
86
+ if(kind==='check_runtime')return mechanical(payload);
87
+ seenMode=payload.installMode;
88
+ const value=assessment(payload);
89
+ for(const id of [1,7]){
90
+ const row=value.checks.find(check=>check.id===id);
91
+ row.status='not_applicable';row.evidence=[];
92
+ row.findings=[`installMode=${payload.installMode}: the Codex-owned artefact is absent by install mode`];
93
+ }
94
+ return value;
95
+ }});
96
+ const report=await host.handle({requestId:'na-1',operation:'start'});
97
+ assert.equal(seenMode,'claude-compat','the assessor must be told the mode, not left to guess');
98
+ assert.equal(report.result.overall,'PASSED',JSON.stringify(report.result));
99
+ assert.equal(report.result.installMode,'claude-compat');
100
+ assert.equal(report.result.version,'9.9.9','claude-compat reports templates/cm-VERSION, not the root VERSION');
101
+ assert.equal(report.result.findingsCount,0);
102
+ assert.deepEqual(report.result.checks.filter(row=>row.status==='not_applicable').map(row=>row.id),[1,7]);
103
+ });
104
+
105
+ test('not_applicable is refused outside the mode-scoped groups and when findings are missing',{timeout:5000},async t=>{
106
+ for(const mutate of [
107
+ value=>{const row=value.checks.find(check=>check.id===3);row.status='not_applicable';row.evidence=[];row.findings=['not a mode-scoped group'];},
108
+ value=>{const row=value.checks.find(check=>check.id===1);row.status='not_applicable';row.evidence=[];row.findings=[];},
109
+ ]){
110
+ const f=fixture(t);
111
+ const host=createCmCheckHost(f.input,{call:async(kind,payload)=>{
112
+ if(kind==='check_runtime')return mechanical(payload);
113
+ const value=assessment(payload);mutate(value);return value;
114
+ }});
115
+ const report=await host.handle({requestId:'na-2',operation:'start'});
116
+ assert.equal(report.result.overall,'BLOCKED',JSON.stringify(report.result));
117
+ assert.equal(report.result.reason,'check_result_invalid');
118
+ }
119
+ });
120
+
121
+ test('a plugin installation keeps reporting the root VERSION', {timeout:5000}, async t=>{
122
+ const f=fixture(t);
123
+ fs.mkdirSync(path.join(f.dir,'.codex-plugin'),{recursive:true});
124
+ fs.writeFileSync(path.join(f.dir,'.codex-plugin/plugin.json'),JSON.stringify({name:'cm-workflow',version:'0.0.0'}));
125
+ let seenMode=null;
126
+ const host=createCmCheckHost(f.input,{call:async(kind,payload)=>{
127
+ if(kind==='check_runtime')return mechanical(payload);
128
+ seenMode=payload.installMode;return assessment(payload);
129
+ }});
130
+ const report=await host.handle({requestId:'na-3',operation:'start'});
131
+ assert.equal(seenMode,'plugin');
132
+ assert.equal(report.result.installMode,'plugin');
133
+ assert.equal(report.result.version,'0.0.0');
134
+ assert.equal(report.result.overall,'PASSED');
135
+ });
@@ -90,8 +90,11 @@ export async function updateInstallation({skillDir, runtime}, {
90
90
  root = fs.realpathSync(path.resolve(skillDir, '../..'));
91
91
  if (fs.realpathSync(skillDir) !== path.join(root, 'skills/cm-check')) throw new Error('Invalid Skill root');
92
92
  regularFile(path.join(root, 'skills/cm-check/SKILL.md'));
93
- // Source checkouts use VERSION even when invoked from Claude.
94
- const versionRuntime = fs.existsSync(path.join(root, 'VERSION')) ? 'codex' : runtime;
93
+ // Prefer this runtime's own marker. Only a source checkout or tarball, which has no
94
+ // templates/cm-VERSION, falls back to the root VERSION: a Claude installation root is
95
+ // ~/.claude, where an unrelated VERSION file must not be mistaken for the CM version.
96
+ const runtimeVersionFile = runtime === 'claude' ? 'templates/cm-VERSION' : 'VERSION';
97
+ const versionRuntime = fs.existsSync(path.join(root, runtimeVersionFile)) ? runtime : 'codex';
95
98
  current = versionAt(root, versionRuntime);
96
99
  try { latest = await query(); compareVersions(latest, latest); }
97
100
  catch { return result('offline', 'Cannot confirm the latest npm version; continue local checks with this limitation.'); }
@@ -87,6 +87,27 @@ test('source checkout and unknown package managers are never overwritten', async
87
87
  assert.equal(f.calls.length, 0);
88
88
  });
89
89
 
90
+ test('an unrelated root VERSION never overrides the Claude installation marker', async t => {
91
+ const f = fixture(t, 'claude');
92
+ // ~/.claude is Claude Code's own home; a foreign VERSION file there is not the CM version.
93
+ f.write(path.join(f.root, 'VERSION'), '2.1.274\n');
94
+ const report = await updateInstallation(f.input, f.options);
95
+ assert.equal(report.current, '0.10.6');
96
+ assert.equal(report.status, 'updated');
97
+ assert.equal(report.installed, '0.11.0');
98
+ });
99
+
100
+ test('a Claude source checkout without templates/cm-VERSION still reads the root VERSION', async t => {
101
+ const f = fixture(t, 'claude');
102
+ fs.rmSync(path.join(f.root, 'templates'), {recursive: true});
103
+ f.write(path.join(f.root, 'VERSION'), '0.10.6\n');
104
+ const moved = path.join(f.home, 'source'); fs.renameSync(f.root, moved);
105
+ const report = await updateInstallation({...f.input, skillDir: path.join(moved, 'skills/cm-check')}, f.options);
106
+ assert.equal(report.current, '0.10.6');
107
+ assert.equal(report.status, 'unmanaged');
108
+ assert.equal(f.calls.length, 0);
109
+ });
110
+
90
111
  test('old active cache checks newer managed installation without reinstalling or downgrading', async t => {
91
112
  const f = fixture(t);
92
113
  const cache = path.join(f.home, '.codex/plugins/cache/personal/cm-workflow/old');
@@ -0,0 +1,30 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {QA_ENVIRONMENT_CARRIERS,QA_ENVIRONMENT_SCOPES,isQaEnvironmentCarrier} from '../runtime/js/cm-ai/qa-environment.mjs';
4
+
5
+ test('carrier table covers every cm-prd delivery form plus backend, CLI and library projects',()=>{
6
+ // cm-prd confirms Web / iOS / Android / 小程序 / 桌面 / 多端 with the user, and
7
+ // separately recognises projects with no deployment form (local tools, libraries).
8
+ assert.deepEqual(Object.keys(QA_ENVIRONMENT_CARRIERS).sort(),
9
+ ['app','desktop','library','miniprogram','service','web']);
10
+ for(const [kind,carrier] of [['web','browser'],['app','ios-simulator'],['app','android-emulator'],
11
+ ['app','device'],['miniprogram','wechat-devtools'],['miniprogram','device'],
12
+ ['desktop','app-window'],['service','cli'],['service','http-api'],['library','none']]){
13
+ assert.equal(isQaEnvironmentCarrier(kind,carrier),true,`${kind}/${carrier}`);
14
+ }
15
+ });
16
+
17
+ test('carriers stay bound to their own kind and unknown values are rejected',()=>{
18
+ for(const [kind,carrier] of [['service','browser'],['library','cli'],['desktop','device'],
19
+ ['web','app-window'],['backend','cli'],['service','shell'],['','']]){
20
+ assert.equal(isQaEnvironmentCarrier(kind,carrier),false,`${kind}/${carrier}`);
21
+ }
22
+ assert.equal(isQaEnvironmentCarrier('__proto__','cli'),false);
23
+ assert.deepEqual([...QA_ENVIRONMENT_SCOPES],['local','test']);
24
+ });
25
+
26
+ test('the shared table is frozen so one consumer cannot mutate it for the others',()=>{
27
+ assert.throws(()=>{QA_ENVIRONMENT_CARRIERS.service=['anything'];},TypeError);
28
+ assert.throws(()=>{QA_ENVIRONMENT_CARRIERS.web.push('app-window');},TypeError);
29
+ assert.equal(isQaEnvironmentCarrier('web','app-window'),false);
30
+ });
@@ -64,6 +64,8 @@
64
64
  需要单独核验批准 manifest 时,可只读运行 `python3 {CM_WORKFLOW_ROOT}/scripts/cm-spec-manifest.py {SPECS_DIR} --status-file {SPECS_DIR}/.cm-specs-status`;失败不授权改写。
65
65
  N5/N6 的任务与 AC checkbox 变化仍由现有 manifest 规范化处理,文案、ID、设计和测试合同变化继续受准入保护。
66
66
 
67
+ 多任务批次的并行组提议规则见 `js-host.md` 第 3.1 条;本兼容流程不自行发明并行判定。
68
+
67
69
  > 这是**入口授权门**(人把关方案端),不属于"暂停仅灾难级"约束的中途暂停,也不计入 METRICS 人工介入。实跑教训:没有这道闸,prd 生成完会被一句"继续"顺势带进开发,人审形同虚设。
68
70
 
69
71
  ## 独立审查通道预检
@@ -83,12 +83,15 @@ git -C {CODE_PROJECT} commit -m "T-{编号} {feature名}: {任务标题}
83
83
  标记完成后,向 `{SPECS_DIR}/METRICS.md` 追加本任务一行(文件不存在则先创建表头):
84
84
 
85
85
  ```markdown
86
- | 任务 | Feature | 开始 | 结束 | 审查轮次 | 独立审查拦截 | QA | 人工介入(次:原因) |
87
- | T-003 | 1.user-auth | 10:02 | 10:41 | 2 | 1 | — | 1:业务歧义 |
86
+ | 任务 | Feature | 开始 | 结束 | 审查轮次 | 独立审查拦截 | QA | 人工介入(次:原因) | 执行方式 |
87
+ | T-003 | 1.user-auth | 10:02 | 10:41 | 2 | 1 | — | 1:业务歧义 | 串行 |
88
+ | T-004 | 1.user-auth | 10:41 | 11:03 | 1 | 0 | — | 0 | 并行:组内2个 |
88
89
  ```
89
90
 
90
91
  - 审查轮次 / 独立审查拦截数来自 N4;QA 列先写 `—`,N6 触发时回填
91
92
  - 人工介入:本任务执行期间每次暂停问人计 1 次并注明原因(技术选型自主决策不计)
93
+ - 执行方式:本任务串行执行写 `串行`;作为批次并行组成员执行写 `并行:组内{N}个`(N 为该组成员数)。
94
+ 这一列是判断并行是否真的省时间的唯一依据——没有它,无法区分耗时变化来自并行还是任务本身
92
95
  - 这张表是试点/灰度门槛(人工介入 ≤2 次/任务、一次通过率等)的**唯一数据源,不可跳过**
93
96
 
94
97
  ## LESSONS.md
@@ -23,6 +23,21 @@
23
23
  单任务用 `cm-ai-host.mjs`;多任务用 `cm-ai-batch-host.mjs` 的原 batch/workflows 配置。
24
24
  任务列表只包含该运行计划内的任务;恢复必须使用原身份、配置和真实当前会话身份,
25
25
  会话不同导致不能恢复时报告阻断,不能冒用旧 host-context。
26
+ 3.1 多任务批次可提议并行组,写进 batch 配置的可选 `parallel`(任务 key 的数组的数组)。
27
+ 只提议同时满足以下全部条件的任务,任一不满足就不进组;一个组都成立不了就**不写该字段**,正常串行:
28
+ - **纯新建文件**:该任务 scope 的每个路径在 `HEAD` 上都不存在(`git cat-file -e HEAD:{path}`
29
+ 判定,不看工作区——成员工作树从 HEAD 创建,未跟踪文件不算数)。任务若需改动现有文件
30
+ 来注册新模块(路由表、index 导出等),那些文件会出现在 scope 里,本条自动将其排除。
31
+ - **scope 两两不交集**:候选之间不得有重复路径。
32
+ - **无依赖路径**:按 `tasks.md` 依赖图计算**传递闭包**,组内任意两任务之间不得存在依赖路径。
33
+ runner 也按传递闭包校验并以 `parallel_dependency_conflict` 拒绝,此处自行判定是为了
34
+ 提出合法的组而不是被拒后返工。
35
+ - **同一 feature**,且排除该 feature 最后一个未 DROPPED 的任务(它承担合并后的统一 QA)。
36
+ - **每组 2–4 个**,不足 2 个不成组。
37
+ 能并行才并行,不为组而组;判定不确定时按串行处理。成员在各自 Git 工作树开发、串行合并回
38
+ 主分支,成员 QA 自动延后到末任务;当前会话模式下开发请求仍逐个应答,重叠的是审查与流程开销,
39
+ 不是写代码本身,不得据此承诺成倍提速。
40
+
26
41
  4. 核对任务所需能力后才启动。QA 使用原测试合同与已授权命令/环境;无 QA 配置不能宣称
27
42
  已完成必需 QA。文档路径预先纳入任务批准 scope;需要 AGENTS/CLAUDE 等保护指令同步、
28
43
  bootstrap规范用下文受信入口;其他未满足的必需能力记录具体缺口,不降格成可选项。
@@ -55,13 +55,13 @@ node "{CM_WORKFLOW_ROOT}/scripts/cm-check-host.mjs" serve \
55
55
 
56
56
  ## 语义检查
57
57
 
58
- 1. **Codex 入口**:`.codex-plugin/plugin.json` 的 `skills` 指向 `./skills/`;`cm-idea/cm-init/cm-prd/cm-ai/cm-test/cm-security/cm-fix/cm-refactor/cm-check/cm-runtime` 十个核心 Skill 与独立 `external-expert` Skill 均有合法 frontmatter。
58
+ 1. **Codex 入口**(按 `installMode` 分流):`cm-idea/cm-init/cm-prd/cm-ai/cm-test/cm-security/cm-fix/cm-refactor/cm-check/cm-runtime` 十个核心 Skill 与独立 `external-expert` Skill 均有合法 frontmatter,两种模式都查。`plugin` 模式另查 `.codex-plugin/plugin.json` 的 `skills` 指向 `./skills/`;`claude-compat` 模式没有该清单文件(安装器不生成),这一半记 `not_applicable` 并说明,不记 blocked。
59
59
  2. **共享真相**:十个核心 Skill 引用 `runtime/` 合同;`external-expert` 引用共享外部专家合同;`compat/claude-commands/cm-*.md` 只是 macOS/Linux 旧入口薄包装,不再复制业务规则。
60
60
  3. **流程链路**:`cm-ai` 的 N1–N8 引用全部存在;`cm-prd` 的 greenfield/brownfield/change-mode 全部存在;`cm-idea` 引用 `idea-to-prd`;`cm-prd/cm-ai/cm-test/cm-qa-engineer` 共用 `runtime/test-contract.md`;`cm-prd/cm-ai/cm-test/cm-security/cm-fix/cm-refactor/external-expert` 共用 `runtime/logging.md` 与统一 writer;`cm-test --generate-cases` 生成校验后的 inferred 草稿并硬停止。
61
61
  4. **角色链路**:N3 引用的 `cm-*-engineer/manager/expert` Skill 存在;Claude `agents/` 中每个兼容角色能找到对应工种 Skill。Codex 不依赖这些 `.md` agent 文件;配套完整性核对用户级 `runtimes.yml` 的安装器/cm-runtime 生成方与 cm-workflow-config 消费方,cm-runtime 是独立工具、不配工种。
62
62
  5. **状态与审查**:`.cm-specs-status`、`.cm-status.json`、`.cm-run.json`、`tasks.md`、可选 `test-cases.json`、`METRICS.md`、`LESSONS.md`、`运行日志.jsonl` 及 `.reviews/` 的生成方与消费方配对;项目日志保持权威,全局日志只是私有可重建镜像;N4 凭证头包含 reviewer/independent/task/round/at/scope;`cm-fix` 收口前机械检查修后审查凭证;`.external/` 不得冒充 N4/N5 凭证。
63
63
  6. **模板路径**:所有 `{CM_WORKFLOW_ROOT}/templates/...` 引用都对应真实文件,重点核对 `templates/rules/`、`templates/ui-lens/`、`templates/hooks/`、`templates/refactor/`。
64
- 7. **版本**:根 `VERSION` 与 plugin manifest 一致;README 不得宣称不存在的入口或安装路径。
64
+ 7. **版本**(按 `installMode` 分流):`plugin` 模式核对根 `VERSION` 与 `.codex-plugin/plugin.json` 一致,并核对根 `README.md` 不宣称不存在的入口或安装路径;`claude-compat` 模式的版本标志是 `templates/cm-VERSION`,根 `VERSION` 与根 `README.md` 均不由安装器生成(`install.sh` 只写 `templates/cm-VERSION`),这两项记 `not_applicable` 并说明,不记 blocked。
65
65
  8. **私有调用清零**:Codex 核心 Skill 不得残留 `TaskCreate`、`TodoWrite`、`codex:review`、`~/.claude/commands`;兼容包装中出现 `/cm:*` 是合法的 macOS/Linux 旧入口。
66
66
 
67
67
  传入 `--project` 时机械检查额外输出「运行时声明对照」:按项目 > 用户级默认 > 未声明读取
@@ -83,9 +83,12 @@ Claude 兼容: {通过/失败}
83
83
  状态与审查: {通过/断链清单}
84
84
  模板与版本: {通过/不一致清单}
85
85
  可选增强: {已配置/降级项}
86
- 结论: PASSED / FAILED ({N} 处)
86
+ 结论: PASSED / FAILED ({N} 处) / BLOCKED(附未查完的组)
87
87
  ```
88
88
 
89
+ 第 1、7 组的 `not_applicable` 只适用于另一种安装模式独有的产物,且必须写明缺的是哪个文件、为何本模式不该有;
90
+ 其余各组以及本模式确实拥有的产物,证据不足一律记 blocked,不得借 `not_applicable` 放行。
91
+
89
92
  除上述安装升级外,只报告可复现的断链,不自动修复项目文件或配置。
90
93
  独立的 `cm-check-host.mjs`、`cm-check-entry.mjs`、`cm-check-runtime.sh/.ps1` 仍只检查,
91
94
  不会联网升级;CI、安装器与发版校验调用这些入口,不递归触发更新。
@@ -5,7 +5,7 @@ description: 用户运行 cm-security,或要求代码安全扫描、漏洞检
5
5
 
6
6
  # cm-security — 代码安全扫描与业务复核
7
7
 
8
- 先读 `../../runtime/project-context.md` 和 [执行合同](references/scan-contract.md)。
8
+ 先读 `../../runtime/project-context.md`、`../../runtime/logging.md` 和 [执行合同](references/scan-contract.md)。
9
9
  本 Skill 是独立只读安全入口;不改变 cm-test、任务完成门禁或发布授权。
10
10
  Codex 用 `$cm-security`,Claude Code 用 `/cm-security`;macOS/Linux 兼容 `/cm:security`。
11
11
 
@@ -41,6 +41,8 @@ node "{CM_WORKFLOW_ROOT}/scripts/cm-security.mjs" --project "{项目根}" --fina
41
41
 
42
42
  9. 以 `--finalize` 返回的 `result`、`coverage`、`gaps` 与 `reportPath` 输出简短结论,模型不再自行决定结论词。宿主在项目外创建私有报告目录;BLOCKED 时报告证据过期或输入错误,不替用户回滚。最终 JSON 原样保留校验通过的分析结论及未复核 reason,按路径列出未复核项;stdout 仅含六个摘要字段,不含自由描述。脱敏针对工具原始 stdout/stderr、密钥原文与源码片段;模型不得把这些内容粘进复核字段,JS 无法验证这项语义义务。默认扫描不自动修复、不安装、不提交、不上传给额外服务;需要修复时将证据交给用户决定。
43
43
 
44
+ 范围、业务地图与安全边界确认后按 `runtime/logging.md` 写 `run_start`;`--finalize` 返回终态后写 `run_done`,只记录扫描范围、结论词、发现数量、覆盖率与报告路径。本 Skill 通常在没有 specs 目录的项目上独立运行,保存首次写入器返回的 `run_id` 并在后续事件显式传回。工具原始 stdout/stderr、密钥原文、源码片段与 findings 正文不进日志;`BLOCKED` 同样写 `run_done`,detail 只写阻断原因。写日志不改变本 Skill 的只读边界。
45
+
44
46
  ## 报告
45
47
 
46
48
  ```text
@@ -44,9 +44,10 @@
44
44
  不改 argv、不用底层二进制回退;workspace/prefix/if-present 等变体不静默放行。
45
45
  禁止安装/升级、自动改快照或代码,以及生产操作;执行前由宿主核对命令行为。
46
46
  4. commands/browser 需要明确的 `environment`:
47
- `{scope:"local"|"test",kind:"web"|"app"|"miniprogram",carrier,target}`;
48
- carrier 使用 browser、ios-simulator、android-emulator、wechat-devtools 或 device,
49
- 与形态匹配。目标必须真实是本地/测试环境,不能只把生产 URL 标成 test。
47
+ `{scope:"local"|"test",kind,carrier,target}`;kind 与 carrier 的合法组合以
48
+ `runtime/js/cm-ai/qa-environment.mjs` 的 `QA_ENVIRONMENT_CARRIERS` 为准:
49
+ web→browser,app→ios-simulator/android-emulator/device,miniprogram→wechat-devtools/device,
50
+ desktop→app-window,service→cli/http-api,library→none。按真实交付形态填写,不得借用不符的形态。目标必须真实是本地/测试环境,不能只把生产 URL 标成 test。
50
51
  浏览器有副作用时确认可执行 cleanup;权限不足、工具缺失或无法清理时阻断。
51
52
  5. 启动 `node "{CM_WORKFLOW_ROOT}/scripts/cm-test-host.mjs" serve --config "{配置路径}"`,
52
53
  保持 stdin/stdout 双向连接。收到 host_ready 后发送
@@ -128,10 +128,10 @@ async function load(){
128
128
  const met=await txt('./METRICS.md');
129
129
  let rows=[],human=0,firstPass=0;
130
130
  if(met){
131
- rows=[...met.matchAll(/^\|\s*(T-\d+)\s*\|(.+)$/gm)].map(m=>[m[1],...m[2].split('|').map(s=>s.trim()).slice(0,7)]);
131
+ rows=[...met.matchAll(/^\|\s*(T-\d+)\s*\|(.+)$/gm)].map(m=>[m[1],...m[2].split('|').map(s=>s.trim()).slice(0,8)]);
132
132
  for(const r of rows){human+=parseInt(r[7])||0;if((r[4]||'')==='1')firstPass++}
133
133
  if(rows.length){
134
- $('metrics').innerHTML='<table><tr><th>任务</th><th>Feature</th><th>开始</th><th>结束</th><th>审查轮</th><th>独立审查拦截</th><th>QA</th><th>人工介入</th></tr>'+
134
+ $('metrics').innerHTML='<table><tr><th>任务</th><th>Feature</th><th>开始</th><th>结束</th><th>审查轮</th><th>独立审查拦截</th><th>QA</th><th>人工介入</th><th>执行方式</th></tr>'+
135
135
  rows.map(r=>'<tr>'+r.map(c=>`<td>${c}</td>`).join('')+'</tr>').join('')+'</table>';
136
136
  }
137
137
  }