@aibyzero/cm-workflow 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +61 -0
- package/README.md +2 -2
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +8 -2
- package/docs/untested-branches.md +73 -0
- package/package.json +1 -1
- package/runtime/js/cm-ai/checklist-coverage.mjs +70 -0
- package/runtime/js/cm-ai/effect-contract.mjs +37 -3
- package/runtime/js/cm-ai/host-conversation-execution.mjs +37 -1
- package/runtime/js/cm-ai/metrics-table.mjs +22 -0
- package/runtime/js/cm-ai/review-package.mjs +29 -3
- package/runtime/js/cm-ai/task-runner.mjs +10 -4
- package/runtime/js/cm-fix/cause-invocation.mjs +17 -4
- package/runtime/js/cm-fix/execution.mjs +41 -24
- package/runtime/js/cm-fix/final-review.mjs +18 -11
- package/runtime/js/cm-fix/finish.mjs +14 -1
- package/runtime/js/cm-fix/layout.mjs +26 -0
- package/runtime/js/cm-fix/metrics.mjs +2 -4
- package/runtime/js/cm-fix/walkthrough.mjs +8 -2
- package/runtime/js/cm-refactor/workflow.mjs +3 -2
- package/runtime/js/cm-security/scan.mjs +7 -1
- package/scripts/audit-untested-enums.mjs +59 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +116 -0
- package/scripts/cm-ai-execution-diagnostic.test.mjs +25 -0
- package/scripts/cm-ai-verification-gate.test.mjs +18 -0
- package/scripts/cm-fix-cross-session-host.test.mjs +100 -0
- package/scripts/cm-fix-execution.test.mjs +74 -0
- package/scripts/cm-fix-host.mjs +11 -5
- package/scripts/cm-fix-metrics.test.mjs +32 -0
- package/scripts/cm-fix-repair-owner.test.mjs +22 -18
- package/scripts/cm-release-smoke.sh +14 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +85 -0
- package/scripts/cm-review-inventory.test.mjs +42 -0
- package/scripts/cm-security.test.mjs +24 -0
- package/skills/cm-fix/references/js-host.md +18 -1
- package/templates/auto-update/cm-update.sh +51 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cm-workflow",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Spec-driven product development workflow for Codex: external research, PRD, implementation, read-only feature testing, review, QA, fixes, refactors, and documentation.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "cm-workflow maintainers",
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,67 @@
|
|
|
7
7
|
|
|
8
8
|
(暂无)
|
|
9
9
|
|
|
10
|
+
## 0.16.2 — 2026-09-21
|
|
11
|
+
|
|
12
|
+
**把「文档写了但没测」这个形状本身盘了一遍**
|
|
13
|
+
|
|
14
|
+
- 这一轮修掉的四个缺陷是同一个形状:文档承诺了某个选项,代码里也有那条分支,但从来没有测试走过它——交付方式三选一只测了一种、METRICS 列名「语义升级」只测了新名字、跨会话恢复一条都没有、iOS 软链接没测过。它们不是被写坏的,是没人走过。
|
|
15
|
+
- 新增 `scripts/audit-untested-enums.mjs`:扫 runtime 里 `['a','b'].includes(x)` 形式的枚举,逐个对照测试有没有碰过。当前结果 51 个取值缺覆盖、分布在 49 处。
|
|
16
|
+
- 新增 `docs/untested-branches.md`:把这 51 个人工分成三类——A 类是用户能配的选项或文档明确承诺的行为(`auto_fix: never`、视觉证据 `video`、诊断 `design_change` 升级出口、cm-check 三态、cm-test 两种模式、cm-refactor 规则三态与四个失败码),每条写清「补测试前要先弄清什么」;B 类是内部协议分支;C 类是噪声,明说不要为它们写测试。
|
|
17
|
+
- 文档同时写明这份清单的局限:只认一种写法所以 51 是下限;「测试提到过某字符串」不等于那条分支被真正走到;以及最要紧的一条——那四个缺陷是跑真实项目跑出来的,不是读代码读出来的。
|
|
18
|
+
|
|
19
|
+
**走查配置和诊断对不上,要等独立审查做完才发现**
|
|
20
|
+
|
|
21
|
+
- 走查声明的模块必须和诊断结论一一对上,这条规矩一直有,但只在走查那一步才查——而走查在独立审查之后。配错了的一轮,要先把复现、编写测试、修复、回归、外部审查全跑完,才在最后一步被拦下,整轮白跑。实测踩过一次。
|
|
22
|
+
- 判定抽成独立函数,诊断一落盘就问一次,对不上当场停在 `walkthrough_configuration_mismatch`。
|
|
23
|
+
- 只在「刚诊断完、还没往下走」时改阶段:已经跑过头的存量记录保持原样。这个判断放在记录回放**之后**——回放循环会拿当前阶段去校验下一条记录,插在循环里会让存量记录直接打不开(实现过程中真踩了一次,靠存量运行验出来的)。
|
|
24
|
+
|
|
25
|
+
**任务编号重名要等跑到红灯测试才炸,而且那一轮直接报废**
|
|
26
|
+
|
|
27
|
+
- 证据文件名由任务 slug 和轮次拼出来,跟 runId 无关,所以两次运行用同一个 taskId 就会写同一批文件。这个冲突原本要等红灯测试去发布输出时才撞上 `review_file_conflict`——那时 intent 已经登记,运行留在 `unknown` 且不可重派,等于前面复现、诊断、编写测试全部白跑。实测踩过一次。
|
|
28
|
+
- 名字在建运行时就全都算得出来。现在 `--mode create` 会先检查这批名字有没有被占,占了就报 `fix_evidence_name_taken`,发生在任何记录落盘之前。只列这次配置真的会写的文件,不拦根本不会发生的冲突;只在 create 时检查,恢复已有运行不受影响。
|
|
29
|
+
|
|
30
|
+
**出了错查不出是哪一步拦的**
|
|
31
|
+
|
|
32
|
+
- runtime 里有 1032 种不同的失败码(光 cm-fix 就 204 种),但同一个码常常在好几处抛出——`fix_closeout_unavailable` 就有四处——而对端只看得到一句笼统的 `host_request_failed`。真实的码虽然写到了 stderr,却不说位置。实测代价:为了定位一次收尾失败,只能把整个宿主脚本复制一份、自己包一层打印调用栈才找到,普通使用者做不到这个。
|
|
33
|
+
- 现在 `need()` 在造错误时就把现场记成一个普通字段,诊断行多出 `origin`,例如 `{"diagnostic":"host_request_failed","operation":"finish","code":"fix_finish_authorization_required","origin":"cm-fix/execution.mjs:1003"}`。
|
|
34
|
+
- 两条边界没动:位置按 runtime 根取相对路径,不会带出绝对路径和用户名;只报这套 runtime 里的帧,不报调用方文件,更不会输出 `error.message`。读取方式也仍然是「只看自有数据属性」——`stack` 是访问器属性,只在 `need` 内部对刚造出来的原生 Error 上读,绝不去碰外来对象的访问器。
|
|
35
|
+
- 协议回复、日志、运行状态、任何摘要都逐字节不变:`origin` 只走 stderr。
|
|
36
|
+
|
|
37
|
+
**CI 只跑了 118 份自动检查里的 15 份**
|
|
38
|
+
|
|
39
|
+
- 其余 103 份从来没在 CI 跑过,包括 cm-fix 的整个持久化核心。本轮修的四个缺陷,本地跑全套都能暴露,CI 一个都发现不了。根因是那份逐个点名的清单:新写的检查不会自动进去,攒着攒着就成了这样。
|
|
40
|
+
- 改成通配符跑全部,清单不会再漂。Node 从 22 提到 24.14——JS 流程本来就要求 24.14+,跑 22 属于测一个没人声明支持的配置,核心那批还会被平台闸门当场挡掉。
|
|
41
|
+
- 有 7 份进不了 CI:它们要启动 Codex 沙箱,而沙箱在 Linux 上靠 bubblewrap 建网络隔离,GitHub 托管机器不给这个权限(`bwrap: loopback: Failed RTM_NEWADDR`),跟登录无关、装上 codex 也没用。这 7 份改由 `cm-release-smoke.sh` 在发版时覆盖——那个脚本本来就要求本机装了 codex 和 byz。于是**每个 PR 覆盖 111 份,每次发版覆盖满 118 份**,没有看不见的缺口。
|
|
42
|
+
- CI 里加了一句断言:排除名单必须正好是这 7 份。想往里加东西就得改那句,改动会出现在评审里。
|
|
43
|
+
- 上线前用一条一次性流水线在 Linux + Node 24.14 上实跑了 4 次,111 份每次全绿、耗时稳定在 4 分上下,确认不是把随机红灯搬进 CI。
|
|
44
|
+
|
|
45
|
+
**改过 METRICS 列名之后,所有存量表都被硬拒且没有迁移路径**
|
|
46
|
+
|
|
47
|
+
- `N4-review.md` 把这次改名写成「保持原列顺序,将原『Codex拦截』语义升级为『独立审查拦截』」——同一列换个名字。但代码是整行精确匹配表头,于是任何改名前就存在的 `METRICS.md` 都过不去:cm-fix 收尾报 `metrics_table_invalid`,cm-refactor 报 `refactor_metrics_format`,两条收尾路径一起停,且没有任何升级办法。
|
|
48
|
+
- 现在两处共用同一份表头定义,认得出这张表用过的所有列名。新文件仍写当前列名,**绝不改写用户文件里已有的表头**;真正不是这张表的文件照旧拒绝。
|
|
49
|
+
- 真实项目上验证:一张 `Codex拦截` 的旧表,收尾成功追加新行、表头原样保留、运行走到 completed。
|
|
50
|
+
|
|
51
|
+
## 0.16.1 — 2026-09-21
|
|
52
|
+
|
|
53
|
+
**cm-fix 收尾只认 delivery:diff,把 cm-init 自己生成的默认配置锁在门外**
|
|
54
|
+
|
|
55
|
+
- `finish` 原本硬要求 `policies.delivery === 'diff'`,否则 `fix_delivery_authorization_required`。而 `cm-init` 给任何带 remote 的仓库生成的就是 `draft-mr`,于是这类项目的 JS 运行**永远走不到收尾**,档案、METRICS、`task_done` 一样都写不成。这条限制原本写在 `js-host.md` 里,但它和同一套体系的其它约定互相矛盾:`runtime/logging.md` 把 Git 交付定义成独立的 `delivery` 事件(`commit`/`push`/`pull_request`),cm-ai 在任何交付模式下都照常完成任务,cm-fix 自己的 SKILL 第 7 步也明写 branch/draft-mr 怎么提交。
|
|
56
|
+
- 更要命的是它无法绕开:`findConfig` 只读项目根,而项目根在业务快照范围内,所以临时把 delivery 改成 `diff` 这个动作本身就改了快照,阶段立刻从 `closeout_required` 掉成 `learning_writeback_evidence_required`,收尾照样过不去;改回来又变回 `draft-mr`。两头堵,唯一出路是重跑整轮。
|
|
57
|
+
- 现在 finish 接受任一合法取值,只要求它在写完成记录期间**不变**(`fix_delivery_changed`)。写的还是档案/METRICS/`task_done`,**依然不执行 Git**:branch/draft-mr 的提交、推送、开 MR 仍由执行者单独完成并记 `delivery` 事件。
|
|
58
|
+
|
|
59
|
+
**受保护模式跑不了任何需要本地 IPC 的测试命令(无代码修复,只补文档)**
|
|
60
|
+
|
|
61
|
+
- 受保护模式的沙箱 `network={enabled=false}`,而这个开关同时管着 unix domain socket 的 `listen`。于是 `tsx` CLI(启动时在 TMPDIR 建 `<pid>.pipe`)、`vitest` 之类一律 `Error: listen EPERM`;写 TMPDIR 文件本身不受影响。实测确认过两者的差别。
|
|
62
|
+
- **没有安全的代码修法**:放开它就等于给所有受保护测试命令放开整个外网,那是比问题本身更大的倒退。`js-host.md` 改为写清这条约束、症状、以及可用的替代写法(把 `npm test` 串联的 `tsx xxx.test.ts` 换成逐文件 `node --import .../tsx/dist/loader.mjs <file>`,覆盖面不变),并说明沙箱内失败为什么只留 `host check exited N`(原始输出有意不进证据)以及怎么手工重放看真实原因。
|
|
63
|
+
|
|
64
|
+
**cm-fix 两处让修复跑不下去的阻断**
|
|
65
|
+
|
|
66
|
+
- **换一个会话就再也打不开自己的运行**。`--mode resume` 一直存在,但 durable 配置里存着创建这次运行的会话 ID,指纹又是整份配置的摘要,于是新会话换上自己的 `--host-context` 必然 `fingerprint_mismatch`,而沿用旧 ID 又正是文档禁止的冒用旧会话——两条路都堵死,跨会话恢复实际上从来没能用过。现在把「这次运行绑定的宿主」和「此刻在跑的会话」分开:durable 配置与旧记录一字不改,恢复时用 `--original-host-context` 报上原会话,`--host-context` 仍是当前真实会话。两个身份都算宿主,授权凭据两者皆可、重放旧凭据不受影响,reviewer 必须同时独立于两者;改动 durable 宿主仍然 `fingerprint_mismatch` 关闭。
|
|
67
|
+
- **iOS 项目连基线快照都拍不成**。CocoaPods 装出来的 `ios/Pods/` 是几千个头文件软链接,而快照对软链接一律 `unsupported_file` 失败关闭,于是任何做过 `pod install` 的仓库在编写测试这一步直接阻断(实测 6179 个软链接)。现在把它按 `node_modules` 那样当依赖目录跳过,但**光看名字不算**:目录名要是 `pods`,里面要有 `Manifest.lock` 和 `Pods.xcodeproj`,旁边还要有 `Podfile.lock`,四样齐全才认。业务代码里自己写的 `pods/` 目录照常入快照、其中的软链接照常拒绝。软链接保护一行未放宽,Pods 内的文件也不能选进 scope 或 requirements。
|
|
68
|
+
|
|
69
|
+
判定本身就是安全边界——被它认下的目录会**无声**离开评审视野,所以遍历侧和 scope 守卫必须问同一个函数。初版这两处口径不一致:遍历侧不看名字、只探测生成物,于是在任意目录(例如 `src/`)放一个空 `Manifest.lock` 加一个空 `Pods.xcodeproj/`,整棵目录连同**已声明进 scope 的文件**一起被静默跳过,且不报任何错。现已统一为同一个判定,并补了三条回归测试钉住「两处必须一致」。
|
|
70
|
+
|
|
10
71
|
## 0.16.0 — 2026-09-20
|
|
11
72
|
|
|
12
73
|
一次真实实跑把 cm-ai 从「跑不完」推到「跑得完」,本版是那趟跑出来的修复与新增。
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
## 最近更新
|
|
19
19
|
|
|
20
|
-
**0.16.
|
|
20
|
+
**0.16.2**
|
|
21
21
|
|
|
22
22
|
- **安装时会问你要不要开启新版提示**。此前安装完只有一句含糊的「自动更新器未自动启用」,已经开启的人也会看到这句(是错的),没开启的人又不会当回事,结果几乎没人用上这个功能。现在安装器会先看你实际配没配,再决定说什么;没配且是手动安装时,问一句、你答 y 才写入。用 `--yes` 静默安装的不会被改动任何配置,只会打印该加什么。
|
|
23
23
|
- 它**只加一条「有新版就告诉你」的提示**,不会顺手打开后台自动升级——那是另一回事,仍需你自己决定。你的 `settings.json` 里原有的内容(比如自定义状态栏)不会被动。
|
|
@@ -148,7 +148,7 @@ $cm-check
|
|
|
148
148
|
|
|
149
149
|
仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
|
|
150
150
|
|
|
151
|
-
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.16.
|
|
151
|
+
需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.16.2 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
|
|
152
152
|
|
|
153
153
|
## 升级旧版本
|
|
154
154
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.16.
|
|
1
|
+
0.16.2
|
package/docs/installation.md
CHANGED
|
@@ -73,7 +73,7 @@ Install or upgrade with the same command:
|
|
|
73
73
|
npx @aibyzero/cm-workflow@latest install
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
To pin a version, use `npx @aibyzero/cm-workflow@0.16.
|
|
76
|
+
To pin a version, use `npx @aibyzero/cm-workflow@0.16.2 install` from outside
|
|
77
77
|
the CM Workflow source checkout (for example, your home directory). Inside a
|
|
78
78
|
checkout with the same package name and version, npm can select the local
|
|
79
79
|
uninstalled package and report `cm-workflow: command not found`.
|
|
@@ -349,8 +349,8 @@ host-context 必须是真实当前会话身份;宿主将其排除出独立审
|
|
|
349
349
|
一轮独立审查要花一到三分钟,返工则要再赔上一整轮开发加审查。
|
|
350
350
|
|
|
351
351
|
启用后,宿主在收齐任务自身的检查之后、**构建审查包与派发独立审查之前**,
|
|
352
|
-
发一个 `verification_precheck` 请求,把该任务 `tasks.md`
|
|
353
|
-
|
|
352
|
+
发一个 `verification_precheck` 请求,把该任务 `tasks.md` 里的**任务描述**与**验证要求**原文、
|
|
353
|
+
连同本次检查结果一起交给对端,由对端逐条核对本次交付并回答:
|
|
354
354
|
|
|
355
355
|
```json
|
|
356
356
|
{"items":[{"requirement":"记录实现前基线","satisfied":true,"evidence":"npm test tests 42 / pass 42 / fail 0"}]}
|
|
@@ -362,6 +362,12 @@ host-context 必须是真实当前会话身份;宿主将其排除出独立审
|
|
|
362
362
|
**它只能拦,不能放。** 通过闸门不产生审查回执、不授予任何批准、不减少后续的完整独立审查。
|
|
363
363
|
这与 `prd_self_check` 的定位一致:机械通过不等于语义通过,不能用自检冒充独立审查。
|
|
364
364
|
|
|
365
|
+
**为什么描述也要核对**:硬性要求经常写在任务描述里而不是验证要求段,例如
|
|
366
|
+
「并核对既有筛选/搜索/编辑/删除不回归」「不修改 `src/todos.js`」。只读验证要求段
|
|
367
|
+
等于放过这一半——实跑中末任务正是因此漏做三项回归检查、被独立审查以 P1 打回。
|
|
368
|
+
描述里同时混着工作量估计与背景说明,**只核对其中可判定的硬性要求**,取舍交给对端;
|
|
369
|
+
两段都没有写时闸门自动让路。
|
|
370
|
+
|
|
365
371
|
**一条要如实说明的限制**:任务的验证要求在 `tasks.md` 里是自由文本,
|
|
366
372
|
**JS 无法机械证明对端把其中每一条都枚举到了**。JS 强制的是:回答的形状、
|
|
367
373
|
每条都必须给出非空的证据落点、以及只有全部满足才放行。形状合规不等于语义覆盖。
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# 没有测试走过的分支
|
|
2
|
+
|
|
3
|
+
一轮真实实跑修掉的四个缺陷是**同一个形状**:文档承诺了某个选项,代码里也确实有那条
|
|
4
|
+
分支,但从来没有测试走过它。
|
|
5
|
+
|
|
6
|
+
| 文档承诺 | 实际覆盖 | 后果 |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| 交付方式 `diff` / `branch` / `draft-mr` 三选一 | 每个夹具都写 `diff` | 另外两种的项目永远收不了尾 |
|
|
9
|
+
| METRICS 列名「语义升级,保持原列顺序」 | 只有新列名 | 所有改名前的表被硬拒 |
|
|
10
|
+
| `--mode resume` 换会话恢复 | 一条都没有 | 从来没有人成功恢复过 |
|
|
11
|
+
| iOS 项目照常支持 | 没有带软链接的夹具 | 基线快照拍不出来 |
|
|
12
|
+
|
|
13
|
+
它们不是被写坏的,是**没人走过**。所以值得把同一形状的其余候选一次列出来,而不是等下
|
|
14
|
+
一次实跑再撞。
|
|
15
|
+
|
|
16
|
+
`scripts/audit-untested-enums.mjs` 扫 `runtime/js` 里 `['a','b'].includes(x)` 形式的枚举,
|
|
17
|
+
逐个看 `scripts/*.test.mjs` 里有没有出现过。写这份文档时的结果:**51 个取值缺覆盖,
|
|
18
|
+
分布在 49 处**。
|
|
19
|
+
|
|
20
|
+
脚本输出的是**候选,不是待办**——内部记录类型和 `typeof` 判断也会被匹配到。下面是人工
|
|
21
|
+
分好的类。改完代码后重跑脚本对照。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## A 类:用户能配的选项、或文档明确承诺的行为
|
|
26
|
+
|
|
27
|
+
这一类和上表四个缺陷完全同形,优先补。
|
|
28
|
+
|
|
29
|
+
| 取值 | 位置 | 承诺在哪 | 补测试前要先弄清 |
|
|
30
|
+
| --- | --- | --- | --- |
|
|
31
|
+
| `auto_fix: never` | `cm-ai/host-qa-fix.mjs:21` | `templates/cm-workflow.yml` 写着 `explicit \| never \| auto`;`runtime/workflow-config.md` 说它决定「N6 失败后的三分支」 | `never` 下 QA 失败到底该停在哪、和 `explicit` 的差别是什么 |
|
|
32
|
+
| 视觉证据 `kind: video` | `cm-ai/review-package.mjs:371` | `cm-fix-host.mjs --help` 明写 `before:{path,sha256,kind:screenshot\|video,...}` | 录屏载体的校验和取证跟截图有没有实质差别 |
|
|
33
|
+
| 诊断 `design_change` | `cm-fix/cause-package.mjs` | cm-fix SKILL 第 4 步「升级出口」:停止硬修、转 `$cm-prd --change` 立项 | 这条出口下红灯测试要保留、档案要记「升级立项」,这些有没有真发生 |
|
|
34
|
+
| cm-check `configured` | `cm-check/host.mjs:105` | 三态之一(`configured\|degraded\|unknown`) | 什么条件算 configured,和 degraded 的边界 |
|
|
35
|
+
| cm-test `snapshot` / `evaluation` | `cm-test/session.mjs:47` | 两种模式**都**没被测过 | 两种模式各自的输入和产物 |
|
|
36
|
+
| cm-refactor 规则三态 | `cm-refactor/workflow.mjs:244` | `rule_correct\|rule_missing\|rule_wrong` 全没测过 | 规则判定的输入从哪来、三态各自怎么触发 |
|
|
37
|
+
| cm-refactor 四个失败码 | `cm-refactor/workflow.mjs:322` | 全没测过 | 每个码对应的真实冲突场景 |
|
|
38
|
+
|
|
39
|
+
**建议按模块分批**,不要一次全开。cm-prd、cm-refactor、cm-test、cm-check 这四块各自
|
|
40
|
+
独立,给一条从没走过的分支补测试,得先读懂那条分支本来该是什么行为——读浅了会写出
|
|
41
|
+
「形状对但没验到点上」的测试,那比没有更糟:它让人以为测过了。
|
|
42
|
+
|
|
43
|
+
## B 类:内部协议分支,值得测但不紧急
|
|
44
|
+
|
|
45
|
+
- `cm-ai/claude-tool-preview.mjs:51` —— `gzip` / `zstd` 传输编码,只测过 `identity`
|
|
46
|
+
- `cm-ai/tool-preview.mjs` —— `argument` 提示词传输方式,全部现有用例走 `stdin`
|
|
47
|
+
- `cm-ai/contracts.mjs` —— 状态机取值 `waiting_user` / `deny` / `revoked` / `active`
|
|
48
|
+
- `cm-ai/durable-runner-state.mjs:215,336` —— `grant_expired` / `clock_invalid`
|
|
49
|
+
- `cm-ai/cm-ai-conversation-entry.mjs:48-56` —— `context_refresh` / `run_finalize`
|
|
50
|
+
- `cm-prd/correction-check.mjs:28,45` —— `mechanical_failed` / `context_result`
|
|
51
|
+
|
|
52
|
+
这些不在用户配置面上,踩中的路径更窄。但 `grant_expired` 和 `clock_invalid` 关系到授权
|
|
53
|
+
凭据的过期判定,真出问题代价不小,排在 B 类的前面。
|
|
54
|
+
|
|
55
|
+
## C 类:噪声,不必单独补
|
|
56
|
+
|
|
57
|
+
脚本会匹配到,但不构成缺口,**不要**为它们单独写测试:
|
|
58
|
+
|
|
59
|
+
- `typeof` 判断里的 `'string'` / `'boolean'` / `'function'`——语言层面,不是业务分支
|
|
60
|
+
- 内部记录类型 `append-intent` / `append-result` / `task-commit-intent`——已被上层用例
|
|
61
|
+
整条链路间接覆盖,单独断言只会重复
|
|
62
|
+
- 只做透传的错误码 `catch` 列表,例如 `cm-fix/execution.mjs` 里
|
|
63
|
+
`['context_invalid','context_too_large',...].includes(error?.code)`——这些码由抛出方
|
|
64
|
+
的用例负责,这里只是把它们原样传出去
|
|
65
|
+
|
|
66
|
+
## 这份清单的局限
|
|
67
|
+
|
|
68
|
+
- 只扫 `['a','b'].includes(x)` 这一种写法。`switch`、对象查表、`Set.has` 都漏掉了,
|
|
69
|
+
所以 51 是**下限**不是全部。
|
|
70
|
+
- 「测试里出现过这个字符串」只能说明它被提到过,不等于那条分支被真正走到并断言了。
|
|
71
|
+
A 类里每一条仍要人去确认。
|
|
72
|
+
- 最重要的一点:上表那四个缺陷是**跑真实项目**跑出来的,不是读代码读出来的。这份清单
|
|
73
|
+
补的是读得出来的那部分;拿工作流去跑真实项目,仍然是发现问题最有效的办法。
|
package/package.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Checklist coverage: a reminder, never a verdict.
|
|
2
|
+
//
|
|
3
|
+
// Four of the five development-stage rejections recorded on the reference
|
|
4
|
+
// project were not defects. The task text had enumerated a list — "confirm
|
|
5
|
+
// filter / search / edit / delete / clear-completed / clear-all do not
|
|
6
|
+
// regress", "record the empty, partial and complete states" — and the delivery
|
|
7
|
+
// simply left some entries out. A human reviewer found them, which costs a
|
|
8
|
+
// full review round.
|
|
9
|
+
//
|
|
10
|
+
// Counting entries is mechanical, so it does not need a reviewer. What is NOT
|
|
11
|
+
// mechanical is deciding whether an entry was covered under different wording
|
|
12
|
+
// ("列表为空" in the task, "空列表" in the evidence), which is why every result
|
|
13
|
+
// here is advisory: it says what to look at, never what to reject.
|
|
14
|
+
|
|
15
|
+
const MAX_LISTS = 16, MAX_ITEMS = 12, MAX_TEXT = 512 * 1024;
|
|
16
|
+
|
|
17
|
+
const suffixes = value => {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (let i = 1; i <= value.length - 2; i += 1) out.push(value.slice(i));
|
|
20
|
+
return out;
|
|
21
|
+
};
|
|
22
|
+
const prefixes = value => {
|
|
23
|
+
const out = [];
|
|
24
|
+
for (let i = value.length - 1; i >= 2; i -= 1) out.push(value.slice(0, i));
|
|
25
|
+
return out;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// The first and last entry of a slash list absorb the surrounding sentence
|
|
29
|
+
// ("核对既有筛选", "清空全部不回归"), so they are matched by giving ground from
|
|
30
|
+
// the outside in. Interior entries stand alone and are matched verbatim.
|
|
31
|
+
function locate(item, text, position, length) {
|
|
32
|
+
if (text.includes(item)) return item;
|
|
33
|
+
const relaxed = position === 0 ? suffixes(item) : position === length - 1 ? prefixes(item) : [];
|
|
34
|
+
return relaxed.find(candidate => text.includes(candidate)) ?? null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function extractChecklists(taskText) {
|
|
38
|
+
if (typeof taskText !== 'string' || taskText.length === 0 || taskText.length > MAX_TEXT) return Object.freeze([]);
|
|
39
|
+
const lists = [], seen = new Set();
|
|
40
|
+
const add = (source, items) => {
|
|
41
|
+
const entries = items.map(value => value.trim()).filter(value => value.length >= 2);
|
|
42
|
+
if (entries.length < 3 || entries.length > MAX_ITEMS || lists.length >= MAX_LISTS) return;
|
|
43
|
+
const key = entries.join('\u0000');
|
|
44
|
+
if (seen.has(key)) return;
|
|
45
|
+
seen.add(key);
|
|
46
|
+
lists.push(Object.freeze({ source, items: Object.freeze(entries) }));
|
|
47
|
+
};
|
|
48
|
+
// 核对既有筛选/搜索/编辑/删除/清理已完成/清空全部不回归
|
|
49
|
+
for (const match of taskText.matchAll(/([\u4e00-\u9fa5]{2,8}(?:\/[\u4e00-\u9fa5]{2,8}){2,})/g))
|
|
50
|
+
add(match[1], match[1].split('/'));
|
|
51
|
+
// 分别记录**列表为空、有未完成、全部已完成**三种情形
|
|
52
|
+
for (const match of taskText.matchAll(/\*\*([^*\n]{4,80})\*\*\s*(?:这)?(?:三|四|五|六|七|八)\s*(?:种|类|个|项)/g))
|
|
53
|
+
add(match[1], match[1].split(/[、,,]/));
|
|
54
|
+
return Object.freeze(lists);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Returns only the lists that are missing at least one entry. An empty array
|
|
58
|
+
// means nothing was detected — not that the delivery is complete.
|
|
59
|
+
export function checklistGaps(taskText, evidenceText) {
|
|
60
|
+
if (typeof evidenceText !== 'string' || evidenceText.length === 0) return Object.freeze([]);
|
|
61
|
+
const text = evidenceText.length > MAX_TEXT ? evidenceText.slice(0, MAX_TEXT) : evidenceText;
|
|
62
|
+
const gaps = [];
|
|
63
|
+
for (const list of extractChecklists(taskText)) {
|
|
64
|
+
const missing = list.items.filter((item, index) => locate(item, text, index, list.items.length) === null);
|
|
65
|
+
if (missing.length > 0) gaps.push(Object.freeze({
|
|
66
|
+
source: list.source, total: list.items.length, missing: Object.freeze(missing),
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
return Object.freeze(gaps);
|
|
70
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Shared strict data boundary for S2b. No dispatch or approval authority.
|
|
2
2
|
import { digest } from './contracts.mjs';
|
|
3
3
|
export { digest };
|
|
4
|
-
export const need=(ok,code='invalid_input')=>{
|
|
4
|
+
export const need=(ok,code='invalid_input')=>{
|
|
5
|
+
if(!ok){const e=new Error(code);e.code=code;const at=raisedAt(e);if(at!==null)e.origin=at;throw e;}
|
|
6
|
+
};
|
|
5
7
|
// Explicit host call budget, shared by live initialization and journal replay.
|
|
6
8
|
// This is not the short-lived authorization grant expiry.
|
|
7
9
|
export const validCallTimeout=value=>need(Number.isInteger(value)&&value>=1&&value<=3600000);
|
|
@@ -18,9 +20,39 @@ const failureCodes=new Set(['invalid_input','limit_exceeded','call_timeout','can
|
|
|
18
20
|
// error.message, which can carry arbitrary provider output or source text.
|
|
19
21
|
const diagnosticText=value=>typeof value==='string'&&value.length>0&&value.length<=1024
|
|
20
22
|
&&!/[\x00-\x08\x0b-\x1f]/.test(value);
|
|
23
|
+
// The code alone is often not actionable: fix_closeout_unavailable is raised in
|
|
24
|
+
// four different places and the peer only ever sees host_request_failed, so the
|
|
25
|
+
// only way to tell them apart was to copy the host and add prints by hand. Name
|
|
26
|
+
// the call site as well. Two boundaries hold: the location is rendered relative
|
|
27
|
+
// to the runtime root, so no absolute path (and no username) is emitted, and only
|
|
28
|
+
// frames inside this runtime are reported — never a caller's file, and never
|
|
29
|
+
// error.message, which can carry arbitrary provider output.
|
|
30
|
+
const runtimeRoot=new URL('../',import.meta.url).href;
|
|
31
|
+
const frameLocation=/(?:\(|\bat )(file:\/\/\S*?):(\d+):\d+\)?$/;
|
|
32
|
+
// Only ever called from need(), on an Error this module just constructed, so
|
|
33
|
+
// reading .stack cannot run a foreign getter. executionDiagnostic below still
|
|
34
|
+
// reads origin the same way as every other field: as an own data property,
|
|
35
|
+
// never by dereferencing an accessor on an object someone else made.
|
|
36
|
+
function raisedAt(error) {
|
|
37
|
+
try {
|
|
38
|
+
const stack=error.stack;
|
|
39
|
+
if(typeof stack!=='string')return null;
|
|
40
|
+
for(const line of stack.split('\n')) {
|
|
41
|
+
const match=frameLocation.exec(line.trim());
|
|
42
|
+
if(!match || !match[1].startsWith(runtimeRoot))continue;
|
|
43
|
+
const relative=decodeURIComponent(match[1].slice(runtimeRoot.length));
|
|
44
|
+
// need() lives here, so its own frame is never the scene; the first frame
|
|
45
|
+
// outside this file is the contract that actually refused.
|
|
46
|
+
if(relative==='cm-ai/effect-contract.mjs')continue;
|
|
47
|
+
const origin=`${relative}:${match[2]}`;
|
|
48
|
+
return diagnosticText(origin)?origin:null;
|
|
49
|
+
}
|
|
50
|
+
} catch {/* diagnostics never change the failure path */}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
21
53
|
export function executionDiagnostic(error) {
|
|
22
54
|
const detail={};
|
|
23
|
-
for(const name of ['code','syscall','path','dest']) {
|
|
55
|
+
for(const name of ['code','syscall','path','dest','origin']) {
|
|
24
56
|
const d=Object.getOwnPropertyDescriptor(error,name);
|
|
25
57
|
if(d && Object.hasOwn(d,'value') && diagnosticText(d.value))detail[name]=d.value;
|
|
26
58
|
}
|
|
@@ -140,4 +172,6 @@ export function reviewExclusions(invocation,calls,developerContextId){
|
|
|
140
172
|
// Host configuration allows 32 exclusions. FIX second-round review additionally
|
|
141
173
|
// excludes the cause reviewer, first implementation reviewer and logical context.
|
|
142
174
|
// Preserve that full union; ordinary two-author-attempt callers still fit.
|
|
143
|
-
|
|
175
|
+
// A run resumed in a new session adds that session's host context to the union,
|
|
176
|
+
// so the bound carries one entry more than a single-session run ever needs.
|
|
177
|
+
export const MAX_REVIEW_EXCLUSIONS=36;
|
|
@@ -17,6 +17,7 @@ import {codexWorker,preflightMatches} from './worker-codex.mjs';
|
|
|
17
17
|
import {createHostReviewAuthority} from './host-review-authority.mjs';
|
|
18
18
|
import {createHostWorkflowCapabilities} from './host-workflow-capabilities.mjs';
|
|
19
19
|
import {resolveHostRole} from './host-role-routing.mjs';
|
|
20
|
+
import {checklistGaps} from './checklist-coverage.mjs';
|
|
20
21
|
import {specsPermissionArgs} from './codex-config.mjs';
|
|
21
22
|
import {createProjectExecution} from './host-project-execution.mjs';
|
|
22
23
|
import {codeProjectPaths,codeProjectInstructionPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
@@ -59,7 +60,30 @@ export function readVerificationPrecheck(raw){
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
return freeze({satisfied:items.every(item=>item.satisfied===true),
|
|
62
|
-
unsatisfied:items.filter(item=>item.satisfied!==true).map(item=>item.requirement)
|
|
63
|
+
unsatisfied:items.filter(item=>item.satisfied!==true).map(item=>item.requirement),
|
|
64
|
+
evidence:items.map(item=>item.evidence).join('\n')});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The delivered evidence usually lives in the scope files (a walkthrough
|
|
68
|
+
// document, a baseline note), not in the gate answers, so the coverage
|
|
69
|
+
// reminder reads both. Unreadable, oversized, symlinked or binary entries are
|
|
70
|
+
// skipped: a file this reminder cannot read is the review's problem, not its
|
|
71
|
+
// own, and it must never turn a readable delivery into a failure.
|
|
72
|
+
const COVERAGE_FILE_LIMIT=256*1024;
|
|
73
|
+
export function deliveredText(codeProject,scope){
|
|
74
|
+
if(typeof codeProject!=='string'||!Array.isArray(scope))return '';
|
|
75
|
+
const parts=[];
|
|
76
|
+
for(const entry of scope.slice(0,64)){
|
|
77
|
+
if(typeof entry!=='string'||entry.length===0)continue;
|
|
78
|
+
try{
|
|
79
|
+
const file=path.join(codeProject,entry);
|
|
80
|
+
const info=fs.lstatSync(file);
|
|
81
|
+
if(!info.isFile()||info.isSymbolicLink()||info.size>COVERAGE_FILE_LIMIT)continue;
|
|
82
|
+
const body=fs.readFileSync(file,'utf8');
|
|
83
|
+
if(!body.includes('\u0000'))parts.push(body);
|
|
84
|
+
}catch{/* a file the reminder cannot read simply contributes nothing */}
|
|
85
|
+
}
|
|
86
|
+
return parts.join('\n');
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
export function resolveReviewTimeout(review,protection){
|
|
@@ -151,6 +175,18 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
151
175
|
task:request.identity.taskId,attempt:request.identity.attempt,
|
|
152
176
|
unsatisfied:verdict.unsatisfied})+'\n');
|
|
153
177
|
}catch{/* diagnostics never change the verdict */}
|
|
178
|
+
// Advisory only. An enumerated list in the task text whose entries are not
|
|
179
|
+
// all present in the delivery is the cheapest rejection to catch, but
|
|
180
|
+
// wording differs legitimately ("列表为空" vs "空列表"), so this reports and
|
|
181
|
+
// never rejects: the verdict below is the gate's, untouched.
|
|
182
|
+
try{
|
|
183
|
+
const gaps=checklistGaps([request.description,request.verification]
|
|
184
|
+
.filter(text=>typeof text==='string').join('\n'),
|
|
185
|
+
[verdict.evidence,deliveredText(definition.codeProject,definition.scope)].join('\n'));
|
|
186
|
+
if(gaps.length>0)process.stderr.write(JSON.stringify({diagnostic:'checklist_coverage',
|
|
187
|
+
task:request.identity.taskId,attempt:request.identity.attempt,advisory:true,
|
|
188
|
+
gaps:gaps.map(gap=>({total:gap.total,missing:gap.missing}))})+'\n');
|
|
189
|
+
}catch{/* diagnostics never change the verdict */}
|
|
154
190
|
return {satisfied:verdict.satisfied};
|
|
155
191
|
}:null;
|
|
156
192
|
const execution={configuration,timeoutMs:provider?protection.timeoutMs:1800000,excludedContexts:[hostContextId],hostDecision:null,applicableAgentFiles:[],
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// One METRICS.md table shape, shared by the fix and refactor closeouts.
|
|
2
|
+
// The 「Codex拦截」 column was renamed to 「独立审查拦截」 as a semantic upgrade of the
|
|
3
|
+
// same column — N4-review.md says exactly that: keep the original column order, upgrade
|
|
4
|
+
// what the old 「Codex拦截」 means. Matching the header as one exact string turned that
|
|
5
|
+
// rename into a hard wall instead: every METRICS.md written before it is refused with
|
|
6
|
+
// metrics_table_invalid / refactor_metrics_format, both closeouts stop, and there is no
|
|
7
|
+
// migration path. Accept every name this table has ever used, keep writing the current
|
|
8
|
+
// one for new files, and never rewrite the header inside a file the user owns.
|
|
9
|
+
export const METRICS_HEADER='| 任务 | Feature | 开始 | 结束 | 审查轮次 | 独立审查拦截 | QA | 人工介入(次:原因) |';
|
|
10
|
+
export const METRICS_SEPARATOR='| --- | --- | --- | --- | --- | --- | --- | --- |';
|
|
11
|
+
|
|
12
|
+
// Column order and count are identical across the rename, so a row written today lines
|
|
13
|
+
// up under either header. Only these exact lines count: an arbitrary table is still not
|
|
14
|
+
// this table, and is still refused by the callers.
|
|
15
|
+
const ACCEPTED_HEADERS=Object.freeze([METRICS_HEADER,
|
|
16
|
+
'| 任务 | Feature | 开始 | 结束 | 审查轮次 | Codex拦截 | QA | 人工介入(次:原因) |']);
|
|
17
|
+
|
|
18
|
+
export function hasMetricsHeader(content) {
|
|
19
|
+
if(typeof content!=='string')return false;
|
|
20
|
+
const lines=content.split(/\r?\n/);
|
|
21
|
+
return ACCEPTED_HEADERS.some(candidate=>lines.includes(candidate));
|
|
22
|
+
}
|
|
@@ -16,6 +16,28 @@ const materialPath=(p,selected)=>selected.has(p)||p.split('/').at(-1)==='AGENTS.
|
|
|
16
16
|
// Keep this narrower than the discovery scanner: dist/build may be authored files.
|
|
17
17
|
const dependencyDirectories=new Set(['.venv','node_modules','__pycache__','.pytest_cache','.ruff_cache']);
|
|
18
18
|
const inDependencyDirectory=p=>p.split('/').slice(0,-1).some(part=>dependencyDirectories.has(part.toLowerCase()));
|
|
19
|
+
// CocoaPods installs ios/Pods as a generated tree whose headers are symlinks.
|
|
20
|
+
// It is a dependency root like node_modules, but every other dependency root
|
|
21
|
+
// here is a fixed name, while this one is recognised from the filesystem. That
|
|
22
|
+
// makes the predicate itself a security boundary: whatever it accepts leaves
|
|
23
|
+
// the snapshot silently, so both the traversal and the scope guard must ask
|
|
24
|
+
// exactly this one function, and it must be expensive to satisfy by accident
|
|
25
|
+
// or on purpose. Four independent CocoaPods artefacts are required — the name,
|
|
26
|
+
// the two generated entries inside, and the Podfile.lock beside it — so an
|
|
27
|
+
// authored directory called pods/ still enters the snapshot and its symlinks
|
|
28
|
+
// still fail closed.
|
|
29
|
+
function isCocoaPodsRoot(absolute) {
|
|
30
|
+
if(path.basename(absolute).toLowerCase()!=='pods')return false;
|
|
31
|
+
try {
|
|
32
|
+
return fs.lstatSync(path.join(absolute,'Manifest.lock')).isFile()
|
|
33
|
+
&& fs.lstatSync(path.join(absolute,'Pods.xcodeproj')).isDirectory()
|
|
34
|
+
&& fs.lstatSync(path.join(path.dirname(absolute),'Podfile.lock')).isFile();
|
|
35
|
+
} catch { return false; }
|
|
36
|
+
}
|
|
37
|
+
const inCocoaPodsTree=(root,p)=>{
|
|
38
|
+
const parts=p.split('/');
|
|
39
|
+
return parts.slice(0,-1).some((part,index)=>isCocoaPodsRoot(path.join(root,...parts.slice(0,index+1))));
|
|
40
|
+
};
|
|
19
41
|
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
20
42
|
const fail = code => { const error=new Error(code); error.code=code; throw error; };
|
|
21
43
|
const need = (condition,code='invalid_input') => { if(!condition) fail(code); };
|
|
@@ -55,8 +77,12 @@ function filePath(p) {
|
|
|
55
77
|
&& p.normalize('NFC')===p,'unsupported_path');
|
|
56
78
|
const parts=p.split('/');
|
|
57
79
|
need(parts.every(s=>s && s!=='.' && s!=='..'),'unsupported_path');
|
|
80
|
+
// Committed placeholder files are ordinary source: .env.example and friends
|
|
81
|
+
// exist to be copied, and a repository that contains one must still be able to
|
|
82
|
+
// capture a baseline at all. Only these four explicit suffixes are allowed, so
|
|
83
|
+
// .env, .env.local and even .env.example.bak stay rejected as before.
|
|
58
84
|
need(parts.every(s=>!['.git','.ssh','.aws','.gnupg'].includes(s.toLowerCase())
|
|
59
|
-
&& !/^\.env(?:\.|$)/i.test(s)),'unsupported_path');
|
|
85
|
+
&& (!/^\.env(?:\.|$)/i.test(s) || /^\.env\.(?:example|sample|template|dist)$/i.test(s))),'unsupported_path');
|
|
60
86
|
return p;
|
|
61
87
|
}
|
|
62
88
|
function paths(input) {
|
|
@@ -141,7 +167,7 @@ function snapshot(root,specsPath=null,projectPaths=null,retainedPaths=[],selecte
|
|
|
141
167
|
if(p===specsPath){need(s.isDirectory()&&!s.isSymbolicLink(),'unsupported_path');continue;}
|
|
142
168
|
// Never follow a dependency-root symlink. Old baselines that captured
|
|
143
169
|
// these files still verify their original material instead of dropping it.
|
|
144
|
-
if(s.isDirectory()&&dependencyDirectories.has(name)
|
|
170
|
+
if(s.isDirectory()&&(dependencyDirectories.has(name.toLowerCase())||isCocoaPodsRoot(path.join(root,p)))
|
|
145
171
|
&&!retainedPaths.some(file=>file.startsWith(p+'/')))continue;
|
|
146
172
|
if(s.isDirectory()) walk(p,depth+1,codeRoot);
|
|
147
173
|
else add(p,s);
|
|
@@ -183,7 +209,7 @@ export function captureReviewBaseline(options) {
|
|
|
183
209
|
specification=captureSpecificationMaterial({...v.specification,taskId:v.identity.taskId});
|
|
184
210
|
}
|
|
185
211
|
const scope=paths(v.scope), requirements=requirementPaths(v.requirements,bootstrap!==null||specification!==null),root=rootPath(v.root);
|
|
186
|
-
need(![...scope,...requirements].some(inDependencyDirectory),'excluded_snapshot_path');
|
|
212
|
+
need(![...scope,...requirements].some(p=>inDependencyDirectory(p)||inCocoaPodsTree(root,p)),'excluded_snapshot_path');
|
|
187
213
|
const projectPaths=Object.hasOwn(v,'codeProjectPaths')?validateCodeProjectPaths(v.codeProjectPaths):null;
|
|
188
214
|
if(projectPaths!==null)resolveCodeProjects(v.root,projectPaths.map(prefix=>path.join(root,prefix)));
|
|
189
215
|
const specsPath=Object.hasOwn(v,'specsRoot')?reviewSpecsPath(root,v.specsRoot):null;
|
|
@@ -578,13 +578,19 @@ export function createTaskRunner(options) {
|
|
|
578
578
|
// verification never spends an independent review round.
|
|
579
579
|
async function verificationSatisfied(checks) {
|
|
580
580
|
if(verificationGate===null)return true;
|
|
581
|
-
//
|
|
582
|
-
//
|
|
581
|
+
// The description carries hard requirements too ("also confirm X/Y/Z do not
|
|
582
|
+
// regress", "do not modify A"), and a gate that reads only the verification
|
|
583
|
+
// section lets exactly those through to the independent review. Both are
|
|
584
|
+
// sent; neither is required to exist.
|
|
583
585
|
const specification=Object.hasOwn(original,'specification')?verifySpecificationMaterial(original):null;
|
|
584
586
|
const verification=specification?.task?.verification??null;
|
|
585
|
-
|
|
587
|
+
const description=specification?.task?.description??null;
|
|
588
|
+
const written=value=>typeof value==='string'&&value.trim().length>0;
|
|
589
|
+
if(!written(verification)&&!written(description))return true;
|
|
586
590
|
const verdict=json(await bounded(verificationGate,
|
|
587
|
-
json({identity:{...config.identity,attempt},
|
|
591
|
+
json({identity:{...config.identity,attempt},
|
|
592
|
+
...(written(description)?{description}:{}),
|
|
593
|
+
...(written(verification)?{verification}:{}),checks})));
|
|
588
594
|
shape(verdict,['satisfied']);need(typeof verdict.satisfied==='boolean','invalid_result');
|
|
589
595
|
return verdict.satisfied;
|
|
590
596
|
}
|
|
@@ -3,7 +3,19 @@ import {validateReviewDispatchGrant} from '../cm-ai/durable-runner-state.mjs';
|
|
|
3
3
|
import {inspectProviderCauseReview} from '../cm-ai/provider-review-observation.mjs';
|
|
4
4
|
import {digest,id,json,need,shape,text,hex} from '../cm-ai/effect-contract.mjs';
|
|
5
5
|
|
|
6
|
+
// A run outlives the session that created it. Its durable configuration keeps the
|
|
7
|
+
// original hostContextId, so stored records and fingerprints stay byte-identical;
|
|
8
|
+
// a resumed session declares its own next to it. Both are host identities: a grant
|
|
9
|
+
// may carry either, and the reviewer stays independent of both.
|
|
10
|
+
export function fixHostContexts(configuration){
|
|
11
|
+
const hosts=configuration.hostContextIds??[configuration.hostContextId];
|
|
12
|
+
need(Array.isArray(hosts)&&hosts.length>=1&&hosts.length<=2&&new Set(hosts).size===hosts.length
|
|
13
|
+
&&hosts[0]===configuration.hostContextId,'invalid_host_context');
|
|
14
|
+
hosts.forEach(id);return hosts;
|
|
15
|
+
}
|
|
6
16
|
export function validateCauseReviewer(raw,hostContextId,maxExclusions=32){
|
|
17
|
+
const hosts=Array.isArray(hostContextId)?hostContextId:[hostContextId];
|
|
18
|
+
need(hosts.length>=1&&hosts.length<=2,'invalid_cause_reviewer');hosts.forEach(id);
|
|
7
19
|
need([32,33,34].includes(maxExclusions),'invalid_cause_reviewer');
|
|
8
20
|
const value=json(raw);shape(value,['reviewerId','adapterId','provider','requestedModel','contextId','excludedThreadIds',
|
|
9
21
|
...(Object.hasOwn(value,'workerConfigurationDigest')?['workerConfigurationDigest']:[])]);
|
|
@@ -11,12 +23,13 @@ export function validateCauseReviewer(raw,hostContextId,maxExclusions=32){
|
|
|
11
23
|
for(const key of ['reviewerId','adapterId','contextId'])id(value[key]);text(value.requestedModel);
|
|
12
24
|
need(['codex','claude'].includes(value.provider),'invalid_cause_reviewer');
|
|
13
25
|
need(Array.isArray(value.excludedThreadIds)&&value.excludedThreadIds.length<=maxExclusions,'invalid_cause_reviewer');
|
|
14
|
-
value.excludedThreadIds.forEach(id);need(value.contextId
|
|
26
|
+
value.excludedThreadIds.forEach(id);need(!hosts.includes(value.contextId)&&!value.excludedThreadIds.includes(value.contextId),'invalid_cause_reviewer');
|
|
15
27
|
return value;
|
|
16
28
|
}
|
|
17
29
|
export function causeExpectation(request,configuration){
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
const hosts=fixHostContexts(configuration);
|
|
31
|
+
return {request,developerThreadId:hosts[0],
|
|
32
|
+
excludedThreadIds:[...configuration.causeReview.excludedThreadIds,...hosts.slice(1),request.contextId,
|
|
20
33
|
...(request.payload.reviewPackage.correction?.finalReview?[request.payload.reviewPackage.correction.finalReview.providerThreadId]:[])]};
|
|
21
34
|
}
|
|
22
35
|
export function inspectCauseRegistration(raw,configuration){
|
|
@@ -24,7 +37,7 @@ export function inspectCauseRegistration(raw,configuration){
|
|
|
24
37
|
const r=configuration.causeReview,request=value.request;
|
|
25
38
|
need(request.provider===r.provider&&request.requestedModel===r.requestedModel&&request.contextId===r.contextId,'cause_registration_mismatch');
|
|
26
39
|
validateReviewDispatchGrant(value.grant,{request,reviewerId:r.reviewerId,adapterId:r.adapterId,
|
|
27
|
-
packageDigest:request.payload.reviewPackage.packageDigest,hostContextIds:
|
|
40
|
+
packageDigest:request.payload.reviewPackage.packageDigest,hostContextIds:fixHostContexts(configuration),
|
|
28
41
|
authorizationAt:value.authorizationAt,registeredAt:value.registeredAt});
|
|
29
42
|
inspectProviderCauseReview(JSON.stringify({version:1,kind:'cm-provider-review-observation',
|
|
30
43
|
requestDigest:request.requestDigest,events:[],result:{status:'failed',code:'in_progress'}}),
|