@smoothbricks/nx-plugin 0.5.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/README.md +1095 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/all-verdicts/executor.d.ts +35 -0
  59. package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
  60. package/dist/executors/all-verdicts/executor.js +133 -0
  61. package/dist/executors/all-verdicts/schema.d.ts +10 -0
  62. package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
  63. package/dist/executors/all-verdicts/schema.js +2 -0
  64. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  65. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  66. package/dist/executors/bounded-exec/bounds.js +43 -0
  67. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  68. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  70. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  71. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/executor.js +371 -239
  73. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  74. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  76. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  77. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  78. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  79. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  80. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  82. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  83. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  85. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  86. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  88. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  89. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  90. package/dist/executors/bounded-exec/progress.js +5 -2
  91. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  92. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  93. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  94. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  95. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  96. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  97. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  98. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  100. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  101. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  102. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  103. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  104. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  105. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  106. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  107. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  108. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  109. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  110. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  111. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  112. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  113. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  114. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  115. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  116. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  117. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  118. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +88 -19
  121. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  122. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  123. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  124. package/dist/executors/clean-outputs/executor.js +1 -0
  125. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  126. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/executor.js +367 -0
  128. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  129. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  130. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  131. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  132. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  133. package/dist/executors/scriptc-native/schema.js +1 -0
  134. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  135. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  136. package/dist/executors/typescript-emit/executor.js +164 -33
  137. package/dist/forbidden-spelling-policy.d.ts +56 -0
  138. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  139. package/dist/forbidden-spelling-policy.js +176 -0
  140. package/dist/generators/create-package/generator.d.ts.map +1 -1
  141. package/dist/generators/create-package/generator.js +3 -4
  142. package/dist/graph-input-contract.d.ts +14 -0
  143. package/dist/graph-input-contract.d.ts.map +1 -1
  144. package/dist/graph-input-contract.js +67 -2
  145. package/dist/index.d.ts +23 -6
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +676 -215
  148. package/dist/managed-assets.d.ts +2 -0
  149. package/dist/managed-assets.d.ts.map +1 -1
  150. package/dist/managed-files/files.d.ts +3 -3
  151. package/dist/managed-files/files.d.ts.map +1 -1
  152. package/dist/managed-files/files.js +28 -3
  153. package/dist/managed-files/managed-format.d.ts.map +1 -1
  154. package/dist/managed-files/managed-format.js +1 -0
  155. package/dist/nextest-code-bound.js +1 -0
  156. package/dist/nextest-timings.d.ts +35 -0
  157. package/dist/nextest-timings.d.ts.map +1 -0
  158. package/dist/nextest-timings.js +168 -0
  159. package/dist/owned-installation.d.ts +6 -5
  160. package/dist/owned-installation.d.ts.map +1 -1
  161. package/dist/owned-installation.js +150 -26
  162. package/dist/package-target-policy.d.ts.map +1 -1
  163. package/dist/package-target-policy.js +2 -3
  164. package/dist/process-children.d.ts +7 -0
  165. package/dist/process-children.d.ts.map +1 -0
  166. package/dist/process-children.darwin.d.ts +7 -0
  167. package/dist/process-children.darwin.d.ts.map +1 -0
  168. package/dist/process-children.darwin.js +13 -0
  169. package/dist/process-children.js +14 -0
  170. package/dist/process-children.linux.d.ts +8 -0
  171. package/dist/process-children.linux.d.ts.map +1 -0
  172. package/dist/process-children.linux.js +25 -0
  173. package/dist/process-group.d.ts +108 -0
  174. package/dist/process-group.d.ts.map +1 -0
  175. package/dist/process-group.js +171 -0
  176. package/dist/process-listing.d.ts +7 -0
  177. package/dist/process-listing.d.ts.map +1 -0
  178. package/dist/process-listing.js +51 -0
  179. package/dist/producer-receipts.d.ts +8 -2
  180. package/dist/producer-receipts.d.ts.map +1 -1
  181. package/dist/producer-receipts.js +75 -48
  182. package/dist/task-graph-policy.d.ts +21 -0
  183. package/dist/task-graph-policy.d.ts.map +1 -0
  184. package/dist/task-graph-policy.js +91 -0
  185. package/dist/test-timings.js +4 -4
  186. package/dist/test-walk-policy.d.ts +14 -5
  187. package/dist/test-walk-policy.d.ts.map +1 -1
  188. package/dist/test-walk-policy.js +8 -2
  189. package/dist/testing.d.ts +73 -28
  190. package/dist/testing.d.ts.map +1 -1
  191. package/dist/testing.js +217 -223
  192. package/dist/tool-bins.d.ts +33 -0
  193. package/dist/tool-bins.d.ts.map +1 -0
  194. package/dist/tool-bins.js +72 -0
  195. package/dist/typecheck-test-policy.d.ts.map +1 -1
  196. package/dist/typecheck-test-policy.js +3 -4
  197. package/dist/wait-why-policy.d.ts +28 -0
  198. package/dist/wait-why-policy.d.ts.map +1 -0
  199. package/dist/wait-why-policy.js +223 -0
  200. package/dist/workspace-config-policy.d.ts +14 -8
  201. package/dist/workspace-config-policy.d.ts.map +1 -1
  202. package/dist/workspace-config-policy.js +60 -16
  203. package/dist/workspace-manifest.d.ts +41 -6
  204. package/dist/workspace-manifest.d.ts.map +1 -1
  205. package/dist/workspace-manifest.js +57 -0
  206. package/executors.json +21 -1
  207. package/loader.js +2 -0
  208. package/managed/raw/envrc +11 -0
  209. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  210. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  211. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  212. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  213. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  214. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  215. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  216. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  217. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  218. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  219. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  220. package/managed/raw/tooling/direnv/repo-path +68 -6
  221. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  222. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  223. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  224. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  225. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  226. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  227. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  228. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  229. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  230. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  231. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  232. package/package.json +77 -13
  233. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  234. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  235. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  236. package/src/bounded-test-policy.ts +12 -14
  237. package/src/build-state-output-policy.ts +458 -34
  238. package/src/bun-lock-scope.ts +108 -0
  239. package/src/cargo-build-script-env.ts +265 -0
  240. package/src/cargo-closure-input.ts +74 -7
  241. package/src/cargo-retention-hook.ts +94 -0
  242. package/src/cargo-source-hash.ts +138 -41
  243. package/src/cargo-toolchain-paths.ts +95 -0
  244. package/src/cargo-toolchain-policy.ts +49 -5
  245. package/src/cargo-workspace.ts +72 -123
  246. package/src/cross-check-policy.ts +12 -10
  247. package/src/disk-command-policy.ts +1 -0
  248. package/src/ensure-built-receipt.ts +132 -39
  249. package/src/ensure-built-witness.ts +62 -10
  250. package/src/ensure-built.ts +11 -1
  251. package/src/eslint-config-closure.ts +357 -0
  252. package/src/executors/all-verdicts/executor.ts +164 -0
  253. package/src/executors/all-verdicts/schema.json +22 -0
  254. package/src/executors/all-verdicts/schema.ts +10 -0
  255. package/src/executors/bounded-exec/bounds.ts +76 -0
  256. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  257. package/src/executors/bounded-exec/executor.ts +423 -259
  258. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  259. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  260. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  261. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  262. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  263. package/src/executors/bounded-exec/progress.ts +9 -3
  264. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  265. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  266. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  267. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  268. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  269. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  270. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  271. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  272. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  273. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  274. package/src/executors/bounded-exec/schema.json +11 -2
  275. package/src/executors/bounded-exec/schema.ts +19 -1
  276. package/src/executors/bounded-exec/verdict.ts +137 -34
  277. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  278. package/src/executors/clean-outputs/executor.ts +1 -0
  279. package/src/executors/scriptc-native/executor.ts +394 -0
  280. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  281. package/src/executors/scriptc-native/schema.json +60 -0
  282. package/src/executors/scriptc-native/schema.ts +34 -0
  283. package/src/executors/typescript-emit/executor.ts +205 -38
  284. package/src/forbidden-spelling-policy.ts +226 -0
  285. package/src/generators/create-package/generator.ts +7 -7
  286. package/src/graph-input-contract.ts +61 -2
  287. package/src/index.ts +792 -225
  288. package/src/managed-assets.ts +3 -0
  289. package/src/managed-files/files.ts +28 -3
  290. package/src/managed-files/managed-format.ts +1 -0
  291. package/src/nextest-code-bound.ts +1 -0
  292. package/src/nextest-timings.ts +106 -0
  293. package/src/owned-installation.ts +150 -23
  294. package/src/package-target-policy.ts +2 -3
  295. package/src/process-children.darwin.ts +14 -0
  296. package/src/process-children.linux.ts +33 -0
  297. package/src/process-children.ts +22 -0
  298. package/src/process-group.ts +209 -0
  299. package/src/process-listing.ts +54 -0
  300. package/src/producer-receipts.ts +68 -45
  301. package/src/task-graph-policy.ts +98 -0
  302. package/src/test-walk-policy.ts +23 -8
  303. package/src/testing.ts +240 -232
  304. package/src/tool-bins.ts +108 -0
  305. package/src/typecheck-test-policy.ts +2 -3
  306. package/src/wait-why-policy.ts +226 -0
  307. package/src/workspace-config-policy.ts +63 -15
  308. package/src/workspace-manifest.ts +89 -6
  309. package/test-timings.json +123 -98
  310. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  311. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  312. package/dist/bin/smoo-nx-failures.js +0 -3
  313. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  314. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  315. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  316. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  317. package/dist/failure-summary.d.ts +0 -5
  318. package/dist/failure-summary.d.ts.map +0 -1
  319. package/dist/failure-summary.js +0 -118
  320. package/dist/nextest-extraction.d.ts +0 -117
  321. package/dist/nextest-extraction.d.ts.map +0 -1
  322. package/dist/nextest-extraction.js +0 -303
  323. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  324. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  325. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  326. package/src/__tests__/counted-cargo-process.ts +0 -286
  327. package/src/__tests__/counted-cargo.ts +0 -713
  328. package/src/__tests__/directory-change.ts +0 -27
  329. package/src/__tests__/fixture-cargo-home.ts +0 -36
  330. package/src/__tests__/fixture-nx-env.ts +0 -193
  331. package/src/__tests__/owned-installation.ts +0 -13
  332. package/src/__tests__/past-tick.ts +0 -12
  333. package/src/__tests__/progress-clock.ts +0 -43
  334. package/src/__tests__/runtime-input.ts +0 -23
  335. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  336. package/src/bin/smoo-nx-failures.ts +0 -4
  337. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  338. package/src/bounded-test-policy.test.ts +0 -1029
  339. package/src/build-state-output-policy.test.ts +0 -115
  340. package/src/bun-bootstrap.test.ts +0 -102
  341. package/src/bun-file-packages.test.ts +0 -47
  342. package/src/cargo-closure-filesets.test.ts +0 -63
  343. package/src/cargo-closure-input.property.test.ts +0 -50
  344. package/src/cargo-closure-input.test.ts +0 -506
  345. package/src/cargo-closure-key.test.ts +0 -240
  346. package/src/cargo-resolve-cache.test.ts +0 -1181
  347. package/src/cargo-source-hash.test.ts +0 -707
  348. package/src/cargo-workspace.test.ts +0 -615
  349. package/src/cross-check-policy.test.ts +0 -316
  350. package/src/disk-command-policy.test.ts +0 -61
  351. package/src/ensure-built-receipt.test.ts +0 -279
  352. package/src/ensure-built-witness.test.ts +0 -688
  353. package/src/ensure-built.test.ts +0 -1462
  354. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  355. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  356. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  357. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  358. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  359. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  360. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  361. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  362. package/src/executors/bounded-exec/progress.test.ts +0 -139
  363. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  364. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  365. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  366. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  367. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  368. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  369. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  370. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  371. package/src/executors/clean-outputs/executor.test.ts +0 -20
  372. package/src/executors/typescript-emit/executor.test.ts +0 -83
  373. package/src/failure-summary.ts +0 -119
  374. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  375. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  376. package/src/generators/create-package/generator.test.ts +0 -190
  377. package/src/generators/make-public/generator.test.ts +0 -137
  378. package/src/graph-input-contract.test.ts +0 -379
  379. package/src/host-controller-wiring.test.ts +0 -31
  380. package/src/index.test.ts +0 -3319
  381. package/src/linked-snapshots.nx.test.ts +0 -254
  382. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  383. package/src/managed-files/generator.test.ts +0 -243
  384. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  385. package/src/managed-files/json-edit.test.ts +0 -216
  386. package/src/managed-files/managed-content.test.ts +0 -166
  387. package/src/managed-files/managed-format-json.test.ts +0 -308
  388. package/src/managed-files/repo-path.test.ts +0 -172
  389. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  390. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  391. package/src/managed-files/tree-permissions.test.ts +0 -109
  392. package/src/managed-files/tree.test.ts +0 -123
  393. package/src/manifest-hash.test.ts +0 -219
  394. package/src/nextest-code-bound.test.ts +0 -161
  395. package/src/nextest-extraction.test.ts +0 -216
  396. package/src/nextest-extraction.ts +0 -371
  397. package/src/nextest-partitions.test.ts +0 -501
  398. package/src/nx-cache-bound.test.ts +0 -109
  399. package/src/nx-cache-restore-mtime.test.ts +0 -170
  400. package/src/nx-daemon-claim.test.ts +0 -279
  401. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  402. package/src/nx-daemon-idle-policy.test.ts +0 -111
  403. package/src/nx-daemon-ignore-files.test.ts +0 -210
  404. package/src/nx-daemon-root-normalization.test.ts +0 -105
  405. package/src/nx-daemon-start-never.test.ts +0 -292
  406. package/src/nx-daemon-validity.test.ts +0 -1055
  407. package/src/nx-dot-input-policy.test.ts +0 -353
  408. package/src/nx-failure-life-cycles.test.ts +0 -207
  409. package/src/nx-files-archive-racy.test.ts +0 -97
  410. package/src/nx-foreign-workspace-env.test.ts +0 -329
  411. package/src/nx-incomplete-run-summary.test.ts +0 -70
  412. package/src/nx-plugin-load-errors.test.ts +0 -120
  413. package/src/nx-project-graph-errors.test.ts +0 -70
  414. package/src/nx-project-resolution-cache.test.ts +0 -176
  415. package/src/nx-raw-inputs.test.ts +0 -166
  416. package/src/nx-resident-graph-workers.test.ts +0 -112
  417. package/src/nx-run-information.test.ts +0 -118
  418. package/src/nx-skipped-task-exit.test.ts +0 -180
  419. package/src/nx-state-location.test.ts +0 -63
  420. package/src/nx-store-resolution.test.ts +0 -81
  421. package/src/nx-task-graph-cycles.test.ts +0 -148
  422. package/src/nx-task-output-lease.test.ts +0 -550
  423. package/src/nx-use-local.test.ts +0 -105
  424. package/src/owned-installation.test.ts +0 -105
  425. package/src/package-target-policy.test.ts +0 -1014
  426. package/src/producer-receipts.test.ts +0 -285
  427. package/src/release-config-policy.test.ts +0 -311
  428. package/src/runtime-input.test.ts +0 -393
  429. package/src/serial-group-wiring.test.ts +0 -326
  430. package/src/task-history-namespace.test.ts +0 -181
  431. package/src/task-results.test.ts +0 -228
  432. package/src/test-clock-policy.test.ts +0 -338
  433. package/src/test-program.test.ts +0 -303
  434. package/src/test-timings.test.ts +0 -240
  435. package/src/test-walk-policy.test.ts +0 -620
  436. package/src/testing.test.ts +0 -509
  437. package/src/typecheck-test-policy.test.ts +0 -1468
  438. package/src/typescript-resolution.test.ts +0 -76
  439. package/src/version-actions.test.ts +0 -80
  440. package/src/workspace-config-policy.test.ts +0 -737
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Lock-wait evidence from open-file tables. Pure: no I/O and no clock. `hang-diagnostics.ts` runs `lsof` and hands its
3
+ * output here, so every decision is a function of the rows it was given.
4
+ *
5
+ * A wait is open-handle evidence, not a kernel lock owner. flock(2) and fcntl(2) name no holder, so a regular file the
6
+ * run holds on a numbered descriptor, and that another process also holds open, is the only candidate for the lock a
7
+ * run blocks on. Nothing here observes the lock call itself.
8
+ */
9
+
10
+ /** One row of an `lsof -nP -p ...` table: a file a process holds open. */
11
+ export interface OpenFile {
12
+ readonly pid: number;
13
+ readonly fd: string;
14
+ readonly type: string;
15
+ readonly path: string;
16
+ }
17
+
18
+ /** A process that holds a file open. */
19
+ export interface Opener {
20
+ readonly pid: number;
21
+ readonly command: string;
22
+ }
23
+
24
+ /** An opener that `lsof -F` named for one path. */
25
+ export interface PathOpener extends Opener {
26
+ readonly path: string;
27
+ }
28
+
29
+ /**
30
+ * A regular file the run holds on a numbered descriptor while processes outside the run also hold it open. `waiters`
31
+ * are the run's pids holding it; `holders` are the outside processes, never a run pid.
32
+ */
33
+ export interface LockWait {
34
+ readonly path: string;
35
+ readonly waiters: readonly number[];
36
+ readonly holders: readonly Opener[];
37
+ }
38
+
39
+ /** COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME; NAME is everything from the ninth column on, spaces included. */
40
+ const TABLE_ROW = /^\S+\s+(?<pid>\d+)\s+\S+\s+(?<fd>\S+)\s+(?<type>\S+)\s+\S+\s+\S+\s+\S+\s+(?<path>.+)$/;
41
+
42
+ /** The rows of an `lsof -nP` table. The header and any row that does not parse are skipped. */
43
+ export function parseLsofTable(text: string): OpenFile[] {
44
+ const rows: OpenFile[] = [];
45
+ for (const line of text.split('\n')) {
46
+ const row = toOpenFile(line);
47
+ if (row !== null) rows.push(row);
48
+ }
49
+ return rows;
50
+ }
51
+
52
+ function toOpenFile(line: string): OpenFile | null {
53
+ const groups: Partial<Record<'pid' | 'fd' | 'type' | 'path', string>> = TABLE_ROW.exec(line)?.groups ?? {};
54
+ const { pid, fd, type, path } = groups;
55
+ if (pid === undefined || fd === undefined || type === undefined || path === undefined) return null;
56
+ return { pid: Number(pid), fd, type, path };
57
+ }
58
+
59
+ /**
60
+ * A regular file on a numbered descriptor: the only kind a blocking flock or fcntl can wait on. `cwd`, `txt`, `rtd`,
61
+ * `mem` and the other unnumbered descriptors name files a process runs or maps, not files it locks.
62
+ */
63
+ function isLockable(row: OpenFile): boolean {
64
+ return row.type === 'REG' && /^\d/.test(row.fd);
65
+ }
66
+
67
+ /** The distinct lockable paths in `tree`, sorted. */
68
+ export function lockCandidates(tree: readonly OpenFile[]): string[] {
69
+ return [...new Set(tree.filter(isLockable).map((row) => row.path))].sort();
70
+ }
71
+
72
+ /**
73
+ * The lock waits in `tree`, the open files of the run's processes. A path is a wait only when some process outside
74
+ * the run (`treePids` excludes the run) also holds it open. Sorted by path; holders deduplicated by pid and sorted.
75
+ */
76
+ export function lockWaits(
77
+ tree: readonly OpenFile[],
78
+ treePids: ReadonlySet<number>,
79
+ openers: readonly PathOpener[],
80
+ ): LockWait[] {
81
+ const waits: LockWait[] = [];
82
+ for (const path of lockCandidates(tree)) {
83
+ const holders = new Map<number, Opener>();
84
+ for (const opener of openers) {
85
+ if (opener.path === path && !treePids.has(opener.pid) && !holders.has(opener.pid)) {
86
+ holders.set(opener.pid, { pid: opener.pid, command: opener.command });
87
+ }
88
+ }
89
+ if (holders.size === 0) continue;
90
+ const waiters = [...new Set(tree.filter((row) => isLockable(row) && row.path === path).map((row) => row.pid))];
91
+ waits.push({
92
+ path,
93
+ waiters: waiters.sort((a, b) => a - b),
94
+ holders: [...holders.values()].sort((a, b) => a.pid - b.pid),
95
+ });
96
+ }
97
+ return waits;
98
+ }
99
+
100
+ /**
101
+ * Parse `lsof -F pcn` output: `p<pid>` opens a process, `c<command>` names it, `f<fd>` opens a file (lsof always
102
+ * emits one), and `n<path>` names the file. `null` for any other shape: the caller must then call the census
103
+ * incomplete, never empty.
104
+ */
105
+ export function parseLsofFields(text: string): PathOpener[] | null {
106
+ const openers: PathOpener[] = [];
107
+ let pid: number | null = null;
108
+ let command: string | null = null;
109
+ for (const line of text.split('\n')) {
110
+ if (line === '') continue;
111
+ const value = line.slice(1);
112
+ switch (line.charAt(0)) {
113
+ case 'p': {
114
+ const next = Number(value);
115
+ if (!Number.isSafeInteger(next) || next <= 0) return null;
116
+ pid = next;
117
+ command = null;
118
+ break;
119
+ }
120
+ case 'c':
121
+ if (pid === null || command !== null) return null;
122
+ command = value;
123
+ break;
124
+ case 'f':
125
+ if (pid === null) return null;
126
+ break;
127
+ case 'n':
128
+ if (pid === null || command === null) return null;
129
+ openers.push({ pid, command, path: value });
130
+ break;
131
+ default:
132
+ return null;
133
+ }
134
+ }
135
+ return openers;
136
+ }
137
+
138
+ /** The holders as a reader names them: `pid 51234 (cargo), pid 9 (rustc)`. */
139
+ export function describeHolders(holders: readonly Opener[]): string {
140
+ return holders.map(({ pid, command }) => `pid ${pid} (${command})`).join(', ');
141
+ }
@@ -0,0 +1,235 @@
1
+ import { spawn } from 'node:child_process';
2
+ import type { Readable } from 'node:stream';
3
+ import { isRecord } from '../../type-guards.js';
4
+
5
+ /**
6
+ * What a `bounded-exec` command leaves running, owned the way cowshed's supervisor owns a job's processes
7
+ * (specs/cowshed/11_shell.md, "Process identity and signal ownership"): by the tree the supervisor observes from
8
+ * fork, never by who works in a directory. The command runs as `cowshed subtree-root`, which asks its job's
9
+ * supervisor for a handle on itself while it is alive, writes that answer to an inherited descriptor, and execs the
10
+ * command in the same life. At the end, `cowshed retire-descendants` hands the handle back: the supervisor signals
11
+ * the live members its tree records under that root, and nothing else, so a process that merely works in the
12
+ * command's directory is never touched.
13
+ */
14
+
15
+ /** Set by a cowshed runtime for a job only when a supervisor serves that job's socket. */
16
+ export const SUPERVISOR_SOCKET_ENV = 'COWSHED_SUPERVISOR_SOCKET';
17
+
18
+ /**
19
+ * The variable naming the cowshed executable that runs `cowshed disk-command` and `cowshed subtree-root`. Unset, it is
20
+ * the installed `cowshed` on PATH. A repository that tests its own cowshed sets it, on the targets that test it, to that
21
+ * checkout's build: an installed cowshed that predates a command its own checkout added would fail the very code under
22
+ * test. The executor passes the one it resolved to the command, so it is part of what the command runs.
23
+ */
24
+ export const COWSHED_EXECUTABLE_ENV = 'COWSHED_EXECUTABLE';
25
+
26
+ /**
27
+ * The descriptor `cowshed subtree-root` writes its admission to. fd 3 is the runner lifecycle's duplex socket
28
+ * (`runner-hook.ts`), which must reach the command, so the admission takes the next one.
29
+ */
30
+ export const HANDLE_FD = 4;
31
+
32
+ /** The supervisor's opaque capability for one subtree; only `retire-descendants` reads it. */
33
+ export type SubtreeHandle = Readonly<Record<string, unknown>>;
34
+
35
+ /** Why the supervisor answered no, by its own typed reason. */
36
+ export type SubtreeRefusal = 'foldUnavailable' | 'notMember' | 'foreignHandle' | 'jobEnded' | 'spentHandle';
37
+
38
+ const REFUSALS: readonly string[] = ['foldUnavailable', 'notMember', 'foreignHandle', 'jobEnded', 'spentHandle'];
39
+
40
+ /** What `cowshed subtree-root` wrote, or why nothing readable came. */
41
+ export type SubtreeAdmission =
42
+ | { kind: 'admitted'; handle: SubtreeHandle }
43
+ | { kind: 'refused'; reason: SubtreeRefusal }
44
+ | { kind: 'unread'; detail: string };
45
+
46
+ /** A process the retirement signalled: its pid, and its image when the supervisor read one. */
47
+ export interface SignalledProcess {
48
+ readonly pid: number;
49
+ readonly image: string | null;
50
+ readonly signal: number;
51
+ }
52
+
53
+ /** Where the supervisor's observation of the subtree may have missed something. */
54
+ export interface CoverageGap {
55
+ readonly kind: string;
56
+ readonly pid: number | null;
57
+ }
58
+
59
+ export type SubtreeRetirement =
60
+ | {
61
+ kind: 'retired';
62
+ signalled: readonly SignalledProcess[];
63
+ /** True when the supervisor could not list every process it signalled. */
64
+ signalledIncomplete: boolean;
65
+ gaps: readonly CoverageGap[];
66
+ }
67
+ | { kind: 'refused'; reason: SubtreeRefusal }
68
+ | { kind: 'failed'; detail: string };
69
+
70
+ /** The client half: how a command becomes an owned subtree root, and how its subtree ends. */
71
+ export interface SubtreeOwner {
72
+ /** The argv that runs the shell `command` as an owned subtree root, its admission on {@link HANDLE_FD}. */
73
+ rootArgv(command: string): { file: string; args: string[] };
74
+ /** Retire every live member recorded under `handle`'s root: TERM, then KILL after `graceMs`. */
75
+ retire(handle: SubtreeHandle, graceMs: number): Promise<SubtreeRetirement>;
76
+ }
77
+
78
+ function isRefusal(value: unknown): value is SubtreeRefusal {
79
+ return typeof value === 'string' && REFUSALS.includes(value);
80
+ }
81
+
82
+ /** Parse the admission JSON line `cowshed subtree-root` writes. */
83
+ export function parseAdmission(text: string): SubtreeAdmission {
84
+ let value: unknown;
85
+ try {
86
+ value = JSON.parse(text);
87
+ } catch {
88
+ return {
89
+ kind: 'unread',
90
+ detail: `cowshed subtree-root wrote no admission JSON: ${JSON.stringify(text.slice(0, 200))}`,
91
+ };
92
+ }
93
+ if (isRecord(value) && value.kind === 'admitted' && isRecord(value.handle)) {
94
+ return { kind: 'admitted', handle: value.handle };
95
+ }
96
+ if (isRecord(value) && value.kind === 'refused' && isRefusal(value.reason)) {
97
+ return { kind: 'refused', reason: value.reason };
98
+ }
99
+ return {
100
+ kind: 'unread',
101
+ detail: `cowshed subtree-root wrote an admission this client does not know: ${text.trim()}`,
102
+ };
103
+ }
104
+
105
+ /** A handle recorded as JSON, or null when the record holds none: a writer that died mid-write left no handle. */
106
+ export function parseHandle(text: string): SubtreeHandle | null {
107
+ try {
108
+ const value: unknown = JSON.parse(text);
109
+ return isRecord(value) ? value : null;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+
115
+ /** Read the admission from the command's handle descriptor; it closes before the command execs. */
116
+ export function readAdmission(stream: Readable | null | undefined): Promise<SubtreeAdmission> {
117
+ if (stream === null || stream === undefined) {
118
+ return Promise.resolve({ kind: 'unread', detail: 'the command was started without its handle descriptor' });
119
+ }
120
+ const chunks: Buffer[] = [];
121
+ let settle!: (admission: SubtreeAdmission) => void;
122
+ const answer = new Promise<SubtreeAdmission>((resolve) => {
123
+ settle = resolve;
124
+ });
125
+ stream.on('data', (chunk: Buffer) => chunks.push(chunk));
126
+ stream.once('error', (error: Error) => settle({ kind: 'unread', detail: `handle descriptor: ${error.message}` }));
127
+ stream.once('end', () => {
128
+ const text = Buffer.concat(chunks).toString('utf8');
129
+ settle(
130
+ text.trim() === ''
131
+ ? { kind: 'unread', detail: 'cowshed subtree-root closed its handle descriptor without an admission' }
132
+ : parseAdmission(text),
133
+ );
134
+ });
135
+ return answer;
136
+ }
137
+
138
+ /** Parse the retirement JSON line `cowshed retire-descendants` prints. */
139
+ export function parseRetirement(text: string): SubtreeRetirement {
140
+ let value: unknown;
141
+ try {
142
+ value = JSON.parse(text);
143
+ } catch {
144
+ return {
145
+ kind: 'failed',
146
+ detail: `cowshed retire-descendants printed no JSON: ${JSON.stringify(text.slice(0, 200))}`,
147
+ };
148
+ }
149
+ if (isRecord(value) && value.kind === 'refused' && isRefusal(value.reason)) {
150
+ return { kind: 'refused', reason: value.reason };
151
+ }
152
+ if (isRecord(value) && value.kind === 'retired' && isRecord(value.retirement)) {
153
+ const { containment, outlived, outlivedIncomplete } = value.retirement;
154
+ // `kernel` is a kernel-proven membership (a Linux cgroup), so it carries no gaps; `observed` lists what its fold
155
+ // may have missed (specs/cowshed/07_api.md, `containment`).
156
+ const lost = !isRecord(containment)
157
+ ? null
158
+ : containment.kind === 'kernel'
159
+ ? []
160
+ : containment.kind === 'observed' && Array.isArray(containment.lost)
161
+ ? containment.lost
162
+ : null;
163
+ if (lost !== null && Array.isArray(outlived)) {
164
+ const signalled: SignalledProcess[] = [];
165
+ for (const entry of outlived) {
166
+ if (!isRecord(entry) || typeof entry.pid !== 'number' || typeof entry.signal !== 'number') {
167
+ return {
168
+ kind: 'failed',
169
+ detail: `cowshed retire-descendants named a process this client cannot read: ${JSON.stringify(entry)}`,
170
+ };
171
+ }
172
+ signalled.push({
173
+ pid: entry.pid,
174
+ image: typeof entry.image === 'string' ? entry.image : null,
175
+ signal: entry.signal,
176
+ });
177
+ }
178
+ const gaps: CoverageGap[] = [];
179
+ for (const entry of lost) {
180
+ if (!isRecord(entry) || typeof entry.kind !== 'string') {
181
+ return {
182
+ kind: 'failed',
183
+ detail: `cowshed retire-descendants named a coverage gap this client cannot read: ${JSON.stringify(entry)}`,
184
+ };
185
+ }
186
+ gaps.push({ kind: entry.kind, pid: typeof entry.pid === 'number' ? entry.pid : null });
187
+ }
188
+ return { kind: 'retired', signalled, signalledIncomplete: outlivedIncomplete === true, gaps };
189
+ }
190
+ }
191
+ return {
192
+ kind: 'failed',
193
+ detail: `cowshed retire-descendants printed a retirement this client does not know: ${text.trim()}`,
194
+ };
195
+ }
196
+
197
+ /** The owner a cowshed runtime serves, through the installed `cowshed`'s own native socket client. */
198
+ export function cowshedSubtreeOwner(cowshed: string): SubtreeOwner {
199
+ return {
200
+ rootArgv(command) {
201
+ return {
202
+ file: cowshed,
203
+ args: ['subtree-root', '--handle-fd', String(HANDLE_FD), '--', '/bin/sh', '-c', command],
204
+ };
205
+ },
206
+ retire(handle, graceMs) {
207
+ const child = spawn(cowshed, ['retire-descendants', '--grace-ms', String(graceMs)], {
208
+ stdio: ['pipe', 'pipe', 'pipe'],
209
+ });
210
+ const out: Buffer[] = [];
211
+ const err: Buffer[] = [];
212
+ child.stdout.on('data', (chunk: Buffer) => out.push(chunk));
213
+ child.stderr.on('data', (chunk: Buffer) => err.push(chunk));
214
+ child.stdin.end(`${JSON.stringify(handle)}\n`);
215
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: the cowshed CLI bounds its own supervisor call (control bound, then the 15 s heartbeat silence; 05_gateway.md, "Deadlines") and exits with the answer or its TIMEOUT/SILENT failure
216
+ return new Promise<SubtreeRetirement>((resolve) => {
217
+ child.once('error', (error) =>
218
+ resolve({ kind: 'failed', detail: `${cowshed} retire-descendants: ${error.message}` }),
219
+ );
220
+ child.once('close', (code, signal) => {
221
+ const stdout = Buffer.concat(out).toString('utf8');
222
+ if (code === 0) {
223
+ resolve(parseRetirement(stdout));
224
+ return;
225
+ }
226
+ const stderr = Buffer.concat(err).toString('utf8').trim();
227
+ resolve({
228
+ kind: 'failed',
229
+ detail: `${cowshed} retire-descendants exited ${code ?? `on ${signal}`}${stderr === '' ? '' : `: ${stderr}`}`,
230
+ });
231
+ });
232
+ });
233
+ },
234
+ };
235
+ }
@@ -1,5 +1,5 @@
1
1
  import typia from 'typia';
2
- import { invocationSpan, withInvocationFlag } from './cpu-tokens.js';
2
+ import { invocationSpan, withInvocationFlag } from './runner-sizing.js';
3
3
  import { BUN_TEST, GO_TEST, NEXTEST_RUN } from './verdict.js';
4
4
 
5
5
  /**
@@ -16,6 +16,9 @@ import { BUN_TEST, GO_TEST, NEXTEST_RUN } from './verdict.js';
16
16
  * spells `classname name`.
17
17
  * - libtest (`cargo test`): `test tests::quick ... ok` (or `FAILED`, `ignored`); a test still running is named by
18
18
  * `test tests::slow has been running for over 60 seconds`.
19
+ * - vitest: timed ✓/× test results, timed ❯ failed-file results, and ↓ skipped-file results. The default
20
+ * reporter prints a completed file as ✓ file (N tests) Xms, plus slow or failed tests beneath it.
21
+ * Reporter headers, summaries and stack locations report no new completion.
19
22
  * - bun: a line of dots, one per test finished (`--dots`, which `withProgressReport` asks for: bun prints nothing
20
23
  * per passing test when it believes an agent runs it), or a `(pass)`/`(fail)`/`(skip)`/`(todo)` line. bun names
21
24
  * no test before it finishes, so a bun run names nothing in flight.
@@ -26,7 +29,7 @@ import { BUN_TEST, GO_TEST, NEXTEST_RUN } from './verdict.js';
26
29
  * Execution phases are owned by the private supervisor channel in runner-lifecycle.ts, never these text reports.
27
30
  */
28
31
  export interface RunProgress {
29
- /** One chunk of one of the command's output streams; true when it reports a finished test or Go package. */
32
+ /** One chunk of one output stream; true when it reports a finished test, file or Go package. */
30
33
  scan(stream: OutputStream, chunk: string): boolean;
31
34
  /** The tests the runner reported running and has not reported finished, in the order it first named them. */
32
35
  inFlight(): string[];
@@ -35,11 +38,14 @@ export interface RunProgress {
35
38
  export type OutputStream = 'stdout' | 'stderr';
36
39
 
37
40
  const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[A-Za-z]`, 'g');
38
- /** Lines naming a test that finished; group 1 is its name. */
41
+ /** Lines naming a test or file that finished; group 1 is its name. */
39
42
  const FINISHED = [
40
43
  /^\s*(?:[A-Z0-9][A-Z0-9-]*\s+)+\[\s*[0-9.]+s\]\s+\(\s*\d+\/\d+\)\s+(\S.*)$/,
41
44
  /^test (\S+) \.\.\. (?:ok|FAILED|ignored)\b/,
42
45
  /^\((?:pass|fail|skip|todo)\) (.+)$/,
46
+ /^\s*[✓×]\s+(\S.*?)\s+\d+ms\b/,
47
+ /^\s*❯\s+(\S.*?)\s+\(\d+ tests?(?: \| \d+ (?:failed|skipped|todo))*\)\s+\d+ms\b/,
48
+ /^\s*↓\s+(\S.*?)\s+\(\d+ tests?(?: \| \d+ (?:skipped|todo))+\)(?:\s+\d+ms\b|$)/,
43
49
  ];
44
50
  /** Lines naming a test still running; group 1 is its name. */
45
51
  const RUNNING = [
@@ -0,0 +1,238 @@
1
+ import { connect, type Socket } from 'node:net';
2
+ import { readDetachAnswer } from './ram-detach.js';
3
+ import type { RamDiskLease, RamUnavailable, Result } from './ram-temp.js';
4
+
5
+ /**
6
+ * The client of the cowshed gateway's `ram-lease` (specs/cowshed/05_gateway.md, "RAM disks"). The RAM temp volume's
7
+ * disk lives in the `diskimages-helper` that `hdiutil attach ram://<n>` forks. Forked inside a task's job, the helper is
8
+ * that job's member, and the job's end retires it with the disk under every other job's lease on the volume. The helper
9
+ * belongs to the gateway, which no job contains and which attaches the disk; no job's retirement reaches it.
10
+ *
11
+ * The client writes one line, `{"op":"ram-lease","sectors":<n>}`, and keeps its connection open; the gateway answers
12
+ * one line, `{"ok":true,"ramDisk":{"device":"/dev/diskN","registryEntry":"0x…"}}` or a refusal. The connection is the
13
+ * lease: the gateway holds the disk until the client writes `{"end":"keep"}`, after which the disk is the caller's, or
14
+ * `{"end":"release"}`, which the gateway answers with its detach as `ram-detach` does. A connection that ends first,
15
+ * at the client's deadline or with its process, has the gateway detach the disk. An end the gateway never answers leaves
16
+ * nothing known: the gateway may have handed the disk over or left it to its next startup scan, so the caller detaches it
17
+ * by its entry.
18
+ */
19
+
20
+ export const RAM_LEASE_OP = 'ram-lease';
21
+
22
+ const WHOLE_DISK = /^\/dev\/disk\d+$/;
23
+ const REGISTRY_ENTRY = /^0x[0-9a-f]+$/;
24
+ /** A release answers what `ram-detach` does, whose native output the gateway bounds; no answer grows past that. */
25
+ const ANSWER_BYTES_MAX = 2 * 64 * 1024 * 6 + 4096;
26
+
27
+ /** What the lease's connection gave next: one answer line, or why it gave none. */
28
+ type Next =
29
+ | { readonly kind: 'line'; readonly line: string }
30
+ | { readonly kind: 'closed' }
31
+ | { readonly kind: 'failed'; readonly error: Error }
32
+ | { readonly kind: 'late' };
33
+
34
+ /** The disk a granted lease holds. */
35
+ interface Granted {
36
+ readonly device: string;
37
+ readonly registryEntry: string;
38
+ }
39
+
40
+ /** Ask the gateway at `socket` for a RAM disk of `sectors` 512-byte sectors; its lease, or why there is none. */
41
+ export async function attachRamDisk(
42
+ socket: string,
43
+ sectors: number,
44
+ deadlineMs: number,
45
+ ): Promise<Result<RamDiskLease, string | RamUnavailable>> {
46
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a unix-socket connect completes or fails at once, and every answer on it is awaited by next(deadlineMs), whose timer ends the wait
47
+ const connection = connect(socket);
48
+ const next = answers(connection);
49
+ connection.on('connect', () => connection.write(`${JSON.stringify({ op: RAM_LEASE_OP, sectors })}\n`));
50
+ const granted = readGrant(await next(deadlineMs), socket, deadlineMs);
51
+ if (!granted.ok) {
52
+ connection.destroy();
53
+ return granted;
54
+ }
55
+ // The open connection is the lease; it never keeps this process alive on its own.
56
+ connection.unref();
57
+ return { ok: true, value: heldLease(connection, next, granted.value, deadlineMs) };
58
+ }
59
+
60
+ /** The connection's answer lines, one per call, each awaited for at most `deadlineMs`. */
61
+ function answers(connection: Socket): (deadlineMs: number) => Promise<Next> {
62
+ let received = '';
63
+ let gone: Next | null = null;
64
+ let waiting: ((next: Next) => void) | null = null;
65
+ const deliver = () => {
66
+ const wake = waiting;
67
+ if (wake === null) return;
68
+ const newline = received.indexOf('\n');
69
+ let next = gone;
70
+ if (newline >= 0) {
71
+ next = { kind: 'line', line: received.slice(0, newline) };
72
+ received = received.slice(newline + 1);
73
+ } else if (gone !== null && received !== '') {
74
+ next = { kind: 'line', line: received };
75
+ received = '';
76
+ }
77
+ if (next === null) return;
78
+ waiting = null;
79
+ wake(next);
80
+ };
81
+ connection.on('data', (chunk: Buffer) => {
82
+ received += chunk.toString('utf8');
83
+ if (received.length <= ANSWER_BYTES_MAX) return deliver();
84
+ received = '';
85
+ connection.destroy(new Error(`the gateway's answer exceeds ${ANSWER_BYTES_MAX} bytes`));
86
+ });
87
+ connection.on('error', (error) => {
88
+ gone ??= { kind: 'failed', error };
89
+ deliver();
90
+ });
91
+ connection.on('close', () => {
92
+ gone ??= { kind: 'closed' };
93
+ deliver();
94
+ });
95
+ return (deadlineMs) =>
96
+ new Promise((resolve) => {
97
+ const timer = setTimeout(() => {
98
+ waiting = null;
99
+ resolve({ kind: 'late' });
100
+ }, deadlineMs);
101
+ waiting = (next) => {
102
+ clearTimeout(timer);
103
+ resolve(next);
104
+ };
105
+ deliver();
106
+ });
107
+ }
108
+
109
+ /** The lease the attach answer grants, or why it grants none. */
110
+ function readGrant(next: Next, socket: string, deadlineMs: number): Result<Granted, string | RamUnavailable> {
111
+ switch (next.kind) {
112
+ case 'late':
113
+ return {
114
+ ok: false,
115
+ error: `the gateway answered no ram-lease within ${deadlineMs} ms; this client closed the lease, so the gateway detaches any disk its attach still makes`,
116
+ };
117
+ case 'failed':
118
+ return {
119
+ ok: false,
120
+ error:
121
+ 'code' in next.error && (next.error.code === 'ENOENT' || next.error.code === 'ECONNREFUSED')
122
+ ? {
123
+ kind: 'ram-unavailable',
124
+ reason: 'gateway-absent',
125
+ detail: `gateway ${socket} is unavailable: ${next.error.message}`,
126
+ }
127
+ : `gateway ram-lease I/O failed: ${next.error.message}`,
128
+ };
129
+ case 'closed':
130
+ return { ok: false, error: 'the gateway closed ram-lease without an answer' };
131
+ case 'line':
132
+ return readAnswer(next.line);
133
+ }
134
+ }
135
+
136
+ /** The fields of one JSON object answer line, or null for anything else. */
137
+ function fieldsOf(line: string): Readonly<Record<string, unknown>> | null {
138
+ let parsed: unknown;
139
+ try {
140
+ parsed = JSON.parse(line);
141
+ } catch {
142
+ return null;
143
+ }
144
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
145
+ ? Object.fromEntries(Object.entries(parsed))
146
+ : null;
147
+ }
148
+
149
+ /** The whole disk and registry entry a `ram-lease` answer names, or why the answer names none. */
150
+ function readAnswer(line: string): Result<Granted, string | RamUnavailable> {
151
+ const fields = fieldsOf(line);
152
+ if (fields === null) {
153
+ return { ok: false, error: `the gateway answered ram-lease with something that is not an answer: ${line}` };
154
+ }
155
+ if (fields.ok !== true) {
156
+ const why = `${String(fields.code ?? 'refused')}: ${String(fields.error ?? '')}`;
157
+ return {
158
+ ok: false,
159
+ error: String(fields.error ?? '').endsWith('unknown gateway control operation')
160
+ ? { kind: 'ram-unavailable', reason: 'gateway-unsupported', detail: `gateway predates ram-lease (${why})` }
161
+ : `the gateway refused ram-lease (${why})`,
162
+ };
163
+ }
164
+ const ramDisk = fields.ramDisk;
165
+ const device =
166
+ typeof ramDisk === 'object' && ramDisk !== null && 'device' in ramDisk && typeof ramDisk.device === 'string'
167
+ ? ramDisk.device
168
+ : null;
169
+ const registryEntry =
170
+ typeof ramDisk === 'object' &&
171
+ ramDisk !== null &&
172
+ 'registryEntry' in ramDisk &&
173
+ typeof ramDisk.registryEntry === 'string'
174
+ ? ramDisk.registryEntry
175
+ : null;
176
+ return device !== null && WHOLE_DISK.test(device) && registryEntry !== null && REGISTRY_ENTRY.test(registryEntry)
177
+ ? { ok: true, value: { device, registryEntry } }
178
+ : { ok: false, error: `the gateway's ram-lease answer names no whole disk and registry entry: ${line}` };
179
+ }
180
+
181
+ /** The lease `connection` holds on `disk`; each end is one line, half-closed, whose answer is awaited `deadlineMs`. */
182
+ function heldLease(
183
+ connection: Socket,
184
+ next: (deadlineMs: number) => Promise<Next>,
185
+ disk: Granted,
186
+ deadlineMs: number,
187
+ ): RamDiskLease {
188
+ let ended: 'keep' | 'release' | null = null;
189
+ const end = async (how: 'keep' | 'release'): Promise<Result<string, string>> => {
190
+ if (ended !== null) {
191
+ return {
192
+ ok: false,
193
+ error: `the ram-lease of ${disk.device} already ended at its ${ended}; nothing is known of a detach`,
194
+ };
195
+ }
196
+ ended = how;
197
+ connection.end(`${JSON.stringify({ end: how })}\n`);
198
+ const answer = await next(deadlineMs);
199
+ connection.destroy();
200
+ if (answer.kind === 'line') return { ok: true, value: answer.line };
201
+ const why =
202
+ answer.kind === 'late'
203
+ ? `none within ${deadlineMs} ms`
204
+ : answer.kind === 'failed'
205
+ ? answer.error.message
206
+ : 'it closed the connection';
207
+ return {
208
+ ok: false,
209
+ error: `the gateway answered no ${how} of the ram-lease of ${disk.device} (${why}): ${
210
+ how === 'keep'
211
+ ? 'nothing is known: the gateway may have handed the disk over or left it to its next startup scan; detach it by its entry'
212
+ : 'the lease is lost, so nothing is known of a detach'
213
+ }`,
214
+ };
215
+ };
216
+ return {
217
+ device: disk.device,
218
+ registryEntry: disk.registryEntry,
219
+ async keep() {
220
+ const answer = await end('keep');
221
+ if (!answer.ok) return answer;
222
+ return fieldsOf(answer.value)?.ok === true
223
+ ? { ok: true, value: undefined }
224
+ : { ok: false, error: `the gateway refused to keep the ram-lease of ${disk.device}: ${answer.value}` };
225
+ },
226
+ async release() {
227
+ const answer = await end('release');
228
+ if (!answer.ok) return answer;
229
+ const output = readDetachAnswer(answer.value);
230
+ return output === null
231
+ ? {
232
+ ok: false,
233
+ error: `the gateway's release of the ram-lease of ${disk.device} proves no detach outcome: ${answer.value}`,
234
+ }
235
+ : { ok: true, value: output };
236
+ },
237
+ };
238
+ }