@smoothbricks/nx-plugin 0.5.7 → 0.6.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 (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -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 +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,10 +1,10 @@
1
1
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
- import { readFile } from 'node:fs/promises';
3
- import { dirname, isAbsolute, join, normalize, posix, relative, resolve, sep } from 'node:path';
2
+ import { readFile, realpath } from 'node:fs/promises';
3
+ import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
4
4
  import { readNxJson } from 'nx/src/config/nx-json.js';
5
5
  import { parse as parseToml, type TomlTable } from 'smol-toml';
6
6
 
7
- import { type CompiledCargoInput, compiledInFiles } from './cargo-source-hash.js';
7
+ import { buildClosure, type CargoResolve, type CompiledCargoInput, compiledInFiles } from './cargo-source-hash.js';
8
8
 
9
9
  export interface CargoWorkspacePackage {
10
10
  name: string;
@@ -223,6 +223,8 @@ export interface CargoPackageTestInputsOptions {
223
223
  /** The cargo workspace root holding the top-level `Cargo.toml`. */
224
224
  absoluteProjectRoot: string;
225
225
  memberDir: string;
226
+ /** Cargo's locked resolve of that workspace, which decides the crates the member's tests build. */
227
+ cargo: CargoResolve;
226
228
  /** Shared across every call of one graph computation; see {@link createCargoInputsCache}. */
227
229
  cache?: CargoInputsCache;
228
230
  }
@@ -258,7 +260,7 @@ export function cargoPackageTestInputs(options: CargoPackageTestInputsOptions):
258
260
  }
259
261
 
260
262
  async function deriveCargoPackageTestInputs(
261
- { workspaceRoot, absoluteProjectRoot, memberDir }: CargoPackageTestInputsOptions,
263
+ { workspaceRoot, absoluteProjectRoot, memberDir, cargo }: CargoPackageTestInputsOptions,
262
264
  cache: CargoInputsCache,
263
265
  ): Promise<string[]> {
264
266
  // Every fileset is anchored at `{workspaceRoot}`, never `{projectRoot}`: Nx
@@ -276,121 +278,58 @@ async function deriveCargoPackageTestInputs(
276
278
  cache.manifests.set(normalized, parsed);
277
279
  return parsed;
278
280
  };
279
- const rootManifest = await loadManifest(join(absoluteProjectRoot, 'Cargo.toml'));
280
- // The closure over in-tree path dependencies, not the direct edge set: a
281
+ // Cargo reports canonical paths, so every path below is related to the canonical roots.
282
+ const [nxRoot, cargoRoot, crateDirectory] = await Promise.all([
283
+ realpath(workspaceRoot),
284
+ realpath(absoluteProjectRoot),
285
+ realpath(join(absoluteProjectRoot, memberDir)),
286
+ ]);
287
+ const crate = cargo.local.find((pkg) => pkg.directory === crateDirectory);
288
+ if (crate === undefined) {
289
+ throw new Error(`Cargo's resolve of ${join(absoluteProjectRoot, 'Cargo.toml')} holds no package at ${memberDir}`);
290
+ }
291
+ // Exactly the crates Cargo builds for this crate's tests, read from Cargo's
292
+ // own resolve: the crate's normal, build and dev dependencies, and below it
293
+ // only normal and build ones (`buildClosure`), with the workspace's patches
294
+ // and replacements already applied. The closure, not the direct edge set: a
281
295
  // test binary links every crate beneath it, and the chained cargo-test
282
- // targets order runs without contributing to each other's hash, so a
283
- // dependency reachable only through another crate would otherwise change
284
- // nothing in the target that links it.
296
+ // targets order runs without contributing to each other's hash. A
297
+ // dependency's own dev-dependencies never compile into this crate's test
298
+ // binaries, so an edit to one leaves this key alone.
299
+ const closure = buildClosure(cargo, [crate.id]);
285
300
  const dirs = new Set<string>();
286
301
  const external = new Map<string, string>();
287
- const pending = [normalize(memberDir).split(sep).join('/')];
288
302
  const declaredSources = new Set<string>();
289
- // Workspace patches/replacements can substitute local code for locked sources.
290
- if (isRecord(rootManifest.patch)) {
291
- for (const replacements of Object.values(rootManifest.patch)) {
292
- enqueuePathDependencies(
293
- { dependencies: replacements },
294
- '.',
295
- new Map(),
296
- pending,
297
- external,
298
- absoluteProjectRoot,
299
- workspaceRoot,
300
- );
301
- }
302
- }
303
- if (isRecord(rootManifest.replace)) {
304
- enqueuePathDependencies(
305
- { dependencies: rootManifest.replace },
306
- '.',
307
- new Map(),
308
- pending,
309
- external,
310
- absoluteProjectRoot,
311
- workspaceRoot,
312
- );
313
- }
314
- while (pending.length > 0) {
315
- const dir = pending.pop();
316
- if (dir === undefined || dirs.has(dir)) {
317
- continue;
318
- }
319
- dirs.add(dir);
320
- const crateTomlPath = join(absoluteProjectRoot, dir, 'Cargo.toml');
321
- if (!existsSync(crateTomlPath)) {
322
- continue;
323
- }
324
- const crateParsed = await loadManifest(crateTomlPath);
325
- if (!isRecord(crateParsed)) {
326
- continue;
327
- }
328
- let owner = resolve(absoluteProjectRoot, dir);
329
- if (isRecord(crateParsed.package) && typeof crateParsed.package.workspace === 'string') {
330
- owner = resolve(owner, crateParsed.package.workspace);
331
- if (isOutsideRoot(relative(workspaceRoot, owner))) {
332
- external.set(`${dir} workspace`, owner);
333
- }
334
- }
335
- let workspacePathDeps = new Map<string, string>();
336
- while (!isOutsideRoot(relative(workspaceRoot, owner))) {
337
- const manifestPath = join(owner, 'Cargo.toml');
338
- if (existsSync(manifestPath)) {
339
- const manifest = await loadManifest(manifestPath);
340
- if (isRecord(manifest.workspace)) {
341
- workspacePathDeps = workspacePathDependencies(manifest, owner);
342
- declaredSources.add(manifestPath);
343
- break;
344
- }
345
- }
346
- const parent = dirname(owner);
347
- if (parent === owner) break;
348
- owner = parent;
349
- }
350
- enqueuePathDependencies(crateParsed, dir, workspacePathDeps, pending, external, absoluteProjectRoot, workspaceRoot);
351
- // All cfg variants can affect a compiled target; do not evaluate Cargo cfg here.
352
- if (isRecord(crateParsed.target)) {
353
- for (const target of Object.values(crateParsed.target)) {
354
- if (isRecord(target)) {
355
- enqueuePathDependencies(
356
- target,
357
- dir,
358
- workspacePathDeps,
359
- pending,
360
- external,
361
- absoluteProjectRoot,
362
- workspaceRoot,
363
- );
364
- }
365
- }
366
- }
367
- if (isRecord(crateParsed.package) && typeof crateParsed.package.build === 'string') {
368
- declaredSources.add(resolve(absoluteProjectRoot, dir, crateParsed.package.build));
303
+ for (const pkg of cargo.local) {
304
+ if (!closure.has(pkg.id)) continue;
305
+ if (isOutsideRoot(relative(nxRoot, pkg.directory))) {
306
+ external.set(pkg.name, pkg.directory);
307
+ } else {
308
+ dirs.add(relative(cargoRoot, pkg.directory).split(sep).join('/') || '.');
369
309
  }
370
- for (const targetName of ['lib', 'bin', 'example', 'test', 'bench']) {
371
- const targets = crateParsed[targetName];
372
- for (const target of Array.isArray(targets) ? targets : [targets]) {
373
- if (isRecord(target) && typeof target.path === 'string') {
374
- declaredSources.add(resolve(absoluteProjectRoot, dir, target.path));
375
- }
376
- }
310
+ // Target sources outside the package's directory (a shared build script, a `[lib] path`), and its governing
311
+ // manifest.
312
+ for (const source of [...pkg.sources, pkg.governingManifest]) {
313
+ if (isOutsideRoot(relative(pkg.directory, source))) declaredSources.add(source);
377
314
  }
378
315
  }
379
316
  const inputPath = (absolutePath: string): string => {
380
- const cargoRelative = relative(absoluteProjectRoot, absolutePath).split(sep).join('/');
317
+ const cargoRelative = relative(cargoRoot, absolutePath).split(sep).join('/');
381
318
  return isOutsideRoot(cargoRelative)
382
- ? posix.join('{workspaceRoot}', relative(workspaceRoot, absolutePath).split(sep).join('/'))
319
+ ? posix.join('{workspaceRoot}', relative(nxRoot, absolutePath).split(sep).join('/'))
383
320
  : posix.join(inputRoot, cargoRelative);
384
321
  };
385
- const inputs = new Set<string>([`${inputRoot}/Cargo.toml`, `${inputRoot}/Cargo.lock`]);
322
+ // Cargo.lock is not a fileset here: the runner names the crate's lock-scope
323
+ // node, the lock entries its closure reaches (cargo-closure-input.ts).
324
+ const inputs = new Set<string>([`${inputRoot}/Cargo.toml`]);
386
325
  const exclusions = new Set<string>();
387
326
  for (const dir of [...dirs].sort()) {
388
- const absoluteDir = resolve(absoluteProjectRoot, dir);
327
+ const absoluteDir = resolve(cargoRoot, dir);
389
328
  // Cargo packages can compile include_bytes!, headers, schemas and build.rs,
390
329
  // not only Rust sources. Nested packages are separate source owners.
391
330
  inputs.add(`${inputPath(absoluteDir)}/**/*`);
392
331
  for (const child of nestedCrateDirs(absoluteDir, cache)) {
393
- const childDir = relative(absoluteProjectRoot, child).split(sep).join('/');
332
+ const childDir = relative(cargoRoot, child).split(sep).join('/');
394
333
  if (!dirs.has(childDir)) exclusions.add(`!${inputPath(child)}/**`);
395
334
  }
396
335
  // `include_str!("../../../skills/SKILL.md")` compiles a file the package's own
@@ -401,7 +340,7 @@ async function deriveCargoPackageTestInputs(
401
340
  }
402
341
  }
403
342
  for (const source of [...declaredSources].sort()) {
404
- const sourceRelative = relative(workspaceRoot, source);
343
+ const sourceRelative = relative(nxRoot, source);
405
344
  if (isOutsideRoot(sourceRelative)) {
406
345
  external.set(source, source);
407
346
  } else {
@@ -410,7 +349,7 @@ async function deriveCargoPackageTestInputs(
410
349
  }
411
350
  // Cargo/rustup search from the command's working directory upwards. Do not
412
351
  // hash unrelated descendant configuration or generated Cargo target caches.
413
- for (let current = resolve(absoluteProjectRoot); ; current = dirname(current)) {
352
+ for (let current = cargoRoot; ; current = dirname(current)) {
414
353
  for (const config of [
415
354
  '.cargo/config',
416
355
  '.cargo/config.toml',
@@ -428,14 +367,14 @@ async function deriveCargoPackageTestInputs(
428
367
  const cargoConfig = await loadManifest(configPath);
429
368
  if (isRecord(cargoConfig.build) && typeof cargoConfig.build['target-dir'] === 'string') {
430
369
  const targetDir = resolve(current, cargoConfig.build['target-dir']);
431
- if (!isOutsideRoot(relative(workspaceRoot, targetDir))) {
370
+ if (!isOutsideRoot(relative(nxRoot, targetDir))) {
432
371
  exclusions.add(`!${inputPath(targetDir)}/**`);
433
372
  }
434
373
  }
435
374
  }
436
375
  }
437
376
  }
438
- if (current === resolve(workspaceRoot) || dirname(current) === current) break;
377
+ if (current === nxRoot || dirname(current) === current) break;
439
378
  }
440
379
  inputs.add(`${inputRoot}/.config/nextest.toml`);
441
380
  for (const generated of ['.git', 'node_modules', '.nx']) {
@@ -447,22 +386,34 @@ async function deriveCargoPackageTestInputs(
447
386
  // Arbitrary build-script reads outside package trees, custom output trees,
448
387
  // and ambient tools/environment require explicit target or named inputs.
449
388
  if (external.size > 0) {
450
- if (readNxJson(workspaceRoot).namedInputs?.[EXTERNAL_RUST_CRATES_INPUT] === undefined) {
451
- const listed = [...external]
452
- .sort(([left], [right]) => left.localeCompare(right))
453
- .map(([name, dir]) => `${name} -> ${dir}`)
454
- .join(', ');
455
- throw new Error(
456
- `${memberDir}/Cargo.toml references inputs outside the Nx workspace (${listed}) that no fileset can hash; ` +
457
- `declare namedInputs.${EXTERNAL_RUST_CRATES_INPUT} in ${join(workspaceRoot, 'nx.json')} ` +
458
- 'with runtime inputs that hash those external sources and configuration',
459
- );
460
- }
389
+ requireExternalRustCratesInput(workspaceRoot, `${memberDir}/Cargo.toml`, external);
461
390
  inputs.add(EXTERNAL_RUST_CRATES_INPUT);
462
391
  }
463
392
  return [...inputs];
464
393
  }
465
394
 
395
+ /**
396
+ * Refuses inputs outside the Nx workspace that `nx.json` gives no `externalRustCrates` runtime hash for: no fileset
397
+ * can hash them, and a key without them would replay a verdict across their edits. `external` maps each input's name
398
+ * to its path.
399
+ */
400
+ export function requireExternalRustCratesInput(
401
+ workspaceRoot: string,
402
+ manifest: string,
403
+ external: ReadonlyMap<string, string>,
404
+ ): void {
405
+ if (readNxJson(workspaceRoot).namedInputs?.[EXTERNAL_RUST_CRATES_INPUT] !== undefined) return;
406
+ const listed = [...external]
407
+ .sort(([left], [right]) => left.localeCompare(right))
408
+ .map(([name, dir]) => `${name} -> ${dir}`)
409
+ .join(', ');
410
+ throw new Error(
411
+ `${manifest} references inputs outside the Nx workspace (${listed}) that no fileset can hash; ` +
412
+ `declare namedInputs.${EXTERNAL_RUST_CRATES_INPUT} in ${join(workspaceRoot, 'nx.json')} ` +
413
+ 'with runtime inputs that hash those external sources and configuration',
414
+ );
415
+ }
416
+
466
417
  /** Every directory beneath `root` that holds its own `Cargo.toml`, the walk stopping at each. */
467
418
  function nestedCrateDirs(root: string, cache: CargoInputsCache): string[] {
468
419
  const cached = cache.nestedCrateDirs.get(root);
@@ -600,7 +551,9 @@ function isRecord(value: unknown): value is Record<string, unknown> {
600
551
  * exact partition of whatever the crate currently contains.
601
552
  *
602
553
  * It is declared rather than inferred because the only honest input is how long
603
- * the suite takes, which target inference cannot measure. Defaulting to 1 keeps
554
+ * the suite takes, which target inference cannot measure. Measured time places a
555
+ * crate's slow tests instead of the hash once `.config/nextest-timings.json` names
556
+ * them (nextest-timings.ts). Defaulting to 1 keeps
604
557
  * small crates on a single target without paying another Cargo freshness check.
605
558
  */
606
559
  function readTestShards(cratePackage: Record<string, unknown>, crateTomlPath: string): number {
@@ -624,9 +577,6 @@ function readTestShards(cratePackage: Record<string, unknown>, crateTomlPath: st
624
577
  */
625
578
  export const CARGO_TEST_TARGET = 'cargo-test';
626
579
 
627
- /** Prerequisite that compiles the workspace; not a per-crate runner. */
628
- export const CARGO_TEST_COMPILE_TARGET = 'cargo-test-compile';
629
-
630
580
  /**
631
581
  * The one workspace-wide `cargo nextest archive` every per-crate runner
632
582
  * executes from. Named here beside the other cargo target names so the policy
@@ -774,7 +724,6 @@ export function cargoTestGroupTargetName(group: string): string {
774
724
  export function packageNameFromCargoTestTarget(targetName: string): string | null {
775
725
  if (
776
726
  !targetName.startsWith('cargo-test-') ||
777
- targetName === CARGO_TEST_COMPILE_TARGET ||
778
727
  targetName === CARGO_TEST_ARCHIVE_TARGET ||
779
728
  targetName.startsWith(CARGO_TEST_GROUP_PREFIX)
780
729
  ) {
@@ -1130,7 +1079,7 @@ export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/
1130
1079
  * contain spaces.
1131
1080
  *
1132
1081
  * The file is named through the workspace root's `node_modules` link, as
1133
- * `NEXTEST_EXTRACT_BIN` is, never through where the plugin really lives: a
1082
+ * tool package CLIs are (tool-bins.ts), never through where the plugin really lives: a
1134
1083
  * plugin linked from a checkout outside the workspace sits a different number
1135
1084
  * of `../` away from each workspace depending on how deep that workspace is,
1136
1085
  * and that count re-keyed every target of every Cargo project — and every
@@ -173,17 +173,19 @@ export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
173
173
  export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${CARGO_ZIGBUILD_CLIPPY_FROZEN_PREFIX}--workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross ${CARGO_DENY_WARNINGS}`;
174
174
 
175
175
  /**
176
- * No `--target-dir`: clippy writes the workspace's own `target/`, beside every
177
- * dev build. Check units carry their mode in the unit hash, so they never
178
- * collide with build units, and the host units a dev build already compiled —
179
- * build scripts and their host-only dependencies — are reused rather than
180
- * compiled a second time in a directory of their own. A dependency that both
181
- * a proc-macro and ordinary code use stays a distinct unit: a dev build
182
- * compiles it once at the target profile, while a check build needs a separate
183
- * host copy. Distinct hashes coexist, so neither command dirties the other.
184
- * A plain `cargo clippy --workspace --all-targets` checks exactly these units.
176
+ * `target/cargo-lint`: clippy writes a directory of its own, as the cross lint
177
+ * does. Cargo flocks one build directory per invocation, and a workspace-wide
178
+ * check is the longest Cargo invocation in a gate, so in the dev build's
179
+ * `target/` it would queue the test archive and every dev build behind its lock.
180
+ * The price is that clippy compiles its own host units (build scripts,
181
+ * proc-macros) once per directory; cargo retention passes it as a nested root of
182
+ * the target directory, reclaiming its superseded generations but not its
183
+ * `incremental/`. A plain `cargo clippy --workspace --all-targets
184
+ * --target-dir target/cargo-lint` checks exactly these units.
185
185
  */
186
- export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen(`clippy --workspace --all-targets ${CARGO_DENY_WARNINGS}`);
186
+ export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen(
187
+ `clippy --workspace --all-targets --target-dir target/cargo-lint ${CARGO_DENY_WARNINGS}`,
188
+ );
187
189
 
188
190
  /** Root `package.json` script name, in the repo's `verb:qualifier` style. */
189
191
  export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
@@ -57,6 +57,7 @@ export function directDiskCommands(source: string, path = ''): number[] {
57
57
 
58
58
  /** Scan tracked code, tests and scripts, never build output, prose or recorded benchmark data. */
59
59
  export function checkDiskCommandBoundary(root: string): string[] {
60
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git file listing whose length is its own read of this repository: it asks no remote, and a held index.lock fails it at once rather than waiting, so only the operator's interrupt ends a hung one
60
61
  const files = execFileSync('git', ['ls-files', '-z', '--cached', '--others', '--exclude-standard'], {
61
62
  cwd: root,
62
63
  encoding: 'utf8',
@@ -1,6 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
3
  import {
4
+ type BigIntStats,
4
5
  closeSync,
5
6
  lstatSync,
6
7
  openSync,
@@ -13,7 +14,7 @@ import {
13
14
  import { isAbsolute, join, relative } from 'node:path';
14
15
  import type { Task } from 'nx/src/config/task-graph';
15
16
  import type { expandOutputs, HashInputs } from 'nx/src/native';
16
- import { CARGO_TOOLCHAIN_PIN_INPUTS, cargoRuntimeInput } from './cargo-toolchain-policy.js';
17
+ import { CARGO_TOOLCHAIN_PIN_INPUTS, cargoRuntimeInput, cargoToolchainPathsInput } from './cargo-toolchain-policy.js';
17
18
  import type {
18
19
  EnsureBuiltOutputReceipt,
19
20
  EnsureBuiltProbeFailure,
@@ -21,7 +22,15 @@ import type {
21
22
  EnsureBuiltProducerReceipt,
22
23
  EnsureBuiltReceipt,
23
24
  } from './ensure-built.js';
24
- import { censusStart, movedNodes, type NodeWitness, recordedStamp, type StampFields } from './ensure-built-witness.js';
25
+ import {
26
+ type CensusRead,
27
+ censusStart,
28
+ directoryMembers,
29
+ movedNodes,
30
+ type NodeWitness,
31
+ recordedStamp,
32
+ type StampFields,
33
+ } from './ensure-built-witness.js';
25
34
 
26
35
  export type ReceiptEvidence<T> =
27
36
  | { readonly ok: true; readonly value: T }
@@ -58,6 +67,7 @@ export function receiptGit(root: string, args: string[]): ReceiptEvidence<string
58
67
  'GIT_NAMESPACE',
59
68
  ])
60
69
  delete env[key];
70
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git query: it asks no remote, and a held index.lock fails it at once rather than waiting, so only the operator's interrupt ends a hung one
61
71
  const child = spawnSync('git', ['-C', root, ...args], { env, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
62
72
  return child.status === 0 && child.error === undefined
63
73
  ? { ok: true, value: child.stdout }
@@ -141,16 +151,19 @@ function sourceFileDigests(
141
151
  }
142
152
  /**
143
153
  * One independently read node; absolute paths also serve tool/package closures. A census records the node's stamp as
144
- * of its `start` (recordedStamp); a re-read against a record records none.
154
+ * of its `start` (recordedStamp); a re-read against a record records none. `known` is what a census of the same capture
155
+ * already read of the node ({@link CensusRead}): its stat, listing and start stand for this read, so a capture stats a
156
+ * node once; the stability check after execution reads it again.
145
157
  */
146
158
  export function receiptNode(
147
159
  path: string,
148
160
  name: string,
149
161
  census?: { readonly start: bigint; readonly observed: NodeWitness[] },
150
162
  recorded?: (path: string, stats: StampFields) => string | undefined,
163
+ known?: CensusRead,
151
164
  ): EnsureBuiltOutputReceipt {
152
- const stats = lstatSync(path, { bigint: true });
153
- census?.observed.push({ path, stamp: recordedStamp(stats, census.start) });
165
+ const stats = known?.stats ?? lstatSync(path, { bigint: true });
166
+ census?.observed.push({ path, stamp: recordedStamp(stats, known?.start ?? census.start) });
154
167
  const mode = Number(stats.mode & 0o7777n);
155
168
  if (stats.isFile())
156
169
  return {
@@ -161,7 +174,7 @@ export function receiptNode(
161
174
  };
162
175
  if (stats.isSymbolicLink()) return { path: name, type: 'symlink', mode, linkText: readlinkSync(path) };
163
176
  if (stats.isDirectory()) {
164
- const entries = readdirSync(path).sort();
177
+ const entries = known?.entries ?? directoryMembers(path);
165
178
  return {
166
179
  path: name,
167
180
  type: 'directory',
@@ -174,17 +187,74 @@ export function receiptNode(
174
187
  }
175
188
  /**
176
189
  * Whether a tracked source node whose stamp does not prove it (its ctime alone moved, or it was read in the tick it
177
- * changed in) still holds the bytes or link text `files` recorded for it.
190
+ * changed in) still holds the bytes or link text `files` recorded for it. A node that is gone, or no longer a file, does not.
178
191
  */
179
192
  function recordedSource(root: string, files: readonly EnsureBuiltProducerFileInput[]): (path: string) => boolean {
180
193
  const recorded = new Map(files.map((file) => [join(root, file.path), file.sha256]));
181
- return (path) =>
182
- recorded.get(path) ===
183
- createHash('sha256')
184
- .update(lstatSync(path).isSymbolicLink() ? readlinkSync(path) : readFileSync(path))
194
+ return (path) => {
195
+ try {
196
+ return (
197
+ recorded.get(path) ===
198
+ createHash('sha256')
199
+ .update(lstatSync(path).isSymbolicLink() ? readlinkSync(path) : readFileSync(path))
200
+ .digest('hex')
201
+ );
202
+ } catch (error) {
203
+ if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'EISDIR'))
204
+ return false;
205
+ throw error;
206
+ }
207
+ };
208
+ }
209
+ /**
210
+ * One tracked file as it stands against HEAD's entry for it (`head.mode`, `head.oid`): the witness a receipt binds it
211
+ * by and the stamp it was read at, or how it differs.
212
+ */
213
+ function trackedSource(
214
+ root: string,
215
+ file: string,
216
+ head: { readonly mode: string; readonly oid: string; readonly algorithm: 'sha1' | 'sha256' },
217
+ start: bigint,
218
+ ): ReceiptEvidence<{ readonly node: NodeWitness; readonly input: EnsureBuiltProducerFileInput }> {
219
+ const path = join(root, file);
220
+ let stats: BigIntStats;
221
+ try {
222
+ stats = lstatSync(path, { bigint: true });
223
+ } catch (error) {
224
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
225
+ return { ok: false, detail: `Tracked source is missing: ${file}` };
226
+ throw error;
227
+ }
228
+ const actualMode = stats.isSymbolicLink() ? '120000' : (stats.mode & 0o111n) !== 0n ? '100755' : '100644';
229
+ if (actualMode !== head.mode) return { ok: false, detail: `Tracked source mode differs from HEAD: ${file}` };
230
+ let gitBlob: string;
231
+ let sha256: string;
232
+ if (stats.isFile()) {
233
+ const digests = sourceFileDigests(path, Number(stats.size), head.algorithm);
234
+ gitBlob = digests.gitBlob;
235
+ sha256 = digests.sha256;
236
+ } else if (stats.isSymbolicLink()) {
237
+ const text = readlinkSync(path);
238
+ gitBlob = createHash(head.algorithm)
239
+ .update(`blob ${Buffer.byteLength(text)}\0`)
240
+ .update(text)
185
241
  .digest('hex');
242
+ sha256 = createHash('sha256').update(text).digest('hex');
243
+ } else return { ok: false, detail: `Unbound tracked source node: ${file}` };
244
+ if (gitBlob !== head.oid) return { ok: false, detail: `Tracked source bytes differ from HEAD: ${file}` };
245
+ return {
246
+ ok: true,
247
+ value: {
248
+ node: { path, stamp: recordedStamp(stats, start) },
249
+ input: { path: file, mode: Number(stats.mode & 0o7777n), gitBlob, sha256 },
250
+ },
251
+ };
186
252
  }
187
- /** Capture every tracked source byte at pre. Unrelated untracked files are not source basis. */
253
+ /**
254
+ * Capture every tracked source byte at pre. Unrelated untracked files are not source basis. A tracked public output is
255
+ * source while it holds HEAD's bytes, so a later task can read it as a FILE input; one that differs from HEAD is the
256
+ * run's to write, and no input binds to it.
257
+ */
188
258
  export function captureProducerSource(
189
259
  root: string,
190
260
  outputs: readonly string[],
@@ -214,28 +284,15 @@ export function captureProducerSource(
214
284
  return { ok: false, detail: `Unproved HEAD tree entry ${entry}` };
215
285
  if (kind !== 'blob') return { ok: false, detail: `Unbound tracked source namespace ${entry}` };
216
286
  const file = entry.slice(tab + 1);
217
- if (excluded.has(file)) continue;
218
- const path = join(root, file);
219
- const stats = lstatSync(path, { bigint: true });
220
- nodes.push({ path, stamp: recordedStamp(stats, start) });
221
- const actualMode = stats.isSymbolicLink() ? '120000' : (stats.mode & 0o111n) !== 0n ? '100755' : '100644';
222
- if (actualMode !== mode) return { ok: false, detail: `Tracked source mode differs from HEAD: ${file}` };
223
- let gitBlob: string;
224
- let sha256: string;
225
- if (stats.isFile()) {
226
- const digests = sourceFileDigests(path, Number(stats.size), algorithm);
227
- gitBlob = digests.gitBlob;
228
- sha256 = digests.sha256;
229
- } else if (stats.isSymbolicLink()) {
230
- const text = readlinkSync(path);
231
- gitBlob = createHash(algorithm)
232
- .update(`blob ${Buffer.byteLength(text)}\0`)
233
- .update(text)
234
- .digest('hex');
235
- sha256 = createHash('sha256').update(text).digest('hex');
236
- } else return { ok: false, detail: `Unbound tracked source node: ${file}` };
237
- if (gitBlob !== oid) return { ok: false, detail: `Tracked source bytes differ from HEAD: ${file}` };
238
- files.push({ path: file, mode: Number(stats.mode & 0o7777n), gitBlob, sha256 });
287
+ const witnessed = trackedSource(root, file, { mode, oid, algorithm }, start);
288
+ if (!witnessed.ok) {
289
+ if (excluded.has(file)) continue;
290
+ return witnessed;
291
+ }
292
+ // A public output's stamp is the run's to move (a cache restore or a regeneration does), so only its bytes are
293
+ // held.
294
+ if (!excluded.has(file)) nodes.push(witnessed.value.node);
295
+ files.push(witnessed.value.input);
239
296
  }
240
297
  const status = receiptGit(root, ['status', '--porcelain=v1', '-z', '--untracked-files=no']);
241
298
  if (!status.ok) return status;
@@ -250,6 +307,34 @@ export function captureProducerSource(
250
307
  throw error;
251
308
  }
252
309
  }
310
+ /** Share Git and tracked-byte acquisition, never one target's output exemption with another. */
311
+ export function captureProducerSources(
312
+ root: string,
313
+ targets: ReadonlyMap<string, readonly string[]>,
314
+ ): ReceiptEvidence<ReadonlyMap<string, ProducerSourceWitness>> {
315
+ if (targets.size === 0) return { ok: true, value: new Map() };
316
+ const plans = [...targets].map(([target, outputs]) => ({
317
+ target,
318
+ outputs,
319
+ excluded: new Set(outputs.filter((path) => !graphConfiguration(path))),
320
+ }));
321
+ const common = [...(plans[0]?.excluded ?? [])].filter((path) => plans.every(({ excluded }) => excluded.has(path)));
322
+ const source = captureProducerSource(root, common);
323
+ if (!source.ok) return source;
324
+ return {
325
+ ok: true,
326
+ value: new Map(
327
+ plans.map(({ target, outputs, excluded }) => [
328
+ target,
329
+ {
330
+ ...source.value,
331
+ outputs,
332
+ nodes: source.value.nodes.filter(({ path }) => !excluded.has(relative(root, path))),
333
+ },
334
+ ]),
335
+ ),
336
+ };
337
+ }
253
338
  export function producerSourceUnchanged(root: string, before: ProducerSourceWitness): ReceiptEvidence<true> {
254
339
  const revision = receiptGit(root, ['rev-parse', '--verify', 'HEAD']);
255
340
  if (!revision.ok) return revision;
@@ -263,8 +348,15 @@ export function producerSourceUnchanged(root: string, before: ProducerSourceWitn
263
348
  return { ok: false, detail: `${changed}: HEAD's tree is ${tree.value.trim()}, not ${before.headTree}` };
264
349
  const dirty = dirtyProviderPaths(status.value).filter((path) => !outputs.has(path));
265
350
  if (dirty.length !== 0) return { ok: false, detail: `${changed}: ${dirty.join(', ')} differ from HEAD` };
266
- const moved = movedNodes(before.nodes, recordedSource(root, before.files));
351
+ const holds = recordedSource(root, before.files);
352
+ const moved = movedNodes(before.nodes, holds);
267
353
  if (moved !== null) return { ok: false, detail: `${changed}: ${moved}` };
354
+ const rewritten = before.files.filter(({ path }) => outputs.has(path) && !holds(join(root, path)));
355
+ if (rewritten.length !== 0)
356
+ return {
357
+ ok: false,
358
+ detail: `${changed}: tracked public output ${rewritten.map(({ path }) => path).join(', ')} no longer holds HEAD's bytes`,
359
+ };
268
360
  return { ok: true, value: true };
269
361
  }
270
362
  /** Enumerate exact public nodes; never exempt a broad directory of tracked source. */
@@ -384,7 +476,7 @@ export function providerReceipt(
384
476
  throw error;
385
477
  }
386
478
  }
387
- /** Admit only version recipes emitted by the owning generator and declared toolchain pins. */
479
+ /** Admit only the recipes emitted by the owning generator: the version recipes, the declared-programs one, and declared toolchain pins. */
388
480
  export function boundedReceiptRuntimes(
389
481
  inputs: Readonly<Record<string, HashInputs>>,
390
482
  directories: readonly string[],
@@ -397,8 +489,8 @@ export function boundedReceiptRuntimes(
397
489
  const pins = CARGO_TOOLCHAIN_PIN_INPUTS.map((path) => path.replace('{workspaceRoot}/', ''));
398
490
  if (!pins.some((pin) => files.includes(pin)))
399
491
  return { kind: 'opaque', detail: 'Version runtime input has no declared toolchain FILE pin' };
400
- const allowed = new Set(
401
- directories.flatMap((directory) =>
492
+ const allowed = new Set([
493
+ ...directories.flatMap((directory) =>
402
494
  [
403
495
  'rustc -vV && cargo -V',
404
496
  'rustc -vV && cargo -V && cargo clippy -V',
@@ -406,7 +498,8 @@ export function boundedReceiptRuntimes(
406
498
  'rustc -vV && cargo -V && cargo nextest --version',
407
499
  ].map((command) => cargoRuntimeInput(directory, command).runtime),
408
500
  ),
409
- );
501
+ cargoToolchainPathsInput().runtime,
502
+ ]);
410
503
  const opaque = runtimes.filter((runtime) => !allowed.has(runtime));
411
504
  return opaque.length === 0
412
505
  ? { kind: 'bounded' }