@smoothbricks/nx-plugin 0.4.26 → 0.4.27

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 (343) hide show
  1. package/README.md +994 -117
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +15 -73
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +3 -2
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +16 -15
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +43 -6
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +309 -73
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +101 -5
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +291 -10
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +207 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +576 -202
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +370 -138
  102. package/dist/managed-files/ci-workflow.d.ts +13 -0
  103. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.js +44 -13
  105. package/dist/managed-files/files.d.ts +7 -1
  106. package/dist/managed-files/files.d.ts.map +1 -1
  107. package/dist/managed-files/files.js +62 -8
  108. package/dist/managed-files/json-edit.d.ts +21 -0
  109. package/dist/managed-files/json-edit.d.ts.map +1 -0
  110. package/dist/managed-files/json-edit.js +295 -0
  111. package/dist/managed-files/managed-format.d.ts +33 -1
  112. package/dist/managed-files/managed-format.d.ts.map +1 -1
  113. package/dist/managed-files/managed-format.js +82 -2
  114. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  115. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  116. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  117. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/publish-workflow.js +231 -48
  119. package/dist/managed-files/tree.d.ts +5 -0
  120. package/dist/managed-files/tree.d.ts.map +1 -1
  121. package/dist/managed-files/tree.js +5 -3
  122. package/dist/manifest-hash.d.ts.map +1 -1
  123. package/dist/manifest-hash.js +2 -5
  124. package/dist/nextest-code-bound.d.ts +62 -0
  125. package/dist/nextest-code-bound.d.ts.map +1 -0
  126. package/dist/nextest-code-bound.js +154 -0
  127. package/dist/nextest-extraction.d.ts +24 -8
  128. package/dist/nextest-extraction.d.ts.map +1 -1
  129. package/dist/nextest-extraction.js +42 -7
  130. package/dist/package-target-policy.d.ts.map +1 -1
  131. package/dist/package-target-policy.js +3 -5
  132. package/dist/release-config-policy.d.ts.map +1 -1
  133. package/dist/release-config-policy.js +3 -5
  134. package/dist/runtime-input.d.ts +14 -0
  135. package/dist/runtime-input.d.ts.map +1 -0
  136. package/dist/runtime-input.js +15 -0
  137. package/dist/rust-tokens.d.ts +11 -0
  138. package/dist/rust-tokens.d.ts.map +1 -0
  139. package/dist/rust-tokens.js +81 -0
  140. package/dist/task-results.d.ts +6 -0
  141. package/dist/task-results.d.ts.map +1 -0
  142. package/dist/task-results.js +61 -0
  143. package/dist/test-program.d.ts +54 -0
  144. package/dist/test-program.d.ts.map +1 -0
  145. package/dist/test-program.js +292 -0
  146. package/dist/test-timings.d.ts +71 -0
  147. package/dist/test-timings.d.ts.map +1 -0
  148. package/dist/test-timings.js +393 -0
  149. package/dist/test-walk-policy.d.ts +103 -0
  150. package/dist/test-walk-policy.d.ts.map +1 -0
  151. package/dist/test-walk-policy.js +657 -0
  152. package/dist/testing.d.ts +177 -0
  153. package/dist/testing.d.ts.map +1 -0
  154. package/dist/testing.js +824 -0
  155. package/dist/type-guards.d.ts +3 -0
  156. package/dist/type-guards.d.ts.map +1 -0
  157. package/dist/type-guards.js +4 -0
  158. package/dist/typecheck-test-policy.d.ts +8 -5
  159. package/dist/typecheck-test-policy.d.ts.map +1 -1
  160. package/dist/typecheck-test-policy.js +113 -100
  161. package/dist/workspace-config-policy.d.ts +8 -0
  162. package/dist/workspace-config-policy.d.ts.map +1 -1
  163. package/dist/workspace-config-policy.js +175 -63
  164. package/dist/workspace-index.d.ts +12 -0
  165. package/dist/workspace-index.d.ts.map +1 -0
  166. package/dist/workspace-index.js +17 -0
  167. package/dist/workspace-manifest.d.ts +37 -0
  168. package/dist/workspace-manifest.d.ts.map +1 -1
  169. package/executors.json +5 -0
  170. package/loader.js +13 -11
  171. package/managed/raw/envrc +33 -67
  172. package/managed/raw/git-format-staged.yml +30 -35
  173. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  174. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  175. package/managed/raw/tooling/direnv/developer-links.ts +569 -11
  176. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
  177. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  178. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  179. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  180. package/managed/raw/tooling/direnv/repo-path +14 -2
  181. package/managed/raw/tooling/direnv/setup-environment.ts +962 -148
  182. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  183. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  184. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  185. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  186. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  187. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  188. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  189. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  190. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  191. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  192. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  194. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  196. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  197. package/managed/templates/github/workflows/managed-files.yml +1 -2
  198. package/nextest.toml +8 -41
  199. package/package.json +74 -12
  200. package/runtime-input.sh +81 -0
  201. package/src/__tests__/counted-cargo.ts +33 -14
  202. package/src/__tests__/fixture-nx-env.ts +111 -46
  203. package/src/__tests__/progress-clock.ts +43 -0
  204. package/src/__tests__/runtime-input.ts +23 -0
  205. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  206. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  207. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  208. package/src/bin/smoo-nx-exec.ts +16 -74
  209. package/src/bin/smoo-nx-failures.ts +4 -0
  210. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  211. package/src/bin/smoo-nx-test-walks.ts +42 -0
  212. package/src/bounded-test-policy.test.ts +268 -21
  213. package/src/bounded-test-policy.ts +114 -42
  214. package/src/build-state-output-policy.test.ts +115 -0
  215. package/src/build-state-output-policy.ts +90 -0
  216. package/src/bun-bootstrap.test.ts +57 -3
  217. package/src/bun-file-packages.test.ts +47 -0
  218. package/src/cargo-closure-input.test.ts +138 -66
  219. package/src/cargo-closure-input.ts +17 -15
  220. package/src/cargo-dev-profile.ts +137 -0
  221. package/src/cargo-resolve-cache.test.ts +70 -1
  222. package/src/cargo-source-hash.test.ts +193 -97
  223. package/src/cargo-source-hash.ts +345 -68
  224. package/src/cargo-toolchain-policy.ts +6 -0
  225. package/src/cargo-workspace.test.ts +320 -0
  226. package/src/cargo-workspace.ts +336 -10
  227. package/src/cross-check-policy.test.ts +59 -1
  228. package/src/cross-check-policy.ts +25 -6
  229. package/src/disk-command-policy.test.ts +61 -0
  230. package/src/disk-command-policy.ts +107 -0
  231. package/src/ensure-built-receipt.test.ts +184 -0
  232. package/src/ensure-built-receipt.ts +263 -0
  233. package/src/ensure-built-witness.test.ts +344 -0
  234. package/src/ensure-built-witness.ts +252 -0
  235. package/src/ensure-built.test.ts +1036 -578
  236. package/src/ensure-built.ts +820 -224
  237. package/src/eslint-file-set.ts +9 -0
  238. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  239. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  240. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  241. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  242. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  243. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  244. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  245. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  246. package/src/executors/bounded-exec/executor.ts +565 -67
  247. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  248. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  249. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  250. package/src/executors/bounded-exec/progress.test.ts +79 -0
  251. package/src/executors/bounded-exec/progress.ts +118 -0
  252. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  253. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  254. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  255. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  256. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  257. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  258. package/src/executors/bounded-exec/schema.json +11 -5
  259. package/src/executors/bounded-exec/schema.ts +27 -11
  260. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  261. package/src/executors/bounded-exec/verdict.ts +433 -0
  262. package/src/executors/shard-timings/executor.ts +36 -0
  263. package/src/executors/shard-timings/schema.json +21 -0
  264. package/src/executors/shard-timings/schema.ts +4 -0
  265. package/src/failure-summary.ts +119 -0
  266. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  267. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  268. package/src/generators/create-package/generator.test.ts +6 -0
  269. package/src/generators/create-package/generator.ts +6 -2
  270. package/src/host-controller-wiring.test.ts +31 -0
  271. package/src/index.test.ts +909 -295
  272. package/src/index.ts +441 -143
  273. package/src/linked-snapshots.nx.test.ts +172 -0
  274. package/src/managed-files/ci-workflow.ts +54 -13
  275. package/src/managed-files/files.ts +65 -9
  276. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  277. package/src/managed-files/generator.test.ts +60 -1
  278. package/src/managed-files/json-edit.test.ts +216 -0
  279. package/src/managed-files/json-edit.ts +290 -0
  280. package/src/managed-files/managed-format-json.test.ts +308 -0
  281. package/src/managed-files/managed-format.ts +90 -2
  282. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  283. package/src/managed-files/publish-workflow.ts +285 -67
  284. package/src/managed-files/repo-path.test.ts +129 -0
  285. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  286. package/src/managed-files/tree.ts +11 -3
  287. package/src/manifest-hash.ts +2 -6
  288. package/src/nextest-code-bound.test.ts +155 -0
  289. package/src/nextest-code-bound.ts +195 -0
  290. package/src/nextest-extraction.test.ts +37 -5
  291. package/src/nextest-extraction.ts +51 -9
  292. package/src/nextest-partitions.test.ts +427 -82
  293. package/src/nx-cache-bound.test.ts +5 -10
  294. package/src/nx-cache-restore-mtime.test.ts +170 -0
  295. package/src/nx-daemon-claim.test.ts +277 -0
  296. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  297. package/src/nx-daemon-idle-policy.test.ts +51 -0
  298. package/src/nx-daemon-ignore-files.test.ts +210 -0
  299. package/src/nx-daemon-root-normalization.test.ts +105 -0
  300. package/src/nx-daemon-validity.test.ts +925 -0
  301. package/src/nx-dot-input-policy.test.ts +353 -0
  302. package/src/nx-failure-life-cycles.test.ts +207 -0
  303. package/src/nx-files-archive-racy.test.ts +97 -0
  304. package/src/nx-foreign-workspace-env.test.ts +329 -0
  305. package/src/nx-incomplete-run-summary.test.ts +70 -0
  306. package/src/nx-plugin-load-errors.test.ts +120 -0
  307. package/src/nx-project-resolution-cache.test.ts +176 -0
  308. package/src/nx-raw-inputs.test.ts +166 -0
  309. package/src/nx-resident-graph-workers.test.ts +7 -16
  310. package/src/nx-run-information.test.ts +118 -0
  311. package/src/nx-skipped-task-exit.test.ts +180 -0
  312. package/src/nx-state-location.test.ts +63 -0
  313. package/src/nx-store-resolution.test.ts +26 -25
  314. package/src/nx-task-graph-cycles.test.ts +148 -0
  315. package/src/nx-task-output-lease.test.ts +414 -0
  316. package/src/nx-use-local.test.ts +103 -0
  317. package/src/package-target-policy.ts +3 -6
  318. package/src/release-config-policy.ts +3 -6
  319. package/src/runtime-input.test.ts +215 -0
  320. package/src/runtime-input.ts +17 -0
  321. package/src/rust-tokens.ts +78 -0
  322. package/src/serial-group-wiring.test.ts +326 -0
  323. package/src/task-history-namespace.test.ts +87 -89
  324. package/src/task-results.test.ts +226 -0
  325. package/src/task-results.ts +75 -0
  326. package/src/test-program.test.ts +303 -0
  327. package/src/test-program.ts +341 -0
  328. package/src/test-timings.test.ts +240 -0
  329. package/src/test-timings.ts +311 -0
  330. package/src/test-walk-policy.test.ts +585 -0
  331. package/src/test-walk-policy.ts +731 -0
  332. package/src/testing.test.ts +509 -0
  333. package/src/testing.ts +922 -0
  334. package/src/type-guards.ts +4 -0
  335. package/src/typecheck-test-policy.test.ts +496 -11
  336. package/src/typecheck-test-policy.ts +137 -103
  337. package/src/workspace-config-policy.test.ts +212 -13
  338. package/src/workspace-config-policy.ts +101 -73
  339. package/src/workspace-index.ts +18 -0
  340. package/src/workspace-manifest.ts +41 -0
  341. package/test-timings.json +85 -30
  342. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
  343. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
@@ -4,6 +4,8 @@ import { dirname, isAbsolute, join, normalize, posix, relative, resolve, sep } f
4
4
  import { readNxJson } from 'nx/src/config/nx-json.js';
5
5
  import { parse as parseToml, type TomlTable } from 'smol-toml';
6
6
 
7
+ import { type CompiledCargoInput, compiledInFiles } from './cargo-source-hash.js';
8
+
7
9
  export interface CargoWorkspacePackage {
8
10
  name: string;
9
11
  dir: string;
@@ -237,11 +239,12 @@ export interface CargoPackageTestInputsOptions {
237
239
  export interface CargoInputsCache {
238
240
  readonly manifests: Map<string, Promise<TomlTable>>;
239
241
  readonly nestedCrateDirs: Map<string, string[]>;
242
+ readonly compiledInFiles: Map<string, CompiledCargoInput[]>;
240
243
  readonly results: Map<string, Promise<string[]>>;
241
244
  }
242
245
 
243
246
  export function createCargoInputsCache(): CargoInputsCache {
244
- return { manifests: new Map(), nestedCrateDirs: new Map(), results: new Map() };
247
+ return { manifests: new Map(), nestedCrateDirs: new Map(), compiledInFiles: new Map(), results: new Map() };
245
248
  }
246
249
 
247
250
  export function cargoPackageTestInputs(options: CargoPackageTestInputsOptions): Promise<string[]> {
@@ -390,6 +393,12 @@ async function deriveCargoPackageTestInputs(
390
393
  const childDir = relative(absoluteProjectRoot, child).split(sep).join('/');
391
394
  if (!dirs.has(childDir)) exclusions.add(`!${inputPath(child)}/**`);
392
395
  }
396
+ // `include_str!("../../../skills/SKILL.md")` compiles a file the package's own
397
+ // fileset does not reach; a target that does not hash it serves a binary
398
+ // built from the file's old bytes.
399
+ for (const { file } of compiledInFiles(absoluteDir, cache.compiledInFiles)) {
400
+ if (isOutsideRoot(relative(absoluteDir, file))) declaredSources.add(file);
401
+ }
393
402
  }
394
403
  for (const source of [...declaredSources].sort()) {
395
404
  const sourceRelative = relative(workspaceRoot, source);
@@ -632,8 +641,10 @@ export const CARGO_TEST_ARCHIVE_TARGET = 'cargo-test-archive';
632
641
  * does NOT create this parent directory and fails the whole build when it is
633
642
  * missing ("error writing to archive ... No such file or directory"), so the
634
643
  * target mkdir's it first.
644
+ * The archive is an Nx-restored output, so it lives on the source volume, never
645
+ * beneath Cargo's symlinked target directory (16_build_volumes.md).
635
646
  */
636
- export const CARGO_TEST_ARCHIVE_FILE = 'target/nextest/archive.tar.zst';
647
+ export const CARGO_TEST_ARCHIVE_FILE = '.cache/nextest/archive.tar.zst';
637
648
 
638
649
  /**
639
650
  * One foreign target triple this cargo workspace also archives its tests for.
@@ -725,13 +736,29 @@ export function listCargoCrossTestTargets(absoluteProjectRoot: string): CargoCro
725
736
  */
726
737
  export const CARGO_TEST_EXCEPTIONS_SUFFIX = 'exceptions';
727
738
 
739
+ /** Name prefix of the runner a serial test group gets; see `serialTestGroups`. */
740
+ export const CARGO_TEST_GROUP_PREFIX = 'cargo-test-group-';
741
+
728
742
  /**
729
743
  * A crate on one target keeps the bare name; a split crate suffixes the piece,
730
744
  * so `cargo-test-example-core-shard2` still reads as "example-core's tests".
731
745
  */
732
746
  export function cargoTestPackageTargetName(packageName: string, piece?: string): string {
733
747
  const base = `cargo-test-${packageName}`;
734
- return piece === undefined ? base : `${base}-${piece}`;
748
+ const name = piece === undefined ? base : `${base}-${piece}`;
749
+ // A crate named `group-*` would take the name of a serial group's runner.
750
+ if (name.startsWith(CARGO_TEST_GROUP_PREFIX)) {
751
+ throw new Error(`cargo crate ${packageName} would be named ${name}, reserved for a nextest test group runner`);
752
+ }
753
+ return name;
754
+ }
755
+
756
+ /**
757
+ * A serial group's runner. It selects by filter across the whole workspace, so
758
+ * it is no crate: `packageNameFromCargoTestTarget` reads it as none.
759
+ */
760
+ export function cargoTestGroupTargetName(group: string): string {
761
+ return `${CARGO_TEST_GROUP_PREFIX}${group}`;
735
762
  }
736
763
 
737
764
  /**
@@ -739,15 +766,17 @@ export function cargoTestPackageTargetName(packageName: string, piece?: string):
739
766
  * check that the per-crate targets cover every workspace member. Pieces of one
740
767
  * crate collapse back to that crate, so a split crate counts as covered once.
741
768
  *
742
- * The two workspace-wide `cargo-test-*` targets are not crates: reading them as
743
- * one would invent members named "compile" and "archive" and report every real
744
- * crate's coverage against a set that can never match.
769
+ * The workspace-wide `cargo-test-*` targets are not crates: reading them as one
770
+ * would invent members named "compile" and "archive", and a serial group's runner
771
+ * would invent one named after its group. Each reports every crate's coverage
772
+ * against a set that can never match.
745
773
  */
746
774
  export function packageNameFromCargoTestTarget(targetName: string): string | null {
747
775
  if (
748
776
  !targetName.startsWith('cargo-test-') ||
749
777
  targetName === CARGO_TEST_COMPILE_TARGET ||
750
- targetName === CARGO_TEST_ARCHIVE_TARGET
778
+ targetName === CARGO_TEST_ARCHIVE_TARGET ||
779
+ targetName.startsWith(CARGO_TEST_GROUP_PREFIX)
751
780
  ) {
752
781
  return null;
753
782
  }
@@ -789,10 +818,298 @@ export function exceptionalTestFilter(nextestConfigPath: string): string | null
789
818
  }
790
819
  }
791
820
  }
821
+ return filterUnion(filters);
822
+ }
823
+
824
+ /** The filters as one filterset that any of them matches, or null for none. */
825
+ function filterUnion(filters: readonly string[]): string | null {
792
826
  const unique = [...new Set(filters)];
793
827
  return unique.length === 0 ? null : unique.map((filter) => `(${filter})`).join(' or ');
794
828
  }
795
829
 
830
+ /**
831
+ * The only `platform` a serial group's overrides may declare: nextest's cfg for macOS. The group
832
+ * runs on macOS hosts only, a host decision made by the planner, never a cfg parse here.
833
+ */
834
+ export const SERIAL_TEST_GROUP_PLATFORM = 'cfg(target_os="macos")';
835
+
836
+ /**
837
+ * Which workspace members a serial group's filter can select tests from: exactly the named
838
+ * packages when every clause of the filter is scoped to one, otherwise every member.
839
+ */
840
+ export type SerialTestGroupScope =
841
+ | { readonly kind: 'packages'; readonly packages: readonly string[] }
842
+ | { readonly kind: 'workspace' };
843
+
844
+ /**
845
+ * One nextest test group capped at a single thread, and the tests its overrides
846
+ * assign it.
847
+ */
848
+ export interface SerialTestGroup {
849
+ /** The group's name, as `[test-groups]` declares it. */
850
+ group: string;
851
+ /** Every default-profile override filter that names the group, as one filterset. */
852
+ filter: string;
853
+ /** The members the filter can select from, which are the members whose sources its runner hashes. */
854
+ scope: SerialTestGroupScope;
855
+ }
856
+
857
+ /**
858
+ * The repository's test groups capped at one thread (`max-threads = 1`), each
859
+ * with the tests its default-profile overrides assign it.
860
+ *
861
+ * A serial group is declared exactly once, in `.config/nextest.toml`: the name
862
+ * under `[test-groups]` plus the overrides that name it. Its runner's filter is
863
+ * derived from those overrides rather than restated, so the runner and the
864
+ * per-crate exclusions cannot drift from what nextest actually serializes.
865
+ *
866
+ * Each group also carries the `scope` of its filter (`filterScope`): the members its runner hashes.
867
+ * A group whose every clause is scoped to a `package(<name>)` reruns only when those crates or their
868
+ * local dependencies change; any other group is scoped to the whole workspace. Nothing here orders one
869
+ * group against another: they are separate runners, and a repository that needs two never concurrent
870
+ * declares the edge between their targets itself.
871
+ *
872
+ * Every override naming a serial group must declare `SERIAL_TEST_GROUP_PLATFORM`.
873
+ * This plugin has no cfg evaluator, so it honours exactly that platform and
874
+ * refuses any other rather than guessing where the group applies.
875
+ *
876
+ * Returns [] when the file is absent or declares no serial group, so a workspace
877
+ * without one keeps exactly its existing targets.
878
+ */
879
+ export function serialTestGroups(nextestConfigPath: string): SerialTestGroup[] {
880
+ if (!existsSync(nextestConfigPath)) {
881
+ return [];
882
+ }
883
+ const parsed: unknown = parseToml(readFileSync(nextestConfigPath, 'utf-8'));
884
+ if (!isRecord(parsed)) {
885
+ return [];
886
+ }
887
+ const declaredValue = parsed['test-groups'];
888
+ const declaredGroups: Record<string, unknown> = isRecord(declaredValue) ? declaredValue : {};
889
+ const serial = Object.keys(declaredGroups)
890
+ .filter((name) => {
891
+ const declared = declaredGroups[name];
892
+ return isRecord(declared) && declared['max-threads'] === 1;
893
+ })
894
+ .sort((left, right) => left.localeCompare(right));
895
+ const profiles: Record<string, unknown> = isRecord(parsed.profile) ? parsed.profile : {};
896
+ const defaults: Record<string, unknown> = isRecord(profiles.default) ? profiles.default : {};
897
+ const overridesValue: unknown = defaults.overrides;
898
+ const overrides: unknown[] = Array.isArray(overridesValue) ? overridesValue : [];
899
+ return serial.flatMap((group) => {
900
+ const filters: string[] = [];
901
+ for (const override of overrides) {
902
+ if (!isRecord(override) || override['test-group'] !== group) {
903
+ continue;
904
+ }
905
+ if (override.platform !== SERIAL_TEST_GROUP_PLATFORM) {
906
+ throw new Error(
907
+ `${nextestConfigPath}: test-group "${group}" overrides must declare platform = '${SERIAL_TEST_GROUP_PLATFORM}' ` +
908
+ `(the only platform a serial group runs on here), got ${JSON.stringify(override.platform ?? null)}`,
909
+ );
910
+ }
911
+ if (typeof override.filter === 'string' && override.filter.length > 0) {
912
+ filters.push(override.filter);
913
+ }
914
+ }
915
+ const filter = filterUnion(filters);
916
+ return filter === null ? [] : [{ group, filter, scope: filterScope(filter) }];
917
+ });
918
+ }
919
+
920
+ /**
921
+ * The packages `filter` can select tests from, read off its `package(<name>)` predicates. The scope is
922
+ * never narrower than the selection: whatever this does not read with certainty is the whole workspace.
923
+ *
924
+ * The filter is read as nextest reads it, with nextest's precedence — parentheses, then `not` and `!`,
925
+ * then `and`, `&` and `-`, then `or`, `|` and `+`, each level left to right — and with nextest's blanks,
926
+ * which are spaces and line endings. Each expression is bounded by the packages it can select from:
927
+ *
928
+ * - `package(<name>)` and `package(=<name>)`, for a plain Cargo name, bound it to that package. A glob,
929
+ * `~contains`, `/regex/` or `#glob` name can match any package, so it bounds nothing.
930
+ * - Every other predicate bounds nothing, and nor does `not`: `not package(a)` selects from every other
931
+ * package, and `deps` and `rdeps` reach beyond the package they name.
932
+ * - `a and b` selects only what both select, so it is bounded by the narrower of the two bounds, and
933
+ * `a - b`, which is `a and not b`, by `a`. `a or b` is bounded by both together, so one unbounded
934
+ * clause leaves the union unbounded however the union is spelled.
935
+ *
936
+ * A predicate's argument ends where nextest ends it: a regex at its closing `/`, any other matcher at its
937
+ * first `)`. Only arguments that need none of nextest's escape sequences are read: a backslash, or a comma
938
+ * outside a regex, makes where the predicate ends depend on escapes this does not implement. Those, a
939
+ * filter that does not parse, and one whose packages exclude each other have no bound.
940
+ */
941
+ export function filterScope(filter: string): SerialTestGroupScope {
942
+ const read = readUnion(filter, 0);
943
+ if (read === null || skipBlank(filter, read.end) !== filter.length || read.bound === 'any' || read.bound.size === 0) {
944
+ return { kind: 'workspace' };
945
+ }
946
+ return { kind: 'packages', packages: [...read.bound].sort((left, right) => left.localeCompare(right)) };
947
+ }
948
+
949
+ /** What a filterset can select from: only the named packages, or `'any'` when no package bounds it. */
950
+ type PackageBound = ReadonlySet<string> | 'any';
951
+
952
+ /** A filterset prefix that has been read: the packages it can select from, and the offset just past it. */
953
+ interface ReadFilter {
954
+ readonly bound: PackageBound;
955
+ readonly end: number;
956
+ }
957
+
958
+ /** nextest's loosest-binding level: `or`, `|` and `+` between chains of `and`. */
959
+ function readUnion(text: string, from: number): ReadFilter | null {
960
+ let left = readIntersection(text, from);
961
+ while (left !== null) {
962
+ const operatorEnd = skipUnionOperator(text, left.end);
963
+ if (operatorEnd === null) return left;
964
+ const right = readIntersection(text, operatorEnd);
965
+ if (right === null) return null;
966
+ const bound = left.bound === 'any' || right.bound === 'any' ? 'any' : new Set([...left.bound, ...right.bound]);
967
+ left = { bound, end: right.end };
968
+ }
969
+ return null;
970
+ }
971
+
972
+ /** A chain of `and`, `&` and `-`, which bind tighter than a union, left to right. */
973
+ function readIntersection(text: string, from: number): ReadFilter | null {
974
+ let left = readOperand(text, from);
975
+ while (left !== null) {
976
+ const operator = readIntersectionOperator(text, left.end);
977
+ if (operator === null) return left;
978
+ const right = readOperand(text, operator.end);
979
+ left =
980
+ right === null
981
+ ? null
982
+ : { bound: operator.difference ? left.bound : boundIntersection(left.bound, right.bound), end: right.end };
983
+ }
984
+ return null;
985
+ }
986
+
987
+ /** A negation, a parenthesised filterset, or one predicate. */
988
+ function readOperand(text: string, from: number): ReadFilter | null {
989
+ const at = skipBlank(text, from);
990
+ const word = readWord(text, at, 'not');
991
+ const negated = word ?? (text.charAt(at) === '!' ? at + 1 : null);
992
+ if (negated !== null) {
993
+ const operand = readOperand(text, negated);
994
+ return operand === null ? null : { bound: 'any', end: operand.end };
995
+ }
996
+ if (text.charAt(at) !== '(') return readPredicate(text, at);
997
+ const inner = readUnion(text, at + 1);
998
+ if (inner === null) return null;
999
+ const close = skipBlank(text, inner.end);
1000
+ return text.charAt(close) === ')' ? { bound: inner.bound, end: close + 1 } : null;
1001
+ }
1002
+
1003
+ /** What follows a predicate's `(`: nothing, or a name matcher. */
1004
+ const PREDICATE_ARGUMENTS: Record<string, 'none' | 'matcher'> = {
1005
+ all: 'none',
1006
+ none: 'none',
1007
+ default: 'none',
1008
+ test: 'matcher',
1009
+ group: 'matcher',
1010
+ package: 'matcher',
1011
+ deps: 'matcher',
1012
+ rdeps: 'matcher',
1013
+ binary_id: 'matcher',
1014
+ kind: 'matcher',
1015
+ binary: 'matcher',
1016
+ platform: 'matcher',
1017
+ };
1018
+
1019
+ /** One predicate: `all()` and its kin, or a name followed by its parenthesised matcher. */
1020
+ function readPredicate(text: string, at: number): ReadFilter | null {
1021
+ const identifier = /[a-z_]+/y;
1022
+ identifier.lastIndex = at;
1023
+ const predicate = identifier.exec(text)?.[0];
1024
+ if (predicate === undefined) return null;
1025
+ const open = skipBlank(text, at + predicate.length);
1026
+ if (text.charAt(open) !== '(') return null;
1027
+ const argument = Object.hasOwn(PREDICATE_ARGUMENTS, predicate) ? PREDICATE_ARGUMENTS[predicate] : undefined;
1028
+ if (argument === undefined) return null;
1029
+ if (argument === 'none') {
1030
+ const close = skipBlank(text, open + 1);
1031
+ return text.charAt(close) === ')' ? { bound: 'any', end: close + 1 } : null;
1032
+ }
1033
+ const matcher = readMatcher(text, open + 1);
1034
+ return matcher === null
1035
+ ? null
1036
+ : { bound: predicate === 'package' ? packageBound(matcher.text) : 'any', end: matcher.end };
1037
+ }
1038
+
1039
+ /**
1040
+ * The argument of a predicate whose `(` ends just before `from`, as written between its parentheses, and
1041
+ * the offset past its `)`; null when it cannot be delimited exactly as nextest delimits it.
1042
+ */
1043
+ function readMatcher(text: string, from: number): { readonly text: string; readonly end: number } | null {
1044
+ const start = skipBlank(text, from);
1045
+ const close = text.charAt(start) === '/' ? regexMatcherClose(text, start) : plainMatcherClose(text, start);
1046
+ return close === null ? null : { text: text.slice(from, close), end: close + 1 };
1047
+ }
1048
+
1049
+ /** The `)` that follows the `/regex/` starting at `start`, when the regex holds no backslash. */
1050
+ function regexMatcherClose(text: string, start: number): number | null {
1051
+ const slash = text.indexOf('/', start + 1);
1052
+ if (slash < 0 || text.slice(start, slash).includes('\\')) return null;
1053
+ const close = skipBlank(text, slash + 1);
1054
+ return text.charAt(close) === ')' ? close : null;
1055
+ }
1056
+
1057
+ /** The first `)` at or after `start`, when nothing before it is a backslash or a comma. */
1058
+ function plainMatcherClose(text: string, start: number): number | null {
1059
+ const close = text.indexOf(')', start);
1060
+ return close < 0 || /[,\\]/.test(text.slice(start, close)) ? null : close;
1061
+ }
1062
+
1063
+ /** A plain Cargo package name, with or without nextest's `=` prefix: nothing a glob can widen. */
1064
+ const PLAIN_PACKAGE_NAME = /^=?([A-Za-z0-9_-]+)$/;
1065
+
1066
+ function packageBound(matcher: string): PackageBound {
1067
+ const name = PLAIN_PACKAGE_NAME.exec(matcher)?.[1];
1068
+ return name === undefined ? 'any' : new Set([name]);
1069
+ }
1070
+
1071
+ function boundIntersection(left: PackageBound, right: PackageBound): PackageBound {
1072
+ if (left === 'any') return right;
1073
+ if (right === 'any') return left;
1074
+ return new Set([...left].filter((name) => right.has(name)));
1075
+ }
1076
+
1077
+ /** The offset of the first character at or after `from` that nextest does not read as blank. */
1078
+ function skipBlank(text: string, from: number): number {
1079
+ const blank = /(?: |\r?\n)*/y;
1080
+ blank.lastIndex = from;
1081
+ return from + (blank.exec(text)?.[0].length ?? 0);
1082
+ }
1083
+
1084
+ /** `word` at `at`, read as nextest reads an operator word: not the start of a longer identifier. */
1085
+ function readWord(text: string, at: number, word: string): number | null {
1086
+ const end = at + word.length;
1087
+ return text.startsWith(word, at) && !/[A-Za-z0-9_]/.test(text.charAt(end)) ? end : null;
1088
+ }
1089
+
1090
+ /** The offset past the `or`, `|` or `+` that follows `from` after any blanks, or null. */
1091
+ function skipUnionOperator(text: string, from: number): number | null {
1092
+ const at = skipBlank(text, from);
1093
+ const character = text.charAt(at);
1094
+ return readWord(text, at, 'or') ?? (character === '|' || character === '+' ? at + 1 : null);
1095
+ }
1096
+
1097
+ /** The `and`, `&` or `-` that follows `from` after any blanks: where it ends, and whether it subtracts. */
1098
+ function readIntersectionOperator(
1099
+ text: string,
1100
+ from: number,
1101
+ ): { readonly end: number; readonly difference: boolean } | null {
1102
+ const at = skipBlank(text, from);
1103
+ const word = readWord(text, at, 'and');
1104
+ if (word !== null) return { end: word, difference: false };
1105
+ const character = text.charAt(at);
1106
+ if (character === '&') return { end: at + 1, difference: false };
1107
+ return character === '-' ? { end: at + 1, difference: true } : null;
1108
+ }
1109
+
1110
+ /** The plugin's nextest.toml as the workspace root's `node_modules` links it. */
1111
+ export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/nextest.toml';
1112
+
796
1113
  /**
797
1114
  * The plugin's own nextest settings, as a config layer BENEATH the repository's.
798
1115
  *
@@ -811,10 +1128,19 @@ export function exceptionalTestFilter(nextestConfigPath: string): string | null
811
1128
  * (`bounded-exec`, which spawns with `shell: true`) go through a shell — so the
812
1129
  * command text stays identical everywhere. Quoted, because a workspace path may
813
1130
  * contain spaces.
1131
+ *
1132
+ * The file is named through the workspace root's `node_modules` link, as
1133
+ * `NEXTEST_EXTRACT_BIN` is, never through where the plugin really lives: a
1134
+ * plugin linked from a checkout outside the workspace sits a different number
1135
+ * of `../` away from each workspace depending on how deep that workspace is,
1136
+ * and that count re-keyed every target of every Cargo project — and every
1137
+ * dependent task — in each workspace that sat at a new depth.
1138
+ *
1139
+ * `projectRoot` is the Cargo workspace's root relative to the Nx workspace
1140
+ * root, which is the directory these commands run in.
814
1141
  */
815
- export function nextestToolConfigArg(workspaceRoot: string, projectRoot: string, configAbs: string): string {
816
- const rel = relative(join(workspaceRoot, projectRoot), configAbs);
817
- const path = rel.length === 0 ? configAbs : rel.split(sep).join('/');
1142
+ export function nextestToolConfigArg(projectRoot: string): string {
1143
+ const path = posix.join(posix.relative(projectRoot, '.'), PLUGIN_NEXTEST_CONFIG_PATH);
818
1144
  return `--tool-config-file "smoo:$PWD/${path}"`;
819
1145
  }
820
1146
 
@@ -6,6 +6,7 @@ import { join } from 'node:path';
6
6
  import {
7
7
  CARGO_CROSS_LINT_COMMAND,
8
8
  CARGO_CROSS_LINT_TARGET,
9
+ CARGO_DENY_WARNINGS,
9
10
  CARGO_LINT_CLIPPY_COMMAND,
10
11
  CARGO_LINUX_TRIPLE,
11
12
  CROSS_CHECK_SCRIPT_COMMAND,
@@ -57,10 +58,67 @@ describe('Linux cross-check policy', () => {
57
58
  it('matches the severity and triple CI lints with', () => {
58
59
  // A weaker local command passes where CI fails, which is the failure this
59
60
  // gate exists to prevent rather than reproduce.
60
- expect(CARGO_CROSS_LINT_COMMAND).toContain('-D warnings');
61
+ expect(CARGO_CROSS_LINT_COMMAND).toContain(CARGO_DENY_WARNINGS);
61
62
  expect(CARGO_CROSS_LINT_COMMAND).toContain(`--target ${CARGO_LINUX_TRIPLE}`);
62
63
  });
63
64
 
65
+ it('passes clippy-driver no arguments, so the gate and a plain clippy share one unit set', () => {
66
+ // Anything after `--` becomes CLIPPY_ARGS, part of every member's fingerprint.
67
+ for (const command of [CARGO_LINT_CLIPPY_COMMAND, CARGO_CROSS_LINT_COMMAND]) {
68
+ expect(command).not.toContain(' -- ');
69
+ }
70
+ });
71
+
72
+ it('fails on warnings it replays from units a plain clippy already checked', async () => {
73
+ const project = await mkdtemp(join(tmpdir(), 'cargo-lint-warnings-'));
74
+ const clippy = async (command: string): Promise<{ exitCode: number; output: string }> => {
75
+ const child = Bun.spawn(['sh', '-c', command], {
76
+ cwd: project,
77
+ env: { ...process.env, RUSTC_WRAPPER: '', RUSTC_WORKSPACE_WRAPPER: '' },
78
+ stdout: 'pipe',
79
+ stderr: 'pipe',
80
+ });
81
+ const [exitCode, stdout, stderr] = await Promise.all([
82
+ child.exited,
83
+ new Response(child.stdout).text(),
84
+ new Response(child.stderr).text(),
85
+ ]);
86
+ return { exitCode, output: stdout + stderr };
87
+ };
88
+ try {
89
+ await mkdir(join(project, 'src'));
90
+ await writeFile(
91
+ join(project, 'Cargo.toml'),
92
+ '[package]\nname = "warning-fixture"\nversion = "0.1.0"\nedition = "2021"\n[workspace]\n',
93
+ );
94
+ await writeFile(
95
+ join(project, 'Cargo.lock'),
96
+ 'version = 4\n\n[[package]]\nname = "warning-fixture"\nversion = "0.1.0"\n',
97
+ );
98
+ await writeFile(join(project, 'src/lib.rs'), 'pub fn planted() {\n let unused = 1;\n}\n');
99
+ const plain = cargoFrozen('clippy --workspace --all-targets');
100
+
101
+ const first = await clippy(plain);
102
+ expect(first).toMatchObject({ exitCode: 0 });
103
+ expect(first.output).toContain('Checking warning-fixture');
104
+ expect(first.output).toContain('unused variable');
105
+
106
+ // Fresh: the gate replays the plain run's units and their warning, and fails on it.
107
+ const gate = await clippy(CARGO_LINT_CLIPPY_COMMAND);
108
+ expect(gate.exitCode).not.toBe(0);
109
+ expect(gate.output).not.toContain('Checking warning-fixture');
110
+ expect(gate.output).toContain('unused variable');
111
+ expect(gate.output).toContain('warnings are denied by `build.warnings` configuration');
112
+
113
+ // And the gate left the plain run's units Fresh in turn.
114
+ const again = await clippy(plain);
115
+ expect(again).toMatchObject({ exitCode: 0 });
116
+ expect(again.output).not.toContain('Checking warning-fixture');
117
+ } finally {
118
+ await rm(project, { recursive: true, force: true });
119
+ }
120
+ }, 60_000);
121
+
64
122
  it('fails closed on Darwin without the linux-cross compiler instead of compiling', () => {
65
123
  // Without this guard a Darwin cache miss sits in ring's cc-rs looking for
66
124
  // x86_64-linux-gnu-gcc. The linux-cross profile exports
@@ -94,8 +94,25 @@ export const CARGO_FETCH_TARGET = 'cargo-fetch';
94
94
  export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
95
95
 
96
96
  /**
97
- * Clippy rather than `cargo check`, and `-D warnings`, because that is exactly
98
- * what CI's `lint` runs; a weaker local command would pass where CI fails.
97
+ * Deny warnings through Cargo's `build.warnings`, never `-- -D warnings`.
98
+ *
99
+ * Arguments after `--` reach clippy-driver through `CLIPPY_ARGS`, which Cargo
100
+ * hashes into every member unit's fingerprint. A gate that passes
101
+ * `-D warnings` therefore owns a unit set of its own: it and a plain
102
+ * `cargo clippy` invalidate each other, re-checking every member each time.
103
+ * `build.warnings` is Cargo's own verdict over the diagnostics it collected,
104
+ * including those it replays from Fresh units, and it reaches no compiler
105
+ * invocation, so every caller shares one unit set while the gate still fails.
106
+ *
107
+ * On the command line rather than in a config file: the gate's verdict is not
108
+ * a repository's local choice, and `--config` outranks every config file.
109
+ */
110
+ export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
111
+
112
+ /**
113
+ * Clippy rather than `cargo check`, and warnings denied, because that is
114
+ * exactly what CI's `lint` runs; a weaker local command would pass where CI
115
+ * fails.
99
116
  *
100
117
  * `--all-targets` is what answers "what does test mean when cross-compiling": it
101
118
  * type-checks bins, tests, benches and examples for the target, so test CODE is
@@ -113,7 +130,8 @@ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
113
130
  *
114
131
  * Keep the caller's CARGO_HOME: it owns registry sources, credentials and global
115
132
  * Cargo configuration, including paths relative to that configuration. Relocating
116
- * or replaying it through --config changes path resolution or precedence.
133
+ * or replaying it through --config changes path resolution or precedence; the
134
+ * one `--config` here sets `build.warnings` alone.
117
135
  * Cargo may serialize registry access on its package-cache lock; these checks
118
136
  * are unbounded, and correctness takes priority over overlapping that access.
119
137
  *
@@ -122,7 +140,7 @@ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
122
140
  * behind host builds.
123
141
  */
124
142
  export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${cargoFrozen(
125
- `clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross -- -D warnings`,
143
+ `clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross ${CARGO_DENY_WARNINGS}`,
126
144
  )}`;
127
145
 
128
146
  /**
@@ -134,8 +152,9 @@ export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${cargoFroze
134
152
  * a proc-macro and ordinary code use stays a distinct unit: a dev build
135
153
  * compiles it once at the target profile, while a check build needs a separate
136
154
  * host copy. Distinct hashes coexist, so neither command dirties the other.
155
+ * A plain `cargo clippy --workspace --all-targets` checks exactly these units.
137
156
  */
138
- export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen('clippy --workspace --all-targets -- -D warnings');
157
+ export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen(`clippy --workspace --all-targets ${CARGO_DENY_WARNINGS}`);
139
158
 
140
159
  /** Root `package.json` script name, in the repo's `verb:qualifier` style. */
141
160
  export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
@@ -198,7 +217,7 @@ export function cargoCrossTestTargetName(triple: string): string {
198
217
  * the other's name.
199
218
  */
200
219
  export function cargoCrossTestArchiveFile(triple: string): string {
201
- return `target/nextest/archive-${triple}.tar.zst`;
220
+ return `.cache/nextest/archive-${triple}.tar.zst`;
202
221
  }
203
222
 
204
223
  const CARGO_CROSS_TEST_ARCHIVE_PREFIX = cargoCrossTestArchiveTargetName('');
@@ -0,0 +1,61 @@
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
+ });