@smoothbricks/nx-plugin 0.5.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/README.md +1095 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/all-verdicts/executor.d.ts +35 -0
  59. package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
  60. package/dist/executors/all-verdicts/executor.js +133 -0
  61. package/dist/executors/all-verdicts/schema.d.ts +10 -0
  62. package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
  63. package/dist/executors/all-verdicts/schema.js +2 -0
  64. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  65. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  66. package/dist/executors/bounded-exec/bounds.js +43 -0
  67. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  68. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  70. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  71. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/executor.js +371 -239
  73. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  74. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  76. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  77. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  78. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  79. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  80. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  82. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  83. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/lock-wait.js +108 -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 +4 -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 +20 -30
  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 +40 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +88 -19
  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/executor.d.ts +3 -1
  135. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  136. package/dist/executors/typescript-emit/executor.js +164 -33
  137. package/dist/forbidden-spelling-policy.d.ts +56 -0
  138. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  139. package/dist/forbidden-spelling-policy.js +176 -0
  140. package/dist/generators/create-package/generator.d.ts.map +1 -1
  141. package/dist/generators/create-package/generator.js +3 -4
  142. package/dist/graph-input-contract.d.ts +14 -0
  143. package/dist/graph-input-contract.d.ts.map +1 -1
  144. package/dist/graph-input-contract.js +67 -2
  145. package/dist/index.d.ts +23 -6
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +676 -215
  148. package/dist/managed-assets.d.ts +2 -0
  149. package/dist/managed-assets.d.ts.map +1 -1
  150. package/dist/managed-files/files.d.ts +3 -3
  151. package/dist/managed-files/files.d.ts.map +1 -1
  152. package/dist/managed-files/files.js +28 -3
  153. package/dist/managed-files/managed-format.d.ts.map +1 -1
  154. package/dist/managed-files/managed-format.js +1 -0
  155. package/dist/nextest-code-bound.js +1 -0
  156. package/dist/nextest-timings.d.ts +35 -0
  157. package/dist/nextest-timings.d.ts.map +1 -0
  158. package/dist/nextest-timings.js +168 -0
  159. package/dist/owned-installation.d.ts +6 -5
  160. package/dist/owned-installation.d.ts.map +1 -1
  161. package/dist/owned-installation.js +150 -26
  162. package/dist/package-target-policy.d.ts.map +1 -1
  163. package/dist/package-target-policy.js +2 -3
  164. package/dist/process-children.d.ts +7 -0
  165. package/dist/process-children.d.ts.map +1 -0
  166. package/dist/process-children.darwin.d.ts +7 -0
  167. package/dist/process-children.darwin.d.ts.map +1 -0
  168. package/dist/process-children.darwin.js +13 -0
  169. package/dist/process-children.js +14 -0
  170. package/dist/process-children.linux.d.ts +8 -0
  171. package/dist/process-children.linux.d.ts.map +1 -0
  172. package/dist/process-children.linux.js +25 -0
  173. package/dist/process-group.d.ts +108 -0
  174. package/dist/process-group.d.ts.map +1 -0
  175. package/dist/process-group.js +171 -0
  176. package/dist/process-listing.d.ts +7 -0
  177. package/dist/process-listing.d.ts.map +1 -0
  178. package/dist/process-listing.js +51 -0
  179. package/dist/producer-receipts.d.ts +8 -2
  180. package/dist/producer-receipts.d.ts.map +1 -1
  181. package/dist/producer-receipts.js +75 -48
  182. package/dist/task-graph-policy.d.ts +21 -0
  183. package/dist/task-graph-policy.d.ts.map +1 -0
  184. package/dist/task-graph-policy.js +91 -0
  185. package/dist/test-timings.js +4 -4
  186. package/dist/test-walk-policy.d.ts +14 -5
  187. package/dist/test-walk-policy.d.ts.map +1 -1
  188. package/dist/test-walk-policy.js +8 -2
  189. package/dist/testing.d.ts +73 -28
  190. package/dist/testing.d.ts.map +1 -1
  191. package/dist/testing.js +217 -223
  192. package/dist/tool-bins.d.ts +33 -0
  193. package/dist/tool-bins.d.ts.map +1 -0
  194. package/dist/tool-bins.js +72 -0
  195. package/dist/typecheck-test-policy.d.ts.map +1 -1
  196. package/dist/typecheck-test-policy.js +3 -4
  197. package/dist/wait-why-policy.d.ts +28 -0
  198. package/dist/wait-why-policy.d.ts.map +1 -0
  199. package/dist/wait-why-policy.js +223 -0
  200. package/dist/workspace-config-policy.d.ts +14 -8
  201. package/dist/workspace-config-policy.d.ts.map +1 -1
  202. package/dist/workspace-config-policy.js +60 -16
  203. package/dist/workspace-manifest.d.ts +41 -6
  204. package/dist/workspace-manifest.d.ts.map +1 -1
  205. package/dist/workspace-manifest.js +57 -0
  206. package/executors.json +21 -1
  207. package/loader.js +2 -0
  208. package/managed/raw/envrc +11 -0
  209. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  210. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  211. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  212. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  213. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  214. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  215. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  216. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  217. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  218. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  219. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  220. package/managed/raw/tooling/direnv/repo-path +68 -6
  221. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  222. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  223. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  224. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  225. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  226. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  227. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  228. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  229. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  230. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  231. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  232. package/package.json +77 -13
  233. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  234. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  235. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  236. package/src/bounded-test-policy.ts +12 -14
  237. package/src/build-state-output-policy.ts +458 -34
  238. package/src/bun-lock-scope.ts +108 -0
  239. package/src/cargo-build-script-env.ts +265 -0
  240. package/src/cargo-closure-input.ts +74 -7
  241. package/src/cargo-retention-hook.ts +94 -0
  242. package/src/cargo-source-hash.ts +138 -41
  243. package/src/cargo-toolchain-paths.ts +95 -0
  244. package/src/cargo-toolchain-policy.ts +49 -5
  245. package/src/cargo-workspace.ts +72 -123
  246. package/src/cross-check-policy.ts +12 -10
  247. package/src/disk-command-policy.ts +1 -0
  248. package/src/ensure-built-receipt.ts +132 -39
  249. package/src/ensure-built-witness.ts +62 -10
  250. package/src/ensure-built.ts +11 -1
  251. package/src/eslint-config-closure.ts +357 -0
  252. package/src/executors/all-verdicts/executor.ts +164 -0
  253. package/src/executors/all-verdicts/schema.json +22 -0
  254. package/src/executors/all-verdicts/schema.ts +10 -0
  255. package/src/executors/bounded-exec/bounds.ts +76 -0
  256. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  257. package/src/executors/bounded-exec/executor.ts +423 -259
  258. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  259. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  260. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  261. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  262. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  263. package/src/executors/bounded-exec/progress.ts +9 -3
  264. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  265. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  266. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  267. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  268. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  269. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  270. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  271. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  272. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  273. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  274. package/src/executors/bounded-exec/schema.json +11 -2
  275. package/src/executors/bounded-exec/schema.ts +19 -1
  276. package/src/executors/bounded-exec/verdict.ts +137 -34
  277. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  278. package/src/executors/clean-outputs/executor.ts +1 -0
  279. package/src/executors/scriptc-native/executor.ts +394 -0
  280. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  281. package/src/executors/scriptc-native/schema.json +60 -0
  282. package/src/executors/scriptc-native/schema.ts +34 -0
  283. package/src/executors/typescript-emit/executor.ts +205 -38
  284. package/src/forbidden-spelling-policy.ts +226 -0
  285. package/src/generators/create-package/generator.ts +7 -7
  286. package/src/graph-input-contract.ts +61 -2
  287. package/src/index.ts +792 -225
  288. package/src/managed-assets.ts +3 -0
  289. package/src/managed-files/files.ts +28 -3
  290. package/src/managed-files/managed-format.ts +1 -0
  291. package/src/nextest-code-bound.ts +1 -0
  292. package/src/nextest-timings.ts +106 -0
  293. package/src/owned-installation.ts +150 -23
  294. package/src/package-target-policy.ts +2 -3
  295. package/src/process-children.darwin.ts +14 -0
  296. package/src/process-children.linux.ts +33 -0
  297. package/src/process-children.ts +22 -0
  298. package/src/process-group.ts +209 -0
  299. package/src/process-listing.ts +54 -0
  300. package/src/producer-receipts.ts +68 -45
  301. package/src/task-graph-policy.ts +98 -0
  302. package/src/test-walk-policy.ts +23 -8
  303. package/src/testing.ts +240 -232
  304. package/src/tool-bins.ts +108 -0
  305. package/src/typecheck-test-policy.ts +2 -3
  306. package/src/wait-why-policy.ts +226 -0
  307. package/src/workspace-config-policy.ts +63 -15
  308. package/src/workspace-manifest.ts +89 -6
  309. package/test-timings.json +123 -98
  310. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  311. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  312. package/dist/bin/smoo-nx-failures.js +0 -3
  313. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  314. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  315. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  316. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  317. package/dist/failure-summary.d.ts +0 -5
  318. package/dist/failure-summary.d.ts.map +0 -1
  319. package/dist/failure-summary.js +0 -118
  320. package/dist/nextest-extraction.d.ts +0 -117
  321. package/dist/nextest-extraction.d.ts.map +0 -1
  322. package/dist/nextest-extraction.js +0 -303
  323. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  324. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  325. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  326. package/src/__tests__/counted-cargo-process.ts +0 -286
  327. package/src/__tests__/counted-cargo.ts +0 -713
  328. package/src/__tests__/directory-change.ts +0 -27
  329. package/src/__tests__/fixture-cargo-home.ts +0 -36
  330. package/src/__tests__/fixture-nx-env.ts +0 -193
  331. package/src/__tests__/owned-installation.ts +0 -13
  332. package/src/__tests__/past-tick.ts +0 -12
  333. package/src/__tests__/progress-clock.ts +0 -43
  334. package/src/__tests__/runtime-input.ts +0 -23
  335. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  336. package/src/bin/smoo-nx-failures.ts +0 -4
  337. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  338. package/src/bounded-test-policy.test.ts +0 -1029
  339. package/src/build-state-output-policy.test.ts +0 -115
  340. package/src/bun-bootstrap.test.ts +0 -102
  341. package/src/bun-file-packages.test.ts +0 -47
  342. package/src/cargo-closure-filesets.test.ts +0 -63
  343. package/src/cargo-closure-input.property.test.ts +0 -50
  344. package/src/cargo-closure-input.test.ts +0 -506
  345. package/src/cargo-closure-key.test.ts +0 -240
  346. package/src/cargo-resolve-cache.test.ts +0 -1181
  347. package/src/cargo-source-hash.test.ts +0 -707
  348. package/src/cargo-workspace.test.ts +0 -615
  349. package/src/cross-check-policy.test.ts +0 -316
  350. package/src/disk-command-policy.test.ts +0 -61
  351. package/src/ensure-built-receipt.test.ts +0 -279
  352. package/src/ensure-built-witness.test.ts +0 -688
  353. package/src/ensure-built.test.ts +0 -1462
  354. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  355. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  356. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  357. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  358. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  359. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  360. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  361. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  362. package/src/executors/bounded-exec/progress.test.ts +0 -139
  363. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  364. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  365. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  366. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  367. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  368. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  369. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  370. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  371. package/src/executors/clean-outputs/executor.test.ts +0 -20
  372. package/src/executors/typescript-emit/executor.test.ts +0 -83
  373. package/src/failure-summary.ts +0 -119
  374. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  375. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  376. package/src/generators/create-package/generator.test.ts +0 -190
  377. package/src/generators/make-public/generator.test.ts +0 -137
  378. package/src/graph-input-contract.test.ts +0 -379
  379. package/src/host-controller-wiring.test.ts +0 -31
  380. package/src/index.test.ts +0 -3319
  381. package/src/linked-snapshots.nx.test.ts +0 -254
  382. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  383. package/src/managed-files/generator.test.ts +0 -243
  384. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  385. package/src/managed-files/json-edit.test.ts +0 -216
  386. package/src/managed-files/managed-content.test.ts +0 -166
  387. package/src/managed-files/managed-format-json.test.ts +0 -308
  388. package/src/managed-files/repo-path.test.ts +0 -172
  389. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  390. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  391. package/src/managed-files/tree-permissions.test.ts +0 -109
  392. package/src/managed-files/tree.test.ts +0 -123
  393. package/src/manifest-hash.test.ts +0 -219
  394. package/src/nextest-code-bound.test.ts +0 -161
  395. package/src/nextest-extraction.test.ts +0 -216
  396. package/src/nextest-extraction.ts +0 -371
  397. package/src/nextest-partitions.test.ts +0 -501
  398. package/src/nx-cache-bound.test.ts +0 -109
  399. package/src/nx-cache-restore-mtime.test.ts +0 -170
  400. package/src/nx-daemon-claim.test.ts +0 -279
  401. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  402. package/src/nx-daemon-idle-policy.test.ts +0 -111
  403. package/src/nx-daemon-ignore-files.test.ts +0 -210
  404. package/src/nx-daemon-root-normalization.test.ts +0 -105
  405. package/src/nx-daemon-start-never.test.ts +0 -292
  406. package/src/nx-daemon-validity.test.ts +0 -1055
  407. package/src/nx-dot-input-policy.test.ts +0 -353
  408. package/src/nx-failure-life-cycles.test.ts +0 -207
  409. package/src/nx-files-archive-racy.test.ts +0 -97
  410. package/src/nx-foreign-workspace-env.test.ts +0 -329
  411. package/src/nx-incomplete-run-summary.test.ts +0 -70
  412. package/src/nx-plugin-load-errors.test.ts +0 -120
  413. package/src/nx-project-graph-errors.test.ts +0 -70
  414. package/src/nx-project-resolution-cache.test.ts +0 -176
  415. package/src/nx-raw-inputs.test.ts +0 -166
  416. package/src/nx-resident-graph-workers.test.ts +0 -112
  417. package/src/nx-run-information.test.ts +0 -118
  418. package/src/nx-skipped-task-exit.test.ts +0 -180
  419. package/src/nx-state-location.test.ts +0 -63
  420. package/src/nx-store-resolution.test.ts +0 -81
  421. package/src/nx-task-graph-cycles.test.ts +0 -148
  422. package/src/nx-task-output-lease.test.ts +0 -550
  423. package/src/nx-use-local.test.ts +0 -105
  424. package/src/owned-installation.test.ts +0 -105
  425. package/src/package-target-policy.test.ts +0 -1014
  426. package/src/producer-receipts.test.ts +0 -285
  427. package/src/release-config-policy.test.ts +0 -311
  428. package/src/runtime-input.test.ts +0 -393
  429. package/src/serial-group-wiring.test.ts +0 -326
  430. package/src/task-history-namespace.test.ts +0 -181
  431. package/src/task-results.test.ts +0 -228
  432. package/src/test-clock-policy.test.ts +0 -338
  433. package/src/test-program.test.ts +0 -303
  434. package/src/test-timings.test.ts +0 -240
  435. package/src/test-walk-policy.test.ts +0 -620
  436. package/src/testing.test.ts +0 -509
  437. package/src/typecheck-test-policy.test.ts +0 -1468
  438. package/src/typescript-resolution.test.ts +0 -76
  439. package/src/version-actions.test.ts +0 -80
  440. package/src/workspace-config-policy.test.ts +0 -737
@@ -4,7 +4,6 @@ import {
4
4
  chmodSync,
5
5
  closeSync,
6
6
  cpSync,
7
- type Dirent,
8
7
  existsSync,
9
8
  lstatSync,
10
9
  mkdirSync,
@@ -13,7 +12,6 @@ import {
13
12
  readdirSync,
14
13
  readFileSync,
15
14
  readlinkSync,
16
- readSync,
17
15
  realpathSync,
18
16
  renameSync,
19
17
  rmSync,
@@ -26,14 +24,22 @@ import { homedir } from 'node:os';
26
24
  import path from 'node:path';
27
25
  import { getSystemErrorName, parseArgs } from 'node:util';
28
26
  import { $ } from 'bun';
27
+ import {
28
+ boundedFetchEnv,
29
+ CARGO_FETCH_DEADLINE_ENV,
30
+ describeDeadline,
31
+ fetchDeadline,
32
+ smooCacheDirectory,
33
+ } from './cargo-fetch-bound.ts';
34
+ import { type BoundedOutcome, runBounded } from './cargo-fetch-run.ts';
29
35
  import {
30
36
  applyDeclaredLinks,
31
37
  hasStaleDeveloperLinks,
32
38
  keepDeveloperLinks,
33
39
  planDeclaredLinks,
34
40
  reportDeveloperLinks,
35
- unreadableDeveloperLinks,
36
41
  } from './developer-links.ts';
42
+ import { type BunInstallIntegrityError, danglingStoreLinks, verifyInstalledBunLinks } from './installed-bun-links.ts';
37
43
  import {
38
44
  type DeferredSecret,
39
45
  dependentGroups,
@@ -41,6 +47,7 @@ import {
41
47
  resolveSecretEnvironment,
42
48
  SHELL_GROUP,
43
49
  } from './secret-references.ts';
50
+ import { relativizeCheckoutPaths, uvEnvironmentRelocatable } from './uv-relocation.ts';
44
51
 
45
52
  // DEVENV_ROOT is set by the devenv shell. It is only checked against the checkout this script runs
46
53
  // in, never trusted to select the root: see resolveProjectRoot.
@@ -63,25 +70,18 @@ class CapturedCommandError extends Error {
63
70
  }
64
71
  }
65
72
 
66
- type BunInstallIntegrityOperation =
67
- | 'inspect isolated store'
68
- | 'resolve installed path'
69
- | 'list installed package aliases'
70
- | 'read installed package manifest';
71
-
72
- class BunInstallIntegrityError extends Error {
73
- readonly code = 'BUN_INSTALL_INTEGRITY';
74
-
73
+ /**
74
+ * A setup command that outlived its deadline and was killed with its process group. It has no exit code: `message`
75
+ * says what it held while it ran, and what it printed until the kill is kept for the replay.
76
+ */
77
+ class CommandDeadlineError extends Error {
75
78
  constructor(
76
- public readonly operation: BunInstallIntegrityOperation,
77
- public readonly actualPath: string,
78
- public readonly expectedTarget: string,
79
- cause: unknown,
79
+ public readonly command: string,
80
+ message: string,
81
+ public readonly stdout: Uint8Array,
82
+ public readonly stderr: Uint8Array,
80
83
  ) {
81
- super(
82
- `Bun install integrity: ${operation} failed for ${actualPath}; expected target ${expectedTarget}: ${cause instanceof Error ? cause.message : String(cause)}`,
83
- { cause },
84
- );
84
+ super(message);
85
85
  }
86
86
  }
87
87
 
@@ -201,10 +201,12 @@ const POST_COMMIT_BLOCK = [
201
201
  // environment uv builds does not name this checkout's profile as its home.
202
202
  // `--cargo` runs the Cargo fetches instead of the installs: they are devenv's
203
203
  // smoo:cargo-fetch task, whose `status` is `--cargo --check` (exit 0 when
204
- // CARGO_HOME already holds every workspace's locked packages). Their stamps
205
- // (cargoFetcher) live in smoo's user cache and count only while CARGO_HOME
206
- // names the directory they were fetched into, which no checkout-relative
207
- // change detection can see.
204
+ // CARGO_HOME already holds every workspace's locked packages). Each fetch runs
205
+ // under a deadline, and under git's low-speed limits: while it runs it holds
206
+ // Cargo's package-cache lock, so one that stalls stops every cargo that shares
207
+ // CARGO_HOME (cargo-fetch-bound.ts). Their stamps (cargoFetcher) live in smoo's
208
+ // user cache and count only while CARGO_HOME names the directory they were
209
+ // fetched into, which no checkout-relative change detection can see.
208
210
  // `--links` repairs stale install links (including external Nx aliases and
209
211
  // store links whose install-cache entry is gone), then
210
212
  // points the packages `smoo.developerLinks` declares at their local checkouts.
@@ -252,7 +254,11 @@ try {
252
254
  // A stale pin is informational, not a stale install: say it even when devenv skips the exec.
253
255
  if (current && plan.reports.length > 0) applyDeclaredLinks(projectRoot, plan);
254
256
  process.exit(
255
- current && !hasStaleDeveloperLinks(projectRoot, ['nx']) && danglingStoreLinks(projectRoot).length === 0 ? 0 : 1,
257
+ current &&
258
+ !hasStaleDeveloperLinks(projectRoot, ['nx']) &&
259
+ danglingStoreLinks(projectRoot, () => workspaceMemberModules(projectRoot)).length === 0
260
+ ? 0
261
+ : 1,
256
262
  );
257
263
  }
258
264
  // Planning reads, apart from a snapshot it may capture, which seals by an atomic rename (linked-snapshots.ts),
@@ -262,7 +268,7 @@ try {
262
268
  const plan = await planDeclaredLinks(projectRoot);
263
269
  if (
264
270
  plan.changes.length === 0 &&
265
- danglingStoreLinks(projectRoot).length === 0 &&
271
+ danglingStoreLinks(projectRoot, () => workspaceMemberModules(projectRoot)).length === 0 &&
266
272
  !hasStaleDeveloperLinks(projectRoot, ['nx'])
267
273
  ) {
268
274
  applyDeclaredLinks(projectRoot, plan);
@@ -271,7 +277,7 @@ try {
271
277
  await withInstallLock(async () => {
272
278
  // Recheck under the install lock: another shell may already have repaired
273
279
  // the aliases. Use the same installer as smoo:install, never a second linker.
274
- const store = danglingStoreLinks(projectRoot);
280
+ const store = danglingStoreLinks(projectRoot, () => workspaceMemberModules(projectRoot));
275
281
  for (const link of store) {
276
282
  console.error(
277
283
  `! ${link} -> ${readlinkSync(link)}: that Bun install-cache entry no longer exists; reinstalling`,
@@ -299,12 +305,11 @@ try {
299
305
  // variable as GITHUB_*. Not `CI`: agent harnesses set CI=true on every command
300
306
  // they run, and this branch installs unconditionally.
301
307
  if (process.env.GITHUB_ACTIONS === 'true' && cargoMode) {
302
- await withInstallLock(async () => {
303
- for (const fetch of cargoFetches) {
304
- const error = await fetch.install({ quiet: false });
305
- if (error !== undefined) reportSetupFailure(error);
306
- }
307
- });
308
+ // Cargo owns CARGO_HOME's package-cache locks; this task never mutates node_modules.
309
+ for (const fetch of cargoFetches) {
310
+ const error = await fetch.install({ quiet: false });
311
+ if (error !== undefined) reportSetupFailure(error);
312
+ }
308
313
  } else if (process.env.GITHUB_ACTIONS === 'true') {
309
314
  const uv = uvInstaller(uvInputs, { locked: true });
310
315
  await resolveSecrets();
@@ -366,9 +371,7 @@ try {
366
371
  });
367
372
  } else if (cargoMode) {
368
373
  // A failed fetch loads the shell like a failed install; the graph then names Cargo's refusal.
369
- const fetchError = await withInstallLock(() =>
370
- installLocalDependencies(cargoFetches.filter((fetch) => !fetch.isCurrent())),
371
- );
374
+ const fetchError = await installLocalDependencies(cargoFetches.filter((fetch) => !fetch.isCurrent()));
372
375
  if (fetchError !== undefined) {
373
376
  reportDegradedSetup(fetchError);
374
377
  }
@@ -437,9 +440,9 @@ async function resolveSecrets(): Promise<void> {
437
440
 
438
441
  /**
439
442
  * Runs every installer whose inputs changed since its last successful run.
440
- * Returned, not thrown: the caller still keeps the git config, then reports a
441
- * degraded shell. The caller selects them under the install lock, so an
442
- * installer another shell entry just ran is already current there.
443
+ * Returned, not thrown: the caller reports a degraded shell after any remaining
444
+ * checkout setup. Bun/uv callers select under the install lock so another
445
+ * entry's completed install is current; Cargo uses its own package-cache locks.
443
446
  */
444
447
  async function installLocalDependencies(pending: readonly Installer[]): Promise<unknown> {
445
448
  if (pending.length === 0) {
@@ -462,13 +465,12 @@ async function installLocalDependencies(pending: readonly Installer[]): Promise<
462
465
  }
463
466
 
464
467
  /**
465
- * One install at a time per checkout, across processes. Shell entries race
466
- * whenever two shells load at once — a shell pool warming several, two
467
- * terminals, an editor beside a terminal — and two installs into one
468
- * node_modules collide on its links (`EEXIST … symlink`). The second entry
469
- * waits, then finds the first entry's stamps current and installs nothing.
470
- * The repository's git config and hooks are kept under the same lock, for the
471
- * same reason.
468
+ * One Bun/uv install or installed-package mutation at a time per checkout,
469
+ * across processes. Shell entries race whenever two shells load at once, and
470
+ * two installs into one node_modules collide on its links (EEXIST symlink).
471
+ * The second entry waits, then finds the first entry's stamps current.
472
+ * Alias/link repair and repository git config/hooks share this lock. Cargo
473
+ * fetch changes CARGO_HOME instead and uses Cargo's own package-cache locks.
472
474
  *
473
475
  * flock(2), not a lock directory or file the script creates and removes: the
474
476
  * kernel releases it when the holder exits however it exits, so a killed
@@ -593,13 +595,13 @@ async function repairMissingPayload(requested: string): Promise<Error | undefine
593
595
  }
594
596
  return undefined;
595
597
  };
596
- const admissionError = verifyInstalledBunLinks(projectRoot);
598
+ const admissionError = verifyInstalledBunLinks(projectRoot, workspaceMemberModules(projectRoot));
597
599
  if (admissionError !== undefined) return admissionError;
598
600
  // Let Bun resolve the registry using the checkout's existing npm/bun configuration.
599
601
  const metadata = await runSetupCommand(`bun info ${identity} dist --json`, $`bun info ${identity} dist --json`, {
600
602
  quiet: true,
601
603
  });
602
- const dist: unknown = JSON.parse(metadata.stdout);
604
+ const dist: unknown = JSON.parse(new TextDecoder().decode(metadata.stdout));
603
605
  if (
604
606
  !payloadObject(dist) ||
605
607
  typeof dist.tarball !== 'string' ||
@@ -917,7 +919,7 @@ function bunInstallStamp(inputs: readonly string[]): {
917
919
  );
918
920
  },
919
921
  record: () => {
920
- const error = verifyInstalledBunLinks(projectRoot);
922
+ const error = verifyInstalledBunLinks(projectRoot, workspaceMemberModules(projectRoot));
921
923
  if (error !== undefined) return error;
922
924
  writeInstallStamp(stampPath, { inputs: inputsDigest(identity, inputs), lockfiles: lockDigests() });
923
925
  return undefined;
@@ -925,240 +927,6 @@ function bunInstallStamp(inputs: readonly string[]): {
925
927
  };
926
928
  }
927
929
 
928
- /** Link/manifest admission only, once before an install writes its success receipt. */
929
- function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undefined {
930
- const store = path.join(root, 'node_modules', '.bun');
931
- let actualPath = store;
932
- let expectedTarget = store;
933
- let operation: BunInstallIntegrityOperation = 'inspect isolated store';
934
- // Developer links whose target this process may not read (developer-links.ts): the install
935
- // did not make them and nothing here can read what they name, so they are not admitted here.
936
- let unreadable: ReadonlySet<string> = new Set();
937
-
938
- const select = (candidate: string, symbolicLink: boolean): void => {
939
- actualPath = candidate;
940
- expectedTarget = candidate;
941
- operation = 'resolve installed path';
942
- if (symbolicLink) {
943
- const target = readlinkSync(candidate);
944
- expectedTarget = path.resolve(path.dirname(candidate), target);
945
- expectedTarget = path.resolve(realpathSync(path.dirname(candidate)), target);
946
- }
947
- realpathSync(candidate);
948
- };
949
- const manifest = (candidate: string, symbolicLink: boolean): void => {
950
- if (unreadable.has(candidate)) return;
951
- select(candidate, symbolicLink);
952
- operation = 'read installed package manifest';
953
- JSON.parse(readFileSync(path.join(candidate, 'package.json'), 'utf8'));
954
- };
955
- const aliases = (tree: string, symbolicLink = false): void => {
956
- select(tree, symbolicLink);
957
- operation = 'list installed package aliases';
958
- for (const entry of readdirSync(tree, { withFileTypes: true })) {
959
- if (entry.name.startsWith('.')) continue;
960
- const candidate = path.join(tree, entry.name);
961
- if (entry.name.startsWith('@')) {
962
- select(candidate, entry.isSymbolicLink());
963
- operation = 'list installed package aliases';
964
- for (const scoped of readdirSync(candidate, { withFileTypes: true })) {
965
- if (!scoped.name.startsWith('.')) manifest(path.join(candidate, scoped.name), scoped.isSymbolicLink());
966
- }
967
- } else {
968
- manifest(candidate, entry.isSymbolicLink());
969
- }
970
- }
971
- };
972
-
973
- // Admission walks the live closure, not every directory in the store. A restored store can
974
- // carry superseded peer variants of packages the install also wrote under other variants:
975
- // their links point into the install cache of the machine that wrote them and dangle here,
976
- // and their own dependency aliases dangle with them. Nothing the install produced references
977
- // those variants, so they are not broken live links. An entry is walked strictly when a link
978
- // in the live tree resolves into it, or when it is the only variant of its package and
979
- // version — a sole dangling variant still refuses, because there is no replacement to point
980
- // at. Same package and version alone is never reachability proof.
981
- const identityOf = (name: string): string | null => /^(.+@\d[^+]*)(\+.*)?$/.exec(name)?.[1] ?? null;
982
- try {
983
- unreadable = new Set(unreadableDeveloperLinks(root));
984
- const state = lstatSync(store, { throwIfNoEntry: false });
985
- // A hoisted install has no isolated store to admit.
986
- if (state === undefined) return undefined;
987
- select(store, state.isSymbolicLink());
988
- operation = 'inspect isolated store';
989
- const entries = readdirSync(store, { withFileTypes: true }).filter((entry) => !entry.name.startsWith('.'));
990
- const identityCounts = new Map<string, number>();
991
- for (const entry of entries) {
992
- if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
993
- const identity = identityOf(entry.name) ?? entry.name;
994
- identityCounts.set(identity, (identityCounts.get(identity) ?? 0) + 1);
995
- }
996
- const members = workspaceMemberModules(root);
997
- const referenced = referencedStoreEntries(root, store, entries, members);
998
- // Package aliases are what every consumer actually resolves: each package they name must
999
- // resolve to a readable manifest, wherever it points — into the store, into the install
1000
- // cache, or at a workspace member. The same strict walk applies at the root and in every
1001
- // workspace member's node_modules; member links seeded the closure above, and seeding is
1002
- // not validation. No identity waiver applies: an alias whose target does not exist is a
1003
- // broken import, however intact a same-version sibling is.
1004
- const checkPackage = (candidate: string, symbolicLink: boolean): void => {
1005
- try {
1006
- // Only a plain metadata file is skipped; a package alias that resolves to a regular
1007
- // file is a broken package and manifest() refuses it below.
1008
- if (!symbolicLink && !statSync(candidate).isDirectory()) return;
1009
- } catch {
1010
- // Dangling: manifest() refuses it with the path named.
1011
- }
1012
- manifest(candidate, symbolicLink);
1013
- };
1014
- const walkPackageAliases = (modules: string): void => {
1015
- for (const child of readdirSync(modules, { withFileTypes: true })) {
1016
- if (child.name.startsWith('.')) continue;
1017
- const childPath = path.join(modules, child.name);
1018
- if (child.name.startsWith('@')) {
1019
- // A scope is a namespace, symlinked or not: the same strict alias walk as the store's.
1020
- aliases(childPath, child.isSymbolicLink());
1021
- } else {
1022
- checkPackage(childPath, child.isSymbolicLink());
1023
- }
1024
- }
1025
- };
1026
- walkPackageAliases(path.join(root, 'node_modules'));
1027
- for (const modules of members) {
1028
- // A member with nothing installed has no aliases to validate; a present directory is
1029
- // walked with the root's strictness.
1030
- if (existsSync(modules)) walkPackageAliases(modules);
1031
- }
1032
- for (const entry of entries) {
1033
- const candidate = path.join(store, entry.name);
1034
- if (entry.name === 'node_modules') {
1035
- aliases(candidate, entry.isSymbolicLink());
1036
- } else if (entry.isDirectory() || entry.isSymbolicLink()) {
1037
- const identity = identityOf(entry.name) ?? entry.name;
1038
- // An unreferenced variant beside others of its package and version is superseded
1039
- // garbage the install left behind; nothing live resolves through it, so it is not
1040
- // walked. A sole variant is walked: there is no replacement to point at.
1041
- if (!referenced.has(entry.name) && (identityCounts.get(identity) ?? 0) > 1) continue;
1042
- select(candidate, entry.isSymbolicLink());
1043
- aliases(path.join(candidate, 'node_modules'));
1044
- }
1045
- }
1046
- return undefined;
1047
- } catch (cause) {
1048
- return new BunInstallIntegrityError(operation, actualPath, expectedTarget, cause);
1049
- }
1050
- }
1051
-
1052
- /**
1053
- * The store entries the installed tree reaches. Every link in the root's node_modules, the
1054
- * store's own and each workspace member's that resolves into an entry makes that entry live,
1055
- * and so does every link in a live entry's own node_modules, to a fixed point. Member links
1056
- * are as live as root links.
1057
- */
1058
- function referencedStoreEntries(
1059
- root: string,
1060
- store: string,
1061
- entries: readonly Dirent[],
1062
- members: readonly string[],
1063
- ): Set<string> {
1064
- const referenced = new Set<string>();
1065
- const knownEntries = new Set(entries.filter((entry) => entry.name !== 'node_modules').map((entry) => entry.name));
1066
- // Where each store entry actually lives: a link can reach an entry through its install
1067
- // cache target (whose basename carries a cache suffix the entry name does not), so live
1068
- // reachability is also containment inside an entry's real directory, not name matching.
1069
- const entryReals = new Map<string, string>();
1070
- for (const entry of entries) {
1071
- if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
1072
- try {
1073
- entryReals.set(entry.name, realpathSync(path.join(store, entry.name)));
1074
- } catch {
1075
- // A dangling entry has no real directory for a live alias to land inside.
1076
- }
1077
- }
1078
- const scanLinks = (dir: string, owner: string | null): void => {
1079
- let children: Dirent[];
1080
- try {
1081
- children = readdirSync(dir, { withFileTypes: true });
1082
- } catch {
1083
- return;
1084
- }
1085
- for (const child of children) {
1086
- if (child.name.startsWith('.')) continue;
1087
- const childPath = path.join(dir, child.name);
1088
- if (child.name.startsWith('@')) {
1089
- // A scope is a namespace, symlinked or not: traverse it, never treat it as a package.
1090
- let isDirectory = false;
1091
- try {
1092
- isDirectory = statSync(childPath).isDirectory();
1093
- } catch {
1094
- isDirectory = false;
1095
- }
1096
- if (isDirectory) {
1097
- scanLinks(childPath, owner);
1098
- continue;
1099
- }
1100
- }
1101
- if (!child.isSymbolicLink()) continue;
1102
- let target: string;
1103
- try {
1104
- target = readlinkSync(childPath);
1105
- } catch {
1106
- continue;
1107
- }
1108
- // The alias's canonical endpoint is what it actually reaches — through intermediate
1109
- // symlinks as well as its literal target — and is what select() already witnesses.
1110
- // A dangling alias has no endpoint; fall back to resolving its literal target
1111
- // against the physical parent, so a live reference to a broken entry still marks
1112
- // that entry referenced.
1113
- let physicalDir = path.dirname(childPath);
1114
- try {
1115
- physicalDir = realpathSync(physicalDir);
1116
- } catch {
1117
- // Keep the lexical parent; the segment mark below still applies.
1118
- }
1119
- let endpoint: string | null = null;
1120
- try {
1121
- endpoint = realpathSync(childPath);
1122
- } catch {
1123
- endpoint = null;
1124
- }
1125
- const resolved = endpoint ?? path.resolve(physicalDir, target);
1126
- if (endpoint !== null) {
1127
- // The canonical endpoint is authoritative: the entry whose real directory
1128
- // contains it is the live target, whatever any path segment happens to name.
1129
- for (const [name, real] of entryReals) {
1130
- if (name !== owner && (endpoint === real || endpoint.startsWith(`${real}${path.sep}`))) {
1131
- referenced.add(name);
1132
- break;
1133
- }
1134
- }
1135
- } else {
1136
- for (const segment of resolved.split(path.sep)) {
1137
- if (knownEntries.has(segment) && segment !== owner) {
1138
- referenced.add(segment);
1139
- break;
1140
- }
1141
- }
1142
- }
1143
- }
1144
- };
1145
- scanLinks(path.join(root, 'node_modules'), null);
1146
- scanLinks(path.join(store, 'node_modules'), null);
1147
- for (const modules of members) scanLinks(modules, null);
1148
- let grew = true;
1149
- while (grew) {
1150
- grew = false;
1151
- for (const entry of entries) {
1152
- if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
1153
- if (!referenced.has(entry.name)) continue;
1154
- const before = referenced.size;
1155
- scanLinks(path.join(store, entry.name, 'node_modules'), entry.name);
1156
- if (referenced.size > before) grew = true;
1157
- }
1158
- }
1159
- return referenced;
1160
- }
1161
-
1162
930
  /**
1163
931
  * The node_modules directory of every workspace member, beside its manifest. The enumeration
1164
932
  * is the one bunInstallInputs owns: both workspace forms, full glob patterns, exclusions.
@@ -1172,34 +940,6 @@ function workspaceMemberModules(root: string): string[] {
1172
940
  );
1173
941
  }
1174
942
 
1175
- /**
1176
- * The store links the installed tree reaches whose target in Bun's install cache is gone. Under
1177
- * `globalStore` each node_modules/.bun/<entry> is a link into that cache, and one that dangles
1178
- * names a cache entry that no longer exists: the install is out of date, as it is while a
1179
- * developer link dangles, and `bun install` links the entry again (measured, Bun 1.4.3). A
1180
- * dangling variant nothing live reaches is superseded garbage the install leaves in place (see
1181
- * verifyInstalledBunLinks), so it never makes the install stale: no install would change it.
1182
- * The closure is walked only when some store link dangles.
1183
- */
1184
- function danglingStoreLinks(root: string): string[] {
1185
- const store = path.join(root, 'node_modules', '.bun');
1186
- let entries: Dirent[];
1187
- try {
1188
- entries = readdirSync(store, { withFileTypes: true }).filter((entry) => !entry.name.startsWith('.'));
1189
- } catch (error) {
1190
- // A hoisted install, or none yet, has no store to link from.
1191
- if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) return [];
1192
- throw error;
1193
- }
1194
- const dangling = entries.filter(
1195
- (entry) =>
1196
- entry.isSymbolicLink() && statSync(path.join(store, entry.name), { throwIfNoEntry: false }) === undefined,
1197
- );
1198
- if (dangling.length === 0) return [];
1199
- const referenced = referencedStoreEntries(root, store, entries, workspaceMemberModules(root));
1200
- return dangling.filter((entry) => referenced.has(entry.name)).map((entry) => path.join(store, entry.name));
1201
- }
1202
-
1203
943
  /**
1204
944
  * `bun install`. Its result is location-independent: the isolated linker
1205
945
  * links packages from the install cache by absolute path and workspace
@@ -1229,7 +969,7 @@ function bunInstaller(inputs: readonly string[]): Installer {
1229
969
  (!declaresNativeTypeScript(projectRoot) ||
1230
970
  existsSync(path.join(projectRoot, 'node_modules', '@typescript', 'native', 'bin', 'tsc'))) &&
1231
971
  !hasStaleDeveloperLinks(projectRoot, ['nx']) &&
1232
- danglingStoreLinks(projectRoot).length === 0,
972
+ danglingStoreLinks(projectRoot, () => workspaceMemberModules(projectRoot)).length === 0,
1233
973
  install: async ({ quiet }) => {
1234
974
  await keepDeveloperLinks(
1235
975
  projectRoot,
@@ -1283,178 +1023,6 @@ function bunInstaller(inputs: readonly string[]): Installer {
1283
1023
  * in the checkout is part of the identity: the relative `.pth` lines hold only
1284
1024
  * there.
1285
1025
  */
1286
- function sitePackagesDirectories(environment: string): string[] {
1287
- const lib = path.join(environment, 'lib');
1288
- const directories: string[] = [];
1289
- for (const python of existsSync(lib) ? readdirSync(lib) : []) {
1290
- if (!python.startsWith('python')) continue;
1291
- const sitePackages = path.join(lib, python, 'site-packages');
1292
- if (existsSync(sitePackages)) directories.push(sitePackages);
1293
- }
1294
- return directories;
1295
- }
1296
-
1297
- /**
1298
- * Whether an existing environment is the relocatable one install would leave: its config says
1299
- * so, no launcher or interpreter link names an environment or a checkout (its own, a foreign
1300
- * one, or a checkout's .devenv profile, in a shebang, a wrapper's exec argv, or the link
1301
- * itself), and no `.pth` line is an absolute path. The stamp alone cannot witness this — a
1302
- * copied checkout carries a matching
1303
- * stamp and an old absolute launcher together, and admits the launcher forever.
1304
- */
1305
- /** One shell command line as its words: quotes group, backslash escapes, no expansion. */
1306
- function shellWords(line: string): string[] {
1307
- const words: string[] = [];
1308
- let word = '';
1309
- let quote: string | null = null;
1310
- let started = false;
1311
- for (let index = 0; index < line.length; index += 1) {
1312
- const char = line[index] ?? '';
1313
- if (quote !== null) {
1314
- if (char === quote) quote = null;
1315
- else if (char === '\\' && quote === '"' && index + 1 < line.length) word += line[++index];
1316
- else word += char;
1317
- continue;
1318
- }
1319
- if (char === "'" || char === '"') {
1320
- quote = char;
1321
- started = true;
1322
- } else if (char === '\\' && index + 1 < line.length) {
1323
- word += line[++index];
1324
- started = true;
1325
- } else if (/\s/.test(char)) {
1326
- if (started || word !== '') words.push(word);
1327
- word = '';
1328
- started = false;
1329
- } else {
1330
- word += char;
1331
- }
1332
- }
1333
- if (started || word !== '') words.push(word);
1334
- return words;
1335
- }
1336
-
1337
- function uvEnvironmentRelocatable(environment: string): boolean {
1338
- const config = readFileIfPresent(path.join(environment, 'pyvenv.cfg'));
1339
- if (config === null || !/^relocatable\s*=\s*true\s*$/m.test(config.toString('utf8'))) return false;
1340
- const environmentReal = realpathSync(environment);
1341
- // Whether an absolute interpreter path names an environment or a checkout, as opposed to a
1342
- // store or system interpreter, which names neither: it is inside this environment, inside
1343
- // another environment (its home carries pyvenv.cfg), under a checkout's .devenv state, or
1344
- // it no longer exists at all.
1345
- const namesEnvironment = (interpreter: string): boolean => {
1346
- if (interpreter.startsWith(`${environment}/`) || interpreter.startsWith(`${environmentReal}/`)) return true;
1347
- if (!existsSync(interpreter)) return true;
1348
- if (interpreter.split(path.sep).includes('.devenv')) return true;
1349
- const home = path.dirname(path.dirname(interpreter));
1350
- return existsSync(path.join(home, 'pyvenv.cfg')) && home !== environment && home !== environmentReal;
1351
- };
1352
- const bin = path.join(environment, 'bin');
1353
- if (existsSync(bin)) {
1354
- const buffer = Buffer.alloc(256);
1355
- for (const name of readdirSync(bin)) {
1356
- const file = path.join(bin, name);
1357
- let size: number;
1358
- let isFile: boolean;
1359
- let isLink = false;
1360
- try {
1361
- const stat = statSync(file);
1362
- size = stat.size;
1363
- isFile = stat.isFile();
1364
- isLink = lstatSync(file).isSymbolicLink();
1365
- } catch {
1366
- return false;
1367
- }
1368
- if (!isFile) continue;
1369
- if (isLink) {
1370
- // The interpreter link itself is witnessed lexically, but only when it leaves the
1371
- // environment: a relative alias (bin/python3 -> python) is the layout uv itself
1372
- // writes and stays inside it. An absolute link into another checkout's .devenv
1373
- // state names that checkout even when its final target is a store interpreter,
1374
- // and no shebang reading ever sees it.
1375
- let linkTarget: string;
1376
- try {
1377
- linkTarget = readlinkSync(file);
1378
- } catch {
1379
- return false;
1380
- }
1381
- if (path.isAbsolute(linkTarget)) {
1382
- const lexical = path.resolve(bin, linkTarget);
1383
- if (lexical.split(path.sep).includes('.devenv')) return false;
1384
- const linkHome = path.dirname(path.dirname(lexical));
1385
- if (existsSync(path.join(linkHome, 'pyvenv.cfg')) && linkHome !== environment && linkHome !== environmentReal)
1386
- return false;
1387
- } else {
1388
- // A relative alias that resolves outside the environment is judged by where it
1389
- // lands, like an absolute one; only aliases staying inside are uv's own layout.
1390
- const lexical = path.resolve(bin, linkTarget);
1391
- if (
1392
- !lexical.startsWith(`${environment}${path.sep}`) &&
1393
- !lexical.startsWith(`${environmentReal}${path.sep}`) &&
1394
- namesEnvironment(lexical)
1395
- )
1396
- return false;
1397
- }
1398
- }
1399
- let head: string;
1400
- try {
1401
- const fd = openSync(file, 'r');
1402
- try {
1403
- head = buffer.toString('utf8', 0, readSync(fd, buffer, 0, buffer.length, 0));
1404
- } finally {
1405
- closeSync(fd);
1406
- }
1407
- } catch {
1408
- return false;
1409
- }
1410
- const shebang = /^#!\s*(\/\S+)(?:\s+(.*))?$/.exec(head.split('\n')[0] ?? '');
1411
- if (shebang === null) continue;
1412
- const interpreter = shebang[1] ?? '';
1413
- const program = path.basename(interpreter);
1414
- if (program === 'env') {
1415
- // An env trampoline naming a bare program resolves through PATH; one naming an
1416
- // absolute interpreter (after any flags, -S included) is judged as that interpreter.
1417
- const tokens = shellWords(shebang[2] ?? '');
1418
- let index = 0;
1419
- while (index < tokens.length && tokens[index]?.startsWith('-')) index += tokens[index] === '-u' ? 2 : 1;
1420
- const target = tokens[index];
1421
- if (target !== undefined && target.startsWith('/') && namesEnvironment(target)) return false;
1422
- continue;
1423
- }
1424
- if (['sh', 'bash', 'dash', 'zsh'].includes(program)) {
1425
- // A relocatable wrapper execs a self-locating interpreter; a legacy one execs an
1426
- // absolute environment path. Only exec lines are judged, tokenized as shell words
1427
- // (quotes group, so spaced paths stay whole; a $VAR expansion is not an absolute
1428
- // path and is never classified).
1429
- if (size > 262_144) return false;
1430
- let body: string;
1431
- try {
1432
- body = readFileSync(file, 'utf8');
1433
- } catch {
1434
- return false;
1435
- }
1436
- for (const line of body.split('\n')) {
1437
- // Producer headers are shell words too: a uv console script's polyglot first
1438
- // line tokenizes to the same exec argv as a plain exec line.
1439
- const words = shellWords(line);
1440
- if (words[0] !== 'exec') continue;
1441
- const target = words.find((word) => word.includes('/bin/python')) ?? words[1];
1442
- if (target !== undefined && target.startsWith('/') && namesEnvironment(target)) return false;
1443
- }
1444
- continue;
1445
- }
1446
- if (namesEnvironment(interpreter)) return false;
1447
- }
1448
- }
1449
- for (const sitePackages of sitePackagesDirectories(environment)) {
1450
- for (const name of readdirSync(sitePackages).filter((entry) => entry.endsWith('.pth'))) {
1451
- const content = readFileSync(path.join(sitePackages, name), 'utf8');
1452
- if (content.split('\n').some((line) => path.isAbsolute(line))) return false;
1453
- }
1454
- }
1455
- return true;
1456
- }
1457
-
1458
1026
  function uvInstaller(inputs: readonly string[], options: { locked: boolean }): Installer | null {
1459
1027
  const python = flags.python;
1460
1028
  if (python === undefined || !existsSync(path.join(projectRoot, 'pyproject.toml'))) {
@@ -1496,7 +1064,7 @@ function uvInstaller(inputs: readonly string[], options: { locked: boolean }): I
1496
1064
  await runSetupCommand(`uv ${create.join(' ')}`, $`uv ${create}`.env(env), { quiet });
1497
1065
  }
1498
1066
  await runSetupCommand(`uv ${argv.join(' ')}`, $`uv ${argv}`.env(env), { quiet });
1499
- relativizeCheckoutPaths(environment);
1067
+ relativizeCheckoutPaths(environment, projectRoot);
1500
1068
  writeInstallStamp(stampPath, { inputs: inputsDigest(identity, inputs) });
1501
1069
  },
1502
1070
  };
@@ -1515,9 +1083,10 @@ function uvInstaller(inputs: readonly string[], options: { locked: boolean }): I
1515
1083
  * `registry` and `git` caches), so a stamp directory fails the entry with
1516
1084
  * EPERM. It lives in smoo's user cache instead — `$XDG_CACHE_HOME/smoo`, or
1517
1085
  * `~/.cache/smoo` when the variable is unset, empty or not absolute, as the XDG
1518
- * base directory rule has it; a cowshed sandbox owns XDG_CACHE_HOME — named by
1519
- * the digest of the Cargo binary, the CARGO_HOME path, and the workspace's
1520
- * Cargo.lock, manifest and Cargo configuration.
1086
+ * base directory rule has it (smooCacheDirectory, cargo-fetch-bound.ts); a
1087
+ * cowshed sandbox owns XDG_CACHE_HOME — named by the digest of the Cargo
1088
+ * binary, the CARGO_HOME path, and the workspace's Cargo.lock, manifest and
1089
+ * Cargo configuration.
1521
1090
  *
1522
1091
  * A stamp outside CARGO_HOME no longer dies with it, and a stamp that outlived
1523
1092
  * its packages would promise ones that are gone. So it also records which
@@ -1528,6 +1097,13 @@ function uvInstaller(inputs: readonly string[], options: { locked: boolean }): I
1528
1097
  * this checkout sharing that CARGO_HOME enters fetched. `--locked` makes a
1529
1098
  * stale Cargo.lock fail here, in Cargo's words, rather than fetch a graph the
1530
1099
  * lockfile does not name.
1100
+ *
1101
+ * The fetch holds Cargo's package-cache lock while it runs, so a fetch that
1102
+ * stalls would stop every cargo that shares CARGO_HOME. It is bounded
1103
+ * (cargo-fetch-bound.ts): it runs in a process group of its own under a
1104
+ * deadline that kills the group, with git's low-speed limits for the git
1105
+ * transfers Cargo starts. A fetch that is killed records no stamp, like one
1106
+ * that failed.
1531
1107
  */
1532
1108
  function cargoFetcher(workspace: string): Installer {
1533
1109
  const manifest = path.posix.join(workspace, 'Cargo.toml');
@@ -1535,13 +1111,7 @@ function cargoFetcher(workspace: string): Installer {
1535
1111
  const cargoHome = path.resolve(process.env.CARGO_HOME ?? path.join(homedir(), '.cargo'));
1536
1112
  const identity = ['cargo fetch --locked', cargo === null ? 'cargo not on PATH' : realpathSync(cargo), cargoHome];
1537
1113
  const digest = inputsDigest(identity, cargoWorkspaceInputs(workspace));
1538
- const cacheHome = process.env.XDG_CACHE_HOME;
1539
- const stampPath = path.join(
1540
- cacheHome !== undefined && path.isAbsolute(cacheHome) ? cacheHome : path.join(homedir(), '.cache'),
1541
- 'smoo',
1542
- 'cargo-fetched',
1543
- digest,
1544
- );
1114
+ const stampPath = path.join(smooCacheDirectory(process.env.XDG_CACHE_HOME, homedir()), 'cargo-fetched', digest);
1545
1115
  // What a stamp promises: these inputs were fetched into the directory CARGO_HOME names now.
1546
1116
  // A CARGO_HOME with nothing at it is an identity of its own.
1547
1117
  const fetched = () => {
@@ -1551,10 +1121,17 @@ function cargoFetcher(workspace: string): Installer {
1551
1121
  return {
1552
1122
  isCurrent: () => readInstallStamp(stampPath)?.inputs === fetched(),
1553
1123
  install: async ({ quiet }) => {
1554
- await runSetupCommand(
1124
+ const deadline = fetchDeadline(process.env[CARGO_FETCH_DEADLINE_ENV]);
1125
+ if (deadline.kind === 'refused') throw new Error(deadline.message);
1126
+ await runBoundedSetupCommand(
1555
1127
  `cargo fetch --locked --manifest-path ${manifest}`,
1556
- $`cargo fetch --locked --manifest-path ${manifest}`,
1557
- { quiet },
1128
+ ['cargo', 'fetch', '--locked', '--manifest-path', manifest],
1129
+ {
1130
+ quiet,
1131
+ deadlineMs: deadline.ms,
1132
+ env: boundedFetchEnv(process.env),
1133
+ lockPath: path.join(cargoHome, '.package-cache'),
1134
+ },
1558
1135
  );
1559
1136
  // After the fetch, not before: the fetch may be what created CARGO_HOME.
1560
1137
  writeInstallStamp(stampPath, { inputs: fetched() });
@@ -1562,34 +1139,6 @@ function cargoFetcher(workspace: string): Installer {
1562
1139
  };
1563
1140
  }
1564
1141
 
1565
- /**
1566
- * Rewrite every `.pth` line in the environment's site-packages that names a
1567
- * directory inside this checkout as a path relative to that site-packages,
1568
- * which is how Python's `site` resolves a relative line. Every other line — an
1569
- * `import` line, a path outside the checkout, a directory that does not exist
1570
- * — stays as uv wrote it.
1571
- */
1572
- function relativizeCheckoutPaths(environment: string): void {
1573
- const root = `${realpathSync(projectRoot)}${path.sep}`;
1574
- for (const sitePackages of sitePackagesDirectories(environment)) {
1575
- const site = realpathSync(sitePackages);
1576
- for (const name of readdirSync(site).filter((entry) => entry.endsWith('.pth'))) {
1577
- const file = path.join(site, name);
1578
- const content = readFileSync(file, 'utf8');
1579
- const rewritten = content
1580
- .split('\n')
1581
- .map((line) => {
1582
- const target = path.isAbsolute(line) && existsSync(line) ? realpathSync(line) : null;
1583
- return target?.startsWith(root) ? path.relative(site, target) : line;
1584
- })
1585
- .join('\n');
1586
- if (rewritten !== content) {
1587
- writeFileSync(file, rewritten);
1588
- }
1589
- }
1590
- }
1591
- }
1592
-
1593
1142
  /**
1594
1143
  * What `bun install` reads, relative to the project root and sorted: the root
1595
1144
  * manifest (dependencies, catalogs, overrides, patchedDependencies), every
@@ -1787,13 +1336,10 @@ function declaresNativeTypeScript(root: string): boolean {
1787
1336
  const rootPackageJson = path.join(root, 'package.json');
1788
1337
  if (!existsSync(rootPackageJson)) return false;
1789
1338
  try {
1790
- const pkg = JSON.parse(readFileSync(rootPackageJson, 'utf8')) as {
1791
- devDependencies?: Record<string, string>;
1792
- dependencies?: Record<string, string>;
1793
- };
1794
- return (
1795
- typeof pkg.devDependencies?.['@typescript/native'] === 'string' ||
1796
- typeof pkg.dependencies?.['@typescript/native'] === 'string'
1339
+ const pkg: unknown = JSON.parse(readFileSync(rootPackageJson, 'utf8'));
1340
+ if (!payloadObject(pkg)) return false;
1341
+ return [pkg.devDependencies, pkg.dependencies].some(
1342
+ (dependencies) => payloadObject(dependencies) && typeof dependencies['@typescript/native'] === 'string',
1797
1343
  );
1798
1344
  } catch {
1799
1345
  return false;
@@ -1847,11 +1393,13 @@ function assertTypescriptApiAt(typescriptRoot: string, expectedTarget: string):
1847
1393
  throw new Error(`Missing ${typescriptRoot} after linking TypeScript ${TYPESCRIPT_API_VERSION} API package`);
1848
1394
  }
1849
1395
  const requireFromInstall = createRequire(path.join(typescriptRoot, 'package.json'));
1850
- const typed = requireFromInstall(typescriptRoot) as { version?: string; readConfigFile?: unknown };
1851
- if (typeof typed.readConfigFile !== 'function' || typed.version !== TYPESCRIPT_API_VERSION) {
1396
+ const typed: unknown = requireFromInstall(typescriptRoot);
1397
+ const api: Record<string, unknown> = payloadObject(typed) ? typed : {};
1398
+ const version = typeof api.version === 'string' ? api.version : undefined;
1399
+ if (typeof api.readConfigFile !== 'function' || version !== TYPESCRIPT_API_VERSION) {
1852
1400
  throw new Error(
1853
1401
  `${typescriptRoot} must export TypeScript ${TYPESCRIPT_API_VERSION} compiler API (readConfigFile). ` +
1854
- `Resolved version ${typed.version ?? 'unknown'} (expected link target ${expectedTarget}). ` +
1402
+ `Resolved version ${version ?? 'unknown'} (expected link target ${expectedTarget}). ` +
1855
1403
  'Bun isolated linking races .bun/node_modules/typescript between typescript@6 and ' +
1856
1404
  "@typescript/native's TS7. See https://github.com/oven-sh/bun/issues/40355.",
1857
1405
  );
@@ -1971,6 +1519,46 @@ async function runSetupCommand(
1971
1519
  return result;
1972
1520
  }
1973
1521
 
1522
+ /**
1523
+ * `runSetupCommand` for a command that must not outlive `deadlineMs`: it runs in a process group of its own, which is
1524
+ * killed with everything in it when the deadline passes (cargo-fetch-run.ts). `lockPath` is the lock the command holds
1525
+ * while it runs, which the failure of one that was killed names.
1526
+ */
1527
+ async function runBoundedSetupCommand(
1528
+ command: string,
1529
+ argv: readonly string[],
1530
+ options: { quiet: boolean; deadlineMs: number; env: Readonly<Record<string, string>>; lockPath: string },
1531
+ ): Promise<CapturedOutput> {
1532
+ let outcome: BoundedOutcome;
1533
+ try {
1534
+ outcome = await runBounded({
1535
+ argv,
1536
+ cwd: projectRoot,
1537
+ env: options.env,
1538
+ deadlineMs: options.deadlineMs,
1539
+ echo: !options.quiet,
1540
+ });
1541
+ } catch (cause) {
1542
+ throw new Error(`${command} could not run: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
1543
+ }
1544
+ if (outcome.kind === 'expired') {
1545
+ const { deadlineMs, lockPath } = options;
1546
+ const message = describeDeadline({
1547
+ command,
1548
+ deadlineMs,
1549
+ elapsedMs: Math.round(outcome.elapsedMs),
1550
+ lockPath,
1551
+ group: outcome.group,
1552
+ membersLeft: outcome.membersLeft,
1553
+ });
1554
+ throw new CommandDeadlineError(command, message, outcome.stdout, outcome.stderr);
1555
+ }
1556
+ if (outcome.exitCode !== 0) {
1557
+ throw new CapturedCommandError(command, outcome.exitCode, outcome.stdout, outcome.stderr);
1558
+ }
1559
+ return outcome;
1560
+ }
1561
+
1974
1562
  /**
1975
1563
  * One value the repository's own config holds. `replaces` is a pattern over the
1976
1564
  * key's existing values: the values it matches are this one's to replace, and
@@ -2136,6 +1724,9 @@ function describeFailure(level: 'ERROR' | 'WARNING', error: unknown): void {
2136
1724
  if (error instanceof CapturedCommandError) {
2137
1725
  console.error(`--- ${level}: setup-environment.ts failed while running: ${error.command}`);
2138
1726
  console.error(`exit code: ${error.exitCode}`);
1727
+ } else if (error instanceof CommandDeadlineError) {
1728
+ console.error(`--- ${level}: setup-environment.ts failed while running: ${error.command}`);
1729
+ console.error(error.message);
2139
1730
  } else {
2140
1731
  console.error(`--- ${level}: setup-environment.ts failed: ${error}`);
2141
1732
  }
@@ -2144,7 +1735,7 @@ function describeFailure(level: 'ERROR' | 'WARNING', error: unknown): void {
2144
1735
  }
2145
1736
 
2146
1737
  function replayCapturedOutput(error: unknown): void {
2147
- if (!(error instanceof CapturedCommandError)) {
1738
+ if (!(error instanceof CapturedCommandError || error instanceof CommandDeadlineError)) {
2148
1739
  return;
2149
1740
  }
2150
1741
  // The install ran with every resolved secret in its environment, so its