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
@@ -3,6 +3,7 @@
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import {
6
+ inspectWorkflowPathSegments,
6
7
  inspectWorkflowProtectedPath,
7
8
  parseProtocolWriteWhitelist,
8
9
  readProtocolFile,
@@ -183,7 +184,18 @@ function codexWriteTargetsFromCommand(command) {
183
184
  const addTarget = (raw) => {
184
185
  let t = raw && raw.trim();
185
186
  if (t) t = t.replace(/^["']|["']$/g, ''); // 剥引号
186
- if (t && t !== 'NUL' && t !== '/dev/null' && !targets.includes(t)) targets.push(t); // 去重
187
+ if (t) {
188
+ // 空设备不是写入目标,但"是设备"取决于执行它的 shell:
189
+ // - `nul` 只在 Windows 是空设备(大小写不敏感);POSIX shell 上 `>nul` 会真的
190
+ // 创建一个名为 nul 的文件,必须照常按写入目标判定;
191
+ // - `/dev/null` 在两类 shell 上都不是落盘目标;
192
+ // - `/dev/stdout` / `/dev/stderr` **不过滤**:它们可能被 `exec 1<>file` 之类的
193
+ // 重定向绑定到真实文件,放行等于给出一条绕过白名单的写路径。
194
+ const lower = t.toLowerCase();
195
+ const isDevice =
196
+ lower === '/dev/null' || (lower === 'nul' && process.platform === 'win32');
197
+ if (!isDevice && !targets.includes(t)) targets.push(t);
198
+ } // 去重
187
199
  };
188
200
  const patterns = [
189
201
  // PowerShell **路径型**写类 cmdlet 的 -Path/-LiteralPath/-FilePath(引号内空格整体捕获并剥引号;
@@ -529,27 +541,46 @@ function blockProtocolFileWrite(target) {
529
541
  );
530
542
  }
531
543
 
544
+ // 写目标解析失败(链接逃逸 / 硬链接共享文件对象 / realpath 报错)的统一出口:
545
+ // 按成因选报文,避免把硬链接说成"符号链接",也避免三处调用各写一份措辞。
546
+ function blockUnsafeWriteTarget(rawTarget, reason, label = '写入') {
547
+ const shared = /硬链接/.test(reason);
548
+ hookBlock(
549
+ shared
550
+ ? 'BLOCKED: ' + label + ' "' + rawTarget + '" 指向被多处共享的文件对象(' + reason + ')——拒绝'
551
+ : 'BLOCKED: ' + label + ' "' + rawTarget + '" 经符号链接/junction 指向非法落点(' + reason + ')',
552
+ shared
553
+ ? '恢复: 该路径与白名单外的文件是同一实体,请改用独立文件;确需共享时移除多余链接后重试'
554
+ : '恢复: 改用项目内的真实路径,或移除指向项目外的链接后再写入'
555
+ );
556
+ }
557
+
532
558
  // 身份在场时的最小保护集执行:候选写入目标逐个判定,命中即以既有报文风格拦截(hookBlock
533
559
  // 不返回);未命中 ⇒ 返回(调用方按子代理语义放行)。判定入口唯一——身份短路与保护集判定都在此收口。
534
560
  // 两个目标各双判据:词法同一性(规范拼写)+ 物理同一性(别名形态)。
535
561
  async function enforceMinimalProtectionSet(hookInput) {
536
562
  const stateFileAbsolute = path.join(runRoot, ...STATE_FILE_REL.split('/'));
537
563
  for (const candidate of protectedCandidateTargets(hookInput)) {
538
- const resolvedTarget = resolveWriteTarget(candidate);
564
+ const resolvedTarget = await resolveWriteTarget(candidate);
539
565
  if (resolvedTarget === null) continue;
566
+ // 身份通道不在此处拒绝链接形态(空闲放行与执行者可写任意路径的既有语义);
567
+ // 链接指向受保护文件时由下方同一性判定拦住。
568
+
540
569
  if (
541
570
  blockedProtocolFileTarget(resolvedTarget.absolute) ||
542
571
  (await isSameProtectedFileObject(resolvedTarget.absolute, protocolPath))
543
572
  ) {
544
573
  blockProtocolFileWrite(resolvedTarget.raw);
545
574
  }
546
- if (resolvedTarget.targetRel !== null) {
547
- if (
548
- blockedStateFileTarget(resolvedTarget.targetRel) ||
549
- (await isSameProtectedFileObject(resolvedTarget.absolute, stateFileAbsolute))
550
- ) {
551
- blockStateFileWrite(resolvedTarget.raw);
552
- }
575
+ // 两条判据并列而非嵌套:路径词法命中(targetRel)与物理同一性(可能经链接、也可能在项目根外——
576
+ // 根外目标的 targetRel 恒为 null,嵌套会把"根外链接指向状态文件"整条放走)。
577
+ if (
578
+ (resolvedTarget.targetRel !== null && blockedStateFileTarget(resolvedTarget.targetRel)) ||
579
+ (await isSameProtectedFileObject(resolvedTarget.absolute, stateFileAbsolute))
580
+ ) {
581
+ blockStateFileWrite(
582
+ typeof resolvedTarget.lexicalRel === 'string' ? resolvedTarget.lexicalRel : resolvedTarget.raw,
583
+ );
553
584
  }
554
585
  }
555
586
  }
@@ -696,19 +727,147 @@ function normalizeDriveRootSpelling(rawTarget) {
696
727
  // insideRunRoot=true → targetRel = 相对 runRoot 的 POSIX 路径(白名单前缀匹配 / 状态文件比较)
697
728
  // insideRunRoot=false → targetRel = null(项目根之外;由「runRoot 外写入关断」与 Bash 分支同判)
698
729
  // 无写入语义(非字符串 / 空串)→ null(该目标不参与任何判定)。
699
- function resolveWriteTarget(rawTarget) {
730
+ // '..' 段必须按文件系统顺序解析,不能交给 path.resolve 词法折叠:折叠发生在段扫描之前,
731
+ // 链接段连同它后面的 '..' 一起被提前吃掉(.specs/j/../x 折成 .specs/x,扫描器看不到 j),
732
+ // 而内核按分量走一遍是 .specs/j → src、再 '..' 回项目根。两结果不一致就是"折叠掩盖了链接"。
733
+ // 只在目标含 '..' 段时才做这次复核——其余路径的折叠与逐段解析等价,不必多付一次遍历。
734
+ async function resolveThroughSegmentsPhysically(rawTarget) {
735
+ const parts = rawTarget.split(/[\\/]+/).filter((segment) => segment !== '' && segment !== '.');
736
+ let cursor;
737
+ let start = 0;
738
+ if (path.isAbsolute(rawTarget)) {
739
+ cursor = path.parse(path.resolve(rawTarget)).root;
740
+ if (/^[A-Za-z]:$/.test(parts[0] ?? '')) start = 1;
741
+ } else {
742
+ cursor = runRoot;
743
+ }
744
+ for (let index = start; index < parts.length; index += 1) {
745
+ const segment = parts[index];
746
+ if (segment === '..') {
747
+ cursor = path.dirname(cursor);
748
+ continue;
749
+ }
750
+ const candidate = path.join(cursor, segment);
751
+ let stat = null;
752
+ try {
753
+ stat = await fs.lstat(candidate);
754
+ } catch {
755
+ stat = null; // 尚不存在(写资格允许新建):按词法形态继续
756
+ }
757
+ if (stat && stat.isSymbolicLink()) {
758
+ try {
759
+ cursor = await fs.realpath(candidate);
760
+ } catch {
761
+ cursor = candidate;
762
+ }
763
+ continue;
764
+ }
765
+ cursor = candidate;
766
+ }
767
+ return cursor;
768
+ }
769
+
770
+ async function resolveWriteTarget(rawTarget) {
700
771
  if (typeof rawTarget !== 'string') return null;
701
772
  const trimmed = rawTarget.trim();
702
773
  if (trimmed === '') return null;
703
- const absolute = path.resolve(runRoot, normalizeDriveRootSpelling(trimmed));
774
+ const normalizedTarget = normalizeDriveRootSpelling(trimmed);
775
+ const absolute = path.resolve(runRoot, normalizedTarget);
776
+ // 含 '..' 段 → 逐段物理复核(见上方注释)。折叠结果与物理解析不一致 ⇒ 拒绝,理由点名该段。
777
+ if (normalizedTarget.split(/[\\/]+/).some((segment) => segment === '..')) {
778
+ const physical = await resolveThroughSegmentsPhysically(normalizedTarget);
779
+ if (path.resolve(physical) !== path.resolve(absolute)) {
780
+ return {
781
+ raw: trimmed,
782
+ absolute,
783
+ insideRunRoot: true,
784
+ targetRel: null,
785
+ physicalRel: null,
786
+ lexicalRel: null,
787
+ exists: false,
788
+ blocked: true,
789
+ blockedReason:
790
+ '路径含 ".." 段且该段位于符号链接之后——词法折叠与逐段解析落点不同(折叠 '
791
+ + path.relative(runRoot, absolute).replaceAll('\\', '/')
792
+ + ',实际 ' + path.relative(runRoot, physical).replaceAll('\\', '/')
793
+ + ');请改用不含 ".."' + ' 的目标路径',
794
+ };
795
+ }
796
+ }
704
797
  const relative = path.relative(runRoot, absolute);
705
798
  const outside =
706
799
  path.isAbsolute(relative) || relative === '..' || relative.startsWith('..' + path.sep);
800
+ const lexicalRel = outside ? null : relative === '' ? '.' : relative.replaceAll('\\', '/');
801
+ if (outside) {
802
+ return {
803
+ raw: trimmed,
804
+ absolute,
805
+ insideRunRoot: false,
806
+ targetRel: null,
807
+ physicalRel: null,
808
+ lexicalRel: null,
809
+ exists: false,
810
+ blocked: false,
811
+ };
812
+ }
813
+ let inspection;
814
+ try {
815
+ inspection = await inspectWorkflowPathSegments(runRoot, absolute, 'write target', 'any', {
816
+ followLinks: true,
817
+ physicalRel: true,
818
+ });
819
+ } catch (error) {
820
+ return {
821
+ raw: trimmed,
822
+ absolute,
823
+ insideRunRoot: true,
824
+ targetRel: null,
825
+ physicalRel: null,
826
+ lexicalRel,
827
+ exists: false,
828
+ blocked: true,
829
+ blockedReason: error && error.message ? error.message : String(error),
830
+ };
831
+ }
832
+ // 硬链接是路径判定的盲区:它是同一文件对象的第二个名字,realpath 解析出的仍是它自己,
833
+ // 白名单前缀判不出来。目标存在且链接数 > 1 ⇒ 该路径与别处共享文件对象,写入会改到白名单之外
834
+ // 的文件——按 fail-closed 拒绝(普通新建/单链接文件 nlink === 1,不受影响)。
835
+ let hardLinkedFile = false;
836
+ let nlink = 1;
837
+ if (inspection.exists) {
838
+ try {
839
+ const targetStat = await fs.stat(absolute, { bigint: true });
840
+ nlink = Number(targetStat.nlink);
841
+ // 只对普通文件生效:POSIX 目录 nlink 恒 ≥2("." 与 ".."),把目录算进来会在
842
+ // Linux / macOS 上把「写目录目标」全判成硬链接(本机 NTFS 目录 nlink=1,看不出来)。
843
+ hardLinkedFile = targetStat.isFile() && nlink > 1;
844
+ } catch (error) {
845
+ // stat 失败时无法确认链接数 ⇒ 按 fail-closed 拒绝:硬链判据的意义就是"看不出来也要拒",
846
+ // 在拿不到 nlink 的情况下放行,等于让瞬时文件系统错误把这条判据整个关掉。
847
+ return {
848
+ raw: trimmed,
849
+ absolute,
850
+ insideRunRoot: true,
851
+ targetRel: null,
852
+ physicalRel: null,
853
+ lexicalRel,
854
+ exists: false,
855
+ blocked: true,
856
+ blockedReason:
857
+ '无法确认目标的链接数(stat 失败:' + (error && error.code ? error.code : String(error)) + ')',
858
+ };
859
+ }
860
+ }
707
861
  return {
708
862
  raw: trimmed,
709
863
  absolute,
710
- insideRunRoot: !outside,
711
- targetRel: outside ? null : relative === '' ? '.' : relative.replaceAll('\\', '/'),
864
+ insideRunRoot: true,
865
+ targetRel: inspection.physicalRel,
866
+ lexicalRel,
867
+ blocked: hardLinkedFile,
868
+ blockedReason: hardLinkedFile
869
+ ? '目标与其它路径共享同一文件对象(硬链接,链接数 ' + nlink + ')'
870
+ : undefined,
712
871
  };
713
872
  }
714
873
 
@@ -722,7 +881,7 @@ function toolFilePathFromHookInput(input) {
722
881
 
723
882
  // file_path 形态(Write / Edit / …):载荷无 file_path ⇒ null(无写入语义,不判定)。
724
883
  // 与命令级 token 共用 resolveWriteTarget——同一路径不因所选工具而异。
725
- function fileWriteTargetFromHookInput(input) {
884
+ async function fileWriteTargetFromHookInput(input) {
726
885
  return resolveWriteTarget(toolFilePathFromHookInput(input));
727
886
  }
728
887
 
@@ -788,12 +947,13 @@ async function main() {
788
947
  }
789
948
  // Phase 写入控制:按运行时状态文件的 currentNode 检查写入目标是否在白名单内
790
949
  // state 文件读取失败时不阻断(state 可能不存在),继续执行后续安全检查
791
- const stateFile = path.join(runRoot, RUNTIME_DIR, RUNTIME_STATE_FILE_NAME);
950
+ // 机器状态文件的绝对路径(读取与保护集共用本表达式——各处不得再拼一遍)
951
+ const stateFileAbsolute = path.join(runRoot, ...STATE_FILE_REL.split('/'));
792
952
  let currentNode = null;
793
953
  let executionMode = 'subagent';
794
954
  let activeChange = null;
795
955
  try {
796
- const stateContent = await fs.readFile(stateFile, 'utf8');
956
+ const stateContent = await fs.readFile(stateFileAbsolute, 'utf8');
797
957
  const state = JSON.parse(stateContent);
798
958
  currentNode = state.currentNode;
799
959
  executionMode = state.executionMode ?? 'subagent';
@@ -824,7 +984,7 @@ async function main() {
824
984
  return;
825
985
  }
826
986
 
827
- const fileTarget = fileWriteTargetFromHookInput(hookInput);
987
+ const fileTarget = await fileWriteTargetFromHookInput(hookInput);
828
988
  const target = fileTarget ? fileTarget.targetRel : null;
829
989
 
830
990
  // R5: Bash 工具写路径适配(CC 与 Codex 通用)——Bash 工具的 command 字符串(无 file_path),
@@ -833,16 +993,36 @@ async function main() {
833
993
  if (hookInput && typeof hookInput === 'object' && hookInput.tool_name === 'Bash') {
834
994
  const command = hookInput.tool_input && typeof hookInput.tool_input === 'object' ? hookInput.tool_input.command : null;
835
995
  const writeTargets = codexWriteTargetsFromCommand(command);
836
- if (writeTargets.length > 0 && currentNode) {
837
- const whitelist = PHASE_WRITE_WHITELIST[currentNode];
838
- // 声明模式未列出节点 → fail-closed(同 file_path 判定);缺省表无此节点 → 协调者默认 .specs/
839
- const effectiveWhitelist = whitelist || (declared ? null : ['.specs/']);
996
+ // 空闲态(无 state / 无 activeChange / completed)按既有语义零拦截,只保留一条例外:
997
+ // **状态文件**恒拦——否则删掉 state 文件就能重建 executionMode=direct 的状态造成持久降级。
998
+ // 协议文件、链接/硬链拒绝、隔离区放行与白名单仍只在活跃流程生效(用户裁决 2026-11-09)。
999
+ if (writeTargets.length > 0) {
840
1000
  for (const t of writeTargets) {
841
- const resolvedTarget = resolveWriteTarget(t);
1001
+ const resolvedTarget = await resolveWriteTarget(t);
842
1002
  const targetRel = resolvedTarget ? resolvedTarget.targetRel : null;
843
- if (targetRel !== null && blockedStateFileTarget(targetRel)) {
1003
+ // 状态文件的两条判据并列(路径 + 物理身份):硬链接是同一文件的第二个名字,路径前缀
1004
+ // 看不见它(与身份通道的保护集判定同一个判据,不另写一份)。
1005
+ if (
1006
+ (targetRel !== null && blockedStateFileTarget(targetRel)) ||
1007
+ (resolvedTarget && (await isSameProtectedFileObject(resolvedTarget.absolute, stateFileAbsolute)))
1008
+ ) {
844
1009
  blockStateFileWrite(t);
845
1010
  }
1011
+ // 空闲(无 state / 无 activeChange / completed):只剩 state 文件一条拦截,其余与
1012
+ // 既有 (no active workflow) 同语义——放行(用户裁决:空闲态零拦截)。
1013
+ if (!currentNode) continue;
1014
+ // 协议文件只在流程运行中拦(空闲态放行);两通道同判——同一个文件用 Bash 写
1015
+ //(printf > / Remove-Item)不得比 file_path 更宽(「同一路径不因所选工具而异」)。
1016
+ if (
1017
+ resolvedTarget &&
1018
+ (blockedProtocolFileTarget(resolvedTarget.absolute) ||
1019
+ (await isSameProtectedFileObject(resolvedTarget.absolute, protocolPath)))
1020
+ ) {
1021
+ blockProtocolFileWrite(t);
1022
+ }
1023
+ if (resolvedTarget && resolvedTarget.blocked) {
1024
+ blockUnsafeWriteTarget(t, resolvedTarget.blockedReason, '命令写入');
1025
+ }
846
1026
  // worktree 隔离区放行(与 file_path 判定共用同一判定——同路径同结论);
847
1027
  // 放行前置 = 物理包含性(词法命中但真实落点在区外 → 拒,不放行)
848
1028
  if (targetRel !== null && isInsideAgentWorktree(targetRel)) {
@@ -852,6 +1032,9 @@ async function main() {
852
1032
  '恢复: 改用隔离区内的真实路径(隔离区放行仅限物理位于 <项目根>/.claude/worktrees/ 之下的写入)'
853
1033
  );
854
1034
  }
1035
+ const whitelist = PHASE_WRITE_WHITELIST[currentNode];
1036
+ // 声明模式未列出节点 → fail-closed(同 file_path 判定);缺省表无此节点 → 协调者默认 .specs/
1037
+ const effectiveWhitelist = whitelist || (declared ? null : ['.specs/']);
855
1038
  const allowed = targetRel !== null && effectiveWhitelist !== null && targetAllowed(targetRel, effectiveWhitelist, activeChange);
856
1039
  if (!allowed) {
857
1040
  hookBlock(
@@ -865,10 +1048,39 @@ async function main() {
865
1048
  }
866
1049
  }
867
1050
 
1051
+ // ── 最小保护集(先于隔离区放行)────────────────────────────────────────────
1052
+ // worktree 的早退只该豁免**白名单**(隔离区里写源码是设计意图),不该豁免保护集:
1053
+ // 实测「.claude/worktrees/ 下指向 state / 协议文件的硬链接」在协调者通道被放行,
1054
+ // 而同一硬链放在 .specs/ 下被拒——同一目标因所在目录而异。三处判定前置到早退之前。
1055
+ // 链接/硬链的拒绝只在活跃流程生效(空闲放行是既有语义);state 文件**恒拦**——否则删掉
1056
+ // state 即可重建 permissive state(用户裁决 2026-11-09:空闲态零拦截,最多只拦 state);
1057
+ // 协议文件只在活跃流程拦。
1058
+ if (currentNode && fileTarget && fileTarget.blocked) {
1059
+ blockUnsafeWriteTarget(fileTarget.raw, fileTarget.blockedReason);
1060
+ }
1061
+ if (fileTarget) {
1062
+ if (
1063
+ (target !== null && blockedStateFileTarget(target)) ||
1064
+ (await isSameProtectedFileObject(fileTarget.absolute, stateFileAbsolute))
1065
+ ) {
1066
+ blockStateFileWrite(
1067
+ typeof fileTarget.lexicalRel === 'string' ? fileTarget.lexicalRel : fileTarget.raw,
1068
+ );
1069
+ }
1070
+ if (
1071
+ currentNode &&
1072
+ (blockedProtocolFileTarget(fileTarget.absolute) ||
1073
+ (await isSameProtectedFileObject(fileTarget.absolute, protocolPath)))
1074
+ ) {
1075
+ blockProtocolFileWrite(fileTarget.raw);
1076
+ }
1077
+ }
1078
+
868
1079
  // ── worktree 隔离区放行(CC Agent isolation:"worktree")────────────────────
869
1080
  // 判定实现见 isInsideAgentWorktree + agentWorktreeWriteStaysIsolated(与上方 Bash 命令写入
870
1081
  // 判定共用——同一路径不因工具而异);词法命中但物理落点在区外 → 拒(fail-closed)。
871
- if (isInsideAgentWorktree(target)) {
1082
+ // 空闲态不进入:隔离区放行与它的穿越拒绝都只在活跃流程生效(空闲放行语义;与 Bash 分支逐条对齐)。
1083
+ if (currentNode && isInsideAgentWorktree(target)) {
872
1084
  if (!(await agentWorktreeWriteStaysIsolated(target))) {
873
1085
  hookBlock(
874
1086
  `BLOCKED: 写入 "${target}" 位于 worktree 隔离区但物理落点在区外(符号链接/junction 穿越)`,
@@ -892,9 +1104,6 @@ async function main() {
892
1104
  }
893
1105
 
894
1106
  if (currentNode && target) {
895
- if (blockedStateFileTarget(target)) {
896
- blockStateFileWrite(target);
897
- }
898
1107
  const whitelist = PHASE_WRITE_WHITELIST[currentNode];
899
1108
  if (whitelist) {
900
1109
  const allowed = targetAllowed(target, whitelist, activeChange);
@@ -951,7 +1160,38 @@ async function main() {
951
1160
  console.log('NODE: ' + current);
952
1161
  }
953
1162
 
954
- main().catch((error) => {
955
- console.error(error.message);
956
- process.exit(1);
1163
+ main().catch(async (error) => {
1164
+ const detail = error && error.message ? error.message : String(error);
1165
+ // 兜底必须是**阻塞**而不是普通错误:宿主只把 exit 2 当拒绝,其余非零退出码会被降级成
1166
+ // 非阻断错误(实测:协议文件缺失时 exit 1 → 之后所有写入都不再被拦 = 整条防线关闭)。
1167
+ // 与既有"解析失败 / 未知状态 fail-closed"同向:无法判定就不放行。拒绝通道复用 hookBlock
1168
+ // (Codex = {"decision":"block"} + exit 0;CC = 文本 + exit 2)——否则 Codex 上仍会静默放行。
1169
+ //
1170
+ // 但**无写入语义的调用必须放行**:守卫在 main 的第一步就要读协议,读不到时连 ls / git status
1171
+ // 都被拒——而报文给出的恢复命令(prepare-env / workflow-state)本身也是 Bash 调用,会被同一条
1172
+ // 兜底再拒一次,恢复路径被自己堵死。判据与既有「未命中写入模式 = 无写入语义,放行」同源:
1173
+ // 拿不到写入目标就没有可判的对象,阻塞换不来安全性,只换来会话不可用。
1174
+ let hasWriteSemantics = false;
1175
+ try {
1176
+ const input = await readHookInput();
1177
+ if (input && typeof input === 'object') {
1178
+ if (input.tool_name === 'Bash') {
1179
+ const command = input.tool_input && typeof input.tool_input === 'object' ? input.tool_input.command : null;
1180
+ hasWriteSemantics = codexWriteTargetsFromCommand(command).length > 0;
1181
+ } else {
1182
+ hasWriteSemantics = toolFilePathFromHookInput(input) !== null;
1183
+ }
1184
+ }
1185
+ } catch {
1186
+ hasWriteSemantics = true; // 读不出来就按有写入语义处理(保守)
1187
+ }
1188
+ if (!hasWriteSemantics) {
1189
+ console.error('DEGRADED: 守卫无法完成判定(' + detail + ')——本次调用没有写入目标,放行;写入仍会被拦,直到协议/状态修好');
1190
+ hookOk('(guard degraded: no write target)');
1191
+ return;
1192
+ }
1193
+ hookBlock(
1194
+ 'BLOCKED: 守卫无法完成判定(' + detail + ')',
1195
+ '恢复: 确认本次运行使用的协议文件(技能包 reference/workflow-protocol.json,或 FLOW_COMET_PROTOCOL 指定的文件)与 .flow-comet/flow-comet-state.json 完好;必要时重跑安装器(prepare-env)修复技能副本,或用 workflow-state.mjs 修复状态。若恢复命令本身也被拒,先在 agent 会话之外的终端执行',
1196
+ );
957
1197
  });
@@ -10,6 +10,9 @@
10
10
  import { promises as fs } from 'fs';
11
11
  import path from 'path';
12
12
  import { EVOLVE_METADATA_SECTION, EVOLVE_METADATA_FIELDS } from './state-schema.mjs';
13
+ // 二级段体的段界(同级标题 / 分隔线 / 文末)取 lib/section-body.mjs 的唯一实现:本文件不再持有
14
+ // 第二份「按标题切段体」的行扫描(同一件事两份实现必然分叉)。
15
+ import { sectionBody } from './lib/section-body.mjs';
13
16
 
14
17
  // 既有 AI 上下文文档探测清单(与 flow-kit 入场判定同源:AGENTS/CLAUDE/Cursor/Windsurf/Copilot/Cline)
15
18
  const AI_DOC_CANDIDATES = [
@@ -174,15 +177,22 @@ async function contextSections(runRoot) {
174
177
  // 无任何生产者,故已从通过判据移除(取值单形 = state-schema 的 EVOLVE_METADATA_FIELDS)。本常量
175
178
  // 只用于**提示**:既有文档带该别名时,报错文案点名它并给出应写字段,让格式问题可见且可改写。
176
179
  const EVOLVE_DEPRECATED_SUGGESTION_FIELD = '下次同步建议';
180
+ // 「已锁决策」段名:在场判定与段内判定共用本常量(两处各写一份字面量,改名时必然分叉)。
181
+ const LOCKED_DECISIONS_SECTION = '已锁决策';
182
+
177
183
  // 模板关键格式检查(flow-kit/templates/CONTEXT.md 基准——段存在时校验其内格式,确定性检查)
178
184
  const CONTEXT_FORMAT_CHECKS = [
179
185
  {
180
186
  name: '已锁决策条目日期前缀',
181
- applies: (t) => t.includes('## 已锁决策'),
187
+ applies: (t) => t.includes('## ' + LOCKED_DECISIONS_SECTION),
182
188
  // 段内列表条目须带日期 `- [20xx-xx-xx]`;占位条目([xxx] 形态/待沉淀类/模板尖括号)放行——
183
- // 新项目骨架(无历史决策)不应被格式校验拒绝(DF-5)。
189
+ // 新项目骨架(无历史决策)不应被格式校验拒绝(DF-5)。段体经 contextSectionBody 切片:段界只由
190
+ // lib/section-body.mjs 决定(围栏内的标题不结束段体),本文件不再自带第二份「按标题切段」——
191
+ // 此前这里用字符串字面量切分(`.split('## 已锁决策')` 后再 `.split('\n##')`),是一份只在本文件
192
+ // 存在、且静态锁看不见的段体切片:同一个「这一段到哪里结束」由两处决定时,围栏 / 分隔线 / 段名
193
+ // 归一的差异迟早让两处给出不同答案。
184
194
  passes: (t) => {
185
- const seg = (t.split('## 已锁决策')[1] ?? '').split('\n##')[0];
195
+ const seg = contextSectionBody(t, LOCKED_DECISIONS_SECTION) ?? '';
186
196
  const items = seg.split('\n').filter((l) => /^\s*-\s+/.test(l));
187
197
  if (items.length === 0) return true; // 空段放行
188
198
  const bare = items.filter((l) => {
@@ -206,14 +216,14 @@ const CONTEXT_FORMAT_CHECKS = [
206
216
  // 「跑过一次但字段写残」正是最需要拦的半成品(段在场却少字段,元数据双落点会静默失真)。
207
217
  // 段名与三字段名都取自 state-schema.mjs 的单一常量集(写方 evolve.mjs 同源),本处不再写字面量。
208
218
  name: EVOLVE_METADATA_SECTION + '三字段',
209
- // 三字段判定**限定在段内**(sectionBody 切片):全文 includes 会被别处的同名字段蒙混过关——
210
- // 例如 intel-scan 段有 `**scanner**` 而 evolve 段少这一个字段,全文判定照样放行。
211
- applies: (t) => sectionBody(t, '## ' + EVOLVE_METADATA_SECTION) !== null,
219
+ // 三字段判定**限定在段内**(contextSectionBody 切片,段界来自单源):全文 includes 会被别处的同名字
220
+ // 字段蒙混过关——例如 intel-scan 段有 `**scanner**` 而 evolve 段少这一个字段,全文判定照样放行。
221
+ applies: (t) => contextSectionBody(t, EVOLVE_METADATA_SECTION) !== null,
212
222
  // 通过判据是**单形**的:取值只认常量集(写方真实产出的三个字段名)。旧的协作期容差别名
213
223
  // (`下次同步建议`)没有任何生产者,已从判据中移除——容纳它就是「校验集合 ⊃ 生产集合」,
214
224
  // 写残的段会被静默放行。带旧别名的既有文档由下方 hint 给出可见的改写指引,不是静默失败。
215
225
  passes: (t) => {
216
- const segment = sectionBody(t, '## ' + EVOLVE_METADATA_SECTION) ?? '';
226
+ const segment = contextSectionBody(t, EVOLVE_METADATA_SECTION) ?? '';
217
227
  return EVOLVE_METADATA_FIELDS.every((field) => segment.includes('**' + field + '**'));
218
228
  },
219
229
  hint: '字段 ' + EVOLVE_METADATA_FIELDS.join(' / ') + ';与 intel-scan 段同构'
@@ -301,23 +311,16 @@ function headingSet(text) {
301
311
  // `## evolve 元数据`)不得算段在场——可选段的「缺席不报」语义完全依赖这一点;字段判定限定段内,
302
312
  // 否则别处的同名标签会替缺失字段蒙混过关。必填段的同名检查沿用历史 includes 写法(缺段另有
303
313
  // missingSections 兜底,报道面不变),故两条检查的在场判据措辞不同是刻意的,不是漏改。
304
- function sectionBody(body, headingName) {
314
+ // 段界(同级标题 / 分隔线 / 文末)由 lib/section-body.mjs 单点决定,本文件只表达命中方式:恰好
315
+ // 二级 + 段名归一后相等。调用方给的是**结构文本**(围栏代码块已剥离,见 validateContext),因此围栏
316
+ // 里的书写样例既不结束段体、也不被当成数据。
317
+ function contextSectionBody(structureText, headingName) {
305
318
  const wanted = normalizeSectionName(headingName);
306
- const kept = [];
307
- let inSection = false;
308
- for (const line of String(body ?? '').split('\n')) {
309
- const heading = /^(#{1,6})[ \t]+(.+?)[ \t]*$/.exec(line);
310
- if (heading) {
311
- const level = heading[1].length;
312
- if (inSection && level <= 2) break; // 到下一个同级或更高级标题即段结束
313
- if (!inSection && level === 2 && normalizeSectionName(heading[2]) === wanted) {
314
- inSection = true;
315
- continue;
316
- }
317
- }
318
- if (inSection) kept.push(line);
319
- }
320
- return inSection ? kept.join('\n') : null;
319
+ return sectionBody(
320
+ structureText,
321
+ (heading) => heading.level === 2 && normalizeSectionName(heading.text) === wanted,
322
+ { level: 2, endOnSeparator: false },
323
+ );
321
324
  }
322
325
 
323
326
  // 校验 .specs/CONTEXT.md 7 段结构 + 模板关键格式;文件缺失 = 全缺。返回
@@ -19,9 +19,7 @@ import {
19
19
  } from './lib/test-helpers.mjs';
20
20
  import {
21
21
  BUILTIN_PROTOCOL_SOURCE,
22
- REPO_ROOT,
23
22
  createdDirs,
24
- isAuthoritativeSourceRepo,
25
23
  makeTmp,
26
24
  sleepSync,
27
25
  } from './lib/test-fixtures.mjs';
@@ -29,16 +27,7 @@ import {
29
27
  scenarioProtocolPath,
30
28
  } from './lib/test-assertions.mjs';
31
29
  import {
32
- PUBLIC_CODE_RE,
33
- SCENARIO_COUNT_FILES,
34
- SCENARIO_COUNT_FILES_MAINTAINER,
35
- SYSTEM_TEST_COUNT_FILES,
36
- SYSTEM_TEST_COUNT_FILES_MAINTAINER,
37
- countSyncProblems,
38
- internalDocsProblems,
39
- maintainerFacePresent,
40
- maintainerFaceSkips,
41
- vocabularyMirrorProblems,
30
+ publicFaceSelfCheck,
42
31
  } from './lib/text-anchor-checks.mjs';
43
32
 
44
33
  import { ENTRIES as SCENARIOS_A } from './scenarios/a.mjs';
@@ -103,89 +92,20 @@ for (const sc of SCENARIOS) {
103
92
 
104
93
  console.log('RESULT: ' + passed + '/' + SCENARIOS.length + ' scenarios passed');
105
94
 
106
- // 文档一致性自检(场景数纪律 + 公开产物零代号纪律工具化):
107
- // ① 场景数:受检清单文档须与 SCENARIOS.length 一致(全变体检查),且清单条目必须真实存在
108
- // (AC-14:缺失显式报告,不静默跳过);
109
- // ② 公开产物零代号:公开文档不得含过程代号(场景编号/修复编号/批次/缺陷编号/问题级/验证代号/验证轮次/未公开概念——历史 CHANGELOG 回归实证)。
110
- // 仅权威源检出执行;安装副本(目标项目)无 flow-comet 文档面,跳过。
111
- if (isAuthoritativeSourceRepo()) {
112
- // ①a 受检面可见化(F2 防漂移):实际受检文件数由模块级常量**推导**、不硬编码——分发组 =
113
- // SCENARIO_COUNT_FILES ∪ SYSTEM_TEST_COUNT_FILES(后者为前者子集),维护者组 =
114
- // SCENARIO_COUNT_FILES_MAINTAINER ∪ SYSTEM_TEST_COUNT_FILES_MAINTAINER(后者为前者子集);
115
- // 维护者面缺席(CI 全新检出 / worktree)时按组跳过语义只计分发面。本行是对外可复核的
116
- // 「覆盖面事实」——清单增删/口径漂移在此直接可见,不再依赖人工核对注释(F2 根因)。
117
- const distFaceCount = new Set([...SCENARIO_COUNT_FILES, ...SYSTEM_TEST_COUNT_FILES]).size;
118
- const maintainerFaceCount = maintainerFacePresent()
119
- ? new Set([...SCENARIO_COUNT_FILES_MAINTAINER, ...SYSTEM_TEST_COUNT_FILES_MAINTAINER]).size
120
- : 0;
121
- console.log('受检面: ' + (distFaceCount + maintainerFaceCount) + ' 文件(分发 ' + distFaceCount
122
- + ' + 维护者 ' + maintainerFaceCount + ')');
123
- // ① 计数一致性受检清单(分发组恒检 + 维护者组整组在场时检;判据与场景 105 共用同一实现)
124
- // SCENARIO_COUNT_FILES(_MAINTAINER) / SYSTEM_TEST_COUNT_FILES(_MAINTAINER) 为模块级常量
125
- // (见文件头定义)——场景数与系统测试集项数两套计数合并检查
126
- for (const problem of await countSyncProblems()) {
127
- failures.push({ name: '计数一致性', error: problem });
128
- console.error('FAIL: 计数一致性\n' + problem);
129
- }
130
-
131
- // ①b 维护文档机检(docs/internal 死引用 + ROADMAP 最低结构;整组缺席即跳过)
132
- for (const problem of internalDocsProblems()) {
133
- failures.push({ name: '维护文档机检', error: problem });
134
- console.error('FAIL: 维护文档机检\n' + problem);
135
- }
136
-
137
- // ①c 维护者面缺席可见化:结构性缺席(worktree / CI 全新检出)不判失败(退出码不变、不误红),
138
- // 但必须可见——逐面输出 SKIP 行(面名 + 原因 + 本检出未执行什么校验 + 回维护者主树重跑的指引)。
139
- for (const skip of maintainerFaceSkips()) {
140
- console.log('SKIP: ' + skip.face + ' — ' + skip.reason
141
- + ';本次检出未执行该面校验,请在维护者主树重跑本套件(主树 L1),勿把跳过当成已校验。');
142
- }
143
-
144
- // ② 公开文档零代号(公开产物纪律——变更日志历史编号回归的教训)
145
- const PUBLIC_DOCS = [
146
- 'README.md', 'README-zh.md', 'CONTRIBUTING.md', 'CONTRIBUTING-zh.md',
147
- 'SECURITY.md', 'SECURITY-zh.md', 'CODE_OF_CONDUCT.md', 'CODE_OF_CONDUCT-zh.md',
148
- 'CHANGELOG.md', 'CHANGELOG-zh.md',
149
- 'docs/INSTALLATION.md', 'docs/INSTALLATION-zh.md', 'docs/MECHANISM.md', 'docs/MECHANISM-zh.md',
150
- 'docs/USAGE.md', 'docs/USAGE-zh.md',
151
- 'docs/TROUBLESHOOTING.md', 'docs/TROUBLESHOOTING-zh.md', 'docs/VERSIONS.md', 'docs/VERSIONS-zh.md',
152
- '.github/PULL_REQUEST_TEMPLATE.md',
153
- '.github/ISSUE_TEMPLATE/1-bug_report.yml', '.github/ISSUE_TEMPLATE/2-feature_request.yml',
154
- '.github/ISSUE_TEMPLATE/3-question.md', '.github/ISSUE_TEMPLATE/4-task.md',
155
- ];
156
- // 词表判据 = 模块级 PUBLIC_CODE_RE(与 .githooks/internal-codes.mjs 的 BANNED 同判据,
157
- // 见其定义处的同步约定;维护文档机检场景族另有该判据的判别力/边界锚)。
158
- for (const rel of PUBLIC_DOCS) {
159
- let text;
160
- try {
161
- text = fs.readFileSync(path.join(REPO_ROOT, rel), 'utf8');
162
- } catch (e) {
163
- // ENOENT 同样显式报告:本清单全部为随仓库分发的文件,任何权威源检出都应存在——
164
- // 静默跳过会让"永不生效的条目"藏身(同类 AC-14 缺陷)。
165
- failures.push({ name: '公开产物零代号(' + rel + ')', error: '文件缺失: ' + e.message });
166
- console.error('FAIL: 公开产物零代号(' + rel + ')\n文件缺失: ' + e.message);
167
- continue;
168
- }
169
- const m = text.match(PUBLIC_CODE_RE);
170
- if (m) {
171
- failures.push({ name: '公开产物零代号(' + rel + ')', error: rel + ' 含过程代号: "' + m[0] + '"' });
172
- console.error('FAIL: 公开产物零代号(' + rel + ')\n' + rel + ' 含过程代号: "' + m[0] + '"');
173
- }
174
- }
175
-
176
- // ③ 词表镜像漂移:主仓私有的词表单一来源与套件内的同义镜像必须**逐字符
177
- // 等价**——两侧此前只有注释互指"同步"、零一致性判据:主仓增补模式时分发侧扫描静默落后
178
- // (新词可在公开面长期存活而套件全绿),反向则分发面误红。判据只读文件、不改任何判定语义。
179
- for (const problem of vocabularyMirrorProblems()) {
180
- failures.push({ name: '词表镜像漂移', error: problem });
181
- console.error('FAIL: 词表镜像漂移\n' + problem);
182
- }
95
+ // 文档一致性自检(场景数纪律 + 公开产物零代号纪律工具化):形态分派(权威源检出 / 包形态 / 安装
96
+ // 副本)与四条判据(计数一致性 / 维护文档机检 / 公开产物零代号 / 词表镜像)的唯一实现在
97
+ // lib/text-anchor-checks.mjs 的 publicFaceSelfCheck——本处只负责调用与打印。该判定接受任意根,
98
+ // 故它另有常驻场景锚(公开面形态分派探针),不必等到在包形态里整跑一次才知道分派对不对。
99
+ const selfCheck = await publicFaceSelfCheck();
100
+ if (selfCheck.skip !== null) {
101
+ // 该形态不含这一面:仍然显式可见——SKIP = 未校验,不是通过。
102
+ console.log(selfCheck.skip.notice);
183
103
  } else {
184
- // 安装副本形态:.githooks 是主仓私有面(随 clone 不分发)→ 该判据**不适用**。结构性缺席
185
- // 不判失败(退出码不变、不误红),但必须显式可见——未验证 ≠ 通过,不得静默跳过。
186
- console.log('SKIP/NOT-APPLICABLE: 词表镜像漂移判据(.githooks 为主仓私有面)'
187
- + ';本次检出无该私有面,未执行「词表单一来源 ↔ 套件同义镜像」的逐字符等价性比对'
188
- + '——请在主仓私有面在场处重跑本套件(主树 L1),勿把不适用当成已校验。');
104
+ for (const notice of selfCheck.notices) console.log(notice);
105
+ for (const problem of selfCheck.problems) {
106
+ failures.push(problem);
107
+ console.error('FAIL: ' + problem.name + '\n' + problem.error);
108
+ }
189
109
  }
190
110
 
191
111
  // 清理验证:自测套件自身创建的临时目录不留残留