@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,164 @@
1
+ import { type ChildProcessByStdio, spawn } from 'node:child_process';
2
+ import { resolve } from 'node:path';
3
+ import type { Readable } from 'node:stream';
4
+
5
+ import type { AllVerdictsOptions } from './schema.js';
6
+
7
+ /**
8
+ * A command's verdict. Only a command that exited reached one. A command a signal ended, one that never started and
9
+ * one still running when the run itself was signalled are unjudged: never a pass, and never left out of the report.
10
+ */
11
+ export type Verdict =
12
+ | { readonly kind: 'pass' }
13
+ | { readonly kind: 'fail'; readonly code: number }
14
+ | { readonly kind: 'unjudged'; readonly cause: string };
15
+
16
+ export interface CommandVerdict {
17
+ readonly command: string;
18
+ readonly verdict: Verdict;
19
+ }
20
+
21
+ /** The verdict of a process that closed with exit `code`, or, when `code` is null, was ended by `signal`. */
22
+ export function closedVerdict(code: number | null, signal: NodeJS.Signals | null): Verdict {
23
+ if (code === 0) return { kind: 'pass' };
24
+ if (code !== null) return { kind: 'fail', code };
25
+ return { kind: 'unjudged', cause: `${signal ?? 'an unreported signal'} ended it before it gave a verdict` };
26
+ }
27
+
28
+ /** How much of a command the verdict list quotes; the command's output block names it whole. */
29
+ const LABEL_LENGTH = 120;
30
+
31
+ function label(command: string): string {
32
+ return command.length <= LABEL_LENGTH ? command : `${command.slice(0, LABEL_LENGTH - 1)}…`;
33
+ }
34
+
35
+ function tag(verdict: Verdict): string {
36
+ switch (verdict.kind) {
37
+ case 'pass':
38
+ return 'PASS';
39
+ case 'fail':
40
+ return `FAIL (exit ${verdict.code})`;
41
+ case 'unjudged':
42
+ return 'UNJUDGED';
43
+ }
44
+ }
45
+
46
+ /** Every command's verdict, in the order the target lists the commands, under a count of each verdict. */
47
+ export function verdictReport(verdicts: readonly CommandVerdict[]): string {
48
+ const count = (kind: Verdict['kind']): number => verdicts.filter(({ verdict }) => verdict.kind === kind).length;
49
+ const lines = verdicts.map(({ command, verdict }) => {
50
+ const line = ` ${tag(verdict).padEnd(15)} ${label(command)}`;
51
+ return verdict.kind === 'unjudged' ? `${line} (${verdict.cause})` : line;
52
+ });
53
+ const counts = `${count('pass')} passed, ${count('fail')} failed, ${count('unjudged')} unjudged`;
54
+ return `\nall-verdicts: ${counts} of ${verdicts.length}\n${lines.join('\n')}\n`;
55
+ }
56
+
57
+ /** On POSIX each command leads a process group of its own, so a signal reaches every process the command started. */
58
+ const OWN_GROUP = process.platform !== 'win32';
59
+
60
+ function signalCommand(pid: number, signal: NodeJS.Signals): void {
61
+ try {
62
+ process.kill(OWN_GROUP ? -pid : pid, signal);
63
+ } catch (error) {
64
+ // ESRCH: every process of the command has already exited.
65
+ if (!(error instanceof Error && 'code' in error && error.code === 'ESRCH')) throw error;
66
+ }
67
+ }
68
+
69
+ const TERMINATION_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'] as const satisfies readonly NodeJS.Signals[];
70
+
71
+ interface Run {
72
+ readonly command: string;
73
+ readonly output: string[];
74
+ pid: number | undefined;
75
+ verdict: Verdict | null;
76
+ }
77
+
78
+ /** A command's output as one block, headed by the command the way Nx's run-commands heads it. */
79
+ function block(run: Run): string {
80
+ return `\n> ${run.command}\n\n${run.output.join('')}`;
81
+ }
82
+
83
+ /** Starts `run`'s command and settles with its verdict once it closes; its output prints as one block then. */
84
+ function judge(run: Run, cwd: string): Promise<Verdict> {
85
+ return new Promise((settle) => {
86
+ const close = (verdict: Verdict): void => {
87
+ // A run the signal handler already judged keeps that verdict: the run is ending by the signal.
88
+ if (run.verdict !== null) return;
89
+ run.verdict = verdict;
90
+ process.stdout.write(block(run));
91
+ settle(verdict);
92
+ };
93
+ let child: ChildProcessByStdio<null, Readable, Readable>;
94
+ try {
95
+ child = spawn(run.command, {
96
+ cwd,
97
+ shell: true,
98
+ stdio: ['ignore', 'pipe', 'pipe'],
99
+ detached: OWN_GROUP,
100
+ windowsHide: true,
101
+ });
102
+ } catch (error) {
103
+ close({ kind: 'unjudged', cause: `it never ran: ${error instanceof Error ? error.message : String(error)}` });
104
+ return;
105
+ }
106
+ run.pid = child.pid;
107
+ for (const stream of [child.stdout, child.stderr]) {
108
+ stream.setEncoding('utf8');
109
+ stream.on('data', (text: string) => run.output.push(text));
110
+ }
111
+ child.once('error', (error) => close({ kind: 'unjudged', cause: `it never ran: ${error.message}` }));
112
+ child.once('close', (code, signal) => close(closedVerdict(code, signal)));
113
+ });
114
+ }
115
+
116
+ /**
117
+ * Starts every command at once and lets each reach its own verdict. Nx's run-commands cannot: in parallel it terminates
118
+ * the other commands once one fails, and serially it never starts the ones after a failure, so one tool's errors hide
119
+ * another's until a later run. Here no command ends another. Each command's output prints as one block when it closes,
120
+ * then every command's verdict. A signal to the run ends every command's process group, reports each command still
121
+ * running UNJUDGED, and ends the run by the same signal. The run succeeds only when every command passed.
122
+ */
123
+ export default async function allVerdictsExecutor(
124
+ options: AllVerdictsOptions,
125
+ context: { readonly root: string },
126
+ ): Promise<{ success: boolean }> {
127
+ if (options.commands.length === 0) {
128
+ process.stderr.write('all-verdicts: no commands: an empty set of checks cannot fail, so it cannot pass\n');
129
+ return { success: false };
130
+ }
131
+ const cwd = resolve(context.root, options.cwd);
132
+ const runs: Run[] = options.commands.map((command) => ({ command, output: [], pid: undefined, verdict: null }));
133
+ const onExit = (): void => {
134
+ for (const run of runs) {
135
+ if (run.verdict === null && run.pid !== undefined) signalCommand(run.pid, 'SIGTERM');
136
+ }
137
+ };
138
+ const onSignal = (signal: NodeJS.Signals): void => {
139
+ detach();
140
+ const verdicts = runs.map((run): CommandVerdict => {
141
+ if (run.verdict === null) {
142
+ if (run.pid !== undefined) signalCommand(run.pid, signal);
143
+ run.verdict = { kind: 'unjudged', cause: `the run received ${signal} before it gave a verdict` };
144
+ process.stdout.write(block(run));
145
+ }
146
+ return { command: run.command, verdict: run.verdict };
147
+ });
148
+ process.stdout.write(verdictReport(verdicts), () => process.kill(process.pid, signal));
149
+ };
150
+ const listeners = TERMINATION_SIGNALS.map((signal) => [signal, () => onSignal(signal)] as const);
151
+ const detach = (): void => {
152
+ process.removeListener('exit', onExit);
153
+ for (const [signal, listener] of listeners) process.removeListener(signal, listener);
154
+ };
155
+ process.on('exit', onExit);
156
+ for (const [signal, listener] of listeners) process.on(signal, listener);
157
+
158
+ const verdicts = await Promise.all(
159
+ runs.map(async (run): Promise<CommandVerdict> => ({ command: run.command, verdict: await judge(run, cwd) })),
160
+ );
161
+ detach();
162
+ process.stdout.write(verdictReport(verdicts));
163
+ return { success: verdicts.every(({ verdict }) => verdict.kind === 'pass') };
164
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "All Verdicts Executor",
5
+ "description": "Run every command at once to its own verdict: none ends another, and each command a signal ended or that never ran is reported UNJUDGED by name.",
6
+ "type": "object",
7
+ "cli": "nx",
8
+ "required": ["commands", "cwd"],
9
+ "properties": {
10
+ "commands": {
11
+ "type": "array",
12
+ "items": { "type": "string" },
13
+ "minItems": 1,
14
+ "description": "Shell commands, all started at once. An empty list is refused: it could never fail."
15
+ },
16
+ "cwd": {
17
+ "type": "string",
18
+ "description": "Where every command runs, relative to the workspace root."
19
+ }
20
+ },
21
+ "additionalProperties": false
22
+ }
@@ -0,0 +1,10 @@
1
+ /** The executor the inferred `lint` target runs its tool commands with. */
2
+ export const ALL_VERDICTS_EXECUTOR = '@smoothbricks/nx-plugin:all-verdicts';
3
+
4
+ /** Options of `@smoothbricks/nx-plugin:all-verdicts`. */
5
+ export interface AllVerdictsOptions {
6
+ /** Shell commands, all started at once; none ends another. An empty list is refused: it could never fail. */
7
+ readonly commands: readonly string[];
8
+ /** Where every command runs, relative to the workspace root. */
9
+ readonly cwd: string;
10
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Which of a run's bounds is armed, and when each expires: the decision bounded-exec's timers carry out, kept here as
3
+ * a pure function of the run's events and the times they happened at, so a table can test it with no clock and no
4
+ * process (verdict.ts says why the bounds are separate).
5
+ *
6
+ * - The total ceiling runs from the spawn.
7
+ * - The fixture ceiling runs from the spawn while a supervised fixture runs, and ends with the fixture's segment.
8
+ * - The progress bound runs only while the runner is testing (runner-lifecycle.ts): from the spawn when the runner is
9
+ * testing then (startup is bounded until a build declares itself), restarted by a finished test or by the clock
10
+ * starting again after a build, and stopped while nothing tests.
11
+ */
12
+
13
+ /** The limits a run was given, in milliseconds; an absent one never expires. */
14
+ export interface BoundLimits {
15
+ readonly idleMs?: number;
16
+ readonly fixtureMs?: number;
17
+ readonly totalMs?: number;
18
+ }
19
+
20
+ /** When each armed bound expires, in the clock's milliseconds; `null` when it is not armed. */
21
+ export interface Bounds {
22
+ readonly idle: number | null;
23
+ readonly fixture: number | null;
24
+ readonly total: number | null;
25
+ }
26
+
27
+ export type BoundKind = keyof Bounds;
28
+
29
+ export type BoundEvent =
30
+ /** The command started; `testing` is the lifecycle's answer then, `fixture` whether a supervised fixture leads it. */
31
+ | { readonly kind: 'spawn'; readonly at: number; readonly testing: boolean; readonly fixture: boolean }
32
+ /**
33
+ * The runner's state may have moved: a test finished (`finished`), a phase changed, or the lifecycle failed.
34
+ * `wasTesting` is the answer before the event, `testing` the answer after it.
35
+ */
36
+ | {
37
+ readonly kind: 'progress';
38
+ readonly at: number;
39
+ readonly testing: boolean;
40
+ readonly wasTesting: boolean;
41
+ readonly finished: boolean;
42
+ }
43
+ /** The fixture's segment ended: its ceiling no longer applies. */
44
+ | { readonly kind: 'fixture-done' };
45
+
46
+ export const UNARMED: Bounds = { idle: null, fixture: null, total: null };
47
+
48
+ /** The bounds after `event`. */
49
+ export function stepBounds(bounds: Bounds, limits: BoundLimits, event: BoundEvent): Bounds {
50
+ switch (event.kind) {
51
+ case 'spawn':
52
+ return {
53
+ idle: event.testing && limits.idleMs !== undefined ? event.at + limits.idleMs : null,
54
+ fixture: event.fixture && limits.fixtureMs !== undefined ? event.at + limits.fixtureMs : null,
55
+ total: limits.totalMs !== undefined ? event.at + limits.totalMs : null,
56
+ };
57
+ case 'progress': {
58
+ if (!event.testing) return { ...bounds, idle: null };
59
+ const restart = event.finished || !event.wasTesting;
60
+ if (!restart || limits.idleMs === undefined) return bounds;
61
+ return { ...bounds, idle: event.at + limits.idleMs };
62
+ }
63
+ case 'fixture-done':
64
+ return { ...bounds, fixture: null };
65
+ }
66
+ }
67
+
68
+ /** The bound that expires first, or `null` when none is armed. A tie names the total, then the fixture, then idle. */
69
+ export function earliestBound(bounds: Bounds): { readonly kind: BoundKind; readonly at: number } | null {
70
+ let earliest: { kind: BoundKind; at: number } | null = null;
71
+ for (const kind of ['total', 'fixture', 'idle'] as const) {
72
+ const at = bounds[kind];
73
+ if (at !== null && (earliest === null || at < earliest.at)) earliest = { kind, at };
74
+ }
75
+ return earliest;
76
+ }
@@ -6,27 +6,28 @@ import { join } from 'node:path';
6
6
  import { promisify } from 'node:util';
7
7
  import typia from 'typia';
8
8
  import { ownedSocketDirectory } from '../../testing.js';
9
- import { CPU_TOKENS_ENV, parseInheritedTokens, type TokenGrant } from './cpu-tokens.js';
10
- import { holdLease } from './gateway-lease.js';
9
+ import { holdLease, type Unleased } from './gateway-lease.js';
10
+ import { type CpuLeaseProgress, CpuLeaseWait, HEARTBEAT_MS } from './lease-wait.js';
11
+ import { CPU_TOKENS_ENV, parseInheritedTokens } from './runner-sizing.js';
11
12
 
12
13
  /**
13
- * A parent's CPU pool: the tokens a granted process lends its own children, held live rather than
14
- * inherited as a bare count (specs/cowshed/05_gateway.md, "Host CPU budget", "Nested runners use a
15
- * parent-held sub-ledger").
14
+ * A CPU pool: the tokens a process lends the runners it starts, held live rather than inherited as a
15
+ * bare count (specs/cowshed/05_gateway.md, "Host scheduling", "Parallelism inside a job"). An Nx run
16
+ * serves one (`run-cpu-pool.ts`), and every granted bounded-exec serves a sub-pool of its grant to
17
+ * its own descendants, so the runners of one build tree together stay within the tree's count.
16
18
  *
17
19
  * The pool is a private Unix socket in a directory the process owns: the directory 0700, the socket
18
- * 0600. A child asks it for a count with one request line, exactly as it asks the gateway
19
- * (`holdLease`). The pool answers `queued` at once and `granted` when the child reaches the head of
20
- * its FIFO queue. A grant lasts while its connection does, so a child that dies returns its tokens
21
- * with its socket. A pool grants only from its own count, and a pool whose upstream grant has gone
22
- * grants nothing.
20
+ * 0600. A child asks it for a count with one request line, in `holdLease`'s framing. The pool
21
+ * answers `queued` at once and `granted` when the child reaches the head of its FIFO queue. A grant
22
+ * lasts while its connection does, so a child that dies returns its tokens with its socket. A pool
23
+ * grants only from its own count, and a pool whose upstream grant has gone grants nothing.
23
24
  *
24
25
  * The same count is a GNU make jobserver fifo beside the socket, mode 0600, which Cargo, its build
25
26
  * scripts and every nested `cargo` read through `CARGO_MAKEFLAGS`/`MAKEFLAGS` (specs/cowshed/05_gateway.md,
26
- * "The jobserver fifo"). A pool of `g` holds `g − 1` token bytes there; the holder's own command holds the
27
- * implicit first token. A socket grant takes fifo bytes first and that implicit slot last, which the holder
28
- * is not using while it waits on the child it lends it to; release writes the bytes back and frees the slot.
29
- * A Cargo reading the fifo and a nested runner holding a socket grant so share one count.
27
+ * "Cargo reads its holder's jobserver"). A pool of `g` holds `g − 1` token bytes there; the holder's own
28
+ * command holds the implicit first token. A socket grant takes fifo bytes first and that implicit slot last,
29
+ * which the holder is not using while it waits on the child it lends it to; release writes the bytes back and
30
+ * frees the slot. A Cargo reading the fifo and a nested runner holding a socket grant so share one count.
30
31
  */
31
32
 
32
33
  /** The environment name a child reads its parent's pool endpoint from; its count is `CPU_TOKENS_ENV`. */
@@ -35,7 +36,7 @@ export const CPU_POOL_ENV = 'BOUNDED_EXEC_CPU_POOL';
35
36
  /** An inherited pool descriptor; only a grant from its endpoint proves a live allocation. */
36
37
  export interface InheritedCpuPool {
37
38
  readonly socket: string;
38
- /** The count the parent names beside its endpoint: 0 for a resident's relay pool, which holds no token. */
39
+ /** The count the parent names beside its endpoint. */
39
40
  readonly tokens: number;
40
41
  }
41
42
 
@@ -53,41 +54,21 @@ export interface CpuPool {
53
54
 
54
55
  type CloseOutcome = { ok: true } | { ok: false; error: string };
55
56
 
56
- /**
57
- * The run's count of descendant work queued for host CPU tokens (specs/cowshed/05_gateway.md, "The bounds start at
58
- * the grant"). A queued job is not an idle one: its owner stops the run's idle clock while any wait is held. Every
59
- * pool of one run, its sub-pools included, reports to the same one.
60
- */
61
- export interface HostWaits {
62
- begin(): void;
63
- end(): void;
64
- }
65
-
66
57
  /** The one line a child sends: a count of whole tokens, at least one. */
67
58
  interface CpuPoolRequest {
68
59
  op: 'cpu-pool';
69
60
  want: number & typia.tags.Type<'uint32'> & typia.tags.Minimum<1>;
70
- /** Ask the owning pool to serve this allocation as its own child pool, with a jobserver fifo of its own. */
71
- children?: boolean;
72
- }
73
-
74
- /**
75
- * A descendant's word that work it started waits in a host CPU queue (a cowshed job the gateway holds `waiting`). It
76
- * is held like a grant: the wait lasts while its connection does, so a descendant that dies ends its wait.
77
- */
78
- interface HostWaitRequest {
79
- op: 'host-wait';
80
61
  }
81
62
 
82
63
  /** The pool's answers, in `holdLease`'s framing. */
83
64
  type CpuPoolReply =
65
+ | CpuLeaseProgress
84
66
  | { ok: true; lease: 'queued' }
85
- | { ok: true; lease: 'granted'; tokens: number; pool?: string }
86
- | { ok: true; wait: 'held' }
67
+ | { ok: true; lease: 'granted'; tokens: number }
87
68
  | { ok: false; code: 'invalid-request'; error: string };
88
69
 
89
- /** Exactly a request's fields, as the gateway's own pools read them: any other field is an invalid request. */
90
- const isRequest = typia.createEquals<CpuPoolRequest | HostWaitRequest>();
70
+ /** Exactly a request's fields: any other field is an invalid request. */
71
+ const isRequest = typia.createEquals<CpuPoolRequest>();
91
72
  const stringifyReply = typia.json.createStringify<CpuPoolReply>();
92
73
 
93
74
  /** A request over this many bytes is refused as `invalid-request` (specs/cowshed/05_gateway.md, "Wire"). */
@@ -107,14 +88,12 @@ const run = promisify(execFile);
107
88
 
108
89
  /**
109
90
  * A child's phase. Tokens are owed back only while `holding`: the bytes it took from the jobserver fifo, and whether it
110
- * holds the pool's implicit slot. A queued child holds nothing; a `waiting` child holds a host wait on the run's idle
111
- * clock.
91
+ * holds the pool's implicit slot. A queued child holds nothing.
112
92
  */
113
93
  type Phase =
114
94
  | { readonly kind: 'reading' }
115
95
  | { readonly kind: 'queued' }
116
96
  | { readonly kind: 'holding'; readonly bytes: number; readonly slot: boolean }
117
- | { readonly kind: 'waiting' }
118
97
  | { readonly kind: 'done' };
119
98
 
120
99
  /** A child connection and what the pool owes it. Its grant, or its place in line, ends with the connection. */
@@ -127,7 +106,6 @@ interface Child {
127
106
  interface Waiter {
128
107
  readonly child: Child;
129
108
  readonly want: number;
130
- readonly children: boolean;
131
109
  }
132
110
 
133
111
  /** One framed reply line. The newline is the framing; every reply goes through here. */
@@ -135,16 +113,12 @@ const frame = (reply: CpuPoolReply): string => `${stringifyReply(reply)}\n`;
135
113
 
136
114
  /**
137
115
  * The inherited descriptor, or null when malformed or absent. A missing or bare count, or an empty
138
- * or NUL-bearing endpoint, proves no allocation. A resident's relay pool names a count of 0 beside its
139
- * endpoint: it holds no token for its lifetime and asks the host for each child that asks it, so zero is
140
- * valid only with the endpoint, and every other count is a positive whole number. A valid descriptor still
141
- * needs a live endpoint grant (specs/cowshed/05_gateway.md, "Host CPU budget", "A resident holds no token").
116
+ * or NUL-bearing endpoint, proves no allocation; the count is a positive whole number. A valid
117
+ * descriptor still needs a live endpoint grant.
142
118
  */
143
119
  export function readInheritedCpuPool(environment: Readonly<NodeJS.ProcessEnv>): InheritedCpuPool | null {
144
120
  const socket = environment[CPU_POOL_ENV];
145
- const count = environment[CPU_TOKENS_ENV];
146
- // Zero is valid only as the literal 0 a relay pool names; any other count must be a positive safe integer.
147
- const tokens = count === '0' ? 0 : parseInheritedTokens(count);
121
+ const tokens = parseInheritedTokens(environment[CPU_TOKENS_ENV]);
148
122
  if (socket === undefined || socket.length === 0 || socket.includes('\0') || tokens === null) {
149
123
  return null;
150
124
  }
@@ -152,11 +126,16 @@ export function readInheritedCpuPool(environment: Readonly<NodeJS.ProcessEnv>):
152
126
  }
153
127
 
154
128
  /**
155
- * Ask the immediate parent pool for `want` tokens. Neither the inherited count nor the host's core count bounds the
156
- * ask: a lent pool grants at most what it holds, and a gate's or a resident's relay pool asks the host for each
157
- * child. A granted lease is the child's local allocation: its connection is the grant, and closing it returns only
158
- * that allocation. An absent endpoint allows normal host acquisition; a connected endpoint's refusal
159
- * or protocol failure must fail admission rather than taking a second grant above its parent.
129
+ * Tokens a parent pool lent, held until released, or why there are none. `closed` resolves when the grant's
130
+ * connection closes, however it closes, so a sub-pool built on the grant ends with it.
131
+ */
132
+ export type TokenGrant = { granted: true; tokens: number; release: () => void; closed: Promise<void> } | Unleased;
133
+
134
+ /**
135
+ * Ask the immediate parent pool for `want` tokens. The inherited count does not bound the ask: a pool grants at
136
+ * most what it holds. A granted lease is the child's local allocation: its connection is the grant, and closing it
137
+ * returns only that allocation. An absent endpoint grants nothing and refuses nothing; a connected endpoint's refusal
138
+ * or protocol failure must fail admission rather than run the child beside its parent's count.
160
139
  */
161
140
  export async function takeParentCpuTokens(parent: InheritedCpuPool, want: number): Promise<TokenGrant> {
162
141
  if (!Number.isSafeInteger(want) || want < 1) {
@@ -169,11 +148,7 @@ export async function takeParentCpuTokens(parent: InheritedCpuPool, want: number
169
148
  reason: `the parent CPU pool's endpoint ${JSON.stringify(parent.socket)} is not a socket path`,
170
149
  };
171
150
  }
172
- const lease = await holdLease(parent.socket, { op: 'cpu-pool', want }, 'the parent CPU pool', {
173
- ackMs: 2_000,
174
- afterCloseMs: 5_000,
175
- grantMs: null,
176
- });
151
+ const lease = await holdLease(parent.socket, { op: 'cpu-pool', want }, 'the parent CPU pool', new CpuLeaseWait());
177
152
  if (!lease.granted) {
178
153
  return lease;
179
154
  }
@@ -186,7 +161,7 @@ export async function takeParentCpuTokens(parent: InheritedCpuPool, want: number
186
161
  reason: `the parent CPU pool granted ${JSON.stringify(tokens)} tokens for ${want}`,
187
162
  };
188
163
  }
189
- return { granted: true, tokens, release: lease.release, closed: lease.closed, inherited: true };
164
+ return { granted: true, tokens, release: lease.release, closed: lease.closed };
190
165
  }
191
166
 
192
167
  /** A thrown value's message. */
@@ -339,14 +314,12 @@ function watchFifo(
339
314
 
340
315
  /**
341
316
  * Make a pool of `tokens` that lives while `closed` does: when `closed` resolves the pool refuses
342
- * grants, ends its child connections, drains its jobserver fifo and removes its directory. A child's
343
- * `host-wait` is reported to `waits` for as long as its connection holds it; a sub-pool reports to the
344
- * same `waits`. Setup failures are values; a non-positive or unsafe count is a programmer bug and throws.
317
+ * grants, ends its child connections, drains its jobserver fifo and removes its directory. Setup
318
+ * failures are values; a non-positive or unsafe count is a programmer bug and throws.
345
319
  */
346
320
  export async function createCpuPool(
347
321
  tokens: number,
348
322
  closed: Promise<void>,
349
- waits: HostWaits,
350
323
  ): Promise<{ ok: true; pool: CpuPool } | { ok: false; error: string }> {
351
324
  if (!Number.isSafeInteger(tokens) || tokens < 1) {
352
325
  throw new RangeError(`a CPU pool holds a positive safe integer of tokens, not ${tokens}`);
@@ -381,10 +354,15 @@ export async function createCpuPool(
381
354
  // Every failure the pool records, including one its listener reports while it runs. The outcome reads them.
382
355
  const failures: string[] = [];
383
356
  const queue: Waiter[] = [];
384
- // Allocated only for children that need the owner to serve their local sub-ledger.
385
- let subpools: Set<CpuPool> | undefined;
386
- let creating: Promise<void>[] | undefined;
387
357
  const children = new Set<Socket>();
358
+ // This callback runs on the pool's actor, so it proves the same loop that admits and grants is turning.
359
+ let progress = 0;
360
+ const heartbeat = setInterval(() => {
361
+ progress += 1;
362
+ for (const { child } of queue) {
363
+ if (child.socket.writable) child.socket.write(frame({ ok: true, progress }));
364
+ }
365
+ }, HEARTBEAT_MS);
388
366
  let resolveStarted!: (failure: Error | null) => void;
389
367
  const started = new Promise<Error | null>((done) => {
390
368
  resolveStarted = done;
@@ -461,34 +439,7 @@ export async function createCpuPool(
461
439
  const slot = granted > bytes;
462
440
  if (slot) slotLent = true;
463
441
  waiter.child.phase = { kind: 'holding', bytes, slot };
464
- if (!waiter.children) {
465
- waiter.child.socket.write(frame({ ok: true, lease: 'granted', tokens: granted }));
466
- continue;
467
- }
468
- const ended = new Promise<void>((done) => {
469
- if (waiter.child.socket.destroyed) done();
470
- else waiter.child.socket.once('close', done);
471
- });
472
- const creation = createCpuPool(granted, ended, waits).then(async (made) => {
473
- if (!made.ok) {
474
- failures.push(made.error);
475
- // Keep holding until close credits exactly this allocation once.
476
- waiter.child.socket.end(frame({ ok: false, code: 'invalid-request', error: made.error }));
477
- return;
478
- }
479
- subpools ??= new Set();
480
- subpools.add(made.pool);
481
- if (waiter.child.phase.kind !== 'holding' || closing) {
482
- const outcome = await made.pool.close();
483
- if (!outcome.ok) failures.push(outcome.error);
484
- return;
485
- }
486
- waiter.child.socket.write(
487
- frame({ ok: true, lease: 'granted', tokens: granted, pool: made.pool.environment[CPU_POOL_ENV] }),
488
- );
489
- });
490
- creating ??= [];
491
- creating.push(creation);
442
+ waiter.child.socket.write(frame({ ok: true, lease: 'granted', tokens: granted }));
492
443
  }
493
444
  stopWatching();
494
445
  if (!closing) returnTokens(inHand);
@@ -520,8 +471,6 @@ export async function createCpuPool(
520
471
  // A closing pool drains its fifo whole; until then the bytes go back for the next holder.
521
472
  if (child.phase.slot) slotLent = false;
522
473
  if (!closing) returnTokens(child.phase.bytes);
523
- } else if (child.phase.kind === 'waiting') {
524
- waits.end();
525
474
  }
526
475
  child.phase = { kind: 'done' };
527
476
  drain(0);
@@ -573,22 +522,12 @@ export async function createCpuPool(
573
522
  parsed = undefined;
574
523
  }
575
524
  if (!isRequest(parsed)) {
576
- refuse(
577
- child,
578
- 'a request is {"op":"cpu-pool","want":<a whole number of tokens, at least 1>} or {"op":"host-wait"}',
579
- );
525
+ refuse(child, 'a request is {"op":"cpu-pool","want":<a whole number of tokens, at least 1>}');
580
526
  return;
581
527
  }
582
528
  const request = parsed;
583
- if (request.op === 'host-wait') {
584
- // Counted from here until the connection closes, which `close` reports however it ends.
585
- child.phase = { kind: 'waiting' };
586
- waits.begin();
587
- socket.write(frame({ ok: true, wait: 'held' }));
588
- return;
589
- }
590
529
  child.phase = { kind: 'queued' };
591
- queue.push({ child, want: request.want, children: request.children === true });
530
+ queue.push({ child, want: request.want });
592
531
  socket.write(frame({ ok: true, lease: 'queued' }));
593
532
  drain(0);
594
533
  });
@@ -601,12 +540,14 @@ export async function createCpuPool(
601
540
  const shutdown = (): Promise<CloseOutcome> => {
602
541
  shut ??= (async (): Promise<CloseOutcome> => {
603
542
  closing = true;
543
+ clearInterval(heartbeat);
604
544
  stopWatching();
605
545
  await started;
606
546
  for (const socket of children) {
607
547
  socket.destroy();
608
548
  }
609
549
  if (listening) {
550
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: every accepted socket was destroyed just above, so the server closes without waiting on a peer
610
551
  await new Promise<void>((done) => {
611
552
  server.close((error) => {
612
553
  if (error) {
@@ -616,13 +557,6 @@ export async function createCpuPool(
616
557
  });
617
558
  });
618
559
  }
619
- if (creating !== undefined) await Promise.all(creating);
620
- if (subpools !== undefined) {
621
- for (const pool of subpools) {
622
- const outcome = await pool.close();
623
- if (!outcome.ok) failures.push(outcome.error);
624
- }
625
- }
626
560
  // The fifo's bytes are drained before it goes: a Cargo that outlives the pool keeps its descriptor and the tokens
627
561
  // it holds, and takes no more.
628
562
  try {