@mysten-incubation/devstack 0.1.1 → 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 +6 -3
  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 -32
  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,17 +1,142 @@
1
1
  import { resolvePluginDependencies } from "../../plugin.mjs";
2
- import { annotateOp, annotatePhase, withPluginSpan } from "../observability/spans.mjs";
3
- import "../capability-sinks/index.mjs";
4
- import { prettyErrorStructured } from "../observability/pretty-error.mjs";
5
- import "../observability/index.mjs";
6
2
  import { buildDependencyReaderFor, makeEntry, makeRegistry } from "../lifecycle/plugin-registry.mjs";
7
3
  import { awaitUpstreams } from "../lifecycle/ready-gate.mjs";
8
4
  import "../lifecycle/index.mjs";
5
+ import { prettyErrorStructured } from "../observability/pretty-error.mjs";
6
+ import "../observability/index.mjs";
9
7
  import { CurrentPluginKey, CurrentPluginProgress } from "../current-plugin.mjs";
8
+ import { PluginContext } from "../../plugin-ctx.mjs";
9
+ import { StrategyRegistryService } from "../strategy-registry/service.mjs";
10
10
  import { operationalEndpointEventsFromResolvedValue } from "../projection/operational-endpoints.mjs";
11
- import { bestEffort, publish } from "./wiring.mjs";
12
- import { dispatchContributions, resolveCapabilities } from "./dispatch-contributions.mjs";
13
- import { Cause, Context, Effect, Exit, Scope } from "effect";
11
+ import { OptionalService, bestEffort, noopStrategyRegistry, publish } from "./wiring.mjs";
12
+ import { Cause, Context, Deferred, Effect, Exit, Fiber, Scope } from "effect";
14
13
  //#region src/substrate/runtime/supervisor/acquire-node.ts
14
+ /**
15
+ * Thrown (as a DEFECT, not a typed failure) when a plugin emits a ctx
16
+ * contribution AFTER its `start` returned and the buffer was sealed
17
+ * (PR#3). The buffer is the SOLE source of post-start contributions and
18
+ * is read exactly once after `start`; a late async emission — e.g. a verb
19
+ * called from a fiber the plugin forked but did not await — would
20
+ * otherwise be silently dropped (a route that never registers, a codegen
21
+ * file that never emits, with the plugin still `ready`). Sealing turns
22
+ * that silent loss into a loud, attributable crash on the OFFENDING
23
+ * fiber. The verb signatures return `void`, so this surfaces as a thrown
24
+ * defect rather than an Effect failure. */
25
+ var ContributionBufferSealedError = class extends Error {
26
+ _tag = "ContributionBufferSealedError";
27
+ constructor(pluginKey, kind) {
28
+ super(`plugin${pluginKey === null ? "" : ` '${pluginKey}'`} emitted a '${kind}' contribution after start() returned (the contribution buffer is sealed). Emit all ctx.* contributions synchronously within start(); a late async emission would be silently dropped.`);
29
+ this.name = "ContributionBufferSealedError";
30
+ }
31
+ };
32
+ const strategyRegistryAccess = OptionalService(StrategyRegistryService);
33
+ /**
34
+ * Build the per-plugin `PluginCtx` + its replay buffer. The four
35
+ * declarative verbs (`codegen`/`endpoint`/`snapshotExtra`/`publish`) and
36
+ * the strategy-bus writer (`provides`) PUSH a typed `BufferedContribution`
37
+ * into `buffer` IN EMIT ORDER; the supervisor replays that buffer through
38
+ * the closed `ContributionDispatcher` after a successful `start`. The
39
+ * buffer is the SOLE source of post-start contributions.
40
+ */
41
+ const makePluginCtx = (pluginKey) => {
42
+ const buffer = [];
43
+ let frozen = false;
44
+ const pushOrThrow = (kind, decl) => {
45
+ if (frozen) throw new ContributionBufferSealedError(pluginKey, kind);
46
+ buffer.push(decl);
47
+ };
48
+ return {
49
+ ctx: {
50
+ codegen: (decl) => {
51
+ pushOrThrow("codegenable", decl);
52
+ },
53
+ endpoint: (decl) => {
54
+ pushOrThrow("routable", decl);
55
+ },
56
+ snapshotExtra: (decl) => {
57
+ pushOrThrow("snapshotable", decl);
58
+ },
59
+ publish: (decl) => {
60
+ pushOrThrow("projection", decl);
61
+ },
62
+ provides: (decl) => {
63
+ pushOrThrow("strategy-contributor", decl);
64
+ }
65
+ },
66
+ buffer,
67
+ sealBuffer: () => {
68
+ frozen = true;
69
+ }
70
+ };
71
+ };
72
+ /**
73
+ * Render the underlying cause of a contribution-dispatch failure to a
74
+ * single operator-facing string. A failing dispatch body (e.g. a router
75
+ * route collision) may reject with an Effect `Cause`, a tagged domain
76
+ * error (carrying a spec-mismatch `detail`), a plain `Error`, or an
77
+ * arbitrary value. The plugin stays `ready`, so without this the
78
+ * operator would see a healthy-looking stack with dead routing.
79
+ */
80
+ const formatCause = (cause) => {
81
+ if (Cause.isCause(cause)) return Cause.pretty(cause);
82
+ if (cause instanceof Error) return cause.stack ?? cause.message;
83
+ if (typeof cause === "string") return cause;
84
+ try {
85
+ return JSON.stringify(cause) ?? String(cause);
86
+ } catch {
87
+ return String(cause);
88
+ }
89
+ };
90
+ /** Best-effort `_tag` of the failing cause for the additive `causeType`
91
+ * on the `dispatchFailed` event. */
92
+ const causeTagOf = (cause) => {
93
+ if (typeof cause === "object" && cause !== null && "_tag" in cause && typeof cause._tag === "string") return cause._tag;
94
+ };
95
+ /**
96
+ * Replay one plugin's buffered contributions through the closed
97
+ * `ContributionDispatcher` after a successful `start`.
98
+ *
99
+ * Failure semantics: a dispatch BODY failure is an orchestrator-fault —
100
+ * the supervisor publishes
101
+ * `engine.orchestrator.dispatchFailed` + logs a warning, and the plugin
102
+ * stays `ready` (NOT `markFailed`). The contribution kinds are a CLOSED
103
+ * union, so the dispatch is an exhaustive switch on the decl
104
+ * discriminant (no UnknownContributionKind arm).
105
+ *
106
+ * Runs on the plugin's scope (`pluginScope`) so any finalizer a dispatch
107
+ * body arms (e.g. `strategy.unregistered`) reaps on plugin teardown.
108
+ */
109
+ const dispatchBufferedContributions = (pluginKey, buffer, pluginContext, pluginScope, dispatcher, ref, hub) => Effect.gen(function* () {
110
+ const dispatchCtx = {
111
+ pluginKey,
112
+ publish: (event) => publish(ref, hub, event),
113
+ strategyRegistry: strategyRegistryAccess.read(pluginContext, noopStrategyRegistry)
114
+ };
115
+ for (const decl of buffer) {
116
+ const guarded = (() => {
117
+ switch (decl.kind) {
118
+ case "snapshotable": return dispatcher.snapshotable(decl, dispatchCtx);
119
+ case "codegenable": return dispatcher.codegenable(decl, dispatchCtx);
120
+ case "routable": return dispatcher.routable(decl, dispatchCtx);
121
+ case "projection": return dispatcher.projection(decl, dispatchCtx);
122
+ case "strategy-contributor": return dispatcher.strategyContributor(decl, dispatchCtx);
123
+ default: return Effect.void;
124
+ }
125
+ })().pipe(Effect.catch((cause) => Effect.gen(function* () {
126
+ const causeType = causeTagOf(cause);
127
+ yield* publish(ref, hub, {
128
+ tag: "engine.orchestrator.dispatchFailed",
129
+ pluginKey,
130
+ kind: decl.kind,
131
+ message: `routing/contribution sink '${decl.kind}' failed`,
132
+ ...causeType === void 0 ? {} : { causeType },
133
+ at: Date.now()
134
+ });
135
+ yield* Effect.logWarning(`routing/contribution sink '${decl.kind}' failed for plugin '${pluginKey}': ${formatCause(cause)}`);
136
+ })));
137
+ yield* Scope.provide(guarded, pluginScope);
138
+ }
139
+ });
15
140
  const buildRegistry = (graph, parentScope, emit) => Effect.gen(function* () {
16
141
  const entries = /* @__PURE__ */ new Map();
17
142
  for (const [key, node] of graph.nodes) {
@@ -40,7 +165,7 @@ const buildRegistry = (graph, parentScope, emit) => Effect.gen(function* () {
40
165
  * fiber surfaces the union via `Fiber.join` when the user asks for
41
166
  * "stack ready or err".
42
167
  */
43
- const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot) => Effect.gen(function* () {
168
+ const acquireNode = (registry, key, ref, hub, pluginContext, dispatcher, logger, _identity) => Effect.gen(function* () {
44
169
  const entry = registry.entries.get(key);
45
170
  if (entry === void 0) return;
46
171
  if ((yield* awaitUpstreams(registry, entry.node).pipe(Effect.matchEffect({
@@ -56,7 +181,6 @@ const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, iden
56
181
  });
57
182
  return;
58
183
  }
59
- yield* annotatePhase("acquire");
60
184
  yield* logger.log(`supervisor/${key}`, key, {
61
185
  level: "debug",
62
186
  message: "plugin acquire start",
@@ -66,7 +190,8 @@ const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, iden
66
190
  const readDependency = buildDependencyReaderFor(registry, entry.node);
67
191
  const deps = resolvePluginDependencies(entry.node.member, readDependency);
68
192
  const start = entry.node.member.start;
69
- const currentPluginContext = pluginContext.pipe(Context.add(CurrentPluginKey, { key }), Context.add(CurrentPluginProgress, { setPhase: (phase) => publish(ref, hub, {
193
+ const { ctx: pluginCtx, buffer, sealBuffer } = makePluginCtx(key);
194
+ const currentPluginContext = pluginContext.pipe(Context.add(CurrentPluginKey, { key }), Context.add(PluginContext, pluginCtx), Context.add(CurrentPluginProgress, { setPhase: (phase) => publish(ref, hub, {
70
195
  tag: "lifecycle.phaseSet",
71
196
  pluginKey: key,
72
197
  phase,
@@ -91,33 +216,10 @@ const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, iden
91
216
  value
92
217
  })
93
218
  }));
219
+ sealBuffer();
94
220
  if (result.ok) {
95
- const acquireContext = {
96
- identity,
97
- chain: identity.chain,
98
- runtimeRoot
99
- };
100
- const capsExit = yield* Effect.exit(resolveCapabilities(key, entry.node.member.capabilities, result.value, acquireContext));
101
- if (Exit.isFailure(capsExit)) {
102
- yield* bestEffort(registry.markFailed(key, capsExit.cause));
103
- yield* publish(ref, hub, {
104
- tag: "error.reported",
105
- error: prettyErrorStructured(capsExit.cause, {
106
- pluginKey: key,
107
- severity: "error",
108
- at: Date.now()
109
- })
110
- });
111
- yield* logger.log(`supervisor/${key}`, key, {
112
- level: "error",
113
- message: "plugin capability factory failed"
114
- });
115
- return;
116
- }
117
- const caps = capsExit.value;
118
- const errorContributions = entry.node.member.errorContributions ?? [];
119
- if (caps.length > 0 || errorContributions.length > 0) {
120
- const dispatchExit = yield* Effect.exit(dispatchContributions(key, caps, errorContributions, entry.node.member.role, identity, pluginContext, entry.scope, sinks, ref, hub));
221
+ if (buffer.length > 0) {
222
+ const dispatchExit = yield* Effect.exit(dispatchBufferedContributions(key, buffer, pluginContext, entry.scope, dispatcher, ref, hub));
121
223
  if (Exit.isFailure(dispatchExit)) {
122
224
  yield* bestEffort(registry.markFailed(key, dispatchExit.cause));
123
225
  yield* publish(ref, hub, {
@@ -135,7 +237,7 @@ const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, iden
135
237
  return;
136
238
  }
137
239
  }
138
- const routablesPresent = caps.some((capability) => capability.kind === "routable");
240
+ const routablesPresent = buffer.some((decl) => decl.kind === "routable");
139
241
  for (const event of operationalEndpointEventsFromResolvedValue(key, result.value, Date.now(), { routablesPresent })) yield* publish(ref, hub, event);
140
242
  yield* publish(ref, hub, {
141
243
  tag: "lifecycle.phaseSet",
@@ -148,33 +250,63 @@ const acquireNode = (registry, key, ref, hub, pluginContext, sinks, logger, iden
148
250
  yield* logger.log(`supervisor/${key}`, key, {
149
251
  level: "debug",
150
252
  message: entry.node.member.role === "task" ? "plugin done" : "plugin ready",
151
- fields: {
152
- capabilities: caps.length,
153
- errorContributions: errorContributions.length
154
- }
253
+ fields: { contributions: buffer.length }
155
254
  });
156
255
  } else yield* logger.log(`supervisor/${key}`, key, {
157
256
  level: "debug",
158
257
  message: "plugin acquire failed"
159
258
  });
160
- }).pipe(withPluginSpan("lifecycle.supervisor.acquireNode", {
161
- app: identity.app,
162
- stack: identity.stack,
163
- network: identity.chain,
164
- pluginKey: key,
165
- role: registry.entries.get(key)?.node.member.role ?? "service"
166
- }));
167
- const acquireKeys = (registry, keys, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot) => Effect.gen(function* () {
168
- yield* Effect.annotateCurrentSpan({ "devstack.level.size": keys.length });
169
- yield* Effect.all(keys.map((key) => acquireNode(registry, key, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot)), {
259
+ });
260
+ var PluginAcquireInterruptedBeforeReady = class extends Error {
261
+ pluginKey;
262
+ _tag = "PluginAcquireInterruptedBeforeReady";
263
+ constructor(pluginKey) {
264
+ super(`plugin '${pluginKey}' acquire was interrupted before readiness`);
265
+ this.pluginKey = pluginKey;
266
+ this.name = "PluginAcquireInterruptedBeforeReady";
267
+ }
268
+ };
269
+ const failIfAcquireInterruptedBeforeReady = (registry, key, entry) => Effect.gen(function* () {
270
+ if (registry.entries.get(key) !== entry) return;
271
+ const status = yield* registry.getStatus(key).pipe(Effect.catch(() => Effect.succeed(null)));
272
+ if (registry.entries.get(key) !== entry) return;
273
+ if (status !== "pending" && status !== "acquiring") return;
274
+ yield* bestEffort(registry.markFailed(key, new PluginAcquireInterruptedBeforeReady(key)));
275
+ });
276
+ const acquireKeys = (registry, keys, ref, hub, pluginContext, dispatcher, logger, identity, parentScope) => Effect.gen(function* () {
277
+ const fibers = yield* Effect.all(keys.map((key) => Effect.gen(function* () {
278
+ const entry = registry.entries.get(key);
279
+ if (entry === void 0) return yield* Effect.forkIn(Effect.void, parentScope);
280
+ const registeredGate = yield* Deferred.make();
281
+ const readyToRegister = yield* Deferred.make();
282
+ const guarded = Effect.gen(function* () {
283
+ const selfId = yield* Effect.fiberId;
284
+ yield* Effect.gen(function* () {
285
+ yield* Deferred.succeed(readyToRegister, void 0);
286
+ yield* Deferred.await(registeredGate);
287
+ yield* acquireNode(registry, key, ref, hub, pluginContext, dispatcher, logger, identity);
288
+ }).pipe(Effect.onInterrupt(() => failIfAcquireInterruptedBeforeReady(registry, key, entry)), Effect.ensuring(registry.clearAcquireFiberIfEntry(key, entry, selfId).pipe(Effect.catch(() => Effect.void))));
289
+ });
290
+ const fiber = yield* Effect.forkIn(Scope.provide(guarded, parentScope), parentScope);
291
+ yield* Deferred.await(readyToRegister);
292
+ if (!(yield* registry.setAcquireFiberIfEntry(key, entry, fiber).pipe(Effect.catch(() => Effect.succeed(false))))) {
293
+ yield* Fiber.interrupt(fiber).pipe(Effect.asVoid);
294
+ return fiber;
295
+ }
296
+ yield* Deferred.succeed(registeredGate, void 0);
297
+ return fiber;
298
+ })), { concurrency: "unbounded" });
299
+ yield* Effect.all(fibers.map((fiber) => Fiber.await(fiber).pipe(Effect.flatMap((exit) => {
300
+ if (Exit.isSuccess(exit) || Cause.hasInterruptsOnly(exit.cause)) return Effect.void;
301
+ return Effect.failCause(exit.cause);
302
+ }))), {
170
303
  concurrency: "unbounded",
171
304
  discard: true
172
305
  });
173
- }).pipe(Effect.withSpan("lifecycle.supervisor.acquireKeys"));
174
- const acquireFullGraph = (graph, registry, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot) => Effect.gen(function* () {
175
- yield* annotateOp("acquireFullGraph");
176
- yield* acquireKeys(registry, [...graph.nodes.keys()], ref, hub, pluginContext, sinks, logger, identity, runtimeRoot);
177
- }).pipe(Effect.withSpan("lifecycle.supervisor.acquireFullGraph"));
306
+ });
307
+ const acquireFullGraph = (graph, registry, ref, hub, pluginContext, dispatcher, logger, identity, parentScope) => Effect.gen(function* () {
308
+ yield* acquireKeys(registry, [...graph.nodes.keys()], ref, hub, pluginContext, dispatcher, logger, identity, parentScope);
309
+ });
178
310
  //#endregion
179
311
  export { acquireFullGraph, acquireKeys, buildRegistry };
180
312
 
@@ -1 +1 @@
1
- {"version":3,"file":"acquire-node.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/acquire-node.ts"],"sourcesContent":["// Per-plugin acquire pipeline.\n//\n// Three entrypoints:\n// - `buildRegistry(graph, parentScope, emit)` — boots the plugin\n// registry from a resolved graph; each plugin's scope is parented\n// to the supervisor's outer scope.\n// - `acquireNode(...)` — runs one plugin's `start` body inside its\n// entry scope; on success harvests `capabilities` +\n// `errorContributions` and registers them through `CapabilitySinks`.\n// - `acquireKeys` / `acquireFullGraph` — fan out per-node acquires\n// in parallel; each node waits on its own upstream ready gate.\n\nimport { Cause, Context, Effect, Exit, Queue, Scope, SubscriptionRef } from 'effect';\n\nimport type { CapabilityDecl } from '../../../contracts/capability-decl.ts';\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport { resolvePluginDependencies, type AcquireContext } from '../../plugin.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport { type CapabilitySinksShape } from '../capability-sinks/index.ts';\nimport { CurrentPluginKey, CurrentPluginProgress } from '../current-plugin.ts';\nimport {\n\tannotateOp,\n\tannotatePhase,\n\tprettyErrorStructured,\n\twithPluginSpan,\n\ttype LoggerShape,\n} from '../observability/index.ts';\nimport {\n\tawaitUpstreams,\n\tbuildDependencyReaderFor,\n\tmakeEntry,\n\tmakeRegistry,\n\ttype PluginEntry,\n\ttype PluginRegistry,\n\ttype ResolvedGraph,\n} from '../lifecycle/index.ts';\nimport { operationalEndpointEventsFromResolvedValue } from '../projection/operational-endpoints.ts';\nimport { dispatchContributions, resolveCapabilities } from './dispatch-contributions.ts';\nimport { bestEffort, publish } from './wiring.ts';\n\n// -----------------------------------------------------------------------------\n// Boot the registry from a graph\n// -----------------------------------------------------------------------------\n\nexport const buildRegistry = (\n\tgraph: ResolvedGraph,\n\tparentScope: Scope.Scope,\n\temit: (key: PluginKey, from: LifecycleStatus, to: LifecycleStatus) => Effect.Effect<void>,\n): Effect.Effect<PluginRegistry, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst entries = new Map<PluginKey, PluginEntry>();\n\t\tfor (const [key, node] of graph.nodes) {\n\t\t\tconst entry = yield* makeEntry(node, parentScope);\n\t\t\tentries.set(key, entry);\n\t\t}\n\t\treturn makeRegistry(entries, emit);\n\t});\n\n// -----------------------------------------------------------------------------\n// Acquire one node\n// -----------------------------------------------------------------------------\n\n/**\n * Run one node's `start` under its own scope. Steps:\n * 1. Await upstreams (their ready-gates).\n * 2. Transition `pending → acquiring` (publishes the event).\n * 3. Build resolved dependency values from declared resource refs.\n * 4. Run the plugin's `start` Effect inside the entry's Scope,\n * after providing the substrate-context services bundle so the\n * plugin's R-channel yields (`IdentityContext`,\n * `ContainerRuntimeService`, etc.) resolve to live instances.\n * 5. On success: stash the resolved value + `markReady` (publishes\n * the `ready` transition).\n * 6. On failure: `markFailed` (publishes the `failed` transition, fails\n * the deferred so downstream consumers short-circuit).\n *\n * Errors are caught and stashed onto the registry entry — the outer\n * scheduler doesn't propagate per-plugin failures; ready-gate failure\n * propagation handles the downstream blocking. The supervisor's outer\n * fiber surfaces the union via `Fiber.join` when the user asks for\n * \"stack ready or err\".\n */\nexport const acquireNode = (\n\tregistry: PluginRegistry,\n\tkey: PluginKey,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tsinks: CapabilitySinksShape,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\truntimeRoot: string,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst entry = registry.entries.get(key);\n\t\tif (entry === undefined) return;\n\t\tconst upstreamWait = awaitUpstreams(registry, entry.node).pipe(\n\t\t\tEffect.matchEffect({\n\t\t\t\tonFailure: (cause) =>\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* bestEffort(registry.markFailed(key, cause));\n\t\t\t\t\t\treturn false as const;\n\t\t\t\t\t}),\n\t\t\t\tonSuccess: () => Effect.succeed(true as const),\n\t\t\t}),\n\t\t);\n\t\tconst ok = yield* upstreamWait;\n\t\tif (ok !== true) {\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'warn',\n\t\t\t\tmessage: 'plugin acquire skipped — upstream failed',\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tyield* annotatePhase('acquire');\n\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\tlevel: 'debug',\n\t\t\tmessage: 'plugin acquire start',\n\t\t\tfields: { role: entry.node.member.role },\n\t\t});\n\t\t// Best-effort claim. `transition` `Effect.die`s on an off-table move,\n\t\t// which a concurrent acquire can trigger: an in-flight initial\n\t\t// `acquireNode` racing a selective-restart re-acquire of the same key\n\t\t// hits `acquiring → acquiring`. `Effect.catch` (used originally here)\n\t\t// cannot catch that DEFECT, so it would escape and kill the\n\t\t// command-loop fiber (supervisor wedge — same class as the lifecycle\n\t\t// reset fix). `Effect.exit` swallows BOTH failure and defect, keeping\n\t\t// this the best-effort transition it was always meant to be.\n\t\t// NOTE: this prevents the wedge but not the underlying double-acquire\n\t\t// (two fibers running one node's `start`). A complete fix must\n\t\t// interrupt a node's in-flight acquire fiber before a restart\n\t\t// re-acquires it — tracked as a follow-up (needs per-node acquire-fiber\n\t\t// handles, which `acquireKeys`' `Effect.all` does not retain today).\n\t\tyield* Effect.exit(registry.transition(key, 'acquiring'));\n\t\tconst readDependency = buildDependencyReaderFor(registry, entry.node);\n\t\tconst deps = resolvePluginDependencies(entry.node.member, readDependency);\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst start = entry.node.member.start as (\n\t\t\tdeps: unknown,\n\t\t) => Effect.Effect<unknown, unknown, any>;\n\t\tconst currentPluginContext = pluginContext.pipe(\n\t\t\tContext.add(CurrentPluginKey, { key }),\n\t\t\tContext.add(CurrentPluginProgress, {\n\t\t\t\tsetPhase: (phase) =>\n\t\t\t\t\tpublish(ref, hub, {\n\t\t\t\t\t\ttag: 'lifecycle.phaseSet',\n\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\tphase,\n\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t\tconst providedAcquire = Effect.provide(start(deps), currentPluginContext) as Effect.Effect<\n\t\t\tunknown,\n\t\t\tunknown,\n\t\t\tScope.Scope\n\t\t>;\n\t\tconst result = yield* Scope.provide(providedAcquire, entry.scope).pipe(\n\t\t\tEffect.matchEffect({\n\t\t\t\tonFailure: (cause) =>\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* bestEffort(registry.markFailed(key, cause));\n\t\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\t\ttag: 'error.reported',\n\t\t\t\t\t\t\terror: prettyErrorStructured(Cause.fail(cause), {\n\t\t\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\t\t\tseverity: 'error',\n\t\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { ok: false as const };\n\t\t\t\t\t}),\n\t\t\t\tonSuccess: (value: unknown) =>\n\t\t\t\t\tEffect.succeed({ ok: true as const, value: value as unknown }),\n\t\t\t}),\n\t\t);\n\t\tif (result.ok) {\n\t\t\tconst acquireContext: AcquireContext = {\n\t\t\t\tidentity,\n\t\t\t\tchain: identity.chain,\n\t\t\t\truntimeRoot,\n\t\t\t};\n\t\t\tconst capsExit = yield* Effect.exit(\n\t\t\t\tresolveCapabilities(\n\t\t\t\t\tkey,\n\t\t\t\t\tentry.node.member.capabilities as\n\t\t\t\t\t\t| ReadonlyArray<CapabilityDecl>\n\t\t\t\t\t\t| ((r: unknown, c: AcquireContext) => ReadonlyArray<CapabilityDecl>)\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tresult.value,\n\t\t\t\t\tacquireContext,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (Exit.isFailure(capsExit)) {\n\t\t\t\tyield* bestEffort(registry.markFailed(key, capsExit.cause));\n\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\ttag: 'error.reported',\n\t\t\t\t\terror: prettyErrorStructured(capsExit.cause, {\n\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\tseverity: 'error',\n\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\t\tlevel: 'error',\n\t\t\t\t\tmessage: 'plugin capability factory failed',\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst caps = capsExit.value;\n\t\t\tconst errorContributions = entry.node.member.errorContributions ?? [];\n\t\t\tif (caps.length > 0 || errorContributions.length > 0) {\n\t\t\t\tconst dispatchExit = yield* Effect.exit(\n\t\t\t\t\tdispatchContributions(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tcaps,\n\t\t\t\t\t\terrorContributions,\n\t\t\t\t\t\tentry.node.member.role,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\tentry.scope,\n\t\t\t\t\t\tsinks,\n\t\t\t\t\t\tref,\n\t\t\t\t\t\thub,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (Exit.isFailure(dispatchExit)) {\n\t\t\t\t\t// dispatchContributions catches both UnknownContributionKind\n\t\t\t\t\t// (no-op) and ContributionSinkFailed (orchestrator event +\n\t\t\t\t\t// warning) internally. A surfaced failure here therefore\n\t\t\t\t\t// reflects an unexpected defect — keep the legacy\n\t\t\t\t\t// markFailed projection so the unknown shape doesn't\n\t\t\t\t\t// silently degrade the plugin.\n\t\t\t\t\tyield* bestEffort(registry.markFailed(key, dispatchExit.cause));\n\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\ttag: 'error.reported',\n\t\t\t\t\t\terror: prettyErrorStructured(dispatchExit.cause, {\n\t\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\t\tseverity: 'error',\n\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\t\t\tlevel: 'error',\n\t\t\t\t\t\tmessage: 'plugin capability dispatch failed',\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst routablesPresent = caps.some((capability) => capability.kind === 'routable');\n\t\t\tfor (const event of operationalEndpointEventsFromResolvedValue(\n\t\t\t\tkey,\n\t\t\t\tresult.value,\n\t\t\t\tDate.now(),\n\t\t\t\t{\n\t\t\t\t\troutablesPresent,\n\t\t\t\t},\n\t\t\t)) {\n\t\t\t\tyield* publish(ref, hub, event);\n\t\t\t}\n\t\t\tyield* publish(ref, hub, {\n\t\t\t\ttag: 'lifecycle.phaseSet',\n\t\t\t\tpluginKey: key,\n\t\t\t\tphase: null,\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t\tyield* bestEffort(registry.markReady(key, result.value));\n\t\t\tif (entry.node.member.role === 'task') {\n\t\t\t\tyield* bestEffort(registry.transition(key, 'done'));\n\t\t\t}\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: entry.node.member.role === 'task' ? 'plugin done' : 'plugin ready',\n\t\t\t\tfields: {\n\t\t\t\t\tcapabilities: caps.length,\n\t\t\t\t\terrorContributions: errorContributions.length,\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: 'plugin acquire failed',\n\t\t\t});\n\t\t}\n\t}).pipe(\n\t\twithPluginSpan('lifecycle.supervisor.acquireNode', {\n\t\t\tapp: identity.app,\n\t\t\tstack: identity.stack,\n\t\t\tnetwork: identity.chain,\n\t\t\tpluginKey: key,\n\t\t\trole: registry.entries.get(key)?.node.member.role ?? 'service',\n\t\t}),\n\t);\n\n// -----------------------------------------------------------------------------\n// Acquire a key set in parallel. Each node waits on its own upstreams,\n// so downstream nodes begin as soon as their dependencies are ready\n// instead of waiting for unrelated nodes in the same topological level.\n// -----------------------------------------------------------------------------\n\nexport const acquireKeys = (\n\tregistry: PluginRegistry,\n\tkeys: ReadonlyArray<PluginKey>,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tsinks: CapabilitySinksShape,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\truntimeRoot: string,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.annotateCurrentSpan({ 'devstack.level.size': keys.length });\n\t\tyield* Effect.all(\n\t\t\tkeys.map((key) =>\n\t\t\t\tacquireNode(registry, key, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot),\n\t\t\t),\n\t\t\t{ concurrency: 'unbounded', discard: true },\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.acquireKeys'));\n\nexport const acquireFullGraph = (\n\tgraph: ResolvedGraph,\n\tregistry: PluginRegistry,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tsinks: CapabilitySinksShape,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\truntimeRoot: string,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* annotateOp('acquireFullGraph');\n\t\tyield* acquireKeys(\n\t\t\tregistry,\n\t\t\t[...graph.nodes.keys()],\n\t\t\tref,\n\t\t\thub,\n\t\t\tpluginContext,\n\t\t\tsinks,\n\t\t\tlogger,\n\t\t\tidentity,\n\t\t\truntimeRoot,\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.acquireFullGraph'));\n"],"mappings":";;;;;;;;;;;;;;AA+CA,MAAa,iBACZ,OACA,aACA,SAEA,OAAO,IAAI,aAAa;CACvB,MAAM,0BAAU,IAAI,KAA6B;AACjD,MAAK,MAAM,CAAC,KAAK,SAAS,MAAM,OAAO;EACtC,MAAM,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AO,IACb,KAAK,KAAK,QACT,YAAY,UAAU,KAAK,KAAK,KAAK,eAAe,OAAO,QAAQ,UAAU,YAAY,CACzF,EACD;EAAE,aAAa;EAAa,SAAS;EAAM,CAC3C;EACA,CAAC,KAAK,OAAO,SAAS,mCAAmC,CAAC;AAE7D,MAAa,oBACZ,OACA,UACA,KACA,KACA,eACA,OACA,QACA,UACA,gBAEA,OAAO,IAAI,aAAa;AACvB,QAAO,WAAW,mBAAmB;AACrC,QAAO,YACN,UACA,CAAC,GAAG,MAAM,MAAM,MAAM,CAAC,EACvB,KACA,KACA,eACA,OACA,QACA,UACA,YACA;EACA,CAAC,KAAK,OAAO,SAAS,wCAAwC,CAAC"}
1
+ {"version":3,"file":"acquire-node.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/acquire-node.ts"],"sourcesContent":["// Per-plugin acquire pipeline.\n//\n// Three entrypoints:\n// - `buildRegistry(graph, parentScope, emit)` — boots the plugin\n// registry from a resolved graph; each plugin's scope is parented\n// to the supervisor's outer scope.\n// - `acquireNode(...)` — runs one plugin's `start` body inside its\n// entry scope; on success replays the ctx-buffered contributions\n// through the closed `ContributionDispatcher`.\n// - `acquireKeys` / `acquireFullGraph` — fan out per-node acquires\n// in parallel; each node waits on its own upstream ready gate.\n\nimport {\n\tCause,\n\tContext,\n\tDeferred,\n\tEffect,\n\tExit,\n\tFiber,\n\tQueue,\n\tScope,\n\tSubscriptionRef,\n} from 'effect';\n\nimport type { CodegenableDecl } from '../../../contracts/codegenable.ts';\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 { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport type { PluginCtx } from '../../plugin-ctx.ts';\nimport { PluginContext } from '../../plugin-ctx.ts';\nimport { resolvePluginDependencies } from '../../plugin.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport { StrategyRegistryService } from '../strategy-registry/service.ts';\nimport { CurrentPluginKey, CurrentPluginProgress } from '../current-plugin.ts';\nimport { prettyErrorStructured, type LoggerShape } from '../observability/index.ts';\nimport {\n\tawaitUpstreams,\n\tbuildDependencyReaderFor,\n\tmakeEntry,\n\tmakeRegistry,\n\ttype PluginEntry,\n\ttype PluginRegistry,\n\ttype ResolvedGraph,\n} from '../lifecycle/index.ts';\nimport { operationalEndpointEventsFromResolvedValue } from '../projection/operational-endpoints.ts';\nimport type {\n\tContributionDispatcher,\n\tContributionDispatchContext,\n} from './contribution-dispatcher.ts';\nimport { bestEffort, noopStrategyRegistry, OptionalService, publish } from './wiring.ts';\n\n// A single buffered contribution — a discriminated union over the five\n// closed decl kinds, in the order the plugin's `start` emitted them.\ntype BufferedContribution =\n\t| SnapshotableDecl\n\t| CodegenableDecl<string>\n\t| RoutableDecl\n\t| ProjectionDecl\n\t| StrategyContributorDecl<string, unknown>;\n\n/**\n * Thrown (as a DEFECT, not a typed failure) when a plugin emits a ctx\n * contribution AFTER its `start` returned and the buffer was sealed\n * (PR#3). The buffer is the SOLE source of post-start contributions and\n * is read exactly once after `start`; a late async emission — e.g. a verb\n * called from a fiber the plugin forked but did not await — would\n * otherwise be silently dropped (a route that never registers, a codegen\n * file that never emits, with the plugin still `ready`). Sealing turns\n * that silent loss into a loud, attributable crash on the OFFENDING\n * fiber. The verb signatures return `void`, so this surfaces as a thrown\n * defect rather than an Effect failure. */\nexport class ContributionBufferSealedError extends Error {\n\treadonly _tag = 'ContributionBufferSealedError' as const;\n\tconstructor(pluginKey: PluginKey | null, kind: string) {\n\t\tsuper(\n\t\t\t`plugin${pluginKey === null ? '' : ` '${pluginKey}'`} emitted a '${kind}' contribution ` +\n\t\t\t\t`after start() returned (the contribution buffer is sealed). Emit all ctx.* ` +\n\t\t\t\t`contributions synchronously within start(); a late async emission would be ` +\n\t\t\t\t`silently dropped.`,\n\t\t);\n\t\tthis.name = 'ContributionBufferSealedError';\n\t}\n}\n\n// -----------------------------------------------------------------------------\n// Per-plugin PluginCtx\n// -----------------------------------------------------------------------------\n\nconst strategyRegistryAccess = OptionalService(StrategyRegistryService);\n\n/**\n * Build the per-plugin `PluginCtx` + its replay buffer. The four\n * declarative verbs (`codegen`/`endpoint`/`snapshotExtra`/`publish`) and\n * the strategy-bus writer (`provides`) PUSH a typed `BufferedContribution`\n * into `buffer` IN EMIT ORDER; the supervisor replays that buffer through\n * the closed `ContributionDispatcher` after a successful `start`. The\n * buffer is the SOLE source of post-start contributions.\n */\nconst makePluginCtx = (\n\tpluginKey: PluginKey,\n): {\n\treadonly ctx: PluginCtx;\n\treadonly buffer: BufferedContribution[];\n\treadonly sealBuffer: () => void;\n} => {\n\tconst buffer: BufferedContribution[] = [];\n\t// PR#3: the buffer is read exactly once after `start` returns, then\n\t// frozen. A push afterwards is a late async emission that would be\n\t// silently dropped — throw a loud, attributable defect instead.\n\tlet frozen = false;\n\tconst pushOrThrow = (kind: string, decl: BufferedContribution): void => {\n\t\tif (frozen) throw new ContributionBufferSealedError(pluginKey, kind);\n\t\tbuffer.push(decl);\n\t};\n\tconst ctx: PluginCtx = {\n\t\tcodegen: <E extends string>(decl: CodegenableDecl<E>): void => {\n\t\t\tpushOrThrow('codegenable', decl);\n\t\t},\n\t\tendpoint: (decl: RoutableDecl): void => {\n\t\t\tpushOrThrow('routable', decl);\n\t\t},\n\t\tsnapshotExtra: (decl: SnapshotableDecl): void => {\n\t\t\tpushOrThrow('snapshotable', decl);\n\t\t},\n\t\tpublish: (decl: ProjectionDecl): void => {\n\t\t\tpushOrThrow('projection', decl);\n\t\t},\n\t\tprovides: <K extends string, S>(decl: StrategyContributorDecl<K, S>): void => {\n\t\t\tpushOrThrow('strategy-contributor', decl);\n\t\t},\n\t};\n\treturn {\n\t\tctx,\n\t\tbuffer,\n\t\tsealBuffer: () => {\n\t\t\tfrozen = true;\n\t\t},\n\t};\n};\n\n// -----------------------------------------------------------------------------\n// Static post-start dispatch\n// -----------------------------------------------------------------------------\n\n/**\n * Render the underlying cause of a contribution-dispatch failure to a\n * single operator-facing string. A failing dispatch body (e.g. a router\n * route collision) may reject with an Effect `Cause`, a tagged domain\n * error (carrying a spec-mismatch `detail`), a plain `Error`, or an\n * arbitrary value. The plugin stays `ready`, so without this the\n * operator would see a healthy-looking stack with dead routing.\n */\nconst formatCause = (cause: unknown): string => {\n\tif (Cause.isCause(cause)) return Cause.pretty(cause);\n\tif (cause instanceof Error) return cause.stack ?? cause.message;\n\tif (typeof cause === 'string') return cause;\n\ttry {\n\t\treturn JSON.stringify(cause) ?? String(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n};\n\n/** Best-effort `_tag` of the failing cause for the additive `causeType`\n * on the `dispatchFailed` event. */\nconst causeTagOf = (cause: unknown): string | undefined => {\n\tif (\n\t\ttypeof cause === 'object' &&\n\t\tcause !== null &&\n\t\t'_tag' in cause &&\n\t\ttypeof (cause as { _tag: unknown })._tag === 'string'\n\t) {\n\t\treturn (cause as { _tag: string })._tag;\n\t}\n\treturn undefined;\n};\n\n/**\n * Replay one plugin's buffered contributions through the closed\n * `ContributionDispatcher` after a successful `start`.\n *\n * Failure semantics: a dispatch BODY failure is an orchestrator-fault —\n * the supervisor publishes\n * `engine.orchestrator.dispatchFailed` + logs a warning, and the plugin\n * stays `ready` (NOT `markFailed`). The contribution kinds are a CLOSED\n * union, so the dispatch is an exhaustive switch on the decl\n * discriminant (no UnknownContributionKind arm).\n *\n * Runs on the plugin's scope (`pluginScope`) so any finalizer a dispatch\n * body arms (e.g. `strategy.unregistered`) reaps on plugin teardown.\n */\nconst dispatchBufferedContributions = (\n\tpluginKey: PluginKey,\n\tbuffer: ReadonlyArray<BufferedContribution>,\n\tpluginContext: Context.Context<never>,\n\tpluginScope: Scope.Scope,\n\tdispatcher: ContributionDispatcher,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst strategyRegistry = strategyRegistryAccess.read(pluginContext, noopStrategyRegistry);\n\t\tconst dispatchCtx: ContributionDispatchContext = {\n\t\t\tpluginKey,\n\t\t\tpublish: (event) => publish(ref, hub, event),\n\t\t\tstrategyRegistry,\n\t\t};\n\n\t\tfor (const decl of buffer) {\n\t\t\tconst body = ((): Effect.Effect<void, unknown, Scope.Scope> => {\n\t\t\t\tswitch (decl.kind) {\n\t\t\t\t\tcase 'snapshotable':\n\t\t\t\t\t\treturn dispatcher.snapshotable(decl, dispatchCtx);\n\t\t\t\t\tcase 'codegenable':\n\t\t\t\t\t\treturn dispatcher.codegenable(decl, dispatchCtx);\n\t\t\t\t\tcase 'routable':\n\t\t\t\t\t\treturn dispatcher.routable(decl, dispatchCtx);\n\t\t\t\t\tcase 'projection':\n\t\t\t\t\t\treturn dispatcher.projection(decl, dispatchCtx);\n\t\t\t\t\tcase 'strategy-contributor':\n\t\t\t\t\t\treturn dispatcher.strategyContributor(decl, dispatchCtx);\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tconst _exhaustive: never = decl;\n\t\t\t\t\t\tvoid _exhaustive;\n\t\t\t\t\t\treturn Effect.void;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})();\n\t\t\t// Orchestrator-fault path: a dispatch body failure surfaces the\n\t\t\t// typed `dispatchFailed` event + warning WITHOUT marking the\n\t\t\t// plugin failed (the plugin already reached a good `start`).\n\t\t\tconst guarded = body.pipe(\n\t\t\t\tEffect.catch((cause) =>\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tconst causeType = causeTagOf(cause);\n\t\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\t\ttag: 'engine.orchestrator.dispatchFailed',\n\t\t\t\t\t\t\tpluginKey,\n\t\t\t\t\t\t\tkind: decl.kind,\n\t\t\t\t\t\t\tmessage: `routing/contribution sink '${decl.kind}' failed`,\n\t\t\t\t\t\t\t...(causeType === undefined ? {} : { causeType }),\n\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t\t\t`routing/contribution sink '${decl.kind}' failed for plugin '${pluginKey}': ${formatCause(cause)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tyield* Scope.provide(guarded, pluginScope);\n\t\t}\n\t});\n\n// -----------------------------------------------------------------------------\n// Boot the registry from a graph\n// -----------------------------------------------------------------------------\n\nexport const buildRegistry = (\n\tgraph: ResolvedGraph,\n\tparentScope: Scope.Scope,\n\temit: (key: PluginKey, from: LifecycleStatus, to: LifecycleStatus) => Effect.Effect<void>,\n): Effect.Effect<PluginRegistry, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst entries = new Map<PluginKey, PluginEntry>();\n\t\tfor (const [key, node] of graph.nodes) {\n\t\t\tconst entry = yield* makeEntry(node, parentScope);\n\t\t\tentries.set(key, entry);\n\t\t}\n\t\treturn makeRegistry(entries, emit);\n\t});\n\n// -----------------------------------------------------------------------------\n// Acquire one node\n// -----------------------------------------------------------------------------\n\n/**\n * Run one node's `start` under its own scope. Steps:\n * 1. Await upstreams (their ready-gates).\n * 2. Transition `pending → acquiring` (publishes the event).\n * 3. Build resolved dependency values from declared resource refs.\n * 4. Run the plugin's `start` Effect inside the entry's Scope,\n * after providing the substrate-context services bundle so the\n * plugin's R-channel yields (`IdentityContext`,\n * `ContainerRuntimeService`, etc.) resolve to live instances.\n * 5. On success: stash the resolved value + `markReady` (publishes\n * the `ready` transition).\n * 6. On failure: `markFailed` (publishes the `failed` transition, fails\n * the deferred so downstream consumers short-circuit).\n *\n * Errors are caught and stashed onto the registry entry — the outer\n * scheduler doesn't propagate per-plugin failures; ready-gate failure\n * propagation handles the downstream blocking. The supervisor's outer\n * fiber surfaces the union via `Fiber.join` when the user asks for\n * \"stack ready or err\".\n */\nexport const acquireNode = (\n\tregistry: PluginRegistry,\n\tkey: PluginKey,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tdispatcher: ContributionDispatcher,\n\tlogger: LoggerShape,\n\t// Threaded through the acquire path for parity with acquireKeys/\n\t// acquireFullGraph; no longer read here (only the removed span used it).\n\t_identity: Identity,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst entry = registry.entries.get(key);\n\t\tif (entry === undefined) return;\n\t\tconst upstreamWait = awaitUpstreams(registry, entry.node).pipe(\n\t\t\tEffect.matchEffect({\n\t\t\t\tonFailure: (cause) =>\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* bestEffort(registry.markFailed(key, cause));\n\t\t\t\t\t\treturn false as const;\n\t\t\t\t\t}),\n\t\t\t\tonSuccess: () => Effect.succeed(true as const),\n\t\t\t}),\n\t\t);\n\t\tconst ok = yield* upstreamWait;\n\t\tif (ok !== true) {\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'warn',\n\t\t\t\tmessage: 'plugin acquire skipped — upstream failed',\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\tlevel: 'debug',\n\t\t\tmessage: 'plugin acquire start',\n\t\t\tfields: { role: entry.node.member.role },\n\t\t});\n\t\t// Best-effort claim. `transition` `Effect.die`s on an off-table move,\n\t\t// which a concurrent acquire can trigger: an in-flight initial\n\t\t// `acquireNode` racing a selective-restart re-acquire of the same key\n\t\t// hits `acquiring → acquiring`. `Effect.catch` (used originally here)\n\t\t// cannot catch that DEFECT, so it would escape and kill the\n\t\t// command-loop fiber (supervisor wedge — same class as the lifecycle\n\t\t// reset fix). `Effect.exit` swallows BOTH failure and defect, keeping\n\t\t// this the best-effort transition it was always meant to be.\n\t\t// NOTE: this prevents the wedge but not the underlying double-acquire\n\t\t// (two fibers running one node's `start`). A complete fix must\n\t\t// interrupt a node's in-flight acquire fiber before a restart\n\t\t// re-acquires it — tracked as a follow-up (needs per-node acquire-fiber\n\t\t// handles, which `acquireKeys`' `Effect.all` does not retain today).\n\t\tyield* Effect.exit(registry.transition(key, 'acquiring'));\n\t\tconst readDependency = buildDependencyReaderFor(registry, entry.node);\n\t\tconst deps = resolvePluginDependencies(entry.node.member, readDependency);\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst start = entry.node.member.start as (\n\t\t\tdeps: unknown,\n\t\t) => Effect.Effect<unknown, unknown, any>;\n\t\t// Build the per-plugin ctx + replay buffer. Every plugin emits its\n\t\t// contributions inline via the typed `ctx` verbs during `start`; the\n\t\t// buffer is the SOLE source of the post-start dispatch.\n\t\t// The ctx is delivered through the `PluginContext` service tag (a\n\t\t// plugin reaches it with `yield* PluginContext`), provided into the\n\t\t// start Effect's requirement channel below — NOT as a 2nd positional\n\t\t// argument — which keeps `start` single-arg and `deps` auto-inferred.\n\t\tconst { ctx: pluginCtx, buffer, sealBuffer } = makePluginCtx(key);\n\t\tconst currentPluginContext = pluginContext.pipe(\n\t\t\tContext.add(CurrentPluginKey, { key }),\n\t\t\tContext.add(PluginContext, pluginCtx),\n\t\t\tContext.add(CurrentPluginProgress, {\n\t\t\t\tsetPhase: (phase) =>\n\t\t\t\t\tpublish(ref, hub, {\n\t\t\t\t\t\ttag: 'lifecycle.phaseSet',\n\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\tphase,\n\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t\tconst providedAcquire = Effect.provide(start(deps), currentPluginContext) as Effect.Effect<\n\t\t\tunknown,\n\t\t\tunknown,\n\t\t\tScope.Scope\n\t\t>;\n\t\tconst result = yield* Scope.provide(providedAcquire, entry.scope).pipe(\n\t\t\tEffect.matchEffect({\n\t\t\t\tonFailure: (cause) =>\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\tyield* bestEffort(registry.markFailed(key, cause));\n\t\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\t\ttag: 'error.reported',\n\t\t\t\t\t\t\terror: prettyErrorStructured(Cause.fail(cause), {\n\t\t\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\t\t\tseverity: 'error',\n\t\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { ok: false as const };\n\t\t\t\t\t}),\n\t\t\t\tonSuccess: (value: unknown) =>\n\t\t\t\t\tEffect.succeed({ ok: true as const, value: value as unknown }),\n\t\t\t}),\n\t\t);\n\t\t// PR#3: `start` has resolved — the contribution buffer is now FINAL and\n\t\t// is read exactly once below. Freeze it so any late async `ctx.*`\n\t\t// emission (a verb called from a fiber the plugin forked but did not\n\t\t// await) crashes the OFFENDING fiber with a typed defect instead of\n\t\t// being silently dropped.\n\t\tsealBuffer();\n\t\tif (result.ok) {\n\t\t\t// The ctx buffer (decls the 5 verbs pushed during `start`, in\n\t\t\t// emit order) is the SOLE source of post-start contributions.\n\t\t\t// The dispatch is a closed exhaustive switch on the decl\n\t\t\t// discriminant — its internal dual-catch keeps an\n\t\t\t// orchestrator-fault (a failing dispatch body) off the plugin's\n\t\t\t// `markFailed` path, so a surfaced failure here would be an\n\t\t\t// unexpected defect only.\n\t\t\tif (buffer.length > 0) {\n\t\t\t\tconst dispatchExit = yield* Effect.exit(\n\t\t\t\t\tdispatchBufferedContributions(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tbuffer,\n\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\tentry.scope,\n\t\t\t\t\t\tdispatcher,\n\t\t\t\t\t\tref,\n\t\t\t\t\t\thub,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (Exit.isFailure(dispatchExit)) {\n\t\t\t\t\tyield* bestEffort(registry.markFailed(key, dispatchExit.cause));\n\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\ttag: 'error.reported',\n\t\t\t\t\t\terror: prettyErrorStructured(dispatchExit.cause, {\n\t\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t\t\tseverity: 'error',\n\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\t\t\tlevel: 'error',\n\t\t\t\t\t\tmessage: 'plugin capability dispatch failed',\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst routablesPresent = buffer.some((decl) => decl.kind === 'routable');\n\t\t\tfor (const event of operationalEndpointEventsFromResolvedValue(\n\t\t\t\tkey,\n\t\t\t\tresult.value,\n\t\t\t\tDate.now(),\n\t\t\t\t{\n\t\t\t\t\troutablesPresent,\n\t\t\t\t},\n\t\t\t)) {\n\t\t\t\tyield* publish(ref, hub, event);\n\t\t\t}\n\t\t\tyield* publish(ref, hub, {\n\t\t\t\ttag: 'lifecycle.phaseSet',\n\t\t\t\tpluginKey: key,\n\t\t\t\tphase: null,\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t\tyield* bestEffort(registry.markReady(key, result.value));\n\t\t\tif (entry.node.member.role === 'task') {\n\t\t\t\tyield* bestEffort(registry.transition(key, 'done'));\n\t\t\t}\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: entry.node.member.role === 'task' ? 'plugin done' : 'plugin ready',\n\t\t\t\tfields: {\n\t\t\t\t\tcontributions: buffer.length,\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\tyield* logger.log(`supervisor/${key}`, key, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: 'plugin acquire failed',\n\t\t\t});\n\t\t}\n\t});\n\nclass PluginAcquireInterruptedBeforeReady extends Error {\n\treadonly _tag = 'PluginAcquireInterruptedBeforeReady' as const;\n\tconstructor(readonly pluginKey: PluginKey) {\n\t\tsuper(`plugin '${pluginKey}' acquire was interrupted before readiness`);\n\t\tthis.name = 'PluginAcquireInterruptedBeforeReady';\n\t}\n}\n\nconst failIfAcquireInterruptedBeforeReady = (\n\tregistry: PluginRegistry,\n\tkey: PluginKey,\n\tentry: PluginEntry,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tif (registry.entries.get(key) !== entry) return;\n\t\tconst status = yield* registry\n\t\t\t.getStatus(key)\n\t\t\t.pipe(Effect.catch(() => Effect.succeed<LifecycleStatus | null>(null)));\n\t\tif (registry.entries.get(key) !== entry) return;\n\t\tif (status !== 'pending' && status !== 'acquiring') return;\n\t\tyield* bestEffort(registry.markFailed(key, new PluginAcquireInterruptedBeforeReady(key)));\n\t});\n\n// -----------------------------------------------------------------------------\n// Acquire a key set in parallel. Each node waits on its own upstreams,\n// so downstream nodes begin as soon as their dependencies are ready\n// instead of waiting for unrelated nodes in the same topological level.\n// -----------------------------------------------------------------------------\n\nexport const acquireKeys = (\n\tregistry: PluginRegistry,\n\tkeys: ReadonlyArray<PluginKey>,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tdispatcher: ContributionDispatcher,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\tparentScope: Scope.Scope,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fibers = yield* Effect.all(\n\t\t\tkeys.map((key) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst entry = registry.entries.get(key);\n\t\t\t\t\tif (entry === undefined) return yield* Effect.forkIn(Effect.void, parentScope);\n\t\t\t\t\tconst registeredGate = yield* Deferred.make<void, never>();\n\t\t\t\t\tconst readyToRegister = yield* Deferred.make<void, never>();\n\t\t\t\t\tconst guarded = Effect.gen(function* () {\n\t\t\t\t\t\tconst selfId = yield* Effect.fiberId;\n\t\t\t\t\t\tyield* Effect.gen(function* () {\n\t\t\t\t\t\t\tyield* Deferred.succeed(readyToRegister, void 0);\n\t\t\t\t\t\t\tyield* Deferred.await(registeredGate);\n\t\t\t\t\t\t\tyield* acquireNode(\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\thub,\n\t\t\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\t\t\tdispatcher,\n\t\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t\t\tidentity,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}).pipe(\n\t\t\t\t\t\t\tEffect.onInterrupt(() => failIfAcquireInterruptedBeforeReady(registry, key, entry)),\n\t\t\t\t\t\t\tEffect.ensuring(\n\t\t\t\t\t\t\t\tregistry\n\t\t\t\t\t\t\t\t\t.clearAcquireFiberIfEntry(key, entry, selfId)\n\t\t\t\t\t\t\t\t\t.pipe(Effect.catch(() => Effect.void)),\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\tconst fiber = yield* Effect.forkIn(Scope.provide(guarded, parentScope), parentScope);\n\t\t\t\t\tyield* Deferred.await(readyToRegister);\n\t\t\t\t\tconst registered = yield* registry\n\t\t\t\t\t\t.setAcquireFiberIfEntry(key, entry, fiber)\n\t\t\t\t\t\t.pipe(Effect.catch(() => Effect.succeed(false)));\n\t\t\t\t\tif (!registered) {\n\t\t\t\t\t\tyield* Fiber.interrupt(fiber).pipe(Effect.asVoid);\n\t\t\t\t\t\treturn fiber;\n\t\t\t\t\t}\n\t\t\t\t\tyield* Deferred.succeed(registeredGate, void 0);\n\t\t\t\t\treturn fiber;\n\t\t\t\t}),\n\t\t\t),\n\t\t\t{ concurrency: 'unbounded' },\n\t\t);\n\t\tyield* Effect.all(\n\t\t\tfibers.map((fiber) =>\n\t\t\t\tFiber.await(fiber).pipe(\n\t\t\t\t\tEffect.flatMap((exit) => {\n\t\t\t\t\t\tif (Exit.isSuccess(exit) || Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\t\t\t\treturn Effect.void;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Effect.failCause(exit.cause);\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t\t{ concurrency: 'unbounded', discard: true },\n\t\t);\n\t});\n\nexport const acquireFullGraph = (\n\tgraph: ResolvedGraph,\n\tregistry: PluginRegistry,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tpluginContext: Context.Context<never>,\n\tdispatcher: ContributionDispatcher,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\tparentScope: Scope.Scope,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* acquireKeys(\n\t\t\tregistry,\n\t\t\t[...graph.nodes.keys()],\n\t\t\tref,\n\t\t\thub,\n\t\t\tpluginContext,\n\t\t\tdispatcher,\n\t\t\tlogger,\n\t\t\tidentity,\n\t\t\tparentScope,\n\t\t);\n\t});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4EA,IAAa,gCAAb,cAAmD,MAAM;CACxD,OAAgB;CAChB,YAAY,WAA6B,MAAc;EACtD,MACC,SAAS,cAAc,OAAO,KAAK,KAAK,UAAU,GAAG,cAAc,KAAK,uLAIzE;EACA,KAAK,OAAO;CACb;AACD;AAMA,MAAM,yBAAyB,gBAAgB,uBAAuB;;;;;;;;;AAUtE,MAAM,iBACL,cAKI;CACJ,MAAM,SAAiC,CAAC;CAIxC,IAAI,SAAS;CACb,MAAM,eAAe,MAAc,SAAqC;EACvE,IAAI,QAAQ,MAAM,IAAI,8BAA8B,WAAW,IAAI;EACnE,OAAO,KAAK,IAAI;CACjB;CAkBA,OAAO;EACN,KAAA;GAjBA,UAA4B,SA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OAHqB,SACxB,uBAAuB,KAAK,OAAO,KAAK,CAAC,CACzC,KAAK,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,IAC/B;GAChB,OAAO,MAAM,UAAU,KAAK,CAAC,CAAC,KAAK,OAAO,MAAM;GAChD,OAAO;EACR;EACA,OAAO,SAAS,QAAQ,gBAAgB,KAAK,CAAC;EAC9C,OAAO;CACR,CAAC,CACF,GACA,EAAE,aAAa,YAAY,CAC5B;CACA,OAAO,OAAO,IACb,OAAO,KAAK,UACX,MAAM,MAAM,KAAK,CAAC,CAAC,KAClB,OAAO,SAAS,SAAS;EACxB,IAAI,KAAK,UAAU,IAAI,KAAK,MAAM,kBAAkB,KAAK,KAAK,GAC7D,OAAO,OAAO;EAEf,OAAO,OAAO,UAAU,KAAK,KAAK;CACnC,CAAC,CACF,CACD,GACA;EAAE,aAAa;EAAa,SAAS;CAAK,CAC3C;AACD,CAAC;AAEF,MAAa,oBACZ,OACA,UACA,KACA,KACA,eACA,YACA,QACA,UACA,gBAEA,OAAO,IAAI,aAAa;CACvB,OAAO,YACN,UACA,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC,GACtB,KACA,KACA,eACA,YACA,QACA,UACA,WACD;AACD,CAAC"}
@@ -3,26 +3,40 @@ import { prettyErrorStructured } from "../observability/pretty-error.mjs";
3
3
  import "../observability/index.mjs";
4
4
  import { bestEffort, publish } from "./wiring.mjs";
5
5
  import { PostAcquireTaskFailed } from "../post-acquire-tasks.mjs";
6
- import { Cause, Effect, Exit, Fiber, Ref } from "effect";
6
+ import { Cause, Effect, Exit, Fiber, Ref, Scope } from "effect";
7
7
  //#region src/substrate/runtime/supervisor/background-tasks.ts
8
8
  /** `snapshot.captureFailed` / `snapshot.captureSkipped` carry a REQUIRED
9
9
  * `snapshotId`. When the originating command carried an id, surfaces
10
10
  * correlate the outcome with it (the CLI's pending-capture map keys on
11
11
  * it). When the command omitted an id there is nothing to correlate
12
12
  * against — the CLI's bridge does NOT register a pending-capture entry
13
- * for an id-less capture (`cli/wirings/up.ts` falls through to a
14
- * legacy auto-ack and never keys this synthetic id) — so the minted
13
+ * for an id-less capture (`cli/wirings/up.ts` falls through to a plain
14
+ * auto-ack and never keys this synthetic id) — so the minted
15
15
  * `snap-<ts>` here only satisfies the event's required field. */
16
16
  const effectiveSnapshotId = (cmd) => cmd.snapshotId ?? `snap-${Date.now()}`;
17
- const runInjectedCommandHandler = (deps, cmd) => Effect.gen(function* () {
18
- if (deps.commandHandler === void 0) return;
17
+ /**
18
+ * Run the injected L3 command handler and report the typed outcome.
19
+ *
20
+ * On success the handler's events are published and `ok: true` is
21
+ * returned. On failure the failure is surfaced on the event stream
22
+ * (`snapshot.captureFailed` for a capture, plus `error.reported`) AND
23
+ * the cause is returned to the caller so a command that must NOT
24
+ * proceed on a half-applied handler (e.g. `snapshot.restore`, which
25
+ * otherwise drains + re-acquires every service off a half-restored
26
+ * tree) can short-circuit and propagate the failure to `submitCommand`.
27
+ *
28
+ * Interrupt-only causes return `ok: true` (the interrupting sibling
29
+ * owns the lifecycle decision) — same as the void runner below.
30
+ */
31
+ const runInjectedCommandHandlerExit = (deps, cmd) => Effect.gen(function* () {
32
+ if (deps.commandHandler === void 0) return { ok: true };
19
33
  const publishFromHandler = (event) => publish(deps.ref, deps.hub, event);
20
34
  const exit = yield* Effect.exit(deps.commandHandler(cmd, { publish: publishFromHandler }));
21
35
  if (Exit.isSuccess(exit)) {
22
36
  for (const event of exit.value) yield* publish(deps.ref, deps.hub, event);
23
- return;
37
+ return { ok: true };
24
38
  }
25
- if (Cause.hasInterruptsOnly(exit.cause)) return;
39
+ if (Cause.hasInterruptsOnly(exit.cause)) return { ok: true };
26
40
  if (cmd.tag === "snapshot.capture") yield* publish(deps.ref, deps.hub, {
27
41
  tag: "snapshot.captureFailed",
28
42
  snapshotId: effectiveSnapshotId(cmd),
@@ -42,65 +56,65 @@ const runInjectedCommandHandler = (deps, cmd) => Effect.gen(function* () {
42
56
  level: "error",
43
57
  message: `command handler failed for ${cmd.tag}`
44
58
  });
45
- }).pipe(Effect.withSpan("lifecycle.supervisor.injectedCommandHandler"));
46
- const startBackgroundSnapshotCapture = (deps, cmd) => Effect.gen(function* () {
47
- const token = yield* Ref.updateAndGet(deps.snapshotCaptureSeq, (n) => n + 1);
48
- if (!(yield* Ref.modify(deps.snapshotCaptureTask, (state) => state.tag === "idle" ? [true, {
49
- tag: "starting",
50
- token,
51
- snapshotId: cmd.snapshotId ?? null
52
- }] : [false, state]))) {
53
- yield* publish(deps.ref, deps.hub, {
54
- tag: "snapshot.captureSkipped",
55
- reason: "already-running",
56
- snapshotId: effectiveSnapshotId(cmd),
57
- ...cmd.name === void 0 ? {} : { name: cmd.name },
58
- at: Date.now()
59
- });
60
- return;
61
- }
62
- yield* publish(deps.ref, deps.hub, {
63
- tag: "snapshot.captureStarted",
64
- ...cmd.snapshotId === void 0 ? {} : { snapshotId: cmd.snapshotId },
65
- ...cmd.name === void 0 ? {} : { name: cmd.name },
66
- at: Date.now()
59
+ return {
60
+ ok: false,
61
+ cause: exit.cause
62
+ };
63
+ });
64
+ /**
65
+ * Fire-and-forget wrapper over {@link runInjectedCommandHandlerExit}:
66
+ * the handler's failure is already surfaced on the event stream, so the
67
+ * void channel suffices for capture / list / delete / wipe / prune,
68
+ * whose callers don't branch on the outcome.
69
+ */
70
+ const runInjectedCommandHandler = (deps, cmd) => Effect.asVoid(runInjectedCommandHandlerExit(deps, cmd));
71
+ /**
72
+ * Fork `body` into the supervisor-lifetime scope and claim a background
73
+ * task slot atomically.
74
+ *
75
+ * `Effect.forkIn(supervisorScope)` parents the fiber to the supervisor's
76
+ * lifetime NOT the command-loop fiber that triggered it — so a
77
+ * long-running capture/restart does not block the command loop and
78
+ * cannot wedge a subsequent `shutdown.requested` (Bug #13). The forked
79
+ * fiber is created suspended (`forkIn`'s default `startImmediately`), so
80
+ * the CAS below runs before it executes a single step.
81
+ *
82
+ * Skip-dedup: the slot is the running state. If it is already occupied
83
+ * the just-forked fiber is interrupted (it never ran) and the function
84
+ * returns `'skipped'` so the caller can publish/log the skip. Otherwise
85
+ * the fiber is installed, its `ensuring` clears the slot on completion,
86
+ * and the function returns `'started'`.
87
+ */
88
+ const forkIntoSlot = (supervisorScope, slot, body) => Effect.gen(function* () {
89
+ const guarded = Effect.gen(function* () {
90
+ const selfId = yield* Effect.fiberId;
91
+ yield* body.pipe(Effect.ensuring(Ref.update(slot, (current) => current !== null && current.id === selfId ? null : current)));
67
92
  });
68
- const fiber = yield* runInjectedCommandHandler(deps, cmd).pipe(Effect.ensuring(Ref.update(deps.snapshotCaptureTask, (state) => state.tag !== "idle" && state.token === token ? { tag: "idle" } : state)), Effect.forkScoped);
69
- yield* Ref.update(deps.snapshotCaptureTask, (state) => state.tag === "starting" && state.token === token ? {
70
- tag: "running",
71
- token,
72
- snapshotId: cmd.snapshotId ?? null,
73
- fiber
74
- } : state);
75
- }).pipe(Effect.withSpan("lifecycle.supervisor.backgroundSnapshotCapture"));
76
- const requestBackgroundSnapshotInterrupt = (deps) => Effect.gen(function* () {
77
- const fiber = yield* Ref.modify(deps.snapshotCaptureTask, (state) => state.tag === "running" ? [state.fiber, { tag: "idle" }] : [null, state]);
78
- if (fiber !== null) yield* Fiber.interrupt(fiber);
79
- }).pipe(Effect.withSpan("lifecycle.supervisor.interruptSnapshotCapture"));
80
- const startBackgroundStackRestart = (deps, handleCommand) => Effect.gen(function* () {
81
- const token = yield* Ref.updateAndGet(deps.stackRestartSeq, (n) => n + 1);
82
- if (!(yield* Ref.modify(deps.stackRestartTask, (state) => state.tag === "idle" ? [true, {
83
- tag: "starting",
84
- token
85
- }] : [false, state]))) {
86
- yield* deps.logger.log("supervisor", null, {
87
- level: "debug",
88
- message: "stack restart skipped because one is already running"
89
- });
90
- return;
93
+ const fiber = yield* Effect.forkIn(Scope.provide(guarded, supervisorScope), supervisorScope);
94
+ if (!(yield* Ref.modify(slot, (current) => current === null ? [true, fiber] : [false, current]))) {
95
+ yield* Fiber.interrupt(fiber);
96
+ return "skipped";
91
97
  }
92
- const fiber = yield* handleCommand(deps, { tag: "stack.restart" }).pipe(Effect.catch(() => Effect.void), Effect.ensuring(Ref.update(deps.stackRestartTask, (state) => state.tag !== "idle" && state.token === token ? { tag: "idle" } : state)), Effect.forkScoped);
93
- yield* Ref.update(deps.stackRestartTask, (state) => state.tag === "starting" && state.token === token ? {
94
- tag: "running",
95
- token,
96
- fiber
97
- } : state);
98
- }).pipe(Effect.withSpan("lifecycle.supervisor.backgroundStackRestart"));
99
- const requestBackgroundStackRestartInterrupt = (deps) => Effect.gen(function* () {
100
- const fiber = yield* Ref.modify(deps.stackRestartTask, (state) => state.tag === "running" ? [state.fiber, { tag: "idle" }] : [null, state]);
98
+ return "started";
99
+ });
100
+ /**
101
+ * Read-and-clear a background task slot, then await the fiber's
102
+ * interrupt. Awaiting matters: a follow-up snapshot capture must not
103
+ * begin while the previous fiber is still inside `pauseAndCommit` /
104
+ * `saveImages`, and shutdown must not race a half-torn-down restart.
105
+ */
106
+ const interruptSlot = (slot) => Effect.gen(function* () {
107
+ const fiber = yield* Ref.getAndSet(slot, null);
101
108
  if (fiber !== null) yield* Fiber.interrupt(fiber);
102
- }).pipe(Effect.withSpan("lifecycle.supervisor.interruptStackRestart"));
103
- const publishHookFailure = (deps, cause, message, pluginKey = null) => Effect.gen(function* () {
109
+ });
110
+ const startBackgroundStackRestart = (deps, handleCommand) => Effect.gen(function* () {
111
+ if ((yield* forkIntoSlot(deps.supervisorScope, deps.stackRestartTask, handleCommand(deps, { tag: "stack.restart" }).pipe(Effect.catch(() => Effect.void)))) === "skipped") yield* deps.logger.log("supervisor", null, {
112
+ level: "debug",
113
+ message: "stack restart skipped because one is already running"
114
+ });
115
+ });
116
+ const requestBackgroundStackRestartInterrupt = (deps) => interruptSlot(deps.stackRestartTask);
117
+ const publishHookFailure = (deps, cause, message, pluginKey) => Effect.gen(function* () {
104
118
  yield* publish(deps.ref, deps.hub, {
105
119
  tag: "error.reported",
106
120
  error: prettyErrorStructured(cause, {
@@ -137,8 +151,8 @@ const runPostAcquireHook = (deps) => Effect.gen(function* () {
137
151
  if (taskFailure !== null) yield* bestEffort(deps.registry.markFailed(taskFailure.pluginKey, taskFailure.cause));
138
152
  yield* publishHookFailure(deps, exit.cause, taskFailure === null ? "post-acquire hook failed" : `post-acquire task failed: ${taskFailure.label}`, taskFailure?.pluginKey ?? null);
139
153
  return yield* Effect.fail(new SupervisorPostAcquireFailed({ cause: exit.cause }));
140
- }).pipe(Effect.withSpan("lifecycle.supervisor.postAcquireHook"));
154
+ });
141
155
  //#endregion
142
- export { requestBackgroundSnapshotInterrupt, requestBackgroundStackRestartInterrupt, runInjectedCommandHandler, runPostAcquireHook, startBackgroundSnapshotCapture, startBackgroundStackRestart };
156
+ export { requestBackgroundStackRestartInterrupt, runInjectedCommandHandler, runInjectedCommandHandlerExit, runPostAcquireHook, startBackgroundStackRestart };
143
157
 
144
158
  //# sourceMappingURL=background-tasks.mjs.map