flow-comet 1.6.2 → 1.6.4
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/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/SKILL.md +64 -46
- package/.flow-comet/skills/flow-comet/reference/KNOWN-ISSUES-template.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/commit-discipline.md +32 -0
- package/.flow-comet/skills/flow-comet/reference/dirty-worktree.md +1 -1
- package/.flow-comet/skills/flow-comet/{GUIDANCE.md → reference/entry-detail.md} +18 -28
- package/.flow-comet/skills/flow-comet/reference/fix-loop.md +57 -0
- package/.flow-comet/skills/flow-comet/reference/platform-facts.md +58 -0
- package/.flow-comet/skills/flow-comet/reference/replan.md +23 -0
- package/.flow-comet/skills/flow-comet/scripts/comet-check.mjs +5 -4
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +266 -25
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/evolve.mjs +6 -6
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +67 -16325
- package/.flow-comet/skills/flow-comet/scripts/health.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +1030 -0
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +830 -0
- package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +781 -0
- package/.flow-comet/skills/flow-comet/scripts/items/d.mjs +99 -0
- package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +185 -0
- package/.flow-comet/skills/flow-comet/scripts/items/f.mjs +90 -0
- package/.flow-comet/skills/flow-comet/scripts/items/g.mjs +59 -0
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +815 -0
- package/.flow-comet/skills/flow-comet/scripts/items/i.mjs +77 -0
- package/.flow-comet/skills/flow-comet/scripts/items/j.mjs +75 -0
- package/.flow-comet/skills/flow-comet/scripts/items/k.mjs +1427 -0
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +275 -0
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +614 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/count-derivation.mjs +97 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/fix-loop-node.mjs +196 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +553 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +837 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +404 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-state-io.mjs +404 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +302 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +133 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/reentry-node.mjs +237 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/replan-node.mjs +209 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-branch.mjs +49 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-bridgecheck.mjs +201 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +141 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +700 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +578 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-determine.mjs +52 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-evolve-hint.mjs +55 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +106 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-intelscan.mjs +58 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +147 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +189 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +1441 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/task-graph.mjs +471 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-assertions.mjs +509 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +1228 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +237 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +2484 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +73 -1077
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +966 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +1233 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +1382 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +483 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +1388 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +1466 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +1364 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/h.mjs +1287 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +1436 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +1384 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +1338 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +1484 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +971 -0
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +14 -1
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +58 -6692
- package/.flow-comet/skills/flow-comet/scripts/time-utils.mjs +4 -4
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +151 -2428
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +116 -9
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +29 -2086
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +10 -19
- package/.flow-comet/skills/flow-comet-change/SKILL.md +2 -3
- package/.flow-comet/skills/flow-comet-compose/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-design/SKILL.md +6 -6
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +58 -16
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +8 -5
- package/.flow-comet/skills/flow-comet-open/SKILL.md +5 -1
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +1 -1
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +8 -8
- package/.flow-comet/skills/flow-comet-review/SKILL.md +9 -12
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +59 -16
- package/.flow-comet/skills/flow-comet-task/SKILL.md +3 -2
- package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +3 -3
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +8 -17
- package/README.md +53 -70
- package/package.json +3 -2
- package/scripts/dsh-bridge.mjs +59 -26
- package/scripts/lib/installer-cleanup.mjs +152 -0
- package/scripts/lib/installer-flowkit.mjs +119 -0
- package/scripts/lib/installer-hooks.mjs +363 -0
- package/scripts/lib/installer-loader.mjs +220 -0
- package/scripts/lib/installer-migrate.mjs +236 -0
- package/scripts/lib/installer-platforms.mjs +314 -0
- package/scripts/prepare-env.mjs +36 -1164
- package/.flow-comet/skills/flow-comet/reference/TEST-MATRIX.md +0 -116
- package/.flow-comet/skills/flow-comet/reference/composition-report.md +0 -65
- package/.flow-comet/skills/flow-comet/reference/dsh-platform.md +0 -184
- package/.flow-comet/skills/flow-comet/reference/resolved-skills.json +0 -661
- package/.flow-comet/skills/flow-comet/reference/skill-review.md +0 -13
- package/.flow-comet/skills/flow-comet/reference/subagents/script-author.md +0 -7
- package/.flow-comet/skills/flow-comet/reference/worktree-notes.md +0 -70
|
@@ -0,0 +1,1466 @@
|
|
|
1
|
+
// 场景组 f — 多趟路由核心 · 出口硬化 · 技能文本锁
|
|
2
|
+
// 元素形态:`{ name, run }`;计数由 `lib/count-derivation.mjs` 从本目录聚合,不手抄数字。
|
|
3
|
+
// 组界按场景名前缀与文件内既有分段划,与入口 `SCENARIOS` 的拼接顺序一致。
|
|
4
|
+
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { execFileSync, spawnSync } from 'child_process';
|
|
8
|
+
import {
|
|
9
|
+
assertExit,
|
|
10
|
+
assertNotOut,
|
|
11
|
+
assertOut,
|
|
12
|
+
baseState,
|
|
13
|
+
runGuard,
|
|
14
|
+
runHandoff,
|
|
15
|
+
writeFile,
|
|
16
|
+
writeState,
|
|
17
|
+
} from '../lib/test-helpers.mjs';
|
|
18
|
+
import {
|
|
19
|
+
CHANGE_ID,
|
|
20
|
+
HOOK,
|
|
21
|
+
REPO_ROOT,
|
|
22
|
+
SCRIPTS_DIR,
|
|
23
|
+
TASK_P1,
|
|
24
|
+
TASK_P2,
|
|
25
|
+
TASK_P2_PENDING,
|
|
26
|
+
TASK_VALID_ALL_SERIAL,
|
|
27
|
+
TASK_VALID_PS,
|
|
28
|
+
TASK_VALID_SP,
|
|
29
|
+
engineDefinitionHits,
|
|
30
|
+
engineDefinitionModule,
|
|
31
|
+
handoffFor,
|
|
32
|
+
renderMultiWaveTasks,
|
|
33
|
+
runPlanExit,
|
|
34
|
+
skillTreeDocFiles,
|
|
35
|
+
summaryContent,
|
|
36
|
+
writeIntakeArtifacts,
|
|
37
|
+
} from '../lib/test-fixtures.mjs';
|
|
38
|
+
import {
|
|
39
|
+
runStateWithProtocol,
|
|
40
|
+
scenarioProtocolPath,
|
|
41
|
+
} from '../lib/test-assertions.mjs';
|
|
42
|
+
import {
|
|
43
|
+
COMMIT_DISCIPLINE_AUTHORITY_PHRASES,
|
|
44
|
+
COMMIT_DISCIPLINE_ELEMENT_GROUPS,
|
|
45
|
+
COMMIT_DISCIPLINE_REL,
|
|
46
|
+
CONTRACT_EVIDENCE_AUTHORITY_PHRASES,
|
|
47
|
+
DELEGATION_POINTER_RELS,
|
|
48
|
+
IDENTITY_UPGRADE_AUTHORITY_PHRASES,
|
|
49
|
+
IDENTITY_UPGRADE_ENTRY_PHRASES,
|
|
50
|
+
IDENTITY_UPGRADE_STALE_PHRASES,
|
|
51
|
+
PAIRED_GUIDANCE_ENTRY_REL,
|
|
52
|
+
PAIRED_GUIDANCE_ENTRY_TARGET,
|
|
53
|
+
PAIRED_GUIDANCE_POINTER_RE,
|
|
54
|
+
PARALLEL_CONTRACT_BOOK_PHRASES,
|
|
55
|
+
PLATFORM_FACTS_ONLY_PHRASES,
|
|
56
|
+
PLATFORM_FACTS_REL,
|
|
57
|
+
SKILL_TREE_ENTRY_BOOK,
|
|
58
|
+
SKILL_TREE_EXPLICIT_REFERENCE_PREFIX,
|
|
59
|
+
SKILL_TREE_REFERENCE_RE,
|
|
60
|
+
TEMPLATE_AUTHORITY_SKILLS,
|
|
61
|
+
delegationDisciplineProblems,
|
|
62
|
+
identityUpgradeProblems,
|
|
63
|
+
pairedGuidancePointerProblems,
|
|
64
|
+
platformFactsAuthorityProblems,
|
|
65
|
+
skillTreeReferenceProblems,
|
|
66
|
+
task7SetAnchorProblems,
|
|
67
|
+
templateAuthorityBody,
|
|
68
|
+
templateAuthorityParagraphs,
|
|
69
|
+
templateAuthorityProblems,
|
|
70
|
+
templateAuthorityRegistrationProblems,
|
|
71
|
+
} from '../lib/text-anchor-checks.mjs';
|
|
72
|
+
|
|
73
|
+
export const ENTRIES = [
|
|
74
|
+
|
|
75
|
+
// ---------- 场景(多趟路由核心——多趟推进完成 / 零进展防呆 / 委托节点二次进入完成判定 / 向后兼容等价) ----------
|
|
76
|
+
|
|
77
|
+
// 172: 多波混合推进完成(AC-1/AC-2)——多波混合 TASK 经 next 分趟自动路由直至清空:
|
|
78
|
+
// 无 eligible 并行时回串行消化(execute);依赖满足即再入 subagent-execute(第二趟——
|
|
79
|
+
// completedNodes 已含该节点仍路由回 = 多趟循环路由);全部 done 后经产物门控进 review。
|
|
80
|
+
// 旧引擎单趟限制下第三步会停留在 execute = 预期 RED。
|
|
81
|
+
{
|
|
82
|
+
name: '172 多波混合推进完成:分趟自动路由直至清空进 review',
|
|
83
|
+
run: (dir) => {
|
|
84
|
+
writeIntakeArtifacts(dir);
|
|
85
|
+
const goNext = (currentNode, doneIds, completedExtra = []) => {
|
|
86
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + renderMultiWaveTasks(doneIds));
|
|
87
|
+
writeState(dir, {
|
|
88
|
+
activeChange: CHANGE_ID,
|
|
89
|
+
currentNode,
|
|
90
|
+
completedNodes: ['open', 'design', 'plan', ...completedExtra],
|
|
91
|
+
evidence: {
|
|
92
|
+
open: { summary: 'o' },
|
|
93
|
+
design: { summary: 'd' },
|
|
94
|
+
plan: { summary: 'p' },
|
|
95
|
+
...(completedExtra.includes('subagent-execute') ? { 'subagent-execute': { summary: 'wave delegated' } } : {}),
|
|
96
|
+
...(completedExtra.includes('execute') ? { execute: { summary: 'serial digested' } } : {}),
|
|
97
|
+
},
|
|
98
|
+
verifyFailures: 0,
|
|
99
|
+
executionMode: 'subagent',
|
|
100
|
+
directOverride: false,
|
|
101
|
+
});
|
|
102
|
+
return runStateWithProtocol(dir, ['next']);
|
|
103
|
+
};
|
|
104
|
+
// 趟 0:无可委托并行(P 波依赖 T01 未完成)、串行 T01 pending → execute
|
|
105
|
+
let res = goNext('execute', []);
|
|
106
|
+
assertExit(res, 0);
|
|
107
|
+
assertOut(res, 'NODE: execute');
|
|
108
|
+
// 趟 1:T01 done → P01/P02 eligible → 第一趟委托
|
|
109
|
+
res = goNext('execute', ['T01']);
|
|
110
|
+
assertExit(res, 0);
|
|
111
|
+
assertOut(res, 'NODE: subagent-execute');
|
|
112
|
+
// 趟间:P01/P02 done(第一趟委托收集完成)→ 回 execute 消化 T02(第二波未满足不抢跑)
|
|
113
|
+
res = goNext('subagent-execute', ['T01', 'P01', 'P02'], ['subagent-execute']);
|
|
114
|
+
assertExit(res, 0);
|
|
115
|
+
assertOut(res, 'NODE: execute');
|
|
116
|
+
// 趟 2(多趟关键断言):T02 done → P03/P04 eligible → 第二趟再入 subagent-execute
|
|
117
|
+
//(真实链路中此处由 execute exit --apply 的平行路由镜像直接落点;next 级断言同一谓词)
|
|
118
|
+
res = goNext('subagent-execute', ['T01', 'P01', 'P02', 'T02'], ['subagent-execute', 'execute']);
|
|
119
|
+
assertExit(res, 0);
|
|
120
|
+
assertOut(res, 'NODE: subagent-execute');
|
|
121
|
+
// 清空:全部 done + SUMMARY 在场 → 委托与串行均无残留 → review(产物门控照旧)。
|
|
122
|
+
// 状态取真实链路形态:completedNodes 按路由序排列(末元素 = subagent-execute,
|
|
123
|
+
// 其 exit --apply 已把 currentNode 推到 review——正常推进豁免放行 next)
|
|
124
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', summaryContent());
|
|
125
|
+
res = goNext('review', ['T01', 'P01', 'P02', 'T02', 'P03', 'P04'], ['execute', 'subagent-execute']);
|
|
126
|
+
assertExit(res, 0);
|
|
127
|
+
assertOut(res, 'NODE: review');
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
// 173: 单趟零进展防呆(三重防呆决策之二·状态机侧)——TASK 仅剩依赖无法满足的孤儿并行任务(depends_on 引用
|
|
132
|
+
// 不存在的 T99):既无可委托并行又无串行 pending 且 TASK 未全 done → next 应 BLOCKED 防静默死锁。
|
|
133
|
+
// 旧引擎无防呆静默路由 execute = 预期 RED。
|
|
134
|
+
{
|
|
135
|
+
name: '173 单趟零进展 BLOCK:孤儿并行依赖无法满足(检查 depends_on)',
|
|
136
|
+
run: (dir) => {
|
|
137
|
+
writeIntakeArtifacts(dir);
|
|
138
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
139
|
+
'<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');
|
|
140
|
+
writeState(dir, {
|
|
141
|
+
activeChange: CHANGE_ID,
|
|
142
|
+
currentNode: 'execute',
|
|
143
|
+
completedNodes: ['open', 'design', 'plan'],
|
|
144
|
+
evidence: { open: { summary: 'o' }, design: { summary: 'd' }, plan: { summary: 'p' } },
|
|
145
|
+
verifyFailures: 0,
|
|
146
|
+
executionMode: 'subagent',
|
|
147
|
+
directOverride: false,
|
|
148
|
+
});
|
|
149
|
+
const res = runStateWithProtocol(dir, ['next']);
|
|
150
|
+
assertExit(res, 1);
|
|
151
|
+
assertOut(res, 'BLOCKED');
|
|
152
|
+
assertOut(res, '孤儿并行');
|
|
153
|
+
assertOut(res, 'depends_on');
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
// 174: 委托节点二次进入完成判定(AC-2 合取语义)——completedNodes 含 subagent-execute:
|
|
158
|
+
// ① 仍有 eligible 并行 pending → next 返回 NODE: subagent-execute(未最终完成,继续委托);
|
|
159
|
+
// ② 并行全 done、仅串行 pending → NODE: execute(本趟委托完成,趟间回串行);
|
|
160
|
+
// ③ 全部 done + SUMMARY 在场 → NODE: review(可委托集合为空 ∧ 无串行 pending → 最终完成)。
|
|
161
|
+
// 旧引擎①停留 execute = 预期 RED。
|
|
162
|
+
{
|
|
163
|
+
name: '174 委托节点二次进入完成判定:eligible 再入 → 趟间串行 → 清空进 review',
|
|
164
|
+
run: (dir) => {
|
|
165
|
+
writeIntakeArtifacts(dir);
|
|
166
|
+
const pDone = (id, deps) =>
|
|
167
|
+
'<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>' +
|
|
168
|
+
(deps ? '<depends_on>' + deps + '</depends_on>' : '') + '</task>\n';
|
|
169
|
+
const t03 = (status) =>
|
|
170
|
+
'<task id="T03"' + (status ? ' status="' + status + '"' : '') + '><action>实现 T03</action><write_files>src/t3.mjs</write_files><verify>node --check src/t3.mjs</verify><depends_on>P01,P02</depends_on></task>\n';
|
|
171
|
+
// ① 第一波 P01 done + 第二波 P02(dep P01)pending eligible + 串行 T03 pending → 二次进入委托
|
|
172
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + TASK_P2_PENDING + t03(''));
|
|
173
|
+
writeState(dir, {
|
|
174
|
+
activeChange: CHANGE_ID,
|
|
175
|
+
currentNode: 'subagent-execute',
|
|
176
|
+
completedNodes: ['open', 'design', 'plan', 'execute', 'subagent-execute'],
|
|
177
|
+
evidence: {
|
|
178
|
+
open: { summary: 'o' }, design: { summary: 'd' }, plan: { summary: 'p' },
|
|
179
|
+
execute: { summary: 'serial digested' }, 'subagent-execute': { summary: 'wave1 delegated' },
|
|
180
|
+
},
|
|
181
|
+
verifyFailures: 0,
|
|
182
|
+
executionMode: 'subagent',
|
|
183
|
+
directOverride: false,
|
|
184
|
+
});
|
|
185
|
+
let res = runStateWithProtocol(dir, ['next']);
|
|
186
|
+
assertExit(res, 0);
|
|
187
|
+
assertOut(res, 'NODE: subagent-execute');
|
|
188
|
+
// ② P02 也 done → 可委托集合为空、串行 T03 pending → 趟间回 execute
|
|
189
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + pDone('P02', 'P01') + t03(''));
|
|
190
|
+
res = runStateWithProtocol(dir, ['next']);
|
|
191
|
+
assertExit(res, 0);
|
|
192
|
+
assertOut(res, 'NODE: execute');
|
|
193
|
+
// ③ 全部 done + SUMMARY 在场 → 合取完成(无 eligible ∧ 无 serial pending)→ review
|
|
194
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + pDone('P02', 'P01') + t03('done'));
|
|
195
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/P01-SUMMARY.md', summaryContent());
|
|
196
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/T03-SUMMARY.md', summaryContent());
|
|
197
|
+
res = runStateWithProtocol(dir, ['next']);
|
|
198
|
+
assertExit(res, 0);
|
|
199
|
+
assertOut(res, 'NODE: review');
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
// 175: 向后兼容等价断言(AC-3)——旧合法形态在新引擎下路由结果与旧期望一致(零行为漂移):
|
|
204
|
+
// 全串行 → execute;并→串首趟 → subagent-execute;并→串委托完成后(无新 eligible)→ execute;
|
|
205
|
+
// 串→并首趟 → execute(先串行)。旧合法序列退化为单趟,行为不变。
|
|
206
|
+
{
|
|
207
|
+
name: '175 向后兼容等价:旧合法形态路由结果与旧期望一致',
|
|
208
|
+
run: (dir) => {
|
|
209
|
+
writeIntakeArtifacts(dir);
|
|
210
|
+
const goNext = (taskContent, currentNode, completedExtra = [], withExecuteEvidence = false) => {
|
|
211
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + taskContent);
|
|
212
|
+
writeState(dir, {
|
|
213
|
+
activeChange: CHANGE_ID,
|
|
214
|
+
currentNode,
|
|
215
|
+
completedNodes: ['open', 'design', 'plan', ...completedExtra],
|
|
216
|
+
evidence: {
|
|
217
|
+
open: { summary: 'o' },
|
|
218
|
+
design: { summary: 'd' },
|
|
219
|
+
plan: { summary: 'p' },
|
|
220
|
+
// withExecuteEvidence:模拟首趟串行消化已 record 过 execute(证据跨重入累积——
|
|
221
|
+
// 真实链路 evidence 不清零;无标记 = 尚未进入过 execute 的干净态)
|
|
222
|
+
...(withExecuteEvidence ? { execute: { summary: 'serial pass recorded' } } : {}),
|
|
223
|
+
...(completedExtra.includes('subagent-execute') ? { 'subagent-execute': { summary: 'delegated' } } : {}),
|
|
224
|
+
},
|
|
225
|
+
verifyFailures: 0,
|
|
226
|
+
executionMode: 'subagent',
|
|
227
|
+
directOverride: false,
|
|
228
|
+
});
|
|
229
|
+
return runStateWithProtocol(dir, ['next']);
|
|
230
|
+
};
|
|
231
|
+
// ① 全串行(含依赖链)→ execute
|
|
232
|
+
let res = goNext(TASK_VALID_ALL_SERIAL, 'execute');
|
|
233
|
+
assertExit(res, 0);
|
|
234
|
+
assertOut(res, 'NODE: execute');
|
|
235
|
+
// ② 并→串(并存前+串在后)首趟 → subagent-execute(与旧引擎第一趟一致)
|
|
236
|
+
res = goNext(TASK_VALID_PS, 'execute');
|
|
237
|
+
assertExit(res, 0);
|
|
238
|
+
assertOut(res, 'NODE: subagent-execute');
|
|
239
|
+
// ③ 并→串委托完成后(并行全 done、无新 eligible)→ execute 消化串行(与旧引擎一致;
|
|
240
|
+
// execute 已 record 过——证据累积,严格顺序校验放行)
|
|
241
|
+
res = goNext(
|
|
242
|
+
'<task id="P01" status="done" parallel="true"><action>实现 P01</action><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify></task>\n' +
|
|
243
|
+
'<task id="P02" status="done" parallel="true"><action>实现 P02</action><write_files>src/p2.mjs</write_files><verify>node --check src/p2.mjs</verify></task>\n' +
|
|
244
|
+
'<task id="T01" parallel="false" status="pending"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify><depends_on>P01,P02</depends_on></task>\n',
|
|
245
|
+
'execute', ['subagent-execute'], true);
|
|
246
|
+
assertExit(res, 0);
|
|
247
|
+
assertOut(res, 'NODE: execute');
|
|
248
|
+
// ④ 串→并(串在前+并在后)首趟 → execute 先串行(与旧引擎一致)
|
|
249
|
+
res = goNext(TASK_VALID_SP, 'execute');
|
|
250
|
+
assertExit(res, 0);
|
|
251
|
+
assertOut(res, 'NODE: execute');
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
// 176: 伪并行检测(多趟混排合法化后的语义盲区兜底)——并行任务 write_files 仅声明测试产物
|
|
256
|
+
// 而无任何生产代码文件时,plan 出口输出 WARN(列任务 id 并给出 depends_on/垂直切片建议)
|
|
257
|
+
// 且不阻断——渐进提示语义本身即断言点;write_files 混有生产文件的并行任务不触发。
|
|
258
|
+
{
|
|
259
|
+
name: '176 伪并行 WARN:仅写测试产物的并行任务提示依赖嫌疑且不阻断',
|
|
260
|
+
run: (dir) => {
|
|
261
|
+
writeIntakeArtifacts(dir);
|
|
262
|
+
writeState(dir, {
|
|
263
|
+
activeChange: CHANGE_ID,
|
|
264
|
+
currentNode: 'plan',
|
|
265
|
+
completedNodes: ['open', 'design'],
|
|
266
|
+
evidence: { open: { summary: 'o' }, design: { summary: 'd' }, plan: { summary: 'p' } },
|
|
267
|
+
verifyFailures: 0,
|
|
268
|
+
executionMode: 'subagent',
|
|
269
|
+
directOverride: false,
|
|
270
|
+
});
|
|
271
|
+
// 正例:纯测试面并行任务 → WARN 列 id 并建议 depends_on;plan 出口仍通过
|
|
272
|
+
let res = runPlanExit(dir,
|
|
273
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>tests/test_p1.mjs</write_files><verify>node --check tests/test_p1.mjs</verify></task>\n');
|
|
274
|
+
assertExit(res, 0);
|
|
275
|
+
assertOut(res, 'WARN: 伪并行检测');
|
|
276
|
+
assertOut(res, 'P01');
|
|
277
|
+
assertOut(res, 'depends_on');
|
|
278
|
+
// 新形态 a:test 后缀文件(src/helper.test.mjs)——应 WARN
|
|
279
|
+
res = runPlanExit(dir,
|
|
280
|
+
'<task id="P01b" parallel="true" status="pending"><action>实现 P01b</action><write_files>src/helper.test.mjs</write_files><verify>node --check src/helper.test.mjs</verify></task>\n');
|
|
281
|
+
assertExit(res, 0);
|
|
282
|
+
assertOut(res, 'WARN: 伪并行检测');
|
|
283
|
+
assertOut(res, 'P01b');
|
|
284
|
+
// 新形态 b:__tests__/ 目录(__tests__/helper.test.ts)——应 WARN
|
|
285
|
+
res = runPlanExit(dir,
|
|
286
|
+
'<task id="P01c" parallel="true" status="pending"><action>实现 P01c</action><write_files>__tests__/helper.test.ts</write_files><verify>node --check __tests__/helper.test.ts</verify></task>\n');
|
|
287
|
+
assertExit(res, 0);
|
|
288
|
+
assertOut(res, 'WARN: 伪并行检测');
|
|
289
|
+
assertOut(res, 'P01c');
|
|
290
|
+
// 新形态 c:Windows 反斜杠分隔(tests\foo.test.mjs)——应 WARN
|
|
291
|
+
res = runPlanExit(dir,
|
|
292
|
+
'<task id="P01d" parallel="true" status="pending"><action>实现 P01d</action><write_files>tests\\foo.test.mjs</write_files><verify>node --check tests\\foo.test.mjs</verify></task>\n');
|
|
293
|
+
assertExit(res, 0);
|
|
294
|
+
assertOut(res, 'WARN: 伪并行检测');
|
|
295
|
+
assertOut(res, 'P01d');
|
|
296
|
+
// 新形态 d:多行注释块包裹(整块剥除后再解析,注释内容不得当生产文件)——仍 WARN
|
|
297
|
+
res = runPlanExit(dir,
|
|
298
|
+
'<task id="P01e" parallel="true" status="pending"><action>实现 P01e</action><write_files><!-- 规划备注\nsrc/fake.mjs\n-->tests/real.test.mjs</write_files><verify>node --check tests/real.test.mjs</verify></task>\n');
|
|
299
|
+
assertExit(res, 0);
|
|
300
|
+
assertOut(res, 'WARN: 伪并行检测');
|
|
301
|
+
assertOut(res, 'P01e');
|
|
302
|
+
// 反例:write_files 混有生产文件 → 不触发
|
|
303
|
+
res = runPlanExit(dir,
|
|
304
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>src/p2.mjs\ntests/test_p2.mjs</write_files><verify>node --check src/p2.mjs</verify></task>\n');
|
|
305
|
+
assertExit(res, 0);
|
|
306
|
+
assertNotOut(res, '伪并行检测');
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
// 177: hook 项目根判定兜底链(级3 实测暴露的 H5 残留缺口收口)——会话 cwd 漂移后:
|
|
311
|
+
// ① 有 CLAUDE_PROJECT_DIR(CC hook env 注入)→ 越界写 BLOCKED / .specs 写放行;
|
|
312
|
+
// ② 无任何 env → 自 cwd 向上锚定最近含 .flow-comet/flow-comet-state.json 的祖先,同样正确判定。
|
|
313
|
+
// 修复前两种漂移形态下协议读取失败 → exit 1 报错式放行(越界写有痕放过)。
|
|
314
|
+
{
|
|
315
|
+
name: '177 hook 根判定兜底:cwd 漂移经变量/祖先锚定后正确拦截(H5 收口)',
|
|
316
|
+
run: (dir) => {
|
|
317
|
+
// running 态(review 节点白名单 .specs/)
|
|
318
|
+
writeState(dir, {
|
|
319
|
+
activeChange: CHANGE_ID,
|
|
320
|
+
currentNode: 'review',
|
|
321
|
+
status: 'running',
|
|
322
|
+
completedNodes: ['open', 'design', 'plan', 'execute', 'subagent-execute'],
|
|
323
|
+
evidence: {}, verifyFailures: 0, executionMode: 'subagent', directOverride: false,
|
|
324
|
+
});
|
|
325
|
+
fs.mkdirSync(path.join(dir, 'deep'), { recursive: true });
|
|
326
|
+
const spawnDrift = (input, extraEnv) => {
|
|
327
|
+
// 封闭性:剥离宿主可能注入的锚定变量,确保用例只测显式给定的锚定形态
|
|
328
|
+
const inherited = { ...process.env };
|
|
329
|
+
delete inherited.FLOW_COMET_RUN_ROOT;
|
|
330
|
+
delete inherited.CLAUDE_PROJECT_DIR;
|
|
331
|
+
const res = spawnSync(process.execPath, [HOOK, 'before_tool'], {
|
|
332
|
+
cwd: path.join(dir, 'deep'),
|
|
333
|
+
input: JSON.stringify(input),
|
|
334
|
+
env: {
|
|
335
|
+
...inherited,
|
|
336
|
+
FLOW_COMET_PROTOCOL: scenarioProtocolPath(dir),
|
|
337
|
+
...extraEnv,
|
|
338
|
+
},
|
|
339
|
+
encoding: 'utf8', timeout: 60000,
|
|
340
|
+
});
|
|
341
|
+
return { status: res.status ?? 1, output: String(res.stdout || '') + String(res.stderr || '') };
|
|
342
|
+
};
|
|
343
|
+
const evil = path.join(dir, 'evil', 'x.txt').split(path.sep).join('/');
|
|
344
|
+
const inspec = path.join(dir, '.specs', 'ok.txt').split(path.sep).join('/');
|
|
345
|
+
// ① CLAUDE_PROJECT_DIR 锚定
|
|
346
|
+
let r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: evil } }, { CLAUDE_PROJECT_DIR: dir });
|
|
347
|
+
assertExit(r, 2);
|
|
348
|
+
assertOut(r, 'BLOCKED');
|
|
349
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: inspec } }, { CLAUDE_PROJECT_DIR: dir });
|
|
350
|
+
assertExit(r, 0);
|
|
351
|
+
assertOut(r, 'workflow-hook-guard-ok');
|
|
352
|
+
// ② 无 env → 祖先锚定(dir 含 .flow-comet/flow-comet-state.json)
|
|
353
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: evil } }, {});
|
|
354
|
+
assertExit(r, 2);
|
|
355
|
+
assertOut(r, 'BLOCKED');
|
|
356
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: inspec } }, {});
|
|
357
|
+
assertExit(r, 0);
|
|
358
|
+
assertOut(r, 'workflow-hook-guard-ok');
|
|
359
|
+
// ③ 相对 file_path 按锚定根解析(修复点:曾按漂移 cwd 解析,好写被误拦)
|
|
360
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: '.specs/ok.txt' } }, { CLAUDE_PROJECT_DIR: dir });
|
|
361
|
+
assertExit(r, 0);
|
|
362
|
+
assertOut(r, 'workflow-hook-guard-ok');
|
|
363
|
+
// ④ 相对路径在项目内但白名单外 → 拦截
|
|
364
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: 'evil-rel/x.txt' } }, { CLAUDE_PROJECT_DIR: dir });
|
|
365
|
+
assertExit(r, 2);
|
|
366
|
+
assertOut(r, 'BLOCKED');
|
|
367
|
+
// ⑤ 陈旧 CLAUDE_PROJECT_DIR(不存在的路径)→ 不采纳,落入祖先锚定仍正确判定
|
|
368
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: evil } }, { CLAUDE_PROJECT_DIR: path.join(dir, 'gone') });
|
|
369
|
+
assertExit(r, 2);
|
|
370
|
+
assertOut(r, 'BLOCKED');
|
|
371
|
+
r = spawnDrift({ tool_name: 'Write', tool_input: { file_path: inspec } }, { CLAUDE_PROJECT_DIR: path.join(dir, 'gone') });
|
|
372
|
+
assertExit(r, 0);
|
|
373
|
+
assertOut(r, 'workflow-hook-guard-ok');
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
// ---------- 场景族(多趟出口与解析硬化 · AC-1~AC-7):期望先行 TDD——部分场景对未修复引擎
|
|
378
|
+
// RED 属预期中间态(GREEN 随引擎修复落地后于收口前全量确认);BLOCKED 文案断言与设计决策
|
|
379
|
+
// 的提示句逐字对齐;既有场景不受本族影响(编号连续接续)。
|
|
380
|
+
|
|
381
|
+
// 178: S 开局混排拓扑 execute 首趟出口放行——T01[S] 已委托交付标 done、T02/T03[P] dep T01
|
|
382
|
+
// pending(待下一趟委托)、T04[S] dep T02,T03 pending(依赖未满足)。串行 pending 判定收窄为
|
|
383
|
+
// 「可运行串行」后,依赖未满足的中段串行 = 等后续波次的合法中间态 → 放行,多趟路由零干预续驱;
|
|
384
|
+
// 未修复引擎按「全部 pending 串行」无条件拦截 → 对未修复引擎 RED。
|
|
385
|
+
{
|
|
386
|
+
name: '178 execute 出口放行:S 开局混排拓扑中段串行依赖未满足不再拦',
|
|
387
|
+
run: (dir) => {
|
|
388
|
+
const st = baseState('execute');
|
|
389
|
+
st.evidence.execute = { summary: 'executed' };
|
|
390
|
+
writeState(dir, st);
|
|
391
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
392
|
+
'<task id="T01" parallel="false" status="done"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n' +
|
|
393
|
+
'<task id="T02" parallel="true" status="pending"><action>实现 T02</action><write_files>src/t2.mjs</write_files><verify>node --check src/t2.mjs</verify><depends_on>T01</depends_on></task>\n' +
|
|
394
|
+
'<task id="T03" parallel="true" status="pending"><action>实现 T03</action><write_files>src/t3.mjs</write_files><verify>node --check src/t3.mjs</verify><depends_on>T01</depends_on></task>\n' +
|
|
395
|
+
'<task id="T04" parallel="false" status="pending"><action>实现 T04</action><write_files>src/t4.mjs</write_files><verify>node --check src/t4.mjs</verify><depends_on>T02,T03</depends_on></task>\n' +
|
|
396
|
+
'<task id="T05" parallel="false"><action>遗留无状态串行</action><write_files>src/t5.mjs</write_files><verify>node --check src/t5.mjs</verify></task>\n');
|
|
397
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
398
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', summaryContent());
|
|
399
|
+
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
400
|
+
st2.evidence['subagent-execute'] = { handoffResult: handoffFor(['T01']) };
|
|
401
|
+
writeState(dir, st2);
|
|
402
|
+
const res = runGuard(['exit', 'execute', '--apply'], dir);
|
|
403
|
+
assertExit(res, 0);
|
|
404
|
+
assertOut(res, 'ALL CHECKS PASSED');
|
|
405
|
+
assertNotOut(res, 'BLOCKED');
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
// 179: 可运行串行仍拦(保守边界不松动的负例锚)——同拓扑但 T04 depends_on 为空:
|
|
410
|
+
// 依赖已满足、既未委托也未标 done 的串行 pending = 规划错误信号 → BLOCKED 且消息指明该任务 id。
|
|
411
|
+
// 拦截语义与 id 明细既有引擎已具备 → 即刻绿锚,钉住判定收窄不弱化此向。
|
|
412
|
+
{
|
|
413
|
+
name: '179 execute 出口仍拦:可运行串行 pending BLOCKED 且消息含任务 id',
|
|
414
|
+
run: (dir) => {
|
|
415
|
+
const st = baseState('execute');
|
|
416
|
+
st.evidence.execute = { summary: 'executed' };
|
|
417
|
+
writeState(dir, st);
|
|
418
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
419
|
+
'<task id="T01" parallel="false" status="done"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n' +
|
|
420
|
+
'<task id="T02" parallel="true" status="pending"><action>实现 T02</action><write_files>src/t2.mjs</write_files><verify>node --check src/t2.mjs</verify><depends_on>T01</depends_on></task>\n' +
|
|
421
|
+
'<task id="T03" parallel="true" status="pending"><action>实现 T03</action><write_files>src/t3.mjs</write_files><verify>node --check src/t3.mjs</verify><depends_on>T01</depends_on></task>\n' +
|
|
422
|
+
'<task id="T04" parallel="false" status="pending"><action>实现 T04</action><write_files>src/t4.mjs</write_files><verify>node --check src/t4.mjs</verify></task>\n');
|
|
423
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
424
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', summaryContent());
|
|
425
|
+
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
426
|
+
st2.evidence['subagent-execute'] = { handoffResult: handoffFor(['T01']) };
|
|
427
|
+
writeState(dir, st2);
|
|
428
|
+
const res = runGuard(['exit', 'execute'], dir);
|
|
429
|
+
assertExit(res, 1);
|
|
430
|
+
assertOut(res, 'BLOCKED');
|
|
431
|
+
assertOut(res, '串行 pending');
|
|
432
|
+
assertOut(res, 'T04');
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
|
|
436
|
+
// 180: 委托边界单行分号 write_files 自动解析正例——request 不带 --write-files 走 TASK.md
|
|
437
|
+
// 自动解析,`a; b` 单行分号形态须切分为两条路径(与换行形态等价);随后 result 回传恰好触碰
|
|
438
|
+
// 这两个文件的提交,提交文件子集校验通过、不出现「超出 writeFiles 范围」误拦。
|
|
439
|
+
{
|
|
440
|
+
name: '180 handoff 分号单行 write_files 自动解析等价换行且 result 子集校验通过',
|
|
441
|
+
run: (dir) => {
|
|
442
|
+
execFileSync('git', ['init'], { cwd: dir, stdio: 'ignore' });
|
|
443
|
+
const git = (...args) => execFileSync('git', args, { cwd: dir, stdio: 'ignore' });
|
|
444
|
+
writeFile(dir, 'src/todo_x.py', '# impl\n');
|
|
445
|
+
writeFile(dir, 'tests/test_todo_x.py', '# test\n');
|
|
446
|
+
// 只加任务切片文件——运行器预置的 reference/ 协议副本不属于本任务提交面
|
|
447
|
+
git('add', 'src/todo_x.py');
|
|
448
|
+
git('add', 'tests/test_todo_x.py');
|
|
449
|
+
git('-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '-m', 'vertical slice');
|
|
450
|
+
const hash = execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd: dir, encoding: 'utf8' }).trim();
|
|
451
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
452
|
+
'<task id="T01"><action>实现 T01</action><write_files>src/todo_x.py; tests/test_todo_x.py</write_files><verify>node --check src/todo_x.py</verify></task>\n');
|
|
453
|
+
const st = baseState('subagent-execute');
|
|
454
|
+
st.newChange = true;
|
|
455
|
+
writeState(dir, st);
|
|
456
|
+
// 技能加载前置门材料:新 change 下 request 须有本节点声明标记
|
|
457
|
+
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID, '.skill-loads'), { recursive: true });
|
|
458
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/.skill-loads/subagent-execute-flow-comet-dev.json',
|
|
459
|
+
JSON.stringify({ node: 'subagent-execute', skill: 'flow-comet-dev', protocol: '4-dev.md', at: '2026-08-01T00:00:00.000Z' }, null, 2) + '\n');
|
|
460
|
+
const resReq = runHandoff(['request', 'T01', 'delegate todo slice'], dir);
|
|
461
|
+
assertExit(resReq, 0);
|
|
462
|
+
assertOut(resReq, 'HANDOFF REQUEST: T01');
|
|
463
|
+
// 自动解析结果与换行形态等价:单行分号切分为两条独立路径入库
|
|
464
|
+
const stAfter = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
465
|
+
const parsedFiles = stAfter.evidence['subagent-execute'].handoffRequests.T01.writeFiles;
|
|
466
|
+
if (!Array.isArray(parsedFiles) || parsedFiles.length !== 2
|
|
467
|
+
|| !parsedFiles.includes('src/todo_x.py') || !parsedFiles.includes('tests/test_todo_x.py')) {
|
|
468
|
+
throw new Error('request 自动解析未把单行分号 write_files 切分为两条路径: ' + JSON.stringify(parsedFiles));
|
|
469
|
+
}
|
|
470
|
+
const payload = JSON.stringify({
|
|
471
|
+
status: 'DONE', taskId: 'T01', commitHash: hash,
|
|
472
|
+
completedChecks: ['required-skill:subagent-execute.flow-comet-dev'],
|
|
473
|
+
greenEvidence: { command: 'node --check src/todo_x.py', output: 'ok' },
|
|
474
|
+
redEvidence: { command: 'node --check tests/test_todo_x.py', output: 'ok' },
|
|
475
|
+
});
|
|
476
|
+
const resResult = runHandoff(['result', 'T01', payload], dir);
|
|
477
|
+
assertExit(resResult, 0);
|
|
478
|
+
assertOut(resResult, 'HANDOFF RESULT: T01');
|
|
479
|
+
assertNotOut(resResult, '超出 writeFiles 范围');
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
// 181: 伪并行启发式分号容错(一景双断言)——① 并行任务 write_files 为单行分号垂直切片
|
|
484
|
+
// (生产文件; 测试文件):未修复引擎按整行匹配测试路径模式 → 误报 WARN(RED 取证点);
|
|
485
|
+
// 修复补分号二次切分后识别出生产文件 → 不误报。② 纯测试文件并行任务(换行形态)仍输出
|
|
486
|
+
// WARN 且不阻断(真报保持)。WARN 明细行以「无生产代码文件: <任务id>」前缀区分两任务归属。
|
|
487
|
+
{
|
|
488
|
+
name: '181 伪并行检测分号容错:单行垂直切片不误报且纯测试并行任务仍告警',
|
|
489
|
+
run: (dir) => {
|
|
490
|
+
writeIntakeArtifacts(dir);
|
|
491
|
+
writeState(dir, {
|
|
492
|
+
activeChange: CHANGE_ID,
|
|
493
|
+
currentNode: 'plan',
|
|
494
|
+
completedNodes: ['open', 'design'],
|
|
495
|
+
evidence: { open: { summary: 'o' }, design: { summary: 'd' }, plan: { summary: 'p' } },
|
|
496
|
+
verifyFailures: 0,
|
|
497
|
+
executionMode: 'subagent',
|
|
498
|
+
directOverride: false,
|
|
499
|
+
});
|
|
500
|
+
const res = runPlanExit(dir,
|
|
501
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>todo_x.py; tests/test_todo_x.py</write_files><verify>node --check todo_x.py</verify></task>\n' +
|
|
502
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>tests/test_p2.mjs\ntests/test_p2_helper.mjs</write_files><verify>node --check tests/test_p2.mjs</verify></task>\n');
|
|
503
|
+
assertExit(res, 0); // WARN 渐进不阻断
|
|
504
|
+
assertOut(res, 'WARN: 伪并行检测'); // ② 纯测试并行任务真报保持
|
|
505
|
+
assertOut(res, '无生产代码文件: P02');
|
|
506
|
+
assertNotOut(res, '无生产代码文件: P01'); // ① 分号垂直切片不误报
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
|
|
510
|
+
// 182: 收尾态 ROUTE WARN 静默——TASK 全部任务 done 后,「未找到可委托并行块」诊断失去
|
|
511
|
+
// 信息量(噪音只在收尾态出现);增加存在 pending 任务前置条件后静默。未修复引擎无条件
|
|
512
|
+
// 输出 → 对未修复引擎 RED。
|
|
513
|
+
{
|
|
514
|
+
name: '182 execute 出口静默:全部任务 done 后无 ROUTE WARN',
|
|
515
|
+
run: (dir) => {
|
|
516
|
+
const st = baseState('execute');
|
|
517
|
+
st.evidence.execute = { summary: 'executed' };
|
|
518
|
+
writeState(dir, st);
|
|
519
|
+
// 未分类并行任务(缺 status)自初始 TASK 在场——全部可解析任务 done 后,
|
|
520
|
+
// 该任务按「缺 status 不视为 pending」文档语义保持静默(与既有「无可解析 pending 静默」
|
|
521
|
+
// 案例锚同源),不误报路由警告。
|
|
522
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 + TASK_P2 +
|
|
523
|
+
'<task id="P03" parallel="true"><action>实现 P03</action><write_files>src/p3.mjs</write_files><verify>node --check src/p3.mjs</verify></task>\n');
|
|
524
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
525
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/P01-SUMMARY.md', summaryContent());
|
|
526
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/P02-SUMMARY.md', summaryContent());
|
|
527
|
+
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
528
|
+
st2.evidence['subagent-execute'] = { handoffResult: handoffFor(['P01', 'P02']) };
|
|
529
|
+
writeState(dir, st2);
|
|
530
|
+
const res = runGuard(['exit', 'execute', '--apply'], dir);
|
|
531
|
+
assertExit(res, 0);
|
|
532
|
+
assertNotOut(res, 'ROUTE WARN');
|
|
533
|
+
assertOut(res, 'ALL CHECKS PASSED');
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
|
|
537
|
+
// 183: 死结类 BLOCKED 补 advance 边界提示——可运行串行拦截分支的 BLOCKED 消息含逐字句
|
|
538
|
+
// 「无可执行的常规恢复动作时,可用 workflow-state.mjs advance 渡过结构性死结」(仅死结分支
|
|
539
|
+
// 提示,常规缺产物/缺证据情形不适用)。文案由引擎侧任务落地——未修复消息无该句 → RED。
|
|
540
|
+
{
|
|
541
|
+
name: '183 死结 BLOCKED 消息含 advance 边界提示逐字句',
|
|
542
|
+
run: (dir) => {
|
|
543
|
+
const st = baseState('execute');
|
|
544
|
+
st.evidence.execute = { summary: 'executed' };
|
|
545
|
+
writeState(dir, st);
|
|
546
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + TASK_P1 +
|
|
547
|
+
'<task id="T02" parallel="false" status="pending"><action>实现 T02</action><write_files>src/t2.mjs</write_files><verify>node --check src/t2.mjs</verify><depends_on>P01</depends_on></task>\n');
|
|
548
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
549
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/P01-SUMMARY.md', summaryContent());
|
|
550
|
+
const st2 = JSON.parse(fs.readFileSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), 'utf8'));
|
|
551
|
+
st2.evidence['subagent-execute'] = { handoffResult: handoffFor(['P01']) };
|
|
552
|
+
writeState(dir, st2);
|
|
553
|
+
const res = runGuard(['exit', 'execute'], dir);
|
|
554
|
+
assertExit(res, 1);
|
|
555
|
+
assertOut(res, 'BLOCKED');
|
|
556
|
+
assertOut(res, '无可执行的常规恢复动作时,可用 workflow-state.mjs advance 渡过结构性死结');
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
// 184: 技能文本混排合法化语义文本锁(in-place 扩展:模板权威整句 / 入口 archive 读法 /
|
|
561
|
+
// 规划约束 / Codex 平台事实)——plan 与 subagent-execute 两 SKILL 权威源不得再含
|
|
562
|
+
// 「连续块」「居首」旧波次形态约束表述,且依赖图语义描述(depends_on)在场、「用 Skill 工具」
|
|
563
|
+
// 两层加载句式保持(措辞锁族既有锚不破坏)。
|
|
564
|
+
// **逐字锁重定向(ADR-016)**:原「同一文字须在多册出现」的硬锁一律改为「单一权威 + 指针在场 +
|
|
565
|
+
// 正文唯一」三件套,每条新锚自带反向构造(抽掉目标文字必红——判别句式,非裸子串):
|
|
566
|
+
// ② 模板权威:14 册各自的锚句**即指向唯一权威 `flow-kit/templates/**` 的指针**(整句语义组合
|
|
567
|
+
// 仍在场,缺任一册即红);「该句只在 1 处」落在**册内一侧**(每册恰一处——同册复制第二份即红),
|
|
568
|
+
// 并补「作者面唯一」:全部持锚行的分发文本必须同指 `flow-kit/templates/**`(指向别处即红)。
|
|
569
|
+
// ⑤ 平台事实:判别句随 `worktree-notes.md` 移出而迁入 `reference/platform-facts.md`(T07 已搬入)
|
|
570
|
+
// ——判据改为「权威文件在场 + 判别句在权威处 + 各引用册指针在场 + 判别句**不再回流册子**」。
|
|
571
|
+
// ⑥ 三块归一处:`reference/commit-discipline.md` 持 pathspec 五要素与集成四要素**全文**(权威处),
|
|
572
|
+
// 两册只留要点句(**不再要求逐字一致**,逐字锁已作废);权威处独有的「证据与判级」判别句
|
|
573
|
+
// 回流任一册即红。
|
|
574
|
+
// ⑦ 入口册的 7 条字面量与「建树适用面两句」保留(能力契约锚);`worktree-notes.md` 的 6 条整句
|
|
575
|
+
// 随文件移出改锚到 `reference/platform-facts.md`,并断言各引用册指针在场。
|
|
576
|
+
// ⑧ 文本↔实现一致(文本不得说谎):**保留原样**——它不是「多册同文字」类锁,本批不动。
|
|
577
|
+
// 附:技能树正文的相对路径引用必须解析得到(本轮 `GUIDANCE.md` 改名曾造成 5 册死引用而零红灯)。
|
|
578
|
+
// 附 2:成对展开文件的指针**不得指错**——「能解析 ≠ 指对了」:同目录带同名 `GUIDANCE.md` 的册,
|
|
579
|
+
// 册首「手写区详细协议见 …」必须是本册裸文件名;入口册(展开版为 `reference/entry-detail.md`)
|
|
580
|
+
// 是唯一例外。解析判据只证明目标**存在**,证明不了**指对了**——本附与之互补。
|
|
581
|
+
// 文本存在级断言(结构级由其余场景族覆盖)。
|
|
582
|
+
// in-place 扩展(委托契约纪律文本锁):两册(委托册 / 串行册)各自须含四属性契约、提交面 pathspec
|
|
583
|
+
// 纪律与集成纪律的**要点句与条件句**;旧表述零残留(无条件 worktree 口号仅允许被反驳形态、
|
|
584
|
+
// 「未获机制明文放行」清零);文本点名的实现常量 / 载荷键名 / 受保护目标与引擎实现逐项对照
|
|
585
|
+
//(文本说 A、实现说 B 即红)。
|
|
586
|
+
{
|
|
587
|
+
name: '184a 技能文本锁:两层加载/依赖图既有锚 + 模板权威指针与登记',
|
|
588
|
+
run: () => {
|
|
589
|
+
const problems = [];
|
|
590
|
+
// —— 既有锚(原文语义与失败消息保持)——
|
|
591
|
+
for (const skillDir of ['flow-comet-plan', 'flow-comet-subagent-execute']) {
|
|
592
|
+
const text = fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', skillDir, 'SKILL.md'), 'utf8');
|
|
593
|
+
if (text.includes('连续块')) problems.push(skillDir + ' 含「连续块」旧形态约束表述');
|
|
594
|
+
if (text.includes('居首')) problems.push(skillDir + ' 含「居首」旧位置约束表述');
|
|
595
|
+
if (!text.includes('depends_on')) problems.push(skillDir + ' 缺依赖图语义描述(depends_on)');
|
|
596
|
+
if (!text.includes('用 Skill 工具')) problems.push(skillDir + ' 缺「用 Skill 工具」两层加载句式');
|
|
597
|
+
}
|
|
598
|
+
// —— ② 模板权威(重定向后的三件套)——成员面与整句锚点取自模块级常量(单一来源):
|
|
599
|
+
// 9 个既有成员 + 5 个 flow-kit 阶段协议技能 = 14 个真实成员(含 task);受检面另加
|
|
600
|
+
// 入口册与入口展开册(两者是「短指针」形态的既有持有者)。
|
|
601
|
+
const templateAuthoritySkills = TEMPLATE_AUTHORITY_SKILLS;
|
|
602
|
+
const templateAuthorityDocs = new Map();
|
|
603
|
+
for (const skillDir of templateAuthoritySkills) {
|
|
604
|
+
templateAuthorityDocs.set(skillDir + '/SKILL.md',
|
|
605
|
+
fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', skillDir, 'SKILL.md'), 'utf8'));
|
|
606
|
+
}
|
|
607
|
+
templateAuthorityDocs.set('flow-comet/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8'));
|
|
608
|
+
templateAuthorityDocs.set('flow-comet/reference/entry-detail.md',
|
|
609
|
+
fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'reference', 'entry-detail.md'), 'utf8'));
|
|
610
|
+
problems.push(...templateAuthorityProblems(templateAuthorityDocs));
|
|
611
|
+
// 反向构造(同一判据驱动,逐条对应重定向后的两侧):
|
|
612
|
+
// ① 同一册复制第二份锚行 ⇒ 必报「只允许 1 处」(重复回潮的同册形态);
|
|
613
|
+
// ② 权威目标改指别处 ⇒ 必报「未指向」(单一权威侧);
|
|
614
|
+
// ③ **真实文本变异**(不再用合成 `'y'.repeat(n)` 串):把入口册的声明块**原样**搬进另一册
|
|
615
|
+
// ——判据面里的那册原块被**替换**掉,故不触发「同册第二处锚句」,只可能由正文唯一判据
|
|
616
|
+
// 发声 ⇒ 必报「第二份展开正文」(旧探针只证明比较器能用,证不了判据面选得对);
|
|
617
|
+
// ④ 抽掉某册锚句 ⇒ 必报该册缺声明(指针在场侧)。
|
|
618
|
+
{
|
|
619
|
+
const openRel = 'flow-comet-open/SKILL.md';
|
|
620
|
+
const openText = templateAuthorityDocs.get(openRel);
|
|
621
|
+
const anchorLine = openText.split(/\r?\n/).find((l) => l.includes('模板权威'));
|
|
622
|
+
const entryBlock = templateAuthorityParagraphs(templateAuthorityDocs.get('flow-comet/SKILL.md'))[0] ?? '';
|
|
623
|
+
const openBlock = templateAuthorityParagraphs(openText)[0] ?? '';
|
|
624
|
+
if (entryBlock === '' || openBlock === '' || templateAuthorityBody(entryBlock) === '') {
|
|
625
|
+
problems.push('正文唯一反向构造的前提不成立:入口册声明块缺失 / 无正文行(无法构造真实变异探针)');
|
|
626
|
+
}
|
|
627
|
+
const probes = [
|
|
628
|
+
['同册复制第二份锚行', new Map(templateAuthorityDocs).set(openRel, openText + '\n' + anchorLine + '\n'),
|
|
629
|
+
'只允许 1 处'],
|
|
630
|
+
['权威目标改指别处', new Map(templateAuthorityDocs).set(openRel,
|
|
631
|
+
openText.split('`flow-kit/templates/**`').join('`.specs/archive/**`')), '未指向'],
|
|
632
|
+
['入口册声明块原样搬进另一册', new Map(templateAuthorityDocs)
|
|
633
|
+
.set(openRel, openText.split(openBlock).join(entryBlock)), '第二份展开正文'],
|
|
634
|
+
['抽掉某册锚句', new Map(templateAuthorityDocs).set(openRel,
|
|
635
|
+
openText.split(anchorLine).join('(反向构造:抽掉锚句)')), '缺模板权威'],
|
|
636
|
+
];
|
|
637
|
+
for (const [label, probed, expected] of probes) {
|
|
638
|
+
if (!templateAuthorityProblems(probed).some((p) => p.includes(expected))) {
|
|
639
|
+
problems.push('反向构造判别力缺失(模板权威: ' + label + ' 未被判违规)');
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
// 作者面完备性(判据 = **登记**,不是**计数相等**):新增持锚文本必须**显式登记**在受检面
|
|
644
|
+
// 常量里,否则报「未登记的权威声明」——报错指向真实动作(把新册登记进 `TEMPLATE_AUTHORITY_SKILLS`
|
|
645
|
+
// 并同批加声明)。**不做计数相等**:同文件别处的判据注释明确反对「以总量取红」的自锁探针
|
|
646
|
+
//(合法扩册会先撞红、报错方向指向锚而非真实动作);受检面成员**缺**声明由
|
|
647
|
+
// `templateAuthorityProblems` 的逐份「缺模板权威整句声明」覆盖,故登记判据**单向**判定即可。
|
|
648
|
+
{
|
|
649
|
+
const expectedHolders = [...templateAuthorityDocs.keys()].sort();
|
|
650
|
+
const actualHolders = skillTreeDocFiles()
|
|
651
|
+
.filter(([, file]) => fs.readFileSync(file, 'utf8').includes('模板权威'))
|
|
652
|
+
.map(([rel]) => rel)
|
|
653
|
+
.sort();
|
|
654
|
+
problems.push(...templateAuthorityRegistrationProblems(actualHolders, expectedHolders));
|
|
655
|
+
// 反向构造(同一判据驱动):① 未登记的新持有者 ⇒ 必报「未登记」;② 同批登记(把新册加进
|
|
656
|
+
// 受检面常量)⇒ **零问题**(合法扩册不再先红——旧计数相等判据正是在这一步撞红)。
|
|
657
|
+
const registeredProbe = 'flow-comet-probe-node/SKILL.md';
|
|
658
|
+
for (const [label, holders, expected, shouldReport] of [
|
|
659
|
+
['未登记的新持有者', [...actualHolders, registeredProbe], expectedHolders, true],
|
|
660
|
+
['同批登记后的新持有者', [...actualHolders, registeredProbe], [...expectedHolders, registeredProbe], false],
|
|
661
|
+
]) {
|
|
662
|
+
const reported = templateAuthorityRegistrationProblems(holders, expected)
|
|
663
|
+
.some((p) => p.includes(registeredProbe));
|
|
664
|
+
if (reported !== shouldReport) {
|
|
665
|
+
problems.push('反向构造判别力缺失(模板权威登记: ' + label + (shouldReport ? ' 未被判违规' : ' 被误判违规') + ')');
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (problems.length > 0) throw new Error('技能文本锁(模板权威族)不符: ' + problems.join('; '));
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
|
|
673
|
+
// 184b: 技能树正文的相对路径引用必须解析得到——改名造成的 5 册死引用曾零红灯;含三层反向构造
|
|
674
|
+
// (改写成不存在目标 / 抽掉引用不误报 / 显式跨册指针改回裸形态)。
|
|
675
|
+
{
|
|
676
|
+
name: '184b 技能文本锁:技能树正文相对路径引用可解析(含三层反向构造)',
|
|
677
|
+
run: () => {
|
|
678
|
+
const problems = [];
|
|
679
|
+
// —— 附:技能树正文的相对路径引用必须解析得到(本轮改名造成 5 册死引用而**零红灯**)——
|
|
680
|
+
{
|
|
681
|
+
const skillsRootAbs = path.join(SCRIPTS_DIR, '..', '..');
|
|
682
|
+
const treeDocs = new Map(skillTreeDocFiles().map(([rel, file]) => [rel, fs.readFileSync(file, 'utf8')]));
|
|
683
|
+
problems.push(...skillTreeReferenceProblems(treeDocs, skillsRootAbs));
|
|
684
|
+
// 反向构造(同一判据驱动):① 把引用改写成不存在的目标 ⇒ 必报「解析不到」;
|
|
685
|
+
// ② 抽掉引用 ⇒ 判据面收缩但**不误报**(证明判据只在引用在场时发声,不恒真);
|
|
686
|
+
// ③ **形态收窄侧**:把节点册里的一处**显式跨册**指针改回**裸形态** ⇒ 必报「解析不到」
|
|
687
|
+
//(旧实现给裸形态合成「入口册册根」候选,这一改法当时**判绿**——正是假绿本身)。
|
|
688
|
+
const sampleEntry = [...treeDocs].find(([, text]) => SKILL_TREE_REFERENCE_RE.test(text));
|
|
689
|
+
SKILL_TREE_REFERENCE_RE.lastIndex = 0;
|
|
690
|
+
if (!sampleEntry) {
|
|
691
|
+
problems.push('相对路径引用判据的前提不成立:技能树里找不到任何 reference/ 相对引用');
|
|
692
|
+
} else {
|
|
693
|
+
const [sampleRel, sampleText] = sampleEntry;
|
|
694
|
+
const sampleRef = sampleText.match(SKILL_TREE_REFERENCE_RE)[0];
|
|
695
|
+
const broken = new Map(treeDocs).set(sampleRel,
|
|
696
|
+
sampleText.split(sampleRef).join('reference/renamed-away-fixture.md'));
|
|
697
|
+
if (!skillTreeReferenceProblems(broken, skillsRootAbs).some((p) => p.includes('解析不到'))) {
|
|
698
|
+
problems.push('反向构造判别力缺失(死引用未被判「解析不到」): ' + sampleRel + ' → ' + sampleRef);
|
|
699
|
+
}
|
|
700
|
+
const dropped = new Map(treeDocs).set(sampleRel, sampleText.split(sampleRef).join(''));
|
|
701
|
+
if (skillTreeReferenceProblems(dropped, skillsRootAbs).some((p) => p.startsWith(sampleRel))) {
|
|
702
|
+
problems.push('相对路径引用判据误报(抽掉引用后仍报该册): ' + sampleRel);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const explicitEntry = [...treeDocs].find(([rel, text]) => !rel.startsWith(SKILL_TREE_ENTRY_BOOK + '/')
|
|
706
|
+
&& text.includes(SKILL_TREE_EXPLICIT_REFERENCE_PREFIX));
|
|
707
|
+
if (!explicitEntry) {
|
|
708
|
+
problems.push('形态收窄反向构造的前提不成立:节点册里找不到显式跨册指针'
|
|
709
|
+
+ '(`' + SKILL_TREE_EXPLICIT_REFERENCE_PREFIX + 'reference/…`)');
|
|
710
|
+
} else {
|
|
711
|
+
const [nodeRel, nodeText] = explicitEntry;
|
|
712
|
+
const explicitRef = nodeText.match(
|
|
713
|
+
new RegExp('\\.\\.\\/flow-comet\\/reference\\/[A-Za-z0-9._-]+\\.(?:md|json)'))[0];
|
|
714
|
+
const reverted = new Map(treeDocs).set(nodeRel,
|
|
715
|
+
nodeText.split(explicitRef).join(explicitRef.replace(SKILL_TREE_EXPLICIT_REFERENCE_PREFIX, '')));
|
|
716
|
+
if (!skillTreeReferenceProblems(reverted, skillsRootAbs).some((p) => p.includes('解析不到'))) {
|
|
717
|
+
problems.push('反向构造判别力缺失(节点册指针改回裸形态未被判违规): ' + nodeRel + ' → ' + explicitRef);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
// —— 附 2:成对展开文件的指针不得指错(上一条只证明目标**存在**,本条判**指对了**)——
|
|
721
|
+
{
|
|
722
|
+
const bookRels = [...treeDocs.keys()].filter((rel) => rel.endsWith('/SKILL.md')
|
|
723
|
+
&& !path.posix.dirname(rel).includes('/'));
|
|
724
|
+
const hasOwnGuidance = (rel) => fs.existsSync(path.join(skillsRootAbs, path.posix.dirname(rel), 'GUIDANCE.md'));
|
|
725
|
+
const pairedRels = bookRels.filter(hasOwnGuidance);
|
|
726
|
+
const entryHasOwn = hasOwnGuidance(PAIRED_GUIDANCE_ENTRY_REL);
|
|
727
|
+
// 前提:成对形态在场(否则判据空转)+ 入口册的例外目标在场(入口册无同名展开版时)。
|
|
728
|
+
if (pairedRels.length === 0) {
|
|
729
|
+
problems.push('成对指针判据的前提不成立:技能树里找不到任何带同目录 GUIDANCE.md 的册');
|
|
730
|
+
}
|
|
731
|
+
if (!entryHasOwn
|
|
732
|
+
&& !fs.existsSync(path.join(skillsRootAbs, path.posix.dirname(PAIRED_GUIDANCE_ENTRY_REL),
|
|
733
|
+
PAIRED_GUIDANCE_ENTRY_TARGET))) {
|
|
734
|
+
problems.push('成对指针判据的前提不成立:入口册展开版 ' + PAIRED_GUIDANCE_ENTRY_TARGET + ' 不在场(唯一例外无处指向)');
|
|
735
|
+
}
|
|
736
|
+
problems.push(...pairedGuidancePointerProblems(treeDocs, skillsRootAbs));
|
|
737
|
+
// 反向构造(同一判据驱动):① 带同目录 GUIDANCE 的册改指**入口册**展开版 ⇒ 必报「指错文档」;
|
|
738
|
+
// ② 改指**另一册**的展开版 ⇒ 必报(另一侧形态,证明判据不靠"是否含 GUIDANCE.md 子串"恒真);
|
|
739
|
+
// ③ 入口册改指裸文件名 ⇒ 必报(唯一例外侧);④ 抽掉指针 ⇒ 必报缺指针;⑤ 同册第二处指针 ⇒ 必报
|
|
740
|
+
// 重复;⑥ 无配对展开版的册带指针 ⇒ 必报;⑦ 无配对展开版的册不带指针 ⇒ **零误报**(判据不恒真)。
|
|
741
|
+
const pointerProbe = (rel, target) => new Map(treeDocs).set(rel,
|
|
742
|
+
(treeDocs.get(rel) ?? '').replace(PAIRED_GUIDANCE_POINTER_RE,
|
|
743
|
+
'<!-- 手写区详细协议见 ' + target + '(可选阅读) -->'));
|
|
744
|
+
const probeRel = pairedRels.find((rel) => rel !== PAIRED_GUIDANCE_ENTRY_REL);
|
|
745
|
+
const otherProbeRel = pairedRels.find((rel) => rel !== probeRel);
|
|
746
|
+
const quietRel = bookRels.find((rel) => rel !== PAIRED_GUIDANCE_ENTRY_REL && !hasOwnGuidance(rel));
|
|
747
|
+
const probeText = treeDocs.get(probeRel) ?? '';
|
|
748
|
+
const pointerLine = probeText.match(PAIRED_GUIDANCE_POINTER_RE)?.[0] ?? '';
|
|
749
|
+
if (!probeRel || !otherProbeRel || !quietRel || !pointerLine) {
|
|
750
|
+
problems.push('成对指针反向构造的前提不成立:成对册不足两册 / 无无配对展开版的非入口册 / 探针册无指针行');
|
|
751
|
+
} else {
|
|
752
|
+
const probes = [
|
|
753
|
+
['册改指入口册展开版', pointerProbe(probeRel, '../flow-comet/reference/entry-detail.md'), '指错文档'],
|
|
754
|
+
['册改指另一册展开版', pointerProbe(probeRel,
|
|
755
|
+
'../' + path.posix.dirname(otherProbeRel) + '/GUIDANCE.md'), '指错文档'],
|
|
756
|
+
['抽掉指针', new Map(treeDocs).set(probeRel, probeText.replace(PAIRED_GUIDANCE_POINTER_RE, '')),
|
|
757
|
+
'缺「手写区详细协议见 …」指针'],
|
|
758
|
+
['同册第二处指针', new Map(treeDocs).set(probeRel, probeText + '\n' + pointerLine), '只允许 1 处'],
|
|
759
|
+
['无配对展开版的册带指针', new Map(treeDocs).set(quietRel,
|
|
760
|
+
(treeDocs.get(quietRel) ?? '') + '\n' + pointerLine), '既无同目录 GUIDANCE.md 也非入口册'],
|
|
761
|
+
];
|
|
762
|
+
if (!entryHasOwn) {
|
|
763
|
+
probes.push(['入口册改指裸文件名', pointerProbe(PAIRED_GUIDANCE_ENTRY_REL, 'GUIDANCE.md'), '指错文档']);
|
|
764
|
+
}
|
|
765
|
+
for (const [label, probed, expected] of probes) {
|
|
766
|
+
if (!pairedGuidancePointerProblems(probed, skillsRootAbs).some((p) => p.includes(expected))) {
|
|
767
|
+
problems.push('反向构造判别力缺失(成对指针: ' + label + ' 未被判违规)');
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
if (!quietRel) {
|
|
772
|
+
problems.push('成对指针反向构造的前提不成立:找不到无配对展开版的非入口册');
|
|
773
|
+
} else if (pairedGuidancePointerProblems(new Map([[quietRel,
|
|
774
|
+
(treeDocs.get(quietRel) ?? '').replace(PAIRED_GUIDANCE_POINTER_RE, '')]]), skillsRootAbs).length !== 0) {
|
|
775
|
+
problems.push('成对指针判据误报(无配对展开版且不带指针的册被判违规): ' + quietRel);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (problems.length > 0) throw new Error('技能文本锁(相对路径引用族)不符: ' + problems.join('; '));
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
// 184c: 纪律判别句式族——入口 archive 读法三要素、plan/task 判别句式 + GUIDANCE 委托消化、
|
|
784
|
+
// Codex 平台事实与支持面(权威处唯一 + 引用册指针在场 + 判别句不回流)。
|
|
785
|
+
{
|
|
786
|
+
name: '184c 技能文本锁:入口 archive 读法 + 规划约束判别句 + Codex 平台事实',
|
|
787
|
+
run: () => {
|
|
788
|
+
const problems = [];
|
|
789
|
+
// —— 入口 archive 读法:三要素关键词在场 ——
|
|
790
|
+
{
|
|
791
|
+
const entry = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8');
|
|
792
|
+
for (const keyword of ['flow-kit/templates', '何时可读', '不读什么']) {
|
|
793
|
+
if (!entry.includes(keyword)) {
|
|
794
|
+
problems.push('flow-comet/SKILL.md 缺「' + keyword + '」(入口 archive 读法三要素)');
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// —— 规划约束:plan / task 判别句式 + GUIDANCE 委托消化 ——
|
|
799
|
+
{
|
|
800
|
+
const directLockPhrase = 'direct 不是并行任务的逃生口';
|
|
801
|
+
const r15Keywords = {
|
|
802
|
+
'flow-comet-plan': ['同一文件', '并发同伴', directLockPhrase],
|
|
803
|
+
'flow-comet-task': ['同一文件', '并发同伴', directLockPhrase],
|
|
804
|
+
};
|
|
805
|
+
const planText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-plan', 'SKILL.md'), 'utf8');
|
|
806
|
+
const taskText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-task', 'SKILL.md'), 'utf8');
|
|
807
|
+
for (const [skillDir, keywords] of Object.entries(r15Keywords)) {
|
|
808
|
+
const text = skillDir === 'flow-comet-plan' ? planText : taskText;
|
|
809
|
+
for (const keyword of keywords) {
|
|
810
|
+
if (!text.includes(keyword)) {
|
|
811
|
+
problems.push(skillDir + '/SKILL.md 缺「' + keyword + '」(规划期约束判别句式)');
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
if (planText.includes('Same layer = same wave (parallel execution)')) {
|
|
816
|
+
problems.push('flow-comet-plan/SKILL.md 残留「Same layer = same wave (parallel execution)」旧同层并行句');
|
|
817
|
+
}
|
|
818
|
+
if (!planText.includes('以本节为准')) {
|
|
819
|
+
problems.push('flow-comet-plan/SKILL.md 缺「以本节为准」(上游宽松语义显式覆盖锚)');
|
|
820
|
+
}
|
|
821
|
+
if (taskText.includes('同层并行,跨层串行')) {
|
|
822
|
+
problems.push('flow-comet-task/SKILL.md 残留「同层并行,跨层串行」旧波次句');
|
|
823
|
+
}
|
|
824
|
+
if (!taskText.includes('以本节点为准')) {
|
|
825
|
+
problems.push('flow-comet-task/SKILL.md 缺「以本节点为准」(上游宽松语义显式覆盖锚)');
|
|
826
|
+
}
|
|
827
|
+
const guidanceRel = 'flow-comet/reference/entry-detail.md';
|
|
828
|
+
const guidance = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'reference', 'entry-detail.md'), 'utf8');
|
|
829
|
+
if (!guidance.includes('仍必须由 subagent-execute 委托消化')) {
|
|
830
|
+
problems.push(guidanceRel + ' 缺「仍必须由 subagent-execute 委托消化」(direct 委托消化判别句)');
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
// —— ⑤ Codex 平台事实与支持面(**判别句随 `worktree-notes.md` 移出技能树而迁入
|
|
834
|
+
// `reference/platform-facts.md`**,ADR-016):判据 = 权威文件在场 + 判别句在权威处
|
|
835
|
+
//(含被反驳引用形态、适用范围限定、fail-open / 未闭合的现判据)+ 各引用册指针在场 +
|
|
836
|
+
// **判别句不再回流册子**(权威处唯一——原「两处各自须含」的逐字锁已作废)。
|
|
837
|
+
{
|
|
838
|
+
const platformFactsRel = 'flow-comet/reference/platform-facts.md';
|
|
839
|
+
const factsFile = path.join(SCRIPTS_DIR, '..', 'reference', 'platform-facts.md');
|
|
840
|
+
const pointerBooks = [
|
|
841
|
+
['flow-comet-subagent-execute/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-subagent-execute', 'SKILL.md'), 'utf8')],
|
|
842
|
+
['flow-comet-execute/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-execute', 'SKILL.md'), 'utf8')],
|
|
843
|
+
['flow-comet/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8')],
|
|
844
|
+
];
|
|
845
|
+
if (!fs.existsSync(factsFile)) {
|
|
846
|
+
problems.push(platformFactsRel + ' 不在场(判别句的唯一权威处缺失——原 worktree-notes 的锚无处可寻)');
|
|
847
|
+
} else {
|
|
848
|
+
const facts = fs.readFileSync(factsFile, 'utf8');
|
|
849
|
+
problems.push(...platformFactsAuthorityProblems(platformFactsRel, facts, pointerBooks));
|
|
850
|
+
// 反向构造(同一判据驱动):① 权威处逐条抽掉判别句 ⇒ 必报缺句;② 判别句回流任一册 ⇒ 必报
|
|
851
|
+
//(「权威处唯一」——原逐字锁**要求**两处各持一份,恰恰抓不到回流);③ 旧独断句 / 旧过宽句
|
|
852
|
+
// 还原进权威处 ⇒ 必报残留。
|
|
853
|
+
for (const phrase of [...PLATFORM_FACTS_ONLY_PHRASES, 'fail-open', '未闭合']) {
|
|
854
|
+
const stripped = facts.split(phrase).join('(反向构造:抽掉)');
|
|
855
|
+
if (stripped === facts) continue;
|
|
856
|
+
if (!platformFactsAuthorityProblems(platformFactsRel, stripped, pointerBooks)
|
|
857
|
+
.some((p) => p.includes(phrase.slice(0, 20)))) {
|
|
858
|
+
problems.push('反向构造判别力缺失(平台事实: 抽掉「' + phrase.slice(0, 20) + '…」未被判缺失)');
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
for (const phrase of PLATFORM_FACTS_ONLY_PHRASES) {
|
|
862
|
+
const injected = pointerBooks.map(([rel, text]) => [rel, text + '\n' + phrase + '\n']);
|
|
863
|
+
if (!platformFactsAuthorityProblems(platformFactsRel, facts, injected)
|
|
864
|
+
.some((p) => p.includes('回流了平台事实的证据正文'))) {
|
|
865
|
+
problems.push('反向构造判别力缺失(平台事实: 把证据正文复制回册子未被判违规)');
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
const revertedFacts = platformFactsAuthorityProblems(platformFactsRel,
|
|
869
|
+
facts + '\n受支持的工作流仍是串行执行。写入仍会被协调者白名单拦截。\n', pointerBooks);
|
|
870
|
+
for (const label of ['旧独断句', '旧过宽句']) {
|
|
871
|
+
if (!revertedFacts.some((p) => p.includes(label))) {
|
|
872
|
+
problems.push('反向构造判别力缺失(平台事实: 还原' + label + '未被判残留)');
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
const revertedClaimFacts = platformFactsAuthorityProblems(platformFactsRel,
|
|
876
|
+
facts + '\n不使用并行委托。\n', pointerBooks);
|
|
877
|
+
if (!revertedClaimFacts.some((p) => p.includes('非被反驳引用形态'))) {
|
|
878
|
+
problems.push('反向构造判别力缺失(平台事实: 还原裸旧独断句未被判违规)');
|
|
879
|
+
}
|
|
880
|
+
if (!platformFactsAuthorityProblems(platformFactsRel, facts, [
|
|
881
|
+
// 抽掉指针按**文件名子串**(不带反引号、不带前缀)——指针形态从裸形态统一为显式跨册形态
|
|
882
|
+
// 时本探针仍有效(形态变化不得让反向构造静默失效)。
|
|
883
|
+
...pointerBooks.slice(0, 1).map(([rel, text]) => [rel, text.split('reference/platform-facts.md').join('(反向构造:抽掉指针)')]),
|
|
884
|
+
...pointerBooks.slice(1),
|
|
885
|
+
]).some((p) => p.includes('引用册指针不在场'))) {
|
|
886
|
+
problems.push('反向构造判别力缺失(平台事实: 抽掉引用册指针未被判违规)');
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (problems.length > 0) throw new Error('技能文本锁(纪律判别句式族)不符: ' + problems.join('; '));
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
|
|
894
|
+
// 184d: 三块归一处(ADR-016)——pathspec / 集成纪律归 `reference/commit-discipline.md`、四属性
|
|
895
|
+
// 契约归入口册与平台事实册;「要点句在场 + 权威处唯一 + 判别句不再要求两册逐字一致」。
|
|
896
|
+
{
|
|
897
|
+
name: '184d 技能文本锁:三块归一处与委托契约纪律要点句',
|
|
898
|
+
run: () => {
|
|
899
|
+
const problems = [];
|
|
900
|
+
// —— ⑥ 三块归一处(ADR-016):原「两册三块逐字一致(切片 ≥400 字符)+ 两册各持 41 条判别句」
|
|
901
|
+
// 的逐字锁**作废**,改为「两册各自的要点句在场 + 权威处唯一 + 留正文的判别句逐句留原文但
|
|
902
|
+
// **不再要求两册相同**」。归一处:pathspec 与集成 → `reference/commit-discipline.md` 全文;
|
|
903
|
+
// 四属性契约 → 入口册 + `reference/platform-facts.md`。判别句按性质分流:属「该怎么干」的
|
|
904
|
+
// 留两册正文(外部原则:非显然的坑留正文),属「证据与判级」的随平台事实移走。
|
|
905
|
+
{
|
|
906
|
+
const bookTexts = new Map([
|
|
907
|
+
['flow-comet-subagent-execute/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-subagent-execute', 'SKILL.md'), 'utf8')],
|
|
908
|
+
['flow-comet-execute/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-execute', 'SKILL.md'), 'utf8')],
|
|
909
|
+
]);
|
|
910
|
+
const commitDisciplineText = fs.readFileSync(
|
|
911
|
+
path.join(SCRIPTS_DIR, '..', 'reference', 'commit-discipline.md'), 'utf8');
|
|
912
|
+
const elementDocs = new Map([...bookTexts, [COMMIT_DISCIPLINE_REL, commitDisciplineText]]);
|
|
913
|
+
const authorityTexts = new Map([
|
|
914
|
+
[COMMIT_DISCIPLINE_REL, commitDisciplineText],
|
|
915
|
+
[PLATFORM_FACTS_REL, fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'reference', 'platform-facts.md'), 'utf8')],
|
|
916
|
+
['flow-comet/SKILL.md', fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8')],
|
|
917
|
+
]);
|
|
918
|
+
const disciplineSources = { books: bookTexts, elementDocs, authorityTexts };
|
|
919
|
+
problems.push(...delegationDisciplineProblems(disciplineSources));
|
|
920
|
+
// 反向构造(同一判据驱动):逐条抽掉 ⇒ 必报;逐条回流 ⇒ 必报。判别力不依赖人工实验:
|
|
921
|
+
// 要素级 token / 权威处判别句 / 能力契约判别句 / 条件句指针 / 证据与判级判别句五组各取全量。
|
|
922
|
+
const subRel = 'flow-comet-subagent-execute/SKILL.md';
|
|
923
|
+
const exRel = 'flow-comet-execute/SKILL.md';
|
|
924
|
+
const strip = (text, phrase) => text.split(phrase).join('(反向构造:抽掉)');
|
|
925
|
+
const withBook = (rel, text) => ({ ...disciplineSources, books: new Map(bookTexts).set(rel, text) });
|
|
926
|
+
const withElementDoc = (rel, text) => ({ ...disciplineSources, elementDocs: new Map(elementDocs).set(rel, text) });
|
|
927
|
+
const withAuthority = (rel, text) => ({ ...disciplineSources, authorityTexts: new Map(authorityTexts).set(rel, text) });
|
|
928
|
+
for (const [label, tokens] of COMMIT_DISCIPLINE_ELEMENT_GROUPS) {
|
|
929
|
+
const stripped = strip(elementDocs.get(subRel), tokens[0]);
|
|
930
|
+
if (stripped === elementDocs.get(subRel)) continue;
|
|
931
|
+
if (!delegationDisciplineProblems(withElementDoc(subRel, stripped)).some((p) => p.includes(label))) {
|
|
932
|
+
problems.push('反向构造判别力缺失(' + label + ' 的要点 token 被抽掉未被判缺)');
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
for (const phrase of COMMIT_DISCIPLINE_AUTHORITY_PHRASES) {
|
|
936
|
+
if (!commitDisciplineText.includes(phrase)) continue; // 缺失已由真实判据报告
|
|
937
|
+
if (!delegationDisciplineProblems(withAuthority(COMMIT_DISCIPLINE_REL, strip(commitDisciplineText, phrase)))
|
|
938
|
+
.some((p) => p.includes(phrase.slice(0, 40)))) {
|
|
939
|
+
problems.push('反向构造判别力缺失(抽掉 ' + COMMIT_DISCIPLINE_REL + ' 权威处判别句未被判缺): '
|
|
940
|
+
+ phrase.slice(0, 40) + '…');
|
|
941
|
+
}
|
|
942
|
+
if (!delegationDisciplineProblems(withBook(subRel, bookTexts.get(subRel) + '\n' + phrase + '\n'))
|
|
943
|
+
.some((p) => p.includes('回流了'))) {
|
|
944
|
+
problems.push('反向构造判别力缺失(权威处正文回流册子未被判违规): ' + phrase.slice(0, 40) + '…');
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
for (const phrase of PARALLEL_CONTRACT_BOOK_PHRASES) {
|
|
948
|
+
if (!bookTexts.get(exRel).includes(phrase)) continue;
|
|
949
|
+
if (!delegationDisciplineProblems(withBook(exRel, strip(bookTexts.get(exRel), phrase)))
|
|
950
|
+
.some((p) => p.includes(phrase.slice(0, 40)))) {
|
|
951
|
+
problems.push('反向构造判别力缺失(抽掉四属性契约判别句未被判缺): ' + phrase.slice(0, 40) + '…');
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
for (const pointer of DELEGATION_POINTER_RELS) {
|
|
955
|
+
const stripped = bookTexts.get(subRel).split(pointer).join('(反向构造:抽掉指针)');
|
|
956
|
+
if (!delegationDisciplineProblems(withBook(subRel, stripped)).some((p) => p.includes('指针不在场'))) {
|
|
957
|
+
problems.push('反向构造判别力缺失(抽掉条件句指针未被判违规): ' + pointer);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
for (const phrase of CONTRACT_EVIDENCE_AUTHORITY_PHRASES) {
|
|
961
|
+
if (!authorityTexts.get(PLATFORM_FACTS_REL).includes(phrase)) continue;
|
|
962
|
+
if (!delegationDisciplineProblems(withAuthority(PLATFORM_FACTS_REL,
|
|
963
|
+
strip(authorityTexts.get(PLATFORM_FACTS_REL), phrase))).some((p) => p.includes(phrase.slice(0, 40)))) {
|
|
964
|
+
problems.push('反向构造判别力缺失(抽掉证据与判级判别句未被判缺): ' + phrase.slice(0, 40) + '…');
|
|
965
|
+
}
|
|
966
|
+
if (!delegationDisciplineProblems(withBook(subRel, bookTexts.get(subRel) + '\n' + phrase + '\n'))
|
|
967
|
+
.some((p) => p.includes('回流了证据与判级判别句'))) {
|
|
968
|
+
problems.push('反向构造判别力缺失(证据与判级判别句回流册子未被判违规): ' + phrase.slice(0, 40) + '…');
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
// 旧表述零残留(原文语义与失败消息保持):无条件 worktree 口号只允许以「已作废」的被反驳
|
|
972
|
+
// 形态出现;「未获机制明文放行」现状表述一律清零(集成纪律已成文)。配逐条反向构造。
|
|
973
|
+
const staleResidueProblems = (rel, text) => {
|
|
974
|
+
const out = [];
|
|
975
|
+
if (text.split('「一律 worktree」的口号已作废').join('').includes('一律 worktree')) {
|
|
976
|
+
out.push(rel + ' 残留无条件 worktree 口号(非被反驳形态)');
|
|
977
|
+
}
|
|
978
|
+
if (text.includes('未获机制明文放行')) {
|
|
979
|
+
out.push(rel + ' 残留「未获机制明文放行」现状表述(集成纪律已成文)');
|
|
980
|
+
}
|
|
981
|
+
return out;
|
|
982
|
+
};
|
|
983
|
+
for (const [rel, text] of bookTexts) {
|
|
984
|
+
problems.push(...staleResidueProblems(rel, text));
|
|
985
|
+
const revertedSlogan = text.split('「一律 worktree」的口号已作废').join('一律 worktree 是必须的');
|
|
986
|
+
if (!staleResidueProblems(rel, revertedSlogan).some((p) => p.includes('无条件 worktree 口号'))) {
|
|
987
|
+
problems.push(rel + ' 反向构造判别力缺失(还原无条件 worktree 口号未被判违规)');
|
|
988
|
+
}
|
|
989
|
+
const revertedStatus = text + '\n未获机制明文放行。\n';
|
|
990
|
+
if (!staleResidueProblems(rel, revertedStatus).some((p) => p.includes('未获机制明文放行'))) {
|
|
991
|
+
problems.push(rel + ' 反向构造判别力缺失(还原现状表述未被判违规)');
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
// —— ⑦ CC 行判级升格 + 三平台 cwd 语义对照(真机实测落地)——重定向后判据 = 「权威处
|
|
995
|
+
// 正文在场 + 各引用册指针在场 + **仅两处承载**」:入口册的 7 条字面量是**能力契约锚**(本
|
|
996
|
+
// 批明文保留),原 `reference/worktree-notes.md` 的 6 条整句随文件移出技能树而改锚到
|
|
997
|
+
// `reference/platform-facts.md`(T07 逐字搬入);两组文本都不得散进其余册(唯一处 = 入口册
|
|
998
|
+
// + 平台事实册)。锚一律取**段内独有判别句式**(裸子串会被同文件其它上下文满足而恒真——
|
|
999
|
+
// );cwd 对照表**逐行有锚**(三行各自独立,缺任一行即判残缺);旧「未覆盖」判级句零残留。
|
|
1000
|
+
const entrySkillText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8');
|
|
1001
|
+
const platformFactsText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'reference', 'platform-facts.md'), 'utf8');
|
|
1002
|
+
const otherBooks = new Map([
|
|
1003
|
+
['flow-comet-subagent-execute/SKILL.md', bookTexts.get('flow-comet-subagent-execute/SKILL.md')],
|
|
1004
|
+
['flow-comet-execute/SKILL.md', bookTexts.get('flow-comet-execute/SKILL.md')],
|
|
1005
|
+
]);
|
|
1006
|
+
for (const [, file] of skillTreeDocFiles()) {
|
|
1007
|
+
const rel = path.relative(path.join(SCRIPTS_DIR, '..', '..'), file).replaceAll('\\', '/');
|
|
1008
|
+
if (rel === 'flow-comet/SKILL.md' || rel === 'flow-comet/reference/platform-facts.md') continue;
|
|
1009
|
+
if (otherBooks.has(rel)) continue;
|
|
1010
|
+
otherBooks.set(rel, fs.readFileSync(file, 'utf8'));
|
|
1011
|
+
}
|
|
1012
|
+
const upgradeSources = { entry: entrySkillText, facts: platformFactsText, others: otherBooks };
|
|
1013
|
+
problems.push(...identityUpgradeProblems(upgradeSources));
|
|
1014
|
+
// 反向构造(同一判据驱动):① 权威处 / 入口册逐句抽掉 ⇒ 必报该句缺失;② 把整句复制进
|
|
1015
|
+
// 其余任一册 ⇒ 必报「回流」(唯一处的方向——原两处锁**要求**多份,抓不到散播);③ 旧判级
|
|
1016
|
+
// 句还原 ⇒ 必报残留。
|
|
1017
|
+
for (const [side, phrase] of [
|
|
1018
|
+
...IDENTITY_UPGRADE_ENTRY_PHRASES.map((p) => ['entry', p]),
|
|
1019
|
+
...IDENTITY_UPGRADE_AUTHORITY_PHRASES.map((p) => ['facts', p]),
|
|
1020
|
+
]) {
|
|
1021
|
+
const source = side === 'entry' ? entrySkillText : platformFactsText;
|
|
1022
|
+
if (!source.includes(phrase)) continue; // 缺失已由真实判据报告
|
|
1023
|
+
const stripped = identityUpgradeProblems({
|
|
1024
|
+
...upgradeSources, [side]: source.split(phrase).join('(反向构造:抽掉)'),
|
|
1025
|
+
});
|
|
1026
|
+
if (!stripped.some((p) => p.includes(phrase.slice(0, 40)))) {
|
|
1027
|
+
problems.push('反向构造判别力缺失(抽掉「CC 行升格 / 三平台 cwd 对照」判别句未被判缺): '
|
|
1028
|
+
+ phrase.slice(0, 40) + '…');
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
const injectedBookRel = 'flow-comet-subagent-execute/SKILL.md';
|
|
1032
|
+
for (const phrase of [...IDENTITY_UPGRADE_ENTRY_PHRASES, ...IDENTITY_UPGRADE_AUTHORITY_PHRASES]) {
|
|
1033
|
+
const injected = identityUpgradeProblems({
|
|
1034
|
+
...upgradeSources,
|
|
1035
|
+
others: new Map(otherBooks).set(injectedBookRel, otherBooks.get(injectedBookRel) + '\n' + phrase + '\n'),
|
|
1036
|
+
});
|
|
1037
|
+
if (!injected.some((p) => p.includes('回流'))) {
|
|
1038
|
+
problems.push('反向构造判别力缺失(cwd 对照 / CC 判级句散进其余册未被判违规): ' + phrase.slice(0, 40) + '…');
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
for (const stale of IDENTITY_UPGRADE_STALE_PHRASES) {
|
|
1042
|
+
const revertedUpgrade = identityUpgradeProblems({
|
|
1043
|
+
...upgradeSources,
|
|
1044
|
+
entry: entrySkillText + '\n' + stale + '。\n',
|
|
1045
|
+
facts: platformFactsText + '\n' + stale + '。\n',
|
|
1046
|
+
});
|
|
1047
|
+
if (!revertedUpgrade.some((p) => p.includes('旧「未覆盖」判级表述'))) {
|
|
1048
|
+
problems.push('反向构造判别力缺失(还原旧「未覆盖」判级句未被判残留): ' + stale);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
// —— 文本 ↔ 实现一致锚:文本点名的实现常量 / 载荷键名 / 受保护目标必须与引擎同值 ——
|
|
1052
|
+
const guardSrc = fs.readFileSync(path.join(SCRIPTS_DIR, 'comet-hook-guard.mjs'), 'utf8');
|
|
1053
|
+
// 桥接源位于**仓库根** scripts/(分发面脚本,非技能包内)——安装副本形态(目标项目)该面
|
|
1054
|
+
// 结构性缺席:缺席时该侧锚不适用,但必须**显式可见**(未验证 ≠ 通过),不得静默跳过。
|
|
1055
|
+
const bridgePath = path.join(REPO_ROOT, 'scripts', 'dsh-bridge.mjs');
|
|
1056
|
+
const bridgeSrc = fs.existsSync(bridgePath) ? fs.readFileSync(bridgePath, 'utf8') : null;
|
|
1057
|
+
if (bridgeSrc === null) {
|
|
1058
|
+
console.log('SKIP: 184 的桥接侧一致锚(仓库根 scripts/dsh-bridge.mjs 为权威源检出面)'
|
|
1059
|
+
+ '——本次未校验「文本点名的身份透传变量与桥接注入处同值」,请在权威源检出重跑本套件');
|
|
1060
|
+
}
|
|
1061
|
+
const stateSchemaSrc = fs.readFileSync(path.join(SCRIPTS_DIR, 'state-schema.mjs'), 'utf8');
|
|
1062
|
+
const handoffSrc = fs.readFileSync(path.join(SCRIPTS_DIR, 'workflow-handoff.mjs'), 'utf8');
|
|
1063
|
+
// 在飞委托判据的落点**按导出符号反查**(不写文件名):判据模块 = 定义 inFlightHandoffRequests
|
|
1064
|
+
// 的引擎模块(hook 守卫只做写入拦截,两者同包不同册)——「撤回的 request 不再计为在飞」这一条
|
|
1065
|
+
// 必须在**该模块**里被消费(锚不按文件名取文本,模块搬家 / 再切分不必改锚)。
|
|
1066
|
+
const inFlightModule = engineDefinitionModule('inFlightHandoffRequests');
|
|
1067
|
+
if (inFlightModule === null) {
|
|
1068
|
+
throw new Error('在飞委托判据的定义面不唯一(应恰一处): '
|
|
1069
|
+
+ JSON.stringify(engineDefinitionHits('inFlightHandoffRequests')));
|
|
1070
|
+
}
|
|
1071
|
+
const inFlightJudgeSrc = inFlightModule.text;
|
|
1072
|
+
// 一致性判据(单一实现:真实判据与反向构造探针共用本函数)。
|
|
1073
|
+
const consistencyProblems = ({ guard, bridge, schema, handoff, inFlightJudge, books }) => {
|
|
1074
|
+
const out = [];
|
|
1075
|
+
// ① 身份判据的载荷键:文本声称判据 = agent_id;引擎身份判据段必须读取该键。
|
|
1076
|
+
const regionStart = guard.indexOf('function payloadAgentIdentity');
|
|
1077
|
+
const regionEnd = guard.indexOf('const __dirname');
|
|
1078
|
+
if (regionStart < 0 || regionEnd <= regionStart) {
|
|
1079
|
+
out.push('comet-hook-guard.mjs 未找到身份判据段(文本与实现无法对照)');
|
|
1080
|
+
} else {
|
|
1081
|
+
const identityRegion = guard.slice(regionStart, regionEnd);
|
|
1082
|
+
if (!identityRegion.includes('input.agent_id')) {
|
|
1083
|
+
out.push('身份判据段未读取载荷 agent_id(文本声称的判据键与实现不一致)');
|
|
1084
|
+
}
|
|
1085
|
+
// ② agent_type 只是载荷形态描述、不是判据:身份判据段零使用(文本与实现逐字一致)。
|
|
1086
|
+
if (identityRegion.includes('agent_type')) {
|
|
1087
|
+
out.push('身份判据段使用了 agent_type(文本声称判据 = agent_id,二者不一致)');
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
// ③ 身份透传的环境变量名单一:守卫读取处与桥接注入处同值(文本两侧同值)。
|
|
1091
|
+
if (!guard.includes('process.env.FLOW_COMET_AGENT_DEPTH')) {
|
|
1092
|
+
out.push('守卫未读取环境变量身份深度(与文本 / 桥接不一致)');
|
|
1093
|
+
}
|
|
1094
|
+
if (bridge === null) {
|
|
1095
|
+
// 结构性缺席(安装副本形态无仓库根 scripts/):该侧锚不适用——可见 SKIP 由场景主体输出,
|
|
1096
|
+
// 此处不判违规也不静默当通过(未验证 ≠ 通过)。
|
|
1097
|
+
} else if (!bridge.includes('FLOW_COMET_AGENT_DEPTH')) {
|
|
1098
|
+
out.push('桥接未透传环境变量身份深度(与文本 / 守卫不一致)');
|
|
1099
|
+
}
|
|
1100
|
+
// ③b 桥接通道标记的名单一与值单一(env 面身份的作用域收紧):守卫读取处、守卫判据常量、
|
|
1101
|
+
// 桥接注入处三处同值;缺任一处即「文本声称需标记自证、实现却直接认深度」的分叉。
|
|
1102
|
+
// 文本侧的判据由两册同锁块承载(见上方 contractLockPhrases 的标记判别句)。
|
|
1103
|
+
if (!guard.includes('process.env.FLOW_COMET_AGENT_DEPTH_SOURCE')) {
|
|
1104
|
+
out.push('守卫未读取桥接通道标记(env 面身份的作用域收紧无实现承载)');
|
|
1105
|
+
}
|
|
1106
|
+
if (!guard.includes("BRIDGE_DEPTH_CHANNEL_MARKER = 'dsh-bridge'")) {
|
|
1107
|
+
out.push('守卫缺桥接通道标记的判据常量(标记值无单一来源)');
|
|
1108
|
+
}
|
|
1109
|
+
if (bridge === null) {
|
|
1110
|
+
// 同上:安装副本形态无仓库根 scripts/,该侧锚不适用。
|
|
1111
|
+
} else if (!/FLOW_COMET_AGENT_DEPTH_SOURCE:\s*'dsh-bridge'/.test(bridge)) {
|
|
1112
|
+
out.push('桥接未注入桥接通道标记 ' + "'dsh-bridge'" + '(守卫要求标记在场,桥接不注入即通道失效)');
|
|
1113
|
+
}
|
|
1114
|
+
// ③c 撤回留痕的字段名与判据落点:文本点名的两个字段由单一实现判定,且守卫的在飞判据
|
|
1115
|
+
// 必须消费该实现(缺一即「文本说撤回可放行、实现仍按在飞拦」)。
|
|
1116
|
+
if (!schema.includes('withdrawnAt') || !schema.includes('withdrawnBy')) {
|
|
1117
|
+
out.push('撤回留痕字段名未落在单一判据实现(与文本声称的 withdrawnAt / withdrawnBy 不一致)');
|
|
1118
|
+
}
|
|
1119
|
+
if (!/handoffRequestWithdrawn\(requests\[taskId\]\)/.test(inFlightJudge)) {
|
|
1120
|
+
out.push('在飞委托判据未消费撤回留痕判据(撤回的 request 仍会被计为在飞)');
|
|
1121
|
+
}
|
|
1122
|
+
// ④ 最小保护集的两个目标:实现侧取值来源(状态文件路径常量 + 协议解析结果)与文本字面同值。
|
|
1123
|
+
if (!schema.includes("RUNTIME_DIR = '.flow-comet'")
|
|
1124
|
+
|| !schema.includes("RUNTIME_STATE_FILE_NAME = 'flow-comet-state.json'")) {
|
|
1125
|
+
out.push('状态文件路径常量与文本声称的受保护目标不一致');
|
|
1126
|
+
}
|
|
1127
|
+
if (!guard.includes('blockedStateFileTarget') || !guard.includes('blockedProtocolFileTarget')) {
|
|
1128
|
+
out.push('守卫缺最小保护集判定入口(文本声称的两个受保护目标无实现承载)');
|
|
1129
|
+
}
|
|
1130
|
+
// ⑤ 留痕字段与落点:文本点名的既有字段 = 实现写入的嵌套键(零新增 state 顶层字段)。
|
|
1131
|
+
if (!handoff.includes("state.evidence['subagent-execute'].handoffRequests")) {
|
|
1132
|
+
out.push('留痕未落在嵌套证据(与文本声称的同族嵌套形态不一致)');
|
|
1133
|
+
}
|
|
1134
|
+
// ⑥ 零提交资格字段与落库形态:文本声称「提交隔离走既有 noCommit 资格」——实现必须在
|
|
1135
|
+
// request 侧真实记录该字段(文本说 A、实现说 B 即红)。
|
|
1136
|
+
if (!handoff.includes('noCommit: true')) {
|
|
1137
|
+
out.push('零提交资格落库形态与文本声称的 request 记录不一致(缺 noCommit: true)');
|
|
1138
|
+
}
|
|
1139
|
+
for (const [rel, text] of books) {
|
|
1140
|
+
if (!text.includes('.flow-comet/flow-comet-state.json')) {
|
|
1141
|
+
out.push(rel + ' 缺最小保护集目标字面(机器状态文件)');
|
|
1142
|
+
}
|
|
1143
|
+
if (!text.includes('reference/workflow-protocol.json')) {
|
|
1144
|
+
out.push(rel + ' 缺最小保护集目标字面(协议保护路径)');
|
|
1145
|
+
}
|
|
1146
|
+
if (!text.includes('handoffRequests') || !text.includes('handoffResult')) {
|
|
1147
|
+
out.push(rel + ' 缺留痕字段名(handoffRequests / handoffResult)');
|
|
1148
|
+
}
|
|
1149
|
+
if (!text.includes('noCommit')) {
|
|
1150
|
+
out.push(rel + ' 缺零提交资格字段名(noCommit)');
|
|
1151
|
+
}
|
|
1152
|
+
// 桥接通道标记名(env 面身份的作用域收紧):两册文本须点名标记本身——只说「env 透传
|
|
1153
|
+
// 深度」会让读者以为继承来的深度变量也能当身份用(正是收紧前的缺口表述)。
|
|
1154
|
+
if (!text.includes('FLOW_COMET_AGENT_DEPTH_SOURCE')) {
|
|
1155
|
+
out.push(rel + ' 缺桥接通道标记名(文本声称 env 面身份需标记自证,却未点名标记)');
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return out;
|
|
1159
|
+
};
|
|
1160
|
+
const consistencySources = { guard: guardSrc, bridge: bridgeSrc, schema: stateSchemaSrc, handoff: handoffSrc, inFlightJudge: inFlightJudgeSrc, books: bookTexts };
|
|
1161
|
+
problems.push(...consistencyProblems(consistencySources));
|
|
1162
|
+
// 反向构造(同一判据驱动):逐项把实现侧常量改成与文本不同的值 ⇒ 必报(文本说 A、实现说 B 即红)。
|
|
1163
|
+
const consistencyProbes = [
|
|
1164
|
+
['载荷键改名', { guard: guardSrc.replace('input.agent_id', 'input.agentId') }, 'agent_id'],
|
|
1165
|
+
['agent_type 混入判据段', {
|
|
1166
|
+
guard: guardSrc.replace('function payloadAgentIdentity',
|
|
1167
|
+
"function payloadAgentIdentity(input) { const probe = input.agent_type;\n"),
|
|
1168
|
+
}, 'agent_type'],
|
|
1169
|
+
['环境变量改名', { guard: guardSrc.replaceAll('FLOW_COMET_AGENT_DEPTH', 'FLOW_COMET_DEPTH') }, '环境变量身份深度'],
|
|
1170
|
+
// 桥接通道标记(env 面身份的作用域收紧)与撤回通道:逐项抽掉实现侧或文本侧的承载 ⇒ 必报。
|
|
1171
|
+
['桥接标记读取抽掉', { guard: guardSrc.replaceAll('process.env.FLOW_COMET_AGENT_DEPTH_SOURCE', 'process.env.FLOW_COMET_DEPTH_SOURCE') }, '桥接通道标记'],
|
|
1172
|
+
['桥接标记判据常量改名', { guard: guardSrc.replace("BRIDGE_DEPTH_CHANNEL_MARKER = 'dsh-bridge'", "BRIDGE_DEPTH_CHANNEL_MARKER = 'bridge'") }, '标记值无单一来源'],
|
|
1173
|
+
// 桥接源在安装副本形态结构性缺席(见上方 SKIP 行):该探针不构造——未验证 ≠ 通过,
|
|
1174
|
+
// 由 SKIP 行显式声明;不构造也不得让整块判据崩掉(缺席面不得变成套件错误)。
|
|
1175
|
+
...(bridgeSrc === null ? [] : [['桥接注入标记值漂移', { bridge: bridgeSrc.replaceAll("FLOW_COMET_AGENT_DEPTH_SOURCE: 'dsh-bridge'", "FLOW_COMET_AGENT_DEPTH_SOURCE: 'other'") }, '桥接未注入桥接通道标记']]),
|
|
1176
|
+
['撤回留痕字段改名', { schema: stateSchemaSrc.replaceAll('withdrawnBy', 'cancelledBy') }, '撤回留痕字段名未落在单一判据实现'],
|
|
1177
|
+
['在飞判据不消费撤回留痕', { inFlightJudge: inFlightJudgeSrc.replace('handoffRequestWithdrawn(requests[taskId])', 'false') }, '在飞委托判据未消费撤回留痕判据'],
|
|
1178
|
+
['文本侧桥接标记名缺失', { books: new Map([...bookTexts].map(([rel, text]) => [rel, text.split('FLOW_COMET_AGENT_DEPTH_SOURCE').join('(反向构造:抽掉)')])) }, '桥接通道标记名'],
|
|
1179
|
+
['状态文件路径常量改名', { schema: stateSchemaSrc.replace("RUNTIME_STATE_FILE_NAME = 'flow-comet-state.json'", "RUNTIME_STATE_FILE_NAME = 'state.json'") }, '状态文件路径常量'],
|
|
1180
|
+
['留痕落点改顶层', { handoff: handoffSrc.replaceAll("state.evidence['subagent-execute'].handoffRequests", 'state.handoffRequests') }, '留痕未落在嵌套证据'],
|
|
1181
|
+
['零提交落库形态改名', { handoff: handoffSrc.replaceAll('noCommit: true', 'zeroCommitFlag: true') }, '零提交资格落库形态'],
|
|
1182
|
+
['文本侧目标字面缺失', { books: new Map([...bookTexts].map(([rel, text]) => [rel, text.split('.flow-comet/flow-comet-state.json').join('(反向构造:抽掉)')])) }, '机器状态文件'],
|
|
1183
|
+
['文本侧零提交字段缺失', { books: new Map([...bookTexts].map(([rel, text]) => [rel, text.split('noCommit').join('(反向构造:抽掉)')])) }, '零提交资格字段名'],
|
|
1184
|
+
];
|
|
1185
|
+
for (const [probeLabel, override, expected] of consistencyProbes) {
|
|
1186
|
+
const probed = { ...consistencySources, ...override };
|
|
1187
|
+
if (!consistencyProblems(probed).some((p) => p.includes(expected))) {
|
|
1188
|
+
problems.push('反向构造判别力缺失(' + probeLabel + ' 未被判不一致)');
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (problems.length > 0) throw new Error('技能文本锁(三块归一处族)不符: ' + problems.join('; '));
|
|
1193
|
+
},
|
|
1194
|
+
},
|
|
1195
|
+
|
|
1196
|
+
// 184e: 文本 ↔ 实现一致族——7 字段集合锚(枚举自 `TASK7_REQUIRED` 常量派生后逐处对账;常量
|
|
1197
|
+
// 所在模块与文案派生模块**按符号反查**、不写文件名)+ 公开面口径机检(公开机制册判级一致 /
|
|
1198
|
+
// 变更日志条目带编号 PR 链接 / 已关闭缺口与建树适用面成文;公开面缺席时输出可见 SKIP)。
|
|
1199
|
+
{
|
|
1200
|
+
name: '184e 技能文本锁:7 字段集合文本↔实现一致 + 公开面口径机检',
|
|
1201
|
+
run: () => {
|
|
1202
|
+
const problems = [];
|
|
1203
|
+
// —— 7 字段集合的文本 ↔ 实现一致锚(文本不得说谎的**根治**面:任一处枚举分叉即红)——
|
|
1204
|
+
// 判据与反向构造探针见模块级 `task7SetAnchorProblems`(单一实现):唯一权威 = `TASK7_REQUIRED`
|
|
1205
|
+
// 常量(plan 出口判据的集合来源),技能树侧枚举**从该常量派生**后逐处对账——锚里不写第二份
|
|
1206
|
+
// 集合(第二份同口径表达会在判据演进时分叉);覆盖双语形态与斜杠枚举形态,同批固化「文案
|
|
1207
|
+
// 落后于判据」静默面(两处 BLOCKED 文案从判据常量派生)。两个实现侧落点(权威常量模块 /
|
|
1208
|
+
// 文案派生模块)由导出符号在引擎面内反查——模块再切分不必改锚。反向构造:任一处枚举改字段名
|
|
1209
|
+
//(depends_on → id)/ 抽掉整处枚举 / 常量侧改名 / 文案回写字面集合 ⇒ 必红。
|
|
1210
|
+
problems.push(...task7SetAnchorProblems({
|
|
1211
|
+
docs: new Map(skillTreeDocFiles().map(([rel, file]) => [rel, fs.readFileSync(file, 'utf8')])),
|
|
1212
|
+
}));
|
|
1213
|
+
// —— 公开面口径机检(文档不说假话):公开机制册的判级须与技能册一致、公开变更日志的新增
|
|
1214
|
+
// 条目须带**编号** PR 链接、技能册的已关闭缺口与建树适用面须写成本文。三面各自可判,
|
|
1215
|
+
// 并配反向构造(抽掉新表述 / 还原旧表述 ⇒ 必报)。公开面在安装副本形态结构性缺席:
|
|
1216
|
+
// 缺席时输出可见 SKIP(未验证 ≠ 通过),不得静默当通过。
|
|
1217
|
+
{
|
|
1218
|
+
const publicDocRelPaths = ['docs/MECHANISM.md', 'docs/MECHANISM-zh.md', 'CHANGELOG.md', 'CHANGELOG-zh.md'];
|
|
1219
|
+
const publicDocs = new Map(publicDocRelPaths.map((rel) => {
|
|
1220
|
+
const abs = path.join(REPO_ROOT, rel);
|
|
1221
|
+
return [rel, fs.existsSync(abs) ? fs.readFileSync(abs, 'utf8') : null];
|
|
1222
|
+
}));
|
|
1223
|
+
const missingDocFaces = [...publicDocs].filter(([, text]) => text === null).map(([rel]) => rel);
|
|
1224
|
+
if (missingDocFaces.length > 0) {
|
|
1225
|
+
console.log('SKIP: 184 的公开面口径锚(' + missingDocFaces.join(', ') + ')——本次检出无该公开文档面,'
|
|
1226
|
+
+ '未校验「公开机制册判级与技能册一致 / 变更日志新增条目链接带编号 / 建树适用面成文」,请在权威源检出重跑本套件');
|
|
1227
|
+
}
|
|
1228
|
+
const subagentFaceText = fs.readFileSync(
|
|
1229
|
+
path.join(SCRIPTS_DIR, '..', '..', 'flow-comet-subagent-execute', 'SKILL.md'), 'utf8');
|
|
1230
|
+
const entryFaceText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'SKILL.md'), 'utf8');
|
|
1231
|
+
// 第三面随 `worktree-notes.md` 移出技能树改读 `reference/platform-facts.md`(判别句新落点)。
|
|
1232
|
+
const factsFaceText = fs.readFileSync(path.join(SCRIPTS_DIR, '..', 'reference', 'platform-facts.md'), 'utf8');
|
|
1233
|
+
const treeScopeSentence = '**建树选择的适用面**';
|
|
1234
|
+
const treeBypassSentence = '**以建树绕过边界**不受支持';
|
|
1235
|
+
const staleTreeBan = '手工 `git worktree add <任意路径>` **不是受支持路径**';
|
|
1236
|
+
const gapClosureSentence = '该缺口现已被守卫关闭';
|
|
1237
|
+
// 公开变更日志的段切片(止于下一个版本标题)。
|
|
1238
|
+
const sectionAt = (text, start) => {
|
|
1239
|
+
const next = text.indexOf('\n## [', start + 1);
|
|
1240
|
+
return text.slice(start, next < 0 ? text.length : next);
|
|
1241
|
+
};
|
|
1242
|
+
const unreleasedSectionOf = (text) => {
|
|
1243
|
+
const start = text.indexOf('## [Unreleased]');
|
|
1244
|
+
return start < 0 ? null : sectionAt(text, start);
|
|
1245
|
+
};
|
|
1246
|
+
// 「最新条目段」(判据与反向构造共用同一切片,单一实现):dev 态新增条目在 `## [Unreleased]`;
|
|
1247
|
+
// 发布结算把条目移入最新版本段、Unreleased 只留空标题——这是仓库既有发布形态(`v1.6.2` tag 即
|
|
1248
|
+
// 「空 Unreleased + 版本段」,`v1.6.1` tag 甚至无 Unreleased 段)。只切 Unreleased 段的实现
|
|
1249
|
+
// 在发布态必然失配,故:Unreleased 段有条目则取之,否则回退到最新版本段。
|
|
1250
|
+
const newestEntriesSectionOf = (text) => {
|
|
1251
|
+
const unreleased = unreleasedSectionOf(text);
|
|
1252
|
+
if (unreleased !== null && /^- /m.test(unreleased)) return unreleased;
|
|
1253
|
+
const versioned = text.search(/^## \[\d+\.\d+\.\d+/m);
|
|
1254
|
+
if (versioned >= 0) return sectionAt(text, versioned);
|
|
1255
|
+
return unreleased;
|
|
1256
|
+
};
|
|
1257
|
+
// 一致性判据(单一实现:真实判据与反向构造探针共用本函数)。
|
|
1258
|
+
const publicFaceProblems = ({ mechanism, mechanismZh, changelog, changelogZh, subagentBook, entryBook, factsBook }) => {
|
|
1259
|
+
const out = [];
|
|
1260
|
+
// 公开机制册双语判级:CC 行「证实 + 限定形态」,未覆盖项照旧标注,旧判级句零残留。
|
|
1261
|
+
const gradeCases = [
|
|
1262
|
+
['docs/MECHANISM.md', mechanism,
|
|
1263
|
+
'payload `agent_id` / `agent_type` — **verified**, in a stated shape only',
|
|
1264
|
+
['`agent_type`', 'nested delegations', 'non-Windows environments', 'remain uncovered'],
|
|
1265
|
+
'payload `agent_id` — **not yet covered**'],
|
|
1266
|
+
['docs/MECHANISM-zh.md', mechanismZh,
|
|
1267
|
+
'载荷 `agent_id` / `agent_type`——**证实**,且**限定形态**',
|
|
1268
|
+
['`agent_type` 取值域', '嵌套委派载荷', '非 Windows 环境', '仍未覆盖'],
|
|
1269
|
+
'载荷 `agent_id`——真机会话**尚未覆盖**'],
|
|
1270
|
+
];
|
|
1271
|
+
for (const [rel, text, phrase, keep, stale] of gradeCases) {
|
|
1272
|
+
if (text === null) continue;
|
|
1273
|
+
if (!text.includes(phrase)) out.push(rel + ' 未把 CC 身份通道标为证实(缺判别句:' + phrase.slice(0, 30) + '…)');
|
|
1274
|
+
for (const item of keep) {
|
|
1275
|
+
if (!text.includes(item)) out.push(rel + ' 判级升格时丢了限定形态 / 未覆盖项(缺「' + item + '」)');
|
|
1276
|
+
}
|
|
1277
|
+
if (text.includes(stale)) out.push(rel + ' 残留旧判级表述「' + stale + '」');
|
|
1278
|
+
}
|
|
1279
|
+
// 公开变更日志:最新条目段的条目数与**条目行内**带编号 PR 链接数一致,且不得有空链接。
|
|
1280
|
+
// 计数面限定在条目行——版本段的摘要行另按惯例携带 PR 链接,段级计数会把摘要行读成条目失配。
|
|
1281
|
+
for (const [rel, text] of [['CHANGELOG.md', changelog], ['CHANGELOG-zh.md', changelogZh]]) {
|
|
1282
|
+
if (text === null) continue;
|
|
1283
|
+
const section = newestEntriesSectionOf(text);
|
|
1284
|
+
if (section === null) { out.push(rel + ' 缺 Unreleased 段与版本段(新增条目无处登记)'); continue; }
|
|
1285
|
+
const entryLines = section.split('\n').filter((line) => line.startsWith('- '));
|
|
1286
|
+
const entries = entryLines.length;
|
|
1287
|
+
const numbered = entryLines.reduce((n, line) => n + (line.match(/\/pull\/\d+/g) ?? []).length, 0);
|
|
1288
|
+
const bare = entryLines.reduce((n, line) => n + (line.match(/\/pull\/\)/g) ?? []).length, 0);
|
|
1289
|
+
if (bare > 0) out.push(rel + ' 新增条目含空 PR 链接(pull/ 无编号)×' + bare);
|
|
1290
|
+
if (entries > 0 && numbered !== entries) {
|
|
1291
|
+
out.push(rel + ' 新增条目与带编号 PR 链接数不一致(条目 ' + entries + ' / 链接 ' + numbered + ')');
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
// 已关闭缺口:**权威处**(`reference/platform-facts.md`)的陈旧注释须以「已关闭 + 当前判据」
|
|
1295
|
+
// 形态在场(边界陈述保留);两册**不得**再持该证据段正文(随平台事实移走——回流即红)。
|
|
1296
|
+
const gapCases = [
|
|
1297
|
+
[PLATFORM_FACTS_REL, factsBook, ['**fail-open**', '**未闭合**', '补丁体按行语义解析出']],
|
|
1298
|
+
];
|
|
1299
|
+
for (const [rel, text, keep] of gapCases) {
|
|
1300
|
+
if (text === null) continue;
|
|
1301
|
+
if (!text.includes(gapClosureSentence)) {
|
|
1302
|
+
out.push(rel + ' 未把已关闭的守卫缺口写成本文(缺「' + gapClosureSentence + '」——陈旧注释仍在描述现状)');
|
|
1303
|
+
}
|
|
1304
|
+
for (const item of keep) {
|
|
1305
|
+
if (!text.includes(item)) out.push(rel + ' 已关闭缺口的当前判据 / 边界陈述缺失(缺「' + item + '」)');
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
for (const [rel, text] of [['flow-comet-subagent-execute/SKILL.md', subagentBook]]) {
|
|
1309
|
+
if (text === null) continue;
|
|
1310
|
+
if (text.includes(gapClosureSentence)) {
|
|
1311
|
+
out.push(rel + ' 回流了已关闭缺口的证据段正文(缺「' + gapClosureSentence + '」段的权威处唯一)');
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
// 建树适用面:三处同写「显式建树受支持 / 以建树绕过边界不受支持」(能力契约锚,ADR-016 保留),
|
|
1315
|
+
// 旧一刀切禁令零残留。
|
|
1316
|
+
for (const [rel, text] of [
|
|
1317
|
+
['flow-comet/SKILL.md', entryBook],
|
|
1318
|
+
['flow-comet-subagent-execute/SKILL.md', subagentBook],
|
|
1319
|
+
[PLATFORM_FACTS_REL, factsBook],
|
|
1320
|
+
]) {
|
|
1321
|
+
if (text === null) continue;
|
|
1322
|
+
if (!text.includes(treeScopeSentence)) out.push(rel + ' 未写清建树适用面(缺「' + treeScopeSentence + '」)');
|
|
1323
|
+
if (!text.includes(treeBypassSentence)) out.push(rel + ' 未写清绕过面边界(缺「' + treeBypassSentence + '」)');
|
|
1324
|
+
if (text.includes(staleTreeBan)) {
|
|
1325
|
+
out.push(rel + ' 残留一刀切禁令「' + staleTreeBan + '…」(与入口册平台通道表口径相反)');
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
return out;
|
|
1329
|
+
};
|
|
1330
|
+
// 面缺席(安装副本形态)时的 null 安全改写:缺席面既无真实判据也无反向构造,
|
|
1331
|
+
// 由上方 SKIP 行显式声明未验证;探针循环再跳过含缺席面的探针(不静默当通过)。
|
|
1332
|
+
const patchText = (text, from, to) => (text === null ? null : text.split(from).join(to));
|
|
1333
|
+
const publicFaceSources = {
|
|
1334
|
+
mechanism: publicDocs.get('docs/MECHANISM.md'),
|
|
1335
|
+
mechanismZh: publicDocs.get('docs/MECHANISM-zh.md'),
|
|
1336
|
+
changelog: publicDocs.get('CHANGELOG.md'),
|
|
1337
|
+
changelogZh: publicDocs.get('CHANGELOG-zh.md'),
|
|
1338
|
+
subagentBook: subagentFaceText,
|
|
1339
|
+
entryBook: entryFaceText,
|
|
1340
|
+
factsBook: factsFaceText,
|
|
1341
|
+
};
|
|
1342
|
+
problems.push(...publicFaceProblems(publicFaceSources));
|
|
1343
|
+
// 反向构造(同一判据驱动):逐项抽掉新表述 / 还原旧表述 ⇒ 必报该问题。
|
|
1344
|
+
const publicFaceProbes = [
|
|
1345
|
+
['公开册判级回退', {
|
|
1346
|
+
mechanism: patchText(publicFaceSources.mechanism, 'payload `agent_id` / `agent_type` — **verified**, in a stated shape only', 'payload `agent_id` — **not yet covered** in a real session, in a stated shape only'),
|
|
1347
|
+
mechanismZh: patchText(publicFaceSources.mechanismZh, '载荷 `agent_id` / `agent_type`——**证实**,且**限定形态**', '载荷 `agent_id`——真机会话**尚未覆盖**,且**限定形态**'),
|
|
1348
|
+
}, '残留旧判级表述'],
|
|
1349
|
+
['公开册限定形态抽掉', {
|
|
1350
|
+
mechanism: patchText(publicFaceSources.mechanism, 'nested delegations', 'REMOVED'),
|
|
1351
|
+
mechanismZh: patchText(publicFaceSources.mechanismZh, '嵌套委派载荷', 'REMOVED'),
|
|
1352
|
+
}, '丢了限定形态'],
|
|
1353
|
+
['已关闭缺口注解抽掉', {
|
|
1354
|
+
factsBook: publicFaceSources.factsBook.split(gapClosureSentence).join('REMOVED'),
|
|
1355
|
+
}, '未把已关闭的守卫缺口写成本文'],
|
|
1356
|
+
['已关闭缺口证据回流册子', {
|
|
1357
|
+
subagentBook: publicFaceSources.subagentBook + '\n' + gapClosureSentence + ':补丁体按行语义解析出。\n',
|
|
1358
|
+
}, '回流了已关闭缺口的证据段正文'],
|
|
1359
|
+
['建树适用面句抽掉', {
|
|
1360
|
+
entryBook: publicFaceSources.entryBook.split(treeScopeSentence).join('REMOVED'),
|
|
1361
|
+
subagentBook: publicFaceSources.subagentBook.split(treeScopeSentence).join('REMOVED'),
|
|
1362
|
+
factsBook: publicFaceSources.factsBook.split(treeScopeSentence).join('REMOVED'),
|
|
1363
|
+
}, '未写清建树适用面'],
|
|
1364
|
+
['旧一刀切禁令还原', {
|
|
1365
|
+
subagentBook: publicFaceSources.subagentBook + '\n' + staleTreeBan + ',不得作为绕过手段。\n',
|
|
1366
|
+
}, '残留一刀切禁令'],
|
|
1367
|
+
];
|
|
1368
|
+
// 链接编号反向构造(**两面各自取目标、各自断言**):目标数据驱动——取「最新条目段」条目行内第一处
|
|
1369
|
+
// `/pull/<编号>`,两面各按自己的取值抽掉编号,两面都须报出空链接。写死批次编号的实现会在结算把
|
|
1370
|
+
// 条目移入版本段后恒不命中(判别力静默归零),批次更替后同样过期;只取英文侧编号的实现会让中文侧
|
|
1371
|
+
// 的判据在编号分叉或回归时不被覆盖。
|
|
1372
|
+
// 公开面缺席(安装副本形态)时不做该探针——上方 SKIP 行已显式声明未验证,不在此另报。
|
|
1373
|
+
const newestEntryLinkOf = (text) => ((newestEntriesSectionOf(text) ?? '')
|
|
1374
|
+
.split('\n').filter((line) => line.startsWith('- ')).join('\n')
|
|
1375
|
+
.match(/\/pull\/\d+/) ?? [null])[0];
|
|
1376
|
+
const changelogFacesPresent = publicFaceSources.changelog !== null && publicFaceSources.changelogZh !== null;
|
|
1377
|
+
if (changelogFacesPresent) {
|
|
1378
|
+
const linkEn = newestEntryLinkOf(publicFaceSources.changelog);
|
|
1379
|
+
const linkZh = newestEntryLinkOf(publicFaceSources.changelogZh);
|
|
1380
|
+
if (linkEn === null || linkZh === null) {
|
|
1381
|
+
problems.push('公开面口径反向构造目标缺失:最新条目段内无带编号 PR 链接(无从反证,不表示为通过)');
|
|
1382
|
+
} else {
|
|
1383
|
+
const strippedProblems = publicFaceProblems({
|
|
1384
|
+
...publicFaceSources,
|
|
1385
|
+
changelog: patchText(publicFaceSources.changelog, linkEn, '/pull/'),
|
|
1386
|
+
changelogZh: patchText(publicFaceSources.changelogZh, linkZh, '/pull/'),
|
|
1387
|
+
});
|
|
1388
|
+
for (const rel of ['CHANGELOG.md', 'CHANGELOG-zh.md']) {
|
|
1389
|
+
if (!strippedProblems.some((problem) => problem.startsWith(rel + ' 新增条目含空 PR 链接'))) {
|
|
1390
|
+
problems.push('公开面口径反向构造判别力缺失(变更日志链接编号抽掉:' + rel + ' 未被判违规)');
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
for (const [probeLabel, override, expected] of publicFaceProbes) {
|
|
1396
|
+
const probed = { ...publicFaceSources, ...override };
|
|
1397
|
+
// 含缺席面的探针不执行(该面既无真实判据也无反向构造)——上方 SKIP 行已显式声明未验证。
|
|
1398
|
+
if (Object.values(probed).some((value) => value === null)) continue;
|
|
1399
|
+
if (!publicFaceProblems(probed).some((problem) => problem.includes(expected))) {
|
|
1400
|
+
problems.push('公开面口径反向构造判别力缺失(' + probeLabel + ' 未被判违规)');
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
// 发布结算形态锚(本判据在发布态失配的回归锚):把 dev 态变更日志改写成发布结算后的形态——
|
|
1404
|
+
// Unreleased 只留空标题、条目连同条目行内的 PR 链接落在最新版本段——判据须零问题,且链接编号
|
|
1405
|
+
// 反向构造在此形态下仍必报(只切 Unreleased 段 + 写死批次编号的实现在此形态下必红)。
|
|
1406
|
+
{
|
|
1407
|
+
const settled = (text) => {
|
|
1408
|
+
if (text === null) return null;
|
|
1409
|
+
const section = unreleasedSectionOf(text);
|
|
1410
|
+
if (section === null) return null;
|
|
1411
|
+
// 树本身已是发布态(Unreleased 无条目)时无从构造该转换:此时真实判据与数据驱动探针
|
|
1412
|
+
// 已直接覆盖发布态,本锚跳过(不静默当通过——覆盖由上方真实判据承担)。
|
|
1413
|
+
if (!/^- /m.test(section)) return null;
|
|
1414
|
+
const headingStart = text.indexOf('## [Unreleased]');
|
|
1415
|
+
const nextVersion = text.indexOf('\n## [', headingStart + 1);
|
|
1416
|
+
if (nextVersion < 0) return null;
|
|
1417
|
+
const body = section.slice(section.indexOf('\n') + 1).replace(/^\n+/, '');
|
|
1418
|
+
// 前缀止于 Unreleased 标题行末——条目**只**出现在合成的版本段下(前缀若带到条目,判据仍会
|
|
1419
|
+
// 选中 Unreleased 段,本锚就变成空转的恒真锚)。
|
|
1420
|
+
return text.slice(0, headingStart + '## [Unreleased]'.length)
|
|
1421
|
+
+ '\n\n## [9.9.9] - 2099-01-01\n\nA release gathering the settled work.\n\n' + body
|
|
1422
|
+
+ text.slice(nextVersion);
|
|
1423
|
+
};
|
|
1424
|
+
const settledSources = {
|
|
1425
|
+
...publicFaceSources,
|
|
1426
|
+
changelog: settled(publicFaceSources.changelog),
|
|
1427
|
+
changelogZh: settled(publicFaceSources.changelogZh),
|
|
1428
|
+
};
|
|
1429
|
+
if (Object.values(settledSources).every((value) => value !== null)) {
|
|
1430
|
+
// 构造自证:合成后 Unreleased 段须为空、最新条目段须是合成的版本段——否则本锚没有真正构造
|
|
1431
|
+
// 出发布形态(静默空转),直接判红。
|
|
1432
|
+
for (const [rel, text] of [['CHANGELOG.md', settledSources.changelog], ['CHANGELOG-zh.md', settledSources.changelogZh]]) {
|
|
1433
|
+
if (/^- /m.test(unreleasedSectionOf(text) ?? '')) {
|
|
1434
|
+
problems.push('发布结算形态锚构造失效(' + rel + '):合成后 Unreleased 段仍带条目,未真正构造发布形态');
|
|
1435
|
+
}
|
|
1436
|
+
if (!/^## \[9\.9\.9\]/m.test(newestEntriesSectionOf(text) ?? '')) {
|
|
1437
|
+
problems.push('发布结算形态锚构造失效(' + rel + '):最新条目段未回退到合成的版本段');
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
const settledProblems = publicFaceProblems(settledSources);
|
|
1441
|
+
if (settledProblems.length > 0) {
|
|
1442
|
+
problems.push('发布结算形态(Unreleased 空标题 + 条目在最新版本段)下判据误报: ' + settledProblems.join('; '));
|
|
1443
|
+
}
|
|
1444
|
+
const settledLinkEn = newestEntryLinkOf(settledSources.changelog);
|
|
1445
|
+
const settledLinkZh = newestEntryLinkOf(settledSources.changelogZh);
|
|
1446
|
+
if (settledLinkEn === null || settledLinkZh === null) {
|
|
1447
|
+
problems.push('发布结算形态下链接编号反向构造目标缺失:最新条目段内无带编号 PR 链接');
|
|
1448
|
+
} else {
|
|
1449
|
+
const reversedProblems = publicFaceProblems({
|
|
1450
|
+
...settledSources,
|
|
1451
|
+
changelog: patchText(settledSources.changelog, settledLinkEn, '/pull/'),
|
|
1452
|
+
changelogZh: patchText(settledSources.changelogZh, settledLinkZh, '/pull/'),
|
|
1453
|
+
});
|
|
1454
|
+
for (const rel of ['CHANGELOG.md', 'CHANGELOG-zh.md']) {
|
|
1455
|
+
if (!reversedProblems.some((problem) => problem.startsWith(rel + ' 新增条目含空 PR 链接'))) {
|
|
1456
|
+
problems.push('发布结算形态下链接编号反向构造判别力缺失(抽掉条目行内编号:' + rel + ' 未被判违规)');
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
if (problems.length > 0) throw new Error('技能文本混排合法化语义不符: ' + problems.join('; '));
|
|
1464
|
+
},
|
|
1465
|
+
},
|
|
1466
|
+
];
|