@smoothbricks/nx-plugin 0.5.7 → 0.6.1

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 (446) hide show
  1. package/README.md +1097 -360
  2. package/dist/.build-inputs.json +141 -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 +22 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +168 -48
  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-thread.d.ts +28 -0
  62. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -0
  63. package/dist/executors/bounded-exec/cpu-pool-thread.js +20 -0
  64. package/dist/executors/bounded-exec/cpu-pool.d.ts +35 -38
  65. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/cpu-pool.js +56 -120
  67. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  68. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/executor.js +389 -239
  70. package/dist/executors/bounded-exec/gateway-lease.d.ts +23 -19
  71. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/gateway-lease.js +102 -29
  73. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  74. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  76. package/dist/executors/bounded-exec/lease-wait.d.ts +64 -0
  77. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lease-wait.js +72 -0
  79. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  80. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  82. package/dist/executors/bounded-exec/mbx-pool.d.ts +31 -0
  83. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/mbx-pool.js +24 -0
  85. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  86. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  88. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  89. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  90. package/dist/executors/bounded-exec/progress.js +5 -2
  91. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  92. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  93. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  94. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  95. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  96. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  97. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  98. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  100. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  101. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  102. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  103. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -4
  104. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  105. package/dist/executors/bounded-exec/run-cpu-pool.js +122 -35
  106. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  107. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  108. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  109. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  110. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  111. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  112. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  113. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  114. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  115. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  116. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  117. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  118. package/dist/executors/bounded-exec/verdict.d.ts +48 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +89 -20
  121. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  122. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  123. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  124. package/dist/executors/clean-outputs/executor.js +1 -0
  125. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  126. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/executor.js +367 -0
  128. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  129. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  130. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  131. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  132. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  133. package/dist/executors/scriptc-native/schema.js +1 -0
  134. package/dist/executors/typescript-emit/emit-overrides.d.ts +14 -0
  135. package/dist/executors/typescript-emit/emit-overrides.d.ts.map +1 -0
  136. package/dist/executors/typescript-emit/emit-overrides.js +24 -0
  137. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  138. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  139. package/dist/executors/typescript-emit/executor.js +146 -33
  140. package/dist/forbidden-spelling-policy.d.ts +56 -0
  141. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  142. package/dist/forbidden-spelling-policy.js +176 -0
  143. package/dist/generators/create-package/generator.d.ts.map +1 -1
  144. package/dist/generators/create-package/generator.js +3 -4
  145. package/dist/graph-input-contract.d.ts +14 -0
  146. package/dist/graph-input-contract.d.ts.map +1 -1
  147. package/dist/graph-input-contract.js +67 -2
  148. package/dist/index.d.ts +23 -6
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +672 -214
  151. package/dist/managed-assets.d.ts +2 -0
  152. package/dist/managed-assets.d.ts.map +1 -1
  153. package/dist/managed-files/files.d.ts +3 -3
  154. package/dist/managed-files/files.d.ts.map +1 -1
  155. package/dist/managed-files/files.js +28 -3
  156. package/dist/managed-files/managed-format.d.ts.map +1 -1
  157. package/dist/managed-files/managed-format.js +1 -0
  158. package/dist/managed-files/publish-workflow.js +14 -11
  159. package/dist/nextest-code-bound.js +1 -0
  160. package/dist/nextest-timings.d.ts +35 -0
  161. package/dist/nextest-timings.d.ts.map +1 -0
  162. package/dist/nextest-timings.js +168 -0
  163. package/dist/owned-installation.d.ts +6 -5
  164. package/dist/owned-installation.d.ts.map +1 -1
  165. package/dist/owned-installation.js +150 -26
  166. package/dist/package-target-policy.d.ts.map +1 -1
  167. package/dist/package-target-policy.js +2 -3
  168. package/dist/process-children.d.ts +7 -0
  169. package/dist/process-children.d.ts.map +1 -0
  170. package/dist/process-children.darwin.d.ts +7 -0
  171. package/dist/process-children.darwin.d.ts.map +1 -0
  172. package/dist/process-children.darwin.js +13 -0
  173. package/dist/process-children.js +14 -0
  174. package/dist/process-children.linux.d.ts +8 -0
  175. package/dist/process-children.linux.d.ts.map +1 -0
  176. package/dist/process-children.linux.js +25 -0
  177. package/dist/process-group.d.ts +108 -0
  178. package/dist/process-group.d.ts.map +1 -0
  179. package/dist/process-group.js +171 -0
  180. package/dist/process-listing.d.ts +7 -0
  181. package/dist/process-listing.d.ts.map +1 -0
  182. package/dist/process-listing.js +51 -0
  183. package/dist/producer-receipts.d.ts +8 -2
  184. package/dist/producer-receipts.d.ts.map +1 -1
  185. package/dist/producer-receipts.js +514 -47
  186. package/dist/task-graph-policy.d.ts +21 -0
  187. package/dist/task-graph-policy.d.ts.map +1 -0
  188. package/dist/task-graph-policy.js +91 -0
  189. package/dist/test-timings.js +4 -4
  190. package/dist/test-walk-policy.d.ts +14 -5
  191. package/dist/test-walk-policy.d.ts.map +1 -1
  192. package/dist/test-walk-policy.js +8 -2
  193. package/dist/testing.d.ts +73 -28
  194. package/dist/testing.d.ts.map +1 -1
  195. package/dist/testing.js +217 -223
  196. package/dist/tool-bins.d.ts +33 -0
  197. package/dist/tool-bins.d.ts.map +1 -0
  198. package/dist/tool-bins.js +72 -0
  199. package/dist/typecheck-test-policy.d.ts.map +1 -1
  200. package/dist/typecheck-test-policy.js +3 -4
  201. package/dist/wait-why-policy.d.ts +28 -0
  202. package/dist/wait-why-policy.d.ts.map +1 -0
  203. package/dist/wait-why-policy.js +223 -0
  204. package/dist/workspace-config-policy.d.ts +14 -8
  205. package/dist/workspace-config-policy.d.ts.map +1 -1
  206. package/dist/workspace-config-policy.js +60 -16
  207. package/dist/workspace-manifest.d.ts +41 -6
  208. package/dist/workspace-manifest.d.ts.map +1 -1
  209. package/dist/workspace-manifest.js +57 -0
  210. package/executors.json +16 -1
  211. package/loader.js +2 -0
  212. package/managed/raw/envrc +11 -0
  213. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  214. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  215. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  216. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  217. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  218. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  219. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  220. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  221. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  222. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  223. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  224. package/managed/raw/tooling/direnv/repo-path +68 -6
  225. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  226. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  227. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  228. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  229. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  230. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  231. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  232. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  233. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  234. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  235. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  236. package/package.json +95 -14
  237. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  238. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  239. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  240. package/src/bounded-test-policy.ts +12 -14
  241. package/src/build-state-output-policy.ts +458 -34
  242. package/src/bun-lock-scope.ts +108 -0
  243. package/src/cargo-build-script-env.ts +265 -0
  244. package/src/cargo-closure-input.ts +74 -7
  245. package/src/cargo-retention-hook.ts +94 -0
  246. package/src/cargo-source-hash.ts +138 -41
  247. package/src/cargo-toolchain-paths.ts +95 -0
  248. package/src/cargo-toolchain-policy.ts +49 -5
  249. package/src/cargo-workspace.ts +72 -123
  250. package/src/cross-check-policy.ts +12 -10
  251. package/src/disk-command-policy.ts +1 -0
  252. package/src/ensure-built-receipt.ts +173 -39
  253. package/src/ensure-built-witness.ts +62 -10
  254. package/src/ensure-built.ts +11 -1
  255. package/src/eslint-config-closure.ts +357 -0
  256. package/src/executors/bounded-exec/bounds.ts +76 -0
  257. package/src/executors/bounded-exec/cpu-pool-thread.ts +43 -0
  258. package/src/executors/bounded-exec/cpu-pool.ts +55 -120
  259. package/src/executors/bounded-exec/executor.ts +442 -260
  260. package/src/executors/bounded-exec/gateway-lease.ts +94 -35
  261. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  262. package/src/executors/bounded-exec/lease-wait.ts +116 -0
  263. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  264. package/src/executors/bounded-exec/mbx-pool.ts +48 -0
  265. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  266. package/src/executors/bounded-exec/progress.ts +9 -3
  267. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  268. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  269. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  270. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  271. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  272. package/src/executors/bounded-exec/run-cpu-pool.ts +129 -35
  273. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  274. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  275. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  276. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  277. package/src/executors/bounded-exec/schema.json +11 -2
  278. package/src/executors/bounded-exec/schema.ts +19 -1
  279. package/src/executors/bounded-exec/verdict.ts +145 -35
  280. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  281. package/src/executors/clean-outputs/executor.ts +1 -0
  282. package/src/executors/scriptc-native/executor.ts +394 -0
  283. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  284. package/src/executors/scriptc-native/schema.json +60 -0
  285. package/src/executors/scriptc-native/schema.ts +34 -0
  286. package/src/executors/typescript-emit/emit-overrides.ts +24 -0
  287. package/src/executors/typescript-emit/executor.ts +186 -38
  288. package/src/forbidden-spelling-policy.ts +226 -0
  289. package/src/generators/create-package/generator.ts +7 -7
  290. package/src/graph-input-contract.ts +61 -2
  291. package/src/index.ts +788 -224
  292. package/src/managed-assets.ts +3 -0
  293. package/src/managed-files/files.ts +28 -3
  294. package/src/managed-files/managed-format.ts +1 -0
  295. package/src/managed-files/publish-workflow.ts +20 -15
  296. package/src/nextest-code-bound.ts +1 -0
  297. package/src/nextest-timings.ts +106 -0
  298. package/src/owned-installation.ts +150 -23
  299. package/src/package-target-policy.ts +2 -3
  300. package/src/process-children.darwin.ts +14 -0
  301. package/src/process-children.linux.ts +33 -0
  302. package/src/process-children.ts +22 -0
  303. package/src/process-group.ts +209 -0
  304. package/src/process-listing.ts +54 -0
  305. package/src/producer-receipts.ts +92 -41
  306. package/src/task-graph-policy.ts +98 -0
  307. package/src/test-walk-policy.ts +23 -8
  308. package/src/testing.ts +240 -232
  309. package/src/tool-bins.ts +108 -0
  310. package/src/typecheck-test-policy.ts +2 -3
  311. package/src/wait-why-policy.ts +226 -0
  312. package/src/workspace-config-policy.ts +63 -15
  313. package/src/workspace-manifest.ts +89 -6
  314. package/test-timings.json +124 -99
  315. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  316. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  317. package/dist/bin/smoo-nx-failures.js +0 -3
  318. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  319. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  320. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  321. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  322. package/dist/failure-summary.d.ts +0 -5
  323. package/dist/failure-summary.d.ts.map +0 -1
  324. package/dist/failure-summary.js +0 -118
  325. package/dist/nextest-extraction.d.ts +0 -117
  326. package/dist/nextest-extraction.d.ts.map +0 -1
  327. package/dist/nextest-extraction.js +0 -303
  328. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  329. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  330. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  331. package/src/__tests__/counted-cargo-process.ts +0 -286
  332. package/src/__tests__/counted-cargo.ts +0 -713
  333. package/src/__tests__/directory-change.ts +0 -27
  334. package/src/__tests__/fixture-cargo-home.ts +0 -36
  335. package/src/__tests__/fixture-nx-env.ts +0 -193
  336. package/src/__tests__/owned-installation.ts +0 -13
  337. package/src/__tests__/past-tick.ts +0 -12
  338. package/src/__tests__/progress-clock.ts +0 -43
  339. package/src/__tests__/runtime-input.ts +0 -23
  340. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  341. package/src/bin/smoo-nx-failures.ts +0 -4
  342. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  343. package/src/bounded-test-policy.test.ts +0 -1029
  344. package/src/build-state-output-policy.test.ts +0 -115
  345. package/src/bun-bootstrap.test.ts +0 -102
  346. package/src/bun-file-packages.test.ts +0 -47
  347. package/src/cargo-closure-filesets.test.ts +0 -63
  348. package/src/cargo-closure-input.property.test.ts +0 -50
  349. package/src/cargo-closure-input.test.ts +0 -506
  350. package/src/cargo-closure-key.test.ts +0 -240
  351. package/src/cargo-resolve-cache.test.ts +0 -1181
  352. package/src/cargo-source-hash.test.ts +0 -707
  353. package/src/cargo-workspace.test.ts +0 -615
  354. package/src/cross-check-policy.test.ts +0 -316
  355. package/src/disk-command-policy.test.ts +0 -61
  356. package/src/ensure-built-receipt.test.ts +0 -279
  357. package/src/ensure-built-witness.test.ts +0 -688
  358. package/src/ensure-built.test.ts +0 -1462
  359. package/src/executors/all-verdicts/executor.test.ts +0 -135
  360. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  361. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  362. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  363. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  364. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  365. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  366. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  367. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  368. package/src/executors/bounded-exec/progress.test.ts +0 -139
  369. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  370. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  371. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  372. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  373. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  374. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  375. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  376. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  377. package/src/executors/clean-outputs/executor.test.ts +0 -20
  378. package/src/executors/typescript-emit/executor.test.ts +0 -83
  379. package/src/failure-summary.ts +0 -119
  380. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  381. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  382. package/src/generators/create-package/generator.test.ts +0 -190
  383. package/src/generators/make-public/generator.test.ts +0 -137
  384. package/src/graph-input-contract.test.ts +0 -379
  385. package/src/host-controller-wiring.test.ts +0 -31
  386. package/src/index.test.ts +0 -3321
  387. package/src/linked-snapshots.nx.test.ts +0 -254
  388. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  389. package/src/managed-files/generator.test.ts +0 -243
  390. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  391. package/src/managed-files/json-edit.test.ts +0 -216
  392. package/src/managed-files/managed-content.test.ts +0 -166
  393. package/src/managed-files/managed-format-json.test.ts +0 -308
  394. package/src/managed-files/repo-path.test.ts +0 -172
  395. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  396. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  397. package/src/managed-files/tree-permissions.test.ts +0 -109
  398. package/src/managed-files/tree.test.ts +0 -123
  399. package/src/manifest-hash.test.ts +0 -219
  400. package/src/nextest-code-bound.test.ts +0 -161
  401. package/src/nextest-extraction.test.ts +0 -216
  402. package/src/nextest-extraction.ts +0 -371
  403. package/src/nextest-partitions.test.ts +0 -501
  404. package/src/nx-cache-bound.test.ts +0 -109
  405. package/src/nx-cache-restore-mtime.test.ts +0 -170
  406. package/src/nx-daemon-claim.test.ts +0 -279
  407. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  408. package/src/nx-daemon-idle-policy.test.ts +0 -111
  409. package/src/nx-daemon-ignore-files.test.ts +0 -210
  410. package/src/nx-daemon-root-normalization.test.ts +0 -105
  411. package/src/nx-daemon-start-never.test.ts +0 -292
  412. package/src/nx-daemon-validity.test.ts +0 -1055
  413. package/src/nx-dot-input-policy.test.ts +0 -353
  414. package/src/nx-failure-life-cycles.test.ts +0 -207
  415. package/src/nx-files-archive-racy.test.ts +0 -97
  416. package/src/nx-foreign-workspace-env.test.ts +0 -329
  417. package/src/nx-incomplete-run-summary.test.ts +0 -70
  418. package/src/nx-plugin-load-errors.test.ts +0 -120
  419. package/src/nx-project-graph-errors.test.ts +0 -70
  420. package/src/nx-project-resolution-cache.test.ts +0 -176
  421. package/src/nx-raw-inputs.test.ts +0 -166
  422. package/src/nx-resident-graph-workers.test.ts +0 -112
  423. package/src/nx-run-information.test.ts +0 -118
  424. package/src/nx-skipped-task-exit.test.ts +0 -180
  425. package/src/nx-state-location.test.ts +0 -63
  426. package/src/nx-store-resolution.test.ts +0 -81
  427. package/src/nx-task-graph-cycles.test.ts +0 -148
  428. package/src/nx-task-output-lease.test.ts +0 -550
  429. package/src/nx-use-local.test.ts +0 -105
  430. package/src/owned-installation.test.ts +0 -105
  431. package/src/package-target-policy.test.ts +0 -1014
  432. package/src/producer-receipts.test.ts +0 -285
  433. package/src/release-config-policy.test.ts +0 -311
  434. package/src/runtime-input.test.ts +0 -393
  435. package/src/serial-group-wiring.test.ts +0 -326
  436. package/src/task-history-namespace.test.ts +0 -181
  437. package/src/task-results.test.ts +0 -228
  438. package/src/test-clock-policy.test.ts +0 -338
  439. package/src/test-program.test.ts +0 -303
  440. package/src/test-timings.test.ts +0 -240
  441. package/src/test-walk-policy.test.ts +0 -620
  442. package/src/testing.test.ts +0 -509
  443. package/src/typecheck-test-policy.test.ts +0 -1468
  444. package/src/typescript-resolution.test.ts +0 -76
  445. package/src/version-actions.test.ts +0 -80
  446. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,15 +1,26 @@
1
1
  import { type ChildProcess, type ChildProcessByStdio, execFileSync, spawn, spawnSync } from 'node:child_process';
2
2
  import { createHash, randomUUID } from 'node:crypto';
3
3
  import { channel } from 'node:diagnostics_channel';
4
- import { accessSync, constants, existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
4
+ import {
5
+ accessSync,
6
+ constants,
7
+ existsSync,
8
+ readdirSync,
9
+ readFileSync,
10
+ realpathSync,
11
+ statSync,
12
+ writeSync,
13
+ } from 'node:fs';
5
14
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
6
15
  import { createRequire } from 'node:module';
7
16
  import { homedir } from 'node:os';
8
17
  import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
18
  import type { Readable } from 'node:stream';
19
+ import { CARGO_ANCESTOR_INPUTS } from '@smoothbricks/cargo-retain/cargo-ancestor-inputs';
10
20
  import native from 'nx/src/native/index.js';
11
21
  import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
12
22
  import { CARGO_TOOLCHAIN_PIN_INPUTS } from './cargo-toolchain-policy.js';
23
+ import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from './process-group.js';
13
24
  import { rustTokens } from './rust-tokens.js';
14
25
 
15
26
  const { IS_WASM, WorkspaceContext } = native;
@@ -28,7 +39,7 @@ interface CargoMetadata {
28
39
  /** Added by the cache after Cargo identifies each local package's governing workspace. */
29
40
  governing_manifest_path?: string;
30
41
  }[];
31
- resolve: { nodes: { id: string; deps: { pkg: string }[] }[] } | null;
42
+ resolve: { nodes: { id: string; deps: { pkg: string; dep_kinds: { kind: CargoDependencyKind }[] }[] }[] } | null;
32
43
  workspace_members: string[];
33
44
  workspace_root: string;
34
45
  }
@@ -73,6 +84,7 @@ function parseCargoMetadata(json: string): CargoMetadata {
73
84
  id: text(member(node, 'id'), 'resolve node id'),
74
85
  deps: list(member(node, 'deps'), 'resolve node deps').map((dependency) => ({
75
86
  pkg: text(member(dependency, 'pkg'), 'resolve edge'),
87
+ dep_kinds: dependencyKinds(member(dependency, 'dep_kinds')),
76
88
  })),
77
89
  })),
78
90
  },
@@ -83,6 +95,31 @@ function parseCargoMetadata(json: string): CargoMetadata {
83
95
  };
84
96
  }
85
97
 
98
+ /** How a package declares a dependency: `[dependencies]` (null), `[dev-dependencies]` or `[build-dependencies]`. */
99
+ type CargoDependencyKind = null | 'dev' | 'build';
100
+
101
+ /** A resolve edge's `dep_kinds`. An edge Cargo reports with no kind is refused: read as dev-only, it would drop a dependency. */
102
+ function dependencyKinds(value: unknown): { kind: CargoDependencyKind }[] {
103
+ if (!Array.isArray(value) || value.length === 0)
104
+ throw new Error('cargo metadata reported no valid resolve edge kinds');
105
+ return value.map((entry: unknown) => {
106
+ const kind = typeof entry === 'object' && entry !== null ? Reflect.get(entry, 'kind') : undefined;
107
+ if (kind !== null && kind !== 'dev' && kind !== 'build')
108
+ throw new Error('cargo metadata reported no valid resolve edge kind');
109
+ return { kind };
110
+ });
111
+ }
112
+
113
+ /** One resolved dependency of a package: the package it resolved to, and whether every declaration of it is a dev one. */
114
+ export interface CargoEdge {
115
+ readonly pkg: string;
116
+ /** Cargo builds this dependency for the dependent's tests, examples and benches only. */
117
+ readonly devOnly: boolean;
118
+ }
119
+
120
+ /** Every package Cargo builds for a selection, by package id, each with the dependencies Cargo builds for it. */
121
+ export type CargoClosure = ReadonlyMap<string, readonly string[]>;
122
+
86
123
  /** A mutable (path) package in Cargo's locked resolve. Every path is canonical. */
87
124
  export interface LocalCargoPackage {
88
125
  readonly id: string;
@@ -102,8 +139,13 @@ export interface CargoResolve {
102
139
  /** The workspace's own members: `root`'s manifest governs each of them. */
103
140
  readonly members: ReadonlySet<string>;
104
141
  readonly local: readonly LocalCargoPackage[];
142
+ /**
143
+ * Every package Cargo.lock pins (registry, git, alternate registry), by package id: its `source`, which for a git
144
+ * dependency names the locked commit that the id alone does not.
145
+ */
146
+ readonly locked: ReadonlyMap<string, string>;
105
147
  /** Every dependency edge by package id, or null when Cargo reported no resolution. */
106
- readonly edges: ReadonlyMap<string, readonly string[]> | null;
148
+ readonly edges: ReadonlyMap<string, readonly CargoEdge[]> | null;
107
149
  }
108
150
 
109
151
  export interface CargoPathInputsOptions {
@@ -125,22 +167,46 @@ export interface CargoPathInputsOptions {
125
167
  * soon as it is spawned, and a signal that reached this process before its
126
168
  * hooks would end it on the default action with Cargo's group left running.
127
169
  * Uncatchable SIGKILL cannot execute either hook.
170
+ * Each child is kept with what it is called when something is told of it.
128
171
  */
129
- const cargoChildren = new Set<ChildProcess>();
172
+ const cargoChildren = new Map<ChildProcess, string>();
130
173
 
131
- function killCargoChild(child: ChildProcess): void {
132
- if (process.platform === 'win32' || child.pid === undefined) child.kill('SIGKILL');
133
- else {
134
- try {
135
- process.kill(-child.pid, 'SIGKILL');
136
- } catch (error) {
137
- if (!(error instanceof Error && 'code' in error && error.code === 'ESRCH')) throw error;
138
- }
174
+ /**
175
+ * Ends the child's process group, and keeps ending it while the kernel lists members: a member forked as the signal
176
+ * goes out survives it, and one that holds Cargo's output pipe keeps `close` from ever coming, so the call would never
177
+ * settle. Every caller is synchronous, so the child stays unreaped until this returns and the kernel lists it as a
178
+ * member of its own group however dead it is: a group left listed cannot be told from one with a survivor, and is said
179
+ * on stderr as listed, not as running (`describeTeardown`). A kill that fails is said too. Neither is thrown: the
180
+ * callers are ending this process or failing a call, and the failure they carry, the other children still to be ended
181
+ * and the signal still to be given back all come before a diagnostic.
182
+ */
183
+ function killCargoChild(child: ChildProcess, command: string): void {
184
+ if (process.platform === 'win32' || child.pid === undefined) {
185
+ child.kill('SIGKILL');
186
+ return;
187
+ }
188
+ try {
189
+ if (killProcessGroupNow(child.pid, TEARDOWN_PATIENCE)) tell(describeTeardown({ command, group: child.pid }));
190
+ } catch (error) {
191
+ tell(`${command} could not be ended: ${error instanceof Error ? error.message : String(error)}`);
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Says `message` on stderr, now: the exit hook and the signal handler run where nothing is awaited. Where stderr is
197
+ * gone there is nobody to tell, and a diagnostic must neither replace the failure it accompanies nor stop the signal
198
+ * being given back.
199
+ */
200
+ function tell(message: string): void {
201
+ try {
202
+ writeSync(2, `${message}\n`);
203
+ } catch {
204
+ // Nobody is left to tell.
139
205
  }
140
206
  }
141
207
 
142
208
  function killCargoChildren(): void {
143
- for (const child of cargoChildren) killCargoChild(child);
209
+ for (const [child, command] of cargoChildren) killCargoChild(child, command);
144
210
  }
145
211
 
146
212
  type CargoSignal = 'SIGINT' | 'SIGTERM' | 'SIGHUP';
@@ -156,10 +222,14 @@ function removeCargoSignalHandlers(): void {
156
222
  forwardedSignals.clear();
157
223
  }
158
224
 
225
+ /** Ends the children, then gives the signal back so that this process still ends by it, whatever the kill did. */
159
226
  function forwardCargoSignal(signal: CargoSignal): void {
160
- killCargoChildren();
161
- removeCargoSignalHandlers();
162
- process.kill(process.pid, signal);
227
+ try {
228
+ killCargoChildren();
229
+ } finally {
230
+ removeCargoSignalHandlers();
231
+ process.kill(process.pid, signal);
232
+ }
163
233
  }
164
234
 
165
235
  function ownCargoChildren(): void {
@@ -188,6 +258,7 @@ function disownCargoChildren(): void {
188
258
  function runCargo(args: readonly string[], cwd: string, boundMs: number = CARGO_RESOLVE_BOUND_MS): Promise<string> {
189
259
  // spawn forwards detached groups; execFile does not. The public ES2022
190
260
  // library API requires the constructor form, not Promise.withResolvers.
261
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: settled by the CARGO_RESOLVE_BOUND_MS timer armed inside it, which ends a cargo held behind another's lock as CargoResolveLockError
191
262
  return new Promise((settle, reject) => {
192
263
  // Hooks first: a signal caught from here on runs its listener after this
193
264
  // synchronous body, by which time the child is in `cargoChildren`.
@@ -203,7 +274,8 @@ function runCargo(args: readonly string[], cwd: string, boundMs: number = CARGO_
203
274
  if (cargoChildren.size === 0) disownCargoChildren();
204
275
  throw error;
205
276
  }
206
- cargoChildren.add(child);
277
+ const command = `cargo ${args.join(' ')}`;
278
+ cargoChildren.set(child, command);
207
279
  let stdout = '';
208
280
  let stderr = '';
209
281
  let stdoutBytes = 0;
@@ -211,7 +283,7 @@ function runCargo(args: readonly string[], cwd: string, boundMs: number = CARGO_
211
283
  let failure: Error | undefined;
212
284
  const fail = (error: Error): void => {
213
285
  failure ??= error;
214
- killCargoChild(child);
286
+ killCargoChild(child, command);
215
287
  };
216
288
  const timer = setTimeout(
217
289
  () =>
@@ -274,8 +346,6 @@ export const HASH_SKIPPED_DIRECTORIES = [
274
346
  '.Spotlight-V100',
275
347
  '.DocumentRevisions-V100',
276
348
  ] as const;
277
- /** Files in every ancestor of a package directory that Cargo reads while building it. */
278
- export const CARGO_ANCESTOR_INPUTS = ['Cargo.toml', '.cargo/config', '.cargo/config.toml'] as const;
279
349
 
280
350
  /**
281
351
  * Cargo owns resolution, including workspace inheritance, target dependencies,
@@ -345,8 +415,8 @@ interface ResolveState {
345
415
  pending?: { readonly key: string; readonly promise: Promise<CargoResolve> };
346
416
  }
347
417
  const resolves = new Map<string, ResolveState>();
348
- // v2 retains package name/version for checkout-independent artifact input identities.
349
- const RESOLVE_CACHE_SCHEMA = 'cargo-resolve-v2';
418
+ // v3 retains each resolve edge's dependency kinds, which decide what Cargo builds for a selected package.
419
+ const RESOLVE_CACHE_SCHEMA = 'cargo-resolve-v3';
350
420
 
351
421
  /**
352
422
  * The longest one Cargo child, or one wait for a foreign resolve flight's lock, may take.
@@ -464,10 +534,16 @@ function cargoFromMetadata(metadata: CargoMetadata): CargoResolve {
464
534
  governingManifest: pkg.governing_manifest_path,
465
535
  };
466
536
  }),
537
+ locked: new Map(metadata.packages.flatMap((pkg) => (pkg.source === null ? [] : [[pkg.id, pkg.source] as const]))),
467
538
  edges:
468
539
  metadata.resolve === null
469
540
  ? null
470
- : new Map(metadata.resolve.nodes.map((node) => [node.id, node.deps.map((dep) => dep.pkg)])),
541
+ : new Map(
542
+ metadata.resolve.nodes.map((node) => [
543
+ node.id,
544
+ node.deps.map((dep) => ({ pkg: dep.pkg, devOnly: dep.dep_kinds.every(({ kind }) => kind === 'dev') })),
545
+ ]),
546
+ ),
471
547
  };
472
548
  }
473
549
 
@@ -673,6 +749,9 @@ export class CargoResolveLockError extends Error {
673
749
  }
674
750
  }
675
751
 
752
+ /** What the child that waits for the Cargo resolve lock is called when something is told of it. */
753
+ const LOCK_WAITER = 'the Cargo resolve lock waiter';
754
+
676
755
  /**
677
756
  * The pinned Nx binding has only blocking acquisition. Isolate that syscall in
678
757
  * one child per cold flight so the caller's deadline can kill and reap it.
@@ -692,6 +771,7 @@ export function acquireCargoResolveLock(
692
771
  "process.stdin.on('end', () => { lock.unlock(); process.exit(0); });",
693
772
  ].join('\n');
694
773
  // The public ES2022 library API requires the constructor form, not Promise.withResolvers.
774
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: settled by the boundMs timer armed inside it, which ends the lock waiter as CargoResolveLockError
695
775
  return new Promise((settle, reject) => {
696
776
  const started = performance.now();
697
777
  const child = spawn(process.execPath, ['--eval', program], {
@@ -705,12 +785,13 @@ export function acquireCargoResolveLock(
705
785
  let stderr = '';
706
786
  const fail = (error: Error): void => {
707
787
  failure ??= error;
708
- killCargoChild(child);
788
+ killCargoChild(child, LOCK_WAITER);
709
789
  };
710
790
  const timer = setTimeout(
711
791
  () => fail(new CargoResolveLockError(lockFile, boundMs, Math.ceil(performance.now() - started), child.pid)),
712
792
  boundMs,
713
793
  );
794
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: the waiter's close after the boundMs timer above settled or killed it; a killed child's close follows its SIGKILL
714
795
  const closed = new Promise<void>((finish) => {
715
796
  child.on('close', (code, signal) => {
716
797
  clearTimeout(timer);
@@ -762,7 +843,7 @@ export function acquireCargoResolveLock(
762
843
  child.stdout.on('error', fail);
763
844
  child.stderr.on('error', fail);
764
845
  if (cargoChildren.size === 0) ownCargoChildren();
765
- cargoChildren.add(child);
846
+ cargoChildren.set(child, LOCK_WAITER);
766
847
  });
767
848
  }
768
849
 
@@ -852,10 +933,10 @@ export async function hashCargoPathInputs(
852
933
  const fromCargo = relative(cargo.root, directory);
853
934
  if (
854
935
  fromRoot !== '..' &&
855
- !fromRoot.startsWith('..' + sep) &&
936
+ !fromRoot.startsWith(`..${sep}`) &&
856
937
  !isAbsolute(fromRoot) &&
857
938
  fromCargo !== '..' &&
858
- !fromCargo.startsWith('..' + sep) &&
939
+ !fromCargo.startsWith(`..${sep}`) &&
859
940
  !isAbsolute(fromCargo) &&
860
941
  !fromRoot.split(sep).includes('node_modules')
861
942
  )
@@ -875,7 +956,7 @@ export async function hashCargoPathInputs(
875
956
  for (const name of CARGO_ANCESTOR_INPUTS) {
876
957
  const file = join(ancestor, name);
877
958
  if (statSync(file, { throwIfNoEntry: false })?.isFile()) {
878
- includeFile(await realpath(file), inputKey(pkg, 'ancestor', depth + '/' + name));
959
+ includeFile(await realpath(file), inputKey(pkg, 'ancestor', `${depth}/${name}`));
879
960
  }
880
961
  }
881
962
  }
@@ -892,7 +973,7 @@ export async function hashCargoPathInputs(
892
973
  if (skipped.has(entry.name)) continue;
893
974
  const path = join(canonical, entry.name);
894
975
  if (ignored(path)) continue;
895
- const localPath = within === '' ? entry.name : within + '/' + entry.name;
976
+ const localPath = within === '' ? entry.name : `${within}/${entry.name}`;
896
977
  if (entry.isSymbolicLink())
897
978
  links.set(path, { key: inputKey(owner, 'link', localPath), target: await readlink(path) });
898
979
  const info = entry.isSymbolicLink() ? await lstat(await realpath(path)) : entry;
@@ -922,7 +1003,7 @@ export async function hashCargoPathInputs(
922
1003
  const scan: SourceScan = { directory, owner, sources: [...compiledSourceFiles(directory)], found: new Map() };
923
1004
  for (const source of scan.sources) scans.set(source, scan);
924
1005
  // Equal package identities can interleave, so their discovery shares one boundary.
925
- const prefix = JSON.stringify([owner.name, owner.version]).slice(0, -1) + ',';
1006
+ const prefix = `${JSON.stringify([owner.name, owner.version]).slice(0, -1)},`;
926
1007
  const group = groups.get(prefix);
927
1008
  if (group === undefined) groups.set(prefix, [scan]);
928
1009
  else group.push(scan);
@@ -957,7 +1038,7 @@ export async function hashCargoPathInputs(
957
1038
  // All ordinary sources have a file identity before this package's include identities.
958
1039
  // Earlier includes may already have consumed a later package's source; only its
959
1040
  // discovered references survive that boundary, never the source buffer.
960
- const boundary = prefix + '"include",';
1041
+ const boundary = `${prefix}"include",`;
961
1042
  while (next < scheduled.length && scheduled[next].key < boundary) await consume(scheduled[next++]);
962
1043
  const included: FileInput[] = [];
963
1044
  for (const scan of group) {
@@ -973,7 +1054,7 @@ export async function hashCargoPathInputs(
973
1054
  if (ignored(input.file)) continue;
974
1055
  const accepted = includeFile(
975
1056
  await realpath(input.file),
976
- inputKey(scan.owner, 'include', relative(scan.directory, input.source) + '\0' + input.literal),
1057
+ inputKey(scan.owner, 'include', `${relative(scan.directory, input.source)}\0${input.literal}`),
977
1058
  );
978
1059
  if (accepted !== undefined) included.push(accepted);
979
1060
  }
@@ -987,22 +1068,35 @@ export async function hashCargoPathInputs(
987
1068
  }
988
1069
 
989
1070
  /**
990
- * The ids Cargo's resolve graph reaches from the local packages under
991
- * `directory`, over every dependency kind: a target may build, test or run
992
- * build scripts, and any of those compiles the edge's source.
1071
+ * What Cargo builds for the local packages under `directory`, as {@link buildClosure} computes it with those packages
1072
+ * selected.
993
1073
  */
994
- export async function dependencyClosure(cargo: CargoResolve, directory: string): Promise<ReadonlySet<string>> {
1074
+ export async function dependencyClosure(cargo: CargoResolve, directory: string): Promise<CargoClosure> {
995
1075
  const base = await realpath(directory);
996
- const pending = cargo.local
1076
+ const selected = cargo.local
997
1077
  .filter((pkg) => pkg.directory === base || pkg.directory.startsWith(`${base}${sep}`))
998
1078
  .map((pkg) => pkg.id);
999
- if (pending.length === 0) throw new Error(`no local Cargo package lies under ${directory}`);
1079
+ if (selected.length === 0) throw new Error(`no local Cargo package lies under ${directory}`);
1080
+ return buildClosure(cargo, selected);
1081
+ }
1082
+
1083
+ /**
1084
+ * The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
1085
+ * it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
1086
+ * script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
1087
+ * its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
1088
+ * binaries and are not part of what it builds.
1089
+ */
1090
+ export function buildClosure(cargo: CargoResolve, selected: readonly string[]): CargoClosure {
1000
1091
  if (cargo.edges === null) throw new Error('cargo metadata reported no dependency resolution');
1001
- const reached = new Set<string>();
1092
+ const roots = new Set(selected);
1093
+ const reached = new Map<string, readonly string[]>();
1094
+ const pending = [...selected];
1002
1095
  for (let id = pending.pop(); id !== undefined; id = pending.pop()) {
1003
1096
  if (reached.has(id)) continue;
1004
- reached.add(id);
1005
- for (const dependency of cargo.edges.get(id) ?? []) pending.push(dependency);
1097
+ const built = (cargo.edges.get(id) ?? []).filter((edge) => roots.has(id) || !edge.devOnly).map((edge) => edge.pkg);
1098
+ reached.set(id, built);
1099
+ pending.push(...built);
1006
1100
  }
1007
1101
  return reached;
1008
1102
  }
@@ -1032,6 +1126,7 @@ function gitIgnoredBeneath(directories: readonly string[]): (path: string) => bo
1032
1126
  const sourceRoots = relativeMembers.filter((member) => !ignoredRoots.has(member));
1033
1127
  if (sourceRoots.length === 0) continue;
1034
1128
  const installed = [...ignoredRoots].map((member) => join(repository, member));
1129
+ // 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
1035
1130
  const listing = execFileSync(
1036
1131
  'git',
1037
1132
  [
@@ -1066,6 +1161,7 @@ function gitIgnoredBeneath(directories: readonly string[]): (path: string) => bo
1066
1161
 
1067
1162
  /** The members of `paths` (relative to `repository`) that git ignores, own patterns or an ancestor's. */
1068
1163
  function gitCheckIgnore(repository: string, paths: readonly string[]): string[] {
1164
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git ignore check of the paths on its stdin: 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
1069
1165
  const result = spawnSync('git', [...ISOLATED_GIT_ARGS, '-C', repository, 'check-ignore', '-z', '--stdin'], {
1070
1166
  input: `${paths.join('\0')}\0`,
1071
1167
  encoding: 'utf8',
@@ -1085,6 +1181,7 @@ function gitRepository(directory: string): string | undefined {
1085
1181
  try {
1086
1182
  // The walk compares realpaths, so git's answer is canonicalized the same way.
1087
1183
  return realpathSync(
1184
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git work-tree lookup: 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
1088
1185
  execFileSync('git', [...ISOLATED_GIT_ARGS, '-C', directory, 'rev-parse', '--show-toplevel'], {
1089
1186
  encoding: 'utf8',
1090
1187
  stdio: CHILD_STDIO,
@@ -0,0 +1,95 @@
1
+ import { accessSync, constants, realpathSync } from 'node:fs';
2
+ import { delimiter, join } from 'node:path';
3
+
4
+ /**
5
+ * The programs the shell declares for Cargo to compile and link with, each named by the Nix store object it is: the
6
+ * half of a cargo task's toolchain identity that no file states.
7
+ *
8
+ * `devenv.lock` locks the inputs, not what the shell builds from them. A patch to the linker moves no byte of the lock
9
+ * and no line of `rustc -vV`, yet it changes what links every unit. Hashing the shell's Nix sources instead was
10
+ * measured to rekey every cargo verdict on every unrelated shell edit (the managed module alone changed 43 times in 30
11
+ * days). The store object is the fact itself: devenv evaluates a package to the path of a derivation whose hash covers
12
+ * everything it was built from, so the path moves when the toolchain moves, once, and not when anything else in the
13
+ * shell does.
14
+ *
15
+ * What counts is what Cargo keys on. The linker of each target is `CARGO_TARGET_<TRIPLE>_LINKER`, which Cargo hashes
16
+ * into every unit. The programs cc-rs runs for build scripts are `CC`, `CXX`, `AR` and `RANLIB` (generic, per target,
17
+ * and their `HOST_` and `TARGET_` forms), each of which cc-rs declares `rerun-if-env-changed`. Flag variables name no
18
+ * program. The wrapper devenv builds for a Linux linker names its clang and its lld, so a change to either moves that
19
+ * wrapper's object, and one entry covers all three.
20
+ *
21
+ * rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
22
+ * version recipe beside this one hashes it. On a non-Linux host the default shell and its linux-cross profile carry
23
+ * different rust-std targets, so a rustc path would split the pre-push probe from the cached cross-check verdict.
24
+ *
25
+ * Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
26
+ * shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
27
+ */
28
+ export const NIX_STORE_ROOT = '/nix/store';
29
+
30
+ /** The variables naming a program Cargo or one of its build scripts runs. */
31
+ const PROGRAM_VARIABLE =
32
+ /^(?:CARGO_TARGET_[A-Z0-9_]+_LINKER|(?:CC|CXX|AR|RANLIB)(?:_[a-z].*)?|(?:HOST_|TARGET_)(?:CC|CXX|AR|RANLIB))$/;
33
+
34
+ export interface CargoToolchainProbe {
35
+ readonly environment: Readonly<Record<string, string | undefined>>;
36
+ readonly storeRoot: string;
37
+ /** What `program` is once every link is followed, or undefined where it names no executable file. */
38
+ readonly resolve: (program: string) => string | undefined;
39
+ }
40
+
41
+ /** The store object holding `path`, whichever of its files the path names, or undefined outside the store. */
42
+ function storeObject(path: string, storeRoot: string): string | undefined {
43
+ const prefix = `${storeRoot}/`;
44
+ if (!path.startsWith(prefix)) return undefined;
45
+ const [object] = path.slice(prefix.length).split('/', 1);
46
+ return object === undefined || object === '' ? undefined : `${prefix}${object}`;
47
+ }
48
+
49
+ /**
50
+ * One `NAME store-object` line, in name order, for each program variable whose program lives in the store; empty where
51
+ * the shell declares none. A variable holds a program name or path, then arguments (`ccache cc`): the first word is
52
+ * the program, a bare name is looked up on PATH.
53
+ */
54
+ export function cargoToolchainPaths(probe: CargoToolchainProbe): string {
55
+ const lines: string[] = [];
56
+ for (const name of Object.keys(probe.environment).sort()) {
57
+ if (!PROGRAM_VARIABLE.test(name)) continue;
58
+ const program = probe.environment[name]?.trim().split(/\s+/, 1)[0];
59
+ if (program === undefined || program === '') continue;
60
+ const resolved = probe.resolve(program);
61
+ const object = resolved === undefined ? undefined : storeObject(resolved, probe.storeRoot);
62
+ if (object !== undefined) lines.push(`${name} ${object}\n`);
63
+ }
64
+ return lines.join('');
65
+ }
66
+
67
+ /** Errors that say a candidate is not a program, as opposed to a machine that cannot be read. */
68
+ const NOT_A_PROGRAM = new Set(['ENOENT', 'ENOTDIR', 'EACCES', 'ELOOP', 'ENAMETOOLONG']);
69
+
70
+ /** The real path of `program`: itself where it holds a path, else the first executable file `searchPath` names. */
71
+ export function resolveProgram(program: string, searchPath: string | undefined): string | undefined {
72
+ const candidates = program.includes('/')
73
+ ? [program]
74
+ : (searchPath ?? '')
75
+ .split(delimiter)
76
+ .filter((directory) => directory !== '')
77
+ .map((directory) => join(directory, program));
78
+ for (const candidate of candidates) {
79
+ try {
80
+ accessSync(candidate, constants.X_OK);
81
+ return realpathSync(candidate);
82
+ } catch (error) {
83
+ if (
84
+ error instanceof Error &&
85
+ 'code' in error &&
86
+ typeof error.code === 'string' &&
87
+ NOT_A_PROGRAM.has(error.code)
88
+ ) {
89
+ continue;
90
+ }
91
+ throw error;
92
+ }
93
+ }
94
+ return undefined;
95
+ }
@@ -9,7 +9,7 @@ import { runtimeInput, shellWord } from './runtime-input.js';
9
9
  * The DECLARED pin, hashed as an ordinary file. devenv resolves this lock into
10
10
  * the rustc, cargo, linker, C toolchain and SDK that every cargo command
11
11
  * inherits, so a bump here is exactly the event that must invalidate a cached
12
- * artifact — and it is the only such event the workspace can state portably.
12
+ * artifact — and it is the half of the identity that a file can state portably.
13
13
  *
14
14
  * This replaces a runtime input that dumped the ambient cargo environment
15
15
  * (every `CARGO_`, `RUST`, `CC`, `CXX`, `AR`, `SDKROOT`, `LIBCLANG_PATH`,
@@ -46,14 +46,37 @@ export const CARGO_TOOLCHAIN_PIN_INPUTS: readonly string[] = [
46
46
  ];
47
47
 
48
48
  /**
49
- * The name a repository's own `inputs` declaration uses to reach the pin
50
- * without restating its paths.
49
+ * The runtime input naming the programs the shell declares for Cargo to compile and link with, by Nix store object:
50
+ * the other half of the identity, which no file states (cargo-toolchain-paths.ts says what it names, and why). Nx runs
51
+ * a runtime input from the workspace root, so the command names the plugin as the workspace's `node_modules` links it.
52
+ */
53
+ const CARGO_TOOLCHAIN_PATHS_COMMAND = 'node node_modules/@smoothbricks/nx-plugin/dist/bin/smoo-nx-cargo-toolchain.js';
54
+
55
+ /** The runtime input of the programs the shell declares, a fresh value for each caller. */
56
+ export function cargoToolchainPathsInput(): { runtime: string } {
57
+ return runtimeInput(CARGO_TOOLCHAIN_PATHS_COMMAND);
58
+ }
59
+
60
+ /** An input of a resolved list that can carry the identity: a fileset, or a runtime command. */
61
+ export type ReachedInput = string | { readonly runtime: string };
62
+
63
+ /** Every input a cargo task's key names of its toolchain: the pin files, then the programs the shell declares. */
64
+ export function cargoToolchainInputs(): (string | { runtime: string })[] {
65
+ return [...CARGO_TOOLCHAIN_PIN_INPUTS, cargoToolchainPathsInput()];
66
+ }
67
+
68
+ /**
69
+ * The name a repository's own `inputs` declaration uses to reach the whole
70
+ * toolchain identity without restating it.
51
71
  *
52
72
  * A declared target REPLACES the inferred input list, pin included, so a
53
73
  * hand-written `inputs` array silently drops the toolchain identity and the
54
74
  * target stops seeing a toolchain bump at all. Inference defines this named
55
75
  * input on every project that has cargo targets so a declaration can name one
56
76
  * token that cannot drift from what the plugin attaches.
77
+ *
78
+ * The identity holds an input no fileset can state, so a declaration names this
79
+ * rather than restating the lock.
57
80
  */
58
81
  export const CARGO_TOOLCHAIN_NAMED_INPUT = 'cargoToolchain';
59
82
 
@@ -63,12 +86,33 @@ export function cargoRuntimeInput(projectRoot: string, command: string): { runti
63
86
  }
64
87
 
65
88
  /**
66
- * Does one resolved input string carry the toolchain identity?
89
+ * Does one resolved input string hold a toolchain lock?
67
90
  *
68
91
  * Resolved: named inputs already expanded. The check is by suffix rather than
69
92
  * by exact path because a repository may keep its lock at a location this list
70
93
  * does not name; what matters is that a devenv lock is hashed, not which one.
71
94
  */
72
- export function isCargoToolchainInput(input: string): boolean {
95
+ function isCargoToolchainLock(input: string): boolean {
73
96
  return !input.startsWith('!') && input.endsWith('/devenv.lock');
74
97
  }
98
+
99
+ /**
100
+ * Does a resolved input list carry the toolchain identity?
101
+ *
102
+ * `reached` is what a declaration's inputs hold once their named inputs are resolved. The inference-owned
103
+ * `cargoToolchain`, left unresolved, stands for the whole identity. Otherwise the list must hold both halves itself: a
104
+ * devenv lock that nothing in the list excludes, and the programs runtime input exactly as inference spells it. A lock
105
+ * restated without the programs is refused, however it is reached: no fileset can state the programs the shell
106
+ * declares, so a list that stops at the lock misses a change to the linker.
107
+ */
108
+ export function carriesCargoToolchain(reached: readonly ReachedInput[]): boolean {
109
+ if (reached.includes(CARGO_TOOLCHAIN_NAMED_INPUT)) return true;
110
+ const excluded = new Set(
111
+ reached.flatMap((input) => (typeof input === 'string' && input.startsWith('!') ? [input.slice(1)] : [])),
112
+ );
113
+ const hasLock = reached.some(
114
+ (input) => typeof input === 'string' && isCargoToolchainLock(input) && !excluded.has(input),
115
+ );
116
+ const programs = cargoToolchainPathsInput().runtime;
117
+ return hasLock && reached.some((input) => typeof input === 'object' && input.runtime === programs);
118
+ }