@smoothbricks/nx-plugin 0.4.28 → 0.4.30

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 (158) hide show
  1. package/README.md +277 -89
  2. package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
  3. package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-test-clocks.js +28 -0
  5. package/dist/bounded-test-policy.d.ts +8 -8
  6. package/dist/bounded-test-policy.d.ts.map +1 -1
  7. package/dist/bounded-test-policy.js +18 -30
  8. package/dist/cargo-closure-input.d.ts +23 -0
  9. package/dist/cargo-closure-input.d.ts.map +1 -1
  10. package/dist/cargo-closure-input.js +41 -9
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +42 -19
  13. package/dist/ensure-built-receipt.d.ts +40 -6
  14. package/dist/ensure-built-receipt.d.ts.map +1 -1
  15. package/dist/ensure-built-receipt.js +297 -159
  16. package/dist/ensure-built-witness.d.ts +65 -4
  17. package/dist/ensure-built-witness.d.ts.map +1 -1
  18. package/dist/ensure-built-witness.js +2237 -23
  19. package/dist/ensure-built.d.ts +99 -1
  20. package/dist/ensure-built.d.ts.map +1 -1
  21. package/dist/ensure-built.js +45 -56
  22. package/dist/executors/bounded-exec/cpu-pool.d.ts +22 -7
  23. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/cpu-pool.js +51 -22
  25. package/dist/executors/bounded-exec/executor.d.ts +12 -3
  26. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/executor.js +174 -51
  28. package/dist/executors/bounded-exec/no-space.d.ts +8 -0
  29. package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
  30. package/dist/executors/bounded-exec/no-space.js +31 -0
  31. package/dist/executors/bounded-exec/ram-temp.d.ts +20 -11
  32. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  33. package/dist/executors/bounded-exec/ram-temp.js +42 -17
  34. package/dist/executors/bounded-exec/verdict.d.ts +34 -4
  35. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  36. package/dist/executors/bounded-exec/verdict.js +54 -3
  37. package/dist/generators/bun-test-tracing/generator.js +2 -2
  38. package/dist/graph-input-contract.d.ts +102 -0
  39. package/dist/graph-input-contract.d.ts.map +1 -0
  40. package/dist/graph-input-contract.js +637 -0
  41. package/dist/index.d.ts +12 -5
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +17 -3
  44. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  45. package/dist/managed-files/ci-workflow.js +5 -2
  46. package/dist/managed-files/publish-workflow.d.ts +11 -1
  47. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  48. package/dist/owned-installation.d.ts +14 -0
  49. package/dist/owned-installation.d.ts.map +1 -0
  50. package/dist/owned-installation.js +324 -0
  51. package/dist/producer-receipts.d.ts +19 -0
  52. package/dist/producer-receipts.d.ts.map +1 -0
  53. package/dist/producer-receipts.js +926 -0
  54. package/dist/test-backstop.d.ts +9 -0
  55. package/dist/test-backstop.d.ts.map +1 -0
  56. package/dist/test-backstop.js +10 -0
  57. package/dist/test-clock-policy.d.ts +30 -0
  58. package/dist/test-clock-policy.d.ts.map +1 -0
  59. package/dist/test-clock-policy.js +686 -0
  60. package/dist/testing.d.ts +8 -0
  61. package/dist/testing.d.ts.map +1 -1
  62. package/dist/testing.js +66 -1
  63. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  64. package/managed/raw/tooling/direnv/developer-links.ts +148 -29
  65. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  66. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  67. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  68. package/managed/raw/tooling/direnv/repo-path +15 -2
  69. package/managed/raw/tooling/direnv/setup-environment.ts +179 -115
  70. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  71. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  72. package/nextest.toml +1 -1
  73. package/package.json +25 -9
  74. package/src/__tests__/cargo-closure-fixture.ts +113 -0
  75. package/src/__tests__/counted-cargo.ts +8 -25
  76. package/src/__tests__/directory-change.ts +27 -0
  77. package/src/__tests__/fixture-nx-env.ts +7 -0
  78. package/src/__tests__/owned-installation.ts +14 -0
  79. package/src/__tests__/past-tick.ts +12 -0
  80. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  81. package/src/bin/smoo-nx-test-clocks.ts +29 -0
  82. package/src/bounded-test-policy.test.ts +36 -22
  83. package/src/bounded-test-policy.ts +18 -32
  84. package/src/bun-bootstrap.test.ts +1 -1
  85. package/src/cargo-closure-input.property.test.ts +50 -0
  86. package/src/cargo-closure-input.test.ts +73 -121
  87. package/src/cargo-closure-input.ts +47 -8
  88. package/src/cargo-closure-key.test.ts +239 -0
  89. package/src/cargo-resolve-cache.test.ts +168 -31
  90. package/src/cargo-source-hash.test.ts +78 -3
  91. package/src/cargo-source-hash.ts +48 -30
  92. package/src/cross-check-policy.test.ts +2 -2
  93. package/src/ensure-built-receipt.test.ts +111 -16
  94. package/src/ensure-built-receipt.ts +294 -149
  95. package/src/ensure-built-witness.test.ts +306 -13
  96. package/src/ensure-built-witness.ts +255 -24
  97. package/src/ensure-built.test.ts +228 -102
  98. package/src/ensure-built.ts +127 -66
  99. package/src/executors/bounded-exec/cpu-pool.test.ts +134 -32
  100. package/src/executors/bounded-exec/cpu-pool.ts +64 -20
  101. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  102. package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
  103. package/src/executors/bounded-exec/executor-host.test.ts +74 -52
  104. package/src/executors/bounded-exec/executor.test.ts +343 -97
  105. package/src/executors/bounded-exec/executor.ts +192 -56
  106. package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
  107. package/src/executors/bounded-exec/no-space.ts +40 -0
  108. package/src/executors/bounded-exec/progress.test.ts +1 -1
  109. package/src/executors/bounded-exec/ram-temp-host.test.ts +51 -21
  110. package/src/executors/bounded-exec/ram-temp.test.ts +92 -16
  111. package/src/executors/bounded-exec/ram-temp.ts +49 -20
  112. package/src/executors/bounded-exec/verdict.test.ts +127 -22
  113. package/src/executors/bounded-exec/verdict.ts +78 -3
  114. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  115. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  116. package/src/generators/bun-test-tracing/generator.ts +2 -2
  117. package/src/graph-input-contract.test.ts +379 -0
  118. package/src/graph-input-contract.ts +627 -0
  119. package/src/index.test.ts +3 -3
  120. package/src/index.ts +24 -3
  121. package/src/linked-snapshots.nx.test.ts +112 -30
  122. package/src/managed-files/ci-workflow.ts +5 -2
  123. package/src/managed-files/publish-workflow.ts +12 -1
  124. package/src/managed-files/repo-path.test.ts +44 -1
  125. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  126. package/src/nextest-code-bound.test.ts +23 -17
  127. package/src/nextest-extraction.test.ts +114 -4
  128. package/src/nextest-partitions.test.ts +7 -1
  129. package/src/nx-cache-restore-mtime.test.ts +2 -2
  130. package/src/nx-daemon-claim.test.ts +10 -8
  131. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  132. package/src/nx-daemon-idle-policy.test.ts +61 -1
  133. package/src/nx-daemon-ignore-files.test.ts +2 -2
  134. package/src/nx-daemon-validity.test.ts +36 -22
  135. package/src/nx-dot-input-policy.test.ts +5 -5
  136. package/src/nx-files-archive-racy.test.ts +1 -1
  137. package/src/nx-incomplete-run-summary.test.ts +1 -1
  138. package/src/nx-plugin-load-errors.test.ts +2 -2
  139. package/src/nx-project-graph-errors.test.ts +70 -0
  140. package/src/nx-skipped-task-exit.test.ts +2 -2
  141. package/src/nx-store-resolution.test.ts +7 -25
  142. package/src/nx-task-output-lease.test.ts +3 -3
  143. package/src/nx-use-local.test.ts +7 -5
  144. package/src/owned-installation.ts +174 -0
  145. package/src/producer-receipts.test.ts +164 -0
  146. package/src/producer-receipts.ts +636 -0
  147. package/src/runtime-input.test.ts +1 -1
  148. package/src/serial-group-wiring.test.ts +4 -4
  149. package/src/task-results.test.ts +18 -16
  150. package/src/test-backstop.ts +11 -0
  151. package/src/test-clock-policy.test.ts +338 -0
  152. package/src/test-clock-policy.ts +708 -0
  153. package/src/test-timings.test.ts +2 -2
  154. package/src/testing.test.ts +5 -5
  155. package/src/testing.ts +67 -1
  156. package/src/typecheck-test-policy.test.ts +1 -1
  157. package/src/typescript-resolution.test.ts +76 -0
  158. package/test-timings.json +8 -0
@@ -117,7 +117,7 @@ describe('Linux cross-check policy', () => {
117
117
  } finally {
118
118
  await rm(project, { recursive: true, force: true });
119
119
  }
120
- }, 60_000);
120
+ });
121
121
 
122
122
  it('fails closed on Darwin without the linux-cross compiler instead of compiling', () => {
123
123
  // Without this guard a Darwin cache miss sits in ring's cc-rs looking for
@@ -167,7 +167,7 @@ describe('Linux cross-check policy', () => {
167
167
  } finally {
168
168
  await rm(root, { recursive: true, force: true });
169
169
  }
170
- }, 30_000);
170
+ });
171
171
 
172
172
  it('pins clippy to the committed lockfile and local cache', () => {
173
173
  expect(cargoFrozen('clippy --workspace')).toBe('cargo --frozen clippy --workspace');
@@ -6,14 +6,21 @@ import { join } from 'node:path';
6
6
  import type { Task } from 'nx/src/config/task-graph';
7
7
  import { expandOutputs } from 'nx/src/native';
8
8
  import { cargoRuntimeInput } from './cargo-toolchain-policy.js';
9
+ import type { EnsureBuiltProducerReceipt } from './ensure-built.js';
9
10
  import {
10
11
  boundedReceiptRuntimes,
12
+ captureProducerSource,
11
13
  dirtyProviderPaths,
14
+ type ProducerSourceWitness,
12
15
  type ProviderInputProof,
16
+ producerOutputPaths,
17
+ producerSourceUnchanged,
13
18
  providerReceipt,
14
19
  } from './ensure-built-receipt.js';
15
20
 
16
21
  let root = '';
22
+ let source: ProducerSourceWitness;
23
+ let producer: Omit<EnsureBuiltProducerReceipt, 'outputSha256'>;
17
24
  const task = {
18
25
  id: 'app:build',
19
26
  target: { project: 'app', target: 'build' },
@@ -46,6 +53,28 @@ beforeEach(async () => {
46
53
  await symlink('file', join(root, 'output/link'));
47
54
  await chmod(join(root, 'output/file'), 0o644);
48
55
  await chmod(join(root, 'output/empty'), 0o755);
56
+ const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
57
+ if (!captured.ok) throw new Error(captured.detail);
58
+ source = captured.value;
59
+ producer = {
60
+ version: 1,
61
+ target: task.id,
62
+ argv: ['nx', 'run', task.id],
63
+ trackedTreeClean: true,
64
+ environmentIdentity: 'unit-fixture-nx-hash-identity',
65
+ tools: [],
66
+ wallTimeMs: 0,
67
+ inputs: [
68
+ {
69
+ taskId: task.id,
70
+ overrides: task.overrides,
71
+ declared: [],
72
+ expanded: inputs,
73
+ hashDetails: { command: 'unit-fixture', nodes: {} },
74
+ files: source.files.filter(({ path }) => inputs.files.includes(path)),
75
+ },
76
+ ],
77
+ };
49
78
  });
50
79
  afterEach(async () => {
51
80
  await rm(root, { recursive: true, force: true });
@@ -56,14 +85,36 @@ describe('provider receipt', () => {
56
85
  const saved = process.env.GIT_DIR;
57
86
  process.env.GIT_DIR = join(root, 'not-the-provider-git-directory');
58
87
  try {
59
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('hit');
88
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
60
89
  } finally {
61
90
  if (saved === undefined) delete process.env.GIT_DIR;
62
91
  else process.env.GIT_DIR = saved;
63
92
  }
64
93
  });
94
+ it("reads provider provenance without the operator's global git configuration", async () => {
95
+ // The cowshed sandbox denies the operator's global git configuration to a workspace's Nx daemon, which runs these
96
+ // hooks under a host client's HOME; git then dies "unable to access". A self-referencing link fails git the same
97
+ // way (ELOOP), where an unreadable file would only warn (EACCES).
98
+ const home = join(root, 'operator-home');
99
+ await mkdir(home);
100
+ await symlink('.gitconfig', join(home, '.gitconfig'));
101
+ const names = ['HOME', 'XDG_CONFIG_HOME', 'GIT_CONFIG_GLOBAL', 'GIT_CONFIG_NOSYSTEM'] as const;
102
+ const saved = names.map((name) => [name, process.env[name]] as const);
103
+ for (const name of names) delete process.env[name];
104
+ process.env.HOME = home;
105
+ try {
106
+ const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
107
+ expect(captured.ok ? 'captured' : captured.detail).toBe('captured');
108
+ expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
109
+ } finally {
110
+ for (const [name, value] of saved) {
111
+ if (value === undefined) delete process.env[name];
112
+ else process.env[name] = value;
113
+ }
114
+ }
115
+ });
65
116
  it('names current hashes, HEAD/tree, independent file digests, link text and empty directory modes', async () => {
66
- const result = providerReceipt(root, task.id, [task], proof, expandOutputs);
117
+ const result = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
67
118
  expect(result.disposition).toBe('hit');
68
119
  if (result.disposition !== 'hit') throw new Error(result.reason.detail);
69
120
  expect(result.receipt.head).toMatch(/^[a-f0-9]{40,64}$/);
@@ -91,51 +142,93 @@ describe('provider receipt', () => {
91
142
  });
92
143
  });
93
144
 
94
- it('does not refuse an unrelated untracked source when FILE closure is exactly proven', async () => {
145
+ it('ignores unrelated untracked files while retaining tracked-tree production provenance', async () => {
95
146
  await writeFile(join(root, 'unrelated.ts'), 'unrelated');
96
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('hit');
147
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
97
148
  expect(
98
- providerReceipt(root, task.id, [task], { ...proof, kind: 'conservative-provider-source' }, expandOutputs)
99
- .disposition,
100
- ).toBe('failed');
149
+ providerReceipt(
150
+ root,
151
+ task.id,
152
+ [task],
153
+ { ...proof, kind: 'conservative-provider-source' },
154
+ expandOutputs,
155
+ source,
156
+ producer,
157
+ ).disposition,
158
+ ).toBe('hit');
101
159
  });
102
160
 
103
161
  it('refuses modified, deleted, newly matched and index-only dirty FILE inputs', async () => {
104
162
  await writeFile(join(root, 'source.txt'), 'changed');
105
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
163
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
106
164
  git('add', 'source.txt');
107
165
  await writeFile(join(root, 'source.txt'), 'source');
108
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
166
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
109
167
  git('restore', '--staged', 'source.txt');
110
168
  await writeFile(join(root, 'new-source.txt'), 'new');
111
169
  expect(
112
- providerReceipt(root, task.id, [task], { ...proof, files: [...proof.files, 'new-source.txt'] }, expandOutputs)
113
- .disposition,
170
+ providerReceipt(
171
+ root,
172
+ task.id,
173
+ [task],
174
+ { ...proof, files: [...proof.files, 'new-source.txt'] },
175
+ expandOutputs,
176
+ source,
177
+ producer,
178
+ ).disposition,
114
179
  ).toBe('failed');
115
180
  await rm(join(root, 'source.txt'));
116
- expect(providerReceipt(root, task.id, [task], { ...proof, files: [] }, expandOutputs).disposition).toBe('failed');
181
+ expect(
182
+ providerReceipt(root, task.id, [task], { ...proof, files: [] }, expandOutputs, source, producer).disposition,
183
+ ).toBe('failed');
117
184
  });
118
185
 
119
186
  it('recomputes output byte/directory identities after every public mutation', async () => {
120
- const first = providerReceipt(root, task.id, [task], proof, expandOutputs);
187
+ const first = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
121
188
  if (first.disposition !== 'hit') throw new Error(first.reason.detail);
122
189
  await writeFile(join(root, 'output/file'), 'PUBLIC BYTES');
123
190
  await chmod(join(root, 'output/empty'), 0o700);
124
- const next = providerReceipt(root, task.id, [task], proof, expandOutputs);
191
+ const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
125
192
  if (next.disposition !== 'hit') throw new Error(next.reason.detail);
126
193
  expect(next.receipt.tasks[0].outputs).not.toEqual(first.receipt.tasks[0].outputs);
127
194
  expect(next.receipt.tasks[0].outputs.find(({ path }) => path === 'output/empty')).toMatchObject({ mode: 0o700 });
128
195
  });
129
196
 
197
+ it('accepts a new HEAD at the same committed tree without rewriting the producer basis', () => {
198
+ const original = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
199
+ if (original.disposition !== 'hit') throw new Error(original.reason.detail);
200
+ git(
201
+ '-c',
202
+ 'user.name=Receipt fixture',
203
+ '-c',
204
+ 'user.email=receipt@example.invalid',
205
+ 'commit',
206
+ '--allow-empty',
207
+ '-qm',
208
+ 'same tree',
209
+ );
210
+ expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
211
+ const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
212
+ if (next.disposition !== 'hit') throw new Error(next.reason.detail);
213
+ expect(next.receipt.head).toBe(original.receipt.head);
214
+ expect(next.receipt.headTree).toBe(original.receipt.headTree);
215
+ expect(next.receipt.producer.outputSha256).toBe(original.receipt.producer.outputSha256);
216
+ });
217
+ it('revokes a producer pre-source witness for a write/revert even when final bytes match HEAD', async () => {
218
+ await writeFile(join(root, 'source.txt'), 'edited');
219
+ await writeFile(join(root, 'source.txt'), 'source');
220
+ expect(producerSourceUnchanged(root, source).ok).toBe(false);
221
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
222
+ });
130
223
  it('refuses unreadable public bytes, missing outputs and opaque runtime closure', async () => {
131
224
  await chmod(join(root, 'output/file'), 0);
132
225
  try {
133
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
226
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
134
227
  } finally {
135
228
  await chmod(join(root, 'output/file'), 0o600);
136
229
  }
137
230
  await rm(join(root, 'output'), { recursive: true });
138
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
231
+ expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
139
232
  expect(
140
233
  providerReceipt(
141
234
  root,
@@ -143,6 +236,8 @@ describe('provider receipt', () => {
143
236
  [task],
144
237
  { ...proof, runtimeSource: { kind: 'opaque', detail: 'unnameable command input closure' } },
145
238
  expandOutputs,
239
+ source,
240
+ producer,
146
241
  ),
147
242
  ).toMatchObject({
148
243
  disposition: 'failed',