@aibyzero/cm-workflow 0.21.0 → 0.21.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 (42) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +12 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/js-workflow-control.md +1 -1
  7. package/package.json +1 -1
  8. package/runtime/js/cm-ai/codex-config.mjs +6 -1
  9. package/runtime/js/cm-ai/durable-runner-state.mjs +4 -0
  10. package/runtime/js/cm-ai/spec-amendment.mjs +20 -0
  11. package/runtime/js/cm-ai/task-commit-codec.mjs +4 -2
  12. package/runtime/js/cm-ai/task-runner.mjs +2 -1
  13. package/runtime/js/cm-ai/worker-codex-developer.mjs +3 -1
  14. package/runtime/js/cm-prd/change.mjs +4 -1
  15. package/runtime/js/cm-prd/review-findings.mjs +3 -2
  16. package/runtime/js/cm-prd/review-publication.mjs +3 -2
  17. package/runtime/js/cm-prd/split-design.mjs +4 -4
  18. package/scripts/cm-ai-admission.test.mjs +5 -5
  19. package/scripts/cm-ai-batch-run-fixture.mjs +5 -1
  20. package/scripts/cm-ai-drive.mjs +1 -1
  21. package/scripts/cm-ai-review-failure.test.mjs +3 -0
  22. package/scripts/cm-codex-developer-worker.test.mjs +13 -1
  23. package/scripts/cm-notify-command.test.mjs +3 -0
  24. package/scripts/cm-notify.test.mjs +9 -4
  25. package/scripts/cm-patrol.test.mjs +3 -0
  26. package/scripts/cm-prd-design-phase.test.mjs +31 -0
  27. package/scripts/cm-prd-review-gate.mjs +28 -3
  28. package/scripts/cm-prd-summary.test.mjs +5 -5
  29. package/scripts/cm-skill-hints.json +1 -1
  30. package/scripts/cm-skill-hints.mjs +66 -3
  31. package/scripts/cm-skill-hints.test.mjs +96 -0
  32. package/scripts/cm-spec-amend.test.mjs +107 -1
  33. package/scripts/cm-specs-status.test.mjs +5 -5
  34. package/scripts/cm-tool-preview-context.test.mjs +20 -1
  35. package/scripts/cm-upgrade-compat.test.mjs +7 -0
  36. package/skills/cm-prd/SKILL.md +14 -27
  37. package/skills/cm-prd/references/change-mode.md +2 -0
  38. package/skills/cm-prd/references/cm-optout.md +11 -0
  39. package/skills/cm-prd/references/context-scope.md +2 -1
  40. package/skills/cm-prd/references/js-host.md +2 -2
  41. package/skills/cm-prd/references/requirement-grilling.md +116 -0
  42. package/skills/cm-product-manager/SKILL.md +13 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.21.0",
3
+ "version": "0.21.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
@@ -5,6 +5,24 @@
5
5
 
6
6
  ## 未发布
7
7
 
8
+ ## 0.21.2 — 2026-11-18
9
+
10
+ - **任务提交意图写入与读取同用存档上限,存档上限说明更正**:写入改用 `JOURNAL_PAYLOAD_LIMIT`(4 MiB),与 0.21.1 修好的读取端一致;操作指南与 `cm-ai-drive --help` 写明可归档运行首条记录按 4 MiB、归档引用后的检查点按 4 MiB 减预留,不支持归档的运行仍按 1 MiB 内联上限。(#270)
11
+
12
+ - **cm-prd 遇到项目规则禁用 CM 时先停下问一次**(真实项目实跑:项目规则先后写过「只用 CM」和「不用 CM」):按规则自身声明的优先级判断是否仍生效,仍生效或判断不了就在生成 specs 前引用原文位置问用户,未确认则不写 specs。上下文范围规则的地图读取顺序改为以 Step 4 B1 为准(先看 CLAUDE.md「业务地图」字段),不再与 B1 冲突。
13
+
14
+ - **用 gpt-6.2-sol 审查时预检不再必然失败**(真实项目实跑:codex-cli 0.167.0 给 gpt-6.2-sol 的请求默认带 `request_user_input`、`view_image` 两个工具,「审查进程零工具」预检必然 `passed=false`):审查参数关闭 `view_image` 功能,并加 `-c tools.experimental_request_user_input.enabled=false`;零工具判定不变,编码进程参数不变。审查路径需要 codex-cli 0.153.4 或更新(更旧版本至少有一项不受支持,会在发出请求前启动失败)。参数变了,升级前生成的预检回执不再匹配,原运行需用同样配置重新预检;早期严格批次留有旧缓存时会报 `legacy_preflight_cache_invalid`,按原人工归档出口处理。
15
+
16
+ - **cm-prd 变更不再被旧审查回执误拦**:已批准或经补正换绑的规格,保存变更时改以批准时的版本为准核对,不再因和旧审查回执对不上而被拦;四个规格文件仍整套核对,未经批准的删除仍会被拦(批准轮次里移除可选的 `test-cases.json` 可以放行)。
17
+
18
+ - **cm-prd 会对照现有业务倒推需求缺口,逐轮追问后再出规格**(产品文档常范围不明或漏项,开发中途才暴露):需求分析后按七项清单(角色权限、状态流转、增删改查成对、存量数据、相邻线路、入口通知、报表导出)对照业务地图和代码找缺口;按设计树分轮提问,每轮最多 5 题,每题带出处,能推荐时给推荐答案,可合理默认的汇成默认清单一次确认;改变范围、权限、数据等的问题答完才生成规格。结论写入 `requirements.md` 新增的「范围与覆盖核对」一节;变更模式同样适用。
19
+
20
+ ## 0.21.1 — 2026-11-17
21
+
22
+ - **接近存档上限的任务提交可以正常读回**(CI 历史组夹具暴露:存档单条上限放到 4 MiB 后,`readCommitIntent` 仍按通用 JSON 校验的 1 MiB 默认值读取,计划接近或超过 1 MiB 的提交意图写得进却读不回):任务提交意图的读取改用 `JOURNAL_PAYLOAD_LIMIT`,与写入侧一致;运行器构造记录(`boundRunnerRecord`)先按同一上限校验载荷,再校验整条记录(上限加 1 KiB 外层余量)。
23
+
24
+ - **交接技能不再被否定句和引号里的词误触发**(实测:Jev 关闭时,“不要换个会话,继续当前任务”会让模型直接执行交接):关键词兜底时,否定词后约 4 个字(英文 3 个词)内的命中不算,“别忘了”除外;引号和行内代码里的词不算;只说换会话、没提交接时改为先问一句;英文 handoff/hand off 也算交接,new/fresh session、context is almost full 等英文说法也算换会话。拦下的情况记入日志,只记规则名和原因。Jev 路径、普通提示和 CM 内部流程不变。
25
+
8
26
  ## 0.21.0 — 2026-11-15
9
27
 
10
28
  - **审查放不下的交付在开发阶段就拦下**(实跑 aihot 副本:存档上限放到 4 MiB 后,约 1.8 MB 的改动能交付,但 Codex 审查输入最多 1 MiB,运行卡在审查结果不明、只能整任务重开):开发交付时按将要发送的审查内容核对审查方输入上限,放不下即 `develop_package_too_large`,缩小改动后原运行重做本轮。
package/README.md CHANGED
@@ -17,6 +17,17 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.21.2**
21
+
22
+ - **cm-prd 遇到项目规则禁用 CM 时先问一次**:项目规则写了「不用 CM」且仍有效时,生成规格前先问你,未确认不写规格。
23
+ - **用 gpt-6.2-sol 审查时预检不再必然失败**:审查进程关掉 Codex 0.167 默认带上的两个工具。
24
+ - **cm-prd 会对照现有业务倒推需求缺口,逐轮追问后再出规格**:分析需求后,对照业务地图和代码检查角色权限、状态流转、增删改查、老数据、相邻功能、入口通知、报表导出七项,找出文档漏掉的地方;分轮提问,每轮最多 5 题,每题带出处,能推荐时给推荐答案;会改变范围、权限、数据的问题答完才生成规格。详见[更新日志](CHANGELOG.md)。
25
+
26
+ **0.21.1**
27
+
28
+ - **接近存档上限的任务提交可以正常读回**:单条存档上限放到 4 MiB 后,任务提交记录读取时仍按 1 MiB 校验,超过 1 MiB 的提交写得进却读不回;现在读写同用一个上限。
29
+ - **技能交接不再被否定句和引号误触发**:「不要换个会话」这类说法和引号里的词不再触发交接。详见[更新日志](CHANGELOG.md)。
30
+
20
31
  **0.21.0**
21
32
 
22
33
  - **开发中途补规格分级生效**:只给 tasks.md 追加「范围与验收不变」这类纯声明的版本记录直接换绑;补任务范围、为已有验收标准补任务或新增用例,由独立审查者审过后生效并通知你;改需求、设计、已有用例或已完成任务,仍要你回复「开始」。改变已有任务验收的版本说明一律按改需求处理。
@@ -276,7 +287,7 @@ $cm-check
276
287
 
277
288
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
278
289
 
279
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.0 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
290
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.2 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
280
291
 
281
292
  ## 升级旧版本
282
293
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.21.2
@@ -76,7 +76,7 @@ Install or upgrade with the same command:
76
76
  npx @aibyzero/cm-workflow@latest install
77
77
  ```
78
78
 
79
- To pin a version, use `npx @aibyzero/cm-workflow@0.21.0 install` from outside
79
+ To pin a version, use `npx @aibyzero/cm-workflow@0.21.2 install` from outside
80
80
  the CM Workflow source checkout (for example, your home directory). Inside a
81
81
  checkout with the same package name and version, npm can select the local
82
82
  uninstalled package and report `cm-workflow: command not found`.
@@ -779,7 +779,7 @@ node scripts/cm-ai-host.mjs serve --config /absolute/run.json --mode create \
779
779
 
780
780
  批次驾驶员同样直接审查;缺第二轮答案时为该任务加 `--hold-revision FEATURE/TASK`。旗标只缩小本次启动能力,不持久化、不进入指纹;审查批准时不受影响。
781
781
 
782
- `develop.json.edits` 的值可以是内容文件名(写入,已有文件保留权限,新文件 0644)、`{file,mode}`、`{mode}`(只改权限位)或 `{delete:true}`;`mode` 只接受 `"0755"`、`"0644"`,改名为删旧写新;同时是 requirements 的 scope 路径不能删除,启动前拒绝,当前会话仍删除时停在可重试的 `blocked/develop_requirement_missing`(范围外改动仍先按 `unknown/out_of_scope` 处理)。运行存档单条记录上限为 1 MiB:开发检查点连同 base64 审查包须在 1 MiB 减去为后续审查与完成记录推出的预留之内。审查结果除 examinedPaths 外以 12 KiB JSON 为界(超出按固定规则截断 finding 文字与 summary、必要时从末尾省略 finding,先 P3 且至少保留一条阻断 finding,verdict 不变),完成检查点最多重复它 13 次,预留 = 13 ×(examinedPaths + 12 KiB)+ 2 ×(已有回执 + 调用 + Learning 回写)+ 96 KiB;驾驶员用宿主同一套审查包、handoff、Learning 证据与 AGENTS.md 回写代码在启动前核算(含 handoff)并拒绝超限交付,任务基线装不进一条记录时驾驶员与宿主都在建存档前拒绝;当前会话仍交付超限改动时停在可重试的 `blocked/develop_package_too_large`,不再以 `unknown/store_failure` 结束,旧 journal 格式与回放不变。开发阶段阻断在第 2 轮重做本轮交付时不再对照第 1 轮审查包(该交付本就改了代码),第 2 轮 `develop_checks_not_passed` 等因此可在原轮次重试;审查中漂移的 `review_package_changed` 仍须先恢复到已审代码。审查包的文件记录本就含 `mode`,删除为 `after:null`,审查提示会说明二者;包验证逐字段比较,事后改权限同样判为漂移,旧基线和旧包格式不变。驾驶员启动前按审查包上限拒绝单文件超过 1 MiB、材料(与审查包快照同一选取:scope、requirements 与树中全部 AGENTS.md)合计超过 2 MiB 或 256 个文件及与基线完全相同的交付,报错带路径与上限;当前会话若仍交付空改动,运行停在可重试的 `blocked/develop_empty_changes`,旧 `unknown/empty_changes` 历史按原样回放。新建运行要求 `runId` 满足运行日志规则(8–128 个字符),已有运行恢复不变。
782
+ `develop.json.edits` 的值可以是内容文件名(写入,已有文件保留权限,新文件 0644)、`{file,mode}`、`{mode}`(只改权限位)或 `{delete:true}`;`mode` 只接受 `"0755"`、`"0644"`,改名为删旧写新;同时是 requirements 的 scope 路径不能删除,启动前拒绝,当前会话仍删除时停在可重试的 `blocked/develop_requirement_missing`(范围外改动仍先按 `unknown/out_of_scope` 处理)。运行存档单条记录上限为 4 MiB(`JOURNAL_PAYLOAD_LIMIT`)。开发检查点的内联预算为单条记录上限(默认 4 MiB)与 1 MiB 取较小值后减去为有界审查与完成记录推出的预留,最低为 0 字节;不支持材料归档的运行(批量、并行、bootstrap 等)按含 base64 审查包的完整检查点核算此预算;支持归档的运行若同一审查包已有归档则直接引用,并要求完整检查点减去审查包大小再加 512 字节后不超过单条记录上限减去预留;若尚未归档且完整检查点装得进内联预算则内联;否则仅在完整检查点加 1 KiB 仍不超过单条记录上限、且引用后的估算大小也符合上述引用预算时首次归档。审查结果除 examinedPaths 外以 12 KiB JSON 为界(超出按固定规则截断 finding 文字与 summary、必要时从末尾省略 finding,先 P3 且至少保留一条阻断 finding,verdict 不变),完成检查点最多重复它 13 次,预留 = 13 ×(examinedPaths + 12 KiB)+ 2 ×(已有回执 + 调用 + Learning 回写)+ 96 KiB;驾驶员用宿主同一套审查包、handoff、Learning 证据与 AGENTS.md 回写代码在启动前核算(含 handoff)并拒绝超限交付,任务基线装不进一条记录时驾驶员与宿主都在建存档前拒绝;当前会话仍交付超限改动时停在可重试的 `blocked/develop_package_too_large`,不再以 `unknown/store_failure` 结束,旧 journal 格式与回放不变。开发阶段阻断在第 2 轮重做本轮交付时不再对照第 1 轮审查包(该交付本就改了代码),第 2 轮 `develop_checks_not_passed` 等因此可在原轮次重试;审查中漂移的 `review_package_changed` 仍须先恢复到已审代码。审查包的文件记录本就含 `mode`,删除为 `after:null`,审查提示会说明二者;包验证逐字段比较,事后改权限同样判为漂移,旧基线和旧包格式不变。驾驶员启动前按审查包上限拒绝单文件超过 1 MiB、材料(与审查包快照同一选取:scope、requirements 与树中全部 AGENTS.md)合计超过 2 MiB 或 256 个文件及与基线完全相同的交付,报错带路径与上限;当前会话若仍交付空改动,运行停在可重试的 `blocked/develop_empty_changes`,旧 `unknown/empty_changes` 历史按原样回放。新建运行要求 `runId` 满足运行日志规则(8–128 个字符),已有运行恢复不变。
783
783
 
784
784
  review.json 含 `{model, disabledSkills, preflight}`,另有可选 `timeoutMs`;disabledSkills 是本机探测实际发现并
785
785
  禁用的 Skill 路径,preflight 沿原配置指纹/模型/stdin 合同。探测输出不包含原始诊断、
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -24,14 +24,19 @@ export const disabledFeatures = Object.freeze([
24
24
  'shell_tool', 'unified_exec', 'shell_snapshot', 'multi_agent', 'goals',
25
25
  'memories', 'image_generation', 'code_mode_host', 'workspace_dependencies',
26
26
  'skill_mcp_dependency_install', 'tool_suggest',
27
+ // codex-cli 0.167.0 sends view_image to gpt-6.2-sol by default (2026-11-17 preflight failure).
28
+ 'view_image',
27
29
  ]);
30
+ // Review-only config: codex-cli 0.167.0 also sends request_user_input to gpt-6.2-sol, and no
31
+ // feature flag removes it; this key does (checked offline with tool-preview, 6.1 and 6.2 both 0 tools).
32
+ export const NO_USER_INPUT_TOOL='tools.experimental_request_user_input.enabled=false';
28
33
 
29
34
  export function commonArgs({ cwd, model, effort, disabledSkills = [] }) {
30
35
  if (!/^[a-zA-Z0-9._-]+$/.test(model)) throw new Error('invalid model');
31
36
  return ['exec', '--ignore-user-config', '--strict-config', '--ephemeral',
32
37
  '--sandbox', 'read-only', '--skip-git-repo-check', '--cd', cwd, '--json',
33
38
  ...disabledFeatures.flatMap(name => ['--disable', name]),
34
- '-c', 'approval_policy="never"', '-c', 'web_search="disabled"',
39
+ '-c', 'approval_policy="never"', '-c', 'web_search="disabled"', '-c', NO_USER_INPUT_TOOL,
35
40
  '-c', 'project_doc_max_bytes=0', '-c', 'mcp_servers={}',
36
41
  '-c', 'check_for_update_on_startup=false', '-c', 'analytics.enabled=false',
37
42
  '-c', `model="${model}"`, '-c', `model_reasoning_effort=${JSON.stringify(externalEffort('codex',effort))}`,
@@ -734,6 +734,10 @@ export const runnerPayloadV3=(type,fields,limit=JOURNAL_PAYLOAD_LIMIT)=>json({..
734
734
  export function boundRunnerRecord({id,kind,payload},seq) {
735
735
  // Exact S3a envelope width. Digest contents do not affect encoded byte count.
736
736
  // The envelope adds at most the 1 KiB the store allows above the payload.
737
+ // The payload itself is bounded like the store bounds it (S3a): the 1 KiB is
738
+ // envelope room only, so a payload above the record limit is refused on read
739
+ // as on write, not only when the envelope also overflows.
740
+ json(payload,JOURNAL_PAYLOAD_LIMIT);
737
741
  json({version:1,seq,id,kind,payload,previousDigest:seq>1?'0'.repeat(64):null,digest:'0'.repeat(64)},JOURNAL_PAYLOAD_LIMIT+1024);
738
742
  }
739
743
  export function attemptBaseline(original,attempt) {
@@ -27,6 +27,7 @@ export function roundLedgerPath(specsDir){
27
27
  export const AMEND_LIMIT=3;
28
28
  export const REVIEW_MARKER='cmSpecAmendReview';
29
29
  const FILES=['requirements.md','design.md','tasks.md','test-cases.json'];
30
+ export const APPROVED_SPEC_FILES=Object.freeze([...FILES]);
30
31
  const FEATURE=/^\d+\.[^/\\]+$/;
31
32
  const ACCEPTANCE=/^\s*[-*]\s+(?:\[[ xX]\]\s+)?(?:\[(AC-\d{3,})\]|(AC-\d{3,}))(?=[:\s])/;
32
33
  const AC_REF=/AC-\d{3,}/g;
@@ -293,6 +294,25 @@ function compareTestCases(before,after,reasons,name){
293
294
  const rawBytes=target=>{try{return fs.readFileSync(target);}catch{return null;}};
294
295
  const sameBytes=(a,b)=>a===null?b===null:b!==null&&a.equals(b);
295
296
 
297
+ // The bytes the latest human approval bound, as re-bound only by applied amendments:
298
+ // path -> runtime-mark-normalized sha256. Null unless status is approved and the
299
+ // snapshot, the out-of-tree round ledger and the status all name the same round, so a
300
+ // restored older snapshot or a hand-synced one never becomes a baseline.
301
+ export function approvedSpecBaseline(specsDir){
302
+ const statusPath=path.join(specsDir,'.cm-specs-status'),snapshotPath=path.join(specsDir,SNAPSHOT_FILE);
303
+ const statusBytes=rawBytes(statusPath),snapshotBytes=rawBytes(snapshotPath),roundBytes=readRound(specsDir);
304
+ const status=readSpecsStatus(specsDir),snapshot=readApprovalSnapshot(specsDir);
305
+ if(!sameBytes(statusBytes,rawBytes(statusPath))||!sameBytes(snapshotBytes,rawBytes(snapshotPath))
306
+ ||!sameBytes(roundBytes,readRound(specsDir)))return null;
307
+ if(status.kind!=='valid'||snapshot.kind!=='valid'||status.value.status!=='approved')return null;
308
+ const listed=status.value.specFiles;
309
+ if(!Array.isArray(listed)||!listed.every(row=>record(row)&&typeof row.path==='string'&&typeof row.sha256==='string'))return null;
310
+ const bound=snapshot.value,rows=snapshotRows(bound.files);
311
+ if(roundProblem(roundBytes,snapshotBytes,bound.approval.at)
312
+ ||rowsDigest(listed)!==rowsDigest(rows)||status.value.approval?.at!==bound.approval.at)return null;
313
+ return new Map(rows.map(row=>[row.path,row.sha256]));
314
+ }
315
+
296
316
  export function inspectSpecAmendment(specsDir){
297
317
  const reasons=[],statusPath=path.join(specsDir,'.cm-specs-status'),snapshotPath=path.join(specsDir,SNAPSHOT_FILE);
298
318
  const statusBytes=rawBytes(statusPath),snapshotBytes=rawBytes(snapshotPath),roundBytes=readRound(specsDir);
@@ -1,7 +1,7 @@
1
1
  // Internal pure C2b payload validation. No filesystem or approval authority.
2
2
  import path from 'node:path';
3
3
  import {createHash} from 'node:crypto';
4
- import {need,shape,hex,json,digest,validIdentity} from './effect-contract.mjs';
4
+ import {need,shape,hex,json,digest,validIdentity,JOURNAL_PAYLOAD_LIMIT} from './effect-contract.mjs';
5
5
  import {reviewSpecsPath} from './review-package.mjs';
6
6
  const FILE_LIMIT=256*1024,sha=b=>createHash('sha256').update(b).digest('hex');
7
7
  const same=(a,b)=>need(digest(a)===digest(b),'commit_history_invalid');
@@ -31,7 +31,9 @@ export function planBytes(raw){
31
31
  need(changes===1,'invalid_plan');return {before,after};
32
32
  }
33
33
  export function readCommitIntent(raw,{owner,identity,fingerprints}){
34
- const p=json(raw);
34
+ // 与写入侧同一上限:提交意图按存档单条上限写入(task-commit boundedRecord),
35
+ // 读取若仍写死 1 MiB,计划接近 1 MiB 时写得进的意图读不回,整次提交记录变成不可读
36
+ const p=json(raw,JOURNAL_PAYLOAD_LIMIT);
35
37
  shape(p,['version','protocol','type','identity','owner','fingerprints','plan','proof','parent','temporaryName']);
36
38
  need(p.version===1&&p.protocol==='cm-task-commit'&&p.type==='intent','commit_history_invalid');
37
39
  validIdentity(p.identity);same(p.identity,identity);same(p.owner,owner);same(p.fingerprints,fingerprints);
@@ -816,7 +816,8 @@ export function createTaskRunner(options) {
816
816
  need(liveToken===token&&state==='committing'&&busy&&completeEffect,'commit_capability_invalid');
817
817
  if(action==='guard'){storeOperation(currentStore);return ack();}
818
818
  need(action==='append-intent'?phase==='prepared':phase==='intent','commit_phase_invalid');
819
- const fields={effectId:completeEffect.effect.id,completeIntentDigest:completeEffect.digest,commit:json(payload)};
819
+ // Same bound as readCommitIntent: a commit record the reader accepts must also be writable.
820
+ const fields={effectId:completeEffect.effect.id,completeIntentDigest:completeEffect.digest,commit:json(payload,JOURNAL_PAYLOAD_LIMIT)};
820
821
  const type=action==='append-intent'?'task-commit-intent':'task-commit-result';
821
822
  // Invalid caller data is rejected before invoking the appender. The actual
822
823
  // append repeats preflight against its protected current cursor.
@@ -4,7 +4,7 @@ import {createProviderUsageCapture} from './provider-usage.mjs';
4
4
  import {signalOwnedGroup} from './process-group-exit.mjs';
5
5
  import {spawn} from 'node:child_process';
6
6
  import {fileURLToPath} from 'node:url';
7
- import {commonArgs,cleanEnvironment,specsPermissionArgs} from './codex-config.mjs';
7
+ import {commonArgs,cleanEnvironment,specsPermissionArgs,NO_USER_INPUT_TOOL} from './codex-config.mjs';
8
8
  import {need,text,validCallTimeout,json} from './effect-contract.mjs';
9
9
  import {CODEX_RECONNECT_NOTICE_LIMIT,isCodexReconnectNotice} from './codex-reconnect-notice.mjs';
10
10
  import {codexRateLimited,CODEX_FAILURE_GRACE_MS} from './worker-codex.mjs';
@@ -20,6 +20,8 @@ export function developerArgs({cwd,model,effort,schemaPath,disabledSkills=[],spe
20
20
  // Codex 0.153.4 uses code_mode_host for tool execution; keep its default
21
21
  // on the coding path without enabling the separate code_mode feature.
22
22
  if(args[i]==='--disable'&&(coding.has(args[i+1])||args[i+1]==='code_mode_host')){i++;continue;}
23
+ // The review-only removals for Codex 0.167 leave the coding tool surface as it was.
24
+ if(args[i]==='--disable'&&args[i+1]==='view_image'||args[i]==='-c'&&args[i+1]===NO_USER_INPUT_TOOL){i++;continue;}
23
25
  result.push(args[i]==='read-only'&&args[i-1]==='--sandbox'?'workspace-write':args[i]);
24
26
  }
25
27
  return [...result,...[...coding].flatMap(name=>['--enable',name]),
@@ -10,6 +10,7 @@ import {loadConfig,resolveRole} from '../../../scripts/cm-workflow-config.mjs';
10
10
  import {buildManifest} from '../../../scripts/cm-spec-manifest.mjs';
11
11
  import {specLines,taskDeclarations,TASK_GRAMMAR,LEGACY_TASK_GRAMMAR,recordedTaskGrammar} from '../spec-task-line.mjs';
12
12
  import {inspectPrdReview} from '../../../scripts/cm-prd-review-gate.mjs';
13
+ import {approvedSpecBaseline} from '../cm-ai/spec-amendment.mjs';
13
14
  import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
14
15
  import {prdTreeFileDigest} from './tree-digest.mjs';
15
16
  import {writeImmutableWorkflowFile} from '../cm-ai/review-evidence-file.mjs';
@@ -290,6 +291,8 @@ export function assertPrdReviewsSettled(specs,selected,{requireSplit=false}={}){
290
291
  const archive=read(specs,`.reviews/prd-change-${status.revisionDigest}.json`);
291
292
  if(archive!==null){const value=JSON.parse(archive);need(value.proposal.proposalDigest===status.revisionDigest,'prd_revision_archive_invalid');historical=value.before.reviews;}
292
293
  }
294
+ // Receipts predate later human approvals and applied amendments; those bound bytes count too.
295
+ const approvedBaseline=approvedSpecBaseline(specs);
293
296
  for(const directory of selected)for(const stage of ['design','split']){
294
297
  const feature=directory.replace(/^\d+\./,''),prefix=`prd-${feature}-${stage}`;
295
298
  for(const suffix of ['-dispatch.json','-r1.md','-r2.md','-disposition.json'])readCmInitSource(specs,`.reviews/${prefix}${suffix}`);
@@ -299,7 +302,7 @@ export function assertPrdReviewsSettled(specs,selected,{requireSplit=false}={}){
299
302
  need(sha(readCmInitSource(specs,file))===hash,'prd_change_review_changed');
300
303
  continue;
301
304
  }
302
- const gate=inspectPrdReview({stage,feature,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`)});
305
+ const gate=inspectPrdReview({stage,feature,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`),approvedBaseline});
303
306
  need(['dispatch_once','completed'].includes(gate.outcome),'prd_revision_prior_review_unresolved');
304
307
  if(requireSplit&&stage==='split')need(gate.outcome==='completed','prd_revision_original_split_required');
305
308
  }
@@ -5,7 +5,8 @@ import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
5
5
  import {publishPrdReview} from './review-publication.mjs';
6
6
  import {need,shape,json,digest} from '../cm-ai/effect-contract.mjs';
7
7
 
8
- export function inspectPrdFindings({specs,stage,feature,pendingSplit=null}){
8
+ // approvedBaseline: change-mode only, see assertPrdReviewsSettled.
9
+ export function inspectPrdFindings({specs,stage,feature,pendingSplit=null,approvedBaseline=null}){
9
10
  need(typeof specs==='string'&&fs.realpathSync(specs)===specs,'prd_review_root_invalid');
10
11
  need(['design','split'].includes(stage),'prd_review_stage_invalid');
11
12
  const match=typeof feature==='string'&&feature.match(/^([1-9]\d*)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/);
@@ -23,7 +24,7 @@ export function inspectPrdFindings({specs,stage,feature,pendingSplit=null}){
23
24
  const packageDigest=digest(archive.reviewPackage);
24
25
  // Reuse the publisher's complete validation and exact-byte projection, but
25
26
  // inspect only: never repair, recreate, overwrite or dispatch from this read.
26
- const verified=publishPrdReview({specs,...archive,packageDigest,inspectOnly:true,pendingSplit});
27
+ const verified=publishPrdReview({specs,...archive,packageDigest,inspectOnly:true,pendingSplit,approvedBaseline});
27
28
  const result=archive.response.result;
28
29
  return json({status:'review_findings_ready',stage,feature,packageDigest,
29
30
  draftDigest:archive.reviewPackage.draftDigest,evidence:relative,gate:verified.gate,
@@ -36,7 +36,8 @@ export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorCont
36
36
  return {response,result,examinedPaths,degraded};
37
37
  }
38
38
 
39
- export function publishPrdReview({specs,reviewPackage,packageDigest,authorContextId,response,inspectOnly=false,pendingSplit=null}){
39
+ export function publishPrdReview({specs,reviewPackage,packageDigest,authorContextId,response,inspectOnly=false,pendingSplit=null,approvedBaseline=null}){
40
+ need(approvedBaseline===null||inspectOnly,'prd_review_approved_baseline_inspect_only');
40
41
  inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response});
41
42
  if(!inspectOnly)assertPrdBatchActive(specs,[reviewPackage.feature]);
42
43
  reviewPackage=json(reviewPackage,256*1024);response=json(response,64*1024);id(authorContextId);
@@ -48,7 +49,7 @@ export function publishPrdReview({specs,reviewPackage,packageDigest,authorContex
48
49
  const reviews=path.join(specs,'.reviews');
49
50
  need(fs.realpathSync(reviews)===reviews&&fs.lstatSync(reviews).isDirectory(),'prd_review_path_invalid');
50
51
  const stage=reviewPackage.stage,feature=match[2],prefix=`prd-${feature}-${stage}`;
51
- const args={stage,feature,pendingSplit,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`)};
52
+ const args={stage,feature,pendingSplit,approvedBaseline,evidence:path.join(reviews,`${prefix}-r1.md`),receipt:path.join(reviews,`${prefix}-disposition.json`)};
52
53
  const gate=inspectPrdReview(args);
53
54
  need(gate.package_sha256===packageDigest&&['dispatch_unknown','resume_disposition','completed'].includes(gate.outcome),
54
55
  'prd_review_unclaimed');
@@ -8,13 +8,13 @@ import {inspectPrdDispositionPlan} from './disposition-plan.mjs';
8
8
  import {need,digest} from '../cm-ai/effect-contract.mjs';
9
9
  const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
10
10
 
11
- export function inspectPrdSplitDesign({specs,feature,originalSha,requirementsSha,draftDigest,pendingSplit=null,document='design.md'}){
11
+ export function inspectPrdSplitDesign({specs,feature,originalSha,requirementsSha,draftDigest,pendingSplit=null,document='design.md',approvedBaseline=null}){
12
12
  need(['requirements.md','design.md'].includes(document),'prd_split_document_invalid');
13
13
  const targetPath=`${feature}/${document}`;
14
14
  const changedError=document==='requirements.md'?'prd_design_requirements_changed':'prd_design_receipt_changed';
15
15
  const prefix=`.reviews/prd-${feature.replace(/^\d+\./,'')}-split`;
16
16
  if(readCmInitSource(specs,prefix+'-r1.md')===null)return null;
17
- const review=inspectPrdFindings({specs,stage:'split',feature});
17
+ const review=inspectPrdFindings({specs,stage:'split',feature,approvedBaseline});
18
18
  const designPath=`${feature}/design.md`,requirementsPath=`${feature}/requirements.md`;
19
19
  const baseline=prdSelfCheckRevisionBaseline(specs,feature,{originalSha,requirementsSha,draftDigest});
20
20
  need(draftDigest===undefined||draftDigest===baseline.draftDigest,'prd_split_design_binding_changed');
@@ -45,7 +45,7 @@ export function inspectPrdSplitDesign({specs,feature,originalSha,requirementsSha
45
45
 
46
46
  // Used by the shared receipt gate, including summary, publication and revision.
47
47
  // Legacy receipts without a host archive retain their original strict behavior.
48
- export function acceptsPrdSplitDesign({specs,evidence,receipt,item,currentSha,pendingSplit=null}){
48
+ export function acceptsPrdSplitDesign({specs,evidence,receipt,item,currentSha,pendingSplit=null,approvedBaseline=null}){
49
49
  if(receipt.stage!=='design'||!item.path.endsWith('/design.md'))return null;
50
50
  const bytes=readCmInitSource(specs,evidence);
51
51
  const line=bytes?.toString('utf8').match(/\n```json\n([^\n]+)\n```\n$/);
@@ -61,7 +61,7 @@ export function acceptsPrdSplitDesign({specs,evidence,receipt,item,currentSha,pe
61
61
  // accepted requirements/design bytes; pending plans require exact saved hashes.
62
62
  const baseline=prdSelfCheckRevisionBaseline(specs,pkg.feature,{designDraftDigest:pkg.draftDigest,originalSha:item.sha256,requirementsSha});
63
63
  const splitSha=inspectPrdSplitDesign({specs,feature:pkg.feature,originalSha:item.sha256,requirementsSha,
64
- pendingSplit:currentSha===baseline.originalSha?null:pendingSplit});
64
+ pendingSplit:currentSha===baseline.originalSha?null:pendingSplit,approvedBaseline});
65
65
  const completed=readCmInitSource(specs,`.reviews/prd-${receipt.feature}-split-disposition.json`)!==null;
66
66
  return (completed||splitSha!==null?splitSha:baseline.originalSha)===currentSha;
67
67
  }
@@ -9,11 +9,11 @@ import {parseFeatureTaskText,validDependencies,identifyApprovedBootstrapFeature,
9
9
  import {validateRunDefinition} from './cm-ai-run.mjs';
10
10
  import {buildManifest} from './cm-spec-manifest.mjs';
11
11
  // Spec approvals write a round ledger under CM_WORKFLOW_HOME; keep it off the real home.
12
- if(!process.env.CM_WORKFLOW_HOME){
13
- const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-approval-home-'));
14
- process.env.CM_WORKFLOW_HOME=isolatedHome;
15
- process.on('exit',()=>fs.rmSync(isolatedHome,{recursive:true,force:true}));
16
- }
12
+ // Always, not only when unset: an exported CM_WORKFLOW_HOME may be the tester's real home
13
+ // (review 2026-11-17: these suites left 11 approval records in an externally named home).
14
+ const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-approval-home-'));
15
+ process.env.CM_WORKFLOW_HOME=isolatedHome;
16
+ process.on('exit',()=>fs.rmSync(isolatedHome,{recursive:true,force:true}));
17
17
 
18
18
  const entry=fileURLToPath(new URL('./cm-ai-admission.mjs',import.meta.url));
19
19
  function fixture(run){
@@ -531,7 +531,11 @@ export async function batchFixture(mode,options={}){
531
531
  if(options.redoCode==='developer_rate_limited'){
532
532
  assert.equal(result.developFailure,'developer_rate_limited',JSON.stringify(result));
533
533
  const {driveNotice,buildNotifyMessage}=await import('../runtime/js/notify.mjs');
534
- const notice=driveNotice({host:'/x/scripts/cm-ai-batch-host.mjs',cwd:codeProject,args:['--host-context','s1'],operation:'advance',row:{requestId:'drive',result}});
534
+ // An empty CM home: the delivery under test must not follow the developer's own standing
535
+ // authorization (~/.cm-workflow/autonomy.json turns every stop into a 'later' notice).
536
+ const noticeHome=fs.mkdtempSync(path.join(root,'notify-home-'));
537
+ const notice=driveNotice({host:'/x/scripts/cm-ai-batch-host.mjs',cwd:codeProject,args:['--host-context','s1'],operation:'advance',row:{requestId:'drive',result},
538
+ env:{...process.env,CM_WORKFLOW_HOME:noticeHome}});
535
539
  assert.equal(notice.delivery,'now');
536
540
  assert.match(buildNotifyMessage(notice,{now:Date.now(),layout:'compact'}).body,/开发进程被限流(429):过一刻钟后回到会话「s1」,授权它重做这一轮开发/);
537
541
  }else assert.equal(Object.hasOwn(result,'developFailure'),false);
@@ -607,7 +607,7 @@ function load(){
607
607
  process.stdout.write('新版 PLAN.controlConfig 为相对 PLAN 的 v2 控制配置路径;development、bootstrap、qa、qaFix 使用明确模式,permissions 禁止所有 --allow-*。普通 advance 自动独立审查;缺少 develop-a2.json 时保持 revision_answer_required。显式恢复需要 resume 与此前 status 返回的 PLAN.expectedControl,驾驶员不会读取新目标覆盖它。\n');
608
608
  process.stdout.write('用法: cm-ai-drive.mjs --plan PLAN.json <operation>\nPLAN: config, mode, hostContext, originalHostContext (换会话 resume 必填), runtime, permissions, answers, checks, checkTimeoutMs。\nchecks 每项为 {id,command,timeoutMs?};checkTimeoutMs 与每项 timeoutMs 为 1..3600000 整数,默认 900000 ms(15 分钟)。\nabandon_review 需要 mode:resume、permissions:["--allow-abandon-review"] 与 PLAN.reason;abandon_effect 需要 mode:resume、permissions:["--allow-abandon-effect"] 与 PLAN.reason(均为单行、最多 500 UTF-8 字节)。develop_redo 需要 mode:resume、permissions:["--allow-develop-redo"] 与 PLAN.reason,先确认会话已停止修改代码。 bootstrap_review_recover 需要 mode:resume、permissions:["--allow-bootstrap-review-recovery"] 与 PLAN.reason;只核对原运行的已写规则与 handoff,不需要答案文件。\n人工答案放 answers/;check 只运行 PLAN.checks,不读取静态执行证据。bootstrap T-001 骨架可用;T-002 规范任务(纯规范 scope、单代码根、非 --protected-config)读 answers/init-generate.json({status:"generated",documents:[{path,contentFile}]},覆盖全部 targets)与 answers/init-verify.json(commands 为驾驶员实跑的草稿命令 {id,command,timeoutMs?},可选 commandsNotRun;checks 只含 globs/file_references/constraint_preservation/rule_applicability;constraintChanges:[];application/retrospective 沿原 Learning);第 1 轮也可用 *-a1.json,第 2 轮只读 init-generate-a2.json 与 init-verify-a2.json,审查自动派发;缺少第2轮草稿时先停在 changes_requested,读取首轮 findings 后再写草稿。commands 在宿主接受启动后、发送操作前由驾驶员实跑(须先带 --allow-bootstrap-write 等宿主授权;受保护模式在 specs 沙箱内),失败或改动了预检核对的文件即退出 2 且不发送操作(create 时改用 resume 重跑);结果只来自实跑,答案文件不能提供。\n'
609
609
  +'develop.json.edits 每项是 scope 路径到下列之一:"内容文件"(写入;已有文件保留权限,新文件 0644)、{"file":"内容文件","mode":"0755"|"0644"}、{"mode":"0755"|"0644"}(只改已有文件权限)、{"delete":true}(删除已有文件)。改名 = 删旧路径 + 写新路径,两者都要在 scope 内;同时列在 requirements 里的路径不能删除。\n'
610
- +'启动前拒绝:单个 scope 文件超过 1 MiB、审查材料(按审查包快照:scope、requirements 与树中全部 AGENTS.md 正文)合计超过 2 MiB 或超过 256 个文件、交付后与任务基线完全相同(edits 为空或内容和权限都没变)、开发检查点(含 handoff 与 AGENTS.md 回写,按宿主同一套构建代码计)装不进运行存档单条 1 MiB 记录减去为有界审查与完成记录推出的预留,或任务基线装不进一条记录。受保护模式(--protected-conversation-config)只收合法 UTF-8 文本,应答大于 --input-limit(默认 65536)时提示应加的值。\n'
610
+ +'启动前拒绝:单个 scope 文件超过 1 MiB、审查材料(按审查包快照:scope、requirements 与树中全部 AGENTS.md 正文)合计超过 2 MiB 或超过 256 个文件、交付后与任务基线完全相同(edits 为空或内容和权限都没变)、开发检查点(含 handoff 与 AGENTS.md 回写,按宿主同一套构建代码计)超出存档上限(开发检查点的内联预算为单条记录上限(默认 4 MiB)与 1 MiB 取较小值后减去为有界审查与完成记录推出的预留,最低为 0 字节;不支持材料归档的运行(批量、并行、bootstrap 等)按含 base64 审查包的完整检查点核算此预算;支持归档的运行若同一审查包已有归档则直接引用,并要求完整检查点减去审查包大小再加 512 字节后不超过单条记录上限减去预留;若尚未归档且完整检查点装得进内联预算则内联;否则仅在完整检查点加 1 KiB 仍不超过单条记录上限、且引用后的估算大小也符合上述引用预算时首次归档),或任务基线装不进一条记录。受保护模式(--protected-conversation-config)只收合法 UTF-8 文本,应答大于 --input-limit(默认 65536)时提示应加的值。\n'
611
611
  +'runId 需 8–128 个字符(运行日志要求),create 前检查。resume 时按存档里的当前轮次发送 identity,第 2 轮的 decision/complete/qa 等无需手改。\n');
612
612
  process.exit(0);
613
613
  }
@@ -24,6 +24,9 @@ import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
24
24
  import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
25
25
  import {rateLimitRetryEligible} from '../runtime/js/cm-ai/drive-rate-limit.mjs';
26
26
  import {guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
27
+ // An exported CM_NOTIFY_OFF silences every notice; these fixtures expect notices on
28
+ // (review 2026-11-17). Tests of the switch itself set it explicitly.
29
+ delete process.env.CM_NOTIFY_OFF;
27
30
 
28
31
  // Native V3 runner fixtures require Node 24.14+ on macOS/Linux. Preserve the
29
32
  // suite's existing explicit platform gate; only CLI fixtures spawn POSIX shims.
@@ -42,13 +42,25 @@ test('coding argv enables tools without weakening reviewer argv',()=>{
42
42
  for(const name of ['shell_tool','unified_exec','code_mode_host']){
43
43
  assert(reviewDisabled.includes(name));assert(!codingDisabled.includes(name));
44
44
  }
45
- assert.deepEqual(codingDisabled,reviewDisabled.filter(name=>!['shell_tool','unified_exec','code_mode_host'].includes(name)));
45
+ // view_image is a review-only removal (Codex 0.167 / gpt-6.2); coding keeps its old surface.
46
+ assert.deepEqual(codingDisabled,reviewDisabled.filter(name=>!['shell_tool','unified_exec','code_mode_host','view_image'].includes(name)));
46
47
  assert.deepEqual(values(coding,'--enable'),['shell_tool','unified_exec']);
47
48
  assert(!coding.includes('code_mode'));assert(!coding.includes('code_mode_host'));
48
49
  assert(coding.includes('sandbox_workspace_write.network_access=false'));
49
50
  assert.equal(coding.at(-1),'-');assert(!coding.includes('--dangerously-bypass-approvals-and-sandbox'));
50
51
  });
51
52
 
53
+ // 实跑事故(2026-11-17,codex-cli 0.167.0):gpt-6.2-sol 默认多带 request_user_input、view_image
54
+ // 两个工具,审查预检的「零工具」判定必然失败。审查参数关掉这两个;编码参数保持原样。
55
+ test('review argv removes the default tools Codex 0.167 adds for gpt-6.2; coding argv keeps them',()=>{
56
+ const options={cwd:'/fixture',model:'gpt-6.2-sol',schemaPath:'/schema.json'};
57
+ const review=commonArgs(options),coding=developerArgs(options);
58
+ const values=(args,flag)=>args.flatMap((arg,i)=>arg===flag?[args[i+1]]:[]);
59
+ assert(values(review,'--disable').includes('view_image'));
60
+ assert.equal(values(review,'-c').filter(arg=>arg==='tools.experimental_request_user_input.enabled=false').length,1);
61
+ assert(!values(coding,'--disable').includes('view_image'));
62
+ assert(!coding.includes('tools.experimental_request_user_input.enabled=false'));
63
+ });
52
64
  test('coding and review argv both suppress the user skills catalog (2026-09-16: 18249 -> 11706 input tokens)',()=>{
53
65
  const options={cwd:'/fixture',model:'fixture',schemaPath:'/schema.json'};
54
66
  for(const args of [developerArgs(options),commonArgs(options)]){
@@ -11,6 +11,9 @@ import {spawnSync} from 'node:child_process';
11
11
  import {fileURLToPath} from 'node:url';
12
12
  import {parseAssignments,readPrivateFile,readSecret,runSender,responseCodeType,readRegularFile,entryDecision,WINDOWS_UNSUPPORTED,SEND_EXIT} from '../runtime/js/notify-send.mjs';
13
13
  import {main,notifyStatus,switchChannel,turnOff,sendTest,formatTest,previewText,formatPreview,managedSenderPath,classifyCommand,SENDER_SOURCE,TEMPLATES} from './cm-notify.mjs';
14
+ // An exported CM_NOTIFY_OFF silences every notice; these fixtures expect notices on
15
+ // (review 2026-11-17). Tests of the switch itself set it explicitly.
16
+ delete process.env.CM_NOTIFY_OFF;
14
17
 
15
18
  // Every test works in its own temp CM_WORKFLOW_HOME / log home / HOME: the
16
19
  // real ~/.cm-workflow/notify.json would push to the user's phone.
@@ -9,10 +9,15 @@ import {notify,notifyLater,cancelPendingNotice,clearAttention,sessionTitle,sched
9
9
 
10
10
  // driveNotice and spawned drivers read the standing authorization from the default
11
11
  // home: point it at an empty directory, never the tester's own ~/.cm-workflow.
12
- if(!process.env.CM_WORKFLOW_HOME){
13
- process.env.CM_WORKFLOW_HOME=fs.mkdtempSync(path.join(os.tmpdir(),'cm-notify-default-home-'));
14
- process.on('exit',()=>fs.rmSync(process.env.CM_WORKFLOW_HOME,{recursive:true,force:true}));
15
- }
12
+ // Always, not only when unset: a tester's exported CM_WORKFLOW_HOME may be their real
13
+ // home with autonomy.json on, which defers every stop and fails the 'now' expectations
14
+ // (dogfood 2026-11-17: four tests failed with a real home under standing authorization).
15
+ const DEFAULT_HOME=fs.mkdtempSync(path.join(os.tmpdir(),'cm-notify-default-home-'));
16
+ process.env.CM_WORKFLOW_HOME=DEFAULT_HOME;
17
+ process.on('exit',()=>fs.rmSync(DEFAULT_HOME,{recursive:true,force:true}));
18
+ // The same for the per-process off switch: an exported CM_NOTIFY_OFF would silence every
19
+ // fixture that expects a notice (review 2026-11-17). Tests that need it set it explicitly.
20
+ delete process.env.CM_NOTIFY_OFF;
16
21
  const NOW=Date.parse('2026-10-08T08:00:00.000Z');
17
22
  const DRIVE_CORE=new URL('../runtime/js/cm-ai/drive-core.mjs',import.meta.url).href;
18
23
  const BRIDGE=new URL('../runtime/js/cm-ai/host-tool-bridge.mjs',import.meta.url).href;
@@ -7,6 +7,9 @@ import {spawn,spawnSync} from 'node:child_process';
7
7
  import {fileURLToPath} from 'node:url';
8
8
  import {patrol,inspectHosts,processAlive} from './cm-patrol.mjs';
9
9
  import {hostRegistryDir,buildNotifyMessage,removeHostRegistry} from '../runtime/js/notify.mjs';
10
+ // An exported CM_NOTIFY_OFF silences every notice; these fixtures expect notices on
11
+ // (review 2026-11-17). Tests of the switch itself set it explicitly.
12
+ delete process.env.CM_NOTIFY_OFF;
10
13
 
11
14
  const HOST_SESSION=new URL('../runtime/js/cm-ai/host-session.mjs',import.meta.url).href;
12
15
  const PATROL=fileURLToPath(new URL('./cm-patrol.mjs',import.meta.url));
@@ -20,6 +20,9 @@ import {preparePrdReview} from '../runtime/js/cm-prd/review-preparation.mjs';
20
20
  import {inspectAcceptedPrdDesign,acceptedPrdDesignForPlanning} from '../runtime/js/cm-prd/accepted-design.mjs';
21
21
  import {createPrdSummaryOwner,inspectPrdSummaryEvidence,publishPrdAwaitingReview} from '../runtime/js/cm-prd/summary.mjs';
22
22
  import {assertPrdReviewsSettled} from '../runtime/js/cm-prd/change.mjs';
23
+ import {writeApprovalSnapshot} from '../runtime/js/cm-ai/spec-amendment.mjs';
24
+ import {writeSpecsStatus} from '../runtime/js/specs-status.mjs';
25
+ import {buildManifest} from './cm-spec-manifest.mjs';
23
26
  import {recordPrdHostDisposition,createPrdDispositionOwner} from '../runtime/js/cm-prd/review-disposition.mjs';
24
27
  const FIXTURE_TIMEOUT_MS=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000);
25
28
  const riskSignals=high=>({greenfieldAdr:false,architectureOrDataFlow:high,newRuntimeDependencyOrToolchain:false,
@@ -544,6 +547,34 @@ for(const mode of ['failed','drift'])test(`disposed-design split self-check cann
544
547
  else assert.equal((await owner(f.args,new AbortController().signal)).gate.disposition,'self_check_failed');
545
548
  assert.equal(checks,1);assert.equal(fs.existsSync(path.join(f.specs,'.reviews/prd-guide-split-disposition.json')),mode==='failed');
546
549
  });
550
+ // Models a human 「开始」 binding the current specs; the round ledger stays in a temporary home.
551
+ function isolateApprovalHome(t){
552
+ const home=fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-approved-home-')),previous=process.env.CM_WORKFLOW_HOME;
553
+ process.env.CM_WORKFLOW_HOME=home;
554
+ t.after(()=>{if(previous===undefined)delete process.env.CM_WORKFLOW_HOME;else process.env.CM_WORKFLOW_HOME=previous;fs.rmSync(home,{recursive:true,force:true});});
555
+ }
556
+ function approveCurrentSpecs(specs){
557
+ const specFiles=buildManifest(specs),features=[...new Set(specFiles.map(row=>row.path.split('/')[0]))];
558
+ const approval={response:'开始',at:'2026-11-17T00:00:00.000Z'};
559
+ writeSpecsStatus(specs,{status:'approved',at:approval.at,features,specFiles,testCases:specFiles.filter(row=>row.path.endsWith('/test-cases.json')),approval,taskGrammar:3});
560
+ writeApprovalSnapshot(specs,{features,specFiles,approval});
561
+ }
562
+ // Codex 审查 #1:批准基线只替代指纹比对,设计与拆分审查的关联校验照常执行。
563
+ test('change save accepts an approved design after a completed split but keeps the split binding check',async t=>{
564
+ isolateApprovalHome(t);const f=await splitDesignFixture(t);f.edit();
565
+ await createPrdDispositionOwner({checkContext:async payload=>checked(payload)})(f.args,new AbortController().signal);
566
+ fs.writeFileSync(path.join(f.specs,f.feature,'design.md'),f.content+'\nLater approved design');
567
+ assert.throws(()=>assertPrdReviewsSettled(f.specs,[f.feature]));
568
+ approveCurrentSpecs(f.specs);
569
+ assert.doesNotThrow(()=>assertPrdReviewsSettled(f.specs,[f.feature]));
570
+ const g=await splitDesignFixture(t),other=await splitDesignFixture(t,{featureName:'other'});
571
+ other.edit();await createPrdDispositionOwner({checkContext:async payload=>checked(payload)})(other.args,new AbortController().signal);
572
+ g.edit();
573
+ for(const suffix of ['-r1.md','-dispatch.json','-disposition.json'])fs.copyFileSync(
574
+ path.join(other.specs,`.reviews/prd-other-split${suffix}`),path.join(g.specs,`.reviews/prd-guide-split${suffix}`));
575
+ approveCurrentSpecs(g.specs);
576
+ assert.throws(()=>assertPrdReviewsSettled(g.specs,[g.feature]),/prd_review_archive_identity_mismatch/);
577
+ });
547
578
  test('unchanged split disposition preserves legacy accepted binding and both receipt bytes',async t=>{
548
579
  const f=await splitDesignFixture(t),args=structuredClone(f.args);
549
580
  args.decisions[0].status='escalated';args.decisions[0].changedPaths=[];
@@ -8,7 +8,8 @@ import {TextDecoder} from 'node:util';
8
8
  import {fileURLToPath} from 'node:url';
9
9
  import {acceptsPrdSplitDesign} from '../runtime/js/cm-prd/split-design.mjs';
10
10
  import {inspectPrdFailedCorrection} from '../runtime/js/cm-prd/failed-correction.mjs';
11
- import {normalizeRuntimeMarks} from './cm-spec-manifest.mjs';
11
+ import {normalizeRuntimeMarks,normalizeRuntimeMarkBytes} from './cm-spec-manifest.mjs';
12
+ import {APPROVED_SPEC_FILES} from '../runtime/js/cm-ai/spec-amendment.mjs';
12
13
  import {tagDiagnosticReason} from '../runtime/js/cm-ai/diagnostic-reason.mjs';
13
14
 
14
15
  // Messages stay byte-identical for the CLI and its Python oracle. Hosts get a stable
@@ -135,6 +136,11 @@ function loadReceipt(file,args,evidence){
135
136
  if(value.disposition==='self_check_failed')need(value.stage==='split','prd_failed_check_split_only','prd_failed_check_split_only',where);
136
137
  need(Array.isArray(value.artifacts)&&value.artifacts.length>0,'PRD review receipt must contain artifact hashes','prd_review_receipt_invalid',where);
137
138
  const root=resolve(path.dirname(path.dirname(file))),seen=new Set();
139
+ // Change mode only (assertPrdReviewsSettled): the bytes the latest human approval bound,
140
+ // as re-bound by applied amendments, path -> runtime-mark-normalized sha256. It stands in
141
+ // for this receipt's fingerprints only; every other receipt and split-binding check runs.
142
+ const approved=args.approvedBaseline instanceof Map?args.approvedBaseline:null;
143
+ const normalizedSha=(bytes,name)=>createHash('sha256').update(normalizeRuntimeMarkBytes(bytes,name)).digest('hex');
138
144
  for(const item of value.artifacts){
139
145
  need(keys(item,['path','sha256'])&&typeof item.path==='string'&&typeof item.sha256==='string'
140
146
  &&/^[0-9a-f]{64}$/.test(item.sha256),'PRD review receipt contains an invalid artifact','prd_review_receipt_invalid',where);
@@ -144,6 +150,11 @@ function loadReceipt(file,args,evidence){
144
150
  const named=()=>({receipt,artifact:item.path});
145
151
  const raw=path.join(root,item.path);need(!link(raw),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',named);
146
152
  const artifact=resolve(raw);need(within(root,artifact),'PRD review artifact escapes the specs directory','prd_review_artifact_unsafe',named);
153
+ // Only the optional test-cases.json may be gone, and only when the approved round of a
154
+ // feature it binds no longer lists it; the whole-set check below enforces that round.
155
+ const parts=item.path.split('/');
156
+ if(!stat(artifact)&&approved!==null&&parts.length===2&&parts[1]==='test-cases.json'&&!approved.has(item.path)
157
+ &&approved.has(`${parts[0]}/design.md`)){value.approvedBaselineAccepted=true;continue;}
147
158
  need(stat(artifact)?.isFile(),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',named);
148
159
  const bytes=bytesOf(artifact,'prd_review_artifact_unsafe',named());
149
160
  const currentSha=createHash('sha256').update(bytes).digest('hex');
@@ -151,8 +162,9 @@ function loadReceipt(file,args,evidence){
151
162
  &&stat(path.join(path.dirname(file),`prd-${value.feature}-split-disposition.json`));
152
163
  if(currentSha!==item.sha256||completedSplit){
153
164
  const accepted=acceptsPrdSplitDesign({specs:root,evidence:path.relative(root,evidence).split(path.sep).join('/'),
154
- receipt:value,item,currentSha,pendingSplit:args.pendingSplit??null});
165
+ receipt:value,item,currentSha,pendingSplit:args.pendingSplit??null,approvedBaseline:approved});
155
166
  if(accepted===true)continue;
167
+ if(approved?.has(item.path)&&normalizedSha(bytes,path.basename(artifact))===approved.get(item.path)){value.approvedBaselineAccepted=true;continue;}
156
168
  if(completedSplit&&accepted!==null)need(false,'prd_design_receipt_changed','prd_design_receipt_changed',named);
157
169
  if(currentSha===item.sha256)continue;
158
170
  const text=bytes.toString('utf8');
@@ -163,6 +175,19 @@ function loadReceipt(file,args,evidence){
163
175
  value.runtimeMarksNormalized=true;
164
176
  }
165
177
  }
178
+ // Once any file leans on the approved round, every file of the receipt's features must be
179
+ // exactly that round: old receipt bytes cannot be mixed with newly approved ones.
180
+ if(value.approvedBaselineAccepted){
181
+ // Every spec file the approval binds, present or not; other receipt artifacts were
182
+ // already held to the receipt's own fingerprints above.
183
+ const features=[...new Set(value.artifacts.map(item=>item.path.split('/')).filter(parts=>parts.length>1&&/^\d+\./.test(parts[0])).map(parts=>parts[0]))].sort();
184
+ for(const row of features.flatMap(feature=>APPROVED_SPEC_FILES.map(name=>`${feature}/${name}`))){
185
+ const target=path.join(root,row),present=stat(target);
186
+ need(!link(target)&&(present===null||present.isFile()),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',()=>({receipt,artifact:row}));
187
+ const current=present===null?undefined:normalizedSha(bytesOf(target,'prd_review_artifact_unsafe',{receipt,artifact:row}),path.basename(row));
188
+ need(current===approved.get(row),'PRD review artifact changed after disposition','prd_review_artifact_changed',()=>({receipt,artifact:row}));
189
+ }
190
+ }
166
191
  if(value.disposition==='self_check_failed')inspectPrdFailedCorrection({specs:root,receipt:value});
167
192
  return value;
168
193
  }
@@ -272,7 +297,7 @@ export function inspectPrdReview(args){
272
297
  {...base,outcome:'dispatch_once'};
273
298
  evidenceHeader(evidence);if(!stat(receipt))return {...base,outcome:'resume_disposition'};
274
299
  const value=loadReceipt(receipt,args,evidence);return {...base,outcome:'completed',disposition:value.disposition,
275
- ...(value.runtimeMarksNormalized?{runtimeMarksNormalized:true}:{})};
300
+ ...(value.runtimeMarksNormalized?{runtimeMarksNormalized:true}:{}),...(value.approvedBaselineAccepted?{approvedBaseline:true}:{})};
276
301
  }
277
302
  export function recordPrdReview(args){
278
303
  counts(args.disposition,args.finding_count,args.unresolved_count,typeof args.receipt==='string'?reviewFile(args.receipt):null);