flow-comet 1.6.5 → 1.8.0
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 +32 -18
- package/.flow-comet/skills/flow-comet/reference/commit-discipline.md +2 -2
- package/.flow-comet/skills/flow-comet/reference/decision-points.md +5 -5
- package/.flow-comet/skills/flow-comet/reference/dirty-worktree.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/entry-detail.md +30 -11
- package/.flow-comet/skills/flow-comet/reference/fix-loop.md +4 -4
- package/.flow-comet/skills/flow-comet/reference/init-detection.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/platform-facts.md +2 -2
- package/.flow-comet/skills/flow-comet/reference/post-archive-handoff.md +264 -0
- package/.flow-comet/skills/flow-comet/reference/recovery.md +1 -1
- package/.flow-comet/skills/flow-comet/reference/replan.md +1 -1
- package/.flow-comet/skills/flow-comet/scripts/comet-check.mjs +1 -0
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +270 -30
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +26 -23
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +14 -94
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +122 -11
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +79 -40
- package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +11 -9
- package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +52 -10
- package/.flow-comet/skills/flow-comet/scripts/items/f.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +128 -56
- package/.flow-comet/skills/flow-comet/scripts/items/k.mjs +357 -3
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +26 -1
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +6 -2
- package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +29 -21
- package/.flow-comet/skills/flow-comet/scripts/lib/ac-coverage.mjs +317 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/fix-loop-node.mjs +4 -15
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-artifact-skeleton.mjs +47 -5
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +357 -219
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +725 -309
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +182 -54
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-state-io.mjs +8 -6
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +224 -83
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +17 -28
- package/.flow-comet/skills/flow-comet/scripts/lib/lessons-hits.mjs +160 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/run-root.mjs +21 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/section-body.mjs +92 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +61 -33
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +663 -205
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +68 -9
- package/.flow-comet/skills/flow-comet/scripts/lib/state-determine.mjs +11 -4
- package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +92 -13
- package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +232 -11
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +140 -74
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +8 -4
- package/.flow-comet/skills/flow-comet/scripts/lib/task-graph.mjs +84 -31
- package/.flow-comet/skills/flow-comet/scripts/lib/test-assertions.mjs +0 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +248 -24
- package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +63 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +181 -8
- package/.flow-comet/skills/flow-comet/scripts/lib/wave-projection.mjs +340 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +132 -20
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +12 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +1564 -54
- package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +1489 -38
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +1466 -243
- package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +743 -24
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +220 -92
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +657 -21
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +41 -27
- package/.flow-comet/skills/flow-comet/scripts/scenarios/h.mjs +285 -9
- package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +7 -6
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +21 -15
- package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +8 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +45 -36
- package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +2381 -85
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +135 -2
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +143 -16
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +339 -103
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +5 -2
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +33 -11
- package/.flow-comet/skills/flow-comet-change/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-design/SKILL.md +5 -3
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +37 -13
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +10 -4
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +1 -1
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +13 -6
- package/.flow-comet/skills/flow-comet-review/SKILL.md +21 -12
- package/.flow-comet/skills/flow-comet-subagent-execute/GUIDANCE.md +1 -1
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +43 -18
- package/.flow-comet/skills/flow-comet-task/SKILL.md +4 -2
- package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +238 -21
|
@@ -43,7 +43,6 @@ export const ENTRIES = [
|
|
|
43
43
|
assertNotOut(result, 'HANDOFF WARN');
|
|
44
44
|
// 新 change 提交越界(writeFiles 范围外文件)→ BLOCKED(记录时校验)
|
|
45
45
|
const stForP4 = readStateFile(dir);
|
|
46
|
-
stForP4.newChange = true;
|
|
47
46
|
writeState(dir, stForP4);
|
|
48
47
|
writeFile(dir, 'src/evil.mjs', 'export const evil = 1;\n');
|
|
49
48
|
execFileSync('git', ['add', 'src/evil.mjs'], { cwd: dir });
|
|
@@ -102,7 +101,6 @@ export const ENTRIES = [
|
|
|
102
101
|
// ⑦ 零提交正式语义:write_files 为空 + 显式零提交 → 跳过提交子集校验 + 可审计提示;
|
|
103
102
|
// write_files 非空 + 声称 noCommit → 仍完整提交子集校验(不可借零提交绕过越界检查)
|
|
104
103
|
const stEmpty = readStateFile(dir);
|
|
105
|
-
stEmpty.newChange = true;
|
|
106
104
|
writeState(dir, stEmpty);
|
|
107
105
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n<task id="T05" status="pending"><action>无边界任务</action><write_files></write_files><verify>echo ok</verify></task>\n');
|
|
108
106
|
assertExit(runHandoff(['request', 'T05'], dir), 0);
|
|
@@ -117,7 +115,6 @@ export const ENTRIES = [
|
|
|
117
115
|
assertOut(resZero, '零提交');
|
|
118
116
|
// ⑦b 零提交滥用负例:write_files 非空 + 契约声称 noCommit → 仍完整校验(越界 BLOCK + 矛盾提示)
|
|
119
117
|
const stNonEmpty = readStateFile(dir);
|
|
120
|
-
stNonEmpty.newChange = true;
|
|
121
118
|
writeState(dir, stNonEmpty);
|
|
122
119
|
writeFile(dir, 'src/rogue-zero.mjs', 'export const rogue = 1;\n');
|
|
123
120
|
execFileSync('git', ['add', 'src/rogue-zero.mjs'], { cwd: dir });
|
|
@@ -202,7 +199,6 @@ export const ENTRIES = [
|
|
|
202
199
|
+ '<write_files>.specs/' + CHANGE_ID + '/T12-SUMMARY.md</write_files>'
|
|
203
200
|
+ '<verify>echo ok</verify></task>\n');
|
|
204
201
|
const stIgnored = readStateFile(dir);
|
|
205
|
-
stIgnored.newChange = true;
|
|
206
202
|
writeState(dir, stIgnored);
|
|
207
203
|
const reqIgnored = runHandoff(['request', 'T12'], dir, { FLOW_COMET_PROTOCOL: '' });
|
|
208
204
|
assertExit(reqIgnored, 0);
|
|
@@ -259,7 +255,6 @@ export const ENTRIES = [
|
|
|
259
255
|
const stParallel = readStateFile(dir);
|
|
260
256
|
stParallel.currentNode = 'subagent-execute';
|
|
261
257
|
stParallel.enteredNodes = ['open', 'design', 'plan', 'execute', 'subagent-execute'];
|
|
262
|
-
stParallel.newChange = true;
|
|
263
258
|
writeState(dir, stParallel);
|
|
264
259
|
const parallelEnv = { FLOW_COMET_PROTOCOL: path.join(dir, 'reference', 'workflow-protocol.json') };
|
|
265
260
|
const reqParallel = runHandoff(['request', 'P16', '并行零提交任务委托'], dir, parallelEnv);
|
|
@@ -324,7 +319,6 @@ export const ENTRIES = [
|
|
|
324
319
|
verifyFailures: 0,
|
|
325
320
|
executionMode: 'subagent',
|
|
326
321
|
directOverride: false,
|
|
327
|
-
newChange: true,
|
|
328
322
|
});
|
|
329
323
|
const reqNonGit = runHandoff(['request', 'T16', '--write-files', '.specs/' + CHANGE_ID + '/x.md'], nonGitRoot,
|
|
330
324
|
{ GIT_CEILING_DIRECTORIES: os.tmpdir() });
|
|
@@ -348,7 +342,6 @@ export const ENTRIES = [
|
|
|
348
342
|
verifyFailures: 0,
|
|
349
343
|
executionMode: 'subagent',
|
|
350
344
|
directOverride: false,
|
|
351
|
-
newChange: true,
|
|
352
345
|
});
|
|
353
346
|
writeIntakeArtifacts(dir);
|
|
354
347
|
writeFile(dir, '.specs/' + CHANGE_ID + '/DESIGN.md',
|
|
@@ -586,7 +579,7 @@ export const ENTRIES = [
|
|
|
586
579
|
const boundProtocol = JSON.parse(fs.readFileSync(path.join(dir, 'reference', 'workflow-protocol.json'), 'utf8'));
|
|
587
580
|
boundProtocol.nodes = boundProtocol.nodes.filter((n) => n.id !== 'execute' && n.id !== 'subagent-execute');
|
|
588
581
|
writeFile(dir, 'reference/protocol-bound.json', JSON.stringify(boundProtocol, null, 2) + '\n');
|
|
589
|
-
assertExit(runState(['init', boundChange, '--init-skip', '--protocol', 'reference/protocol-bound.json'], dir), 0);
|
|
582
|
+
assertExit(runState(['init', boundChange, '--init-skip', '--replace', CHANGE_ID, '--reason', '验证 state 协议绑定(真实命令链路)', '--protocol', 'reference/protocol-bound.json'], dir), 0);
|
|
590
583
|
writeFile(dir, '.specs/' + boundChange + '/TASK.md',
|
|
591
584
|
'# TASK\n\n<task id="R01" parallel="false" status="pending"><action>实现 R01</action>'
|
|
592
585
|
+ '<write_files>src/r01.mjs</write_files><verify>node --check src/r01.mjs</verify></task>\n');
|
|
@@ -609,7 +602,9 @@ export const ENTRIES = [
|
|
|
609
602
|
{
|
|
610
603
|
name: 'C2 handoff:红绿证据时间序(先红后绿通过 / 补录拦截)',
|
|
611
604
|
run: (dir) => {
|
|
612
|
-
|
|
605
|
+
const c2State = baseState('subagent-execute');
|
|
606
|
+
c2State.evidence['subagent-execute'] = { handoffRequests: { P01: { description: 'delegate', writeFiles: ['src/p1.mjs'] } } };
|
|
607
|
+
writeState(dir, c2State);
|
|
613
608
|
fs.mkdirSync(path.join(dir, '.specs', CHANGE_ID), { recursive: true });
|
|
614
609
|
// ① 先记录 RED(TDD 红)
|
|
615
610
|
const red = '{"redEvidence":{"command":"node --check src/p1.mjs"}}';
|
|
@@ -629,6 +624,13 @@ export const ENTRIES = [
|
|
|
629
624
|
throw new Error('greenEvidence 未附带 recordedAt: ' + JSON.stringify(rec.greenEvidence));
|
|
630
625
|
}
|
|
631
626
|
// ③ 新任务:先 GREEN 后补 RED → 事后补录拦截
|
|
627
|
+
// 单轨:result 必须有对应 request(未记录的委托不能回传结果)——夹具补同一份事实
|
|
628
|
+
const c2b = readStateFile(dir);
|
|
629
|
+
c2b.evidence['subagent-execute'].handoffRequests = {
|
|
630
|
+
...(c2b.evidence['subagent-execute'].handoffRequests || {}),
|
|
631
|
+
P02: { description: 'delegate', writeFiles: ['src/p2.mjs'] },
|
|
632
|
+
};
|
|
633
|
+
writeState(dir, c2b);
|
|
632
634
|
const greenOnly = '{"greenEvidence":{"command":"node --check src/p2.mjs"}}';
|
|
633
635
|
assertExit(runHandoff(['result', 'P02', greenOnly], dir), 0);
|
|
634
636
|
const backfill = '{"greenEvidence":{"command":"node --check src/p2.mjs"},"redEvidence":{"command":"node --check src/p2.mjs"}}';
|
|
@@ -103,18 +103,26 @@ function customProtocol() {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
//
|
|
107
|
-
|
|
106
|
+
// 协议变体(绑定面三态;`enforcement` 是出口覆盖判据的单一开关):
|
|
107
|
+
// · base —— 无 requiredSkillCalls:节点没有声明义务;
|
|
108
|
+
// · skill —— main scope 绑定、未登记等级:声明照旧由出口代记(required-skill 条目自动补写);
|
|
109
|
+
// · guarded —— main scope 绑定 + enforcement='guarded':该技能必须自己有一条声明标记。
|
|
110
|
+
function customProtocolVariant(variant) {
|
|
108
111
|
const p = customProtocol();
|
|
109
|
-
|
|
112
|
+
if (variant === 'skill') {
|
|
113
|
+
p.nodes[0].requiredSkillCalls = [{ skill: 'flow-comet-brainstorm', scope: 'main' }];
|
|
114
|
+
} else if (variant === 'guarded') {
|
|
115
|
+
p.nodes[0].requiredSkillCalls = [{ skill: 'flow-comet-brainstorm', scope: 'main', enforcement: 'guarded' }];
|
|
116
|
+
} else if (variant !== 'base') {
|
|
117
|
+
throw new Error('未知协议变体: ' + variant);
|
|
118
|
+
}
|
|
110
119
|
return p;
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
//
|
|
114
|
-
function writeCustomProtocol(dir,
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
fs.writeFileSync(file, JSON.stringify(proto, null, 2) + '\n', 'utf8');
|
|
122
|
+
// 写入自定义协议文件(变体见上),返回绝对路径
|
|
123
|
+
function writeCustomProtocol(dir, variant = 'base') {
|
|
124
|
+
const file = path.join(dir, variant === 'base' ? 'custom-protocol.json' : 'custom-protocol-' + variant + '.json');
|
|
125
|
+
fs.writeFileSync(file, JSON.stringify(customProtocolVariant(variant), null, 2) + '\n', 'utf8');
|
|
118
126
|
return file;
|
|
119
127
|
}
|
|
120
128
|
|
|
@@ -148,9 +156,9 @@ export const ENTRIES = [
|
|
|
148
156
|
},
|
|
149
157
|
|
|
150
158
|
{
|
|
151
|
-
name: 'E2
|
|
159
|
+
name: 'E2 自定义协议:声明机制与出口全链路(含技能绑定与 guarded 覆盖)',
|
|
152
160
|
run: (dir) => {
|
|
153
|
-
const custom = writeCustomProtocol(dir,
|
|
161
|
+
const custom = writeCustomProtocol(dir, 'skill');
|
|
154
162
|
assertExit(runState(['init', 'cp-skill', '--protocol', custom], dir), 0);
|
|
155
163
|
const env = { FLOW_COMET_PROTOCOL: custom };
|
|
156
164
|
// 自定义节点 skill-load 声明(协议节点集合动态校验)
|
|
@@ -179,6 +187,40 @@ export const ENTRIES = [
|
|
|
179
187
|
const envLoad = runGuard(['exit', 'bogus'], dir, env);
|
|
180
188
|
assertExit(envLoad, 1);
|
|
181
189
|
assertOut(envLoad, 'Unknown workflow Node');
|
|
190
|
+
|
|
191
|
+
// guarded 变体的出口覆盖判据(自定义协议路径):协议把绑定登记为 enforcement='guarded' 时,
|
|
192
|
+
// 出口要求该技能**各自**有声明标记——同节点上已声明的另一个技能不构成覆盖(record 只校验载荷里
|
|
193
|
+
// 出现的 required-skill 条目,覆盖判据要的是「每个 guarded 绑定各有一条标记」)。
|
|
194
|
+
// 对照:同一夹具换成未登记等级的绑定(skill 变体)时零该技能声明照样放行——等级是唯一开关。
|
|
195
|
+
const guardedProtocol = writeCustomProtocol(dir, 'guarded');
|
|
196
|
+
const guardedEnv = { FLOW_COMET_PROTOCOL: guardedProtocol };
|
|
197
|
+
assertExit(runState(['init', 'cp-guard', '--replace', 'cp-skill', '--reason', '切换协议夹具(覆盖闸门显式放行)', '--protocol', guardedProtocol], dir), 0);
|
|
198
|
+
assertExit(runState(['skill-load', 'brainstorm', 'flow-comet-tdd'], dir, guardedEnv), 0);
|
|
199
|
+
assertExit(runState(['record', 'brainstorm', '{"summary":"brainstorm done"}'], dir, guardedEnv), 0);
|
|
200
|
+
writeFile(dir, '.specs/cp-guard/notes.md', '# notes\n');
|
|
201
|
+
assertExit(runGuard(['entry', 'brainstorm'], dir, guardedEnv), 0);
|
|
202
|
+
const uncovered = runGuard(['exit', 'brainstorm'], dir, guardedEnv);
|
|
203
|
+
assertExit(uncovered, 1);
|
|
204
|
+
assertOut(uncovered, '缺协议声明标记');
|
|
205
|
+
assertOut(uncovered, '缺必需技能声明: flow-comet-brainstorm');
|
|
206
|
+
// 补上该绑定自己的标记 → 同一出口放行
|
|
207
|
+
assertExit(runState(['skill-load', 'brainstorm', 'flow-comet-brainstorm'], dir, guardedEnv), 0);
|
|
208
|
+
const covered = runGuard(['exit', 'brainstorm', '--apply'], dir, guardedEnv);
|
|
209
|
+
assertExit(covered, 0);
|
|
210
|
+
assertOut(covered, 'ALL CHECKS PASSED');
|
|
211
|
+
assertNotOut(covered, '缺协议声明标记');
|
|
212
|
+
// 对照:未登记等级的同一绑定 → 只声明别的技能也放行(覆盖判据不在这条路径上生效)
|
|
213
|
+
const plainProtocol = writeCustomProtocol(dir, 'skill');
|
|
214
|
+
const plainEnv = { FLOW_COMET_PROTOCOL: plainProtocol };
|
|
215
|
+
assertExit(runState(['init', 'cp-plain', '--replace', 'cp-guard', '--reason', '切换协议夹具(覆盖闸门显式放行)', '--protocol', plainProtocol], dir), 0);
|
|
216
|
+
assertExit(runState(['skill-load', 'brainstorm', 'flow-comet-tdd'], dir, plainEnv), 0);
|
|
217
|
+
assertExit(runState(['record', 'brainstorm', '{"summary":"brainstorm done"}'], dir, plainEnv), 0);
|
|
218
|
+
writeFile(dir, '.specs/cp-plain/notes.md', '# notes\n');
|
|
219
|
+
assertExit(runGuard(['entry', 'brainstorm'], dir, plainEnv), 0);
|
|
220
|
+
const ungated = runGuard(['exit', 'brainstorm'], dir, plainEnv);
|
|
221
|
+
assertExit(ungated, 0);
|
|
222
|
+
assertOut(ungated, 'ALL CHECKS PASSED');
|
|
223
|
+
assertNotOut(ungated, '缺协议声明标记');
|
|
182
224
|
},
|
|
183
225
|
},
|
|
184
226
|
|
|
@@ -40,7 +40,7 @@ export const ENTRIES = [
|
|
|
40
40
|
const st1 = readStateFile(dir);
|
|
41
41
|
if (st1.ai_context_doc !== 'none') throw new Error('跳过后 ai_context_doc 应为 none');
|
|
42
42
|
// 下次 init(新 id)尊重既有决策 → 静默
|
|
43
|
-
const second = runState(['init', CHANGE_ID + '-2'], dir);
|
|
43
|
+
const second = runState(['init', CHANGE_ID + '-2', '--replace', CHANGE_ID, '--reason', '验证跳过记忆跨 change 生效'], dir);
|
|
44
44
|
assertExit(second, 0);
|
|
45
45
|
assertNotOut(second, 'INIT-NEEDED');
|
|
46
46
|
assertNotOut(second, 'INIT-HINT');
|
|
@@ -7,7 +7,7 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { execFileSync, spawnSync } from 'child_process';
|
|
9
9
|
import { createHash } from 'crypto';
|
|
10
|
-
import { assertExit, assertNotOut, assertOut, runGuard, runHandoff, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
10
|
+
import { assertExit, assertNotOut, assertOut, assertTrue, installSkillTreeCopy, runGuard, runHandoff, runHook, runPrintedCommand, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
11
11
|
import { archiveRecordJson, CHANGE_ID, assertNodeLine, assertNotNodeLine, completeFixTaskAndRecord, driveThroughDesign, execSummaryFixture, fixBatchReviewDoc, fixBatchTaskText, fullContract, parseStatusOutput, readStateBytes, readStateFile, writeIntakeArtifacts } from '../lib/system-fixtures.mjs';
|
|
12
12
|
|
|
13
13
|
// 同夹具的「段内大写 Z 早于方法名」变体(真实机检标记形态):6 维自查段体首行是含大写 Z 的机检
|
|
@@ -108,6 +108,8 @@ function seedExecuteEntryState(dir, taskText) {
|
|
|
108
108
|
driveThroughDesign(dir);
|
|
109
109
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', taskText);
|
|
110
110
|
assertExit(runState(['skill-load', 'plan', 'flow-comet-plan', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir), 0);
|
|
111
|
+
// 协议 plan.requiredSkillCalls = flow-comet-task(guarded):出口覆盖判据要求该技能也有标记
|
|
112
|
+
assertExit(runState(['skill-load', 'plan', 'flow-comet-task', '--prompt', 'flow-kit/prompts/3-task.md', '--templates', 'TASK.md'], dir), 0);
|
|
111
113
|
assertExit(runState(['record', 'plan', '{"summary":"plan done"}'], dir), 0);
|
|
112
114
|
assertExit(runGuard(['entry', 'plan'], dir), 0);
|
|
113
115
|
const planExit = runGuard(['exit', 'plan', '--apply'], dir);
|
|
@@ -146,18 +148,27 @@ export const ENTRIES = [
|
|
|
146
148
|
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
147
149
|
assertExit(runState(['skill-load', 'verify', 'flow-comet-integration', '--prompt', 'flow-kit/prompts/7-integration.md'], dir), 0);
|
|
148
150
|
writeFile(dir, '.specs/' + CHANGE_ID + '/UAT.md', '# UAT\n\n通过\n');
|
|
151
|
+
// verify 出口先跑 AC 覆盖判据(新 change):夹具给出可判的最小一对——准则清单 + 1.1 矩阵行
|
|
152
|
+
// (矩阵行写在围栏外;围栏里的编号只是书写样例,不计覆盖)。本项被测的是验证命令的真实执行,
|
|
153
|
+
// 不是 AC 覆盖,故这里只补输入面、不动任何断言。
|
|
154
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/REQUIREMENT.md',
|
|
155
|
+
'# REQUIREMENT\n\n- **Change ID**: ' + CHANGE_ID
|
|
156
|
+
+ '\n\n## 用户故事\n\n- US-1:作为执行者,我想让验证命令真的被执行。'
|
|
157
|
+
+ '\n\n## 验收准则(AC)\n\n- **AC-1**: Given 夹具前置 When 夹具动作 Then 夹具结果\n');
|
|
158
|
+
const acCoverageBlock = '## 第 1 轮 · 功能测试\n\n### 1.1 测试矩阵(AC → 用例)\n\n'
|
|
159
|
+
+ '| AC | 类型 | 用例文件 / UAT | 状态 |\n|---|---|---|---|\n| AC-1 | unit | baseline.js | ✅ |\n\n';
|
|
149
160
|
assertExit(runState(['record', 'verify', '{"summary":"verified"}'], dir), 0);
|
|
150
161
|
const st = readStateFile(dir);
|
|
151
162
|
st.currentNode = 'verify';
|
|
152
163
|
writeState(dir, st);
|
|
153
164
|
// ① 快速命令 → 出口通过
|
|
154
|
-
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n## 验证命令\n\n```bash\nnode -e "1"\n```\n');
|
|
165
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n' + acCoverageBlock + '## 验证命令\n\n```bash\nnode -e "1"\n```\n');
|
|
155
166
|
assertExit(runGuard(['entry', 'verify'], dir), 0);
|
|
156
167
|
const pass = runGuard(['exit', 'verify'], dir);
|
|
157
168
|
assertExit(pass, 0);
|
|
158
169
|
assertOut(pass, 'ALL CHECKS PASSED');
|
|
159
170
|
// ② 缺省超时(未设 env)保持大值:耗时命令通过
|
|
160
|
-
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n## 验证命令\n\n```bash\nnode -e "setTimeout(()=>{}, 1500)"\n```\n');
|
|
171
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n' + acCoverageBlock + '## 验证命令\n\n```bash\nnode -e "setTimeout(()=>{}, 1500)"\n```\n');
|
|
161
172
|
const defaultTimeout = runGuard(['exit', 'verify'], dir);
|
|
162
173
|
assertExit(defaultTimeout, 0);
|
|
163
174
|
assertOut(defaultTimeout, 'ALL CHECKS PASSED');
|
|
@@ -175,7 +186,7 @@ export const ENTRIES = [
|
|
|
175
186
|
throw new Error('exit verify 失败计数未按 change 写入: ' + JSON.stringify(stTimed.verifyFailuresByChange));
|
|
176
187
|
}
|
|
177
188
|
// ④ 无验证命令 → 拦截(严格版要求)
|
|
178
|
-
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n无验证命令段。\n');
|
|
189
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TEST.md', '# TEST\n\n' + acCoverageBlock + '无验证命令段。\n');
|
|
179
190
|
const noCmd = runGuard(['exit', 'verify'], dir);
|
|
180
191
|
assertExit(noCmd, 1);
|
|
181
192
|
assertOut(noCmd, 'BLOCKED: TEST.md 需声明 ## 验证命令 段');
|
|
@@ -190,6 +201,9 @@ export const ENTRIES = [
|
|
|
190
201
|
// 节点推进到归档(模拟前序节点出口已完成的状态——被测机制是归档出口本身)
|
|
191
202
|
const st0 = readStateFile(dir);
|
|
192
203
|
st0.currentNode = 'archive';
|
|
204
|
+
// 夹具自洽:归档日期必须不早于该 change 的创建日期(位置解析按 createdAt 排掉更早的同名归档
|
|
205
|
+
// 目录——排除不了就 fail-closed)。真实链路里归档发生在创建之后,夹具的固定日期须与之一致。
|
|
206
|
+
st0.createdAt = '2026-08-01T00:00:00.000Z';
|
|
193
207
|
writeState(dir, st0);
|
|
194
208
|
// 归档提名随证据落盘(该 change 无任务 SUMMARY → 扫描 0 份,理由写明无候选入库)
|
|
195
209
|
assertExit(runState(['record', 'archive', archiveRecordJson('archived')], dir), 0);
|
|
@@ -218,6 +232,16 @@ export const ENTRIES = [
|
|
|
218
232
|
const status = runState(['status'], dir);
|
|
219
233
|
assertExit(status, 0);
|
|
220
234
|
assertOut(status, '"status": "no-change"');
|
|
235
|
+
// ⑤ 完成态之后(交接的落点):归档已闭合——写项目文件放行,state 机器文件仍恒拦。
|
|
236
|
+
// 两句成对:前一句证明完成态不再是「处处拦」,后一句证明放行没有把守卫整体关掉。
|
|
237
|
+
const postArchiveWrite = runHook(['before_tool'], dir,
|
|
238
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'docs', 'roadmap', 'KI-arch-demo-01.md') } });
|
|
239
|
+
assertExit(postArchiveWrite, 0);
|
|
240
|
+
assertOut(postArchiveWrite, 'no active workflow');
|
|
241
|
+
const stateWrite = runHook(['before_tool'], dir,
|
|
242
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.flow-comet', 'flow-comet-state.json') } });
|
|
243
|
+
assertExit(stateWrite, 2);
|
|
244
|
+
assertOut(stateWrite, 'state 文件');
|
|
221
245
|
},
|
|
222
246
|
},
|
|
223
247
|
|
|
@@ -235,6 +259,9 @@ export const ENTRIES = [
|
|
|
235
259
|
// 节点推进到归档(模拟前序节点出口已完成的状态)
|
|
236
260
|
const st0 = readStateFile(dir);
|
|
237
261
|
st0.currentNode = 'archive';
|
|
262
|
+
// 夹具自洽:同 H2——归档日期必须不早于该 change 的创建日期(位置解析按 createdAt 排除更早的
|
|
263
|
+
// 同名归档目录)。夹具的固定归档日期须落在创建日期之后。
|
|
264
|
+
st0.createdAt = '2026-08-01T00:00:00.000Z';
|
|
238
265
|
writeState(dir, st0);
|
|
239
266
|
// 归档提名随证据落盘(该 change 无任务 SUMMARY → 扫描 0 份,理由写明无候选入库)
|
|
240
267
|
assertExit(runState(['record', 'archive', archiveRecordJson('archived')], dir), 0);
|
|
@@ -254,53 +281,88 @@ export const ENTRIES = [
|
|
|
254
281
|
},
|
|
255
282
|
|
|
256
283
|
{
|
|
257
|
-
name: 'H4
|
|
284
|
+
name: 'H4 归档:移动后缺声明一律 BLOCKED,手动声明后同一 record 通过,不重建活动目录',
|
|
258
285
|
run: (dir) => {
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
|
|
286
|
+
// 自动补写已整体删除(单轨):移动目录后 record 缺声明不再由引擎代记,执行者必须手动声明。
|
|
287
|
+
// 两条不变量:① 归档路径的声明由执行者写入(报文命令可照抄执行);② 任何路径都不得重建
|
|
288
|
+
// 已归档的活动目录。
|
|
289
|
+
assertExit(runState(['init', 'arch-h4'], dir), 0);
|
|
262
290
|
writeFile(dir, 'flow-kit/prompts/0-change.md', '# 阶段 0 · CHANGE\n\n## 角色\n\n你是 Changeer。\n');
|
|
263
291
|
writeFile(dir, 'flow-kit/prompts/7-integration.md', '# 阶段 7 · INTEGRATION\n\n## 角色\n\n你是 Integrationer。\n');
|
|
264
|
-
//
|
|
292
|
+
// 归档前只声明 open(archive 声明留空——构造「移动后缺声明」)
|
|
265
293
|
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
266
|
-
|
|
267
|
-
//
|
|
294
|
+
// 缺声明报文按**实际查找结果**说话(in-place 扩展):活动目录在场、归档区没有本 change 的目录时,
|
|
295
|
+
// 只点活动路径缺件,不对归档路径下任何结论(旧形态无条件打印「(归档路径也未找到)」)。
|
|
296
|
+
const activeMissing = runState(['record', 'archive',
|
|
297
|
+
'{"summary":"archived","completedChecks":["required-skill:archive.flow-comet-integration"]}'], dir);
|
|
298
|
+
assertExit(activeMissing, 1);
|
|
299
|
+
assertOut(activeMissing, '缺少对应声明标记 .specs/arch-h4/.skill-loads/archive-flow-comet-integration.json');
|
|
300
|
+
assertNotOut(activeMissing, '归档路径也未找到');
|
|
301
|
+
assertNotOut(activeMissing, '已归档');
|
|
268
302
|
const st0 = readStateFile(dir);
|
|
269
303
|
st0.currentNode = 'archive';
|
|
304
|
+
st0.enteredNodes = ['open', 'archive'];
|
|
305
|
+
// 夹具自洽:归档日期必须不早于该 change 的创建日期(位置解析按 createdAt 排掉更早的同名归档
|
|
306
|
+
// 目录——排除不了就 fail-closed)。真实链路里归档发生在创建之后,夹具的固定日期须与之一致。
|
|
307
|
+
st0.createdAt = '2026-08-01T00:00:00.000Z';
|
|
308
|
+
// 字段退役后的状态形态(init 不再写 newChange):旧状态带该字段一律被忽略,
|
|
309
|
+
// 这里显式去掉它构造「无字段」形态——删除是幂等的,字段退役后本行自然成为 no-op。
|
|
270
310
|
writeState(dir, st0);
|
|
271
311
|
// 移动目录到归档(真实归档流程:先移动后 record/exit)
|
|
312
|
+
const archiveDir = path.join(dir, '.specs', 'archive', '2026-08-14-arch-h4');
|
|
272
313
|
fs.mkdirSync(path.join(dir, '.specs', 'archive'), { recursive: true });
|
|
273
|
-
fs.renameSync(path.join(dir, '.specs', 'arch-
|
|
274
|
-
//
|
|
314
|
+
fs.renameSync(path.join(dir, '.specs', 'arch-h4'), archiveDir);
|
|
315
|
+
// ① 移动后 record 缺 archive 声明 → BLOCKED(唯一等级;自动补写已删除),报文给可照抄的命令
|
|
275
316
|
const rec = runState(['record', 'archive', '{"summary":"archived"}'], dir);
|
|
276
|
-
assertExit(rec,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
317
|
+
assertExit(rec, 1);
|
|
318
|
+
assertOut(rec, 'BLOCKED');
|
|
319
|
+
assertOut(rec, '缺少技能加载声明标记');
|
|
320
|
+
// 缺声明报文的第二态(in-place 扩展):目录已随归档搬走、归档路径里也没有该标记 —— 报文如实
|
|
321
|
+
// 说出真实路径(哪里找过、哪里也没有),不再固定打印「(归档路径也未找到)」。
|
|
322
|
+
const movedMissing = runState(['record', 'archive',
|
|
323
|
+
'{"summary":"archived","completedChecks":["required-skill:archive.flow-comet-integration"]}'], dir);
|
|
324
|
+
assertExit(movedMissing, 1);
|
|
325
|
+
assertOut(movedMissing, '缺少对应声明标记 .specs/arch-h4/.skill-loads/archive-flow-comet-integration.json');
|
|
326
|
+
assertOut(movedMissing, '已归档到 .specs/archive/2026-08-14-arch-h4');
|
|
327
|
+
assertNotOut(movedMissing, '归档路径也未找到');
|
|
328
|
+
const declareLine = (rec.output.match(/^\s*(node "[^"]+" skill-load archive flow-comet-integration[^\n]+)$/m) || [])[1];
|
|
329
|
+
assertTrue(typeof declareLine === 'string', 'BLOCKED 报文应给出可照抄的 archive 声明命令:\n' + rec.output);
|
|
330
|
+
// ② 不得重建已归档的活动目录,也不得代记任何标记(归档路径不得出现 archive-*.json)
|
|
331
|
+
if (fs.existsSync(path.join(dir, '.specs', 'arch-h4'))) {
|
|
332
|
+
throw new Error('record 在归档后重建了活动目录(残留): .specs/arch-h4/');
|
|
333
|
+
}
|
|
334
|
+
const archiveLoads = path.join(archiveDir, '.skill-loads');
|
|
335
|
+
const autoWritten = fs.existsSync(archiveLoads)
|
|
336
|
+
? fs.readdirSync(archiveLoads).filter((f) => f.startsWith('archive-'))
|
|
337
|
+
: [];
|
|
338
|
+
if (autoWritten.length > 0) {
|
|
339
|
+
throw new Error('record 在缺声明时自动补写了标记(自动补写应已删除): ' + autoWritten.join(', '));
|
|
340
|
+
}
|
|
341
|
+
// ③ 移动后照抄报文命令(真实执行打印文本)直接声明 archive 技能——标记落**归档路径**(解析到的
|
|
342
|
+
// 目录),同一 record 通过,活动目录不重建。这是单轨的直连链路:身份只看状态、位置由解析器
|
|
343
|
+
// 给出,不再需要「先把目录移回活动位置→声明→再移回归档」那两步(该绕道已随单轨删除)。
|
|
344
|
+
installSkillTreeCopy(dir, path.join('.claude', 'skills'));
|
|
345
|
+
const declared = runPrintedCommand(declareLine, dir, { FLOW_COMET_RUN_ROOT: dir, FLOW_COMET_PROTOCOL: '' });
|
|
346
|
+
assertTrue(declared.status === 0,
|
|
347
|
+
'照抄的声明命令跑不通\n 命令: ' + declareLine + '\n exit ' + declared.status + '\n' + declared.output);
|
|
348
|
+
// 报告说出真实落点(归档目录),不是活动路径的相对形态
|
|
349
|
+
assertOut(declared, 'SKILL-LOAD: archive flow-comet-integration → .specs/archive/2026-08-14-arch-h4/.skill-loads/archive-flow-comet-integration.json');
|
|
350
|
+
const markerInArchive = path.join(archiveDir, '.skill-loads', 'archive-flow-comet-integration.json');
|
|
283
351
|
if (!fs.existsSync(markerInArchive)) {
|
|
284
|
-
throw new Error('
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
// 变体:归档后 skill-load 报错须引导 record 自动补路径(真实会话实证:归档后手动声明
|
|
300
|
-
// 不可行,消息须指明 M5 自动补仍可写归档路径标记)
|
|
301
|
-
const slArchive = runState(['skill-load', 'archive', 'flow-comet-integration'], dir);
|
|
302
|
-
assertExit(slArchive, 1);
|
|
303
|
-
assertOut(slArchive, 'record 自动补写');
|
|
352
|
+
throw new Error('归档路径缺执行者声明的标记: ' + markerInArchive);
|
|
353
|
+
}
|
|
354
|
+
if (fs.existsSync(path.join(dir, '.specs', 'arch-h4'))) {
|
|
355
|
+
throw new Error('声明命令在归档后重建了活动目录(残留): .specs/arch-h4/');
|
|
356
|
+
}
|
|
357
|
+
const recPass = runState(['record', 'archive', '{"summary":"archived"}'], dir);
|
|
358
|
+
assertExit(recPass, 0);
|
|
359
|
+
assertOut(recPass, 'EVIDENCE: archive');
|
|
360
|
+
if (fs.existsSync(path.join(dir, '.specs', 'arch-h4'))) {
|
|
361
|
+
throw new Error('record 在归档后重建了活动目录(残留): .specs/arch-h4/');
|
|
362
|
+
}
|
|
363
|
+
// ④ 出口的声明覆盖门认归档路径的标记——不再点名缺声明(出口其余判据不在本格范围内)
|
|
364
|
+
const exitRes = runGuard(['exit', 'archive'], dir);
|
|
365
|
+
assertNotOut(exitRes, '缺协议声明标记');
|
|
304
366
|
},
|
|
305
367
|
},
|
|
306
368
|
|
|
@@ -592,6 +654,8 @@ export const ENTRIES = [
|
|
|
592
654
|
}
|
|
593
655
|
// 源节点(verify)出口真实重跑:验证命令落盘副作用 + 推进 archive
|
|
594
656
|
assertExit(runState(['skill-load', 'verify', 'flow-comet-verify', '--prompt', 'flow-kit/prompts/7-integration.md'], dir, env), 0);
|
|
657
|
+
// 协议 verify.requiredSkillCalls = flow-comet-integration(guarded):同一份协议文件、另一个技能面
|
|
658
|
+
assertExit(runState(['skill-load', 'verify', 'flow-comet-integration', '--prompt', 'flow-kit/prompts/7-integration.md'], dir, env), 0);
|
|
595
659
|
assertExit(runState(['record', 'verify', '{"summary":"回源复验完成"}'], dir, env), 0);
|
|
596
660
|
assertExit(runGuard(['entry', 'verify'], dir, env), 0);
|
|
597
661
|
const verifyExit = runGuard(['exit', 'verify', '--apply'], dir, env);
|
|
@@ -692,21 +756,18 @@ export const ENTRIES = [
|
|
|
692
756
|
// depends_on 后复签通过(同一通道,不做校验豁免)。
|
|
693
757
|
const parallelIds = ['P01', 'P02', 'P03', 'P04'];
|
|
694
758
|
const oldChangeState = readStateFile(dir);
|
|
695
|
-
delete oldChangeState.newChange;
|
|
696
759
|
writeState(dir, oldChangeState);
|
|
697
760
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
698
761
|
replanTaskText({ parallelPending: ['P01'], crossTaskPair: 'no-deps' }));
|
|
699
|
-
const crossWarn = runState(['replan', '计划缺陷重校 1
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
assertOut(crossWarn, '
|
|
762
|
+
const crossWarn = runState(['replan', '计划缺陷重校 1(无字段状态)', '--authorized-by', '用户裁决'], dir);
|
|
763
|
+
// 单轨:replan 不做校验豁免——同文件跨任务族一律 BLOCKED 且状态零改写
|
|
764
|
+
assertExit(crossWarn, 1);
|
|
765
|
+
assertOut(crossWarn, 'BLOCKED: TASK.md 同文件跨任务且无依赖路径');
|
|
703
766
|
assertOut(crossWarn, 'X1×X2(src/shared-cross.mjs)');
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
throw new Error('旧 change 形态应照常重签并写入第 1 条 replan-applied 事件');
|
|
767
|
+
if (replanEventsOf(readStateFile(dir)).length !== 0) {
|
|
768
|
+
throw new Error('BLOCK 不得写入 replan-applied 事件');
|
|
707
769
|
}
|
|
708
770
|
const afterWarnState = readStateFile(dir);
|
|
709
|
-
afterWarnState.newChange = true;
|
|
710
771
|
writeState(dir, afterWarnState);
|
|
711
772
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
712
773
|
replanTaskText({ parallelPending: ['P01', 'P02'], crossTaskPair: 'no-deps' }));
|
|
@@ -719,10 +780,10 @@ export const ENTRIES = [
|
|
|
719
780
|
assertOut(crossBlocked, '补显式 depends_on 或合并为一个任务');
|
|
720
781
|
assertNotOut(crossBlocked, 'REPLAN:');
|
|
721
782
|
if (!readStateBytes(dir).equals(crossBytes)) throw new Error('replan 第三族 BLOCK 改写了 state 字节');
|
|
722
|
-
if (replanBackupFiles(dir).length !==
|
|
723
|
-
throw new Error('replan 第三族 BLOCK
|
|
783
|
+
if (replanBackupFiles(dir).length !== 0) {
|
|
784
|
+
throw new Error('replan 第三族 BLOCK 不得新增备份(单轨:无成功重签即无备份): ' + JSON.stringify(replanBackupFiles(dir)));
|
|
724
785
|
}
|
|
725
|
-
if (replanEventsOf(readStateFile(dir)).length !==
|
|
786
|
+
if (replanEventsOf(readStateFile(dir)).length !== 0) {
|
|
726
787
|
throw new Error('replan 第三族 BLOCK 不得写入 replan-applied 事件');
|
|
727
788
|
}
|
|
728
789
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md',
|
|
@@ -730,21 +791,32 @@ export const ENTRIES = [
|
|
|
730
791
|
const crossRecovered = runState(['replan', '计划缺陷重校 2(已补 depends_on)', '--authorized-by', '用户裁决'], dir);
|
|
731
792
|
assertExit(crossRecovered, 0);
|
|
732
793
|
assertOut(crossRecovered, 'REPLAN');
|
|
733
|
-
if (replanEventsOf(readStateFile(dir)).length !==
|
|
734
|
-
throw new Error('补显式 depends_on 后复签应写入第
|
|
794
|
+
if (replanEventsOf(readStateFile(dir)).length !== 1) {
|
|
795
|
+
throw new Error('补显式 depends_on 后复签应写入第 1 条 replan-applied 事件');
|
|
735
796
|
}
|
|
736
|
-
// 第
|
|
797
|
+
// 第 2 轮:常规修订(轮次按 change 从事件累计)
|
|
737
798
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: parallelIds.slice(0, 3) }));
|
|
738
799
|
const thirdRound = runState(['replan', '计划缺陷重校 3', '--authorized-by', '用户裁决'], dir);
|
|
739
800
|
assertExit(thirdRound, 0);
|
|
740
801
|
assertOut(thirdRound, 'REPLAN');
|
|
802
|
+
if (replanEventsOf(readStateFile(dir)).length !== 2) {
|
|
803
|
+
throw new Error('第 2 轮后 replan-applied 事件数应为 2');
|
|
804
|
+
}
|
|
805
|
+
if (replanBackupFiles(dir).length !== 2) {
|
|
806
|
+
throw new Error('两轮应产生两份备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
807
|
+
}
|
|
808
|
+
// 第 3 轮(上限内的最后一轮)成功
|
|
809
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: parallelIds.slice(0, 2) }));
|
|
810
|
+
const thirdRoundB = runState(['replan', '计划缺陷重校 3b', '--authorized-by', '用户裁决'], dir);
|
|
811
|
+
assertExit(thirdRoundB, 0);
|
|
812
|
+
assertOut(thirdRoundB, 'REPLAN');
|
|
741
813
|
if (replanEventsOf(readStateFile(dir)).length !== 3) {
|
|
742
814
|
throw new Error('第 3 轮后 replan-applied 事件数应为 3');
|
|
743
815
|
}
|
|
744
816
|
if (replanBackupFiles(dir).length !== 3) {
|
|
745
817
|
throw new Error('三轮应产生三份备份: ' + JSON.stringify(replanBackupFiles(dir)));
|
|
746
818
|
}
|
|
747
|
-
// ③ 第 4 次 → BLOCK +
|
|
819
|
+
// ③ 第 4 次 → BLOCK + 人工裁决指引 + state 字节零改写
|
|
748
820
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', replanTaskText({ parallelPending: parallelIds }));
|
|
749
821
|
const beforeFourth = readStateBytes(dir);
|
|
750
822
|
const fourth = runState(['replan', '计划缺陷重校(上限后未授权)', '--authorized-by', '用户裁决'], dir);
|