@mysten-incubation/devstack 0.1.0 → 0.2.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 (858) hide show
  1. package/README.md +7 -4
  2. package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
  3. package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
  4. package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
  5. package/dashboard-ui/index.html +2 -2
  6. package/dist/api/define-capabilities.d.mts +1 -20
  7. package/dist/api/define-capabilities.mjs +15 -22
  8. package/dist/api/define-capabilities.mjs.map +1 -1
  9. package/dist/api/define-devstack-with.d.mts +7 -1
  10. package/dist/api/define-devstack-with.mjs.map +1 -1
  11. package/dist/api/define-devstack.mjs.map +1 -1
  12. package/dist/api/define-plugin.d.mts +2 -1
  13. package/dist/api/inference-network.d.mts +31 -17
  14. package/dist/api/inference-network.mjs +40 -43
  15. package/dist/api/inference-network.mjs.map +1 -1
  16. package/dist/api/load-config.mjs +88 -0
  17. package/dist/api/load-config.mjs.map +1 -0
  18. package/dist/api/mode-narrowed-factory.d.mts +1 -1
  19. package/dist/api/mode-narrowed-factory.mjs.map +1 -1
  20. package/dist/api/run-stack-internal.mjs +202 -0
  21. package/dist/api/run-stack-internal.mjs.map +1 -0
  22. package/dist/api/run-stack.d.mts +82 -31
  23. package/dist/api/run-stack.mjs +22 -141
  24. package/dist/api/run-stack.mjs.map +1 -1
  25. package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
  26. package/dist/build-integrations/dapp-kit/index.mjs +58 -0
  27. package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
  28. package/dist/build-integrations/playwright/config.d.mts +1 -30
  29. package/dist/build-integrations/playwright/config.mjs +1 -27
  30. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  31. package/dist/build-integrations/playwright/errors.d.mts +4 -7
  32. package/dist/build-integrations/playwright/errors.mjs.map +1 -1
  33. package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
  34. package/dist/build-integrations/playwright/global-setup.mjs +142 -218
  35. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  36. package/dist/build-integrations/playwright/index.d.mts +2 -2
  37. package/dist/build-integrations/playwright/index.mjs +2 -2
  38. package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
  39. package/dist/build-integrations/playwright/stack-context.mjs +4 -2
  40. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  41. package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
  42. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  43. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  44. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
  45. package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
  46. package/dist/build-integrations/runtime/discover.d.mts +6 -4
  47. package/dist/build-integrations/runtime/discover.mjs +15 -4
  48. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  49. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/errors.mjs.map +1 -1
  51. package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
  52. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  53. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
  54. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
  55. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
  57. package/dist/build-integrations/vite/index.d.mts +84 -19
  58. package/dist/build-integrations/vite/index.mjs +203 -28
  59. package/dist/build-integrations/vite/index.mjs.map +1 -1
  60. package/dist/build-integrations/vitest/config.d.mts +20 -2
  61. package/dist/build-integrations/vitest/config.mjs +16 -4
  62. package/dist/build-integrations/vitest/config.mjs.map +1 -1
  63. package/dist/build-integrations/vitest/env.d.mts +18 -10
  64. package/dist/build-integrations/vitest/env.mjs +11 -10
  65. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  66. package/dist/build-integrations/vitest/errors.d.mts +7 -11
  67. package/dist/build-integrations/vitest/errors.mjs +3 -4
  68. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  69. package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
  70. package/dist/build-integrations/vitest/global-setup.mjs +156 -0
  71. package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
  72. package/dist/build-integrations/vitest/index.d.mts +3 -2
  73. package/dist/build-integrations/vitest/index.mjs +3 -2
  74. package/dist/build-integrations/vitest/setup.mjs +2 -2
  75. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  76. package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
  77. package/dist/build-integrations/vitest/stack-context.mjs +3 -2
  78. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  79. package/dist/cli/bail.mjs.map +1 -1
  80. package/dist/cli/doctor-probes.mjs +1 -3
  81. package/dist/cli/doctor-probes.mjs.map +1 -1
  82. package/dist/cli/main.d.mts +23 -1
  83. package/dist/cli/main.mjs +63 -8
  84. package/dist/cli/main.mjs.map +1 -1
  85. package/dist/cli/prune-direct.mjs.map +1 -1
  86. package/dist/cli/snapshot-reader.mjs.map +1 -1
  87. package/dist/cli/up-lifecycle.mjs.map +1 -1
  88. package/dist/cli/wirings/apply.mjs +28 -21
  89. package/dist/cli/wirings/apply.mjs.map +1 -1
  90. package/dist/cli/wirings/codegen.mjs +108 -0
  91. package/dist/cli/wirings/codegen.mjs.map +1 -0
  92. package/dist/cli/wirings/config-loader.mjs +12 -62
  93. package/dist/cli/wirings/config-loader.mjs.map +1 -1
  94. package/dist/cli/wirings/dump-ids.mjs +86 -0
  95. package/dist/cli/wirings/dump-ids.mjs.map +1 -0
  96. package/dist/cli/wirings/engine-command.mjs +1 -1
  97. package/dist/cli/wirings/engine-command.mjs.map +1 -1
  98. package/dist/cli/wirings/identity.mjs +2 -2
  99. package/dist/cli/wirings/identity.mjs.map +1 -1
  100. package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
  101. package/dist/cli/wirings/read-devstack-version.mjs +17 -0
  102. package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
  103. package/dist/cli/wirings/snapshot.mjs +27 -34
  104. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  105. package/dist/cli/wirings/up-ipc.mjs +147 -0
  106. package/dist/cli/wirings/up-ipc.mjs.map +1 -0
  107. package/dist/cli/wirings/up.mjs +218 -198
  108. package/dist/cli/wirings/up.mjs.map +1 -1
  109. package/dist/cli/wirings/wipe.mjs +1 -1
  110. package/dist/cli/wirings/wipe.mjs.map +1 -1
  111. package/dist/contracts/chain-probe.d.mts +1 -1
  112. package/dist/contracts/chain-probe.mjs +1 -1
  113. package/dist/contracts/chain-probe.mjs.map +1 -1
  114. package/dist/contracts/codegenable.d.mts +60 -6
  115. package/dist/contracts/codegenable.mjs +28 -0
  116. package/dist/contracts/codegenable.mjs.map +1 -0
  117. package/dist/contracts/config-bindings.mjs +162 -0
  118. package/dist/contracts/config-bindings.mjs.map +1 -0
  119. package/dist/contracts/container-runtime.d.mts +23 -17
  120. package/dist/contracts/plugin-expander.mjs.map +1 -1
  121. package/dist/contracts/snapshotable.d.mts +5 -7
  122. package/dist/contracts/wallet-protocol.d.mts +2 -5
  123. package/dist/contracts/wallet-protocol.mjs +2 -5
  124. package/dist/contracts/wallet-protocol.mjs.map +1 -1
  125. package/dist/index.d.mts +21 -26
  126. package/dist/index.mjs +8 -9
  127. package/dist/orchestrators/boot.d.mts +28 -0
  128. package/dist/orchestrators/boot.mjs +440 -0
  129. package/dist/orchestrators/boot.mjs.map +1 -0
  130. package/dist/orchestrators/codegen/bindings.d.mts +13 -1
  131. package/dist/orchestrators/codegen/bindings.mjs +23 -9
  132. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  133. package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
  134. package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
  135. package/dist/orchestrators/codegen/emit.mjs +1 -1
  136. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  137. package/dist/orchestrators/codegen/errors.mjs +21 -1
  138. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  139. package/dist/orchestrators/codegen/format.mjs +2 -0
  140. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  141. package/dist/orchestrators/codegen/gitignore.mjs +30 -11
  142. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/id-config.mjs +107 -0
  144. package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
  145. package/dist/orchestrators/codegen/output-location.mjs +23 -31
  146. package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/paths.mjs +8 -1
  148. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  150. package/dist/orchestrators/codegen/service.mjs +286 -58
  151. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  152. package/dist/orchestrators/layers.mjs +31 -0
  153. package/dist/orchestrators/layers.mjs.map +1 -0
  154. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
  155. package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
  156. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
  157. package/dist/orchestrators/network-options.d.mts +52 -0
  158. package/dist/orchestrators/network-options.mjs +43 -0
  159. package/dist/orchestrators/network-options.mjs.map +1 -0
  160. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  161. package/dist/orchestrators/router/cors.mjs.map +1 -1
  162. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  163. package/dist/orchestrators/router/errors.mjs.map +1 -1
  164. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  165. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  166. package/dist/orchestrators/router/profile.mjs +1 -1
  167. package/dist/orchestrators/router/profile.mjs.map +1 -1
  168. package/dist/orchestrators/router/service.d.mts +2 -2
  169. package/dist/orchestrators/router/service.mjs +12 -27
  170. package/dist/orchestrators/router/service.mjs.map +1 -1
  171. package/dist/orchestrators/router/traefik-container.mjs +1 -1
  172. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  173. package/dist/orchestrators/snapshot/capture.mjs +171 -195
  174. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  175. package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
  176. package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
  177. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  178. package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
  179. package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
  180. package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
  181. package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
  182. package/dist/orchestrators/snapshot/index.mjs +1 -4
  183. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  184. package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
  185. package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
  186. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
  187. package/dist/orchestrators/snapshot/prune.mjs +40 -31
  188. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  189. package/dist/orchestrators/snapshot/restore.mjs +221 -196
  190. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  191. package/dist/orchestrators/snapshot/service.mjs +72 -62
  192. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  193. package/dist/orchestrators/snapshot/wipe.mjs +67 -56
  194. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  195. package/dist/plugins/account/codegen.mjs +3 -0
  196. package/dist/plugins/account/codegen.mjs.map +1 -1
  197. package/dist/plugins/account/errors.d.mts +2 -2
  198. package/dist/plugins/account/errors.mjs +1 -4
  199. package/dist/plugins/account/errors.mjs.map +1 -1
  200. package/dist/plugins/account/funding.mjs +3 -27
  201. package/dist/plugins/account/funding.mjs.map +1 -1
  202. package/dist/plugins/account/index.d.mts +3 -8
  203. package/dist/plugins/account/index.mjs +71 -35
  204. package/dist/plugins/account/index.mjs.map +1 -1
  205. package/dist/plugins/account/keypair.d.mts +8 -7
  206. package/dist/plugins/account/keypair.mjs +5 -18
  207. package/dist/plugins/account/keypair.mjs.map +1 -1
  208. package/dist/plugins/account/lease.mjs.map +1 -1
  209. package/dist/plugins/account/registry.d.mts +1 -46
  210. package/dist/plugins/account/registry.mjs.map +1 -1
  211. package/dist/plugins/account/service.d.mts +43 -34
  212. package/dist/plugins/account/service.mjs +9 -54
  213. package/dist/plugins/account/service.mjs.map +1 -1
  214. package/dist/plugins/account/snapshot.mjs.map +1 -1
  215. package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
  216. package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
  217. package/dist/plugins/account/variants/signer.mjs.map +1 -1
  218. package/dist/plugins/action/discriminator.mjs.map +1 -1
  219. package/dist/plugins/action/errors.mjs +1 -4
  220. package/dist/plugins/action/errors.mjs.map +1 -1
  221. package/dist/plugins/action/execute.mjs +3 -4
  222. package/dist/plugins/action/execute.mjs.map +1 -1
  223. package/dist/plugins/action/index.d.mts +2 -2
  224. package/dist/plugins/action/index.mjs +7 -11
  225. package/dist/plugins/action/index.mjs.map +1 -1
  226. package/dist/plugins/action/service.d.mts +5 -7
  227. package/dist/plugins/action/service.mjs +2 -16
  228. package/dist/plugins/action/service.mjs.map +1 -1
  229. package/dist/plugins/coin/address-resolution.mjs.map +1 -1
  230. package/dist/plugins/coin/codegen.mjs +97 -16
  231. package/dist/plugins/coin/codegen.mjs.map +1 -1
  232. package/dist/plugins/coin/discovery.mjs.map +1 -1
  233. package/dist/plugins/coin/errors.mjs +1 -4
  234. package/dist/plugins/coin/errors.mjs.map +1 -1
  235. package/dist/plugins/coin/index.d.mts +4 -34
  236. package/dist/plugins/coin/index.mjs +47 -28
  237. package/dist/plugins/coin/index.mjs.map +1 -1
  238. package/dist/plugins/coin/metadata.d.mts +1 -0
  239. package/dist/plugins/coin/metadata.mjs +8 -9
  240. package/dist/plugins/coin/metadata.mjs.map +1 -1
  241. package/dist/plugins/coin/mint.mjs +7 -21
  242. package/dist/plugins/coin/mint.mjs.map +1 -1
  243. package/dist/plugins/coin/registry.mjs +33 -20
  244. package/dist/plugins/coin/registry.mjs.map +1 -1
  245. package/dist/plugins/coin/service.d.mts +1 -1
  246. package/dist/plugins/coin/service.mjs +1 -8
  247. package/dist/plugins/coin/service.mjs.map +1 -1
  248. package/dist/plugins/coin/snapshot.mjs.map +1 -1
  249. package/dist/plugins/coin/type-strings.mjs.map +1 -1
  250. package/dist/plugins/dashboard/domain.mjs +106 -167
  251. package/dist/plugins/dashboard/domain.mjs.map +1 -1
  252. package/dist/plugins/dashboard/index.mjs +13 -13
  253. package/dist/plugins/dashboard/index.mjs.map +1 -1
  254. package/dist/plugins/dashboard/origin-policy.mjs +3 -3
  255. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
  256. package/dist/plugins/dashboard/routable.mjs.map +1 -1
  257. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
  258. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
  259. package/dist/plugins/dashboard/schema/root.mjs +23 -44
  260. package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
  261. package/dist/plugins/dashboard/schema/types.mjs +37 -91
  262. package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
  263. package/dist/plugins/dashboard/schema.mjs.map +1 -1
  264. package/dist/plugins/dashboard/server.mjs.map +1 -1
  265. package/dist/plugins/deepbook/codegen.d.mts +12 -11
  266. package/dist/plugins/deepbook/codegen.mjs +108 -11
  267. package/dist/plugins/deepbook/codegen.mjs.map +1 -1
  268. package/dist/plugins/deepbook/deploy.mjs +7 -14
  269. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  270. package/dist/plugins/deepbook/errors.mjs +4 -2
  271. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  272. package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
  273. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  274. package/dist/plugins/deepbook/hash.mjs.map +1 -1
  275. package/dist/plugins/deepbook/index.d.mts +38 -34
  276. package/dist/plugins/deepbook/index.mjs +133 -64
  277. package/dist/plugins/deepbook/index.mjs.map +1 -1
  278. package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
  279. package/dist/plugins/deepbook/pyth/index.mjs +4 -8
  280. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  281. package/dist/plugins/deepbook/snapshot.mjs +0 -1
  282. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  283. package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
  284. package/dist/plugins/deepbook/types.d.mts +2 -1
  285. package/dist/plugins/deepbook/types.mjs.map +1 -1
  286. package/dist/plugins/faucet/dispatcher.d.mts +3 -3
  287. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  288. package/dist/plugins/faucet/errors.mjs.map +1 -1
  289. package/dist/plugins/faucet/http.mjs +2 -10
  290. package/dist/plugins/faucet/http.mjs.map +1 -1
  291. package/dist/plugins/faucet/index.mjs +0 -1
  292. package/dist/plugins/faucet/index.mjs.map +1 -1
  293. package/dist/plugins/host-service/errors.d.mts +1 -3
  294. package/dist/plugins/host-service/errors.mjs +1 -2
  295. package/dist/plugins/host-service/errors.mjs.map +1 -1
  296. package/dist/plugins/host-service/index.d.mts +1 -2
  297. package/dist/plugins/host-service/index.mjs +11 -11
  298. package/dist/plugins/host-service/index.mjs.map +1 -1
  299. package/dist/plugins/host-service/routable.mjs.map +1 -1
  300. package/dist/plugins/host-service/service.mjs +13 -13
  301. package/dist/plugins/host-service/service.mjs.map +1 -1
  302. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
  303. package/dist/plugins/internal/codegen-helpers.mjs +2 -0
  304. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
  305. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
  306. package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
  307. package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
  308. package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
  309. package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
  310. package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
  311. package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
  312. package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
  313. package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
  314. package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
  315. package/dist/plugins/package/build.mjs +2 -2
  316. package/dist/plugins/package/build.mjs.map +1 -1
  317. package/dist/plugins/package/codegen.d.mts +7 -14
  318. package/dist/plugins/package/codegen.mjs +187 -59
  319. package/dist/plugins/package/codegen.mjs.map +1 -1
  320. package/dist/plugins/package/dep-resolution.mjs +51 -3
  321. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  322. package/dist/plugins/package/errors.mjs +1 -4
  323. package/dist/plugins/package/errors.mjs.map +1 -1
  324. package/dist/plugins/package/git-source.d.mts +18 -0
  325. package/dist/plugins/package/git-source.mjs +119 -0
  326. package/dist/plugins/package/git-source.mjs.map +1 -0
  327. package/dist/plugins/package/index.d.mts +28 -19
  328. package/dist/plugins/package/index.mjs +107 -32
  329. package/dist/plugins/package/index.mjs.map +1 -1
  330. package/dist/plugins/package/mode-known.mjs +2 -2
  331. package/dist/plugins/package/mode-known.mjs.map +1 -1
  332. package/dist/plugins/package/mode-local.mjs +18 -35
  333. package/dist/plugins/package/mode-local.mjs.map +1 -1
  334. package/dist/plugins/package/publish-executor.mjs +13 -8
  335. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  336. package/dist/plugins/package/publish-output.d.mts +1 -11
  337. package/dist/plugins/package/publish-output.mjs +1 -9
  338. package/dist/plugins/package/publish-output.mjs.map +1 -1
  339. package/dist/plugins/package/registry.d.mts +1 -1
  340. package/dist/plugins/package/registry.mjs +26 -14
  341. package/dist/plugins/package/registry.mjs.map +1 -1
  342. package/dist/plugins/package/service.mjs.map +1 -1
  343. package/dist/plugins/package/snapshot.mjs.map +1 -1
  344. package/dist/plugins/router-entrypoints.mjs +1 -3
  345. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  346. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
  347. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  348. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
  349. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  350. package/dist/plugins/seal/codegen.d.mts +1 -5
  351. package/dist/plugins/seal/codegen.mjs +83 -12
  352. package/dist/plugins/seal/codegen.mjs.map +1 -1
  353. package/dist/plugins/seal/config-render.mjs +2 -6
  354. package/dist/plugins/seal/config-render.mjs.map +1 -1
  355. package/dist/plugins/seal/deploy.mjs +18 -29
  356. package/dist/plugins/seal/deploy.mjs.map +1 -1
  357. package/dist/plugins/seal/errors.d.mts +4 -5
  358. package/dist/plugins/seal/errors.mjs +1 -8
  359. package/dist/plugins/seal/errors.mjs.map +1 -1
  360. package/dist/plugins/seal/index.d.mts +7 -28
  361. package/dist/plugins/seal/index.mjs +69 -47
  362. package/dist/plugins/seal/index.mjs.map +1 -1
  363. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  364. package/dist/plugins/seal/key-server.mjs +1 -6
  365. package/dist/plugins/seal/key-server.mjs.map +1 -1
  366. package/dist/plugins/seal/keygen.mjs +2 -3
  367. package/dist/plugins/seal/keygen.mjs.map +1 -1
  368. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  369. package/dist/plugins/seal/mode/live.mjs +1 -1
  370. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  371. package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
  372. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  373. package/dist/plugins/seal/plugin-key.mjs.map +1 -1
  374. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  375. package/dist/plugins/seal/routable.mjs.map +1 -1
  376. package/dist/plugins/seal/service.mjs.map +1 -1
  377. package/dist/plugins/seal/snapshot.mjs +1 -2
  378. package/dist/plugins/seal/snapshot.mjs.map +1 -1
  379. package/dist/plugins/sui/auto-tick.mjs +5 -5
  380. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  381. package/dist/plugins/sui/chain-build-container.mjs +2 -2
  382. package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
  383. package/dist/plugins/sui/chain-probe.mjs +4 -4
  384. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  385. package/dist/plugins/sui/codegen.d.mts +9 -7
  386. package/dist/plugins/sui/codegen.mjs +49 -46
  387. package/dist/plugins/sui/codegen.mjs.map +1 -1
  388. package/dist/plugins/sui/errors.d.mts +1 -1
  389. package/dist/plugins/sui/errors.mjs +1 -9
  390. package/dist/plugins/sui/errors.mjs.map +1 -1
  391. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
  392. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
  393. package/dist/plugins/sui/exec/index.mjs.map +1 -0
  394. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
  395. package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
  396. package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
  397. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
  398. package/dist/plugins/sui/fork-orchestration.mjs +13 -23
  399. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  400. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  401. package/dist/plugins/sui/index.d.mts +34 -83
  402. package/dist/plugins/sui/index.mjs +200 -68
  403. package/dist/plugins/sui/index.mjs.map +1 -1
  404. package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
  405. package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
  406. package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
  407. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
  408. package/dist/plugins/sui/log-attrs.mjs +11 -0
  409. package/dist/plugins/sui/log-attrs.mjs.map +1 -0
  410. package/dist/plugins/sui/mode/external.mjs +4 -12
  411. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  412. package/dist/plugins/sui/mode/fork.mjs +19 -16
  413. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  414. package/dist/plugins/sui/mode/live.mjs +4 -17
  415. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  416. package/dist/plugins/sui/mode/local.d.mts +1 -0
  417. package/dist/plugins/sui/mode/local.mjs +203 -61
  418. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  419. package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
  420. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  421. package/dist/plugins/sui/mode/shared.d.mts +6 -7
  422. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  423. package/dist/plugins/sui/mode/spec.d.mts +23 -6
  424. package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
  425. package/dist/plugins/sui/move/index.mjs.map +1 -0
  426. package/dist/plugins/sui/move-summary-runner.mjs +8 -4
  427. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
  428. package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
  429. package/dist/plugins/sui/network-resolver.d.mts +6 -6
  430. package/dist/plugins/sui/routable.mjs.map +1 -1
  431. package/dist/plugins/sui/service.mjs +10 -6
  432. package/dist/plugins/sui/service.mjs.map +1 -1
  433. package/dist/plugins/sui/snapshot.mjs +10 -5
  434. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  435. package/dist/plugins/wallet/codegen.d.mts +8 -6
  436. package/dist/plugins/wallet/codegen.mjs +4 -10
  437. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  438. package/dist/plugins/wallet/errors.mjs +1 -4
  439. package/dist/plugins/wallet/errors.mjs.map +1 -1
  440. package/dist/plugins/wallet/index.d.mts +3 -6
  441. package/dist/plugins/wallet/index.mjs +16 -21
  442. package/dist/plugins/wallet/index.mjs.map +1 -1
  443. package/dist/plugins/wallet/origin-policy.mjs +3 -3
  444. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  445. package/dist/plugins/wallet/pairing.mjs +6 -24
  446. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  447. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  448. package/dist/plugins/wallet/routable.mjs.map +1 -1
  449. package/dist/plugins/wallet/server.mjs +17 -24
  450. package/dist/plugins/wallet/server.mjs.map +1 -1
  451. package/dist/plugins/wallet/service.d.mts +2 -2
  452. package/dist/plugins/wallet/service.mjs +4 -15
  453. package/dist/plugins/wallet/service.mjs.map +1 -1
  454. package/dist/plugins/wallet/snapshot.mjs.map +1 -1
  455. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
  456. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  457. package/dist/plugins/walrus/codegen.d.mts +2 -13
  458. package/dist/plugins/walrus/codegen.mjs +93 -28
  459. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  460. package/dist/plugins/walrus/deploy-paths.mjs +2 -3
  461. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  462. package/dist/plugins/walrus/deploy.mjs +26 -19
  463. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  464. package/dist/plugins/walrus/errors.mjs +1 -8
  465. package/dist/plugins/walrus/errors.mjs.map +1 -1
  466. package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
  467. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  468. package/dist/plugins/walrus/index.d.mts +13 -44
  469. package/dist/plugins/walrus/index.mjs +119 -122
  470. package/dist/plugins/walrus/index.mjs.map +1 -1
  471. package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
  472. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  473. package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
  474. package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
  475. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  476. package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
  477. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  478. package/dist/plugins/walrus/routable.mjs.map +1 -1
  479. package/dist/plugins/walrus/service.mjs.map +1 -1
  480. package/dist/plugins/walrus/snapshot.mjs +3 -3
  481. package/dist/plugins/walrus/snapshot.mjs.map +1 -1
  482. package/dist/plugins/walrus/storage-nodes.mjs +53 -14
  483. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  484. package/dist/plugins/walrus/wal-swap.mjs +4 -8
  485. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  486. package/dist/primitives/artifact-publisher.mjs.map +1 -1
  487. package/dist/primitives/cache.d.mts +1 -1
  488. package/dist/runtime/docker/client.mjs +47 -3
  489. package/dist/runtime/docker/client.mjs.map +1 -1
  490. package/dist/runtime/docker/container.mjs +37 -57
  491. package/dist/runtime/docker/container.mjs.map +1 -1
  492. package/dist/runtime/docker/errors.mjs.map +1 -1
  493. package/dist/runtime/docker/exec.mjs +2 -2
  494. package/dist/runtime/docker/exec.mjs.map +1 -1
  495. package/dist/runtime/docker/image.mjs +10 -11
  496. package/dist/runtime/docker/image.mjs.map +1 -1
  497. package/dist/runtime/docker/index.mjs +0 -1
  498. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
  499. package/dist/runtime/docker/inventory.mjs +9 -9
  500. package/dist/runtime/docker/inventory.mjs.map +1 -1
  501. package/dist/runtime/docker/labels.mjs +12 -1
  502. package/dist/runtime/docker/labels.mjs.map +1 -1
  503. package/dist/runtime/docker/network.mjs +6 -6
  504. package/dist/runtime/docker/network.mjs.map +1 -1
  505. package/dist/runtime/docker/render-run-args.mjs.map +1 -1
  506. package/dist/runtime/docker/service.mjs +31 -45
  507. package/dist/runtime/docker/service.mjs.map +1 -1
  508. package/dist/runtime/docker/sweep.mjs +14 -64
  509. package/dist/runtime/docker/sweep.mjs.map +1 -1
  510. package/dist/runtime/docker/volume.mjs +1 -1
  511. package/dist/runtime/docker/volume.mjs.map +1 -1
  512. package/dist/runtime/docker/wrap.mjs +14 -2
  513. package/dist/runtime/docker/wrap.mjs.map +1 -1
  514. package/dist/substrate/brand.d.mts +2 -5
  515. package/dist/substrate/brand.mjs +3 -2
  516. package/dist/substrate/brand.mjs.map +1 -1
  517. package/dist/substrate/cross-process.mjs +2 -16
  518. package/dist/substrate/cross-process.mjs.map +1 -1
  519. package/dist/substrate/event-time.mjs +0 -2
  520. package/dist/substrate/event-time.mjs.map +1 -1
  521. package/dist/substrate/events.d.mts +46 -16
  522. package/dist/substrate/identity.d.mts +11 -5
  523. package/dist/substrate/manifest.d.mts +33 -26
  524. package/dist/substrate/manifest.mjs +8 -3
  525. package/dist/substrate/manifest.mjs.map +1 -1
  526. package/dist/substrate/options.d.mts +33 -4
  527. package/dist/substrate/plugin-ctx.d.mts +70 -0
  528. package/dist/substrate/plugin-ctx.mjs +66 -0
  529. package/dist/substrate/plugin-ctx.mjs.map +1 -0
  530. package/dist/substrate/plugin.d.mts +46 -38
  531. package/dist/substrate/plugin.mjs +13 -9
  532. package/dist/substrate/plugin.mjs.map +1 -1
  533. package/dist/substrate/projection.d.mts +1 -1
  534. package/dist/substrate/runtime/atomic-write.mjs +3 -4
  535. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  536. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  537. package/dist/substrate/runtime/cache/service.mjs +50 -20
  538. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  539. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  540. package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
  541. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
  542. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
  543. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
  544. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  545. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  546. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  547. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
  548. package/dist/substrate/runtime/cross-process/index.mjs +0 -2
  549. package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
  550. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
  551. package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
  552. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  553. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
  554. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
  555. package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
  556. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  557. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
  558. package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
  559. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  560. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  561. package/dist/substrate/runtime/errors.mjs +1 -13
  562. package/dist/substrate/runtime/errors.mjs.map +1 -1
  563. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
  564. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
  565. package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
  566. package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
  567. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  568. package/dist/substrate/runtime/http-probe.d.mts +1 -3
  569. package/dist/substrate/runtime/http-probe.mjs.map +1 -1
  570. package/dist/substrate/runtime/index.mjs +1 -6
  571. package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
  572. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  573. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
  574. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  575. package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
  576. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
  577. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
  578. package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
  579. package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
  580. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
  581. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  582. package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
  583. package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
  584. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
  585. package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
  586. package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
  587. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  588. package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
  589. package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
  590. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
  591. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
  592. package/dist/substrate/runtime/managed-container.d.mts +5 -1
  593. package/dist/substrate/runtime/managed-container.mjs +8 -10
  594. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  595. package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
  596. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  597. package/dist/substrate/runtime/mode-errors.d.mts +1 -2
  598. package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
  599. package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
  600. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  601. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
  602. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  603. package/dist/substrate/runtime/observability/index.mjs +4 -6
  604. package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
  605. package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
  606. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
  607. package/dist/substrate/runtime/observability/logger.mjs +3 -3
  608. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  609. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
  610. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  611. package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
  612. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  613. package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
  614. package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
  615. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
  616. package/dist/substrate/runtime/paths.mjs +27 -9
  617. package/dist/substrate/runtime/paths.mjs.map +1 -1
  618. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
  619. package/dist/substrate/runtime/port-broker/service.mjs +10 -27
  620. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  621. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  622. package/dist/substrate/runtime/probes.d.mts +2 -3
  623. package/dist/substrate/runtime/probes.mjs.map +1 -1
  624. package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
  625. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  626. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  627. package/dist/substrate/runtime/projection/update.mjs +87 -11
  628. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  629. package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
  630. package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
  631. package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
  632. package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
  633. package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
  634. package/dist/substrate/runtime/reconcile/index.mjs +5 -0
  635. package/dist/substrate/runtime/reconcile/label.mjs +41 -0
  636. package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
  637. package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
  638. package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
  639. package/dist/substrate/runtime/retry-policy.d.mts +2 -3
  640. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  641. package/dist/substrate/runtime/routed-url.mjs.map +1 -1
  642. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  643. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  644. package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
  645. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  646. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
  647. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  648. package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
  649. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  650. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
  651. package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
  652. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
  653. package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
  654. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
  655. package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
  656. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
  657. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
  658. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
  659. package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
  660. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
  661. package/dist/substrate/runtime/supervisor/index.mjs +2 -0
  662. package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
  663. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
  664. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
  665. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
  666. package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
  667. package/dist/substrate/runtime/supervisor/state.mjs +1 -1
  668. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
  669. package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
  670. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
  671. package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
  672. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
  673. package/dist/substrate/runtime/tar/reader.mjs +216 -0
  674. package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
  675. package/dist/substrate/runtime/typed-env.mjs.map +1 -1
  676. package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
  677. package/dist/substrate/versioned-doc-sync.mjs +5 -5
  678. package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
  679. package/dist/surfaces/cli/command-tree.mjs +49 -7
  680. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  681. package/dist/surfaces/cli/commands/config.mjs +1 -1
  682. package/dist/surfaces/cli/commands/config.mjs.map +1 -1
  683. package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
  684. package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
  685. package/dist/surfaces/cli/commands/doctor.mjs +1 -1
  686. package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
  687. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
  688. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  689. package/dist/surfaces/cli/commands/prune.mjs +1 -1
  690. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  691. package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
  692. package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
  693. package/dist/surfaces/cli/commands/status.mjs +1 -1
  694. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  695. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  696. package/dist/surfaces/cli/commands/wipe.mjs +3 -4
  697. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  698. package/dist/surfaces/cli/envelope.mjs.map +1 -1
  699. package/dist/surfaces/cli/errors.mjs.map +1 -1
  700. package/dist/surfaces/cli/flags.mjs.map +1 -1
  701. package/dist/surfaces/cli/index.mjs +45 -14
  702. package/dist/surfaces/cli/index.mjs.map +1 -1
  703. package/dist/surfaces/cli/output.mjs.map +1 -1
  704. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  705. package/dist/surfaces/tui/app.mjs +0 -21
  706. package/dist/surfaces/tui/app.mjs.map +1 -1
  707. package/dist/surfaces/tui/dashboard.mjs +0 -48
  708. package/dist/surfaces/tui/dashboard.mjs.map +1 -1
  709. package/dist/surfaces/tui/display-derivation.mjs +80 -16
  710. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  711. package/dist/surfaces/tui/errors.mjs.map +1 -1
  712. package/dist/surfaces/tui/event-log.mjs +0 -9
  713. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  714. package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
  715. package/dist/surfaces/tui/index.mjs +2 -2
  716. package/dist/surfaces/tui/index.mjs.map +1 -1
  717. package/dist/surfaces/tui/input.mjs.map +1 -1
  718. package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
  719. package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
  720. package/dist/surfaces/tui/plain-renderer.mjs +26 -19
  721. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  722. package/dist/surfaces/tui/resource-table.mjs +8 -10
  723. package/dist/surfaces/tui/resource-table.mjs.map +1 -1
  724. package/images/postgres/Dockerfile +0 -1
  725. package/images/sui/Dockerfile +27 -54
  726. package/images/sui/entrypoint.sh +17 -179
  727. package/package.json +23 -15
  728. package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
  729. package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
  730. package/dashboard-ui/assets/index-Deml9drg.css +0 -1
  731. package/dist/api/plugin-errors.d.mts +0 -7
  732. package/dist/api/plugin-errors.mjs +0 -10
  733. package/dist/api/plugin-errors.mjs.map +0 -1
  734. package/dist/cli/wirings/build-verb-layers.mjs +0 -42
  735. package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
  736. package/dist/contracts/capability-decl.d.mts +0 -40
  737. package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
  738. package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
  739. package/dist/orchestrators/run.mjs +0 -91
  740. package/dist/orchestrators/run.mjs.map +0 -1
  741. package/dist/orchestrators/runtime-composition.d.mts +0 -10
  742. package/dist/orchestrators/runtime-composition.mjs +0 -252
  743. package/dist/orchestrators/runtime-composition.mjs.map +0 -1
  744. package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
  745. package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
  746. package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
  747. package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
  748. package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
  749. package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
  750. package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
  751. package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
  752. package/dist/orchestrators/snapshot/state-document.mjs +0 -58
  753. package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
  754. package/dist/plugins/account/spans.mjs +0 -16
  755. package/dist/plugins/account/spans.mjs.map +0 -1
  756. package/dist/plugins/account/variants/env.mjs +0 -24
  757. package/dist/plugins/account/variants/env.mjs.map +0 -1
  758. package/dist/plugins/account/variants/inline.mjs +0 -13
  759. package/dist/plugins/account/variants/inline.mjs.map +0 -1
  760. package/dist/plugins/account/variants/keystore.mjs +0 -91
  761. package/dist/plugins/account/variants/keystore.mjs.map +0 -1
  762. package/dist/plugins/action/spans.mjs +0 -11
  763. package/dist/plugins/action/spans.mjs.map +0 -1
  764. package/dist/plugins/coin/spans.mjs +0 -20
  765. package/dist/plugins/coin/spans.mjs.map +0 -1
  766. package/dist/plugins/deepbook/spans.mjs +0 -18
  767. package/dist/plugins/deepbook/spans.mjs.map +0 -1
  768. package/dist/plugins/faucet/spans.mjs +0 -12
  769. package/dist/plugins/faucet/spans.mjs.map +0 -1
  770. package/dist/plugins/package/spans.mjs +0 -14
  771. package/dist/plugins/package/spans.mjs.map +0 -1
  772. package/dist/plugins/postgres/codegen.mjs +0 -42
  773. package/dist/plugins/postgres/codegen.mjs.map +0 -1
  774. package/dist/plugins/postgres/connection.d.mts +0 -33
  775. package/dist/plugins/postgres/connection.mjs.map +0 -1
  776. package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
  777. package/dist/plugins/postgres/errors.d.mts +0 -60
  778. package/dist/plugins/postgres/errors.mjs +0 -29
  779. package/dist/plugins/postgres/errors.mjs.map +0 -1
  780. package/dist/plugins/postgres/index.d.mts +0 -37
  781. package/dist/plugins/postgres/index.mjs +0 -68
  782. package/dist/plugins/postgres/index.mjs.map +0 -1
  783. package/dist/plugins/postgres/routable.mjs +0 -33
  784. package/dist/plugins/postgres/routable.mjs.map +0 -1
  785. package/dist/plugins/postgres/service.d.mts +0 -50
  786. package/dist/plugins/postgres/service.mjs +0 -179
  787. package/dist/plugins/postgres/service.mjs.map +0 -1
  788. package/dist/plugins/postgres/snapshot.mjs +0 -32
  789. package/dist/plugins/postgres/snapshot.mjs.map +0 -1
  790. package/dist/plugins/postgres/spans.mjs +0 -11
  791. package/dist/plugins/postgres/spans.mjs.map +0 -1
  792. package/dist/plugins/seal/spans.mjs +0 -18
  793. package/dist/plugins/seal/spans.mjs.map +0 -1
  794. package/dist/plugins/sui/spans.mjs +0 -17
  795. package/dist/plugins/sui/spans.mjs.map +0 -1
  796. package/dist/plugins/wallet/spans.mjs +0 -22
  797. package/dist/plugins/wallet/spans.mjs.map +0 -1
  798. package/dist/plugins/walrus/registry-publish.d.mts +0 -24
  799. package/dist/plugins/walrus/spans.mjs +0 -18
  800. package/dist/plugins/walrus/spans.mjs.map +0 -1
  801. package/dist/runtime/docker/logs.d.mts +0 -1
  802. package/dist/runtime/docker/logs.mjs +0 -34
  803. package/dist/runtime/docker/logs.mjs.map +0 -1
  804. package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
  805. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
  806. package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
  807. package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
  808. package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
  809. package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
  810. package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
  811. package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
  812. package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
  813. package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
  814. package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
  815. package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
  816. package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
  817. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
  818. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
  819. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
  820. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
  821. package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
  822. package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
  823. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
  824. package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
  825. package/dist/substrate/runtime/observability/span-store.mjs +0 -110
  826. package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
  827. package/dist/substrate/runtime/observability/spans.d.mts +0 -1
  828. package/dist/substrate/runtime/observability/spans.mjs +0 -87
  829. package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
  830. package/dist/substrate/runtime/projection/index.mjs +0 -4
  831. package/dist/substrate/runtime/projection/persisted.mjs +0 -213
  832. package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
  833. package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
  834. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
  835. package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
  836. package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
  837. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
  838. package/dist/substrate/runtime/state-store/index.mjs +0 -3
  839. package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
  840. package/dist/substrate/runtime/state-store/schema.mjs +0 -41
  841. package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
  842. package/dist/substrate/runtime/state-store/service.d.mts +0 -1
  843. package/dist/substrate/runtime/state-store/service.mjs +0 -145
  844. package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
  845. package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
  846. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
  847. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
  848. package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
  849. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
  850. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
  851. package/dist/substrate/state-store.d.mts +0 -1
  852. /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
  853. /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
  854. /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
  855. /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
  856. /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
  857. /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
  858. /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"background-tasks.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/background-tasks.ts"],"sourcesContent":["// Background tasks: injected command handler runner, snapshot capture,\n// stack restart, and post-acquire hook.\n//\n// Each background task is forked into the supervisor's parent scope so\n// it rides the supervisor's lifetime rather than the command-loop\n// fiber. Interrupt requests use a Ref-typed handle (`idle`/`starting`/\n// `running`) so a sibling command can interrupt a running task without\n// racing the fork.\n\nimport { Cause, Effect, Exit, Fiber, Ref, Scope } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineCommand, EngineEvent } from '../../events.ts';\nimport { prettyErrorStructured } from '../observability/index.ts';\nimport { PostAcquireTaskFailed } from '../post-acquire-tasks.ts';\nimport { SupervisorPostAcquireFailed } from './errors.ts';\nimport type { SnapshotCaptureTaskState, StackRestartTaskState, SupervisorState } from './state.ts';\nimport { bestEffort, publish } from './wiring.ts';\n\n// Forward reference: the stack-restart background task runs through\n// the same `handleCommand` dispatch path that the command loop uses;\n// imports cycle if we hoist it directly, so we accept a runner from the\n// caller.\ntype HandleCommandRunner = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n) => Effect.Effect<void, SupervisorPostAcquireFailed, Scope.Scope>;\n\n/** `snapshot.captureFailed` / `snapshot.captureSkipped` carry a REQUIRED\n * `snapshotId`. When the originating command carried an id, surfaces\n * correlate the outcome with it (the CLI's pending-capture map keys on\n * it). When the command omitted an id there is nothing to correlate\n * against — the CLI's bridge does NOT register a pending-capture entry\n * for an id-less capture (`cli/wirings/up.ts` falls through to a\n * legacy auto-ack and never keys this synthetic id) — so the minted\n * `snap-<ts>` here only satisfies the event's required field. */\nconst effectiveSnapshotId = (\n\tcmd: Extract<EngineCommand, { readonly tag: 'snapshot.capture' }>,\n): string => cmd.snapshotId ?? `snap-${Date.now()}`;\n\nexport const runInjectedCommandHandler = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tif (deps.commandHandler === undefined) return;\n\t\tconst publishFromHandler = (event: EngineEvent): Effect.Effect<void, never, never> =>\n\t\t\tpublish(deps.ref, deps.hub, event);\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.commandHandler(cmd, {\n\t\t\t\tpublish: publishFromHandler,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (Cause.hasInterruptsOnly(exit.cause)) return;\n\t\tif (cmd.tag === 'snapshot.capture') {\n\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\ttag: 'snapshot.captureFailed',\n\t\t\t\tsnapshotId: effectiveSnapshotId(cmd),\n\t\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\t\tsummary: Cause.pretty(exit.cause).split('\\n')[0] ?? 'snapshot capture failed',\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t}\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(exit.cause, {\n\t\t\t\tpluginKey: null,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage: `command handler failed for ${cmd.tag}`,\n\t\t});\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.injectedCommandHandler'));\n\nexport const startBackgroundSnapshotCapture = (\n\tdeps: SupervisorState,\n\tcmd: Extract<EngineCommand, { readonly tag: 'snapshot.capture' }>,\n): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst token = yield* Ref.updateAndGet(deps.snapshotCaptureSeq, (n) => n + 1);\n\t\tconst started = yield* Ref.modify(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'idle'\n\t\t\t\t? [\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttag: 'starting' as const,\n\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\tsnapshotId: cmd.snapshotId ?? null,\n\t\t\t\t\t\t} satisfies SnapshotCaptureTaskState,\n\t\t\t\t\t]\n\t\t\t\t: [false, state],\n\t\t);\n\n\t\tif (!started) {\n\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\ttag: 'snapshot.captureSkipped',\n\t\t\t\treason: 'already-running',\n\t\t\t\tsnapshotId: effectiveSnapshotId(cmd),\n\t\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'snapshot.captureStarted',\n\t\t\t...(cmd.snapshotId === undefined ? {} : { snapshotId: cmd.snapshotId }),\n\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\tat: Date.now(),\n\t\t});\n\n\t\tconst fiber = yield* runInjectedCommandHandler(deps, cmd).pipe(\n\t\t\tEffect.ensuring(\n\t\t\t\tRef.update(deps.snapshotCaptureTask, (state) =>\n\t\t\t\t\tstate.tag !== 'idle' && state.token === token\n\t\t\t\t\t\t? ({ tag: 'idle' } satisfies SnapshotCaptureTaskState)\n\t\t\t\t\t\t: state,\n\t\t\t\t),\n\t\t\t),\n\t\t\tEffect.forkScoped,\n\t\t);\n\n\t\tyield* Ref.update(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'starting' && state.token === token\n\t\t\t\t? ({\n\t\t\t\t\t\ttag: 'running',\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tsnapshotId: cmd.snapshotId ?? null,\n\t\t\t\t\t\tfiber,\n\t\t\t\t\t} satisfies SnapshotCaptureTaskState)\n\t\t\t\t: state,\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.backgroundSnapshotCapture'));\n\nexport const requestBackgroundSnapshotInterrupt = (\n\tdeps: Pick<SupervisorState, 'snapshotCaptureTask'>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fiber = yield* Ref.modify(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'running'\n\t\t\t\t? [state.fiber, { tag: 'idle' } as SnapshotCaptureTaskState]\n\t\t\t\t: [null, state],\n\t\t);\n\t\t// Await the interrupt so a follow-up snapshot capture cannot begin\n\t\t// while the previous fiber is still inside `pauseAndCommit` /\n\t\t// `saveImages`. Mirrors `requestBackgroundStackRestartInterrupt`.\n\t\tif (fiber !== null) {\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.interruptSnapshotCapture'));\n\nexport const startBackgroundStackRestart = (\n\tdeps: SupervisorState,\n\thandleCommand: HandleCommandRunner,\n): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst token = yield* Ref.updateAndGet(deps.stackRestartSeq, (n) => n + 1);\n\t\tconst started = yield* Ref.modify(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'idle' ? [true, { tag: 'starting' as const, token }] : [false, state],\n\t\t);\n\n\t\tif (!started) {\n\t\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: 'stack restart skipped because one is already running',\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst fiber = yield* handleCommand(deps, { tag: 'stack.restart' }).pipe(\n\t\t\tEffect.catch(() => Effect.void),\n\t\t\tEffect.ensuring(\n\t\t\t\tRef.update(deps.stackRestartTask, (state) =>\n\t\t\t\t\tstate.tag !== 'idle' && state.token === token\n\t\t\t\t\t\t? ({ tag: 'idle' } satisfies StackRestartTaskState)\n\t\t\t\t\t\t: state,\n\t\t\t\t),\n\t\t\t),\n\t\t\tEffect.forkScoped,\n\t\t);\n\n\t\tyield* Ref.update(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'starting' && state.token === token\n\t\t\t\t? ({ tag: 'running', token, fiber } satisfies StackRestartTaskState)\n\t\t\t\t: state,\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.backgroundStackRestart'));\n\nexport const requestBackgroundStackRestartInterrupt = (\n\tdeps: Pick<SupervisorState, 'stackRestartTask'>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fiber = yield* Ref.modify(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'running'\n\t\t\t\t? [state.fiber, { tag: 'idle' } as StackRestartTaskState]\n\t\t\t\t: [null, state],\n\t\t);\n\t\tif (fiber !== null) {\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.interruptStackRestart'));\n\n// -----------------------------------------------------------------------------\n// Post-acquire hook\n// -----------------------------------------------------------------------------\n\nconst publishHookFailure = (\n\tdeps: SupervisorState,\n\tcause: Cause.Cause<unknown>,\n\tmessage: string,\n\tpluginKey: PluginKey | null = null,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(cause, {\n\t\t\t\tpluginKey,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage,\n\t\t});\n\t});\n\nconst findPostAcquireTaskFailure = (cause: Cause.Cause<unknown>): PostAcquireTaskFailed | null => {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) continue;\n\t\tif (reason.error instanceof PostAcquireTaskFailed) return reason.error;\n\t}\n\treturn null;\n};\n\nexport const runPostAcquireHook = (\n\tdeps: SupervisorState,\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\tEffect.gen(function* () {\n\t\tif (deps.postAcquireHook === undefined) return;\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.postAcquireHook({\n\t\t\t\tgraph: deps.graph,\n\t\t\t\tregistry: deps.registry,\n\t\t\t\tidentity: deps.identity,\n\t\t\t\truntimeRoot: deps.runtimeRoot,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst taskFailure = findPostAcquireTaskFailure(exit.cause);\n\t\tif (taskFailure !== null) {\n\t\t\tyield* bestEffort(deps.registry.markFailed(taskFailure.pluginKey, taskFailure.cause));\n\t\t}\n\t\tyield* publishHookFailure(\n\t\t\tdeps,\n\t\t\texit.cause,\n\t\t\ttaskFailure === null\n\t\t\t\t? 'post-acquire hook failed'\n\t\t\t\t: `post-acquire task failed: ${taskFailure.label}`,\n\t\t\ttaskFailure?.pluginKey ?? null,\n\t\t);\n\t\treturn yield* Effect.fail(new SupervisorPostAcquireFailed({ cause: exit.cause }));\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.postAcquireHook'));\n"],"mappings":"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"}
1
+ {"version":3,"file":"background-tasks.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/background-tasks.ts"],"sourcesContent":["// Background tasks: injected command handler runner, snapshot capture,\n// stack restart, and post-acquire hook.\n//\n// Each long-running background task (snapshot capture, stack restart) is\n// forked into the SUPERVISOR-LIFETIME scope via `Effect.forkIn` so it\n// rides the supervisor's lifetime rather than the command-loop fiber — a\n// forked capture must not wedge shutdown (Bug #13). The live fiber IS the\n// task's running state: it's held in a `BackgroundTaskSlot`\n// (`Ref<Fiber | null>`); a second concurrent trigger sees a non-null slot\n// and is skipped (skip-dedup), and a conflicting command reads-and-clears\n// the slot then `Fiber.interrupt`s it. This is the Effect-native\n// replacement for the hand-rolled idle/starting/running token Ref machine.\n\nimport { Cause, Effect, Exit, Fiber, Ref, Scope } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineCommand, EngineEvent } from '../../events.ts';\nimport { prettyErrorStructured } from '../observability/index.ts';\nimport { PostAcquireTaskFailed } from '../post-acquire-tasks.ts';\nimport { SupervisorPostAcquireFailed, SupervisorRestoreFailed } from './errors.ts';\nimport type { BackgroundTaskSlot, SupervisorState } from './state.ts';\nimport { bestEffort, publish } from './wiring.ts';\n\n// Forward reference: the stack-restart background task runs through\n// the same `handleCommand` dispatch path that the command loop uses;\n// imports cycle if we hoist it directly, so we accept a runner from the\n// caller.\ntype HandleCommandRunner = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n) => Effect.Effect<void, SupervisorPostAcquireFailed | SupervisorRestoreFailed, Scope.Scope>;\n\n/** `snapshot.captureFailed` / `snapshot.captureSkipped` carry a REQUIRED\n * `snapshotId`. When the originating command carried an id, surfaces\n * correlate the outcome with it (the CLI's pending-capture map keys on\n * it). When the command omitted an id there is nothing to correlate\n * against — the CLI's bridge does NOT register a pending-capture entry\n * for an id-less capture (`cli/wirings/up.ts` falls through to a plain\n * auto-ack and never keys this synthetic id) — so the minted\n * `snap-<ts>` here only satisfies the event's required field. */\nconst effectiveSnapshotId = (\n\tcmd: Extract<EngineCommand, { readonly tag: 'snapshot.capture' }>,\n): string => cmd.snapshotId ?? `snap-${Date.now()}`;\n\n/**\n * Run the injected L3 command handler and report the typed outcome.\n *\n * On success the handler's events are published and `ok: true` is\n * returned. On failure the failure is surfaced on the event stream\n * (`snapshot.captureFailed` for a capture, plus `error.reported`) AND\n * the cause is returned to the caller so a command that must NOT\n * proceed on a half-applied handler (e.g. `snapshot.restore`, which\n * otherwise drains + re-acquires every service off a half-restored\n * tree) can short-circuit and propagate the failure to `submitCommand`.\n *\n * Interrupt-only causes return `ok: true` (the interrupting sibling\n * owns the lifecycle decision) — same as the void runner below.\n */\nexport const runInjectedCommandHandlerExit = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n): Effect.Effect<\n\t{ readonly ok: true } | { readonly ok: false; readonly cause: Cause.Cause<unknown> },\n\tnever,\n\tnever\n> =>\n\tEffect.gen(function* () {\n\t\tif (deps.commandHandler === undefined) return { ok: true } as const;\n\t\tconst publishFromHandler = (event: EngineEvent): Effect.Effect<void, never, never> =>\n\t\t\tpublish(deps.ref, deps.hub, event);\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.commandHandler(cmd, {\n\t\t\t\tpublish: publishFromHandler,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn { ok: true } as const;\n\t\t}\n\t\tif (Cause.hasInterruptsOnly(exit.cause)) return { ok: true } as const;\n\t\tif (cmd.tag === 'snapshot.capture') {\n\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\ttag: 'snapshot.captureFailed',\n\t\t\t\tsnapshotId: effectiveSnapshotId(cmd),\n\t\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\t\tsummary: Cause.pretty(exit.cause).split('\\n')[0] ?? 'snapshot capture failed',\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t}\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(exit.cause, {\n\t\t\t\tpluginKey: null,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage: `command handler failed for ${cmd.tag}`,\n\t\t});\n\t\treturn { ok: false, cause: exit.cause } as const;\n\t});\n\n/**\n * Fire-and-forget wrapper over {@link runInjectedCommandHandlerExit}:\n * the handler's failure is already surfaced on the event stream, so the\n * void channel suffices for capture / list / delete / wipe / prune,\n * whose callers don't branch on the outcome.\n */\nexport const runInjectedCommandHandler = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n): Effect.Effect<void, never, never> => Effect.asVoid(runInjectedCommandHandlerExit(deps, cmd));\n\n/**\n * Fork `body` into the supervisor-lifetime scope and claim a background\n * task slot atomically.\n *\n * `Effect.forkIn(supervisorScope)` parents the fiber to the supervisor's\n * lifetime — NOT the command-loop fiber that triggered it — so a\n * long-running capture/restart does not block the command loop and\n * cannot wedge a subsequent `shutdown.requested` (Bug #13). The forked\n * fiber is created suspended (`forkIn`'s default `startImmediately`), so\n * the CAS below runs before it executes a single step.\n *\n * Skip-dedup: the slot is the running state. If it is already occupied\n * the just-forked fiber is interrupted (it never ran) and the function\n * returns `'skipped'` so the caller can publish/log the skip. Otherwise\n * the fiber is installed, its `ensuring` clears the slot on completion,\n * and the function returns `'started'`.\n */\nconst forkIntoSlot = (\n\tsupervisorScope: Scope.Scope,\n\tslot: BackgroundTaskSlot,\n\tbody: Effect.Effect<void, never, Scope.Scope>,\n): Effect.Effect<'started' | 'skipped', never, never> =>\n\tEffect.gen(function* () {\n\t\t// Self-clear the slot when the task settles (success OR interrupt),\n\t\t// but only if it still holds THIS fiber — a racing interrupt\n\t\t// (`interruptSlot`) may have already swapped it to `null`, or a\n\t\t// subsequent task may already own the slot. Comparing on the running\n\t\t// fiber's own id makes this self-contained (no fork-then-store hole).\n\t\tconst guarded = Effect.gen(function* () {\n\t\t\tconst selfId = yield* Effect.fiberId;\n\t\t\tyield* body.pipe(\n\t\t\t\tEffect.ensuring(\n\t\t\t\t\tRef.update(slot, (current) =>\n\t\t\t\t\t\tcurrent !== null && current.id === selfId ? null : current,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t});\n\t\t// Provide the supervisor scope to the body (so a forked restart's\n\t\t// `doSelectiveRestart` parents its plugin scopes off the supervisor's\n\t\t// lifetime, as the former `forkScoped` did) and fork into that same\n\t\t// scope so the fiber rides the supervisor's lifetime — NOT the\n\t\t// command-loop fiber that triggered it. `forkIn` does not start the\n\t\t// fiber immediately, so the CAS-claim below runs first.\n\t\tconst fiber = yield* Effect.forkIn(Scope.provide(guarded, supervisorScope), supervisorScope);\n\t\tconst claimed = yield* Ref.modify(slot, (current) =>\n\t\t\tcurrent === null ? [true, fiber] : [false, current],\n\t\t);\n\t\tif (!claimed) {\n\t\t\t// Slot already held by a running task — interrupt the fiber we\n\t\t\t// just forked (it has not run yet) and report the skip.\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t\treturn 'skipped' as const;\n\t\t}\n\t\treturn 'started' as const;\n\t});\n\n/**\n * Read-and-clear a background task slot, then await the fiber's\n * interrupt. Awaiting matters: a follow-up snapshot capture must not\n * begin while the previous fiber is still inside `pauseAndCommit` /\n * `saveImages`, and shutdown must not race a half-torn-down restart.\n */\nconst interruptSlot = (slot: BackgroundTaskSlot): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fiber = yield* Ref.getAndSet(slot, null);\n\t\tif (fiber !== null) {\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t}\n\t});\n\nexport const startBackgroundStackRestart = (\n\tdeps: SupervisorState,\n\thandleCommand: HandleCommandRunner,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst outcome = yield* forkIntoSlot(\n\t\t\tdeps.supervisorScope,\n\t\t\tdeps.stackRestartTask,\n\t\t\thandleCommand(deps, { tag: 'stack.restart' }).pipe(Effect.catch(() => Effect.void)),\n\t\t);\n\t\tif (outcome === 'skipped') {\n\t\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: 'stack restart skipped because one is already running',\n\t\t\t});\n\t\t}\n\t});\n\nexport const requestBackgroundStackRestartInterrupt = (\n\tdeps: Pick<SupervisorState, 'stackRestartTask'>,\n): Effect.Effect<void, never, never> => interruptSlot(deps.stackRestartTask);\n\n// -----------------------------------------------------------------------------\n// Post-acquire hook\n// -----------------------------------------------------------------------------\n\nconst publishHookFailure = (\n\tdeps: SupervisorState,\n\tcause: Cause.Cause<unknown>,\n\tmessage: string,\n\tpluginKey: PluginKey | null,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(cause, {\n\t\t\t\tpluginKey,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage,\n\t\t});\n\t});\n\nconst findPostAcquireTaskFailure = (cause: Cause.Cause<unknown>): PostAcquireTaskFailed | null => {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) continue;\n\t\tif (reason.error instanceof PostAcquireTaskFailed) return reason.error;\n\t}\n\treturn null;\n};\n\nexport const runPostAcquireHook = (\n\tdeps: SupervisorState,\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\tEffect.gen(function* () {\n\t\tif (deps.postAcquireHook === undefined) return;\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.postAcquireHook({\n\t\t\t\tgraph: deps.graph,\n\t\t\t\tregistry: deps.registry,\n\t\t\t\tidentity: deps.identity,\n\t\t\t\truntimeRoot: deps.runtimeRoot,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst taskFailure = findPostAcquireTaskFailure(exit.cause);\n\t\tif (taskFailure !== null) {\n\t\t\tyield* bestEffort(deps.registry.markFailed(taskFailure.pluginKey, taskFailure.cause));\n\t\t}\n\t\tyield* publishHookFailure(\n\t\t\tdeps,\n\t\t\texit.cause,\n\t\t\ttaskFailure === null\n\t\t\t\t? 'post-acquire hook failed'\n\t\t\t\t: `post-acquire task failed: ${taskFailure.label}`,\n\t\t\ttaskFailure?.pluginKey ?? null,\n\t\t);\n\t\treturn yield* Effect.fail(new SupervisorPostAcquireFailed({ cause: exit.cause }));\n\t});\n"],"mappings":"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"}
@@ -1,15 +1,16 @@
1
- import "./errors.mjs";
2
- import { planFullDrain } from "../lifecycle/selective-restart.mjs";
1
+ import { SupervisorRestoreFailed } from "./errors.mjs";
2
+ import { planExcluding } from "../lifecycle/selective-restart.mjs";
3
3
  import "../lifecycle/index.mjs";
4
- import { runInjectedCommandHandler, runPostAcquireHook, startBackgroundSnapshotCapture, startBackgroundStackRestart } from "./background-tasks.mjs";
4
+ import { allReadyOrTerminal } from "./state.mjs";
5
+ import { publish } from "./wiring.mjs";
6
+ import { runInjectedCommandHandler, runInjectedCommandHandlerExit, runPostAcquireHook, startBackgroundStackRestart } from "./background-tasks.mjs";
5
7
  import { doSelectiveRestart } from "./teardown.mjs";
6
8
  import { handleHardKillRequested, handleShutdownRequested } from "./shutdown.mjs";
7
- import { allReadyOrTerminal } from "./state.mjs";
8
- import { Deferred, Effect, Queue, Ref } from "effect";
9
+ import { Cause, Deferred, Effect, Queue, Ref } from "effect";
9
10
  //#region src/substrate/runtime/supervisor/command-loop.ts
10
11
  const maybeRunPostAcquire = (deps, options) => options.failOnPostAcquireHook === true ? runPostAcquireHook(deps) : runPostAcquireHook(deps).pipe(Effect.catch(() => Effect.void));
11
12
  const handleCommand = (deps, cmd, options = {}) => Effect.gen(function* () {
12
- const { graph, registry, pluginContext, sinks, logger, identity, runtimeRoot } = deps;
13
+ const { graph, registry, pluginContext, dispatcher, logger, identity } = deps;
13
14
  const parentScope = yield* Effect.scope;
14
15
  switch (cmd.tag) {
15
16
  case "shutdown.requested":
@@ -19,17 +20,15 @@ const handleCommand = (deps, cmd, options = {}) => Effect.gen(function* () {
19
20
  case "shutdown.hardKillRequested":
20
21
  yield* handleHardKillRequested(deps, cmd);
21
22
  return;
22
- case "stack.restart": {
23
- const plan = planFullDrain(graph);
24
- if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(plan.slice), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
23
+ case "stack.restart":
24
+ if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(graph.nodes.keys()), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
25
25
  return;
26
- }
27
26
  case "selective-restart.requested":
28
- if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
27
+ if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
29
28
  return;
30
29
  case "apply.requested":
31
30
  if (cmd.pluginKey !== void 0) {
32
- if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
31
+ if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
33
32
  return;
34
33
  }
35
34
  if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
@@ -37,10 +36,53 @@ const handleCommand = (deps, cmd, options = {}) => Effect.gen(function* () {
37
36
  case "codegen.requested":
38
37
  if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
39
38
  return;
40
- case "snapshot.capture":
41
- yield* startBackgroundSnapshotCapture(deps, cmd);
39
+ case "snapshot.capture": {
40
+ const captureOutcome = yield* runInjectedCommandHandlerExit(deps, cmd);
41
+ if (!captureOutcome.ok) {
42
+ const recoverPlan = planExcluding(graph, (node) => node.keepAliveOnRestore);
43
+ if (recoverPlan.slice.size > 0) yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(recoverPlan.slice), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.catch(() => Effect.void));
44
+ return yield* Effect.fail(new SupervisorRestoreFailed({
45
+ reason: "handler",
46
+ cause: captureOutcome.cause
47
+ }));
48
+ }
49
+ const plan = planExcluding(graph, (node) => node.keepAliveOnRestore);
50
+ if (plan.slice.size === 0) {
51
+ if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
52
+ return;
53
+ }
54
+ const recovered = yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(plan.slice), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)));
55
+ if (!(recovered && (yield* allReadyOrTerminal(graph, registry)))) return yield* Effect.fail(new SupervisorRestoreFailed({
56
+ reason: "reacquire",
57
+ cause: Cause.fail(/* @__PURE__ */ new Error(recovered ? "snapshot capture resume left one or more services not ready" : "snapshot capture resume failed"))
58
+ }));
59
+ yield* maybeRunPostAcquire(deps, options);
42
60
  return;
43
- case "snapshot.restore":
61
+ }
62
+ case "snapshot.restore": {
63
+ const restoreOutcome = yield* runInjectedCommandHandlerExit(deps, cmd);
64
+ if (!restoreOutcome.ok) return yield* Effect.fail(new SupervisorRestoreFailed({
65
+ reason: "handler",
66
+ cause: restoreOutcome.cause
67
+ }));
68
+ const plan = planExcluding(graph, (node) => node.keepAliveOnRestore);
69
+ if (plan.slice.size === 0) {
70
+ yield* publish(deps.ref, deps.hub, {
71
+ tag: "restart.completed",
72
+ target: "stack",
73
+ at: Date.now()
74
+ });
75
+ if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
76
+ return;
77
+ }
78
+ const restarted = yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(plan.slice), pluginContext, dispatcher, logger, identity, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)));
79
+ if (!(restarted && (yield* allReadyOrTerminal(graph, registry)))) return yield* Effect.fail(new SupervisorRestoreFailed({
80
+ reason: "reacquire",
81
+ cause: Cause.fail(/* @__PURE__ */ new Error(restarted ? "snapshot restore re-acquire left one or more services not ready" : "snapshot restore re-acquire failed"))
82
+ }));
83
+ yield* maybeRunPostAcquire(deps, options);
84
+ return;
85
+ }
44
86
  case "snapshot.list":
45
87
  case "snapshot.delete":
46
88
  case "wipe.requested":
@@ -50,18 +92,35 @@ const handleCommand = (deps, cmd, options = {}) => Effect.gen(function* () {
50
92
  case "advance-clock.requested":
51
93
  case "stack.start": return;
52
94
  }
53
- }).pipe(Effect.withSpan("lifecycle.supervisor.handleCommand"));
95
+ });
96
+ /**
97
+ * Dispatch one dequeued command. The loop is the SOLE consumer of the
98
+ * command queue, so the spine is: `dequeue → handle → await Exit →
99
+ * ack|fail`. Three intents:
100
+ *
101
+ * - `submitted` — the caller (`submitCommand`, the dashboard restore
102
+ * path) awaits the real exit, so run inline (`failOnPostAcquireHook`)
103
+ * and feed the Exit back through the completion deferred (the ack/fail).
104
+ * - fire-and-forget `stack.restart` — the watcher/keypress must not
105
+ * block the loop on a full re-acquire, so it forks into the
106
+ * supervisor scope (a second concurrent restart is skip-deduped).
107
+ * - every other fire-and-forget — run inline, swallowing failures (the
108
+ * handler already surfaced them on the event stream).
109
+ */
110
+ const dispatch = (deps, next) => {
111
+ if (next.kind === "submitted") return Effect.gen(function* () {
112
+ const exit = yield* Effect.exit(handleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }));
113
+ yield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);
114
+ });
115
+ if (next.command.tag === "stack.restart") return startBackgroundStackRestart(deps, handleCommand);
116
+ return handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));
117
+ };
54
118
  const commandLoop = (deps) => Effect.gen(function* () {
55
119
  while (true) {
56
- const next = yield* Queue.take(deps.queuedCommands);
57
- if (next.kind === "submitted") {
58
- const exit = yield* Effect.exit(handleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }));
59
- yield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);
60
- } else if (next.command.tag === "stack.restart") yield* startBackgroundStackRestart(deps, handleCommand);
61
- else yield* handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));
120
+ yield* dispatch(deps, yield* Queue.take(deps.queuedCommands));
62
121
  if (yield* Ref.get(deps.shutdownLatch)) return;
63
122
  }
64
- }).pipe(Effect.withSpan("lifecycle.supervisor.commandLoop"));
123
+ });
65
124
  //#endregion
66
125
  export { commandLoop };
67
126
 
@@ -1 +1 @@
1
- {"version":3,"file":"command-loop.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/command-loop.ts"],"sourcesContent":["// Supervisor command-loop.\n//\n// One consumer of the `queuedCommands` channel. Each iteration:\n// 1. Take the next queued command (fire-and-forget OR submitted).\n// 2. Dispatch via `handleCommand`. Submitted commands carry a\n// `completion` deferred so the publisher can await the exit.\n// 3. Re-check the shutdown latch — exit the loop when set.\n//\n// `handleCommand` switches by tag and delegates to the per-concern\n// modules (shutdown, teardown, selective-restart, background-tasks).\n\nimport { Deferred, Effect, Queue, Ref, Scope } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport {\n\trunInjectedCommandHandler,\n\trunPostAcquireHook,\n\tstartBackgroundSnapshotCapture,\n\tstartBackgroundStackRestart,\n} from './background-tasks.ts';\nimport { SupervisorPostAcquireFailed } from './errors.ts';\nimport { handleHardKillRequested, handleShutdownRequested } from './shutdown.ts';\nimport { allReadyOrTerminal, type SupervisorState } from './state.ts';\nimport { doSelectiveRestart } from './teardown.ts';\nimport { planFullDrain } from '../lifecycle/index.ts';\n\nconst maybeRunPostAcquire = (\n\tdeps: SupervisorState,\n\toptions: { readonly failOnPostAcquireHook?: boolean },\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\toptions.failOnPostAcquireHook === true\n\t\t? runPostAcquireHook(deps)\n\t\t: runPostAcquireHook(deps).pipe(Effect.catch(() => Effect.void));\n\nexport const handleCommand = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n\toptions: { readonly failOnPostAcquireHook?: boolean } = {},\n): Effect.Effect<void, SupervisorPostAcquireFailed, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, pluginContext, sinks, logger, identity, runtimeRoot } = deps;\n\t\tconst parentScope = yield* Effect.scope;\n\t\tswitch (cmd.tag) {\n\t\t\tcase 'shutdown.requested':\n\t\t\tcase 'stack.stop': {\n\t\t\t\tyield* handleShutdownRequested(deps);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'shutdown.hardKillRequested': {\n\t\t\t\tyield* handleHardKillRequested(deps, cmd);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'stack.restart': {\n\t\t\t\tconst plan = planFullDrain(graph);\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set(plan.slice),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tsinks,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\truntimeRoot,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'selective-restart.requested': {\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tsinks,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\truntimeRoot,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'apply.requested': {\n\t\t\t\t// Re-acquire after watch invalidation. Caller may target a\n\t\t\t\t// specific plugin; otherwise no-op (the watcher already fed\n\t\t\t\t// `selective-restart.requested` for the affected keys).\n\t\t\t\tif (cmd.pluginKey !== undefined) {\n\t\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\t\tgraph,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tdeps.ref,\n\t\t\t\t\t\tdeps.hub,\n\t\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\tsinks,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\truntimeRoot,\n\t\t\t\t\t\tparentScope,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.as(true),\n\t\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t\t);\n\t\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'codegen.requested': {\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Snapshot/wipe/prune are owned by injected L3 handlers. The\n\t\t\t// supervisor keeps one consumer of the command queue and only\n\t\t\t// publishes the handler's typed events / errors.\n\t\t\tcase 'snapshot.capture':\n\t\t\t\tyield* startBackgroundSnapshotCapture(deps, cmd);\n\t\t\t\treturn;\n\t\t\tcase 'snapshot.restore':\n\t\t\tcase 'snapshot.list':\n\t\t\tcase 'snapshot.delete':\n\t\t\tcase 'wipe.requested':\n\t\t\tcase 'prune.requested':\n\t\t\t\tyield* runInjectedCommandHandler(deps, cmd);\n\t\t\t\treturn;\n\t\t\tcase 'advance-clock.requested':\n\t\t\tcase 'stack.start':\n\t\t\t\treturn;\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.handleCommand'));\n\nexport const commandLoop = (deps: SupervisorState): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\twhile (true) {\n\t\t\tconst next = yield* Queue.take(deps.queuedCommands);\n\t\t\tif (next.kind === 'submitted') {\n\t\t\t\tconst exit = yield* Effect.exit(\n\t\t\t\t\thandleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }),\n\t\t\t\t);\n\t\t\t\tyield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);\n\t\t\t} else if (next.command.tag === 'stack.restart') {\n\t\t\t\tyield* startBackgroundStackRestart(deps, handleCommand);\n\t\t\t} else {\n\t\t\t\tyield* handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));\n\t\t\t}\n\t\t\tconst drained = yield* Ref.get(deps.shutdownLatch);\n\t\t\tif (drained) return;\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.commandLoop'));\n"],"mappings":";;;;;;;;;AA0BA,MAAM,uBACL,MACA,YAEA,QAAQ,0BAA0B,OAC/B,mBAAmB,KAAK,GACxB,mBAAmB,KAAK,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAElE,MAAa,iBACZ,MACA,KACA,UAAwD,EAAE,KAE1D,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,OAAO,UAAU,eAAe,OAAO,QAAQ,UAAU,gBAAgB;CACjF,MAAM,cAAc,OAAO,OAAO;AAClC,SAAQ,IAAI,KAAZ;EACC,KAAK;EACL,KAAK;AACJ,UAAO,wBAAwB,KAAK;AACpC;EAED,KAAK;AACJ,UAAO,wBAAwB,MAAM,IAAI;AACzC;EAED,KAAK,iBAAiB;GACrB,MAAM,OAAO,cAAc,MAAM;AAiBjC,QAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,KAAK,MAAM,EACnB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;;EAED,KAAK;AAiBJ,QAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,CAAC,IAAI,UAAU,CAAC,EACxB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAED,KAAK;AAIJ,OAAI,IAAI,cAAc,KAAA,GAAW;AAiBhC,SAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,CAAC,IAAI,UAAU,CAAC,EACxB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;;AAED,OAAI,OAAO,mBAAmB,OAAO,SAAS,CAC7C,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAED,KAAK;AACJ,OAAI,OAAO,mBAAmB,OAAO,SAAS,CAC7C,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAKD,KAAK;AACJ,UAAO,+BAA+B,MAAM,IAAI;AAChD;EACD,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;AACJ,UAAO,0BAA0B,MAAM,IAAI;AAC3C;EACD,KAAK;EACL,KAAK,cACJ;;EAED,CAAC,KAAK,OAAO,SAAS,qCAAqC,CAAC;AAE/D,MAAa,eAAe,SAC3B,OAAO,IAAI,aAAa;AACvB,QAAO,MAAM;EACZ,MAAM,OAAO,OAAO,MAAM,KAAK,KAAK,eAAe;AACnD,MAAI,KAAK,SAAS,aAAa;GAC9B,MAAM,OAAO,OAAO,OAAO,KAC1B,cAAc,MAAM,KAAK,WAAW,SAAS,EAAE,uBAAuB,MAAM,CAAC,CAC7E;AACD,UAAO,SAAS,QAAQ,KAAK,WAAW,YAAY,KAAK,CAAC,KAAK,OAAO,OAAO;aACnE,KAAK,QAAQ,QAAQ,gBAC/B,QAAO,4BAA4B,MAAM,cAAc;MAEvD,QAAO,cAAc,MAAM,KAAK,QAAQ,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAG/E,MAAI,OADmB,IAAI,IAAI,KAAK,cAAc,CACrC;;EAEb,CAAC,KAAK,OAAO,SAAS,mCAAmC,CAAC"}
1
+ {"version":3,"file":"command-loop.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/command-loop.ts"],"sourcesContent":["// Supervisor command-loop.\n//\n// One consumer of the `queuedCommands` channel. Each iteration:\n// 1. Take the next queued command (fire-and-forget OR submitted).\n// 2. Dispatch via `handleCommand`. Submitted commands carry a\n// `completion` deferred so the publisher can await the exit.\n// 3. Re-check the shutdown latch — exit the loop when set.\n//\n// `handleCommand` switches by tag and delegates to the per-concern\n// modules (shutdown, teardown, selective-restart, background-tasks).\n\nimport { Cause, Deferred, Effect, Queue, Ref, Scope } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport {\n\trunInjectedCommandHandler,\n\trunInjectedCommandHandlerExit,\n\trunPostAcquireHook,\n\tstartBackgroundStackRestart,\n} from './background-tasks.ts';\nimport { SupervisorRestoreFailed, SupervisorPostAcquireFailed } from './errors.ts';\nimport { handleHardKillRequested, handleShutdownRequested } from './shutdown.ts';\nimport { allReadyOrTerminal, type QueuedCommand, type SupervisorState } from './state.ts';\nimport { doSelectiveRestart } from './teardown.ts';\nimport { publish } from './wiring.ts';\nimport { planExcluding } from '../lifecycle/index.ts';\n\nconst maybeRunPostAcquire = (\n\tdeps: SupervisorState,\n\toptions: { readonly failOnPostAcquireHook?: boolean },\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\toptions.failOnPostAcquireHook === true\n\t\t? runPostAcquireHook(deps)\n\t\t: runPostAcquireHook(deps).pipe(Effect.catch(() => Effect.void));\n\nexport const handleCommand = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n\toptions: { readonly failOnPostAcquireHook?: boolean } = {},\n): Effect.Effect<void, SupervisorPostAcquireFailed | SupervisorRestoreFailed, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, pluginContext, dispatcher, logger, identity } = deps;\n\t\tconst parentScope = yield* Effect.scope;\n\t\tswitch (cmd.tag) {\n\t\t\tcase 'shutdown.requested':\n\t\t\tcase 'stack.stop': {\n\t\t\t\tyield* handleShutdownRequested(deps);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'shutdown.hardKillRequested': {\n\t\t\t\tyield* handleHardKillRequested(deps, cmd);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'stack.restart': {\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set(graph.nodes.keys()),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tdispatcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'selective-restart.requested': {\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tdispatcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'apply.requested': {\n\t\t\t\t// Re-acquire after watch invalidation. Caller may target a\n\t\t\t\t// specific plugin; otherwise no-op (the watcher already fed\n\t\t\t\t// `selective-restart.requested` for the affected keys).\n\t\t\t\tif (cmd.pluginKey !== undefined) {\n\t\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\t\tgraph,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tdeps.ref,\n\t\t\t\t\t\tdeps.hub,\n\t\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\tdispatcher,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tparentScope,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.as(true),\n\t\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t\t);\n\t\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'codegen.requested': {\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Snapshot/wipe/prune are owned by injected L3 handlers. The\n\t\t\t// supervisor keeps one consumer of the command queue and only\n\t\t\t// publishes the handler's typed events / errors.\n\t\t\tcase 'snapshot.capture': {\n\t\t\t\t// Capture is the lifecycle bounce, structurally IDENTICAL to\n\t\t\t\t// restore: the handler (`runCapture`) gathers (live) → graceful-\n\t\t\t\t// stops (flushes RocksDB) → commits + tars + writes meta → retags\n\t\t\t\t// each committed image onto its container's ORIGINAL name + HARD-rms\n\t\t\t\t// the stopped containers. This loop then runs the RESUME (CONVERGE\n\t\t\t\t// recreate-from-image + wait-write-ready): R1 removed the live\n\t\t\t\t// containers, so the re-acquire sees facts:null and recreates fresh\n\t\t\t\t// from the retagged committed images (whose names now resolve to the\n\t\t\t\t// flushed layers), inheriting walrus's write-ready ready-gate — so\n\t\t\t\t// the just-captured stack comes back write-ready (NEVER `docker\n\t\t\t\t// start`, which walrus nodes exit on). Mirrors `snapshot.restore`.\n\t\t\t\tconst captureOutcome = yield* runInjectedCommandHandlerExit(deps, cmd);\n\t\t\t\tif (!captureOutcome.ok) {\n\t\t\t\t\t// The handler already surfaced the failure on the event stream\n\t\t\t\t\t// (`snapshot.captureFailed` + `error.reported`). A failed capture\n\t\t\t\t\t// left the containers only STOPPED (recoverable) — converge them\n\t\t\t\t\t// back so the stack returns to running, then propagate.\n\t\t\t\t\tconst recoverPlan = planExcluding(graph, (node) => node.keepAliveOnRestore);\n\t\t\t\t\tif (recoverPlan.slice.size > 0) {\n\t\t\t\t\t\tyield* doSelectiveRestart(\n\t\t\t\t\t\t\tgraph,\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tdeps.ref,\n\t\t\t\t\t\t\tdeps.hub,\n\t\t\t\t\t\t\tnew Set(recoverPlan.slice),\n\t\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\t\tdispatcher,\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t\tidentity,\n\t\t\t\t\t\t\tparentScope,\n\t\t\t\t\t\t).pipe(Effect.catch(() => Effect.void));\n\t\t\t\t\t}\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew SupervisorRestoreFailed({ reason: 'handler', cause: captureOutcome.cause }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst plan = planExcluding(graph, (node) => node.keepAliveOnRestore);\n\t\t\t\tif (plan.slice.size === 0) {\n\t\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst recovered = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set(plan.slice),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tdispatcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tconst allReady = recovered && (yield* allReadyOrTerminal(graph, registry));\n\t\t\t\tif (!allReady) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew SupervisorRestoreFailed({\n\t\t\t\t\t\t\treason: 'reacquire',\n\t\t\t\t\t\t\tcause: Cause.fail(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\trecovered\n\t\t\t\t\t\t\t\t\t\t? 'snapshot capture resume left one or more services not ready'\n\t\t\t\t\t\t\t\t\t\t: 'snapshot capture resume failed',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'snapshot.restore': {\n\t\t\t\t// Restore is the unified reconcile's ORDERED 4-step body\n\t\t\t\t// split across this loop and the injected handler: the handler\n\t\t\t\t// (`runRestore`) runs step0 (identity-guard\n\t\t\t\t// precondition, fail-closed) → step1 (fsPlan swap-tree(untar))\n\t\t\t\t// → step2 R1 (HARD container rm). This loop runs step2 R2\n\t\t\t\t// (CONVERGE recreate-from-fresh): since R1 already removed the\n\t\t\t\t// live managed containers, the next acquire sees facts:null and\n\t\t\t\t// creates fresh from the restored images. The CLI offline path\n\t\t\t\t// gets that converge for free (supervisor was DOWN, boots fresh\n\t\t\t\t// after). For a LIVE supervisor (the dashboard path) nothing else\n\t\t\t\t// re-acquires — so we chain a drain + re-acquire here via\n\t\t\t\t// `doSelectiveRestart`, which sequences `teardownKeys` (drain)\n\t\t\t\t// then `acquireKeys` (converge) directly, mirroring\n\t\t\t\t// `stack.restart`. The handler runs first (and publishes\n\t\t\t\t// `snapshot.restored`); we only converge once it succeeded.\n\t\t\t\t//\n\t\t\t\t// Drain EXCLUDES any plugin that declared `keepAliveOnRestore`\n\t\t\t\t// (the operator transport answering this restore) so a\n\t\t\t\t// restore-initiating connection isn't torn down mid-flight —\n\t\t\t\t// otherwise the `submitCommand` completion the resolver awaits\n\t\t\t\t// never reaches the client (502) even though the restore +\n\t\t\t\t// re-acquire succeeded. The substrate planner filters on that\n\t\t\t\t// node flag alone, with no knowledge of which plugins set it.\n\t\t\t\t//\n\t\t\t\t// The handler runs via the TYPED-exit runner (not the\n\t\t\t\t// error-swallowing void wrapper) so a FAILED restore (bad\n\t\t\t\t// snapshot id, or a failure AFTER the on-disk swap)\n\t\t\t\t// short-circuits: we must NOT drain + re-acquire every service off\n\t\t\t\t// a half-applied tree, and the submitted-command completion must\n\t\t\t\t// FAIL so the dashboard mutation reports `{ ok:false }` instead of\n\t\t\t\t// resolving success on `id:\"does-not-exist\"`.\n\t\t\t\tconst restoreOutcome = yield* runInjectedCommandHandlerExit(deps, cmd);\n\t\t\t\tif (!restoreOutcome.ok) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew SupervisorRestoreFailed({ reason: 'handler', cause: restoreOutcome.cause }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst plan = planExcluding(graph, (node) => node.keepAliveOnRestore);\n\t\t\t\tif (plan.slice.size === 0) {\n\t\t\t\t\t// Empty re-acquire slice (the stack's only members are\n\t\t\t\t\t// dashboard()/host-service(...), which carry `keepAliveOnRestore`):\n\t\t\t\t\t// `doSelectiveRestart` emits its `restart.*` settle events\n\t\t\t\t\t// per-root, so an empty slice would fire NONE and leave the\n\t\t\t\t\t// projection stuck at the `restoring` phase set on\n\t\t\t\t\t// `snapshot.restored`. Emit the settle ourselves so the phase\n\t\t\t\t\t// returns to `running`.\n\t\t\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\t\t\ttag: 'restart.completed',\n\t\t\t\t\t\ttarget: 'stack',\n\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t});\n\t\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set(plan.slice),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tdispatcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\t// Feed the REAL re-acquire outcome into the completion: a valid\n\t\t\t\t// snapshot whose re-acquire leaves any row `failed` (port conflict,\n\t\t\t\t// broken dep) must report `{ ok:false }`, not a green dashboard with\n\t\t\t\t// failed rows. `allReadyOrTerminal` collapses a failed/unreadable\n\t\t\t\t// node to non-ready, so this is the all-rows-ready gate.\n\t\t\t\tconst allReady = restarted && (yield* allReadyOrTerminal(graph, registry));\n\t\t\t\tif (!allReady) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew SupervisorRestoreFailed({\n\t\t\t\t\t\t\treason: 'reacquire',\n\t\t\t\t\t\t\tcause: Cause.fail(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\trestarted\n\t\t\t\t\t\t\t\t\t\t? 'snapshot restore re-acquire left one or more services not ready'\n\t\t\t\t\t\t\t\t\t\t: 'snapshot restore re-acquire failed',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'snapshot.list':\n\t\t\tcase 'snapshot.delete':\n\t\t\tcase 'wipe.requested':\n\t\t\tcase 'prune.requested':\n\t\t\t\tyield* runInjectedCommandHandler(deps, cmd);\n\t\t\t\treturn;\n\t\t\tcase 'advance-clock.requested':\n\t\t\tcase 'stack.start':\n\t\t\t\treturn;\n\t\t}\n\t});\n\n/**\n * Dispatch one dequeued command. The loop is the SOLE consumer of the\n * command queue, so the spine is: `dequeue → handle → await Exit →\n * ack|fail`. Three intents:\n *\n * - `submitted` — the caller (`submitCommand`, the dashboard restore\n * path) awaits the real exit, so run inline (`failOnPostAcquireHook`)\n * and feed the Exit back through the completion deferred (the ack/fail).\n * - fire-and-forget `stack.restart` — the watcher/keypress must not\n * block the loop on a full re-acquire, so it forks into the\n * supervisor scope (a second concurrent restart is skip-deduped).\n * - every other fire-and-forget — run inline, swallowing failures (the\n * handler already surfaced them on the event stream).\n */\nconst dispatch = (\n\tdeps: SupervisorState,\n\tnext: QueuedCommand,\n): Effect.Effect<void, never, Scope.Scope> => {\n\tif (next.kind === 'submitted') {\n\t\treturn Effect.gen(function* () {\n\t\t\tconst exit = yield* Effect.exit(\n\t\t\t\thandleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }),\n\t\t\t);\n\t\t\tyield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);\n\t\t});\n\t}\n\tif (next.command.tag === 'stack.restart') {\n\t\treturn startBackgroundStackRestart(deps, handleCommand);\n\t}\n\treturn handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));\n};\n\nexport const commandLoop = (deps: SupervisorState): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\twhile (true) {\n\t\t\tyield* dispatch(deps, yield* Queue.take(deps.queuedCommands));\n\t\t\tif (yield* Ref.get(deps.shutdownLatch)) return;\n\t\t}\n\t});\n"],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ import { Effect } from "effect";
2
+ //#region src/substrate/runtime/supervisor/contribution-dispatcher.ts
3
+ /** A dispatcher whose methods are all no-ops. Used by bare smoke-test
4
+ * `supervise()` paths that layer no orchestrators — the buffered
5
+ * contributions simply have nowhere to go. */
6
+ const noopContributionDispatcher = {
7
+ snapshotable: () => Effect.void,
8
+ routable: () => Effect.void,
9
+ codegenable: () => Effect.void,
10
+ projection: () => Effect.void,
11
+ strategyContributor: () => Effect.void
12
+ };
13
+ //#endregion
14
+ export { noopContributionDispatcher };
15
+
16
+ //# sourceMappingURL=contribution-dispatcher.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution-dispatcher.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/contribution-dispatcher.ts"],"sourcesContent":["// ContributionDispatcher — the closed, typed post-start contribution seam.\n//\n// A CLOSED set of five typed dispatch methods, one per built-in\n// contribution kind. The supervisor reads the buffered ctx contributions\n// after a successful `start` and calls the matching method directly (an\n// exhaustive switch on the decl discriminant — no string-kind matching,\n// no UnknownContributionKind arm).\n//\n// Substrate name-blindness (ARCHITECTURE.md §\"Substrate name-blindness\"):\n// each method's BODY lives in L3 orchestrator composition\n// (`orchestrators/boot.ts buildProductionContributionDispatcher`),\n// where the backing orchestrator services (Snapshot/Codegen/Router/\n// ManifestEndpoint) are in scope. The supervisor only holds this opaque\n// record of effects — it never imports an orchestrator service and never\n// names a concrete contract beyond the five substrate-owned decl shapes.\n//\n// The four buffered verbs' backing services are SUPERVISOR-FRAME-ONLY\n// (absent from plugin scope), which is exactly why they are buffered and\n// replayed here rather than run inline in the plugin's `start`.\n\nimport { Effect, type Scope } from 'effect';\n\nimport type { ProjectionDecl } from '../../../contracts/projection.ts';\nimport type { RoutableDecl } from '../../../contracts/routable.ts';\nimport type { SnapshotableDecl } from '../../../contracts/snapshotable.ts';\nimport type { StrategyContributorDecl } from '../../../contracts/strategy-contributor.ts';\nimport type { CodegenableDecl } from '../../../contracts/codegenable.ts';\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { StrategyRegistry } from '../../../contracts/strategy-contributor.ts';\n\n/**\n * Per-plugin context the dispatcher methods receive. Carries the\n * plugin's key + the supervisor-owned `publish` (so dispatcher-emitted\n * events keep lifecycle/log/error ordering) + the scope-local\n * StrategyRegistry the `strategyContributor` body registers against.\n *\n * The dispatcher methods run on the plugin's scope (the supervisor\n * `Scope.provide`s it), so any `addFinalizer` they arm reaps on plugin\n * teardown (selective-restart / shutdown).\n */\nexport interface ContributionDispatchContext {\n\treadonly pluginKey: PluginKey;\n\treadonly publish: (event: EngineEvent) => Effect.Effect<void, never, never>;\n\treadonly strategyRegistry: StrategyRegistry;\n}\n\n/**\n * The closed, typed contribution-dispatch seam. EXACTLY five methods —\n * one per built-in contribution kind. Each `accept*` body is an effect\n * that may FAIL (`unknown` error channel): a failure is the\n * orchestrator-fault path (a broken sink, e.g. a router-route\n * collision), surfaced by the supervisor as\n * `engine.orchestrator.dispatchFailed` WITHOUT marking the plugin\n * failed.\n *\n * The bodies live in L3 (`buildProductionContributionDispatcher`); the\n * supervisor holds this record opaquely.\n */\nexport interface ContributionDispatcher {\n\treadonly snapshotable: (\n\t\tdecl: SnapshotableDecl,\n\t\tctx: ContributionDispatchContext,\n\t) => Effect.Effect<void, unknown, Scope.Scope>;\n\treadonly routable: (\n\t\tdecl: RoutableDecl,\n\t\tctx: ContributionDispatchContext,\n\t) => Effect.Effect<void, unknown, Scope.Scope>;\n\treadonly codegenable: (\n\t\tdecl: CodegenableDecl<string>,\n\t\tctx: ContributionDispatchContext,\n\t) => Effect.Effect<void, unknown, Scope.Scope>;\n\treadonly projection: (\n\t\tdecl: ProjectionDecl,\n\t\tctx: ContributionDispatchContext,\n\t) => Effect.Effect<void, unknown, Scope.Scope>;\n\treadonly strategyContributor: (\n\t\tdecl: StrategyContributorDecl<string, unknown>,\n\t\tctx: ContributionDispatchContext,\n\t) => Effect.Effect<void, unknown, Scope.Scope>;\n}\n\n/** A dispatcher whose methods are all no-ops. Used by bare smoke-test\n * `supervise()` paths that layer no orchestrators — the buffered\n * contributions simply have nowhere to go. */\nexport const noopContributionDispatcher: ContributionDispatcher = {\n\tsnapshotable: () => Effect.void,\n\troutable: () => Effect.void,\n\tcodegenable: () => Effect.void,\n\tprojection: () => Effect.void,\n\tstrategyContributor: () => Effect.void,\n};\n"],"mappings":";;;;;AAqFA,MAAa,6BAAqD;CACjE,oBAAoB,OAAO;CAC3B,gBAAgB,OAAO;CACvB,mBAAmB,OAAO;CAC1B,kBAAkB,OAAO;CACzB,2BAA2B,OAAO;AACnC"}
@@ -2,8 +2,17 @@ import { Data } from "effect";
2
2
  //#region src/substrate/runtime/supervisor/errors.ts
3
3
  var SupervisorBootError = class extends Data.TaggedError("SupervisorBootError") {};
4
4
  var SupervisorPostAcquireFailed = class extends Data.TaggedError("SupervisorPostAcquireFailed") {};
5
- var CapabilityFactoryFailed = class extends Data.TaggedError("CapabilityFactoryFailed") {};
5
+ /**
6
+ * A live `snapshot.restore` did not leave the stack in a good state.
7
+ * Raised by the command-loop so the submitted-command completion fails
8
+ * (and the dashboard mutation reports `{ ok: false, detail }`) instead
9
+ * of resolving success off a half-applied tree. Carries the failing
10
+ * cause — either the injected restore handler's failure (`reason:
11
+ * 'handler'`, drain skipped) or a post-restore re-acquire that left
12
+ * rows `failed` (`reason: 'reacquire'`).
13
+ */
14
+ var SupervisorRestoreFailed = class extends Data.TaggedError("SupervisorRestoreFailed") {};
6
15
  //#endregion
7
- export { CapabilityFactoryFailed, SupervisorBootError, SupervisorPostAcquireFailed };
16
+ export { SupervisorBootError, SupervisorPostAcquireFailed, SupervisorRestoreFailed };
8
17
 
9
18
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/errors.ts"],"sourcesContent":["// Supervisor-owned typed errors.\n//\n// Split out of the monolith. These shapes are part of the public\n// supervisor surface (re-exported from `./index.ts`).\n\nimport { Cause, Data } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { DepGraphError } from '../lifecycle/index.ts';\nimport type {\n\tPluginAcquireFailed,\n\tRestartTargetMissing,\n\tUnknownDependency,\n} from '../lifecycle/index.ts';\n\nexport class SupervisorBootError extends Data.TaggedError('SupervisorBootError')<{\n\treadonly cause: DepGraphError;\n}> {}\n\nexport class SupervisorPostAcquireFailed extends Data.TaggedError('SupervisorPostAcquireFailed')<{\n\treadonly cause: Cause.Cause<unknown>;\n}> {}\n\nexport class CapabilityFactoryFailed extends Data.TaggedError('CapabilityFactoryFailed')<{\n\treadonly pluginKey: PluginKey;\n\treadonly message: string;\n\treadonly cause: unknown;\n}> {}\n\nexport type SupervisorError =\n\t| SupervisorBootError\n\t| SupervisorPostAcquireFailed\n\t| CapabilityFactoryFailed\n\t| PluginAcquireFailed\n\t| RestartTargetMissing\n\t| UnknownDependency;\n"],"mappings":";;AAeA,IAAa,sBAAb,cAAyC,KAAK,YAAY,sBAAsB,CAE7E;AAEH,IAAa,8BAAb,cAAiD,KAAK,YAAY,8BAA8B,CAE7F;AAEH,IAAa,0BAAb,cAA6C,KAAK,YAAY,0BAA0B,CAIrF"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/errors.ts"],"sourcesContent":["// Supervisor-owned typed errors.\n//\n// Split out of the monolith. These shapes are part of the public\n// supervisor surface (re-exported from `./index.ts`).\n\nimport { Cause, Data } from 'effect';\n\nimport type { DepGraphError } from '../lifecycle/index.ts';\nimport type {\n\tPluginAcquireFailed,\n\tRestartTargetMissing,\n\tUnknownDependency,\n} from '../lifecycle/index.ts';\n\nexport class SupervisorBootError extends Data.TaggedError('SupervisorBootError')<{\n\treadonly cause: DepGraphError;\n}> {}\n\nexport class SupervisorPostAcquireFailed extends Data.TaggedError('SupervisorPostAcquireFailed')<{\n\treadonly cause: Cause.Cause<unknown>;\n}> {}\n\n/**\n * A live `snapshot.restore` did not leave the stack in a good state.\n * Raised by the command-loop so the submitted-command completion fails\n * (and the dashboard mutation reports `{ ok: false, detail }`) instead\n * of resolving success off a half-applied tree. Carries the failing\n * cause — either the injected restore handler's failure (`reason:\n * 'handler'`, drain skipped) or a post-restore re-acquire that left\n * rows `failed` (`reason: 'reacquire'`).\n */\nexport class SupervisorRestoreFailed extends Data.TaggedError('SupervisorRestoreFailed')<{\n\treadonly reason: 'handler' | 'reacquire';\n\treadonly cause: Cause.Cause<unknown>;\n}> {}\n\nexport type SupervisorError =\n\t| SupervisorBootError\n\t| SupervisorPostAcquireFailed\n\t| SupervisorRestoreFailed\n\t| PluginAcquireFailed\n\t| RestartTargetMissing\n\t| UnknownDependency;\n"],"mappings":";;AAcA,IAAa,sBAAb,cAAyC,KAAK,YAAY,qBAAqB,CAAC,CAE7E,CAAC;AAEJ,IAAa,8BAAb,cAAiD,KAAK,YAAY,6BAA6B,CAAC,CAE7F,CAAC;;;;;;;;;;AAWJ,IAAa,0BAAb,cAA6C,KAAK,YAAY,yBAAyB,CAAC,CAGrF,CAAC"}
@@ -1,3 +1,5 @@
1
1
  import "./errors.mjs";
2
+ import "./contribution-dispatcher.mjs";
3
+ import "./state.mjs";
2
4
  import "./start-supervisor.mjs";
3
5
  export {};
@@ -1,14 +1,12 @@
1
- import { planFullDrain } from "../lifecycle/selective-restart.mjs";
2
- import "../lifecycle/index.mjs";
1
+ import { plan } from "../reconcile/graph.mjs";
3
2
  import { publish, setCyclePhase } from "./wiring.mjs";
4
- import { requestBackgroundSnapshotInterrupt, requestBackgroundStackRestartInterrupt } from "./background-tasks.mjs";
3
+ import { requestBackgroundStackRestartInterrupt } from "./background-tasks.mjs";
5
4
  import { teardownKeys } from "./teardown.mjs";
6
5
  import { Deferred, Effect, Ref } from "effect";
7
6
  //#region src/substrate/runtime/supervisor/shutdown.ts
8
7
  const handleShutdownRequested = (deps) => Effect.gen(function* () {
9
8
  const { graph, registry, ref, shutdownLatch, logger } = deps;
10
9
  yield* Effect.uninterruptible(Effect.gen(function* () {
11
- yield* requestBackgroundSnapshotInterrupt(deps);
12
10
  yield* setCyclePhase(ref, "shutting-down");
13
11
  yield* Ref.set(shutdownLatch, true);
14
12
  yield* logger.log("supervisor", null, {
@@ -16,14 +14,16 @@ const handleShutdownRequested = (deps) => Effect.gen(function* () {
16
14
  message: "shutdown requested"
17
15
  });
18
16
  yield* requestBackgroundStackRestartInterrupt(deps);
19
- yield* teardownKeys(graph, registry, planFullDrain(graph).teardownOrder);
17
+ yield* teardownKeys(graph, registry, plan(graph, {
18
+ kind: "graph-keys",
19
+ keys: [...graph.nodes.keys()]
20
+ }).teardownOrder);
20
21
  yield* Effect.yieldNow;
21
22
  yield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);
22
23
  }));
23
24
  });
24
25
  const handleHardKillRequested = (deps, cmd) => Effect.gen(function* () {
25
26
  const { ref, hub, shutdownLatch, logger } = deps;
26
- yield* requestBackgroundSnapshotInterrupt(deps);
27
27
  yield* publish(ref, hub, {
28
28
  tag: "shutdown.escalated",
29
29
  signal: cmd.signal,
@@ -1 +1 @@
1
- {"version":3,"file":"shutdown.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/shutdown.ts"],"sourcesContent":["// Shutdown branches.\n//\n// Two paths handled here:\n//\n// - `shutdown.requested` / `stack.stop` — graceful drain. Teardown +\n// the deferred resolution live in one `Effect.uninterruptible`\n// block (Bug #13 fix, regression test in\n// `test/substrate/runtime/supervisor-hard-shutdown.test.ts`).\n//\n// - `shutdown.hardKillRequested` — escalated shutdown. The graceful\n// teardown is owned by the supervisor's scope-close finalizer\n// (which is already uninterruptible); this branch atomically\n// signals `shutdownComplete` + emits the fatal log so a third SIGINT\n// can't slip an Effect-level interrupt between the two writes.\n// `process.exit` from `signals.ts` IS still a hard kill — that\n// escape hatch is intentional double-Ctrl-C semantics.\n\nimport { Deferred, Effect, Ref } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport { planFullDrain } from '../lifecycle/index.ts';\nimport {\n\trequestBackgroundSnapshotInterrupt,\n\trequestBackgroundStackRestartInterrupt,\n} from './background-tasks.ts';\nimport type { SupervisorState } from './state.ts';\nimport { publish, setCyclePhase } from './wiring.ts';\nimport { teardownKeys } from './teardown.ts';\n\nexport const handleShutdownRequested = (deps: SupervisorState): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, ref, shutdownLatch, logger } = deps;\n\t\t// Uninterruptible covers the Effect-level interrupt a second\n\t\t// SIGINT would inject anywhere between the awaited snapshot/restart\n\t\t// interrupts, the latch set, and the shutdownComplete signal —\n\t\t// scope close racing the in-loop teardown leaks Docker containers,\n\t\t// and a second SIGINT landing during the awaited snapshot-interrupt\n\t\t// must not interrupt the command loop before teardown runs. The\n\t\t// latch set + deferred resolution live in the same block so callers\n\t\t// blocked on `awaitShutdown` only release AFTER teardown has run.\n\t\t// The signal handler's `process.exit` (signals.ts:75-102) is\n\t\t// still a hard kill — that's intentional; double-Ctrl-C is\n\t\t// the operator asking for abort.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* requestBackgroundSnapshotInterrupt(deps);\n\t\t\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\t\t\tyield* Ref.set(shutdownLatch, true);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'info',\n\t\t\t\t\tmessage: 'shutdown requested',\n\t\t\t\t});\n\t\t\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t\t\tconst plan = planFullDrain(graph);\n\t\t\t\tyield* teardownKeys(graph, registry, plan.teardownOrder);\n\t\t\t\tyield* Effect.yieldNow;\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t}),\n\t\t);\n\t});\n\nexport const handleHardKillRequested = (\n\tdeps: SupervisorState,\n\tcmd: Extract<EngineCommand, { readonly tag: 'shutdown.hardKillRequested' }>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { ref, hub, shutdownLatch, logger } = deps;\n\t\tyield* requestBackgroundSnapshotInterrupt(deps);\n\t\tyield* publish(ref, hub, {\n\t\t\ttag: 'shutdown.escalated',\n\t\t\tsignal: cmd.signal,\n\t\t\texitCode: cmd.exitCode,\n\t\t\tat: cmd.at,\n\t\t});\n\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\tyield* Ref.set(shutdownLatch, true);\n\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t// Hard-kill path: graceful teardown is owned by the\n\t\t// scope-close finalizer (start-supervisor.ts addFinalizer) which\n\t\t// already runs uninterruptibly. We only need to atomically signal\n\t\t// `shutdownComplete` + emit the fatal log so a third SIGINT\n\t\t// can't slip an Effect-level interrupt between the two.\n\t\t// `process.exit` from signals.ts:75-102 IS still the hard\n\t\t// kill — that escape hatch is intentional.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'fatal',\n\t\t\t\t\tmessage: `shutdown escalated by ${cmd.signal}`,\n\t\t\t\t\tfields: { signal: cmd.signal, exitCode: cmd.exitCode },\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t});\n"],"mappings":";;;;;;;AA6BA,MAAa,2BAA2B,SACvC,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,OAAO,UAAU,KAAK,eAAe,WAAW;AAYxD,QAAO,OAAO,gBACb,OAAO,IAAI,aAAa;AACvB,SAAO,mCAAmC,KAAK;AAC/C,SAAO,cAAc,KAAK,gBAAgB;AAC1C,SAAO,IAAI,IAAI,eAAe,KAAK;AACnC,SAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS;GACT,CAAC;AACF,SAAO,uCAAuC,KAAK;AAEnD,SAAO,aAAa,OAAO,UADd,cAAc,MACc,CAAC,cAAc;AACxD,SAAO,OAAO;AACd,SAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,EAAE,CAAC,KAAK,OAAO,OAAO;GACzE,CACF;EACA;AAEH,MAAa,2BACZ,MACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,KAAK,KAAK,eAAe,WAAW;AAC5C,QAAO,mCAAmC,KAAK;AAC/C,QAAO,QAAQ,KAAK,KAAK;EACxB,KAAK;EACL,QAAQ,IAAI;EACZ,UAAU,IAAI;EACd,IAAI,IAAI;EACR,CAAC;AACF,QAAO,cAAc,KAAK,gBAAgB;AAC1C,QAAO,IAAI,IAAI,eAAe,KAAK;AACnC,QAAO,uCAAuC,KAAK;AAQnD,QAAO,OAAO,gBACb,OAAO,IAAI,aAAa;AACvB,SAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,EAAE,CAAC,KAAK,OAAO,OAAO;AAC1E,SAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS,yBAAyB,IAAI;GACtC,QAAQ;IAAE,QAAQ,IAAI;IAAQ,UAAU,IAAI;IAAU;GACtD,CAAC;GACD,CACF;EACA"}
1
+ {"version":3,"file":"shutdown.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/shutdown.ts"],"sourcesContent":["// Shutdown branches.\n//\n// Two paths handled here:\n//\n// - `shutdown.requested` / `stack.stop` — graceful drain. Teardown +\n// the deferred resolution live in one `Effect.uninterruptible`\n// block (Bug #13 fix, regression test in\n// `test/substrate/runtime/supervisor-hard-shutdown.test.ts`).\n//\n// - `shutdown.hardKillRequested` — escalated shutdown. The graceful\n// teardown is owned by the supervisor's scope-close finalizer\n// (which is already uninterruptible); this branch atomically\n// signals `shutdownComplete` + emits the fatal log so a third SIGINT\n// can't slip an Effect-level interrupt between the two writes.\n// `process.exit` from `signals.ts` IS still a hard kill — that\n// escape hatch is intentional double-Ctrl-C semantics.\n\nimport { Deferred, Effect, Ref } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport { plan } from '../reconcile/graph.ts';\nimport { requestBackgroundStackRestartInterrupt } from './background-tasks.ts';\nimport type { SupervisorState } from './state.ts';\nimport { teardownKeys } from './teardown.ts';\nimport { publish, setCyclePhase } from './wiring.ts';\n\nexport const handleShutdownRequested = (deps: SupervisorState): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, ref, shutdownLatch, logger } = deps;\n\t\t// Uninterruptible covers the Effect-level interrupt a second\n\t\t// SIGINT would inject anywhere between the awaited snapshot/restart\n\t\t// interrupts, the latch set, and the shutdownComplete signal —\n\t\t// scope close racing the in-loop teardown leaks Docker containers,\n\t\t// and a second SIGINT landing during the awaited snapshot-interrupt\n\t\t// must not interrupt the command loop before teardown runs. The\n\t\t// latch set + deferred resolution live in the same block so callers\n\t\t// blocked on `awaitShutdown` only release AFTER teardown has run.\n\t\t// The signal handler's `process.exit` (signals.ts:75-102) is\n\t\t// still a hard kill — that's intentional; double-Ctrl-C is\n\t\t// the operator asking for abort.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\t\t\tyield* Ref.set(shutdownLatch, true);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'info',\n\t\t\t\t\tmessage: 'shutdown requested',\n\t\t\t\t});\n\t\t\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t\t\t// Graceful drain of the WHOLE graph: the kept `teardownKeys`\n\t\t\t\t// over reverse-dep order, over the full key set. This whole\n\t\t\t\t// block stays `Effect.uninterruptible` so a second SIGINT can't\n\t\t\t\t// slip an interrupt between the teardown and the latch/deferred\n\t\t\t\t// writes (Bug #13).\n\t\t\t\tconst fullDrain = plan(graph, {\n\t\t\t\t\tkind: 'graph-keys',\n\t\t\t\t\tkeys: [...graph.nodes.keys()],\n\t\t\t\t});\n\t\t\t\tyield* teardownKeys(graph, registry, fullDrain.teardownOrder);\n\t\t\t\tyield* Effect.yieldNow;\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t}),\n\t\t);\n\t});\n\nexport const handleHardKillRequested = (\n\tdeps: SupervisorState,\n\tcmd: Extract<EngineCommand, { readonly tag: 'shutdown.hardKillRequested' }>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { ref, hub, shutdownLatch, logger } = deps;\n\t\tyield* publish(ref, hub, {\n\t\t\ttag: 'shutdown.escalated',\n\t\t\tsignal: cmd.signal,\n\t\t\texitCode: cmd.exitCode,\n\t\t\tat: cmd.at,\n\t\t});\n\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\tyield* Ref.set(shutdownLatch, true);\n\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t// Hard-kill path: graceful teardown is owned by the\n\t\t// scope-close finalizer (start-supervisor.ts addFinalizer) which\n\t\t// already runs uninterruptibly. We only need to atomically signal\n\t\t// `shutdownComplete` + emit the fatal log so a third SIGINT\n\t\t// can't slip an Effect-level interrupt between the two.\n\t\t// `process.exit` from signals.ts:75-102 IS still the hard\n\t\t// kill — that escape hatch is intentional.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'fatal',\n\t\t\t\t\tmessage: `shutdown escalated by ${cmd.signal}`,\n\t\t\t\t\tfields: { signal: cmd.signal, exitCode: cmd.exitCode },\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t});\n"],"mappings":";;;;;;AA0BA,MAAa,2BAA2B,SACvC,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,OAAO,UAAU,KAAK,eAAe,WAAW;CAYxD,OAAO,OAAO,gBACb,OAAO,IAAI,aAAa;EACvB,OAAO,cAAc,KAAK,eAAe;EACzC,OAAO,IAAI,IAAI,eAAe,IAAI;EAClC,OAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS;EACV,CAAC;EACD,OAAO,uCAAuC,IAAI;EAUlD,OAAO,aAAa,OAAO,UAJT,KAAK,OAAO;GAC7B,MAAM;GACN,MAAM,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC;EAC7B,CAC6C,CAAC,CAAC,aAAa;EAC5D,OAAO,OAAO;EACd,OAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;CAC1E,CAAC,CACF;AACD,CAAC;AAEF,MAAa,2BACZ,MACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,KAAK,KAAK,eAAe,WAAW;CAC5C,OAAO,QAAQ,KAAK,KAAK;EACxB,KAAK;EACL,QAAQ,IAAI;EACZ,UAAU,IAAI;EACd,IAAI,IAAI;CACT,CAAC;CACD,OAAO,cAAc,KAAK,eAAe;CACzC,OAAO,IAAI,IAAI,eAAe,IAAI;CAClC,OAAO,uCAAuC,IAAI;CAQlD,OAAO,OAAO,gBACb,OAAO,IAAI,aAAa;EACvB,OAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM;EACzE,OAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS,yBAAyB,IAAI;GACtC,QAAQ;IAAE,QAAQ,IAAI;IAAQ,UAAU,IAAI;GAAS;EACtD,CAAC;CACF,CAAC,CACF;AACD,CAAC"}