@aibyzero/cm-workflow 0.20.0 → 0.21.1
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.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +36 -0
- package/README.md +13 -1
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +1 -1
- package/docs/proposals/spec-amendment-tiers.md +100 -0
- package/package.json +1 -1
- package/runtime/js/acceptance-language.mjs +32 -0
- package/runtime/js/autonomy.mjs +15 -6
- package/runtime/js/cm-ai/acceptance-contract.mjs +8 -3
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +13 -3
- package/runtime/js/cm-ai/cm-ai-admission.mjs +35 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +19 -3
- package/runtime/js/cm-ai/drive-core.mjs +9 -2
- package/runtime/js/cm-ai/durable-runner-state.mjs +12 -4
- package/runtime/js/cm-ai/effect-contract.mjs +8 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -3
- package/runtime/js/cm-ai/execution-store-limits.mjs +3 -3
- package/runtime/js/cm-ai/execution-store.mjs +7 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +27 -6
- package/runtime/js/cm-ai/review-package.mjs +20 -6
- package/runtime/js/cm-ai/review-presentation.mjs +12 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +10 -7
- package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
- package/runtime/js/cm-ai/spec-amendment.mjs +535 -0
- package/runtime/js/cm-ai/task-commit-codec.mjs +4 -2
- package/runtime/js/cm-ai/task-commit.mjs +4 -2
- package/runtime/js/cm-ai/task-runner.mjs +26 -9
- package/runtime/js/cm-ai/user-maintained-paths.mjs +68 -0
- package/runtime/js/cm-prd/change.mjs +35 -4
- package/runtime/js/cm-prd/self-check.mjs +36 -6
- package/runtime/js/cm-prd/session.mjs +8 -3
- package/runtime/js/cm-prd/task-scope-record.mjs +13 -7
- package/runtime/js/task-scope.mjs +4 -1
- package/runtime/test-contract.md +1 -0
- package/scripts/cm-ai-acceptance-contract.test.mjs +10 -0
- package/scripts/cm-ai-admission.mjs +8 -2
- package/scripts/cm-ai-admission.test.mjs +15 -2
- package/scripts/cm-ai-batch-run-fixture.mjs +5 -1
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +60 -6
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +1 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +1 -0
- package/scripts/cm-ai-drive.mjs +18 -11
- package/scripts/cm-ai-fix-later-delivery.test.mjs +2 -2
- package/scripts/cm-ai-later-delivery-feature.test.mjs +102 -0
- package/scripts/cm-ai-review-input-limit.test.mjs +91 -0
- package/scripts/cm-ai-user-maintained-paths.test.mjs +183 -0
- package/scripts/cm-autonomy-review-r1.test.mjs +49 -0
- package/scripts/cm-check-runtime.sh +4 -1
- package/scripts/cm-drive-liveness.test.mjs +8 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +49 -0
- package/scripts/cm-fix-review-storage.test.mjs +14 -4
- package/scripts/cm-journal-limit.test.mjs +69 -0
- package/scripts/cm-notify.test.mjs +6 -4
- package/scripts/cm-prd-completion.test.mjs +37 -0
- package/scripts/cm-prd-drive.mjs +1 -1
- package/scripts/cm-prd-host.test.mjs +1 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +23 -11
- package/scripts/cm-prd-self-check.test.mjs +24 -1
- package/scripts/cm-prd-summary.test.mjs +6 -0
- package/scripts/cm-review-inventory.test.mjs +5 -1
- package/scripts/cm-skill-hints.json +1 -1
- package/scripts/cm-skill-hints.mjs +66 -3
- package/scripts/cm-skill-hints.test.mjs +96 -0
- package/scripts/cm-spec-amend.mjs +68 -0
- package/scripts/cm-spec-amend.test.mjs +510 -0
- package/scripts/cm-specs-status.test.mjs +6 -0
- package/scripts/cm-start-check.mjs +82 -2
- package/scripts/cm-start-check.test.mjs +64 -1
- package/scripts/cm-task-scope.test.mjs +3 -2
- package/scripts/test-journal-limit-1mib.mjs +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/references/N1-init.md +23 -1
- package/skills/cm-ai/references/js-host-qa-recovery.md +3 -2
- package/skills/cm-ai/references/js-host-recovery.md +2 -1
- package/skills/cm-ai/references/js-host.md +2 -1
- package/skills/cm-prd/references/js-change-recovery.md +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cm-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
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,42 @@
|
|
|
5
5
|
|
|
6
6
|
## 未发布
|
|
7
7
|
|
|
8
|
+
## 0.21.1 — 2026-11-17
|
|
9
|
+
|
|
10
|
+
- **接近存档上限的任务提交可以正常读回**(CI 历史组夹具暴露:存档单条上限放到 4 MiB 后,`readCommitIntent` 仍按通用 JSON 校验的 1 MiB 默认值读取,计划接近或超过 1 MiB 的提交意图写得进却读不回):任务提交意图的读取改用 `JOURNAL_PAYLOAD_LIMIT`,与写入侧一致;运行器构造记录(`boundRunnerRecord`)先按同一上限校验载荷,再校验整条记录(上限加 1 KiB 外层余量)。
|
|
11
|
+
|
|
12
|
+
- **交接技能不再被否定句和引号里的词误触发**(实测:Jev 关闭时,“不要换个会话,继续当前任务”会让模型直接执行交接):关键词兜底时,否定词后约 4 个字(英文 3 个词)内的命中不算,“别忘了”除外;引号和行内代码里的词不算;只说换会话、没提交接时改为先问一句;英文 handoff/hand off 也算交接,new/fresh session、context is almost full 等英文说法也算换会话。拦下的情况记入日志,只记规则名和原因。Jev 路径、普通提示和 CM 内部流程不变。
|
|
13
|
+
|
|
14
|
+
## 0.21.0 — 2026-11-15
|
|
15
|
+
|
|
16
|
+
- **审查放不下的交付在开发阶段就拦下**(实跑 aihot 副本:存档上限放到 4 MiB 后,约 1.8 MB 的改动能交付,但 Codex 审查输入最多 1 MiB,运行卡在审查结果不明、只能整任务重开):开发交付时按将要发送的审查内容核对审查方输入上限,放不下即 `develop_package_too_large`,缩小改动后原运行重做本轮。
|
|
17
|
+
|
|
18
|
+
- **普通版本行不再被送去审查**(实跑 aihot 副本:真实版本表多数行写「范围与验收不变」):补正分级里,版本行点名已有任务且含验收或测试措辞仍按改需求处理;说明整句只由「范围与验收不变」「检查与断言不放宽」「无其他改动」这类声明组成(日期、版本格之外不夹别的内容)才 0 级直接换绑,其余一律送独立审查(不需要用户回复)。常设授权遇到不是纯声明、又涉及测试或验收的版本说明会停下请用户确认。全角编号按半角认。
|
|
19
|
+
|
|
20
|
+
- **启动体检提前报出缺少重开目标**(Wue specs8 T-003 重开:带了 `--supersede-reviewed-evidence` 却没有 `--supersede-target`,推进白跑一轮才被驾驶员拒绝):新版控制策略下重开缺目标文件时,`cm-start-check` 报 error `supersede_target_missing`,并提示先用 `cm-ai-run.mjs inspect-history` 取旧运行的 `supersedeTarget`。
|
|
21
|
+
|
|
22
|
+
- **大代码根下宿主不再因心跳超时被误杀**(Wue specs8 T-001:开发改动已写入后,宿主做同步文件树采集,单次 12–22 秒,连做几次超过 30 秒心跳上限,驾驶员以 `host_heartbeat_timeout` 终止了健康的宿主):查找被忽略目录里的 `AGENTS.md` 与 `.gitignore` 合并成一次 git 查询(原来两次各走一遍被忽略的目录树,结果逐项比对一致);驾驶员心跳默认上限从 30 秒提到 120 秒,整步上限 `operationMs` 不变,真卡死的宿主仍会被终止。
|
|
23
|
+
|
|
24
|
+
- **启动前体检补上两类会让推进白跑一轮的问题,驾驶员一次列全缺的答案文件**(Wue specs8 T-001:体检通过后,推进先后因缺 `qa-assess.json`、缺 `documentation-inspect.json`、缺 `--browser-qa` 各停一次):`cm-start-check` 新增第 5 项,启用 QA 且 feature 有交互式用例时缺少或误用 `--browser-qa` 报 error `browser_qa_declaration`(与宿主启动时同一判断);advance 会反问而答案目录里缺的文件报 error `answers_missing`,一次列全。驾驶员缺多个答案文件时也一次列出,不再每次只报第一个。
|
|
25
|
+
|
|
26
|
+
- **被忽略的大构建目录不再拖垮审查清单,启动体检提前报出**(Wue specs8:代码根下被 Git 忽略的 `.artifacts/` 有 67 GB,列出其中 `AGENTS.md` 的 git 查询要 11 秒,超过原 10 秒限时;查询失败后忽略规则整体作废,整棵构建目录被算进审查清单,超过 1 GiB 上限,运行在开发答案写完后才被拒):读取忽略规则的 git 查询限时提到 120 秒(`GIT_IGNORE_TIMEOUT_MS`)。`cm-start-check` 新增第 4 项:按运行时同样的规则采一次审查基线,超出清单上限时报 error `review_inventory_limit` 并给出路径,其他采集失败报 warn。
|
|
27
|
+
|
|
28
|
+
- **单条日志记录上限从 1 MiB 提到 4 MiB**(Wue specs8:收集箱 T-001 改了 33 个文件,审查包要存每个文件改前改后的全文,约 1.17 MB,开发回合在写检查点时就被拒,自动流程走不下去):`JOURNAL_PAYLOAD_LIMIT` 现为 4 MiB,存储、追加预算、审查包材料归档与旧格式解包同用这一个值。同时修复两处误标:非修复流程的大记录(超过 1 MiB)此前也被打上修复流程专用的存储编码标记,现在只有修复流程才标。测试可用 `CM_JOURNAL_PAYLOAD_LIMIT_TEST` 把上限调低(只允许 64 KiB 到 4 MiB 之间、只能调低),用来在 1 MiB 下复现原来的边界用例。运行器构造记录时(`runnerPayload`/`runnerPayloadV3`/`boundRunnerRecord`)原来沿用通用 JSON 校验的 1 MiB 默认值,超过 1 MiB 的开发检查点在存储操作内被拒,整个运行被记成 `store_failure`;现在与存储同用这个上限;只读发现路径(`readExecutionSnapshot`,驾驶员每次推进先走它)和任务提交时的逐条核对也改用同一上限,原来写死的 1 MiB 让第 2 轮推进直接报 `limit_exceeded`。超过 1 MiB 的审查包只存一份材料归档、之后的检查点引用它,避免两轮审查加完成时整份 16 MiB 状态在任务提交后才写满(Codex 审查);不支持材料归档的运行(批量、并行、bootstrap 等)仍按原 1 MiB 在开发交付前拒绝。
|
|
29
|
+
|
|
30
|
+
- cm-ai 开发中途补规格不再每次都要用户回复「开始」:tasks.md 只追加版本行时直接换绑;只补任务范围、为已有验收标准补任务或新增用例时,由独立审查者审过后生效并通知用户;改需求、设计、已有用例或已完成任务仍要用户本人批准。新入口 `scripts/cm-spec-amend.mjs`,批准时可用 `--no-spec-amend` 关闭。
|
|
31
|
+
|
|
32
|
+
- **标为 NOT_APPLICABLE 的验收条目不再要求用例覆盖(自检规则 5)**(Wue specs8:AC-012 写明「NOT_APPLICABLE:本期不做(依据)」,规格自检仍报 `acceptance_test_coverage_missing`,规格变更提交不了):编号后紧跟 `NOT_APPLICABLE`(可隔冒号)的条目仍是已声明编号、可被用例引用,但从规则 5(任务语法 3 的会话)或规则 6(仍按任务语法 2 发布的规格目录开新会话时绑定,即规则 3 加此豁免)起不计入覆盖要求;规则 1–4 的历史报告与已记录的旧会话按原语义重算不变,规则 5 保存的范围记录让后续复查沿用豁免。标记只认严格 Markdown 围栏外的(结束围栏后只许空格或制表符);同编号另有普通声明时不豁免。必验合同不再从不适用条目的依据推断设备、基线等执行义务。
|
|
33
|
+
|
|
34
|
+
- **任务范围接受带方括号的文件名**(Wue specs8:expo-router 动态路由 `app/reminder/[id].tsx` 被当成通配符拒绝,相关任务生成不了运行定义):范围是精确文件清单,交给 git 的地方都按字面路径处理,所以方括号现在按字面文件名接受;`*`、`?` 仍拒绝。
|
|
35
|
+
|
|
36
|
+
- **修复大 feature 无法做规格变更**(Wue specs8:收集箱四件套约 94 KB,连只改用例格式的变更都在 `change_tasks` 报 `limit_exceeded`):变更任务阶段的回包现在可以省略已有 feature 未改动的文档,需求/设计按前两阶段已接受的原字节补回,`tasks.md` 与 `testCasesReason` 为 null 时的 `test-cases.json` 按原稿补回;64 KiB 上限只算实际回的文档,回包本身仍封顶 64 KiB。省略过去本就是无效回包,原本合法的回包含义不变;新 feature 仍须完整,删除用例合同仍须写非 null 的 `testCasesReason`。主机与驾驶员预检走同一补回逻辑。
|
|
37
|
+
|
|
38
|
+
- **新增用户维护文件声明**(AI潮 specs7:用户按项目规则手工提交 `Baseline/glass-verdicts.json`,已完成运行补开 QA 后永远报未经审查的改动):代码根可放 `.cm-user-maintained.json`(`{"version":1,"paths":[...]}`)逐个声明用户手工维护的文件。没有已接受 QA 修复的已完成运行接续后续已审交付时,这些文件和声明本身像项目根 CM 配置一样被容忍,但只限运行自身范围外(大小写不敏感);其他路径、QA 修复链与集成接纳照旧严格。只收相对普通文件路径,按审查清单的路径规则拒绝目录、通配、`.git/`、`.env`、`AGENTS.md`/`CLAUDE.md`、CM 配置和重复项;声明须在审查清单内(不能被忽略规则排除),读取后到比对前被替换即拒绝;声明无效时什么都不容忍,并在 `reason` 里说明。没写入 journal:容忍判定发生在只读的状态核对里,可追溯来源是代码根这份声明文件本身。
|
|
39
|
+
|
|
40
|
+
- **修复已完成运行误报未经审查的改动**(AI潮 specs7:补开 QA 后三个 feature 的末任务停在 `correction_review_required`):接续后续已审交付时,「同一任务」原来只看任务编号,而各 feature 都从 T-001 编号,别的 feature 的同编号任务交付被当成替代运行丢掉,接续链断开。现在按 feature 的 `tasks.md` 加任务编号判断;同一 feature 的替代运行仍不采纳,缺 `tasks.md` 记录的旧运行保持原来的保守排除。
|
|
41
|
+
|
|
42
|
+
- **修正 QA 恢复文档的过时说法**(AI潮 specs7:五个 feature 的末任务都停在 qa_triggered,按旧说法以为无法收尾):`js-host-qa-recovery.md` 的「补挂 QA」与「项目收尾」两节曾写 v2 没有补开 QA 的入口,与 0.18.0 起已有的「已完成运行补开 QA」不符;现改为指向该入口并写明前提。代码行为不变。
|
|
43
|
+
|
|
8
44
|
## 0.20.0 — 2026-11-02
|
|
9
45
|
|
|
10
46
|
- **必验合同与完成范围**:明确写有必验标记的新运行将本任务及关联 AC/用例冻结为合同,预览与实际门禁同源。完成摘要分别显示任务、功能、项目、运行、人工验收声明和部署声明。声明是绑定候选与证据的本地记录,不等于实际部署或授权。
|
package/README.md
CHANGED
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
|
|
18
18
|
## 最近更新
|
|
19
19
|
|
|
20
|
+
**0.21.1**
|
|
21
|
+
|
|
22
|
+
- **接近存档上限的任务提交可以正常读回**:单条存档上限放到 4 MiB 后,任务提交记录读取时仍按 1 MiB 校验,超过 1 MiB 的提交写得进却读不回;现在读写同用一个上限。
|
|
23
|
+
- **技能交接不再被否定句和引号误触发**:「不要换个会话」这类说法和引号里的词不再触发交接。详见[更新日志](CHANGELOG.md)。
|
|
24
|
+
|
|
25
|
+
**0.21.0**
|
|
26
|
+
|
|
27
|
+
- **开发中途补规格分级生效**:只给 tasks.md 追加「范围与验收不变」这类纯声明的版本记录直接换绑;补任务范围、为已有验收标准补任务或新增用例,由独立审查者审过后生效并通知你;改需求、设计、已有用例或已完成任务,仍要你回复「开始」。改变已有任务验收的版本说明一律按改需求处理。
|
|
28
|
+
- **大任务不再卡在存档上**:单条运行存档上限从 1 MiB 提到 4 MiB;超过 1 MiB 的审查包只存一份、后续步骤引用它。批量、并行等不支持归档的运行仍按 1 MiB 在交付前拦下。
|
|
29
|
+
- **启动前体检报得更全**:缺答案文件一次列全,多余的浏览器 QA 声明、缺重开目标、被忽略的大构建目录都在开跑前报出;宿主心跳与启动期限放宽,大代码根下不再被误判卡死。
|
|
30
|
+
- **规格自检与收尾修复**:标为 NOT_APPLICABLE 的验收条目不再要求用例覆盖,任务范围接受带方括号的文件名,大 feature 的规格变更只算实际改动的文档。详见[更新日志](CHANGELOG.md)。
|
|
31
|
+
|
|
20
32
|
**0.20.0**
|
|
21
33
|
|
|
22
34
|
- **必验合同(需手动启用)**:在任务、关联 AC 或用例里写 `必验:`、`必跑测试:`、`必跑检查:` 等明确标记,新运行就会冻结这份必验清单,开发报告必须逐条作答,完成前核对证据。没写标记的旧规格照旧运行。
|
|
@@ -269,7 +281,7 @@ $cm-check
|
|
|
269
281
|
|
|
270
282
|
仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
|
|
271
283
|
|
|
272
|
-
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.
|
|
284
|
+
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.21.1 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
|
|
273
285
|
|
|
274
286
|
## 升级旧版本
|
|
275
287
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.21.1
|
package/docs/installation.md
CHANGED
|
@@ -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.
|
|
79
|
+
To pin a version, use `npx @aibyzero/cm-workflow@0.21.1 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`.
|
|
@@ -310,7 +310,7 @@ const result = await generateCmInitRules(
|
|
|
310
310
|
仅 scope、requirements 及 AGENTS.md 保存正文。范围外图片或视频也逐块计算摘要,新增、删除、
|
|
311
311
|
改名、改权限和正文变化仍阻断审查。正文保持每文件 1 MiB、合计 2 MiB、最多 256 文件;
|
|
312
312
|
摘要清单最多 10,000 文件、累计扫描 1 GiB,序列化基线最多 8 MiB,超限明确失败。
|
|
313
|
-
|
|
313
|
+
宿主现有单条持久记录上限(普通流程 4 MiB,cm-fix 未压缩载荷 1 MiB)等门限仍适用;这不是任意规模仓库保证。
|
|
314
314
|
已保存 V1 基线继续按原格式、容量和摘要核验,不迁移或重写历史审查凭据。
|
|
315
315
|
- 不读取凭证,不加载任意 JS 模块,不接受 shell command 或自报审批字段。
|
|
316
316
|
- 已有 tasks.md、Review 和 Learning 文件不被控制入口直接修改;`serve` 会创建运行控制记录与锁。
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# 规格补正分级批准
|
|
2
|
+
|
|
3
|
+
状态:已实现(`runtime/js/cm-ai/spec-amendment.mjs`、`scripts/cm-spec-amend.mjs`);Codex(gpt-6.1-sol high)四轮审查,第 4 轮 approved。
|
|
4
|
+
|
|
5
|
+
## 问题
|
|
6
|
+
|
|
7
|
+
开发中途每改一次规格,CM 都把批准作废,要用户本人再回「开始」。
|
|
8
|
+
|
|
9
|
+
依据:2026-11-03 至 11-04 两个会话,共 17 次「开始」,16 次因改规格。
|
|
10
|
+
|
|
11
|
+
| 会话 | 「开始」次数 | 因改规格 |
|
|
12
|
+
| ---- | ---- | ---- |
|
|
13
|
+
| wue `76c1afb5` | 5 | 5 |
|
|
14
|
+
| aihot-dev `0e1fcd44` | 12 | 11 |
|
|
15
|
+
|
|
16
|
+
现行规则出处:`skills/cm-prd/references/change-mode.md` 末尾「审批位重置」;
|
|
17
|
+
`runtime/js/cm-ai/cm-ai-admission.mjs` 的 `admissionFor`(`awaiting_review` 或 manifest 不符即停)。
|
|
18
|
+
|
|
19
|
+
## 16 次改规格的分类
|
|
20
|
+
|
|
21
|
+
| 类别 | 例子 | 次数 | 真需要用户吗 |
|
|
22
|
+
| ---- | ---- | ---- | ---- |
|
|
23
|
+
| A 机械修正 | 说明写进了「范围」行;范围路径根目录写错 | 2 | 不需要 |
|
|
24
|
+
| B 执行内补漏 | 测试文件补进任务范围;为已有验收标准补修复任务;拆文件;拆检查分工 | 9 | 不需要,事后知道即可 |
|
|
25
|
+
| C 产品决定 | 首次批准;新功能;确认设计稿;改视觉基准;删接口别名 | 5 | 需要 |
|
|
26
|
+
|
|
27
|
+
结论:约 11 次可以不停。
|
|
28
|
+
|
|
29
|
+
## 方案:三级
|
|
30
|
+
|
|
31
|
+
### 0 级:只追加版本记录,自动生效
|
|
32
|
+
|
|
33
|
+
条件:只有 tasks.md 变了,且只是在标题含「版本」的表格里追加了行(空行不计)。
|
|
34
|
+
|
|
35
|
+
动作:重算 manifest,记入快照的补正记录,不停。说明或范围的任何改写都算 1 级。
|
|
36
|
+
|
|
37
|
+
### 1 级:执行内补正,Codex 审过即生效
|
|
38
|
+
|
|
39
|
+
条件全部满足(机器判定,不靠模型自报):
|
|
40
|
+
|
|
41
|
+
- `requirements.md` 未变;
|
|
42
|
+
- `design.md` 未变;
|
|
43
|
+
- `test-cases.json` 只新增用例;已有用例和文件头部逐字不变;
|
|
44
|
+
- `tasks.md` 已完成任务逐字不变;
|
|
45
|
+
- `tasks.md` 只允许三种变化:新增任务、扩大未完成任务的范围、拆分未完成任务;
|
|
46
|
+
- 新增任务必须引用已有验收标准编号;
|
|
47
|
+
- 本 feature 自批正 ≤3 次(第 4 次起升为 2 级)。
|
|
48
|
+
|
|
49
|
+
动作:
|
|
50
|
+
|
|
51
|
+
1. 另一个新上下文的审查者(按宿主规则,本机为 Codex)审查本次规格差异,只判「是否越出上面条件、是否削弱验收」;
|
|
52
|
+
2. 审查输出最后一行的 JSON 必须带本次差异摘要且判 approved,才写新 manifest;补正记录写进快照;
|
|
53
|
+
3. 宿主在下一条消息告诉用户改了什么,不等回复;
|
|
54
|
+
4. 在途运行走现有 `spec_rebind` 换绑。
|
|
55
|
+
|
|
56
|
+
### 2 级:仍要用户回「开始」
|
|
57
|
+
|
|
58
|
+
不满足 1 级的任何改动,包括:改需求或验收标准、改设计、删或弱化用例、改视觉基准、作废任务。
|
|
59
|
+
|
|
60
|
+
## 授权从哪来
|
|
61
|
+
|
|
62
|
+
首次批准时,摘要卡加一行:
|
|
63
|
+
|
|
64
|
+
> 执行中的补漏(不改需求、设计和验收标准)由 Codex 审后自动生效,你会收到通知。
|
|
65
|
+
|
|
66
|
+
用户回「开始」即同时授权 1 级。批准时加 `--no-spec-amend` 可关掉,回到现行逐次批准。
|
|
67
|
+
|
|
68
|
+
## 实现要点
|
|
69
|
+
|
|
70
|
+
- 批准时先删旧快照,再写状态,再保存 `{SPECS_DIR}/.cm-specs-approved.json` 快照(manifest 只存哈希,无法比对差异);快照写失败时没有快照,一律 2 级;
|
|
71
|
+
- 快照带自身摘要,被单独改过即无效。状态为 approved 时,快照还必须等于已批准 manifest 且属于同一次人工批准(`approval.at` 相同),否则 2 级;
|
|
72
|
+
- 另在规格目录之外记一份批准台账:`${CM_WORKFLOW_HOME:-~/.cm-workflow}/spec-approvals/{规格目录路径哈希}.json`,记最近一次批准轮次与当前快照字节的哈希。人工批准和换绑都先作废它,全部写完才重写;中途失败就没有台账,一律 2 级。恢复规格目录的旧备份或 git 旧版本时,旧快照与台账不符,一律 2 级;
|
|
73
|
+
- 已知缺口:有人同时改回规格目录和用户目录下的台账时识别不出,保障级别同 `.cm-specs-status` 本身;
|
|
74
|
+
- 人工批准与补正换绑共用 `{SPECS_DIR}/.cm-specs-approval.lock`。人工批准在锁内重查状态字节和准入结果,期间已有别的批准落盘就拒绝;换绑在状态改名前再核对状态、快照、轮次文件和规格字节,cm-prd 并发写入时拒绝;
|
|
75
|
+
- `prepare` 的审查副本取自分级时冻结的同一份字节;另把涉及 feature 中未改动的规格文件放进 `context/` 供对照(实跑教训:wue v4 补正是让任务对齐设计,审查者看不到设计就判断不了);
|
|
76
|
+
- `scripts/cm-spec-amend.mjs`:`inspect` 只读分级,`prepare` 写出批准时/现在两份副本和审查提示,`apply` 换绑;
|
|
77
|
+
- 换绑时先写 `.cm-specs-status` 再写快照;快照写失败时两者不符,下次自动退回 2 级;
|
|
78
|
+
- 只改 cm-ai 一侧(N1、js-host、准入)。cm-prd 的「审批位重置」不动,按流程隔离原则由 cm-ai 读取它落盘的 `awaiting_review` 后再分级;
|
|
79
|
+
- 夹具 `scripts/cm-spec-amend.test.mjs`:每个 1 级条件各一条「越界即升 2 级」的反例。
|
|
80
|
+
|
|
81
|
+
## 实跑(2026-11-04,wue 副本,未写 wue)
|
|
82
|
+
|
|
83
|
+
用 wue 会话留下的任务清单备份逐次重放:
|
|
84
|
+
|
|
85
|
+
| 当时回「开始」 | 改动 | 分级 |
|
|
86
|
+
| ---- | ---- | ---- |
|
|
87
|
+
| 14:00 | 首次批准 | — |
|
|
88
|
+
| 15:02 | v3:手动勾掉任务、改设计 | 2 |
|
|
89
|
+
| 16:19 | 说明挪出「范围」行 | 1 |
|
|
90
|
+
| 16:37 | 范围路径改为相对代码根 | 1 |
|
|
91
|
+
| 16:53 | v4:T-003 直接删旧字体别名 | 1 |
|
|
92
|
+
| 之后 | v5:改设计 | 2 |
|
|
93
|
+
|
|
94
|
+
只打勾不算改动。v4 由全新上下文审查者对照 `context/` 设计判 approved,换绑后准入不再报 spec_drift,批准记录仍是原「开始」。
|
|
95
|
+
|
|
96
|
+
## 不在本方案内
|
|
97
|
+
|
|
98
|
+
- 批准口令仍只认「开始」,不放宽「可以」;
|
|
99
|
+
- 在本功能上线前批准的规格没有快照,下一次补正仍要回一次「开始」;
|
|
100
|
+
- 审查两轮上限、重开只许一条旧运行等工具自身卡点,另行处理。
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Shared wording rules for "does this spec text state or weaken an acceptance
|
|
2
|
+
// obligation". The standing authorization (autonomy.mjs) and tiered spec
|
|
3
|
+
// amendment (cm-ai/spec-amendment.mjs) must judge version notes the same way.
|
|
4
|
+
export const taskNames=body=>body.match(/(?<![A-Za-z0-9])T-[A-Za-z0-9][A-Za-z0-9._-]*/g)??[];
|
|
5
|
+
export const acceptanceLanguage=body=>/验收|必验|必跑|必须|要求|真机|物理设备|physical[- ]device|\b(?:must|required|shall|acceptance)\b/i.test(body);
|
|
6
|
+
export const weakensLanguage=body=>/取消|无需|不再|改为|可忽略|即可|延期|\b(?:optional|instead|waiv(?:e|ed)|no longer|not required|previous)\b/i.test(body);
|
|
7
|
+
// Version notes are read with full-width letters, digits and dashes as ASCII
|
|
8
|
+
// (T-002, T-002), so an id cannot hide behind its full-width form.
|
|
9
|
+
export const versionNote=text=>String(text).normalize('NFKC');
|
|
10
|
+
// Whether a version note is nothing but explicit "unchanged" statements, such as
|
|
11
|
+
// 范围与验收不变, 行为与验收不变, 检查与断言不放宽, 无其他改动 (dogfood: real version
|
|
12
|
+
// tables write these on most rows). The whole note must consist of them: any other
|
|
13
|
+
// wording, including wording no list foresees, is not plain. This is a positive
|
|
14
|
+
// grammar, not a list of forbidden words (review: synonyms and negations slip past lists).
|
|
15
|
+
const STATEMENT=/^(?:(?:范围|行为|验收|检查|断言|用例|文案|测试|设计|其余|其他)(?:[与和及、]|\s)*)+(?:均|都|也)?(?:不变|不放宽|未改动?)$|^无其他改动$|^(?:no other changes?|scope and acceptance unchanged|unchanged)$/i;
|
|
16
|
+
// A version table row (| 日期 | 版本 | 说明 |) is judged by its description, the last cell.
|
|
17
|
+
const description=text=>{
|
|
18
|
+
const note=versionNote(text).trim();
|
|
19
|
+
if(!note.startsWith('|'))return note;
|
|
20
|
+
const cells=note.split('|').map(cell=>cell.trim()).filter(Boolean);
|
|
21
|
+
// The other cells may only be dates and version labels; anything else is not plain.
|
|
22
|
+
if(cells.slice(0,-1).some(cell=>!/^(?:\d{4}-\d{1,2}-\d{1,2}|v\d+(?:\.\d+)*)$/i.test(cell)))return null;
|
|
23
|
+
return cells.at(-1)??'';
|
|
24
|
+
};
|
|
25
|
+
export const plainVersionNote=text=>{
|
|
26
|
+
const note=description(text);if(note===null)return false;
|
|
27
|
+
const parts=note.replace(/[。.;;,,\s]+$/u,'').split(/\s*[,,;;。]\s*/u);
|
|
28
|
+
return parts.length>0&&parts.every(part=>STATEMENT.test(part));
|
|
29
|
+
};
|
|
30
|
+
// Wording about tests or acceptance anywhere in a note, read broadly. The standing
|
|
31
|
+
// authorization stops for a version note that uses it unless the note is plain.
|
|
32
|
+
export const testingLanguage=body=>/验收|必验|必跑|必须|要求|真机|设备|断言|测试|检查|用例|门槛|状态码|覆盖|只需|仅测|只测|跳过|免跑|免测|不跑|不测|放宽|降低|成功路径|失败场景|\b(?:tests?|assert|accept|acceptance|check|verify|skip|omit|sufficient|relax|waive|scenario|required|must)\b/i.test(versionNote(body));
|
package/runtime/js/autonomy.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import {randomUUID,createHash} from 'node:crypto';
|
|
|
11
11
|
import {taskLines,TASK_GRAMMAR,recordedTaskGrammar,specLines} from './spec-task-line.mjs';
|
|
12
12
|
import {validateTestCases} from '../../scripts/validate-test-cases.mjs';
|
|
13
13
|
import {declaredAcceptanceIds,DEPENDENCY} from './cm-ai/cm-ai-admission.mjs';
|
|
14
|
+
import {taskNames,acceptanceLanguage,weakensLanguage,versionNote,plainVersionNote,testingLanguage} from './acceptance-language.mjs';
|
|
14
15
|
|
|
15
16
|
export const AUTONOMY_FILE='autonomy.json',AUTONOMY_OFF_FILE='autonomy.off.json',REOPEN_DIR='autonomy-reopens',AUTO_REOPEN_LIMIT=2;
|
|
16
17
|
// Same directory as notify.json (notify.mjs notifyHome); kept here so notify.mjs can import this module.
|
|
@@ -107,9 +108,6 @@ const includesAll=(after,before)=>before.every(value=>after.includes(value));
|
|
|
107
108
|
const versionHeading=/^(?:任务版本|设计版本|版本历史|版本记录|变更记录|Version history)$/i;
|
|
108
109
|
const versionRow=/^\|[^\r\n]*\bv\d+\b[^\r\n]*\|\s*$/;
|
|
109
110
|
const indent=body=>/^[ \t]*/.exec(body)[0].length;
|
|
110
|
-
const taskNames=body=>body.match(/(?<![A-Za-z0-9])T-[A-Za-z0-9][A-Za-z0-9._-]*/g)??[];
|
|
111
|
-
const acceptanceLanguage=body=>/验收|必验|必跑|必须|要求|真机|物理设备|physical[- ]device|\b(?:must|required|shall|acceptance)\b/i.test(body);
|
|
112
|
-
const weakensLanguage=body=>/取消|无需|不再|改为|可忽略|即可|延期|\b(?:optional|instead|waiv(?:e|ed)|no longer|not required|previous)\b/i.test(body);
|
|
113
111
|
|
|
114
112
|
function protectedRows(source,{grammar=TASK_GRAMMAR,priorIds=null,tasks=false}={}){
|
|
115
113
|
const rows=[],ids=new Set(),declarations=[];let owner=null,ownerIndent=0,historyLevel=null;
|
|
@@ -154,7 +152,14 @@ function documentProblem(before,after,file,grammar){
|
|
|
154
152
|
const protectedDesign=old.rows.some(row=>row.fenced||acceptanceLanguage(row.text));
|
|
155
153
|
// No task/AC contract is built from design-only implementation details.
|
|
156
154
|
// Keep explicit legacy acceptance statements and examples protected.
|
|
157
|
-
|
|
155
|
+
// A newly added design version note about tests or acceptance still reaches the
|
|
156
|
+
// history check below; notes already in the approved design do not.
|
|
157
|
+
// Matched by count, so a duplicated or copied-over approved note counts as new.
|
|
158
|
+
const approvedNotes=new Map();
|
|
159
|
+
for(const row of old.rows)if(row.history)approvedNotes.set(row.text,(approvedNotes.get(row.text)??0)+1);
|
|
160
|
+
const newNote=row=>{const left=approvedNotes.get(row.text)??0;if(left>0){approvedNotes.set(row.text,left-1);return false;}return true;};
|
|
161
|
+
if(!protectedDesign&&!next.rows.some(row=>acceptanceLanguage(row.text)||weakensLanguage(row.text)
|
|
162
|
+
||row.history&&newNote(row)&&!plainVersionNote(row.text)&&testingLanguage(row.text)))return null;
|
|
158
163
|
}
|
|
159
164
|
let position=0;
|
|
160
165
|
for(const row of next.rows){
|
|
@@ -163,9 +168,13 @@ function documentProblem(before,after,file,grammar){
|
|
|
163
168
|
// A history row is metadata only in an explicitly named history section;
|
|
164
169
|
// a table elsewhere may contain an obligation and is never ignored.
|
|
165
170
|
if(row.history){
|
|
166
|
-
const
|
|
167
|
-
if(affected&&(acceptanceLanguage(
|
|
171
|
+
const note=versionNote(row.text),affected=taskNames(note).find(id=>old.ids.has(id));
|
|
172
|
+
if(affected&&(acceptanceLanguage(note)||weakensLanguage(note)||testingLanguage(note)))
|
|
168
173
|
return `${file}(${affected})的版本说明改变了既有验收,需明确确认规格变更`;
|
|
174
|
+
// Without a named task, a note about tests or acceptance still cannot be shown
|
|
175
|
+
// not to weaken an obligation, unless it only states that nothing changed.
|
|
176
|
+
if(!plainVersionNote(note)&&testingLanguage(note))
|
|
177
|
+
return `${file} 的版本说明涉及测试或验收,无法证明验收未减弱,需明确确认规格变更`;
|
|
169
178
|
continue;
|
|
170
179
|
}
|
|
171
180
|
if(!tasks&&!row.fenced&&!acceptanceLanguage(row.text)&&!weakensLanguage(row.text))continue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Free text remains verbatim for independent review; the machine proves set and
|
|
3
3
|
// evidence-kind agreement, not that arbitrary prose or test assertions are true.
|
|
4
4
|
import {digest,need,shape,freeze} from './effect-contract.mjs';
|
|
5
|
-
import {declaredAcceptanceIds} from './cm-ai-admission.mjs';
|
|
5
|
+
import {declaredAcceptanceIds,acceptanceDeclarations} from './cm-ai-admission.mjs';
|
|
6
6
|
import {taskLines} from '../spec-task-line.mjs';
|
|
7
7
|
import {mandatoryCheckCoverage} from '../check-coverage.mjs';
|
|
8
8
|
import {selectedNodeTestFiles} from '../node-test-selection.mjs';
|
|
@@ -146,11 +146,16 @@ export function buildAcceptanceContract({taskId,taskText,requirementsText,testCa
|
|
|
146
146
|
for(const {body,fenced} of taskLines(taskText))add(`task:${taskId}`,body,null,fenced);
|
|
147
147
|
const linked=new Set(taskText.match(/\bAC-\d{3,}\b/g)??[]);
|
|
148
148
|
for(const item of testCases)for(const id of item.acIds??[])linked.add(id);
|
|
149
|
-
const declared=new Set();let owner=null,ownerIndent=0;
|
|
149
|
+
const declared=new Set();let owner=null,ownerIndent=0,ownerInapplicable=false;
|
|
150
150
|
for(const {body:line,fenced} of taskLines(requirementsText)){
|
|
151
151
|
const match=fenced?[]:[...declaredAcceptanceIds(line)],indent=/^[ \t]*/.exec(line)[0].length;
|
|
152
|
-
|
|
152
|
+
// An item marked NOT_APPLICABLE right after its id stays declared (cases may link it) but its
|
|
153
|
+
// block states why it is excluded, not a duty: inferring "真机"/baseline evidence from the
|
|
154
|
+
// reason would turn the exclusion back into an execution obligation.
|
|
155
|
+
if(match.length){owner=match[0];ownerIndent=indent;declared.add(owner);
|
|
156
|
+
ownerInapplicable=acceptanceDeclarations(line).some(item=>item.id===owner&&item.inapplicable);}
|
|
153
157
|
else if(line.trim()&&indent<=ownerIndent)owner=null;
|
|
158
|
+
if(owner!==null&&ownerInapplicable)continue;
|
|
154
159
|
// Only explicitly linked AC blocks and explicit shared directives are duties.
|
|
155
160
|
// An indented heading never cuts off an AC's environment/expected subclauses.
|
|
156
161
|
if(owner!==null&&linked.has(owner)||owner===null&&/^\s*(?:Shared|共用必验)[::]/i.test(line))add(owner??'requirements:shared',line,null,fenced);
|
|
@@ -5,6 +5,8 @@ import {digest,json,shape,need,hex,id,validIdentity,freeze,JOURNAL_PAYLOAD_LIMIT
|
|
|
5
5
|
|
|
6
6
|
const INVALID='checkpoint_package_material_invalid',STATE_LIMIT=16*1024*1024;
|
|
7
7
|
const MARKER_ALLOWANCE=1024,REFERENCE_ALLOWANCE=512;
|
|
8
|
+
// The record budget before it was raised to 4 MiB; see checkpointPackageBudget.
|
|
9
|
+
export const INLINE_PACKAGE_LIMIT=1024*1024;
|
|
8
10
|
const must=condition=>need(condition,INVALID);
|
|
9
11
|
const guarded=run=>{try{return run();}catch(error){if(error?.code===INVALID)throw error;throw Object.assign(new Error(INVALID),{code:INVALID});}};
|
|
10
12
|
const size=value=>Buffer.byteLength(JSON.stringify(value));
|
|
@@ -129,7 +131,14 @@ export function checkpointPackageBudget({inlineBytes,packageBytes,reserve,enable
|
|
|
129
131
|
must([inlineBytes,packageBytes,reserve].every(v=>Number.isSafeInteger(v)&&v>=0)
|
|
130
132
|
&&packageBytes<=inlineBytes&&reserve<JOURNAL_PAYLOAD_LIMIT&&typeof enabled==='boolean'&&typeof referenced==='boolean');
|
|
131
133
|
const budget=JOURNAL_PAYLOAD_LIMIT-reserve;
|
|
132
|
-
|
|
134
|
+
// A package repeats in every later checkpoint unless archived once. The whole
|
|
135
|
+
// state stays 16 MiB, so packages above the original 1 MiB record budget go to
|
|
136
|
+
// a material archive however large the record limit is (a 3.6 MB package
|
|
137
|
+
// repeated through two review rounds overflows the state after the task
|
|
138
|
+
// commit). Runs without archives keep that original inline budget and are
|
|
139
|
+
// refused before develop is accepted, as before the record limit was raised.
|
|
140
|
+
const inline=Math.max(0,Math.min(JOURNAL_PAYLOAD_LIMIT,INLINE_PACKAGE_LIMIT)-reserve);
|
|
141
|
+
if(!enabled||!referenced&&inlineBytes<=inline)return freeze({fits:inlineBytes<=inline,material:false,bytes:inlineBytes,budget:inline});
|
|
133
142
|
const bytes=inlineBytes-packageBytes+REFERENCE_ALLOWANCE,material=!referenced;
|
|
134
143
|
return freeze({fits:bytes<=budget&&(!material||inlineBytes+MARKER_ALLOWANCE<=JOURNAL_PAYLOAD_LIMIT),material,bytes,budget});
|
|
135
144
|
});}
|
|
@@ -145,8 +154,9 @@ export function checkpointStoragePlan({records:rawRecords,effectId,checkpoint:ra
|
|
|
145
154
|
const ref=findReference(records,pkg,identity);
|
|
146
155
|
// Develop reserved the later checkpoints before accepting its inline package.
|
|
147
156
|
// Those later records enforce their actual limit, not that future reserve again;
|
|
148
|
-
// a review or completion
|
|
149
|
-
|
|
157
|
+
// a review or completion (including a reconciled review invocation) cannot
|
|
158
|
+
// introduce a first material archive.
|
|
159
|
+
if(!ref&&['review','complete'].includes(effect.kind)){
|
|
150
160
|
must(size(payload)<=JOURNAL_PAYLOAD_LIMIT);return freeze({checkpoint,payloadFields:{}});
|
|
151
161
|
}
|
|
152
162
|
const budget=checkpointPackageBudget({inlineBytes:size(payload),packageBytes:size(pkg),reserve,enabled,referenced:ref!==null});
|
|
@@ -8,6 +8,7 @@ import {readSpecsStatus,writeSpecsStatus} from '../specs-status.mjs';
|
|
|
8
8
|
import {readAutonomy,standingArchiveProblem} from '../autonomy.mjs';
|
|
9
9
|
import {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
|
|
10
10
|
import {buildManifest,verifyApprovedManifest} from '../../../scripts/cm-spec-manifest.mjs';
|
|
11
|
+
import {writeApprovalSnapshot,removeApprovalSnapshot,withApprovalLock} from './spec-amendment.mjs';
|
|
11
12
|
import {outstandingFeatureQa,describeOutstandingQa} from './project-qa-gate.mjs';
|
|
12
13
|
import {taskLines,taskDeclarations,approvedTaskGrammar,recordedTaskGrammar,TASK_GRAMMAR,SHARED_TASK_GRAMMAR,LEGACY_TASK_GRAMMAR,TASK_ID_SOURCE,isTaskId} from '../spec-task-line.mjs';
|
|
13
14
|
export {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
|
|
@@ -216,6 +217,13 @@ function readFeature(specsDir,name){
|
|
|
216
217
|
export function declaredAcceptanceIds(source){
|
|
217
218
|
return new Set(source.split(/\r?\n/).map(line=>line.match(ACCEPTANCE)).filter(Boolean).map(match=>match[1]||match[2]));
|
|
218
219
|
}
|
|
220
|
+
// 每条验收声明一行:{id, inapplicable}。紧跟编号写明 NOT_APPLICABLE(可隔冒号,如
|
|
221
|
+
// `- [ ] [AC-012] NOT_APPLICABLE:…(依据)`)的条目 inapplicable 为真;正文顺带提到的不算。
|
|
222
|
+
// 调用方自己决定围栏与同编号冲突的处理(Wue specs8 AC-012,2026-11-14)。
|
|
223
|
+
export function acceptanceDeclarations(source){
|
|
224
|
+
return source.split(/\r?\n/).map(line=>{const match=line.match(ACCEPTANCE);if(!match)return null;
|
|
225
|
+
return {id:match[1]||match[2],inapplicable:/^\s*[::]?\s*NOT_APPLICABLE(?=[\s::]|$)/.test(line.slice(match[0].length))};}).filter(Boolean);
|
|
226
|
+
}
|
|
219
227
|
|
|
220
228
|
// Shared declaration grammar (spec-task-line.mjs), versioned by the approval.
|
|
221
229
|
export function parseFeatureTaskText(source,{allowDependencyPunctuation=false,grammar=TASK_GRAMMAR}={}){
|
|
@@ -438,7 +446,18 @@ export function approveCmAiSpecs(options){
|
|
|
438
446
|
throw Object.assign(new Error('revision_changed_during_approval'),{code:'revision_changed_during_approval'});
|
|
439
447
|
}};
|
|
440
448
|
}
|
|
441
|
-
|
|
449
|
+
let specAmend;
|
|
450
|
+
// Runs under the approval lock shared with spec amendment re-binding. The decision
|
|
451
|
+
// rests on the status bytes validated above; it is void if another approval or
|
|
452
|
+
// publication replaced them since (inspect is re-run below for the rest).
|
|
453
|
+
const decidedStatus=status.bytes??null;
|
|
454
|
+
const write=()=>{
|
|
455
|
+
let now=null;
|
|
456
|
+
try{now=fs.readFileSync(path.join(specsDir,'.cm-specs-status'));}catch{}
|
|
457
|
+
if(!(decidedStatus===null?now===null:now!==null&&decidedStatus.equals(now)))
|
|
458
|
+
return refuse(bound?'revision_changed_during_approval':'spec_status_changed_during_approval');
|
|
459
|
+
if(inspect().some(item=>item.state!=='awaiting_spec_approval'||!allowed.has(item.reason)))
|
|
460
|
+
return refuse('spec_status_changed_during_approval');
|
|
442
461
|
const discovered=discoverFeatures(specsDir);
|
|
443
462
|
if(discovered.error)return refuse(discovered.error);
|
|
444
463
|
// An approval binds a shared grammar (2 or 3) to every feature, including ones this change
|
|
@@ -468,13 +487,27 @@ export function approveCmAiSpecs(options){
|
|
|
468
487
|
+'。此前的批准不把这些行当任务(或反之);是示例就放进 ``` 围栏或删去,是任务就改用英文冒号「:」写法后再批准。');
|
|
469
488
|
}
|
|
470
489
|
const specFiles=bound?bound.saved:buildManifest(specsDir),at=new Date().toISOString();
|
|
490
|
+
// Drop the previous round's snapshot first: if writing the new one fails,
|
|
491
|
+
// no older round or policy can stay in force.
|
|
492
|
+
removeApprovalSnapshot(specsDir);
|
|
471
493
|
writeSpecsStatus(specsDir,{status:'approved',summaryDigest:status.value?.summaryDigest??null,at,
|
|
472
494
|
features:discovered.names,specFiles,testCases:specFiles.filter(item=>item.path.endsWith('/test-cases.json')),
|
|
473
495
|
approval:{response:approvalResponse,at},taskGrammar:grammar,
|
|
474
496
|
...(status.value&&Object.hasOwn(status.value,'revisionDigest')?{revisionDigest:status.value.revisionDigest}:{})},
|
|
475
497
|
bound?{beforeRename:()=>bound.check()}:{});
|
|
498
|
+
// The snapshot only enables later reviewed corrections; failing to write it
|
|
499
|
+
// never undoes the human approval, it just leaves every change at tier 2.
|
|
500
|
+
try{specAmend={...writeApprovalSnapshot(specsDir,{features:discovered.names,specFiles,
|
|
501
|
+
approval:{response:approvalResponse,at},policy:options.specAmend===false?'off':'reviewed'}),snapshot:'written'};}
|
|
502
|
+
catch(error){specAmend={snapshot:'failed',reason:error.code??'spec_amend_snapshot_failed'};}
|
|
503
|
+
return null;
|
|
504
|
+
};
|
|
505
|
+
try{
|
|
506
|
+
if(typeof options._beforeApprovalLock==='function')options._beforeApprovalLock(); // test seam
|
|
507
|
+
const refused=withApprovalLock(specsDir,write);
|
|
508
|
+
if(refused)return refused;
|
|
476
509
|
}catch(error){return refuse(error.code??error.message);}
|
|
477
|
-
return {projectResults:inspect()};
|
|
510
|
+
return {projectResults:inspect(),specAmend};
|
|
478
511
|
}
|
|
479
512
|
|
|
480
513
|
function admissionFor(options,inProgressBootstrap=null){
|
|
@@ -65,11 +65,27 @@ export function buildCodexReviewPrompt(raw) {
|
|
|
65
65
|
// Shared package/prompt contract; the trusted adapter selects the provider.
|
|
66
66
|
export function buildReviewPrompt(raw,provider,executionPolicy=null) {
|
|
67
67
|
const {request,reviewPackage}=readReviewerRequest(raw,provider);
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
return presentationPrompt(reviewPromptData(reviewPackage,request.payload),INSTRUCTIONS,executionPolicy,provider);
|
|
69
|
+
}
|
|
70
|
+
function reviewPromptData(reviewPackage,payload){
|
|
71
|
+
return json({reviewPackage,priorReview:payload.priorReview,
|
|
72
|
+
...(Object.hasOwn(payload,'supersededReview')?{supersededReview:payload.supersededReview}:{}),
|
|
70
73
|
examinedPaths:reviewPaths(reviewPackage),
|
|
71
74
|
...(reviewPackage.handoff?{handoffPath:reviewPackage.handoff.path}:{})},REQUEST_LIMIT);
|
|
72
|
-
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Whether the review prompt for this package (same data and presentation the review
|
|
78
|
+
// will send) fits the reviewer's input limit. Develop asks before it accepts a
|
|
79
|
+
// delivery: a package no reviewer can take must be refused there, not left as an
|
|
80
|
+
// unknown review the run cannot redo (Codex takes at most 1 MiB of input).
|
|
81
|
+
export function reviewInputFit({reviewPackage,payload,provider,executionPolicy=null}){
|
|
82
|
+
need(['codex','claude'].includes(provider),'review_request_invalid');
|
|
83
|
+
const limit=provider==='codex'?CODEX_INPUT_LIMIT:PROMPT_LIMIT;
|
|
84
|
+
try{
|
|
85
|
+
const prompt=presentationPrompt(reviewPromptData(readReviewPackage(reviewPackage),{priorReview:null,...payload}),
|
|
86
|
+
INSTRUCTIONS,executionPolicy,provider);
|
|
87
|
+
return {fits:true,bytes:Buffer.byteLength(prompt,'utf8'),limit};
|
|
88
|
+
}catch(error){if(error?.code==='limit_exceeded')return {fits:false,bytes:null,limit};throw error;}
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
export function buildCauseReviewPrompt(raw,provider,executionPolicy=null){
|
|
@@ -80,8 +80,15 @@ export function deliberatelyUnanswered(message){
|
|
|
80
80
|
}
|
|
81
81
|
// Transport-only budgets: no field is added to a run or its configuration hash.
|
|
82
82
|
// The long fallback covers hosts that cannot advertise individual phase budgets.
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// heartbeatMs: the host beats from a timer, which cannot fire while it runs a
|
|
84
|
+
// synchronous tree capture. On a code root with a large ignored build tree one
|
|
85
|
+
// capture took 12-22 s and a develop step runs several, so 30 s killed a healthy
|
|
86
|
+
// host after it had applied the edits (Wue specs8 T-001). operationMs still
|
|
87
|
+
// bounds a host that never finishes. startupMs covers a create's baseline capture
|
|
88
|
+
// before host_ready, whose Git ignore query may take up to GIT_IGNORE_TIMEOUT_MS
|
|
89
|
+
// (120 s, review-package.mjs) plus the capture itself.
|
|
90
|
+
export const DRIVE_LIVENESS_DEFAULTS=Object.freeze({startupMs:180000,operationMs:21600000,
|
|
91
|
+
heartbeatMs:120000,graceMs:30000,closeMs:5000,killMs:1000,pollMs:250});
|
|
85
92
|
// rateLimitRetry (cm-ai drivers only, drive-rate-limit.mjs; 'batch' for the batch driver): a review the provider
|
|
86
93
|
// rate limited is redispatched by re-running this same driver command after a
|
|
87
94
|
// wait, without printing the interim result or notifying; the re-run's result is
|
|
@@ -7,7 +7,7 @@ import {readExternalModels} from './external-models.mjs';
|
|
|
7
7
|
import {beforeFirstQaRound,qaRevisionFollows,readQaConfigRevision} from './qa-config-revision.mjs';
|
|
8
8
|
import {readCloseoutPolicy} from './knowledge-closeout.mjs';
|
|
9
9
|
// Host-only S3b2b journal grammar. Data validation grants no provider authority.
|
|
10
|
-
import {digest,need,shape,id,text,hex,json,validIdentity,validTaskLearningInput,validCallTimeout,validBlockedReason,validFailureCode,requestFor,JOURNAL_REASON_LIMIT,boundedReason} from './effect-contract.mjs';
|
|
10
|
+
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
11
|
import {readReviewBaseline,readReviewPackage,reviewSpecsPath,reviewMaterialLimitReason} from './review-package.mjs';
|
|
12
12
|
import {reviewResult,reviewReceipt} from './review-runner.mjs';
|
|
13
13
|
import {checkCompletion} from './gate-bridge.mjs';
|
|
@@ -725,12 +725,20 @@ export function bootstrapReviewRecoverable(s,pending=null,configuration=null) {
|
|
|
725
725
|
}
|
|
726
726
|
// limit only widens the builder's own copy check so a caller can measure an
|
|
727
727
|
// oversized record exactly; the store still refuses it (JOURNAL_PAYLOAD_LIMIT).
|
|
728
|
-
|
|
728
|
+
// The default is the store's own record limit: json()'s 1 MiB default made the
|
|
729
|
+
// runner refuse a record the store accepts, inside the store operation, which
|
|
730
|
+
// poisons the run as store_failure (Wue specs8 T-001 develop checkpoint).
|
|
731
|
+
export const runnerPayload=(type,fields,version=1,limit=JOURNAL_PAYLOAD_LIMIT)=>{need([1,2].includes(version),'runner_version');
|
|
729
732
|
return json(version===1?{version,protocol:'cm-task-runner',type,...fields}:{...fields,version,protocol:'cm-task-runner',type},limit);};
|
|
730
|
-
export const runnerPayloadV3=(type,fields,limit=
|
|
733
|
+
export const runnerPayloadV3=(type,fields,limit=JOURNAL_PAYLOAD_LIMIT)=>json({...fields,version:3,protocol:'cm-task-runner',type},limit);
|
|
731
734
|
export function boundRunnerRecord({id,kind,payload},seq) {
|
|
732
735
|
// Exact S3a envelope width. Digest contents do not affect encoded byte count.
|
|
733
|
-
|
|
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);
|
|
741
|
+
json({version:1,seq,id,kind,payload,previousDigest:seq>1?'0'.repeat(64):null,digest:'0'.repeat(64)},JOURNAL_PAYLOAD_LIMIT+1024);
|
|
734
742
|
}
|
|
735
743
|
export function attemptBaseline(original,attempt) {
|
|
736
744
|
const {baselineDigest,...data}=original,next={...data,identity:{...original.identity,attempt}};
|
|
@@ -6,7 +6,14 @@ export const need=(ok,code='invalid_input')=>{
|
|
|
6
6
|
};
|
|
7
7
|
// One journal record payload (execution-store). Anything a record must carry,
|
|
8
8
|
// such as a review package inside a checkpoint, has to fit this, not only its own limits.
|
|
9
|
-
|
|
9
|
+
// 4 MiB:审查材料允许 2 MiB,审查包又按 base64 存改动前后两份;1 MiB 时一个改 30 来个文件的任务
|
|
10
|
+
// (Wue specs8 T-001,审查包约 1.17 MB)连外置归档也装不下(2026-11-15)。
|
|
11
|
+
// CM_JOURNAL_PAYLOAD_LIMIT_TEST 只许调小(64 KiB 起、低于默认值):边界测试用它压回 1 MiB 复现原场景;
|
|
12
|
+
// 调大或非法值一律忽略,这个开关不能放宽任何检查。
|
|
13
|
+
const JOURNAL_PAYLOAD_DEFAULT=4*1024*1024;
|
|
14
|
+
const loweredJournalLimit=Number(globalThis.process?.env?.CM_JOURNAL_PAYLOAD_LIMIT_TEST);
|
|
15
|
+
export const JOURNAL_PAYLOAD_LIMIT=Number.isSafeInteger(loweredJournalLimit)&&loweredJournalLimit>=64*1024
|
|
16
|
+
&&loweredJournalLimit<JOURNAL_PAYLOAD_DEFAULT?loweredJournalLimit:JOURNAL_PAYLOAD_DEFAULT;
|
|
10
17
|
// A develop checkpoint must leave room for the later checkpoints of the same
|
|
11
18
|
// attempt, which carry the same package again. Their growth is bounded:
|
|
12
19
|
// - the reviewer result (verdict, digest, findings, summary; examinedPaths are
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// reconstructed expected fingerprints and acquire its normal ownership lock.
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {digest,need,shape,id,hex,json} from './effect-contract.mjs';
|
|
6
|
-
import {fixJournalWorkflow,packFixJournalPayload,unpackFixJournalState} from './review-presentation.mjs';
|
|
5
|
+
import {digest,need,shape,id,hex,json,JOURNAL_PAYLOAD_LIMIT} from './effect-contract.mjs';
|
|
6
|
+
import {fixJournalWorkflow,journalPhysicalLimit,packFixJournalPayload,unpackFixJournalState} from './review-presentation.mjs';
|
|
7
7
|
export function readExecutionSnapshot({specsRoot,identity}){
|
|
8
8
|
shape(identity,['repositoryId','runId']);Object.values(identity).forEach(id);
|
|
9
9
|
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
@@ -32,7 +32,8 @@ export function readExecutionSnapshot({specsRoot,identity}){
|
|
|
32
32
|
let previous=null;const ids=new Set();
|
|
33
33
|
for(const [index,r] of v.records.entries()){
|
|
34
34
|
shape(r,['version','seq','id','kind','payload','previousDigest','digest']);id(r.id);hex(r.digest);
|
|
35
|
-
|
|
35
|
+
// Same per-record bound as the store that wrote it (execution-store.mjs).
|
|
36
|
+
need(Buffer.byteLength(JSON.stringify(packFixJournalPayload(r.payload,{workflow:fixJournalWorkflow(v)})))<=journalPhysicalLimit(v),'limit_exceeded');
|
|
36
37
|
const {digest:checksum,...body}=r;
|
|
37
38
|
need(r.version===1&&r.seq===index+1&&r.previousDigest===previous&&!ids.has(r.id)
|
|
38
39
|
&&['intent','result','cancel','commit-intent','commit-result','finalized'].includes(r.kind)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Size and count limits of the local durable record store, without the store
|
|
2
2
|
// itself (no node:sqlite import), so owners can check an append before making it.
|
|
3
|
-
import { digest,json } from './effect-contract.mjs';
|
|
4
|
-
import {fixJournalWorkflow,packFixJournalPayload,packFixJournalState} from './review-presentation.mjs';
|
|
3
|
+
import { digest,json,JOURNAL_PAYLOAD_LIMIT } from './effect-contract.mjs';
|
|
4
|
+
import {fixJournalWorkflow,journalPhysicalLimit,packFixJournalPayload,packFixJournalState} from './review-presentation.mjs';
|
|
5
5
|
|
|
6
6
|
export const MiB=1024*1024,STATE_LIMIT=16*MiB,PHYSICAL_LIMIT=32*MiB,RECORD_LIMIT=1024;
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ export function appendFits(current,input){
|
|
|
13
13
|
try{
|
|
14
14
|
const bytes=value=>Buffer.byteLength(JSON.stringify(value));
|
|
15
15
|
const entry=json(input,10*MiB),physicalPayload=packFixJournalPayload(entry.payload,{workflow:fixJournalWorkflow(current)});
|
|
16
|
-
if(bytes({...entry,payload:physicalPayload})>
|
|
16
|
+
if(bytes({...entry,payload:physicalPayload})>journalPhysicalLimit(current)+1024||current.records.length>=RECORD_LIMIT)return false;
|
|
17
17
|
const record={version:1,seq:current.records.length+1,id:entry.id,kind:entry.kind,payload:entry.payload,
|
|
18
18
|
previousDigest:current.records.at(-1)?.digest??null};
|
|
19
19
|
const {revision,...data}=current,next={...data,records:[...current.records,{...record,digest:digest(record)}]};
|