@smoothbricks/nx-plugin 0.6.2 → 0.7.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 (177) hide show
  1. package/README.md +417 -171
  2. package/dist/.build-inputs.json +39 -28
  3. package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
  4. package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-go-test-build.js +79 -0
  6. package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
  7. package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-go-test-run.js +129 -0
  9. package/dist/bin/smoo-nx-publish.d.ts +3 -0
  10. package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-publish.js +3 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +9 -8
  15. package/dist/cargo-retention-hook.d.ts +6 -2
  16. package/dist/cargo-retention-hook.d.ts.map +1 -1
  17. package/dist/cargo-retention-hook.js +13 -7
  18. package/dist/cargo-workspace.d.ts +10 -20
  19. package/dist/cargo-workspace.d.ts.map +1 -1
  20. package/dist/cargo-workspace.js +12 -22
  21. package/dist/cross-check-policy.d.ts +2 -2
  22. package/dist/cross-check-policy.js +2 -2
  23. package/dist/deploy-policy.d.ts +6 -0
  24. package/dist/deploy-policy.d.ts.map +1 -1
  25. package/dist/deploy-policy.js +11 -0
  26. package/dist/eslint-file-set.d.ts +4 -1
  27. package/dist/eslint-file-set.d.ts.map +1 -1
  28. package/dist/eslint-sources.d.ts +25 -0
  29. package/dist/eslint-sources.d.ts.map +1 -0
  30. package/dist/eslint-sources.js +99 -0
  31. package/dist/executors/all-verdicts/executor.d.ts +2 -1
  32. package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
  33. package/dist/executors/all-verdicts/executor.js +48 -2
  34. package/dist/executors/all-verdicts/schema.d.ts +13 -0
  35. package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
  36. package/dist/executors/all-verdicts/schema.js +7 -0
  37. package/dist/executors/bounded-exec/bounds.d.ts +57 -8
  38. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  39. package/dist/executors/bounded-exec/bounds.js +100 -11
  40. package/dist/executors/bounded-exec/executor.d.ts +2 -1
  41. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  42. package/dist/executors/bounded-exec/executor.js +289 -34
  43. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
  44. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  45. package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
  46. package/dist/executors/bounded-exec/mbx-pool.d.ts +56 -10
  47. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  48. package/dist/executors/bounded-exec/mbx-pool.js +145 -11
  49. package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
  50. package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
  51. package/dist/executors/bounded-exec/mbx-queue.js +229 -0
  52. package/dist/executors/bounded-exec/progress.d.ts +9 -2
  53. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  54. package/dist/executors/bounded-exec/progress.js +151 -25
  55. package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
  56. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  57. package/dist/executors/bounded-exec/runner-sizing.js +55 -4
  58. package/dist/executors/bounded-exec/runtime-pin.js +1 -1
  59. package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
  60. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/test-result-writer.js +126 -0
  62. package/dist/executors/bounded-exec/test-results.d.ts +33 -0
  63. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
  64. package/dist/executors/bounded-exec/test-results.js +33 -0
  65. package/dist/executors/bounded-exec/verdict.d.ts +26 -2
  66. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  67. package/dist/executors/bounded-exec/verdict.js +108 -4
  68. package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
  69. package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
  70. package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
  71. package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
  72. package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
  73. package/dist/executors/wrangler-deploy/executor.js +43 -0
  74. package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
  75. package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
  76. package/dist/executors/wrangler-deploy/hasher.js +90 -0
  77. package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
  78. package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
  79. package/dist/go-tests.d.ts +30 -0
  80. package/dist/go-tests.d.ts.map +1 -0
  81. package/dist/go-tests.js +43 -0
  82. package/dist/index.d.ts +12 -4
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +338 -295
  85. package/dist/managed-files/files.d.ts.map +1 -1
  86. package/dist/managed-files/files.js +5 -0
  87. package/dist/nx-publish.d.ts +24 -0
  88. package/dist/nx-publish.d.ts.map +1 -0
  89. package/dist/nx-publish.js +150 -0
  90. package/dist/process-group.js +2 -2
  91. package/dist/runtime-input-policy.d.ts +17 -3
  92. package/dist/runtime-input-policy.d.ts.map +1 -1
  93. package/dist/runtime-input-policy.js +4 -4
  94. package/dist/test-timings.d.ts +23 -4
  95. package/dist/test-timings.d.ts.map +1 -1
  96. package/dist/test-timings.js +72 -12
  97. package/dist/tool-bins.d.ts +6 -8
  98. package/dist/tool-bins.d.ts.map +1 -1
  99. package/dist/tool-bins.js +7 -5
  100. package/dist/version-actions.cjs +10 -11
  101. package/dist/version-actions.d.cts.map +1 -1
  102. package/dist/workspace-config-policy.d.ts.map +1 -1
  103. package/dist/workspace-config-policy.js +17 -22
  104. package/dist/workspace-index.d.ts +7 -0
  105. package/dist/workspace-index.d.ts.map +1 -1
  106. package/dist/workspace-index.js +11 -0
  107. package/dist/workspace-manifest.js +3 -3
  108. package/executors.json +7 -6
  109. package/managed/raw/patches/nx@23.2.1.patch +118 -24
  110. package/managed/raw/patches/ttsc@0.34.1.patch +139 -0
  111. package/managed/raw/tooling/devenv +1 -2
  112. package/managed/raw/tooling/direnv/developer-links.ts +124 -51
  113. package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
  114. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
  115. package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
  116. package/managed/raw/tooling/direnv/setup-environment.ts +49 -24
  117. package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
  118. package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
  119. package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
  120. package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
  121. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
  122. package/package.json +277 -11
  123. package/runtime/nx-publish/.build-inputs.json +11 -0
  124. package/runtime/nx-publish/cache_adapter.js +45 -0
  125. package/runtime/nx-publish/nx_publish.js +60 -0
  126. package/runtime-input.sh +62 -26
  127. package/src/bin/smoo-nx-go-test-build.ts +83 -0
  128. package/src/bin/smoo-nx-go-test-run.ts +140 -0
  129. package/src/bin/smoo-nx-publish.ts +4 -0
  130. package/src/bounded-test-policy.ts +9 -8
  131. package/src/cargo-retention-hook.ts +16 -10
  132. package/src/cargo-workspace.ts +12 -24
  133. package/src/cross-check-policy.ts +2 -2
  134. package/src/deploy-policy.ts +11 -0
  135. package/src/eslint-file-set.ts +4 -1
  136. package/src/eslint-sources.ts +134 -0
  137. package/src/executors/all-verdicts/executor.ts +58 -3
  138. package/src/executors/all-verdicts/schema.json +4 -0
  139. package/src/executors/all-verdicts/schema.ts +14 -0
  140. package/src/executors/bounded-exec/bounds.ts +132 -15
  141. package/src/executors/bounded-exec/executor.ts +329 -34
  142. package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
  143. package/src/executors/bounded-exec/mbx-pool.ts +158 -17
  144. package/src/executors/bounded-exec/mbx-queue.ts +170 -0
  145. package/src/executors/bounded-exec/progress.ts +171 -18
  146. package/src/executors/bounded-exec/runner-sizing.ts +73 -7
  147. package/src/executors/bounded-exec/runtime-pin.ts +1 -1
  148. package/src/executors/bounded-exec/test-result-writer.ts +152 -0
  149. package/src/executors/bounded-exec/test-results.ts +39 -0
  150. package/src/executors/bounded-exec/verdict.ts +115 -5
  151. package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
  152. package/src/executors/wrangler-deploy/executor.ts +63 -0
  153. package/src/executors/wrangler-deploy/hasher.ts +111 -0
  154. package/src/executors/wrangler-deploy/schema.json +16 -0
  155. package/src/executors/wrangler-deploy/schema.ts +4 -0
  156. package/src/go-tests.ts +67 -0
  157. package/src/index.ts +368 -323
  158. package/src/managed-files/files.ts +5 -0
  159. package/src/nx-publish.ts +157 -0
  160. package/src/process-group.ts +2 -2
  161. package/src/runtime-input-policy.ts +4 -4
  162. package/src/test-timings.ts +72 -14
  163. package/src/tool-bins.ts +13 -9
  164. package/src/version-actions.cts +10 -11
  165. package/src/workspace-config-policy.ts +20 -29
  166. package/src/workspace-index.ts +12 -0
  167. package/src/workspace-manifest.ts +3 -3
  168. package/test-timings.json +131 -125
  169. package/dist/executors/clean-outputs/executor.d.ts +0 -26
  170. package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
  171. package/dist/executors/clean-outputs/executor.js +0 -83
  172. package/dist/executors/clean-outputs/schema.d.ts +0 -4
  173. package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
  174. package/src/executors/clean-outputs/executor.ts +0 -131
  175. package/src/executors/clean-outputs/schema.json +0 -15
  176. package/src/executors/clean-outputs/schema.ts +0 -3
  177. /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -33,6 +33,16 @@
33
33
  "import": "./dist/bounded-test-policy.js",
34
34
  "default": "./dist/bounded-test-policy.js"
35
35
  },
36
+ "./test-results": {
37
+ "types": "./dist/executors/bounded-exec/test-results.d.ts",
38
+ "import": "./dist/executors/bounded-exec/test-results.js",
39
+ "default": "./dist/executors/bounded-exec/test-results.js"
40
+ },
41
+ "./test-results/host": {
42
+ "types": "./dist/executors/bounded-exec/test-result-writer.d.ts",
43
+ "import": "./dist/executors/bounded-exec/test-result-writer.js",
44
+ "default": "./dist/executors/bounded-exec/test-result-writer.js"
45
+ },
36
46
  "./build-state-output-policy": {
37
47
  "types": "./dist/build-state-output-policy.d.ts",
38
48
  "import": "./dist/build-state-output-policy.js",
@@ -138,6 +148,11 @@
138
148
  "import": "./dist/deploy-policy.js",
139
149
  "default": "./dist/deploy-policy.js"
140
150
  },
151
+ "./nx-publish": {
152
+ "types": "./dist/nx-publish.d.ts",
153
+ "import": "./dist/nx-publish.js",
154
+ "default": "./dist/nx-publish.js"
155
+ },
141
156
  "./managed-assets": {
142
157
  "types": "./dist/managed-assets.d.ts",
143
158
  "import": "./dist/managed-assets.js",
@@ -212,7 +227,10 @@
212
227
  "smoo-nx-bound-failures": "./dist/bin/smoo-nx-bound-failures.js",
213
228
  "smoo-nx-test-walks": "./dist/bin/smoo-nx-test-walks.js",
214
229
  "smoo-nx-test-clocks": "./dist/bin/smoo-nx-test-clocks.js",
215
- "smoo-nx-forbidden-spellings": "./dist/bin/smoo-nx-forbidden-spellings.js"
230
+ "smoo-nx-publish": "./dist/bin/smoo-nx-publish.js",
231
+ "smoo-nx-forbidden-spellings": "./dist/bin/smoo-nx-forbidden-spellings.js",
232
+ "smoo-nx-go-test-build": "./dist/bin/smoo-nx-go-test-build.js",
233
+ "smoo-nx-go-test-run": "./dist/bin/smoo-nx-go-test-run.js"
216
234
  },
217
235
  "generators": "./generators.json",
218
236
  "executors": "./executors.json",
@@ -221,6 +239,114 @@
221
239
  },
222
240
  "nx": {
223
241
  "targets": {
242
+ "build": {
243
+ "dependsOn": [
244
+ "...",
245
+ "copy-nx-publish-assets"
246
+ ]
247
+ },
248
+ "copy-nx-publish-assets": {
249
+ "executor": "nx:run-commands",
250
+ "cache": true,
251
+ "dependsOn": [
252
+ {
253
+ "projects": [
254
+ "build-inputs"
255
+ ],
256
+ "target": "build"
257
+ }
258
+ ],
259
+ "inputs": [
260
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js",
261
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js",
262
+ {
263
+ "externalDependencies": []
264
+ },
265
+ {
266
+ "dependentTasksOutputFiles": "**/*.js",
267
+ "transitive": false
268
+ }
269
+ ],
270
+ "outputs": [
271
+ "{projectRoot}/runtime/nx-publish/"
272
+ ],
273
+ "options": {
274
+ "command": "asset_source=../cowshed/crates/cowshed-core/src/build_volume; if [ -e runtime/nx-publish ]; then rm -r runtime/nx-publish; fi && mkdir -p runtime/nx-publish && cp \"$asset_source/cache_adapter.js\" \"$asset_source/nx_publish.js\" runtime/nx-publish/ && node ../build-inputs/dist/ts/bin/smoo-nx-build-inputs.js --input \"$asset_source/cache_adapter.js\" --input \"$asset_source/nx_publish.js\" --output runtime/nx-publish",
275
+ "cwd": "{projectRoot}"
276
+ }
277
+ },
278
+ "test-nx-publish": {
279
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
280
+ "cache": true,
281
+ "inputs": [
282
+ "...",
283
+ "default",
284
+ "^dependencyDefault",
285
+ "bunToolchain",
286
+ {
287
+ "runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh node --version"
288
+ },
289
+ {
290
+ "dependentTasksOutputFiles": "**/dist/bin/smoo-nx-publish.js",
291
+ "transitive": true
292
+ },
293
+ {
294
+ "dependentTasksOutputFiles": "**/dist/nx-publish.js",
295
+ "transitive": true
296
+ },
297
+ {
298
+ "dependentTasksOutputFiles": "**/runtime/nx-publish/*.js",
299
+ "transitive": true
300
+ }
301
+ ],
302
+ "dependsOn": [
303
+ "...",
304
+ "tsc-js",
305
+ "copy-nx-publish-assets",
306
+ "typecheck-tests"
307
+ ],
308
+ "options": {
309
+ "command": "bun test --timeout=0 ./src/__tests__/nx-publish.cases.ts ./src/__tests__/nx-publish-bin.cases.ts",
310
+ "cwd": "{projectRoot}",
311
+ "idleTimeoutMs": 180000,
312
+ "killAfterMs": 10000
313
+ }
314
+ },
315
+ "test-go-bins": {
316
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
317
+ "cache": true,
318
+ "inputs": [
319
+ "...",
320
+ "default",
321
+ "^dependencyDefault",
322
+ "bunToolchain",
323
+ {
324
+ "runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh node --version"
325
+ },
326
+ {
327
+ "runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh go version"
328
+ },
329
+ {
330
+ "dependentTasksOutputFiles": "**/dist/bin/smoo-nx-go-test-*.js",
331
+ "transitive": true
332
+ },
333
+ {
334
+ "dependentTasksOutputFiles": "**/dist/go-tests.js",
335
+ "transitive": true
336
+ }
337
+ ],
338
+ "dependsOn": [
339
+ "...",
340
+ "tsc-js",
341
+ "typecheck-tests"
342
+ ],
343
+ "options": {
344
+ "command": "bun test --timeout=0 ./src/__tests__/go-test-bins.cases.ts",
345
+ "cwd": "{projectRoot}",
346
+ "idleTimeoutMs": 180000,
347
+ "killAfterMs": 10000
348
+ }
349
+ },
224
350
  "lint": {},
225
351
  "test": {
226
352
  "executor": "nx:noop",
@@ -230,13 +356,78 @@
230
356
  "test-shard3",
231
357
  "test-shard4",
232
358
  "test-host",
233
- "test-pool-silence"
359
+ "test-pool-silence",
360
+ "test-nx-publish",
361
+ "test-go-bins",
362
+ "test-results-runtime"
234
363
  ]
235
364
  },
365
+ "closed-results-runtime-bundle": {
366
+ "executor": "nx:run-commands",
367
+ "cache": true,
368
+ "metadata": {
369
+ "smooTaskKind": "test"
370
+ },
371
+ "dependsOn": [
372
+ "tsc-js",
373
+ "typecheck-tests"
374
+ ],
375
+ "inputs": [
376
+ "{projectRoot}/src/__tests__/test-results-runtime.entry.ts",
377
+ "{projectRoot}/package.json",
378
+ "{projectRoot}/tsconfig.json",
379
+ "{workspaceRoot}/tsconfig.base.json",
380
+ "bunToolchain",
381
+ {
382
+ "externalDependencies": [
383
+ "bun-lock:packages/nx-plugin"
384
+ ]
385
+ },
386
+ {
387
+ "dependentTasksOutputFiles": "**/dist/**/*.js",
388
+ "transitive": false
389
+ }
390
+ ],
391
+ "outputs": [
392
+ "{projectRoot}/.cache/test-results-runtime/"
393
+ ],
394
+ "options": {
395
+ "command": "bun build src/__tests__/test-results-runtime.entry.ts --target=bun --conditions=production --outfile=.cache/test-results-runtime/bundle.mjs",
396
+ "cwd": "{projectRoot}"
397
+ }
398
+ },
399
+ "test-results-runtime": {
400
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
401
+ "cache": true,
402
+ "dependsOn": [
403
+ "...",
404
+ "closed-results-runtime-bundle"
405
+ ],
406
+ "inputs": [
407
+ "...",
408
+ "bunToolchain",
409
+ {
410
+ "externalDependencies": [
411
+ "bun-lock:packages/nx-plugin"
412
+ ]
413
+ },
414
+ {
415
+ "dependentTasksOutputFiles": "**/test-results-runtime/bundle.mjs",
416
+ "transitive": false
417
+ }
418
+ ],
419
+ "options": {
420
+ "command": "bun .cache/test-results-runtime/bundle.mjs",
421
+ "cwd": "{projectRoot}",
422
+ "idleTimeoutMs": 180000,
423
+ "killAfterMs": 10000
424
+ }
425
+ },
236
426
  "test-pool-silence": {
237
427
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
238
428
  "cache": true,
239
429
  "inputs": [
430
+ "...",
240
431
  "default",
241
432
  "^dependencyDefault",
242
433
  "bunToolchain",
@@ -249,14 +440,49 @@
249
440
  "killAfterMs": 10000
250
441
  }
251
442
  },
443
+ "cargo-stream-archive": {
444
+ "executor": "nx:run-commands",
445
+ "cache": true,
446
+ "metadata": {
447
+ "smooTaskKind": "test"
448
+ },
449
+ "inputs": [
450
+ "{projectRoot}/test-fixtures/stream-witness/**/*",
451
+ "!{projectRoot}/test-fixtures/stream-witness/target/**/*",
452
+ "{workspaceRoot}/.cargo/config",
453
+ "{workspaceRoot}/.cargo/config.toml",
454
+ "cargoToolchain",
455
+ {
456
+ "externalDependencies": []
457
+ }
458
+ ],
459
+ "outputs": [
460
+ "{projectRoot}/.cache/test-stream/archive.tar.zst"
461
+ ],
462
+ "options": {
463
+ "command": "mkdir -p .cache/test-stream && cargo --frozen nextest archive --manifest-path test-fixtures/stream-witness/Cargo.toml --archive-file .cache/test-stream/archive.tar.zst --user-config-file none",
464
+ "cwd": "{projectRoot}"
465
+ }
466
+ },
252
467
  "test-shard1": {
253
468
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
254
469
  "cache": true,
255
470
  "inputs": [
471
+ "...",
256
472
  "default",
257
473
  "^dependencyDefault",
258
474
  "bunToolchain",
259
- "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs"
475
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs",
476
+ {
477
+ "dependentTasksOutputFiles": "**/test-stream/archive.tar.zst",
478
+ "transitive": false
479
+ }
480
+ ],
481
+ "dependsOn": [
482
+ "...",
483
+ "^build",
484
+ "build",
485
+ "cargo-stream-archive"
260
486
  ],
261
487
  "options": {
262
488
  "command": "bun test --timeout=0 --timings=test-timings.json --shard=1/4 --path-ignore-patterns='**/*-host.test.ts'",
@@ -269,10 +495,21 @@
269
495
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
270
496
  "cache": true,
271
497
  "inputs": [
498
+ "...",
272
499
  "default",
273
500
  "^dependencyDefault",
274
501
  "bunToolchain",
275
- "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs"
502
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs",
503
+ {
504
+ "dependentTasksOutputFiles": "**/test-stream/archive.tar.zst",
505
+ "transitive": false
506
+ }
507
+ ],
508
+ "dependsOn": [
509
+ "...",
510
+ "^build",
511
+ "build",
512
+ "cargo-stream-archive"
276
513
  ],
277
514
  "options": {
278
515
  "command": "bun test --timeout=0 --timings=test-timings.json --shard=2/4 --path-ignore-patterns='**/*-host.test.ts'",
@@ -285,10 +522,21 @@
285
522
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
286
523
  "cache": true,
287
524
  "inputs": [
525
+ "...",
288
526
  "default",
289
527
  "^dependencyDefault",
290
528
  "bunToolchain",
291
- "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs"
529
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs",
530
+ {
531
+ "dependentTasksOutputFiles": "**/test-stream/archive.tar.zst",
532
+ "transitive": false
533
+ }
534
+ ],
535
+ "dependsOn": [
536
+ "...",
537
+ "^build",
538
+ "build",
539
+ "cargo-stream-archive"
292
540
  ],
293
541
  "options": {
294
542
  "command": "bun test --timeout=0 --timings=test-timings.json --shard=3/4 --path-ignore-patterns='**/*-host.test.ts'",
@@ -301,10 +549,21 @@
301
549
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
302
550
  "cache": true,
303
551
  "inputs": [
552
+ "...",
304
553
  "default",
305
554
  "^dependencyDefault",
306
555
  "bunToolchain",
307
- "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs"
556
+ "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs",
557
+ {
558
+ "dependentTasksOutputFiles": "**/test-stream/archive.tar.zst",
559
+ "transitive": false
560
+ }
561
+ ],
562
+ "dependsOn": [
563
+ "...",
564
+ "^build",
565
+ "build",
566
+ "cargo-stream-archive"
308
567
  ],
309
568
  "options": {
310
569
  "command": "bun test --timeout=0 --timings=test-timings.json --shard=4/4 --path-ignore-patterns='**/*-host.test.ts'",
@@ -317,6 +576,7 @@
317
576
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
318
577
  "cache": true,
319
578
  "inputs": [
579
+ "...",
320
580
  "default",
321
581
  "^dependencyDefault",
322
582
  "bunToolchain",
@@ -329,6 +589,7 @@
329
589
  }
330
590
  ],
331
591
  "dependsOn": [
592
+ "...",
332
593
  {
333
594
  "projects": [
334
595
  "cowshed"
@@ -356,6 +617,9 @@
356
617
  "tags": [
357
618
  "npm:public"
358
619
  ],
620
+ "implicitDependencies": [
621
+ "!cowshed"
622
+ ],
359
623
  "name": "nx-plugin"
360
624
  },
361
625
  "files": [
@@ -371,7 +635,8 @@
371
635
  "!**/*.tsbuildinfo",
372
636
  "!src/**/*.test.ts",
373
637
  "!src/**/__tests__",
374
- "managed"
638
+ "managed",
639
+ "runtime/nx-publish"
375
640
  ],
376
641
  "license": "MIT",
377
642
  "publishConfig": {
@@ -384,9 +649,10 @@
384
649
  },
385
650
  "dependencies": {
386
651
  "@nx/js": "23.2.1",
387
- "@smoothbricks/build-inputs": "0.0.1",
652
+ "@smoothbricks/build-inputs": "0.0.2",
388
653
  "@smoothbricks/cargo-retain": "0.0.1",
389
- "@smoothbricks/nextest-extract": "0.0.1",
654
+ "@smoothbricks/cowshed": "0.4.3",
655
+ "@smoothbricks/nextest-extract": "0.0.2",
390
656
  "jsonc-parser": "^3.3.1",
391
657
  "minimatch": "10.2.5",
392
658
  "nx": "latest",
@@ -398,7 +664,7 @@
398
664
  "yaml": "^2.9.0"
399
665
  },
400
666
  "devDependencies": {
401
- "@smoothbricks/lmao": "0.5.8",
667
+ "@smoothbricks/lmao": "0.6.0",
402
668
  "@smoothbricks/validation": "0.1.13",
403
669
  "fast-check": "^4.4.0"
404
670
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 1,
3
+ "files": {
4
+ "packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js": "3355da0dc7972b2fe981ca2217a1f373e60004dedeaa62c31131315bba2f4f18",
5
+ "packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js": "83ccff840b9d3e53cdcc629ffc2af6e64c956a0fcbaaa6c5ce0e59fe0dce436b"
6
+ },
7
+ "producer": {
8
+ "project": "nx-plugin",
9
+ "target": "copy-nx-publish-assets"
10
+ }
11
+ }
@@ -0,0 +1,45 @@
1
+ // One version-sensitive boundary for the checkout's own Nx cache (05_gateway.md, "Publication").
2
+ // DbCache and its native cache field are INTERNAL Nx 23.2.1 APIs, not a public stable adapter.
3
+ // biome-ignore lint/correctness/noUnusedVariables: invoked by the bodies cache_adapter::script prefixes (cache_adapter.rs), not from this file.
4
+ function openNxCache(root) {
5
+ const path = require('node:path');
6
+ const { createRequire } = require('node:module');
7
+ if (!root || !path.isAbsolute(root)) {
8
+ throw new Error(`Nx cache adapter requires an absolute checkout root, got ${JSON.stringify(root)}`);
9
+ }
10
+ const requireNx = createRequire(path.join(root, 'package.json'));
11
+ const version = requireNx('nx/package.json').version;
12
+ if (version !== '23.2.1') {
13
+ throw new Error(
14
+ `Nx cache adapter supports exactly Nx 23.2.1, not ${version}; requalify the adapter before upgrading`,
15
+ );
16
+ }
17
+ // Nx fixes these paths at module load. Every root is handled in its own existing job process.
18
+ process.env.NX_WORKSPACE_ROOT_PATH = root;
19
+ process.env.NX_WORKSPACE_DATA_DIRECTORY = path.join(root, '.nx', 'workspace-data');
20
+ process.env.NX_CACHE_DIRECTORY = path.join(root, '.nx', 'cache');
21
+ if (requireNx('nx/src/native').IS_WASM) {
22
+ throw new Error('The Nx cache adapter requires the pinned native database cache, not WASM');
23
+ }
24
+ // Nx resolves its workspace-data directory itself; prove it is this checkout's before any database is opened.
25
+ const { sharedDataDirectory } = requireNx('nx/src/utils/cache-directory');
26
+ const workspaceData = path.join(root, '.nx', 'workspace-data');
27
+ const actualWorkspaceData = sharedDataDirectory(root, 'workspace-data');
28
+ if (path.resolve(actualWorkspaceData) !== path.resolve(workspaceData)) {
29
+ throw new Error(
30
+ `Nx 23.2.1 workspace-data directory changed: expected ${workspaceData}, actual ${actualWorkspaceData}`,
31
+ );
32
+ }
33
+ const { DbCache } = requireNx('nx/src/tasks-runner/cache');
34
+ // Construction, not init(): Nx owns all schema/metadata setup; no remote loader is contacted.
35
+ const cache = new DbCache({ nxCloudRemoteCache: null, skipRemoteCache: true });
36
+ const native = cache.cache;
37
+ if (!native || typeof native.get !== 'function' || typeof native.cacheDirectory !== 'string') {
38
+ throw new Error('Nx 23.2.1 DbCache native cache surface changed; requalify the adapter');
39
+ }
40
+ const expectedCacheDir = path.join(root, '.nx', 'cache');
41
+ if (path.resolve(native.cacheDirectory) !== path.resolve(expectedCacheDir)) {
42
+ throw new Error(`Nx 23.2.1 cache directory changed: expected ${expectedCacheDir}, actual ${native.cacheDirectory}`);
43
+ }
44
+ return { requireNx, cache, cacheDir: native.cacheDirectory, getLocal: (hash) => native.get(hash) };
45
+ }
@@ -0,0 +1,60 @@
1
+ // A land's publish (05_gateway.md "`/nx/v1/cache/{hash}`"): after the gate passed, every task result
2
+ // the gate's Nx runs named is stored to the project's Nx cache from this checkout's own cache, as
3
+ // plain PUTs by the stock native client. Prefixed once by cache_adapter::script.
4
+ // Usage: node - <absolute Nx root> <JSON array of task hashes>; answers one JSON line on stdout.
5
+ const answer = process.stdout.write.bind(process.stdout);
6
+ process.stdout.write = process.stderr.write.bind(process.stderr);
7
+ const fs = require('node:fs');
8
+ const path = require('node:path');
9
+ const [root, hashesJson] = process.argv.slice(2);
10
+ if (!root || !path.isAbsolute(root) || hashesJson === undefined) {
11
+ throw new Error('usage: node - <absolute Nx root> <JSON array of task hashes>');
12
+ }
13
+ const hashes = JSON.parse(hashesJson);
14
+ if (!Array.isArray(hashes) || new Set(hashes).size !== hashes.length) {
15
+ throw new Error('the land must name distinct task hashes');
16
+ }
17
+ // One validated Nx task key (05_gateway.md): the charset the gateway's route and the store accept.
18
+ for (const hash of hashes) {
19
+ if (typeof hash !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(hash)) {
20
+ throw new Error(`invalid Nx task hash ${JSON.stringify(hash)}`);
21
+ }
22
+ }
23
+ const server = process.env.NX_SELF_HOSTED_REMOTE_CACHE_SERVER;
24
+ if (!server) throw new Error('NX_SELF_HOSTED_REMOTE_CACHE_SERVER names no project Nx cache');
25
+
26
+ async function publish() {
27
+ const { requireNx, cacheDir, getLocal } = openNxCache(root);
28
+ const { HttpRemoteCache } = requireNx('nx/src/native');
29
+ const remote = new HttpRemoteCache();
30
+ let published = 0;
31
+ let existing = 0;
32
+ let skipped = 0;
33
+ for (const hash of hashes) {
34
+ const result = getLocal(hash);
35
+ // A task Nx does not cache, or one that failed, has no complete entry to share.
36
+ if (result?.code !== 0 || !fs.statSync(result.outputsPath, { throwIfNoEntry: false })?.isDirectory()) {
37
+ skipped += 1;
38
+ continue;
39
+ }
40
+ if (await remote.store(hash, cacheDir, result.terminalOutput ?? '', 0)) {
41
+ published += 1;
42
+ continue;
43
+ }
44
+ // The native store answers false for an existing key (409) and for a refusal: tell them apart.
45
+ const response = await fetch(`${server}/v1/cache/${hash}`);
46
+ await response.body?.cancel();
47
+ if (response.status !== 200) {
48
+ throw new Error(`task ${hash} was not stored, and the project cache answers GET ${response.status}`);
49
+ }
50
+ existing += 1;
51
+ }
52
+ return { published, existing, skipped };
53
+ }
54
+ publish().then(
55
+ (result) => answer(`${JSON.stringify(result)}\n`),
56
+ (error) => {
57
+ console.error(error);
58
+ process.exitCode = 1;
59
+ },
60
+ );
package/runtime-input.sh CHANGED
@@ -27,43 +27,70 @@
27
27
  # are visible.
28
28
  #
29
29
  # A failed command's own stdout never reaches the hasher either: it is
30
- # captured to a file from the start, retained in the failure record, and the
31
- # only byte this script emits on failure is the 0xFF poison above. Nothing
32
- # from a failure path flows into the hash as input bytes. Successful stdout
33
- # is replayed from the capture file byte-exact.
30
+ # captured from the start, retained in the failure record, and the only byte
31
+ # this script emits on failure is the 0xFF poison above. Nothing from a
32
+ # failure path flows into the hash as input bytes. Successful stdout is
33
+ # replayed from the capture.
34
34
  #
35
35
  # The command's stderr is not part of the value; it surfaces only on failure.
36
36
  # Diagnostics name temp paths, process ids and the boundary the input ran in
37
37
  # (an Nx daemon inside a sandbox runs inputs with the sandbox's view of the
38
38
  # client's environment), none of which is the input.
39
+ # A successful input costs the command alone: both of its streams are captured
40
+ # by command substitution, a forked subshell rather than a program run, so the
41
+ # success path executes nothing but the command. Under Nx a runtime input runs
42
+ # on every hash of every task that names it, and each program the wrapper ran
43
+ # cost more than the input it wrapped. The command's stdout goes to the outer
44
+ # capture as it is written; its stderr, then its exit status, are captured
45
+ # within, and follow it with their length, so the value is cut from the end and
46
+ # no delimiter has to be absent from the output. Lengths and patterns count
47
+ # bytes (LC_ALL=C), set only once the command has run.
48
+ #
49
+ # The one residual difference: a shell variable cannot hold a NUL byte, so a
50
+ # NUL in either stream is dropped. Two outputs that differ only in NUL bytes
51
+ # share a key; a command that might print a NUL hex-encodes its output.
39
52
  set -u
40
53
  if [ "$#" -eq 0 ]; then
41
54
  echo 'usage: runtime-input.sh <command> [argument...]' >&2
42
55
  printf '\377'
43
56
  exit 64
44
57
  fi
45
- if diagnostic=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input-stderr.XXXXXXXXXX") &&
46
- captured=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input-stdout.XXXXXXXXXX"); then
47
- :
48
- else
58
+ both=$(
59
+ exec 3>&1
60
+ ran=$("$@" 2>&1 1>&3 3>&-; printf ':%s' "$?")
61
+ LC_ALL=C
62
+ printf '%s;%s' "$ran" "${#ran}"
63
+ )
64
+ LC_ALL=C
65
+ case $both in
66
+ *';'*) ;;
67
+ *)
49
68
  printf 'runtime input could not capture streams: %s\n' "$*" >&2
50
69
  printf '\377'
51
70
  exit 73
52
- fi
53
- if "$@" >"$captured" 2>"$diagnostic"; then
54
- cat "$captured"
55
- rm -f "$diagnostic" "$captured"
71
+ ;;
72
+ esac
73
+ length=${both##*;}
74
+ both=${both%;*}
75
+ tail=
76
+ while [ "${#tail}" -lt "$length" ]; do
77
+ tail="$tail?"
78
+ done
79
+ stdout=${both%$tail}
80
+ ran=${both#"$stdout"}
81
+ status=${ran##*:}
82
+ stderr=${ran%:*}
83
+ if [ "$status" -eq 0 ]; then
84
+ printf '%s' "$stdout"
56
85
  exit 0
57
- else
58
- status=$?
59
86
  fi
60
- cat "$diagnostic" >&2
87
+ printf '%s' "$stderr" >&2
61
88
  if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
62
89
  mktemp -d "$PWD/.runtime-input-failures/failure.XXXXXXXXXX"); then
63
90
  if printf '%s\000' "$@" >"$record/argv" &&
64
91
  printf '%s\n' "$status" >"$record/exit-status" &&
65
- mv "$diagnostic" "$record/stderr" &&
66
- mv "$captured" "$record/stdout" && {
92
+ printf '%s' "$stderr" >"$record/stderr" &&
93
+ printf '%s' "$stdout" >"$record/stdout" && {
67
94
  printf 'runtime input exited %s: %s\n' "$status" "$*"
68
95
  printf 'working directory: %s\n' "$PWD"
69
96
  index=0
@@ -73,21 +100,30 @@ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
73
100
  index=$((index + 1))
74
101
  done
75
102
  printf 'original stderr:\n'
76
- cat "$record/stderr"
103
+ printf '%s' "$stderr"
77
104
  printf 'original stdout (never hashed):\n'
78
- cat "$record/stdout"
105
+ printf '%s' "$stdout"
79
106
  } >"$record/report"; then
80
107
  printf '\nruntime input exited %s: %s; evidence: %s/report\n' "$status" "$*" "$record" >&2
81
- # A detached daemon may have no terminal. Preserve that error too, rather
82
- # than sending it into Nx's discarded stderr or swallowing it.
83
- (exec 4>/dev/tty && cat "$record/report" >&4) 2>"$record/terminal-error"
108
+ # Nx discards this stderr, so a controlling terminal is the one live display
109
+ # of the report. Nx's daemon has none (ENXIO) and cowshed's sandbox denies
110
+ # it (EPERM). Having no terminal is no failure of the input: the shell's
111
+ # refusal of the open joins the notice above on stderr, and the record
112
+ # gains nothing. `command` keeps that refusal from exiting the shell. A
113
+ # write that fails on a terminal that did open is retained in the record.
114
+ if command exec 4>/dev/tty; then
115
+ if ! failure=$(cat "$record/report" 2>&1 >&4); then
116
+ printf '%s\n' "$failure" >"$record/terminal-error"
117
+ fi
118
+ exec 4>&-
119
+ fi
84
120
  else
85
- printf '\nruntime input exited %s: %s; evidence incomplete: %s; stderr capture: %s\n' \
86
- "$status" "$*" "$record" "$diagnostic" >&2
121
+ printf '\nruntime input exited %s: %s; evidence incomplete: %s\n' \
122
+ "$status" "$*" "$record" >&2
87
123
  fi
88
124
  else
89
- printf '\nruntime input exited %s: %s; could not retain evidence; stderr capture: %s\n' \
90
- "$status" "$*" "$diagnostic" >&2
125
+ printf '\nruntime input exited %s: %s; could not retain evidence\n' \
126
+ "$status" "$*" >&2
91
127
  fi
92
128
  printf '\377'
93
129
  exit "$status"