@smoothbricks/nx-plugin 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,316 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { spawnSync } from 'node:child_process';
3
- import { chmod, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
-
7
- import {
8
- CARGO_CROSS_LINT_COMMAND,
9
- CARGO_CROSS_LINT_REFUSAL,
10
- CARGO_CROSS_LINT_TARGET,
11
- CARGO_DENY_WARNINGS,
12
- CARGO_LINT_CLIPPY_COMMAND,
13
- CARGO_LINUX_TRIPLE,
14
- CROSS_CHECK_SCRIPT_COMMAND,
15
- CROSS_CHECK_SCRIPT_NAME,
16
- cargoFrozen,
17
- DEVENV_CROSS_PROFILE,
18
- runsFrozenCargo,
19
- } from './cross-check-policy.js';
20
- import { BUILD_OUTPUT_DEPENDENCIES, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
21
-
22
- const suffixOf = (glob: string): string => (glob.startsWith('*') ? glob.slice(1) : glob);
23
-
24
- describe('Linux cross-check policy', () => {
25
- it('keeps the cross target out of every platform artifact family', () => {
26
- // `*-linux` is not decoration: publish-workflow fans out over
27
- // LINUX_PLATFORM_TARGET_GLOBS to build RELEASE ARTIFACTS on a Linux runner,
28
- // platformTargetFamily classifies by it, and a matching name flags the whole
29
- // project as platform-bearing. Naming this validation target `*-linux` would
30
- // enrol a clippy run in release artifact production — silently, and only
31
- // visible at publish time.
32
- for (const glob of PLATFORM_TARGET_GLOBS) {
33
- expect(CARGO_CROSS_LINT_TARGET.endsWith(suffixOf(glob))).toBe(false);
34
- }
35
- });
36
-
37
- it('keeps the cross target out of every build output family', () => {
38
- // A match here would attach the gate to each project's aggregate `build`,
39
- // making an ordinary macOS build demand the opt-in cross toolchain.
40
- for (const dependency of BUILD_OUTPUT_DEPENDENCIES) {
41
- expect(CARGO_CROSS_LINT_TARGET.endsWith(suffixOf(dependency))).toBe(false);
42
- }
43
- });
44
-
45
- it('names targets without colons', () => {
46
- // Nx CLI syntax is already project:target:configuration.
47
- expect(CARGO_CROSS_LINT_TARGET).not.toContain(':');
48
- });
49
-
50
- it('compiles test code for the target without running anything', () => {
51
- // --all-targets is the entire test story for the cross arm: bins, tests,
52
- // benches and examples are type-checked for Linux, and nothing is executed
53
- // because an x86_64 Linux binary cannot run on Apple Silicon. Dropping it
54
- // would silently stop checking every #[cfg(test)] and #[bench] block.
55
- expect(CARGO_CROSS_LINT_COMMAND).toContain('--all-targets');
56
- // No cargo subcommand here may execute what it built.
57
- expect(CARGO_CROSS_LINT_COMMAND).not.toContain('cargo test');
58
- expect(CARGO_CROSS_LINT_COMMAND).not.toContain('cargo run');
59
- });
60
-
61
- it('matches the severity and triple CI lints with', () => {
62
- // A weaker local command passes where CI fails, which is the failure this
63
- // gate exists to prevent rather than reproduce.
64
- expect(CARGO_CROSS_LINT_COMMAND).toContain(CARGO_DENY_WARNINGS);
65
- expect(CARGO_CROSS_LINT_COMMAND).toContain(`--target ${CARGO_LINUX_TRIPLE}`);
66
- });
67
-
68
- it('passes clippy-driver no arguments, so the gate and a plain clippy share one unit set', () => {
69
- // Anything after `--` becomes CLIPPY_ARGS, part of every member's fingerprint.
70
- for (const command of [CARGO_LINT_CLIPPY_COMMAND, CARGO_CROSS_LINT_COMMAND]) {
71
- expect(command).not.toContain(' -- ');
72
- }
73
- });
74
-
75
- it('fails on warnings it replays from units a plain clippy already checked', async () => {
76
- const project = await mkdtemp(join(tmpdir(), 'cargo-lint-warnings-'));
77
- const clippy = async (command: string): Promise<{ exitCode: number; output: string }> => {
78
- const child = Bun.spawn(['sh', '-c', command], {
79
- cwd: project,
80
- env: { ...process.env, RUSTC_WRAPPER: '', RUSTC_WORKSPACE_WRAPPER: '' },
81
- stdout: 'pipe',
82
- stderr: 'pipe',
83
- });
84
- const [exitCode, stdout, stderr] = await Promise.all([
85
- child.exited,
86
- new Response(child.stdout).text(),
87
- new Response(child.stderr).text(),
88
- ]);
89
- return { exitCode, output: stdout + stderr };
90
- };
91
- try {
92
- await mkdir(join(project, 'src'));
93
- await writeFile(
94
- join(project, 'Cargo.toml'),
95
- '[package]\nname = "warning-fixture"\nversion = "0.1.0"\nedition = "2021"\n[workspace]\n',
96
- );
97
- await writeFile(
98
- join(project, 'Cargo.lock'),
99
- 'version = 4\n\n[[package]]\nname = "warning-fixture"\nversion = "0.1.0"\n',
100
- );
101
- await writeFile(join(project, 'src/lib.rs'), 'pub fn planted() {\n let unused = 1;\n}\n');
102
- const plain = cargoFrozen('clippy --workspace --all-targets');
103
-
104
- const first = await clippy(plain);
105
- expect(first).toMatchObject({ exitCode: 0 });
106
- expect(first.output).toContain('Checking warning-fixture');
107
- expect(first.output).toContain('unused variable');
108
-
109
- // Fresh: the gate replays the plain run's units and their warning, and fails on it.
110
- const gate = await clippy(CARGO_LINT_CLIPPY_COMMAND);
111
- expect(gate.exitCode).not.toBe(0);
112
- expect(gate.output).not.toContain('Checking warning-fixture');
113
- expect(gate.output).toContain('unused variable');
114
- expect(gate.output).toContain('warnings are denied by `build.warnings` configuration');
115
-
116
- // And the gate left the plain run's units Fresh in turn.
117
- const again = await clippy(plain);
118
- expect(again).toMatchObject({ exitCode: 0 });
119
- expect(again.output).not.toContain('Checking warning-fixture');
120
- } finally {
121
- await rm(project, { recursive: true, force: true });
122
- }
123
- });
124
-
125
- it('refuses to start without cargo-zigbuild instead of compiling', async () => {
126
- // Without this guard a cache miss outside the linux-cross toolchain would
127
- // start a compile that cannot finish. Run for real against a PATH with no
128
- // cargo-zigbuild: it must refuse, name the fix, and never reach cargo.
129
- const child = Bun.spawn(['/bin/sh', '-c', CARGO_CROSS_LINT_COMMAND], {
130
- cwd: tmpdir(),
131
- env: { PATH: '/usr/bin:/bin' },
132
- stdout: 'pipe',
133
- stderr: 'pipe',
134
- });
135
- const [exitCode, stderr] = await Promise.all([child.exited, new Response(child.stderr).text()]);
136
- expect(exitCode).toBe(2);
137
- expect(stderr).toContain('needs cargo-zigbuild');
138
- expect(stderr).toContain('bun run check:linux');
139
- });
140
-
141
- it('prints the refusal the managed pre-push hook reads as a cache miss', () => {
142
- expect(CARGO_CROSS_LINT_COMMAND).toContain(`echo '${CARGO_CROSS_LINT_REFUSAL}' >&2; exit 2`);
143
- });
144
-
145
- it('carries the triple explicitly so a host lint cannot pass for a cross one', () => {
146
- // The devenv profile deliberately exports no CARGO_BUILD_TARGET. Were the
147
- // triple ambient instead, running this target outside the cross shell would
148
- // lint the host and report green — a gate that cannot fail.
149
- expect(CARGO_CROSS_LINT_COMMAND).toContain('--target ');
150
- });
151
-
152
- it('preserves Cargo home configuration and its relative paths while linting', async () => {
153
- const root = await mkdtemp(join(tmpdir(), 'cargo-lint-config-'));
154
- const home = join(root, 'home');
155
- const project = join(root, 'project');
156
- try {
157
- await mkdir(home);
158
- await mkdir(join(project, 'src'), { recursive: true });
159
- await writeFile(join(home, 'config.toml'), '[env]\nCONFIG_DATA = { value = "data.txt", relative = true }\n');
160
- await writeFile(join(root, 'data.txt'), 'configuration-relative data\n');
161
- await writeFile(
162
- join(project, 'Cargo.toml'),
163
- '[package]\nname = "config-fixture"\nversion = "0.1.0"\nedition = "2021"\n[workspace]\n',
164
- );
165
- await writeFile(
166
- join(project, 'Cargo.lock'),
167
- 'version = 4\n\n[[package]]\nname = "config-fixture"\nversion = "0.1.0"\n',
168
- );
169
- await writeFile(join(project, 'src/lib.rs'), 'pub const DATA: &str = include_str!(env!("CONFIG_DATA"));\n');
170
- const child = Bun.spawn(['sh', '-c', CARGO_LINT_CLIPPY_COMMAND], {
171
- cwd: project,
172
- env: { ...process.env, CARGO_HOME: home, RUSTC_WRAPPER: '', RUSTC_WORKSPACE_WRAPPER: '' },
173
- stdout: 'pipe',
174
- stderr: 'pipe',
175
- });
176
- const [exitCode, stdout, stderr] = await Promise.all([
177
- child.exited,
178
- new Response(child.stdout).text(),
179
- new Response(child.stderr).text(),
180
- ]);
181
- expect({ exitCode, output: stdout + stderr }).toMatchObject({ exitCode: 0 });
182
- } finally {
183
- await rm(root, { recursive: true, force: true });
184
- }
185
- });
186
-
187
- it('pins clippy to the committed lockfile and local cache', () => {
188
- expect(cargoFrozen('clippy --workspace')).toBe('cargo --frozen clippy --workspace');
189
- // cargo drops a global --frozen in front of an external subcommand, so the
190
- // flag sits on cargo-zigbuild's own subcommand.
191
- expect(CARGO_CROSS_LINT_COMMAND).toContain('cargo-zigbuild clippy --frozen ');
192
- expect(CARGO_CROSS_LINT_COMMAND).not.toContain('cargo --frozen zigbuild');
193
- expect(CARGO_LINT_CLIPPY_COMMAND).toContain('cargo --frozen clippy');
194
- // Inference recognizes both spellings, so both get the fetch prerequisite
195
- // and the toolchain identity.
196
- expect(runsFrozenCargo(CARGO_CROSS_LINT_COMMAND)).toBe(true);
197
- expect(runsFrozenCargo(CARGO_LINT_CLIPPY_COMMAND)).toBe(true);
198
- expect(runsFrozenCargo('cargo clippy --workspace')).toBe(false);
199
- });
200
-
201
- it('drives the Nx target through the cross profile from the root script', () => {
202
- expect(CROSS_CHECK_SCRIPT_NAME).toBe('check:linux');
203
- // Activates the profile...
204
- expect(CROSS_CHECK_SCRIPT_COMMAND).toContain(`-P ${DEVENV_CROSS_PROFILE}`);
205
- // ...via the managed wrapper, so it resolves devenv config in any fleet repo...
206
- expect(CROSS_CHECK_SCRIPT_COMMAND).toStartWith('tooling/devenv ');
207
- // ...and runs Nx rather than cargo directly, so caching and project
208
- // discovery stay Nx's job.
209
- expect(CROSS_CHECK_SCRIPT_COMMAND).toContain(`nx run-many -t ${CARGO_CROSS_LINT_TARGET}`);
210
- // The pre-push gate never enters the cross profile, so a human does — and
211
- // devenv's own progress has to reach them, or a 0.9 GiB toolchain closure
212
- // and an unbounded clippy are indistinguishable from a hang.
213
- expect(CROSS_CHECK_SCRIPT_COMMAND).not.toContain('--quiet');
214
- });
215
-
216
- it('uses the verb:qualifier root script convention', () => {
217
- expect(CROSS_CHECK_SCRIPT_NAME).toMatch(/^[a-z]+:[a-z-]+$/);
218
- });
219
- });
220
-
221
- /**
222
- * The managed pre-push hook, run for real in a fixture repository whose `tooling/direnv/repo-path` puts stand-ins
223
- * first on PATH: `uname` says Darwin, `smoo` passes the denylist, `direnv` enters the checkout's environment, and `nx`
224
- * prints what a cross run printed and exits with its status, refusing to run in any environment but the checkout's.
225
- * The hook must ask in the checkout's environment and call a miss a miss and every other failure what it is.
226
- */
227
- describe('managed pre-push cross probe', () => {
228
- const hook = join(import.meta.dir, '../managed/raw/tooling/git-hooks/pre-push.sh');
229
- /** The SDK the checkout's environment names; the caller's shell names another. */
230
- const CHECKOUT_SDK = '/checkout/MacOSX.sdk';
231
-
232
- interface Push {
233
- readonly nxOutput: string;
234
- readonly nxStatus: number;
235
- /** Whether direnv is on the hook's PATH. */
236
- readonly direnv?: boolean;
237
- }
238
-
239
- async function push({ nxOutput, nxStatus, direnv = true }: Push): Promise<{ status: number | null; stderr: string }> {
240
- const root = await mkdtemp(join(tmpdir(), 'pre-push-cross-'));
241
- try {
242
- const bin = join(root, 'bin');
243
- await mkdir(bin);
244
- await mkdir(join(root, 'repo', 'tooling', 'direnv'), { recursive: true });
245
- const stub = async (name: string, body: string) => {
246
- await writeFile(join(bin, name), `#!/bin/sh\n${body}\n`);
247
- await chmod(join(bin, name), 0o755);
248
- };
249
- await stub('uname', 'echo Darwin');
250
- await stub('smoo', 'exit 0');
251
- // Nx keys on the environment it runs in: outside the checkout's, it is not the gate's run.
252
- await stub(
253
- 'nx',
254
- `[ "$SDKROOT" = '${CHECKOUT_SDK}' ] || { echo "nx stub: keyed on the caller's SDKROOT $SDKROOT" >&2; exit 1; }\nprintf '%s\\n' "$NX_STUB_OUTPUT"; exit ${nxStatus}`,
255
- );
256
- if (direnv) {
257
- // The checkout's .envrc: `direnv exec <checkout>` enters the environment that checkout declares.
258
- await stub(
259
- 'direnv',
260
- `[ "$1" = exec ] && [ "$2" = "$PWD" ] || { echo "direnv stub: unexpected $*" >&2; exit 64; }\nexport SDKROOT='${CHECKOUT_SDK}'\nshift 2\nexec "$@"`,
261
- );
262
- }
263
- // Without direnv, PATH holds the stand-ins alone: no host direnv is found, and no coreutils either, as on a
264
- // Nix-built Linux host whose /usr/bin and /bin hold none. The refusal must still be said.
265
- const path = direnv ? `${bin}:$PATH` : bin;
266
- await writeFile(join(root, 'repo', 'tooling', 'direnv', 'repo-path'), `#!/bin/sh\necho "${path}"\n`);
267
- await chmod(join(root, 'repo', 'tooling', 'direnv', 'repo-path'), 0o755);
268
- await writeFile(join(root, 'repo', 'tooling', 'direnv', 'ttsc-env.sh'), '');
269
- expect(spawnSync('git', ['init', '-q', join(root, 'repo')]).status).toBe(0);
270
- const run = spawnSync('bash', [hook, 'origin'], {
271
- cwd: join(root, 'repo'),
272
- // The caller's shell carries another directory's SDK, as a shell inside a parent directory's devenv does.
273
- env: { ...process.env, NX_STUB_OUTPUT: nxOutput, SDKROOT: '/nix/store/caller-apple-sdk/MacOSX.sdk' },
274
- input: '',
275
- encoding: 'utf8',
276
- });
277
- return { status: run.status, stderr: run.stderr };
278
- } finally {
279
- await rm(root, { recursive: true, force: true });
280
- }
281
- }
282
-
283
- it("passes a hit, asked in the checkout's environment rather than the caller's", async () => {
284
- const { status, stderr } = await push({ nxOutput: 'Successfully ran target cargo-lint-cross', nxStatus: 0 });
285
- expect(stderr).not.toContain("keyed on the caller's SDKROOT");
286
- expect(status).toBe(0);
287
- });
288
-
289
- it('names a miss when the cross target refused to compile', async () => {
290
- const { status, stderr } = await push({ nxOutput: CARGO_CROSS_LINT_REFUSAL, nxStatus: 1 });
291
- expect(status).toBe(1);
292
- expect(stderr).toContain('NOT cached for this tree');
293
- expect(stderr).toContain('bun run check:linux');
294
- });
295
-
296
- it('names any other failure as that, never as a cache miss', async () => {
297
- const { status, stderr } = await push({
298
- nxOutput: 'NX NX_WORKSPACE_ROOT_PATH names another workspace',
299
- nxStatus: 1,
300
- });
301
- expect(status).toBe(1);
302
- expect(stderr).toContain('failed (exit 1) before it reached');
303
- expect(stderr).not.toContain('NOT cached');
304
- });
305
-
306
- it("refuses, naming direnv, when it cannot enter the checkout's environment", async () => {
307
- const { status, stderr } = await push({
308
- nxOutput: 'Successfully ran target cargo-lint-cross',
309
- nxStatus: 0,
310
- direnv: false,
311
- });
312
- expect(status).toBe(1);
313
- expect(stderr).toContain('direnv is not on PATH');
314
- expect(stderr).not.toContain('NOT cached');
315
- });
316
- });
@@ -1,61 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { directDiskCommands, PHYSICAL_BOOT_LAYER } from './disk-command-policy.js';
3
-
4
- const imageTool = '/usr/bin/hdiutil';
5
- const diskTool = '/usr/sbin/diskutil';
6
-
7
- describe('disk-image execution boundary', () => {
8
- it('rejects direct process calls in Rust, Node, Python and shell, including aliases', () => {
9
- for (const source of [
10
- `Command::new("${imageTool}").args(["attach", image]);`,
11
- `const PROGRAM: &str = "${diskTool}"; Command::new(PROGRAM);`,
12
- `const executable = '${imageTool}'; spawn(executable, ['attach', image]);`,
13
- `execFileSync('${diskTool}', ['image', 'attach', image]);`,
14
- `Bun.spawn(['${imageTool}', 'attach', image]);`,
15
- `Bun.spawn({ cmd: ['${imageTool}', 'attach', image] });`,
16
- `argv = ['${diskTool}', 'eject', device]\nsubprocess.run(argv)`,
17
- `subprocess.run(['${diskTool}', 'image', 'attach', image]);`,
18
- `sh(['${diskTool}', 'eject', device])`,
19
- `$\`${imageTool} detach \${device}\``,
20
- `#!/bin/sh\n${imageTool} attach "$image"`,
21
- `info=$(${diskTool} info -plist "$device")`,
22
- ]) {
23
- expect(directDiskCommands(source).length, source).toBeGreaterThan(0);
24
- }
25
- });
26
-
27
- it('allows the shared command layer, its Nx adapter, and declarative command requests', () => {
28
- for (const source of [
29
- `SystemCommandRunner.run(&CommandRequest::new("${imageTool}", ["detach", device]));`,
30
- `host.run('${diskTool}', ['image', 'attach', image]);`,
31
- `this.commands.run('${imageTool}', ['attach', image]);`,
32
- `subprocess.run(['cowshed', 'disk-command', '${diskTool}', '--', 'info']);`,
33
- '$`cowshed disk-command hdiutil -- detach "$device"`',
34
- `// ${imageTool} attach is prohibited\n/* Command::new("${diskTool}") */`,
35
- `"""Measure \`${diskTool} image attach\` and \`${imageTool} detach\`."""`,
36
- `format!("retry with \`${imageTool} detach\`; this message executes nothing");`,
37
- `{"op":"disk-lease","command":"${imageTool} detach /dev/disk9"}`,
38
- ]) {
39
- expect(directDiskCommands(source), source).toEqual([]);
40
- }
41
- });
42
-
43
- it('admits only the fixed physical-volume boot commands in their owning layer', () => {
44
- const boot = [
45
- `info=$(${diskTool} info -plist "$uuid")`,
46
- `| ${diskTool} apfs unlockVolume "$uuid" -nomount -stdinpassphrase`,
47
- `${diskTool} mount -nobrowse -mountPoint "$mountpoint" "$uuid"`,
48
- ].join('\n');
49
- expect(directDiskCommands(boot, PHYSICAL_BOOT_LAYER)).toEqual([]);
50
- expect(directDiskCommands(boot, 'elsewhere.sh').length).toBeGreaterThan(0);
51
- for (const verb of ['image attach', 'image create', 'attach', 'detach', 'eject']) {
52
- expect(directDiskCommands(`${diskTool} ${verb} "$image"`, PHYSICAL_BOOT_LAYER)).toEqual([1]);
53
- expect(directDiskCommands(`${imageTool} ${verb} "$image"`, PHYSICAL_BOOT_LAYER)).toEqual([1]);
54
- }
55
- expect(directDiskCommands(`HostCommand::new("${diskTool}", ["image", "attach", path])`)).toEqual([1]);
56
- });
57
-
58
- it('reports the source line, retaining multiline comment offsets', () => {
59
- expect(directDiskCommands(`/* example\nnot executed */\nspawn('${imageTool}', []);`)).toEqual([3]);
60
- });
61
- });
@@ -1,279 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
2
- import { createHash } from 'node:crypto';
3
- import { chmod, lstat, mkdir, mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import type { Task } from 'nx/src/config/task-graph';
7
- import { expandOutputs } from 'nx/src/native';
8
- import { cargoRuntimeInput } from './cargo-toolchain-policy.js';
9
- import type { EnsureBuiltProducerReceipt } from './ensure-built.js';
10
- import {
11
- boundedReceiptRuntimes,
12
- captureProducerSource,
13
- dirtyProviderPaths,
14
- type ProducerSourceWitness,
15
- type ProviderInputProof,
16
- producerOutputPaths,
17
- producerSourceUnchanged,
18
- providerReceipt,
19
- } from './ensure-built-receipt.js';
20
-
21
- let root = '';
22
- let source: ProducerSourceWitness;
23
- let producer: Omit<EnsureBuiltProducerReceipt, 'outputSha256'>;
24
- const task = {
25
- id: 'app:build',
26
- target: { project: 'app', target: 'build' },
27
- overrides: {},
28
- outputs: ['output'],
29
- cache: true,
30
- hash: 'current-key',
31
- } satisfies Task;
32
- const inputs = { files: ['source.txt'], runtime: [], environment: [], depOutputs: [], external: [] };
33
- const proof: ProviderInputProof = {
34
- kind: 'exact-file-inputs',
35
- files: ['source.txt'],
36
- inputs: { [task.id]: inputs },
37
- runtimeSource: { kind: 'bounded' },
38
- };
39
- function git(...args: string[]): void {
40
- const result = Bun.spawnSync(['git', '-C', root, ...args], { stderr: 'pipe' });
41
- expect(result.exitCode, result.stderr.toString()).toBe(0);
42
- }
43
-
44
- beforeEach(async () => {
45
- root = await realpath(await mkdtemp(join(tmpdir(), 'ensure-built-receipt-')));
46
- git('init', '--quiet');
47
- await writeFile(join(root, '.gitignore'), 'output/\n');
48
- await writeFile(join(root, 'source.txt'), 'source');
49
- git('add', '.');
50
- git('-c', 'user.name=Receipt fixture', '-c', 'user.email=receipt@example.invalid', 'commit', '-qm', 'fixture');
51
- await mkdir(join(root, 'output/empty'), { recursive: true });
52
- await writeFile(join(root, 'output/file'), 'public bytes');
53
- await symlink('file', join(root, 'output/link'));
54
- await chmod(join(root, 'output/file'), 0o644);
55
- await chmod(join(root, 'output/empty'), 0o755);
56
- const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
57
- if (!captured.ok) throw new Error(captured.detail);
58
- source = captured.value;
59
- producer = {
60
- version: 1,
61
- target: task.id,
62
- argv: ['nx', 'run', task.id],
63
- trackedTreeClean: true,
64
- environmentIdentity: 'unit-fixture-nx-hash-identity',
65
- tools: [],
66
- wallTimeMs: 0,
67
- inputs: [
68
- {
69
- taskId: task.id,
70
- overrides: task.overrides,
71
- declared: [],
72
- expanded: inputs,
73
- hashDetails: { command: 'unit-fixture', nodes: {} },
74
- files: source.files.filter(({ path }) => inputs.files.includes(path)),
75
- },
76
- ],
77
- };
78
- });
79
- afterEach(async () => {
80
- await rm(root, { recursive: true, force: true });
81
- });
82
-
83
- describe('provider receipt', () => {
84
- it('does not borrow the caller Git directory/index/object namespace for provider provenance', () => {
85
- const saved = process.env.GIT_DIR;
86
- process.env.GIT_DIR = join(root, 'not-the-provider-git-directory');
87
- try {
88
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
89
- } finally {
90
- if (saved === undefined) delete process.env.GIT_DIR;
91
- else process.env.GIT_DIR = saved;
92
- }
93
- });
94
- it("reads provider provenance without the operator's global git configuration", async () => {
95
- // The cowshed sandbox denies the operator's global git configuration to a workspace's Nx daemon, which runs these
96
- // hooks under a host client's HOME; git then dies "unable to access". A self-referencing link fails git the same
97
- // way (ELOOP), where an unreadable file would only warn (EACCES).
98
- const home = join(root, 'operator-home');
99
- await mkdir(home);
100
- await symlink('.gitconfig', join(home, '.gitconfig'));
101
- const names = ['HOME', 'XDG_CONFIG_HOME', 'GIT_CONFIG_GLOBAL', 'GIT_CONFIG_NOSYSTEM'] as const;
102
- const saved = names.map((name) => [name, process.env[name]] as const);
103
- for (const name of names) delete process.env[name];
104
- process.env.HOME = home;
105
- try {
106
- const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
107
- expect(captured.ok ? 'captured' : captured.detail).toBe('captured');
108
- expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
109
- } finally {
110
- for (const [name, value] of saved) {
111
- if (value === undefined) delete process.env[name];
112
- else process.env[name] = value;
113
- }
114
- }
115
- });
116
- it('names current hashes, HEAD/tree, independent file digests, link text and empty directory modes', async () => {
117
- const result = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
118
- expect(result.disposition).toBe('hit');
119
- if (result.disposition !== 'hit') throw new Error(result.reason.detail);
120
- expect(result.receipt.head).toMatch(/^[a-f0-9]{40,64}$/);
121
- expect(result.receipt.headTree).toMatch(/^[a-f0-9]{40,64}$/);
122
- expect(result.receipt.workspaceRoot).toBe(root);
123
- expect(result.receipt.runtimeEnvironmentProvenance).toBe('nx-task-hash-only');
124
- expect(result.receipt.tasks[0].id).toBe(task.id);
125
- expect(result.receipt.tasks[0].hash).toBe(task.hash);
126
- expect(result.receipt.tasks[0].outputs).toContainEqual({
127
- path: 'output/file',
128
- type: 'file',
129
- mode: 0o644,
130
- sha256: createHash('sha256').update('public bytes').digest('hex'),
131
- });
132
- expect(result.receipt.tasks[0].outputs).toContainEqual({
133
- path: 'output/link',
134
- type: 'symlink',
135
- mode: (await lstat(join(root, 'output/link'))).mode & 0o7777,
136
- linkText: 'file',
137
- });
138
- expect(result.receipt.tasks[0].outputs.find(({ path }) => path === 'output/empty')).toMatchObject({
139
- type: 'directory',
140
- mode: 0o755,
141
- entries: [],
142
- });
143
- });
144
-
145
- it('ignores unrelated untracked files while retaining tracked-tree production provenance', async () => {
146
- await writeFile(join(root, 'unrelated.ts'), 'unrelated');
147
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
148
- expect(
149
- providerReceipt(
150
- root,
151
- task.id,
152
- [task],
153
- { ...proof, kind: 'conservative-provider-source' },
154
- expandOutputs,
155
- source,
156
- producer,
157
- ).disposition,
158
- ).toBe('hit');
159
- });
160
-
161
- it('refuses modified, deleted, newly matched and index-only dirty FILE inputs', async () => {
162
- await writeFile(join(root, 'source.txt'), 'changed');
163
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
164
- git('add', 'source.txt');
165
- await writeFile(join(root, 'source.txt'), 'source');
166
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
167
- git('restore', '--staged', 'source.txt');
168
- await writeFile(join(root, 'new-source.txt'), 'new');
169
- expect(
170
- providerReceipt(
171
- root,
172
- task.id,
173
- [task],
174
- { ...proof, files: [...proof.files, 'new-source.txt'] },
175
- expandOutputs,
176
- source,
177
- producer,
178
- ).disposition,
179
- ).toBe('failed');
180
- await rm(join(root, 'source.txt'));
181
- expect(
182
- providerReceipt(root, task.id, [task], { ...proof, files: [] }, expandOutputs, source, producer).disposition,
183
- ).toBe('failed');
184
- });
185
-
186
- it('recomputes output byte/directory identities after every public mutation', async () => {
187
- const first = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
188
- if (first.disposition !== 'hit') throw new Error(first.reason.detail);
189
- await writeFile(join(root, 'output/file'), 'PUBLIC BYTES');
190
- await chmod(join(root, 'output/empty'), 0o700);
191
- const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
192
- if (next.disposition !== 'hit') throw new Error(next.reason.detail);
193
- expect(next.receipt.tasks[0].outputs).not.toEqual(first.receipt.tasks[0].outputs);
194
- expect(next.receipt.tasks[0].outputs.find(({ path }) => path === 'output/empty')).toMatchObject({ mode: 0o700 });
195
- });
196
-
197
- it('accepts a new HEAD at the same committed tree without rewriting the producer basis', () => {
198
- const original = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
199
- if (original.disposition !== 'hit') throw new Error(original.reason.detail);
200
- git(
201
- '-c',
202
- 'user.name=Receipt fixture',
203
- '-c',
204
- 'user.email=receipt@example.invalid',
205
- 'commit',
206
- '--allow-empty',
207
- '-qm',
208
- 'same tree',
209
- );
210
- expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
211
- const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
212
- if (next.disposition !== 'hit') throw new Error(next.reason.detail);
213
- expect(next.receipt.head).toBe(original.receipt.head);
214
- expect(next.receipt.headTree).toBe(original.receipt.headTree);
215
- expect(next.receipt.producer.outputSha256).toBe(original.receipt.producer.outputSha256);
216
- });
217
- it('revokes a producer pre-source witness for a write/revert even when final bytes match HEAD', async () => {
218
- await writeFile(join(root, 'source.txt'), 'edited');
219
- await writeFile(join(root, 'source.txt'), 'source');
220
- expect(producerSourceUnchanged(root, source).ok).toBe(false);
221
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
222
- });
223
- it('refuses unreadable public bytes, missing outputs and opaque runtime closure', async () => {
224
- await chmod(join(root, 'output/file'), 0);
225
- try {
226
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
227
- } finally {
228
- await chmod(join(root, 'output/file'), 0o600);
229
- }
230
- await rm(join(root, 'output'), { recursive: true });
231
- expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
232
- expect(
233
- providerReceipt(
234
- root,
235
- task.id,
236
- [task],
237
- { ...proof, runtimeSource: { kind: 'opaque', detail: 'unnameable command input closure' } },
238
- expandOutputs,
239
- source,
240
- producer,
241
- ),
242
- ).toMatchObject({
243
- disposition: 'failed',
244
- reason: { kind: 'provider-proof', detail: 'unnameable command input closure' },
245
- });
246
- });
247
- });
248
-
249
- describe('receipt runtime provenance', () => {
250
- it('admits only the existing generated pinned toolchain-version recipe, never a command containing the same words', () => {
251
- const recipe = cargoRuntimeInput('packages/app', 'rustc -vV && cargo -V').runtime;
252
- const planned = { [task.id]: { ...inputs, runtime: [recipe] } };
253
- expect(boundedReceiptRuntimes(planned, ['packages/app'], ['devenv.lock'], true)).toEqual({ kind: 'bounded' });
254
- expect(boundedReceiptRuntimes(planned, ['packages/app'], [], true).kind).toBe('opaque');
255
- expect(boundedReceiptRuntimes(planned, ['packages/app'], ['devenv.lock'], false).kind).toBe('opaque');
256
- expect(
257
- boundedReceiptRuntimes(
258
- { [task.id]: { ...inputs, runtime: [recipe + '; cat /unproved/external'] } },
259
- ['packages/app'],
260
- ['devenv.lock'],
261
- true,
262
- ).kind,
263
- ).toBe('opaque');
264
- expect(
265
- boundedReceiptRuntimes(
266
- { [task.id]: { ...inputs, runtime: ['sh arbitrary-source-reader.sh'] } },
267
- ['packages/app'],
268
- ['devenv.lock'],
269
- true,
270
- ).kind,
271
- ).toBe('opaque');
272
- });
273
-
274
- it('preserves whitespace, both sides of renames, deletion and index-only status paths', () => {
275
- expect(
276
- dirtyProviderPaths(' M source with spaces.ts\0R new.ts\0old.ts\0D deleted.ts\0?? new-source.ts\0'),
277
- ).toEqual(['source with spaces.ts', 'new.ts', 'old.ts', 'deleted.ts', 'new-source.ts']);
278
- });
279
- });