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.
Files changed (89) hide show
  1. package/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
  2. package/.flow-comet/skills/flow-comet/SKILL.md +32 -18
  3. package/.flow-comet/skills/flow-comet/reference/commit-discipline.md +2 -2
  4. package/.flow-comet/skills/flow-comet/reference/decision-points.md +5 -5
  5. package/.flow-comet/skills/flow-comet/reference/dirty-worktree.md +1 -1
  6. package/.flow-comet/skills/flow-comet/reference/entry-detail.md +30 -11
  7. package/.flow-comet/skills/flow-comet/reference/fix-loop.md +4 -4
  8. package/.flow-comet/skills/flow-comet/reference/init-detection.md +1 -1
  9. package/.flow-comet/skills/flow-comet/reference/platform-facts.md +2 -2
  10. package/.flow-comet/skills/flow-comet/reference/post-archive-handoff.md +264 -0
  11. package/.flow-comet/skills/flow-comet/reference/recovery.md +1 -1
  12. package/.flow-comet/skills/flow-comet/reference/replan.md +1 -1
  13. package/.flow-comet/skills/flow-comet/scripts/comet-check.mjs +1 -0
  14. package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +270 -30
  15. package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +26 -23
  16. package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +14 -94
  17. package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +122 -11
  18. package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +79 -40
  19. package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +11 -9
  20. package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +52 -10
  21. package/.flow-comet/skills/flow-comet/scripts/items/f.mjs +1 -1
  22. package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +128 -56
  23. package/.flow-comet/skills/flow-comet/scripts/items/k.mjs +357 -3
  24. package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +26 -1
  25. package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +6 -2
  26. package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +29 -21
  27. package/.flow-comet/skills/flow-comet/scripts/lib/ac-coverage.mjs +317 -0
  28. package/.flow-comet/skills/flow-comet/scripts/lib/fix-loop-node.mjs +4 -15
  29. package/.flow-comet/skills/flow-comet/scripts/lib/guard-artifact-skeleton.mjs +47 -5
  30. package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +357 -219
  31. package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +725 -309
  32. package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +182 -54
  33. package/.flow-comet/skills/flow-comet/scripts/lib/guard-state-io.mjs +8 -6
  34. package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +224 -83
  35. package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +17 -28
  36. package/.flow-comet/skills/flow-comet/scripts/lib/lessons-hits.mjs +160 -0
  37. package/.flow-comet/skills/flow-comet/scripts/lib/run-root.mjs +21 -0
  38. package/.flow-comet/skills/flow-comet/scripts/lib/section-body.mjs +92 -0
  39. package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +61 -33
  40. package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +663 -205
  41. package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +68 -9
  42. package/.flow-comet/skills/flow-comet/scripts/lib/state-determine.mjs +11 -4
  43. package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +92 -13
  44. package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +232 -11
  45. package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +140 -74
  46. package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +8 -4
  47. package/.flow-comet/skills/flow-comet/scripts/lib/task-graph.mjs +84 -31
  48. package/.flow-comet/skills/flow-comet/scripts/lib/test-assertions.mjs +0 -3
  49. package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +248 -24
  50. package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +63 -3
  51. package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +181 -8
  52. package/.flow-comet/skills/flow-comet/scripts/lib/wave-projection.mjs +340 -0
  53. package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +132 -20
  54. package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +12 -5
  55. package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +1564 -54
  56. package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +1489 -38
  57. package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +1466 -243
  58. package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +743 -24
  59. package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +220 -92
  60. package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +657 -21
  61. package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +41 -27
  62. package/.flow-comet/skills/flow-comet/scripts/scenarios/h.mjs +285 -9
  63. package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +7 -6
  64. package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +21 -15
  65. package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +8 -5
  66. package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +45 -36
  67. package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +2 -2
  68. package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +2381 -85
  69. package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +135 -2
  70. package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +143 -16
  71. package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +339 -103
  72. package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +5 -2
  73. package/.flow-comet/skills/flow-comet-archive/SKILL.md +33 -11
  74. package/.flow-comet/skills/flow-comet-change/SKILL.md +1 -1
  75. package/.flow-comet/skills/flow-comet-design/SKILL.md +5 -3
  76. package/.flow-comet/skills/flow-comet-dev/SKILL.md +2 -2
  77. package/.flow-comet/skills/flow-comet-execute/SKILL.md +37 -13
  78. package/.flow-comet/skills/flow-comet-integration/SKILL.md +10 -4
  79. package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +1 -1
  80. package/.flow-comet/skills/flow-comet-plan/SKILL.md +13 -6
  81. package/.flow-comet/skills/flow-comet-review/SKILL.md +21 -12
  82. package/.flow-comet/skills/flow-comet-subagent-execute/GUIDANCE.md +1 -1
  83. package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +43 -18
  84. package/.flow-comet/skills/flow-comet-task/SKILL.md +4 -2
  85. package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +2 -2
  86. package/.flow-comet/skills/flow-comet-verify/SKILL.md +1 -1
  87. package/README.md +2 -2
  88. package/package.json +1 -1
  89. package/scripts/dsh-bridge.mjs +238 -21
@@ -19,22 +19,24 @@ import {
19
19
  writeState,
20
20
  } from '../lib/test-helpers.mjs';
21
21
  import {
22
- CHANGE_ID,
23
- PREPARE_ENV,
24
- REPO_ROOT,
25
- SCRIPTS_DIR,
26
22
  bridgeStampSyncProblems,
27
23
  bridgeStampSyncSubAnchorCases,
24
+ CHANGE_ID,
28
25
  fixtureBridgeBaseVersion,
29
26
  fixtureIsBridgeDevVersion,
30
27
  handoffFor,
28
+ PREPARE_ENV,
29
+ REPO_ROOT,
31
30
  runBridgeCheck,
32
31
  runPlanExit,
33
32
  runPrepareEnv,
33
+ SCRIPTS_DIR,
34
34
  strictSummary,
35
35
  summaryContent,
36
+ writeAllNodeDeclarationMarkers,
36
37
  writeBridgeFixture,
37
38
  writeIntakeArtifacts,
39
+ writeNodeDeclarationMarkers,
38
40
  } from '../lib/test-fixtures.mjs';
39
41
  import {
40
42
  assertInstalledCopyBridgeVersionCase,
@@ -457,6 +459,10 @@ export const ENTRIES = [
457
459
  {
458
460
  name: '198 多趟出口路由时序收敛:逐节点 exit --apply 后 next 输出 NODE 与 guard 出口 NODE 一致',
459
461
  run: (dir) => {
462
+ writeNodeDeclarationMarkers(dir, 'execute');
463
+ writeNodeDeclarationMarkers(dir, 'subagent-execute');
464
+ writeNodeDeclarationMarkers(dir, 'review');
465
+ writeAllNodeDeclarationMarkers(dir);
460
466
  const writeTask = (statusMap) => {
461
467
  const blk = (id, parallel, deps) =>
462
468
  '<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
@@ -485,7 +491,7 @@ export const ENTRIES = [
485
491
  o.evidence[node] = merged;
486
492
  writeState(dir, o);
487
493
  };
488
- const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', summaryContent()); };
494
+ const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', strictSummary('T01')); };
489
495
  const nodeOf = (out) => (out.match(/^NODE: ([a-z-]+)$/m) || [])[1] ?? null;
490
496
  const assertConverge = (guardRes) => {
491
497
  assertExit(guardRes, 0);
@@ -570,7 +576,7 @@ export const ENTRIES = [
570
576
  // ⑩ archive 出口 → 全部完成(两侧均 NEXT: done)
571
577
  assertExit(runGuard(['entry', 'archive'], dir), 0);
572
578
  writeFile(dir, '.specs/archive/2026-08-28-' + CHANGE_ID + '/KNOWN-ISSUES.md', '# 遗留问题\n\n无。\n');
573
- appendEvidence('archive', { summary: 'archive complete' });
579
+ appendEvidence('archive', { summary: 'archive complete', lessonsNomination: { scanned: 6, nominated: [], reasonIfNone: '夹具无候选条目' } });
574
580
  const res = runGuard(['exit', 'archive', '--apply'], dir);
575
581
  assertExit(res, 0);
576
582
  assertOut(res, 'NEXT: done');
@@ -694,7 +700,6 @@ export const ENTRIES = [
694
700
  run: (dir) => {
695
701
  const st = baseState('plan');
696
702
  st.evidence.plan = { summary: 'plan done' };
697
- st.newChange = true;
698
703
  writeState(dir, st);
699
704
  const tasks =
700
705
  '<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' +
@@ -754,10 +759,9 @@ export const ENTRIES = [
754
759
  },
755
760
  },
756
761
 
757
- // 203: 写写强判分级(渐进)——同拓扑旧 change(无 newChange 标记):plan 出口应 WARN 渐进
758
- // 不 BLOCK(与依赖环分级同先例)。修复前 plan 出口无检测 = 预期 RED(无 WARN 亦无 BLOCK)。
762
+ // 203: 写写强判——同拓扑(无任何新旧标记字段):plan 出口一律 BLOCKED(单轨,无渐进侧)
759
763
  {
760
- name: '203 plan exit 兼容:旧 change 写写重叠不 BLOCK(渐进 WARN)',
764
+ name: '203 plan exit:写写重叠一律 BLOCKED',
761
765
  run: (dir) => {
762
766
  const st = baseState('plan');
763
767
  st.evidence.plan = { summary: 'plan done' };
@@ -766,9 +770,8 @@ export const ENTRIES = [
766
770
  '<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' +
767
771
  '<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';
768
772
  const res = runPlanExit(dir, tasks);
769
- assertExit(res, 0);
770
- assertNotOut(res, 'BLOCKED');
771
- assertOut(res, 'WARN');
773
+ assertExit(res, 1);
774
+ assertOut(res, 'BLOCKED');
772
775
  assertOut(res, 'P01×P02');
773
776
  assertOut(res, 'bak_a.txt');
774
777
  },
@@ -781,7 +784,6 @@ export const ENTRIES = [
781
784
  run: (dir) => {
782
785
  const st = baseState('plan');
783
786
  st.evidence.plan = { summary: 'plan done' };
784
- st.newChange = true;
785
787
  writeState(dir, st);
786
788
  const tasks =
787
789
  '<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>notes.txt</write_files><verify>node --check notes.txt</verify></task>\n' +
@@ -805,7 +807,6 @@ export const ENTRIES = [
805
807
  run: (dir) => {
806
808
  const st = baseState('plan');
807
809
  st.evidence.plan = { summary: 'plan done' };
808
- st.newChange = true;
809
810
  writeState(dir, st);
810
811
  // ① 无显式关联对:P01 读 shared-context.md,P02 写同路径 → WARN 提示级(不 BLOCK)
811
812
  const weak =
@@ -836,7 +837,6 @@ export const ENTRIES = [
836
837
  run: (dir) => {
837
838
  // ① 委托前锚:同波次并行 pending 写写重叠 → entry subagent-execute 仍 BLOCKED
838
839
  const st = baseState('subagent-execute');
839
- st.newChange = true;
840
840
  writeState(dir, st);
841
841
  const conflictTasksForDelegation =
842
842
  '<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' +
@@ -850,7 +850,6 @@ export const ENTRIES = [
850
850
  // 仍触发伪并行 WARN——新检测与既有检测并存不干扰
851
851
  const st2 = baseState('plan');
852
852
  st2.evidence.plan = { summary: 'plan done' };
853
- st2.newChange = true;
854
853
  writeState(dir, st2);
855
854
  const coexisting =
856
855
  '<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>src/p1.mjs</write_files><verify>node --check src/p1.mjs</verify></task>\n' +
@@ -870,6 +869,8 @@ export const ENTRIES = [
870
869
  {
871
870
  name: '207 多趟平行转换 next 可达且与 guard NEXT 一致(完整时序锚)',
872
871
  run: (dir) => {
872
+ writeAllNodeDeclarationMarkers(dir);
873
+ writeNodeDeclarationMarkers(dir, 'plan');
873
874
  const writeTask = (statusMap) => {
874
875
  const blk = (id, parallel, deps) =>
875
876
  '<task id="' + id + '"' + (parallel ? ' parallel="true"' : '') +
@@ -894,7 +895,7 @@ export const ENTRIES = [
894
895
  o.evidence[node] = merged;
895
896
  writeState(dir, o);
896
897
  };
897
- const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', summaryContent()); };
898
+ const writeSummary = (ids) => { for (const id of ids) writeFile(dir, '.specs/' + CHANGE_ID + '/' + id + '-SUMMARY.md', strictSummary('T01')); };
898
899
  const nodeOf = (out) => (out.match(/^NODE: ([a-z-]+)$/m) || [])[1] ?? null;
899
900
  const assertConverge = (guardRes) => {
900
901
  assertExit(guardRes, 0);
@@ -966,7 +967,7 @@ export const ENTRIES = [
966
967
  assertConverge(runGuard(['exit', 'verify', '--apply'], dir));
967
968
  // ⑩ archive 出口 → 完成(两侧均 NEXT: done)
968
969
  writeFile(dir, '.specs/archive/2026-08-28-' + CHANGE_ID + '/KNOWN-ISSUES.md', '# 遗留问题\n\n无。\n');
969
- appendEvidence('archive', { summary: 'archive complete' });
970
+ appendEvidence('archive', { summary: 'archive complete', lessonsNomination: { scanned: 6, nominated: [], reasonIfNone: '夹具无候选条目' } });
970
971
  assertExit(runGuard(['entry', 'archive'], dir), 0);
971
972
  const resArch = runGuard(['exit', 'archive', '--apply'], dir);
972
973
  assertExit(resArch, 0);
@@ -1000,8 +1001,8 @@ export const ENTRIES = [
1000
1001
  design: { summary: 'design complete' },
1001
1002
  plan: { summary: 'plan complete' },
1002
1003
  };
1003
- st.newChange = true;
1004
1004
  writeState(dir, st);
1005
+ writeNodeDeclarationMarkers(dir, 'plan');
1005
1006
  // ① record 后未 exit 先 next:不把 currentNode 提前校正到 subagent-execute(路由后继)
1006
1007
  const r1 = runStateWithProtocol(dir, ['next']);
1007
1008
  assertExit(r1, 0);
@@ -1058,8 +1059,8 @@ export const ENTRIES = [
1058
1059
  plan: { summary: 'plan done' },
1059
1060
  execute: { summary: 'executed', parallelTakeoverApproved: true },
1060
1061
  };
1061
- st.newChange = true;
1062
1062
  writeState(dir, st);
1063
+ writeNodeDeclarationMarkers(dir, 'execute');
1063
1064
  const res = runGuard(['exit', 'execute', '--apply'], dir);
1064
1065
  assertExit(res, 0);
1065
1066
  assertNotOut(res, 'BLOCKED: currentNode');
@@ -1091,12 +1092,25 @@ export const ENTRIES = [
1091
1092
  plan: { summary: 'plan done' },
1092
1093
  execute: { summary: 'executed' },
1093
1094
  };
1094
- st.newChange = true;
1095
1095
  writeState(dir, st);
1096
1096
  const res = runGuard(['exit', 'execute', '--apply'], dir);
1097
1097
  assertExit(res, 1);
1098
1098
  assertOut(res, 'BLOCKED: currentNode is review');
1099
1099
  assertNotOut(res, 'ALL CHECKS PASSED');
1100
+ // 恢复指引按目录在哪分两种说法(in-place 扩展):活动态给 advance / select;目录已搬进归档时
1101
+ // 这两步都走不通(select 要求活动目录在场,advance 的产物推导读的也是活动路径),只给可执行
1102
+ // 的那一步——把目录移回活动位置。断言用「不出现」的负向形态钉住这个分叉。
1103
+ assertOut(res, '用 workflow-state.mjs advance');
1104
+ fs.mkdirSync(path.join(dir, '.specs', 'archive'), { recursive: true });
1105
+ fs.renameSync(path.join(dir, '.specs', CHANGE_ID),
1106
+ path.join(dir, '.specs', 'archive', '2026-11-05-' + CHANGE_ID));
1107
+ const resMoved = runGuard(['exit', 'execute', '--apply'], dir);
1108
+ assertExit(resMoved, 1);
1109
+ assertOut(resMoved, 'BLOCKED: currentNode is review');
1110
+ assertOut(resMoved, '已移到归档位置(.specs/archive/2026-11-05-' + CHANGE_ID + ')');
1111
+ assertOut(resMoved, '移回活动位置 .specs/' + CHANGE_ID + '/');
1112
+ assertNotOut(resMoved, 'advance');
1113
+ assertNotOut(resMoved, 'select');
1100
1114
  },
1101
1115
  },
1102
1116
 
@@ -1106,6 +1120,7 @@ export const ENTRIES = [
1106
1120
  {
1107
1121
  name: '211 路由诊断静默:剩余 pending 全串行(P→S 收尾转换)无 ROUTE WARN',
1108
1122
  run: (dir) => {
1123
+ writeNodeDeclarationMarkers(dir, 'plan');
1109
1124
  writeIntakeArtifacts(dir);
1110
1125
  const st = baseState('plan');
1111
1126
  st.completedNodes = ['open', 'design'];
@@ -1128,6 +1143,7 @@ export const ENTRIES = [
1128
1143
  {
1129
1144
  name: '212 路由诊断保持:parallel 缺 status(畸形块)仍报 ROUTE WARN',
1130
1145
  run: (dir) => {
1146
+ writeNodeDeclarationMarkers(dir, 'plan');
1131
1147
  writeIntakeArtifacts(dir);
1132
1148
  const st = baseState('plan');
1133
1149
  st.completedNodes = ['open', 'design'];
@@ -1163,8 +1179,8 @@ export const ENTRIES = [
1163
1179
  st.directOverride = true;
1164
1180
  st.directOverrideAt = '2026-08-29T10:00:00.000Z';
1165
1181
  st.directOverrideSource = 'execution-mode';
1166
- st.newChange = true;
1167
1182
  writeState(dir, st);
1183
+ writeNodeDeclarationMarkers(dir, 'execute');
1168
1184
  writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
1169
1185
  '<task id="S01" status="done"><action>实现 S01</action><write_files>src/s1.mjs</write_files><verify>node --check src/s1.mjs</verify></task>\n');
1170
1186
  writeFile(dir, '.specs/' + CHANGE_ID + '/S01-SUMMARY.md', strictSummary('S01'));
@@ -1193,7 +1209,6 @@ export const ENTRIES = [
1193
1209
  st.executionMode = 'direct';
1194
1210
  st.directOverride = true;
1195
1211
  // 无 directOverrideAt 授权审计记录(执行者自切/修复前遗留形态)
1196
- st.newChange = true;
1197
1212
  writeState(dir, st);
1198
1213
  writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
1199
1214
  '<task id="S01" status="done"><action>实现 S01</action><write_files>src/s1.mjs</write_files><verify>node --check src/s1.mjs</verify></task>\n');
@@ -1243,7 +1258,6 @@ export const ENTRIES = [
1243
1258
  execute: { summary: 'executed' },
1244
1259
  'subagent-execute': { summary: 'delegated', handoffResult: handoffFor(['S01']) },
1245
1260
  };
1246
- st.newChange = true;
1247
1261
  return st;
1248
1262
  };
1249
1263
  const writeTask = () => writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
@@ -1254,6 +1268,7 @@ export const ENTRIES = [
1254
1268
  st1.executionMode = 'direct';
1255
1269
  st1.directOverride = true;
1256
1270
  writeState(dir, st1);
1271
+ writeNodeDeclarationMarkers(dir, 'execute');
1257
1272
  writeTask();
1258
1273
  const rBlock = runGuard(['exit', 'execute', '--apply'], dir);
1259
1274
  assertExit(rBlock, 1);
@@ -1324,7 +1339,7 @@ export const ENTRIES = [
1324
1339
  writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', '# TASK\n\n' +
1325
1340
  '<task id="T01" status="done"><action>实现 T01</action><write_files>src/t1.mjs</write_files><verify>node --check src/t1.mjs</verify></task>\n' +
1326
1341
  '<task id="T02" parallel="true"><action>实现 T02</action><write_files>src/t2.mjs</write_files><verify>node --check src/t2.mjs</verify></task>\n');
1327
- writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', summaryContent());
1342
+ writeFile(dir, '.specs/' + CHANGE_ID + '/T01-SUMMARY.md', strictSummary('T01'));
1328
1343
  writeState(dir, {
1329
1344
  activeChange: CHANGE_ID,
1330
1345
  currentNode: 'execute',
@@ -1351,7 +1366,6 @@ export const ENTRIES = [
1351
1366
  run: (dir) => {
1352
1367
  const st = baseState('plan');
1353
1368
  st.evidence.plan = { summary: 'plan done' };
1354
- st.newChange = true;
1355
1369
  writeState(dir, st);
1356
1370
  const tasks =
1357
1371
  '<task id="P01" parallel="true" status="pending"><action>实现 P01</action><write_files>src/a.mjs</write_files><verify>node --check src/a.mjs</verify></task>\n' +
@@ -17,29 +17,30 @@ import {
17
17
  writeState,
18
18
  } from '../lib/test-helpers.mjs';
19
19
  import {
20
+ assertGitignoreManaged,
21
+ bridgeIdentityEnv,
20
22
  BUILTIN_PROTOCOL_SOURCE,
21
23
  CHANGE_ID,
22
24
  GUARD,
23
25
  HOOK,
24
26
  LEGACY_RUNTIME_DIR,
25
- MIGRATION_CHANGE,
26
- PREPARE_ENV,
27
- REPO_ROOT,
28
- RUNTIME_DIR,
29
- RUNTIME_STATE_NAME,
30
- SCRIPTS_DIR,
31
- assertGitignoreManaged,
32
- bridgeIdentityEnv,
33
27
  makeTmp,
34
28
  migratableStateBytes,
29
+ MIGRATION_CHANGE,
35
30
  migrationBackups,
36
31
  normalizeRoot,
32
+ PREPARE_ENV,
33
+ REPO_ROOT,
37
34
  runGitignoreForm,
38
35
  runInstalled,
39
36
  runPrepareEnv,
37
+ RUNTIME_DIR,
38
+ RUNTIME_STATE_NAME,
39
+ SCRIPTS_DIR,
40
40
  writeClassicCometAssets,
41
41
  writeIntakeArtifacts,
42
42
  writeMigratedProjectArtifacts,
43
+ writeNodeDeclarationMarkers,
43
44
  writeSharedCometDir,
44
45
  } from '../lib/test-fixtures.mjs';
45
46
  import {
@@ -328,6 +329,7 @@ export const ENTRIES = [
328
329
  st.status = 'running';
329
330
  st.evidence.open = { summary: 'intake complete' };
330
331
  writeState(proj, st);
332
+ writeNodeDeclarationMarkers(proj, 'open');
331
333
  if (withClassic) writeClassicCometAssets(proj);
332
334
  return proj;
333
335
  };
@@ -378,6 +380,7 @@ export const ENTRIES = [
378
380
  st.status = 'running';
379
381
  st.evidence.open = { summary: 'intake complete' };
380
382
  writeState(proj, st);
383
+ writeNodeDeclarationMarkers(proj, 'open');
381
384
  writeClassicCometAssets(proj); // 叠加分支的前置(classic 活动 change)在场
382
385
  return proj;
383
386
  };
@@ -1278,10 +1281,283 @@ export const ENTRIES = [
1278
1281
  '## intel-scan 元数据 ##', '- **last_intel_scan**: x', '- **scanner**: x', '- **下次重扫建议**: x',
1279
1282
  '',
1280
1283
  ].join('\n'));
1281
- const boundary = runStateWithProtocol(dir, ['init', CHANGE_ID + '-2', '--init-context']);
1284
+ const boundary = runStateWithProtocol(dir, ['init', CHANGE_ID + '-2', '--init-context', '--replace', CHANGE_ID, '--reason', '验证段标题闭合标记判定']);
1282
1285
  assertExit(boundary, 0);
1283
1286
  assertOut(boundary, 'INIT-VALIDATE-FAILED');
1284
1287
  assertOut(boundary, '项目概要');
1285
1288
  },
1286
1289
  },
1290
+
1291
+ // 243: 写目标按**物理落点**判定——白名单目录里的链接曾把写入引流到源码目录:
1292
+ // `.specs/j` 指向 `src` 时,写 `.specs/j/x` 词法命中白名单,真实落点却是 src。
1293
+ // 修复后白名单 / 包含性 / 保护集三处都按 realpath 后的相对路径判定,报文回显调用方拼写。
1294
+ // 硬链接是路径判定的盲区(没有可解析的目标、realpath 仍指向自己),按"共享文件对象"fail-closed。
1295
+ {
1296
+ name: '243 hook 写目标物理判定:链接不再把白名单写入引流到源码目录,硬链接拒绝',
1297
+ run: (dir) => {
1298
+ writeState(dir, { ...baseState('subagent-execute'), status: 'running' });
1299
+ const posix = (p) => p.split(path.sep).join('/');
1300
+ const specs = path.join(dir, '.specs');
1301
+ const srcDir = path.join(dir, 'src');
1302
+ fs.mkdirSync(specs, { recursive: true });
1303
+ fs.mkdirSync(srcDir, { recursive: true });
1304
+ fs.writeFileSync(path.join(srcDir, 'app.js'), 'console.log(1);\n', 'utf8');
1305
+ const linkInto = path.join(specs, 'j');
1306
+ try {
1307
+ fs.symlinkSync(srcDir, linkInto, process.platform === 'win32' ? 'junction' : 'dir');
1308
+ } catch (error) {
1309
+ console.error('WARN: 无法创建目录链接,链接断言跳过(' + (error.code || error.message) + ')');
1310
+ return;
1311
+ }
1312
+ // ① file_path:白名单内的链接路径 → 按物理落点拒绝(修复前词法放行 = RED)
1313
+ const viaWrite = runHook(['before_tool'], dir, {
1314
+ tool_name: 'Write',
1315
+ tool_input: { file_path: path.join(linkInto, 'w.txt') },
1316
+ });
1317
+ assertExit(viaWrite, 2);
1318
+ assertOut(viaWrite, 'BLOCKED');
1319
+ assertOut(viaWrite, 'src/w.txt'); // 报文点名物理相对路径,便于定位真实落点
1320
+ // ② Bash 命令目标:同一路径同一结论(两条判定共用解析)
1321
+ const viaBash = runHook(['before_tool'], dir, {
1322
+ tool_name: 'Bash',
1323
+ tool_input: { command: 'printf x > "' + posix(path.join(linkInto, 'v.txt')) + '"' },
1324
+ });
1325
+ assertExit(viaBash, 2);
1326
+ assertOut(viaBash, 'BLOCKED');
1327
+ // ③ 放行面不受影响:白名单内的普通写入仍放行
1328
+ const plain = runHook(['before_tool'], dir, {
1329
+ tool_name: 'Write',
1330
+ tool_input: { file_path: path.join(specs, 'plain.txt') },
1331
+ });
1332
+ assertExit(plain, 0);
1333
+ assertOut(plain, 'workflow-hook-guard-ok');
1334
+ // ④ 两端都在白名单内的链接仍放行(不能退化成"链接一律拒绝")
1335
+ const realDir = path.join(specs, 'real');
1336
+ fs.mkdirSync(realDir, { recursive: true });
1337
+ const alias = path.join(specs, 'alias');
1338
+ try { fs.symlinkSync(realDir, alias, process.platform === 'win32' ? 'junction' : 'dir'); } catch { /* 上方已降级过 */ }
1339
+ if (fs.existsSync(alias)) {
1340
+ const viaAlias = runHook(['before_tool'], dir, {
1341
+ tool_name: 'Write',
1342
+ tool_input: { file_path: path.join(alias, 'ok.md') },
1343
+ });
1344
+ assertExit(viaAlias, 0);
1345
+ assertOut(viaAlias, 'workflow-hook-guard-ok');
1346
+ }
1347
+ // ⑤ 链接指向**项目根之外**:包含性子句的锚(删掉协议层的物理包含性判定 ⇒ 此条必红)
1348
+ // 真·项目根之外(此前夹具建在根内,断言 'outside' 被目录名喂饱 —— 判别力为零)
1349
+ const outsideDir = path.join(path.dirname(dir), 'outside-' + path.basename(dir));
1350
+ fs.mkdirSync(outsideDir, { recursive: true });
1351
+ const outLink = path.join(specs, 'out');
1352
+ try { fs.symlinkSync(outsideDir, outLink, process.platform === 'win32' ? 'junction' : 'dir'); } catch { /* 已降级 */ }
1353
+ if (fs.existsSync(outLink)) {
1354
+ const viaOut = runHook(['before_tool'], dir, {
1355
+ tool_name: 'Write',
1356
+ tool_input: { file_path: path.join(outLink, 'escaped.md') },
1357
+ });
1358
+ assertExit(viaOut, 2);
1359
+ assertOut(viaOut, 'BLOCKED');
1360
+ // 报文来自物理包含性判定(写目标解析越界),不是白名单前缀
1361
+ assertOut(viaOut, 'resolves outside');
1362
+ }
1363
+ // ⑥ 最小保护集:协调者经链接写状态文件 → 拒绝(物理相对路径命中保护集)
1364
+ const stateLink = path.join(specs, 's');
1365
+ try { fs.symlinkSync(path.join(dir, '.flow-comet'), stateLink, process.platform === 'win32' ? 'junction' : 'dir'); } catch { /* 同上 */ }
1366
+ if (fs.existsSync(stateLink)) {
1367
+ const viaState = runHook(['before_tool'], dir, {
1368
+ tool_name: 'Write',
1369
+ tool_input: { file_path: path.join(stateLink, 'flow-comet-state.json') },
1370
+ });
1371
+ assertExit(viaState, 2);
1372
+ assertOut(viaState, 'BLOCKED');
1373
+ }
1374
+ // ⑦b 协议文件:经链接写它同样要拒(此前协议身份判定零断言)
1375
+ const protoDir = path.join(dir, 'reference');
1376
+ if (fs.existsSync(protoDir)) {
1377
+ const protoLink = path.join(specs, 'p');
1378
+ try { fs.symlinkSync(protoDir, protoLink, process.platform === 'win32' ? 'junction' : 'dir'); } catch { /* 已降级 */ }
1379
+ if (fs.existsSync(protoLink)) {
1380
+ const viaProto = runHook(['before_tool'], dir, {
1381
+ tool_name: 'Write',
1382
+ tool_input: { file_path: path.join(protoLink, 'workflow-protocol.json') },
1383
+ });
1384
+ assertExit(viaProto, 2);
1385
+ assertOut(viaProto, 'BLOCKED');
1386
+ assertOut(viaProto, '协议文件');
1387
+ }
1388
+ }
1389
+ // ⑦b-2 Bash 通道同判:同一目标不因所选工具而异(此前这两条在两级套件里零断言——
1390
+ // 撤掉 Bash 分支的协议判定与 blocked 判定,套件仍然全绿,等于行为无人看守)。
1391
+ {
1392
+ const bashProtoTarget = posix(path.join(dir, 'reference', 'workflow-protocol.json'));
1393
+ const viaBashProto = runHook(['before_tool'], dir, {
1394
+ tool_name: 'Bash',
1395
+ tool_input: { command: 'printf x > "' + bashProtoTarget + '"' },
1396
+ });
1397
+ assertExit(viaBashProto, 2);
1398
+ assertOut(viaBashProto, 'BLOCKED');
1399
+ assertOut(viaBashProto, '协议文件');
1400
+ }
1401
+ // ⑦c 目录目标不得被硬链接判据误拦(POSIX 上目录 nlink 恒 ≥2,判据只认普通文件)
1402
+ const dirTarget = path.join(specs, 'dir-target');
1403
+ fs.mkdirSync(dirTarget, { recursive: true });
1404
+ const viaDir = runHook(['before_tool'], dir, {
1405
+ tool_name: 'Write',
1406
+ tool_input: { file_path: dirTarget },
1407
+ });
1408
+ assertExit(viaDir, 0);
1409
+ assertOut(viaDir, 'workflow-hook-guard-ok');
1410
+
1411
+ // ⑦d worktree 隔离区只豁免白名单,不豁免保护集:worktrees 下指向 state 的硬链必须拒绝
1412
+ // (协调者通道的 worktree 早退曾绕过保护集判定——实测放行,现前置判定后拒绝)
1413
+ {
1414
+ const wtDir = path.join(dir, '.claude', 'worktrees', 'w');
1415
+ fs.mkdirSync(wtDir, { recursive: true });
1416
+ const wtState = path.join(wtDir, 'state-hl.json');
1417
+ let wtReady = false;
1418
+ try { fs.linkSync(path.join(dir, '.flow-comet', 'flow-comet-state.json'), wtState); wtReady = true; } catch { wtReady = false; }
1419
+ if (!wtReady) {
1420
+ console.error('SKIP: worktree 硬链断言不适用(本机无法创建硬链接)——未覆盖,不是通过');
1421
+ } else {
1422
+ const viaWt = runHook(['before_tool'], dir, {
1423
+ tool_name: 'Write',
1424
+ tool_input: { file_path: wtState },
1425
+ });
1426
+ assertExit(viaWt, 2);
1427
+ assertOut(viaWt, 'BLOCKED');
1428
+ }
1429
+ // 对照:worktree 内的普通写入仍放行(隔离区放行不得被这条判据误伤)
1430
+ const viaWtOk = runHook(['before_tool'], dir, {
1431
+ tool_name: 'Write',
1432
+ tool_input: { file_path: path.join(wtDir, 'src', 'ok.mjs') },
1433
+ });
1434
+ assertExit(viaWtOk, 0);
1435
+ assertOut(viaWtOk, 'workflow-hook-guard-ok');
1436
+ }
1437
+
1438
+ // ⑧ 硬链接:同一文件对象的第二个名字,路径判定看不出来 → 一律拒绝
1439
+ // (硬链接不需要符号链接特权,Windows 普通用户即可创建)
1440
+ const hardTarget = path.join(specs, 'hard.js');
1441
+ let hardKind = 'file';
1442
+ try {
1443
+ fs.linkSync(path.join(srcDir, 'app.js'), hardTarget);
1444
+ } catch {
1445
+ // 跨卷/文件系统不支持时退回目录 junction + 文件对(保持同一类判据仍被覆盖)
1446
+ try { fs.symlinkSync(path.join(srcDir, 'app.js'), hardTarget, 'file'); hardKind = 'symlink'; } catch { hardKind = null; }
1447
+ }
1448
+ if (!hardKind) {
1449
+ console.error('SKIP: 硬链接断言不适用(本机无法创建硬链接或文件符号链接)——未覆盖,不是通过');
1450
+ }
1451
+ if (hardKind) {
1452
+ const viaHard = runHook(['before_tool'], dir, {
1453
+ tool_name: 'Write',
1454
+ tool_input: { file_path: hardTarget },
1455
+ });
1456
+ assertExit(viaHard, 2);
1457
+ assertOut(viaHard, 'BLOCKED');
1458
+ // 撤掉 nlink 判定后,硬链接形态会退化成"白名单内普通文件"⇒ 此断言必红(判别力锚)
1459
+ // 回退形态(文件符号链接)不走 nlink 判据,落点解析到 src/app.js ⇒ 报文是白名单拒绝,
1460
+ // 这里按实际成因断言,避免"支持符号链接但不支持硬链接"的文件系统上整套件必红。
1461
+ assertOut(viaHard, hardKind === 'file' ? '硬链接' : 'src/app.js');
1462
+ // ⑦c-2 Bash 通道同判(此前该分支的 blocked 判定零断言,撤掉实现套件仍全绿)
1463
+ const bashHard = runHook(['before_tool'], dir, {
1464
+ tool_name: 'Bash',
1465
+ tool_input: { command: 'printf x > "' + posix(hardTarget) + '"' },
1466
+ });
1467
+ assertExit(bashHard, 2);
1468
+ assertOut(bashHard, 'BLOCKED');
1469
+ assertOut(bashHard, hardKind === 'file' ? '硬链接' : 'src/app.js');
1470
+ }
1471
+ // ⑨ 同一实体不同拼写:win32 大小写不敏感 ⇒ 放行;非 win32 显式声明不适用(不静默跳过)
1472
+ if (process.platform === 'win32') {
1473
+ const viaCase = runHook(['before_tool'], dir, {
1474
+ tool_name: 'Write',
1475
+ tool_input: { file_path: path.join(dir, '.SPECS', 'case.md') },
1476
+ });
1477
+ assertExit(viaCase, 0);
1478
+ assertOut(viaCase, 'workflow-hook-guard-ok');
1479
+ } else {
1480
+ console.error('SKIP: 大小写等价拼写断言不适用(非 win32 大小写敏感文件系统)——未覆盖,不是通过');
1481
+ }
1482
+ // ⑩ 恢复:移除链接后同一路径恢复放行(拦截不是永久状态)
1483
+ try { fs.rmdirSync(linkInto); } catch { try { fs.unlinkSync(linkInto); } catch { /* 忽略 */ } }
1484
+ if (fs.existsSync(linkInto)) throw new Error('恢复夹具:链接未被移除');
1485
+ const recovered = runHook(['before_tool'], dir, {
1486
+ tool_name: 'Write',
1487
+ tool_input: { file_path: path.join(linkInto, 'again.txt') },
1488
+ });
1489
+ assertExit(recovered, 0);
1490
+ assertOut(recovered, 'workflow-hook-guard-ok');
1491
+
1492
+ // ⑪ 空闲态只保留一条拦截:state 文件(用户裁决:空闲零拦截,最多只拦 state)。
1493
+ // 实测链条:删除 state 后守卫降为空闲;若连 state 也能写,就能重建
1494
+ // executionMode=direct 的状态造成持久降级。协议文件在空闲态放行(下次运行的协议由
1495
+ // 人工/安装器通道维护)。反向构造:把状态判定退回 currentNode 门内 ⇒ ⑪b 必红;
1496
+ // 把协议判定移出活跃流程门 ⇒ ⑪b 的协议放行用例必红;把链接拒绝移出流程态门 ⇒ ⑪c 必红。
1497
+ const stateTarget = path.join(dir, '.flow-comet', 'flow-comet-state.json');
1498
+ const protoTarget = path.join(dir, 'reference', 'workflow-protocol.json');
1499
+ // ⑪a 空闲态(state 在盘但无 activeChange / currentNode)+ 指向 state 的硬链接:
1500
+ // 路径前缀看不见同一文件的第二个名字,只有物理身份判据能拦(空闲态下硬链的
1501
+ // blocked 拒绝按空闲放行语义不生效,故本断言与 ⑧ 的活跃态硬链断言相互独立)。
1502
+ writeState(dir, { ...baseState('review'), activeChange: null, currentNode: null, status: 'completed' });
1503
+ const idleStateLink = path.join(specs, 'idle-state-link.json');
1504
+ let idleLinkKind = null;
1505
+ try { fs.linkSync(stateTarget, idleStateLink); idleLinkKind = 'hard'; }
1506
+ catch { try { fs.symlinkSync(stateTarget, idleStateLink, 'file'); idleLinkKind = 'symlink'; } catch { idleLinkKind = null; } }
1507
+ if (idleLinkKind) {
1508
+ const idleLinkBash = runHook(['before_tool'], dir, {
1509
+ tool_name: 'Bash',
1510
+ tool_input: { command: 'printf x > "' + posix(idleStateLink) + '"' },
1511
+ });
1512
+ assertExit(idleLinkBash, 2);
1513
+ assertOut(idleLinkBash, 'state 文件');
1514
+ const idleLinkWrite = runHook(['before_tool'], dir, {
1515
+ tool_name: 'Write',
1516
+ tool_input: { file_path: idleStateLink },
1517
+ });
1518
+ assertExit(idleLinkWrite, 2);
1519
+ assertOut(idleLinkWrite, 'state 文件');
1520
+ } else {
1521
+ console.error('SKIP: 空闲态保护集别名断言不适用(本机无法创建硬链接或文件符号链接)——未覆盖,不是通过');
1522
+ }
1523
+ // ⑪b 无 state(空闲)时:写 state 仍拒绝(两通道同判);写协议放行——空闲态零拦截,
1524
+ // 最多只拦 state 文件(用户裁决)。反向构造:把协议判定移进活跃流程门 ⇒ 本条必红。
1525
+ fs.rmSync(stateTarget);
1526
+ for (const [label, toolName, toolInput] of [
1527
+ ['state 文件(file_path)', 'Write', { file_path: stateTarget }],
1528
+ ['state 文件(Bash)', 'Bash', { command: 'printf x > "' + posix(stateTarget) + '"' }],
1529
+ ]) {
1530
+ const idleProtected = runHook(['before_tool'], dir, { tool_name: toolName, tool_input: toolInput });
1531
+ if (idleProtected.status !== 2 || !idleProtected.output.includes('state 文件')) {
1532
+ throw new Error('空闲态写 state 文件应拒绝并点名(' + label + '),实际输出: ' + JSON.stringify(idleProtected.output));
1533
+ }
1534
+ }
1535
+ for (const [label, toolName, toolInput] of [
1536
+ ['协议文件(file_path)', 'Write', { file_path: protoTarget }],
1537
+ ['协议文件(Bash)', 'Bash', { command: 'printf x > "' + posix(protoTarget) + '"' }],
1538
+ ]) {
1539
+ const idleProtocol = runHook(['before_tool'], dir, { tool_name: toolName, tool_input: toolInput });
1540
+ if (idleProtocol.status !== 0 || !idleProtocol.output.includes('no active workflow')) {
1541
+ throw new Error('空闲态写协议文件应放行(' + label + ';用户裁决:空闲零拦截),实际输出: ' + JSON.stringify(idleProtocol.output));
1542
+ }
1543
+ }
1544
+ // ⑪c 对照:空闲态经链接逃逸的目标仍放行(空闲放行语义不变)。普通源码目标的空闲放行
1545
+ // 由场景 30a / 67 覆盖,此处不再重复(同一行为三份断言 = 噪音)。
1546
+ if (fs.existsSync(outLink)) {
1547
+ // 两通道都不得在空闲态拒绝链接逃逸目标(Bash 的 blocked 拒绝必须留在流程态门之后)
1548
+ const idleEscapeBash = runHook(['before_tool'], dir, {
1549
+ tool_name: 'Bash',
1550
+ tool_input: { command: 'printf x > "' + posix(path.join(outLink, 'idle-escaped.txt')) + '"' },
1551
+ });
1552
+ assertExit(idleEscapeBash, 0);
1553
+ assertOut(idleEscapeBash, 'no active workflow');
1554
+ const idleEscape = runHook(['before_tool'], dir, {
1555
+ tool_name: 'Write',
1556
+ tool_input: { file_path: path.join(outLink, 'idle-escaped.md') },
1557
+ });
1558
+ assertExit(idleEscape, 0);
1559
+ assertOut(idleEscape, 'no active workflow');
1560
+ }
1561
+ },
1562
+ },
1287
1563
  ];
@@ -22,6 +22,7 @@ import {
22
22
  scriptTreeFiles,
23
23
  strictSummary,
24
24
  writeIntakeArtifacts,
25
+ writeNodeDeclarationMarkers,
25
26
  } from '../lib/test-fixtures.mjs';
26
27
  import {
27
28
  FIX_RETURN_FAMILY_COMPLETED,
@@ -704,7 +705,6 @@ export const ENTRIES = [
704
705
  activeChange: CHANGE_ID,
705
706
  currentNode: 'review',
706
707
  evidence: { review: { summary: 'pending fix' } },
707
- newChange: true,
708
708
  };
709
709
  const pendingDecision = { kind: 'pending', target: 'execute' };
710
710
  for (let round = 1; round <= 3; round += 1) {
@@ -766,7 +766,7 @@ export const ENTRIES = [
766
766
  throw new Error('授权放行后计数器应为 4,实际 ' + JSON.stringify(roundState.fixRoundsByChange));
767
767
  }
768
768
  // 旧 change 缺轮次字段 → 缺省 0、不因计数 BLOCK
769
- const legacyRoundState = { activeChange: CHANGE_ID, currentNode: 'review', evidence: {}, newChange: false };
769
+ const legacyRoundState = { activeChange: CHANGE_ID, currentNode: 'review', evidence: {} };
770
770
  const legacyRound = applyRound({ state: legacyRoundState, sourceNode: 'review', decision: pendingDecision });
771
771
  if (!legacyRound.counted || legacyRound.blocked || legacyRound.round !== 1) {
772
772
  throw new Error('旧 change 缺省 0 应可从第 1 轮计数,实际 ' + JSON.stringify(legacyRound));
@@ -775,7 +775,7 @@ export const ENTRIES = [
775
775
  throw new Error('旧 change 第 1 轮应写入缺省容器,实际 ' + JSON.stringify(legacyRoundState.fixRoundsByChange));
776
776
  }
777
777
  // 分支② done-but-unclosed 不计数(计数语义 = 一次受控归位)
778
- const unclosedState = { activeChange: CHANGE_ID, currentNode: 'review', evidence: {}, newChange: true };
778
+ const unclosedState = { activeChange: CHANGE_ID, currentNode: 'review', evidence: {} };
779
779
  const unclosedRound = applyRound({ state: unclosedState, sourceNode: 'review', decision: { kind: 'unclosed', target: 'execute' } });
780
780
  if (unclosedRound.counted || unclosedRound.round !== null || unclosedState.fixRoundsByChange) {
781
781
  throw new Error('done-but-unclosed 分支不得计数/建容器,实际 '
@@ -1073,7 +1073,6 @@ export const ENTRIES = [
1073
1073
  verifyFailures: 0,
1074
1074
  executionMode: 'subagent',
1075
1075
  directOverride: false,
1076
- newChange: true,
1077
1076
  };
1078
1077
  // ① 正例:pending Fix 任务在场 → 受控归位 + 审计行 + 真实写盘
1079
1078
  writeFile(dir, taskPath, fixBatchTaskText('pending'));
@@ -1192,7 +1191,6 @@ export const ENTRIES = [
1192
1191
  verifyFailures: 0,
1193
1192
  executionMode: 'subagent',
1194
1193
  directOverride: false,
1195
- newChange: true,
1196
1194
  };
1197
1195
  writeFile(dir, taskPath, fixBatchTaskText('pending'));
1198
1196
  writeState(dir, st);
@@ -1279,8 +1277,9 @@ export const ENTRIES = [
1279
1277
  verifyFailures: 0,
1280
1278
  executionMode: 'subagent',
1281
1279
  directOverride: false,
1282
- newChange: true,
1283
1280
  });
1281
+ // 声明标记:真实流程里由协调者 / record 写;夹具直接写 state,须补同一份事实(否则先撞覆盖门)
1282
+ writeNodeDeclarationMarkers(dir, 'execute');
1284
1283
  const res = runGuard(['exit', 'execute', '--apply'], dir);
1285
1284
  assertExit(res, 0);
1286
1285
  assertOut(res, 'FIX-BATCH: 回源节点 review(execute 出口已完成)');
@@ -1343,6 +1342,8 @@ export const ENTRIES = [
1343
1342
  },
1344
1343
  ],
1345
1344
  }));
1345
+ // 声明标记(新 change 的出口覆盖门):夹具直接写 state,补上真实流程里协调者 / record 写的那份。
1346
+ writeNodeDeclarationMarkers(dir, 'execute');
1346
1347
  const resDivergentPlain = runGuard(['exit', 'execute', '--apply'], dir);
1347
1348
  assertExit(resDivergentPlain, 0);
1348
1349
  assertOut(resDivergentPlain, 'FIX-BATCH: 回源节点 review(execute 出口已完成)');