flow-comet 1.6.0 → 1.6.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/.flow-comet/skills/flow-comet/GUIDANCE.md +22 -3
- package/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/SKILL.md +20 -1
- package/.flow-comet/skills/flow-comet/reference/KNOWN-ISSUES-template.md +3 -3
- package/.flow-comet/skills/flow-comet/reference/TEST-MATRIX.md +15 -15
- package/.flow-comet/skills/flow-comet/reference/dsh-platform.md +19 -11
- package/.flow-comet/skills/flow-comet/reference/recovery.md +1 -7
- package/.flow-comet/skills/flow-comet/reference/worktree-notes.md +21 -3
- package/.flow-comet/skills/flow-comet/scripts/contract-check.mjs +41 -31
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +2513 -295
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +459 -11
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +3 -3
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +422 -10
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +140 -226
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +362 -4
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-change/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-design/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +3 -1
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +6 -4
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-open/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +17 -6
- package/.flow-comet/skills/flow-comet-requirement/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-review/SKILL.md +7 -5
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +12 -9
- package/.flow-comet/skills/flow-comet-task/SKILL.md +7 -3
- package/.flow-comet/skills/flow-comet-test/SKILL.md +2 -0
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +7 -5
- package/README.md +45 -119
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// C1 · flow-comet 引擎自测套件(场景数以 SCENARIOS.length 为准:节点门禁 entry/exit 校验正反例与 WARN 渐进、自定义协议加载路由与防线、TASK 签名与 next 推进、handoff Return Contract 与时间序、init 状态机与 hook 写白名单、CONTEXT 自动初始化检测、completedChecks 真实性声明机制(skill-load/record/exit 校验 + 交叉自洽 + 旧兼容)、init 参数误用防护、执行遗漏防护、严格模式、验证失败计数按变更隔离、多趟路由依赖图校验(环/缺失依赖 BLOCK 与混排合法锚)、契约解析失败检测、计数一致性自检(场景数 + 系统测试集项数)、prepare-env 平台选择链、零提交边界与入口首部强制、多趟出口硬化(可运行串行放行与拦截双向锚、单行分号 write_files 容错、收尾态路由静默、死结提示与技能文本锁)、installer 新链路(flow-kit 获取五态 / 桥接健康六态 / 他方保持 / 强制回退)、并行文件依赖检测(写写重叠强判前移 plan 出口 + read 读写弱判渐进 + 触发面排除 + 委托前保持锚 + 扩展名闭合)、directOverride 授权约束(协调者授权留痕正例 / 执行者自切无授权 BLOCK / 越界改 state hook 拦截 / 恢复双路径)、hook state 大小写变体拦截(win32/darwin 闭合 / 其他平台放行)、路由完成判定 fail-closed(缺/未知 status 畸形块不提前放行)、并行文件依赖路径归一化(`.` 段变体重叠检出)、运行时文件位置迁移(白名单搬移 / 迁移前备份与回退 / 新旧并存·符号链接·内容损坏三边界 / 失败保护 / gitignore 三形态保守纳管与幂等)、Comet 感知层剥离(classic 资产有无判定一致 / overlay 协议不再进入叠加分支 +
|
|
2
|
+
// C1 · flow-comet 引擎自测套件(场景数以 SCENARIOS.length 为准:节点门禁 entry/exit 校验正反例与 WARN 渐进、自定义协议加载路由与防线、TASK 签名与 next 推进、handoff Return Contract 与时间序、init 状态机与 hook 写白名单、CONTEXT 自动初始化检测、completedChecks 真实性声明机制(skill-load/record/exit 校验 + 交叉自洽 + 旧兼容)、init 参数误用防护、执行遗漏防护、严格模式、验证失败计数按变更隔离、多趟路由依赖图校验(环/缺失依赖 BLOCK 与混排合法锚)、契约解析失败检测、计数一致性自检(场景数 + 系统测试集项数)、prepare-env 平台选择链、零提交边界与入口首部强制、多趟出口硬化(可运行串行放行与拦截双向锚、单行分号 write_files 容错、收尾态路由静默、死结提示与技能文本锁)、installer 新链路(flow-kit 获取五态 / 桥接健康六态 / 他方保持 / 强制回退)、并行文件依赖检测(写写重叠强判前移 plan 出口 + read 读写弱判渐进 + 触发面排除 + 委托前保持锚 + 扩展名闭合)、directOverride 授权约束(协调者授权留痕正例 / 执行者自切无授权 BLOCK / 越界改 state hook 拦截 / 恢复双路径)、hook state 大小写变体拦截(win32/darwin 闭合 / 其他平台放行)、路由完成判定 fail-closed(缺/未知 status 畸形块不提前放行)、并行文件依赖路径归一化(`.` 段变体重叠检出)、运行时文件位置迁移(白名单搬移 / 迁移前备份与回退 / 新旧并存·符号链接·内容损坏三边界 / 失败保护 / gitignore 三形态保守纳管与幂等)、Comet 感知层剥离(classic 资产有无判定一致 / overlay 协议不再进入叠加分支 + 源码符号检索)、自检清单条目缺失显式报告、受控计划重校重签(replan 授权 fail-closed / 轮次上限与显式续轮 / 幂等空操作 / 重签后 execute 出口放行 / 校验不豁免与任务图分析单源锚)与强制推进留痕(advance-forced 事件 / status.forcedNodes 派生视图))
|
|
3
3
|
//
|
|
4
4
|
// 每个场景 = 独立临时目录(fs.mkdtemp)+ 伪造 .flow-comet/flow-comet-state.json
|
|
5
5
|
// (currentNode + evidence + executionMode:'subagent',满足前置校验)+
|
|
@@ -64,7 +64,7 @@ const CHANGE_ID = 'ch';
|
|
|
64
64
|
// 组件技能(flow-comet-execute / flow-comet-review / flow-comet-verify 等)是 <skillsRoot>
|
|
65
65
|
// 下的同级目录。权威源 checkout → <root>/.flow-comet/skills/;安装副本 → <目标>/.claude|
|
|
66
66
|
// .agents|.dsh/skills/ —— 同一相对推导覆盖全部形态。禁止再假定权威源布局
|
|
67
|
-
// (REPO_ROOT/.flow-comet/skills 在安装副本形态不存在 → 技能文本锁场景 ENOENT
|
|
67
|
+
// (REPO_ROOT/.flow-comet/skills 在安装副本形态不存在 → 技能文本锁场景 ENOENT,端到端冒烟缺陷)。
|
|
68
68
|
function skillsRootForScriptsDir(scriptsDir) {
|
|
69
69
|
return path.resolve(scriptsDir, '..', '..');
|
|
70
70
|
}
|
|
@@ -83,8 +83,29 @@ function resolveComponentSkillFile(nodeSkill, scriptsDir = __dirname) {
|
|
|
83
83
|
return file;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
//
|
|
87
|
-
//
|
|
86
|
+
// 公开产物零代号判据(与 .githooks/internal-codes.mjs 的 BANNED 保持同步——单一来源约定:
|
|
87
|
+
// 本文件随技能包分发,不能 import 主仓私有的 .githooks;改动词表时两份同改,行为必须一致)。
|
|
88
|
+
// 等价性不只靠注释约定:底部自检在权威源检出下读该私有件**逐字符比对**(主仓形态),安装副本
|
|
89
|
+
// 形态输出显式「不适用」描述符(未验证 ≠ 通过)——见词表镜像漂移判据。
|
|
90
|
+
// 除既有过程代号外,本批并入"未公开概念"类**收窄模式**:批次编号 / 批+数字 / 级别编号 /
|
|
91
|
+
// 验收代号 / 工作项编号。模式刻意收窄(词界 + 字母边界):合法中文用法(发布批次 / 维护批次 /
|
|
92
|
+
// 级联 / 变更请求与采纳编号前缀)不命中;判别力与边界锚见维护文档机检场景族(表驱动等价性:
|
|
93
|
+
// 词表每个分支各一条正例 + 一条对应反例,另加本文件注释层零残留——三向自检)。禁止放宽为裸词
|
|
94
|
+
// ——那会误伤公开面大量合法中文用法。
|
|
95
|
+
// 2026-10-01 收窄一处:「批 + 数字」补中文序数否定环视——「第 N 批 + 数字」是普通计数短语
|
|
96
|
+
// (合法中文用法),旧模式把它当未公开概念命中。序号与「批」之间隔着数字(阿拉伯或中文),
|
|
97
|
+
// 故环视必须吸收这段数字(变长环视),且**允许两侧空格**(`第 1 批 2 次` 同属普通计数短语);
|
|
98
|
+
// 工作项编号补**尾界**(要求恰好两位,`R-123` 形态不命中)。以上均属"只收窄不放宽";
|
|
99
|
+
// 只排除这两类形态,其余判定不变。无空格连写形态(如「批次2」)刻意不命中:实测受检三层 0 处,
|
|
100
|
+
// 放宽会增误报。本正则与 `.githooks/internal-codes.mjs` 的 `BANNED` 保持 **source 逐字符相等**
|
|
101
|
+
// (主仓形态由镜像漂移判据强制,改一侧必须同步另一侧)。
|
|
102
|
+
const PUBLIC_CODE_RE = /\bS\d{1,3}\b|T-FIX|batch-(?![a-z])|D-\d+|P[0-7]\b|round\s*\d|dogfood|内部|批次 [A-Z0-9]|(?<!第 ?[0-9一二三四五六七八九十百千万]* ?)批 ?\d|级 [0-9]|UAT-\d|(?<![A-Za-z])R-\d{2}(?![A-Za-z0-9_-])/;
|
|
103
|
+
|
|
104
|
+
// 场景数一致性自检清单(15 文件 = 9 分发组 + 6 维护者组,全变体:ALL n SCENARIOS PASSED / n scenarios / n 场景 / n/n)——
|
|
105
|
+
// 数字由下方常量清单**推导**、不硬编码:9 = SCENARIO_COUNT_FILES 9 条与 SYSTEM_TEST_COUNT_FILES 4 条的
|
|
106
|
+
// 并集(后者是前者子集);6 = SCENARIO_COUNT_FILES_MAINTAINER 6 条与 SYSTEM_TEST_COUNT_FILES_MAINTAINER
|
|
107
|
+
// 6 条的并集(后者是前者子集,故并集即 6 条)——底部自检输出「受检面: n 文件」实际值,清单/数字漂移即可见(防再漂移)。
|
|
108
|
+
// 场景数自检与底部自检共用同一清单/同一实现(自检常量同步:SCENARIOS.length 变更 → 全部受检文件须同步)。
|
|
88
109
|
// 分两组按"分发形态"划界(AC-14:条目缺失必须显式报告,不得静默跳过——幽灵条目无处藏身):
|
|
89
110
|
// ① 分发组:随仓库分发(受版本控制),**任何**权威源检出都必须存在——维护者工作副本、
|
|
90
111
|
// CI 全新检出、worktree 检出皆然 → 条目缺失即报错(幽灵条目在此被强制暴露)。
|
|
@@ -92,11 +113,14 @@ function resolveComponentSkillFile(nodeSkill, scriptsDir = __dirname) {
|
|
|
92
113
|
// worktree 检出**整组必然缺席** → 判据取"整组是否在场"而非"单条目是否在场":整组缺席 =
|
|
93
114
|
// 该检出无此文档面,跳过该组;整组在场时同样逐条强制存在与同步,缺失即报错。
|
|
94
115
|
// (单条目静默跳过正是本 change 修正的缺陷——故跳过粒度只能是"整组",不能是"单条"。)
|
|
95
|
-
// CLAUDE.md 为主仓私有指导文件(gitignore 不随 clone
|
|
96
|
-
//
|
|
116
|
+
// CLAUDE.md 为主仓私有指导文件(gitignore 不随 clone 分发)——现列入**维护者组**受检清单:
|
|
117
|
+
// 与 docs/internal/ 同进同退(该目录缺席即整组跳过,非维护者检出不会误红),主仓形态下其
|
|
118
|
+
// 计数不再由人工维护。分发组仍只含随仓库分发的文件。
|
|
119
|
+
// 2026-09-27 文档重构:计数只允许出现在入口页徽章行、发布权威与机器锁面(PR 模板 / CI / 欢迎消息 / 变更日志);
|
|
120
|
+
// 其余公开文档一律改述为「见 VERSIONS」,因此本清单随之收缩(此前把 CONTRIBUTING/INSTALLATION/MECHANISM 也列进来,
|
|
121
|
+
// 与单一权威策略冲突:同一数字散落越多越容易漂移)。
|
|
97
122
|
const SCENARIO_COUNT_FILES = [
|
|
98
|
-
'README.md', 'README-zh.md',
|
|
99
|
-
'docs/INSTALLATION.md', 'docs/INSTALLATION-zh.md', 'docs/MECHANISM.md', 'docs/MECHANISM-zh.md',
|
|
123
|
+
'README.md', 'README-zh.md',
|
|
100
124
|
'docs/VERSIONS.md', 'docs/VERSIONS-zh.md', '.github/PULL_REQUEST_TEMPLATE.md',
|
|
101
125
|
'CHANGELOG.md', 'CHANGELOG-zh.md',
|
|
102
126
|
// CI workflow 文件纳入场景数自检(此前盲区——ci.yml 注释/greeting 欢迎消息的
|
|
@@ -114,8 +138,15 @@ const SCENARIO_COUNT_FILES_MAINTAINER = [
|
|
|
114
138
|
'docs/internal/ARCHITECTURE.md', 'docs/internal/DOC-CHECKLIST.md', 'docs/internal/MECHANISM.md',
|
|
115
139
|
'docs/internal/ROADMAP.md',
|
|
116
140
|
'docs/internal/WORKING-METHOD.md',
|
|
141
|
+
// 主仓私有指导面(见上方分组说明):纳入维护者组后其场景数由机检维护;docs/internal/ 缺席
|
|
142
|
+
// 的检出形态整组跳过(该文件同样被 gitignore,两种缺席同源)。
|
|
143
|
+
'CLAUDE.md',
|
|
117
144
|
];
|
|
118
145
|
const MAINTAINER_DOC_DIR = 'docs/internal';
|
|
146
|
+
// 三册显式清单(维护文档机检扫描面;与 docs/internal/*.md、.specs/adr/*.md 并列):
|
|
147
|
+
// 知识权威累积面,更新频率高——写入即需校验。显式清单(不用 .specs/*.md 通配)可预测、
|
|
148
|
+
// 可按册 allowlist,未来新增册需手工登记(与计数受检清单同纪律)。
|
|
149
|
+
const MAINTAINER_BOOKS = ['.specs/CONTEXT.md', '.specs/LESSONS.md', '.specs/CHANGELOG.md'];
|
|
119
150
|
|
|
120
151
|
// 系统测试集项数受检清单——与场景数清单**并列不合并**:两者数字不同、受检文件面也不同
|
|
121
152
|
// (项数只出现在下面这些文档里;场景数散布更广,含 README / 模板 / CI)。清单本身是
|
|
@@ -123,21 +154,22 @@ const MAINTAINER_DOC_DIR = 'docs/internal';
|
|
|
123
154
|
// 漂移只能靠人工发现)。分组语义与场景数清单一致(见上方分组说明):分发组恒检,
|
|
124
155
|
// 维护者组整组在场时逐条严检。
|
|
125
156
|
const SYSTEM_TEST_COUNT_FILES = [
|
|
126
|
-
'CONTRIBUTING.md', 'CONTRIBUTING-zh.md',
|
|
127
|
-
'docs/MECHANISM.md', 'docs/MECHANISM-zh.md',
|
|
128
157
|
'docs/VERSIONS.md', 'docs/VERSIONS-zh.md',
|
|
129
158
|
'CHANGELOG.md', 'CHANGELOG-zh.md',
|
|
130
159
|
];
|
|
131
160
|
const SYSTEM_TEST_COUNT_FILES_MAINTAINER = [
|
|
132
|
-
'docs/internal/ARCHITECTURE.md', 'docs/internal/DOC-CHECKLIST.md',
|
|
161
|
+
'docs/internal/ARCHITECTURE.md', 'docs/internal/DOC-CHECKLIST.md', 'docs/internal/MECHANISM.md',
|
|
133
162
|
'docs/internal/ROADMAP.md', 'docs/internal/WORKING-METHOD.md',
|
|
163
|
+
// 与场景数维护者组同面同序(该组为子集关系,便于并集口径一眼可核):机制知识册纳入后
|
|
164
|
+
// 其项数由机检维护;CLAUDE.md 同属主仓私有面。
|
|
165
|
+
'CLAUDE.md',
|
|
134
166
|
];
|
|
135
167
|
// 刻意不收进清单的项数副本(逐条留痕,避免"清单外漏网"变成无声的例外):
|
|
136
|
-
// - CLAUDE.md:主仓私有指导文件,计数人工维护(场景数清单同一决策);
|
|
137
|
-
// - docs/internal/MECHANISM.md:其项数写法与当前值不一致,由维护批次单独同步——收进清单
|
|
138
|
-
// 就等于要求与本批同时修正;
|
|
139
168
|
// - .specs/CONTEXT.md:流程工件目录随 change 清理/归档——收进清单会让套件在维护者检出
|
|
140
169
|
// 依赖流程工件状态。
|
|
170
|
+
// 两条原排除说明已结清:CLAUDE.md 与 docs/internal/MECHANISM.md 现均列入维护者组受检清单
|
|
171
|
+
// (前者随 docs/internal/ 缺席整组跳过;后者的项数已与当前值同步)。presence 之外另有 stale
|
|
172
|
+
// 检测兜住"在场但值过期"的形态(见下方 staleCountProblems)。
|
|
141
173
|
const SYSTEM_TEST_SCRIPT_REL = '.flow-comet/skills/flow-comet/scripts/system-test.mjs';
|
|
142
174
|
|
|
143
175
|
let passed = 0;
|
|
@@ -177,6 +209,99 @@ function scanCountFiles(files, variants, root = REPO_ROOT) {
|
|
|
177
209
|
return { missing, unsynced };
|
|
178
210
|
}
|
|
179
211
|
|
|
212
|
+
// 维护者面的在场探针(单一来源):以**组外**目录 docs/internal/ 是否存在为判据——不能用组内
|
|
213
|
+
// 成员当探针(成员缺失会被误判成「整组缺席」而跳过,正好藏起该成员的缺失)。计数受检清单的
|
|
214
|
+
// 维护者组与 maintainerFaceSkips 的计数面描述符共用本判据(单一决策,避免多处各写一份而漂移)。
|
|
215
|
+
function maintainerFacePresent(root = REPO_ROOT) {
|
|
216
|
+
return fs.existsSync(path.join(root, MAINTAINER_DOC_DIR));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ---------- 计数 stale 检测(presence 之外的判别力补足) ----------
|
|
220
|
+
// presence 只能证明"当前值在场",证不了"旧值不在场":维护面曾长期带着无标记旧值仍全绿。
|
|
221
|
+
// 判据:受检面里出现**计数形态 token**、数值落在合理量程、且不等于当前值、且行内没有历史
|
|
222
|
+
// 标记 → 报"旧值未标记"(在场 + 旧值不在场两条一起才叫同步)。
|
|
223
|
+
// ① token 白名单(只认这几种计数写法,避免把通用比值/编号误当计数):`N 场景` / `N scenarios` /
|
|
224
|
+
// `N 项` / `N items` / `ALL N SCENARIOS` / `N/N`——最后一种还须**同行点名套件**
|
|
225
|
+
// (guard-self-test|system-test|SYSTEM TEST|SCENARIOS|场景|项|items|scenarios),
|
|
226
|
+
// 否则 `69/69 = 100%` 一类通用比值会被误伤(设计期实测口径)。
|
|
227
|
+
// ② 量程门:30~400 之外不参与(把版本号、年份、行号一类数字挡在外面)。
|
|
228
|
+
// ③ 历史标记豁免:行内出现"历史 / history / VERSIONS"即视为已标注的历史值。另有两枚等价标记
|
|
229
|
+
// `本轮`(维护笔记记述既往事件的固定措辞)与 `过时`(行内自述该值已过期)——实测受检面里
|
|
230
|
+
// 仅有的两处旧值都出现在这类回顾叙述行里,它们是**已标注**的历史值,不是"未标记旧值"。
|
|
231
|
+
// 受检面(staleCountTargets):维护者面(docs/internal/ 全册 + CLAUDE.md)+ 参考册
|
|
232
|
+
// (reference/*.md,路径从本脚本自身位置推导)。**分发组计数清单不入本面**:变更日志按语义
|
|
233
|
+
// 就是历史记录(双语实测 42 处既往计数),纳入即灾难性误报;分发组的"当前值在场"要求照旧
|
|
234
|
+
// 由 presence 判据覆盖(见上方清单)。
|
|
235
|
+
const STALE_COUNT_TOKEN_RE = /\b(\d{2,4})\s*(?:场景|scenarios|项|items)|\b(\d{2,4})\/(\d{2,4})\b|\bALL (\d{2,4}) SCENARIOS\b/g;
|
|
236
|
+
const STALE_COUNT_SUITE_KEYWORD_RE = /guard-self-test|system-test|SYSTEM TEST|SCENARIOS|场景|项|items|scenarios/;
|
|
237
|
+
const STALE_COUNT_HISTORY_MARKER_RE = /历史|history|VERSIONS|本轮|过时|outdated|superseded/i;
|
|
238
|
+
const STALE_COUNT_MIN = 30;
|
|
239
|
+
const STALE_COUNT_MAX = 400;
|
|
240
|
+
// 参考册面(分发参考册):技能树从本脚本自身位置推导——权威源与各安装副本(.claude / .agents /
|
|
241
|
+
// .dsh/skills)同一推导覆盖,不假定权威源布局(与技能树布局感知注释同一纪律)。
|
|
242
|
+
const REFERENCE_FACE_DIR_REL = path
|
|
243
|
+
.relative(REPO_ROOT, path.join(__dirname, '..', 'reference'))
|
|
244
|
+
.split(path.sep).join('/');
|
|
245
|
+
|
|
246
|
+
function staleCountTargets(root = REPO_ROOT) {
|
|
247
|
+
const targets = [];
|
|
248
|
+
const internalDir = path.join(root, MAINTAINER_DOC_DIR);
|
|
249
|
+
if (fs.existsSync(internalDir)) {
|
|
250
|
+
for (const name of fs.readdirSync(internalDir)) {
|
|
251
|
+
if (name.endsWith('.md')) targets.push(path.posix.join(MAINTAINER_DOC_DIR, name));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const referenceDir = path.join(root, REFERENCE_FACE_DIR_REL);
|
|
255
|
+
if (fs.existsSync(referenceDir)) {
|
|
256
|
+
for (const name of fs.readdirSync(referenceDir)) {
|
|
257
|
+
if (name.endsWith('.md')) targets.push(path.posix.join(REFERENCE_FACE_DIR_REL, name));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (fs.existsSync(path.join(root, 'CLAUDE.md'))) targets.push('CLAUDE.md');
|
|
261
|
+
return targets;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// counts = 当前值集合(场景数 / 系统测试集项数;派生失败时按 null 过滤——派生失败本身已由
|
|
265
|
+
// 计数一致性判据显式报告,不在此重复)。返回问题描述数组(空数组 = 无未标记旧值)。
|
|
266
|
+
function staleCountProblems(counts, root = REPO_ROOT) {
|
|
267
|
+
const problems = [];
|
|
268
|
+
const current = new Set(counts.filter((v) => typeof v === 'number' && Number.isFinite(v)));
|
|
269
|
+
for (const rel of staleCountTargets(root)) {
|
|
270
|
+
let text;
|
|
271
|
+
try {
|
|
272
|
+
text = fs.readFileSync(path.join(root, rel), 'utf8');
|
|
273
|
+
} catch (e) {
|
|
274
|
+
// 与维护文档机检同型:读取失败不得静默跳过("未执行 ≠ 通过")。
|
|
275
|
+
const reason = e && e.code ? e.code : (e && e.message ? e.message : String(e));
|
|
276
|
+
problems.push('无法读取: ' + rel + ': ' + reason);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const lines = text.split(/\r?\n/);
|
|
280
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
281
|
+
const line = lines[i];
|
|
282
|
+
if (STALE_COUNT_HISTORY_MARKER_RE.test(line)) continue;
|
|
283
|
+
for (const m of line.matchAll(STALE_COUNT_TOKEN_RE)) {
|
|
284
|
+
let value = null;
|
|
285
|
+
if (m[1] !== undefined) {
|
|
286
|
+
value = Number(m[1]);
|
|
287
|
+
} else if (m[2] !== undefined) {
|
|
288
|
+
if (m[2] !== m[3]) continue; // 非等值比值(如 69/70)不是计数形态
|
|
289
|
+
if (!STALE_COUNT_SUITE_KEYWORD_RE.test(line)) continue; // 通用比值须同行点名套件
|
|
290
|
+
value = Number(m[2]);
|
|
291
|
+
} else {
|
|
292
|
+
value = Number(m[4]);
|
|
293
|
+
}
|
|
294
|
+
if (!Number.isFinite(value) || value < STALE_COUNT_MIN || value > STALE_COUNT_MAX) continue;
|
|
295
|
+
if (current.has(value)) continue;
|
|
296
|
+
problems.push('旧值未标记: ' + rel + ':' + (i + 1) + ' 计数 ' + m[0].trim()
|
|
297
|
+
+ '(当前值 ' + [...current].join(' / ') + ')——请改写为当前值,或补历史标记'
|
|
298
|
+
+ '(历史 / VERSIONS 指针 / 过时 说明)');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return problems;
|
|
303
|
+
}
|
|
304
|
+
|
|
180
305
|
// 场景数一致性检查(单一来源):场景 105 与底部自检共用同一实现与同一判据。
|
|
181
306
|
// 返回问题描述数组(空数组 = 通过)。
|
|
182
307
|
// root 可覆盖扫描根(默认仓库根)——同上:仅为可测性接缝(生产调用不传,判据与改前一致)。
|
|
@@ -186,7 +311,7 @@ function scenarioCountSyncProblems(n, root = REPO_ROOT) {
|
|
|
186
311
|
if (dist.missing.length > 0) problems.push('受检条目文件缺失(幽灵条目): ' + dist.missing.join(', '));
|
|
187
312
|
if (dist.unsynced.length > 0) problems.push('场景数未同步(应为 ' + n + '): ' + dist.unsynced.join(', '));
|
|
188
313
|
// 维护者组:整组在场才检查(CI 全新检出 / worktree 检出整组必然缺席——见清单分组说明)
|
|
189
|
-
if (
|
|
314
|
+
if (maintainerFacePresent(root)) {
|
|
190
315
|
const mnt = scanCountFiles(SCENARIO_COUNT_FILES_MAINTAINER, scenarioCountVariants(n), root);
|
|
191
316
|
if (mnt.missing.length > 0) problems.push('维护者文档条目文件缺失(幽灵条目): ' + mnt.missing.join(', '));
|
|
192
317
|
if (mnt.unsynced.length > 0) problems.push('维护者文档场景数未同步(应为 ' + n + '): ' + mnt.unsynced.join(', '));
|
|
@@ -230,7 +355,7 @@ function systemTestCountSyncProblems(root = REPO_ROOT) {
|
|
|
230
355
|
const dist = scanCountFiles(SYSTEM_TEST_COUNT_FILES, systemTestCountVariants(itemCount), root);
|
|
231
356
|
if (dist.missing.length > 0) problems.push('系统测试集项数条目文件缺失(幽灵条目): ' + dist.missing.join(', '));
|
|
232
357
|
if (dist.unsynced.length > 0) problems.push('系统测试集项数未同步(应为 ' + itemCount + '): ' + dist.unsynced.join(', '));
|
|
233
|
-
if (
|
|
358
|
+
if (maintainerFacePresent(root)) {
|
|
234
359
|
const mnt = scanCountFiles(SYSTEM_TEST_COUNT_FILES_MAINTAINER, systemTestCountVariants(itemCount), root);
|
|
235
360
|
if (mnt.missing.length > 0) problems.push('维护者文档系统测试集项数条目文件缺失(幽灵条目): ' + mnt.missing.join(', '));
|
|
236
361
|
if (mnt.unsynced.length > 0) problems.push('维护者文档系统测试集项数未同步(应为 ' + itemCount + '): ' + mnt.unsynced.join(', '));
|
|
@@ -238,19 +363,128 @@ function systemTestCountSyncProblems(root = REPO_ROOT) {
|
|
|
238
363
|
return problems;
|
|
239
364
|
}
|
|
240
365
|
|
|
241
|
-
//
|
|
366
|
+
// 计数一致性检查(两套计数合并 + stale 检测):场景 105 与底部自检共用,两处判据不会漂移。
|
|
367
|
+
// 顺序有意为之:先跑 presence(含派生源缺失/失败,必要时 fail-closed 抛出),再跑 stale——
|
|
368
|
+
// 当前值取自同一派生(场景数 = SCENARIOS.length,项数 = 系统测试集脚本派生),不二次硬编码。
|
|
242
369
|
function countSyncProblems(root = REPO_ROOT) {
|
|
243
|
-
|
|
370
|
+
const problems = [
|
|
371
|
+
...scenarioCountSyncProblems(SCENARIOS.length, root),
|
|
372
|
+
...systemTestCountSyncProblems(root),
|
|
373
|
+
];
|
|
374
|
+
const { count: itemCount } = readSystemTestItemCount(root);
|
|
375
|
+
problems.push(...staleCountProblems([SCENARIOS.length, itemCount], root));
|
|
376
|
+
return problems;
|
|
244
377
|
}
|
|
245
378
|
|
|
246
|
-
// 维护文档机检(docs-governance):覆盖 CI
|
|
379
|
+
// 维护文档机检(docs-governance):覆盖 CI 结构上不可见的维护者面——docs/internal/、
|
|
380
|
+
// .specs/adr/ 与三册显式清单(见 MAINTAINER_BOOKS)的
|
|
247
381
|
// ① 死引用(文档中的仓库相对路径引用必须存在);② ROADMAP 最低结构(Now / Next / Later / Open decisions)。
|
|
248
|
-
//
|
|
382
|
+
// 与计数检查同构:全部目标面缺席(CI 全新检出 / worktree 检出)→ 跳过(空数组,不误红)。
|
|
249
383
|
// 判别力边界(实测教训):提取必须取「完整路径 token」而非后缀子串;scripts/… 一类简写按技能树基准解析;
|
|
250
384
|
// 占位符 / 通配 / 未来路径不参与判定(见 ALLOWLIST)。
|
|
251
|
-
|
|
385
|
+
// 解析基准(数据驱动,扩展条目不写逻辑分支):前四条为既有基准(技能树 / 包根 / 上游),
|
|
386
|
+
// 新增基准覆盖权威树根(.flow-comet)、技能树根(.flow-comet/skills、.claude/skills、
|
|
387
|
+
// .agents/skills、.dsh/skills)、规则树根(.flow-comet/rules、.claude/rules)与平台副本根
|
|
388
|
+
// (.claude)——用于解析 `rules/…`、`flow-comet-*/SKILL.md` 这类树根相对形态。
|
|
389
|
+
const INTERNAL_DOC_REF_BASES = [
|
|
390
|
+
'.flow-comet/skills/flow-comet', '.claude/skills/flow-comet', '', 'flow-kit',
|
|
391
|
+
'.flow-comet', '.flow-comet/skills', '.flow-comet/rules',
|
|
392
|
+
'.claude', '.claude/skills', '.claude/rules', '.agents/skills', '.dsh/skills',
|
|
393
|
+
];
|
|
394
|
+
// 窄域报告规则(判别力补丁):基准全部未解析时,首段属于下列「仓库内树根相对形态」族的引用
|
|
395
|
+
// 必须按死引用报告——即使顶层目录在仓库根不存在也报(这正是旧逻辑「顶层整体缺席 → 跳过」
|
|
396
|
+
// 会静默放过的形态)。族为声明式清单,只覆盖已确证的形态:flow-comet* 技能目录 / rules。
|
|
397
|
+
const INTERNAL_DOC_REF_TREE_ROOT_FAMILIES = [/^flow-comet[A-Za-z0-9-]*$/, /^rules$/];
|
|
398
|
+
function isTreeRootRelativeRef(ref) {
|
|
399
|
+
const firstSegment = ref.split('/')[0];
|
|
400
|
+
return INTERNAL_DOC_REF_TREE_ROOT_FAMILIES.some((re) => re.test(firstSegment));
|
|
401
|
+
}
|
|
402
|
+
// 声明式族(取代"顶层段不存在即静默跳过"):解析失败后仍允许跳过的形态必须**逐条显式登记**,
|
|
403
|
+
// 未登记者一律按死引用报告(fail-closed)。旧语义实测吞掉过指向已移除临时区的真实残留——
|
|
404
|
+
// 隐含边界把"允许"藏进了代码,声明式族把允许面变成可见清单,新增跳过必须显式登记。
|
|
405
|
+
// ① 外部命名空间族(前缀声明):平台侧命名空间,本仓库根天然不存在。
|
|
406
|
+
const EXTERNAL_NAMESPACE_PREFIXES = ['DSH_HOME/', 'dsh-tui/', 'dsh-base/'];
|
|
407
|
+
// ② 退役命名空间允许面(**按角色 / 前缀匹配**,不再逐条硬编码精确 ref):仅限**记录该迁移**
|
|
408
|
+
// 的决策件与决策册——退役命名空间在那里是历史事实,改掉反而丢失迁移记录。
|
|
409
|
+
// 匹配 = 文件面(前缀形态 `filePrefix` 或角色形态 `role`)+ 引用面(退役命名空间前缀)。
|
|
410
|
+
// 精确 ref 硬编码的脆性在于:文件改名即静默失配 → 合法历史迁移记录被误报死引用(误红),
|
|
411
|
+
// 而误红会诱导维护者删掉历史事实。改名不改角色,故按角色/前缀匹配;反过来**不**放宽
|
|
412
|
+
// 引用面与文件面之外的部分:未登记文件 / 未登记命名空间的引用照旧一律报(fail-closed)。
|
|
413
|
+
const RETIRED_NAMESPACE_PREFIX = '.comet/';
|
|
414
|
+
// 决策册角色判定:`.specs` 下的决策账本族文件(含改名后的 `CONTEXT-<后缀>.md` 形态)——
|
|
415
|
+
// 角色判定按语义而非精确文件名,改名不该让合法迁移记录变成死引用误报。
|
|
416
|
+
// 边界(登记):角色判定只作用于**扫描目标**(该族文件本身须在受检目标清单内才会被扫描)。
|
|
417
|
+
function isDecisionLedgerFile(rel) {
|
|
418
|
+
return /^\.specs\/CONTEXT(?:[-.][A-Za-z0-9_.-]+)?\.md$/i.test(rel);
|
|
419
|
+
}
|
|
420
|
+
// 文件面匹配器(声明式):kind = filePrefix(路径前缀,改名后缀不影响)| role(角色判定函数)。
|
|
421
|
+
const RETIRED_NAMESPACE_FILE_MATCHERS = {
|
|
422
|
+
'decision-ledger': isDecisionLedgerFile,
|
|
423
|
+
};
|
|
424
|
+
const RETIRED_NAMESPACE_ALLOWLIST = [
|
|
425
|
+
{
|
|
426
|
+
filePrefix: '.specs/adr/ADR-009',
|
|
427
|
+
refPrefix: RETIRED_NAMESPACE_PREFIX,
|
|
428
|
+
reason: '记录运行时命名空间迁移的决策件:退役命名空间作为迁移前事实保留(改名不改角色)',
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
filePrefix: '.specs/adr/ADR-010',
|
|
432
|
+
refPrefix: RETIRED_NAMESPACE_PREFIX,
|
|
433
|
+
reason: '同族决策件(迁移决策的后续修订):迁移前事实同样保留,按前缀匹配避免改名失配',
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
role: 'decision-ledger',
|
|
437
|
+
refPrefix: RETIRED_NAMESPACE_PREFIX,
|
|
438
|
+
reason: '决策册角色(.specs 下决策账本族):已锁决策记录迁移事实(退役命名空间的历史形态)',
|
|
439
|
+
},
|
|
440
|
+
];
|
|
441
|
+
// 允许面条目匹配(单一实现):文件面(前缀 / 角色)与引用面(前缀)同时命中才算登记在案。
|
|
442
|
+
function matchesRetiredNamespaceEntry(entry, rel, ref) {
|
|
443
|
+
const refOk = typeof entry.refPrefix === 'string' && ref.startsWith(entry.refPrefix);
|
|
444
|
+
if (!refOk) return false;
|
|
445
|
+
if (typeof entry.filePrefix === 'string' && rel.startsWith(entry.filePrefix)) return true;
|
|
446
|
+
if (typeof entry.role === 'string') {
|
|
447
|
+
const roleMatcher = RETIRED_NAMESPACE_FILE_MATCHERS[entry.role];
|
|
448
|
+
if (typeof roleMatcher === 'function' && roleMatcher(rel)) return true;
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
// ③ 示例形态允许面(逐条 {file, ref, reason}):文档里的示意路径。**当前为空清单**——
|
|
453
|
+
// 空清单的语义是「无任何示例允许项」(未登记即报,fail-closed),不是「该判据不生效」;
|
|
454
|
+
// 查询带长度短路(零条目时不进入匹配),避免把零条目扩展点当成隐式权限。
|
|
455
|
+
// 出现新示例时在此登记(未登记即报,不再静默跳过)。
|
|
456
|
+
const EXAMPLE_REF_ALLOWLIST = [];
|
|
457
|
+
function isDeclaredReferenceSkip(rel, ref) {
|
|
458
|
+
if (EXTERNAL_NAMESPACE_PREFIXES.some((prefix) => ref.startsWith(prefix))) return true;
|
|
459
|
+
if (RETIRED_NAMESPACE_ALLOWLIST.some((e) => matchesRetiredNamespaceEntry(e, rel, ref))) return true;
|
|
460
|
+
if (EXAMPLE_REF_ALLOWLIST.length > 0
|
|
461
|
+
&& EXAMPLE_REF_ALLOWLIST.some((e) => e.file === rel && e.ref === ref)) return true;
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
252
464
|
const INTERNAL_DOC_REF_ALLOWLIST = new Set(['.specs/archive/CONTEXT-history.md']);
|
|
253
|
-
|
|
465
|
+
// 引用提取:既有形态(≥1 段路径 + 扩展名)+ **可选行号后缀**(`:N` / `:N-M` / 逗号列表
|
|
466
|
+
// `:N,M`)——行号存在性与不越界判据需要把行号一起取出来(见 internalDocsProblems)。
|
|
467
|
+
const INTERNAL_DOC_REF_RE = /(?<![A-Za-z0-9_.\-\/])(\.?(?:[A-Za-z0-9_][A-Za-z0-9_.\-]*\/)+[A-Za-z0-9_.\-]+\.(?:md|mjs|cjs|js|ts|json|ya?ml|sh|patch|toml))(?::(\d+(?:-\d+)?(?:\s*,\s*\d+(?:-\d+)?)*))?(?![A-Za-z0-9])/gm;
|
|
468
|
+
// 并列写法护栏:首段**本身带文件扩展名**的 token 不是路径引用(如 `TEST.md/REVIEW.md` 是两个
|
|
469
|
+
// 文件名并列写法)——不参与解析(存在性判据与行号判据同此)。判据必须收窄到"首段带扩展名":
|
|
470
|
+
// 用"首段含 `.`"会把 `.specs/…` / `.flow-comet/…` 这类隐藏目录一并误排(设计期实测该写法把
|
|
471
|
+
// 5 处带行号引用压成 3 处)。
|
|
472
|
+
const INTERNAL_DOC_REF_PARALLEL_RE = /\.(?:md|mjs|cjs|js|ts|json|ya?ml|sh|patch|toml)$/i;
|
|
473
|
+
|
|
474
|
+
// 行号后缀 → 数值数组(区间取两端;逗号列表逐项展开)。
|
|
475
|
+
function parseRefLineNumbers(suffix) {
|
|
476
|
+
if (!suffix) return [];
|
|
477
|
+
const out = [];
|
|
478
|
+
for (const part of suffix.split(/\s*,\s*/)) {
|
|
479
|
+
if (part.includes('-')) {
|
|
480
|
+
const [start, end] = part.split('-');
|
|
481
|
+
out.push(Number(start), Number(end));
|
|
482
|
+
} else {
|
|
483
|
+
out.push(Number(part));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return out;
|
|
487
|
+
}
|
|
254
488
|
|
|
255
489
|
function internalDocRefCandidates(text) {
|
|
256
490
|
const out = [];
|
|
@@ -260,21 +494,33 @@ function internalDocRefCandidates(text) {
|
|
|
260
494
|
for (const m of lines[i].matchAll(INTERNAL_DOC_REF_RE)) {
|
|
261
495
|
const token = m[1];
|
|
262
496
|
if (token.includes('*') || token.includes('<')) continue; // 通配 / 占位符
|
|
263
|
-
|
|
497
|
+
if (INTERNAL_DOC_REF_PARALLEL_RE.test(token.split('/')[0])) continue; // 并列写法(见上方护栏)
|
|
498
|
+
const key = i + 1 + ' ' + token + ':' + (m[2] || '');
|
|
264
499
|
if (seen.has(key)) continue;
|
|
265
500
|
seen.add(key);
|
|
266
|
-
out.push({ ref: token, line: i + 1 });
|
|
501
|
+
out.push({ ref: token, line: i + 1, lineRefs: parseRefLineNumbers(m[2]) });
|
|
267
502
|
}
|
|
268
503
|
}
|
|
269
504
|
return out;
|
|
270
505
|
}
|
|
271
506
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
507
|
+
// 引用解析(单一实现):按声明式基准清单逐个试解析,命中即返回绝对路径;全部失败返回 null。
|
|
508
|
+
function resolveInternalDocRef(ref, root = REPO_ROOT) {
|
|
509
|
+
for (const base of INTERNAL_DOC_REF_BASES) {
|
|
510
|
+
const p = base === '' ? path.join(root, ref) : path.join(root, base, ref);
|
|
511
|
+
if (fs.existsSync(p)) return p;
|
|
512
|
+
}
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// 维护文档机检的受检目标清单(单一来源):docs/internal/*.md(目录在场时)+ .specs/adr/*.md
|
|
517
|
+
// + 三册显式清单(MAINTAINER_BOOKS)。三册是知识权威累积面、更新频率高(写入即需校验);
|
|
518
|
+
// 显式清单可预测,未来新增第四册需手工登记(与计数受检清单同纪律)。
|
|
519
|
+
// 全部目标面缺席 → 空数组(组缺席语义;internalDocsProblems 与 maintainerFaceSkips 共用同一判据)。
|
|
520
|
+
function internalDocTargets(root = REPO_ROOT) {
|
|
276
521
|
const targets = [];
|
|
277
|
-
|
|
522
|
+
const internalDir = path.join(root, MAINTAINER_DOC_DIR);
|
|
523
|
+
if (fs.existsSync(internalDir)) {
|
|
278
524
|
for (const name of fs.readdirSync(internalDir)) {
|
|
279
525
|
if (name.endsWith('.md')) targets.push(path.posix.join(MAINTAINER_DOC_DIR, name));
|
|
280
526
|
}
|
|
@@ -285,37 +531,191 @@ function internalDocsProblems(root = REPO_ROOT) {
|
|
|
285
531
|
if (name.endsWith('.md')) targets.push(path.posix.join('.specs', 'adr', name));
|
|
286
532
|
}
|
|
287
533
|
}
|
|
288
|
-
|
|
534
|
+
for (const rel of MAINTAINER_BOOKS) {
|
|
535
|
+
if (fs.existsSync(path.join(root, rel))) targets.push(rel);
|
|
536
|
+
}
|
|
537
|
+
return targets;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// ROADMAP 表头新鲜度(内容锚):声明式表头行 `> 最后更新:<YYYY-MM-DD>` 的日期必须 ≥ 该文件
|
|
541
|
+
// 正文中出现过的最大日期。维护面无 git 跟踪文件(实测 0 跟踪),提交日锚不可得——内容锚纯结构、
|
|
542
|
+
// 可夹具驱动。未声明表头的目标跳过(登记边界:表头即"最后更新"声明,没声明就没得比)。
|
|
543
|
+
const ROADMAP_HEADER_RE = /^\s*>\s*最后更新[::]\s*(20\d{2}-\d{2}-\d{2})/m;
|
|
544
|
+
const INTERNAL_DOC_DATE_RE = /20\d{2}-\d{2}-\d{2}/g;
|
|
545
|
+
// 归档目录条目:`<日期>-<change-id>`。
|
|
546
|
+
const ARCHIVE_DIR_ENTRY_RE = /^\d{4}-\d{2}-\d{2}-(.+)$/;
|
|
547
|
+
|
|
548
|
+
// 行号存在与不越界判定(结构级;单一实现):只在引用本身解析成功后才调用——引用不存在时由
|
|
549
|
+
// 死引用判据负责报告(同一处只报一次,不叠两条)。区间取两端、逗号列表逐项,逐个校验 1..N。
|
|
550
|
+
function lineNumberProblems(rel, entry, resolvedPath, lineCountOf) {
|
|
551
|
+
const problems = [];
|
|
552
|
+
if (entry.lineRefs.length === 0) return problems;
|
|
553
|
+
const total = lineCountOf(resolvedPath);
|
|
554
|
+
if (total === null) return problems; // 目标瞬时不可读:存在性已通过,行号按不可判跳过
|
|
555
|
+
for (const num of entry.lineRefs) {
|
|
556
|
+
if (num < 1 || num > total) {
|
|
557
|
+
problems.push('行号越界: ' + rel + ':' + entry.line + ' → ' + entry.ref + ':' + num
|
|
558
|
+
+ '(目标共 ' + total + ' 行)——请改指目标里真实存在的行,或删除行号后缀');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return problems;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// 表头新鲜度判定(内容锚;单一实现):无表头声明 → 跳过(登记边界);表头日期 < 正文最大日期 → 报。
|
|
565
|
+
function headerFreshnessProblems(rel, text) {
|
|
566
|
+
const header = text.match(ROADMAP_HEADER_RE);
|
|
567
|
+
if (!header) return [];
|
|
568
|
+
const dates = [...text.matchAll(INTERNAL_DOC_DATE_RE)].map((m) => m[0]);
|
|
569
|
+
const maxBody = dates.reduce((a, b) => (a > b ? a : b), '');
|
|
570
|
+
if (maxBody === '' || header[1] >= maxBody) return [];
|
|
571
|
+
return ['表头不新鲜: ' + rel + ' 表头 ' + header[1] + ' < 正文最大 ' + maxBody
|
|
572
|
+
+ '——请把表头日期刷新到不早于正文最大日期'];
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// 已归档 change 清单(读目录名;归档面缺席 → 空数组,非维护者检出/夹具形态不误红)。
|
|
576
|
+
function archivedChangeIds(root = REPO_ROOT) {
|
|
577
|
+
const archiveDir = path.join(root, '.specs', 'archive');
|
|
578
|
+
if (!fs.existsSync(archiveDir)) return [];
|
|
579
|
+
const ids = [];
|
|
580
|
+
for (const name of fs.readdirSync(archiveDir)) {
|
|
581
|
+
const m = ARCHIVE_DIR_ENTRY_RE.exec(name);
|
|
582
|
+
if (m) ids.push({ id: m[1], dir: name });
|
|
583
|
+
}
|
|
584
|
+
return ids;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// `## Now`(在办段)不得出现已归档 change-id:段定位**必须用标题扫描**(允许段名尾部括号注记),
|
|
588
|
+
// 切到下一个二级标题 Next 为止。禁止用 indexOf('## Now')——该册文件头的目录说明行里含被反引号
|
|
589
|
+
// 包住的同名标题字样,indexOf 会命中说明行、切出极短窗口使判据恒过(实测教训:判据的定位口径
|
|
590
|
+
// 必须自实测推导,不能被同一文件里"看起来对"的文本骗过)。
|
|
591
|
+
function roadmapNowArchivedProblems(rel, text, root = REPO_ROOT) {
|
|
592
|
+
const problems = [];
|
|
593
|
+
const nowRe = /^##\s*Now\s*(?:[((][^))\n]*[))])?\s*$/m;
|
|
594
|
+
const nowMatch = nowRe.exec(text);
|
|
595
|
+
if (!nowMatch) return problems; // 段缺席由结构判据报告,此处不重复
|
|
596
|
+
const rest = text.slice(nowMatch.index + nowMatch[0].length);
|
|
597
|
+
const nextRe = /^##\s*Next\s*(?:[((][^))\n]*[))])?\s*$/m;
|
|
598
|
+
const nextMatch = nextRe.exec(rest);
|
|
599
|
+
const section = nextMatch ? rest.slice(0, nextMatch.index) : rest;
|
|
600
|
+
for (const { id, dir } of archivedChangeIds(root)) {
|
|
601
|
+
// 命中面 = id 及其路径形态(两形态都要判:只判路径会漏掉裸 id 写法)。
|
|
602
|
+
// id 用**整词**匹配(字母/数字/连字符为词字符)——直接 `includes(id)` 会让短 id 命中更长 id
|
|
603
|
+
// 或同族更长 id 的中间(如归档 id `archived-fixture` 命中 `archived-fixture-v2`),属假红。
|
|
604
|
+
const idRe = new RegExp('(?<![A-Za-z0-9_-])' + id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?![A-Za-z0-9_-])');
|
|
605
|
+
if (idRe.test(section) || section.includes(dir)) {
|
|
606
|
+
problems.push('Now 段含已归档 change-id: ' + id + '(' + rel + ' 的在办段引用了已归档记录 '
|
|
607
|
+
+ dir + ')——请从在办段移出(历史指针面记录)');
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return problems;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function internalDocsProblems(root = REPO_ROOT) {
|
|
614
|
+
const problems = [];
|
|
615
|
+
const targets = internalDocTargets(root);
|
|
616
|
+
if (targets.length === 0) return problems; // 全部目标面缺席 → 整组跳过(CI / worktree 形态)
|
|
617
|
+
const lineCountCache = new Map();
|
|
618
|
+
const lineCountOf = (p) => {
|
|
619
|
+
if (!lineCountCache.has(p)) {
|
|
620
|
+
try {
|
|
621
|
+
// 逻辑行数:**尾随换行不产生额外一行**(`a\nb\nc\n` = 3 行),**空文件 = 0 行**(不是 1 行)。
|
|
622
|
+
// 直接取 `split(/\r?\n/).length` 会把尾随空段算成一行 → `:N+1` 越界被漏报;空文件若按段数
|
|
623
|
+
// 计会得 1 行 → `:1` 被放过(空文件没有任何行,任何行号都越界)。
|
|
624
|
+
const body = fs.readFileSync(p, 'utf8');
|
|
625
|
+
const parts = body === '' ? [] : body.split(/\r?\n/);
|
|
626
|
+
if (parts.length > 1 && parts[parts.length - 1] === '') parts.pop();
|
|
627
|
+
lineCountCache.set(p, parts.length);
|
|
628
|
+
} catch {
|
|
629
|
+
lineCountCache.set(p, null); // 目标瞬时不可读:存在性已通过,行号判据按不可判跳过
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return lineCountCache.get(p);
|
|
633
|
+
};
|
|
289
634
|
for (const rel of targets) {
|
|
290
635
|
let text;
|
|
291
636
|
try {
|
|
292
637
|
text = fs.readFileSync(path.join(root, rel), 'utf8');
|
|
293
|
-
} catch {
|
|
638
|
+
} catch (e) {
|
|
639
|
+
// F4:读取失败(EACCES / EBUSY / EISDIR 等)不得静默 continue——该目标既没被判死引用、
|
|
640
|
+
// 也没被判缺失,静默跳过会让受检面出现「未执行 ≠ 通过」的黑洞(L-079 同类通道;本批
|
|
641
|
+
// 正落在新扩扫描面上)。按可见问题报告,并继续扫描其余目标(一个目标损坏不吞整册扫描面)。
|
|
642
|
+
const reason = e && e.code ? e.code : (e && e.message ? e.message : String(e));
|
|
643
|
+
problems.push('无法读取: ' + rel + ': ' + reason);
|
|
294
644
|
continue;
|
|
295
645
|
}
|
|
296
|
-
for (const
|
|
297
|
-
if (INTERNAL_DOC_REF_ALLOWLIST.has(ref)) continue;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
646
|
+
for (const entry of internalDocRefCandidates(text)) {
|
|
647
|
+
if (INTERNAL_DOC_REF_ALLOWLIST.has(entry.ref)) continue;
|
|
648
|
+
const resolved = resolveInternalDocRef(entry.ref, root);
|
|
649
|
+
if (resolved !== null) {
|
|
650
|
+
problems.push(...lineNumberProblems(rel, entry, resolved, lineCountOf));
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
// 窄域报告规则:树根相对形态(flow-comet* 技能目录 / rules)基准全失败 → 按死引用报告,
|
|
654
|
+
// 不再落入「顶层整体缺席 → 跳过」(旧逻辑在此静默放过——族见上方声明)。
|
|
655
|
+
if (isTreeRootRelativeRef(entry.ref)) {
|
|
656
|
+
problems.push('死引用: ' + rel + ':' + entry.line + ' → ' + entry.ref
|
|
657
|
+
+ '(树根相对形态未解析:技能树 / 规则树内不存在该目标)');
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
// 声明式族:登记在案的外部命名空间 / 退役命名空间 / 示例形态 → 跳过;其余一律按死引用报
|
|
661
|
+
// (顶层段不存在不再是免检理由——那正是旧逻辑吞掉真实残留的通道)。
|
|
662
|
+
if (isDeclaredReferenceSkip(rel, entry.ref)) continue;
|
|
663
|
+
problems.push('死引用: ' + rel + ':' + entry.line + ' → ' + entry.ref
|
|
664
|
+
+ '(顶层段不存在且未登记为允许跳过;请修正路径,或按声明式族逐条登记理由)');
|
|
302
665
|
}
|
|
666
|
+
// 表头新鲜度(内容锚;未声明表头 → 跳过)
|
|
667
|
+
problems.push(...headerFreshnessProblems(rel, text));
|
|
303
668
|
}
|
|
304
669
|
const roadmapRel = path.posix.join(MAINTAINER_DOC_DIR, 'ROADMAP.md');
|
|
305
670
|
if (!fs.existsSync(path.join(root, roadmapRel))) {
|
|
306
671
|
problems.push('ROADMAP 缺失: ' + roadmapRel);
|
|
307
672
|
} else {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
673
|
+
let text = null;
|
|
674
|
+
try {
|
|
675
|
+
text = fs.readFileSync(path.join(root, roadmapRel), 'utf8');
|
|
676
|
+
} catch (e) {
|
|
677
|
+
// F4 语义的结构检查侧补齐:ROADMAP 自身读取失败(EACCES / EBUSY / EISDIR 等)与目标扫描
|
|
678
|
+
// 同型报告(同一错误摘要口径),并跳过四段结构检查——不得让同一受检面在结构检查处抛
|
|
679
|
+
// 未捕获异常、以堆栈崩溃整个套件(读取失败可见化在两个消费点语义一致)。
|
|
680
|
+
const reason = e && e.code ? e.code : (e && e.message ? e.message : String(e));
|
|
681
|
+
problems.push('无法读取: ' + roadmapRel + ': ' + reason);
|
|
682
|
+
}
|
|
683
|
+
if (text !== null) {
|
|
684
|
+
for (const section of ['Now', 'Next', 'Later', 'Open decisions']) {
|
|
685
|
+
const sectionRe = new RegExp('^##\\s*' + section + '\\s*(?:[((][^))\\n]*[))])?\\s*$', 'm');
|
|
686
|
+
if (!sectionRe.test(text)) {
|
|
687
|
+
problems.push('ROADMAP 结构缺段: ' + section + '(' + roadmapRel + ')');
|
|
688
|
+
}
|
|
313
689
|
}
|
|
690
|
+
problems.push(...roadmapNowArchivedProblems(roadmapRel, text, root));
|
|
314
691
|
}
|
|
315
692
|
}
|
|
316
693
|
return problems;
|
|
317
694
|
}
|
|
318
695
|
|
|
696
|
+
// 维护者面缺席可见化(可测接缝;root 可覆盖=测试专用入口,生产调用不传):
|
|
697
|
+
// 返回被跳过的面与原因描述符数组(空数组 = 全部维护者面在场,无跳过)。与消费点共用同一在场
|
|
698
|
+
// 判据——① 计数受检清单的维护者组复用 maintainerFacePresent(组外目录探针,与
|
|
699
|
+
// scenarioCountSyncProblems 同源);② 维护文档机检以 internalDocTargets 是否为空为判据
|
|
700
|
+
// (同 internalDocsProblems)。
|
|
701
|
+
// 只产出描述符,不改任何判定 / 返回值语义 / 退出码;套件底部据此输出可见的 SKIP 行
|
|
702
|
+
// (worktree / CI 全新检出等结构性缺席不误红,但不得被当成「已校验」——以维护者主树 L1 为准)。
|
|
703
|
+
function maintainerFaceSkips(root = REPO_ROOT) {
|
|
704
|
+
const skips = [];
|
|
705
|
+
if (!maintainerFacePresent(root)) {
|
|
706
|
+
skips.push({
|
|
707
|
+
face: '维护者文档计数面(场景数 + 系统测试集项数)',
|
|
708
|
+
reason: MAINTAINER_DOC_DIR + '/ 目录缺席(CI 全新检出 / worktree 检出等非维护者形态)',
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
if (internalDocTargets(root).length === 0) {
|
|
712
|
+
skips.push({
|
|
713
|
+
face: '维护文档机检(引用解析 + 路线图结构)',
|
|
714
|
+
reason: '受检目标面全部缺席(' + MAINTAINER_DOC_DIR + ' 与 .specs/adr 与三册均不可见)',
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return skips;
|
|
718
|
+
}
|
|
319
719
|
|
|
320
720
|
function makeTmp() {
|
|
321
721
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'flow-comet-guard-test-'));
|
|
@@ -323,6 +723,29 @@ function makeTmp() {
|
|
|
323
723
|
return dir;
|
|
324
724
|
}
|
|
325
725
|
|
|
726
|
+
// 场景夹具清理(Windows 韧性,2026-10-01 实证):子进程退出后,其 cwd / 文件句柄可能仍被短暂占用
|
|
727
|
+
// → `rmSync` 抛 EPERM/EBUSY。Node 的 `maxRetries`/`retryDelay` 正是为该窗口设计(对 EBUSY /
|
|
728
|
+
// EMFILE / ENFILE / ENOTEMPTY / EPERM 线性退避重试)。**仍失败不得让整轮崩溃**——旧写法把
|
|
729
|
+
// `rmSync` 裸放在 finally 里,一个目录删不掉就抛未捕获异常:后续场景不执行、末尾的「临时目录
|
|
730
|
+
// 清理」判据与失败报告也全都不执行(本机实测:整轮 exit 1 且无 RESULT 行,并每次留下一个残留目录)。
|
|
731
|
+
// 现改为「重试 + 容忍」:清理不了的目录留待末尾判据统一报告(可见失败,不静默、也不自杀)。
|
|
732
|
+
const CLEANUP_RETRIES = 10;
|
|
733
|
+
const CLEANUP_RETRY_DELAY_MS = 150;
|
|
734
|
+
// 不返回清理状态:调用方不据它分支,且「清理成功」的**单一判定点**是末尾「临时目录清理」判据
|
|
735
|
+
// (避免 helper 与调用方各自 existsSync 形成两套判定——Sourcery 评审指出,2026-10-01 收敛)。
|
|
736
|
+
function cleanupTmpDir(dir) {
|
|
737
|
+
try {
|
|
738
|
+
fs.rmSync(dir, { recursive: true, force: true, maxRetries: CLEANUP_RETRIES, retryDelay: CLEANUP_RETRY_DELAY_MS });
|
|
739
|
+
} catch {
|
|
740
|
+
// 交由末尾「临时目录清理」判据报告
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// 同步小睡(末尾延迟重试用;主线程可用 Atomics.wait 阻塞等待)
|
|
745
|
+
function sleepSync(ms) {
|
|
746
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
747
|
+
}
|
|
748
|
+
|
|
326
749
|
function writeFile(root, rel, content) {
|
|
327
750
|
const p = path.join(root, rel);
|
|
328
751
|
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
@@ -446,6 +869,41 @@ function fixtureIsBridgeDevVersion(version) {
|
|
|
446
869
|
return FIXTURE_BRIDGE_DEV_SUFFIX_RE.test(String(version));
|
|
447
870
|
}
|
|
448
871
|
|
|
872
|
+
// 发布同步守卫(场景 200 子断言)纯函数:权威源 loader 的标记行 / 导出常量与载体
|
|
873
|
+
// INSTALLED_VERSION 三处一致性判定——比较语义 = bridge-check 既有语义(MECHANISM 二·二十七
|
|
874
|
+
// 「bridge-check 基础版本归一」:比较前剥离 git-describe dev 态后缀 `-<N>-g<hash>`、按基础版本
|
|
875
|
+
// 比较;预发布标识(如 -rc.N)不是 dev 态后缀、不剥离;基础版本不同(含发布版对发布版)仍报
|
|
876
|
+
// 漂移)。归一复用 fixtureBridgeBaseVersion(单点正则,不再复制第二份实现)——发布态权威源与
|
|
877
|
+
// dev 态安装副本(INSTALLED_VERSION = `<发布>-<N>-g<hash>`)归一后同基础判同步;真实跨文件/
|
|
878
|
+
// 跨值分叉仍必报。返回问题描述数组(空 = 三处基础版本一致)。
|
|
879
|
+
function bridgeStampSyncProblems(markerStamp, exportStamp, installedVersion) {
|
|
880
|
+
const base = fixtureBridgeBaseVersion;
|
|
881
|
+
const problems = [];
|
|
882
|
+
if (base(markerStamp) !== base(installedVersion)) {
|
|
883
|
+
problems.push('标记行=' + markerStamp + '(基础 ' + base(markerStamp) + ')vs INSTALLED_VERSION=' + installedVersion + '(基础 ' + base(installedVersion) + ')');
|
|
884
|
+
}
|
|
885
|
+
if (base(exportStamp) !== base(installedVersion)) {
|
|
886
|
+
problems.push('export=' + exportStamp + '(基础 ' + base(exportStamp) + ')vs INSTALLED_VERSION=' + installedVersion + '(基础 ' + base(installedVersion) + ')');
|
|
887
|
+
}
|
|
888
|
+
return problems;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// 发布同步守卫(场景 200)子锚表(判别力双向,全部由载体基础版本派生):正例 = 三处基础版本一致
|
|
892
|
+
// (含 dev 态副本戳 vs 权威源发布戳的真实形态、两侧 dev 后缀同基础);负例 = 标记行 / export
|
|
893
|
+
// 任一基础版本漂移、发布版对发布版失配、预发布标识不剥离——归一不得放行真实漂移。
|
|
894
|
+
function bridgeStampSyncSubAnchorCases(baseVersion, devVersion) {
|
|
895
|
+
const major = parseInt(baseVersion.split('.')[0], 10);
|
|
896
|
+
const otherBase = (major + 9) + '.0.0';
|
|
897
|
+
return [
|
|
898
|
+
{ label: 'dev 态副本戳 vs 权威源发布戳同基础', expectSync: true, problems: bridgeStampSyncProblems(baseVersion, baseVersion, devVersion) },
|
|
899
|
+
{ label: '两侧 dev 后缀同基础', expectSync: true, problems: bridgeStampSyncProblems(baseVersion + '-2-g1234567', baseVersion + '-1-gabcdef0', devVersion) },
|
|
900
|
+
{ label: '标记行基础版本不同', expectSync: false, problems: bridgeStampSyncProblems(otherBase, baseVersion, devVersion) },
|
|
901
|
+
{ label: 'export 基础版本不同', expectSync: false, problems: bridgeStampSyncProblems(baseVersion, otherBase, devVersion) },
|
|
902
|
+
{ label: '发布版对发布版失配', expectSync: false, problems: bridgeStampSyncProblems('9.9.9-fixture-skew', baseVersion, baseVersion) },
|
|
903
|
+
{ label: '预发布标识不剥离', expectSync: false, problems: bridgeStampSyncProblems(baseVersion + '-rc.3', baseVersion, devVersion) },
|
|
904
|
+
];
|
|
905
|
+
}
|
|
906
|
+
|
|
449
907
|
// 组装 dsh 桥接健康夹具(bridge-check 六态场景共用):项目根挂 .dsh/skills/flow-comet
|
|
450
908
|
// 适用性门;$DSH_HOME/plugins/ 放 loader(含契约锚点 BRIDGE_VERSION 戳,值取自权威源
|
|
451
909
|
// INSTALLED_VERSION,与 bridge-check 比对源同值——健康态恒等、偏斜态可控);cordis.patch.yml
|
|
@@ -661,7 +1119,7 @@ function bridgeCopyVersionSubAnchorCases(baseVersion, devVersion) {
|
|
|
661
1119
|
|
|
662
1120
|
// 协议副本由运行器在场景执行前复制到 <dir>/reference/(见底部运行段)。
|
|
663
1121
|
function readScenarioProtocol(dir) {
|
|
664
|
-
return JSON.parse(fs.readFileSync(
|
|
1122
|
+
return JSON.parse(fs.readFileSync(scenarioProtocolPath(dir), 'utf8'));
|
|
665
1123
|
}
|
|
666
1124
|
|
|
667
1125
|
// 245~247 场景直接调用 route-node 纯函数:缺失导出在此显式报告(RED 定位到具体场景,
|
|
@@ -807,7 +1265,7 @@ function runReenter(dir, target, options = {}) {
|
|
|
807
1265
|
if (options.reason !== undefined) args.push('--reason', options.reason);
|
|
808
1266
|
if (Array.isArray(options.extra)) args.push(...options.extra);
|
|
809
1267
|
return runState(args, dir, {
|
|
810
|
-
FLOW_COMET_PROTOCOL: options.protocol ||
|
|
1268
|
+
FLOW_COMET_PROTOCOL: options.protocol || scenarioProtocolPath(dir),
|
|
811
1269
|
});
|
|
812
1270
|
}
|
|
813
1271
|
|
|
@@ -870,6 +1328,153 @@ function assertOutMatches(res, pattern, label) {
|
|
|
870
1328
|
}
|
|
871
1329
|
}
|
|
872
1330
|
|
|
1331
|
+
// ---------- 受控计划重校重签(replan)与强制推进留痕(advance-forced)场景材料 ----------
|
|
1332
|
+
// replan 是"计划在执行中被证明有缺陷"时的受控通道(ADR-013):仅 execute / subagent-execute
|
|
1333
|
+
// 相位可用、停原位、不跳节点——重新校验任务图与任务字段 → 重录 state.taskHash → 双写留痕
|
|
1334
|
+
// (evidence.<node>.replanAuthorization + history 事件 replan-applied)。判定语义的唯一权威在
|
|
1335
|
+
// route-node.mjs(测试侧不复制生产判定——L-067);本段只装配夹具与断言助手。纯函数契约按
|
|
1336
|
+
// reentry 族同构声明:
|
|
1337
|
+
// parseReplanAuthorization({ authorization, node }) // authorization = { round, at, source, reason, node }
|
|
1338
|
+
// replanRoundCount({ history, changeName })
|
|
1339
|
+
// replanRoundDecision({ history, changeName, continuationAuthorized })
|
|
1340
|
+
// replanNoOpDecision({ state, taskContent })
|
|
1341
|
+
// resolveReplanDecision({ protocol, state, authorization, continuationRound })
|
|
1342
|
+
// 缺失导出由 requireRouteNodeExport 在场景内显式报告(RED 可定位到具体场景,不整套件 abort)。
|
|
1343
|
+
|
|
1344
|
+
// 修订前的任务集(entry 形态):一个串行待办任务
|
|
1345
|
+
const REPLAN_TASK_INITIAL =
|
|
1346
|
+
'<task id="S01" status="pending" parallel="false"><action>实现 S01</action>'
|
|
1347
|
+
+ '<write_files>src/s01.mjs</write_files><verify>node --check src/s01.mjs</verify></task>\n';
|
|
1348
|
+
// 修订后的任务集(死锁现场):原任务完成 + 计划外新增的并行就绪任务
|
|
1349
|
+
const REPLAN_TASK_REVISED =
|
|
1350
|
+
'<task id="S01" status="done" parallel="false"><action>实现 S01</action>'
|
|
1351
|
+
+ '<write_files>src/s01.mjs</write_files><verify>node --check src/s01.mjs</verify></task>\n'
|
|
1352
|
+
+ '<task id="P02" status="pending" parallel="true"><action>实现计划外新增的 P02</action>'
|
|
1353
|
+
+ '<write_files>src/p02.mjs</write_files><verify>node --check src/p02.mjs</verify></task>\n';
|
|
1354
|
+
// 缺 <verify> 字段的负例任务集(plan 出口与 replan 共用的任务字段校验)
|
|
1355
|
+
const REPLAN_TASK_NO_VERIFY =
|
|
1356
|
+
'<task id="S01" status="pending" parallel="false"><action>实现 S01</action>'
|
|
1357
|
+
+ '<write_files>src/s01.mjs</write_files></task>\n';
|
|
1358
|
+
// 过期签名占位(与哈希算法实现解耦:只比较是否相等/同版本,不依赖真实摘要值)
|
|
1359
|
+
const REPLAN_STALE_SIGNATURE = 'v1:' + '0'.repeat(64);
|
|
1360
|
+
|
|
1361
|
+
// replan 相位夹具:execute 已 entry、前序完成、证据齐备(execute 出口可通过)、TASK.md 在场。
|
|
1362
|
+
// branchMode / enablePrReview / branchPrefix 显式在场——避免 readState 兼容默认值让「零改写」
|
|
1363
|
+
// 口径混入实现细节噪音(与受控重入夹具同做法)。
|
|
1364
|
+
function replanExecuteState(overrides = {}) {
|
|
1365
|
+
return {
|
|
1366
|
+
activeChange: CHANGE_ID,
|
|
1367
|
+
currentNode: 'execute',
|
|
1368
|
+
completedNodes: ['open', 'design', 'plan'],
|
|
1369
|
+
enteredNodes: ['open', 'design', 'plan', 'execute'],
|
|
1370
|
+
evidence: {
|
|
1371
|
+
open: { summary: 'open done' },
|
|
1372
|
+
design: { summary: 'design done' },
|
|
1373
|
+
plan: { summary: 'plan done' },
|
|
1374
|
+
execute: { summary: 'implementation recorded' },
|
|
1375
|
+
'subagent-execute': { handoffResult: handoffFor(['S01']) },
|
|
1376
|
+
},
|
|
1377
|
+
verifyFailures: 0,
|
|
1378
|
+
executionMode: 'subagent',
|
|
1379
|
+
directOverride: false,
|
|
1380
|
+
newChange: true,
|
|
1381
|
+
status: 'running',
|
|
1382
|
+
branchMode: false,
|
|
1383
|
+
enablePrReview: false,
|
|
1384
|
+
branchPrefix: 'change/',
|
|
1385
|
+
history: [{ event: 'exit-applied', node: 'plan', at: '2026-09-27T00:00:00.000Z', change: CHANGE_ID }],
|
|
1386
|
+
...overrides,
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// 备份目录/清单(replan 备份规则 .specs/<change-id>/replan-backups/):BLOCK / 空操作路径零新增。
|
|
1391
|
+
function replanBackupFiles(dir, changeName = CHANGE_ID) {
|
|
1392
|
+
const backupDir = path.join(dir, '.specs', changeName, 'replan-backups');
|
|
1393
|
+
return fs.existsSync(backupDir) ? fs.readdirSync(backupDir).sort() : [];
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// replan-applied 事件过滤(轮次按 change 从 history 派生——与受控重入同计数法)
|
|
1397
|
+
function replanEventsOf(state) {
|
|
1398
|
+
return (state.history || []).filter((e) => e && e.event === 'replan-applied');
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// 轮次事件夹具:change 归属字段是跨 change 隔离的唯一依据(写侧必须带 change)
|
|
1402
|
+
function replanHistoryEvent(roundNumber, changeName = CHANGE_ID) {
|
|
1403
|
+
return {
|
|
1404
|
+
event: 'replan-applied',
|
|
1405
|
+
node: 'execute',
|
|
1406
|
+
round: roundNumber,
|
|
1407
|
+
change: changeName,
|
|
1408
|
+
reason: '计划重校',
|
|
1409
|
+
authorizedBy: 'user-approval',
|
|
1410
|
+
taskSetSignature: REPLAN_STALE_SIGNATURE,
|
|
1411
|
+
at: '2026-09-27T00:00:00.000Z',
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// advance-forced 事件夹具(status.forcedNodes 事件判据):change 归属过滤与 advance 写侧同形——
|
|
1416
|
+
// 派生只取 event / change / node,skipped 等字段保留以贴近真实事件。
|
|
1417
|
+
function advanceForcedEvent(node, changeName = CHANGE_ID) {
|
|
1418
|
+
return {
|
|
1419
|
+
event: 'advance-forced',
|
|
1420
|
+
change: changeName,
|
|
1421
|
+
node,
|
|
1422
|
+
skipped: ['exit:' + node],
|
|
1423
|
+
reason: 'advance',
|
|
1424
|
+
at: '2026-09-28T00:00:00.000Z',
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// 授权形态纯函数锚(AC-2 的 guard-self-test 验证方式):形态合法性由 route-node 的
|
|
1429
|
+
// parseReplanAuthorization 单一权威判定,本助手只声明期望(malformed → ok:false)。
|
|
1430
|
+
function assertReplanAuthorizationShape(authorization, node, expectedOk, label) {
|
|
1431
|
+
const parse = requireRouteNodeExport('parseReplanAuthorization');
|
|
1432
|
+
const result = parse({ authorization, node });
|
|
1433
|
+
if (!result || result.ok !== expectedOk) {
|
|
1434
|
+
throw new Error('[' + label + '] replan 授权形态判定应为 ok=' + expectedOk + ',实际 ' + JSON.stringify(result));
|
|
1435
|
+
}
|
|
1436
|
+
return result;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// 重签复核:state.taskHash 必须等于当前 TASK.md 的签名(同版本比较复用 route-node 既有实现,
|
|
1440
|
+
// 不在此内联第二份判据)。
|
|
1441
|
+
function assertReplanSignatureRecorded(state, taskContent, label) {
|
|
1442
|
+
const same = requireRouteNodeExport('sameTaskSetSignature');
|
|
1443
|
+
const signature = requireRouteNodeExport('taskSetSignature')(taskContent);
|
|
1444
|
+
if (!same(state.taskHash, signature)) {
|
|
1445
|
+
throw new Error(label + ':state.taskHash 应重签为当前 TASK.md 的签名,实际 '
|
|
1446
|
+
+ JSON.stringify(state.taskHash) + ',期望 ' + JSON.stringify(signature));
|
|
1447
|
+
}
|
|
1448
|
+
return signature;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// status 输出(JSON 块 + 尾巴行)解析:只取首个 { 到末个 } 之间的 JSON 对象。
|
|
1452
|
+
function parseStatusJson(res) {
|
|
1453
|
+
const text = outputText(res);
|
|
1454
|
+
const start = text.indexOf('{');
|
|
1455
|
+
const end = text.lastIndexOf('}');
|
|
1456
|
+
if (start < 0 || end <= start) throw new Error('status 输出缺少 JSON 块:\n' + text);
|
|
1457
|
+
return JSON.parse(text.slice(start, end + 1));
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
// 场景协议副本路径(单一来源,L-067):以 dir 为基准的协议路径表达式只在此处出现一次;
|
|
1461
|
+
// 调用面统一走下方助手。跨树(root)/ 安装副本(skillCopy)/ 自定义协议(options.protocol 或
|
|
1462
|
+
// --protocol CLI)场景仍各自显式传路径,不经本助手(数据点保留)。
|
|
1463
|
+
function scenarioProtocolPath(dir) {
|
|
1464
|
+
return path.join(dir, 'reference', 'workflow-protocol.json');
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// 场景内受控命令(replan / advance / status / next):显式注入场景协议副本路径
|
|
1468
|
+
// (L-079:依赖协议解析的门禁不得静默跳过;副本由运行器预置在 <dir>/reference/)。
|
|
1469
|
+
function runStateWithProtocol(dir, args) {
|
|
1470
|
+
return runState(args, dir, { FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) });
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// 同形 runGuard 助手(入口/出口门禁场景):注入与 runStateWithProtocol 同一 FLOW_COMET_PROTOCOL 表达。
|
|
1474
|
+
function runGuardWithProtocol(dir, args) {
|
|
1475
|
+
return runGuard(args, dir, { FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) });
|
|
1476
|
+
}
|
|
1477
|
+
|
|
873
1478
|
// ---------- 伪造材料 ----------
|
|
874
1479
|
|
|
875
1480
|
function baseState(node) {
|
|
@@ -1209,6 +1814,50 @@ const TASK_DEP_CYCLE =
|
|
|
1209
1814
|
const TASK_MISSING_DEP =
|
|
1210
1815
|
'<task id="T01" parallel="false" status="pending"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n' +
|
|
1211
1816
|
'<task id="P01" status="pending" parallel="true"><action>实现 P01</action><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify><depends_on>T99</depends_on></task>\n';
|
|
1817
|
+
// 并行写冲突(replan 越界场景扩展):前置串行任务已 done,两个并行任务依赖已满足且 write_files
|
|
1818
|
+
// 重叠——plan 出口写写强判为 BLOCKED,replan 不做校验豁免、必须同样 BLOCK 且状态零改写(禁止备份先于拦截)。
|
|
1819
|
+
const TASK_PARALLEL_WRITE_CONFLICT =
|
|
1820
|
+
'<task id="S01" parallel="false" status="done"><action>完成 S01</action><write_files>src/s01.mjs</write_files><verify>node --check src/s01.mjs</verify></task>\n' +
|
|
1821
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify><depends_on>S01</depends_on></task>\n' +
|
|
1822
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify><depends_on>S01</depends_on></task>\n';
|
|
1823
|
+
|
|
1824
|
+
// 并行读写弱判(replan 侧,2026-09-28 PR 审查补锚):同一对并行任务无显式 depends_on,一方读取对方
|
|
1825
|
+
// 写路径 → 与 plan 出口同一判据:read∩write 仅 WARN 不阻断,replan 照常重签并写重签前备份。
|
|
1826
|
+
const TASK_PARALLEL_READ_OVERLAP =
|
|
1827
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify></task>\n' +
|
|
1828
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><read_files>src/shared.mjs</read_files><write_files>src/other.mjs</write_files><verify>node --check src/other.mjs</verify></task>\n';
|
|
1829
|
+
|
|
1830
|
+
// 同文件跨任务(第三族)夹具族:串行拆分出的同文件任务、彼此无 depends_on(#125 要抓的形态)。
|
|
1831
|
+
// ① 非修复任务对 → 必须命中;② 修复任务族对(同文件回修)→ 不参与(顺序由修复生命周期保证);
|
|
1832
|
+
// ③ 混合夹具:两类并存 → 只报非修复对(反向构造:第三族缺位时 ①③ 必然放过)。
|
|
1833
|
+
const CROSS_TASK_PLAIN_PAIR =
|
|
1834
|
+
'<task id="T01" parallel="false" status="pending"><action>实现 T01</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify></task>\n'
|
|
1835
|
+
+ '<task id="T02" parallel="false" status="pending"><action>实现 T02</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify></task>\n';
|
|
1836
|
+
const CROSS_TASK_FIX_PAIR =
|
|
1837
|
+
'<task id="T-FIX-01" parallel="false" status="pending"><action>修复 T-FIX-01</action><write_files>src/fix-shared.mjs</write_files><verify>node --check src/fix-shared.mjs</verify></task>\n'
|
|
1838
|
+
+ '<task id="T-FIX-02" parallel="false" status="pending"><action>修复 T-FIX-02</action><write_files>src/fix-shared.mjs</write_files><verify>node --check src/fix-shared.mjs</verify></task>\n';
|
|
1839
|
+
const CROSS_TASK_MIXED_PAIR =
|
|
1840
|
+
'<task id="T01" parallel="false" status="pending"><action>实现 T01</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify></task>\n'
|
|
1841
|
+
+ '<task id="T02" parallel="false" status="pending"><action>实现 T02</action><write_files>src/shared.mjs</write_files><verify>node --check src/shared.mjs</verify></task>\n'
|
|
1842
|
+
+ '<task id="T-FIX-01" parallel="false" status="pending"><action>修复 T-FIX-01</action><write_files>src/other-shared.mjs</write_files><verify>node --check src/other-shared.mjs</verify></task>\n'
|
|
1843
|
+
+ '<task id="T-FIX-02" parallel="false" status="pending"><action>修复 T-FIX-02</action><write_files>src/other-shared.mjs</write_files><verify>node --check src/other-shared.mjs</verify></task>\n';
|
|
1844
|
+
// ④ **段归属分支**夹具:修复段内的任务 id **不带**修复族前缀(F01/F02)——判定必须靠「位于修复
|
|
1845
|
+
// 任务段内」这条边界,而不是 id 命名。既有 ② 用的是带前缀 id,走的是 id 分支,段归属分支此前
|
|
1846
|
+
// 没有行为夹具(该分支的行尾归一口径缺陷因此漏过,2026-10-01 PR 审查发现后补)。
|
|
1847
|
+
// **块内必须跨行**:单行块在 LF 与 CRLF 下文本完全相同,行尾口径缺陷无从显现——真实 TASK.md
|
|
1848
|
+
// 的任务块本就跨行,夹具按真实形态构造(否则夹具自身无判别力)。
|
|
1849
|
+
const CROSS_TASK_FIX_SECTION_PAIR =
|
|
1850
|
+
'## Fix 任务(来自 REVIEW)\n\n'
|
|
1851
|
+
+ '<task id="F01" parallel="false" status="pending">\n'
|
|
1852
|
+
+ ' <action>回修 F01</action>\n'
|
|
1853
|
+
+ ' <write_files>src/section-shared.mjs</write_files>\n'
|
|
1854
|
+
+ ' <verify>node --check src/section-shared.mjs</verify>\n'
|
|
1855
|
+
+ '</task>\n'
|
|
1856
|
+
+ '<task id="F02" parallel="false" status="pending">\n'
|
|
1857
|
+
+ ' <action>回修 F02</action>\n'
|
|
1858
|
+
+ ' <write_files>src/section-shared.mjs</write_files>\n'
|
|
1859
|
+
+ ' <verify>node --check src/section-shared.mjs</verify>\n'
|
|
1860
|
+
+ '</task>\n';
|
|
1212
1861
|
|
|
1213
1862
|
// 波次分组场景公共路径:注入 TASK.md → entry plan(记录 enteredNodes,新 change 强制先 entry;
|
|
1214
1863
|
// 旧 change 亦先 entry 避免 ENTER WARN 干扰断言)→ exit plan。返回 exit plan 结果。
|
|
@@ -1402,6 +2051,204 @@ function exerciseSystemTestCountCheck(dir) {
|
|
|
1402
2051
|
}
|
|
1403
2052
|
}
|
|
1404
2053
|
|
|
2054
|
+
// ---------- 结构锚的共享判定(判别力升级:按表达式形态计数,而不只是数标识符名) ----------
|
|
2055
|
+
|
|
2056
|
+
// 引擎脚本集(不含套件自身与系统测试集):结构锚共用同一清单——多处各写一份过滤表达式会在
|
|
2057
|
+
// 清单口径变化时漂移(同一事实的第二实现)。
|
|
2058
|
+
function engineScriptFiles(scriptsDir = __dirname) {
|
|
2059
|
+
return fs.readdirSync(scriptsDir)
|
|
2060
|
+
.filter((f) => f.endsWith('.mjs') && f !== 'guard-self-test.mjs' && f !== 'system-test.mjs');
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
// 注释行判定:与检查工具的注释层口径一致(行首 // / /* / * 才算注释行,行尾注释不在此列)。
|
|
2064
|
+
function isScriptCommentLine(line) {
|
|
2065
|
+
return /^\s*(\/\/|\*|\/\*)/.test(line);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
// 具名函数体文本:先配平参数表圆括号(解构入参内含 `new Map()` 一类调用),再配平函数体花括号。
|
|
2069
|
+
// 目标函数体内不含字符串花括号,故不做字面量扫描。找不到定义返回 null——调用方据此显式报告
|
|
2070
|
+
// "结构锚前提失效",不静默按通过处理。
|
|
2071
|
+
function functionBodyText(text, name) {
|
|
2072
|
+
const start = text.indexOf('function ' + name + '(');
|
|
2073
|
+
if (start < 0) return null;
|
|
2074
|
+
let i = text.indexOf('(', start);
|
|
2075
|
+
if (i < 0) return null;
|
|
2076
|
+
let parens = 0;
|
|
2077
|
+
for (; i < text.length; i += 1) {
|
|
2078
|
+
if (text[i] === '(') parens += 1;
|
|
2079
|
+
else if (text[i] === ')') {
|
|
2080
|
+
parens -= 1;
|
|
2081
|
+
if (parens === 0) break;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
i = text.indexOf('{', i);
|
|
2085
|
+
if (i < 0) return null;
|
|
2086
|
+
let depth = 0;
|
|
2087
|
+
for (; i < text.length; i += 1) {
|
|
2088
|
+
if (text[i] === '{') depth += 1;
|
|
2089
|
+
else if (text[i] === '}') {
|
|
2090
|
+
depth -= 1;
|
|
2091
|
+
if (depth === 0) return text.slice(start, i + 1);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
return null;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
// 修复族 id 前缀边界的权威表达式文本(单一来源:判据与夹具锚共用同一份字面量)。
|
|
2098
|
+
const FIX_PREFIX_LITERAL_TEXT = '/^[TP]-FIX-/i';
|
|
2099
|
+
|
|
2100
|
+
// 修复族边界"出现处"扫描(纯读取,单一实现):引擎脚本里的五类出现面——
|
|
2101
|
+
// 前缀正则字面量 / 含 FIX 词干的其它正则字面量 / 修复族 id 字符串字面量 / 段内成员判定 /
|
|
2102
|
+
// 边界常量的按文件使用次数。注释行不参与(与检查工具的注释层口径一致):注释里提到标识符
|
|
2103
|
+
// 是说明,不是第二份实现。判定与扫描分离(本函数只收集事实,下函数只下结论)。
|
|
2104
|
+
function fixFamilyBoundarySites(scriptsDir = __dirname) {
|
|
2105
|
+
const sites = {
|
|
2106
|
+
prefixLiterals: [],
|
|
2107
|
+
otherFixRegexes: [],
|
|
2108
|
+
idLiterals: [],
|
|
2109
|
+
sectionMemberships: [],
|
|
2110
|
+
prefixUsesByFile: new Map(),
|
|
2111
|
+
texts: new Map(),
|
|
2112
|
+
};
|
|
2113
|
+
for (const file of engineScriptFiles(scriptsDir)) {
|
|
2114
|
+
const text = fs.readFileSync(path.join(scriptsDir, file), 'utf8');
|
|
2115
|
+
sites.texts.set(file, text);
|
|
2116
|
+
const lines = text.split(/\r?\n/);
|
|
2117
|
+
let prefixUses = 0;
|
|
2118
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
2119
|
+
const line = lines[i];
|
|
2120
|
+
if (isScriptCommentLine(line)) continue;
|
|
2121
|
+
let at = line.indexOf(FIX_PREFIX_LITERAL_TEXT);
|
|
2122
|
+
while (at >= 0) {
|
|
2123
|
+
sites.prefixLiterals.push(file + ':' + (i + 1));
|
|
2124
|
+
at = line.indexOf(FIX_PREFIX_LITERAL_TEXT, at + 1);
|
|
2125
|
+
}
|
|
2126
|
+
// 含 FIX 词干的其它正则字面量(单行内闭合、\ 转义感知):第二份前缀表达式在此现形
|
|
2127
|
+
for (const m of line.matchAll(/\/(?:\\.|[^/\\\n])*FIX(?:\\.|[^/\\\n])*\/[a-z]*/g)) {
|
|
2128
|
+
if (m[0] !== FIX_PREFIX_LITERAL_TEXT) sites.otherFixRegexes.push(file + ':' + (i + 1) + ' ' + m[0]);
|
|
2129
|
+
}
|
|
2130
|
+
for (const token of ['T-FIX', 'P-FIX']) {
|
|
2131
|
+
if (line.includes(token)) sites.idLiterals.push(file + ':' + (i + 1) + ' ' + token);
|
|
2132
|
+
}
|
|
2133
|
+
if (line.includes('sectionBlocks.has(')) sites.sectionMemberships.push(file + ':' + (i + 1));
|
|
2134
|
+
prefixUses += line.split('FIX_TASK_ID_PREFIX').length - 1;
|
|
2135
|
+
}
|
|
2136
|
+
if (prefixUses > 0) sites.prefixUsesByFile.set(file, prefixUses);
|
|
2137
|
+
}
|
|
2138
|
+
return sites;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
// 修复族约定「只表达一次」判定(AC-15 判别力锚):返回问题描述数组(空数组 = 唯一表达)。
|
|
2142
|
+
// 判别力设计——旧锚按**标识符名**统计(哪个文件里出现该常量名),对"同一约定被表达两次"
|
|
2143
|
+
// 零判别力:第二份等价前缀表达式(交替式写法)不含该常量名 → 旧锚必放过(虚假单一来源信心)。
|
|
2144
|
+
// 本判据按**表达式形态**计数(扫描见 fixFamilyBoundarySites),四条一起构成"约定被表达两次即红":
|
|
2145
|
+
// ① id 前缀边界:唯一前缀正则字面量只允许出现一次,且必须位于 route-node.mjs;
|
|
2146
|
+
// ② 第二份表达式:引擎代码行不得出现其它含 FIX 词干的正则字面量,也不得出现修复族 id 的
|
|
2147
|
+
// 字符串字面量(`.startsWith(...)` 一类内联前缀判定形态);
|
|
2148
|
+
// ③ 段内边界:段内成员判定(`sectionBlocks.has(`)只允许出现一次——「位于修复段内」这条
|
|
2149
|
+
// 边界只在唯一分类器里表达;
|
|
2150
|
+
// ④ 谓词共用:修复族标记与并行文件依赖第三族的参与者排除必须各自调用唯一分类器,且不得
|
|
2151
|
+
// 自持边界常量 / 段切片(任一消费方自建第二份边界即红)。
|
|
2152
|
+
// 判据自身的判别力由场景内的反向夹具锚(同源 → 无问题;逐条注入 → 逐条专项报告)常驻保证。
|
|
2153
|
+
function fixFamilyBoundaryProblems(scriptsDir = __dirname) {
|
|
2154
|
+
const problems = [];
|
|
2155
|
+
const sites = fixFamilyBoundarySites(scriptsDir);
|
|
2156
|
+
if (sites.prefixLiterals.length !== 1 || !sites.prefixLiterals[0].startsWith('route-node.mjs:')) {
|
|
2157
|
+
problems.push('修复族 id 前缀边界必须只表达一次且位于 route-node.mjs,实际出现处: '
|
|
2158
|
+
+ JSON.stringify(sites.prefixLiterals));
|
|
2159
|
+
}
|
|
2160
|
+
if (sites.otherFixRegexes.length !== 0) {
|
|
2161
|
+
problems.push('引擎内出现第二份修复族 id 前缀表达式(同一约定被表达两次): '
|
|
2162
|
+
+ sites.otherFixRegexes.join('; '));
|
|
2163
|
+
}
|
|
2164
|
+
if (sites.idLiterals.length !== 0) {
|
|
2165
|
+
problems.push('引擎代码行出现修复族 id 字面量(内联前缀判定形态,应经唯一分类器): '
|
|
2166
|
+
+ sites.idLiterals.join('; '));
|
|
2167
|
+
}
|
|
2168
|
+
if (sites.sectionMemberships.length !== 1) {
|
|
2169
|
+
problems.push('「位于修复段内」边界(段内成员判定)必须只表达一次,实际出现处: '
|
|
2170
|
+
+ JSON.stringify(sites.sectionMemberships));
|
|
2171
|
+
}
|
|
2172
|
+
// 边界常量的使用面:定义 1 处 + 唯一分类器内 1 次 test = 2(其他消费方一律经分类器)
|
|
2173
|
+
const prefixUseTotal = [...sites.prefixUsesByFile.values()].reduce((a, b) => a + b, 0);
|
|
2174
|
+
if (prefixUseTotal !== 2 || sites.prefixUsesByFile.size !== 1 || !sites.prefixUsesByFile.has('route-node.mjs')) {
|
|
2175
|
+
problems.push('修复族 id 边界常量的使用面必须恰为「定义 + 唯一分类器内一次判定」,实际: '
|
|
2176
|
+
+ JSON.stringify([...sites.prefixUsesByFile.entries()]));
|
|
2177
|
+
}
|
|
2178
|
+
const routeText = sites.texts.get('route-node.mjs') ?? '';
|
|
2179
|
+
for (const fnName of ['fixTaskMarker', 'collectCrossTaskConflicts']) {
|
|
2180
|
+
const body = functionBodyText(routeText, fnName);
|
|
2181
|
+
if (body === null) {
|
|
2182
|
+
problems.push('结构锚前提失效:route-node.mjs 未找到 ' + fnName + ' 的定义');
|
|
2183
|
+
continue;
|
|
2184
|
+
}
|
|
2185
|
+
if (!/fixTaskClassifier\s*\(/.test(body)) {
|
|
2186
|
+
problems.push(fnName + ' 必须经唯一分类器判定修复族(不得自持第二份边界)');
|
|
2187
|
+
}
|
|
2188
|
+
if (/FIX_TASK_ID_PREFIX|fixSectionBody/.test(body)) {
|
|
2189
|
+
problems.push(fnName + ' 自持修复族边界常量 / 段切片(应只调用唯一分类器)');
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
return problems;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
// ---------- 词表镜像漂移判据(主仓私有单一来源 ↔ 分发套件的同义镜像;L-067 收口) ----------
|
|
2196
|
+
// 背景:套件随技能包分发、不能 import 主仓私有的 .githooks(该面不随 clone 分发),故套件内
|
|
2197
|
+
// 保留同义镜像 PUBLIC_CODE_RE。两份此前只有注释互指"同步",零一致性判据:主仓增补模式时
|
|
2198
|
+
// 分发侧扫描静默落后(新词可在公开面长期存活而套件全绿),反向则分发面误红——正是
|
|
2199
|
+
// 「同一判据两份实现必然分叉」点名的形态。本判据把等价性变成机检事实:
|
|
2200
|
+
// · 主仓形态(权威源检出):读 .githooks 的 BANNED.source,与套件镜像**逐字符比对**,
|
|
2201
|
+
// 不等即报(消息含两侧 source 片段、长度与首个差异位置,可直接定位);
|
|
2202
|
+
// · 安装副本形态:该私有面结构性缺席 → 判据**不适用**,由调用方输出显式「不适用」描述符
|
|
2203
|
+
// (未验证 ≠ 通过,与维护者面缺席的可见 SKIP 同族语义)。
|
|
2204
|
+
const GITHOOKS_CODES_REL = path.posix.join('.githooks', 'internal-codes.mjs');
|
|
2205
|
+
|
|
2206
|
+
// 导出正则字面量抽取(\ 转义感知):从 `export const <name> = /<body>/<flags>;` 取 body 与 flags。
|
|
2207
|
+
// 解析失败返回 null(调用方按"判据未执行"显式报告,不静默放过)。
|
|
2208
|
+
function extractExportedRegexLiteral(text, name) {
|
|
2209
|
+
const re = new RegExp('export\\s+const\\s+' + name + '\\s*=\\s*/((?:\\\\.|[^/\\\\\\n])*)/([a-z]*)\\s*;');
|
|
2210
|
+
const m = re.exec(text);
|
|
2211
|
+
return m === null ? null : { source: m[1], flags: m[2] };
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
function vocabularyMirrorProblems(root = REPO_ROOT) {
|
|
2215
|
+
const problems = [];
|
|
2216
|
+
const rel = GITHOOKS_CODES_REL;
|
|
2217
|
+
let text;
|
|
2218
|
+
try {
|
|
2219
|
+
text = fs.readFileSync(path.join(root, rel), 'utf8');
|
|
2220
|
+
} catch (e) {
|
|
2221
|
+
const reason = e && e.code ? e.code : (e && e.message ? e.message : String(e));
|
|
2222
|
+
problems.push('词表镜像漂移判据无法执行: ' + rel + ' 读取失败(' + reason
|
|
2223
|
+
+ ')——未执行 ≠ 通过;请在主仓私有面在场处重跑(主树 L1)');
|
|
2224
|
+
return problems;
|
|
2225
|
+
}
|
|
2226
|
+
const banned = extractExportedRegexLiteral(text, 'BANNED');
|
|
2227
|
+
if (banned === null) {
|
|
2228
|
+
problems.push('词表镜像漂移判据无法执行: ' + rel + ' 未解析出导出的 BANNED 正则字面量'
|
|
2229
|
+
+ '(词表单一来源形态变化)——未执行 ≠ 通过');
|
|
2230
|
+
return problems;
|
|
2231
|
+
}
|
|
2232
|
+
const mine = PUBLIC_CODE_RE.source;
|
|
2233
|
+
if (banned.source !== mine) {
|
|
2234
|
+
const shared = Math.min(banned.source.length, mine.length);
|
|
2235
|
+
let firstDiff = shared;
|
|
2236
|
+
for (let i = 0; i < shared; i += 1) {
|
|
2237
|
+
if (banned.source[i] !== mine[i]) { firstDiff = i; break; }
|
|
2238
|
+
}
|
|
2239
|
+
const fragment = (s) => (s.length > 80 ? s.slice(0, 80) + '…' : s);
|
|
2240
|
+
problems.push('词表镜像漂移: ' + rel + ' 的 BANNED.source(' + banned.source.length
|
|
2241
|
+
+ ' 字符)≠ 套件 PUBLIC_CODE_RE.source(' + mine.length + ' 字符);首个差异位置 ' + firstDiff
|
|
2242
|
+
+ ';主仓侧片段「' + fragment(banned.source) + '」;套件侧片段「' + fragment(mine)
|
|
2243
|
+
+ '」——两侧必须逐字符等价,请同改(词表只许收窄、不许放宽)');
|
|
2244
|
+
}
|
|
2245
|
+
if (banned.flags !== PUBLIC_CODE_RE.flags) {
|
|
2246
|
+
problems.push('词表镜像标志位漂移: ' + rel + ' 的 BANNED flags=' + JSON.stringify(banned.flags)
|
|
2247
|
+
+ ' ≠ 套件 PUBLIC_CODE_RE flags=' + JSON.stringify(PUBLIC_CODE_RE.flags));
|
|
2248
|
+
}
|
|
2249
|
+
return problems;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
1405
2252
|
// ---------- 17 个场景 ----------
|
|
1406
2253
|
|
|
1407
2254
|
const SCENARIOS = [
|
|
@@ -2124,7 +2971,7 @@ const SCENARIOS = [
|
|
|
2124
2971
|
run: (dir) => {
|
|
2125
2972
|
writeState(dir, baseState('open'));
|
|
2126
2973
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
2127
|
-
const res =
|
|
2974
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2128
2975
|
assertExit(res, 1);
|
|
2129
2976
|
assertOut(res, '疑似未 exit 节点 open');
|
|
2130
2977
|
assertOut(res, 'workflow-guard.mjs exit open --apply');
|
|
@@ -2142,7 +2989,7 @@ const SCENARIOS = [
|
|
|
2142
2989
|
writeState(dir, st);
|
|
2143
2990
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why\n');
|
|
2144
2991
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n');
|
|
2145
|
-
const res =
|
|
2992
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2146
2993
|
assertExit(res, 0);
|
|
2147
2994
|
assertOut(res, 'NODE: design');
|
|
2148
2995
|
assertNotOut(res, 'BLOCKED');
|
|
@@ -2260,7 +3107,7 @@ const SCENARIOS = [
|
|
|
2260
3107
|
writeFile(dir, '.specs/' + CHANGE_ID + '/DESIGN.md', '# DESIGN\n\n## 0. 技术栈\n');
|
|
2261
3108
|
// 既有 done 任务 + verify 阶段追加的 pending 修复任务
|
|
2262
3109
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_DONE + TASK_P1 + TASK_TFIX);
|
|
2263
|
-
const res =
|
|
3110
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2264
3111
|
assertExit(res, 0);
|
|
2265
3112
|
assertOut(res, 'NODE: execute');
|
|
2266
3113
|
assertNotOut(res, 'BLOCKED');
|
|
@@ -2280,7 +3127,7 @@ const SCENARIOS = [
|
|
|
2280
3127
|
writeFile(dir, '.specs/' + CHANGE_ID + '/DESIGN.md', '# DESIGN\n\n## 0. 技术栈\n');
|
|
2281
3128
|
// 全部 done(无 pending)——正常推进场景不豁免
|
|
2282
3129
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_DONE + TASK_P1);
|
|
2283
|
-
const res =
|
|
3130
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2284
3131
|
assertExit(res, 1);
|
|
2285
3132
|
assertOut(res, '疑似未 exit 节点 verify');
|
|
2286
3133
|
assertOut(res, 'workflow-guard.mjs exit verify --apply');
|
|
@@ -2356,7 +3203,7 @@ const SCENARIOS = [
|
|
|
2356
3203
|
// open exit 已通过的产物(design 尚未开始,无 DESIGN.md)
|
|
2357
3204
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why\n');
|
|
2358
3205
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n');
|
|
2359
|
-
const res =
|
|
3206
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2360
3207
|
assertExit(res, 0);
|
|
2361
3208
|
assertOut(res, 'NODE: design');
|
|
2362
3209
|
assertNotOut(res, 'BLOCKED');
|
|
@@ -2376,7 +3223,7 @@ const SCENARIOS = [
|
|
|
2376
3223
|
writeState(dir, st);
|
|
2377
3224
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why\n');
|
|
2378
3225
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n');
|
|
2379
|
-
const res =
|
|
3226
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2380
3227
|
assertExit(res, 1);
|
|
2381
3228
|
assertOut(res, '疑似未 exit 节点 review');
|
|
2382
3229
|
assertOut(res, 'workflow-guard.mjs exit review --apply');
|
|
@@ -2409,8 +3256,7 @@ const SCENARIOS = [
|
|
|
2409
3256
|
assertOut(res, 'HANDOFF RESULT: T01');
|
|
2410
3257
|
// ② record subagent-execute '{"handoffResult":{}}' 整体覆盖 evidence['subagent-execute']
|
|
2411
3258
|
//(浅合并替换 handoffResult 键)→ 已记录的 T01 handoff 丢失(对照组 A 踩坑路径)
|
|
2412
|
-
assertExit(
|
|
2413
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') }), 0);
|
|
3259
|
+
assertExit(runStateWithProtocol(dir, ['record', 'subagent-execute', '{"handoffResult":{}}']), 0);
|
|
2414
3260
|
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
2415
3261
|
const hr = st2.evidence['subagent-execute'] && st2.evidence['subagent-execute'].handoffResult;
|
|
2416
3262
|
if (!hr || hr['T01']) {
|
|
@@ -2439,7 +3285,7 @@ const SCENARIOS = [
|
|
|
2439
3285
|
st.evidence['subagent-execute'] = { summary: 'wave1 delegated and collected' };
|
|
2440
3286
|
writeState(dir, st);
|
|
2441
3287
|
// ① next:第二波 eligible 并行存在 → 多趟路由回该节点(旧单趟「不回流」行为已移除)
|
|
2442
|
-
const res =
|
|
3288
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2443
3289
|
assertExit(res, 0);
|
|
2444
3290
|
assertOut(res, 'NODE: subagent-execute');
|
|
2445
3291
|
// ② entry subagent-execute:completedNodes 含该节点仍可重入(每趟完整 entry 检查)
|
|
@@ -2505,7 +3351,7 @@ const SCENARIOS = [
|
|
|
2505
3351
|
run: (dir) => {
|
|
2506
3352
|
execFileSync('git', ['init', '-q'], { cwd: dir, stdio: 'ignore' });
|
|
2507
3353
|
execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '--allow-empty', '-m', 'init'], { cwd: dir, stdio: 'ignore' });
|
|
2508
|
-
const res =
|
|
3354
|
+
const res = runStateWithProtocol(dir, ['init', 'prefix-test', '--branch-prefix', 'feat/']);
|
|
2509
3355
|
assertExit(res, 0);
|
|
2510
3356
|
assertOut(res, 'BRANCH: feat/prefix-test');
|
|
2511
3357
|
const branch = execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: dir, encoding: 'utf8' }).trim();
|
|
@@ -2528,7 +3374,7 @@ const SCENARIOS = [
|
|
|
2528
3374
|
writeState(dir, st);
|
|
2529
3375
|
writeFile(dir, '.specs/pref-state/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2530
3376
|
writeFile(dir, '.specs/pref-state/REQUIREMENT.md', '# REQUIREMENT\n## 用户故事\nx\n## 验收准则(AC)\nx\n');
|
|
2531
|
-
const res =
|
|
3377
|
+
const res = runStateWithProtocol(dir, ['status']);
|
|
2532
3378
|
assertExit(res, 0);
|
|
2533
3379
|
assertOut(res, '一致性: ok');
|
|
2534
3380
|
},
|
|
@@ -2540,8 +3386,7 @@ const SCENARIOS = [
|
|
|
2540
3386
|
{
|
|
2541
3387
|
name: '55 init state 含 status: running',
|
|
2542
3388
|
run: (dir) => {
|
|
2543
|
-
const res =
|
|
2544
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3389
|
+
const res = runStateWithProtocol(dir, ['init', 'tf15-st']);
|
|
2545
3390
|
assertExit(res, 0);
|
|
2546
3391
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
2547
3392
|
if (st.status !== 'running') {
|
|
@@ -2554,8 +3399,7 @@ const SCENARIOS = [
|
|
|
2554
3399
|
{
|
|
2555
3400
|
name: '56 hook BLOCKED:init 后越权写源码',
|
|
2556
3401
|
run: (dir) => {
|
|
2557
|
-
const initRes =
|
|
2558
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3402
|
+
const initRes = runStateWithProtocol(dir, ['init', 'tf15-hk']);
|
|
2559
3403
|
assertExit(initRes, 0);
|
|
2560
3404
|
const res = runHook(['before_tool'], dir,
|
|
2561
3405
|
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'src', 'evil.py') } });
|
|
@@ -2580,11 +3424,9 @@ const SCENARIOS = [
|
|
|
2580
3424
|
{
|
|
2581
3425
|
name: '58 init 后 next 识别 active change',
|
|
2582
3426
|
run: (dir) => {
|
|
2583
|
-
const initRes =
|
|
2584
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3427
|
+
const initRes = runStateWithProtocol(dir, ['init', 'tf16-dir']);
|
|
2585
3428
|
assertExit(initRes, 0);
|
|
2586
|
-
const res =
|
|
2587
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3429
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
2588
3430
|
assertExit(res, 1);
|
|
2589
3431
|
assertOut(res, '疑似未 exit 节点 open');
|
|
2590
3432
|
assertNotOut(res, 'No active change');
|
|
@@ -2600,8 +3442,7 @@ const SCENARIOS = [
|
|
|
2600
3442
|
writeState(dir, composeState({ status: 'completed', activeChange: null, currentNode: null }));
|
|
2601
3443
|
writeFile(dir, '.specs/stale/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2602
3444
|
writeFile(dir, '.specs/stale/TASK.md', '# TASK\n');
|
|
2603
|
-
const res =
|
|
2604
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3445
|
+
const res = runStateWithProtocol(dir, ['status']);
|
|
2605
3446
|
assertExit(res, 0);
|
|
2606
3447
|
assertOut(res, 'no-change');
|
|
2607
3448
|
assertNotOut(res, 'stale');
|
|
@@ -2645,8 +3486,7 @@ const SCENARIOS = [
|
|
|
2645
3486
|
{
|
|
2646
3487
|
name: '62 hook 放行:init 后写 .specs/ 工件',
|
|
2647
3488
|
run: (dir) => {
|
|
2648
|
-
const initRes =
|
|
2649
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3489
|
+
const initRes = runStateWithProtocol(dir, ['init', 'tf15-ok']);
|
|
2650
3490
|
assertExit(initRes, 0);
|
|
2651
3491
|
const res = runHook(['before_tool'], dir,
|
|
2652
3492
|
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', 'tf15-ok', 'CHANGE.md') } });
|
|
@@ -2663,8 +3503,7 @@ const SCENARIOS = [
|
|
|
2663
3503
|
writeFile(dir, '.specs/sci-notation/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2664
3504
|
writeFile(dir, '.specs/sci-notation/TASK.md', '# TASK\n');
|
|
2665
3505
|
writeFile(dir, '.specs/archive/2026-08-08-sci-notation/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2666
|
-
const res =
|
|
2667
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3506
|
+
const res = runStateWithProtocol(dir, ['status']);
|
|
2668
3507
|
assertExit(res, 0);
|
|
2669
3508
|
assertOut(res, '"change": "sci-notation"');
|
|
2670
3509
|
},
|
|
@@ -2677,8 +3516,7 @@ const SCENARIOS = [
|
|
|
2677
3516
|
name: '64 record --protocol 不污染 payload',
|
|
2678
3517
|
run: (dir) => {
|
|
2679
3518
|
const custom = writeCustomProtocol(dir);
|
|
2680
|
-
const initRes =
|
|
2681
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3519
|
+
const initRes = runStateWithProtocol(dir, ['init', 'tf14-rec']);
|
|
2682
3520
|
assertExit(initRes, 0);
|
|
2683
3521
|
const res = runState(['record', 'open', '{"summary":"x","completedChecks":["a"]}', '--protocol', custom], dir);
|
|
2684
3522
|
assertExit(res, 0);
|
|
@@ -2721,7 +3559,7 @@ const SCENARIOS = [
|
|
|
2721
3559
|
},
|
|
2722
3560
|
},
|
|
2723
3561
|
|
|
2724
|
-
// 67: 旧格式 state(无 status 字段 + 无 activeChange + 无 currentNode
|
|
3562
|
+
// 67: 旧格式 state(无 status 字段 + 无 activeChange + 无 currentNode——归档批次的升级场景)
|
|
2725
3563
|
// → hook 放行(:无 activeChange 与无 state 文件同语义——当前被「not running」拦截)
|
|
2726
3564
|
{
|
|
2727
3565
|
name: '67 旧 state 无 status 无 activeChange hook 放行',
|
|
@@ -2781,8 +3619,7 @@ const SCENARIOS = [
|
|
|
2781
3619
|
writeState(dir, st);
|
|
2782
3620
|
writeFile(dir, '.specs/stale-id/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2783
3621
|
writeFile(dir, '.specs/stale-id/TASK.md', '# TASK\n');
|
|
2784
|
-
const res =
|
|
2785
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3622
|
+
const res = runStateWithProtocol(dir, ['status']);
|
|
2786
3623
|
assertExit(res, 0);
|
|
2787
3624
|
assertOut(res, 'no-change');
|
|
2788
3625
|
},
|
|
@@ -2815,8 +3652,7 @@ const SCENARIOS = [
|
|
|
2815
3652
|
fs.mkdirSync(path.join(dir, '.flow-comet'), { recursive: true });
|
|
2816
3653
|
fs.writeFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), raw, 'utf8');
|
|
2817
3654
|
writeFile(dir, '.specs/compose-demo/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2818
|
-
const res =
|
|
2819
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3655
|
+
const res = runStateWithProtocol(dir, ['status']);
|
|
2820
3656
|
assertExit(res, 0);
|
|
2821
3657
|
assertOut(res, '"status": "running"');
|
|
2822
3658
|
},
|
|
@@ -2909,8 +3745,7 @@ const SCENARIOS = [
|
|
|
2909
3745
|
fs.mkdirSync(path.join(dir, '.flow-comet'), { recursive: true });
|
|
2910
3746
|
fs.writeFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), raw, 'utf8');
|
|
2911
3747
|
writeFile(dir, '.specs/compose-demo/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
2912
|
-
const res =
|
|
2913
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3748
|
+
const res = runGuardWithProtocol(dir, ['entry', 'open']);
|
|
2914
3749
|
assertExit(res, 0);
|
|
2915
3750
|
},
|
|
2916
3751
|
},
|
|
@@ -2939,15 +3774,14 @@ const SCENARIOS = [
|
|
|
2939
3774
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
2940
3775
|
'<task id="P01" parallel="true" status="done">\n <action>do</action>\n <verify>echo ok</verify>\n</task>\n' +
|
|
2941
3776
|
'<task id="T01" parallel="false" status="pending">\n <action>do serial</action>\n <verify>echo ok</verify>\n</task>\n');
|
|
2942
|
-
const
|
|
2943
|
-
const res = runGuard(['exit', 'plan', '--apply'], dir, env);
|
|
3777
|
+
const res = runGuardWithProtocol(dir, ['exit', 'plan', '--apply']);
|
|
2944
3778
|
assertExit(res, 0);
|
|
2945
3779
|
assertNotOut(res, 'ROUTE WARN');
|
|
2946
3780
|
// ② 旧模板无 status 属性(无可解析 pending)→ 前置条件跳过诊断 → 静默
|
|
2947
3781
|
//(① 的 --apply 已把 currentNode 推进到 execute——先复位 state 再独立跑第二半)
|
|
2948
3782
|
writeState(dir, st);
|
|
2949
3783
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n<task id="T02" parallel="true">\n <action>do legacy</action>\n <verify>echo ok</verify>\n</task>\n');
|
|
2950
|
-
const resLegacy =
|
|
3784
|
+
const resLegacy = runGuardWithProtocol(dir, ['exit', 'plan', '--apply']);
|
|
2951
3785
|
assertExit(resLegacy, 0);
|
|
2952
3786
|
assertNotOut(resLegacy, 'ROUTE WARN');
|
|
2953
3787
|
},
|
|
@@ -2960,8 +3794,7 @@ const SCENARIOS = [
|
|
|
2960
3794
|
run: (dir) => {
|
|
2961
3795
|
const st = baseState('execute');
|
|
2962
3796
|
writeState(dir, st);
|
|
2963
|
-
const res =
|
|
2964
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3797
|
+
const res = runGuardWithProtocol(dir, ['entry', 'execute']);
|
|
2965
3798
|
assertExit(res, 0);
|
|
2966
3799
|
assertOut(res, 'C4-CHECK SKIP');
|
|
2967
3800
|
},
|
|
@@ -3002,8 +3835,7 @@ const SCENARIOS = [
|
|
|
3002
3835
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', summaryContent({
|
|
3003
3836
|
method: '## 自检方法\n\nbuiltin-quickcheck — brooks-lint 不可用(Skill 仅返回占位,插件执行体未加载),按协议降级内置 R1~R6 快查',
|
|
3004
3837
|
}));
|
|
3005
|
-
const res =
|
|
3006
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3838
|
+
const res = runGuardWithProtocol(dir, ['exit', 'execute']);
|
|
3007
3839
|
assertExit(res, 0);
|
|
3008
3840
|
assertOut(res, 'BROOKS-LINT WARN');
|
|
3009
3841
|
assertOut(res, 'WARN COUNT:');
|
|
@@ -3018,8 +3850,7 @@ const SCENARIOS = [
|
|
|
3018
3850
|
st.evidence.execute = { summary: 'executed' };
|
|
3019
3851
|
writeState(dir, st);
|
|
3020
3852
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n<task id="T01" parallel="true" status="pending">\n <action>do</action>\n</task>\n<task id="T02" parallel="true" status="pending">\n <action>do2</action>\n</task>\n');
|
|
3021
|
-
const res =
|
|
3022
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
3853
|
+
const res = runGuardWithProtocol(dir, ['exit', 'execute']);
|
|
3023
3854
|
assertExit(res, 1);
|
|
3024
3855
|
assertOut(res, 'missing Output Schema artifacts');
|
|
3025
3856
|
},
|
|
@@ -3033,7 +3864,7 @@ const SCENARIOS = [
|
|
|
3033
3864
|
name: '83 CONTEXT 缺失 + 有代码 → init 输出 INIT-NEEDED 不生成',
|
|
3034
3865
|
run: (dir) => {
|
|
3035
3866
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3036
|
-
const res =
|
|
3867
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
3037
3868
|
assertExit(res, 0);
|
|
3038
3869
|
assertOut(res, 'INIT-NEEDED');
|
|
3039
3870
|
if (fs.existsSync(path.join(dir, '.specs', 'CONTEXT.md'))) throw new Error('CONTEXT 不应被自动生成');
|
|
@@ -3045,10 +3876,10 @@ const SCENARIOS = [
|
|
|
3045
3876
|
name: '84 --init-skip 记 none 且下次 init 静默',
|
|
3046
3877
|
run: (dir) => {
|
|
3047
3878
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3048
|
-
|
|
3879
|
+
runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-skip']);
|
|
3049
3880
|
const st1 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
3050
3881
|
if (st1.ai_context_doc !== 'none') throw new Error('ai_context_doc 应为 none');
|
|
3051
|
-
const res2 =
|
|
3882
|
+
const res2 = runStateWithProtocol(dir, ['init', CHANGE_ID + '-2']);
|
|
3052
3883
|
if (res2.output.includes('INIT-NEEDED') || res2.output.includes('INIT-HINT')) throw new Error('下次 init 不应再提示');
|
|
3053
3884
|
},
|
|
3054
3885
|
},
|
|
@@ -3059,7 +3890,7 @@ const SCENARIOS = [
|
|
|
3059
3890
|
run: (dir) => {
|
|
3060
3891
|
writeState(dir, { ...baseState('open'), last_intel_scan: new Date(Date.now() - 10 * 864e5).toISOString() });
|
|
3061
3892
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n');
|
|
3062
|
-
const res =
|
|
3893
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
3063
3894
|
assertExit(res, 0);
|
|
3064
3895
|
if (res.output.includes('INIT-NEEDED') || res.output.includes('INIT-HINT')) throw new Error('不应有初始化提示');
|
|
3065
3896
|
},
|
|
@@ -3070,7 +3901,7 @@ const SCENARIOS = [
|
|
|
3070
3901
|
name: '86 有 CONTEXT 无扫描记录 → INIT-HINT 文案无 null',
|
|
3071
3902
|
run: (dir) => {
|
|
3072
3903
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n');
|
|
3073
|
-
const res =
|
|
3904
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
3074
3905
|
assertExit(res, 0);
|
|
3075
3906
|
assertOut(res, 'INIT-HINT');
|
|
3076
3907
|
if (res.output.includes('null')) throw new Error('INIT-HINT 不应含 "null"(无扫描记录时用友好文案)');
|
|
@@ -3082,7 +3913,7 @@ const SCENARIOS = [
|
|
|
3082
3913
|
name: '87 --init-context 无 CONTEXT → INIT-GENERATE 指引不生成',
|
|
3083
3914
|
run: (dir) => {
|
|
3084
3915
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3085
|
-
const res =
|
|
3916
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3086
3917
|
assertExit(res, 0);
|
|
3087
3918
|
assertOut(res, 'INIT-GENERATE');
|
|
3088
3919
|
if (fs.existsSync(path.join(dir, '.specs', 'CONTEXT.md'))) throw new Error('CONTEXT 不应由脚本生成(生成职责在 agent)');
|
|
@@ -3097,7 +3928,7 @@ const SCENARIOS = [
|
|
|
3097
3928
|
run: (dir) => {
|
|
3098
3929
|
writeFile(dir, 'CLAUDE.md', '# CLAUDE\n项目约定:使用 kebab-case 命名。\n');
|
|
3099
3930
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3100
|
-
const res =
|
|
3931
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3101
3932
|
assertExit(res, 0);
|
|
3102
3933
|
assertOut(res, 'INIT-GENERATE');
|
|
3103
3934
|
assertOut(res, 'CLAUDE.md');
|
|
@@ -3109,7 +3940,7 @@ const SCENARIOS = [
|
|
|
3109
3940
|
name: '89 --init-context 指引含代码信号',
|
|
3110
3941
|
run: (dir) => {
|
|
3111
3942
|
writeFile(dir, 'requirements.txt', 'pytest\n');
|
|
3112
|
-
const res =
|
|
3943
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3113
3944
|
assertExit(res, 0);
|
|
3114
3945
|
assertOut(res, 'INIT-GENERATE');
|
|
3115
3946
|
assertOut(res, '代码信号');
|
|
@@ -3122,7 +3953,7 @@ const SCENARIOS = [
|
|
|
3122
3953
|
run: (dir) => {
|
|
3123
3954
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n## 技术栈\nx\n## 域语言\n| 术语 | 定义 |\n|---|---|\n| 例 | 定义 |\n## 已锁决策\n- [2026-08-01] 决策一\n## 默认偏好\nx\n## 既有抽象索引\nx\n## intel-scan 元数据\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n');
|
|
3124
3955
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3125
|
-
const res =
|
|
3956
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3126
3957
|
assertExit(res, 0);
|
|
3127
3958
|
assertOut(res, 'INIT-DONE');
|
|
3128
3959
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -3139,7 +3970,7 @@ const SCENARIOS = [
|
|
|
3139
3970
|
run: (dir) => {
|
|
3140
3971
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n');
|
|
3141
3972
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3142
|
-
let res =
|
|
3973
|
+
let res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3143
3974
|
assertExit(res, 0);
|
|
3144
3975
|
assertOut(res, 'INIT-VALIDATE-FAILED');
|
|
3145
3976
|
assertOut(res, '重写');
|
|
@@ -3147,7 +3978,7 @@ const SCENARIOS = [
|
|
|
3147
3978
|
if (st.last_intel_scan) throw new Error('校验失败不应写 last_intel_scan');
|
|
3148
3979
|
// ② 段名变体(含正文提及)不满足必填段
|
|
3149
3980
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n## 技术栈补充\nx\n## 域语言说明\n| 术语 | 定义 |\n|---|---|\n| 例 | 定义 |\n## 已锁决策说明\n- [2026-08-01] 决策一\n## 默认偏好补充\nx\n## 既有抽象索引附录\nx\n## intel-scan 元数据附录\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n正文提及 域语言 与 默认偏好 与 既有抽象索引(文本非标题)。\n');
|
|
3150
|
-
res =
|
|
3981
|
+
res = runStateWithProtocol(dir, ['init', CHANGE_ID + '-2', '--init-context']);
|
|
3151
3982
|
assertExit(res, 0);
|
|
3152
3983
|
assertOut(res, 'INIT-VALIDATE-FAILED');
|
|
3153
3984
|
st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -3169,7 +4000,7 @@ const SCENARIOS = [
|
|
|
3169
4000
|
'~~~text', '## 默认偏好', '~~~',
|
|
3170
4001
|
'',
|
|
3171
4002
|
].join('\n'));
|
|
3172
|
-
res =
|
|
4003
|
+
res = runStateWithProtocol(dir, ['init', CHANGE_ID + '-3', '--init-context']);
|
|
3173
4004
|
assertExit(res, 0);
|
|
3174
4005
|
assertOut(res, 'INIT-VALIDATE-FAILED');
|
|
3175
4006
|
st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -3184,7 +4015,7 @@ const SCENARIOS = [
|
|
|
3184
4015
|
// 7 段齐全但已锁决策条目缺 [YYYY-MM-DD] 日期前缀(模板格式)
|
|
3185
4016
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n## 技术栈\nx\n## 域语言\n| 术语 | 定义 |\n|---|---|\n| 例 | 定义 |\n## 已锁决策\n- 决策缺日期前缀\n## 默认偏好\nx\n## 既有抽象索引\nx\n## intel-scan 元数据\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n');
|
|
3186
4017
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3187
|
-
const res =
|
|
4018
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3188
4019
|
assertExit(res, 0);
|
|
3189
4020
|
assertOut(res, 'INIT-VALIDATE-FAILED');
|
|
3190
4021
|
assertOut(res, '日期');
|
|
@@ -3199,7 +4030,7 @@ const SCENARIOS = [
|
|
|
3199
4030
|
run: (dir) => {
|
|
3200
4031
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\n新项目骨架\n## 技术栈\nx\n## 域语言\n| 术语 | 定义 |\n|---|---|\n| (待沉淀) | 随 change 逐步补充 |\n## 已锁决策\n- (待沉淀——后续 change 按时间倒序追加)\n## 默认偏好\n- 待补充\n## 既有抽象索引\nx\n## intel-scan 元数据\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n');
|
|
3201
4032
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3202
|
-
const res =
|
|
4033
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
3203
4034
|
assertExit(res, 0);
|
|
3204
4035
|
assertOut(res, 'INIT-DONE');
|
|
3205
4036
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -3214,7 +4045,7 @@ const SCENARIOS = [
|
|
|
3214
4045
|
run: (dir) => {
|
|
3215
4046
|
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n## 技术栈\nx\n## 域语言\n| 术语 | 定义 |\n|---|---|\n| 例 | 定义 |\n## 已锁决策\n- [2026-08-01] 决策一\n## 默认偏好\nx\n## 既有抽象索引\nx\n## intel-scan 元数据\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n');
|
|
3216
4047
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3217
|
-
const res =
|
|
4048
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
3218
4049
|
assertExit(res, 0);
|
|
3219
4050
|
assertOut(res, '记录扫描时间');
|
|
3220
4051
|
if (res.output.includes('刷新')) throw new Error('CONTEXT 已就绪不应提示"刷新"(应提示记录扫描时间)');
|
|
@@ -3226,8 +4057,8 @@ const SCENARIOS = [
|
|
|
3226
4057
|
name: '95 init 同 id 重跑 → WARN 防护不阻断',
|
|
3227
4058
|
run: (dir) => {
|
|
3228
4059
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
3229
|
-
|
|
3230
|
-
const res =
|
|
4060
|
+
runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
4061
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
3231
4062
|
assertExit(res, 0);
|
|
3232
4063
|
assertOut(res, 'WARN: change ' + CHANGE_ID + ' 已存在');
|
|
3233
4064
|
assertOut(res, '重置节点状态');
|
|
@@ -3301,8 +4132,7 @@ const SCENARIOS = [
|
|
|
3301
4132
|
writeFile(dir, 'flow-kit/prompts/0-change.md', '# 阶段 0 · CHANGE\n\n## 角色\n\n你是 Changeer。\n');
|
|
3302
4133
|
writeState(dir, baseState('open'));
|
|
3303
4134
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3304
|
-
const res =
|
|
3305
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
4135
|
+
const res = runStateWithProtocol(dir, ['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md']);
|
|
3306
4136
|
assertExit(res, 0);
|
|
3307
4137
|
assertOut(res, 'SKILL-LOAD: open flow-comet-change → .skill-loads/open-flow-comet-change.json');
|
|
3308
4138
|
const markerPath = path.join(dir, '.specs', CHANGE_ID, '.skill-loads', 'open-flow-comet-change.json');
|
|
@@ -3330,22 +4160,21 @@ const SCENARIOS = [
|
|
|
3330
4160
|
run: (dir) => {
|
|
3331
4161
|
writeState(dir, baseState('open'));
|
|
3332
4162
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3333
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
3334
4163
|
// a) 缺参数(无 node/skill)
|
|
3335
|
-
const rA =
|
|
4164
|
+
const rA = runStateWithProtocol(dir, ['skill-load']);
|
|
3336
4165
|
assertExit(rA, 1);
|
|
3337
4166
|
assertOut(rA, 'skill-load requires <node> <skill>');
|
|
3338
4167
|
// b) node 非法(非内置节点)
|
|
3339
|
-
const rB =
|
|
4168
|
+
const rB = runStateWithProtocol(dir, ['skill-load', 'bogus', 'flow-comet-change']);
|
|
3340
4169
|
assertExit(rB, 1);
|
|
3341
4170
|
assertOut(rB, 'skill-load node 非法');
|
|
3342
4171
|
// c) skill 名含非法字符
|
|
3343
|
-
const rC =
|
|
4172
|
+
const rC = runStateWithProtocol(dir, ['skill-load', 'open', 'bad/name']);
|
|
3344
4173
|
assertExit(rC, 1);
|
|
3345
4174
|
assertOut(rC, 'skill-load skill 名非法');
|
|
3346
4175
|
// d) --prompt 不在 flow-kit/prompts/ 下(指向场景内 reference 副本——文件存在可加载,
|
|
3347
4176
|
// 归属校验拒绝;若归属校验被跳过则此处会成功写标记,断言即失效)
|
|
3348
|
-
const rD =
|
|
4177
|
+
const rD = runStateWithProtocol(dir, ['skill-load', 'open', 'flow-comet-change', '--prompt', 'reference/workflow-protocol.json']);
|
|
3349
4178
|
assertExit(rD, 1);
|
|
3350
4179
|
assertOut(rD, 'skill-load --prompt 路径必须位于 flow-kit/prompts/ 下');
|
|
3351
4180
|
// e) 自定义协议下未知节点同样拒绝(node 校验从内置清单改为当前协议节点集合
|
|
@@ -3369,8 +4198,7 @@ const SCENARIOS = [
|
|
|
3369
4198
|
run: (dir) => {
|
|
3370
4199
|
writeState(dir, baseState('open'));
|
|
3371
4200
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3372
|
-
const res =
|
|
3373
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
4201
|
+
const res = runStateWithProtocol(dir, ['record', 'open', JSON.stringify({ summary: 'done', completedChecks: ['required-skill:open.flow-comet-change'] })]);
|
|
3374
4202
|
assertExit(res, 1);
|
|
3375
4203
|
assertOut(res, 'BLOCKED');
|
|
3376
4204
|
assertOut(res, '缺少对应声明标记');
|
|
@@ -3387,11 +4215,10 @@ const SCENARIOS = [
|
|
|
3387
4215
|
run: (dir) => {
|
|
3388
4216
|
writeState(dir, baseState('open'));
|
|
3389
4217
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3390
|
-
const
|
|
3391
|
-
const sl = runState(['skill-load', 'open', 'flow-comet-change'], dir, env);
|
|
4218
|
+
const sl = runStateWithProtocol(dir, ['skill-load', 'open', 'flow-comet-change']);
|
|
3392
4219
|
assertExit(sl, 0);
|
|
3393
4220
|
assertOut(sl, 'SKILL-LOAD: open flow-comet-change');
|
|
3394
|
-
const res =
|
|
4221
|
+
const res = runStateWithProtocol(dir, ['record', 'open', JSON.stringify({ summary: 'done', completedChecks: ['required-skill:open.flow-comet-change'] })]);
|
|
3395
4222
|
assertExit(res, 0);
|
|
3396
4223
|
assertOut(res, 'EVIDENCE: open');
|
|
3397
4224
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -3427,7 +4254,6 @@ const SCENARIOS = [
|
|
|
3427
4254
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n\n## 验收准则(AC)\n');
|
|
3428
4255
|
// 场景内 flow-kit/prompts/ 提示文件(真实 skill-load --prompt 指向——归属校验仅查前缀不读内容)
|
|
3429
4256
|
writeFile(dir, 'flow-kit/prompts/0-change.md', '# 阶段 0 · CHANGE\n\n## 角色\n\n你是 Changeer。\n');
|
|
3430
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
3431
4257
|
const loadsDir = path.join(dir, '.specs', CHANGE_ID, '.skill-loads');
|
|
3432
4258
|
fs.mkdirSync(loadsDir, { recursive: true });
|
|
3433
4259
|
// ① 机制已激活(.skill-loads/ 存在)但无 open-* 标记(仅他节点标记)→ BLOCKED
|
|
@@ -3439,7 +4265,7 @@ const SCENARIOS = [
|
|
|
3439
4265
|
assertOut(resBlock, 'exit 缺协议声明标记');
|
|
3440
4266
|
// ② 真实链路:skill-load --prompt 写入标记(protocol = basename)→ exit 通过
|
|
3441
4267
|
const markerPath = path.join(loadsDir, 'open-flow-comet-change.json');
|
|
3442
|
-
const sl =
|
|
4268
|
+
const sl = runStateWithProtocol(dir, ['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md']);
|
|
3443
4269
|
assertExit(sl, 0);
|
|
3444
4270
|
assertOut(sl, 'SKILL-LOAD: open flow-comet-change');
|
|
3445
4271
|
const marker = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
|
|
@@ -3452,7 +4278,7 @@ const SCENARIOS = [
|
|
|
3452
4278
|
assertNotOut(resPass, 'BLOCKED');
|
|
3453
4279
|
// ③ skill-load 未传 --prompt → 标记 protocol = null → exit BLOCKED(fail-closed:
|
|
3454
4280
|
// 无协议声明不可通过——指引补 skill-load --prompt)
|
|
3455
|
-
const slNull =
|
|
4281
|
+
const slNull = runStateWithProtocol(dir, ['skill-load', 'open', 'flow-comet-change']);
|
|
3456
4282
|
assertExit(slNull, 0);
|
|
3457
4283
|
const markerNull = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
|
|
3458
4284
|
if (markerNull.protocol !== null) {
|
|
@@ -3481,8 +4307,7 @@ const SCENARIOS = [
|
|
|
3481
4307
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3482
4308
|
writeFile(dir, '.specs/' + CHANGE_ID + '/.skill-loads/open-flow-comet-change.json',
|
|
3483
4309
|
JSON.stringify({ node: 'open', skill: 'flow-comet-change', protocol: '0-change.md', at: '2999-12-31T00:00:00.000Z' }, null, 2) + '\n');
|
|
3484
|
-
const res =
|
|
3485
|
-
{ FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') });
|
|
4310
|
+
const res = runStateWithProtocol(dir, ['record', 'open', JSON.stringify({ summary: 'done', completedChecks: ['required-skill:open.flow-comet-change'] })]);
|
|
3486
4311
|
assertExit(res, 1);
|
|
3487
4312
|
assertOut(res, 'BLOCKED');
|
|
3488
4313
|
assertOut(res, '标记必须先于记录声明');
|
|
@@ -3497,13 +4322,12 @@ const SCENARIOS = [
|
|
|
3497
4322
|
run: (dir) => {
|
|
3498
4323
|
writeState(dir, baseState('open'));
|
|
3499
4324
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
3500
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
3501
4325
|
// ① 旧格式 record:completedChecks 无 required-skill 条目 → 无标记也通过
|
|
3502
|
-
const resA =
|
|
4326
|
+
const resA = runStateWithProtocol(dir, ['record', 'open', JSON.stringify({ summary: 'legacy', completedChecks: ['unit-tests'] })]);
|
|
3503
4327
|
assertExit(resA, 0);
|
|
3504
4328
|
assertOut(resA, 'EVIDENCE: open');
|
|
3505
4329
|
// ② 无 completedChecks 的纯 summary 记录 → 通过
|
|
3506
|
-
const resB =
|
|
4330
|
+
const resB = runStateWithProtocol(dir, ['record', 'open', JSON.stringify({ summary: 'plain' })]);
|
|
3507
4331
|
assertExit(resB, 0);
|
|
3508
4332
|
// ③ exit open:M5 后 record 已自动补声明标记 → 无 SKILL-LOAD WARN,正常通过
|
|
3509
4333
|
const st = baseState('open');
|
|
@@ -3745,7 +4569,7 @@ const SCENARIOS = [
|
|
|
3745
4569
|
const st1 = baseState('execute'); // evidence 空——无豁免,触发"疑似未 exit"BLOCK
|
|
3746
4570
|
writeState(dir, st1);
|
|
3747
4571
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true }); // findActiveChange 要求目录存在
|
|
3748
|
-
const nx =
|
|
4572
|
+
const nx = runStateWithProtocol(dir, ['next']);
|
|
3749
4573
|
assertExit(nx, 1);
|
|
3750
4574
|
assertOut(nx, 'BLOCKED');
|
|
3751
4575
|
assertOut(nx, 'advance');
|
|
@@ -3808,7 +4632,7 @@ const SCENARIOS = [
|
|
|
3808
4632
|
execFileSync('git', ['init', '-q'], { cwd: dir, stdio: 'ignore' });
|
|
3809
4633
|
execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '--allow-empty', '-m', 'init'], { cwd: dir, stdio: 'ignore' });
|
|
3810
4634
|
const branchBefore = execFileSync('git', ['branch', '--show-current'], { cwd: dir, encoding: 'utf8' }).trim();
|
|
3811
|
-
const res =
|
|
4635
|
+
const res = runStateWithProtocol(dir, ['init', '--help']);
|
|
3812
4636
|
assertExit(res, 1);
|
|
3813
4637
|
assertOut(res, 'not a change name');
|
|
3814
4638
|
assertOut(res, 'Usage: workflow-state.mjs init');
|
|
@@ -3822,7 +4646,7 @@ const SCENARIOS = [
|
|
|
3822
4646
|
throw new Error('init --help 不应创建 .specs/--help 工件目录');
|
|
3823
4647
|
}
|
|
3824
4648
|
// ② 带前导空白的 flag-like 参数(如 " --help")经 trim 后同样应被拒绝
|
|
3825
|
-
const res2 =
|
|
4649
|
+
const res2 = runStateWithProtocol(dir, ['init', ' --help']);
|
|
3826
4650
|
assertExit(res2, 1);
|
|
3827
4651
|
assertOut(res2, 'not a change name');
|
|
3828
4652
|
if (fs.existsSync(path.join(dir, '.specs', ' --help'))) {
|
|
@@ -3942,7 +4766,7 @@ const SCENARIOS = [
|
|
|
3942
4766
|
writeState(dir, st);
|
|
3943
4767
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why(为什么做)\nx');
|
|
3944
4768
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\nx\n\n## 验收准则(AC)\n- Given x When y Then z');
|
|
3945
|
-
const res =
|
|
4769
|
+
const res = runStateWithProtocol(dir, ['record', 'open', '{"summary":"done"}']);
|
|
3946
4770
|
assertExit(res, 0);
|
|
3947
4771
|
const loads = path.join(dir, '.specs', CHANGE_ID, '.skill-loads');
|
|
3948
4772
|
const changeMarker = path.join(loads, 'open-flow-comet-change.json');
|
|
@@ -4010,7 +4834,7 @@ const SCENARIOS = [
|
|
|
4010
4834
|
name: '123 init 空仓库提示:无提交仓库的分支创建边界(M8)',
|
|
4011
4835
|
run: (dir) => {
|
|
4012
4836
|
execFileSync('git', ['init', '-q'], { cwd: dir, stdio: 'ignore' });
|
|
4013
|
-
const res =
|
|
4837
|
+
const res = runStateWithProtocol(dir, ['init', 'empty-repo']);
|
|
4014
4838
|
assertExit(res, 0);
|
|
4015
4839
|
assertOut(res, 'EMPTY-REPO');
|
|
4016
4840
|
// 子断言 ①:警告后不得实际创建分支(unborn HEAD 下 rev-parse 失败 → currentBranch=null
|
|
@@ -4179,7 +5003,7 @@ const SCENARIOS = [
|
|
|
4179
5003
|
const res = runGuard(['exit', 'execute'], dir);
|
|
4180
5004
|
assertExit(res, 1);
|
|
4181
5005
|
assertOut(res, '缓存');
|
|
4182
|
-
// 子断言:拦截消息须含关键词引导(
|
|
5006
|
+
// 子断言:拦截消息须含关键词引导(声明级校验的执行者体验——真机回归实证:语义完整但
|
|
4183
5007
|
// 缺关键词被拦,消息应指明所需关键词,防执行者无从下手)
|
|
4184
5008
|
assertOut(res, '须含关键词');
|
|
4185
5009
|
},
|
|
@@ -4222,7 +5046,7 @@ const SCENARIOS = [
|
|
|
4222
5046
|
// ===== M-02 request 时刻归属门禁(AC-1/AC-2/AC-3 的 L1 面)=====
|
|
4223
5047
|
// 夹具前提:新 change 驻留 execute + 本节点技能声明标记在场(否则先被技能声明门 BLOCK,
|
|
4224
5048
|
// 测不到归属门禁本身);协议副本由运行器放入 <dir>/reference/ 并显式指向(env 优先级)。
|
|
4225
|
-
const reqEnv = { FLOW_COMET_PROTOCOL:
|
|
5049
|
+
const reqEnv = { FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) };
|
|
4226
5050
|
const reqStatePath = path.join(dir, '.flow-comet', 'flow-comet-state.json');
|
|
4227
5051
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID, '.skill-loads'), { recursive: true });
|
|
4228
5052
|
writeFile(dir, '.specs/' + CHANGE_ID + '/.skill-loads/execute-flow-comet-dev.json',
|
|
@@ -4296,7 +5120,7 @@ const SCENARIOS = [
|
|
|
4296
5120
|
throw new Error('依赖未满足 BLOCK 不得落 handoffRequests: ' + JSON.stringify(stUnmet.evidence));
|
|
4297
5121
|
}
|
|
4298
5122
|
// 同构真实链路:next 对当前 TASK 实际输出 execute(依赖未满足/串行消化),与指引条件分支一致
|
|
4299
|
-
const resUnmetNext =
|
|
5123
|
+
const resUnmetNext = runStateWithProtocol(dir, ['next']);
|
|
4300
5124
|
assertExit(resUnmetNext, 0);
|
|
4301
5125
|
if (!/^NODE: execute$/m.test(resUnmetNext.output)) {
|
|
4302
5126
|
throw new Error('依赖未满足时 next 应输出 execute(指引一致性锚):\n' + resUnmetNext.output);
|
|
@@ -4339,7 +5163,7 @@ const SCENARIOS = [
|
|
|
4339
5163
|
run: (dir) => {
|
|
4340
5164
|
execFileSync('git', ['init', '-q'], { cwd: dir, stdio: 'ignore' });
|
|
4341
5165
|
execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '--allow-empty', '-m', 'init'], { cwd: dir, stdio: 'ignore' });
|
|
4342
|
-
const res =
|
|
5166
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID]);
|
|
4343
5167
|
assertExit(res, 0);
|
|
4344
5168
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
4345
5169
|
if (st.newChange !== true) throw new Error('init 未写入 newChange: true');
|
|
@@ -4392,7 +5216,7 @@ const SCENARIOS = [
|
|
|
4392
5216
|
const st = baseState('open');
|
|
4393
5217
|
writeState(dir, st);
|
|
4394
5218
|
assertExit(runGuard(['entry', 'open'], dir), 0);
|
|
4395
|
-
assertExit(
|
|
5219
|
+
assertExit(runStateWithProtocol(dir, ['record', 'open', '{"summary":"intake"}']), 0);
|
|
4396
5220
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why(为什么做)\nx');
|
|
4397
5221
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\nx\n\n## 验收准则(AC)\n- Given x When y Then z');
|
|
4398
5222
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID, '.skill-loads'), { recursive: true });
|
|
@@ -4474,14 +5298,13 @@ const SCENARIOS = [
|
|
|
4474
5298
|
{
|
|
4475
5299
|
name: '136 verifyFailures 按 change 隔离:切换计数独立 + 旧字段迁移',
|
|
4476
5300
|
run: (dir) => {
|
|
4477
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
4478
5301
|
// ① 旧字段迁移:旧 state(顶层 verifyFailures=2)→ verify-fail 并入当前 change(2+1=3)不超限
|
|
4479
5302
|
const st = baseState('verify');
|
|
4480
5303
|
st.verifyFailures = 2;
|
|
4481
5304
|
writeState(dir, st);
|
|
4482
5305
|
// 场景内 ch/ch2 目录(select 要求 change 目录存在)
|
|
4483
5306
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
4484
|
-
const r1 =
|
|
5307
|
+
const r1 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4485
5308
|
assertExit(r1, 0);
|
|
4486
5309
|
assertOut(r1, 'VERIFY-FAIL: 3/3');
|
|
4487
5310
|
const stAfter = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -4492,26 +5315,26 @@ const SCENARIOS = [
|
|
|
4492
5315
|
throw new Error('旧顶层字段应已清除: ' + JSON.stringify(stAfter.verifyFailures));
|
|
4493
5316
|
}
|
|
4494
5317
|
// ② 同 change 第 4 次 → BLOCK(3 >= 3)
|
|
4495
|
-
const r2 =
|
|
5318
|
+
const r2 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4496
5319
|
assertExit(r2, 1);
|
|
4497
5320
|
assertOut(r2, '超限');
|
|
4498
5321
|
// ③ 切换 change:select ch2 → 计数独立(若实现仍用全局计数 3,此处会误 BLOCK = RED)
|
|
4499
5322
|
writeFile(dir, '.specs/ch2/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
4500
|
-
const r3 =
|
|
5323
|
+
const r3 = runStateWithProtocol(dir, ['select', 'ch2']);
|
|
4501
5324
|
assertExit(r3, 0);
|
|
4502
|
-
const r4 =
|
|
5325
|
+
const r4 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4503
5326
|
assertExit(r4, 0);
|
|
4504
5327
|
assertOut(r4, 'VERIFY-FAIL: 1/3');
|
|
4505
5328
|
// ④ ch2 独立计数:连续 3 次后第 4 次 BLOCK
|
|
4506
|
-
assertExit(
|
|
4507
|
-
assertExit(
|
|
4508
|
-
const r7 =
|
|
5329
|
+
assertExit(runStateWithProtocol(dir, ['verify-fail']), 0);
|
|
5330
|
+
assertExit(runStateWithProtocol(dir, ['verify-fail']), 0);
|
|
5331
|
+
const r7 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4509
5332
|
assertExit(r7, 1);
|
|
4510
5333
|
assertOut(r7, '超限');
|
|
4511
5334
|
// ⑤ 切回 ch:原计数保留(3 → 仍超限,不串扰不回零)
|
|
4512
|
-
const r8 =
|
|
5335
|
+
const r8 = runStateWithProtocol(dir, ['select', 'ch']);
|
|
4513
5336
|
assertExit(r8, 0);
|
|
4514
|
-
const r9 =
|
|
5337
|
+
const r9 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4515
5338
|
assertExit(r9, 1);
|
|
4516
5339
|
assertOut(r9, '超限');
|
|
4517
5340
|
// ⑥ 计数隔离扩展(AC-5):verify 失败计数与 Fix 归位轮次各自独立——verify-fail 只动
|
|
@@ -4521,11 +5344,11 @@ const SCENARIOS = [
|
|
|
4521
5344
|
stIsolated.fixRoundsByChange = { ch: 2, ch2: 1 };
|
|
4522
5345
|
writeState(dir, stIsolated);
|
|
4523
5346
|
writeFile(dir, '.specs/ch3/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
4524
|
-
assertExit(
|
|
5347
|
+
assertExit(runStateWithProtocol(dir, ['select', 'ch3']), 0);
|
|
4525
5348
|
const stCh3Before = readScenarioState(dir);
|
|
4526
5349
|
stCh3Before.fixRoundsByChange = { ch: 2, ch2: 1, ch3: 5 };
|
|
4527
5350
|
writeState(dir, stCh3Before);
|
|
4528
|
-
const r10 =
|
|
5351
|
+
const r10 = runStateWithProtocol(dir, ['verify-fail']);
|
|
4529
5352
|
assertExit(r10, 0);
|
|
4530
5353
|
assertOut(r10, 'VERIFY-FAIL: 1/3');
|
|
4531
5354
|
const stCh3After = readScenarioState(dir);
|
|
@@ -4547,7 +5370,6 @@ const SCENARIOS = [
|
|
|
4547
5370
|
{
|
|
4548
5371
|
name: '137 next 不推走进行中节点:exit 被拦截后重跑路径保留',
|
|
4549
5372
|
run: (dir) => {
|
|
4550
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
4551
5373
|
const st = baseState('review');
|
|
4552
5374
|
st.completedNodes = ['open', 'design', 'plan', 'execute', 'subagent-execute'];
|
|
4553
5375
|
st.evidence.review = { summary: 'reviewed' }; // record 过但 exit 被拦截
|
|
@@ -4561,18 +5383,18 @@ const SCENARIOS = [
|
|
|
4561
5383
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', '# T01-SUMMARY\n## verify 输出\nx\n## 6 维自查\nx\n## 越界检查\nx\n');
|
|
4562
5384
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md', '# REVIEW\n\n## Critical\n\n无。\n\n## 发现\n\n- **问题A**: 某处问题 **[已修]**\n\n## 结论\n\n通过\n');
|
|
4563
5385
|
// ① next:进行中节点(evidence 存在且未 exit)不被漂移校正推走(修复前校正到 verify = RED)
|
|
4564
|
-
const r1 =
|
|
5386
|
+
const r1 = runStateWithProtocol(dir, ['next']);
|
|
4565
5387
|
assertExit(r1, 0);
|
|
4566
5388
|
assertOut(r1, 'NODE: review');
|
|
4567
5389
|
assertNotOut(r1, 'NODE: verify');
|
|
4568
5390
|
// ② exit review 重跑路径保留:缺处置标记 → BLOCKED(新 change),补标记后通过
|
|
4569
|
-
assertExit(
|
|
5391
|
+
assertExit(runGuardWithProtocol(dir, ['entry', 'review']), 0); // 新 change 强制先 entry
|
|
4570
5392
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md', '# REVIEW\n\n## Critical\n\n无。\n\n## 发现\n\n- **问题B**: 某处问题无处置标记\n\n## 结论\n\n通过\n');
|
|
4571
|
-
const rBlock =
|
|
5393
|
+
const rBlock = runGuardWithProtocol(dir, ['exit', 'review']);
|
|
4572
5394
|
assertExit(rBlock, 1);
|
|
4573
5395
|
assertOut(rBlock, '处置状态标记');
|
|
4574
5396
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md', '# REVIEW\n\n## Critical\n\n无。\n\n## 发现\n\n- **问题B**: 某处问题 **[已修]**\n\n## 结论\n\n通过\n');
|
|
4575
|
-
const rPass =
|
|
5397
|
+
const rPass = runGuardWithProtocol(dir, ['exit', 'review', '--apply']);
|
|
4576
5398
|
assertExit(rPass, 0);
|
|
4577
5399
|
assertOut(rPass, 'ALL CHECKS PASSED');
|
|
4578
5400
|
},
|
|
@@ -4862,7 +5684,7 @@ const SCENARIOS = [
|
|
|
4862
5684
|
writeState(dir, st);
|
|
4863
5685
|
// 形似对象字面量但未闭合(PowerShell 剥离内嵌引号后常见的损坏 JSON 形态)
|
|
4864
5686
|
const bad = '{summary: "intake", completedChecks: ["unit-tests"]';
|
|
4865
|
-
const res =
|
|
5687
|
+
const res = runStateWithProtocol(dir, ['record', 'open', bad]);
|
|
4866
5688
|
assertExit(res, 1);
|
|
4867
5689
|
assertOut(res, '--json-file');
|
|
4868
5690
|
// fail-closed:state 文件须保持原样(evidence.open 未被脏字符串污染)
|
|
@@ -4996,17 +5818,16 @@ const SCENARIOS = [
|
|
|
4996
5818
|
const st = baseState('open');
|
|
4997
5819
|
st.evidence.open = { summary: 'intake complete' };
|
|
4998
5820
|
writeState(dir, st);
|
|
4999
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
5000
5821
|
// ① --json-file 指向损坏 JSON(以 { 开头)→ "不是合法 JSON" + 长度元数据,不再建议 --json-file
|
|
5001
5822
|
writeFile(dir, 'payload.json', '{summary: "broken", completedChecks: ["x"]');
|
|
5002
|
-
const resFile =
|
|
5823
|
+
const resFile = runStateWithProtocol(dir, ['record', 'open', '--json-file', 'payload.json']);
|
|
5003
5824
|
assertExit(resFile, 1);
|
|
5004
5825
|
assertNotOut(resFile, '--json-file');
|
|
5005
5826
|
assertOut(resFile, '不是合法 JSON');
|
|
5006
5827
|
assertOut(resFile, 'length=');
|
|
5007
5828
|
// ② 内联传参损坏(以 { 开头)→ 仍建议 --json-file(既有语义保留)
|
|
5008
5829
|
const bad = '{summary: "broken"';
|
|
5009
|
-
const resInline =
|
|
5830
|
+
const resInline = runStateWithProtocol(dir, ['record', 'open', bad]);
|
|
5010
5831
|
assertExit(resInline, 1);
|
|
5011
5832
|
assertOut(resInline, '--json-file');
|
|
5012
5833
|
},
|
|
@@ -5021,8 +5842,7 @@ const SCENARIOS = [
|
|
|
5021
5842
|
const st = baseState('open');
|
|
5022
5843
|
st.evidence.open = { summary: 'intake complete' };
|
|
5023
5844
|
writeState(dir, st);
|
|
5024
|
-
const
|
|
5025
|
-
const res = runState(['record', 'open', '[plain-text-not-json'], dir, env);
|
|
5845
|
+
const res = runStateWithProtocol(dir, ['record', 'open', '[plain-text-not-json']);
|
|
5026
5846
|
assertExit(res, 1);
|
|
5027
5847
|
if (!/--json-file|not valid JSON|不是合法 JSON/.test(res.output)) {
|
|
5028
5848
|
throw new Error('fail-closed 应有提示(--json-file / not valid JSON / 不是合法 JSON),实际输出: ' + res.output);
|
|
@@ -5622,7 +6442,7 @@ const SCENARIOS = [
|
|
|
5622
6442
|
{
|
|
5623
6443
|
name: '162 技能加载前置门:request/record 无声明新 BLOCK / 旧 WARN',
|
|
5624
6444
|
run: (dir) => {
|
|
5625
|
-
const env = { FLOW_COMET_PROTOCOL:
|
|
6445
|
+
const env = { FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) };
|
|
5626
6446
|
// ① handoff request 前置门:新 change、subagent-execute 节点无声明标记 → BLOCK
|
|
5627
6447
|
const stReq = baseState('subagent-execute');
|
|
5628
6448
|
stReq.newChange = true;
|
|
@@ -5634,13 +6454,13 @@ const SCENARIOS = [
|
|
|
5634
6454
|
const stRec = baseState('plan');
|
|
5635
6455
|
stRec.newChange = true;
|
|
5636
6456
|
writeState(dir, stRec);
|
|
5637
|
-
const resRec =
|
|
6457
|
+
const resRec = runStateWithProtocol(dir, ['record', 'plan', '{"summary":"plan done"}']);
|
|
5638
6458
|
assertExit(resRec, 1);
|
|
5639
6459
|
assertOut(resRec, '先加载技能');
|
|
5640
6460
|
// ③ 旧 change:record 无声明 → WARN 渐进不阻断
|
|
5641
6461
|
const stOld = baseState('plan');
|
|
5642
6462
|
writeState(dir, stOld);
|
|
5643
|
-
const resOld =
|
|
6463
|
+
const resOld = runStateWithProtocol(dir, ['record', 'plan', '{"summary":"plan done"}']);
|
|
5644
6464
|
assertExit(resOld, 0);
|
|
5645
6465
|
assertOut(resOld, 'WARN');
|
|
5646
6466
|
|
|
@@ -5719,7 +6539,7 @@ const SCENARIOS = [
|
|
|
5719
6539
|
// ⑨ 协议无对应 enabled 节点 → 跳过归属门禁(删除 subagent-execute 节点):驻留 execute
|
|
5720
6540
|
// 但任务为并行 pending——若实现不做协议感知会误判目标 subagent-execute ≠ execute 而 BLOCK
|
|
5721
6541
|
writeMarker('execute');
|
|
5722
|
-
const proto = JSON.parse(fs.readFileSync(
|
|
6542
|
+
const proto = JSON.parse(fs.readFileSync(scenarioProtocolPath(dir), 'utf8'));
|
|
5723
6543
|
const noSubProto = { ...proto, nodes: proto.nodes.filter((n) => n.id !== 'subagent-execute') };
|
|
5724
6544
|
writeFile(dir, 'reference/protocol-nosub.json', JSON.stringify(noSubProto, null, 2) + '\n');
|
|
5725
6545
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', taskXml('P02', 'parallel="true" status="pending"', 'src/p02.mjs'));
|
|
@@ -5775,7 +6595,7 @@ const SCENARIOS = [
|
|
|
5775
6595
|
if (readScenarioState(dir).evidence?.['subagent-execute']?.handoffRequests?.P04) {
|
|
5776
6596
|
throw new Error('依赖未满足 BLOCK 不得落 handoffRequests');
|
|
5777
6597
|
}
|
|
5778
|
-
const resUnmetNext =
|
|
6598
|
+
const resUnmetNext = runStateWithProtocol(dir, ['next']);
|
|
5779
6599
|
assertExit(resUnmetNext, 0);
|
|
5780
6600
|
if (!/^NODE: execute$/m.test(resUnmetNext.output)) {
|
|
5781
6601
|
throw new Error('依赖未满足时 next 应输出 execute:\n' + resUnmetNext.output);
|
|
@@ -5788,7 +6608,7 @@ const SCENARIOS = [
|
|
|
5788
6608
|
afterSerial.completedNodes = [...new Set([...(afterSerial.completedNodes || []), 'execute'])];
|
|
5789
6609
|
afterSerial.evidence = { ...(afterSerial.evidence || {}), execute: { summary: 'serial digest done' } };
|
|
5790
6610
|
writeState(dir, afterSerial);
|
|
5791
|
-
const resDelegableNext =
|
|
6611
|
+
const resDelegableNext = runStateWithProtocol(dir, ['next']);
|
|
5792
6612
|
assertExit(resDelegableNext, 0);
|
|
5793
6613
|
if (!/^NODE: subagent-execute$/m.test(resDelegableNext.output)) {
|
|
5794
6614
|
throw new Error('依赖满足后 next 应输出 subagent-execute:\n' + resDelegableNext.output);
|
|
@@ -5797,7 +6617,7 @@ const SCENARIOS = [
|
|
|
5797
6617
|
throw new Error('依赖满足后 next 应把工作归属推到 subagent-execute');
|
|
5798
6618
|
}
|
|
5799
6619
|
writeMarker('subagent-execute');
|
|
5800
|
-
assertExit(
|
|
6620
|
+
assertExit(runGuardWithProtocol(dir, ['entry', 'subagent-execute']), 0);
|
|
5801
6621
|
const resRecovered = runHandoff(['request', 'P04', 'now delegable'], dir, env);
|
|
5802
6622
|
assertExit(resRecovered, 0);
|
|
5803
6623
|
assertOut(resRecovered, 'HANDOFF REQUEST: P04');
|
|
@@ -5871,7 +6691,7 @@ const SCENARIOS = [
|
|
|
5871
6691
|
assertExit(runState(['init', boundChange, '--init-skip', '--protocol', 'reference/protocol-bound.json'], dir), 0);
|
|
5872
6692
|
writeFile(dir, '.specs/' + boundChange + '/TASK.md', taskXml('B01', 'parallel="false" status="pending"', 'src/b01.mjs'));
|
|
5873
6693
|
const resBound = runHandoff(['request', 'B01', 'bound protocol serial'], dir,
|
|
5874
|
-
{ FLOW_COMET_PROTOCOL:
|
|
6694
|
+
{ FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) });
|
|
5875
6695
|
assertExit(resBound, 0);
|
|
5876
6696
|
assertOut(resBound, 'HANDOFF REQUEST: B01');
|
|
5877
6697
|
assertNotOut(resBound, 'BLOCKED');
|
|
@@ -5890,7 +6710,7 @@ const SCENARIOS = [
|
|
|
5890
6710
|
writeState(dir, boundMissingState);
|
|
5891
6711
|
writeFile(dir, '.specs/' + boundChange + '/TASK.md', taskXml('B02', 'parallel="false" status="pending"', 'src/b02.mjs'));
|
|
5892
6712
|
const resBoundMissing = runHandoff(['request', 'B02', 'bound protocol unreadable'], dir,
|
|
5893
|
-
{ FLOW_COMET_PROTOCOL:
|
|
6713
|
+
{ FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) });
|
|
5894
6714
|
assertExit(resBoundMissing, 0);
|
|
5895
6715
|
assertOut(resBoundMissing, 'WARN:');
|
|
5896
6716
|
assertOut(resBoundMissing, '本次未执行归属校验');
|
|
@@ -5909,7 +6729,7 @@ const SCENARIOS = [
|
|
|
5909
6729
|
writeState(dir, legacyBoundState);
|
|
5910
6730
|
writeFile(dir, '.specs/' + boundChange + '/TASK.md', taskXml('B03', 'parallel="false" status="pending"', 'src/b03.mjs'));
|
|
5911
6731
|
const resLegacyBound = runHandoff(['request', 'B03', 'legacy state no binding'], dir,
|
|
5912
|
-
{ FLOW_COMET_PROTOCOL:
|
|
6732
|
+
{ FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir) });
|
|
5913
6733
|
assertExit(resLegacyBound, 1);
|
|
5914
6734
|
assertOut(resLegacyBound, 'BLOCKED: 任务 B03(串行 pending)应归属节点 execute');
|
|
5915
6735
|
},
|
|
@@ -5921,20 +6741,19 @@ const SCENARIOS = [
|
|
|
5921
6741
|
{
|
|
5922
6742
|
name: '163 next / entry 输出点名 LOAD SKILL:用 Skill 工具,禁止跳过',
|
|
5923
6743
|
run: (dir) => {
|
|
5924
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
5925
6744
|
// ① next:open 节点 → 输出点名 flow-comet-open
|
|
5926
6745
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
5927
6746
|
const st = baseState('open');
|
|
5928
6747
|
st.evidence.open = { summary: 'intake complete' };
|
|
5929
6748
|
writeState(dir, st);
|
|
5930
|
-
const resNext =
|
|
6749
|
+
const resNext = runStateWithProtocol(dir, ['next']);
|
|
5931
6750
|
assertExit(resNext, 0);
|
|
5932
6751
|
assertOut(resNext, 'LOAD SKILL: flow-comet-open');
|
|
5933
6752
|
assertOut(resNext, '禁止跳过');
|
|
5934
6753
|
// ② guard entry:plan 节点 → 输出点名 flow-comet-plan
|
|
5935
6754
|
const st2 = baseState('plan');
|
|
5936
6755
|
writeState(dir, st2);
|
|
5937
|
-
const resEntry =
|
|
6756
|
+
const resEntry = runGuardWithProtocol(dir, ['entry', 'plan']);
|
|
5938
6757
|
assertExit(resEntry, 0);
|
|
5939
6758
|
assertOut(resEntry, 'LOAD SKILL: flow-comet-plan');
|
|
5940
6759
|
assertOut(resEntry, '禁止跳过');
|
|
@@ -5977,7 +6796,6 @@ const SCENARIOS = [
|
|
|
5977
6796
|
{
|
|
5978
6797
|
name: '165 next 保护扩展:entered 未 record 节点不推走(保持 plan)',
|
|
5979
6798
|
run: (dir) => {
|
|
5980
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
5981
6799
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
5982
6800
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why(为什么做)\n\nx');
|
|
5983
6801
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n\nx\n\n## 验收准则(AC)\n\n- Given x When y Then z');
|
|
@@ -5997,7 +6815,7 @@ const SCENARIOS = [
|
|
|
5997
6815
|
directOverride: false,
|
|
5998
6816
|
};
|
|
5999
6817
|
writeState(dir, st);
|
|
6000
|
-
const res =
|
|
6818
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
6001
6819
|
assertExit(res, 0);
|
|
6002
6820
|
assertOut(res, 'NODE: plan');
|
|
6003
6821
|
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -6297,7 +7115,6 @@ const SCENARIOS = [
|
|
|
6297
7115
|
{
|
|
6298
7116
|
name: '172 多波混合推进完成:分趟自动路由直至清空进 review',
|
|
6299
7117
|
run: (dir) => {
|
|
6300
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
6301
7118
|
writeIntakeArtifacts(dir);
|
|
6302
7119
|
const goNext = (currentNode, doneIds, completedExtra = []) => {
|
|
6303
7120
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + renderMultiWaveTasks(doneIds));
|
|
@@ -6316,7 +7133,7 @@ const SCENARIOS = [
|
|
|
6316
7133
|
executionMode: 'subagent',
|
|
6317
7134
|
directOverride: false,
|
|
6318
7135
|
});
|
|
6319
|
-
return
|
|
7136
|
+
return runStateWithProtocol(dir, ['next']);
|
|
6320
7137
|
};
|
|
6321
7138
|
// 趟 0:无可委托并行(P 波依赖 T01 未完成)、串行 T01 pending → execute
|
|
6322
7139
|
let res = goNext('execute', []);
|
|
@@ -6351,7 +7168,6 @@ const SCENARIOS = [
|
|
|
6351
7168
|
{
|
|
6352
7169
|
name: '173 单趟零进展 BLOCK:孤儿并行依赖无法满足(检查 depends_on)',
|
|
6353
7170
|
run: (dir) => {
|
|
6354
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
6355
7171
|
writeIntakeArtifacts(dir);
|
|
6356
7172
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
6357
7173
|
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify><depends_on>T99</depends_on></task>\n');
|
|
@@ -6364,7 +7180,7 @@ const SCENARIOS = [
|
|
|
6364
7180
|
executionMode: 'subagent',
|
|
6365
7181
|
directOverride: false,
|
|
6366
7182
|
});
|
|
6367
|
-
const res =
|
|
7183
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
6368
7184
|
assertExit(res, 1);
|
|
6369
7185
|
assertOut(res, 'BLOCKED');
|
|
6370
7186
|
assertOut(res, '孤儿并行');
|
|
@@ -6380,7 +7196,6 @@ const SCENARIOS = [
|
|
|
6380
7196
|
{
|
|
6381
7197
|
name: '174 委托节点二次进入完成判定:eligible 再入 → 趟间串行 → 清空进 review',
|
|
6382
7198
|
run: (dir) => {
|
|
6383
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
6384
7199
|
writeIntakeArtifacts(dir);
|
|
6385
7200
|
const pDone = (id, deps) =>
|
|
6386
7201
|
'<task id="' + id + '" status="done" parallel="true"><action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files><verify>node --check src/' + id.toLowerCase() + '.mjs</verify>' +
|
|
@@ -6401,19 +7216,19 @@ const SCENARIOS = [
|
|
|
6401
7216
|
executionMode: 'subagent',
|
|
6402
7217
|
directOverride: false,
|
|
6403
7218
|
});
|
|
6404
|
-
let res =
|
|
7219
|
+
let res = runStateWithProtocol(dir, ['next']);
|
|
6405
7220
|
assertExit(res, 0);
|
|
6406
7221
|
assertOut(res, 'NODE: subagent-execute');
|
|
6407
7222
|
// ② P02 也 done → 可委托集合为空、串行 T03 pending → 趟间回 execute
|
|
6408
7223
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + pDone('P02', 'P01') + t03(''));
|
|
6409
|
-
res =
|
|
7224
|
+
res = runStateWithProtocol(dir, ['next']);
|
|
6410
7225
|
assertExit(res, 0);
|
|
6411
7226
|
assertOut(res, 'NODE: execute');
|
|
6412
7227
|
// ③ 全部 done + SUMMARY 在场 → 合取完成(无 eligible ∧ 无 serial pending)→ review
|
|
6413
7228
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + pDone('P02', 'P01') + t03('done'));
|
|
6414
7229
|
writeFile(dir, '.specs/' + CHANGE_ID + '/P01-SUMMARY.md', summaryContent());
|
|
6415
7230
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T03-SUMMARY.md', summaryContent());
|
|
6416
|
-
res =
|
|
7231
|
+
res = runStateWithProtocol(dir, ['next']);
|
|
6417
7232
|
assertExit(res, 0);
|
|
6418
7233
|
assertOut(res, 'NODE: review');
|
|
6419
7234
|
},
|
|
@@ -6425,7 +7240,6 @@ const SCENARIOS = [
|
|
|
6425
7240
|
{
|
|
6426
7241
|
name: '175 向后兼容等价:旧合法形态路由结果与旧期望一致',
|
|
6427
7242
|
run: (dir) => {
|
|
6428
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
6429
7243
|
writeIntakeArtifacts(dir);
|
|
6430
7244
|
const goNext = (taskContent, currentNode, completedExtra = [], withExecuteEvidence = false) => {
|
|
6431
7245
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + taskContent);
|
|
@@ -6446,7 +7260,7 @@ const SCENARIOS = [
|
|
|
6446
7260
|
executionMode: 'subagent',
|
|
6447
7261
|
directOverride: false,
|
|
6448
7262
|
});
|
|
6449
|
-
return
|
|
7263
|
+
return runStateWithProtocol(dir, ['next']);
|
|
6450
7264
|
};
|
|
6451
7265
|
// ① 全串行(含依赖链)→ execute
|
|
6452
7266
|
let res = goNext(TASK_VALID_ALL_SERIAL, 'execute');
|
|
@@ -6478,7 +7292,6 @@ const SCENARIOS = [
|
|
|
6478
7292
|
{
|
|
6479
7293
|
name: '176 伪并行 WARN:仅写测试产物的并行任务提示依赖嫌疑且不阻断',
|
|
6480
7294
|
run: (dir) => {
|
|
6481
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
6482
7295
|
writeIntakeArtifacts(dir);
|
|
6483
7296
|
writeState(dir, {
|
|
6484
7297
|
activeChange: CHANGE_ID,
|
|
@@ -6554,7 +7367,7 @@ const SCENARIOS = [
|
|
|
6554
7367
|
input: JSON.stringify(input),
|
|
6555
7368
|
env: {
|
|
6556
7369
|
...inherited,
|
|
6557
|
-
FLOW_COMET_PROTOCOL:
|
|
7370
|
+
FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir),
|
|
6558
7371
|
...extraEnv,
|
|
6559
7372
|
},
|
|
6560
7373
|
encoding: 'utf8', timeout: 60000,
|
|
@@ -6778,13 +7591,23 @@ const SCENARIOS = [
|
|
|
6778
7591
|
},
|
|
6779
7592
|
},
|
|
6780
7593
|
|
|
6781
|
-
// 184:
|
|
7594
|
+
// 184: 技能文本混排合法化语义文本锁(in-place 扩展:模板权威整句 / 入口 archive 读法 /
|
|
7595
|
+
// 规划约束 / Codex-worktree 订正)——plan 与 subagent-execute 两 SKILL 权威源不得再含
|
|
6782
7596
|
// 「连续块」「居首」旧波次形态约束表述,且依赖图语义描述(depends_on)在场、「用 Skill 工具」
|
|
6783
|
-
//
|
|
7597
|
+
// 两层加载句式保持(措辞锁族既有锚不破坏);模板权威声明覆盖 9 个既有成员(8 产出节点 + task)
|
|
7598
|
+
// 与 5 个 flow-kit 阶段协议技能 = 14 个真实成员(题面 13 按 8+5 计数漏计 task;保留既有断言
|
|
7599
|
+
// 优先,实际按 14 文件落地,成员边界见收口证据)——每份须在同一声明行内按序组合出现
|
|
7600
|
+
// 「唯一权威 = 」/「`flow-kit/templates/**`」/「是历史证据」/「不是模板来源」/「上一轮就是这么写的」
|
|
7601
|
+
// 且全数零命中旧反向声明「archive 是模板来源」;入口 SKILL 含 archive 三要素读法;plan / task
|
|
7602
|
+
// 含规划约束判别句式与各自边界锚(以本节为准 / 以本节点为准),旧同层并行句零残留;
|
|
7603
|
+
// worktree-notes / subagent-execute 含平台事实(multi_agent)与支持面(机制缺口)判别锚、
|
|
7604
|
+
// 适用范围限定(不得外推 / 不可外推),旧独断句只允许以被反驳引用形态出现。
|
|
7605
|
+
// 文本存在级断言(结构级由其余场景族覆盖)。
|
|
6784
7606
|
{
|
|
6785
7607
|
name: '184 技能文本锁:旧连续块/居首表述清零且依赖图语义描述在场',
|
|
6786
7608
|
run: () => {
|
|
6787
7609
|
const problems = [];
|
|
7610
|
+
// —— 既有锚(原文语义与失败消息保持)——
|
|
6788
7611
|
for (const skillDir of ['flow-comet-plan', 'flow-comet-subagent-execute']) {
|
|
6789
7612
|
const text = fs.readFileSync(path.join(__dirname, '..', '..', skillDir, 'SKILL.md'), 'utf8');
|
|
6790
7613
|
if (text.includes('连续块')) problems.push(skillDir + ' 含「连续块」旧形态约束表述');
|
|
@@ -6792,6 +7615,120 @@ const SCENARIOS = [
|
|
|
6792
7615
|
if (!text.includes('depends_on')) problems.push(skillDir + ' 缺依赖图语义描述(depends_on)');
|
|
6793
7616
|
if (!text.includes('用 Skill 工具')) problems.push(skillDir + ' 缺「用 Skill 工具」两层加载句式');
|
|
6794
7617
|
}
|
|
7618
|
+
// —— 模板权威整句声明:9 个既有成员 + 5 个 flow-kit 阶段协议技能(真实成员 14)——
|
|
7619
|
+
const templateAuthoritySkills = [
|
|
7620
|
+
'flow-comet-open', 'flow-comet-design', 'flow-comet-plan', 'flow-comet-execute',
|
|
7621
|
+
'flow-comet-subagent-execute', 'flow-comet-review', 'flow-comet-verify', 'flow-comet-archive',
|
|
7622
|
+
'flow-comet-task',
|
|
7623
|
+
'flow-comet-change', 'flow-comet-requirement', 'flow-comet-dev', 'flow-comet-test',
|
|
7624
|
+
'flow-comet-integration',
|
|
7625
|
+
];
|
|
7626
|
+
// 整句级语义组合:同一段声明行内按序出现下列锚点,防止只留半句或把锚点拆到不同段落。
|
|
7627
|
+
const authoritySentenceAnchors = [
|
|
7628
|
+
'唯一权威 = ', '`flow-kit/templates/**`', '是历史证据', '不是模板来源', '上一轮就是这么写的',
|
|
7629
|
+
];
|
|
7630
|
+
for (const skillDir of templateAuthoritySkills) {
|
|
7631
|
+
const rel = skillDir + '/SKILL.md';
|
|
7632
|
+
const text = fs.readFileSync(path.join(__dirname, '..', '..', skillDir, 'SKILL.md'), 'utf8');
|
|
7633
|
+
const authorityLine = text.split(/\r?\n/).find((line) => line.includes('模板权威'));
|
|
7634
|
+
if (!authorityLine) {
|
|
7635
|
+
problems.push(rel + ' 缺模板权威整句声明(正向权威 + 反向历史证据组合缺失)');
|
|
7636
|
+
continue;
|
|
7637
|
+
}
|
|
7638
|
+
let cursor = -1;
|
|
7639
|
+
for (const anchor of authoritySentenceAnchors) {
|
|
7640
|
+
const at = authorityLine.indexOf(anchor, cursor + 1);
|
|
7641
|
+
if (at < 0) {
|
|
7642
|
+
problems.push(rel + ' 模板权威整句缺「' + anchor + '」(整句语义组合)');
|
|
7643
|
+
} else {
|
|
7644
|
+
cursor = at;
|
|
7645
|
+
}
|
|
7646
|
+
}
|
|
7647
|
+
if (text.includes('archive 是模板来源')) {
|
|
7648
|
+
problems.push(rel + ' 含「archive 是模板来源」旧反向声明');
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
// —— 入口 archive 读法:三要素关键词在场 ——
|
|
7652
|
+
{
|
|
7653
|
+
const entry = fs.readFileSync(path.join(__dirname, '..', 'SKILL.md'), 'utf8');
|
|
7654
|
+
for (const keyword of ['flow-kit/templates', '何时可读', '不读什么']) {
|
|
7655
|
+
if (!entry.includes(keyword)) {
|
|
7656
|
+
problems.push('flow-comet/SKILL.md 缺「' + keyword + '」(入口 archive 读法三要素)');
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
}
|
|
7660
|
+
// —— 规划约束:plan / task 判别句式 + GUIDANCE 委托消化 ——
|
|
7661
|
+
{
|
|
7662
|
+
const directLockPhrase = 'direct 不是并行任务的逃生口';
|
|
7663
|
+
const r15Keywords = {
|
|
7664
|
+
'flow-comet-plan': ['同一文件', '并发同伴', directLockPhrase],
|
|
7665
|
+
'flow-comet-task': ['同一文件', '并发同伴', directLockPhrase],
|
|
7666
|
+
};
|
|
7667
|
+
const planText = fs.readFileSync(path.join(__dirname, '..', '..', 'flow-comet-plan', 'SKILL.md'), 'utf8');
|
|
7668
|
+
const taskText = fs.readFileSync(path.join(__dirname, '..', '..', 'flow-comet-task', 'SKILL.md'), 'utf8');
|
|
7669
|
+
for (const [skillDir, keywords] of Object.entries(r15Keywords)) {
|
|
7670
|
+
const text = skillDir === 'flow-comet-plan' ? planText : taskText;
|
|
7671
|
+
for (const keyword of keywords) {
|
|
7672
|
+
if (!text.includes(keyword)) {
|
|
7673
|
+
problems.push(skillDir + '/SKILL.md 缺「' + keyword + '」(规划期约束判别句式)');
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
if (planText.includes('Same layer = same wave (parallel execution)')) {
|
|
7678
|
+
problems.push('flow-comet-plan/SKILL.md 残留「Same layer = same wave (parallel execution)」旧同层并行句');
|
|
7679
|
+
}
|
|
7680
|
+
if (!planText.includes('以本节为准')) {
|
|
7681
|
+
problems.push('flow-comet-plan/SKILL.md 缺「以本节为准」(上游宽松语义显式覆盖锚)');
|
|
7682
|
+
}
|
|
7683
|
+
if (taskText.includes('同层并行,跨层串行')) {
|
|
7684
|
+
problems.push('flow-comet-task/SKILL.md 残留「同层并行,跨层串行」旧波次句');
|
|
7685
|
+
}
|
|
7686
|
+
if (!taskText.includes('以本节点为准')) {
|
|
7687
|
+
problems.push('flow-comet-task/SKILL.md 缺「以本节点为准」(上游宽松语义显式覆盖锚)');
|
|
7688
|
+
}
|
|
7689
|
+
const guidance = fs.readFileSync(path.join(__dirname, '..', 'GUIDANCE.md'), 'utf8');
|
|
7690
|
+
if (!guidance.includes('仍必须由 subagent-execute 委托消化')) {
|
|
7691
|
+
problems.push('flow-comet/GUIDANCE.md 缺「仍必须由 subagent-execute 委托消化」(direct 委托消化判别句)');
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
7694
|
+
// —— Codex / worktree 订正:平台事实 + 支持面判别锚与适用范围限定在场、旧独断句
|
|
7695
|
+
// 只允许以被反驳引用形态出现、fail-open 与未闭合限定在场、旧过宽句零残留 ——
|
|
7696
|
+
{
|
|
7697
|
+
const codexTexts = new Map([
|
|
7698
|
+
['reference/worktree-notes.md', fs.readFileSync(path.join(__dirname, '..', 'reference', 'worktree-notes.md'), 'utf8')],
|
|
7699
|
+
['flow-comet-subagent-execute/SKILL.md', fs.readFileSync(path.join(__dirname, '..', '..', 'flow-comet-subagent-execute', 'SKILL.md'), 'utf8')],
|
|
7700
|
+
]);
|
|
7701
|
+
const refutedClaim = '「Codex 不能委派 / 不使用并行委托」';
|
|
7702
|
+
for (const [rel, text] of codexTexts) {
|
|
7703
|
+
for (const keyword of ['multi_agent', '机制缺口']) {
|
|
7704
|
+
if (!text.includes(keyword)) {
|
|
7705
|
+
problems.push(rel + ' 缺「' + keyword + '」(Codex 平台事实与支持面判别锚)');
|
|
7706
|
+
}
|
|
7707
|
+
}
|
|
7708
|
+
// 旧独断句只允许以被反驳引用的完整形态出现:剥离该引用后不得再有残句。
|
|
7709
|
+
if (text.split(refutedClaim).join('').includes('不使用并行委托')) {
|
|
7710
|
+
problems.push(rel + ' 残留旧独断句「不使用并行委托」(非被反驳引用形态)');
|
|
7711
|
+
}
|
|
7712
|
+
if (!text.includes('不得外推') && !text.includes('不可外推')) {
|
|
7713
|
+
problems.push(rel + ' 缺「不得外推 / 不可外推」适用范围限定');
|
|
7714
|
+
}
|
|
7715
|
+
}
|
|
7716
|
+
const worktreeNotes = codexTexts.get('reference/worktree-notes.md');
|
|
7717
|
+
for (const keyword of ['fail-open', '未闭合']) {
|
|
7718
|
+
if (!worktreeNotes.includes(keyword)) {
|
|
7719
|
+
problems.push('reference/worktree-notes.md 缺「' + keyword + '」(Codex/worktree 订正限定)');
|
|
7720
|
+
}
|
|
7721
|
+
}
|
|
7722
|
+
if (worktreeNotes.includes('受支持的工作流仍是串行执行')) {
|
|
7723
|
+
problems.push('reference/worktree-notes.md 残留「受支持的工作流仍是串行执行」旧独断句');
|
|
7724
|
+
}
|
|
7725
|
+
if (worktreeNotes.includes('写入仍会被协调者白名单拦截')) {
|
|
7726
|
+
problems.push('reference/worktree-notes.md 残留「写入仍会被协调者白名单拦截」旧过宽句');
|
|
7727
|
+
}
|
|
7728
|
+
if (codexTexts.get('flow-comet-subagent-execute/SKILL.md').includes('写入会被协调者白名单拦截')) {
|
|
7729
|
+
problems.push('flow-comet-subagent-execute/SKILL.md 残留「写入会被协调者白名单拦截」旧过宽句');
|
|
7730
|
+
}
|
|
7731
|
+
}
|
|
6795
7732
|
if (problems.length > 0) throw new Error('技能文本混排合法化语义不符: ' + problems.join('; '));
|
|
6796
7733
|
},
|
|
6797
7734
|
},
|
|
@@ -7144,7 +8081,6 @@ const SCENARIOS = [
|
|
|
7144
8081
|
{
|
|
7145
8082
|
name: '198 多趟出口路由时序收敛:逐节点 exit --apply 后 next 输出 NODE 与 guard 出口 NODE 一致',
|
|
7146
8083
|
run: (dir) => {
|
|
7147
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7148
8084
|
const writeTask = (statusMap) => {
|
|
7149
8085
|
const blk = (id, parallel, deps) =>
|
|
7150
8086
|
'<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
|
|
@@ -7178,7 +8114,7 @@ const SCENARIOS = [
|
|
|
7178
8114
|
const assertConverge = (guardRes) => {
|
|
7179
8115
|
assertExit(guardRes, 0);
|
|
7180
8116
|
const gNode = nodeOf(guardRes.output);
|
|
7181
|
-
const nextRes =
|
|
8117
|
+
const nextRes = runStateWithProtocol(dir, ['next']);
|
|
7182
8118
|
assertExit(nextRes, 0);
|
|
7183
8119
|
const sNode = nodeOf(nextRes.output);
|
|
7184
8120
|
if (gNode !== sNode) {
|
|
@@ -7262,7 +8198,7 @@ const SCENARIOS = [
|
|
|
7262
8198
|
const res = runGuard(['exit', 'archive', '--apply'], dir);
|
|
7263
8199
|
assertExit(res, 0);
|
|
7264
8200
|
assertOut(res, 'NEXT: done');
|
|
7265
|
-
const nextRes =
|
|
8201
|
+
const nextRes = runStateWithProtocol(dir, ['next']);
|
|
7266
8202
|
assertExit(nextRes, 0);
|
|
7267
8203
|
assertOut(nextRes, 'NEXT: done');
|
|
7268
8204
|
},
|
|
@@ -7315,18 +8251,35 @@ const SCENARIOS = [
|
|
|
7315
8251
|
if (!srcStamp) throw new Error('权威源 loader 未提取到版本戳(场景前置失效)');
|
|
7316
8252
|
const installed = fs.readFileSync(path.join(dshHome, 'plugins', 'dsh-flow-comet-bridge.mjs'), 'utf8');
|
|
7317
8253
|
if (!installed.includes('BRIDGE_VERSION: ' + srcStamp[1])) throw new Error('覆盖后 loader 版本戳非权威源值');
|
|
7318
|
-
//
|
|
7319
|
-
//
|
|
7320
|
-
//
|
|
8254
|
+
// 子断言(发布同步守卫):权威源 loader 的标记行、导出常量与载体 INSTALLED_VERSION
|
|
8255
|
+
// 三处按 **bridge-check 既有语义**比较(MECHANISM 二·二十七「bridge-check 基础版本归一」:
|
|
8256
|
+
// 剥离 dev 态后缀 `-<N>-g<hash>`、按基础版本比较;预发布标识不剥离)——任一处基础版本漂移
|
|
8257
|
+
// 时安装副本的 bridge-check 会在已装项目报版本偏斜(上方断言只证明「覆盖 == 权威源文件」,
|
|
8258
|
+
// 无法捕获跨文件/跨值分叉)。旧严格全等使主仓「dev 态副本 + 权威源」形态结构性必红(F6);
|
|
8259
|
+
// 归一后 dev 态同基础判同步,真实漂移仍必报(判别力见下方子锚表)。
|
|
7321
8260
|
const installedVersion = fs.readFileSync(path.join(__dirname, '..', 'INSTALLED_VERSION'), 'utf8').trim();
|
|
7322
8261
|
const exportMatch = /^export const version = '([^']+)';$/m.exec(srcText);
|
|
7323
8262
|
if (!exportMatch) throw new Error('权威源 loader 未提取到 export version(场景前置失效)');
|
|
7324
|
-
|
|
8263
|
+
const syncProblems = bridgeStampSyncProblems(srcStamp[1], exportMatch[1], installedVersion);
|
|
8264
|
+
if (syncProblems.length > 0) {
|
|
7325
8265
|
throw new Error(
|
|
7326
|
-
'
|
|
7327
|
-
' / INSTALLED_VERSION=' + installedVersion + ')——发布同步遗漏(bridge-check
|
|
8266
|
+
'权威源版本三处基础版本不一致(标记行=' + srcStamp[1] + ' / export=' + exportMatch[1] +
|
|
8267
|
+
' / INSTALLED_VERSION=' + installedVersion + ')——发布同步遗漏(bridge-check 会在安装副本报版本偏斜):' +
|
|
8268
|
+
syncProblems.join(';')
|
|
7328
8269
|
);
|
|
7329
8270
|
}
|
|
8271
|
+
// in-place 锚(F6:发布同步守卫判别力双向证明,不新增顶层编号)——权威源 loader 的发布戳
|
|
8272
|
+
// 与 dev 态副本 INSTALLED_VERSION 必须按 bridge-check 既有语义比较:剥离 dev 态后缀按基础
|
|
8273
|
+
// 版本判同步(锚表正例即该真实形态),真实漂移(基础版本不同 / 发布版对发布版 / 预发布标识
|
|
8274
|
+
// 不剥离)仍必报。
|
|
8275
|
+
const baseVersion = fixtureBridgeBaseVersion(installedVersion);
|
|
8276
|
+
for (const subAnchor of bridgeStampSyncSubAnchorCases(baseVersion, installedVersion)) {
|
|
8277
|
+
const synced = subAnchor.problems.length === 0;
|
|
8278
|
+
if (synced !== subAnchor.expectSync) {
|
|
8279
|
+
throw new Error('发布同步守卫子锚失败(' + subAnchor.label + '):期望'
|
|
8280
|
+
+ (subAnchor.expectSync ? '同步' : '报漂移') + ',实际 problems=' + JSON.stringify(subAnchor.problems));
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
7330
8283
|
},
|
|
7331
8284
|
},
|
|
7332
8285
|
|
|
@@ -7492,7 +8445,6 @@ const SCENARIOS = [
|
|
|
7492
8445
|
{
|
|
7493
8446
|
name: '207 多趟平行转换 next 可达且与 guard NEXT 一致(完整时序锚)',
|
|
7494
8447
|
run: (dir) => {
|
|
7495
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7496
8448
|
const writeTask = (statusMap) => {
|
|
7497
8449
|
const blk = (id, parallel, deps) =>
|
|
7498
8450
|
'<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
|
|
@@ -7522,7 +8474,7 @@ const SCENARIOS = [
|
|
|
7522
8474
|
const assertConverge = (guardRes) => {
|
|
7523
8475
|
assertExit(guardRes, 0);
|
|
7524
8476
|
const gNode = nodeOf(guardRes.output);
|
|
7525
|
-
const nextRes =
|
|
8477
|
+
const nextRes = runStateWithProtocol(dir, ['next']);
|
|
7526
8478
|
assertExit(nextRes, 0);
|
|
7527
8479
|
const sNode = nodeOf(nextRes.output);
|
|
7528
8480
|
if (gNode !== sNode) {
|
|
@@ -7594,7 +8546,7 @@ const SCENARIOS = [
|
|
|
7594
8546
|
const resArch = runGuard(['exit', 'archive', '--apply'], dir);
|
|
7595
8547
|
assertExit(resArch, 0);
|
|
7596
8548
|
assertOut(resArch, 'NEXT: done');
|
|
7597
|
-
const nextRes =
|
|
8549
|
+
const nextRes = runStateWithProtocol(dir, ['next']);
|
|
7598
8550
|
assertExit(nextRes, 0);
|
|
7599
8551
|
assertOut(nextRes, 'NEXT: done');
|
|
7600
8552
|
},
|
|
@@ -7606,7 +8558,6 @@ const SCENARIOS = [
|
|
|
7606
8558
|
{
|
|
7607
8559
|
name: '208 record 后未 exit 先 next 不漂移死结:后续 exit 仍可',
|
|
7608
8560
|
run: (dir) => {
|
|
7609
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7610
8561
|
// 前序产物(open/design 已完成,plan 已进入并 record——未 exit)
|
|
7611
8562
|
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n- **Change ID**: ' + CHANGE_ID + '\n\n## Why(为什么做)\n\nx\n\n## 范围(Scope)\n');
|
|
7612
8563
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md', '# REQUIREMENT\n\n- **Change ID**: ' + CHANGE_ID + '\n\n## 用户故事(User Story)\n\nx\n\n## 验收准则(AC)\n\n- Given x When y Then z');
|
|
@@ -7627,7 +8578,7 @@ const SCENARIOS = [
|
|
|
7627
8578
|
st.newChange = true;
|
|
7628
8579
|
writeState(dir, st);
|
|
7629
8580
|
// ① record 后未 exit 先 next:不把 currentNode 提前校正到 subagent-execute(路由后继)
|
|
7630
|
-
const r1 =
|
|
8581
|
+
const r1 = runStateWithProtocol(dir, ['next']);
|
|
7631
8582
|
assertExit(r1, 0);
|
|
7632
8583
|
assertOut(r1, 'NODE: plan');
|
|
7633
8584
|
const stAfterNext = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -7640,7 +8591,7 @@ const SCENARIOS = [
|
|
|
7640
8591
|
assertExit(rExit, 0);
|
|
7641
8592
|
assertOut(rExit, 'ALL CHECKS PASSED');
|
|
7642
8593
|
// ③ exit 推进后 next 路由到 subagent-execute(平行转换点——与 guard 出口一致)
|
|
7643
|
-
const r2 =
|
|
8594
|
+
const r2 = runStateWithProtocol(dir, ['next']);
|
|
7644
8595
|
assertExit(r2, 0);
|
|
7645
8596
|
assertOut(r2, 'NODE: subagent-execute');
|
|
7646
8597
|
},
|
|
@@ -7652,7 +8603,6 @@ const SCENARIOS = [
|
|
|
7652
8603
|
{
|
|
7653
8604
|
name: '209 exit 漂移容忍:currentNode 已为文件推导下一节点且证据/产物齐 → exit 可过',
|
|
7654
8605
|
run: (dir) => {
|
|
7655
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7656
8606
|
writeIntakeArtifacts(dir);
|
|
7657
8607
|
// TASK 全 done(T01 串行)+ SUMMARY(execute 产物门控)
|
|
7658
8608
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
@@ -7697,7 +8647,6 @@ const SCENARIOS = [
|
|
|
7697
8647
|
{
|
|
7698
8648
|
name: '210 exit 漂移仍 BLOCK:漂移但证据/产物不齐(容错不放开未完成)',
|
|
7699
8649
|
run: (dir) => {
|
|
7700
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7701
8650
|
writeIntakeArtifacts(dir);
|
|
7702
8651
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
7703
8652
|
'<task id="T01" status="done"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n');
|
|
@@ -7729,7 +8678,6 @@ const SCENARIOS = [
|
|
|
7729
8678
|
{
|
|
7730
8679
|
name: '211 路由诊断静默:剩余 pending 全串行(P→S 收尾转换)无 ROUTE WARN',
|
|
7731
8680
|
run: (dir) => {
|
|
7732
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7733
8681
|
writeIntakeArtifacts(dir);
|
|
7734
8682
|
const st = baseState('plan');
|
|
7735
8683
|
st.completedNodes = ['open', 'design'];
|
|
@@ -7739,7 +8687,7 @@ const SCENARIOS = [
|
|
|
7739
8687
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
7740
8688
|
'<task id="P01" parallel="true" status="done">\n <action>do</action>\n <verify>echo ok</verify>\n</task>\n' +
|
|
7741
8689
|
'<task id="S01" parallel="false" status="pending">\n <action>do serial</action>\n <verify>echo ok</verify>\n</task>\n');
|
|
7742
|
-
const res =
|
|
8690
|
+
const res = runGuardWithProtocol(dir, ['exit', 'plan', '--apply']);
|
|
7743
8691
|
assertExit(res, 0);
|
|
7744
8692
|
assertNotOut(res, 'ROUTE WARN');
|
|
7745
8693
|
assertOut(res, 'ALL CHECKS PASSED');
|
|
@@ -7752,7 +8700,6 @@ const SCENARIOS = [
|
|
|
7752
8700
|
{
|
|
7753
8701
|
name: '212 路由诊断保持:parallel 缺 status(畸形块)仍报 ROUTE WARN',
|
|
7754
8702
|
run: (dir) => {
|
|
7755
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7756
8703
|
writeIntakeArtifacts(dir);
|
|
7757
8704
|
const st = baseState('plan');
|
|
7758
8705
|
st.completedNodes = ['open', 'design'];
|
|
@@ -7763,7 +8710,7 @@ const SCENARIOS = [
|
|
|
7763
8710
|
'<task id="P01" parallel="true" status="done">\n <action>do</action>\n <verify>echo ok</verify>\n</task>\n' +
|
|
7764
8711
|
'<task id="P03" parallel="true">\n <action>do malformed parallel</action>\n <verify>echo ok</verify>\n</task>\n' +
|
|
7765
8712
|
'<task id="S02" parallel="false" status="pending">\n <action>do serial</action>\n <verify>echo ok</verify>\n</task>\n');
|
|
7766
|
-
const res =
|
|
8713
|
+
const res = runGuardWithProtocol(dir, ['exit', 'plan', '--apply']);
|
|
7767
8714
|
assertExit(res, 0);
|
|
7768
8715
|
assertOut(res, 'ROUTE WARN');
|
|
7769
8716
|
},
|
|
@@ -7857,7 +8804,6 @@ const SCENARIOS = [
|
|
|
7857
8804
|
{
|
|
7858
8805
|
name: '216 directOverride 恢复:BLOCK 后补授权 / 回 subagent → exit 通过',
|
|
7859
8806
|
run: (dir) => {
|
|
7860
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7861
8807
|
const buildState = () => {
|
|
7862
8808
|
const st = baseState('execute');
|
|
7863
8809
|
st.completedNodes = ['open', 'design', 'plan'];
|
|
@@ -7886,7 +8832,7 @@ const SCENARIOS = [
|
|
|
7886
8832
|
assertOut(rBlock, 'BLOCKED');
|
|
7887
8833
|
// ② 恢复路径一:协调者 execution-mode direct(脚本写入授权留痕)→ exit 通过
|
|
7888
8834
|
writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', strictSummary('S01'));
|
|
7889
|
-
const auth =
|
|
8835
|
+
const auth = runStateWithProtocol(dir, ['execution-mode', 'direct']);
|
|
7890
8836
|
assertExit(auth, 0);
|
|
7891
8837
|
assertOut(auth, 'DIRECT-AUTH');
|
|
7892
8838
|
const st2 = readState();
|
|
@@ -7897,7 +8843,7 @@ const SCENARIOS = [
|
|
|
7897
8843
|
assertExit(rAuth, 0);
|
|
7898
8844
|
assertOut(rAuth, 'ALL CHECKS PASSED');
|
|
7899
8845
|
// ③ 恢复路径二:回 subagent(清除 directOverride 与授权留痕)→ exit 通过
|
|
7900
|
-
const back =
|
|
8846
|
+
const back = runStateWithProtocol(dir, ['execution-mode', 'subagent']);
|
|
7901
8847
|
assertExit(back, 0);
|
|
7902
8848
|
const st3 = readState();
|
|
7903
8849
|
if (st3.directOverride !== false || st3.directOverrideAt !== undefined) {
|
|
@@ -7946,7 +8892,6 @@ const SCENARIOS = [
|
|
|
7946
8892
|
{
|
|
7947
8893
|
name: '218 route-node 完成判定:done 任务 + 畸形块(缺 status) → next 仍回 execute',
|
|
7948
8894
|
run: (dir) => {
|
|
7949
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
7950
8895
|
writeIntakeArtifacts(dir);
|
|
7951
8896
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
7952
8897
|
'<task id="T01" status="done"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n' +
|
|
@@ -7961,7 +8906,7 @@ const SCENARIOS = [
|
|
|
7961
8906
|
executionMode: 'subagent',
|
|
7962
8907
|
directOverride: false,
|
|
7963
8908
|
});
|
|
7964
|
-
const res =
|
|
8909
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
7965
8910
|
assertExit(res, 0);
|
|
7966
8911
|
assertOut(res, 'NODE: execute');
|
|
7967
8912
|
assertNotOut(res, 'NODE: review');
|
|
@@ -8252,7 +9197,7 @@ const SCENARIOS = [
|
|
|
8252
9197
|
{
|
|
8253
9198
|
name: '229 感知层剥离:classic 资产有无不改变 hook 与 guard 判定(AC-5)',
|
|
8254
9199
|
run: (dir) => {
|
|
8255
|
-
const builtin =
|
|
9200
|
+
const builtin = scenarioProtocolPath(dir);
|
|
8256
9201
|
const build = (name, withClassic) => {
|
|
8257
9202
|
const proj = path.join(dir, name);
|
|
8258
9203
|
fs.mkdirSync(path.join(proj, 'reference'), { recursive: true });
|
|
@@ -8305,7 +9250,7 @@ const SCENARIOS = [
|
|
|
8305
9250
|
const protocol = JSON.parse(JSON.stringify(builtinProtocol));
|
|
8306
9251
|
protocol.kind = kind;
|
|
8307
9252
|
fs.mkdirSync(path.join(proj, 'reference'), { recursive: true });
|
|
8308
|
-
fs.copyFileSync(
|
|
9253
|
+
fs.copyFileSync(scenarioProtocolPath(dir), path.join(proj, 'reference', 'workflow-protocol.json'));
|
|
8309
9254
|
writeFile(proj, 'overlay-protocol.json', JSON.stringify(protocol, null, 2) + '\n');
|
|
8310
9255
|
writeIntakeArtifacts(proj);
|
|
8311
9256
|
const st = baseState('open');
|
|
@@ -8371,6 +9316,69 @@ const SCENARIOS = [
|
|
|
8371
9316
|
}
|
|
8372
9317
|
// ③ 系统测试集项数受检面:运行时派生 + 缺失 / 未同步 / 组判定 / 派生源缺失全分支
|
|
8373
9318
|
exerciseSystemTestCountCheck(dir);
|
|
9319
|
+
// ④ stale 检测(presence 之外的判别力):在场 ≠ 同步——旧值不在场才是同步的另一半。
|
|
9320
|
+
// 受检面 = 维护者面(docs/internal/ 全册 + CLAUDE.md)+ 参考册(reference/*.md,路径从本
|
|
9321
|
+
// 脚本自身位置推导);夹具用独立临时根驱动(夹具根下参考册缺席 → 该面为空,不误红)。
|
|
9322
|
+
const staleRoot = makeTmp();
|
|
9323
|
+
writeFile(staleRoot, 'docs/internal/DOC.md',
|
|
9324
|
+
'当前 ' + SCENARIOS.length + ' 场景 全部通过。\n');
|
|
9325
|
+
writeFile(staleRoot, 'CLAUDE.md', '回归基线:ALL ' + SCENARIOS.length + ' SCENARIOS PASSED\n');
|
|
9326
|
+
if (staleCountProblems([SCENARIOS.length, 86], staleRoot).length !== 0) {
|
|
9327
|
+
throw new Error('当前值不得被判成旧值: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9328
|
+
}
|
|
9329
|
+
// 反例(旧 presence 判据必然放过:当前值在场即全绿,旁边的旧值不可见)
|
|
9330
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', '当前 ' + SCENARIOS.length + ' 场景;另有 120 场景 的记录。\n');
|
|
9331
|
+
const staleOld = staleCountProblems([SCENARIOS.length, 86], staleRoot);
|
|
9332
|
+
if (!(staleOld.some((p) => p.includes('旧值未标记') && p.includes('docs/internal/DOC.md:1')
|
|
9333
|
+
&& p.includes('120')))) {
|
|
9334
|
+
throw new Error('无标记旧值未被报告(应含文件:行 + 旧值): ' + JSON.stringify(staleOld));
|
|
9335
|
+
}
|
|
9336
|
+
// 历史标记豁免:已标注的历史值不是"未标记旧值"(四枚标记各取一例——标记清单本身也受锚)
|
|
9337
|
+
for (const marked of ['(历史)120 场景。\n', '该值 120 场景 已过时。\n', '回顾:120 场景(history)。\n',
|
|
9338
|
+
'本轮踩坑:模板里写过 120 场景。\n']) {
|
|
9339
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', marked);
|
|
9340
|
+
if (staleCountProblems([SCENARIOS.length, 86], staleRoot).length !== 0) {
|
|
9341
|
+
throw new Error('带历史标记的行不得报告: ' + JSON.stringify([marked, staleCountProblems([SCENARIOS.length, 86], staleRoot)]));
|
|
9342
|
+
}
|
|
9343
|
+
}
|
|
9344
|
+
// 量程门:30 以下 / 400 以上不参与(年份、编号一类数字挡在外面)
|
|
9345
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', '夹具 7 场景 与 9999 场景。\n');
|
|
9346
|
+
if (staleCountProblems([SCENARIOS.length, 86], staleRoot).length !== 0) {
|
|
9347
|
+
throw new Error('量程外的数字不得参与: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9348
|
+
}
|
|
9349
|
+
// 通用比值门控:同行未点名套件的 N/N 不参与(覆盖率一类通用比值不误伤);点名套件才判
|
|
9350
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', '覆盖率 120/120。\n');
|
|
9351
|
+
if (staleCountProblems([SCENARIOS.length, 86], staleRoot).length !== 0) {
|
|
9352
|
+
throw new Error('同行未点名套件的通用比值不得参与: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9353
|
+
}
|
|
9354
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', 'guard-self-test 覆盖率 120/120。\n');
|
|
9355
|
+
if (!staleCountProblems([SCENARIOS.length, 86], staleRoot).some((p) => p.includes('旧值未标记') && p.includes('120/120'))) {
|
|
9356
|
+
throw new Error('点名套件的旧比值未被报告: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9357
|
+
}
|
|
9358
|
+
writeFile(staleRoot, 'docs/internal/DOC.md', 'guard-self-test 覆盖率 120/121。\n');
|
|
9359
|
+
if (staleCountProblems([SCENARIOS.length, 86], staleRoot).length !== 0) {
|
|
9360
|
+
throw new Error('非等值比值不是计数形态(不得参与): ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9361
|
+
}
|
|
9362
|
+
// 声明的 CLAUDE.md 形态:维护者面逐册纳入(夹具根下 CLAUDE.md 在场即入面)
|
|
9363
|
+
writeFile(staleRoot, 'CLAUDE.md', '自检套件 120 场景。\n');
|
|
9364
|
+
if (!staleCountProblems([SCENARIOS.length, 86], staleRoot).some((p) => p.includes('CLAUDE.md:1') && p.includes('旧值未标记'))) {
|
|
9365
|
+
throw new Error('CLAUDE.md 未纳入 stale 受检面: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9366
|
+
}
|
|
9367
|
+
// 读取失败可见化:与维护文档机检同型(同名目录 → 读取错误,不得静默跳过)
|
|
9368
|
+
fs.mkdirSync(path.join(staleRoot, 'docs', 'internal', 'DIR.md'), { recursive: true });
|
|
9369
|
+
if (!staleCountProblems([SCENARIOS.length, 86], staleRoot).some((p) => p.includes('无法读取: docs/internal/DIR.md'))) {
|
|
9370
|
+
throw new Error('stale 受检面里的不可读目标被静默跳过: ' + JSON.stringify(staleCountProblems([SCENARIOS.length, 86], staleRoot)));
|
|
9371
|
+
}
|
|
9372
|
+
fs.rmSync(staleRoot, { recursive: true, force: true }); // 夹具根清理(残留目录由底部统一校验)
|
|
9373
|
+
// ⑤ 面路径的推导纪律锚(同类断言回扫):参考册受检面必须**从本脚本自身位置**推导——
|
|
9374
|
+
// 权威源(.flow-comet/skills)与各安装副本(.claude / .agents / .dsh/skills)同一推导
|
|
9375
|
+
// 覆盖;硬编码树根相对路径会在安装副本形态指向不存在的面(静默空面 = 未执行当通过)。
|
|
9376
|
+
if (path.resolve(REPO_ROOT, REFERENCE_FACE_DIR_REL) !== path.resolve(__dirname, '..', 'reference')) {
|
|
9377
|
+
throw new Error('参考册受检面必须由脚本自身位置推导(不得硬编码树根相对路径),实际: ' + REFERENCE_FACE_DIR_REL);
|
|
9378
|
+
}
|
|
9379
|
+
if (path.basename(REFERENCE_FACE_DIR_REL) !== 'reference') {
|
|
9380
|
+
throw new Error('参考册受检面路径异常: ' + REFERENCE_FACE_DIR_REL);
|
|
9381
|
+
}
|
|
8374
9382
|
},
|
|
8375
9383
|
},
|
|
8376
9384
|
|
|
@@ -8860,7 +9868,7 @@ const SCENARIOS = [
|
|
|
8860
9868
|
'',
|
|
8861
9869
|
].join('\n'));
|
|
8862
9870
|
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
8863
|
-
const res =
|
|
9871
|
+
const res = runStateWithProtocol(dir, ['init', CHANGE_ID, '--init-context']);
|
|
8864
9872
|
assertExit(res, 0);
|
|
8865
9873
|
assertOut(res, 'INIT-DONE');
|
|
8866
9874
|
const st = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
@@ -8879,7 +9887,7 @@ const SCENARIOS = [
|
|
|
8879
9887
|
'## intel-scan 元数据 ##', '- **last_intel_scan**: x', '- **scanner**: x', '- **下次重扫建议**: x',
|
|
8880
9888
|
'',
|
|
8881
9889
|
].join('\n'));
|
|
8882
|
-
const boundary =
|
|
9890
|
+
const boundary = runStateWithProtocol(dir, ['init', CHANGE_ID + '-2', '--init-context']);
|
|
8883
9891
|
assertExit(boundary, 0);
|
|
8884
9892
|
assertOut(boundary, 'INIT-VALIDATE-FAILED');
|
|
8885
9893
|
assertOut(boundary, '项目概要');
|
|
@@ -8935,11 +9943,15 @@ const SCENARIOS = [
|
|
|
8935
9943
|
},
|
|
8936
9944
|
},
|
|
8937
9945
|
|
|
8938
|
-
// 244: 维护文档机检(docs-governance
|
|
9946
|
+
// 244: 维护文档机检(docs-governance)——死引用 + ROADMAP 最低结构。
|
|
8939
9947
|
// 判别力四类:正例(干净夹具通过)/ 反例(死引用必须报告且含来源与目标)/
|
|
8940
9948
|
// 越界(ROADMAP 缺段必须报告)/ 恢复(修复后通过);另锁「整组缺席即跳过」语义。
|
|
9949
|
+
// 本批 in-place 扩展(不新增顶层编号):① 三册显式扫描面(.specs 三册)正/反例;
|
|
9950
|
+
// ② 树根相对形态解析正例与同族缺目标反例——后者是窄域规则的判别力证据(旧逻辑在顶层目录
|
|
9951
|
+
// 不存在时直接跳过,必然放过);③ 窄域边界负例(外部命名空间 / 已移除临时区仍跳过);
|
|
9952
|
+
// ④ maintainerFaceSkips 描述符正/反例。
|
|
8941
9953
|
{
|
|
8942
|
-
name: '244
|
|
9954
|
+
name: '244 维护文档机检:死引用与 ROADMAP 结构(含三册扫描面与树根相对解析)',
|
|
8943
9955
|
run: (dir) => {
|
|
8944
9956
|
writeFile(dir, 'docs/internal/ROADMAP.md', '# 路线图\n\n## Now\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
8945
9957
|
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/ROADMAP.md` 与 `docs/internal/missing-file.md`。\n');
|
|
@@ -8965,16 +9977,385 @@ const SCENARIOS = [
|
|
|
8965
9977
|
if (internalDocsProblems(dir).length !== 0) {
|
|
8966
9978
|
throw new Error('修复后应通过: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
8967
9979
|
}
|
|
9980
|
+
// —— 扫描面扩展:三册显式清单(.specs/CONTEXT.md / LESSONS.md / CHANGELOG.md)——
|
|
9981
|
+
// 正例:三册在场且互相引用(册间互引)→ 合法引用不得误报
|
|
9982
|
+
writeFile(dir, '.specs/CONTEXT.md', '见 `docs/internal/ROADMAP.md` 与 `.specs/LESSONS.md`。\n');
|
|
9983
|
+
writeFile(dir, '.specs/LESSONS.md', '见 `.specs/CONTEXT.md`。\n');
|
|
9984
|
+
writeFile(dir, '.specs/CHANGELOG.md', '见 `.specs/LESSONS.md`。\n');
|
|
9985
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
9986
|
+
throw new Error('三册合法引用不得误报: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
9987
|
+
}
|
|
9988
|
+
// 反例:逐册注入一行死引用——每册都必须被扫到,且报告需带册名与行号
|
|
9989
|
+
for (const [book, deadRef] of [
|
|
9990
|
+
['.specs/CONTEXT.md', 'docs/internal/missing-context-target.md'],
|
|
9991
|
+
['.specs/LESSONS.md', 'docs/internal/missing-lessons-target.md'],
|
|
9992
|
+
['.specs/CHANGELOG.md', 'docs/internal/missing-changelog-target.md'],
|
|
9993
|
+
]) {
|
|
9994
|
+
writeFile(dir, book, '第一行。\n见 `' + deadRef + '`。\n');
|
|
9995
|
+
const bookProblems = internalDocsProblems(dir);
|
|
9996
|
+
if (!bookProblems.some((p) => p.includes(path.posix.basename(book) + ':2') && p.includes(deadRef))) {
|
|
9997
|
+
throw new Error(book + ' 死引用未被报告(三册扫描面缺失): ' + JSON.stringify(bookProblems));
|
|
9998
|
+
}
|
|
9999
|
+
if (bookProblems.length !== 1) {
|
|
10000
|
+
throw new Error(book + ' 死引用判定应恰 1 条: ' + JSON.stringify(bookProblems));
|
|
10001
|
+
}
|
|
10002
|
+
writeFile(dir, book, '见 `.specs/CONTEXT.md`。\n'); // 修复 → 复绿
|
|
10003
|
+
}
|
|
10004
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
10005
|
+
throw new Error('三册修复后应通过: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10006
|
+
}
|
|
10007
|
+
// —— 解析基准扩展:树根相对形态(flow-comet-* 技能目录 / rules)——
|
|
10008
|
+
// 正例:目标真实存在(技能树根 / 规则树根各一)→ 不报
|
|
10009
|
+
writeFile(dir, '.flow-comet/skills/flow-comet-fixture/SKILL.md', '# fixture\n');
|
|
10010
|
+
writeFile(dir, '.flow-comet/rules/fixture-rule.md', '# rule\n');
|
|
10011
|
+
writeFile(dir, 'docs/internal/FIXTURE.md',
|
|
10012
|
+
'见 `flow-comet-fixture/SKILL.md` 与 `rules/fixture-rule.md` 与 `docs/internal/ROADMAP.md`。\n');
|
|
10013
|
+
const treePositive = internalDocsProblems(dir);
|
|
10014
|
+
if (treePositive.length !== 0) {
|
|
10015
|
+
throw new Error('树根相对形态(技能目录 / 规则树)既有目标应解析通过: ' + JSON.stringify(treePositive));
|
|
10016
|
+
}
|
|
10017
|
+
// 反例(窄域规则判别力):同族形态但目标不存在,且顶层目录在仓库根不存在——
|
|
10018
|
+
// 旧判定会以「顶层整体缺席 → 跳过」静默放行,窄域规则必须按死引用报告
|
|
10019
|
+
writeFile(dir, 'docs/internal/FIXTURE.md',
|
|
10020
|
+
'见 `flow-comet-missing-fixture/SKILL.md` 与 `rules/missing-rule.md` 与 `docs/internal/ROADMAP.md`。\n');
|
|
10021
|
+
const treeNegative = internalDocsProblems(dir);
|
|
10022
|
+
for (const deadRef of ['flow-comet-missing-fixture/SKILL.md', 'rules/missing-rule.md']) {
|
|
10023
|
+
if (!treeNegative.some((p) => p.includes('FIXTURE.md:1') && p.includes(deadRef))) {
|
|
10024
|
+
throw new Error('同族缺目标(' + deadRef + ')必须按死引用报告(窄域规则): ' + JSON.stringify(treeNegative));
|
|
10025
|
+
}
|
|
10026
|
+
}
|
|
10027
|
+
// —— 本批 in-place 增锚(声明式族:外部命名空间 / 退役命名空间 / 示例)——旧语义
|
|
10028
|
+
// "顶层段不存在即静默跳过"在此被替换:允许面必须显式登记,未登记者一律按死引用报告
|
|
10029
|
+
// (fail-closed;旧逻辑对下列②③两种形态都静默放过——判别力差异即反向构造证据)。
|
|
10030
|
+
// ① 外部命名空间族(前缀声明)→ 仍跳过(平台侧命名空间在本仓库根天然不存在)
|
|
10031
|
+
writeFile(dir, 'docs/internal/FIXTURE.md',
|
|
10032
|
+
'见 `DSH_HOME/skills/x/SKILL.md` 与 `dsh-tui/lib/a.js` 与 `dsh-base/cordis.patch.yml` 与 `docs/internal/ROADMAP.md`。\n');
|
|
10033
|
+
const externalProblems = internalDocsProblems(dir);
|
|
10034
|
+
if (externalProblems.length !== 0) {
|
|
10035
|
+
throw new Error('声明式外部命名空间族不得误报: ' + JSON.stringify(externalProblems));
|
|
10036
|
+
}
|
|
10037
|
+
// ② 退役命名空间:登记在案(记录迁移的决策件)→ 跳过;未登记文件里的同形态引用 → 必须按死引用报
|
|
10038
|
+
writeFile(dir, '.specs/adr/ADR-009-runtime-namespace.md', '见 `.comet/config.yaml` 与 `.comet/flow-comet-state.json`。\n');
|
|
10039
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `.comet/config.yaml` 与 `docs/internal/ROADMAP.md`。\n');
|
|
10040
|
+
const retiredProblems = internalDocsProblems(dir);
|
|
10041
|
+
if (!retiredProblems.some((p) => p.includes('FIXTURE.md:1') && p.includes('.comet/config.yaml'))) {
|
|
10042
|
+
throw new Error('未登记的退役命名空间引用必须按死引用报告: ' + JSON.stringify(retiredProblems));
|
|
10043
|
+
}
|
|
10044
|
+
if (retiredProblems.some((p) => p.includes('ADR-009-runtime-namespace.md'))) {
|
|
10045
|
+
throw new Error('登记在案的迁移记录件不得误报: ' + JSON.stringify(retiredProblems));
|
|
10046
|
+
}
|
|
10047
|
+
// ②b 允许面按角色 / 前缀匹配(改名不误报):同一决策件 / 同族后续决策件换名后仍须跳过——
|
|
10048
|
+
// 精确 ref 硬编码下改名即静默失配 → 合法历史迁移记录被误报死引用(误红会诱导维护者
|
|
10049
|
+
// 删掉历史事实)。本锚即"改名后仍正确跳过"的反向构造。
|
|
10050
|
+
fs.renameSync(path.join(dir, '.specs', 'adr', 'ADR-009-runtime-namespace.md'),
|
|
10051
|
+
path.join(dir, '.specs', 'adr', 'ADR-009-runtime-namespace-renamed.md'));
|
|
10052
|
+
writeFile(dir, '.specs/adr/ADR-010-namespace-followup.md', '见 `.comet/config.yaml`。\n');
|
|
10053
|
+
const renamedProblems = internalDocsProblems(dir);
|
|
10054
|
+
for (const renamed of ['ADR-009-runtime-namespace-renamed.md', 'ADR-010-namespace-followup.md']) {
|
|
10055
|
+
if (renamedProblems.some((p) => p.includes(renamed))) {
|
|
10056
|
+
throw new Error('决策件改名后不得误报死引用(按前缀匹配退役命名空间允许面): ' + renamed
|
|
10057
|
+
+ ' → ' + JSON.stringify(renamedProblems));
|
|
10058
|
+
}
|
|
10059
|
+
}
|
|
10060
|
+
// ②c 决策册角色匹配(角色面正 / 反例;角色判定直接锚 + 引用面不得被角色面放宽)
|
|
10061
|
+
if (!isDeclaredReferenceSkip('.specs/CONTEXT.md', '.comet/config.yaml')
|
|
10062
|
+
|| !isDeclaredReferenceSkip('.specs/CONTEXT-decisions.md', '.comet/flow-comet-state.json')) {
|
|
10063
|
+
throw new Error('决策册角色(含改名形态)必须按角色命中退役命名空间允许面');
|
|
10064
|
+
}
|
|
10065
|
+
if (isDeclaredReferenceSkip('.specs/CONTEXT-decisions.md', 'docs/internal/missing-target.md')
|
|
10066
|
+
|| isDeclaredReferenceSkip('.specs/OTHER.md', '.comet/config.yaml')) {
|
|
10067
|
+
throw new Error('允许面不得面化:引用面(退役命名空间前缀)与文件面(角色 / 前缀)须同时命中');
|
|
10068
|
+
}
|
|
10069
|
+
// 反例(fail-closed 仍成立):非登记角色的同形态引用 → 必须照报(允许面不得变成宽面)
|
|
10070
|
+
writeFile(dir, '.specs/adr/ADR-008-unrelated.md', '见 `.comet/config.yaml`。\n');
|
|
10071
|
+
const unrelatedProblems = internalDocsProblems(dir);
|
|
10072
|
+
if (!unrelatedProblems.some((p) => p.includes('ADR-008-unrelated.md') && p.includes('.comet/config.yaml'))) {
|
|
10073
|
+
throw new Error('非登记角色的退役命名空间引用必须照报: ' + JSON.stringify(unrelatedProblems));
|
|
10074
|
+
}
|
|
10075
|
+
fs.rmSync(path.join(dir, '.specs', 'adr', 'ADR-009-runtime-namespace-renamed.md'));
|
|
10076
|
+
fs.rmSync(path.join(dir, '.specs', 'adr', 'ADR-010-namespace-followup.md'));
|
|
10077
|
+
fs.rmSync(path.join(dir, '.specs', 'adr', 'ADR-008-unrelated.md'));
|
|
10078
|
+
// 夹具移除后本组不再产生任何报告(判别力反向确认:上面三类断言确由这些夹具驱动,
|
|
10079
|
+
// 不是被其它夹具的既有报告蒙对)。此处只对本组文件断言——docs/internal/FIXTURE.md
|
|
10080
|
+
// 仍带着上一段夹具的未登记引用(其报告由上一段断言负责)。
|
|
10081
|
+
const afterAllowlistCleanup = internalDocsProblems(dir);
|
|
10082
|
+
for (const removed of ['ADR-009-runtime-namespace-renamed.md', 'ADR-010-namespace-followup.md', 'ADR-008-unrelated.md']) {
|
|
10083
|
+
if (afterAllowlistCleanup.some((p) => p.includes(removed))) {
|
|
10084
|
+
throw new Error('允许面夹具移除后不得再报该文件: ' + removed + ' → ' + JSON.stringify(afterAllowlistCleanup));
|
|
10085
|
+
}
|
|
10086
|
+
}
|
|
10087
|
+
// ③ 已移除临时区(未登记形态)→ 必须报(真实残留曾因旧跳过语义长期不可见)
|
|
10088
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `.verify-tools/level3-smoke.mjs` 与 `docs/internal/ROADMAP.md`。\n');
|
|
10089
|
+
const residueProblems = internalDocsProblems(dir);
|
|
10090
|
+
if (!residueProblems.some((p) => p.includes('FIXTURE.md:1') && p.includes('.verify-tools/level3-smoke.mjs'))) {
|
|
10091
|
+
throw new Error('未登记的临时区引用必须按死引用报告: ' + JSON.stringify(residueProblems));
|
|
10092
|
+
}
|
|
10093
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/ROADMAP.md`。\n');
|
|
10094
|
+
// —— 行号存在与不越界(结构级):引用解析成功后才校验行号 ——
|
|
10095
|
+
writeFile(dir, 'docs/internal/TARGET.md', '第一行\n第二行\n第三行\n');
|
|
10096
|
+
writeFile(dir, 'docs/internal/FIXTURE.md',
|
|
10097
|
+
'见 `docs/internal/TARGET.md:1` 与 `docs/internal/TARGET.md:1-3` 与 `docs/internal/TARGET.md:2,3`。\n');
|
|
10098
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
10099
|
+
throw new Error('合法行号引用(单值 / 区间 / 逗号列表)不得误报: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10100
|
+
}
|
|
10101
|
+
// 反例:越界(旧实现只判路径存在性,行号部分根本不参与解析 → 必然放过)
|
|
10102
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/TARGET.md:99`。\n');
|
|
10103
|
+
const lineProblems = internalDocsProblems(dir);
|
|
10104
|
+
if (!(lineProblems.some((p) => p.includes('行号越界') && p.includes('FIXTURE.md:1')
|
|
10105
|
+
&& p.includes('TARGET.md:99') && p.includes('目标共')))) {
|
|
10106
|
+
throw new Error('越界行号未被报告(应含「行号越界」+ 受检文件:行 + 目标:行号 + 目标行数): '
|
|
10107
|
+
+ JSON.stringify(lineProblems));
|
|
10108
|
+
}
|
|
10109
|
+
// 反例:下界(第 0 行不存在)
|
|
10110
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/TARGET.md:0`。\n');
|
|
10111
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('行号越界') && p.includes('TARGET.md:0'))) {
|
|
10112
|
+
throw new Error('下界越界(引用第 0 行)未被报告: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10113
|
+
}
|
|
10114
|
+
// 反例:尾随换行不得让目标文件被算成"多一行"——3 行文件引 `:4` 必须越界
|
|
10115
|
+
// (旧实现按 split 段数计行,尾随空段被算作一行 → :4 被放过;2026-10-01 PR 审查发现)
|
|
10116
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/TARGET.md:4`。\n');
|
|
10117
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('行号越界') && p.includes('TARGET.md:4'))) {
|
|
10118
|
+
throw new Error('尾随换行被算成额外一行(3 行目标文件引 :4 未报越界): '
|
|
10119
|
+
+ JSON.stringify(internalDocsProblems(dir)));
|
|
10120
|
+
}
|
|
10121
|
+
// 反例:**空文件 = 0 行**——空目标文件的任何行号都越界(按 split 段数计会得 1 行 → `:1` 被放过)
|
|
10122
|
+
writeFile(dir, 'docs/internal/EMPTY.md', '');
|
|
10123
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/EMPTY.md:1`。\n');
|
|
10124
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('行号越界') && p.includes('EMPTY.md:1'))) {
|
|
10125
|
+
throw new Error('空目标文件引 :1 未报越界(空文件应为 0 行): ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10126
|
+
}
|
|
10127
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'EMPTY.md'));
|
|
10128
|
+
// 反例:区间上端越界(区间取两端逐一校验)
|
|
10129
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/TARGET.md:2-99`。\n');
|
|
10130
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('行号越界') && p.includes('TARGET.md:99'))) {
|
|
10131
|
+
throw new Error('区间上端越界未被报告: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10132
|
+
}
|
|
10133
|
+
// 反例:逗号列表中的越界项
|
|
10134
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/TARGET.md:1,99`。\n');
|
|
10135
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('行号越界') && p.includes('TARGET.md:99'))) {
|
|
10136
|
+
throw new Error('逗号列表中的越界项未被报告: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10137
|
+
}
|
|
10138
|
+
// 并列写法护栏:首段带文件扩展名的 token 不是路径引用(两个文件名并列)→ 不参与解析;
|
|
10139
|
+
// 同一行里真实的越界引用照报(证明护栏没有把整行一起吞掉——判据必须收窄到"首段带扩展名")
|
|
10140
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `TEST.md/REVIEW.md` 与 `docs/internal/TARGET.md:99`。\n');
|
|
10141
|
+
const parallelProblems = internalDocsProblems(dir);
|
|
10142
|
+
if (parallelProblems.some((p) => p.includes('TEST.md/REVIEW.md'))) {
|
|
10143
|
+
throw new Error('并列写法(首段带扩展名)不得按路径引用解析: ' + JSON.stringify(parallelProblems));
|
|
10144
|
+
}
|
|
10145
|
+
if (!parallelProblems.some((p) => p.includes('TARGET.md:99'))) {
|
|
10146
|
+
throw new Error('并列写法护栏不得吞掉同一行的真实越界引用: ' + JSON.stringify(parallelProblems));
|
|
10147
|
+
}
|
|
10148
|
+
// 目标本身不存在时只报死引用,不叠报行号越界(同一处只报一次)
|
|
10149
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/MISSING-TARGET.md:99`。\n');
|
|
10150
|
+
const missingTargetProblems = internalDocsProblems(dir);
|
|
10151
|
+
if (!missingTargetProblems.some((p) => p.includes('死引用') && p.includes('MISSING-TARGET.md'))) {
|
|
10152
|
+
throw new Error('不存在的目标应报死引用: ' + JSON.stringify(missingTargetProblems));
|
|
10153
|
+
}
|
|
10154
|
+
if (missingTargetProblems.some((p) => p.includes('行号越界'))) {
|
|
10155
|
+
throw new Error('目标不存在时不得叠报行号越界: ' + JSON.stringify(missingTargetProblems));
|
|
10156
|
+
}
|
|
10157
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'TARGET.md'));
|
|
10158
|
+
writeFile(dir, 'docs/internal/FIXTURE.md', '见 `docs/internal/ROADMAP.md`。\n');
|
|
10159
|
+
// —— 表头新鲜度(内容锚:表头日期 ≥ 正文最大日期;未声明表头 → 跳过)——
|
|
10160
|
+
writeFile(dir, 'docs/internal/HEADER.md', '> 最后更新:2026-01-01\n\n正文提到 2026-02-02 的事。\n');
|
|
10161
|
+
const staleHeaderProblems = internalDocsProblems(dir);
|
|
10162
|
+
if (!(staleHeaderProblems.some((p) => p.includes('表头不新鲜') && p.includes('HEADER.md')
|
|
10163
|
+
&& p.includes('2026-01-01') && p.includes('2026-02-02')))) {
|
|
10164
|
+
throw new Error('表头落后于正文最大日期未被报告(应含文件与两侧日期): ' + JSON.stringify(staleHeaderProblems));
|
|
10165
|
+
}
|
|
10166
|
+
writeFile(dir, 'docs/internal/HEADER.md', '> 最后更新:2026-02-02\n\n正文提到 2026-02-02 的事。\n');
|
|
10167
|
+
if (internalDocsProblems(dir).some((p) => p.includes('表头不新鲜'))) {
|
|
10168
|
+
throw new Error('表头与正文最大日期相等(新鲜)不得误报: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10169
|
+
}
|
|
10170
|
+
writeFile(dir, 'docs/internal/HEADER.md', '正文提到 2026-12-31 的事,但本册没声明表头。\n');
|
|
10171
|
+
if (internalDocsProblems(dir).some((p) => p.includes('表头不新鲜'))) {
|
|
10172
|
+
throw new Error('未声明表头的目标必须跳过(登记边界): ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10173
|
+
}
|
|
10174
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'HEADER.md'));
|
|
10175
|
+
// —— `## Now` 段不得出现已归档 change-id(旧逻辑无此判据 → 必然放过)——
|
|
10176
|
+
writeFile(dir, '.specs/archive/2026-01-01-archived-fixture/CHANGE.md', '# 归档夹具\n');
|
|
10177
|
+
writeFile(dir, 'docs/internal/ROADMAP.md',
|
|
10178
|
+
'# 路线图\n\n> 最后更新:2026-01-01\n\n## Now\n\n- 在办:archived-fixture 的后续\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10179
|
+
const nowProblems = internalDocsProblems(dir);
|
|
10180
|
+
if (!nowProblems.some((p) => p.includes('Now 段含已归档 change-id: archived-fixture'))) {
|
|
10181
|
+
throw new Error('在办段引用已归档 change-id 未被报告: ' + JSON.stringify(nowProblems));
|
|
10182
|
+
}
|
|
10183
|
+
// 正例:同一 id 只出现在 Now 段之外 → 不报(判据只约束在办段,历史段本就该记已归档项)
|
|
10184
|
+
writeFile(dir, 'docs/internal/ROADMAP.md',
|
|
10185
|
+
'# 路线图\n\n> 最后更新:2026-01-01\n\n## Now\n\n- 在办:别的主题\n\n## Next\n\n## Later\n\n- 历史:archived-fixture\n\n## Open decisions\n');
|
|
10186
|
+
if (internalDocsProblems(dir).some((p) => p.includes('Now 段含已归档'))) {
|
|
10187
|
+
throw new Error('Now 段之外的归档 id 不得误报: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10188
|
+
}
|
|
10189
|
+
// 反例:归档 id 必须**整词**匹配——`archived-fixture-v2` 含 `archived-fixture` 但不得误报
|
|
10190
|
+
// (旧实现用 includes 子串匹配 → 短 id 会命中更长 id 或同族更长 id 的中间;2026-10-01 PR 审查发现)
|
|
10191
|
+
writeFile(dir, 'docs/internal/ROADMAP.md',
|
|
10192
|
+
'# 路线图\n\n> 最后更新:2026-01-01\n\n## Now\n\n- 在办:archived-fixture-v2 的后续\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10193
|
+
if (internalDocsProblems(dir).some((p) => p.includes('Now 段含已归档 change-id'))) {
|
|
10194
|
+
throw new Error('归档 id 子串误命中(archived-fixture-v2 不得命中 archived-fixture): '
|
|
10195
|
+
+ JSON.stringify(internalDocsProblems(dir)));
|
|
10196
|
+
}
|
|
10197
|
+
// 定位口径锚:文件头目录说明行里出现被反引号包住的同名标题字样时,段定位必须仍命中真实
|
|
10198
|
+
// 在办段(按行首标题扫描,而不是按子串首次出现位置切段——后者会切出极短窗口使判据恒过)
|
|
10199
|
+
writeFile(dir, 'docs/internal/ROADMAP.md',
|
|
10200
|
+
'# 路线图\n\n> 最后更新:2026-01-01\n\n目录说明:`## Now` 与 `## Next` 两段。\n\n## Now\n\n- 在办:archived-fixture\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10201
|
+
if (!internalDocsProblems(dir).some((p) => p.includes('Now 段含已归档 change-id: archived-fixture'))) {
|
|
10202
|
+
throw new Error('目录说明行含标题字样时仍须命中真实在办段(标题扫描口径): ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10203
|
+
}
|
|
10204
|
+
fs.rmSync(path.join(dir, '.specs', 'archive'), { recursive: true, force: true });
|
|
10205
|
+
writeFile(dir, 'docs/internal/ROADMAP.md', '# 路线图\n\n## Now\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10206
|
+
// 缺席可见化描述符(正例):维护者面全在场 → 无跳过描述符
|
|
10207
|
+
if (maintainerFaceSkips(dir).length !== 0) {
|
|
10208
|
+
throw new Error('维护者面在场时应无跳过描述符: ' + JSON.stringify(maintainerFaceSkips(dir)));
|
|
10209
|
+
}
|
|
8968
10210
|
// 越界:删段 → 结构问题必须报告
|
|
8969
10211
|
writeFile(dir, 'docs/internal/ROADMAP.md', '# 路线图\n\n## Now\n## Next\n## Later\n');
|
|
8970
10212
|
const structProblems = internalDocsProblems(dir);
|
|
8971
10213
|
if (!structProblems.some((p) => p.includes('Open decisions'))) {
|
|
8972
10214
|
throw new Error('ROADMAP 缺段未被报告: ' + JSON.stringify(structProblems));
|
|
8973
10215
|
}
|
|
8974
|
-
//
|
|
10216
|
+
// —— 本批 in-place 增锚(F4:读取失败可见化)——以同名目录替换 .md 文件 → readFileSync
|
|
10217
|
+
// 抛 EISDIR(目录读取错误,跨平台同码);旧实现 catch → continue 静默跳过,该目标既无
|
|
10218
|
+
// FAIL 也无 SKIP(「未执行 ≠ 通过」的静默通道,L-079 同类)→ 必须报告
|
|
10219
|
+
// 「无法读取: <rel>: <err 摘要>」。前置:ROADMAP 复原为完整结构,确保本锚的失败只可能
|
|
10220
|
+
// 来自不可读目标(无结构噪声)。
|
|
10221
|
+
writeFile(dir, 'docs/internal/ROADMAP.md', '# 路线图\n\n## Now\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10222
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
10223
|
+
throw new Error('不可读目标锚前置:干净夹具应通过: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10224
|
+
}
|
|
10225
|
+
fs.mkdirSync(path.join(dir, 'docs/internal', 'UNREADABLE.md'), { recursive: true });
|
|
10226
|
+
const unreadableProblems = internalDocsProblems(dir);
|
|
10227
|
+
if (!unreadableProblems.some((p) => p.includes('无法读取: docs/internal/UNREADABLE.md'))) {
|
|
10228
|
+
throw new Error('不可读目标被静默跳过(应报告「无法读取: <rel>: <err 摘要>」): ' + JSON.stringify(unreadableProblems));
|
|
10229
|
+
}
|
|
10230
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'UNREADABLE.md'), { recursive: true, force: true });
|
|
10231
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
10232
|
+
throw new Error('移除不可读目标后应复绿: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10233
|
+
}
|
|
10234
|
+
// —— 本批 in-place 增锚(F4 语义的结构检查侧补齐)——:目标扫描的读取失败已可见化,但
|
|
10235
|
+
// ROADMAP 结构检查此前仍对同一路径直接 readFileSync——ROADMAP 自身不可读(同名目录 →
|
|
10236
|
+
// EISDIR / 访问类错误)时未捕获异常会把整个套件打成堆栈崩溃,而不是给出可见问题条目。
|
|
10237
|
+
// 夹具把 ROADMAP.md 换成同名目录(其余受检面保持合法,失败只可能来自该目标)→ 断言
|
|
10238
|
+
// 返回问题数组且含「无法读取: docs/internal/ROADMAP.md」(不是抛出),且不得以「结构缺段」
|
|
10239
|
+
// 噪声替代读取失败可见化(读取失败即跳过四段结构检查);移除目录、写回合法 ROADMAP → 复绿。
|
|
10240
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'ROADMAP.md'), { force: true });
|
|
10241
|
+
fs.mkdirSync(path.join(dir, 'docs/internal', 'ROADMAP.md'), { recursive: true });
|
|
10242
|
+
const unreadableRoadmap = internalDocsProblems(dir);
|
|
10243
|
+
if (!Array.isArray(unreadableRoadmap)) {
|
|
10244
|
+
throw new Error('ROADMAP 不可读时应返回问题数组(不得抛出): ' + String(unreadableRoadmap));
|
|
10245
|
+
}
|
|
10246
|
+
if (!unreadableRoadmap.some((p) => p.includes('无法读取: docs/internal/ROADMAP.md'))) {
|
|
10247
|
+
throw new Error('ROADMAP 自身不可读未被报告(应含「无法读取: docs/internal/ROADMAP.md」): ' + JSON.stringify(unreadableRoadmap));
|
|
10248
|
+
}
|
|
10249
|
+
if (unreadableRoadmap.some((p) => p.includes('ROADMAP 结构缺段'))) {
|
|
10250
|
+
throw new Error('ROADMAP 读取失败时不得继续四段结构检查: ' + JSON.stringify(unreadableRoadmap));
|
|
10251
|
+
}
|
|
10252
|
+
fs.rmSync(path.join(dir, 'docs/internal', 'ROADMAP.md'), { recursive: true, force: true });
|
|
10253
|
+
writeFile(dir, 'docs/internal/ROADMAP.md', '# 路线图\n\n## Now\n\n## Next\n\n## Later\n\n## Open decisions\n');
|
|
10254
|
+
if (internalDocsProblems(dir).length !== 0) {
|
|
10255
|
+
throw new Error('ROADMAP 写回合法结构后应复绿: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10256
|
+
}
|
|
10257
|
+
// 整组缺席(CI / worktree 形态)→ 跳过,不误红:目标面 = docs/internal 与 .specs/adr 与
|
|
10258
|
+
// 三册——组缺席判据是「全部目标面缺席」(targets.length === 0),故夹具同步移除三册。
|
|
8975
10259
|
fs.rmSync(path.join(dir, 'docs/internal'), { recursive: true, force: true });
|
|
10260
|
+
fs.rmSync(path.join(dir, '.specs'), { recursive: true, force: true });
|
|
8976
10261
|
if (internalDocsProblems(dir).length !== 0) {
|
|
8977
|
-
throw new Error('
|
|
10262
|
+
throw new Error('目标面整组缺席时应跳过: ' + JSON.stringify(internalDocsProblems(dir)));
|
|
10263
|
+
}
|
|
10264
|
+
// 缺席可见化描述符(反例):维护者面整体缺席 → 逐面给出「面名 + 原因」,
|
|
10265
|
+
// 供套件底部输出可见 SKIP 行;本节同时锁住「判定语义零变化」(上面跳过断言)。
|
|
10266
|
+
const skips = maintainerFaceSkips(dir);
|
|
10267
|
+
if (skips.length !== 2) {
|
|
10268
|
+
throw new Error('维护者面缺席应给出 2 条跳过描述符,实际 ' + JSON.stringify(skips));
|
|
10269
|
+
}
|
|
10270
|
+
for (const skip of skips) {
|
|
10271
|
+
if (typeof skip.face !== 'string' || skip.face.trim() === ''
|
|
10272
|
+
|| typeof skip.reason !== 'string' || skip.reason.trim() === '') {
|
|
10273
|
+
throw new Error('跳过描述符须含面名与原因: ' + JSON.stringify(skip));
|
|
10274
|
+
}
|
|
10275
|
+
}
|
|
10276
|
+
if (!skips.some((s) => s.face.includes('计数') && s.reason.includes('docs/internal'))) {
|
|
10277
|
+
throw new Error('计数面跳过描述符应说明 docs/internal 缺席: ' + JSON.stringify(skips));
|
|
10278
|
+
}
|
|
10279
|
+
if (!skips.some((s) => s.face.includes('机检') && s.reason.includes('目标面'))) {
|
|
10280
|
+
throw new Error('维护文档机检面跳过描述符应说明目标面缺席: ' + JSON.stringify(skips));
|
|
10281
|
+
}
|
|
10282
|
+
// —— 本批 in-place 增锚(公开产物零代号判据 + 词表镜像漂移判据)——
|
|
10283
|
+
// 与 .githooks 词表单一来源同判据(该文件主仓私有、不随技能包分发;本文件内保留同义镜像,
|
|
10284
|
+
// 两处同改)。① 表驱动等价性:词表**每个分支**各一条正例(分支被删 / 被收窄过头 → 该行
|
|
10285
|
+
// 先红)与一条对应反例(分支被放宽成裸词 / 宽前缀 → 该行先红)——反例按"放宽后会被误
|
|
10286
|
+
// 命中的合法或无关形态"选取,故"某分支被动过"必然落在某个(正例,反例)对上;
|
|
10287
|
+
// ② 本文件注释层零残留(清理后不许回潮);③ 词表镜像漂移判据夹具锚(同源 → 绿 /
|
|
10288
|
+
// 改一字符 → 红且消息含两侧片段与长度 / 私有面缺席 → 显式"无法执行"而非静默放过)。
|
|
10289
|
+
// 注意:形态字面量只能写在非注释行——本锚的②正是扫注释层。
|
|
10290
|
+
const CODE_BRANCH_SAMPLES = [
|
|
10291
|
+
['场景编号', 'S12', 'S1234'],
|
|
10292
|
+
['修复族 id', 'T-FIX-01', 'FIX-01'],
|
|
10293
|
+
['批次连字符前缀', 'batch-2', 'batch-name'],
|
|
10294
|
+
['缺陷编号', 'D-12', 'D-abc'],
|
|
10295
|
+
['优先级编号', 'P3', 'P9'],
|
|
10296
|
+
['验证轮次', 'round 3', 'round-table'],
|
|
10297
|
+
['英文本地实践词', 'dogfood', 'dog food'],
|
|
10298
|
+
['内部标识词', '内部', '内卷'],
|
|
10299
|
+
['批次加编号', '批次 D', '批次发布'],
|
|
10300
|
+
['批加编号', '批 2', '第一批 2 次'],
|
|
10301
|
+
['批加编号(序数与批之间有空格)', '批 2', '第 1 批 2 次'],
|
|
10302
|
+
['级加编号', '级 3', '级联'],
|
|
10303
|
+
['验收代号', 'UAT-7', 'UAT-x'],
|
|
10304
|
+
['工作项编号', 'R-14', 'ADR-013'],
|
|
10305
|
+
['工作项编号(三位不截断)', 'R-14', 'R-123'],
|
|
10306
|
+
];
|
|
10307
|
+
for (const [label, hit, miss] of CODE_BRANCH_SAMPLES) {
|
|
10308
|
+
if (!PUBLIC_CODE_RE.test(hit)) {
|
|
10309
|
+
throw new Error('词表分支缺失或被收窄过头(正例不再命中): ' + label + ' → ' + JSON.stringify(hit));
|
|
10310
|
+
}
|
|
10311
|
+
if (PUBLIC_CODE_RE.test(miss)) {
|
|
10312
|
+
throw new Error('词表分支被放宽(反例被误命中): ' + label + ' → ' + JSON.stringify(miss));
|
|
10313
|
+
}
|
|
10314
|
+
}
|
|
10315
|
+
for (const legit of ['PR-130', '维护批次', '批处理', 'Fix 批次']) {
|
|
10316
|
+
if (PUBLIC_CODE_RE.test(legit)) {
|
|
10317
|
+
throw new Error('合法相似子串被零代号判据误报: ' + legit);
|
|
10318
|
+
}
|
|
10319
|
+
}
|
|
10320
|
+
// ③ 词表镜像漂移判据(夹具驱动;不依赖真实私有面在场——权威源与安装副本两形态都可跑)
|
|
10321
|
+
const mirrorFixtureRel = path.posix.join('.githooks', 'internal-codes.mjs');
|
|
10322
|
+
const mirrorText = 'export const BANNED = /' + PUBLIC_CODE_RE.source + '/;\n';
|
|
10323
|
+
writeFile(dir, mirrorFixtureRel, mirrorText);
|
|
10324
|
+
const mirrorOk = vocabularyMirrorProblems(dir);
|
|
10325
|
+
if (mirrorOk.length !== 0) {
|
|
10326
|
+
throw new Error('同源词表镜像不得报漂移: ' + JSON.stringify(mirrorOk));
|
|
10327
|
+
}
|
|
10328
|
+
// 逐字符比对必有判别力:镜像侧改动一个字符(这里放宽一条分支)→ 必报,且消息可定位
|
|
10329
|
+
const driftedSource = PUBLIC_CODE_RE.source.replace('dogfood', 'dogfoods');
|
|
10330
|
+
if (driftedSource === PUBLIC_CODE_RE.source) {
|
|
10331
|
+
throw new Error('夹具前提失效:漂移注入未改变镜像 source(词表分支名已变)');
|
|
10332
|
+
}
|
|
10333
|
+
writeFile(dir, mirrorFixtureRel, 'export const BANNED = /' + driftedSource + '/;\n');
|
|
10334
|
+
const driftProblems = vocabularyMirrorProblems(dir);
|
|
10335
|
+
if (!driftProblems.some((p) => p.includes('词表镜像漂移') && p.includes('主仓侧片段')
|
|
10336
|
+
&& p.includes('套件侧片段') && p.includes('首个差异位置')
|
|
10337
|
+
&& p.includes(String(driftedSource.length)) && p.includes(String(PUBLIC_CODE_RE.source.length)))) {
|
|
10338
|
+
throw new Error('镜像侧改动一个字符必须报漂移且消息含两侧片段与长度: ' + JSON.stringify(driftProblems));
|
|
10339
|
+
}
|
|
10340
|
+
writeFile(dir, mirrorFixtureRel, mirrorText);
|
|
10341
|
+
if (vocabularyMirrorProblems(dir).length !== 0) {
|
|
10342
|
+
throw new Error('镜像还原后应复绿: ' + JSON.stringify(vocabularyMirrorProblems(dir)));
|
|
10343
|
+
}
|
|
10344
|
+
// 私有面结构性缺席(安装副本形态)→ 显式"判据无法执行",不得静默返回空
|
|
10345
|
+
fs.rmSync(path.join(dir, '.githooks'), { recursive: true, force: true });
|
|
10346
|
+
const mirrorMissing = vocabularyMirrorProblems(dir);
|
|
10347
|
+
if (!mirrorMissing.some((p) => p.includes('无法执行') && p.includes(mirrorFixtureRel))) {
|
|
10348
|
+
throw new Error('私有面缺席必须显式报告判据未执行(未验证 ≠ 通过): ' + JSON.stringify(mirrorMissing));
|
|
10349
|
+
}
|
|
10350
|
+
const selfLines = fs.readFileSync(path.join(__dirname, 'guard-self-test.mjs'), 'utf8').split(/\r?\n/);
|
|
10351
|
+
const commentHits = [];
|
|
10352
|
+
for (let i = 0; i < selfLines.length; i += 1) {
|
|
10353
|
+
if (!/^\s*(\/\/|\*|\/\*)/.test(selfLines[i])) continue;
|
|
10354
|
+
const hit = selfLines[i].match(PUBLIC_CODE_RE);
|
|
10355
|
+
if (hit) commentHits.push((i + 1) + ': ' + hit[0]);
|
|
10356
|
+
}
|
|
10357
|
+
if (commentHits.length !== 0) {
|
|
10358
|
+
throw new Error('本文件注释层仍有未公开概念字样(判据锚:注释层零残留): ' + commentHits.join(', '));
|
|
8978
10359
|
}
|
|
8979
10360
|
},
|
|
8980
10361
|
},
|
|
@@ -10004,7 +11385,6 @@ const SCENARIOS = [
|
|
|
10004
11385
|
writeIntakeArtifacts(dir);
|
|
10005
11386
|
const taskPath = '.specs/' + CHANGE_ID + '/TASK.md';
|
|
10006
11387
|
const statePath = path.join(dir, '.flow-comet', 'flow-comet-state.json');
|
|
10007
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10008
11388
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md',
|
|
10009
11389
|
'# REVIEW\n\n## 发现\n\n### Critical\n\n- 无\n\n### Major\n\n- 无\n\n### Minor\n\n- 无\n\n## 结论\n\n审查发现需修复项,Fix 任务已追加;待 execute 出口完成后重新出口。\n');
|
|
10010
11390
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', strictSummary('T01'));
|
|
@@ -10120,12 +11500,12 @@ const SCENARIOS = [
|
|
|
10120
11500
|
...handoffFor(['T-FIX-01']),
|
|
10121
11501
|
};
|
|
10122
11502
|
writeState(dir, after);
|
|
10123
|
-
assertExit(
|
|
11503
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md']), 0);
|
|
10124
11504
|
const recDoneExit = runGuard(['exit', 'execute', '--apply'], dir);
|
|
10125
11505
|
assertExit(recDoneExit, 0);
|
|
10126
11506
|
assertOut(recDoneExit, 'FIX-BATCH: 回源节点 review(execute 出口已完成)');
|
|
10127
11507
|
assertOut(recDoneExit, 'NODE: review');
|
|
10128
|
-
assertExit(
|
|
11508
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'review', 'flow-comet-review', '--prompt', 'flow-kit/prompts/6-review.md']), 0);
|
|
10129
11509
|
assertExit(runGuard(['entry', 'review'], dir), 0);
|
|
10130
11510
|
const recDoneReview = runGuard(['exit', 'review', '--apply'], dir);
|
|
10131
11511
|
assertExit(recDoneReview, 0);
|
|
@@ -10168,12 +11548,12 @@ const SCENARIOS = [
|
|
|
10168
11548
|
...handoffFor(['T-FIX-01']),
|
|
10169
11549
|
};
|
|
10170
11550
|
writeState(dir, after);
|
|
10171
|
-
assertExit(
|
|
11551
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md']), 0);
|
|
10172
11552
|
const recDoneVerifyExit = runGuard(['exit', 'execute', '--apply'], dir);
|
|
10173
11553
|
assertExit(recDoneVerifyExit, 0);
|
|
10174
11554
|
assertOut(recDoneVerifyExit, 'FIX-BATCH: 回源节点 verify(execute 出口已完成)');
|
|
10175
11555
|
assertOut(recDoneVerifyExit, 'NODE: verify');
|
|
10176
|
-
assertExit(
|
|
11556
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'verify', 'flow-comet-verify', '--prompt', 'flow-kit/prompts/7-integration.md']), 0);
|
|
10177
11557
|
assertExit(runGuard(['entry', 'verify'], dir), 0);
|
|
10178
11558
|
const recDoneVerify = runGuard(['exit', 'verify', '--apply'], dir);
|
|
10179
11559
|
assertExit(recDoneVerify, 0);
|
|
@@ -10208,7 +11588,7 @@ const SCENARIOS = [
|
|
|
10208
11588
|
assertOut(rParBlock, 'BLOCKED: 存在未归位/未跑出口的 Fix 批次');
|
|
10209
11589
|
assertNotOut(rParBlock, 'ALL CHECKS PASSED');
|
|
10210
11590
|
writeState(dir, reviewState);
|
|
10211
|
-
const rParNext =
|
|
11591
|
+
const rParNext = runStateWithProtocol(dir, ['next']);
|
|
10212
11592
|
assertExit(rParNext, 0);
|
|
10213
11593
|
assertOut(rParNext, 'FIX-BATCH: 归位 subagent-execute(源节点 review)');
|
|
10214
11594
|
assertOut(rParNext, 'NODE: subagent-execute');
|
|
@@ -10230,7 +11610,7 @@ const SCENARIOS = [
|
|
|
10230
11610
|
...handoffFor(['P-FIX-01']),
|
|
10231
11611
|
};
|
|
10232
11612
|
writeState(dir, after);
|
|
10233
|
-
assertExit(
|
|
11613
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'subagent-execute', 'flow-comet-dev', '--prompt', 'flow-kit/prompts/4-dev.md']), 0);
|
|
10234
11614
|
const rParExit = runGuard(['exit', 'subagent-execute', '--apply'], dir);
|
|
10235
11615
|
assertExit(rParExit, 0);
|
|
10236
11616
|
assertOut(rParExit, 'FIX-BATCH: 回源节点 review(subagent-execute 出口已完成)');
|
|
@@ -10245,7 +11625,7 @@ const SCENARIOS = [
|
|
|
10245
11625
|
|| typeof parFamilyExit.taskSetSignature !== 'string' || parFamilyExit.taskSetSignature === '') {
|
|
10246
11626
|
throw new Error('并行修复出口应记录本 change + taskSetSignature 的家族出口事件,实际 ' + JSON.stringify(parFamilyExit));
|
|
10247
11627
|
}
|
|
10248
|
-
assertExit(
|
|
11628
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'review', 'flow-comet-review', '--prompt', 'flow-kit/prompts/6-review.md']), 0);
|
|
10249
11629
|
assertExit(runGuard(['entry', 'review'], dir), 0);
|
|
10250
11630
|
const rParSource = runGuard(['exit', 'review', '--apply'], dir);
|
|
10251
11631
|
assertExit(rParSource, 0);
|
|
@@ -10283,7 +11663,7 @@ const SCENARIOS = [
|
|
|
10283
11663
|
...handoffFor(['P-FIX-01']),
|
|
10284
11664
|
};
|
|
10285
11665
|
writeState(dir, after);
|
|
10286
|
-
assertExit(
|
|
11666
|
+
assertExit(runStateWithProtocol(dir, ['skill-load', 'subagent-execute', 'flow-comet-dev', '--prompt', 'flow-kit/prompts/4-dev.md']), 0);
|
|
10287
11667
|
const rDoneParExit = runGuard(['exit', 'subagent-execute', '--apply'], dir);
|
|
10288
11668
|
assertExit(rDoneParExit, 0);
|
|
10289
11669
|
assertOut(rDoneParExit, 'FIX-BATCH: 回源节点 review(subagent-execute 出口已完成)');
|
|
@@ -10315,7 +11695,6 @@ const SCENARIOS = [
|
|
|
10315
11695
|
{
|
|
10316
11696
|
name: '253 next Fix 回退态显式归位:review/verify 源 + 审计行(无 pending 反例不归位;done-but-unclosed 归位)',
|
|
10317
11697
|
run: (dir) => {
|
|
10318
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10319
11698
|
writeIntakeArtifacts(dir);
|
|
10320
11699
|
const taskPath = '.specs/' + CHANGE_ID + '/TASK.md';
|
|
10321
11700
|
const base = {
|
|
@@ -10335,7 +11714,7 @@ const SCENARIOS = [
|
|
|
10335
11714
|
// ① review 源:pending Fix 任务在场 → NODE: execute + 审计行 + 机器字段归位写盘
|
|
10336
11715
|
writeFile(dir, taskPath, fixBatchTaskText('pending'));
|
|
10337
11716
|
writeState(dir, base);
|
|
10338
|
-
const resReview =
|
|
11717
|
+
const resReview = runStateWithProtocol(dir, ['next']);
|
|
10339
11718
|
assertExit(resReview, 0);
|
|
10340
11719
|
assertOut(resReview, 'FIX-BATCH: 归位 execute(源节点 review)');
|
|
10341
11720
|
assertOut(resReview, 'NODE: execute');
|
|
@@ -10355,7 +11734,7 @@ const SCENARIOS = [
|
|
|
10355
11734
|
enteredNodes: [...base.enteredNodes, 'verify'],
|
|
10356
11735
|
evidence: { ...base.evidence, review: { summary: 'review complete' }, verify: { summary: 'verify in progress' } },
|
|
10357
11736
|
});
|
|
10358
|
-
const resVerify =
|
|
11737
|
+
const resVerify = runStateWithProtocol(dir, ['next']);
|
|
10359
11738
|
assertExit(resVerify, 0);
|
|
10360
11739
|
assertOut(resVerify, 'FIX-BATCH: 归位 execute(源节点 verify)');
|
|
10361
11740
|
assertOut(resVerify, 'NODE: execute');
|
|
@@ -10372,7 +11751,7 @@ const SCENARIOS = [
|
|
|
10372
11751
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md',
|
|
10373
11752
|
'# REVIEW\n\n## 发现\n\n### Critical\n\n- 无\n\n### Major\n\n- 无\n\n### Minor\n\n- 无\n\n## 结论\n\nFix 批次由 execute 完成,待回源重新出口。\n');
|
|
10374
11753
|
writeState(dir, base);
|
|
10375
|
-
const resNoFix =
|
|
11754
|
+
const resNoFix = runStateWithProtocol(dir, ['next']);
|
|
10376
11755
|
assertExit(resNoFix, 0);
|
|
10377
11756
|
assertNotOut(resNoFix, 'FIX-BATCH: 归位 execute');
|
|
10378
11757
|
// ③ 全局缺席:无 pending Fix 任务的回程态,state 侧无 Fix 因果——不得出现任何 FIX-BATCH
|
|
@@ -10387,7 +11766,7 @@ const SCENARIOS = [
|
|
|
10387
11766
|
// ④ done-but-unclosed 回退态(全 done + history 最新 exit execute 签名仍是追加前值):
|
|
10388
11767
|
// next 同样显式归位 execute(修复前 done 变体无恢复通道,next 停在源节点)。
|
|
10389
11768
|
writeState(dir, { ...base, history: fixBatchHistoryWithStaleExecuteExit() });
|
|
10390
|
-
const resDoneRollback =
|
|
11769
|
+
const resDoneRollback = runStateWithProtocol(dir, ['next']);
|
|
10391
11770
|
assertExit(resDoneRollback, 0);
|
|
10392
11771
|
assertOut(resDoneRollback, 'FIX-BATCH: 归位 execute(源节点 review)');
|
|
10393
11772
|
assertOut(resDoneRollback, 'NODE: execute');
|
|
@@ -10401,7 +11780,7 @@ const SCENARIOS = [
|
|
|
10401
11780
|
// 不得停在源节点,也不得错配回 execute。
|
|
10402
11781
|
writeFile(dir, taskPath, fixBatchParallelTaskText('pending'));
|
|
10403
11782
|
writeState(dir, base);
|
|
10404
|
-
const resParallelReview =
|
|
11783
|
+
const resParallelReview = runStateWithProtocol(dir, ['next']);
|
|
10405
11784
|
assertExit(resParallelReview, 0);
|
|
10406
11785
|
assertOut(resParallelReview, 'FIX-BATCH: 归位 subagent-execute(源节点 review)');
|
|
10407
11786
|
assertOut(resParallelReview, 'NODE: subagent-execute');
|
|
@@ -10421,7 +11800,7 @@ const SCENARIOS = [
|
|
|
10421
11800
|
enteredNodes: [...base.enteredNodes, 'verify'],
|
|
10422
11801
|
evidence: { ...base.evidence, review: { summary: 'review complete' }, verify: { summary: 'verify in progress' } },
|
|
10423
11802
|
});
|
|
10424
|
-
const resParallelVerify =
|
|
11803
|
+
const resParallelVerify = runStateWithProtocol(dir, ['next']);
|
|
10425
11804
|
assertExit(resParallelVerify, 0);
|
|
10426
11805
|
assertOut(resParallelVerify, 'FIX-BATCH: 归位 subagent-execute(源节点 verify)');
|
|
10427
11806
|
assertOut(resParallelVerify, 'NODE: subagent-execute');
|
|
@@ -10436,7 +11815,7 @@ const SCENARIOS = [
|
|
|
10436
11815
|
writeFile(dir, taskPath, fixBatchParallelTaskText('done'));
|
|
10437
11816
|
writeFile(dir, '.specs/' + CHANGE_ID + '/P-FIX-01-SUMMARY.md', strictSummary('P-FIX-01'));
|
|
10438
11817
|
writeState(dir, { ...base, history: fixBatchHistoryWithStaleFamilyExit('subagent-execute') });
|
|
10439
|
-
const resDoneParallel =
|
|
11818
|
+
const resDoneParallel = runStateWithProtocol(dir, ['next']);
|
|
10440
11819
|
assertExit(resDoneParallel, 0);
|
|
10441
11820
|
assertOut(resDoneParallel, 'FIX-BATCH: 归位 subagent-execute(源节点 review)');
|
|
10442
11821
|
assertOut(resDoneParallel, 'NODE: subagent-execute');
|
|
@@ -10453,7 +11832,7 @@ const SCENARIOS = [
|
|
|
10453
11832
|
const stRound = readScenarioState(dir);
|
|
10454
11833
|
stRound.fixRoundsByChange = { [CHANGE_ID]: round - 1 };
|
|
10455
11834
|
writeState(dir, stRound);
|
|
10456
|
-
const resRound =
|
|
11835
|
+
const resRound = runStateWithProtocol(dir, ['next']);
|
|
10457
11836
|
assertExit(resRound, 0);
|
|
10458
11837
|
assertOut(resRound, 'FIX-BATCH: 归位 execute(源节点 review)(第 ' + round + '/3 轮)');
|
|
10459
11838
|
const stAfterRound = readScenarioState(dir);
|
|
@@ -10466,7 +11845,7 @@ const SCENARIOS = [
|
|
|
10466
11845
|
writeState(dir, { ...base, fixRoundsByChange: { [CHANGE_ID]: 3 } });
|
|
10467
11846
|
const statePath = path.join(dir, '.flow-comet', 'flow-comet-state.json');
|
|
10468
11847
|
const beforeRound4 = fs.readFileSync(statePath, 'utf8');
|
|
10469
|
-
const resRound4 =
|
|
11848
|
+
const resRound4 = runStateWithProtocol(dir, ['next']);
|
|
10470
11849
|
assertExit(resRound4, 1);
|
|
10471
11850
|
assertOut(resRound4, 'BLOCKED: Fix 批次受控归位已达 3 轮上限');
|
|
10472
11851
|
assertOut(resRound4, '继续修');
|
|
@@ -10485,7 +11864,7 @@ const SCENARIOS = [
|
|
|
10485
11864
|
stBadOverride.evidence.review.fixRoundOverride = { round: 4 };
|
|
10486
11865
|
writeState(dir, stBadOverride);
|
|
10487
11866
|
const badOverrideBytes = fs.readFileSync(statePath, 'utf8');
|
|
10488
|
-
const resBadOverride =
|
|
11867
|
+
const resBadOverride = runStateWithProtocol(dir, ['next']);
|
|
10489
11868
|
assertExit(resBadOverride, 1);
|
|
10490
11869
|
assertOut(resBadOverride, 'BLOCKED: Fix 批次受控归位已达 3 轮上限');
|
|
10491
11870
|
assertNotOut(resBadOverride, '(第 4/3 轮)');
|
|
@@ -10501,7 +11880,7 @@ const SCENARIOS = [
|
|
|
10501
11880
|
const stOverride = JSON.parse(fs.readFileSync(statePath, 'utf8'));
|
|
10502
11881
|
stOverride.evidence.review.fixRoundOverride = { round: 4, at: '2026-09-25T00:00:00.000Z', source: 'fixture-user' };
|
|
10503
11882
|
writeState(dir, stOverride);
|
|
10504
|
-
const resOverride =
|
|
11883
|
+
const resOverride = runStateWithProtocol(dir, ['next']);
|
|
10505
11884
|
assertExit(resOverride, 0);
|
|
10506
11885
|
assertOut(resOverride, '(第 4/3 轮)');
|
|
10507
11886
|
const stAuthorized = readScenarioState(dir);
|
|
@@ -10519,7 +11898,6 @@ const SCENARIOS = [
|
|
|
10519
11898
|
{
|
|
10520
11899
|
name: '254 next Fix 回程豁免:review 源(REVIEW.md 在场不跳过;无 inProgress 证据也不 BLOCK)',
|
|
10521
11900
|
run: (dir) => {
|
|
10522
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10523
11901
|
writeIntakeArtifacts(dir);
|
|
10524
11902
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', fixBatchTaskText('done'));
|
|
10525
11903
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', strictSummary('T01'));
|
|
@@ -10540,7 +11918,7 @@ const SCENARIOS = [
|
|
|
10540
11918
|
};
|
|
10541
11919
|
// ① 真实回程态(review 已 entry)→ 审计行 + NODE: review + state 只读不改写
|
|
10542
11920
|
writeState(dir, base);
|
|
10543
|
-
const res =
|
|
11921
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
10544
11922
|
assertExit(res, 0);
|
|
10545
11923
|
assertOut(res, 'RETURN: 回程源节点 review');
|
|
10546
11924
|
assertOut(res, 'NODE: review');
|
|
@@ -10557,7 +11935,7 @@ const SCENARIOS = [
|
|
|
10557
11935
|
enteredNodes: completedNodes.slice(),
|
|
10558
11936
|
evidence: { execute: { summary: 'fix batch executed' }, 'subagent-execute': { summary: 'delegated' } },
|
|
10559
11937
|
});
|
|
10560
|
-
const resNoEvidence =
|
|
11938
|
+
const resNoEvidence = runStateWithProtocol(dir, ['next']);
|
|
10561
11939
|
assertExit(resNoEvidence, 0);
|
|
10562
11940
|
assertOut(resNoEvidence, 'RETURN: 回程源节点 review');
|
|
10563
11941
|
assertOut(resNoEvidence, 'NODE: review');
|
|
@@ -10569,7 +11947,7 @@ const SCENARIOS = [
|
|
|
10569
11947
|
}
|
|
10570
11948
|
// ③ 无任何 evidence 的引擎回程态 → 回程豁免先于「疑似未 exit」门禁,不 BLOCK
|
|
10571
11949
|
writeState(dir, { ...base, enteredNodes: [], evidence: {} });
|
|
10572
|
-
const resNoAnyEvidence =
|
|
11950
|
+
const resNoAnyEvidence = runStateWithProtocol(dir, ['next']);
|
|
10573
11951
|
assertExit(resNoAnyEvidence, 0);
|
|
10574
11952
|
assertOut(resNoAnyEvidence, 'RETURN: 回程源节点 review');
|
|
10575
11953
|
assertOut(resNoAnyEvidence, 'NODE: review');
|
|
@@ -10587,7 +11965,6 @@ const SCENARIOS = [
|
|
|
10587
11965
|
{
|
|
10588
11966
|
name: '255 next Fix 回程豁免:verify 源(TEST/UAT 在场不跳过;不漂移 archive/不 BLOCK)',
|
|
10589
11967
|
run: (dir) => {
|
|
10590
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10591
11968
|
writeIntakeArtifacts(dir);
|
|
10592
11969
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', fixBatchTaskText('done'));
|
|
10593
11970
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', strictSummary('T01'));
|
|
@@ -10614,7 +11991,7 @@ const SCENARIOS = [
|
|
|
10614
11991
|
};
|
|
10615
11992
|
// ① 真实回程态(verify 已 entry)→ 审计行 + NODE: verify + state 只读不改写
|
|
10616
11993
|
writeState(dir, base);
|
|
10617
|
-
const res =
|
|
11994
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
10618
11995
|
assertExit(res, 0);
|
|
10619
11996
|
assertOut(res, 'RETURN: 回程源节点 verify');
|
|
10620
11997
|
assertOut(res, 'NODE: verify');
|
|
@@ -10631,7 +12008,7 @@ const SCENARIOS = [
|
|
|
10631
12008
|
enteredNodes: completedNodes.slice(),
|
|
10632
12009
|
evidence: { execute: { summary: 'fix batch executed' }, review: { summary: 'review complete' } },
|
|
10633
12010
|
});
|
|
10634
|
-
const resNoEvidence =
|
|
12011
|
+
const resNoEvidence = runStateWithProtocol(dir, ['next']);
|
|
10635
12012
|
assertExit(resNoEvidence, 0);
|
|
10636
12013
|
assertOut(resNoEvidence, 'RETURN: 回程源节点 verify');
|
|
10637
12014
|
assertOut(resNoEvidence, 'NODE: verify');
|
|
@@ -10643,7 +12020,7 @@ const SCENARIOS = [
|
|
|
10643
12020
|
}
|
|
10644
12021
|
// ③ 无任何 evidence → 回程豁免先于「疑似未 exit」门禁,不 BLOCK
|
|
10645
12022
|
writeState(dir, { ...base, enteredNodes: [], evidence: {} });
|
|
10646
|
-
const resNoAnyEvidence =
|
|
12023
|
+
const resNoAnyEvidence = runStateWithProtocol(dir, ['next']);
|
|
10647
12024
|
assertExit(resNoAnyEvidence, 0);
|
|
10648
12025
|
assertOut(resNoAnyEvidence, 'RETURN: 回程源节点 verify');
|
|
10649
12026
|
assertOut(resNoAnyEvidence, 'NODE: verify');
|
|
@@ -10657,7 +12034,6 @@ const SCENARIOS = [
|
|
|
10657
12034
|
{
|
|
10658
12035
|
name: '256 负例:正常多趟中间态(execute 已完成 + 可委托 parallel pending)不误分流',
|
|
10659
12036
|
run: (dir) => {
|
|
10660
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10661
12037
|
writeIntakeArtifacts(dir);
|
|
10662
12038
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', renderMultiWaveTasks(['T01', 'P01', 'P02', 'T02']));
|
|
10663
12039
|
for (const id of ['T01', 'P01', 'P02', 'T02']) {
|
|
@@ -10678,7 +12054,7 @@ const SCENARIOS = [
|
|
|
10678
12054
|
directOverride: false,
|
|
10679
12055
|
newChange: true,
|
|
10680
12056
|
});
|
|
10681
|
-
const res =
|
|
12057
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
10682
12058
|
assertExit(res, 0);
|
|
10683
12059
|
assertOut(res, 'NODE: subagent-execute');
|
|
10684
12060
|
assertNotOut(res, 'NODE: review');
|
|
@@ -10697,7 +12073,6 @@ const SCENARIOS = [
|
|
|
10697
12073
|
{
|
|
10698
12074
|
name: '257 旧 change 兼容:无 newChange 的回退/回程态不新增 BLOCK 且 NODE 正确',
|
|
10699
12075
|
run: (dir) => {
|
|
10700
|
-
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
10701
12076
|
writeIntakeArtifacts(dir);
|
|
10702
12077
|
const taskPath = '.specs/' + CHANGE_ID + '/TASK.md';
|
|
10703
12078
|
const completedNodes = ['open', 'design', 'plan', 'execute', 'subagent-execute'];
|
|
@@ -10715,7 +12090,7 @@ const SCENARIOS = [
|
|
|
10715
12090
|
// ① 旧 change 回退态(pending Fix 任务)→ NODE: execute + 审计行,不得 BLOCK
|
|
10716
12091
|
writeFile(dir, taskPath, fixBatchTaskText('pending'));
|
|
10717
12092
|
writeState(dir, oldState);
|
|
10718
|
-
const resRollback =
|
|
12093
|
+
const resRollback = runStateWithProtocol(dir, ['next']);
|
|
10719
12094
|
assertExit(resRollback, 0);
|
|
10720
12095
|
assertNotOut(resRollback, 'BLOCKED');
|
|
10721
12096
|
assertOut(resRollback, 'FIX-BATCH: 归位 execute(源节点 review)');
|
|
@@ -10734,7 +12109,7 @@ const SCENARIOS = [
|
|
|
10734
12109
|
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md',
|
|
10735
12110
|
'# REVIEW\n\n## 发现\n\n### Critical\n\n- 无\n\n### Major\n\n- 无\n\n### Minor\n\n- 无\n\n## 结论\n\n待回源出口。\n');
|
|
10736
12111
|
writeState(dir, oldState);
|
|
10737
|
-
const resReturn =
|
|
12112
|
+
const resReturn = runStateWithProtocol(dir, ['next']);
|
|
10738
12113
|
assertExit(resReturn, 0);
|
|
10739
12114
|
assertNotOut(resReturn, 'BLOCKED');
|
|
10740
12115
|
assertOut(resReturn, 'RETURN: 回程源节点 review');
|
|
@@ -10747,7 +12122,7 @@ const SCENARIOS = [
|
|
|
10747
12122
|
// RETURN 回程行——缺 taskSetSignature、TASK 无 Fix 段/编号 → 不得冒充 FIX-BATCH。
|
|
10748
12123
|
writeFile(dir, taskPath, '# TASK\n\n' + fixTaskBlock('T01', 'done') + '\n');
|
|
10749
12124
|
writeState(dir, oldState);
|
|
10750
|
-
const resReturnNoMarker =
|
|
12125
|
+
const resReturnNoMarker = runStateWithProtocol(dir, ['next']);
|
|
10751
12126
|
assertExit(resReturnNoMarker, 0);
|
|
10752
12127
|
assertNotOut(resReturnNoMarker, 'BLOCKED');
|
|
10753
12128
|
assertNotOut(resReturnNoMarker, 'FIX-BATCH');
|
|
@@ -10760,13 +12135,13 @@ const SCENARIOS = [
|
|
|
10760
12135
|
},
|
|
10761
12136
|
|
|
10762
12137
|
// 258: 三节点 SKILL 文本锁(AC-9 / T05 已落地)——execute/review/verify 均含
|
|
10763
|
-
// 「##
|
|
12138
|
+
// 「## 修复回路状态机路径」段,段内含受控归位 + 回源节点跑出口 + 禁止绕过;不得把
|
|
10764
12139
|
// 直接 exit 源节点收场或 advance 当正常路径(反捷径文本锚)。
|
|
10765
|
-
//
|
|
12140
|
+
// 布局感知(端到端冒烟副本缺陷):技能树从 suite 脚本自身位置推导
|
|
10766
12141
|
// (<skillsRoot>/flow-comet/scripts/ → 组件技能为 <skillsRoot> 下同级目录),权威源
|
|
10767
12142
|
// .flow-comet/skills/ 与安装副本 .claude|.agents|.dsh/skills/ 同一相对布局通吃。
|
|
10768
12143
|
{
|
|
10769
|
-
name: '258 技能文本锁:三节点 SKILL
|
|
12144
|
+
name: '258 技能文本锁:三节点 SKILL 含修复回路状态机路径(禁止直接 exit/advance 为正常路径)',
|
|
10770
12145
|
run: (dir) => {
|
|
10771
12146
|
const componentSkills = ['flow-comet-execute', 'flow-comet-review', 'flow-comet-verify'];
|
|
10772
12147
|
// 布局感知回归锚(合成安装副本):suite 位于 <skillsRoot>/flow-comet/scripts/ 时组件技能
|
|
@@ -10776,7 +12151,7 @@ const SCENARIOS = [
|
|
|
10776
12151
|
const syntheticScriptsDir = path.join(syntheticSkillsRoot, 'flow-comet', 'scripts');
|
|
10777
12152
|
for (const nodeSkill of componentSkills) {
|
|
10778
12153
|
writeFile(dir, path.join('synthetic-carrier', '.claude', 'skills', nodeSkill, 'SKILL.md'),
|
|
10779
|
-
'##
|
|
12154
|
+
'## 修复回路状态机路径\n\n受控归位(合成布局锚)\n');
|
|
10780
12155
|
const expected = path.join(syntheticSkillsRoot, nodeSkill, 'SKILL.md');
|
|
10781
12156
|
const resolved = resolveComponentSkillFile(nodeSkill, syntheticScriptsDir);
|
|
10782
12157
|
if (resolved !== expected) {
|
|
@@ -10798,27 +12173,27 @@ const SCENARIOS = [
|
|
|
10798
12173
|
}
|
|
10799
12174
|
// 真实三节点文本锁:从本 suite 自身位置推导技能树(不假定权威源布局)。逐份断言:
|
|
10800
12175
|
// 段在场 + 6 关键词 + 反 advance 捷径 + 不得把直接 exit 源节点收场当正常路径;同时收集
|
|
10801
|
-
// 段正文(同一区间:首个 ##
|
|
12176
|
+
// 段正文(同一区间:首个 ## 修复回路状态机路径 → 下一 ## 或 EOF,标题不计入)供 F-4 互比。
|
|
10802
12177
|
const sectionEntries = [];
|
|
10803
12178
|
for (const nodeSkill of componentSkills) {
|
|
10804
12179
|
const file = resolveComponentSkillFile(nodeSkill);
|
|
10805
12180
|
const text = fs.readFileSync(file, 'utf8');
|
|
10806
|
-
const match = text.match(/(?:^|\r?\n)##
|
|
12181
|
+
const match = text.match(/(?:^|\r?\n)## 修复回路状态机路径\r?\n([\s\S]*?)(?=\r?\n## |$)/);
|
|
10807
12182
|
if (!match) {
|
|
10808
|
-
throw new Error(nodeSkill + ' SKILL.md 缺「##
|
|
12183
|
+
throw new Error(nodeSkill + ' SKILL.md 缺「## 修复回路状态机路径」段');
|
|
10809
12184
|
}
|
|
10810
12185
|
const section = match[1];
|
|
10811
12186
|
for (const keyword of ['受控归位', 'NODE: execute', '回源节点跑出口', 'entry <源节点>', 'exit <源节点> --apply', '禁止绕过']) {
|
|
10812
12187
|
if (!section.includes(keyword)) {
|
|
10813
|
-
throw new Error(nodeSkill + '
|
|
12188
|
+
throw new Error(nodeSkill + ' 修复回路状态机路径段缺关键词: ' + keyword);
|
|
10814
12189
|
}
|
|
10815
12190
|
}
|
|
10816
12191
|
if (section.includes('advance')) {
|
|
10817
|
-
throw new Error(nodeSkill + '
|
|
12192
|
+
throw new Error(nodeSkill + ' 修复回路状态机路径段不得把 advance 作为正常路径');
|
|
10818
12193
|
}
|
|
10819
12194
|
for (const line of section.split(/\r?\n/)) {
|
|
10820
12195
|
if (line.includes('直接') && line.includes('exit') && !/禁止|不得|会被 BLOCKED/.test(line)) {
|
|
10821
|
-
throw new Error(nodeSkill + '
|
|
12196
|
+
throw new Error(nodeSkill + ' 修复回路状态机路径段不得把直接 exit 源节点收场作为正常路径: ' + line.trim());
|
|
10822
12197
|
}
|
|
10823
12198
|
}
|
|
10824
12199
|
// F-4 段一致性锁:CRLF→LF 归一、不 trim(行尾/空白差异同样算漂移),正文参与三份互比。
|
|
@@ -10829,7 +12204,7 @@ const SCENARIOS = [
|
|
|
10829
12204
|
// 套件失败;失败信息给出三份 hash 与首处差异位置/上下文(L-064 反向构造证明判别力)。
|
|
10830
12205
|
const emptyEntry = sectionEntries.find((entry) => entry.body.trim() === '');
|
|
10831
12206
|
if (emptyEntry) {
|
|
10832
|
-
throw new Error('
|
|
12207
|
+
throw new Error('修复回路状态机路径段不得为空: ' + emptyEntry.nodeSkill);
|
|
10833
12208
|
}
|
|
10834
12209
|
const baselineEntry = sectionEntries[0];
|
|
10835
12210
|
for (const entry of sectionEntries.slice(1)) {
|
|
@@ -10838,7 +12213,7 @@ const SCENARIOS = [
|
|
|
10838
12213
|
let diffIndex = 0;
|
|
10839
12214
|
while (diffIndex < limit && baselineEntry.body[diffIndex] === entry.body[diffIndex]) diffIndex += 1;
|
|
10840
12215
|
const context = baselineEntry.body.slice(Math.max(0, diffIndex - 40), diffIndex + 40);
|
|
10841
|
-
throw new Error('
|
|
12216
|
+
throw new Error('修复回路状态机路径段三份 SKILL 正文不一致(F-4 段一致性锁):'
|
|
10842
12217
|
+ baselineEntry.nodeSkill + ' sha256=' + baselineEntry.hash
|
|
10843
12218
|
+ ' vs ' + entry.nodeSkill + ' sha256=' + entry.hash
|
|
10844
12219
|
+ ';首处差异 @' + diffIndex + '(基准上下文: ' + JSON.stringify(context) + ')');
|
|
@@ -11125,26 +12500,25 @@ const SCENARIOS = [
|
|
|
11125
12500
|
+ JSON.stringify(appliedEvent));
|
|
11126
12501
|
}
|
|
11127
12502
|
// ⑧ select 入口收紧:多段路径(归档相对路径形态)与保留目录名不得被选为 activeChange
|
|
11128
|
-
const selectEnv = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
11129
12503
|
fs.mkdirSync(path.join(dir, '.specs', 'archive', '2026-09-26-' + CHANGE_ID), { recursive: true });
|
|
11130
12504
|
const beforeSelect = readStateBytes(dir);
|
|
11131
|
-
assertExit(
|
|
12505
|
+
assertExit(runStateWithProtocol(dir, ['select', 'archive/2026-09-26-' + CHANGE_ID]), 1);
|
|
11132
12506
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 归档相对路径');
|
|
11133
|
-
assertExit(
|
|
12507
|
+
assertExit(runStateWithProtocol(dir, ['select', 'archive']), 1);
|
|
11134
12508
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 保留目录名');
|
|
11135
12509
|
// ⑧b 名字变体族:保留目录名大小写变体(ARCHIVE/Archive)、真实目录名的大小写变体(CH)与
|
|
11136
12510
|
// 首尾空白变体在大小写不敏感文件系统上同样可达,但会让 activeChange 与实际目录名不一致
|
|
11137
12511
|
// (轮次事件按 activeChange 精确匹配 → 配额被换键重置)→ 一律拒绝且 state 字节零改写
|
|
11138
|
-
assertExit(
|
|
12512
|
+
assertExit(runStateWithProtocol(dir, ['select', 'ARCHIVE']), 1);
|
|
11139
12513
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 保留目录名大小写变体');
|
|
11140
|
-
assertExit(
|
|
12514
|
+
assertExit(runStateWithProtocol(dir, ['select', 'Archive']), 1);
|
|
11141
12515
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 保留目录名混合大小写变体');
|
|
11142
12516
|
const caseVariant = String(CHANGE_ID).toUpperCase();
|
|
11143
12517
|
if (caseVariant !== CHANGE_ID) {
|
|
11144
|
-
assertExit(
|
|
12518
|
+
assertExit(runStateWithProtocol(dir, ['select', caseVariant]), 1);
|
|
11145
12519
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 真实目录名大小写变体');
|
|
11146
12520
|
}
|
|
11147
|
-
assertExit(
|
|
12521
|
+
assertExit(runStateWithProtocol(dir, ['select', ' ' + CHANGE_ID + ' ']), 1);
|
|
11148
12522
|
assertStateBytesUnchanged(dir, beforeSelect, 'select 首尾空白变体');
|
|
11149
12523
|
if (readScenarioState(dir).activeChange !== CHANGE_ID) {
|
|
11150
12524
|
throw new Error('被拒绝的 select 不得改写 activeChange:' + JSON.stringify(readScenarioState(dir).activeChange));
|
|
@@ -11369,23 +12743,25 @@ const SCENARIOS = [
|
|
|
11369
12743
|
},
|
|
11370
12744
|
|
|
11371
12745
|
// 264: history 事件类型集合静态锚(唯一事件类型例外 / 禁止扩散)——扫描引擎生产脚本的
|
|
11372
|
-
// 事件类型字面量:写侧集合必须恰为 {exit-applied, reentry-applied
|
|
11373
|
-
//
|
|
11374
|
-
//
|
|
12746
|
+
// 事件类型字面量:写侧集合必须恰为 {exit-applied, reentry-applied, replan-applied,
|
|
12747
|
+
// advance-forced}(新增类型必须由引擎写侧真实落地 + 显式更新本锚,未落地即 RED),读侧集合
|
|
12748
|
+
// 必须 ⊆ 允许集(出现允许集外的事件类型即红);另锚新的两类写点必须带跨 change 归属字段
|
|
12749
|
+
// (replan-applied → change)与「被跳过的出口门禁」标识(advance-forced → skipped:
|
|
12750
|
+
// exit:<node>),事件对象的动态断言在 259 / 263 / 受控计划重校场景族。
|
|
11375
12751
|
{
|
|
11376
|
-
name: '264 history 事件类型集合静态锚:既有类型 +
|
|
12752
|
+
name: '264 history 事件类型集合静态锚:既有类型 + replan-applied / advance-forced(新增即红、判据不放宽)',
|
|
11377
12753
|
run: () => {
|
|
11378
|
-
const allowed = ['exit-applied', 'reentry-applied'];
|
|
12754
|
+
const allowed = ['exit-applied', 'reentry-applied', 'replan-applied', 'advance-forced'];
|
|
11379
12755
|
const scripts = fs.readdirSync(__dirname)
|
|
11380
12756
|
.filter((f) => f.endsWith('.mjs') && f !== 'guard-self-test.mjs' && f !== 'system-test.mjs');
|
|
11381
12757
|
const writers = new Set();
|
|
11382
12758
|
const readers = new Set();
|
|
11383
|
-
|
|
12759
|
+
const writeSites = new Map();
|
|
11384
12760
|
for (const file of scripts) {
|
|
11385
12761
|
const text = fs.readFileSync(path.join(__dirname, file), 'utf8');
|
|
11386
12762
|
for (const match of text.matchAll(/event:\s*'([a-z][a-z-]*)'/g)) {
|
|
11387
12763
|
writers.add(match[1]);
|
|
11388
|
-
|
|
12764
|
+
writeSites.set(match[1], { file, text, index: match.index });
|
|
11389
12765
|
}
|
|
11390
12766
|
for (const match of text.matchAll(/\.event\s*(?:===|!==)\s*'([a-z][a-z-]*)'/g)) {
|
|
11391
12767
|
readers.add(match[1]);
|
|
@@ -11398,15 +12774,28 @@ const SCENARIOS = [
|
|
|
11398
12774
|
}
|
|
11399
12775
|
const missingWriters = allowed.filter((type) => !writers.has(type));
|
|
11400
12776
|
if (missingWriters.length > 0) {
|
|
11401
|
-
throw new Error('history
|
|
12777
|
+
throw new Error('history 事件类型写侧缺类型(受控通道未落地即 RED): ' + missingWriters.join(', ')
|
|
11402
12778
|
+ ';实际写侧=' + [...writers].join(','));
|
|
11403
12779
|
}
|
|
11404
|
-
|
|
11405
|
-
|
|
12780
|
+
// 跨 change 归属字段锚:轮次/配额按 change 隔离依赖事件的 change 字段(reentry / replan 同判据)
|
|
12781
|
+
const changeFieldTypes = ['reentry-applied', 'replan-applied'];
|
|
12782
|
+
for (const type of changeFieldTypes) {
|
|
12783
|
+
const site = writeSites.get(type);
|
|
12784
|
+
if (!site) throw new Error(type + ' 写点缺失(审计事件必须由引擎脚本写入)');
|
|
12785
|
+
const windowText = site.text.slice(site.index, site.index + 800);
|
|
12786
|
+
if (!/\bchange\s*:/.test(windowText)) {
|
|
12787
|
+
throw new Error(type + ' 写点必须带 change 字段(跨 change 轮次隔离依据): ' + site.file);
|
|
12788
|
+
}
|
|
11406
12789
|
}
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
12790
|
+
// 强制推进留痕锚:事件必须记录被跳过的出口门禁标识(skipped: ['exit:<node>'])
|
|
12791
|
+
const forcedSite = writeSites.get('advance-forced');
|
|
12792
|
+
if (!forcedSite) throw new Error('advance-forced 写点缺失(逃生口留痕必须由引擎脚本写入)');
|
|
12793
|
+
const forcedWindow = forcedSite.text.slice(forcedSite.index, forcedSite.index + 800);
|
|
12794
|
+
if (!/\bskipped\s*:/.test(forcedWindow)) {
|
|
12795
|
+
throw new Error('advance-forced 写点必须带 skipped 字段(记录被跳过的出口门禁): ' + forcedSite.file);
|
|
12796
|
+
}
|
|
12797
|
+
if (!/exit:/.test(forcedWindow)) {
|
|
12798
|
+
throw new Error('advance-forced 写点的 skipped 值必须标识 exit:<node> 形态的门禁: ' + forcedSite.file);
|
|
11410
12799
|
}
|
|
11411
12800
|
},
|
|
11412
12801
|
},
|
|
@@ -11466,6 +12855,797 @@ const SCENARIOS = [
|
|
|
11466
12855
|
}
|
|
11467
12856
|
},
|
|
11468
12857
|
},
|
|
12858
|
+
|
|
12859
|
+
// 266: replan 授权 fail-closed(AC-2 / ADR-013 决策 5)——缺 --authorized-by / 空串 /
|
|
12860
|
+
// 纯空白 / 缺 <reason> / 纯空白 reason → BLOCKED、state 字节(sha256)零改写、零备份、零事件;
|
|
12861
|
+
// 授权形态由 route-node 纯函数单一权威判定(malformed → block + 合法形态放行对照)。
|
|
12862
|
+
{
|
|
12863
|
+
name: '266 replan 授权 fail-closed:缺/空/纯空白授权与缺原因 → BLOCKED 零改写 + 形态纯函数锚',
|
|
12864
|
+
run: (dir) => {
|
|
12865
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_INITIAL);
|
|
12866
|
+
writeState(dir, replanExecuteState());
|
|
12867
|
+
// entry 形态:真实记录修订前的任务集签名(后续修订使其成为「到期签名」)
|
|
12868
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
12869
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
12870
|
+
const bytes = readStateBytes(dir);
|
|
12871
|
+
const shaBefore = createHash('sha256').update(bytes, 'utf8').digest('hex');
|
|
12872
|
+
const blockedCases = [
|
|
12873
|
+
['缺 --authorized-by(仅位置 reason)', ['replan', '计划有缺陷:新增并行任务']],
|
|
12874
|
+
['--authorized-by 空串', ['replan', '计划有缺陷:新增并行任务', '--authorized-by', '']],
|
|
12875
|
+
['--authorized-by 纯空白', ['replan', '计划有缺陷:新增并行任务', '--authorized-by', ' ']],
|
|
12876
|
+
['缺 <reason>(仅授权)', ['replan', '--authorized-by', 'user-approval']],
|
|
12877
|
+
['<reason> 纯空白', ['replan', ' ', '--authorized-by', 'user-approval']],
|
|
12878
|
+
];
|
|
12879
|
+
for (const [label, args] of blockedCases) {
|
|
12880
|
+
const res = runStateWithProtocol(dir, args);
|
|
12881
|
+
assertExit(res, 1);
|
|
12882
|
+
assertOut(res, 'BLOCKED');
|
|
12883
|
+
assertStateBytesUnchanged(dir, bytes, label);
|
|
12884
|
+
const shaNow = createHash('sha256').update(readStateBytes(dir), 'utf8').digest('hex');
|
|
12885
|
+
if (shaNow !== shaBefore) {
|
|
12886
|
+
throw new Error(label + ':state sha256 应零改写,实际 ' + shaNow + ' ≠ ' + shaBefore);
|
|
12887
|
+
}
|
|
12888
|
+
}
|
|
12889
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
12890
|
+
throw new Error('授权非法路径不得产生备份:' + JSON.stringify(replanBackupFiles(dir)));
|
|
12891
|
+
}
|
|
12892
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 0) {
|
|
12893
|
+
throw new Error('授权非法路径不得写审计事件:' + JSON.stringify(replanEventsOf(readScenarioState(dir))));
|
|
12894
|
+
}
|
|
12895
|
+
// 授权形态纯函数锚:malformed 一律 ok:false;合法形态 ok:true 且归一化字段完整
|
|
12896
|
+
const valid = {
|
|
12897
|
+
round: 1,
|
|
12898
|
+
at: '2026-09-27T00:00:00.000Z',
|
|
12899
|
+
source: 'user-approval',
|
|
12900
|
+
reason: '计划有缺陷',
|
|
12901
|
+
node: 'execute',
|
|
12902
|
+
};
|
|
12903
|
+
const parsedValid = assertReplanAuthorizationShape(valid, 'execute', true, '合法授权三元组');
|
|
12904
|
+
if (!parsedValid.authorization || parsedValid.authorization.source !== 'user-approval'
|
|
12905
|
+
|| parsedValid.authorization.reason !== '计划有缺陷' || parsedValid.authorization.node !== 'execute') {
|
|
12906
|
+
throw new Error('合法授权的归一化结果不完整:' + JSON.stringify(parsedValid.authorization));
|
|
12907
|
+
}
|
|
12908
|
+
const malformed = [
|
|
12909
|
+
['缺 authorization', undefined],
|
|
12910
|
+
['authorization 为数组', []],
|
|
12911
|
+
['round=0', { ...valid, round: 0 }],
|
|
12912
|
+
['round 非整数', { ...valid, round: 1.5 }],
|
|
12913
|
+
['round 类型错误', { ...valid, round: '1' }],
|
|
12914
|
+
['at 空串', { ...valid, at: '' }],
|
|
12915
|
+
['at 纯空白', { ...valid, at: ' ' }],
|
|
12916
|
+
['at 类型错误', { ...valid, at: 42 }],
|
|
12917
|
+
['source 空串', { ...valid, source: '' }],
|
|
12918
|
+
['source 纯空白', { ...valid, source: ' ' }],
|
|
12919
|
+
['source 类型错误', { ...valid, source: [] }],
|
|
12920
|
+
['node 与调用不一致', { ...valid, node: 'subagent-execute' }],
|
|
12921
|
+
];
|
|
12922
|
+
for (const [label, authorization] of malformed) {
|
|
12923
|
+
assertReplanAuthorizationShape(authorization, 'execute', false, label);
|
|
12924
|
+
}
|
|
12925
|
+
// 综合判定的未授权路径:非法授权 → block(不抛异常、不写盘;零改写由上方 CLI 用例锚定)
|
|
12926
|
+
const decide = requireRouteNodeExport('resolveReplanDecision');
|
|
12927
|
+
const decideState = replanExecuteState();
|
|
12928
|
+
for (const [label, authorization] of malformed) {
|
|
12929
|
+
const decision = decide({ protocol: readScenarioProtocol(dir), state: decideState, authorization });
|
|
12930
|
+
if (!decision || decision.ok !== false || decision.action !== 'block') {
|
|
12931
|
+
throw new Error('[' + label + '] resolveReplanDecision 应返回 block,实际 ' + JSON.stringify(decision));
|
|
12932
|
+
}
|
|
12933
|
+
}
|
|
12934
|
+
// 纯函数族存在性锚(T03 交付面):五项导出缺任一即本场景 RED
|
|
12935
|
+
requireRouteNodeExport('replanRoundCount');
|
|
12936
|
+
requireRouteNodeExport('replanRoundDecision');
|
|
12937
|
+
requireRouteNodeExport('replanNoOpDecision');
|
|
12938
|
+
},
|
|
12939
|
+
},
|
|
12940
|
+
|
|
12941
|
+
// 267: replan 校验不豁免(ADR-013 决策 3 / 明确 out:replan 绝不做校验豁免)——依赖环 /
|
|
12942
|
+
// 缺失依赖 / 缺 <verify> / 并行写冲突四类任务集在 replan 上一律 BLOCKED 且状态零改写;
|
|
12943
|
+
// 并且 plan 出口与 replan 对同一输入给出同一机器分类。同源是结构事实而非注释声明(L-067):
|
|
12944
|
+
// 任务图分析与并行写冲突检测各只有一份实现(route-node.mjs 定义并导出),
|
|
12945
|
+
// workflow-guard 静态 import 使用它。
|
|
12946
|
+
{
|
|
12947
|
+
name: '267 replan 校验不豁免:依赖环/缺失依赖/缺 verify/并行写冲突 → BLOCKED 零改写 + 单源锚',
|
|
12948
|
+
run: async (dir) => {
|
|
12949
|
+
const cases = [
|
|
12950
|
+
['依赖环', TASK_DEP_CYCLE, '依赖环', '依赖环'],
|
|
12951
|
+
['依赖不存在的任务', TASK_MISSING_DEP, '依赖不存在的任务', '依赖'],
|
|
12952
|
+
['缺 <verify> 字段', REPLAN_TASK_NO_VERIFY, '缺 <verify> 字段', 'verify'],
|
|
12953
|
+
['并行写冲突', TASK_PARALLEL_WRITE_CONFLICT, 'write_files', '并行写冲突'],
|
|
12954
|
+
];
|
|
12955
|
+
for (const [label, taskContent, planExpected, replanExpected] of cases) {
|
|
12956
|
+
// ① plan 出口(既有判定路径)对同一输入的机器分类
|
|
12957
|
+
const planState = baseState('plan');
|
|
12958
|
+
planState.evidence.plan = { summary: 'plan done' };
|
|
12959
|
+
planState.newChange = true;
|
|
12960
|
+
writeState(dir, planState);
|
|
12961
|
+
const planRes = runPlanExit(dir, taskContent);
|
|
12962
|
+
assertExit(planRes, 1);
|
|
12963
|
+
assertOut(planRes, 'BLOCKED');
|
|
12964
|
+
assertOut(planRes, planExpected);
|
|
12965
|
+
// ② replan 对同一输入:同一分类 + BLOCKED + state 零改写
|
|
12966
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', taskContent);
|
|
12967
|
+
writeState(dir, replanExecuteState({ taskHash: REPLAN_STALE_SIGNATURE }));
|
|
12968
|
+
const bytes = readStateBytes(dir);
|
|
12969
|
+
const replanRes = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
12970
|
+
assertExit(replanRes, 1);
|
|
12971
|
+
assertOut(replanRes, 'BLOCKED');
|
|
12972
|
+
assertOut(replanRes, replanExpected);
|
|
12973
|
+
assertStateBytesUnchanged(dir, bytes, 'replan ' + label);
|
|
12974
|
+
// 显式 sha256 前后相同(字节零改写的独立哈希表达,L-069:断言覆盖完整契约而非关键词)
|
|
12975
|
+
const shaBefore = createHash('sha256').update(bytes).digest('hex');
|
|
12976
|
+
const shaAfter = createHash('sha256').update(readStateBytes(dir)).digest('hex');
|
|
12977
|
+
if (shaBefore !== shaAfter) {
|
|
12978
|
+
throw new Error(label + ':replan BLOCK 路径 state sha256 应前后相同,实际 '
|
|
12979
|
+
+ shaBefore + ' → ' + shaAfter);
|
|
12980
|
+
}
|
|
12981
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
12982
|
+
throw new Error(label + ':校验失败路径不得产生备份');
|
|
12983
|
+
}
|
|
12984
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 0) {
|
|
12985
|
+
throw new Error(label + ':校验失败路径不得写审计事件');
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
// 读写弱判(read∩write,plan 出口同判据):仅 WARN 不阻断——replan 照常重签、写重签前备份、
|
|
12989
|
+
// 写审计事件(覆盖写写强判之外的非阻断分支,2026-09-28 PR 审查补锚)。
|
|
12990
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', TASK_PARALLEL_READ_OVERLAP);
|
|
12991
|
+
writeState(dir, replanExecuteState({ taskHash: REPLAN_STALE_SIGNATURE }));
|
|
12992
|
+
const readWarnRes = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
12993
|
+
assertExit(readWarnRes, 0);
|
|
12994
|
+
assertOut(readWarnRes, 'REPLAN:');
|
|
12995
|
+
assertOut(readWarnRes, 'WARN: TASK.md 并行任务 read∩write 隐式依赖嫌疑');
|
|
12996
|
+
assertOut(readWarnRes, 'P02×P01(src/shared.mjs)'); // 输出为「读取方×写入方」(P02 读 P01 写路径)
|
|
12997
|
+
if (replanBackupFiles(dir).length !== 1) {
|
|
12998
|
+
throw new Error('read∩write 弱判不得阻断 replan:应恰有 1 份重签前备份,实际 '
|
|
12999
|
+
+ replanBackupFiles(dir).length);
|
|
13000
|
+
}
|
|
13001
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 1) {
|
|
13002
|
+
throw new Error('read∩write 弱判不得阻断 replan:应写入 1 条 replan-applied 审计事件,实际 '
|
|
13003
|
+
+ replanEventsOf(readScenarioState(dir)).length);
|
|
13004
|
+
}
|
|
13005
|
+
// 同源结构锚:任务图分析全引擎只有一处定义,且位于 route-node.mjs(可由 replan 复用)
|
|
13006
|
+
const analyze = requireRouteNodeExport('analyzeDependencyGraph');
|
|
13007
|
+
const cyclicBlocks = TASK_DEP_CYCLE.match(/<task[\s\S]*?<\/task>/g) || [];
|
|
13008
|
+
const verdict = analyze(cyclicBlocks);
|
|
13009
|
+
if (!verdict || verdict.cyclic !== true || !Array.isArray(verdict.cycleIds) || verdict.cycleIds.length === 0) {
|
|
13010
|
+
throw new Error('route-node 导出的任务图分析对依赖环应返回 cyclic=true + cycleIds,实际 ' + JSON.stringify(verdict));
|
|
13011
|
+
}
|
|
13012
|
+
const missingVerdict = analyze(TASK_MISSING_DEP.match(/<task[\s\S]*?<\/task>/g) || []);
|
|
13013
|
+
if (!missingVerdict || missingVerdict.missing.length === 0 || missingVerdict.cyclic !== false) {
|
|
13014
|
+
throw new Error('route-node 导出的任务图分析对缺失依赖应返回 missing 明细,实际 ' + JSON.stringify(missingVerdict));
|
|
13015
|
+
}
|
|
13016
|
+
const engineScripts = engineScriptFiles();
|
|
13017
|
+
const definitionFiles = engineScripts.filter((file) =>
|
|
13018
|
+
/function\s+analyzeDependencyGraph\s*\(/.test(fs.readFileSync(path.join(__dirname, file), 'utf8')));
|
|
13019
|
+
if (definitionFiles.length !== 1 || definitionFiles[0] !== 'route-node.mjs') {
|
|
13020
|
+
throw new Error('任务图分析必须只有一份实现且位于 route-node.mjs(plan 出口与 replan 共用),实际定义处: '
|
|
13021
|
+
+ JSON.stringify(definitionFiles));
|
|
13022
|
+
}
|
|
13023
|
+
const guardText = fs.readFileSync(GUARD, 'utf8');
|
|
13024
|
+
if (!/import[^;]*\banalyzeDependencyGraph\b[^;]*from\s*'\.\/route-node\.mjs'/.test(guardText)) {
|
|
13025
|
+
throw new Error('workflow-guard.mjs 必须静态 import route-node 的任务图分析(不得内联第二份判定)');
|
|
13026
|
+
}
|
|
13027
|
+
// 并行写冲突检测单源锚(CR-2 抽取):全引擎只有一份定义且位于 route-node.mjs,
|
|
13028
|
+
// workflow-guard 静态 import 使用它(replan 与 plan 出口同一判据,禁止内联第二份)。
|
|
13029
|
+
const conflictDefinitionFiles = engineScripts.filter((file) =>
|
|
13030
|
+
/function\s+findParallelWriteConflicts\s*\(/.test(fs.readFileSync(path.join(__dirname, file), 'utf8')));
|
|
13031
|
+
if (conflictDefinitionFiles.length !== 1 || conflictDefinitionFiles[0] !== 'route-node.mjs') {
|
|
13032
|
+
throw new Error('并行写冲突检测必须只有一份实现且位于 route-node.mjs(plan 出口与 replan 共用),实际定义处: '
|
|
13033
|
+
+ JSON.stringify(conflictDefinitionFiles));
|
|
13034
|
+
}
|
|
13035
|
+
if (!/import[^;]*\bfindParallelWriteConflicts\b[^;]*from\s*'\.\/route-node\.mjs'/.test(guardText)) {
|
|
13036
|
+
throw new Error('workflow-guard.mjs 必须静态 import route-node 的并行写冲突检测(不得内联第二份判定)');
|
|
13037
|
+
}
|
|
13038
|
+
// —— 本批 in-place 增锚(第三族:同文件跨任务且无依赖路径)——
|
|
13039
|
+
// ① 单一实现锚(结构事实而非注释声明):第三族的构件(修复任务族前缀常量 / 任务对键 /
|
|
13040
|
+
// 依赖可达闭包)与结果产出在全引擎脚本里只能出现一次且位于 route-node.mjs——消费脚本
|
|
13041
|
+
// 内自建第二份(依赖闭包或写入面交集实现)会在此变红。
|
|
13042
|
+
for (const piece of ['FIX_TASK_ID_PREFIX', 'taskPairKey', 'reachableTaskIds']) {
|
|
13043
|
+
const pieceFiles = engineScripts.filter((file) =>
|
|
13044
|
+
new RegExp('\\b' + piece + '\\b').test(fs.readFileSync(path.join(__dirname, file), 'utf8')));
|
|
13045
|
+
if (pieceFiles.length !== 1 || pieceFiles[0] !== 'route-node.mjs') {
|
|
13046
|
+
throw new Error('第三族判定构件 ' + piece + ' 必须只出现在 route-node.mjs,实际: ' + JSON.stringify(pieceFiles));
|
|
13047
|
+
}
|
|
13048
|
+
}
|
|
13049
|
+
const crossTaskProducerFiles = engineScripts.filter((file) =>
|
|
13050
|
+
/const\s+crossTaskConflicts\s*=/.test(fs.readFileSync(path.join(__dirname, file), 'utf8')));
|
|
13051
|
+
if (crossTaskProducerFiles.length !== 1 || crossTaskProducerFiles[0] !== 'route-node.mjs') {
|
|
13052
|
+
throw new Error('第三族结果只能由 route-node.mjs 产出(不得在消费脚本内内联),实际: ' + JSON.stringify(crossTaskProducerFiles));
|
|
13053
|
+
}
|
|
13054
|
+
if (!/\bcrossTaskConflicts\b/.test(guardText)) {
|
|
13055
|
+
throw new Error('workflow-guard.mjs 必须消费 route-node 的第三族结果(plan 出口判定)');
|
|
13056
|
+
}
|
|
13057
|
+
// ①b 修复族约定「只表达一次」锚(判别力升级:按表达式形态计数,不再只数标识符名)——
|
|
13058
|
+
// 两条边界(id 前缀 / 「位于修复段内」)各只允许一处实现,第三族参与者排除与修复族
|
|
13059
|
+
// 标记必须共用同一分类器;第二份等价前缀表达式(含内联前缀判定)在此变红。
|
|
13060
|
+
// 旧锚只统计"哪个文件含该常量名":第二份写法(不含该名字的等价正则)必然被放过——
|
|
13061
|
+
// 本锚即对该盲区的判别力补齐。
|
|
13062
|
+
for (const problem of fixFamilyBoundaryProblems()) {
|
|
13063
|
+
throw new Error('修复族约定未被唯一表达: ' + problem);
|
|
13064
|
+
}
|
|
13065
|
+
// ①b-1 该判据自身的夹具锚(常驻判别力,不依赖外部临时注入):同源形态 → 无问题;
|
|
13066
|
+
// 逐条注入"同一约定被表达两次"的变体 → 逐条专项报告。夹具目录即判据的 scriptsDir
|
|
13067
|
+
// 接缝(合成引擎脚本,不被执行、只被扫描)。
|
|
13068
|
+
const engineFixtureDir = path.join(dir, 'engine-fixture');
|
|
13069
|
+
// 夹具文本的权威前缀表达式自模块常量拼接(不在夹具里再写一份字面量——同源才测得准)
|
|
13070
|
+
const canonicalPrefixDecl = 'const FIX_TASK_ID_PREFIX = ' + FIX_PREFIX_LITERAL_TEXT + ';';
|
|
13071
|
+
const canonicalEngine = [
|
|
13072
|
+
canonicalPrefixDecl,
|
|
13073
|
+
'function fixTaskClassifier(taskContent, fixSectionTitle) {',
|
|
13074
|
+
' const section = fixSectionBody(taskContent, fixSectionTitle);',
|
|
13075
|
+
' const sectionBlocks = new Set(section === null ? [] : taskBlocks(section));',
|
|
13076
|
+
' return (block) => FIX_TASK_ID_PREFIX.test(taskOpeningAttrs(block).id) || sectionBlocks.has(block);',
|
|
13077
|
+
'}',
|
|
13078
|
+
'function fixTaskMarker(taskContent, fixSectionTitle) {',
|
|
13079
|
+
' const isFixTask = fixTaskClassifier(taskContent, fixSectionTitle);',
|
|
13080
|
+
' return taskBlocks(String(taskContent ?? "")).some((block) => isFixTask(block));',
|
|
13081
|
+
'}',
|
|
13082
|
+
'function collectCrossTaskConflicts({ taskContent = "", allBlocks = [] } = {}) {',
|
|
13083
|
+
' const isFixTask = fixTaskClassifier(taskContent);',
|
|
13084
|
+
' return allBlocks.filter((block) => !isFixTask(block));',
|
|
13085
|
+
'}',
|
|
13086
|
+
'',
|
|
13087
|
+
].join('\n');
|
|
13088
|
+
const fixtureFileRel = path.join('engine-fixture', 'route-node.mjs');
|
|
13089
|
+
writeFile(dir, fixtureFileRel, canonicalEngine);
|
|
13090
|
+
const canonicalProblems = fixFamilyBoundaryProblems(engineFixtureDir);
|
|
13091
|
+
if (canonicalProblems.length !== 0) {
|
|
13092
|
+
throw new Error('唯一表达形态不得报问题(判据夹具模板): ' + JSON.stringify(canonicalProblems));
|
|
13093
|
+
}
|
|
13094
|
+
const boundaryCases = [
|
|
13095
|
+
['第二份前缀表达式', canonicalEngine + 'const legacyFixPrefix = /^(T-FIX|P-FIX)/i;\n',
|
|
13096
|
+
'第二份修复族 id 前缀表达式'],
|
|
13097
|
+
['内联前缀判定(id 字面量)', canonicalEngine + 'const legacyIds = ["T-FIX-01"];\n',
|
|
13098
|
+
'修复族 id 字面量'],
|
|
13099
|
+
['前缀边界被删', canonicalEngine.replace(canonicalPrefixDecl, 'const FIX_TASK_ID_PREFIX = /nope/;'),
|
|
13100
|
+
'修复族 id 前缀边界必须只表达一次'],
|
|
13101
|
+
['段内成员判定第二份',
|
|
13102
|
+
canonicalEngine.replace(' return allBlocks.filter((block) => !isFixTask(block));',
|
|
13103
|
+
' sectionBlocks.has({});\n return allBlocks.filter((block) => !isFixTask(block));'),
|
|
13104
|
+
'段内成员判定)必须只表达一次'],
|
|
13105
|
+
['消费方自持边界(不共用分类器)',
|
|
13106
|
+
canonicalEngine.replace(' const isFixTask = fixTaskClassifier(taskContent);',
|
|
13107
|
+
' const isFixTask = () => false;'),
|
|
13108
|
+
'必须经唯一分类器判定修复族'],
|
|
13109
|
+
];
|
|
13110
|
+
for (const [label, mutated, expected] of boundaryCases) {
|
|
13111
|
+
writeFile(dir, fixtureFileRel, mutated);
|
|
13112
|
+
const mutatedProblems = fixFamilyBoundaryProblems(engineFixtureDir);
|
|
13113
|
+
if (!mutatedProblems.some((p) => p.includes(expected))) {
|
|
13114
|
+
throw new Error('修复族边界反向夹具(' + label + ')未按预期报告「' + expected + '」: '
|
|
13115
|
+
+ JSON.stringify(mutatedProblems));
|
|
13116
|
+
}
|
|
13117
|
+
}
|
|
13118
|
+
// ①c replan 消费锚(结构锚;replan 的真实命令链路由系统测试集承担,此处不重复造链路):
|
|
13119
|
+
// 第三族必须①被解构(只解构两族 = 静默丢失该判据,即修订通道可静默引入该形态)、
|
|
13120
|
+
// ②在 BLOCK 早于备份与写盘的位置判定、③消息与恢复指引与 plan 出口同族(新 change
|
|
13121
|
+
// 阻断 / 旧 change 渐进)。断言写成对 workflow-state.mjs 文本的结构判定。
|
|
13122
|
+
const stateText = fs.readFileSync(STATE, 'utf8');
|
|
13123
|
+
const destructured = stateText.match(/const\s*\{([^}]*)\}\s*=\s*await\s+findParallelWriteConflicts\s*\(/);
|
|
13124
|
+
if (destructured === null || !/\bcrossTaskConflicts\b/.test(destructured[1])) {
|
|
13125
|
+
throw new Error('workflow-state.mjs 的 replan 必须解构 route-node 第三族结果'
|
|
13126
|
+
+ '(只解构两族即静默丢失该判据): ' + JSON.stringify(destructured === null ? null : destructured[1].trim()));
|
|
13127
|
+
}
|
|
13128
|
+
const crossJudgeAt = stateText.indexOf('crossTaskConflicts.length > 0');
|
|
13129
|
+
const backupAt = stateText.indexOf('-pre-replan.json');
|
|
13130
|
+
if (crossJudgeAt < 0) {
|
|
13131
|
+
throw new Error('workflow-state.mjs 的 replan 未消费第三族(缺判定分支)');
|
|
13132
|
+
}
|
|
13133
|
+
if (backupAt < 0 || crossJudgeAt > backupAt) {
|
|
13134
|
+
throw new Error('replan 的第三族判定必须早于重签前备份(BLOCK 早于落盘的零改写语义): '
|
|
13135
|
+
+ '判定位置 ' + crossJudgeAt + ' / 备份位置 ' + backupAt);
|
|
13136
|
+
}
|
|
13137
|
+
for (const message of ['同文件跨任务且无依赖路径', '补显式 depends_on 或合并为一个任务']) {
|
|
13138
|
+
if (!stateText.includes(message)) {
|
|
13139
|
+
throw new Error('replan 的第三族消息必须与 plan 出口同族(缺「' + message + '」)');
|
|
13140
|
+
}
|
|
13141
|
+
}
|
|
13142
|
+
if (!/WARN: TASK\.md 同文件跨任务且无依赖路径(旧 change 渐进不阻断)/.test(stateText)) {
|
|
13143
|
+
throw new Error('replan 的第三族必须保留旧 change 渐进分支(WARN 不阻断)');
|
|
13144
|
+
}
|
|
13145
|
+
// ② 行为锚(直接驱动判定函数,plan 出口与 replan 共用同一实现):非修复同文件对命中、
|
|
13146
|
+
// 修复任务族对不参与(其顺序由修复生命周期保证,回修同文件是必然形态)。
|
|
13147
|
+
const findConflicts = requireRouteNodeExport('findParallelWriteConflicts');
|
|
13148
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n## 任务清单\n\n' + CROSS_TASK_PLAIN_PAIR);
|
|
13149
|
+
const plainConflicts = await findConflicts(path.join(dir, '.specs', CHANGE_ID));
|
|
13150
|
+
if (plainConflicts.crossTaskConflicts.length !== 1
|
|
13151
|
+
|| plainConflicts.crossTaskConflicts[0].files.join(',') !== 'src/shared.mjs') {
|
|
13152
|
+
throw new Error('非修复同文件无依赖对必须命中第三族: ' + JSON.stringify(plainConflicts.crossTaskConflicts));
|
|
13153
|
+
}
|
|
13154
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n## 任务清单\n\n' + CROSS_TASK_FIX_PAIR);
|
|
13155
|
+
const fixConflicts = await findConflicts(path.join(dir, '.specs', CHANGE_ID));
|
|
13156
|
+
if (fixConflicts.crossTaskConflicts.length !== 0 || fixConflicts.writeConflicts.length !== 0) {
|
|
13157
|
+
throw new Error('修复任务族对不得进入第三族(也不得进入写写强判): ' + JSON.stringify(fixConflicts));
|
|
13158
|
+
}
|
|
13159
|
+
// ②-附 段归属分支 + 行尾归一(LF 与 CRLF 两形态都必须识别为修复族):
|
|
13160
|
+
// 段内块来自 LF 归一后的段体,而待判 block 来自原文——Windows 下原文是 CRLF,
|
|
13161
|
+
// 不归一会让段内匹配失败 → 修复族对被当普通参与者误拦(2026-10-01 PR 审查发现)。
|
|
13162
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
13163
|
+
'# TASK\n\n## 任务清单\n\n' + CROSS_TASK_FIX_SECTION_PAIR);
|
|
13164
|
+
const sectionConflicts = await findConflicts(path.join(dir, '.specs', CHANGE_ID));
|
|
13165
|
+
if (sectionConflicts.crossTaskConflicts.length !== 0 || sectionConflicts.writeConflicts.length !== 0) {
|
|
13166
|
+
throw new Error('修复段内**非前缀 id** 的任务对不得进入第三族(段归属分支): '
|
|
13167
|
+
+ JSON.stringify(sectionConflicts));
|
|
13168
|
+
}
|
|
13169
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
13170
|
+
'# TASK\r\n\r\n## 任务清单\r\n\r\n' + CROSS_TASK_FIX_SECTION_PAIR.replace(/\n/g, '\r\n'));
|
|
13171
|
+
const crlfConflicts = await findConflicts(path.join(dir, '.specs', CHANGE_ID));
|
|
13172
|
+
if (crlfConflicts.crossTaskConflicts.length !== 0 || crlfConflicts.writeConflicts.length !== 0) {
|
|
13173
|
+
throw new Error('CRLF 行尾下修复段归属判定必须一致(行尾归一口径): ' + JSON.stringify(crlfConflicts));
|
|
13174
|
+
}
|
|
13175
|
+
// ③ 出口链路锚(新 change):非修复对照对 → BLOCKED 且消息带任务对与重叠文件;
|
|
13176
|
+
// 修复族对 → exit 0 且不出现该族消息(BLOCKED / WARN 两形态都不许有)。
|
|
13177
|
+
const crossState = baseState('plan');
|
|
13178
|
+
crossState.evidence.plan = { summary: 'plan done' };
|
|
13179
|
+
crossState.newChange = true;
|
|
13180
|
+
writeState(dir, crossState);
|
|
13181
|
+
const plainRes = runPlanExit(dir, CROSS_TASK_PLAIN_PAIR);
|
|
13182
|
+
assertExit(plainRes, 1);
|
|
13183
|
+
assertOut(plainRes, 'BLOCKED');
|
|
13184
|
+
assertOut(plainRes, '同文件跨任务且无依赖路径');
|
|
13185
|
+
assertOut(plainRes, 'T01×T02');
|
|
13186
|
+
assertOut(plainRes, 'src/shared.mjs');
|
|
13187
|
+
assertOut(plainRes, 'depends_on');
|
|
13188
|
+
writeState(dir, crossState);
|
|
13189
|
+
const fixRes = runPlanExit(dir, CROSS_TASK_FIX_PAIR);
|
|
13190
|
+
assertExit(fixRes, 0);
|
|
13191
|
+
assertNotOut(fixRes, '同文件跨任务');
|
|
13192
|
+
assertNotOut(fixRes, 'BLOCKED');
|
|
13193
|
+
// ④ 混合夹具:两类并存 → 只报非修复对(修复族对不出现在消息里)
|
|
13194
|
+
writeState(dir, crossState);
|
|
13195
|
+
const mixedRes = runPlanExit(dir, CROSS_TASK_MIXED_PAIR);
|
|
13196
|
+
assertExit(mixedRes, 1);
|
|
13197
|
+
assertOut(mixedRes, 'BLOCKED');
|
|
13198
|
+
assertOut(mixedRes, 'T01×T02');
|
|
13199
|
+
assertNotOut(mixedRes, 'T-FIX-01×T-FIX-02');
|
|
13200
|
+
},
|
|
13201
|
+
},
|
|
13202
|
+
|
|
13203
|
+
// 268: replan 轮次上限与显式续轮(AC-3 / ADR-013 决策 6)——按 history 中本 change 的
|
|
13204
|
+
// replan-applied 事件计数,上限 3:第 4 次 BLOCKED 且给出「继续 / 停止」人工裁决指引;
|
|
13205
|
+
// --continue-round <n> 满足 n ≥ 已用 + 1 才放行并计入下一轮(审计事件 / 授权留痕带续轮标记);
|
|
13206
|
+
// n 不足则 BLOCK 零改写;轮次按 change 隔离(他 change 的事件不占本 change 配额)。
|
|
13207
|
+
{
|
|
13208
|
+
name: '268 replan 轮次上限 3 与显式续轮:超限 BLOCK 人工裁决·续轮放行计下一轮·授权不足 BLOCK·跨 change 隔离',
|
|
13209
|
+
run: (dir) => {
|
|
13210
|
+
const baseHistory = [replanHistoryEvent(1), replanHistoryEvent(2), replanHistoryEvent(3)];
|
|
13211
|
+
const blockedCases = [
|
|
13212
|
+
['超限未续轮', []],
|
|
13213
|
+
['续轮授权轮次不足(n=3 < 已用+1)', ['--continue-round', '3']],
|
|
13214
|
+
];
|
|
13215
|
+
for (const [label, extra] of blockedCases) {
|
|
13216
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
13217
|
+
writeState(dir, replanExecuteState({ history: [...baseHistory], taskHash: REPLAN_STALE_SIGNATURE }));
|
|
13218
|
+
const bytes = readStateBytes(dir);
|
|
13219
|
+
const res = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval', ...extra]);
|
|
13220
|
+
assertExit(res, 1);
|
|
13221
|
+
assertOut(res, 'BLOCKED');
|
|
13222
|
+
assertOut(res, '继续');
|
|
13223
|
+
assertOut(res, '停止');
|
|
13224
|
+
assertStateBytesUnchanged(dir, bytes, label);
|
|
13225
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
13226
|
+
throw new Error(label + ':上限拦截不得产生备份');
|
|
13227
|
+
}
|
|
13228
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 3) {
|
|
13229
|
+
throw new Error(label + ':上限拦截不得追加审计事件');
|
|
13230
|
+
}
|
|
13231
|
+
}
|
|
13232
|
+
// 显式续轮放行:n = 已用 + 1 → 计入第 4 轮(审计行标注续轮)
|
|
13233
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
13234
|
+
writeState(dir, replanExecuteState({ history: [...baseHistory], taskHash: REPLAN_STALE_SIGNATURE }));
|
|
13235
|
+
const continued = runStateWithProtocol(
|
|
13236
|
+
dir, ['replan', '计划缺陷重校(上限后显式续轮)', '--authorized-by', 'admin-approval', '--continue-round', '4']);
|
|
13237
|
+
assertExit(continued, 0);
|
|
13238
|
+
assertOut(continued, 'REPLAN');
|
|
13239
|
+
assertOut(continued, '续轮');
|
|
13240
|
+
const continuedState = readScenarioState(dir);
|
|
13241
|
+
const continuedEvents = replanEventsOf(continuedState);
|
|
13242
|
+
if (continuedEvents.length !== 4) {
|
|
13243
|
+
throw new Error('续轮放行应写入第 4 条 replan-applied 事件,实际 ' + JSON.stringify(continuedEvents.length));
|
|
13244
|
+
}
|
|
13245
|
+
const continuedEvent = continuedEvents[continuedEvents.length - 1];
|
|
13246
|
+
if (continuedEvent.round !== 4 || continuedEvent.change !== CHANGE_ID
|
|
13247
|
+
|| continuedEvent.reason !== '计划缺陷重校(上限后显式续轮)'
|
|
13248
|
+
|| continuedEvent.continuationAuthorized !== true) {
|
|
13249
|
+
throw new Error('续轮审计事件字段不符(round=4 / change / 续轮标记 / reason):' + JSON.stringify(continuedEvent));
|
|
13250
|
+
}
|
|
13251
|
+
const continuedRecord = continuedState.evidence?.execute?.replanAuthorization;
|
|
13252
|
+
if (!continuedRecord || continuedRecord.continuationAuthorized !== true
|
|
13253
|
+
|| continuedRecord.round !== 4 || continuedRecord.source !== 'admin-approval') {
|
|
13254
|
+
throw new Error('续轮授权留痕不符:' + JSON.stringify(continuedRecord));
|
|
13255
|
+
}
|
|
13256
|
+
assertReplanSignatureRecorded(continuedState, REPLAN_TASK_REVISED, '续轮放行');
|
|
13257
|
+
if (replanBackupFiles(dir).length !== 1) {
|
|
13258
|
+
throw new Error('续轮放行应产生一份备份,实际 ' + JSON.stringify(replanBackupFiles(dir)));
|
|
13259
|
+
}
|
|
13260
|
+
// 跨 change 隔离:他 change 的 3 条事件不占本 change 配额 → 本 change 为第 1 轮
|
|
13261
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
13262
|
+
writeState(dir, replanExecuteState({
|
|
13263
|
+
history: [replanHistoryEvent(1, 'other-change'), replanHistoryEvent(2, 'other-change'), replanHistoryEvent(3, 'other-change')],
|
|
13264
|
+
taskHash: REPLAN_STALE_SIGNATURE,
|
|
13265
|
+
}));
|
|
13266
|
+
const isolated = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
13267
|
+
assertExit(isolated, 0);
|
|
13268
|
+
assertOut(isolated, 'REPLAN');
|
|
13269
|
+
assertOut(isolated, '1/3');
|
|
13270
|
+
const isolatedEvent = replanEventsOf(readScenarioState(dir)).find((e) => e.change === CHANGE_ID);
|
|
13271
|
+
if (!isolatedEvent || isolatedEvent.round !== 1) {
|
|
13272
|
+
throw new Error('他 change 的轮次事件不应占用本 change 配额(本 change 应为第 1 轮),实际 '
|
|
13273
|
+
+ JSON.stringify(isolatedEvent));
|
|
13274
|
+
}
|
|
13275
|
+
// 轮次判定纯函数锚(阈值只从实现常量取——本锚同时锁上限 = 3)
|
|
13276
|
+
const roundCount = requireRouteNodeExport('replanRoundCount');
|
|
13277
|
+
if (roundCount({ history: baseHistory, changeName: CHANGE_ID }) !== 3) {
|
|
13278
|
+
throw new Error('replanRoundCount 应统计本 change 的 replan-applied 事件数(3)');
|
|
13279
|
+
}
|
|
13280
|
+
if (roundCount({ history: baseHistory, changeName: 'other-change' }) !== 0) {
|
|
13281
|
+
throw new Error('replanRoundCount 应按 change 过滤(他 change 应为 0)');
|
|
13282
|
+
}
|
|
13283
|
+
if (roundCount({ history: 'corrupted', changeName: CHANGE_ID }) !== 0) {
|
|
13284
|
+
throw new Error('replanRoundCount 对非数组 history 应返回 0(旧 state 形态)');
|
|
13285
|
+
}
|
|
13286
|
+
const roundDecision = requireRouteNodeExport('replanRoundDecision');
|
|
13287
|
+
const available = roundDecision({ history: [replanHistoryEvent(1)], changeName: CHANGE_ID });
|
|
13288
|
+
if (!available || available.ok !== true || available.nextRound !== 2 || available.limit !== 3) {
|
|
13289
|
+
throw new Error('replanRoundDecision 未达上限应放行并给出下一轮:' + JSON.stringify(available));
|
|
13290
|
+
}
|
|
13291
|
+
const capped = roundDecision({ history: baseHistory, changeName: CHANGE_ID });
|
|
13292
|
+
if (!capped || capped.ok !== false || capped.limit !== 3) {
|
|
13293
|
+
throw new Error('replanRoundDecision 达上限且无续轮应 blocked:' + JSON.stringify(capped));
|
|
13294
|
+
}
|
|
13295
|
+
const continuation = roundDecision({ history: baseHistory, changeName: CHANGE_ID, continuationAuthorized: true });
|
|
13296
|
+
if (!continuation || continuation.ok !== true || continuation.nextRound !== 4) {
|
|
13297
|
+
throw new Error('replanRoundDecision 持显式续轮授权应放行第 4 轮:' + JSON.stringify(continuation));
|
|
13298
|
+
}
|
|
13299
|
+
},
|
|
13300
|
+
},
|
|
13301
|
+
|
|
13302
|
+
// 269: replan 幂等空操作(AC-5 / ADR-013 决策 9)——目标形态已成立(state.taskHash 已等于
|
|
13303
|
+
// 当前 TASK.md 签名)时重复调用 = 空操作:可见提示 + 零备份 / 零轮次计数 / 零事件 /
|
|
13304
|
+
// state 字节零改写(与 archive 重入的幂等锚同构)。
|
|
13305
|
+
{
|
|
13306
|
+
name: '269 replan 幂等空操作:重签后重复同形态 → 零备份·零轮次·零事件·零改写',
|
|
13307
|
+
run: (dir) => {
|
|
13308
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
13309
|
+
writeState(dir, replanExecuteState({ taskHash: REPLAN_STALE_SIGNATURE }));
|
|
13310
|
+
const first = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
13311
|
+
assertExit(first, 0);
|
|
13312
|
+
assertOut(first, 'REPLAN');
|
|
13313
|
+
const afterApply = readStateBytes(dir);
|
|
13314
|
+
const appliedState = readScenarioState(dir);
|
|
13315
|
+
if (replanEventsOf(appliedState).length !== 1) {
|
|
13316
|
+
throw new Error('首次重签应恰写 1 条 replan-applied 事件,实际 '
|
|
13317
|
+
+ JSON.stringify(replanEventsOf(appliedState).length));
|
|
13318
|
+
}
|
|
13319
|
+
const backupsAfterApply = replanBackupFiles(dir);
|
|
13320
|
+
if (backupsAfterApply.length !== 1) {
|
|
13321
|
+
throw new Error('首次重签应恰产生一份备份,实际 ' + JSON.stringify(backupsAfterApply));
|
|
13322
|
+
}
|
|
13323
|
+
assertReplanSignatureRecorded(appliedState, REPLAN_TASK_REVISED, '首次重签');
|
|
13324
|
+
// 同形态重复调用 → 空操作(零副作用)
|
|
13325
|
+
const noop = runStateWithProtocol(dir, ['replan', '重复调用同形态', '--authorized-by', 'user-approval']);
|
|
13326
|
+
assertExit(noop, 0);
|
|
13327
|
+
assertOut(noop, '空操作');
|
|
13328
|
+
assertNotOut(noop, 'BLOCKED');
|
|
13329
|
+
assertStateBytesUnchanged(dir, afterApply, '重复同形态空操作');
|
|
13330
|
+
if (!isDeepStrictEqual(replanBackupFiles(dir), backupsAfterApply)) {
|
|
13331
|
+
throw new Error('空操作不得新增备份:' + JSON.stringify(replanBackupFiles(dir)));
|
|
13332
|
+
}
|
|
13333
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 1) {
|
|
13334
|
+
throw new Error('空操作不得写审计事件(history 长度漂移)');
|
|
13335
|
+
}
|
|
13336
|
+
// 空操作判定纯函数存在性锚(T04 编排消费的判定点)
|
|
13337
|
+
requireRouteNodeExport('replanNoOpDecision');
|
|
13338
|
+
},
|
|
13339
|
+
},
|
|
13340
|
+
|
|
13341
|
+
// 270: 重签后 execute 出口放行(AC-1)——entry 后修订任务集(计划外新增并行就绪任务)使
|
|
13342
|
+
// exit execute 撞签名门禁 → replan 重校重签 → 同一出口再跑通过(不再报签名不匹配)→
|
|
13343
|
+
// next 正常路由到委托节点;审计事件 / 授权留痕 / 备份快照齐备,重签值与会话当前 TASK.md 同签。
|
|
13344
|
+
{
|
|
13345
|
+
name: '270 replan 重签后 exit execute --apply 通过:修订任务集(含并行就绪任务)→ 签名 BLOCKED → 重签 → 出口放行',
|
|
13346
|
+
run: (dir) => {
|
|
13347
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_INITIAL);
|
|
13348
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', strictSummary('S01'));
|
|
13349
|
+
// 夹具忠实性修复(协调者授权 A · 夹具缺陷而非放宽带锚):resolveNextNode 的 execute 前
|
|
13350
|
+
// 产物门控按文件存在性判定(不读 completedNodes)——路由到委托节点要求 open / design 的
|
|
13351
|
+
// 前置产物在场。此处补齐 CHANGE.md / REQUIREMENT.md / DESIGN.md(writeIntakeArtifacts
|
|
13352
|
+
// 三件全写,其定义内已含 DESIGN.md),使夹具与真实链路的产物现场一致;不改任何断言 / 锚 /
|
|
13353
|
+
// 判据 / 计数。
|
|
13354
|
+
writeIntakeArtifacts(dir);
|
|
13355
|
+
writeState(dir, replanExecuteState());
|
|
13356
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
13357
|
+
// 任务集修订(#119 死锁现场):新增计划外的并行就绪任务
|
|
13358
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_REVISED);
|
|
13359
|
+
const blockedBytes = readStateBytes(dir);
|
|
13360
|
+
const blocked = runGuard(['exit', 'execute', '--apply'], dir);
|
|
13361
|
+
assertExit(blocked, 1);
|
|
13362
|
+
assertOut(blocked, 'BLOCKED');
|
|
13363
|
+
assertOut(blocked, '签名不匹配');
|
|
13364
|
+
assertStateBytesUnchanged(dir, blockedBytes, '修订任务集后的签名门禁 BLOCK');
|
|
13365
|
+
// 受控重校重签
|
|
13366
|
+
const reason = '计划有缺陷:新增并行任务 P02';
|
|
13367
|
+
const beforeReplan = readScenarioState(dir);
|
|
13368
|
+
const res = runStateWithProtocol(dir, ['replan', reason, '--authorized-by', 'user-approval']);
|
|
13369
|
+
assertExit(res, 0);
|
|
13370
|
+
assertOut(res, 'REPLAN');
|
|
13371
|
+
assertOut(res, 'execute');
|
|
13372
|
+
assertOut(res, '1/3');
|
|
13373
|
+
assertOut(res, 'user-approval');
|
|
13374
|
+
assertOut(res, reason);
|
|
13375
|
+
const st = readScenarioState(dir);
|
|
13376
|
+
// 留痕(双写):history 事件 + evidence.<node>.replanAuthorization
|
|
13377
|
+
const events = replanEventsOf(st);
|
|
13378
|
+
if (events.length !== 1) {
|
|
13379
|
+
throw new Error('重签应恰写 1 条 replan-applied 事件,实际 ' + JSON.stringify(events));
|
|
13380
|
+
}
|
|
13381
|
+
const event = events[0];
|
|
13382
|
+
if (event.change !== CHANGE_ID || event.node !== 'execute' || event.round !== 1
|
|
13383
|
+
|| event.authorizedBy !== 'user-approval' || event.reason !== reason
|
|
13384
|
+
|| typeof event.at !== 'string' || Number.isNaN(Date.parse(event.at))) {
|
|
13385
|
+
throw new Error('replan-applied 事件字段不完整(change / node / round / reason / authorizedBy / at):'
|
|
13386
|
+
+ JSON.stringify(event));
|
|
13387
|
+
}
|
|
13388
|
+
const record = st.evidence?.execute?.replanAuthorization;
|
|
13389
|
+
if (!record || record.source !== 'user-approval' || record.reason !== reason || record.round !== 1
|
|
13390
|
+
|| typeof record.at !== 'string' || record.at.trim() === '') {
|
|
13391
|
+
throw new Error('evidence.execute.replanAuthorization 授权留痕不完整:' + JSON.stringify(record));
|
|
13392
|
+
}
|
|
13393
|
+
// 重签值 = 当前 TASK.md 签名(事件同步记录同一签名)
|
|
13394
|
+
const signed = assertReplanSignatureRecorded(st, REPLAN_TASK_REVISED, '重签');
|
|
13395
|
+
if (!requireRouteNodeExport('sameTaskSetSignature')(event.taskSetSignature, signed)) {
|
|
13396
|
+
throw new Error('replan-applied 事件记录的签名应与 state.taskHash 同签:'
|
|
13397
|
+
+ JSON.stringify({ event: event.taskSetSignature, state: st.taskHash }));
|
|
13398
|
+
}
|
|
13399
|
+
// 转移前备份:全量快照 + sha256 指纹在任何留痕面可核验(ADR-013 决策 7)
|
|
13400
|
+
const backups = replanBackupFiles(dir);
|
|
13401
|
+
if (backups.length !== 1) {
|
|
13402
|
+
throw new Error('重签应恰产生一份备份,实际 ' + JSON.stringify(backups));
|
|
13403
|
+
}
|
|
13404
|
+
if (!/-pre-replan\.json$/.test(backups[0])) {
|
|
13405
|
+
throw new Error('备份命名应为 <UTC ISO>-pre-replan.json,实际 ' + backups[0]);
|
|
13406
|
+
}
|
|
13407
|
+
const backupBytes = fs.readFileSync(path.join(dir, '.specs', CHANGE_ID, 'replan-backups', backups[0]));
|
|
13408
|
+
const backupState = JSON.parse(backupBytes.toString('utf8'));
|
|
13409
|
+
if (!isDeepStrictEqual(backupState, beforeReplan)) {
|
|
13410
|
+
throw new Error('备份应为重签前的 state 全量快照');
|
|
13411
|
+
}
|
|
13412
|
+
const fingerprint = createHash('sha256').update(backupBytes).digest('hex');
|
|
13413
|
+
const haystack = (JSON.stringify(st) + '\n' + outputText(res)).toLowerCase();
|
|
13414
|
+
if (!haystack.includes(fingerprint)) {
|
|
13415
|
+
throw new Error('备份 sha256 指纹未在任何留痕面出现(备份不可核验): ' + fingerprint);
|
|
13416
|
+
}
|
|
13417
|
+
// 同一出口再跑:签名已重签 → 放行;并行就绪任务使 next 路由到委托节点
|
|
13418
|
+
const exitRes = runGuard(['exit', 'execute', '--apply'], dir);
|
|
13419
|
+
assertExit(exitRes, 0);
|
|
13420
|
+
assertOut(exitRes, 'ALL CHECKS PASSED');
|
|
13421
|
+
if (!/^NODE: subagent-execute$/m.test(outputText(exitRes))) {
|
|
13422
|
+
throw new Error('重签后出口应路由到委托节点(并行就绪任务),实际输出:\n' + outputText(exitRes));
|
|
13423
|
+
}
|
|
13424
|
+
const next = runStateWithProtocol(dir, ['next']);
|
|
13425
|
+
assertExit(next, 0);
|
|
13426
|
+
if (!/^NODE: subagent-execute$/m.test(outputText(next))) {
|
|
13427
|
+
throw new Error('next 应正常路由到 subagent-execute,实际输出:\n' + outputText(next));
|
|
13428
|
+
}
|
|
13429
|
+
},
|
|
13430
|
+
},
|
|
13431
|
+
|
|
13432
|
+
// 271: advance 留痕 + 状态可见(AC-4)——advance 仍推进(语义不变),但必须写
|
|
13433
|
+
// history 事件 advance-forced(node + skipped: ['exit:<node>'] + reason: 'advance')并打印
|
|
13434
|
+
// ADVANCE-AUDIT;status 输出派生字段 forcedNodes 以 history 中本 change 的 advance-forced
|
|
13435
|
+
// 事件为准(2026-09-28 PR 审查采纳)——record 后 advance / replanAuthorization 留痕后
|
|
13436
|
+
// advance 两类真实反例都不得漏报;旧 state(无 history 字段)回退「completedNodes 含而
|
|
13437
|
+
// evidence 不含」判据(当时 advance 无痕,无事件可依)。
|
|
13438
|
+
// 正反断言(L-069):被强制推进的节点必现;有出口证据但未被强制的不现。
|
|
13439
|
+
{
|
|
13440
|
+
name: '271 advance 留痕:advance-forced 事件 + status.forcedNodes 派生视图(含反向断言)',
|
|
13441
|
+
run: (dir) => {
|
|
13442
|
+
assertExit(runStateWithProtocol(dir, ['init', CHANGE_ID]), 0);
|
|
13443
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why\n\n推进留痕夹具。\n');
|
|
13444
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md',
|
|
13445
|
+
'# REQUIREMENT\n\n## 用户故事\n\nx\n\n## 验收准则(AC)\n\n- 通过\n');
|
|
13446
|
+
const res = runStateWithProtocol(dir, ['advance']);
|
|
13447
|
+
assertExit(res, 0);
|
|
13448
|
+
assertOut(res, 'Advanced to: design');
|
|
13449
|
+
assertOut(res, 'ADVANCE-AUDIT');
|
|
13450
|
+
assertOut(res, 'open');
|
|
13451
|
+
const st = readScenarioState(dir);
|
|
13452
|
+
const events = (st.history || []).filter((e) => e && e.event === 'advance-forced');
|
|
13453
|
+
if (events.length !== 1) {
|
|
13454
|
+
throw new Error('advance 应恰写 1 条 advance-forced 事件,实际 ' + JSON.stringify(events));
|
|
13455
|
+
}
|
|
13456
|
+
const event = events[0];
|
|
13457
|
+
if (event.change !== CHANGE_ID || event.node !== 'open') {
|
|
13458
|
+
throw new Error('advance-forced 事件应记录 change / 被推进节点,实际 ' + JSON.stringify(event));
|
|
13459
|
+
}
|
|
13460
|
+
if (!isDeepStrictEqual(event.skipped, ['exit:open'])) {
|
|
13461
|
+
throw new Error("advance-forced 事件应记录被跳过的出口门禁 skipped: ['exit:open'],实际 "
|
|
13462
|
+
+ JSON.stringify(event.skipped));
|
|
13463
|
+
}
|
|
13464
|
+
if (event.reason !== 'advance') {
|
|
13465
|
+
throw new Error('advance-forced 事件应记录 reason: \'advance\',实际 ' + JSON.stringify(event.reason));
|
|
13466
|
+
}
|
|
13467
|
+
if (typeof event.at !== 'string' || Number.isNaN(Date.parse(event.at))) {
|
|
13468
|
+
throw new Error('advance-forced 事件应带可解析时间戳,实际 ' + JSON.stringify(event.at));
|
|
13469
|
+
}
|
|
13470
|
+
const status = runStateWithProtocol(dir, ['status']);
|
|
13471
|
+
assertExit(status, 0);
|
|
13472
|
+
const parsed = parseStatusJson(status);
|
|
13473
|
+
if (!Array.isArray(parsed.forcedNodes) || !parsed.forcedNodes.includes('open')) {
|
|
13474
|
+
throw new Error('status.forcedNodes 应包含被强制推进且无出口证据的 open,实际 '
|
|
13475
|
+
+ JSON.stringify(parsed.forcedNodes));
|
|
13476
|
+
}
|
|
13477
|
+
if (parsed.forcedNodes.includes('design')) {
|
|
13478
|
+
throw new Error('status.forcedNodes 只能包含已完成节点,实际 ' + JSON.stringify(parsed.forcedNodes));
|
|
13479
|
+
}
|
|
13480
|
+
// 反向:有出口证据且未被 advance 强制的 completed 节点不得进入 forcedNodes;
|
|
13481
|
+
// 无出口证据但被 advance 强制的节点仍收录(事件判据)。事件派生下「强制」由 history 决定:
|
|
13482
|
+
// 夹具把 advance-forced 事件挂到 design(open 只留 exit 证据),反向断言语义保持不变。
|
|
13483
|
+
const st2 = readScenarioState(dir);
|
|
13484
|
+
st2.completedNodes = ['open', 'design'];
|
|
13485
|
+
st2.currentNode = 'plan';
|
|
13486
|
+
st2.evidence = { ...(st2.evidence || {}), open: { summary: 'open exited' } };
|
|
13487
|
+
st2.history = [advanceForcedEvent('design')];
|
|
13488
|
+
writeState(dir, st2);
|
|
13489
|
+
const status2 = runStateWithProtocol(dir, ['status']);
|
|
13490
|
+
assertExit(status2, 0);
|
|
13491
|
+
const parsed2 = parseStatusJson(status2);
|
|
13492
|
+
if (!Array.isArray(parsed2.forcedNodes) || !parsed2.forcedNodes.includes('design')) {
|
|
13493
|
+
throw new Error('无出口证据的 completed 节点应进入 forcedNodes,实际 ' + JSON.stringify(parsed2.forcedNodes));
|
|
13494
|
+
}
|
|
13495
|
+
if (parsed2.forcedNodes.includes('open')) {
|
|
13496
|
+
throw new Error('有出口证据的 completed 节点不得进入 forcedNodes,实际 ' + JSON.stringify(parsed2.forcedNodes));
|
|
13497
|
+
}
|
|
13498
|
+
// (i) 有 record 出口证据且被 advance 强制 → 必须出现(旧「缺 evidence」推断会漏报)
|
|
13499
|
+
const stRecord = replanExecuteState({
|
|
13500
|
+
completedNodes: ['open', 'design'],
|
|
13501
|
+
currentNode: 'plan',
|
|
13502
|
+
evidence: { open: { summary: 'record 出口证据(advance 事件之外的真实证据)' } },
|
|
13503
|
+
history: [advanceForcedEvent('open')],
|
|
13504
|
+
});
|
|
13505
|
+
writeState(dir, stRecord);
|
|
13506
|
+
const statusRecord = runStateWithProtocol(dir, ['status']);
|
|
13507
|
+
assertExit(statusRecord, 0);
|
|
13508
|
+
const parsedRecord = parseStatusJson(statusRecord);
|
|
13509
|
+
const failures271 = [];
|
|
13510
|
+
if (!Array.isArray(parsedRecord.forcedNodes) || !parsedRecord.forcedNodes.includes('open')) {
|
|
13511
|
+
failures271.push('(i) 有 record 证据且被 advance 强制的 open 应进入 forcedNodes,实际 '
|
|
13512
|
+
+ JSON.stringify(parsedRecord.forcedNodes));
|
|
13513
|
+
}
|
|
13514
|
+
// (ii) 只有 replanAuthorization 授权留痕且被 advance 强制 → 必须出现(旧对象判据会漏报)
|
|
13515
|
+
const stAuth = replanExecuteState({
|
|
13516
|
+
completedNodes: ['open', 'design'],
|
|
13517
|
+
currentNode: 'plan',
|
|
13518
|
+
evidence: {
|
|
13519
|
+
open: { summary: 'open exited' },
|
|
13520
|
+
design: {
|
|
13521
|
+
replanAuthorization: {
|
|
13522
|
+
round: 1,
|
|
13523
|
+
at: '2026-09-28T00:00:00.000Z',
|
|
13524
|
+
source: 'user',
|
|
13525
|
+
reason: '计划重校',
|
|
13526
|
+
backup: '.specs/' + CHANGE_ID + '/replan-backups/x.json',
|
|
13527
|
+
fingerprint: '0'.repeat(64),
|
|
13528
|
+
},
|
|
13529
|
+
},
|
|
13530
|
+
},
|
|
13531
|
+
history: [advanceForcedEvent('design')],
|
|
13532
|
+
});
|
|
13533
|
+
writeState(dir, stAuth);
|
|
13534
|
+
const statusAuth = runStateWithProtocol(dir, ['status']);
|
|
13535
|
+
assertExit(statusAuth, 0);
|
|
13536
|
+
const parsedAuth = parseStatusJson(statusAuth);
|
|
13537
|
+
if (!Array.isArray(parsedAuth.forcedNodes) || !parsedAuth.forcedNodes.includes('design')) {
|
|
13538
|
+
failures271.push('(ii) 仅有 replanAuthorization 留痕且被 advance 强制的 design 应进入 forcedNodes,实际 '
|
|
13539
|
+
+ JSON.stringify(parsedAuth.forcedNodes));
|
|
13540
|
+
}
|
|
13541
|
+
// (iv) 旧 state(无 history 字段)→ 回退「缺 evidence」判据仍生效
|
|
13542
|
+
const stLegacy = replanExecuteState({
|
|
13543
|
+
completedNodes: ['open', 'design'],
|
|
13544
|
+
currentNode: 'plan',
|
|
13545
|
+
evidence: { open: { summary: 'open exited' } },
|
|
13546
|
+
});
|
|
13547
|
+
delete stLegacy.history;
|
|
13548
|
+
writeState(dir, stLegacy);
|
|
13549
|
+
const statusLegacy = runStateWithProtocol(dir, ['status']);
|
|
13550
|
+
assertExit(statusLegacy, 0);
|
|
13551
|
+
const parsedLegacy = parseStatusJson(statusLegacy);
|
|
13552
|
+
if (!Array.isArray(parsedLegacy.forcedNodes) || !parsedLegacy.forcedNodes.includes('design')) {
|
|
13553
|
+
failures271.push('(iv) 旧 state(无 history)应回退缺 evidence 判据:design 应在 forcedNodes,实际 '
|
|
13554
|
+
+ JSON.stringify(parsedLegacy.forcedNodes));
|
|
13555
|
+
}
|
|
13556
|
+
if (parsedLegacy.forcedNodes.includes('open')) {
|
|
13557
|
+
failures271.push('(iv) 旧 state(无 history)有出口证据的 open 不得进入 forcedNodes,实际 '
|
|
13558
|
+
+ JSON.stringify(parsedLegacy.forcedNodes));
|
|
13559
|
+
}
|
|
13560
|
+
if (failures271.length > 0) {
|
|
13561
|
+
throw new Error('advance-forced 事件派生判据失败: ' + failures271.join(' | '));
|
|
13562
|
+
}
|
|
13563
|
+
},
|
|
13564
|
+
},
|
|
13565
|
+
|
|
13566
|
+
// 274: M6 收窄——空退出豁免仅适用于「无任何串行任务」的全并行 change;含串行任务
|
|
13567
|
+
// (parallel="false"/缺省,无论 pending/done)时豁免不生效,产物校验照常执行。
|
|
13568
|
+
// 夹具用旧 change 语义(无 newChange):done 缺 SUMMARY 在 M2 只 WARN → 放行与否
|
|
13569
|
+
// 唯一取决于 M6 是否跳过 task-summaries 产物校验(隔离判据;新 change 由 M2 硬门先行,
|
|
13570
|
+
// 无法观察 M6 行为)。修复前 emptyExitApproved 无条件跳过 → exit 0(本场景 RED)。
|
|
13571
|
+
{
|
|
13572
|
+
name: '274 execute exit BLOCKED:含串行任务的 change 空退出豁免不生效(M6 收窄)',
|
|
13573
|
+
run: (dir) => {
|
|
13574
|
+
const st = baseState('execute');
|
|
13575
|
+
st.evidence.execute = { summary: '陈旧空退出标记', emptyExitApproved: true };
|
|
13576
|
+
st.evidence['subagent-execute'] = { handoffResult: handoffFor(['T01']) };
|
|
13577
|
+
writeState(dir, st);
|
|
13578
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
13579
|
+
'# TASK\n\n<task id="T01" parallel="false" status="done"><action>串行任务已完成但缺 SUMMARY</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n');
|
|
13580
|
+
const res = runGuard(['exit', 'execute', '--apply'], dir);
|
|
13581
|
+
assertExit(res, 1);
|
|
13582
|
+
assertOut(res, 'BLOCKED');
|
|
13583
|
+
assertOut(res, 'task-summaries');
|
|
13584
|
+
assertOut(res, 'EMPTY-EXIT 未生效');
|
|
13585
|
+
assertNotOut(res, '豁免已生效');
|
|
13586
|
+
// 反向子锚:全并行 change 时豁免仍生效,且输出被跳过项清单(补既有全 parallel 通过锚)
|
|
13587
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
13588
|
+
'# TASK\n\n<task id="P01" parallel="true" status="pending"><action>并行任务</action><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify></task>\n');
|
|
13589
|
+
const resParallel = runGuard(['exit', 'execute', '--apply'], dir);
|
|
13590
|
+
assertExit(resParallel, 0);
|
|
13591
|
+
assertOut(resParallel, '豁免已生效');
|
|
13592
|
+
assertOut(resParallel, 'EMPTY-EXIT-SKIPPED');
|
|
13593
|
+
},
|
|
13594
|
+
},
|
|
13595
|
+
// 275: replan 任务内容缺失 fail-closed(引擎既有分支的回归锚)——TASK.md 不存在 / 为空(0 字节)
|
|
13596
|
+
// 时,真实 CLI 的 replan 必须 BLOCKED、消息给出 fail-closed 指引,且 state 字节零改写、零备份、
|
|
13597
|
+
// 零审计事件(判定必须先于任何写盘;不得以「空任务集签名」判幂等空操作放行)。纯空白是边界:
|
|
13598
|
+
// 非空串不落 task-content-missing,但同样 fail-closed 拒绝重签(无 <task> 块)。对照:同一夹具
|
|
13599
|
+
// 下 TASK.md 恢复为可解析任务集 → replan 放行(证明 BLOCK 来自内容缺失而非夹具畸形)。
|
|
13600
|
+
{
|
|
13601
|
+
name: '275 replan 任务内容缺失/为空 → BLOCKED fail-closed 零改写(含放行对照)',
|
|
13602
|
+
run: (dir) => {
|
|
13603
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n\n## Why\n\n任务内容缺失回归锚。\n');
|
|
13604
|
+
writeState(dir, replanExecuteState({ taskHash: REPLAN_STALE_SIGNATURE }));
|
|
13605
|
+
const beforeBytes = readStateBytes(dir);
|
|
13606
|
+
const blockedCases = [
|
|
13607
|
+
['TASK.md 缺失', null],
|
|
13608
|
+
['TASK.md 为空(0 字节)', ''],
|
|
13609
|
+
];
|
|
13610
|
+
for (const [label, content] of blockedCases) {
|
|
13611
|
+
if (content === null) {
|
|
13612
|
+
fs.rmSync(path.join(dir, '.specs', CHANGE_ID, 'TASK.md'), { force: true });
|
|
13613
|
+
} else {
|
|
13614
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', content);
|
|
13615
|
+
}
|
|
13616
|
+
const res = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
13617
|
+
assertExit(res, 1);
|
|
13618
|
+
assertOut(res, 'BLOCKED');
|
|
13619
|
+
assertOut(res, '任务内容缺失');
|
|
13620
|
+
assertOut(res, 'fail-closed');
|
|
13621
|
+
assertOut(res, 'TASK.md');
|
|
13622
|
+
assertStateBytesUnchanged(dir, beforeBytes, label);
|
|
13623
|
+
}
|
|
13624
|
+
// 边界:纯空白非空串 → 不落 task-content-missing,但同样拒绝重签(无 <task> 块),零改写
|
|
13625
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', ' \n');
|
|
13626
|
+
const blank = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
13627
|
+
assertExit(blank, 1);
|
|
13628
|
+
assertOut(blank, 'BLOCKED');
|
|
13629
|
+
assertOut(blank, '无 <task> 块');
|
|
13630
|
+
assertOut(blank, '零改写');
|
|
13631
|
+
assertStateBytesUnchanged(dir, beforeBytes, 'TASK.md 纯空白');
|
|
13632
|
+
// 三条 BLOCK 路径都不得产生备份 / 审计事件(写盘前拦截)
|
|
13633
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
13634
|
+
throw new Error('内容缺失路径不得产生备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
13635
|
+
}
|
|
13636
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 0) {
|
|
13637
|
+
throw new Error('内容缺失路径不得写审计事件: ' + JSON.stringify(replanEventsOf(readScenarioState(dir))));
|
|
13638
|
+
}
|
|
13639
|
+
// 放行对照:同夹具下 TASK.md 可解析 → replan 真实重签成功(判别力:BLOCK 不是夹具畸形导致)
|
|
13640
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', REPLAN_TASK_INITIAL);
|
|
13641
|
+
const ok = runStateWithProtocol(dir, ['replan', '计划缺陷重校', '--authorized-by', 'user-approval']);
|
|
13642
|
+
assertExit(ok, 0);
|
|
13643
|
+
assertOut(ok, 'REPLAN');
|
|
13644
|
+
if (replanEventsOf(readScenarioState(dir)).length !== 1) {
|
|
13645
|
+
throw new Error('放行对照应恰写 1 条 replan-applied 事件');
|
|
13646
|
+
}
|
|
13647
|
+
},
|
|
13648
|
+
},
|
|
11469
13649
|
];
|
|
11470
13650
|
// ---------- 运行 ----------
|
|
11471
13651
|
|
|
@@ -11477,7 +13657,7 @@ for (const sc of SCENARIOS) {
|
|
|
11477
13657
|
// 场景 runRoot=tmpdir、内置协议默认路径在 packageRoot(tmpdir 外)→ 复制到 <dir>/reference/ 内,
|
|
11478
13658
|
// 由 runGuard 的 FLOW_COMET_PROTOCOL env 指向场景内副本。场景内 writeFile('reference/...') 或
|
|
11479
13659
|
// --protocol CLI 覆盖保持后写优先语义(CLI --protocol 优先级高于 env)。
|
|
11480
|
-
const builtinCopy =
|
|
13660
|
+
const builtinCopy = scenarioProtocolPath(dir);
|
|
11481
13661
|
fs.mkdirSync(path.dirname(builtinCopy), { recursive: true });
|
|
11482
13662
|
fs.copyFileSync(BUILTIN_PROTOCOL_SOURCE, builtinCopy);
|
|
11483
13663
|
await sc.run(dir);
|
|
@@ -11487,7 +13667,8 @@ for (const sc of SCENARIOS) {
|
|
|
11487
13667
|
failures.push({ name: sc.name, error: e.message });
|
|
11488
13668
|
console.error('FAIL: ' + sc.name + '\n' + e.message);
|
|
11489
13669
|
} finally {
|
|
11490
|
-
|
|
13670
|
+
// 清理失败不抛(见 cleanupTmpDir 注释):残留由末尾判据报告,避免整轮崩
|
|
13671
|
+
cleanupTmpDir(dir);
|
|
11491
13672
|
}
|
|
11492
13673
|
}
|
|
11493
13674
|
|
|
@@ -11499,6 +13680,17 @@ console.log('RESULT: ' + passed + '/' + SCENARIOS.length + ' scenarios passed');
|
|
|
11499
13680
|
// ② 公开产物零代号:公开文档不得含过程代号(场景编号/修复编号/批次/缺陷编号/问题级/验证代号/验证轮次/未公开概念——历史 CHANGELOG 回归实证)。
|
|
11500
13681
|
// 仅权威源检出执行;安装副本(目标项目)无 flow-comet 文档面,跳过。
|
|
11501
13682
|
if (isAuthoritativeSourceRepo()) {
|
|
13683
|
+
// ①a 受检面可见化(F2 防漂移):实际受检文件数由模块级常量**推导**、不硬编码——分发组 =
|
|
13684
|
+
// SCENARIO_COUNT_FILES ∪ SYSTEM_TEST_COUNT_FILES(后者为前者子集),维护者组 =
|
|
13685
|
+
// SCENARIO_COUNT_FILES_MAINTAINER ∪ SYSTEM_TEST_COUNT_FILES_MAINTAINER(后者为前者子集);
|
|
13686
|
+
// 维护者面缺席(CI 全新检出 / worktree)时按组跳过语义只计分发面。本行是对外可复核的
|
|
13687
|
+
// 「覆盖面事实」——清单增删/口径漂移在此直接可见,不再依赖人工核对注释(F2 根因)。
|
|
13688
|
+
const distFaceCount = new Set([...SCENARIO_COUNT_FILES, ...SYSTEM_TEST_COUNT_FILES]).size;
|
|
13689
|
+
const maintainerFaceCount = maintainerFacePresent()
|
|
13690
|
+
? new Set([...SCENARIO_COUNT_FILES_MAINTAINER, ...SYSTEM_TEST_COUNT_FILES_MAINTAINER]).size
|
|
13691
|
+
: 0;
|
|
13692
|
+
console.log('受检面: ' + (distFaceCount + maintainerFaceCount) + ' 文件(分发 ' + distFaceCount
|
|
13693
|
+
+ ' + 维护者 ' + maintainerFaceCount + ')');
|
|
11502
13694
|
// ① 计数一致性受检清单(分发组恒检 + 维护者组整组在场时检;判据与场景 105 共用同一实现)
|
|
11503
13695
|
// SCENARIO_COUNT_FILES(_MAINTAINER) / SYSTEM_TEST_COUNT_FILES(_MAINTAINER) 为模块级常量
|
|
11504
13696
|
// (见文件头定义)——场景数与系统测试集项数两套计数合并检查
|
|
@@ -11513,22 +13705,27 @@ if (isAuthoritativeSourceRepo()) {
|
|
|
11513
13705
|
console.error('FAIL: 维护文档机检\n' + problem);
|
|
11514
13706
|
}
|
|
11515
13707
|
|
|
13708
|
+
// ①c 维护者面缺席可见化:结构性缺席(worktree / CI 全新检出)不判失败(退出码不变、不误红),
|
|
13709
|
+
// 但必须可见——逐面输出 SKIP 行(面名 + 原因 + 本检出未执行什么校验 + 回维护者主树重跑的指引)。
|
|
13710
|
+
for (const skip of maintainerFaceSkips()) {
|
|
13711
|
+
console.log('SKIP: ' + skip.face + ' — ' + skip.reason
|
|
13712
|
+
+ ';本次检出未执行该面校验,请在维护者主树重跑本套件(主树 L1),勿把跳过当成已校验。');
|
|
13713
|
+
}
|
|
13714
|
+
|
|
11516
13715
|
// ② 公开文档零代号(公开产物纪律——CHANGELOG 历史 S 编号回归的教训,2026-08-10)
|
|
11517
13716
|
const PUBLIC_DOCS = [
|
|
11518
13717
|
'README.md', 'README-zh.md', 'CONTRIBUTING.md', 'CONTRIBUTING-zh.md',
|
|
11519
13718
|
'SECURITY.md', 'SECURITY-zh.md', 'CODE_OF_CONDUCT.md', 'CODE_OF_CONDUCT-zh.md',
|
|
11520
13719
|
'CHANGELOG.md', 'CHANGELOG-zh.md',
|
|
11521
13720
|
'docs/INSTALLATION.md', 'docs/INSTALLATION-zh.md', 'docs/MECHANISM.md', 'docs/MECHANISM-zh.md',
|
|
11522
|
-
'docs/USAGE.md', 'docs/USAGE-zh.md',
|
|
13721
|
+
'docs/USAGE.md', 'docs/USAGE-zh.md',
|
|
11523
13722
|
'docs/TROUBLESHOOTING.md', 'docs/TROUBLESHOOTING-zh.md', 'docs/VERSIONS.md', 'docs/VERSIONS-zh.md',
|
|
11524
|
-
'docs/ECOSYSTEM.md', 'docs/ECOSYSTEM-zh.md',
|
|
11525
13723
|
'.github/PULL_REQUEST_TEMPLATE.md',
|
|
11526
13724
|
'.github/ISSUE_TEMPLATE/1-bug_report.yml', '.github/ISSUE_TEMPLATE/2-feature_request.yml',
|
|
11527
13725
|
'.github/ISSUE_TEMPLATE/3-question.md', '.github/ISSUE_TEMPLATE/4-task.md',
|
|
11528
13726
|
];
|
|
11529
|
-
//
|
|
11530
|
-
//
|
|
11531
|
-
const INTERNAL_CODE_RE = /\bS\d{1,3}\b|T-FIX|batch-(?![a-z])|D-\d+|P[0-7]\b|round\s*\d|dogfood|内部/;
|
|
13727
|
+
// 词表判据 = 模块级 PUBLIC_CODE_RE(与 .githooks/internal-codes.mjs 的 BANNED 同判据,
|
|
13728
|
+
// 见其定义处的同步约定;维护文档机检场景族另有该判据的判别力/边界锚)。
|
|
11532
13729
|
for (const rel of PUBLIC_DOCS) {
|
|
11533
13730
|
let text;
|
|
11534
13731
|
try {
|
|
@@ -11540,15 +13737,36 @@ if (isAuthoritativeSourceRepo()) {
|
|
|
11540
13737
|
console.error('FAIL: 公开产物零代号(' + rel + ')\n文件缺失: ' + e.message);
|
|
11541
13738
|
continue;
|
|
11542
13739
|
}
|
|
11543
|
-
const m = text.match(
|
|
13740
|
+
const m = text.match(PUBLIC_CODE_RE);
|
|
11544
13741
|
if (m) {
|
|
11545
13742
|
failures.push({ name: '公开产物零代号(' + rel + ')', error: rel + ' 含过程代号: "' + m[0] + '"' });
|
|
11546
13743
|
console.error('FAIL: 公开产物零代号(' + rel + ')\n' + rel + ' 含过程代号: "' + m[0] + '"');
|
|
11547
13744
|
}
|
|
11548
13745
|
}
|
|
13746
|
+
|
|
13747
|
+
// ③ 词表镜像漂移(L-067 收口):主仓私有的词表单一来源与套件内的同义镜像必须**逐字符
|
|
13748
|
+
// 等价**——两侧此前只有注释互指"同步"、零一致性判据:主仓增补模式时分发侧扫描静默落后
|
|
13749
|
+
// (新词可在公开面长期存活而套件全绿),反向则分发面误红。判据只读文件、不改任何判定语义。
|
|
13750
|
+
for (const problem of vocabularyMirrorProblems()) {
|
|
13751
|
+
failures.push({ name: '词表镜像漂移', error: problem });
|
|
13752
|
+
console.error('FAIL: 词表镜像漂移\n' + problem);
|
|
13753
|
+
}
|
|
13754
|
+
} else {
|
|
13755
|
+
// 安装副本形态:.githooks 是主仓私有面(随 clone 不分发)→ 该判据**不适用**。结构性缺席
|
|
13756
|
+
// 不判失败(退出码不变、不误红),但必须显式可见——未验证 ≠ 通过,不得静默跳过。
|
|
13757
|
+
console.log('SKIP/NOT-APPLICABLE: 词表镜像漂移判据(.githooks 为主仓私有面)'
|
|
13758
|
+
+ ';本次检出无该私有面,未执行「词表单一来源 ↔ 套件同义镜像」的逐字符等价性比对'
|
|
13759
|
+
+ '——请在主仓私有面在场处重跑本套件(主树 L1),勿把不适用当成已校验。');
|
|
11549
13760
|
}
|
|
11550
13761
|
|
|
11551
13762
|
// 清理验证:自测套件自身创建的临时目录不留残留
|
|
13763
|
+
// 先做一次延迟重试:跨场景仍被占用的句柄(子进程退出、扫描器)可能晚于最后一个场景的清理才释放。
|
|
13764
|
+
// 只等**一次**(不是每个残留目录各等一次),再逐个重试;随后由下方单一判定点统一报告。
|
|
13765
|
+
const remainingDirs = createdDirs.filter((d) => fs.existsSync(d));
|
|
13766
|
+
if (remainingDirs.length > 0) {
|
|
13767
|
+
sleepSync(300);
|
|
13768
|
+
for (const d of remainingDirs) cleanupTmpDir(d);
|
|
13769
|
+
}
|
|
11552
13770
|
const residue = createdDirs.filter((d) => fs.existsSync(d));
|
|
11553
13771
|
if (residue.length > 0) {
|
|
11554
13772
|
failures.push({ name: '临时目录清理', error: '残留目录: ' + residue.join(', ') });
|