@aibyzero/cm-workflow 0.21.1 → 0.21.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.
Files changed (72) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +13 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/js-workflow-control.md +6 -1
  7. package/package.json +1 -1
  8. package/runtime/js/cm-ai/call-timeout.mjs +21 -0
  9. package/runtime/js/cm-ai/checkpoint-package-material.mjs +3 -2
  10. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +5 -1
  11. package/runtime/js/cm-ai/codex-config.mjs +6 -1
  12. package/runtime/js/cm-ai/durable-runner-state.mjs +19 -4
  13. package/runtime/js/cm-ai/fix-code-association.mjs +5 -5
  14. package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -15
  15. package/runtime/js/cm-ai/host-documentation.mjs +4 -3
  16. package/runtime/js/cm-ai/host-handoff.mjs +3 -2
  17. package/runtime/js/cm-ai/host-project-execution.mjs +11 -9
  18. package/runtime/js/cm-ai/host-qa-executor.mjs +3 -2
  19. package/runtime/js/cm-ai/host-replay.mjs +28 -8
  20. package/runtime/js/cm-ai/review-package.mjs +101 -33
  21. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
  22. package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
  23. package/runtime/js/cm-ai/spec-amendment.mjs +20 -0
  24. package/runtime/js/cm-ai/symlink-material.mjs +153 -0
  25. package/runtime/js/cm-ai/task-commit.mjs +6 -3
  26. package/runtime/js/cm-ai/task-runner.mjs +14 -6
  27. package/runtime/js/cm-ai/worker-claude-developer.mjs +19 -7
  28. package/runtime/js/cm-ai/worker-codex-developer.mjs +3 -1
  29. package/runtime/js/cm-fix/protected-edits.mjs +57 -36
  30. package/runtime/js/cm-prd/change.mjs +4 -1
  31. package/runtime/js/cm-prd/review-findings.mjs +3 -2
  32. package/runtime/js/cm-prd/review-publication.mjs +3 -2
  33. package/runtime/js/cm-prd/split-design.mjs +4 -4
  34. package/scripts/ci-test-weights.json +1 -0
  35. package/scripts/cm-ai-admission.test.mjs +5 -5
  36. package/scripts/cm-ai-batch-drive.mjs +9 -5
  37. package/scripts/cm-ai-call-timeout.test.mjs +85 -0
  38. package/scripts/cm-ai-control-launch.test.mjs +18 -0
  39. package/scripts/cm-ai-drive.mjs +142 -43
  40. package/scripts/cm-ai-host.mjs +15 -3
  41. package/scripts/cm-ai-host.test.mjs +3 -1
  42. package/scripts/cm-ai-launch-diagnostics.test.mjs +23 -0
  43. package/scripts/cm-ai-review-failure.test.mjs +3 -0
  44. package/scripts/cm-ai-run.mjs +2 -1
  45. package/scripts/cm-ai-scope-revision.test.mjs +35 -3
  46. package/scripts/cm-ai-supersede.test.mjs +51 -3
  47. package/scripts/cm-ai-symlink.test.mjs +481 -0
  48. package/scripts/cm-codex-developer-worker.test.mjs +13 -1
  49. package/scripts/cm-notify-command.test.mjs +3 -0
  50. package/scripts/cm-notify.test.mjs +3 -0
  51. package/scripts/cm-patrol.test.mjs +3 -0
  52. package/scripts/cm-prd-design-phase.test.mjs +31 -0
  53. package/scripts/cm-prd-review-gate.mjs +28 -3
  54. package/scripts/cm-prd-summary.test.mjs +5 -5
  55. package/scripts/cm-skill-hints.mjs +40 -16
  56. package/scripts/cm-skill-hints.test.mjs +91 -0
  57. package/scripts/cm-spec-amend.test.mjs +107 -1
  58. package/scripts/cm-specs-status.test.mjs +5 -5
  59. package/scripts/cm-start-check.mjs +53 -15
  60. package/scripts/cm-start-check.test.mjs +41 -2
  61. package/scripts/cm-task-gate.mjs +42 -13
  62. package/scripts/cm-task-gate.test.mjs +33 -0
  63. package/scripts/cm-tool-preview-context.test.mjs +20 -1
  64. package/scripts/cm-upgrade-compat.test.mjs +7 -0
  65. package/skills/cm-ai/references/js-host.md +1 -0
  66. package/skills/cm-prd/SKILL.md +14 -27
  67. package/skills/cm-prd/references/change-mode.md +2 -0
  68. package/skills/cm-prd/references/cm-optout.md +11 -0
  69. package/skills/cm-prd/references/context-scope.md +2 -1
  70. package/skills/cm-prd/references/js-host.md +2 -2
  71. package/skills/cm-prd/references/requirement-grilling.md +116 -0
  72. package/skills/cm-product-manager/SKILL.md +13 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.21.1",
3
+ "version": "0.21.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
@@ -5,6 +5,25 @@
5
5
 
6
6
  ## 未发布
7
7
 
8
+ ## 0.21.3 — 2026-11-24
9
+
10
+ - **当前会话运行可用 `--call-timeout-minutes`(30–60)放宽单次宿主调用期限**(设备检查常超过检查整步固定的 30 分钟):只用于当前会话运行,不进运行指纹;已因超时停下的运行可在 resume 时补上,恢复时不得低于创建时的值,每次启动在 stderr 报出实际期限;`--protected-config` 运行不接受。起跑体检按该值算检查预算。(#276)
11
+ - **cm-ai 新运行支持软链**:快照和审查记录链接指向。开发可新建、改指或删除符合项目边界的软链,已有运行沿用原基线与审查规则。
12
+ - **技能提醒的引号与日志补漏**:中文单引号‘’里的词也不再触发技能自动调用;引号不再跨行,没配对的“不会吞掉后面整段话;英文否定紧贴中文(如 don't换个会话)也算否定;同一句里被拦下的多条规则都记入日志,不再只记第一条。已知限制:引号里夹着没配对的引号字符时,引号范围可能判断错。
13
+ - **技能提醒多认几种否定说法**:“不需要”“没必要”和英文 won't 后面的词,也不再触发交接等技能自动调用;“需不需要”“有没有必要”这类正反问和 why won't 仍按提问处理。“如果/要是/若不需要测试就换个会话交接”这类条件句照常触发;“不要现在就换个会话交接”里表示“马上”的“就”仍算否定范围。
14
+
15
+ ## 0.21.2 — 2026-11-18
16
+
17
+ - **任务提交意图写入与读取同用存档上限,存档上限说明更正**:写入改用 `JOURNAL_PAYLOAD_LIMIT`(4 MiB),与 0.21.1 修好的读取端一致;操作指南与 `cm-ai-drive --help` 写明可归档运行首条记录按 4 MiB、归档引用后的检查点按 4 MiB 减预留,不支持归档的运行仍按 1 MiB 内联上限。(#270)
18
+
19
+ - **cm-prd 遇到项目规则禁用 CM 时先停下问一次**(真实项目实跑:项目规则先后写过「只用 CM」和「不用 CM」):按规则自身声明的优先级判断是否仍生效,仍生效或判断不了就在生成 specs 前引用原文位置问用户,未确认则不写 specs。上下文范围规则的地图读取顺序改为以 Step 4 B1 为准(先看 CLAUDE.md「业务地图」字段),不再与 B1 冲突。
20
+
21
+ - **用 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`,按原人工归档出口处理。
22
+
23
+ - **cm-prd 变更不再被旧审查回执误拦**:已批准或经补正换绑的规格,保存变更时改以批准时的版本为准核对,不再因和旧审查回执对不上而被拦;四个规格文件仍整套核对,未经批准的删除仍会被拦(批准轮次里移除可选的 `test-cases.json` 可以放行)。
24
+
25
+ - **cm-prd 会对照现有业务倒推需求缺口,逐轮追问后再出规格**(产品文档常范围不明或漏项,开发中途才暴露):需求分析后按七项清单(角色权限、状态流转、增删改查成对、存量数据、相邻线路、入口通知、报表导出)对照业务地图和代码找缺口;按设计树分轮提问,每轮最多 5 题,每题带出处,能推荐时给推荐答案,可合理默认的汇成默认清单一次确认;改变范围、权限、数据等的问题答完才生成规格。结论写入 `requirements.md` 新增的「范围与覆盖核对」一节;变更模式同样适用。
26
+
8
27
  ## 0.21.1 — 2026-11-17
9
28
 
10
29
  - **接近存档上限的任务提交可以正常读回**(CI 历史组夹具暴露:存档单条上限放到 4 MiB 后,`readCommitIntent` 仍按通用 JSON 校验的 1 MiB 默认值读取,计划接近或超过 1 MiB 的提交意图写得进却读不回):任务提交意图的读取改用 `JOURNAL_PAYLOAD_LIMIT`,与写入侧一致;运行器构造记录(`boundRunnerRecord`)先按同一上限校验载荷,再校验整条记录(上限加 1 KiB 外层余量)。
package/README.md CHANGED
@@ -17,6 +17,18 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.21.3**
21
+
22
+ - **cm-ai 新任务支持软链**:项目里有软链不再一建基线就报错;开发可以新建、改指向或删除软链,CM 会核对它不指出项目、不指进 `.git` 和规格目录。已有任务不受影响。
23
+ - **当前会话运行可放宽单次调用期限**:设备检查等耗时长的步骤,可用 `--call-timeout-minutes`(30–60)放宽,已因超时停下的运行恢复时可补上。
24
+ - **技能提醒更少误触发**:多认「不需要」「没必要」、won't 等否定说法和中文单引号,条件句照常触发。详见[更新日志](CHANGELOG.md)。
25
+
26
+ **0.21.2**
27
+
28
+ - **cm-prd 遇到项目规则禁用 CM 时先问一次**:项目规则写了「不用 CM」且仍有效时,生成规格前先问你,未确认不写规格。
29
+ - **用 gpt-6.2-sol 审查时预检不再必然失败**:审查进程关掉 Codex 0.167 默认带上的两个工具。
30
+ - **cm-prd 会对照现有业务倒推需求缺口,逐轮追问后再出规格**:分析需求后,对照业务地图和代码检查角色权限、状态流转、增删改查、老数据、相邻功能、入口通知、报表导出七项,找出文档漏掉的地方;分轮提问,每轮最多 5 题,每题带出处,能推荐时给推荐答案;会改变范围、权限、数据的问题答完才生成规格。详见[更新日志](CHANGELOG.md)。
31
+
20
32
  **0.21.1**
21
33
 
22
34
  - **接近存档上限的任务提交可以正常读回**:单条存档上限放到 4 MiB 后,任务提交记录读取时仍按 1 MiB 校验,超过 1 MiB 的提交写得进却读不回;现在读写同用一个上限。
@@ -281,7 +293,7 @@ $cm-check
281
293
 
282
294
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
283
295
 
284
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.1 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
296
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.3 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
285
297
 
286
298
  ## 升级旧版本
287
299
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.1
1
+ 0.21.3
@@ -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.1 install` from outside
79
+ To pin a version, use `npx @aibyzero/cm-workflow@0.21.3 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}`(删除文件或软链),以及新运行的 `{symlink:"相对目标"}`(新建或改指)。`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 合同。探测输出不包含原始诊断、
@@ -881,6 +881,11 @@ JSON 配置本身不能证明执行过;未配置的安全检查不会被执行
881
881
  沿用fixed fix编辑器的scope/expected摘要、完整UTF-8/null删除;可选 `mode`("0755"/"0644")只用于写入的文件,新文件为 0644。
882
882
  通道上限默认 64KiB,可用 `--input-limit` 调到 4 MiB,输入行与工具应答共用该上限;宿主不得先写或运行命令。
883
883
  驾驶员只提交严格 UTF-8 内容,二进制文件启动前拒绝。cm-fix 的受保护提案仍不接受 `mode`。
884
+ 新运行的 develop 请求带有 `allowSymlinks:true` 时,可提交 `{path,beforeSha256,symlink}`。
885
+ 链接目标使用相对于链接所在目录的路径,最多 1024 字节,且须在所属代码根内指向已存在的普通文件或目录。
886
+ 目标路径不得穿过其他软链,也不得进入实际规格目录、`.git` 或 `.reviews`。
887
+ 受保护应答用 `content:null` 和链接原指纹删除软链,预检和落盘都拒绝经软链父目录写入。
888
+ 审查材料保存链接指向的原文,已有链接即使悬空或指向项目外也能进入新运行的基线。
884
889
  失败仍返回原 `{status,code}`,blocked值必须空edits。实际编辑及配置中的检查由native Codex sandbox执行,
885
890
  不使用宿主check回报。Claude作者/Review身份保持Claude,所需本机Codex sandbox不是Codex模型调用。
886
891
  文档同步并入最后任务的同次编辑提案,QA命令受保护,语义/浏览器/文档核验仍按原宿主合同执行。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.21.1",
3
+ "version": "0.21.3",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -0,0 +1,21 @@
1
+ // 当前会话运行的每次宿主调用(含「检查」整步)共用一个期限,默认 30 分钟。
2
+ // 设备检查(构建 Release、在模拟器上跑多条流程)常常超过 30 分钟:运行可在创建时用
3
+ // --call-timeout-minutes N(30–60)把它放宽。上限 60 分钟与 runner 的 validCallTimeout、
4
+ // 宿主应答兜底(HOST_ANSWER_BACKSTOP_MS)一致。它不进运行指纹:恢复时可改(含给现有运行加上)。
5
+ export const DEFAULT_CALL_TIMEOUT_MS=1800000;
6
+ export const MIN_CALL_TIMEOUT_MINUTES=30,MAX_CALL_TIMEOUT_MINUTES=60;
7
+ export function parseCallTimeoutMinutes(raw){
8
+ if(raw===undefined)return null;
9
+ if(typeof raw!=='string'||!/^[1-9][0-9]$/.test(raw)||Number(raw)<MIN_CALL_TIMEOUT_MINUTES||Number(raw)>MAX_CALL_TIMEOUT_MINUTES){
10
+ const error=new Error(`--call-timeout-minutes 须为 ${MIN_CALL_TIMEOUT_MINUTES}–${MAX_CALL_TIMEOUT_MINUTES} 的整数(分钟)`);
11
+ error.code='invalid_arguments';throw error;
12
+ }
13
+ return Number(raw)*60000;
14
+ }
15
+ export const callTimeoutFrom=permissions=>{
16
+ const at=Array.isArray(permissions)?permissions.indexOf('--call-timeout-minutes'):-1;
17
+ // 宿主拒绝重复参数;体检同样按非法处理,不只读第一个值
18
+ if(at!==-1&&permissions.indexOf('--call-timeout-minutes',at+1)!==-1)parseCallTimeoutMinutes('');
19
+ // 写了参数却没给值:按非法处理,不悄悄退回默认
20
+ return at===-1?null:parseCallTimeoutMinutes(permissions[at+1]??'');
21
+ };
@@ -1,6 +1,7 @@
1
1
  // Pure storage representation only. The runner still validates every restored
2
2
  // checkpoint transition, package link, receipt and completion prerequisite.
3
3
  import path from 'node:path';
4
+ import {readReviewPackage} from './review-package.mjs';
4
5
  import {digest,json,shape,need,hex,id,validIdentity,freeze,JOURNAL_PAYLOAD_LIMIT} from './effect-contract.mjs';
5
6
 
6
7
  const INVALID='checkpoint_package_material_invalid',STATE_LIMIT=16*1024*1024;
@@ -45,8 +46,8 @@ function storageHeader(payload){
45
46
  }
46
47
  function packageValue(raw,identity){
47
48
  const value=json(raw,STATE_LIMIT);validIdentity(identity);validIdentity(value?.identity);
48
- must(value.version===1&&value.kind==='cm-review-package'&&sameRun(value.identity,identity));hex(value.packageDigest);
49
- const {packageDigest,...body}=value;must(digest(body)===packageDigest);return value;
49
+ must([1,2].includes(value.version)&&value.kind==='cm-review-package'&&sameRun(value.identity,identity));hex(value.packageDigest);
50
+ const {packageDigest,...body}=value;must(digest(body)===packageDigest);return value.version===2?readReviewPackage(value):value;
50
51
  }
51
52
  function history(raw,identity){
52
53
  validIdentity(identity);const records=json(raw,STATE_LIMIT);must(Array.isArray(records)&&records.length<=1024);
@@ -269,6 +269,7 @@ export function createCmAiConversationEntry(options) {
269
269
  const ownerIdentity=json(options.identity);validIdentity(ownerIdentity);
270
270
  const runner=options.runner;
271
271
  const runnerKeys=['executeEffect','status','cancel','run'];
272
+ if(runner&&Object.hasOwn(runner,'qaAllowsSymlinks'))runnerKeys.push('qaAllowsSymlinks');
272
273
  if(runner&&Object.hasOwn(runner,'qaChangedFiles'))runnerKeys.push('qaChangedFiles');
273
274
  if(runner&&Object.hasOwn(runner,'qaCompletionChecks'))runnerKeys.push('qaCompletionChecks');
274
275
  if(runner&&Object.hasOwn(runner,'verificationBlocks'))runnerKeys.push('verificationBlocks');
@@ -295,6 +296,7 @@ export function createCmAiConversationEntry(options) {
295
296
  if(runner&&Object.hasOwn(runner,'interruptions'))runnerKeys.push('interruptions');
296
297
  if(runner&&Object.hasOwn(runner,'inspectBootstrapAdmission'))runnerKeys.push('inspectBootstrapAdmission');
297
298
  shape(runner,runnerKeys);
299
+ if(Object.hasOwn(runner,'qaAllowsSymlinks'))need(typeof runner.qaAllowsSymlinks==='function');
298
300
  if(Object.hasOwn(runner,'qaChangedFiles'))need(typeof runner.qaChangedFiles==='function');
299
301
  if(Object.hasOwn(runner,'qaCompletionChecks'))need(typeof runner.qaCompletionChecks==='function');
300
302
  for(const name of ['executeEffect','status','cancel','run'])need(typeof runner[name]==='function');
@@ -583,7 +585,9 @@ export function createCmAiConversationEntry(options) {
583
585
  const executed=await Promise.race([Promise.resolve().then(()=>{
584
586
  notCancelled();
585
587
  need(!controller.signal.aborted,'cancelled');
586
- return qaExecutor.run(freeze(completionChecks===null?invocation:{...invocation,completionChecks}),controller.signal);
588
+ return qaExecutor.run(freeze({...invocation,
589
+ ...(completionChecks===null?{}:{completionChecks}),
590
+ ...(runner.qaAllowsSymlinks?.(result.packageDigest)?{allowSymlinks:true}:{})}),controller.signal);
587
591
  }),interrupted]);
588
592
  need(!controller.signal.aborted,'cancelled');
589
593
  // A run that moved on meanwhile (for example files in scope replaced):
@@ -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))}`,
@@ -1,3 +1,4 @@
1
+ import {reviewPackageVersion} from './symlink-material.mjs';
1
2
  import {packageMaterialEligible,resolveCheckpointPackage} from './checkpoint-package-material.mjs';
2
3
  import {validateIntegrationRecord} from './reviewed-integration.mjs';
3
4
  import {readExecutionPolicy} from './execution-policy.mjs';
@@ -8,7 +9,7 @@ import {beforeFirstQaRound,qaRevisionFollows,readQaConfigRevision} from './qa-co
8
9
  import {readCloseoutPolicy} from './knowledge-closeout.mjs';
9
10
  // Host-only S3b2b journal grammar. Data validation grants no provider authority.
10
11
  import {digest,need,shape,id,text,hex,json,validIdentity,validTaskLearningInput,validCallTimeout,validBlockedReason,validFailureCode,requestFor,JOURNAL_REASON_LIMIT,boundedReason,JOURNAL_PAYLOAD_LIMIT} from './effect-contract.mjs';
11
- import {readReviewBaseline,readReviewPackage,reviewSpecsPath,reviewMaterialLimitReason} from './review-package.mjs';
12
+ import {readReviewBaseline,readReviewPackage,reviewSpecsPath,reviewMaterialLimitReason,unchangedScopeRecord} from './review-package.mjs';
12
13
  import {reviewResult,reviewReceipt} from './review-runner.mjs';
13
14
  import {checkCompletion} from './gate-bridge.mjs';
14
15
  import path from 'node:path';
@@ -750,6 +751,20 @@ export function initialRunnerState(config,session,version=1) {
750
751
  ...(version>=2?{taskCommit:null}:{}),...(version===3?{reviewInvocation:null}:{}),
751
752
  ...(Object.hasOwn(config,'taskLearning')?{learningResult:null}:{})};
752
753
  }
754
+ // 当前会话运行的单次调用期限(--call-timeout-minutes,30–60 分钟)只管等多久、不授予能力:
755
+ // 恢复时允许与创建时不同,其余字段仍须逐字节一致。受保护配置与外部模型运行的期限由其已授权配置决定,不放宽。
756
+ export function sameRunnerConfig(saved,current) {
757
+ const sessionWindow=c=>c?.developer?.requestedModel==='current-session'&&!Object.hasOwn(c,'externalModels')
758
+ &&Number.isInteger(c.timeoutMs)&&c.timeoutMs>=1800000&&c.timeoutMs<=3600000;
759
+ if(sessionWindow(saved)&&sessionWindow(current)){
760
+ same({...saved,timeoutMs:0},{...current,timeoutMs:0});
761
+ // 不得低于创建时的值:创建时放宽过的运行漏传或调小会缩短检查整步,按参数名报出。
762
+ // 恢复时放宽不入落盘记录,下次恢复按当次传入值生效(宿主每次启动在 stderr 报出实际期限)
763
+ if(current.timeoutMs<saved.timeoutMs)throw Object.assign(new Error('invalid_arguments'),{code:'invalid_arguments',
764
+ reason:`--call-timeout-minutes:此运行已用 ${saved.timeoutMs/60000} 分钟,本次为 ${current.timeoutMs/60000} 分钟;恢复时不得低于创建时的值,请传不小于 ${saved.timeoutMs/60000} 的值`});
765
+ }
766
+ else same(saved,current);
767
+ }
753
768
  export function runnerStatus(s,config) {
754
769
  return json({state:s.state,code:s.code,...(s.reason?{reason:s.reason}:{}),identity:{...config.identity,attempt:s.attempt},packageDigest:s.reviewPackage?.packageDigest??null,
755
770
  receipt:s.receipt,receipts:s.receipts,calls:s.calls,cancelAfterCommit:s.cancelAfterCommit,workflowError:s.workflowError,cancellationRequested:s.cancellationRequested,
@@ -774,13 +789,13 @@ export function controlledState(state,event,outstanding,version=1,developmentRew
774
789
  function packageLink(pkg,original,attempt,checks) {
775
790
  const p=readReviewPackage(pkg),b=attemptBaseline(original,attempt);
776
791
  same(p.identity,b.identity);same(p.scope,b.scope);same(p.checks,checks);
777
- need(p.baseIdentity===b.baselineDigest && p.rootDigest===b.rootDigest,'runner_package');
792
+ need(p.version===reviewPackageVersion(b)&&p.baseIdentity===b.baselineDigest && p.rootDigest===b.rootDigest,'runner_package');
778
793
  const files=new Map(b.files.map(f=>[f.path,f]));
779
794
  for(const c of p.changes){same(c.before,files.get(c.path)??null);if(c.after===null)files.delete(c.path);else files.set(c.path,c.after);}
780
795
  if(Object.hasOwn(p,'unchangedScope')){
781
796
  const changed=new Set(p.changes.map(c=>c.path));
782
797
  same(p.unchangedScope,b.scope.filter(path=>!changed.has(path)&&files.has(path))
783
- .map(path=>b.scopeRevisionPaths?.includes(path)?files.get(path):({path,sha256:files.get(path).sha256})));
798
+ .map(path=>unchangedScopeRecord(b,files.get(path))));
784
799
  }
785
800
  same(p.specification??null,b.specification??null);
786
801
  same(p.requirements,b.requirements.map(path=>files.get(path)??null));
@@ -1402,7 +1417,7 @@ export function readRunnerHistory(raw,config,version=1) {
1402
1417
  const common=['version','protocol','type'];
1403
1418
  if(index===0) {
1404
1419
  shape(p,[...common,'config','baseline','session']);need(p.type==='init' && r.kind==='result','runner_init');
1405
- same(p.config,config);session=p.session;uuid(session);original=readReviewBaseline(p.baseline);
1420
+ sameRunnerConfig(p.config,config);session=p.session;uuid(session);original=readReviewBaseline(p.baseline);
1406
1421
  const reviewScope=Object.hasOwn(config,'taskLearning')&&!config.scope.includes('AGENTS.md')
1407
1422
  ?[...config.scope,'AGENTS.md']:[...config.scope];
1408
1423
  same(original.identity,config.identity);same(original.scope,reviewScope.sort());same(original.requirements,[...config.requirements].sort());
@@ -53,7 +53,7 @@ export function firstReviewAt(records,identity){
53
53
  const known=tasksPath=>typeof tasksPath==='string';
54
54
  export const sameDeliveryTask=(a,b)=>a.taskId===b.taskId
55
55
  &&(!known(a.tasksPath)||!known(b.tasksPath)||a.tasksPath===b.tasksPath);
56
- const key=file=>file===null||file===undefined?null:`${file.sha256}:${file.mode}`;
56
+ const key=file=>file===null||file===undefined?null:`${file.sha256}:${file.mode??null}`;
57
57
  const applyMeta=(state,pkg)=>{for(const change of pkg.changes){
58
58
  if(change.after===null)state.delete(change.path);else state.set(change.path,inventoryFile(change.after));}};
59
59
  // Every qualifying later package, in durable review order (ties: run id, then
@@ -143,7 +143,7 @@ export function composeFixCode({baseline,parentPackage,fixPackages,steps=[]}){
143
143
  const resolved=steps.map(step=>{const pkg=readReviewPackage(step.pkg);
144
144
  need(pkg.packageDigest===step.packageDigest&&pkg.rootDigest===base.rootDigest,'fix_association_unverified');return {...step,pkg};});
145
145
  // Metadata-only transitions cannot rebuild legacy full-content inventories.
146
- need(!resolved.length||base.version===2,'fix_before_mismatch');
146
+ need(!resolved.length||base.version>=2,'fix_before_mismatch');
147
147
  const files=[...composeState(chain,resolved).values()].sort((a,b)=>a.path<b.path?-1:a.path>b.path?1:0);
148
148
  // Use the same canonical inventory for live association and journal replay.
149
149
  return {base,parent,fixes,files:base.version===1?files:files.map(inventoryFile)};
@@ -175,7 +175,7 @@ export function explainCompletedDelivery({root,baseline,parentPackage,deliveries
175
175
  explainReviewedDrift({root,baseline:base,composed:[...expected.values()],ownScope:parent.scope,deliveries,after});
176
176
  return;
177
177
  }catch(error){
178
- if(error.code!=='fix_current_code_unexplained'||base.version!==2||!Number.isSafeInteger(since)
178
+ if(error.code!=='fix_current_code_unexplained'||base.version===1||!Number.isSafeInteger(since)
179
179
  ||!Number.isSafeInteger(after)||since>=after)throw error;
180
180
  // A sibling can finish while the parent is being revised. Prove the whole
181
181
  // bounded interval from the unchanged baseline, in durable review order;
@@ -205,7 +205,7 @@ export function explainCompletedDelivery({root,baseline,parentPackage,deliveries
205
205
  // or rootDigest to make it pass ordinary delivery discovery.
206
206
  export function explainIntegratedDelivery({root,baseline,parentPackage,deliveries,after,since,sources,documents,snapshots}){
207
207
  const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
208
- need(base.version===2&&parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
208
+ need(base.version>=2&&parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
209
209
  &&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
210
210
  if(base.specification)verifySpecificationMaterial(base);
211
211
  const expected=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
@@ -275,7 +275,7 @@ export function inspectFixCodeAssociation({root,specsRoot,baseline,parentPackage
275
275
  // Without a way to read other runs' deliveries the historical exact match holds.
276
276
  need(typeof deliveries==='function','fix_current_code_unexplained');
277
277
  // Metadata-only transitions cannot rebuild legacy full-content inventories.
278
- need(!rest.length||base.version===2,'fix_before_mismatch');
278
+ need(!rest.length||base.version>=2,'fix_before_mismatch');
279
279
  const state=new Map(files.map(file=>[file.path,inventoryFile(file)]));
280
280
  for(const entry of rest)applyDelivery(state,entry.pkg,tolerated);
281
281
  compareCurrent({root,base,state,tolerated});
@@ -1,3 +1,4 @@
1
+ import {DEFAULT_CALL_TIMEOUT_MS} from './call-timeout.mjs';
1
2
  import {createNativeUsageLog} from './native-usage-log.mjs';
2
3
  import {readExecutionPolicy} from './execution-policy.mjs';
3
4
  import {readControlPolicy} from './control-policy.mjs';
@@ -5,7 +6,7 @@ import {selectExternalModels} from './external-models.mjs';
5
6
  // Fixed current-conversation factory, separate from CLI top-level execution.
6
7
  import fs from 'node:fs';
7
8
  import {spawn} from 'node:child_process';
8
- import {createHash} from 'node:crypto';
9
+ import {protectedEditDigest,validateProtectedEdit} from './symlink-material.mjs';
9
10
  import {loadConfig,resolveProtectedRuntimes} from '../../../scripts/cm-workflow-config.mjs';
10
11
  import {claudeDeveloperWorker,validateClaudeProposal} from './worker-claude-developer.mjs';
11
12
  import {codexDeveloperWorker} from './worker-codex-developer.mjs';
@@ -35,7 +36,7 @@ import {verifySpecificationMaterial} from './specification-material.mjs';
35
36
  import {isFinalCmAiTask} from './cm-ai-admission.mjs';
36
37
  import {createHostBootstrap} from './host-bootstrap.mjs';
37
38
  import {withHostProgress} from './host-progress.mjs';
38
- import {digest,id,hex,json,need,shape,freeze,arrayItems,boundedReason} from './effect-contract.mjs';
39
+ import {digest,id,json,need,shape,freeze,arrayItems,boundedReason} from './effect-contract.mjs';
39
40
  export const protectedTextInstructions='\nProtected current-host mode: do not write files or run commands. Return {status,value,edits} on success; '
40
41
  +'value retains the original implementation/Learning contract. edits is [{path,beforeSha256,content[,mode]}], complete UTF-8 text or null for deletion; '
41
42
  +'optional mode "0755" or "0644" sets the permission bits of a written file. '
@@ -100,7 +101,8 @@ export const REVIEW_BOUND_MARGIN_MS=60000;
100
101
  export const reviewRaceTimeout=(outerTimeoutMs,reviewTimeoutMs)=>Math.max(outerTimeoutMs,reviewTimeoutMs+REVIEW_BOUND_MARGIN_MS);
101
102
  export function createConversationExecution(definition,hostContextId,bridge,review=null,reservedReviewAttempt=null,workflow=null,allowQa=false,runtime='codex',options={}){
102
103
  definition=json(definition);workflow=workflow===null?null:json(workflow);options=json(options);
103
- shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','soloMember','verificationPrecheck','executionPolicy','controlPolicy','memberDevelopment'].filter(key=>Object.hasOwn(options,key))]);
104
+ shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','soloMember','verificationPrecheck','executionPolicy','controlPolicy','memberDevelopment','callTimeoutMs'].filter(key=>Object.hasOwn(options,key))]);
105
+ need(!Object.hasOwn(options,'callTimeoutMs')||(Number.isInteger(options.callTimeoutMs)&&options.callTimeoutMs>=DEFAULT_CALL_TIMEOUT_MS&&options.callTimeoutMs<=3600000),'invalid_input');
104
106
  const controlPolicy=options.controlPolicy?readControlPolicy(options.controlPolicy):null;
105
107
  need(!Object.hasOwn(options,'verificationPrecheck')||typeof options.verificationPrecheck==='boolean','invalid_input');
106
108
  const executionPolicy=options.executionPolicy?readExecutionPolicy(options.executionPolicy):null;
@@ -154,6 +156,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
154
156
  selection:options.bootstrap.selection,bridge,allowWrite:options.bootstrap.allowWrite});
155
157
  }
156
158
  const protection=options.protection??null;
159
+ need(!Object.hasOwn(options,'callTimeoutMs')||protection===null,'invalid_input');
157
160
  if(protection){shape(protection,['checkCommands','timeoutMs']);specsPermissionArgs({cwd:definition.codeProject,specsRoot:definition.specsDir});}
158
161
  need(!definition.codeProjects||protection,'multi_root_protection_required');
159
162
  const projectExecution=protection?createProjectExecution({definition,protection,executionPolicy}):null;
@@ -181,6 +184,8 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
181
184
  ...(options.batchWorkflowsDigest?{batchWorkflowsDigest:options.batchWorkflowsDigest}:{}),
182
185
  ...(review?{review:{version:1,model:review.model,disabledSkills:review.disabledSkills,...(externalModels?{effort:review.effort}:{})}}:{}),
183
186
  ...(workflow?{workflow}: {})};
187
+ // --call-timeout-minutes 不进执行配置与运行指纹:它只决定单次调用等多久,不授予任何能力;
188
+ // 现行版本建的运行在设备检查超时后,恢复时可放宽到 60 分钟(durable-runner-state.mjs sameRunnerConfig)。
184
189
  const reviewOptions={cwd:definition.codeProject,model:review?.model??'unconfigured',...(externalModels?{effort:review.effort}:{}),preflight:review?.preflight??null,
185
190
  disabledSkills:review?.disabledSkills??[],
186
191
  ...resolveReviewTimeout(review,protection),
@@ -278,7 +283,9 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
278
283
  return verdict.satisfied?{satisfied:true,items:verdict.items,...(facts?{hostRecord:facts}:{}),...(coverage?{coverage}:{})}
279
284
  :{satisfied:false,reason:boundedReason('verification_precheck_failed: ',verdict.unsatisfied??['门禁未记录具体缺项'])};
280
285
  };
281
- const outerTimeoutMs=provider?protection.timeoutMs:1800000;
286
+ const outerTimeoutMs=provider?protection.timeoutMs:(options.callTimeoutMs??DEFAULT_CALL_TIMEOUT_MS);
287
+ // 当前会话运行默认 30 分钟;--call-timeout-minutes 可放宽到 60 分钟(设备检查)。首条 journal 记录保留创建时的值,
288
+ // 普通当前会话运行恢复时用本次传入值,不得低于创建值(durable-runner-state.mjs sameRunnerConfig)
282
289
  const progress=(request,control,stage,run,selectedRuntime=runtime)=>withHostProgress({definition,
283
290
  identity:request.identity,runtime:selectedRuntime,stage,signal:control.signal},run);
284
291
  const execution={configuration,timeoutMs:outerTimeoutMs,excludedContexts:[durableHostContextId],applicableAgentFiles:[],
@@ -296,11 +303,12 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
296
303
  need(!used.has(bound.invocationId),'duplicate_dispatch');used.add(bound.invocationId);
297
304
  }
298
305
  const route=provider?null:resolveHostRole({definition,identity:bound.identity,role:'coder',signal:control.signal,runtime});
306
+ const allowSymlinks=control.allowSymlinks===true;
299
307
  let developerUsage=null;const developerLog=executionPolicy&&provider?createNativeUsageLog({definition,request:bound,provider:coderRuntime,role:'developer'}):null;
300
308
  const processWorker=provider?(coderRuntime==='codex'?codexDeveloperWorker:claudeDeveloperWorker)({
301
309
  ...(developerLog?{onUsageClaim:()=>developerLog.claimed(),onUsage:value=>{developerUsage=value;}}:{}),
302
310
  cwd:definition.codeProject,model:provider.model,...(externalModels?{effort:provider.effort}:{}),timeoutMs:protection.timeoutMs,
303
- ...(coderRuntime==='codex'?{specsRoot:definition.specsDir}:{}),
311
+ ...(coderRuntime==='codex'?{specsRoot:definition.specsDir}:{allowSymlinks}),
304
312
  spawnProcess:dispatchSpawn('coder',bound.identity,control.signal,typeof control.onWorker==='function'?control.onWorker:null)}):null;
305
313
  const splitReport=response=>{
306
314
  if(response?.status!=='succeeded')return response;
@@ -317,22 +325,24 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
317
325
  developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
318
326
  return response;
319
327
  }
320
- const expected=projectExecution?projectExecution.expected(bound.payload.scope):null;
328
+ const expected=projectExecution?projectExecution.expected(bound.payload.scope,allowSymlinks):null;
321
329
  if(protection){
322
330
  prompt+=protectedTextInstructions;
331
+ if(allowSymlinks)prompt+=' For a link, return {path,beforeSha256,symlink} with a relative target inside its code root. Delete links with content:null.';
323
332
  if(!parallelMember&&documentationPaths.length&&isFinalCmAiTask({specsDir:definition.specsDir,codeProject:definition.codeProject,
324
333
  feature:definition.feature,taskId:bound.identity.taskId,featureSelection:definition.featureSelection?.feature}))prompt+=' Include necessary documentation synchronization in the same edits: '+JSON.stringify(documentationPaths);
325
334
  }
326
335
  const response=splitReport(provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
327
336
  ...(definition.codeProjects?{codeProjects:resolveCodeProjects(definition.codeProject,definition.codeProjects),
328
337
  projectInstructions:definition.codeProjects.map(root=>({codeProject:root,files:readProjectInstructionContext(root)}))}:{}),
338
+ ...(allowSymlinks?{allowSymlinks}:{}),
329
339
  ...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal)));
330
340
  if(provider)developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
331
341
  if(response.status==='succeeded'){
332
342
  const edits=[];
333
343
  try{
334
344
  shape(response,['status','value',...(protection?['edits']:[]),...(provider?['providerThread']:[])]);
335
- if(provider){const {providerThread,...proposal}=response;id(providerThread);validateClaudeProposal(proposal);}
345
+ if(provider){const {providerThread,...proposal}=response;id(providerThread);validateClaudeProposal(proposal,{allowSymlinks});}
336
346
  if(protection){
337
347
  // Complete local validation precedes every protected write.
338
348
  validateDeveloperValue(response.value,bound);
@@ -340,17 +350,12 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
340
350
  if(response.value.outcome==='blocked')need(response.edits.length===0,'protected_edit_invalid');
341
351
  const seen=new Set();
342
352
  for(const edit of response.edits){
343
- shape(edit,['path','beforeSha256','content',...(Object.hasOwn(edit,'mode')?['mode']:[])]);
344
- need(!Object.hasOwn(edit,'mode')||edit.content!==null&&['0644','0755'].includes(edit.mode),'protected_edit_invalid');
353
+ validateProtectedEdit(edit,allowSymlinks);
345
354
  need(bound.payload.scope.includes(edit.path)&&!seen.has(edit.path),'out_of_scope');seen.add(edit.path);
346
- if(edit.beforeSha256!==null)hex(edit.beforeSha256);
347
- need(edit.content===null||typeof edit.content==='string','protected_edit_invalid');
348
- need(edit.content===null||Buffer.byteLength(edit.content)<=1024*1024,'limit_exceeded');
349
- need(edit.content!==null||edit.beforeSha256!==null,'protected_edit_invalid');
350
355
  // Reuse a previous proposal only when its exact output is
351
356
  // already present. A stale proposal never overwrites drift.
352
357
  if(edit.beforeSha256!==expected[edit.path]){
353
- const after=edit.content===null?null:createHash('sha256').update(edit.content).digest('hex');
358
+ const after=protectedEditDigest(edit);
354
359
  need(after===expected[edit.path],'protected_edit_stale');
355
360
  }else edits.push(edit);
356
361
  }
@@ -362,12 +367,14 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
362
367
  specification:bound.payload.specification,identity:bound.identity});
363
368
  // The applying sandbox subprocess is journaled like the worker (V9).
364
369
  try{await projectExecution.commit({scope:bound.payload.scope,
365
- edits,expected,identity:bound.identity,signal:control.signal,
370
+ edits,expected,allowSymlinks,identity:bound.identity,signal:control.signal,
366
371
  ...(typeof control.onWorker==='function'?{onApply:event=>control.onWorker(event)}:{})});}
367
372
  catch(error){
368
373
  // This code is emitted by the pre-write expected-hash check.
369
374
  // Sandbox execution/partial-write failures stay ambiguous.
370
375
  if(error.code==='protected_edit_stale')return {status:'failed',code:'protected_edit_stale'};
376
+ if(allowSymlinks&&['invalid_symlink_target','unsupported_path','protected_edit_invalid'].includes(error.code))
377
+ return {status:'failed',code:'invalid_result',reason:error.code};
371
378
  throw error;
372
379
  }
373
380
  }
@@ -1,6 +1,7 @@
1
1
  // Documentation is part of the existing durable developer invocation, before
2
2
  // checks/Learning/handoff/review. This adapter grants no additional file scope.
3
3
  import {isFinalCmAiTask} from './cm-ai-admission.mjs';
4
+ import {SYMLINK_BASELINE_VERSION} from './symlink-material.mjs';
4
5
  import {captureReviewBaseline} from './review-package.mjs';
5
6
  import {digest,json,shape,need,terminalFor,boundedReason} from './effect-contract.mjs';
6
7
 
@@ -30,9 +31,9 @@ export function splitDocumentationState(files,paths){
30
31
  }
31
32
  // Without a runner snapshot (no journal: nothing is recorded or retried), the
32
33
  // adapter keeps its own scope-only capture for the out-of-scope check.
33
- export function captureDocumentationState({root,specsRoot,identity,paths,requirements,specification=null}){
34
+ export function captureDocumentationState({root,specsRoot,identity,paths,requirements,specification=null,allowSymlinks=false}){
34
35
  const baseline=captureReviewBaseline({root,specsRoot,identity,scope:paths,requirements,
35
- ...(specification?{specification}:{})});
36
+ ...(allowSymlinks?{version:SYMLINK_BASELINE_VERSION}:{}),...(specification?{specification}:{})});
36
37
  return splitDocumentationState(baseline.files,paths);
37
38
  }
38
39
  // Paths outside the documentation paths that differ between two captures.
@@ -62,7 +63,7 @@ export function withHostDocumentation({developer,documentationSync,specsDir,code
62
63
  need(redo===undefined,'documentation_redo_mismatch');return response;
63
64
  }
64
65
  const capture=()=>typeof control.documentationSnapshot==='function'?control.documentationSnapshot(paths):captureDocumentationState({root:codeProject,specsRoot:specsDir,identity:request.identity,paths,
65
- requirements:request.payload.requirements.map(file=>file.path),
66
+ requirements:request.payload.requirements.map(file=>file.path),allowSymlinks:control.allowSymlinks===true,
66
67
  specification:request.payload.specification?{specsRoot:specsDir,feature}:null});
67
68
  const before=capture();
68
69
  // The runner journals the developer answer and this start before the sync
@@ -2,6 +2,7 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import {randomUUID,createHash} from 'node:crypto';
5
+ import {SYMLINK_BASELINE_VERSION} from './symlink-material.mjs';
5
6
  import {createReviewPackage,verifyReviewPackage} from './review-package.mjs';
6
7
  import {supersedeWorkflowFile} from './review-evidence-file.mjs';
7
8
  import {implementationSha256,loadHandoff} from '../../../scripts/cm-task-gate.mjs';
@@ -26,7 +27,7 @@ function prepareHostHandoff(raw){
26
27
  const reviewPackage=createReviewPackage({root,baseline,checks});
27
28
  const changedFiles=reviewPackage.changes.map(change=>change.path);
28
29
  const {payload,bytes}=hostHandoffDocument({baseline,checks,reviewPackage,
29
- implementationSha256:implementationSha256(root,changedFiles),evidence});
30
+ implementationSha256:implementationSha256(root,changedFiles,{allowSymlinks:baseline.version===SYMLINK_BASELINE_VERSION}),evidence});
30
31
  need(bytes.length<=256*1024,'limit_exceeded');
31
32
  return {root,baseline,checks,handoffPath,parent,reviewPackage,changedFiles,payload,bytes};
32
33
  }
@@ -116,7 +117,7 @@ export function createHostHandoff(raw){
116
117
  fs.writeFileSync(fd,bytes);fs.fsyncSync(fd);fs.closeSync(fd);fd=undefined;
117
118
  loadHandoff(temp,{task:baseline.identity.taskId,attempt:baseline.identity.attempt});
118
119
  verifyReviewPackage({root,baseline,checks,reviewPackage,expectedDigest:reviewPackage.packageDigest});
119
- need(payload.implementation_sha256===implementationSha256(root,changedFiles),'snapshot_changed');
120
+ need(payload.implementation_sha256===implementationSha256(root,changedFiles,{allowSymlinks:baseline.version===SYMLINK_BASELINE_VERSION}),'snapshot_changed');
120
121
  // Atomic no-replace publication, unlike rename which could overwrite approval.
121
122
  publishHandoff(parent,handoffPath,temp,bytes,baseline.identity.attempt);
122
123
  fs.unlinkSync(temp);
@@ -1,6 +1,6 @@
1
1
  // Execute declared root-local operations and aggregate into the original task.
2
2
  // Root selection is data, not a second scheduler or a task completion authority.
3
- import {captureProtectedEdits,commitProtectedEdits} from '../cm-fix/protected-edits.mjs';
3
+ import {captureProtectedEdits,checkProtectedEdits,commitProtectedEdits} from '../cm-fix/protected-edits.mjs';
4
4
  import {groupCodeProjectPaths,resolveCodeProjects} from './code-projects.mjs';
5
5
  import {createHostCheck,reportHostCheckProgress} from './host-check.mjs';
6
6
  import {specsPermissionArgs} from './codex-config.mjs';
@@ -33,21 +33,23 @@ export function createProjectExecution({definition,protection,executionPolicy=nu
33
33
  need(roots.every(root=>checks.some(item=>item.cwd===root)),'code_project_checks_required');
34
34
  const recheck=()=>{if(data.codeProjects)need(digest(resolveCodeProjects(data.codeProject,roots))===digest(roots),'execution_root_mismatch');};
35
35
  return Object.freeze({
36
- expected(scope){recheck();return Object.fromEntries(groups(scope).flatMap(group=>
37
- Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths):{}).map(([file,hash])=>[full(group,file),hash])));},
38
- async commit({scope,edits,expected,identity,signal,onApply=null}){
36
+ expected(scope,allowSymlinks=false){recheck();return Object.fromEntries(groups(scope).flatMap(group=>
37
+ Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths,{allowSymlinks}):{}).map(([file,hash])=>[full(group,file),hash])));},
38
+ async commit({scope,edits,expected,identity,signal,onApply=null,allowSymlinks=false}){
39
39
  recheck();need(Array.isArray(edits),'protected_edit_invalid');
40
40
  for(const edit of edits)need(scope.includes(edit.path),'out_of_scope');
41
41
  // Precheck all roots before the first root writes; no claim of atomicity.
42
42
  const selected=groups(scope);
43
- for(const group of selected)for(const [file,hash] of Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths):{}))
43
+ for(const group of selected)for(const [file,hash] of Object.entries(group.paths.length?captureProtectedEdits(group.codeProject,group.paths,{allowSymlinks}):{}))
44
44
  need(hash===expected[full(group,file)],'protected_edit_stale');
45
- for(const group of selected){
46
- const local=edits.filter(edit=>group.paths.some(file=>full(group,file)===edit.path))
47
- .map(edit=>({...edit,path:group.prefix?edit.path.slice(group.prefix.length+1):edit.path}));
45
+ const plans=selected.map(group=>({group,local:edits.filter(edit=>group.paths.some(file=>full(group,file)===edit.path))
46
+ .map(edit=>({...edit,path:group.prefix?edit.path.slice(group.prefix.length+1):edit.path}))}));
47
+ if(allowSymlinks)for(const {group,local} of plans)if(local.length)
48
+ checkProtectedEdits({cwd:group.codeProject,specsRoot:data.specsDir,scope:group.paths,edits:local,allowSymlinks});
49
+ for(const {group,local} of plans){
48
50
  if(!local.length)continue;
49
51
  await commitProtectedEdits({cwd:group.codeProject,specsRoot:data.specsDir,scope:group.paths,edits:local,
50
- expected:Object.fromEntries(group.paths.map(file=>[file,expected[full(group,file)]])),identity,signal,timeoutMs:config.timeoutMs,onApply});
52
+ expected:Object.fromEntries(group.paths.map(file=>[file,expected[full(group,file)]])),identity,signal,timeoutMs:config.timeoutMs,onApply,allowSymlinks});
51
53
  }
52
54
  },
53
55
  async check(request,control){
@@ -1,5 +1,6 @@
1
1
  // N6 execution over already-authorized host capabilities. No model dispatch,
2
2
  // browser installation, task writes, auto-fix or second completion authority.
3
+ import {SYMLINK_BASELINE_VERSION} from './symlink-material.mjs';
3
4
  import fs from 'node:fs';
4
5
  import path from 'node:path';
5
6
  import {spawnSync} from 'node:child_process';
@@ -224,7 +225,7 @@ export function createHostQaExecutor(options) {
224
225
  return Object.freeze({...initial,timeoutMs:configuration.timeoutMs,prepare,
225
226
  async run(rawBinding,signal){
226
227
  const {mode,caseCount,configuration:{plan}}=prepared??prepare();
227
- let {completionChecks=null,...binding}=json(rawBinding);
228
+ let {completionChecks=null,allowSymlinks=false,...binding}=json(rawBinding);
228
229
  shape(binding,['specsDir','codeProject','feature','identity','packageDigest','testRunId','mode','caseCount',
229
230
  ...(Object.hasOwn(binding,'qaRound')?['qaRound']:[])]);
230
231
  need(completionChecks===null||Array.isArray(completionChecks)&&completionChecks.length<=32,'qa_check_reuse_invalid');
@@ -238,7 +239,7 @@ export function createHostQaExecutor(options) {
238
239
  const unchanged=()=>need(digest(readPlan(configuration))===digest(plan),'qa_plan_changed');
239
240
  const notCancelled=()=>need(!signal.aborted,'cancelled');notCancelled();unchanged();
240
241
  const snapshot=()=>captureReviewBaseline({root:configuration.codeProject,specsRoot:configuration.specsDir,
241
- identity:binding.identity,scope:configuration.bootstrap?.scope??(configuration.requirements.length?configuration.requirements:['AGENTS.md']),requirements:configuration.requirements,
242
+ identity:binding.identity,...(allowSymlinks===true?{version:SYMLINK_BASELINE_VERSION}:{}),scope:configuration.bootstrap?.scope??(configuration.requirements.length?configuration.requirements:['AGENTS.md']),requirements:configuration.requirements,
242
243
  ...(!configuration.bootstrap&&!configuration.requirements.length
243
244
  ?{specification:{specsRoot:configuration.specsDir,feature:configuration.feature}}:{}),
244
245
  ...(configuration.bootstrap?{bootstrapRequirements:configuration.bootstrap.requirements}:{}),