@smoothbricks/nx-plugin 0.5.7 → 0.6.1

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 (446) hide show
  1. package/README.md +1097 -360
  2. package/dist/.build-inputs.json +141 -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 +22 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +168 -48
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +28 -0
  62. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -0
  63. package/dist/executors/bounded-exec/cpu-pool-thread.js +20 -0
  64. package/dist/executors/bounded-exec/cpu-pool.d.ts +35 -38
  65. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/cpu-pool.js +56 -120
  67. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  68. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/executor.js +389 -239
  70. package/dist/executors/bounded-exec/gateway-lease.d.ts +23 -19
  71. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/gateway-lease.js +102 -29
  73. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  74. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  76. package/dist/executors/bounded-exec/lease-wait.d.ts +64 -0
  77. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lease-wait.js +72 -0
  79. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  80. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  82. package/dist/executors/bounded-exec/mbx-pool.d.ts +31 -0
  83. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/mbx-pool.js +24 -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 +10 -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 +122 -35
  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 +48 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +89 -20
  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/emit-overrides.d.ts +14 -0
  135. package/dist/executors/typescript-emit/emit-overrides.d.ts.map +1 -0
  136. package/dist/executors/typescript-emit/emit-overrides.js +24 -0
  137. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  138. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  139. package/dist/executors/typescript-emit/executor.js +146 -33
  140. package/dist/forbidden-spelling-policy.d.ts +56 -0
  141. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  142. package/dist/forbidden-spelling-policy.js +176 -0
  143. package/dist/generators/create-package/generator.d.ts.map +1 -1
  144. package/dist/generators/create-package/generator.js +3 -4
  145. package/dist/graph-input-contract.d.ts +14 -0
  146. package/dist/graph-input-contract.d.ts.map +1 -1
  147. package/dist/graph-input-contract.js +67 -2
  148. package/dist/index.d.ts +23 -6
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +672 -214
  151. package/dist/managed-assets.d.ts +2 -0
  152. package/dist/managed-assets.d.ts.map +1 -1
  153. package/dist/managed-files/files.d.ts +3 -3
  154. package/dist/managed-files/files.d.ts.map +1 -1
  155. package/dist/managed-files/files.js +28 -3
  156. package/dist/managed-files/managed-format.d.ts.map +1 -1
  157. package/dist/managed-files/managed-format.js +1 -0
  158. package/dist/managed-files/publish-workflow.js +14 -11
  159. package/dist/nextest-code-bound.js +1 -0
  160. package/dist/nextest-timings.d.ts +35 -0
  161. package/dist/nextest-timings.d.ts.map +1 -0
  162. package/dist/nextest-timings.js +168 -0
  163. package/dist/owned-installation.d.ts +6 -5
  164. package/dist/owned-installation.d.ts.map +1 -1
  165. package/dist/owned-installation.js +150 -26
  166. package/dist/package-target-policy.d.ts.map +1 -1
  167. package/dist/package-target-policy.js +2 -3
  168. package/dist/process-children.d.ts +7 -0
  169. package/dist/process-children.d.ts.map +1 -0
  170. package/dist/process-children.darwin.d.ts +7 -0
  171. package/dist/process-children.darwin.d.ts.map +1 -0
  172. package/dist/process-children.darwin.js +13 -0
  173. package/dist/process-children.js +14 -0
  174. package/dist/process-children.linux.d.ts +8 -0
  175. package/dist/process-children.linux.d.ts.map +1 -0
  176. package/dist/process-children.linux.js +25 -0
  177. package/dist/process-group.d.ts +108 -0
  178. package/dist/process-group.d.ts.map +1 -0
  179. package/dist/process-group.js +171 -0
  180. package/dist/process-listing.d.ts +7 -0
  181. package/dist/process-listing.d.ts.map +1 -0
  182. package/dist/process-listing.js +51 -0
  183. package/dist/producer-receipts.d.ts +8 -2
  184. package/dist/producer-receipts.d.ts.map +1 -1
  185. package/dist/producer-receipts.js +514 -47
  186. package/dist/task-graph-policy.d.ts +21 -0
  187. package/dist/task-graph-policy.d.ts.map +1 -0
  188. package/dist/task-graph-policy.js +91 -0
  189. package/dist/test-timings.js +4 -4
  190. package/dist/test-walk-policy.d.ts +14 -5
  191. package/dist/test-walk-policy.d.ts.map +1 -1
  192. package/dist/test-walk-policy.js +8 -2
  193. package/dist/testing.d.ts +73 -28
  194. package/dist/testing.d.ts.map +1 -1
  195. package/dist/testing.js +217 -223
  196. package/dist/tool-bins.d.ts +33 -0
  197. package/dist/tool-bins.d.ts.map +1 -0
  198. package/dist/tool-bins.js +72 -0
  199. package/dist/typecheck-test-policy.d.ts.map +1 -1
  200. package/dist/typecheck-test-policy.js +3 -4
  201. package/dist/wait-why-policy.d.ts +28 -0
  202. package/dist/wait-why-policy.d.ts.map +1 -0
  203. package/dist/wait-why-policy.js +223 -0
  204. package/dist/workspace-config-policy.d.ts +14 -8
  205. package/dist/workspace-config-policy.d.ts.map +1 -1
  206. package/dist/workspace-config-policy.js +60 -16
  207. package/dist/workspace-manifest.d.ts +41 -6
  208. package/dist/workspace-manifest.d.ts.map +1 -1
  209. package/dist/workspace-manifest.js +57 -0
  210. package/executors.json +16 -1
  211. package/loader.js +2 -0
  212. package/managed/raw/envrc +11 -0
  213. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  214. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  215. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  216. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  217. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  218. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  219. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  220. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  221. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  222. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  223. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  224. package/managed/raw/tooling/direnv/repo-path +68 -6
  225. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  226. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  227. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  228. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  229. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  230. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  231. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  232. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  233. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  234. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  235. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  236. package/package.json +95 -14
  237. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  238. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  239. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  240. package/src/bounded-test-policy.ts +12 -14
  241. package/src/build-state-output-policy.ts +458 -34
  242. package/src/bun-lock-scope.ts +108 -0
  243. package/src/cargo-build-script-env.ts +265 -0
  244. package/src/cargo-closure-input.ts +74 -7
  245. package/src/cargo-retention-hook.ts +94 -0
  246. package/src/cargo-source-hash.ts +138 -41
  247. package/src/cargo-toolchain-paths.ts +95 -0
  248. package/src/cargo-toolchain-policy.ts +49 -5
  249. package/src/cargo-workspace.ts +72 -123
  250. package/src/cross-check-policy.ts +12 -10
  251. package/src/disk-command-policy.ts +1 -0
  252. package/src/ensure-built-receipt.ts +173 -39
  253. package/src/ensure-built-witness.ts +62 -10
  254. package/src/ensure-built.ts +11 -1
  255. package/src/eslint-config-closure.ts +357 -0
  256. package/src/executors/bounded-exec/bounds.ts +76 -0
  257. package/src/executors/bounded-exec/cpu-pool-thread.ts +43 -0
  258. package/src/executors/bounded-exec/cpu-pool.ts +55 -120
  259. package/src/executors/bounded-exec/executor.ts +442 -260
  260. package/src/executors/bounded-exec/gateway-lease.ts +94 -35
  261. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  262. package/src/executors/bounded-exec/lease-wait.ts +116 -0
  263. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  264. package/src/executors/bounded-exec/mbx-pool.ts +48 -0
  265. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  266. package/src/executors/bounded-exec/progress.ts +9 -3
  267. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  268. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  269. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  270. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  271. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  272. package/src/executors/bounded-exec/run-cpu-pool.ts +129 -35
  273. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  274. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  275. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  276. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  277. package/src/executors/bounded-exec/schema.json +11 -2
  278. package/src/executors/bounded-exec/schema.ts +19 -1
  279. package/src/executors/bounded-exec/verdict.ts +145 -35
  280. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  281. package/src/executors/clean-outputs/executor.ts +1 -0
  282. package/src/executors/scriptc-native/executor.ts +394 -0
  283. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  284. package/src/executors/scriptc-native/schema.json +60 -0
  285. package/src/executors/scriptc-native/schema.ts +34 -0
  286. package/src/executors/typescript-emit/emit-overrides.ts +24 -0
  287. package/src/executors/typescript-emit/executor.ts +186 -38
  288. package/src/forbidden-spelling-policy.ts +226 -0
  289. package/src/generators/create-package/generator.ts +7 -7
  290. package/src/graph-input-contract.ts +61 -2
  291. package/src/index.ts +788 -224
  292. package/src/managed-assets.ts +3 -0
  293. package/src/managed-files/files.ts +28 -3
  294. package/src/managed-files/managed-format.ts +1 -0
  295. package/src/managed-files/publish-workflow.ts +20 -15
  296. package/src/nextest-code-bound.ts +1 -0
  297. package/src/nextest-timings.ts +106 -0
  298. package/src/owned-installation.ts +150 -23
  299. package/src/package-target-policy.ts +2 -3
  300. package/src/process-children.darwin.ts +14 -0
  301. package/src/process-children.linux.ts +33 -0
  302. package/src/process-children.ts +22 -0
  303. package/src/process-group.ts +209 -0
  304. package/src/process-listing.ts +54 -0
  305. package/src/producer-receipts.ts +92 -41
  306. package/src/task-graph-policy.ts +98 -0
  307. package/src/test-walk-policy.ts +23 -8
  308. package/src/testing.ts +240 -232
  309. package/src/tool-bins.ts +108 -0
  310. package/src/typecheck-test-policy.ts +2 -3
  311. package/src/wait-why-policy.ts +226 -0
  312. package/src/workspace-config-policy.ts +63 -15
  313. package/src/workspace-manifest.ts +89 -6
  314. package/test-timings.json +124 -99
  315. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  316. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  317. package/dist/bin/smoo-nx-failures.js +0 -3
  318. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  319. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  320. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  321. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  322. package/dist/failure-summary.d.ts +0 -5
  323. package/dist/failure-summary.d.ts.map +0 -1
  324. package/dist/failure-summary.js +0 -118
  325. package/dist/nextest-extraction.d.ts +0 -117
  326. package/dist/nextest-extraction.d.ts.map +0 -1
  327. package/dist/nextest-extraction.js +0 -303
  328. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  329. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  330. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  331. package/src/__tests__/counted-cargo-process.ts +0 -286
  332. package/src/__tests__/counted-cargo.ts +0 -713
  333. package/src/__tests__/directory-change.ts +0 -27
  334. package/src/__tests__/fixture-cargo-home.ts +0 -36
  335. package/src/__tests__/fixture-nx-env.ts +0 -193
  336. package/src/__tests__/owned-installation.ts +0 -13
  337. package/src/__tests__/past-tick.ts +0 -12
  338. package/src/__tests__/progress-clock.ts +0 -43
  339. package/src/__tests__/runtime-input.ts +0 -23
  340. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  341. package/src/bin/smoo-nx-failures.ts +0 -4
  342. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  343. package/src/bounded-test-policy.test.ts +0 -1029
  344. package/src/build-state-output-policy.test.ts +0 -115
  345. package/src/bun-bootstrap.test.ts +0 -102
  346. package/src/bun-file-packages.test.ts +0 -47
  347. package/src/cargo-closure-filesets.test.ts +0 -63
  348. package/src/cargo-closure-input.property.test.ts +0 -50
  349. package/src/cargo-closure-input.test.ts +0 -506
  350. package/src/cargo-closure-key.test.ts +0 -240
  351. package/src/cargo-resolve-cache.test.ts +0 -1181
  352. package/src/cargo-source-hash.test.ts +0 -707
  353. package/src/cargo-workspace.test.ts +0 -615
  354. package/src/cross-check-policy.test.ts +0 -316
  355. package/src/disk-command-policy.test.ts +0 -61
  356. package/src/ensure-built-receipt.test.ts +0 -279
  357. package/src/ensure-built-witness.test.ts +0 -688
  358. package/src/ensure-built.test.ts +0 -1462
  359. package/src/executors/all-verdicts/executor.test.ts +0 -135
  360. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  361. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  362. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  363. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  364. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  365. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  366. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  367. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  368. package/src/executors/bounded-exec/progress.test.ts +0 -139
  369. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  370. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  371. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  372. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  373. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  374. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  375. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  376. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  377. package/src/executors/clean-outputs/executor.test.ts +0 -20
  378. package/src/executors/typescript-emit/executor.test.ts +0 -83
  379. package/src/failure-summary.ts +0 -119
  380. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  381. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  382. package/src/generators/create-package/generator.test.ts +0 -190
  383. package/src/generators/make-public/generator.test.ts +0 -137
  384. package/src/graph-input-contract.test.ts +0 -379
  385. package/src/host-controller-wiring.test.ts +0 -31
  386. package/src/index.test.ts +0 -3321
  387. package/src/linked-snapshots.nx.test.ts +0 -254
  388. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  389. package/src/managed-files/generator.test.ts +0 -243
  390. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  391. package/src/managed-files/json-edit.test.ts +0 -216
  392. package/src/managed-files/managed-content.test.ts +0 -166
  393. package/src/managed-files/managed-format-json.test.ts +0 -308
  394. package/src/managed-files/repo-path.test.ts +0 -172
  395. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  396. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  397. package/src/managed-files/tree-permissions.test.ts +0 -109
  398. package/src/managed-files/tree.test.ts +0 -123
  399. package/src/manifest-hash.test.ts +0 -219
  400. package/src/nextest-code-bound.test.ts +0 -161
  401. package/src/nextest-extraction.test.ts +0 -216
  402. package/src/nextest-extraction.ts +0 -371
  403. package/src/nextest-partitions.test.ts +0 -501
  404. package/src/nx-cache-bound.test.ts +0 -109
  405. package/src/nx-cache-restore-mtime.test.ts +0 -170
  406. package/src/nx-daemon-claim.test.ts +0 -279
  407. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  408. package/src/nx-daemon-idle-policy.test.ts +0 -111
  409. package/src/nx-daemon-ignore-files.test.ts +0 -210
  410. package/src/nx-daemon-root-normalization.test.ts +0 -105
  411. package/src/nx-daemon-start-never.test.ts +0 -292
  412. package/src/nx-daemon-validity.test.ts +0 -1055
  413. package/src/nx-dot-input-policy.test.ts +0 -353
  414. package/src/nx-failure-life-cycles.test.ts +0 -207
  415. package/src/nx-files-archive-racy.test.ts +0 -97
  416. package/src/nx-foreign-workspace-env.test.ts +0 -329
  417. package/src/nx-incomplete-run-summary.test.ts +0 -70
  418. package/src/nx-plugin-load-errors.test.ts +0 -120
  419. package/src/nx-project-graph-errors.test.ts +0 -70
  420. package/src/nx-project-resolution-cache.test.ts +0 -176
  421. package/src/nx-raw-inputs.test.ts +0 -166
  422. package/src/nx-resident-graph-workers.test.ts +0 -112
  423. package/src/nx-run-information.test.ts +0 -118
  424. package/src/nx-skipped-task-exit.test.ts +0 -180
  425. package/src/nx-state-location.test.ts +0 -63
  426. package/src/nx-store-resolution.test.ts +0 -81
  427. package/src/nx-task-graph-cycles.test.ts +0 -148
  428. package/src/nx-task-output-lease.test.ts +0 -550
  429. package/src/nx-use-local.test.ts +0 -105
  430. package/src/owned-installation.test.ts +0 -105
  431. package/src/package-target-policy.test.ts +0 -1014
  432. package/src/producer-receipts.test.ts +0 -285
  433. package/src/release-config-policy.test.ts +0 -311
  434. package/src/runtime-input.test.ts +0 -393
  435. package/src/serial-group-wiring.test.ts +0 -326
  436. package/src/task-history-namespace.test.ts +0 -181
  437. package/src/task-results.test.ts +0 -228
  438. package/src/test-clock-policy.test.ts +0 -338
  439. package/src/test-program.test.ts +0 -303
  440. package/src/test-timings.test.ts +0 -240
  441. package/src/test-walk-policy.test.ts +0 -620
  442. package/src/testing.test.ts +0 -509
  443. package/src/typecheck-test-policy.test.ts +0 -1468
  444. package/src/typescript-resolution.test.ts +0 -76
  445. package/src/version-actions.test.ts +0 -80
  446. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,13 +1,14 @@
1
+ import { CpuLeaseWait, type CpuWaitRow } from './lease-wait.js';
1
2
  /**
2
- * The client half of a lease held on the cowshed gateway's control socket: the host
3
- * disk-lifecycle lease (`disk-lease.ts`) and the host CPU budget (`cpu-tokens.ts`) speak the same
4
- * protocol (specs/cowshed/05_gateway.md, "Disk-lifecycle lease" and "Host CPU budget").
3
+ * The client half of a lease held on a unix socket: the gateway's host disk-lifecycle lease
4
+ * (`disk-lease.ts`) and a parent's CPU pool (`cpu-pool.ts`) speak the same protocol
5
+ * (specs/cowshed/05_gateway.md, "Disk-lifecycle lease").
5
6
  *
6
7
  * The client writes one request line and keeps the connection open without half-closing it. The
7
8
  * gateway answers `queued` at once and `granted` when the lease is the client's, and the lease
8
9
  * lasts until the client closes the connection, so a client that dies holding one releases it with
9
- * its socket. A lease never decides whether a command runs: without a grant, it runs without one
10
- * and the caller says why.
10
+ * its socket. The caller decides what a refusal means: disk work may run unleased, while CPU
11
+ * admission fails rather than running outside its parent's count.
11
12
  */
12
13
  /** The cowshed gateway's control socket, at the store root every peer agrees on. */
13
14
  export declare const GATEWAY_SOCKET = "/private/cowshed/store/gateway.sock";
@@ -20,11 +21,19 @@ export interface LeaseBounds {
20
21
  grantMs: number | null;
21
22
  }
22
23
  /**
23
- * Why a command runs without a lease: no gateway listens, the gateway predates this kind of lease,
24
- * the gateway knows the lease but predates a field the request names (it refuses the field at
25
- * once), or any other refusal, silence or breakage.
24
+ * Why a lease is not held: no gateway listens, the gateway predates this kind of lease, the gateway
25
+ * knows the lease but predates a field the request names (it refuses the field at once), or any
26
+ * other refusal, silence or breakage.
26
27
  */
27
28
  export type UnleasedCause = 'absent' | 'predates' | 'predates-field' | 'other';
29
+ /** A refusal: the lease is not held, and why. A CPU wait that expired carries its typed row. */
30
+ export type Unleased = {
31
+ granted: false;
32
+ cause: UnleasedCause;
33
+ reason: string;
34
+ code?: string;
35
+ wait?: CpuWaitRow;
36
+ };
28
37
  /**
29
38
  * A granted lease with its `granted` answer, held until released, or why there is none. `closed`
30
39
  * resolves when the connection really closes: after `release`, when the gateway ends it, or when
@@ -35,18 +44,13 @@ export type HeldLease = {
35
44
  answer: Readonly<Record<string, unknown>>;
36
45
  release: () => void;
37
46
  closed: Promise<void>;
38
- } | {
39
- granted: false;
40
- cause: UnleasedCause;
41
- reason: string;
42
- code?: string;
43
- };
47
+ } | Unleased;
44
48
  /**
45
49
  * Ask the gateway at `socket` for the lease `request` names, `what` in its messages ("disk
46
- * leases", "the CPU budget"). A gateway from before one-line requests says nothing until it reads
47
- * EOF, so a request not queued within `ackMs` is half-closed and that gateway's refusal read; a
48
- * gateway that reads the line but does not know the operation refuses it at once. Both predate the
49
- * lease.
50
+ * leases", "the parent CPU pool"). A gateway from before one-line requests says nothing until it reads
51
+ * EOF, so a disk request not queued within its ack bound is half-closed to read that gateway's
52
+ * refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
53
+ * and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
50
54
  */
51
- export declare function holdLease(socket: string, request: Readonly<Record<string, unknown>>, what: string, bounds: LeaseBounds, onQueued?: () => void): Promise<HeldLease>;
55
+ export declare function holdLease(socket: string, request: Readonly<Record<string, unknown>>, what: string, bounds: LeaseBounds | CpuLeaseWait, onQueued?: () => void): Promise<HeldLease>;
52
56
  //# sourceMappingURL=gateway-lease.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gateway-lease.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/gateway-lease.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,oFAAoF;AACpF,eAAO,MAAM,cAAc,wCAAwC,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,gBAAgB,GAAG,OAAO,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACxG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,OAAO,CAAC,SAAS,CAAC,CAwHpB"}
1
+ {"version":3,"file":"gateway-lease.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/gateway-lease.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8C,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK5G;;;;;;;;;;GAUG;AAEH,oFAAoF;AACpF,eAAO,MAAM,cAAc,wCAAwC,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,gBAAgB,GAAG,OAAO,CAAC;AAE/E,gGAAgG;AAChG,MAAM,MAAM,QAAQ,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAElH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACxG,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAAG,YAAY,EAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,OAAO,CAAC,SAAS,CAAC,CA2KpB"}
@@ -1,23 +1,48 @@
1
+ import * as _isTypeUint32_1 from "typia/lib/internal/_isTypeUint32";
1
2
  import { connect } from 'node:net';
3
+ import typia from 'typia';
4
+ import { CpuLeaseWait } from './lease-wait.js';
5
+ const isCpuProgress = (() => {
6
+ const _io0 = (input, _exceptionable = true) => true === input.ok && "number" === typeof input.progress && (2 === Object.keys(input).length || Object.keys(input).every(key => {
7
+ if (["ok", "progress"].some(prop => key === prop))
8
+ return true;
9
+ const value = input[key];
10
+ if (undefined === value)
11
+ return true;
12
+ return false;
13
+ }));
14
+ return (input, _exceptionable = true) => "object" === typeof input && null !== input && _io0(input, true);
15
+ })();
16
+ const isCpuQueued = (() => {
17
+ const _io0 = (input, _exceptionable = true) => true === input.ok && "queued" === input.lease && ("number" === typeof input.server && _isTypeUint32_1._isTypeUint32(input.server)) && (3 === Object.keys(input).length || Object.keys(input).every(key => {
18
+ if (["ok", "lease", "server"].some(prop => key === prop))
19
+ return true;
20
+ const value = input[key];
21
+ if (undefined === value)
22
+ return true;
23
+ return false;
24
+ }));
25
+ return (input, _exceptionable = true) => "object" === typeof input && null !== input && _io0(input, true);
26
+ })();
2
27
  /**
3
- * The client half of a lease held on the cowshed gateway's control socket: the host
4
- * disk-lifecycle lease (`disk-lease.ts`) and the host CPU budget (`cpu-tokens.ts`) speak the same
5
- * protocol (specs/cowshed/05_gateway.md, "Disk-lifecycle lease" and "Host CPU budget").
28
+ * The client half of a lease held on a unix socket: the gateway's host disk-lifecycle lease
29
+ * (`disk-lease.ts`) and a parent's CPU pool (`cpu-pool.ts`) speak the same protocol
30
+ * (specs/cowshed/05_gateway.md, "Disk-lifecycle lease").
6
31
  *
7
32
  * The client writes one request line and keeps the connection open without half-closing it. The
8
33
  * gateway answers `queued` at once and `granted` when the lease is the client's, and the lease
9
34
  * lasts until the client closes the connection, so a client that dies holding one releases it with
10
- * its socket. A lease never decides whether a command runs: without a grant, it runs without one
11
- * and the caller says why.
35
+ * its socket. The caller decides what a refusal means: disk work may run unleased, while CPU
36
+ * admission fails rather than running outside its parent's count.
12
37
  */
13
38
  /** The cowshed gateway's control socket, at the store root every peer agrees on. */
14
39
  export const GATEWAY_SOCKET = '/private/cowshed/store/gateway.sock';
15
40
  /**
16
41
  * Ask the gateway at `socket` for the lease `request` names, `what` in its messages ("disk
17
- * leases", "the CPU budget"). A gateway from before one-line requests says nothing until it reads
18
- * EOF, so a request not queued within `ackMs` is half-closed and that gateway's refusal read; a
19
- * gateway that reads the line but does not know the operation refuses it at once. Both predate the
20
- * lease.
42
+ * leases", "the parent CPU pool"). A gateway from before one-line requests says nothing until it reads
43
+ * EOF, so a disk request not queued within its ack bound is half-closed to read that gateway's
44
+ * refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
45
+ * and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
21
46
  */
22
47
  export function holdLease(socket, request, what, bounds, onQueued) {
23
48
  // `Promise.withResolvers` would read better but needs lib es2024; this package inherits lib
@@ -26,6 +51,8 @@ export function holdLease(socket, request, what, bounds, onQueued) {
26
51
  const promise = new Promise((settled) => {
27
52
  resolve = settled;
28
53
  });
54
+ const cpu = bounds instanceof CpuLeaseWait ? bounds : null;
55
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: CPU connect/send is control-bounded and its answer heartbeat-silence-bounded by armCpu(); disk acknowledgement and half-close are bounded below, and a queued disk lease lasts until its holder releases it
29
56
  const connection = connect(socket);
30
57
  // `closed` is made when a consumer reads it, so a lease nobody watches allocates no promise. The
31
58
  // flag, not `connection.destroyed`, says the socket really closed: `destroy()` sets that flag before
@@ -46,51 +73,88 @@ export function holdLease(socket, request, what, bounds, onQueued) {
46
73
  }
47
74
  resolve(outcome);
48
75
  };
49
- const unleased = (reason, cause = 'other', code) => settle({ granted: false, cause, reason, ...(code === undefined ? {} : { code }) });
76
+ const unleased = (reason, cause = 'other', code, wait) => settle({
77
+ granted: false,
78
+ cause,
79
+ reason,
80
+ ...(code === undefined ? {} : { code }),
81
+ ...(wait === undefined ? {} : { wait }),
82
+ });
50
83
  const wait = (ms, onExpiry) => {
51
84
  clearTimeout(timer);
52
85
  timer = setTimeout(onExpiry, ms);
53
86
  };
87
+ const armCpu = () => {
88
+ if (cpu === null || state === 'settled')
89
+ return;
90
+ wait(cpu.remainingMs(), () => {
91
+ cpu.look();
92
+ const failure = cpu.expired();
93
+ if (failure === null) {
94
+ armCpu();
95
+ return;
96
+ }
97
+ const peer = failure.server === null ? socket : `${socket} (pid ${failure.server})`;
98
+ unleased(`${failure.code}: cpu-pool: the lease endpoint ${peer} exceeded ${failure.boundMs} ms (waited ${failure.elapsedMs} ms; last progress: ${failure.last})`, 'other', failure.code, { ...failure, socket });
99
+ });
100
+ };
101
+ armCpu();
54
102
  const answer = (line) => {
103
+ if (state === 'settled')
104
+ return;
55
105
  let parsed;
56
106
  try {
57
107
  parsed = JSON.parse(line);
58
108
  }
59
109
  catch {
60
- unleased(`the gateway answered something that is not an answer: ${line}`);
110
+ unleased(`the lease endpoint ${socket} answered something that is not an answer: ${line}`);
61
111
  return;
62
112
  }
63
113
  if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
64
- unleased(`the gateway answered something that is not an answer: ${line}`);
114
+ unleased(`the lease endpoint ${socket} answered something that is not an answer: ${line}`);
65
115
  return;
66
116
  }
67
117
  const fields = Object.fromEntries(Object.entries(parsed));
118
+ if (cpu !== null && isCpuProgress(parsed)) {
119
+ if (!cpu.heartbeat(parsed.progress)) {
120
+ unleased(`the lease endpoint ${socket} sent non-advancing CPU progress: ${line}`);
121
+ }
122
+ else {
123
+ armCpu();
124
+ }
125
+ return;
126
+ }
68
127
  const lease = fields.lease;
69
128
  if (fields.ok !== true) {
70
129
  const error = String(fields.error ?? '');
71
130
  const why = `${String(fields.code ?? 'refused')}: ${error}`;
72
131
  if (state === 'half-closed' || error.endsWith('unknown gateway control operation')) {
73
- unleased(`the gateway predates ${what} (${why}); restart it with \`cowshed setup\``, 'predates');
132
+ unleased(`the lease endpoint ${socket} predates ${what} (${why}); restart it with \`cowshed setup\``, 'predates');
74
133
  }
75
134
  else if (error.endsWith('contains an unknown field')) {
76
- unleased(`the gateway predates a field of ${what} (${why}); restart it with \`cowshed setup\``, 'predates-field');
135
+ unleased(`the lease endpoint ${socket} predates a field of ${what} (${why}); restart it with \`cowshed setup\``, 'predates-field');
77
136
  }
78
137
  else {
79
- unleased(`the gateway refused the lease (${why})`, 'other', typeof fields.code === 'string' ? fields.code : undefined);
138
+ unleased(`the lease endpoint ${socket} refused the lease (${why})`, 'other', typeof fields.code === 'string' ? fields.code : undefined);
80
139
  }
81
140
  }
82
141
  else if (state === 'half-closed') {
83
- unleased('the gateway did not queue the request in time; it is alive but overloaded');
142
+ unleased(`the lease endpoint ${socket} did not queue the request in time; it is alive but overloaded`);
84
143
  }
85
144
  else if (state === 'asked' && lease === 'queued') {
86
145
  state = 'queued';
87
146
  onQueued?.();
88
- const grantMs = bounds.grantMs;
89
- if (grantMs === null) {
147
+ if (bounds instanceof CpuLeaseWait) {
148
+ // A pool from before its acknowledgement named its process names none.
149
+ bounds.queued(isCpuQueued(parsed) ? parsed.server : null);
150
+ armCpu();
151
+ }
152
+ else if (bounds.grantMs === null) {
90
153
  clearTimeout(timer);
91
154
  }
92
155
  else {
93
- wait(grantMs, () => unleased(`the gateway granted nothing within ${grantMs} ms`));
156
+ const grantMs = bounds.grantMs;
157
+ wait(grantMs, () => unleased(`the lease endpoint ${socket} granted nothing within ${grantMs} ms`));
94
158
  }
95
159
  }
96
160
  else if (state === 'queued' && lease === 'granted') {
@@ -101,23 +165,32 @@ export function holdLease(socket, request, what, bounds, onQueued) {
101
165
  get closed() {
102
166
  closed ??= socketClosed
103
167
  ? Promise.resolve()
104
- : new Promise((done) => connection.once('close', () => done()));
168
+ : // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a held lease's connection lasts as long as its holder keeps it; release() destroys it on this side, and the gateway's own end closes it too
169
+ new Promise((done) => connection.once('close', () => done()));
105
170
  return closed;
106
171
  },
107
172
  });
108
173
  }
109
174
  else {
110
- unleased(`the gateway answered out of turn: ${line}`);
175
+ unleased(`the lease endpoint ${socket} answered out of turn: ${line}`);
111
176
  }
112
177
  };
113
178
  connection.on('connect', () => {
114
179
  state = 'asked';
115
- connection.write(`${JSON.stringify(request)}\n`);
116
- wait(bounds.ackMs, () => {
117
- state = 'half-closed';
118
- connection.end();
119
- wait(bounds.afterCloseMs, () => unleased('the gateway answered nothing'));
120
- });
180
+ if (bounds instanceof CpuLeaseWait) {
181
+ connection.write(`${JSON.stringify(request)}\n`, () => {
182
+ bounds.sent();
183
+ armCpu();
184
+ });
185
+ }
186
+ else {
187
+ connection.write(`${JSON.stringify(request)}\n`);
188
+ wait(bounds.ackMs, () => {
189
+ state = 'half-closed';
190
+ connection.end();
191
+ wait(bounds.afterCloseMs, () => unleased(`the lease endpoint ${socket} answered nothing`));
192
+ });
193
+ }
121
194
  });
122
195
  connection.on('data', (chunk) => {
123
196
  buffered += chunk.toString('utf8');
@@ -129,7 +202,7 @@ export function holdLease(socket, request, what, bounds, onQueued) {
129
202
  });
130
203
  connection.on('error', (error) => {
131
204
  if (state === 'connecting') {
132
- unleased(`the gateway's control socket ${socket} does not answer (${error.message})`, 'absent');
205
+ unleased(`nothing answers for ${what} at ${socket} (${error.message})`, 'absent');
133
206
  }
134
207
  else {
135
208
  unleased(error.message);
@@ -137,7 +210,7 @@ export function holdLease(socket, request, what, bounds, onQueued) {
137
210
  });
138
211
  connection.on('close', () => {
139
212
  socketClosed = true;
140
- unleased('the gateway closed the lease connection');
213
+ unleased(`the lease connection for ${what} at ${socket} closed`);
141
214
  });
142
215
  return promise;
143
216
  }
@@ -1,10 +1,17 @@
1
- export declare const HANG_CAPTURE_MS = 5000;
1
+ import { type LockWait } from './lock-wait.js';
2
+ /**
3
+ * The pre-expiry capture window. Stack samples set it: under load averages of 27-52 on 18 cores one `sudo -n sample`
4
+ * took 1.1-4.6 s, and in a five-second window two of eight real captures lost their sample at its limit.
5
+ */
6
+ export declare const HANG_CAPTURE_MS = 10000;
2
7
  export interface HangDiagnostics {
3
8
  startedAtMs: number;
4
9
  capturedAtMs: number;
5
10
  /** Positive when the observation completed before the idle expiry. */
6
11
  offsetFromExpiryMs: number;
7
12
  outcome: 'holders' | 'none' | 'incomplete';
13
+ /** Lock waits the snapshot names: empty unless the capture is complete, and always empty without the open-file census. */
14
+ lockWaits: readonly LockWait[];
8
15
  text: string;
9
16
  }
10
17
  export interface HangCaptureRequest {
@@ -32,4 +39,14 @@ export interface HangDiagnosticHost {
32
39
  }
33
40
  /** A pre-expiry observation, never an assertion that an open file is a contested lock. */
34
41
  export declare function captureHangDiagnostics(request: HangCaptureRequest, source?: HangDiagnosticHost): Promise<HangDiagnostics>;
42
+ /**
43
+ * Ends a probe at its limit without waiting for it, and says whether its group still lists members. An ordinary probe
44
+ * runs as this user, so SIGKILL to its process group ends it and anything it started, and the kill is repeated while
45
+ * the group lists members, since one forked as the signal goes out survives it. `sudo` keeps this user's real uid but
46
+ * runs its command as root, which no signal from this user reaches: a group SIGKILL would end sudo alone and orphan
47
+ * the command. Signalled itself, sudo relays SIGTERM to its command and exits only after it. While sudo starts it
48
+ * holds root's real uid, and this throws EPERM. A probe is its caller's child and stays unreaped while the caller
49
+ * waits here, and the kernel lists it as a member of its own group until then, so a group left listed is expected.
50
+ */
51
+ export declare function stopProbe(file: string, pid: number): boolean;
35
52
  //# sourceMappingURL=hang-diagnostics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,OAAQ,CAAC;AAIrC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChH;AAUD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,kBAAyB,GAChC,OAAO,CAAC,eAAe,CAAC,CAyK1B"}
1
+ {"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAkCtC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IAC3C,0HAA0H;IAC1H,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChH;AAUD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,kBAAyB,GAChC,OAAO,CAAC,eAAe,CAAC,CAuP1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAM5D"}
@@ -1,8 +1,41 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from '../../process-group.js';
2
3
  import { withDescendants } from '../../testing.js';
3
- export const HANG_CAPTURE_MS = 5_000;
4
+ import { describeHolders, lockCandidates, lockWaits, parseLsofFields, parseLsofTable, } from './lock-wait.js';
5
+ /**
6
+ * The pre-expiry capture window. Stack samples set it: under load averages of 27-52 on 18 cores one `sudo -n sample`
7
+ * took 1.1-4.6 s, and in a five-second window two of eight real captures lost their sample at its limit.
8
+ */
9
+ export const HANG_CAPTURE_MS = 10_000;
4
10
  const MAX_PROBE_BYTES = 4 * 1024 * 1024;
5
11
  const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,lstart=,command=';
12
+ /**
13
+ * Stack samples: `sample` suspends a process every millisecond for one second and reports its threads' call graph. The
14
+ * runner and at most this many leaf processes are sampled, all at once. `-mayDie` is not passed: it reads symbols
15
+ * before sampling and measured about a second slower under load, and a process that exits mid-sample is a raced
16
+ * capture all the same.
17
+ */
18
+ const MAX_SAMPLED_LEAVES = 4;
19
+ const SAMPLE_SECONDS = 1;
20
+ /**
21
+ * A process census's limit. The stack samples run until the closing census is this far from the window's end.
22
+ */
23
+ const CENSUS_LIMIT_MS = 1_000;
24
+ /**
25
+ * lsof's mount-table fallback (darwin libproc dmnt.c, readmnt()): a mount it cannot stat(), such as one detaching under a
26
+ * concurrent shed, is kept with its mount-table device. Descriptors come per process from libproc, so this warning omits
27
+ * none of the selected processes' rows.
28
+ */
29
+ const LSOF_MOUNT_FALLBACK = /^lsof: WARNING: can't stat\(\) \S+ file system .*\n {6}Output information may be incomplete\.\n {6}assuming "dev=[0-9a-f]+" from mount table\n/gm;
30
+ /** The lsof stderr that makes its census incomplete: everything except its mount-table fallback. */
31
+ function lsofFaults(stderr) {
32
+ return stderr.replace(LSOF_MOUNT_FALLBACK, '').trim();
33
+ }
34
+ /** A `sample` report up to its binary-image list: its header and call graph name the stacks; the load map is bulk. */
35
+ function callGraph(report) {
36
+ const end = report.indexOf('\nBinary Images:');
37
+ return (end === -1 ? report : report.slice(0, end)).trim();
38
+ }
6
39
  const host = { platform: process.platform, probe: runProbe };
7
40
  /** A pre-expiry observation, never an assertion that an open file is a contested lock. */
8
41
  export function captureHangDiagnostics(request, source = host) {
@@ -14,8 +47,10 @@ export function captureHangDiagnostics(request, source = host) {
14
47
  `Hang snapshot: pid=${request.pid} pgid=${request.pgid ?? 'unknown'} startedAtMs=${startedAtMs}`,
15
48
  'Open files and process observations are evidence, not proof of a contested lock or its owner.',
16
49
  ];
17
- let active = 'process census';
50
+ const active = new Set();
51
+ const during = () => (active.size === 0 ? 'process census' : [...active].join(', '));
18
52
  let finished = false;
53
+ let waits = [];
19
54
  // This package targets lib es2022, which does not declare Promise.withResolvers.
20
55
  return new Promise((resolve) => {
21
56
  const finish = (outcome) => {
@@ -32,17 +67,18 @@ export function captureHangDiagnostics(request, source = host) {
32
67
  capturedAtMs,
33
68
  offsetFromExpiryMs,
34
69
  outcome,
70
+ lockWaits: outcome === 'incomplete' ? [] : waits,
35
71
  text: `${lines.join('\n')}\nHang snapshot outcome=${outcome} capturedAtMs=${capturedAtMs} offsetFromExpiryMs=${offsetFromExpiryMs}\n`,
36
72
  });
37
73
  };
38
74
  const timer = setTimeout(() => {
39
- lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${active}; no empty-holder conclusion.`);
75
+ lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${during()}; no empty-holder conclusion.`);
40
76
  finish('incomplete');
41
77
  }, budgetMs);
42
78
  const cancelled = () => {
43
79
  if (finished)
44
80
  return;
45
- lines.push(`Capture cancelled during ${active}; its progress generation is no longer current.`);
81
+ lines.push(`Capture cancelled during ${during()}; its progress generation is no longer current.`);
46
82
  finish('incomplete');
47
83
  };
48
84
  request.signal?.addEventListener('abort', cancelled, { once: true });
@@ -56,9 +92,10 @@ export function captureHangDiagnostics(request, source = host) {
56
92
  return;
57
93
  }
58
94
  const probe = async (name, file, args, limitMs) => {
59
- active = name;
95
+ active.add(name);
60
96
  lines.push(`${name}: ${file} ${args.join(' ')}`);
61
97
  const result = await source.probe(file, args, Math.max(0, Math.min(limitMs, endsAtMs - Date.now())), controller.signal);
98
+ active.delete(name);
62
99
  if (!finished) {
63
100
  lines.push(`${name}: ${result.status}${result.status === 'exited' ? ` code=${result.code}` : ` ${result.detail}`}`);
64
101
  if (result.stderr.trim() !== '')
@@ -67,8 +104,8 @@ export function captureHangDiagnostics(request, source = host) {
67
104
  return result;
68
105
  };
69
106
  const census = async (name) => {
70
- // Bare `ps`, resolved through PATH like testing.ts's processTable: NixOS has no /bin/ps.
71
- const result = await probe(name, 'ps', ['-A', '-o', PS_FIELDS], 1_000);
107
+ // Bare `ps`, resolved through PATH like testing.ts's processesOf: NixOS has no /bin/ps.
108
+ const result = await probe(name, 'ps', ['-A', '-o', PS_FIELDS], CENSUS_LIMIT_MS);
72
109
  if (finished)
73
110
  return null;
74
111
  if (result.status !== 'exited' || result.code !== 0) {
@@ -105,6 +142,37 @@ export function captureHangDiagnostics(request, source = host) {
105
142
  }
106
143
  return tree;
107
144
  };
145
+ /**
146
+ * One-second call stacks of the runner and of its tree's leaf processes, taken at once: a stack names the call a
147
+ * process waits in, which the open-file census cannot. A sample sudo refuses, or one that does not answer, is named
148
+ * as no stack for that process; stacks never change the holder outcome.
149
+ */
150
+ const stackSamples = async (tree) => {
151
+ const live = tree.filter((entry) => !entry.stat.startsWith('Z'));
152
+ const parents = new Set(live.map((entry) => entry.ppid));
153
+ const leaves = live.filter((entry) => entry.pid !== request.pid && !parents.has(entry.pid));
154
+ const omitted = leaves.slice(MAX_SAMPLED_LEAVES).map((entry) => entry.pid);
155
+ if (omitted.length > 0)
156
+ lines.push(`Stack samples bounded to the runner and ${MAX_SAMPLED_LEAVES} leaf processes; not sampled: pid ${omitted.join(', ')}`);
157
+ const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
158
+ const sampled = [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)];
159
+ await Promise.all(sampled.map(async (pid) => {
160
+ const name = `stack sample pid ${pid}`;
161
+ // `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
162
+ const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
163
+ const result = await probe(name, 'sudo', args, limitMs);
164
+ if (finished)
165
+ return;
166
+ const report = callGraph(result.stdout);
167
+ if (result.status === 'exited' && result.code === 0 && report !== '') {
168
+ lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
169
+ return;
170
+ }
171
+ if (report !== '')
172
+ lines.push(`Partial ${name} output:\n${report}`);
173
+ lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
174
+ }));
175
+ };
108
176
  const collect = async () => {
109
177
  const before = await census('ps before');
110
178
  if (finished)
@@ -114,31 +182,58 @@ export function captureHangDiagnostics(request, source = host) {
114
182
  let incomplete = false;
115
183
  let observed = before.length > 0;
116
184
  if (source.platform === 'darwin') {
117
- const args = ['-nP', '-p', before.map((entry) => entry.pid).join(',')];
118
- // Bare `sudo`/`lsof` through PATH, like `ps` above: NixOS provides neither /usr/bin/sudo nor /usr/sbin/lsof.
119
- let resources = await probe('lsof privileged', 'sudo', ['-n', 'lsof', ...args], 1_500);
120
- if (finished)
121
- return;
122
- const answered = (result) => result.status === 'exited' && (result.code === 0 || (result.code === 1 && result.stderr.trim() === ''));
123
- if (!answered(resources)) {
124
- incomplete = true;
125
- if (resources.stdout.trim() !== '')
126
- lines.push(`Partial privileged lsof output:\n${resources.stdout.trimEnd()}`);
127
- lines.push('Privileged resource census unavailable; fallback is ordinary-user visibility only, not proof of no holders.');
128
- resources = await probe('lsof user-scoped fallback', 'lsof', args, 1_000);
185
+ const openFiles = async () => {
186
+ const args = ['-nP', '-p', before.map((entry) => entry.pid).join(',')];
187
+ // Bare `sudo`/`lsof` through PATH, like `ps` above: NixOS provides neither /usr/bin/sudo nor /usr/sbin/lsof.
188
+ let resources = await probe('lsof privileged', 'sudo', ['-n', 'lsof', ...args], 1_500);
129
189
  if (finished)
130
190
  return;
131
- }
132
- if (resources.stdout.trim() !== '')
133
- lines.push(`lsof open files/sockets (not contested-lock proof):\n${resources.stdout.trimEnd()}`);
134
- if (!answered(resources) || resources.stderr.trim() !== '')
135
- incomplete = true;
136
- observed = resources.stdout.trim() !== '';
137
- if (!observed && answered(resources))
138
- lines.push('lsof reported no open-file matches within its stated visibility.');
191
+ const answered = (result) => result.status === 'exited' &&
192
+ (result.code === 0 || (result.code === 1 && lsofFaults(result.stderr) === ''));
193
+ if (!answered(resources)) {
194
+ incomplete = true;
195
+ if (resources.stdout.trim() !== '')
196
+ lines.push(`Partial privileged lsof output:\n${resources.stdout.trimEnd()}`);
197
+ lines.push('Privileged resource census unavailable; fallback is ordinary-user visibility only, not proof of no holders.');
198
+ resources = await probe('lsof user-scoped fallback', 'lsof', args, 1_000);
199
+ if (finished)
200
+ return;
201
+ }
202
+ if (resources.stdout.trim() !== '')
203
+ lines.push(`lsof open files/sockets (not contested-lock proof):\n${resources.stdout.trimEnd()}`);
204
+ if (!answered(resources) || lsofFaults(resources.stderr) !== '')
205
+ incomplete = true;
206
+ else if (resources.stderr.trim() !== '')
207
+ lines.push('lsof warned only that it could not stat() the named mounts and kept their mount-table devices; that omits no descriptor of the selected processes.');
208
+ observed = resources.stdout.trim() !== '';
209
+ if (!observed && answered(resources))
210
+ lines.push('lsof reported no open-file matches within its stated visibility.');
211
+ // A lock wait needs a complete census of the run's files: a regular file the run holds on a numbered descriptor
212
+ // that another process also holds open. One privileged lsof names those holders; a probe that did not answer
213
+ // makes the capture incomplete, never an empty holder set.
214
+ const rows = incomplete ? [] : parseLsofTable(resources.stdout);
215
+ const candidates = lockCandidates(rows);
216
+ if (candidates.length > 0) {
217
+ const holders = await probe('lsof lock holders', 'sudo', ['-n', 'lsof', '-nP', '-F', 'pcn', '--', ...candidates], 1_500);
218
+ if (finished)
219
+ return;
220
+ const openers = answered(holders) && lsofFaults(holders.stderr) === '' ? parseLsofFields(holders.stdout) : null;
221
+ if (openers === null) {
222
+ incomplete = true;
223
+ lines.push('Lock holder census incomplete; no lock wait is named.');
224
+ }
225
+ else {
226
+ waits = lockWaits(rows, new Set(before.map((entry) => entry.pid)), openers);
227
+ }
228
+ }
229
+ };
230
+ await Promise.all([openFiles(), stackSamples(before)]);
231
+ if (finished)
232
+ return;
139
233
  }
140
234
  else {
141
235
  lines.push(`Open-file census not provided on ${source.platform}; observations below name processes only.`);
236
+ lines.push(`Stack samples not provided on ${source.platform}; no blocking call is observed.`);
142
237
  }
143
238
  const after = await census('ps after');
144
239
  if (finished)
@@ -155,16 +250,37 @@ export function captureHangDiagnostics(request, source = host) {
155
250
  incomplete = true;
156
251
  lines.push('Process identities or membership changed during capture; open-file census raced.');
157
252
  }
253
+ if (!incomplete) {
254
+ for (const wait of waits) {
255
+ lines.push(`Lock wait (open-handle evidence, not a kernel lock owner): ${wait.path} open in the run by pid ${wait.waiters.join(', ')} and outside it by ${describeHolders(wait.holders)}`);
256
+ }
257
+ }
158
258
  finish(incomplete ? 'incomplete' : observed ? 'holders' : 'none');
159
259
  };
160
260
  void collect().catch((error) => {
161
261
  if (finished)
162
262
  return;
163
- lines.push(`Capture incomplete during ${active}: ${error instanceof Error ? error.message : String(error)}`);
263
+ lines.push(`Capture incomplete during ${during()}: ${error instanceof Error ? error.message : String(error)}`);
164
264
  finish('incomplete');
165
265
  });
166
266
  });
167
267
  }
268
+ /**
269
+ * Ends a probe at its limit without waiting for it, and says whether its group still lists members. An ordinary probe
270
+ * runs as this user, so SIGKILL to its process group ends it and anything it started, and the kill is repeated while
271
+ * the group lists members, since one forked as the signal goes out survives it. `sudo` keeps this user's real uid but
272
+ * runs its command as root, which no signal from this user reaches: a group SIGKILL would end sudo alone and orphan
273
+ * the command. Signalled itself, sudo relays SIGTERM to its command and exits only after it. While sudo starts it
274
+ * holds root's real uid, and this throws EPERM. A probe is its caller's child and stays unreaped while the caller
275
+ * waits here, and the kernel lists it as a member of its own group until then, so a group left listed is expected.
276
+ */
277
+ export function stopProbe(file, pid) {
278
+ if (file === 'sudo') {
279
+ process.kill(pid, 'SIGTERM');
280
+ return false;
281
+ }
282
+ return killProcessGroupNow(pid, TEARDOWN_PATIENCE);
283
+ }
168
284
  /** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
169
285
  function runProbe(file, args, timeoutMs, signal) {
170
286
  // Keep the package's es2022-compatible event-completion convention.
@@ -195,10 +311,12 @@ function runProbe(file, args, timeoutMs, signal) {
195
311
  let killFailure = '';
196
312
  if (child.pid !== undefined) {
197
313
  try {
198
- process.kill(-child.pid, 'SIGKILL');
314
+ if (stopProbe(file, child.pid)) {
315
+ killFailure = `; probe group cleanup: ${describeTeardown({ command: file, group: child.pid })}`;
316
+ }
199
317
  }
200
318
  catch (error) {
201
- killFailure = `; probe group cleanup: ${error instanceof Error ? error.message : String(error)}`;
319
+ killFailure = `; probe ${file === 'sudo' ? 'stop through sudo' : 'group cleanup'}: ${error instanceof Error ? error.message : String(error)}`;
202
320
  }
203
321
  }
204
322
  finish({ status, detail: detail + killFailure, stdout, stderr });