flow-comet 1.6.3 → 1.6.5
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 +21 -3
- package/.flow-comet/skills/flow-comet/reference/artifact-template-overlay.md +154 -0
- package/.flow-comet/skills/flow-comet/reference/artifact-templates.json +387 -0
- package/.flow-comet/skills/flow-comet/reference/entry-detail.md +8 -2
- package/.flow-comet/skills/flow-comet/reference/workflow-protocol.json +22 -0
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +11 -13
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/evolve.mjs +180 -6
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +69 -18878
- package/.flow-comet/skills/flow-comet/scripts/health.mjs +29 -5
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +1053 -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 +817 -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 +618 -0
- package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +154 -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-artifact-skeleton.mjs +406 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +756 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +1235 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +384 -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 +714 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +204 -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 +179 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +714 -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 +123 -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 +249 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +1505 -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 +1248 -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 +2493 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +214 -2
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +72 -1123
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +976 -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 +1398 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +1466 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +1367 -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 +1492 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +971 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +2125 -0
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +59 -7559
- package/.flow-comet/skills/flow-comet/scripts/time-utils.mjs +4 -4
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +223 -2476
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +5 -5
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +27 -2190
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-change/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-design/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-design/SKILL.md +15 -8
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-evolve/SKILL.md +1 -0
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +13 -10
- package/.flow-comet/skills/flow-comet-health/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-open/GUIDANCE.md +14 -4
- package/.flow-comet/skills/flow-comet-open/SKILL.md +11 -9
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +11 -7
- package/.flow-comet/skills/flow-comet-requirement/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-review/SKILL.md +15 -9
- package/.flow-comet/skills/flow-comet-subagent-execute/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +11 -8
- package/.flow-comet/skills/flow-comet-task/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-test/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +12 -8
- package/README.md +52 -69
- package/package.json +3 -2
- package/scripts/dsh-bridge.mjs +2 -2
- package/scripts/lib/installer-cleanup.mjs +152 -0
- package/scripts/lib/installer-flowkit.mjs +159 -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 +21 -1313
|
@@ -0,0 +1,1053 @@
|
|
|
1
|
+
// items/a.mjs — A 组条目(状态机与路由)
|
|
2
|
+
//
|
|
3
|
+
// 数据层约定:本文件只承载条目数据(`export const ENTRIES = [...]`,计数派生按此聚合,见
|
|
4
|
+
// lib/count-derivation.mjs);夹具一律从 `lib/system-fixtures.mjs` 取,组文件之间零 import。
|
|
5
|
+
//
|
|
6
|
+
// 组界:条目序列按组文件规模上限**连续分区**,A 组尾部三项(Fix 回路)落在 items/b.mjs 头部——
|
|
7
|
+
// 文件是序列的连续分区,条目名保留机制面前缀(先例:场景元素 250c 由 scenarios/i 移入 scenarios/j)。
|
|
8
|
+
// 分区只搬文件、不动条目顺序与名字:system-test 的逐项输出顺序与文案因此逐字节不变。
|
|
9
|
+
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { createHash } from 'crypto';
|
|
13
|
+
import { assertEqual, assertExit, assertNotOut, assertOut, assertTrue, baseState, runGuard, runHandoff, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
14
|
+
import { archiveRecordJson, multiWaveTaskContent, explainContractProblems, assertExplainFailClosed, explainReverseConstructionProblems, CHANGE_ID, readStateFile, gitInit, gitBranch, writeIntakeArtifacts, fullContract, execSummaryFixture, assertNodeLine, driveThroughDesign } from '../lib/system-fixtures.mjs';
|
|
15
|
+
|
|
16
|
+
// skill-load 的模板声明(节点级,C3/AC-13 加载链):参数化的委托驱动按节点查表——夹具是真实命令
|
|
17
|
+
// 序列,声明集合要与节点映射一致(集合不一致时引擎按 C11 fail-closed 拦截)。
|
|
18
|
+
const TEMPLATE_DECLARATION = {
|
|
19
|
+
open: 'CHANGE.md,REQUIREMENT.md',
|
|
20
|
+
design: 'DESIGN.md',
|
|
21
|
+
plan: 'TASK.md',
|
|
22
|
+
execute: 'SUMMARY.md',
|
|
23
|
+
'subagent-execute': 'SUMMARY.md',
|
|
24
|
+
review: 'REVIEW.md,TEST.md',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function skillLoadArgs(nodeId, skill, prompt) {
|
|
28
|
+
const args = ['skill-load', nodeId, skill, '--prompt', prompt];
|
|
29
|
+
if (TEMPLATE_DECLARATION[nodeId]) args.push('--templates', TEMPLATE_DECLARATION[nodeId]);
|
|
30
|
+
return args;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ENTRIES = [
|
|
34
|
+
// ---------- A. 状态机与路由 ----------
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
name: 'A1 init:状态写入与工件目录创建',
|
|
38
|
+
run: (dir) => {
|
|
39
|
+
const res = runState(['init', CHANGE_ID], dir);
|
|
40
|
+
assertExit(res, 0);
|
|
41
|
+
assertOut(res, 'Initialized: ' + CHANGE_ID);
|
|
42
|
+
assertOut(res, 'NODE: open');
|
|
43
|
+
assertOut(res, 'BRANCH: none');
|
|
44
|
+
const st = readStateFile(dir);
|
|
45
|
+
if (st.activeChange !== CHANGE_ID) throw new Error('activeChange 应为 ' + CHANGE_ID);
|
|
46
|
+
if (st.currentNode !== 'open') throw new Error('currentNode 应为 open: ' + JSON.stringify(st.currentNode));
|
|
47
|
+
if (st.status !== 'running') throw new Error('status 应为 running');
|
|
48
|
+
if (st.branchMode !== false) throw new Error('非 git 仓库 branchMode 应为 false');
|
|
49
|
+
if (!fs.existsSync(path.join(dir, '.specs', CHANGE_ID))) throw new Error('.specs/<id>/ 目录未创建');
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
{
|
|
54
|
+
name: 'A2 init 分支模式:--branch-prefix 创建指定前缀分支',
|
|
55
|
+
run: (dir) => {
|
|
56
|
+
gitInit(dir);
|
|
57
|
+
const res = runState(['init', 'br-test', '--branch-prefix', 'feat/'], dir);
|
|
58
|
+
assertExit(res, 0);
|
|
59
|
+
assertOut(res, 'BRANCH: feat/br-test');
|
|
60
|
+
if (gitBranch(dir) !== 'feat/br-test') throw new Error('期望分支 feat/br-test,实际 ' + gitBranch(dir));
|
|
61
|
+
const st = readStateFile(dir);
|
|
62
|
+
if (st.branchPrefix !== 'feat/') throw new Error('branchPrefix 应为 feat/: ' + JSON.stringify(st.branchPrefix));
|
|
63
|
+
// 分支一致性:status 显示 ok
|
|
64
|
+
const status = runState(['status'], dir);
|
|
65
|
+
assertExit(status, 0);
|
|
66
|
+
assertOut(status, 'BRANCH: feat/br-test | 一致性: ok');
|
|
67
|
+
// 非法前缀拒绝
|
|
68
|
+
const bad = runState(['init', 'br-bad', '--branch-prefix', ''], dir);
|
|
69
|
+
assertExit(bad, 1);
|
|
70
|
+
assertOut(bad, '--branch-prefix requires a non-empty prefix');
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
name: 'A3 init 同 id 重跑:防护提示不阻断',
|
|
76
|
+
run: (dir) => {
|
|
77
|
+
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
78
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
79
|
+
const res = runState(['init', CHANGE_ID], dir);
|
|
80
|
+
assertExit(res, 0);
|
|
81
|
+
assertOut(res, 'WARN: change ' + CHANGE_ID + ' 已存在');
|
|
82
|
+
assertOut(res, '重置节点状态');
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
{
|
|
87
|
+
name: 'A4 status/explain:节点推导、节点现问契约(逐字段对账 + fail-closed + 只读)与无活跃兜底',
|
|
88
|
+
run: (dir) => {
|
|
89
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
90
|
+
// 无产物 → 首节点
|
|
91
|
+
const s1 = runState(['status'], dir);
|
|
92
|
+
assertExit(s1, 0);
|
|
93
|
+
assertOut(s1, '"currentNode": "open"');
|
|
94
|
+
// 上游工件齐 → 推导下一节点
|
|
95
|
+
writeIntakeArtifacts(dir);
|
|
96
|
+
const s2 = runState(['status'], dir);
|
|
97
|
+
assertExit(s2, 0);
|
|
98
|
+
assertOut(s2, '"currentNode": "design"');
|
|
99
|
+
// —— explain <node>:节点现问契约(真实子进程,零 mock;契约声明源 = 协议 JSON)——
|
|
100
|
+
// 8 节点逐个逐字段对账(label / kind / outputSchema 名与描述 / artifact / evidence / guardrail /
|
|
101
|
+
// requiredSkillCall / 三条命令)+ 三种 fail-closed 形态 + 只读性 + 反向构造(声明副本抽掉一条
|
|
102
|
+
// guardrail / 一个 artifact、改一条 schema 描述 ⇒ 对账必报;判据与探针见模块级单一实现)。
|
|
103
|
+
const protocolDecl = JSON.parse(fs.readFileSync(path.join(dir, 'reference', 'workflow-protocol.json'), 'utf8'));
|
|
104
|
+
const stateFilePath = path.join(dir, '.flow-comet', 'flow-comet-state.json');
|
|
105
|
+
const stateHashBefore = createHash('sha256').update(fs.readFileSync(stateFilePath)).digest('hex');
|
|
106
|
+
const statusBefore = runState(['status'], dir);
|
|
107
|
+
const explainOutputs = new Map();
|
|
108
|
+
for (const protocolNode of protocolDecl.nodes) {
|
|
109
|
+
const res = runState(['explain', protocolNode.id], dir);
|
|
110
|
+
assertExit(res, 0);
|
|
111
|
+
assertOut(res, 'NODE: ' + protocolNode.id);
|
|
112
|
+
explainOutputs.set(protocolNode.id, res.output);
|
|
113
|
+
}
|
|
114
|
+
const contractProblems = explainContractProblems(protocolDecl, explainOutputs);
|
|
115
|
+
assertTrue(contractProblems.length === 0,
|
|
116
|
+
'explain 输出与协议 JSON 声明不一致: ' + contractProblems.join('; '));
|
|
117
|
+
// 只读性:调用前后状态文件 sha256 全等 + status 读数逐字不变(explain 不写 state、不改路由)
|
|
118
|
+
assertEqual(createHash('sha256').update(fs.readFileSync(stateFilePath)).digest('hex'), stateHashBefore,
|
|
119
|
+
'explain 改写了状态文件(只读通道被破坏)');
|
|
120
|
+
assertEqual(runState(['status'], dir).output, statusBefore.output, 'explain 改动了路由读数(只读通道被破坏)');
|
|
121
|
+
assertExplainFailClosed(dir, protocolDecl);
|
|
122
|
+
const probeProblems = explainReverseConstructionProblems(dir, protocolDecl, explainOutputs);
|
|
123
|
+
assertTrue(probeProblems.length === 0, '反向构造判别力缺失: ' + probeProblems.join('; '));
|
|
124
|
+
// 无 state 无工件 → no-change 兜底
|
|
125
|
+
fs.rmSync(path.join(dir, '.flow-comet'), { recursive: true });
|
|
126
|
+
const s3 = runState(['status'], dir);
|
|
127
|
+
assertExit(s3, 0);
|
|
128
|
+
assertOut(s3, '"status": "no-change"');
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
{
|
|
133
|
+
name: 'A5 next:推进与状态漂移校正',
|
|
134
|
+
run: (dir) => {
|
|
135
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
136
|
+
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
137
|
+
writeIntakeArtifacts(dir);
|
|
138
|
+
assertExit(runState(['record', 'open', '{"summary":"intake complete"}'], dir), 0);
|
|
139
|
+
// 真实出口:exit open --apply(未激活声明机制 → 兼容警告 + 通过)
|
|
140
|
+
assertExit(runGuard(['entry', 'open'], dir), 0);
|
|
141
|
+
const exitRes = runGuard(['exit', 'open', '--apply'], dir);
|
|
142
|
+
assertExit(exitRes, 0);
|
|
143
|
+
assertOut(exitRes, 'ALL CHECKS PASSED');
|
|
144
|
+
let st = readStateFile(dir);
|
|
145
|
+
if (!st.completedNodes.includes('open')) throw new Error('completedNodes 应含 open: ' + JSON.stringify(st.completedNodes));
|
|
146
|
+
// 正常推进:next → design
|
|
147
|
+
const n1 = runState(['next'], dir);
|
|
148
|
+
assertExit(n1, 0);
|
|
149
|
+
assertOut(n1, 'NODE: design');
|
|
150
|
+
assertNotOut(n1, 'BLOCKED');
|
|
151
|
+
// 漂移校正:手工把 currentNode 改回 open(已完成节点)→ next 以文件推导为准校正
|
|
152
|
+
st = readStateFile(dir);
|
|
153
|
+
st.currentNode = 'open';
|
|
154
|
+
writeState(dir, st);
|
|
155
|
+
const n2 = runState(['next'], dir);
|
|
156
|
+
assertExit(n2, 0);
|
|
157
|
+
assertOut(n2, 'NODE: design');
|
|
158
|
+
const stAfter = readStateFile(dir);
|
|
159
|
+
if (stAfter.currentNode !== 'design') throw new Error('漂移应被校正为 design: ' + JSON.stringify(stAfter.currentNode));
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
{
|
|
164
|
+
name: 'A6 next:未出口节点严格拦截',
|
|
165
|
+
run: (dir) => {
|
|
166
|
+
writeState(dir, baseState('open'));
|
|
167
|
+
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
168
|
+
const res = runState(['next'], dir);
|
|
169
|
+
assertExit(res, 1);
|
|
170
|
+
assertOut(res, 'BLOCKED: 疑似未 exit 节点 open');
|
|
171
|
+
assertOut(res, 'workflow-guard.mjs exit open --apply');
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
name: 'A7 select:切换项目与缺失拒绝',
|
|
177
|
+
run: (dir) => {
|
|
178
|
+
assertExit(runState(['init', 'sel-a'], dir), 0);
|
|
179
|
+
// 第二个活跃 change 目录(模拟多 change 并存)
|
|
180
|
+
writeFile(dir, '.specs/sel-b/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
181
|
+
const res = runState(['select', 'sel-b'], dir);
|
|
182
|
+
assertExit(res, 0);
|
|
183
|
+
assertOut(res, 'Selected: sel-b');
|
|
184
|
+
const st = readStateFile(dir);
|
|
185
|
+
if (st.activeChange !== 'sel-b') throw new Error('activeChange 应为 sel-b: ' + JSON.stringify(st.activeChange));
|
|
186
|
+
// 不存在的 change → 拒绝
|
|
187
|
+
const missing = runState(['select', 'no-such'], dir);
|
|
188
|
+
assertExit(missing, 1);
|
|
189
|
+
assertOut(missing, 'Change not found');
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
{
|
|
194
|
+
name: 'A8 advance:节点推进',
|
|
195
|
+
run: (dir) => {
|
|
196
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
197
|
+
writeIntakeArtifacts(dir);
|
|
198
|
+
const res = runState(['advance'], dir);
|
|
199
|
+
assertExit(res, 0);
|
|
200
|
+
assertOut(res, 'Advanced to: design');
|
|
201
|
+
const st = readStateFile(dir);
|
|
202
|
+
if (!st.completedNodes.includes('open')) throw new Error('completedNodes 应含 open: ' + JSON.stringify(st.completedNodes));
|
|
203
|
+
if (st.currentNode !== 'design') throw new Error('currentNode 应为 design');
|
|
204
|
+
// 无活跃 change → 提示不推进
|
|
205
|
+
const st2 = readStateFile(dir);
|
|
206
|
+
st2.activeChange = null;
|
|
207
|
+
writeState(dir, st2);
|
|
208
|
+
const none = runState(['advance'], dir);
|
|
209
|
+
assertExit(none, 0);
|
|
210
|
+
assertOut(none, 'No active change. Use select first.');
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
{
|
|
215
|
+
name: 'A9 record:基础证据记录',
|
|
216
|
+
run: (dir, outcomes) => {
|
|
217
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
218
|
+
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
219
|
+
// JSON payload → evidence 写入 + next 提示
|
|
220
|
+
const res = runState(['record', 'open', '{"summary":"recorded"}'], dir);
|
|
221
|
+
assertExit(res, 0);
|
|
222
|
+
assertOut(res, 'EVIDENCE: open');
|
|
223
|
+
assertOut(res, 'NODE: open');
|
|
224
|
+
const st = readStateFile(dir);
|
|
225
|
+
if (!st.evidence.open || st.evidence.open.summary !== 'recorded') {
|
|
226
|
+
throw new Error('record 未写入 evidence: ' + JSON.stringify(st.evidence));
|
|
227
|
+
}
|
|
228
|
+
if (typeof st.evidence.open.recordedAt !== 'string') throw new Error('evidence 应附带 recordedAt');
|
|
229
|
+
// 非 JSON payload → 按 summary 字符串记录
|
|
230
|
+
assertExit(runState(['record', 'open', 'plain text'], dir), 0);
|
|
231
|
+
const st2 = readStateFile(dir);
|
|
232
|
+
if (st2.evidence.open.summary !== 'plain text') throw new Error('非 JSON payload 应按 summary 记录');
|
|
233
|
+
// --json-file:从文件读 JSON payload(规避 Windows PowerShell 引号剥离)
|
|
234
|
+
fs.writeFileSync(path.join(dir, 'payload.json'), '{"summary":"from-file"}', 'utf8');
|
|
235
|
+
const rf = runState(['record', 'open', '--json-file', 'payload.json'], dir);
|
|
236
|
+
assertExit(rf, 0);
|
|
237
|
+
const st3 = readStateFile(dir);
|
|
238
|
+
if (st3.evidence.open.summary !== 'from-file') throw new Error('--json-file payload 未生效');
|
|
239
|
+
// --json-file 越界路径(解析后出项目根)→ 拒绝(防读取任意文件进 evidence)
|
|
240
|
+
const outsideFile = path.join(dir, '..', 'outside.json');
|
|
241
|
+
fs.writeFileSync(outsideFile, '{"summary":"outside"}', 'utf8');
|
|
242
|
+
const rfBad = runState(['record', 'open', '--json-file', outsideFile], dir);
|
|
243
|
+
assertExit(rfBad, 1);
|
|
244
|
+
assertOut(rfBad, '必须在项目根内');
|
|
245
|
+
// --json-file 符号链接越界(realpath 校验):链接到项目根外的符号链接 → 拒绝。
|
|
246
|
+
// 平台限制:Windows 创建符号链接需开发者模式/管理员——创建失败时显式跳过并说明,
|
|
247
|
+
// 不静默(POSIX/CI 真实覆盖该负例)
|
|
248
|
+
const outsideTarget = path.join(dir, '..', 'outside-symlink-target.json');
|
|
249
|
+
fs.writeFileSync(outsideTarget, '{"summary":"outside"}', 'utf8');
|
|
250
|
+
const symlinkPath = path.join(dir, 'payload-link.json');
|
|
251
|
+
// 平台限制:Windows 创建符号链接需开发者模式/管理员——创建失败时登记显式「不适用(平台原因)」
|
|
252
|
+
// 并由运行器逐条出声(不复用条件分支的静默跳过:未验证 ≠ 通过)。
|
|
253
|
+
// 仅 symlink 创建包在 try 内——断言移出 catch,防断言失败被误报为平台跳过
|
|
254
|
+
// (修复前 try 包住 runState/断言,真实回归会被吞为"平台不支持跳过")
|
|
255
|
+
let symlinkCreated = false;
|
|
256
|
+
try {
|
|
257
|
+
fs.symlinkSync(outsideTarget, symlinkPath);
|
|
258
|
+
symlinkCreated = true;
|
|
259
|
+
} catch (e) {
|
|
260
|
+
outcomes.notApplicablePlatform('A9 --json-file 符号链接越界负例',
|
|
261
|
+
'本平台不支持创建符号链接(' + e.code + ')');
|
|
262
|
+
}
|
|
263
|
+
if (symlinkCreated) {
|
|
264
|
+
const rfSym = runState(['record', 'open', '--json-file', 'payload-link.json'], dir);
|
|
265
|
+
assertExit(rfSym, 1);
|
|
266
|
+
assertOut(rfSym, '符号链接');
|
|
267
|
+
}
|
|
268
|
+
// 缺 node 参数 → 拒绝
|
|
269
|
+
const noNode = runState(['record'], dir);
|
|
270
|
+
assertExit(noNode, 1);
|
|
271
|
+
assertOut(noNode, 'record requires a Node id.');
|
|
272
|
+
// --json-file 缺值(最后一个参数)→ 用法错误而非类型错误(修复前 path.resolve
|
|
273
|
+
// 对 undefined 抛 TypeError——报类型错误而非用法错误,此处应 RED)
|
|
274
|
+
const missingVal = runState(['record', 'open', '--json-file'], dir);
|
|
275
|
+
assertExit(missingVal, 1);
|
|
276
|
+
assertOut(missingVal, '--json-file requires a path argument');
|
|
277
|
+
if (missingVal.output.includes('ERR_INVALID_ARG_TYPE')) {
|
|
278
|
+
throw new Error('--json-file 缺值不应报类型错误');
|
|
279
|
+
}
|
|
280
|
+
// --json-file 空串(--json-file= 形式)→ 同样用法错误(修复前解析为项目根报 EISDIR)
|
|
281
|
+
const emptyVal = runState(['record', 'open', '--json-file='], dir);
|
|
282
|
+
assertExit(emptyVal, 1);
|
|
283
|
+
assertOut(emptyVal, '--json-file requires a path argument');
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
{
|
|
288
|
+
name: 'A10 execution-mode:direct 切换与记录',
|
|
289
|
+
run: (dir) => {
|
|
290
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
291
|
+
const d = runState(['execution-mode', 'direct'], dir);
|
|
292
|
+
assertExit(d, 0);
|
|
293
|
+
assertOut(d, 'EXECUTION-MODE: direct (directOverride)');
|
|
294
|
+
let st = readStateFile(dir);
|
|
295
|
+
if (st.executionMode !== 'direct' || st.directOverride !== true) {
|
|
296
|
+
throw new Error('direct 模式应记录 directOverride=true: ' + JSON.stringify({ executionMode: st.executionMode, directOverride: st.directOverride }));
|
|
297
|
+
}
|
|
298
|
+
const s = runState(['execution-mode', 'subagent'], dir);
|
|
299
|
+
assertExit(s, 0);
|
|
300
|
+
assertOut(s, 'EXECUTION-MODE: subagent');
|
|
301
|
+
st = readStateFile(dir);
|
|
302
|
+
if (st.executionMode !== 'subagent' || st.directOverride !== false) {
|
|
303
|
+
throw new Error('切回 subagent 应清除 directOverride: ' + JSON.stringify(st.directOverride));
|
|
304
|
+
}
|
|
305
|
+
// 非法参数拒绝
|
|
306
|
+
const bad = runState(['execution-mode', 'bogus'], dir);
|
|
307
|
+
assertExit(bad, 1);
|
|
308
|
+
assertOut(bad, 'BLOCKED: execution-mode 参数必须为 subagent 或 direct');
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
{
|
|
313
|
+
name: 'A11 config:配置设置与非法值拒绝',
|
|
314
|
+
run: (dir) => {
|
|
315
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
316
|
+
const ok = runState(['config', 'set', 'enablePrReview', 'true'], dir);
|
|
317
|
+
assertExit(ok, 0);
|
|
318
|
+
assertOut(ok, 'CONFIG: enablePrReview = true');
|
|
319
|
+
const st = readStateFile(dir);
|
|
320
|
+
if (st.enablePrReview !== true) throw new Error('enablePrReview 应为 true');
|
|
321
|
+
// branchMode 只读拒绝
|
|
322
|
+
const branch = runState(['config', 'set', 'branchMode', 'true'], dir);
|
|
323
|
+
assertExit(branch, 1);
|
|
324
|
+
assertOut(branch, 'BLOCKED: branchMode 由 init 自动判定');
|
|
325
|
+
// 值非法拒绝
|
|
326
|
+
const bad = runState(['config', 'set', 'enablePrReview', 'maybe'], dir);
|
|
327
|
+
assertExit(bad, 1);
|
|
328
|
+
assertOut(bad, 'BLOCKED: config set 值非法');
|
|
329
|
+
// 未知键拒绝
|
|
330
|
+
const unknown = runState(['config', 'set', 'foo', 'bar'], dir);
|
|
331
|
+
assertExit(unknown, 1);
|
|
332
|
+
assertOut(unknown, 'BLOCKED: 未知配置键');
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
{
|
|
337
|
+
name: 'A12 verifyFailures:切换 change 后计数独立(按 change 存储)',
|
|
338
|
+
run: (dir) => {
|
|
339
|
+
// ① init ch-a + verify-fail 两次(2/3,未超限)
|
|
340
|
+
assertExit(runState(['init', 'ch-a', '--init-skip'], dir), 0);
|
|
341
|
+
assertExit(runState(['verify-fail'], dir), 0);
|
|
342
|
+
const r2 = runState(['verify-fail'], dir);
|
|
343
|
+
assertExit(r2, 0);
|
|
344
|
+
assertOut(r2, 'VERIFY-FAIL: 2/3');
|
|
345
|
+
// ② 切换到 ch-b(目录需存在)→ verify-fail 从 1 起——按 change 存储后计数独立
|
|
346
|
+
// (若实现仍用全局计数 2,此处输出 3/3——断言 1/3 即 RED)
|
|
347
|
+
writeFile(dir, '.specs/ch-b/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
348
|
+
assertExit(runState(['select', 'ch-b'], dir), 0);
|
|
349
|
+
const r3 = runState(['verify-fail'], dir);
|
|
350
|
+
assertExit(r3, 0);
|
|
351
|
+
assertOut(r3, 'VERIFY-FAIL: 1/3');
|
|
352
|
+
// ③ ch-b 独立计数:连续 3 次后第 4 次 BLOCK
|
|
353
|
+
assertExit(runState(['verify-fail'], dir), 0);
|
|
354
|
+
assertExit(runState(['verify-fail'], dir), 0);
|
|
355
|
+
const r7 = runState(['verify-fail'], dir);
|
|
356
|
+
assertExit(r7, 1);
|
|
357
|
+
assertOut(r7, '超限');
|
|
358
|
+
// ④ 切回 ch-a:原计数保留(2 → 可再失败 1 次,第 4 次 BLOCK;不串扰不回零)
|
|
359
|
+
assertExit(runState(['select', 'ch-a'], dir), 0);
|
|
360
|
+
const r8 = runState(['verify-fail'], dir);
|
|
361
|
+
assertExit(r8, 0);
|
|
362
|
+
assertOut(r8, 'VERIFY-FAIL: 3/3');
|
|
363
|
+
const r9 = runState(['verify-fail'], dir);
|
|
364
|
+
assertExit(r9, 1);
|
|
365
|
+
assertOut(r9, '超限');
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
{
|
|
370
|
+
name: 'A13 多趟路由真实链路:并→串→并交替与多波依赖,NODE 行在 execute/subagent-execute 间多次交替直至全部 done',
|
|
371
|
+
run: (dir) => {
|
|
372
|
+
driveThroughDesign(dir);
|
|
373
|
+
// 混排 TASK:双并行开路 → 串行衔接(依赖双并行)→ 收尾并行(依赖串行衔接)——依赖驱动的
|
|
374
|
+
// 分趟序列:并行趟 → 串行趟 → 并行趟 → review 门控(多趟正向行为)。
|
|
375
|
+
// 驱动遵循真实协调者流程:execute 趟内先消化其全部串行 pending(标 done 并委托留证)再 exit;
|
|
376
|
+
// 委托趟内委派全部可并行后才能退(每趟合取完成判定)。
|
|
377
|
+
// 对未实现循环路由的引擎本用例 RED 属预期(单趟限制下委托节点完成后不再路由回)。
|
|
378
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
379
|
+
multiWaveTaskContent({ P01: 'pending', P02: 'pending', S01: 'pending', P03: 'pending' }));
|
|
380
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir), 0);
|
|
381
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan done"}'], dir), 0);
|
|
382
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
383
|
+
const rPlan = runGuard(['exit', 'plan', '--apply'], dir);
|
|
384
|
+
assertExit(rPlan, 0);
|
|
385
|
+
assertOut(rPlan, 'ALL CHECKS PASSED');
|
|
386
|
+
// 首趟路由:首波双并行无前置依赖 → 直接进入委托节点
|
|
387
|
+
assertOut(rPlan, 'NODE: subagent-execute');
|
|
388
|
+
// 两层加载模型:执行域两节点的手动声明标记(record 前置门;一次声明后续趟次复用)
|
|
389
|
+
assertExit(runState(['skill-load', 'execute', 'flow-comet-dev', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir), 0);
|
|
390
|
+
assertExit(runState(['skill-load', 'subagent-execute', 'flow-comet-dev', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir), 0);
|
|
391
|
+
|
|
392
|
+
// 单趟完成动作:TASK.md 标 done(status 变更不影响任务集签名)+ SUMMARY 夹具 + 真实 handoff 委托回传
|
|
393
|
+
const completeTasks = (ids) => {
|
|
394
|
+
for (const id of ids) {
|
|
395
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', execSummaryFixture(id));
|
|
396
|
+
assertExit(runHandoff(['request', id, id + ' 委托', '--write-files', 'src/' + id.toLowerCase() + '.mjs'], dir), 0);
|
|
397
|
+
assertExit(runHandoff(['result', id, fullContract('abcd1234abcd1234abcd1234abcd1234abcd1234', id)], dir), 0);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
const markDone = (statusMap) => writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', multiWaveTaskContent(statusMap));
|
|
401
|
+
// 单趟驱动:record → entry → exit --apply,断言 NODE 行路由到期望节点(可观测性不变式)
|
|
402
|
+
let lastPassResult = null;
|
|
403
|
+
const drivePass = (node, expectNext, label) => {
|
|
404
|
+
assertExit(runState(['record', node, '{"summary":"' + label + '"}'], dir), 0);
|
|
405
|
+
assertExit(runGuard(['entry', node], dir), 0);
|
|
406
|
+
const res = runGuard(['exit', node, '--apply'], dir);
|
|
407
|
+
assertExit(res, 0);
|
|
408
|
+
assertOut(res, 'ALL CHECKS PASSED');
|
|
409
|
+
lastPassResult = res;
|
|
410
|
+
const m = res.output.match(/^NODE: ([a-z-]+)\s*$/m);
|
|
411
|
+
if (!m) throw new Error('exit ' + node + '(' + label + ')输出缺 NODE 行:\n' + res.output);
|
|
412
|
+
if (m[1] !== expectNext) {
|
|
413
|
+
throw new Error(label + ' 后路由期望 NODE: ' + expectNext + ',实际 NODE: ' + m[1] +
|
|
414
|
+
'(多趟循环路由未生效——委托节点应可重入直至无剩余可并行)\n实际输出:\n' + res.output);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// 趟 1 · subagent-execute:首波双并行委托完成 → 趟间回串行(串行衔接依赖此时已满足)
|
|
419
|
+
markDone({ P01: 'done', P02: 'done', S01: 'pending', P03: 'pending' });
|
|
420
|
+
completeTasks(['P01', 'P02']);
|
|
421
|
+
drivePass('subagent-execute', 'execute', 'parallel-wave-1');
|
|
422
|
+
|
|
423
|
+
// 归属门禁事故回放(真实命令链路):波 1 收口后工作归属在 execute(尚有串行衔接待办),
|
|
424
|
+
// 此刻对未消化的并行 pending 任务发起委托 → 新 change BLOCK(state 字节零改写、不落请求)。
|
|
425
|
+
// P03 依赖未满足:恢复指引以 workflow-state next 实际输出为准(next 按串行消化输出
|
|
426
|
+
// execute),不得固定指向 entry subagent-execute;随后原链路照跑(串行衔接完成后并行收尾正常委托)。
|
|
427
|
+
const ownershipEnv = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
428
|
+
const ownershipStatePath = path.join(dir, '.flow-comet', 'flow-comet-state.json');
|
|
429
|
+
const ownershipBytesBefore = fs.readFileSync(ownershipStatePath, 'utf8');
|
|
430
|
+
const wrongNodeRequest = runHandoff(['request', 'P03', 'P03 委托', '--write-files', 'src/p03.mjs'], dir, ownershipEnv);
|
|
431
|
+
assertExit(wrongNodeRequest, 1);
|
|
432
|
+
assertOut(wrongNodeRequest, 'BLOCKED');
|
|
433
|
+
assertOut(wrongNodeRequest, '当前不可委托');
|
|
434
|
+
assertOut(wrongNodeRequest, '依赖未满足');
|
|
435
|
+
assertOut(wrongNodeRequest, '未完成: S01');
|
|
436
|
+
assertOut(wrongNodeRequest, '原始 currentNode=execute');
|
|
437
|
+
assertOut(wrongNodeRequest, 'workflow-state next');
|
|
438
|
+
assertOut(wrongNodeRequest, '若输出 execute 表示依赖未满足');
|
|
439
|
+
assertOut(wrongNodeRequest, '待任务变为可委托');
|
|
440
|
+
// 反锚:不得固定指引 next 不会输出的节点(按该指引进入会被 currentNode 门禁拦成死路)
|
|
441
|
+
assertNotOut(wrongNodeRequest, 'entry subagent-execute');
|
|
442
|
+
assertNotOut(wrongNodeRequest, 'HANDOFF REQUEST');
|
|
443
|
+
if (fs.readFileSync(ownershipStatePath, 'utf8') !== ownershipBytesBefore) {
|
|
444
|
+
throw new Error('归属门禁 BLOCK 不得改写 state 字节(含 handoffRequests)');
|
|
445
|
+
}
|
|
446
|
+
const ownershipState = readStateFile(dir);
|
|
447
|
+
if (ownershipState.evidence?.['subagent-execute']?.handoffRequests?.P03) {
|
|
448
|
+
throw new Error('归属门禁 BLOCK 不得落 handoffRequests: '
|
|
449
|
+
+ JSON.stringify(ownershipState.evidence?.['subagent-execute']?.handoffRequests));
|
|
450
|
+
}
|
|
451
|
+
// 指引与 next 实际输出一致:依赖未满足 → next 输出 execute(串行消化),无 entry 死路
|
|
452
|
+
const routeAfterBlock = runState(['next'], dir, ownershipEnv);
|
|
453
|
+
assertExit(routeAfterBlock, 0);
|
|
454
|
+
assertNodeLine(routeAfterBlock, 'execute');
|
|
455
|
+
|
|
456
|
+
// 趟 2 · execute:先消化本趟全部串行 pending(串行衔接,标 done 并委托留证)——
|
|
457
|
+
// 确认无串行残留后才 exit → 收尾并行依赖满足 → 再次进入委托节点
|
|
458
|
+
// (旧引擎单趟限制下此处不再路由回——本断言即多趟语义回归锚)
|
|
459
|
+
markDone({ P01: 'done', P02: 'done', S01: 'done', P03: 'pending' });
|
|
460
|
+
completeTasks(['S01']);
|
|
461
|
+
drivePass('execute', 'subagent-execute', 'serial-wave-1');
|
|
462
|
+
|
|
463
|
+
// 趟 3 · subagent-execute:收尾并行委托完成 → 全部 done → 出口照常门控进 review(循环终止语义不变)
|
|
464
|
+
markDone({ P01: 'done', P02: 'done', S01: 'done', P03: 'done' });
|
|
465
|
+
completeTasks(['P03']);
|
|
466
|
+
// 收口前基线(只读):出口 NODE 与完成节点集合之外零改写,收尾前后仅审计行文本变化
|
|
467
|
+
const pass3Before = readStateFile(dir);
|
|
468
|
+
drivePass('subagent-execute', 'review', 'parallel-wave-2');
|
|
469
|
+
const pass3 = lastPassResult;
|
|
470
|
+
// 正常多趟收尾:无 Fix 结构标记且历史签名全等 → 中性 RETURN,不得出现 FIX-BATCH 锚
|
|
471
|
+
assertOut(pass3, 'RETURN: 回源节点 review(subagent-execute 出口已完成;正常多趟收尾,非 Fix 回修)');
|
|
472
|
+
assertNotOut(pass3, 'FIX-BATCH');
|
|
473
|
+
assertNodeLine(pass3, 'review');
|
|
474
|
+
const pass3After = readStateFile(dir);
|
|
475
|
+
if (JSON.stringify(pass3After.completedNodes) !== JSON.stringify(pass3Before.completedNodes)) {
|
|
476
|
+
throw new Error('正常多趟收尾不得改写完成节点集合(审计行分类零副作用): 收口前 '
|
|
477
|
+
+ JSON.stringify(pass3Before.completedNodes) + ' 收口后 ' + JSON.stringify(pass3After.completedNodes));
|
|
478
|
+
}
|
|
479
|
+
if (pass3After.currentNode !== 'review' || pass3After.completedNodes.includes('review')) {
|
|
480
|
+
throw new Error('正常多趟收尾应停在未完成的 review: ' + JSON.stringify(pass3After));
|
|
481
|
+
}
|
|
482
|
+
const pass3PostNext = runState(['next'], dir);
|
|
483
|
+
assertExit(pass3PostNext, 0);
|
|
484
|
+
assertNodeLine(pass3PostNext, 'review');
|
|
485
|
+
|
|
486
|
+
const st = readStateFile(dir);
|
|
487
|
+
if (st.currentNode !== 'review') {
|
|
488
|
+
throw new Error('全部任务 done 后应停在 review 门控前: ' + JSON.stringify(st.currentNode));
|
|
489
|
+
}
|
|
490
|
+
console.log(' 多趟路由:subagent-execute→execute→subagent-execute→review 三趟两交替 + 归属门禁 BLOCK 后原链路续跑 ✓');
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
|
|
494
|
+
{
|
|
495
|
+
name: 'A14 plan 出口依赖环负例:BLOCK 含 depends_on 恢复指引,按指引调环后恢复通过',
|
|
496
|
+
run: (dir) => {
|
|
497
|
+
driveThroughDesign(dir);
|
|
498
|
+
// 负例:X1↔X2 互相依赖成环(结构死锁——任何一趟都无法开工)→ plan 出口前置拦截。
|
|
499
|
+
// 校验语义:依赖图无环 + 趟次可满足;BLOCK 消息附 depends_on 调整恢复指引(恢复类断言面)。
|
|
500
|
+
const cyclic =
|
|
501
|
+
'<task id="C1" status="pending"><action>实现 C1</action><write_files>src/c1.mjs</write_files><verify>node --check src/c1.mjs</verify></task>\n' +
|
|
502
|
+
'<task id="X1" parallel="true" status="pending"><action>实现 X1</action><write_files>src/x1.mjs</write_files><verify>node --check src/x1.mjs</verify><depends_on>X2</depends_on></task>\n' +
|
|
503
|
+
'<task id="X2" parallel="true" status="pending"><action>实现 X2</action><write_files>src/x2.mjs</write_files><verify>node --check src/x2.mjs</verify><depends_on>X1</depends_on></task>\n';
|
|
504
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + cyclic);
|
|
505
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir), 0);
|
|
506
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan drafted"}'], dir), 0);
|
|
507
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
508
|
+
const blocked = runGuard(['exit', 'plan', '--apply'], dir);
|
|
509
|
+
assertExit(blocked, 1);
|
|
510
|
+
assertOut(blocked, 'BLOCKED');
|
|
511
|
+
// 恢复指引关键词:指明调整 depends_on(而非笼统报错)
|
|
512
|
+
assertOut(blocked, 'depends_on');
|
|
513
|
+
if (!/(环|循环|cycle|拓扑|topolog)/i.test(blocked.output)) {
|
|
514
|
+
throw new Error('plan 出口 BLOCK 应含依赖环/拓扑校验语义关键词(环/循环/cycle/拓扑):\n' + blocked.output);
|
|
515
|
+
}
|
|
516
|
+
// 恢复类:按指引调整 depends_on(X1/X2 改依赖 C1)消环 → 同一出口重跑通过
|
|
517
|
+
const recovered =
|
|
518
|
+
'<task id="C1" status="pending"><action>实现 C1</action><write_files>src/c1.mjs</write_files><verify>node --check src/c1.mjs</verify></task>\n' +
|
|
519
|
+
'<task id="X1" parallel="true" status="pending"><action>实现 X1</action><write_files>src/x1.mjs</write_files><verify>node --check src/x1.mjs</verify><depends_on>C1</depends_on></task>\n' +
|
|
520
|
+
'<task id="X2" parallel="true" status="pending"><action>实现 X2</action><write_files>src/x2.mjs</write_files><verify>node --check src/x2.mjs</verify><depends_on>C1</depends_on></task>\n';
|
|
521
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + recovered);
|
|
522
|
+
const ok = runGuard(['exit', 'plan', '--apply'], dir);
|
|
523
|
+
assertExit(ok, 0);
|
|
524
|
+
assertOut(ok, 'ALL CHECKS PASSED');
|
|
525
|
+
// 恢复后路由:并行依赖未满足(C1 仍 pending)→ execute 开工
|
|
526
|
+
assertOut(ok, 'NODE: execute');
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
|
|
530
|
+
{
|
|
531
|
+
// 路由时序收敛(真实命令链路):多趟拓扑(并行开路 → 串行衔接 → 并行收尾 → 串行收尾)逐节点
|
|
532
|
+
// guard exit --apply 后运行 workflow-state next——断言两侧 NODE 逐节点一致(修复前 guard 出口
|
|
533
|
+
// 镜像缺「串行 pending → execute」回流,并行收尾后直接落到 review,与权威 next 偏差)。
|
|
534
|
+
name: 'A15 多趟路由时序收敛:逐节点 exit --apply 后 next NODE 与 guard 出口 NODE 一致',
|
|
535
|
+
run: (dir) => {
|
|
536
|
+
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
537
|
+
const writeTask = (statusMap) => {
|
|
538
|
+
const blk = (id, parallel, deps) =>
|
|
539
|
+
'<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
|
|
540
|
+
' status="' + (statusMap[id] === 'done' ? 'done' : 'pending') + '">' +
|
|
541
|
+
'<action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files>' +
|
|
542
|
+
'<verify>node --check src/' + id.toLowerCase() + '.mjs</verify>' +
|
|
543
|
+
(deps ? '<depends_on>' + deps + '</depends_on>' : '') + '</task>\n';
|
|
544
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
545
|
+
blk('P01', true, '') + blk('P02', true, '') +
|
|
546
|
+
blk('S01', false, 'P01,P02') +
|
|
547
|
+
blk('P03', true, 'S01') + blk('P04', true, 'S01') +
|
|
548
|
+
blk('S02', false, 'P03,P04'));
|
|
549
|
+
};
|
|
550
|
+
const runNext = () => runState(['next'], dir, env);
|
|
551
|
+
const nodeOf = (out) => (out.match(/^NODE: ([a-z-]+)$/m) || [])[1] ?? null;
|
|
552
|
+
const completeTasks = (ids) => {
|
|
553
|
+
for (const id of ids) {
|
|
554
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', execSummaryFixture(id));
|
|
555
|
+
assertExit(runHandoff(['request', id, id + ' 委托', '--write-files', 'src/' + id.toLowerCase() + '.mjs'], dir), 0);
|
|
556
|
+
assertExit(runHandoff(['result', id, fullContract('abcd1234abcd1234abcd1234abcd1234abcd1234', id)], dir), 0);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
// drive 收敛面参数化:委托跳转/趟间回串行态(guard 出口 NODE 与 next 可确认面不一致——
|
|
560
|
+
// next 对「currentNode 无 evidence 且非固定路由后继」的委托跳转态按正常推进豁免不放行,
|
|
561
|
+
// 仅断言 guard 侧 NODE;直接后继/回流态(next 可确认)才做双侧收敛断言。
|
|
562
|
+
const drive = (nodeId, skill, prompt, prepare, { expectedNode, converge = true } = {}) => {
|
|
563
|
+
assertExit(runState(skillLoadArgs(nodeId, skill, prompt), dir, env), 0);
|
|
564
|
+
prepare();
|
|
565
|
+
assertExit(runGuard(['entry', nodeId], dir), 0);
|
|
566
|
+
const res = runGuard(['exit', nodeId, '--apply'], dir);
|
|
567
|
+
assertExit(res, 0);
|
|
568
|
+
const n1 = nodeOf(res.output);
|
|
569
|
+
if (expectedNode && n1 !== expectedNode) {
|
|
570
|
+
throw new Error('节点 ' + nodeId + ' 出口后 guard NODE(' + n1 + ') != 期望(' + expectedNode +
|
|
571
|
+
')\nguard:\n' + res.output);
|
|
572
|
+
}
|
|
573
|
+
if (!converge) return;
|
|
574
|
+
const nxt = runNext();
|
|
575
|
+
assertExit(nxt, 0);
|
|
576
|
+
const n2 = nodeOf(nxt.output);
|
|
577
|
+
if (n1 !== n2) {
|
|
578
|
+
throw new Error('节点 ' + nodeId + ' 出口后 guard NODE(' + n1 + ') != next NODE(' + n2 +
|
|
579
|
+
')\nguard:\n' + res.output + '\nnext:\n' + nxt.output);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', execSummaryFixture(id)); };
|
|
583
|
+
driveThroughDesign(dir);
|
|
584
|
+
// 预置多趟 TASK 并推进到 review 门控前(逐节点收敛断言)
|
|
585
|
+
writeTask({ P01: 'pending', P02: 'pending', S01: 'pending', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
586
|
+
drive('plan', 'flow-comet-plan', 'flow-kit/prompts/3-task.md', () => assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0),
|
|
587
|
+
{ expectedNode: 'subagent-execute', converge: false });
|
|
588
|
+
drive('subagent-execute', 'flow-comet-subagent-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
589
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'pending', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
590
|
+
writeSummary(['P01', 'P02']);
|
|
591
|
+
completeTasks(['P01', 'P02']);
|
|
592
|
+
// 委托收集后按真实链路 record 节点总结(浅合并保留 handoffResult)——guard exit
|
|
593
|
+
// 的 schema evidence 前置需要非空 summary(缺则 BLOCK,与场景级委托出口同形态)。
|
|
594
|
+
assertExit(runState(['record', 'subagent-execute', '{"summary":"wave 1 delegated and collected"}'], dir, env), 0);
|
|
595
|
+
}, { expectedNode: 'execute', converge: false });
|
|
596
|
+
drive('execute', 'flow-comet-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
597
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
598
|
+
writeSummary(['S01']);
|
|
599
|
+
completeTasks(['S01']);
|
|
600
|
+
// execute 节点自身证据(guard exit 校验节点 evidence 须有记录)——真实链路中
|
|
601
|
+
// 串行任务完成后协调者 record execute 节点总结。
|
|
602
|
+
assertExit(runState(['record', 'execute', '{"summary":"serial wave complete"}'], dir, env), 0);
|
|
603
|
+
}, { expectedNode: 'subagent-execute', converge: true });
|
|
604
|
+
drive('subagent-execute', 'flow-comet-subagent-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
605
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'done', P04: 'done', S02: 'pending' });
|
|
606
|
+
writeSummary(['P03', 'P04']);
|
|
607
|
+
completeTasks(['P03', 'P04']);
|
|
608
|
+
assertExit(runState(['record', 'subagent-execute', '{"summary":"wave 2 delegated and collected"}'], dir, env), 0);
|
|
609
|
+
}, { expectedNode: 'execute', converge: true });
|
|
610
|
+
drive('execute', 'flow-comet-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
611
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'done', P04: 'done', S02: 'done' });
|
|
612
|
+
writeSummary(['S02']);
|
|
613
|
+
completeTasks(['S02']);
|
|
614
|
+
assertExit(runState(['record', 'execute', '{"summary":"final serial wave complete"}'], dir, env), 0);
|
|
615
|
+
}, { expectedNode: 'review', converge: true });
|
|
616
|
+
drive('review', 'flow-comet-review', 'flow-kit/prompts/6-review.md', () => {
|
|
617
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md',
|
|
618
|
+
'# REVIEW\n\n## 发现\n\n### Critical\n\n- 无\n\n### Major\n\n- 无\n\n### Minor\n\n- 无\n\n## 结论\n\nreview passed,无遗留问题。\n');
|
|
619
|
+
assertExit(runState(['record', 'review', '{"summary":"review complete"}'], dir, env), 0);
|
|
620
|
+
}, { expectedNode: 'verify', converge: true });
|
|
621
|
+
drive('verify', 'flow-comet-verify', 'flow-kit/prompts/7-integration.md', () => {
|
|
622
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n## 验证命令\n\n```\necho ok\n```\n');
|
|
623
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/UAT.md', '# UAT\n\n## 验收\n\n- 通过\n');
|
|
624
|
+
assertExit(runState(['record', 'verify', '{"summary":"verify complete"}'], dir, env), 0);
|
|
625
|
+
}, { expectedNode: 'archive', converge: true });
|
|
626
|
+
// 归档出口:两侧均 NEXT: done
|
|
627
|
+
assertExit(runState(['skill-load', 'archive', 'flow-comet-archive', '--prompt', 'flow-kit/prompts/7-integration.md'], dir, env), 0);
|
|
628
|
+
writeFile(dir, '.specs/archive/2026-08-28-' + CHANGE_ID + '/KNOWN-ISSUES.md', '# 遗留问题\n\n无。\n');
|
|
629
|
+
// 归档提名随证据落盘:本 change 写了 6 份任务 SUMMARY(并行 4 份 + 串行 2 份,扫描份数按
|
|
630
|
+
// 同一清单对账)。提名门缺字段即拦,与本条被测的路由收敛判据无关。
|
|
631
|
+
assertExit(runState(['record', 'archive',
|
|
632
|
+
archiveRecordJson('archive complete', ['P01', 'P02', 'S01', 'P03', 'P04', 'S02'])], dir, env), 0);
|
|
633
|
+
assertExit(runGuard(['entry', 'archive'], dir), 0);
|
|
634
|
+
const res = runGuard(['exit', 'archive', '--apply'], dir);
|
|
635
|
+
assertExit(res, 0);
|
|
636
|
+
assertOut(res, 'NEXT: done');
|
|
637
|
+
const nxt = runNext();
|
|
638
|
+
assertExit(nxt, 0);
|
|
639
|
+
assertOut(nxt, 'NEXT: done');
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
|
|
643
|
+
{
|
|
644
|
+
// 并行文件依赖检出(真实命令链路):write∩write 重叠强判前移 plan 出口——同波次并行任务
|
|
645
|
+
// 写同一路径(链式重命名的 .txt 事故面)→ 新 change BLOCKED(含重叠路径与 depends_on
|
|
646
|
+
// 恢复指引);按指引补显式 depends_on 后同出口恢复通过。read∩write 弱判:无显式关联并行对
|
|
647
|
+
// 一方读取对方写路径 → WARN 提示不 BLOCK(渐进)。同一文件跨任务族:两个未完成任务写入面
|
|
648
|
+
// 重叠且彼此无依赖路径(串行拆分同样拦截)→ 新 change BLOCKED(消息含任务对与重叠文件);
|
|
649
|
+
// 补显式 depends_on 后放行;旧 change 形态仅 WARN 不阻断;修复任务族(id 带修复前缀)
|
|
650
|
+
// 不参与该族——其顺序由修复生命周期保证,回修同一文件是必然形态。修复前 plan 出口无这些
|
|
651
|
+
// 检测 = 预期 RED。
|
|
652
|
+
name: 'A16 plan 出口文件依赖检出:写写重叠 BLOCK 与恢复 + glob 单侧/双侧/不重叠 + 读写弱判 WARN + 同文件跨任务无依赖路径(真实命令)',
|
|
653
|
+
run: (dir) => {
|
|
654
|
+
driveThroughDesign(dir);
|
|
655
|
+
const planEnv = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
656
|
+
// 非 --apply 出口(弱判/强判阶段不推进状态,避免 apply 后 currentNode 偏离 plan)
|
|
657
|
+
const exitPlanNoApply = () => runGuard(['exit', 'plan'], dir, planEnv);
|
|
658
|
+
const exitPlanApply = () => runGuard(['exit', 'plan', '--apply'], dir, planEnv);
|
|
659
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir), 0);
|
|
660
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan drafted"}'], dir), 0);
|
|
661
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
662
|
+
const planTask = (taskBody) => writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + taskBody);
|
|
663
|
+
const C1 = '<task id="C1" status="pending"><action>实现 C1</action><write_files>src/c1.mjs</write_files><verify>node --check src/c1.mjs</verify></task>\n';
|
|
664
|
+
// 弱判(渐进):无显式关联并行对 read∩write → WARN 提示不 BLOCK
|
|
665
|
+
planTask(
|
|
666
|
+
C1 +
|
|
667
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><read_files>shared-context.md</read_files><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify></task>\n' +
|
|
668
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>shared-context.md</write_files><verify>node --check shared-context.md</verify></task>\n');
|
|
669
|
+
const weakRes = exitPlanNoApply();
|
|
670
|
+
assertExit(weakRes, 0);
|
|
671
|
+
assertOut(weakRes, 'read∩write');
|
|
672
|
+
assertOut(weakRes, 'shared-context.md');
|
|
673
|
+
assertNotOut(weakRes, 'BLOCKED');
|
|
674
|
+
// 强判(负例):P01/P02 同波次并行写同一 .txt 路径(无 depends_on)→ BLOCKED 含恢复指引
|
|
675
|
+
planTask(
|
|
676
|
+
C1 +
|
|
677
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify></task>\n' +
|
|
678
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify></task>\n');
|
|
679
|
+
const blocked = exitPlanNoApply();
|
|
680
|
+
assertExit(blocked, 1);
|
|
681
|
+
assertOut(blocked, 'BLOCKED');
|
|
682
|
+
assertOut(blocked, 'bak_a.txt');
|
|
683
|
+
assertOut(blocked, 'depends_on');
|
|
684
|
+
// glob 形态重叠(单侧元字符 × 字面路径):修复前逐字相等判定漏检 ⇒ 静默放行(本段即 RED);
|
|
685
|
+
// 反向构造:改为互不重叠 / 段数不等 / 段内不匹配 ⇒ 放行(判据不恒真空过);双侧 glob ⇒ 保守判重叠。
|
|
686
|
+
const globPair = (firstWrite, secondWrite, secondDeps = '') =>
|
|
687
|
+
C1 +
|
|
688
|
+
'<task id="G01" parallel="true" status="pending"><action>实现 G01</action><write_files>' + firstWrite + '</write_files><verify>node --check src/x.mjs</verify></task>\n' +
|
|
689
|
+
'<task id="G02" parallel="true" status="pending"><action>实现 G02</action><write_files>' + secondWrite + '</write_files><verify>node --check src/x.mjs</verify>' + secondDeps + '</task>\n';
|
|
690
|
+
planTask(globPair('src/glob/*.mjs', 'src/glob/foo.mjs'));
|
|
691
|
+
const globBlocked = exitPlanNoApply();
|
|
692
|
+
assertExit(globBlocked, 1);
|
|
693
|
+
assertOut(globBlocked, 'BLOCKED');
|
|
694
|
+
assertOut(globBlocked, 'G01×G02');
|
|
695
|
+
assertOut(globBlocked, 'src/glob/*.mjs');
|
|
696
|
+
assertOut(globBlocked, 'src/glob/foo.mjs');
|
|
697
|
+
assertOut(globBlocked, 'depends_on');
|
|
698
|
+
planTask(globPair('src/glob/*.mjs', 'src/glob/deep/foo.mjs'));
|
|
699
|
+
const depthMismatch = exitPlanNoApply();
|
|
700
|
+
assertExit(depthMismatch, 0);
|
|
701
|
+
assertNotOut(depthMismatch, 'BLOCKED');
|
|
702
|
+
planTask(globPair('src/glob/*.mjs', 'src/glob/foo.js'));
|
|
703
|
+
const suffixMismatch = exitPlanNoApply();
|
|
704
|
+
assertExit(suffixMismatch, 0);
|
|
705
|
+
assertNotOut(suffixMismatch, 'BLOCKED');
|
|
706
|
+
planTask(globPair('src/glob/*.mjs', 'src/glob/*.js'));
|
|
707
|
+
const doubleGlob = exitPlanNoApply();
|
|
708
|
+
assertExit(doubleGlob, 1);
|
|
709
|
+
assertOut(doubleGlob, 'BLOCKED');
|
|
710
|
+
assertOut(doubleGlob, 'G01×G02');
|
|
711
|
+
// 恢复(真实链路):按指引补显式 depends_on(重叠路径不改)⇒ 同一出口放行
|
|
712
|
+
planTask(globPair('src/glob/*.mjs', 'src/glob/foo.mjs', '<depends_on>G01</depends_on>'));
|
|
713
|
+
const globRecovered = exitPlanNoApply();
|
|
714
|
+
assertExit(globRecovered, 0);
|
|
715
|
+
assertOut(globRecovered, 'ALL CHECKS PASSED');
|
|
716
|
+
assertNotOut(globRecovered, 'BLOCKED');
|
|
717
|
+
// 同一文件跨任务族(负例):两个非修复任务写入同一文件、彼此无依赖路径(串行拆分同样构成
|
|
718
|
+
// 「未显式排序的同文件多任务」)→ 新 change BLOCKED,消息含任务对与重叠文件 + 恢复指引。
|
|
719
|
+
// 同夹具并列一对修复任务(id 带修复前缀)写同一文件且无依赖路径——该族不参与判定,
|
|
720
|
+
// 消息中不得出现它们(其顺序由修复生命周期保证)。
|
|
721
|
+
const fixPair =
|
|
722
|
+
'<task id="T-FIX-01" status="pending"><action>修复 F1</action><write_files>src/fix.mjs</write_files><verify>node --check src/fix.mjs</verify></task>\n' +
|
|
723
|
+
'<task id="T-FIX-02" status="pending"><action>修复 F2</action><write_files>src/fix.mjs</write_files><verify>node --check src/fix.mjs</verify></task>\n';
|
|
724
|
+
const sameFileTask = (id, depsElement) =>
|
|
725
|
+
'<task id="' + id + '" status="pending"><action>实现 ' + id + '</action><write_files>src/x.mjs</write_files>' +
|
|
726
|
+
'<verify>node --check src/x.mjs</verify>' + depsElement + '</task>\n';
|
|
727
|
+
const sameFilePairNoDeps = sameFileTask('X1', '') + sameFileTask('X2', '');
|
|
728
|
+
const sameFilePairWithDeps = sameFileTask('X1', '') + sameFileTask('X2', '<depends_on>X1</depends_on>');
|
|
729
|
+
planTask(C1 + sameFilePairNoDeps + fixPair);
|
|
730
|
+
const sameFileBlocked = exitPlanNoApply();
|
|
731
|
+
assertExit(sameFileBlocked, 1);
|
|
732
|
+
assertOut(sameFileBlocked, 'BLOCKED');
|
|
733
|
+
assertOut(sameFileBlocked, '同文件跨任务且无依赖路径');
|
|
734
|
+
assertOut(sameFileBlocked, 'X1×X2');
|
|
735
|
+
assertOut(sameFileBlocked, 'src/x.mjs');
|
|
736
|
+
assertOut(sameFileBlocked, 'depends_on');
|
|
737
|
+
assertNotOut(sameFileBlocked, 'T-FIX-01');
|
|
738
|
+
assertNotOut(sameFileBlocked, 'src/fix.mjs');
|
|
739
|
+
// 修复任务族谓词边界(唯一谓词 = id 前缀 + 「位于 Fix 段内」两条边界,只在引擎内表达一次):
|
|
740
|
+
// ① 形似而非修复编号的 id 不属修复族——「前缀后缺连字符」的形似编号在旧判据的宽松前缀下
|
|
741
|
+
// 整对被放过;正确判据下它与同文件无依赖路径对一律 BLOCKED。
|
|
742
|
+
const lookalikeFixPair =
|
|
743
|
+
'<task id="T-FIXUP-01" status="pending"><action>实现 T-FIXUP-01</action><write_files>src/lookalike.mjs</write_files><verify>node --check src/lookalike.mjs</verify></task>\n' +
|
|
744
|
+
'<task id="T-FIXUP-02" status="pending"><action>实现 T-FIXUP-02</action><write_files>src/lookalike.mjs</write_files><verify>node --check src/lookalike.mjs</verify></task>\n';
|
|
745
|
+
planTask(C1 + lookalikeFixPair);
|
|
746
|
+
const lookalikeBlocked = exitPlanNoApply();
|
|
747
|
+
assertExit(lookalikeBlocked, 1);
|
|
748
|
+
assertOut(lookalikeBlocked, 'BLOCKED');
|
|
749
|
+
assertOut(lookalikeBlocked, '同文件跨任务且无依赖路径');
|
|
750
|
+
assertOut(lookalikeBlocked, 'T-FIXUP-01×T-FIXUP-02');
|
|
751
|
+
assertOut(lookalikeBlocked, 'src/lookalike.mjs');
|
|
752
|
+
// ② Fix 段内、id 不带修复前缀的修复任务同属修复族——旧判据只认 id 前缀,会把段内这对当普通
|
|
753
|
+
// 参与者误 BLOCK;正确判据下段内任务整体不参与该族 → 出口放行且无该族消息。
|
|
754
|
+
const fixSectionPair =
|
|
755
|
+
'<task id="F01" status="pending"><action>修复 F01</action><write_files>src/fix-section.mjs</write_files><verify>node --check src/fix-section.mjs</verify></task>\n' +
|
|
756
|
+
'<task id="F02" status="pending"><action>修复 F02</action><write_files>src/fix-section.mjs</write_files><verify>node --check src/fix-section.mjs</verify></task>\n';
|
|
757
|
+
planTask(C1 + '\n## Fix 任务\n\n' + fixSectionPair);
|
|
758
|
+
const fixSectionRes = exitPlanNoApply();
|
|
759
|
+
assertExit(fixSectionRes, 0);
|
|
760
|
+
assertNotOut(fixSectionRes, '同文件跨任务且无依赖路径');
|
|
761
|
+
assertNotOut(fixSectionRes, 'BLOCKED');
|
|
762
|
+
// 旧 change 形态(无新 change 标记):同形态仅 WARN 渐进不阻断,恢复指引仍在
|
|
763
|
+
planTask(C1 + sameFilePairNoDeps + fixPair);
|
|
764
|
+
const sameFileState = readStateFile(dir);
|
|
765
|
+
delete sameFileState.newChange;
|
|
766
|
+
writeState(dir, sameFileState);
|
|
767
|
+
const sameFileWarn = exitPlanNoApply();
|
|
768
|
+
assertExit(sameFileWarn, 0);
|
|
769
|
+
assertOut(sameFileWarn, 'WARN');
|
|
770
|
+
assertOut(sameFileWarn, '同文件跨任务且无依赖路径');
|
|
771
|
+
assertOut(sameFileWarn, 'X1×X2');
|
|
772
|
+
assertNotOut(sameFileWarn, 'BLOCKED');
|
|
773
|
+
writeState(dir, { ...sameFileState, newChange: true });
|
|
774
|
+
// 恢复:按指引补显式 depends_on,且 **P02 保持写原重叠路径 bak_a.txt**
|
|
775
|
+
// (不改路径避开重叠)——证明「补 depends_on 解决原重叠」而非「改路径避开重叠」;补依赖后
|
|
776
|
+
// P02 跨趟(dep 未满足,不在本趟可运行集合)→ 同波次并行对只剩 P01 → 重叠消失 → 同出口通过。
|
|
777
|
+
// 同一文件跨任务族同批恢复:X2 补 depends_on X1(重叠路径不改);并列的修复任务对保持无依赖
|
|
778
|
+
// ——该族不参与判定,故不影响本出口通过。
|
|
779
|
+
planTask(
|
|
780
|
+
C1 +
|
|
781
|
+
'<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify></task>\n' +
|
|
782
|
+
'<task id="P02" parallel="true" status="pending"><action>实现 P02</action><write_files>bak_a.txt</write_files><verify>node --check bak_a.txt</verify><depends_on>P01</depends_on></task>\n' +
|
|
783
|
+
sameFilePairWithDeps + fixPair);
|
|
784
|
+
const ok = exitPlanApply();
|
|
785
|
+
assertExit(ok, 0);
|
|
786
|
+
assertOut(ok, 'ALL CHECKS PASSED');
|
|
787
|
+
assertNotOut(ok, 'BLOCKED');
|
|
788
|
+
assertNotOut(ok, '同文件跨任务且无依赖路径');
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
|
|
792
|
+
{
|
|
793
|
+
// 多趟平行转换后 next 可达且与 guard 出口一致(真实命令链路):在 A15 的收敛链路之上,
|
|
794
|
+
// 把此前排除在收敛断言面外的两个平行转换点(plan→subagent-execute、subagent-execute→execute
|
|
795
|
+
// 趟间回流)也纳入 next 收敛断言——修复前 next 在这些转换点被误拦为“疑似未 exit”,预期失败。
|
|
796
|
+
name: 'A17 多趟平行转换后 next 可达:各转换点 next 与 guard 出口 NODE 一致(真实命令)',
|
|
797
|
+
run: (dir) => {
|
|
798
|
+
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
799
|
+
const writeTask = (statusMap) => {
|
|
800
|
+
const blk = (id, parallel, deps) =>
|
|
801
|
+
'<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
|
|
802
|
+
' status="' + (statusMap[id] === 'done' ? 'done' : 'pending') + '">' +
|
|
803
|
+
'<action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files>' +
|
|
804
|
+
'<verify>node --check src/' + id.toLowerCase() + '.mjs</verify>' +
|
|
805
|
+
(deps ? '<depends_on>' + deps + '</depends_on>' : '') + '</task>\n';
|
|
806
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
807
|
+
blk('P01', true, '') + blk('P02', true, '') +
|
|
808
|
+
blk('S01', false, 'P01,P02') +
|
|
809
|
+
blk('P03', true, 'S01') + blk('P04', true, 'S01') +
|
|
810
|
+
blk('S02', false, 'P03,P04'));
|
|
811
|
+
};
|
|
812
|
+
const runNext = () => runState(['next'], dir, env);
|
|
813
|
+
const nodeOf = (out) => (out.match(/^NODE: ([a-z-]+)$/m) || [])[1] ?? null;
|
|
814
|
+
const completeTasks = (ids) => {
|
|
815
|
+
for (const id of ids) {
|
|
816
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', execSummaryFixture(id));
|
|
817
|
+
assertExit(runHandoff(['request', id, id + ' 委托', '--write-files', 'src/' + id.toLowerCase() + '.mjs'], dir), 0);
|
|
818
|
+
assertExit(runHandoff(['result', id, fullContract('abcd1234abcd1234abcd1234abcd1234abcd1234', id)], dir), 0);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
// drive 收敛面全量:每个转换点(含平行跳转与趟间回流)都断言 next 可达且与 guard 出口 NODE 一致
|
|
822
|
+
const drive = (nodeId, skill, prompt, prepare, { expectedNode } = {}) => {
|
|
823
|
+
assertExit(runState(skillLoadArgs(nodeId, skill, prompt), dir, env), 0);
|
|
824
|
+
prepare();
|
|
825
|
+
assertExit(runGuard(['entry', nodeId], dir), 0);
|
|
826
|
+
const res = runGuard(['exit', nodeId, '--apply'], dir);
|
|
827
|
+
assertExit(res, 0);
|
|
828
|
+
const n1 = nodeOf(res.output);
|
|
829
|
+
if (expectedNode && n1 !== expectedNode) {
|
|
830
|
+
throw new Error('节点 ' + nodeId + ' 出口后 guard NODE(' + n1 + ') != 期望(' + expectedNode +
|
|
831
|
+
')\nguard:\n' + res.output);
|
|
832
|
+
}
|
|
833
|
+
const nxt = runNext();
|
|
834
|
+
assertExit(nxt, 0);
|
|
835
|
+
const n2 = nodeOf(nxt.output);
|
|
836
|
+
if (n1 !== n2) {
|
|
837
|
+
throw new Error('节点 ' + nodeId + ' 出口后 guard NODE(' + n1 + ') != next NODE(' + n2 +
|
|
838
|
+
')\nguard:\n' + res.output + '\nnext:\n' + nxt.output);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', execSummaryFixture(id)); };
|
|
842
|
+
driveThroughDesign(dir);
|
|
843
|
+
writeTask({ P01: 'pending', P02: 'pending', S01: 'pending', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
844
|
+
// ① plan 出口 → subagent-execute(平行跳转——修复前 next 误拦)
|
|
845
|
+
drive('plan', 'flow-comet-plan', 'flow-kit/prompts/3-task.md', () => assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0),
|
|
846
|
+
{ expectedNode: 'subagent-execute' });
|
|
847
|
+
// ② 首波并行委托完成 → 趟间回串行 execute(平行回流——修复前 next 误拦)
|
|
848
|
+
drive('subagent-execute', 'flow-comet-subagent-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
849
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'pending', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
850
|
+
writeSummary(['P01', 'P02']);
|
|
851
|
+
completeTasks(['P01', 'P02']);
|
|
852
|
+
assertExit(runState(['record', 'subagent-execute', '{"summary":"wave 1 delegated and collected"}'], dir, env), 0);
|
|
853
|
+
}, { expectedNode: 'execute' });
|
|
854
|
+
// ③ 串行衔接完成 → 第二波并行可委托
|
|
855
|
+
drive('execute', 'flow-comet-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
856
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'pending', P04: 'pending', S02: 'pending' });
|
|
857
|
+
writeSummary(['S01']);
|
|
858
|
+
completeTasks(['S01']);
|
|
859
|
+
assertExit(runState(['record', 'execute', '{"summary":"serial wave complete"}'], dir, env), 0);
|
|
860
|
+
}, { expectedNode: 'subagent-execute' });
|
|
861
|
+
// ④ 第二波并行委托完成 → 收尾串行回流 execute
|
|
862
|
+
drive('subagent-execute', 'flow-comet-subagent-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
863
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'done', P04: 'done', S02: 'pending' });
|
|
864
|
+
writeSummary(['P03', 'P04']);
|
|
865
|
+
completeTasks(['P03', 'P04']);
|
|
866
|
+
assertExit(runState(['record', 'subagent-execute', '{"summary":"wave 2 delegated and collected"}'], dir, env), 0);
|
|
867
|
+
}, { expectedNode: 'execute' });
|
|
868
|
+
// ⑤ 收尾串行完成 → review(后随 review→verify→archive 同 A15 形态)
|
|
869
|
+
drive('execute', 'flow-comet-execute', 'flow-kit/prompts/4-dev.md', () => {
|
|
870
|
+
writeTask({ P01: 'done', P02: 'done', S01: 'done', P03: 'done', P04: 'done', S02: 'done' });
|
|
871
|
+
writeSummary(['S02']);
|
|
872
|
+
completeTasks(['S02']);
|
|
873
|
+
assertExit(runState(['record', 'execute', '{"summary":"final serial wave complete"}'], dir, env), 0);
|
|
874
|
+
}, { expectedNode: 'review' });
|
|
875
|
+
drive('review', 'flow-comet-review', 'flow-kit/prompts/6-review.md', () => {
|
|
876
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/REVIEW.md',
|
|
877
|
+
'# REVIEW\n\n## 发现\n\n### Critical\n\n- 无\n\n### Major\n\n- 无\n\n### Minor\n\n- 无\n\n## 结论\n\nreview passed,无遗留问题。\n');
|
|
878
|
+
assertExit(runState(['record', 'review', '{"summary":"review complete"}'], dir, env), 0);
|
|
879
|
+
}, { expectedNode: 'verify' });
|
|
880
|
+
drive('verify', 'flow-comet-verify', 'flow-kit/prompts/7-integration.md', () => {
|
|
881
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n## 验证命令\n\n```\necho ok\n```\n');
|
|
882
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/UAT.md', '# UAT\n\n## 验收\n\n- 通过\n');
|
|
883
|
+
assertExit(runState(['record', 'verify', '{"summary":"verify complete"}'], dir, env), 0);
|
|
884
|
+
}, { expectedNode: 'archive' });
|
|
885
|
+
// 归档出口:两侧均 NEXT: done
|
|
886
|
+
assertExit(runState(['skill-load', 'archive', 'flow-comet-archive', '--prompt', 'flow-kit/prompts/7-integration.md'], dir, env), 0);
|
|
887
|
+
writeFile(dir, '.specs/archive/2026-08-28-' + CHANGE_ID + '/KNOWN-ISSUES.md', '# 遗留问题\n\n无。\n');
|
|
888
|
+
// 归档提名随证据落盘:本 change 写了 6 份任务 SUMMARY(并行 4 份 + 串行 2 份,扫描份数按
|
|
889
|
+
// 同一清单对账)。提名门缺字段即拦,与本条被测的路由收敛判据无关。
|
|
890
|
+
assertExit(runState(['record', 'archive',
|
|
891
|
+
archiveRecordJson('archive complete', ['P01', 'P02', 'S01', 'P03', 'P04', 'S02'])], dir, env), 0);
|
|
892
|
+
assertExit(runGuard(['entry', 'archive'], dir), 0);
|
|
893
|
+
const resArch = runGuard(['exit', 'archive', '--apply'], dir);
|
|
894
|
+
assertExit(resArch, 0);
|
|
895
|
+
assertOut(resArch, 'NEXT: done');
|
|
896
|
+
const nxt = runNext();
|
|
897
|
+
assertExit(nxt, 0);
|
|
898
|
+
assertOut(nxt, 'NEXT: done');
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
|
+
|
|
902
|
+
{
|
|
903
|
+
// 漂移容忍 exit 系统锚(真实命令链路):execute 产物/证据齐(单任务完成 +
|
|
904
|
+
// SUMMARY + record execute + entry execute)→ 构造欠账漂移态(currentNode 漂移到文件推导
|
|
905
|
+
// 下一节点 review,execute 未进 completedNodes)→ 容错 exit execute --apply 补齐欠账。
|
|
906
|
+
// 修复前 currentNode 校验直接 BLOCK → 预期失败(RED 锚);场景级同语义锚见自测套件。
|
|
907
|
+
name: 'A18 漂移容忍 exit:execute 欠账经容错路径补齐(真实命令)',
|
|
908
|
+
run: (dir) => {
|
|
909
|
+
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
910
|
+
const writeTask = (statusMap) => {
|
|
911
|
+
const blk = (id, status) =>
|
|
912
|
+
'<task id="' + id + '" status="' + status + '">' +
|
|
913
|
+
'<action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files>' +
|
|
914
|
+
'<verify>node --check src/' + id.toLowerCase() + '.mjs</verify></task>\n';
|
|
915
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + blk('S01', statusMap.S01 ?? 'pending'));
|
|
916
|
+
};
|
|
917
|
+
// 驱动至 plan 出口(真实命令:init→open→design 见 driveThroughDesign,随后 plan 三连)
|
|
918
|
+
driveThroughDesign(dir);
|
|
919
|
+
writeTask({ S01: 'pending' });
|
|
920
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir, env), 0);
|
|
921
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0);
|
|
922
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
923
|
+
assertExit(runGuard(['exit', 'plan', '--apply'], dir), 0);
|
|
924
|
+
// execute 完整完成(产物 + record + entry,真实命令)——仅差 completedNodes(欠账)
|
|
925
|
+
writeTask({ S01: 'done' });
|
|
926
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', execSummaryFixture('S01'));
|
|
927
|
+
assertExit(runState(['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir, env), 0);
|
|
928
|
+
assertExit(runState(['record', 'execute', '{"summary":"executed","parallelTakeoverApproved":true}'], dir, env), 0);
|
|
929
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
930
|
+
// R-1 欠账漂移态:currentNode 漂移到文件推导下一节点 review(execute 未 completed)
|
|
931
|
+
const st = readStateFile(dir);
|
|
932
|
+
st.currentNode = 'review';
|
|
933
|
+
writeState(dir, st);
|
|
934
|
+
// 容错 exit execute --apply → 补齐欠账(completedNodes 补 execute)
|
|
935
|
+
const res = runGuard(['exit', 'execute', '--apply'], dir);
|
|
936
|
+
assertExit(res, 0);
|
|
937
|
+
assertOut(res, 'ALL CHECKS PASSED');
|
|
938
|
+
const stAfter = readStateFile(dir);
|
|
939
|
+
if (!stAfter.completedNodes.includes('execute')) {
|
|
940
|
+
throw new Error('容错 exit execute --apply 后 completedNodes 应含 execute(欠账补齐);实际: ' + stAfter.completedNodes.join(','));
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
|
|
945
|
+
{
|
|
946
|
+
// 路由诊断静默扩展系统锚(真实命令链路):波 1 并行完成后剩余串行 pending
|
|
947
|
+
// (P→S 收尾转换)→ subagent-execute 出口无 ROUTE WARN 噪音;畸形 parallel(parallel=true
|
|
948
|
+
// 缺 status)+ 串行 pending → ROUTE WARN 仍报(结构校验严格保持)。场景级同语义见自测套件对应锚。
|
|
949
|
+
name: 'A19 路由诊断静默扩展:P→S 收尾无噪音 / 畸形块仍报(真实命令)',
|
|
950
|
+
run: (dir) => {
|
|
951
|
+
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
952
|
+
const writeTask = (statusMap, extra) => {
|
|
953
|
+
const blk = (id, parallel, status, deps) =>
|
|
954
|
+
'<task id="' + id + '"' + (parallel ? ' parallel="true"' : ' parallel="false"') +
|
|
955
|
+
' status="' + status + '">' +
|
|
956
|
+
'<name>任务-' + id + '</name><read_files>src/*</read_files>' +
|
|
957
|
+
'<action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files>' +
|
|
958
|
+
'<verify>node --check src/' + id.toLowerCase() + '.mjs</verify>' +
|
|
959
|
+
'<done>AC-' + id + '</done><depends_on>' + (deps || '') + '</depends_on></task>\n';
|
|
960
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
961
|
+
(extra ? extra
|
|
962
|
+
: blk('P01', true, statusMap.P01 ?? 'pending', '') + blk('S01', false, statusMap.S01 ?? 'pending', 'P01')));
|
|
963
|
+
};
|
|
964
|
+
driveThroughDesign(dir);
|
|
965
|
+
writeTask({ P01: 'pending', S01: 'pending' });
|
|
966
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir, env), 0);
|
|
967
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0);
|
|
968
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
969
|
+
assertExit(runGuard(['exit', 'plan', '--apply'], dir), 0);
|
|
970
|
+
// 波 1:并行任务完成(SUMMARY+handoff)→ P→S 收尾(串行尾任务 pending);
|
|
971
|
+
// 发起委托前先 skill-load 声明(handoff request 前置门——先声明再发起委托,与既有委托链同序)
|
|
972
|
+
writeTask({ P01: 'done', S01: 'pending' });
|
|
973
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/P01-SUMMARY.md', execSummaryFixture('P01'));
|
|
974
|
+
assertExit(runState(['skill-load', 'subagent-execute', 'flow-comet-subagent-execute', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir, env), 0);
|
|
975
|
+
assertExit(runHandoff(['request', 'P01', 'P01 委托', '--write-files', 'src/p01.mjs'], dir), 0);
|
|
976
|
+
assertExit(runHandoff(['result', 'P01', fullContract('abcd1234abcd1234abcd1234abcd1234abcd1234', 'P01')], dir), 0);
|
|
977
|
+
assertExit(runState(['record', 'subagent-execute', '{"summary":"wave 1 delegated and collected"}'], dir, env), 0);
|
|
978
|
+
assertExit(runGuard(['entry', 'subagent-execute'], dir), 0);
|
|
979
|
+
const resWave = runGuard(['exit', 'subagent-execute', '--apply'], dir);
|
|
980
|
+
assertExit(resWave, 0);
|
|
981
|
+
assertNotOut(resWave, 'ROUTE WARN'); // 剩余 pending 全串行(P→S 收尾)→ 静默
|
|
982
|
+
// 畸形块仍报:parallel 缺 status(但 7 字段齐)+ 串行 pending → ROUTE WARN 保持
|
|
983
|
+
// (构造 plan 出口态,既有出口同款夹具形态;新 change 下畸形块亦须过结构门再达诊断)
|
|
984
|
+
const st = readStateFile(dir);
|
|
985
|
+
st.currentNode = 'plan';
|
|
986
|
+
st.completedNodes = ['open', 'design'];
|
|
987
|
+
writeState(dir, st);
|
|
988
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
|
|
989
|
+
'<task id="P03" parallel="true"><name>任务-P03(畸形并行,缺 status)</name><read_files>src/*</read_files>' +
|
|
990
|
+
'<action>实现 P03</action><write_files>src/p03.mjs</write_files><verify>node --check src/p03.mjs</verify>' +
|
|
991
|
+
'<done>AC-P03</done><depends_on></depends_on></task>\n' +
|
|
992
|
+
'<task id="S02" parallel="false" status="pending"><name>任务-S02(串行)</name><read_files>src/*</read_files>' +
|
|
993
|
+
'<action>实现 S02</action><write_files>src/s02.mjs</write_files><verify>node --check src/s02.mjs</verify>' +
|
|
994
|
+
'<done>AC-S02</done><depends_on></depends_on></task>\n');
|
|
995
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0);
|
|
996
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
997
|
+
const resMal = runGuard(['exit', 'plan', '--apply'], dir);
|
|
998
|
+
assertExit(resMal, 0);
|
|
999
|
+
assertOut(resMal, 'ROUTE WARN'); // 畸形块仍报(结构校验严格保持)
|
|
1000
|
+
},
|
|
1001
|
+
},
|
|
1002
|
+
|
|
1003
|
+
{
|
|
1004
|
+
// directOverride 授权约束系统锚(真实命令链路):执行者自切 direct 无授权(绕过脚本手改
|
|
1005
|
+
// state——修复后 hook 会拦截此类工具写;此处直接构造越权形态验证 guard 出口拦截)→
|
|
1006
|
+
// execute 出口 BLOCKED + 恢复指引;协调者授权路径(execution-mode direct 真实命令写入
|
|
1007
|
+
// 授权留痕)→ 出口通过。场景级同语义见自测套件对应锚。
|
|
1008
|
+
name: 'A20 directOverride 授权约束:自切 direct 无授权 BLOCK / 协调者授权通过(真实命令)',
|
|
1009
|
+
run: (dir) => {
|
|
1010
|
+
const env = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
1011
|
+
const writeTask = (statusMap) => {
|
|
1012
|
+
const blk = (id, status) =>
|
|
1013
|
+
'<task id="' + id + '" status="' + status + '">' +
|
|
1014
|
+
'<action>实现 ' + id + '</action><write_files>src/' + id.toLowerCase() + '.mjs</write_files>' +
|
|
1015
|
+
'<verify>node --check src/' + id.toLowerCase() + '.mjs</verify></task>\n';
|
|
1016
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' + blk('S01', statusMap.S01 ?? 'pending'));
|
|
1017
|
+
};
|
|
1018
|
+
// 驱动至 execute(真实命令:init→open→design→plan 出口)
|
|
1019
|
+
driveThroughDesign(dir);
|
|
1020
|
+
writeTask({ S01: 'pending' });
|
|
1021
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir, env), 0);
|
|
1022
|
+
assertExit(runState(['record', 'plan', '{"summary":"plan complete"}'], dir, env), 0);
|
|
1023
|
+
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
1024
|
+
assertExit(runGuard(['exit', 'plan', '--apply'], dir), 0);
|
|
1025
|
+
// execute 完整完成(产物 + record + entry,真实命令)
|
|
1026
|
+
writeTask({ S01: 'done' });
|
|
1027
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', execSummaryFixture('S01'));
|
|
1028
|
+
assertExit(runState(['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir, env), 0);
|
|
1029
|
+
assertExit(runState(['record', 'execute', '{"summary":"executed"}'], dir, env), 0);
|
|
1030
|
+
assertExit(runGuard(['entry', 'execute'], dir), 0);
|
|
1031
|
+
// 执行者自切 direct(directOverride=true 但无授权审计记录——B 方案前的自切/遗留形态)
|
|
1032
|
+
const st = readStateFile(dir);
|
|
1033
|
+
st.executionMode = 'direct';
|
|
1034
|
+
st.directOverride = true;
|
|
1035
|
+
writeState(dir, st);
|
|
1036
|
+
const rBlock = runGuard(['exit', 'execute', '--apply'], dir);
|
|
1037
|
+
assertExit(rBlock, 1);
|
|
1038
|
+
assertOut(rBlock, 'BLOCKED');
|
|
1039
|
+
assertOut(rBlock, 'directOverride');
|
|
1040
|
+
// 协调者授权路径:execution-mode direct(脚本写入授权留痕)→ exit 通过
|
|
1041
|
+
const auth = runState(['execution-mode', 'direct'], dir, env);
|
|
1042
|
+
assertExit(auth, 0);
|
|
1043
|
+
assertOut(auth, 'DIRECT-AUTH');
|
|
1044
|
+
const stAuth = readStateFile(dir);
|
|
1045
|
+
if (typeof stAuth.directOverrideAt !== 'string' || stAuth.directOverrideAt.trim() === '') {
|
|
1046
|
+
throw new Error('协调者授权后 state 应含 directOverrideAt 审计字段: ' + JSON.stringify(stAuth.directOverrideAt));
|
|
1047
|
+
}
|
|
1048
|
+
const rPass = runGuard(['exit', 'execute', '--apply'], dir);
|
|
1049
|
+
assertExit(rPass, 0);
|
|
1050
|
+
assertOut(rPass, 'ALL CHECKS PASSED');
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
];
|