@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
@@ -19,18 +19,6 @@
19
19
  pkgs,
20
20
  ...
21
21
  }: let
22
- # ttsc's native-plugin patch compiles microsoft/typescript-go with one
23
- # corrected file. `go list -m` only fills `.Dir` after the module is already
24
- # in GOMODCACHE, which CI does not restore (and GOPROXY is often off under
25
- # nix). Pin the commit ttsc 0.30.4's patch requires so the tree is in the
26
- # devenv closure and TTSC_TYPESCRIPT_GO_DIR names it.
27
- typescriptGo = pkgs.fetchFromGitHub {
28
- owner = "microsoft";
29
- repo = "typescript-go";
30
- rev = "56ab4af42157";
31
- hash = "sha256-ebjX+1+9axEqsnZXCRZSumA38gPNdmoz98tMt2oftN4=";
32
- };
33
-
34
22
  # The nixpkgs the Go pin below comes from (devenv.yaml `nixpkgs-go`).
35
23
  goPkgs = import inputs.nixpkgs-go {inherit (pkgs.stdenv.hostPlatform) system;};
36
24
 
@@ -44,8 +32,8 @@
44
32
  # The revision is can1357/TypeScript perf/checker-speedups-v3: 36 checker,
45
33
  # arena and scheduler commits on microsoft/TypeScript main 6ad8c56f9b5a,
46
34
  # while they are upstreamed. Its Go module (tsc/, Go 1.27) builds with the
47
- # nixpkgs-go input's go_1_27 inside this derivation; the shell's own Go stays the
48
- # one ttsc vendors. The sparse checkout keeps the ~61k test baselines out of
35
+ # nixpkgs-go input's go_1_27 inside this derivation, the same Go the shell
36
+ # provides because ttsc vendors that line. The sparse checkout keeps the ~61k test baselines out of
49
37
  # the store, and GOWORK=off keeps the repository's go.work (tools/) out of
50
38
  # the module build.
51
39
  typecheckTsc = goPkgs.buildGo127Module {
@@ -93,18 +81,27 @@
93
81
  # same files for anything that names it.
94
82
  rustToolchainBin = "${config.languages.rust.toolchainPackage}/bin";
95
83
 
84
+ # The cc-rs compiler variables this shell's `env` declares (a Linux shell
85
+ # pins its native compiler there): compiler-variables.sh keeps them and
86
+ # drops every other one the shell inherits (enterShell item 9).
87
+ declaredCompilerVariables =
88
+ lib.filter
89
+ (name: builtins.match "((HOST|TARGET)_)?(CC|CXX|AR|RANLIB|CFLAGS|CXXFLAGS|ARFLAGS|RANLIBFLAGS)(_[a-z].*)?" name != null)
90
+ (lib.attrNames config.env);
91
+
96
92
  # Expose pyflakes without propagating a second interpreter into the shell.
97
93
  pyflakesBin = pkgs.runCommandLocal "pyflakes-${pkgs.python3Packages.pyflakes.version}" {} ''
98
94
  mkdir -p "$out/bin"
99
95
  ln -s ${pkgs.python3Packages.pyflakes}/bin/pyflakes "$out/bin/pyflakes"
100
96
  '';
101
97
 
102
- # Builds every Linux artifact and the cross clippy; see `profiles.linux-cross`
103
- # below for where it applies and why. The rust-std set is every Linux triple
104
- # an artifact ships for except x86_64-unknown-linux-gnu, which the base shell
105
- # already carries.
98
+ # Builds every Linux Rust artifact and the cross clippy; see
99
+ # `profiles.linux-cross` below for where it applies and why. zig itself is in
100
+ # the base shell (see `pkgs.zig` in `packages`). The rust-std set is every
101
+ # Linux triple an artifact ships for except x86_64-unknown-linux-gnu, which the
102
+ # base shell already carries.
106
103
  linuxToolchain = {
107
- packages = [pkgs.zig pkgs.cargo-zigbuild];
104
+ packages = [pkgs.cargo-zigbuild];
108
105
  languages.rust.targets = [
109
106
  "aarch64-unknown-linux-gnu"
110
107
  "x86_64-unknown-linux-musl"
@@ -112,6 +109,11 @@
112
109
  ];
113
110
  };
114
111
  in {
112
+ # The one evaluation of the nixpkgs-go package set, as a module argument. A
113
+ # repository's devenv.nix that needs this Go takes `goPkgs` instead of
114
+ # importing the same Go inputs again and repeating package-set evaluation.
115
+ _module.args.goPkgs = goPkgs;
116
+
115
117
  # nixpkgs carries actionlint, not the jdx fork. Supply the immutable upstream
116
118
  # release as a normal package, with the same pin in developer shells and CI.
117
119
  # Nix fetches/verifies it once; validation never installs or compiles a tool.
@@ -182,7 +184,15 @@ in {
182
184
  # `nx migrate` run with the installed CLI instead of the newest one;
183
185
  # `NX_USE_LOCAL=false nx migrate` restores that for the one command.
184
186
  NX_USE_LOCAL = "true";
185
- TTSC_TYPESCRIPT_GO_DIR = "${typescriptGo}";
187
+ # Nx loads every project-graph plugin in a worker process of its own by
188
+ # default, so each daemon keeps one resident Node process per plugin
189
+ # beside itself. Off, the daemon (or a daemonless client) loads them in
190
+ # its own process. Measured on a 56-project consumer's shed (2026-10-22,
191
+ # three restarts each): the same project graph and the same hash for all
192
+ # 443 tasks of `nx run-many -t lint`; the daemon tree went from 8
193
+ # processes, about 1.75 GB RSS, to 1 process, about 0.65 GB. Nx 23.2.1
194
+ # reads only "false" as off (project-graph/plugins/isolation/enabled.js).
195
+ NX_ISOLATE_PLUGINS = "false";
186
196
  SMOO_TYPECHECK_TSC = "${typecheckTsc}/bin/tsc";
187
197
  }
188
198
  # Playwright's downloaded Ubuntu browser has no runtime closure on NixOS
@@ -261,10 +271,10 @@ in {
261
271
  ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux linuxToolchain.languages.rust.targets;
262
272
  };
263
273
 
264
- # The Linux toolchain: zig, driven through cargo-zigbuild, plus the Linux
265
- # rust-std set. It builds every published Linux artifact — static musl CLIs,
266
- # glibc 2.17 N-API addons — and `check:linux`'s cross clippy, with the same
267
- # command on every host. zig carries glibc symbol-version stubs for every
274
+ # The Linux Rust toolchain: cargo-zigbuild driving zig, plus the Linux
275
+ # rust-std set. It builds every published Linux Rust artifact — static musl
276
+ # CLIs, glibc 2.17 N-API addons — and `check:linux`'s cross clippy, with the
277
+ # same command on every host. zig carries glibc symbol-version stubs for every
268
278
  # glibc and the musl sources inside its own store path, so nothing on the
269
279
  # build machine reaches the artifact: no loader path, no RUNPATH, no build
270
280
  # host's glibc floor. cargo-zigbuild supplies the `zig cc` shims and per-triple
@@ -273,10 +283,13 @@ in {
273
283
  # A Linux host carries it in the base shell, because its ordinary `build`
274
284
  # includes its own platform's artifacts. A macOS host opts in through the
275
285
  # `linux-cross` profile, activated by `devenv -P linux-cross` and driven by
276
- # the root `check:linux` script: zig is a 380 MiB closure, about 0.9 GiB with
277
- # the three rust-std targets, and nothing else on Darwin needs it. devenv 2.2.3
278
- # has first-class profiles, so this is one gated module in the shared file
279
- # rather than a second config directory that would re-import and re-pin
286
+ # the root `check:linux` script: the three rust-std targets are about 0.5 GiB
287
+ # and nothing else on Darwin needs them. zig is not in the profile: every
288
+ # host's base shell carries it, because the scriptc-<arch>-<family> targets
289
+ # compile every platform's executables through `zig cc` on every host, the
290
+ # host's own platform included (see `pkgs.zig` in `packages` below). devenv
291
+ # 2.2.3 has first-class profiles, so this is one gated module in the shared
292
+ # file rather than a second config directory that would re-import and re-pin
280
293
  # everything here.
281
294
  #
282
295
  # The profile supplies the toolchain and nothing else. CARGO_BUILD_TARGET is
@@ -341,7 +354,7 @@ in {
341
354
  # comment that rots.
342
355
  #
343
356
  # It needs its own input because the fleet's nixpkgs does not carry that patch:
344
- # devenv-nixpkgs rolling ships go 1.26.5, while ttsc 0.30.4 vendors go1.26.8.
357
+ # devenv-nixpkgs rolling has no Go 1.27, while ttsc 0.34.1 vendors go1.27.3.
345
358
  # Same idiom, and same reason, for any single-package pin — one leaf package
346
359
  # from a nixpkgs that has it, lock-pinned, prebuilt, rather than a fleet-wide
347
360
  # bump that would move rustc, bun and node too. Not every pairing is
@@ -381,7 +394,7 @@ in {
381
394
  # `nixpkgs_2`.
382
395
  packages =
383
396
  [
384
- goPkgs.go
397
+ goPkgs.go_1_27
385
398
  pkgs.nodejs_26
386
399
  pkgs.binaryen
387
400
  # Smoo's GitHub Actions validator uses the managed prebuilt package above.
@@ -392,17 +405,26 @@ in {
392
405
  # Test runner for inferred Cargo test targets. Generated targets must never
393
406
  # depend on an ambient host installation that CI does not reproduce.
394
407
  pkgs.cargo-nextest
395
- # Target-dir GC for the inferred cargo-sweep target: cargo never removes
396
- # superseded artifacts on its own (a busy workspace accumulated ~18k stale
397
- # variants per crate and 26 GB of junk before this existed), and a sweep
398
- # prunes them without touching the warm current-fingerprint surface.
399
- pkgs.cargo-sweep
408
+ # The nx-plugin's Cargo retention holds Cargo's profile locks through a
409
+ # perl child: perl's flock is the flock(2) Cargo takes, and the kernel
410
+ # drops it with the child however the Nx process ends.
411
+ pkgs.perl
400
412
  # The stable-toolchain arm of smoo's workspace feature-unification policy:
401
413
  # `cargo hakari` generates and wires the workspace-hack crate that unifies
402
414
  # features when `[resolver] feature-unification` — nightly-only, and what
403
415
  # the channel above selects — is unavailable. `smoo monorepo validate` runs
404
416
  # `cargo hakari verify` for a workspace that took that route.
405
417
  pkgs.cargo-hakari
418
+ # The C compiler driver of every scriptc-<arch>-<family> target, on every
419
+ # host: scriptc refuses an SCRIPTC_TARGET build unless SCRIPTC_CC=zigcc
420
+ # (no other driver has cross sysroots), and the host's own platform builds
421
+ # the same way, so the darwin-x64 binary a macOS publish leg builds on an
422
+ # arm64 runner and the darwin-arm64 one a developer builds take one path.
423
+ # A profile cannot carry it: repair-pending rebuilds historical release
424
+ # commits in a plain `devenv shell`, which passes no profile (see the note
425
+ # on profiles below). The closure is about 380 MiB, fetched once per Nix
426
+ # store, not per checkout.
427
+ pkgs.zig
406
428
  ]
407
429
  ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux ([pkgs.chromium] ++ linuxToolchain.packages);
408
430
 
@@ -473,6 +495,13 @@ in {
473
495
  # and no checkout path can name, so it is gated by `status` (exit 0 when
474
496
  # CARGO_HOME holds them) rather than execIfModified.
475
497
  #
498
+ # Each fetch is bounded (tooling/direnv/cargo-fetch-bound.ts): cargo holds its
499
+ # global package-cache lock while it runs, so a fetch that stalls stops every
500
+ # cargo that shares CARGO_HOME. It runs in a process group of its own under a
501
+ # deadline that kills the group, and git, which has no low-speed limit of its
502
+ # own, drops a transfer that has all but stopped. A fetch that ends either
503
+ # way fails the task and records nothing.
504
+ #
476
505
  # smoo:developer-links points the packages the root package.json's
477
506
  # `smoo.developerLinks` declares at their local checkouts, after an install
478
507
  # and in every tree that installed them (tooling/direnv/developer-links.ts).
@@ -503,8 +532,10 @@ in {
503
532
  "../../tooling/workspace.gitconfig"
504
533
  "setup-environment.ts"
505
534
  "developer-links.ts"
535
+ "installed-bun-links.ts"
506
536
  "linked-snapshots.ts"
507
537
  "secret-references.ts"
538
+ "uv-relocation.ts"
508
539
  "../../node_modules/.smoo-install"
509
540
  "../../node_modules/@typescript/native/bin/tsc"
510
541
  ];
@@ -610,6 +641,9 @@ in {
610
641
  # nixpkgs xcbuild's `xcrun` are dropped, each one announced, so Xcode's
611
642
  # clang compiles against the licensed SDK and `xcrun` is Apple's.
612
643
  # tooling/direnv/apple-developer.sh does it and states why.
644
+ # 9. cc-rs's compiler variables are this shell's: the ones its `env`
645
+ # declares and no others. tooling/direnv/compiler-variables.sh drops
646
+ # and announces every other one the shell inherits, and states why.
613
647
  # Nx's own socket fallback (under HOME or TMPDIR) can exceed the Unix socket
614
648
  # limit in a checkout, and an inherited NX_SOCKET_DIR may be another
615
649
  # workspace's: tooling/direnv/nx-socket-dir.sh, sourced below, names this
@@ -618,12 +652,17 @@ in {
618
652
  # they run.
619
653
  (lib.mkBefore ''
620
654
  cd "$DEVENV_ROOT/../.."
655
+ # A bare assignment: export's status would hide repo-path's refusal of a
656
+ # cowshed workspace it could not serve, and the shell would enter with an
657
+ # empty PATH.
658
+ PATH="$("$PWD/tooling/direnv/repo-path")" || exit $?
621
659
  # Direct `devenv shell` skips .envrc. Reuse cowshed's one environment writer
622
660
  # before project hooks, rather than restating its CI/compiler-cache policy.
661
+ # After repo-path, which serves a workspace cowshed had not served yet, so
662
+ # the shell enters on the file that serve wrote.
623
663
  if [ -f .cowshed/env ]; then
624
664
  . "$PWD/.cowshed/env"
625
665
  fi
626
- export PATH="$("$PWD/tooling/direnv/repo-path")"
627
666
  export PATH="${rustToolchainBin}:$PATH"
628
667
  # devenv enters the shell with TMPDIR unset (not empty) on every platform.
629
668
  # Tools then fall back to /tmp, which on Darwin is not the per-user
@@ -650,7 +689,8 @@ in {
650
689
  # gives every workspace its own socket dir, and in a cowshed checkout the
651
690
  # one literal path its host shells and sandboxed jobs all share, and
652
691
  # states why.
653
- . "$DEVENV_ROOT/nx-socket-dir.sh"
692
+ . "$DEVENV_ROOT/nx-socket-dir.sh" || exit $?
693
+ . "$DEVENV_ROOT/compiler-variables.sh" ${lib.escapeShellArgs declaredCompilerVariables}
654
694
  ${lib.optionalString pkgs.stdenv.isDarwin ''
655
695
  . "$DEVENV_ROOT/apple-developer.sh" /nix/store
656
696
  ''}
@@ -661,7 +701,7 @@ in {
661
701
  (lib.mkAfter ''
662
702
  # Project hooks may prepend real Cargo. Reuse the managed PATH writer
663
703
  # last: its served install identity is the host's, not the private HOME.
664
- export PATH="$("$DEVENV_ROOT/repo-path")"
704
+ PATH="$("$DEVENV_ROOT/repo-path")" || exit $?
665
705
  bun "$DEVENV_ROOT/toolchain-stamp.ts" || exit $?
666
706
  if [ -n "$DEVENV_SHELL_PWD" ]; then
667
707
  cd "$DEVENV_SHELL_PWD"
@@ -20,18 +20,20 @@ add_repo_paths() {
20
20
  # The CLI that evaluates the shell must be the commit whose modules the shell is
21
21
  # locked to, so this installs the commit devenv.lock's `devenv` node names and
22
22
  # nothing here restates it. `smoo monorepo check` holds that node to a release:
23
- # its `original.ref` is `latest` or a tag from v2.0.4 on, which devenv.yaml
24
- # declares as `github:cachix/devenv/v2.3.1?dir=src/modules`. devenv.cachix.org
25
- # has pinned the aarch64-darwin, aarch64-linux and x86_64-linux builds of every
26
- # release from v2.0.4 on for good, so on those three systems the install
27
- # substitutes rather than compiles. From v2.2 on devenv builds nothing for
28
- # x86_64-darwin, so on an Intel macOS runner installing such a release fails
29
- # rather than compiles; there only v2.0.4 to v2.1.2 are pinned. Some older tags,
30
- # such as v2.0.3, have no pin, and their builds are already gone. An input
31
- # nobody declared locks devenv's main as it was that minute, and the cache drops
32
- # such a build after about six weeks, after which every cold runner compiles
33
- # devenv from source (a build of main commit 4ed83c00, which reported 2.1.3 but
34
- # was never tagged, was pushed on 2026-07-15 and was gone by 2026-10-13).
23
+ # it must name its remote and a commit that one of that remote's tags from
24
+ # v2.0.4 on names, which `git ls-remote` answers on every run. devenv.yaml
25
+ # declares such a lock as `github:cachix/devenv/v2.3.1?dir=src/modules`.
26
+ # devenv.cachix.org has pinned the aarch64-darwin, aarch64-linux and
27
+ # x86_64-linux builds of every release from v2.0.4 on for good, so on those
28
+ # three systems the install substitutes rather than compiles. From v2.2 on
29
+ # devenv builds nothing for x86_64-darwin, so on an Intel macOS runner
30
+ # installing such a release fails rather than compiles; there only v2.0.4 to
31
+ # v2.1.2 are pinned. Some older tags, such as v2.0.3, have no pin, and their
32
+ # builds are already gone. The cache drops the build of any commit no tag
33
+ # names, an ancestor of a release included, after about six weeks, after which
34
+ # every cold runner compiles devenv from source (a build of main commit
35
+ # 4ed83c00, which reported 2.1.3 but was never tagged, was pushed on 2026-07-15
36
+ # and was gone by 2026-10-13).
35
37
  #
36
38
  # An unpinned `github:cachix/devenv` instead installs whatever HEAD is on the day
37
39
  # a cold runner misses the store cache — a version that moves with no commit
@@ -0,0 +1,308 @@
1
+ import {
2
+ type Dirent,
3
+ existsSync,
4
+ lstatSync,
5
+ readdirSync,
6
+ readFileSync,
7
+ readlinkSync,
8
+ realpathSync,
9
+ statSync,
10
+ } from 'node:fs';
11
+ import path from 'node:path';
12
+ import { unreadableDeveloperLinks } from './developer-links.ts';
13
+
14
+ /**
15
+ * What a Bun install left linked in node_modules, read from the filesystem alone: whether every package a consumer
16
+ * resolves reaches a readable manifest (verifyInstalledBunLinks, before an install writes its success receipt), and
17
+ * which store links the installed tree reaches dangle (danglingStoreLinks, which makes a matching stamp stale).
18
+ * setup-environment.ts owns the workspace enumeration and passes each member's node_modules directory in.
19
+ */
20
+
21
+ export type BunInstallIntegrityOperation =
22
+ | 'inspect isolated store'
23
+ | 'resolve installed path'
24
+ | 'list installed package aliases'
25
+ | 'read installed package manifest';
26
+
27
+ export class BunInstallIntegrityError extends Error {
28
+ readonly code = 'BUN_INSTALL_INTEGRITY';
29
+
30
+ constructor(
31
+ public readonly operation: BunInstallIntegrityOperation,
32
+ public readonly actualPath: string,
33
+ public readonly expectedTarget: string,
34
+ cause: unknown,
35
+ ) {
36
+ super(
37
+ `Bun install integrity: ${operation} failed for ${actualPath}; expected target ${expectedTarget}: ${cause instanceof Error ? cause.message : String(cause)}`,
38
+ { cause },
39
+ );
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Link/manifest admission only, once before an install writes its success receipt. `members` is the node_modules
45
+ * directory of every workspace member, beside its manifest.
46
+ */
47
+ export function verifyInstalledBunLinks(
48
+ root: string,
49
+ members: readonly string[],
50
+ ): BunInstallIntegrityError | undefined {
51
+ const store = path.join(root, 'node_modules', '.bun');
52
+ let actualPath = store;
53
+ let expectedTarget = store;
54
+ let operation: BunInstallIntegrityOperation = 'inspect isolated store';
55
+ // Developer links whose target this process may not read (developer-links.ts): the install
56
+ // did not make them and nothing here can read what they name, so they are not admitted here.
57
+ let unreadable: ReadonlySet<string> = new Set();
58
+
59
+ const select = (candidate: string, symbolicLink: boolean): void => {
60
+ actualPath = candidate;
61
+ expectedTarget = candidate;
62
+ operation = 'resolve installed path';
63
+ if (symbolicLink) {
64
+ const target = readlinkSync(candidate);
65
+ expectedTarget = path.resolve(path.dirname(candidate), target);
66
+ expectedTarget = path.resolve(realpathSync(path.dirname(candidate)), target);
67
+ }
68
+ realpathSync(candidate);
69
+ };
70
+ const manifest = (candidate: string, symbolicLink: boolean): void => {
71
+ if (unreadable.has(candidate)) return;
72
+ select(candidate, symbolicLink);
73
+ operation = 'read installed package manifest';
74
+ JSON.parse(readFileSync(path.join(candidate, 'package.json'), 'utf8'));
75
+ };
76
+ const aliases = (tree: string, symbolicLink = false): void => {
77
+ select(tree, symbolicLink);
78
+ operation = 'list installed package aliases';
79
+ for (const entry of readdirSync(tree, { withFileTypes: true })) {
80
+ if (entry.name.startsWith('.')) continue;
81
+ const candidate = path.join(tree, entry.name);
82
+ if (entry.name.startsWith('@')) {
83
+ select(candidate, entry.isSymbolicLink());
84
+ operation = 'list installed package aliases';
85
+ for (const scoped of readdirSync(candidate, { withFileTypes: true })) {
86
+ if (!scoped.name.startsWith('.')) manifest(path.join(candidate, scoped.name), scoped.isSymbolicLink());
87
+ }
88
+ } else {
89
+ manifest(candidate, entry.isSymbolicLink());
90
+ }
91
+ }
92
+ };
93
+
94
+ // Admission walks the live closure, not every directory in the store. A restored store can
95
+ // carry superseded peer variants of packages the install also wrote under other variants:
96
+ // their links point into the install cache of the machine that wrote them and dangle here,
97
+ // and their own dependency aliases dangle with them. Nothing the install produced references
98
+ // those variants, so they are not broken live links. An entry is walked strictly when a link
99
+ // in the live tree resolves into it, or when it is the only variant of its package and
100
+ // version — a sole dangling variant still refuses, because there is no replacement to point
101
+ // at. Same package and version alone is never reachability proof.
102
+ const identityOf = (name: string): string | null => /^(.+@\d[^+]*)(\+.*)?$/.exec(name)?.[1] ?? null;
103
+ try {
104
+ unreadable = new Set(unreadableDeveloperLinks(root));
105
+ const state = lstatSync(store, { throwIfNoEntry: false });
106
+ // A hoisted install has no isolated store to admit.
107
+ if (state === undefined) return undefined;
108
+ select(store, state.isSymbolicLink());
109
+ operation = 'inspect isolated store';
110
+ const entries = readdirSync(store, { withFileTypes: true }).filter((entry) => !entry.name.startsWith('.'));
111
+ const identityCounts = new Map<string, number>();
112
+ for (const entry of entries) {
113
+ if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
114
+ const identity = identityOf(entry.name) ?? entry.name;
115
+ identityCounts.set(identity, (identityCounts.get(identity) ?? 0) + 1);
116
+ }
117
+ const referenced = referencedStoreEntries(root, store, entries, members);
118
+ // Package aliases are what every consumer actually resolves: each package they name must
119
+ // resolve to a readable manifest, wherever it points — into the store, into the install
120
+ // cache, or at a workspace member. The same strict walk applies at the root and in every
121
+ // workspace member's node_modules; member links seeded the closure above, and seeding is
122
+ // not validation. No identity waiver applies: an alias whose target does not exist is a
123
+ // broken import, however intact a same-version sibling is.
124
+ const checkPackage = (candidate: string, symbolicLink: boolean): void => {
125
+ try {
126
+ // Only a plain metadata file is skipped; a package alias that resolves to a regular
127
+ // file is a broken package and manifest() refuses it below.
128
+ if (!symbolicLink && !statSync(candidate).isDirectory()) return;
129
+ } catch {
130
+ // Dangling: manifest() refuses it with the path named.
131
+ }
132
+ manifest(candidate, symbolicLink);
133
+ };
134
+ const walkPackageAliases = (modules: string): void => {
135
+ for (const child of readdirSync(modules, { withFileTypes: true })) {
136
+ if (child.name.startsWith('.')) continue;
137
+ const childPath = path.join(modules, child.name);
138
+ if (child.name.startsWith('@')) {
139
+ // A scope is a namespace, symlinked or not: the same strict alias walk as the store's.
140
+ aliases(childPath, child.isSymbolicLink());
141
+ } else {
142
+ checkPackage(childPath, child.isSymbolicLink());
143
+ }
144
+ }
145
+ };
146
+ walkPackageAliases(path.join(root, 'node_modules'));
147
+ for (const modules of members) {
148
+ // A member with nothing installed has no aliases to validate; a present directory is
149
+ // walked with the root's strictness.
150
+ if (existsSync(modules)) walkPackageAliases(modules);
151
+ }
152
+ for (const entry of entries) {
153
+ const candidate = path.join(store, entry.name);
154
+ if (entry.name === 'node_modules') {
155
+ aliases(candidate, entry.isSymbolicLink());
156
+ } else if (entry.isDirectory() || entry.isSymbolicLink()) {
157
+ const identity = identityOf(entry.name) ?? entry.name;
158
+ // An unreferenced variant beside others of its package and version is superseded
159
+ // garbage the install left behind; nothing live resolves through it, so it is not
160
+ // walked. A sole variant is walked: there is no replacement to point at.
161
+ if (!referenced.has(entry.name) && (identityCounts.get(identity) ?? 0) > 1) continue;
162
+ select(candidate, entry.isSymbolicLink());
163
+ aliases(path.join(candidate, 'node_modules'));
164
+ }
165
+ }
166
+ return undefined;
167
+ } catch (cause) {
168
+ return new BunInstallIntegrityError(operation, actualPath, expectedTarget, cause);
169
+ }
170
+ }
171
+
172
+ /**
173
+ * The store entries the installed tree reaches. Every link in the root's node_modules, the
174
+ * store's own and each workspace member's that resolves into an entry makes that entry live,
175
+ * and so does every link in a live entry's own node_modules, to a fixed point. Member links
176
+ * are as live as root links.
177
+ */
178
+ function referencedStoreEntries(
179
+ root: string,
180
+ store: string,
181
+ entries: readonly Dirent[],
182
+ members: readonly string[],
183
+ ): Set<string> {
184
+ const referenced = new Set<string>();
185
+ const knownEntries = new Set(entries.filter((entry) => entry.name !== 'node_modules').map((entry) => entry.name));
186
+ // Where each store entry actually lives: a link can reach an entry through its install
187
+ // cache target (whose basename carries a cache suffix the entry name does not), so live
188
+ // reachability is also containment inside an entry's real directory, not name matching.
189
+ const entryReals = new Map<string, string>();
190
+ for (const entry of entries) {
191
+ if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
192
+ try {
193
+ entryReals.set(entry.name, realpathSync(path.join(store, entry.name)));
194
+ } catch {
195
+ // A dangling entry has no real directory for a live alias to land inside.
196
+ }
197
+ }
198
+ const scanLinks = (dir: string, owner: string | null): void => {
199
+ let children: Dirent[];
200
+ try {
201
+ children = readdirSync(dir, { withFileTypes: true });
202
+ } catch {
203
+ return;
204
+ }
205
+ for (const child of children) {
206
+ if (child.name.startsWith('.')) continue;
207
+ const childPath = path.join(dir, child.name);
208
+ if (child.name.startsWith('@')) {
209
+ // A scope is a namespace, symlinked or not: traverse it, never treat it as a package.
210
+ let isDirectory = false;
211
+ try {
212
+ isDirectory = statSync(childPath).isDirectory();
213
+ } catch {
214
+ isDirectory = false;
215
+ }
216
+ if (isDirectory) {
217
+ scanLinks(childPath, owner);
218
+ continue;
219
+ }
220
+ }
221
+ if (!child.isSymbolicLink()) continue;
222
+ let target: string;
223
+ try {
224
+ target = readlinkSync(childPath);
225
+ } catch {
226
+ continue;
227
+ }
228
+ // The alias's canonical endpoint is what it actually reaches — through intermediate
229
+ // symlinks as well as its literal target — and is what select() already witnesses.
230
+ // A dangling alias has no endpoint; fall back to resolving its literal target
231
+ // against the physical parent, so a live reference to a broken entry still marks
232
+ // that entry referenced.
233
+ let physicalDir = path.dirname(childPath);
234
+ try {
235
+ physicalDir = realpathSync(physicalDir);
236
+ } catch {
237
+ // Keep the lexical parent; the segment mark below still applies.
238
+ }
239
+ let endpoint: string | null = null;
240
+ try {
241
+ endpoint = realpathSync(childPath);
242
+ } catch {
243
+ endpoint = null;
244
+ }
245
+ const resolved = endpoint ?? path.resolve(physicalDir, target);
246
+ if (endpoint !== null) {
247
+ // The canonical endpoint is authoritative: the entry whose real directory
248
+ // contains it is the live target, whatever any path segment happens to name.
249
+ for (const [name, real] of entryReals) {
250
+ if (name !== owner && (endpoint === real || endpoint.startsWith(`${real}${path.sep}`))) {
251
+ referenced.add(name);
252
+ break;
253
+ }
254
+ }
255
+ } else {
256
+ for (const segment of resolved.split(path.sep)) {
257
+ if (knownEntries.has(segment) && segment !== owner) {
258
+ referenced.add(segment);
259
+ break;
260
+ }
261
+ }
262
+ }
263
+ }
264
+ };
265
+ scanLinks(path.join(root, 'node_modules'), null);
266
+ scanLinks(path.join(store, 'node_modules'), null);
267
+ for (const modules of members) scanLinks(modules, null);
268
+ let grew = true;
269
+ while (grew) {
270
+ grew = false;
271
+ for (const entry of entries) {
272
+ if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
273
+ if (!referenced.has(entry.name)) continue;
274
+ const before = referenced.size;
275
+ scanLinks(path.join(store, entry.name, 'node_modules'), entry.name);
276
+ if (referenced.size > before) grew = true;
277
+ }
278
+ }
279
+ return referenced;
280
+ }
281
+
282
+ /**
283
+ * The store links the installed tree reaches whose target in Bun's install cache is gone. Under
284
+ * `globalStore` each node_modules/.bun/<entry> is a link into that cache, and one that dangles
285
+ * names a cache entry that no longer exists: the install is out of date, as it is while a
286
+ * developer link dangles, and `bun install` links the entry again (measured, Bun 1.4.3). A
287
+ * dangling variant nothing live reaches is superseded garbage the install leaves in place (see
288
+ * verifyInstalledBunLinks), so it never makes the install stale: no install would change it.
289
+ * The closure is walked only when some store link dangles, so `members` is asked for only then.
290
+ */
291
+ export function danglingStoreLinks(root: string, members: () => readonly string[]): string[] {
292
+ const store = path.join(root, 'node_modules', '.bun');
293
+ let entries: Dirent[];
294
+ try {
295
+ entries = readdirSync(store, { withFileTypes: true }).filter((entry) => !entry.name.startsWith('.'));
296
+ } catch (error) {
297
+ // A hoisted install, or none yet, has no store to link from.
298
+ if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) return [];
299
+ throw error;
300
+ }
301
+ const dangling = entries.filter(
302
+ (entry) =>
303
+ entry.isSymbolicLink() && statSync(path.join(store, entry.name), { throwIfNoEntry: false }) === undefined,
304
+ );
305
+ if (dangling.length === 0) return [];
306
+ const referenced = referencedStoreEntries(root, store, entries, members());
307
+ return dangling.filter((entry) => referenced.has(entry.name)).map((entry) => path.join(store, entry.name));
308
+ }