@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,207 @@
1
+ import { connect } from 'node:net';
2
+ import { readDetachAnswer } from './ram-detach.js';
3
+ /**
4
+ * The client of the cowshed gateway's `ram-lease` (specs/cowshed/05_gateway.md, "RAM disks"). The RAM temp volume's
5
+ * disk lives in the `diskimages-helper` that `hdiutil attach ram://<n>` forks. Forked inside a task's job, the helper is
6
+ * that job's member, and the job's end retires it with the disk under every other job's lease on the volume. The helper
7
+ * belongs to the gateway, which no job contains and which attaches the disk; no job's retirement reaches it.
8
+ *
9
+ * The client writes one line, `{"op":"ram-lease","sectors":<n>}`, and keeps its connection open; the gateway answers
10
+ * one line, `{"ok":true,"ramDisk":{"device":"/dev/diskN","registryEntry":"0x…"}}` or a refusal. The connection is the
11
+ * lease: the gateway holds the disk until the client writes `{"end":"keep"}`, after which the disk is the caller's, or
12
+ * `{"end":"release"}`, which the gateway answers with its detach as `ram-detach` does. A connection that ends first,
13
+ * at the client's deadline or with its process, has the gateway detach the disk. An end the gateway never answers leaves
14
+ * nothing known: the gateway may have handed the disk over or left it to its next startup scan, so the caller detaches it
15
+ * by its entry.
16
+ */
17
+ export const RAM_LEASE_OP = 'ram-lease';
18
+ const WHOLE_DISK = /^\/dev\/disk\d+$/;
19
+ const REGISTRY_ENTRY = /^0x[0-9a-f]+$/;
20
+ /** A release answers what `ram-detach` does, whose native output the gateway bounds; no answer grows past that. */
21
+ const ANSWER_BYTES_MAX = 2 * 64 * 1024 * 6 + 4096;
22
+ /** Ask the gateway at `socket` for a RAM disk of `sectors` 512-byte sectors; its lease, or why there is none. */
23
+ export async function attachRamDisk(socket, sectors, deadlineMs) {
24
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a unix-socket connect completes or fails at once, and every answer on it is awaited by next(deadlineMs), whose timer ends the wait
25
+ const connection = connect(socket);
26
+ const next = answers(connection);
27
+ connection.on('connect', () => connection.write(`${JSON.stringify({ op: RAM_LEASE_OP, sectors })}\n`));
28
+ const granted = readGrant(await next(deadlineMs), socket, deadlineMs);
29
+ if (!granted.ok) {
30
+ connection.destroy();
31
+ return granted;
32
+ }
33
+ // The open connection is the lease; it never keeps this process alive on its own.
34
+ connection.unref();
35
+ return { ok: true, value: heldLease(connection, next, granted.value, deadlineMs) };
36
+ }
37
+ /** The connection's answer lines, one per call, each awaited for at most `deadlineMs`. */
38
+ function answers(connection) {
39
+ let received = '';
40
+ let gone = null;
41
+ let waiting = null;
42
+ const deliver = () => {
43
+ const wake = waiting;
44
+ if (wake === null)
45
+ return;
46
+ const newline = received.indexOf('\n');
47
+ let next = gone;
48
+ if (newline >= 0) {
49
+ next = { kind: 'line', line: received.slice(0, newline) };
50
+ received = received.slice(newline + 1);
51
+ }
52
+ else if (gone !== null && received !== '') {
53
+ next = { kind: 'line', line: received };
54
+ received = '';
55
+ }
56
+ if (next === null)
57
+ return;
58
+ waiting = null;
59
+ wake(next);
60
+ };
61
+ connection.on('data', (chunk) => {
62
+ received += chunk.toString('utf8');
63
+ if (received.length <= ANSWER_BYTES_MAX)
64
+ return deliver();
65
+ received = '';
66
+ connection.destroy(new Error(`the gateway's answer exceeds ${ANSWER_BYTES_MAX} bytes`));
67
+ });
68
+ connection.on('error', (error) => {
69
+ gone ??= { kind: 'failed', error };
70
+ deliver();
71
+ });
72
+ connection.on('close', () => {
73
+ gone ??= { kind: 'closed' };
74
+ deliver();
75
+ });
76
+ return (deadlineMs) => new Promise((resolve) => {
77
+ const timer = setTimeout(() => {
78
+ waiting = null;
79
+ resolve({ kind: 'late' });
80
+ }, deadlineMs);
81
+ waiting = (next) => {
82
+ clearTimeout(timer);
83
+ resolve(next);
84
+ };
85
+ deliver();
86
+ });
87
+ }
88
+ /** The lease the attach answer grants, or why it grants none. */
89
+ function readGrant(next, socket, deadlineMs) {
90
+ switch (next.kind) {
91
+ case 'late':
92
+ return {
93
+ ok: false,
94
+ error: `the gateway answered no ram-lease within ${deadlineMs} ms; this client closed the lease, so the gateway detaches any disk its attach still makes`,
95
+ };
96
+ case 'failed':
97
+ return {
98
+ ok: false,
99
+ error: 'code' in next.error && (next.error.code === 'ENOENT' || next.error.code === 'ECONNREFUSED')
100
+ ? {
101
+ kind: 'ram-unavailable',
102
+ reason: 'gateway-absent',
103
+ detail: `gateway ${socket} is unavailable: ${next.error.message}`,
104
+ }
105
+ : `gateway ram-lease I/O failed: ${next.error.message}`,
106
+ };
107
+ case 'closed':
108
+ return { ok: false, error: 'the gateway closed ram-lease without an answer' };
109
+ case 'line':
110
+ return readAnswer(next.line);
111
+ }
112
+ }
113
+ /** The fields of one JSON object answer line, or null for anything else. */
114
+ function fieldsOf(line) {
115
+ let parsed;
116
+ try {
117
+ parsed = JSON.parse(line);
118
+ }
119
+ catch {
120
+ return null;
121
+ }
122
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
123
+ ? Object.fromEntries(Object.entries(parsed))
124
+ : null;
125
+ }
126
+ /** The whole disk and registry entry a `ram-lease` answer names, or why the answer names none. */
127
+ function readAnswer(line) {
128
+ const fields = fieldsOf(line);
129
+ if (fields === null) {
130
+ return { ok: false, error: `the gateway answered ram-lease with something that is not an answer: ${line}` };
131
+ }
132
+ if (fields.ok !== true) {
133
+ const why = `${String(fields.code ?? 'refused')}: ${String(fields.error ?? '')}`;
134
+ return {
135
+ ok: false,
136
+ error: String(fields.error ?? '').endsWith('unknown gateway control operation')
137
+ ? { kind: 'ram-unavailable', reason: 'gateway-unsupported', detail: `gateway predates ram-lease (${why})` }
138
+ : `the gateway refused ram-lease (${why})`,
139
+ };
140
+ }
141
+ const ramDisk = fields.ramDisk;
142
+ const device = typeof ramDisk === 'object' && ramDisk !== null && 'device' in ramDisk && typeof ramDisk.device === 'string'
143
+ ? ramDisk.device
144
+ : null;
145
+ const registryEntry = typeof ramDisk === 'object' &&
146
+ ramDisk !== null &&
147
+ 'registryEntry' in ramDisk &&
148
+ typeof ramDisk.registryEntry === 'string'
149
+ ? ramDisk.registryEntry
150
+ : null;
151
+ return device !== null && WHOLE_DISK.test(device) && registryEntry !== null && REGISTRY_ENTRY.test(registryEntry)
152
+ ? { ok: true, value: { device, registryEntry } }
153
+ : { ok: false, error: `the gateway's ram-lease answer names no whole disk and registry entry: ${line}` };
154
+ }
155
+ /** The lease `connection` holds on `disk`; each end is one line, half-closed, whose answer is awaited `deadlineMs`. */
156
+ function heldLease(connection, next, disk, deadlineMs) {
157
+ let ended = null;
158
+ const end = async (how) => {
159
+ if (ended !== null) {
160
+ return {
161
+ ok: false,
162
+ error: `the ram-lease of ${disk.device} already ended at its ${ended}; nothing is known of a detach`,
163
+ };
164
+ }
165
+ ended = how;
166
+ connection.end(`${JSON.stringify({ end: how })}\n`);
167
+ const answer = await next(deadlineMs);
168
+ connection.destroy();
169
+ if (answer.kind === 'line')
170
+ return { ok: true, value: answer.line };
171
+ const why = answer.kind === 'late'
172
+ ? `none within ${deadlineMs} ms`
173
+ : answer.kind === 'failed'
174
+ ? answer.error.message
175
+ : 'it closed the connection';
176
+ return {
177
+ ok: false,
178
+ error: `the gateway answered no ${how} of the ram-lease of ${disk.device} (${why}): ${how === 'keep'
179
+ ? 'nothing is known: the gateway may have handed the disk over or left it to its next startup scan; detach it by its entry'
180
+ : 'the lease is lost, so nothing is known of a detach'}`,
181
+ };
182
+ };
183
+ return {
184
+ device: disk.device,
185
+ registryEntry: disk.registryEntry,
186
+ async keep() {
187
+ const answer = await end('keep');
188
+ if (!answer.ok)
189
+ return answer;
190
+ return fieldsOf(answer.value)?.ok === true
191
+ ? { ok: true, value: undefined }
192
+ : { ok: false, error: `the gateway refused to keep the ram-lease of ${disk.device}: ${answer.value}` };
193
+ },
194
+ async release() {
195
+ const answer = await end('release');
196
+ if (!answer.ok)
197
+ return answer;
198
+ const output = readDetachAnswer(answer.value);
199
+ return output === null
200
+ ? {
201
+ ok: false,
202
+ error: `the gateway's release of the ram-lease of ${disk.device} proves no detach outcome: ${answer.value}`,
203
+ }
204
+ : { ok: true, value: output };
205
+ },
206
+ };
207
+ }
@@ -0,0 +1,25 @@
1
+ import type { CommandOutput } from './ram-temp.js';
2
+ /**
3
+ * The silence the client allows the gateway before its first heartbeat line (05_gateway.md, "Deadlines"; Rust
4
+ * `UNPROVEN_SILENCE`): a gateway of an earlier build never heartbeats, and its slow answers still arrive within the
5
+ * minute doctor always gave it.
6
+ */
7
+ export declare const UNPROVEN_SILENCE_MS = 60000;
8
+ /** The silence allowed once a heartbeat has come: three 5 s heartbeats (Rust `deadline::HEARTBEAT_SILENCE`). */
9
+ export declare const HEARTBEAT_SILENCE_MS = 15000;
10
+ /** Monotonic milliseconds and the one silence timer; `after` answers its cancel. A test fires its timer itself. */
11
+ export interface SilenceTimers {
12
+ now(): number;
13
+ after(ms: number, fire: () => void): () => void;
14
+ }
15
+ /**
16
+ * Typed gateway mutation: no caller-owned native child or arbitrary argv. The request is a one-shot control op, so the
17
+ * answer is read under the gateway's silence rule (05_gateway.md, "Deadlines"), never under a total ceiling: until the
18
+ * first heartbeat line the gateway may be silent for {@link UNPROVEN_SILENCE_MS}, after each one for
19
+ * {@link HEARTBEAT_SILENCE_MS}. A silent gateway ends this caller's wait as `SILENT`, with unknown custody; the gateway's
20
+ * detach keeps running, and its late answer still completes `pending`.
21
+ */
22
+ export declare function detachGatewayRamDisk(socket: string, device: string, registryEntry: string, timers?: SilenceTimers): Promise<CommandOutput>;
23
+ /** Only the gateway can attest whether its exact native child ran and was reaped. */
24
+ export declare function readDetachAnswer(line: string): CommandOutput | null;
25
+ //# sourceMappingURL=ram-detach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ram-detach.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/ram-detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,gHAAgH;AAChH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAK3C,mHAAmH;AACnH,MAAM,WAAW,aAAa;IAC5B,GAAG,IAAI,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACjD;AAwBD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,aAA6B,GACpC,OAAO,CAAC,aAAa,CAAC,CAkFxB;AAqBD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAgEnE"}
@@ -0,0 +1,207 @@
1
+ import { connect } from 'node:net';
2
+ import { StringDecoder } from 'node:string_decoder';
3
+ /**
4
+ * The silence the client allows the gateway before its first heartbeat line (05_gateway.md, "Deadlines"; Rust
5
+ * `UNPROVEN_SILENCE`): a gateway of an earlier build never heartbeats, and its slow answers still arrive within the
6
+ * minute doctor always gave it.
7
+ */
8
+ export const UNPROVEN_SILENCE_MS = 60_000;
9
+ /** The silence allowed once a heartbeat has come: three 5 s heartbeats (Rust `deadline::HEARTBEAT_SILENCE`). */
10
+ export const HEARTBEAT_SILENCE_MS = 15_000;
11
+ /** A detach answers its native output, which the gateway bounds; no answer grows past that. */
12
+ const ANSWER_BYTES_MAX = 2 * 64 * 1024 * 6 + 4096;
13
+ const SYSTEM_TIMERS = {
14
+ now: () => performance.now(),
15
+ after(ms, fire) {
16
+ const timer = setTimeout(fire, ms);
17
+ return () => clearTimeout(timer);
18
+ },
19
+ };
20
+ function describeProgress(progress) {
21
+ switch (progress.kind) {
22
+ case 'nothing':
23
+ return 'nothing';
24
+ case 'sent':
25
+ return 'request sent';
26
+ case 'heartbeat':
27
+ return `heartbeat ${progress.seq}`;
28
+ }
29
+ }
30
+ /**
31
+ * Typed gateway mutation: no caller-owned native child or arbitrary argv. The request is a one-shot control op, so the
32
+ * answer is read under the gateway's silence rule (05_gateway.md, "Deadlines"), never under a total ceiling: until the
33
+ * first heartbeat line the gateway may be silent for {@link UNPROVEN_SILENCE_MS}, after each one for
34
+ * {@link HEARTBEAT_SILENCE_MS}. A silent gateway ends this caller's wait as `SILENT`, with unknown custody; the gateway's
35
+ * detach keeps running, and its late answer still completes `pending`.
36
+ */
37
+ export function detachGatewayRamDisk(socket, device, registryEntry, timers = SYSTEM_TIMERS) {
38
+ let resolve;
39
+ const answer = new Promise((done) => {
40
+ resolve = done;
41
+ });
42
+ let complete;
43
+ const completion = new Promise((done) => {
44
+ complete = done;
45
+ });
46
+ const started = timers.now();
47
+ let last = { kind: 'nothing' };
48
+ let silenceMs = UNPROVEN_SILENCE_MS;
49
+ let disarm = () => { };
50
+ const decoder = new StringDecoder('utf8');
51
+ let received = '';
52
+ let dispatched = false;
53
+ let bounded = false;
54
+ let finished = false;
55
+ const pending = { pid: null, completion };
56
+ const unknown = (reason) => ({ status: 1, stdout: '', stderr: reason, pending });
57
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a unix-socket connect completes or fails at once, and the silence timer listen() arms below ends the whole exchange (05_gateway.md, "Deadlines")
58
+ const connection = connect(socket);
59
+ const finish = (output, reason = 'gateway detach terminal status unavailable') => {
60
+ if (finished)
61
+ return;
62
+ finished = true;
63
+ disarm();
64
+ complete(output);
65
+ if (!bounded)
66
+ resolve(output ?? unknown(reason));
67
+ connection.destroy();
68
+ };
69
+ const silent = () => {
70
+ bounded = true;
71
+ resolve(unknown(`SILENT: ram-detach: the gateway at ${socket} wrote no heartbeat or answer for ${silenceMs} ms (waited ${Math.max(0, timers.now() - started)} ms; last progress: ${describeProgress(last)}); the gateway's detach keeps running, not killed`));
72
+ connection.unref();
73
+ };
74
+ /** Allow the gateway `silenceMs` from now; once the caller's wait has ended there is nothing left to bound. */
75
+ const listen = () => {
76
+ if (bounded || finished)
77
+ return;
78
+ disarm();
79
+ disarm = timers.after(silenceMs, silent);
80
+ };
81
+ listen();
82
+ connection.on('connect', () => {
83
+ dispatched = true;
84
+ connection.end(`${JSON.stringify({ op: 'ram-detach', device, registryEntry })}\n`);
85
+ last = { kind: 'sent' };
86
+ });
87
+ connection.on('data', (chunk) => {
88
+ received += decoder.write(chunk);
89
+ for (let newline = received.indexOf('\n'); newline >= 0; newline = received.indexOf('\n')) {
90
+ const line = received.slice(0, newline);
91
+ received = received.slice(newline + 1);
92
+ // The gateway heartbeats an answer that is not ready yet (05_gateway.md, "Deadlines"): never the answer.
93
+ const seq = heartbeatSeq(line);
94
+ if (seq !== null) {
95
+ last = { kind: 'heartbeat', seq };
96
+ silenceMs = HEARTBEAT_SILENCE_MS;
97
+ listen();
98
+ continue;
99
+ }
100
+ // A line past the cap is refused before it is read, whatever chunk completed it.
101
+ if (Buffer.byteLength(line) > ANSWER_BYTES_MAX)
102
+ return finish(null, 'gateway detach reply exceeds its bounded output contract');
103
+ const parsed = readDetachAnswer(line);
104
+ if (parsed === null)
105
+ finish(null, `gateway detach reply proves no terminal outcome: ${line.slice(0, 512)}`);
106
+ else
107
+ finish(parsed);
108
+ return;
109
+ }
110
+ // Native output is bounded by the gateway contract; never buffer an unbounded peer reply.
111
+ if (Buffer.byteLength(received) > ANSWER_BYTES_MAX)
112
+ finish(null, 'gateway detach reply exceeds its bounded output contract');
113
+ });
114
+ connection.on('error', (error) => {
115
+ if (!dispatched)
116
+ finish({ status: 103, stdout: '', stderr: `gateway detach did not start: ${error.message}` });
117
+ else
118
+ finish(null, `gateway detach connection ended after dispatch: ${error.message}`);
119
+ });
120
+ connection.on('close', () => finish(null, 'gateway detach closed without an authoritative outcome'));
121
+ return answer;
122
+ }
123
+ /**
124
+ * The heartbeat's `progress` when `line` is exactly a gateway heartbeat, `{"ok":<bool>,"progress":<u64>}` and nothing
125
+ * else (Rust `ProgressLine`, `deny_unknown_fields`); `null` for any other line, which is the answer.
126
+ */
127
+ function heartbeatSeq(line) {
128
+ let parsed;
129
+ try {
130
+ parsed = JSON.parse(line);
131
+ }
132
+ catch {
133
+ return null;
134
+ }
135
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
136
+ return null;
137
+ if (Object.keys(parsed).length !== 2 || !('ok' in parsed) || !('progress' in parsed))
138
+ return null;
139
+ const { ok, progress } = parsed;
140
+ return typeof ok === 'boolean' && typeof progress === 'number' && Number.isInteger(progress) && progress >= 0
141
+ ? progress
142
+ : null;
143
+ }
144
+ /** Only the gateway can attest whether its exact native child ran and was reaped. */
145
+ export function readDetachAnswer(line) {
146
+ let parsed;
147
+ try {
148
+ parsed = JSON.parse(line);
149
+ }
150
+ catch {
151
+ return null;
152
+ }
153
+ if (typeof parsed !== 'object' || parsed === null || !('ok' in parsed))
154
+ return null;
155
+ if (parsed.ok === false && 'code' in parsed && parsed.code === 'invalid-request') {
156
+ return {
157
+ status: 103,
158
+ stdout: '',
159
+ stderr: `gateway detach did not start: ${'error' in parsed ? String(parsed.error) : 'invalid request'}`,
160
+ };
161
+ }
162
+ if (parsed.ok !== true ||
163
+ !('ramDetach' in parsed) ||
164
+ typeof parsed.ramDetach !== 'object' ||
165
+ parsed.ramDetach === null)
166
+ return null;
167
+ const result = parsed.ramDetach;
168
+ if (!('outcome' in result))
169
+ return null;
170
+ if (result.outcome === 'unknown')
171
+ return null;
172
+ if (result.outcome === 'not-started' && 'reason' in result && typeof result.reason === 'string') {
173
+ return { status: 103, stdout: '', stderr: `gateway detach did not start: ${result.reason}` };
174
+ }
175
+ if (result.outcome !== 'terminal' ||
176
+ !('status' in result) ||
177
+ typeof result.status !== 'object' ||
178
+ result.status === null ||
179
+ !('stdout' in result) ||
180
+ typeof result.stdout !== 'string' ||
181
+ !('stderr' in result) ||
182
+ typeof result.stderr !== 'string' ||
183
+ !('stdoutTruncated' in result) ||
184
+ typeof result.stdoutTruncated !== 'boolean' ||
185
+ !('stderrTruncated' in result) ||
186
+ typeof result.stderrTruncated !== 'boolean')
187
+ return null;
188
+ const status = result.status;
189
+ const code = 'exit' in status && typeof status.exit === 'number' && Number.isSafeInteger(status.exit) && status.exit >= 0
190
+ ? status.exit
191
+ : 'signal' in status &&
192
+ typeof status.signal === 'number' &&
193
+ Number.isSafeInteger(status.signal) &&
194
+ status.signal > 0
195
+ ? 128 + status.signal
196
+ : null;
197
+ return code === null
198
+ ? null
199
+ : {
200
+ status: code,
201
+ stdout: result.stdout,
202
+ stderr: result.stderr +
203
+ (result.stdoutTruncated || result.stderrTruncated
204
+ ? '\n[gateway detach output truncated at the native inline limit]'
205
+ : ''),
206
+ };
207
+ }
@@ -1,3 +1,79 @@
1
+ import { type HostCommands, type RamDisk, type RamTempPaths, RamTempVolume, type TestNamespace } from './ram-temp.js';
1
2
  /** One attached image as `ioreg -r -c AppleDiskImageDevice -l -w0` lists it. */
2
3
  export declare function registryDevice(url: string, disk: string): string[];
4
+ /**
5
+ * A host proof's RAM volume: its test namespace, where it lives, its size, and the record of the disks its attaches
6
+ * made. Every path derives from the namespace, and the namespace's root is the fixture's one directory.
7
+ */
8
+ export interface ScratchVolume {
9
+ readonly namespace: TestNamespace;
10
+ readonly paths: RamTempPaths;
11
+ readonly capacity: number;
12
+ readonly owned: string;
13
+ readonly gatewaySocket: string;
14
+ }
15
+ /**
16
+ * A volume of its own for one host proof, in a test namespace of its own: `testNamespace(process.pid, index)`. It makes
17
+ * the namespace's root, `/private/var/folders/cowshed/<uid>/<ns>`, 0700, and refuses one that exists: a fixture adopts
18
+ * nothing. Every path derives from the namespace (`ramTempPaths`): the volume mounts at `<root>/ram3`, below the
19
+ * per-user root `cowshed setup` makes, as the user's own volume mounts below that root, so mds keeps no right for it
20
+ * (specs/cowshed/01a_apfs.md, "Spotlight media references"), and the fixture gateway serves `<root>/gateway.sock`
21
+ * (`startFixtureGateway`). Nothing it names can be what production names. The size is a name of its own: one no other
22
+ * test process uses, since the size and the user are what identify a RAM disk as this volume's. `index` is 0 to 3: the
23
+ * size spends 4 sectors per pid. `owned` records the disks the volume's attaches made, by identity: the only disks its
24
+ * teardown may detach.
25
+ */
26
+ export declare function scratchVolume(index: 0 | 1 | 2 | 3): ScratchVolume;
27
+ /**
28
+ * Start the prebuilt real gateway for the volume's namespace (`ram_fixture <ns>`, which serves `<root>/gateway.sock`);
29
+ * readiness and exit are observed, never polled or faked. The stop it returns ends the helper and awaits its exit; the
30
+ * root stays for the teardown (`removeScratchVolume`), which removes it once the volume is gone.
31
+ */
32
+ export declare function startFixtureGateway(volume: ScratchVolume): Promise<() => Promise<void>>;
33
+ /**
34
+ * Remove what a run left of the scratch volume: the directories its volume mounts on, then its namespace root with
35
+ * everything the fixture made there. Teardown must not hide the failure it follows, so a directory `rmdirSync` refuses,
36
+ * one still mounted on, is said on stderr instead of thrown, and the root stays with it: nothing is deleted through a
37
+ * mount.
38
+ */
39
+ export declare function removeScratchVolume(volume: ScratchVolume): void;
40
+ /**
41
+ * This test's size of RAM disks, read from the I/O Registry as the module reads them: `hdiutil info` drops attached disks.
42
+ * A guard for assertions only: a disk of the size is no proof it is the test's, so nothing detaches by it.
43
+ */
44
+ export declare function attachedDisks(paths: RamTempPaths, capacity: number, gatewaySocket: string): Promise<RamDisk[]>;
45
+ /** Exact custody comes only from this fixture's attach receipts, never a size or name filter. */
46
+ export declare function ownsRecordedDisk(owned: string, disk: RamDisk): boolean;
47
+ /**
48
+ * Detach the disks `owned` records, each only while a fresh registry read still lists its entry with the same whole disk,
49
+ * size and owner `uid`; the detach is bound to that entry. A disk already gone needs nothing. Any other listing is
50
+ * refused and reported on stderr, outside the fixture's directories, and never detached; the refusals are thrown once
51
+ * every record has been seen, so the caller removes nothing that holds the evidence.
52
+ */
53
+ export declare function detachOwned(owned: string, uid: number, gatewaySocket: string): Promise<void>;
54
+ /**
55
+ * An attach through this fixture's real gateway. Right after the answer it reads the disk's registry entry and
56
+ * appends the exact attached identity to `owned`,
57
+ * the only record its teardown detaches from (`detachOwned`), and answers the lease. A disk it cannot record has its
58
+ * lease released, so no disk is left that neither the gateway nor the teardown detaches. The user's volume is attached by
59
+ * the gateway (`ram-lease`), so that no job's end takes it from another job's lease.
60
+ */
61
+ export declare function recordedRamAttach(attach: HostCommands['attachRam'], run: HostCommands['run'], owned: string): HostCommands['attachRam'];
62
+ /**
63
+ * The provisioning step a host call is: `mount_apfs` and `umount` of the private staging mount, or
64
+ * the `mount_apfs` that places the volume at its mountpoint. Null for every other call.
65
+ */
66
+ export declare function stepOf(paths: RamTempPaths, file: string, args: readonly string[]): string | null;
67
+ /**
68
+ * A host proof's RAM volume: `volume`'s paths and size, its disk commands through `cowshed`, and its disk attached by the
69
+ * fixture's own gateway and recorded in `volume.owned`. Its paths and its gateway's socket derive from its test
70
+ * namespace, so none can be the user's own; its size is the one name a namespace does not derive, and the user's own is
71
+ * refused: no test leases, creates or detaches that volume.
72
+ */
73
+ export declare function fixtureRamVolume(volume: {
74
+ readonly paths: RamTempPaths;
75
+ readonly capacity: number;
76
+ readonly owned: string;
77
+ readonly gatewaySocket: string;
78
+ }, cowshed: string | undefined): RamTempVolume;
3
79
  //# sourceMappingURL=ram-temp-fixtures.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ram-temp-fixtures.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/ram-temp-fixtures.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUlE"}
1
+ {"version":3,"file":"ram-temp-fixtures.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/ram-temp-fixtures.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,aAAa,EAGb,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAIvB,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUlE;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,aAAa,CAuBjE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAyD7F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAgB/D;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAcpH;AAyCD,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAItE;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuClG;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,EACjC,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,EACxB,KAAK,EAAE,MAAM,GACZ,YAAY,CAAC,WAAW,CAAC,CA0B3B;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAKhG;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IACN,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC,EACD,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,aAAa,CASf"}