@smoothbricks/nx-plugin 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -0,0 +1,42 @@
1
+ # Managed by `smoo monorepo`. Sourced by devenv.smoo.nix's enterShell prologue
2
+ # (bash) on every platform, naming the cc-rs compiler variables the shell's
3
+ # own `env` declares:
4
+ #
5
+ # . "$DEVENV_ROOT/compiler-variables.sh" CC_x86_64_unknown_linux_gnu ...
6
+ #
7
+ # cc-rs's compiler variables are this shell's: the ones it declares and no
8
+ # others. They are the per-target CC_<target>, CXX_<target>, AR_<target> and
9
+ # RANLIB_<target> (either spelling of the target), HOST_ and TARGET_ forms of
10
+ # each, and CFLAGS, CXXFLAGS, ARFLAGS and RANLIBFLAGS in every one of those
11
+ # forms and generic. cc-rs looks a compiler up through them in that order and
12
+ # declares rerun-if-env-changed on each name it looks up, so a value is part of
13
+ # that build script's run and of every unit that depends on its package. One a
14
+ # caller's environment carries in (an agent started in another checkout's
15
+ # devenv shell exports Apple's clang as CC_aarch64_apple_darwin) reruns every
16
+ # such script, and rebuilds everything above it, against a target main's land
17
+ # built without it (specs/cowshed/16_build_volumes.md, "One Cargo environment
18
+ # on every path"). Each inherited one is dropped, and each drop is announced. A
19
+ # deliberate value belongs in the shell's `env`, or in .envrc-local, which
20
+ # direnv sources after this shell.
21
+ #
22
+ # The generic tool names stay where they are: on Linux the stdenv sets CC, CXX,
23
+ # AR and RANLIB, and on Darwin apple-developer.sh drops CC and CXX.
24
+ smoo_compiler_declared=" $* "
25
+ for smoo_compiler_name in ${!CC_@} ${!CXX_@} ${!AR_@} ${!RANLIB_@} ${!CFLAGS@} ${!CXXFLAGS@} ${!ARFLAGS@} ${!RANLIBFLAGS@} ${!HOST_@} ${!TARGET_@}; do
26
+ # A target names a lowercase architecture; CC_ENABLE_DEBUG_OUTPUT and its
27
+ # kind are cc-rs settings, not compilers.
28
+ case "$smoo_compiler_name" in
29
+ CC_[[:lower:]]* | CXX_[[:lower:]]* | AR_[[:lower:]]* | RANLIB_[[:lower:]]*) ;;
30
+ CFLAGS | CXXFLAGS | ARFLAGS | RANLIBFLAGS) ;;
31
+ CFLAGS_[[:lower:]]* | CXXFLAGS_[[:lower:]]* | ARFLAGS_[[:lower:]]* | RANLIBFLAGS_[[:lower:]]*) ;;
32
+ HOST_CC | HOST_CXX | HOST_AR | HOST_RANLIB | HOST_CFLAGS | HOST_CXXFLAGS | HOST_ARFLAGS | HOST_RANLIBFLAGS) ;;
33
+ TARGET_CC | TARGET_CXX | TARGET_AR | TARGET_RANLIB | TARGET_CFLAGS | TARGET_CXXFLAGS | TARGET_ARFLAGS | TARGET_RANLIBFLAGS) ;;
34
+ *) continue ;;
35
+ esac
36
+ case "$smoo_compiler_declared" in
37
+ *" $smoo_compiler_name "*) continue ;;
38
+ esac
39
+ echo "devenv: dropping inherited $smoo_compiler_name (${!smoo_compiler_name}); this shell declares cc-rs's compiler variables" >&2
40
+ unset "$smoo_compiler_name"
41
+ done
42
+ unset smoo_compiler_declared smoo_compiler_name
@@ -104,6 +104,8 @@
104
104
  * the command keep the same links.
105
105
  */
106
106
 
107
+ import { spawnSync } from 'node:child_process';
108
+ import { createHash } from 'node:crypto';
107
109
  import {
108
110
  type Dirent,
109
111
  existsSync,
@@ -121,14 +123,17 @@ import {
121
123
  writeFileSync,
122
124
  } from 'node:fs';
123
125
  import path from 'node:path';
124
- import type { KeepDeveloperLinksOptions } from '@smoothbricks/nx-plugin/managed-assets';
126
+ import type { BuildInputProducer, KeepDeveloperLinksOptions } from '@smoothbricks/nx-plugin/managed-assets';
125
127
  import {
128
+ linkAnchor,
126
129
  type ProducerProbe,
130
+ packedFiles,
127
131
  pinnedSnapshot,
128
132
  pluginProbe,
129
133
  recordedSnapshot,
130
134
  type SealedSnapshot,
131
135
  type SnapshotDeclaration,
136
+ SnapshotRefusal,
132
137
  snapshotBinding,
133
138
  } from './linked-snapshots.ts';
134
139
 
@@ -451,7 +456,7 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
451
456
  const trees = nodeModulesTrees(root);
452
457
  const recorded = readDeclaredRecord(root);
453
458
  const probe: ProducerProbe = (target, providerRoot) =>
454
- pluginProbe(snapshotPluginRoot(root, anchor, declared))(target, providerRoot);
459
+ pluginProbe(snapshotPluginRoot(root, declared))(target, providerRoot);
455
460
  const changes: DeclaredLinkChange[] = [];
456
461
  const unavailable: UnavailableDeclaredLink[] = [];
457
462
  const reports: string[] = [];
@@ -468,6 +473,13 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
468
473
  continue;
469
474
  }
470
475
  let binding: DeclaredBinding = { kind: 'checkout', target: source };
476
+ // A live checkout runs whatever its last build wrote. Linking one whose build is older than its sources would say
477
+ // the checkout runs while older code does, so the link is refused and nothing is changed (a snapshot carries its
478
+ // own producer provenance instead).
479
+ if (snapshot === undefined) {
480
+ const stale = staleBuilds(name, source);
481
+ if (stale.length > 0) throw new Error(staleBuildsRefusal(stale));
482
+ }
471
483
  if (snapshot !== undefined) {
472
484
  const outcome = await snapshotBinding(root, name, source, snapshot, probe);
473
485
  if (outcome.kind === 'refused') {
@@ -576,10 +588,10 @@ function keptSnapshots(
576
588
  * a declaration: an install re-points the plugin alias at the lockfile's published version before this runs, and
577
589
  * that version cannot read a producer receipt only the declared checkout's plugin writes.
578
590
  */
579
- function snapshotPluginRoot(root: string, anchor: string, declared: readonly DeclaredLink[]): string {
591
+ function snapshotPluginRoot(root: string, declared: readonly DeclaredLink[]): string {
580
592
  const plugin = declared.find(({ name }) => name === '@smoothbricks/nx-plugin');
581
- if (plugin === undefined) return root;
582
- const source = declaredTarget(root, anchor, plugin.directory);
593
+ const source = declaredDirectory(root, '@smoothbricks/nx-plugin');
594
+ if (plugin === undefined || source === null) return root;
583
595
  if (typeof plugin.snapshot === 'string') return pinnedSnapshot(root, plugin.name, source, plugin.snapshot).directory;
584
596
  return unavailableReason(source) === null ? source : root;
585
597
  }
@@ -744,6 +756,442 @@ function unavailableReason(target: string): string | null {
744
756
  }
745
757
  }
746
758
 
759
+ /**
760
+ * A build unit of a linked package that does not describe its current sources: what an alias to the live checkout
761
+ * would actually run. A unit with an input record is judged by content: one of its inputs has other bytes than the
762
+ * build read, was removed, or was added since. A unit without one is judged by modification time (`builtAt` is null
763
+ * for a published unit that was never built), which also refuses a file rewritten with its own bytes.
764
+ */
765
+ export type StaleBuild = {
766
+ readonly packageName: string;
767
+ readonly directory: string;
768
+ readonly unit: string;
769
+ /** The command that rewrites the unit's outputs, run in `workspaceRoot`. */
770
+ readonly rebuild: string;
771
+ readonly workspaceRoot: string;
772
+ } & (
773
+ | { readonly basis: 'recorded'; readonly input: string; readonly change: 'changed' | 'removed' | 'added' }
774
+ | {
775
+ readonly basis: 'modification-time';
776
+ readonly builtAt: { readonly path: string; readonly time: Date } | null;
777
+ readonly newestInput: { readonly path: string; readonly time: Date };
778
+ }
779
+ );
780
+
781
+ /**
782
+ * The input record a producer writes into each output directory and Nx restores with it (`.build-inputs.json`; the
783
+ * producer side is the nx-plugin's build-inputs.ts): `files` maps each workspace-relative input to the SHA-256 of the
784
+ * bytes the build read, and `complete`, when present, holds Git pathspecs whose every match is an input.
785
+ */
786
+ const BUILD_INPUTS_FILE = '.build-inputs.json';
787
+
788
+ interface BuildInputRecord {
789
+ readonly files: ReadonlyMap<string, string>;
790
+ readonly complete: readonly string[];
791
+ readonly producer: BuildInputProducer | undefined;
792
+ }
793
+
794
+ /** The file boundary parses JSON once, then the pure decoder validates its data and provenance together. */
795
+ function readBuildInputRecord(workspaceRoot: string, record: string): BuildInputRecord {
796
+ const location = path.join(workspaceRoot, record);
797
+ return decodeBuildInputRecord(JSON.parse(readFileSync(location, 'utf8')), location);
798
+ }
799
+
800
+ /** Parse once: provenance selects the unit, and the same validated inputs judge its currentness. */
801
+ export function decodeBuildInputRecord(parsed: unknown, record: string): BuildInputRecord {
802
+ const files: unknown = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'files') : undefined;
803
+ const complete: unknown = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'complete') : undefined;
804
+ if (
805
+ typeof parsed !== 'object' ||
806
+ parsed === null ||
807
+ Reflect.get(parsed, 'version') !== 1 ||
808
+ typeof files !== 'object' ||
809
+ files === null ||
810
+ !Object.values(files).every((hash) => typeof hash === 'string') ||
811
+ (complete !== undefined &&
812
+ (!Array.isArray(complete) || !complete.every((spec): spec is string => typeof spec === 'string')))
813
+ )
814
+ throw new Error(`${record} is not a version 1 build input record`);
815
+ const producer: unknown = Reflect.get(parsed, 'producer');
816
+ if (producer !== undefined && !isBuildInputProducer(producer))
817
+ throw new Error(`${record} is not a version 1 build input record: producer`);
818
+ return {
819
+ files: new Map(Object.entries(files).map(([file, hash]) => [file, String(hash)])),
820
+ complete: complete ?? [],
821
+ producer,
822
+ };
823
+ }
824
+
825
+ /** The first input whose bytes differ from what the build recorded, or null when the record describes the sources. */
826
+ function recordedChange(
827
+ workspaceRoot: string,
828
+ { files: recorded, complete }: BuildInputRecord,
829
+ ): { readonly input: string; readonly change: 'changed' | 'removed' | 'added' } | null {
830
+ for (const [file, hash] of recorded) {
831
+ const at = path.join(workspaceRoot, file);
832
+ if (!existsSync(at)) return { input: file, change: 'removed' };
833
+ if (createHash('sha256').update(readFileSync(at)).digest('hex') !== hash) return { input: file, change: 'changed' };
834
+ }
835
+ if (Array.isArray(complete) && complete.length > 0) {
836
+ const current = gitText(workspaceRoot, [
837
+ 'ls-files',
838
+ '-z',
839
+ '--cached',
840
+ '--others',
841
+ '--exclude-standard',
842
+ '--',
843
+ ...complete,
844
+ ]);
845
+ // As the producer lists them: a tracked file deleted in the working tree is no input.
846
+ for (const file of current.split('\0').filter(Boolean)) {
847
+ if (!recorded.has(file) && existsSync(path.join(workspaceRoot, file))) return { input: file, change: 'added' };
848
+ }
849
+ }
850
+ return null;
851
+ }
852
+
853
+ /** One build of a linked package: the outputs it writes and the files it reads. */
854
+ interface BuildUnit {
855
+ readonly label: string;
856
+ readonly outputs: readonly string[];
857
+ readonly inputs: readonly string[];
858
+ /** Published, so absent outputs mean it was never built rather than not built for this host. */
859
+ readonly expected: boolean;
860
+ }
861
+
862
+ /** A platform directory as packages name their per-host builds (`dist/bin/darwin-arm64`). */
863
+ const PLATFORM_SEGMENT = /^(?:darwin|linux|win32|freebsd)-(?:arm64|x64|ia32|arm)(?:-[a-z0-9]+)?$/;
864
+
865
+ const isObject = (value: unknown): value is object => typeof value === 'object' && value !== null;
866
+
867
+ function isBuildInputProducer(value: unknown): value is BuildInputProducer {
868
+ if (!isObject(value) || Array.isArray(value)) return false;
869
+ const project: unknown = Reflect.get(value, 'project');
870
+ const target: unknown = Reflect.get(value, 'target');
871
+ const configuration: unknown = Reflect.get(value, 'configuration');
872
+ return (
873
+ typeof project === 'string' &&
874
+ project !== '' &&
875
+ typeof target === 'string' &&
876
+ target !== '' &&
877
+ (configuration === undefined || (typeof configuration === 'string' && configuration !== ''))
878
+ );
879
+ }
880
+
881
+ /** An Nx path declaration with `{projectRoot}` and `{workspaceRoot}` replaced: relative to the workspace root. */
882
+ function resolveRoots(pattern: string, packagePath: string): string {
883
+ return pattern
884
+ .replaceAll('{projectRoot}', packagePath)
885
+ .replaceAll('{workspaceRoot}/', '')
886
+ .replaceAll('{workspaceRoot}', '');
887
+ }
888
+
889
+ /** The receipt's actual task owns the output; no target list or shadow Nx normalization is needed. */
890
+ export function selectedBuildInputProducer(
891
+ producer: BuildInputProducer | undefined,
892
+ project: string,
893
+ targets: unknown,
894
+ ): BuildInputProducer | undefined {
895
+ if (producer === undefined || producer.project !== project || producer.configuration === 'production')
896
+ return undefined;
897
+ const definition: unknown = isObject(targets) ? Reflect.get(targets, producer.target) : undefined;
898
+ const defaultConfiguration: unknown = isObject(definition)
899
+ ? Reflect.get(definition, 'defaultConfiguration')
900
+ : undefined;
901
+ if (producer.configuration !== undefined && producer.configuration !== defaultConfiguration) return undefined;
902
+ return producer;
903
+ }
904
+
905
+ /** Only real source-owned directories: build-volume links, Cargo state and installed dependencies are never entered. */
906
+ function cachedBuildInputRecords(directory: string): string[] {
907
+ const records: string[] = [];
908
+ const walk = (at: string) => {
909
+ for (const entry of directoryEntries(at)) {
910
+ const child = path.join(at, entry.name);
911
+ if (entry.isDirectory() && entry.name !== 'target' && entry.name !== 'node_modules') walk(child);
912
+ else if (entry.isFile() && entry.name === BUILD_INPUTS_FILE) records.push(child);
913
+ }
914
+ };
915
+ const cache = path.join(directory, '.cache');
916
+ if (lstatSync(cache, { throwIfNoEntry: false })?.isDirectory()) walk(cache);
917
+ return records;
918
+ }
919
+
920
+ /**
921
+ * The build units of the package at `directory` that do not describe its current sources.
922
+ *
923
+ * A unit is first each output directory holding an input record: it is current exactly while every recorded input
924
+ * still has the recorded bytes and no source the record's pathspecs match has been added. The producer writes the
925
+ * record as part of its Nx outputs, so a cached build restores the record describing the outputs it restores, and a
926
+ * file rewritten with its own bytes (a branch switch, a stash) changes nothing. Receipts under source-owned `.cache`
927
+ * and in published files carry the actual producer identity: this package's default task, including an inferred one,
928
+ * owns the unit. Foreign, nondefault and obsolete native records without provenance exclude their trees. The
929
+ * TypeScript emit's `outDir` is an independent boundary and accepts a standalone bootstrap's record without a producer,
930
+ * so an enclosing old layout cannot hide it. Shell entry starts no Nx graph and normalizes no output declarations.
931
+ *
932
+ * Outputs no record covers fall back to modification time, per unit, so a `.md` edit or a Rust change cannot make a
933
+ * TypeScript build stale:
934
+ *
935
+ * - the TypeScript project `tsconfig.lib.json` builds: the published, untracked files under its `outDir` less build
936
+ * info, read from the tracked files its `include` matches less its `exclude`, and the config itself;
937
+ * - each target the package manifest's `nx.targets` declares with outputs among those files: its declared file
938
+ * inputs (`{projectRoot}` and `{workspaceRoot}` globs, `!` negations; named and runtime inputs are not files);
939
+ * - every other published, untracked file, read from the package's tracked files less documentation and tests.
940
+ *
941
+ * A fallback unit was built when its newest output was written. Not its oldest: an emit that leaves unchanged outputs
942
+ * in place keeps their old times. Not a `.tsbuildinfo`: the build emits with `incremental: false`, so one under
943
+ * `outDir` is a leftover no build rewrites. The fallback cannot tell a rewrite with the same bytes from a change, and
944
+ * its refusal says so.
945
+ *
946
+ * Output directories built for another host (`darwin-x64` on an arm64 Mac) are skipped: nothing here runs them.
947
+ * The remedy names the receipt's exact producer target and configuration; `build` need not reach a native producer.
948
+ * Missing-record published units retain their timestamp fallback and package `build` remedy. A cached build that
949
+ * leaves a recorded unit stale is a cache-key defect (its inputs miss something its outputs depend on), never a reason
950
+ * to skip the cache.
951
+ */
952
+ export function staleBuilds(packageName: string, directory: string): StaleBuild[] {
953
+ const manifest: unknown = JSON.parse(readFileSync(path.join(directory, 'package.json'), 'utf8'));
954
+ const manifestRecord = typeof manifest === 'object' && manifest !== null ? manifest : {};
955
+ // Packages without declared builds or development receipts need no Git build-state inspection.
956
+ const cachedRecords = cachedBuildInputRecords(directory);
957
+ const nxDeclared = Reflect.get(manifestRecord, 'nx');
958
+ if (
959
+ cachedRecords.length === 0 &&
960
+ Reflect.get(manifestRecord, 'files') === undefined &&
961
+ !existsSync(path.join(directory, 'tsconfig.lib.json')) &&
962
+ (typeof nxDeclared !== 'object' || nxDeclared === null || Reflect.get(nxDeclared, 'targets') === undefined)
963
+ )
964
+ return [];
965
+ const workspaceRoot = realpathSync(gitText(directory, ['rev-parse', '--show-toplevel']));
966
+ const tracked = new Set(gitText(workspaceRoot, ['ls-files', '-z']).split('\0').filter(Boolean));
967
+ const packagePath = path.relative(workspaceRoot, realpathSync(directory));
968
+ const host = `${process.platform}-${process.arch}`;
969
+ const targets = isObject(nxDeclared) ? Reflect.get(nxDeclared, 'targets') : undefined;
970
+ const nxName: unknown = isObject(nxDeclared) ? Reflect.get(nxDeclared, 'name') : undefined;
971
+ const project = typeof nxName === 'string' ? nxName : packageName;
972
+ const rebuild = `nx run ${project}:build`;
973
+ const configPath = path.join(directory, 'tsconfig.lib.json');
974
+ const parsed: unknown = existsSync(configPath) ? Bun.JSONC.parse(readFileSync(configPath, 'utf8')) : undefined;
975
+ const config: object = isObject(parsed) ? parsed : {};
976
+ const compilerOptions: unknown = Reflect.get(config, 'compilerOptions');
977
+ const outDir: unknown = isObject(compilerOptions) ? Reflect.get(compilerOptions, 'outDir') : undefined;
978
+ // The TypeScript emit's output is a default build's too, though no target of the manifest declares it.
979
+ const emit = typeof outDir === 'string' ? { outDir, directory: path.join(packagePath, outDir) } : undefined;
980
+ let published: string[];
981
+ try {
982
+ published = packedFiles(directory, manifestRecord);
983
+ } catch (error) {
984
+ if (!(error instanceof SnapshotRefusal)) throw error;
985
+ published = [];
986
+ }
987
+ const within = (parent: string, file: string) => file === parent || file.startsWith(`${parent}${path.sep}`);
988
+ // A file a build of this checkout wrote that runs here: not a tracked source, and not built for another host
989
+ // (nothing here runs it).
990
+ const written = (file: string) =>
991
+ !tracked.has(file) && file.split(path.sep).every((segment) => !PLATFORM_SEGMENT.test(segment) || segment === host);
992
+ const publishedHere = published.map((file) => path.relative(workspaceRoot, file)).filter(written);
993
+ const emitRecord = emit === undefined ? undefined : path.join(emit.directory, BUILD_INPUTS_FILE);
994
+ const receipts = [
995
+ ...new Set([
996
+ ...cachedRecords.map((file) => path.relative(workspaceRoot, file)),
997
+ ...publishedHere.filter((file) => path.basename(file) === BUILD_INPUTS_FILE),
998
+ ...(emitRecord !== undefined &&
999
+ lstatSync(path.join(workspaceRoot, emitRecord), { throwIfNoEntry: false })?.isFile()
1000
+ ? [emitRecord]
1001
+ : []),
1002
+ ]),
1003
+ ]
1004
+ .filter(written)
1005
+ .map((record) => {
1006
+ const inputs = readBuildInputRecord(workspaceRoot, record);
1007
+ const producer = selectedBuildInputProducer(inputs.producer, project, targets);
1008
+ const unit = path.dirname(record);
1009
+ return {
1010
+ unit,
1011
+ inputs,
1012
+ producer,
1013
+ selected: producer !== undefined || (unit === emit?.directory && inputs.producer === undefined),
1014
+ };
1015
+ });
1016
+ const selected = new Set(receipts.filter((receipt) => receipt.selected).map(({ unit }) => unit));
1017
+ const directories = receipts.map(({ unit }) => unit);
1018
+ // Even without its own record, a nested emit keeps its timestamp fallback instead of inheriting an old parent record.
1019
+ if (emit !== undefined && !directories.includes(emit.directory)) {
1020
+ directories.push(emit.directory);
1021
+ selected.add(emit.directory);
1022
+ }
1023
+ const nearest = (file: string) =>
1024
+ directories
1025
+ .filter((output) => within(output, file))
1026
+ .reduce<string | undefined>(
1027
+ (best, output) => (best === undefined || output.length > best.length ? output : best),
1028
+ undefined,
1029
+ );
1030
+ const built = publishedHere.filter((file) => {
1031
+ const owner = nearest(file);
1032
+ return owner === undefined || selected.has(owner);
1033
+ });
1034
+ const claimed = new Set<string>();
1035
+ const claim = (files: readonly string[]) => {
1036
+ const mine = files.filter((file) => !claimed.has(file));
1037
+ for (const file of mine) claimed.add(file);
1038
+ return mine;
1039
+ };
1040
+ const under = (prefix: string) => built.filter((file) => within(prefix, file));
1041
+ const trackedMatching = (patterns: readonly string[]) => {
1042
+ const include = patterns.filter((pattern) => !pattern.startsWith('!')).map((pattern) => new Bun.Glob(pattern));
1043
+ const exclude = patterns
1044
+ .filter((pattern) => pattern.startsWith('!'))
1045
+ .map((pattern) => new Bun.Glob(pattern.slice(1)));
1046
+ return [...tracked].filter(
1047
+ (file) => include.some((glob) => glob.match(file)) && !exclude.some((glob) => glob.match(file)),
1048
+ );
1049
+ };
1050
+ const stale: StaleBuild[] = [];
1051
+ for (const { unit, inputs, producer, selected: judge } of receipts) {
1052
+ if (!judge) continue;
1053
+ claim(under(unit).filter((file) => nearest(file) === unit));
1054
+ const change = recordedChange(workspaceRoot, inputs);
1055
+ if (change !== null)
1056
+ stale.push({
1057
+ basis: 'recorded',
1058
+ packageName,
1059
+ directory,
1060
+ unit,
1061
+ rebuild:
1062
+ producer === undefined
1063
+ ? rebuild
1064
+ : `nx run ${producer.project}:${producer.target}${producer.configuration === undefined ? '' : `:${producer.configuration}`}`,
1065
+ workspaceRoot,
1066
+ ...change,
1067
+ });
1068
+ }
1069
+ const units: BuildUnit[] = [];
1070
+
1071
+ if (emit !== undefined && !receipts.some(({ unit }) => unit === emit.directory)) {
1072
+ const globs = (key: string) => {
1073
+ const value: unknown = Reflect.get(config, key);
1074
+ return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
1075
+ };
1076
+ const files = Reflect.get(manifestRecord, 'files');
1077
+ const publishes =
1078
+ Array.isArray(files) &&
1079
+ files.some(
1080
+ (entry) => typeof entry === 'string' && (emit.outDir === entry || emit.outDir.startsWith(`${entry}/`)),
1081
+ );
1082
+ units.push({
1083
+ label: `${path.join(packagePath, 'tsconfig.lib.json')} (outDir ${emit.outDir})`,
1084
+ // Claimed with the unit, so a leftover build info is judged by no unit at all.
1085
+ outputs: claim(under(emit.directory)).filter((file) => !file.endsWith('.tsbuildinfo')),
1086
+ inputs: [
1087
+ ...trackedMatching([
1088
+ ...globs('include').map((glob) => path.join(packagePath, glob)),
1089
+ ...globs('exclude').map((glob) => `!${path.join(packagePath, glob)}`),
1090
+ ]),
1091
+ path.join(packagePath, 'tsconfig.lib.json'),
1092
+ ],
1093
+ expected: publishes,
1094
+ });
1095
+ }
1096
+
1097
+ const resolve = (pattern: string) => resolveRoots(pattern, packagePath);
1098
+ for (const [target, definition] of Object.entries(typeof targets === 'object' && targets !== null ? targets : {})) {
1099
+ if (typeof definition !== 'object' || definition === null) continue;
1100
+ const strings = (key: string) => {
1101
+ const value = Reflect.get(definition, key);
1102
+ return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
1103
+ };
1104
+ const outputs = claim(strings('outputs').flatMap((output) => under(path.normalize(resolve(output)))));
1105
+ if (outputs.length === 0) continue;
1106
+ const fileInputs = strings('inputs').filter(
1107
+ (input) => input.includes('{projectRoot}') || input.includes('{workspaceRoot}'),
1108
+ );
1109
+ units.push({
1110
+ label: `nx target ${target}`,
1111
+ outputs,
1112
+ inputs: trackedMatching(
1113
+ fileInputs.map((input) => (input.startsWith('!') ? `!${resolve(input.slice(1))}` : resolve(input))),
1114
+ ),
1115
+ expected: false,
1116
+ });
1117
+ }
1118
+
1119
+ const rest = claim(built);
1120
+ if (rest.length > 0)
1121
+ units.push({
1122
+ label: 'other built files',
1123
+ outputs: rest,
1124
+ inputs: trackedMatching([
1125
+ path.join(packagePath, '**'),
1126
+ `!${path.join(packagePath, '**/*.md')}`,
1127
+ `!${path.join(packagePath, '**/*.test.*')}`,
1128
+ `!${path.join(packagePath, '**/*.spec.*')}`,
1129
+ `!${path.join(packagePath, '**/__tests__/**')}`,
1130
+ `!${path.join(packagePath, 'package.json')}`,
1131
+ ]),
1132
+ expected: false,
1133
+ });
1134
+
1135
+ // A tracked input deleted in the working tree has no time; the files that remain decide.
1136
+ const modified = (file: string) => statSync(path.join(workspaceRoot, file), { throwIfNoEntry: false })?.mtime;
1137
+ for (const unit of units) {
1138
+ if (unit.inputs.length === 0) continue;
1139
+ let newestInput = { path: unit.inputs[0] ?? '', time: new Date(0) };
1140
+ for (const input of unit.inputs) {
1141
+ const time = modified(input);
1142
+ if (time !== undefined && time > newestInput.time) newestInput = { path: input, time };
1143
+ }
1144
+ let builtAt: { readonly path: string; readonly time: Date } | null = null;
1145
+ for (const output of unit.outputs) {
1146
+ const time = modified(output);
1147
+ if (time !== undefined && (builtAt === null || time > builtAt.time)) builtAt = { path: output, time };
1148
+ }
1149
+ if (builtAt === null && !unit.expected) continue;
1150
+ if (builtAt !== null && newestInput.time <= builtAt.time) continue;
1151
+ stale.push({
1152
+ basis: 'modification-time',
1153
+ packageName,
1154
+ directory,
1155
+ unit: unit.label,
1156
+ builtAt,
1157
+ newestInput,
1158
+ rebuild,
1159
+ workspaceRoot,
1160
+ });
1161
+ }
1162
+ return stale;
1163
+ }
1164
+
1165
+ /** The refusal for `stale` builds: what each unit no longer describes, and the cached build that rewrites them. */
1166
+ export function staleBuildsRefusal(stale: readonly StaleBuild[]): string {
1167
+ const lines = stale.map((build) => {
1168
+ if (build.basis === 'recorded') {
1169
+ const how =
1170
+ build.change === 'changed'
1171
+ ? 'has other bytes than the build read'
1172
+ : build.change === 'removed'
1173
+ ? 'was removed since the build'
1174
+ : 'was added since the build';
1175
+ return ` - ${build.packageName}: ${build.unit} is stale: input ${build.input} ${how} (its ${BUILD_INPUTS_FILE})`;
1176
+ }
1177
+ const fallback = `no ${BUILD_INPUTS_FILE}, so judged by modification time, where a file rewritten with its own bytes also counts`;
1178
+ return build.builtAt === null
1179
+ ? ` - ${build.packageName}: ${build.unit} was never built (newest input ${build.newestInput.path} at ${build.newestInput.time.toISOString()}; ${fallback})`
1180
+ : ` - ${build.packageName}: ${build.unit} was built at ${build.builtAt.time.toISOString()} (${build.builtAt.path}), but ${build.newestInput.path} changed at ${build.newestInput.time.toISOString()} (${fallback})`;
1181
+ });
1182
+ const commands = [...new Set(stale.map((build) => `cd ${JSON.stringify(build.workspaceRoot)} && ${build.rebuild}`))];
1183
+ return `refusing developer link(s) to a live checkout whose build does not describe its sources; the link would run the old build:\n${lines.join('\n')}\nRebuild: ${commands.join('; ')}`;
1184
+ }
1185
+
1186
+ function gitText(cwd: string, args: readonly string[]): string {
1187
+ const run = spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
1188
+ if (run.error !== undefined || run.status !== 0)
1189
+ throw new Error(
1190
+ `cannot read the build state of ${cwd}: git ${args.join(' ')}: ${run.error?.message ?? run.stderr.trim()}`,
1191
+ );
1192
+ return run.stdout.trim();
1193
+ }
1194
+
747
1195
  /** A package name as npm spells one: `name` or `@scope/name`, one segment each. */
748
1196
  const PACKAGE_NAME = /^(?:@[A-Za-z0-9_-][A-Za-z0-9._-]*\/)?[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
749
1197
 
@@ -819,6 +1267,17 @@ function readDeclaredLinks(root: string): DeclaredLink[] {
819
1267
  });
820
1268
  }
821
1269
 
1270
+ /**
1271
+ * The directory `name`'s declaration in `root`'s `smoo.developerLinks` names, resolved as its links are: a sibling
1272
+ * directory beside the project's main checkout (`linkAnchor`), a contained one in this checkout. Null when nothing
1273
+ * declares `name`. A consumer that judges a provider's revisions reads them here, where a retired capture root no
1274
+ * longer is.
1275
+ */
1276
+ export function declaredDirectory(root: string, name: string): string | null {
1277
+ const declaration = readDeclaredLinks(root).find((link) => link.name === name);
1278
+ return declaration === undefined ? null : declaredTarget(root, linkAnchor(root), declaration.directory);
1279
+ }
1280
+
822
1281
  /** Project-contained declared directories follow their checkout; siblings retain the shared main anchor. */
823
1282
  function declaredTarget(root: string, anchor: string, relative: string): string {
824
1283
  const shared = path.resolve(anchor, relative);
@@ -843,26 +1302,6 @@ function declaredTarget(root: string, anchor: string, relative: string): string
843
1302
  }
844
1303
  }
845
1304
 
846
- /**
847
- * The stable anchor for genuine sibling directories is the project's main checkout.
848
- * A cowshed marker names it without reading main's tree. Contained declared
849
- * directories are projected into the current checkout by `declaredTarget`, with
850
- * physical containment checked against symlink escapes.
851
- */
852
- function linkAnchor(root: string): string {
853
- let marker: unknown;
854
- try {
855
- marker = JSON.parse(readFileSync(path.join(root, '.cowshed', 'workspace.json'), 'utf8'));
856
- } catch (error) {
857
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
858
- return root;
859
- }
860
- throw error;
861
- }
862
- const projectRoot = typeof marker === 'object' && marker !== null ? Reflect.get(marker, 'projectRoot') : undefined;
863
- return typeof projectRoot === 'string' && path.isAbsolute(projectRoot) ? projectRoot : root;
864
- }
865
-
866
1305
  /** Ownership is the link text we wrote, not merely an alias path we once used. */
867
1306
  const DECLARED_RECORD = path.join('node_modules', '.smoo-declared-links');
868
1307