@smoothbricks/nx-plugin 0.4.28 → 0.4.29

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 (124) hide show
  1. package/README.md +203 -83
  2. package/dist/bounded-test-policy.d.ts +10 -3
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +19 -25
  5. package/dist/cargo-closure-input.d.ts +12 -0
  6. package/dist/cargo-closure-input.d.ts.map +1 -1
  7. package/dist/cargo-closure-input.js +29 -7
  8. package/dist/cargo-source-hash.d.ts.map +1 -1
  9. package/dist/cargo-source-hash.js +42 -19
  10. package/dist/ensure-built-receipt.d.ts +34 -6
  11. package/dist/ensure-built-receipt.d.ts.map +1 -1
  12. package/dist/ensure-built-receipt.js +265 -159
  13. package/dist/ensure-built-witness.d.ts +27 -2
  14. package/dist/ensure-built-witness.d.ts.map +1 -1
  15. package/dist/ensure-built-witness.js +2176 -15
  16. package/dist/ensure-built.d.ts +99 -1
  17. package/dist/ensure-built.d.ts.map +1 -1
  18. package/dist/ensure-built.js +34 -53
  19. package/dist/executors/bounded-exec/cpu-pool.d.ts +16 -5
  20. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  21. package/dist/executors/bounded-exec/cpu-pool.js +43 -19
  22. package/dist/executors/bounded-exec/executor.d.ts +11 -2
  23. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/executor.js +139 -39
  25. package/dist/executors/bounded-exec/ram-temp.d.ts +17 -11
  26. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/ram-temp.js +27 -13
  28. package/dist/generators/bun-test-tracing/generator.js +2 -2
  29. package/dist/graph-input-contract.d.ts +98 -0
  30. package/dist/graph-input-contract.d.ts.map +1 -0
  31. package/dist/graph-input-contract.js +624 -0
  32. package/dist/index.d.ts +12 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +17 -3
  35. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  36. package/dist/managed-files/ci-workflow.js +5 -2
  37. package/dist/managed-files/publish-workflow.d.ts +11 -1
  38. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  39. package/dist/producer-receipts.d.ts +19 -0
  40. package/dist/producer-receipts.d.ts.map +1 -0
  41. package/dist/producer-receipts.js +921 -0
  42. package/dist/testing.d.ts +8 -0
  43. package/dist/testing.d.ts.map +1 -1
  44. package/dist/testing.js +58 -0
  45. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  46. package/managed/raw/tooling/direnv/developer-links.ts +147 -21
  47. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  48. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  49. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  50. package/managed/raw/tooling/direnv/repo-path +15 -2
  51. package/managed/raw/tooling/direnv/setup-environment.ts +179 -114
  52. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  53. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  54. package/nextest.toml +1 -1
  55. package/package.json +11 -6
  56. package/src/__tests__/fixture-nx-env.ts +7 -0
  57. package/src/__tests__/owned-installation.ts +174 -0
  58. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  59. package/src/bounded-test-policy.test.ts +36 -22
  60. package/src/bounded-test-policy.ts +19 -27
  61. package/src/bun-bootstrap.test.ts +1 -1
  62. package/src/cargo-closure-input.test.ts +60 -11
  63. package/src/cargo-closure-input.ts +28 -6
  64. package/src/cargo-resolve-cache.test.ts +140 -25
  65. package/src/cargo-source-hash.test.ts +78 -3
  66. package/src/cargo-source-hash.ts +48 -30
  67. package/src/cross-check-policy.test.ts +2 -2
  68. package/src/ensure-built-receipt.test.ts +111 -16
  69. package/src/ensure-built-receipt.ts +251 -149
  70. package/src/ensure-built-witness.test.ts +197 -13
  71. package/src/ensure-built-witness.ts +187 -15
  72. package/src/ensure-built.test.ts +156 -102
  73. package/src/ensure-built.ts +114 -64
  74. package/src/executors/bounded-exec/cpu-pool.test.ts +116 -32
  75. package/src/executors/bounded-exec/cpu-pool.ts +55 -17
  76. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  77. package/src/executors/bounded-exec/executor-host.test.ts +51 -41
  78. package/src/executors/bounded-exec/executor.test.ts +155 -35
  79. package/src/executors/bounded-exec/executor.ts +156 -45
  80. package/src/executors/bounded-exec/progress.test.ts +1 -1
  81. package/src/executors/bounded-exec/ram-temp-host.test.ts +46 -17
  82. package/src/executors/bounded-exec/ram-temp.test.ts +65 -3
  83. package/src/executors/bounded-exec/ram-temp.ts +32 -16
  84. package/src/executors/bounded-exec/verdict.test.ts +17 -12
  85. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  86. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  87. package/src/generators/bun-test-tracing/generator.ts +2 -2
  88. package/src/graph-input-contract.test.ts +371 -0
  89. package/src/graph-input-contract.ts +605 -0
  90. package/src/index.test.ts +3 -3
  91. package/src/index.ts +24 -3
  92. package/src/linked-snapshots.nx.test.ts +112 -30
  93. package/src/managed-files/ci-workflow.ts +5 -2
  94. package/src/managed-files/publish-workflow.ts +12 -1
  95. package/src/managed-files/repo-path.test.ts +44 -1
  96. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  97. package/src/nextest-code-bound.test.ts +23 -17
  98. package/src/nextest-partitions.test.ts +7 -1
  99. package/src/nx-cache-restore-mtime.test.ts +2 -2
  100. package/src/nx-daemon-claim.test.ts +5 -5
  101. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  102. package/src/nx-daemon-idle-policy.test.ts +56 -0
  103. package/src/nx-daemon-ignore-files.test.ts +2 -2
  104. package/src/nx-daemon-validity.test.ts +31 -9
  105. package/src/nx-dot-input-policy.test.ts +5 -5
  106. package/src/nx-files-archive-racy.test.ts +1 -1
  107. package/src/nx-incomplete-run-summary.test.ts +1 -1
  108. package/src/nx-plugin-load-errors.test.ts +2 -2
  109. package/src/nx-project-graph-errors.test.ts +70 -0
  110. package/src/nx-skipped-task-exit.test.ts +2 -2
  111. package/src/nx-store-resolution.test.ts +7 -25
  112. package/src/nx-task-output-lease.test.ts +3 -3
  113. package/src/nx-use-local.test.ts +7 -5
  114. package/src/producer-receipts.test.ts +164 -0
  115. package/src/producer-receipts.ts +631 -0
  116. package/src/runtime-input.test.ts +1 -1
  117. package/src/serial-group-wiring.test.ts +4 -4
  118. package/src/task-results.test.ts +18 -16
  119. package/src/test-timings.test.ts +2 -2
  120. package/src/testing.test.ts +5 -5
  121. package/src/testing.ts +59 -0
  122. package/src/typecheck-test-policy.test.ts +1 -1
  123. package/src/typescript-resolution.test.ts +76 -0
  124. package/test-timings.json +5 -0
@@ -0,0 +1,371 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
2
+ import { execFileSync } from 'node:child_process';
3
+ import { createHash } from 'node:crypto';
4
+ import {
5
+ chmod,
6
+ link,
7
+ mkdir,
8
+ mkdtemp,
9
+ readFile,
10
+ realpath,
11
+ rename,
12
+ rm,
13
+ stat,
14
+ symlink,
15
+ utimes,
16
+ writeFile,
17
+ } from 'node:fs/promises';
18
+ import { createRequire } from 'node:module';
19
+ import { tmpdir } from 'node:os';
20
+ import { dirname, join } from 'node:path';
21
+ import { expandOutputs, WorkspaceContext } from 'nx/src/native';
22
+ import { graphInstallationIdentity, workspaceSnapshot } from './ensure-built-witness.js';
23
+ import {
24
+ type GraphInputContract,
25
+ GraphInputReadCollector,
26
+ graphInputContractIdentity,
27
+ } from './graph-input-contract.js';
28
+
29
+ const require = createRequire(import.meta.url);
30
+ const pure = 'export const createNodesV2 = ["**/project.json", (files) => files.map(file => [file, {}])];\n';
31
+ const sha = (text: string) => createHash('sha256').update(text).digest('hex');
32
+ let root = '';
33
+ let external = '';
34
+ // One Nx state per checkout (specs/cowshed/04_sandbox.md): the fixture is its own checkout, so the runner's
35
+ // NX_WORKSPACE_DATA_DIRECTORY (CI's shared host directory, a job's checkout `.nx`) must not name its witnesses.
36
+ const inheritedData = process.env.NX_WORKSPACE_DATA_DIRECTORY;
37
+ const data = () => join(root, '.nx', 'workspace-data');
38
+ const snapshot = () => workspaceSnapshot(root, new WorkspaceContext(root, data()), undefined);
39
+ const options = (kind: GraphInputContract['kind'] = 'native-only') => ({
40
+ graphInputContract: {
41
+ version: 1,
42
+ kind,
43
+ modules: [{ path: 'plugin.ts', sha256: sha(pure) }],
44
+ packages: [],
45
+ } satisfies GraphInputContract,
46
+ });
47
+ const configured = (kind: GraphInputContract['kind'] = 'native-only') => ({
48
+ plugins: [{ plugin: './plugin.ts', options: options(kind) }],
49
+ });
50
+ const identity = (kind: GraphInputContract['kind'] = 'native-only') =>
51
+ graphInputContractIdentity(root, configured(kind), snapshot());
52
+ const reader = (kind: GraphInputContract['kind'] = 'tsconfig-extends') =>
53
+ new GraphInputReadCollector(root, './plugin.ts', options(kind));
54
+
55
+ beforeEach(async () => {
56
+ root = await realpath(await mkdtemp(join(tmpdir(), 'graph-input-contract-')));
57
+ external = await realpath(await mkdtemp(join(tmpdir(), 'graph-input-outside-')));
58
+ await mkdir(data(), { recursive: true });
59
+ process.env.NX_WORKSPACE_DATA_DIRECTORY = data();
60
+ await mkdir(join(root, 'node_modules'), { recursive: true });
61
+ for (const name of ['nx', 'typescript']) {
62
+ await symlink(dirname(require.resolve(`${name}/package.json`)), join(root, 'node_modules', name), 'dir');
63
+ }
64
+ await writeFile(join(root, 'package.json'), '{"name":"fixture"}');
65
+ await writeFile(join(root, 'nx.json'), '{}');
66
+ await writeFile(join(root, '.gitignore'), '.nx/\nnode_modules/\n');
67
+ await writeFile(join(root, 'plugin.ts'), pure);
68
+ await writeFile(join(external, 'base.json'), '{"include":["src"]}');
69
+ });
70
+ afterEach(async () => {
71
+ if (inheritedData === undefined) delete process.env.NX_WORKSPACE_DATA_DIRECTORY;
72
+ else process.env.NX_WORKSPACE_DATA_DIRECTORY = inheritedData;
73
+ await rm(root, { recursive: true, force: true });
74
+ await rm(external, { recursive: true, force: true });
75
+ });
76
+
77
+ describe('owner-approved local graph contracts', () => {
78
+ it('admits only the exact audited native-only module and refuses changed/new unapproved code', async () => {
79
+ const original = identity();
80
+ expect(original).not.toBeNull();
81
+ expect(identity()).toEqual(original);
82
+ await writeFile(join(root, 'plugin.ts'), pure.replace('**/project.json', '**/package.json'));
83
+ expect(identity()).toBeNull();
84
+ expect(graphInputContractIdentity(root, { plugins: ['./plugin.ts'] }, snapshot())).toBeNull();
85
+ expect(
86
+ graphInputContractIdentity(
87
+ root,
88
+ { plugins: [{ plugin: './plugin.ts', options: { graphInputContract: { kind: 'native-only' } } }] },
89
+ snapshot(),
90
+ ),
91
+ ).toBeNull();
92
+ });
93
+ it('does not treat a kind alone, another module hash, a missing helper or an undeclared package as approval', async () => {
94
+ const entry = "import { value } from './helper.js'; export { value };";
95
+ await writeFile(join(root, 'plugin.ts'), entry);
96
+ await writeFile(join(root, 'helper.ts'), 'export const value = 1;');
97
+ const contract: GraphInputContract = {
98
+ version: 1,
99
+ kind: 'native-only',
100
+ modules: [{ path: 'plugin.ts', sha256: sha(entry) }],
101
+ packages: [],
102
+ };
103
+ expect(
104
+ graphInputContractIdentity(
105
+ root,
106
+ { plugins: [{ plugin: './plugin.ts', options: { graphInputContract: contract } }] },
107
+ snapshot(),
108
+ ),
109
+ ).toBeNull();
110
+ const complete = {
111
+ ...contract,
112
+ modules: [...contract.modules, { path: 'helper.ts', sha256: sha('export const value = 1;') }],
113
+ };
114
+ expect(
115
+ graphInputContractIdentity(
116
+ root,
117
+ { plugins: [{ plugin: './plugin.ts', options: { graphInputContract: complete } }] },
118
+ snapshot(),
119
+ ),
120
+ ).not.toBeNull();
121
+ await writeFile(join(root, 'helper.ts'), 'export const value = 2;');
122
+ expect(
123
+ graphInputContractIdentity(
124
+ root,
125
+ { plugins: [{ plugin: './plugin.ts', options: { graphInputContract: complete } }] },
126
+ snapshot(),
127
+ ),
128
+ ).toBeNull();
129
+ const externalImport = "import 'unapproved-package';";
130
+ await writeFile(join(root, 'plugin.ts'), externalImport);
131
+ expect(
132
+ graphInputContractIdentity(
133
+ root,
134
+ {
135
+ plugins: [
136
+ {
137
+ plugin: './plugin.ts',
138
+ options: {
139
+ graphInputContract: { ...contract, modules: [{ path: 'plugin.ts', sha256: sha(externalImport) }] },
140
+ },
141
+ },
142
+ ],
143
+ },
144
+ snapshot(),
145
+ ),
146
+ ).toBeNull();
147
+ });
148
+ it('feeds the complete proof into installed package/alias identity and rejects a missing local proof', () => {
149
+ const proof = identity();
150
+ const resolver = () => ({ path: join(root, 'package.json'), packageJson: { name: 'fixture', version: '1' } });
151
+ expect(graphInstallationIdentity(root, configured(), resolver, expandOutputs, null)).toBeNull();
152
+ expect(graphInstallationIdentity(root, configured(), resolver, expandOutputs, proof)).not.toBeNull();
153
+ });
154
+ });
155
+
156
+ describe('owning-reader external input byproducts', () => {
157
+ it('retains the original result while binding external config bytes and missing candidates', async () => {
158
+ const probe = reader();
159
+ const path = join(external, 'base.json');
160
+ const bytes = probe.read(path, () => '{"include":["src"]}');
161
+ expect(bytes).toBe('{"include":["src"]}');
162
+ expect(probe.exists(join(external, 'missing.json'))).toBe(false);
163
+ expect(probe.finish().status).toBe('complete');
164
+ expect(identity('tsconfig-extends')).not.toBeNull();
165
+ const before = await (await import('node:fs/promises')).stat(path);
166
+ await writeFile(path, '{"include":["lib"]}');
167
+ await utimes(path, before.atime, before.mtime);
168
+ expect(identity('tsconfig-extends')).toBeNull();
169
+ });
170
+ it('refuses changed membership, new/deleted candidates and native source generation', async () => {
171
+ const probe = reader();
172
+ probe.namespace(external);
173
+ expect(probe.finish().status).toBe('complete');
174
+ expect(identity('tsconfig-extends')).not.toBeNull();
175
+ await writeFile(join(external, 'new.json'), '{}');
176
+ expect(identity('tsconfig-extends')).toBeNull();
177
+ const next = reader();
178
+ next.namespace(external);
179
+ next.finish();
180
+ await rm(join(external, 'new.json'));
181
+ expect(identity('tsconfig-extends')).toBeNull();
182
+ const native = reader();
183
+ native.finish();
184
+ await writeFile(join(root, 'new-project.json'), '{}');
185
+ expect(identity('tsconfig-extends')).toBeNull();
186
+ });
187
+ it('keeps unrelated sibling writes outside both scopes and upgrades a read directory to namespace evidence', async () => {
188
+ const probe = reader();
189
+ const path = join(external, 'base.json');
190
+ probe.read(path, () => '{"include":["src"]}');
191
+ // The prior file read saw this directory only as an ancestor; traversal upgrades it.
192
+ probe.namespace(external);
193
+ expect(probe.finish().status).toBe('complete');
194
+ const before = identity('tsconfig-extends');
195
+ expect(before).not.toBeNull();
196
+ const sibling = `${root}-unrelated`;
197
+ try {
198
+ await writeFile(sibling, 'outside both the workspace and the external read scope');
199
+ expect(identity('tsconfig-extends')).toEqual(before);
200
+ await writeFile(join(external, 'new-member.json'), '{}');
201
+ expect(identity('tsconfig-extends')).toBeNull();
202
+ } finally {
203
+ await rm(sibling, { force: true });
204
+ }
205
+ });
206
+ it('revokes replacement of a real ancestor even when its hardlinked leaf stays identical', async () => {
207
+ const first = join(external, 'first');
208
+ const second = join(external, 'second');
209
+ await mkdir(first);
210
+ await mkdir(second);
211
+ const path = join(first, 'base.json');
212
+ await writeFile(path, '{}');
213
+ await link(path, join(second, 'base.json'));
214
+ const probe = reader();
215
+ probe.read(path, () => '{}');
216
+ expect(probe.finish().status).toBe('complete');
217
+ expect(identity('tsconfig-extends')).not.toBeNull();
218
+ const before = await stat(path);
219
+ await rename(first, join(external, 'old-first'));
220
+ await rename(second, first);
221
+ expect((await stat(path)).ino).toBe(before.ino);
222
+ expect(await readFile(path, 'utf8')).toBe('{}');
223
+ expect(identity('tsconfig-extends')).toBeNull();
224
+ });
225
+ it('does not re-arm an old trace after a write/revert or an explicitly unproved reader', async () => {
226
+ const probe = reader();
227
+ probe.read(join(external, 'base.json'), () => 'before');
228
+ await writeFile(join(external, 'base.json'), 'after');
229
+ await writeFile(join(external, 'base.json'), '{"include":["src"]}');
230
+ expect(probe.finish().status).toBe('unproved');
231
+ expect(identity('tsconfig-extends')).toBeNull();
232
+ const opaque = reader();
233
+ opaque.refuse('opaque external runtime/file input');
234
+ expect(opaque.finish()).toMatchObject({ status: 'unproved', detail: 'opaque external runtime/file input' });
235
+ expect(identity('tsconfig-extends')).toBeNull();
236
+ });
237
+ it('falls back for missing, unreadable, malformed and wrong-version read witnesses', async () => {
238
+ expect(identity('tsconfig-extends')).toBeNull();
239
+ reader().finish();
240
+ const { readdir } = await import('node:fs/promises');
241
+ const name = (await readdir(data())).find((name) => name.startsWith('graph-input-') && name.endsWith('.json'));
242
+ if (name === undefined) throw new Error('collector published no graph-input witness');
243
+ const path = join(data(), name);
244
+ const bytes = await readFile(path, 'utf8');
245
+ await chmod(path, 0);
246
+ try {
247
+ expect(identity('tsconfig-extends')).toBeNull();
248
+ } finally {
249
+ await chmod(path, 0o600);
250
+ }
251
+ await writeFile(path, 'not json');
252
+ expect(identity('tsconfig-extends')).toBeNull();
253
+ await writeFile(path, bytes.replace('"version":1', '"version":2'));
254
+ expect(identity('tsconfig-extends')).toBeNull();
255
+ });
256
+ it('uses actual Node resolution and revokes changed alias/package candidates immediately', async () => {
257
+ const packageRoot = join(root, 'node_modules', 'base-config');
258
+ await mkdir(packageRoot);
259
+ await writeFile(join(packageRoot, 'package.json'), '{"name":"base-config","version":"1","exports":"./base.json"}');
260
+ await writeFile(join(packageRoot, 'base.json'), '{}');
261
+ const probe = reader();
262
+ const local = createRequire(join(root, 'package.json'));
263
+ expect(probe.resolve(root, 'base-config', () => local.resolve('base-config'))).toBe(join(packageRoot, 'base.json'));
264
+ probe.finish();
265
+ expect(identity('tsconfig-extends')).not.toBeNull();
266
+ await writeFile(join(packageRoot, 'package.json'), '{"name":"base-config","version":"2","exports":"./other.json"}');
267
+ await writeFile(join(packageRoot, 'other.json'), '{}');
268
+ expect(identity('tsconfig-extends')).toBeNull();
269
+ });
270
+ it('revokes a missing outside candidate and names genuinely opaque loader inputs', async () => {
271
+ const path = join(external, 'optional.json');
272
+ const probe = reader();
273
+ expect(probe.exists(path)).toBe(false);
274
+ probe.finish();
275
+ expect(identity('tsconfig-extends')).not.toBeNull();
276
+ await writeFile(path, '{}');
277
+ expect(identity('tsconfig-extends')).toBeNull();
278
+ const previous = process.env.NODE_OPTIONS;
279
+ process.env.NODE_OPTIONS = '--require /unbounded/preload.js';
280
+ try {
281
+ const opaque = reader();
282
+ expect(opaque.read(join(external, 'base.json'), () => 'original-result')).toBe('original-result');
283
+ expect(opaque.finish()).toMatchObject({
284
+ status: 'unproved',
285
+ detail: 'unbounded loader environment: NODE_OPTIONS',
286
+ });
287
+ } finally {
288
+ if (previous === undefined) delete process.env.NODE_OPTIONS;
289
+ else process.env.NODE_OPTIONS = previous;
290
+ }
291
+ });
292
+ it('replays Bun resolution in a fresh process rather than inheriting a retargeted alias cache', async () => {
293
+ const first = join(external, 'first');
294
+ const second = join(external, 'second');
295
+ for (const [directory, value] of [
296
+ [first, '1'],
297
+ [second, '2'],
298
+ ]) {
299
+ if (directory === undefined) throw new Error('fixture directory missing');
300
+ await mkdir(directory);
301
+ await writeFile(join(directory, 'package.json'), '{"name":"workspace-alias","exports":"./index.js"}');
302
+ await writeFile(join(directory, 'index.js'), `export const value = ${value};`);
303
+ }
304
+ const alias = join(root, 'node_modules', 'workspace-alias');
305
+ await symlink(first, alias, 'dir');
306
+ const initial = Bun.resolveSync('workspace-alias', root);
307
+ await rm(alias);
308
+ await symlink(second, alias, 'dir');
309
+ const probe = reader('reference-scan');
310
+ const observed = probe.resolve(root, 'workspace-alias', () => initial, 'bun');
311
+ expect(observed).toBe(initial);
312
+ expect(probe.finish().status).toBe('complete');
313
+ // The prior process result is deliberately stale; the bound fresh Bun replay must reject it.
314
+ expect(identity('reference-scan')).toBeNull();
315
+ });
316
+ it('revokes changed Git-listed source even when Nx excludes its unchanged membership', async () => {
317
+ execFileSync('git', ['init', '-q'], { cwd: root });
318
+ await writeFile(join(root, '.nxignore'), 'outside-native.ts\n');
319
+ await writeFile(join(root, 'outside-native.ts'), 'export const value = 1;\n');
320
+ execFileSync('git', ['add', '--', 'outside-native.ts'], { cwd: root });
321
+ expect(snapshot().files.map(({ file }) => file)).not.toContain('outside-native.ts');
322
+ const probe = reader('reference-scan');
323
+ probe.git(root, []);
324
+ expect(probe.finish().status).toBe('complete');
325
+ expect(identity('reference-scan')).not.toBeNull();
326
+ const nativeFiles = snapshot().files;
327
+ await writeFile(join(root, 'outside-native.ts'), 'export const value = 2;\n');
328
+ expect(snapshot().files).toEqual(nativeFiles);
329
+ expect(identity('reference-scan')).toBeNull();
330
+ });
331
+ it('revokes a symlink grandparent retarget even when its hardlinked leaf keeps identical bytes and inode', async () => {
332
+ const first = join(external, 'first', 'deep');
333
+ const second = join(external, 'second', 'deep');
334
+ await mkdir(first, { recursive: true });
335
+ await mkdir(second, { recursive: true });
336
+ await writeFile(join(first, 'base.json'), '{"include":["src"]}');
337
+ await link(join(first, 'base.json'), join(second, 'base.json'));
338
+ const alias = join(external, 'alias');
339
+ await symlink(dirname(first), alias, 'dir');
340
+ const input = join(alias, 'deep', 'base.json');
341
+ const before = await stat(input);
342
+ const physical = await realpath(input);
343
+ const bytes = await readFile(input, 'utf8');
344
+ const probe = reader();
345
+ expect(probe.read(input, () => bytes)).toBe(bytes);
346
+ expect(probe.finish().status).toBe('complete');
347
+ expect(identity('tsconfig-extends')).not.toBeNull();
348
+ await rm(alias);
349
+ await symlink(dirname(second), alias, 'dir');
350
+ expect((await stat(input)).ino).toBe(before.ino);
351
+ expect(await readFile(input, 'utf8')).toBe(bytes);
352
+ expect(await realpath(input)).not.toBe(physical);
353
+ expect(identity('tsconfig-extends')).toBeNull();
354
+ });
355
+ it('binds Git effective includes, index, membership and attributes through fixed read-only queries', async () => {
356
+ execFileSync('git', ['init', '-q'], { cwd: root });
357
+ execFileSync('git', ['config', 'include.path', join(external, 'gitconfig')], { cwd: root });
358
+ await writeFile(join(external, 'gitconfig'), '[core]\n ignorecase = true\n');
359
+ const probe = reader('reference-scan');
360
+ probe.git(root, ['plugin.ts']);
361
+ expect(probe.finish().status).toBe('complete');
362
+ expect(identity('reference-scan')).not.toBeNull();
363
+ await writeFile(join(external, 'gitconfig'), '[core]\n ignorecase = false\n');
364
+ expect(identity('reference-scan')).toBeNull();
365
+ const attrs = reader('reference-scan');
366
+ attrs.git(root, ['plugin.ts']);
367
+ attrs.finish();
368
+ await writeFile(join(root, '.git', 'info', 'attributes'), '*.ts binary\n');
369
+ expect(identity('reference-scan')).toBeNull();
370
+ });
371
+ });