@gate-forge/cli 0.7.1 → 0.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 (254) hide show
  1. package/README.md +499 -47
  2. package/dist/adapter-audit.d.ts +154 -0
  3. package/dist/adapter-audit.d.ts.map +1 -0
  4. package/dist/adapter-audit.js +531 -0
  5. package/dist/adapter-audit.js.map +1 -0
  6. package/dist/adapter-scaffold.d.ts +66 -0
  7. package/dist/adapter-scaffold.d.ts.map +1 -0
  8. package/dist/adapter-scaffold.js +353 -0
  9. package/dist/adapter-scaffold.js.map +1 -0
  10. package/dist/adopted-baseline.d.ts +10 -0
  11. package/dist/adopted-baseline.d.ts.map +1 -1
  12. package/dist/adopted-baseline.js +18 -1
  13. package/dist/adopted-baseline.js.map +1 -1
  14. package/dist/args.d.ts +15 -0
  15. package/dist/args.d.ts.map +1 -1
  16. package/dist/args.js +59 -2
  17. package/dist/args.js.map +1 -1
  18. package/dist/behavior-setup.d.ts +239 -0
  19. package/dist/behavior-setup.d.ts.map +1 -0
  20. package/dist/behavior-setup.js +738 -0
  21. package/dist/behavior-setup.js.map +1 -0
  22. package/dist/broker.d.ts.map +1 -1
  23. package/dist/broker.js +28 -2
  24. package/dist/broker.js.map +1 -1
  25. package/dist/cache-exclusions.d.ts +45 -0
  26. package/dist/cache-exclusions.d.ts.map +1 -0
  27. package/dist/cache-exclusions.js +205 -0
  28. package/dist/cache-exclusions.js.map +1 -0
  29. package/dist/candidate-tree.d.ts +86 -14
  30. package/dist/candidate-tree.d.ts.map +1 -1
  31. package/dist/candidate-tree.js +236 -62
  32. package/dist/candidate-tree.js.map +1 -1
  33. package/dist/ci-witnessed-template.d.ts +43 -0
  34. package/dist/ci-witnessed-template.d.ts.map +1 -0
  35. package/dist/ci-witnessed-template.js +283 -0
  36. package/dist/ci-witnessed-template.js.map +1 -0
  37. package/dist/cli.d.ts +1 -1
  38. package/dist/cli.d.ts.map +1 -1
  39. package/dist/cli.js +31 -4
  40. package/dist/cli.js.map +1 -1
  41. package/dist/commands/adapters.d.ts +15 -0
  42. package/dist/commands/adapters.d.ts.map +1 -0
  43. package/dist/commands/adapters.js +284 -0
  44. package/dist/commands/adapters.js.map +1 -0
  45. package/dist/commands/adopt.d.ts.map +1 -1
  46. package/dist/commands/adopt.js +9 -1
  47. package/dist/commands/adopt.js.map +1 -1
  48. package/dist/commands/baseline.d.ts.map +1 -1
  49. package/dist/commands/baseline.js +42 -1
  50. package/dist/commands/baseline.js.map +1 -1
  51. package/dist/commands/blocking.d.ts +81 -2
  52. package/dist/commands/blocking.d.ts.map +1 -1
  53. package/dist/commands/blocking.js +336 -53
  54. package/dist/commands/blocking.js.map +1 -1
  55. package/dist/commands/check.d.ts +36 -0
  56. package/dist/commands/check.d.ts.map +1 -1
  57. package/dist/commands/check.js +1008 -62
  58. package/dist/commands/check.js.map +1 -1
  59. package/dist/commands/classify.d.ts +2 -1
  60. package/dist/commands/classify.d.ts.map +1 -1
  61. package/dist/commands/classify.js +143 -5
  62. package/dist/commands/classify.js.map +1 -1
  63. package/dist/commands/enforce.d.ts +4 -4
  64. package/dist/commands/enforce.d.ts.map +1 -1
  65. package/dist/commands/enforce.js +41 -9
  66. package/dist/commands/enforce.js.map +1 -1
  67. package/dist/commands/enforcement.d.ts +13 -1
  68. package/dist/commands/enforcement.d.ts.map +1 -1
  69. package/dist/commands/enforcement.js +800 -30
  70. package/dist/commands/enforcement.js.map +1 -1
  71. package/dist/commands/history.d.ts +12 -0
  72. package/dist/commands/history.d.ts.map +1 -0
  73. package/dist/commands/history.js +45 -0
  74. package/dist/commands/history.js.map +1 -0
  75. package/dist/commands/init-presets.d.ts +148 -0
  76. package/dist/commands/init-presets.d.ts.map +1 -0
  77. package/dist/commands/init-presets.js +194 -0
  78. package/dist/commands/init-presets.js.map +1 -0
  79. package/dist/commands/init.d.ts +7 -12
  80. package/dist/commands/init.d.ts.map +1 -1
  81. package/dist/commands/init.js +610 -69
  82. package/dist/commands/init.js.map +1 -1
  83. package/dist/commands/keys.d.ts.map +1 -1
  84. package/dist/commands/keys.js +29 -13
  85. package/dist/commands/keys.js.map +1 -1
  86. package/dist/commands/next.d.ts.map +1 -1
  87. package/dist/commands/next.js +744 -15
  88. package/dist/commands/next.js.map +1 -1
  89. package/dist/commands/pre-commit.d.ts +25 -0
  90. package/dist/commands/pre-commit.d.ts.map +1 -1
  91. package/dist/commands/pre-commit.js +91 -6
  92. package/dist/commands/pre-commit.js.map +1 -1
  93. package/dist/commands/quarantine.d.ts +16 -0
  94. package/dist/commands/quarantine.d.ts.map +1 -0
  95. package/dist/commands/quarantine.js +213 -0
  96. package/dist/commands/quarantine.js.map +1 -0
  97. package/dist/commands/run.d.ts +39 -0
  98. package/dist/commands/run.d.ts.map +1 -0
  99. package/dist/commands/run.js +196 -0
  100. package/dist/commands/run.js.map +1 -0
  101. package/dist/commands/test-gates.d.ts +284 -2
  102. package/dist/commands/test-gates.d.ts.map +1 -1
  103. package/dist/commands/test-gates.js +3619 -186
  104. package/dist/commands/test-gates.js.map +1 -1
  105. package/dist/commands/tests.d.ts +1 -1
  106. package/dist/commands/tests.d.ts.map +1 -1
  107. package/dist/commands/tests.js +225 -22
  108. package/dist/commands/tests.js.map +1 -1
  109. package/dist/endpoint-compiler.d.ts.map +1 -1
  110. package/dist/endpoint-compiler.js +29 -8
  111. package/dist/endpoint-compiler.js.map +1 -1
  112. package/dist/engine-browser.d.ts +183 -0
  113. package/dist/engine-browser.d.ts.map +1 -0
  114. package/dist/engine-browser.js +381 -0
  115. package/dist/engine-browser.js.map +1 -0
  116. package/dist/engine-identity.d.ts +100 -0
  117. package/dist/engine-identity.d.ts.map +1 -0
  118. package/dist/engine-identity.js +182 -0
  119. package/dist/engine-identity.js.map +1 -0
  120. package/dist/evaluate.d.ts +89 -0
  121. package/dist/evaluate.d.ts.map +1 -1
  122. package/dist/evaluate.js +137 -16
  123. package/dist/evaluate.js.map +1 -1
  124. package/dist/execution.d.ts +253 -9
  125. package/dist/execution.d.ts.map +1 -1
  126. package/dist/execution.js +309 -12
  127. package/dist/execution.js.map +1 -1
  128. package/dist/git-hooks.d.ts +17 -0
  129. package/dist/git-hooks.d.ts.map +1 -1
  130. package/dist/git-hooks.js +119 -0
  131. package/dist/git-hooks.js.map +1 -1
  132. package/dist/git-objects.d.ts +60 -0
  133. package/dist/git-objects.d.ts.map +1 -0
  134. package/dist/git-objects.js +152 -0
  135. package/dist/git-objects.js.map +1 -0
  136. package/dist/history.d.ts +52 -0
  137. package/dist/history.d.ts.map +1 -0
  138. package/dist/history.js +116 -0
  139. package/dist/history.js.map +1 -0
  140. package/dist/host-load.d.ts +49 -0
  141. package/dist/host-load.d.ts.map +1 -0
  142. package/dist/host-load.js +78 -0
  143. package/dist/host-load.js.map +1 -0
  144. package/dist/input-snapshot.d.ts +63 -9
  145. package/dist/input-snapshot.d.ts.map +1 -1
  146. package/dist/input-snapshot.js +195 -17
  147. package/dist/input-snapshot.js.map +1 -1
  148. package/dist/io.d.ts +36 -0
  149. package/dist/io.d.ts.map +1 -1
  150. package/dist/io.js +21 -0
  151. package/dist/io.js.map +1 -1
  152. package/dist/mapping.d.ts +84 -1
  153. package/dist/mapping.d.ts.map +1 -1
  154. package/dist/mapping.js +276 -5
  155. package/dist/mapping.js.map +1 -1
  156. package/dist/native-freeze.d.ts +217 -0
  157. package/dist/native-freeze.d.ts.map +1 -0
  158. package/dist/native-freeze.js +332 -0
  159. package/dist/native-freeze.js.map +1 -0
  160. package/dist/pipeline.d.ts +52 -1
  161. package/dist/pipeline.d.ts.map +1 -1
  162. package/dist/pipeline.js +141 -3
  163. package/dist/pipeline.js.map +1 -1
  164. package/dist/playwright-browsers.d.ts +210 -0
  165. package/dist/playwright-browsers.d.ts.map +1 -0
  166. package/dist/playwright-browsers.js +364 -0
  167. package/dist/playwright-browsers.js.map +1 -0
  168. package/dist/plugins.d.ts +15 -5
  169. package/dist/plugins.d.ts.map +1 -1
  170. package/dist/plugins.js +59 -9
  171. package/dist/plugins.js.map +1 -1
  172. package/dist/progress.d.ts +148 -0
  173. package/dist/progress.d.ts.map +1 -0
  174. package/dist/progress.js +263 -0
  175. package/dist/progress.js.map +1 -0
  176. package/dist/providers.d.ts +26 -1
  177. package/dist/providers.d.ts.map +1 -1
  178. package/dist/providers.js +39 -0
  179. package/dist/providers.js.map +1 -1
  180. package/dist/receipts.d.ts +1 -0
  181. package/dist/receipts.d.ts.map +1 -1
  182. package/dist/receipts.js +35 -7
  183. package/dist/receipts.js.map +1 -1
  184. package/dist/repo-scan.d.ts +8 -1
  185. package/dist/repo-scan.d.ts.map +1 -1
  186. package/dist/repo-scan.js +221 -27
  187. package/dist/repo-scan.js.map +1 -1
  188. package/dist/reseal-chain.d.ts +184 -0
  189. package/dist/reseal-chain.d.ts.map +1 -0
  190. package/dist/reseal-chain.js +735 -0
  191. package/dist/reseal-chain.js.map +1 -0
  192. package/dist/reseal-evidence.d.ts +241 -0
  193. package/dist/reseal-evidence.d.ts.map +1 -0
  194. package/dist/reseal-evidence.js +319 -0
  195. package/dist/reseal-evidence.js.map +1 -0
  196. package/dist/reseal.d.ts +181 -0
  197. package/dist/reseal.d.ts.map +1 -0
  198. package/dist/reseal.js +1620 -0
  199. package/dist/reseal.js.map +1 -0
  200. package/dist/response-field-guidance.d.ts +82 -0
  201. package/dist/response-field-guidance.d.ts.map +1 -0
  202. package/dist/response-field-guidance.js +184 -0
  203. package/dist/response-field-guidance.js.map +1 -0
  204. package/dist/run-cache.d.ts +260 -0
  205. package/dist/run-cache.d.ts.map +1 -0
  206. package/dist/run-cache.js +771 -0
  207. package/dist/run-cache.js.map +1 -0
  208. package/dist/run-preflight.d.ts +77 -0
  209. package/dist/run-preflight.d.ts.map +1 -0
  210. package/dist/run-preflight.js +774 -0
  211. package/dist/run-preflight.js.map +1 -0
  212. package/dist/run-recipe.d.ts +107 -0
  213. package/dist/run-recipe.d.ts.map +1 -0
  214. package/dist/run-recipe.js +295 -0
  215. package/dist/run-recipe.js.map +1 -0
  216. package/dist/run-reliability.d.ts +126 -0
  217. package/dist/run-reliability.d.ts.map +1 -0
  218. package/dist/run-reliability.js +221 -0
  219. package/dist/run-reliability.js.map +1 -0
  220. package/dist/runtime.d.ts +15 -0
  221. package/dist/runtime.d.ts.map +1 -1
  222. package/dist/runtime.js +11 -1
  223. package/dist/runtime.js.map +1 -1
  224. package/dist/secret-guard.d.ts +36 -0
  225. package/dist/secret-guard.d.ts.map +1 -0
  226. package/dist/secret-guard.js +63 -0
  227. package/dist/secret-guard.js.map +1 -0
  228. package/dist/singleton-guidance.d.ts +73 -0
  229. package/dist/singleton-guidance.d.ts.map +1 -0
  230. package/dist/singleton-guidance.js +118 -0
  231. package/dist/singleton-guidance.js.map +1 -0
  232. package/dist/staged-candidate.d.ts +17 -0
  233. package/dist/staged-candidate.d.ts.map +1 -1
  234. package/dist/staged-candidate.js +50 -0
  235. package/dist/staged-candidate.js.map +1 -1
  236. package/dist/state-artifacts.d.ts +70 -0
  237. package/dist/state-artifacts.d.ts.map +1 -0
  238. package/dist/state-artifacts.js +215 -0
  239. package/dist/state-artifacts.js.map +1 -0
  240. package/dist/state.d.ts +170 -2
  241. package/dist/state.d.ts.map +1 -1
  242. package/dist/state.js +248 -8
  243. package/dist/state.js.map +1 -1
  244. package/dist/verifier-keys.d.ts +33 -2
  245. package/dist/verifier-keys.d.ts.map +1 -1
  246. package/dist/verifier-keys.js +95 -9
  247. package/dist/verifier-keys.js.map +1 -1
  248. package/guides/CONNECT-YOUR-PROJECT.md +367 -0
  249. package/guides/QUICKSTART.md +259 -24
  250. package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
  251. package/guides/TEST-ENVIRONMENT.md +1041 -6
  252. package/guides/UPGRADE-0.6-to-0.7.md +3 -3
  253. package/guides/UPGRADE-0.7-to-0.8.md +114 -0
  254. package/package.json +10 -9
@@ -0,0 +1,78 @@
1
+ import { mkdirSync, statfsSync, writeFileSync } from 'node:fs';
2
+ import { cpus, loadavg } from 'node:os';
3
+ import { join } from 'node:path';
4
+ /**
5
+ * Adds a diagnostic note for failed tests whose nearest prior sample is high load.
6
+ *
7
+ * Args:
8
+ * samples: timestamped host load measurements for the supervised run.
9
+ * tests: timestamped runner outcomes from the same run.
10
+ *
11
+ * Returns:
12
+ * string[]: high-load notes for failed tests only.
13
+ */
14
+ export function hostLoadFailureNotices(samples, tests) {
15
+ return tests.flatMap((test) => {
16
+ if (test.status !== 'failed' && test.status !== 'timedOut')
17
+ return [];
18
+ const failedAt = Date.parse(test.finishedAt);
19
+ const sample = samples
20
+ .filter((candidate) => Date.parse(candidate.timestamp) <= failedAt)
21
+ .sort((left, right) => Date.parse(right.timestamp) - Date.parse(left.timestamp))[0];
22
+ if (sample === undefined)
23
+ return [];
24
+ const load = sample.loadAverage[0] ?? 0;
25
+ if (load <= sample.cpuCount * 1.5)
26
+ return [];
27
+ return [`${test.file} > ${test.titlePath.join(' > ')}: load ${load.toFixed(1)} on ${sample.cpuCount} CPUs`];
28
+ });
29
+ }
30
+ /** Reads load averages, CPU count, and free space for the state directory's filesystem.
31
+ *
32
+ * Args:
33
+ * stateDir: run-state directory used to select the filesystem.
34
+ * timestamp: sample timestamp, defaulting to the current time.
35
+ *
36
+ * Returns:
37
+ * HostLoadSample: point-in-time host diagnostics.
38
+ */
39
+ export function sampleHostLoad(stateDir, timestamp = new Date().toISOString()) {
40
+ const disk = statfsSync(stateDir);
41
+ const totalDiskBytes = Number(disk.blocks) * Number(disk.bsize);
42
+ const freeDiskBytes = Number(disk.bavail) * Number(disk.bsize);
43
+ return {
44
+ timestamp,
45
+ loadAverage: loadavg(),
46
+ cpuCount: cpus().length,
47
+ freeDiskBytes,
48
+ totalDiskBytes,
49
+ freeDiskPercent: totalDiskBytes === 0 ? 0 : (freeDiskBytes / totalDiskBytes) * 100,
50
+ };
51
+ }
52
+ /** Collects host samples at run start, every thirty seconds, and at stop.
53
+ *
54
+ * Args:
55
+ * stateDir: run-state directory where diagnostics are written.
56
+ * onWarning: optional callback for low-disk warnings.
57
+ *
58
+ * Returns:
59
+ * { stop }: finalizes the JSON artifact and stops the sampling timer.
60
+ */
61
+ export function startHostLoadSampler(stateDir, onWarning = () => undefined) {
62
+ const samples = [sampleHostLoad(stateDir)];
63
+ if (samples[0].freeDiskPercent < 5)
64
+ onWarning(`free disk space is ${samples[0].freeDiskPercent.toFixed(1)}%`);
65
+ const timer = setInterval(() => samples.push(sampleHostLoad(stateDir)), 30_000);
66
+ timer.unref();
67
+ return {
68
+ stop: () => {
69
+ clearInterval(timer);
70
+ samples.push(sampleHostLoad(stateDir));
71
+ const directory = join(stateDir, 'diagnostics');
72
+ mkdirSync(directory, { recursive: true });
73
+ writeFileSync(join(directory, 'host-load.json'), `${JSON.stringify({ samples }, null, 2)}\n`, 'utf8');
74
+ return samples;
75
+ },
76
+ };
77
+ }
78
+ //# sourceMappingURL=host-load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-load.js","sourceRoot":"","sources":["../src/host-load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmBjC;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAkC,EAClC,KAAoC;IAEpC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU;YAAE,OAAO,EAAE,CAAC;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO;aACnB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAA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AC,CAAC,CAAC,CAAC,aAAa,GAAG,cAAc,CAAC,GAAG,GAAG;KACnF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,YAAuC,GAAG,EAAE,CAAC,SAAS;IAEtD,MAAM,OAAO,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3C,IAAI,OAAO,CAAC,CAAC,CAAE,CAAC,eAAe,GAAG,CAAC;QAAE,SAAS,CAAC,sBAAsB,OAAO,CAAC,CAAC,CAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAChH,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChF,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,OAAO;QACL,IAAI,EAAE,GAAG,EAAE;YACT,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAChD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1C,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtG,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -50,10 +50,12 @@ export declare const MANIFEST_NAMES: string[];
50
50
  */
51
51
  export declare const GIT_SCOPE_CONTROL_BASENAMES: string[];
52
52
  /**
53
- * The input tree cannot be captured completely (submodule, escaping or
54
- * unresolvable symlink, unreadable required input). Evaluation must fail
55
- * closed with an explicit unsupported-snapshot block — never a partial
56
- * digest claimed complete.
53
+ * The input tree cannot be captured completely (submodule, escaping
54
+ * symlink, unreadable required input). Evaluation must fail closed with
55
+ * an explicit unsupported-snapshot block — never a partial digest
56
+ * claimed complete. A symlink that is merely DANGLING, or whose target
57
+ * is a DIRECTORY, is not one of these: it is captured by its link text
58
+ * as a `dangling-symlink` / `directory-symlink` entry.
57
59
  */
58
60
  export declare class UnsupportedSnapshotError extends Error {
59
61
  constructor(message: string);
@@ -70,10 +72,12 @@ export declare class SnapshotUnavailableError extends Error {
70
72
  export interface SnapshotFileEntry {
71
73
  /** Repo-root-relative posix path (or config-relative label for absence). */
72
74
  path: string;
73
- /** `file` = regular bytes, `symlink` = link+target bytes, `absent` = missing optional config, `deleted` = tracked but gone. */
74
- type: 'file' | 'symlink' | 'absent' | 'deleted';
75
+ /** `file` = regular bytes, `symlink` = link+target bytes, `dangling-symlink` = link text of a link whose target does not exist, `directory-symlink` = link text of a link to a directory, `absent` = missing optional config, `deleted` = tracked but gone. */
76
+ type: 'file' | 'symlink' | 'dangling-symlink' | 'directory-symlink' | 'absent' | 'deleted';
75
77
  /** Hex digest binding path + type + content (or absence marker). */
76
78
  contentDigest: string;
79
+ /** The raw link text of a symlink entry (never resolved). */
80
+ linkTarget?: string;
77
81
  }
78
82
  /** Canonical gate context hashed alongside the file inventory. */
79
83
  export interface SnapshotGateContext {
@@ -135,6 +139,8 @@ export interface ComputeSnapshotInput {
135
139
  runtimeReuseMounts?: readonly RuntimeReuseMount[];
136
140
  /** Owner-declared documentation folders approved by the external policy pin. */
137
141
  docsExclusions?: readonly string[];
142
+ /** Exact owner-approved Python bytecode files approved by the external policy pin. */
143
+ cacheExclusions?: readonly string[];
138
144
  }
139
145
  /**
140
146
  * Normalizes a repo-local in-process plugin module specifier to a
@@ -149,6 +155,25 @@ export interface ComputeSnapshotInput {
149
155
  * the repository root via `..`.
150
156
  */
151
157
  export declare function normalizeRepoModule(module: string): string | null;
158
+ /**
159
+ * Expands a configured Alembic versions directory into its migration files.
160
+ *
161
+ * The chain config names a DIRECTORY; the snapshot digests files, so the
162
+ * directory is walked and every file below it is declared instead.
163
+ * Python bytecode (`__pycache__/`, `*.pyc`, `*.pyo`) is skipped: Alembic
164
+ * writes it whenever it imports the migrations, so it would change the
165
+ * input identity without any source change. A missing or unreadable
166
+ * directory contributes nothing here — the compiler reports the broken
167
+ * chain itself.
168
+ *
169
+ * Args:
170
+ * cwd: absolute repo root.
171
+ * directory: repo-relative versions directory.
172
+ *
173
+ * Returns:
174
+ * string[]: repo-relative posix file paths, codepoint-sorted.
175
+ */
176
+ export declare function migrationInputFiles(cwd: string, directory: string): string[];
152
177
  /**
153
178
  * Collects the DECLARED source/configuration inputs: configured scan
154
179
  * inputs (even gitignored) + explicit config/adapter/waiver/plugin/
@@ -171,6 +196,11 @@ export declare function collectDeclaredInputs(cwd: string, config: GateforgeConf
171
196
  * digest) is a hole, not an exclusion. Also rejects the state directory
172
197
  * aliasing the repo root itself (including through a symlink).
173
198
  *
199
+ * The ENGINE's own generated state is not a hole and is exempted through
200
+ * the closed-world set in `./state-artifacts.ts`: a tracked file under
201
+ * `--out` still refuses above, and any other path there still refuses
202
+ * here.
203
+ *
174
204
  * Args:
175
205
  * cwd: absolute repo root.
176
206
  * stateDir: absolute run-state directory.
@@ -215,8 +245,8 @@ export declare function digestSnapshot(files: readonly SnapshotFileEntry[], gate
215
245
  * entries, canonical context, and digest.
216
246
  *
217
247
  * Args:
218
- * input: cwd, config, stateDir, and (post-discovery) classifications,
219
- * obligations, httpRoutes, and pinned plugins.
248
+ * input: repository root, config, run state, optional post-discovery
249
+ * classification context, and approved documentation/cache exclusions.
220
250
  *
221
251
  * Returns:
222
252
  * InputSnapshot: full inventory, gate context, verifier format, and
@@ -238,11 +268,19 @@ export declare function computeInputSnapshot(input: ComputeSnapshotInput): Input
238
268
  * cwd: absolute repo root.
239
269
  * config: validated `.gateforge.yml`.
240
270
  * stateDir: absolute run-state directory.
271
+ * runtimeReuseMounts: externally prepared dependencies bound by digest.
272
+ * docsExclusions: owner-approved documentation folders to omit.
273
+ * cacheExclusions: exact owner-approved Python bytecode files to omit.
241
274
  *
242
275
  * Returns:
243
276
  * SnapshotFileEntry[]: sorted file entries (overlap-checked).
277
+ *
278
+ * Throws:
279
+ * UsageError: an exclusion overlaps run state or a configured input.
280
+ * SnapshotUnavailableError: no usable Git inventory.
281
+ * UnsupportedSnapshotError: a required file cannot be captured.
244
282
  */
245
- export declare function collectInputFiles(cwd: string, config: GateforgeConfig, stateDir: string, runtimeReuseMounts?: readonly RuntimeReuseMount[], docsExclusions?: readonly string[]): SnapshotFileEntry[];
283
+ export declare function collectInputFiles(cwd: string, config: GateforgeConfig, stateDir: string, runtimeReuseMounts?: readonly RuntimeReuseMount[], docsExclusions?: readonly string[], cacheExclusions?: readonly string[]): SnapshotFileEntry[];
246
284
  /**
247
285
  * Compares two file inventories for the discovery-stability check.
248
286
  *
@@ -254,4 +292,20 @@ export declare function collectInputFiles(cwd: string, config: GateforgeConfig,
254
292
  * string[]: human-readable differences (empty when stable).
255
293
  */
256
294
  export declare function diffInputFiles(before: readonly SnapshotFileEntry[], after: readonly SnapshotFileEntry[]): string[];
295
+ /**
296
+ * One plain notice line per symlink captured by link text only.
297
+ *
298
+ * A dangling link or a link to a directory is captured, not fatal, so
299
+ * the run must still say what it saw: each line names the link and its
300
+ * target, and says whether an action is needed. A dangling link needs
301
+ * one (the project's own bootstrap, or drop the link); a directory link
302
+ * needs none — it works as it stands and nothing was read through it.
303
+ *
304
+ * Args:
305
+ * files: the captured file entries.
306
+ * Returns:
307
+ * string[]: one notice line per link captured by text, in path order
308
+ * (empty when every link resolves to a regular file).
309
+ */
310
+ export declare function symlinkNotices(files: readonly SnapshotFileEntry[]): string[];
257
311
  //# sourceMappingURL=input-snapshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-snapshot.d.ts","s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,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAG3C,EACH,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAC7C,WAAW,GAAE,SAAS,UAAU,EAAO,EACvC,UAAU,GAAE,SAAS,kBAAkB,EAAO,EAC9C,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,mBAAmB,CAmCrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,EAAE,WAAW,EAAE,mBAAmB,GAAG,MAAM,CAW5G;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,aAAa,CA0B/E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,GAAE,SAAS,iBAAiB,EAAO,EACrD,cAAc,GAAE,SAAS,MAAM,EAAO,EACtC,eAAe,GAAE,SAAS,MAAM,EAAO,GACtC,iBAAiB,EAAE,CAyDrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,EAAE,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAgBlH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAiB5E"}
@@ -22,9 +22,13 @@
22
22
  *
23
23
  * File identity is bytes + path + type: a deleted tracked file changes
24
24
  * the digest (explicit `deleted` entry). Symlink identity is preserved
25
- * (link target string plus target bytes); links escaping the repository,
26
- * unresolvable links, directory links, and submodules cannot be captured
27
- * and fail closed with {@link UnsupportedSnapshotError} — never a silent
25
+ * (link target string plus target bytes). A DANGLING symlink — one
26
+ * whose target does not exist, e.g. a checked-in link into a
27
+ * not-yet-created virtualenv — is recorded the way git records it: as
28
+ * a `dangling-symlink` entry bound to its link text alone, never
29
+ * followed and never read, so the run continues. Links escaping the
30
+ * repository, directory links, and submodules cannot be captured and
31
+ * fail closed with {@link UnsupportedSnapshotError} — never a silent
28
32
  * omission. Only the actual resolved run-state directory (`--out`) is
29
33
  * excluded from the evidence digest; `.git` internals, absolute paths,
30
34
  * timestamps, run tokens, and verifier keys never enter it. There is no
@@ -42,6 +46,7 @@ import { dirname, join, relative, resolve, sep } from 'node:path';
42
46
  import { compareStrings, sha256Canonical, } from '@gate-forge/core';
43
47
  import { UsageError } from './errors.js';
44
48
  import { expandIncludePaths } from './glob.js';
49
+ import { isEngineGeneratedStatePath } from './state-artifacts.js';
45
50
  import { isRuntimeReusePath, RuntimeReuseBoundaryError, validateRuntimeReuseMounts, } from './runtime-reuse.js';
46
51
  /** Snapshot format version hashed into every digest. */
47
52
  export const INPUT_SNAPSHOT_VERSION = 3;
@@ -118,10 +123,12 @@ export const MANIFEST_NAMES = [
118
123
  */
119
124
  export const GIT_SCOPE_CONTROL_BASENAMES = ['.gitignore', '.gitattributes'];
120
125
  /**
121
- * The input tree cannot be captured completely (submodule, escaping or
122
- * unresolvable symlink, unreadable required input). Evaluation must fail
123
- * closed with an explicit unsupported-snapshot block — never a partial
124
- * digest claimed complete.
126
+ * The input tree cannot be captured completely (submodule, escaping
127
+ * symlink, unreadable required input). Evaluation must fail closed with
128
+ * an explicit unsupported-snapshot block — never a partial digest
129
+ * claimed complete. A symlink that is merely DANGLING, or whose target
130
+ * is a DIRECTORY, is not one of these: it is captured by its link text
131
+ * as a `dangling-symlink` / `directory-symlink` entry.
125
132
  */
126
133
  export class UnsupportedSnapshotError extends Error {
127
134
  constructor(message) {
@@ -223,9 +230,11 @@ function hashEntry(kind, path, content) {
223
230
  * SnapshotFileEntry: the file, symlink, or deleted entry.
224
231
  *
225
232
  * Throws:
226
- * UnsupportedSnapshotError: escaping/unresolvable/directory symlink,
227
- * or a non-ENOENT filesystem failure (fail closed — required inputs
228
- * must not silently vanish).
233
+ * UnsupportedSnapshotError: an escaping symlink, a link to something
234
+ * that is neither a file nor a directory (fifo, socket, device), or a
235
+ * non-ENOENT filesystem failure (fail closed — required inputs must
236
+ * not silently vanish). A dangling link and a link to a directory are
237
+ * captured by their link text instead.
229
238
  */
230
239
  function entryForPath(cwd, path) {
231
240
  const absolute = join(cwd, ...path.split('/'));
@@ -261,11 +270,46 @@ function entryForPath(cwd, path) {
261
270
  try {
262
271
  targetStat = lstatSync(resolved);
263
272
  }
264
- catch {
265
- throw new UnsupportedSnapshotError(`input snapshot rejects unresolvable symlink '${path}' -> '${target}'; ` +
273
+ catch (error) {
274
+ const code = error.code;
275
+ if (code === 'ENOENT' || code === 'ENOTDIR') {
276
+ // A DANGLING link is a link, not a hole: git itself stores a
277
+ // symlink as a 120000 blob whose bytes are the link-target
278
+ // string, so the link text IS the identity. The target is never
279
+ // followed and never read, so a link into a not-yet-created
280
+ // virtualenv is captured exactly the way git records it and the
281
+ // run continues (one plain notice line names it). The entry
282
+ // still moves the digest: retargeting the link, or the target
283
+ // appearing after the project's own bootstrap, changes its
284
+ // identity and its entry type.
285
+ return {
286
+ path,
287
+ type: 'dangling-symlink',
288
+ linkTarget: target,
289
+ contentDigest: hashEntry('dangling-symlink', path, `link:${target}\0`),
290
+ };
291
+ }
292
+ throw new UnsupportedSnapshotError(`input snapshot cannot inspect symlink target of '${path}' (${code ?? 'UNKNOWN'}); ` +
266
293
  'explicit unsupported-snapshot block');
267
294
  }
268
295
  if (!targetStat.isFile()) {
296
+ if (targetStat.isDirectory() || targetStat.isSymbolicLink()) {
297
+ // A link to a DIRECTORY (including one that only exists after the
298
+ // project's own bootstrap) is recorded the way a dangling link is:
299
+ // by its link text alone, exactly as git stores a 120000 blob.
300
+ // The target is never walked and never read — it can be a whole
301
+ // virtualenv — so the run continues with one plain notice line.
302
+ // The entry still moves the digest: retargeting the link, or the
303
+ // target becoming a regular file, changes its identity and its
304
+ // type. Anything else (fifo, socket, device) stays fail-closed:
305
+ // that is not a link into a path.
306
+ return {
307
+ path,
308
+ type: 'directory-symlink',
309
+ linkTarget: target,
310
+ contentDigest: hashEntry('directory-symlink', path, `link:${target}\0`),
311
+ };
312
+ }
269
313
  throw new UnsupportedSnapshotError(`input snapshot rejects non-file symlink '${path}' -> '${target}'; ` +
270
314
  'explicit unsupported-snapshot block');
271
315
  }
@@ -280,7 +324,7 @@ function entryForPath(cwd, path) {
280
324
  // Identity = link location + link target string + target bytes: a
281
325
  // retargeted link and a changed target both move the digest.
282
326
  const combined = Buffer.concat([Buffer.from(`link:${target}\0`, 'utf8'), targetBytes]);
283
- return { path, type: 'symlink', contentDigest: hashEntry('symlink', path, combined) };
327
+ return { path, type: 'symlink', linkTarget: target, contentDigest: hashEntry('symlink', path, combined) };
284
328
  }
285
329
  if (stat.isFile()) {
286
330
  let bytes;
@@ -334,6 +378,57 @@ export function normalizeRepoModule(module) {
334
378
  }
335
379
  return kept.join('/');
336
380
  }
381
+ /**
382
+ * Expands a configured Alembic versions directory into its migration files.
383
+ *
384
+ * The chain config names a DIRECTORY; the snapshot digests files, so the
385
+ * directory is walked and every file below it is declared instead.
386
+ * Python bytecode (`__pycache__/`, `*.pyc`, `*.pyo`) is skipped: Alembic
387
+ * writes it whenever it imports the migrations, so it would change the
388
+ * input identity without any source change. A missing or unreadable
389
+ * directory contributes nothing here — the compiler reports the broken
390
+ * chain itself.
391
+ *
392
+ * Args:
393
+ * cwd: absolute repo root.
394
+ * directory: repo-relative versions directory.
395
+ *
396
+ * Returns:
397
+ * string[]: repo-relative posix file paths, codepoint-sorted.
398
+ */
399
+ export function migrationInputFiles(cwd, directory) {
400
+ const prefix = directory.replace(/\\/g, '/').replace(/\/+$/, '');
401
+ const found = [];
402
+ const walk = (dir, segments) => {
403
+ let entries;
404
+ try {
405
+ entries = readdirSync(dir);
406
+ }
407
+ catch {
408
+ return;
409
+ }
410
+ entries.sort(compareStrings);
411
+ for (const entry of entries) {
412
+ const relativePath = [...segments, entry].join('/');
413
+ let stat;
414
+ try {
415
+ stat = lstatSync(join(dir, entry));
416
+ }
417
+ catch {
418
+ continue;
419
+ }
420
+ if (stat.isDirectory()) {
421
+ if (entry !== '__pycache__')
422
+ walk(join(dir, entry), [...segments, entry]);
423
+ }
424
+ else if (!/\.py[co]$/.test(entry)) {
425
+ found.push(relativePath);
426
+ }
427
+ }
428
+ };
429
+ walk(join(cwd, directory), []);
430
+ return found.map((path) => toPosix(`${prefix}/${path}`)).sort(compareStrings);
431
+ }
337
432
  /**
338
433
  * Collects the DECLARED source/configuration inputs: configured scan
339
434
  * inputs (even gitignored) + explicit config/adapter/waiver/plugin/
@@ -366,10 +461,23 @@ export function collectDeclaredInputs(cwd, config) {
366
461
  ...(config.behaviorPolicy === undefined ? [] : [toPosix(config.behaviorPolicy)]),
367
462
  ...(config.runtime === undefined ? [] : [toPosix(config.runtime)]),
368
463
  ...PACK_CONFIGS,
464
+ ...(config.alembic === undefined
465
+ ? []
466
+ : [
467
+ ...config.alembic.chains.flatMap((chain) => [
468
+ ...migrationInputFiles(cwd, chain.migrations),
469
+ chain.alembicIni ?? 'alembic.ini',
470
+ ...chain.models,
471
+ ]),
472
+ ...(config.alembic.seed === undefined ? [] : [config.alembic.seed.path]),
473
+ ]),
369
474
  ];
370
475
  if (existsSync(join(cwd, '.gateforge/docs-exclusions.yml'))) {
371
476
  explicitFiles.push('.gateforge/docs-exclusions.yml');
372
477
  }
478
+ if (existsSync(join(cwd, '.gateforge/cache-exclusions.yml'))) {
479
+ explicitFiles.push('.gateforge/cache-exclusions.yml');
480
+ }
373
481
  for (const candidate of explicitFiles) {
374
482
  if (candidate.length > 0)
375
483
  paths.add(candidate);
@@ -554,6 +662,11 @@ function buildFileEntries(cwd, inventory, tracked, stateDir) {
554
662
  * digest) is a hole, not an exclusion. Also rejects the state directory
555
663
  * aliasing the repo root itself (including through a symlink).
556
664
  *
665
+ * The ENGINE's own generated state is not a hole and is exempted through
666
+ * the closed-world set in `./state-artifacts.ts`: a tracked file under
667
+ * `--out` still refuses above, and any other path there still refuses
668
+ * here.
669
+ *
557
670
  * Args:
558
671
  * cwd: absolute repo root.
559
672
  * stateDir: absolute run-state directory.
@@ -623,9 +736,19 @@ export function assertOutputDisjoint(cwd, stateDir, declaredInputs) {
623
736
  }
624
737
  if (prefix === '' || prefix.startsWith('..'))
625
738
  return;
739
+ // A declared input that hides under --out is the hole this refuses.
740
+ // The engine's OWN generated state is not a hole: it is the output the
741
+ // exclusion exists for, and a supervised run writes real source-shaped
742
+ // files (the synthesized Playwright config) into the state directory —
743
+ // which made the very next command refuse to run in the repository the
744
+ // run had just graded. The generated set is closed-world
745
+ // (./state-artifacts.ts), so a tracked file (refused above), a
746
+ // hand-written file, and any path the engine never writes all still
747
+ // refuse with byte-identical wording.
626
748
  const hidden = declaredInputs
627
749
  .filter((item) => !item.startsWith('absent:'))
628
750
  .filter((item) => item === prefix || item.startsWith(`${prefix}/`))
751
+ .filter((item) => !isEngineGeneratedStatePath(item.slice(prefix.length + 1)))
629
752
  .sort(compareStrings);
630
753
  if (hidden.length > 0) {
631
754
  throw new UsageError(`refusing to run: --out '${stateDir}' overlaps declared source/configuration inputs ` +
@@ -713,8 +836,8 @@ export function digestSnapshot(files, gateContext) {
713
836
  * entries, canonical context, and digest.
714
837
  *
715
838
  * Args:
716
- * input: cwd, config, stateDir, and (post-discovery) classifications,
717
- * obligations, httpRoutes, and pinned plugins.
839
+ * input: repository root, config, run state, optional post-discovery
840
+ * classification context, and approved documentation/cache exclusions.
718
841
  *
719
842
  * Returns:
720
843
  * InputSnapshot: full inventory, gate context, verifier format, and
@@ -727,7 +850,7 @@ export function digestSnapshot(files, gateContext) {
727
850
  * UsageError: unsafe output overlap (exit 2).
728
851
  */
729
852
  export function computeInputSnapshot(input) {
730
- const files = collectInputFiles(input.cwd, input.config, input.stateDir, input.runtimeReuseMounts, input.docsExclusions);
853
+ const files = collectInputFiles(input.cwd, input.config, input.stateDir, input.runtimeReuseMounts, input.docsExclusions, input.cacheExclusions);
731
854
  const gateContext = buildGateContext(input.config, input.plugins, input.classifications ?? {}, input.obligations ?? [], input.httpRoutes ?? [], input.runtimeReuseDigest);
732
855
  const evidenceInputDigest = digestSnapshot(files, gateContext);
733
856
  return {
@@ -748,11 +871,19 @@ export function computeInputSnapshot(input) {
748
871
  * cwd: absolute repo root.
749
872
  * config: validated `.gateforge.yml`.
750
873
  * stateDir: absolute run-state directory.
874
+ * runtimeReuseMounts: externally prepared dependencies bound by digest.
875
+ * docsExclusions: owner-approved documentation folders to omit.
876
+ * cacheExclusions: exact owner-approved Python bytecode files to omit.
751
877
  *
752
878
  * Returns:
753
879
  * SnapshotFileEntry[]: sorted file entries (overlap-checked).
880
+ *
881
+ * Throws:
882
+ * UsageError: an exclusion overlaps run state or a configured input.
883
+ * SnapshotUnavailableError: no usable Git inventory.
884
+ * UnsupportedSnapshotError: a required file cannot be captured.
754
885
  */
755
- export function collectInputFiles(cwd, config, stateDir, runtimeReuseMounts = [], docsExclusions = []) {
886
+ export function collectInputFiles(cwd, config, stateDir, runtimeReuseMounts = [], docsExclusions = [], cacheExclusions = []) {
756
887
  const declared = collectDeclaredInputs(cwd, config);
757
888
  assertOutputDisjoint(cwd, stateDir, declared);
758
889
  const statePrefix = toPosix(relative(resolve(cwd), resolve(stateDir)));
@@ -770,6 +901,22 @@ export function collectInputFiles(cwd, config, stateDir, runtimeReuseMounts = []
770
901
  throw new UsageError(`documentation exclusion '${folder}' overlaps a configured scan or gate input (fail closed)`);
771
902
  }
772
903
  }
904
+ for (const file of cacheExclusions) {
905
+ const segments = file.split('/');
906
+ const cacheIndex = segments.lastIndexOf('__pycache__');
907
+ if (file.length === 0 || file.startsWith('/') || file.includes('\\') ||
908
+ segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..') ||
909
+ cacheIndex !== segments.length - 2 || !/\.(?:pyc|pyo)$/.test(segments.at(-1) ?? '')) {
910
+ throw new UsageError(`invalid approved Python bytecode exclusion '${file}' (fail closed)`);
911
+ }
912
+ if (statePrefix !== '' &&
913
+ (statePrefix === file || statePrefix.startsWith(`${file}/`) || file.startsWith(`${statePrefix}/`))) {
914
+ throw new UsageError(`Python bytecode exclusion '${file}' overlaps the run-state directory (fail closed)`);
915
+ }
916
+ if (declared.some((path) => !path.startsWith('absent:') && path === file)) {
917
+ throw new UsageError(`Python bytecode exclusion '${file}' overlaps a configured scan or gate input (fail closed)`);
918
+ }
919
+ }
773
920
  try {
774
921
  validateRuntimeReuseMounts(cwd, runtimeReuseMounts);
775
922
  }
@@ -783,6 +930,7 @@ export function collectInputFiles(cwd, config, stateDir, runtimeReuseMounts = []
783
930
  const inventory = [...new Set([...declared, ...git.inventory])]
784
931
  .filter((path) => !isRuntimeReusePath(path.replace(/^absent:/, ''), runtimeReuseMounts))
785
932
  .filter((path) => path.startsWith('absent:') || !docsExclusions.some((folder) => path === folder || path.startsWith(`${folder}/`)))
933
+ .filter((path) => path.startsWith('absent:') || !cacheExclusions.includes(path))
786
934
  .sort(compareStrings);
787
935
  return buildFileEntries(cwd, inventory, git.tracked, stateDir);
788
936
  }
@@ -815,4 +963,34 @@ export function diffInputFiles(before, after) {
815
963
  }
816
964
  return differences.sort(compareStrings);
817
965
  }
966
+ /**
967
+ * One plain notice line per symlink captured by link text only.
968
+ *
969
+ * A dangling link or a link to a directory is captured, not fatal, so
970
+ * the run must still say what it saw: each line names the link and its
971
+ * target, and says whether an action is needed. A dangling link needs
972
+ * one (the project's own bootstrap, or drop the link); a directory link
973
+ * needs none — it works as it stands and nothing was read through it.
974
+ *
975
+ * Args:
976
+ * files: the captured file entries.
977
+ * Returns:
978
+ * string[]: one notice line per link captured by text, in path order
979
+ * (empty when every link resolves to a regular file).
980
+ */
981
+ export function symlinkNotices(files) {
982
+ const notices = [];
983
+ for (const entry of files) {
984
+ const target = entry.linkTarget ?? '';
985
+ if (entry.type === 'dangling-symlink') {
986
+ notices.push(`note: dangling symlink '${entry.path}' -> '${target}' is recorded by its link text ` +
987
+ "(the target does not exist; do: run the project's own bootstrap, or remove the link)");
988
+ }
989
+ else if (entry.type === 'directory-symlink') {
990
+ notices.push(`note: directory symlink '${entry.path}' -> '${target}' is recorded by its link text ` +
991
+ '(the target is a directory and was not read; no action needed)');
992
+ }
993
+ }
994
+ return notices;
995
+ }
818
996
  //# sourceMappingURL=input-snapshot.js.map