@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 +0,0 @@
1
- {"version":3,"file":"layer.mjs","names":[],"sources":["../../../../src/substrate/runtime/capability-sinks/layer.ts"],"sourcesContent":["// CapabilitySinks default layer.\n//\n// Composes the empty registry from `service.ts` with the substrate's\n// error-contribution sink and caller-supplied capability sinks. The\n// substrate does not name built-in capability contracts here; L3\n// orchestrator composition owns those registrations.\n\nimport { Context, Effect, Layer, Scope } from 'effect';\n\nimport type { PluginErrorContribution } from '../../plugin.ts';\nimport {\n\tFormatterRegistryService,\n\tlayerFormatterRegistry,\n} from '../observability/formatter-registry.ts';\nimport {\n\tCapabilitySinksService,\n\tlayerCapabilitySinks,\n\ttype CapabilitySink,\n\ttype ContributionKind,\n} from './service.ts';\n\n// -----------------------------------------------------------------------------\n// Orchestrator-supplied capability-decl registrations\n// -----------------------------------------------------------------------------\n\n/**\n * Orchestrator-side sink registrations. The supervisor accepts these\n * at boot and registers them by `kind`; the substrate does not expose\n * one callback slot per built-in capability contract.\n */\nexport type OrchestratorSinks = ReadonlyArray<CapabilitySink<ContributionKind, never>>;\n\n// -----------------------------------------------------------------------------\n// Built-in sink construction\n// -----------------------------------------------------------------------------\n\nconst errorContributionSink = (formatters: {\n\treadonly register: (c: PluginErrorContribution) => Effect.Effect<void, never, Scope.Scope>;\n}): CapabilitySink<'error-contribution', PluginErrorContribution> => ({\n\tkind: 'error-contribution',\n\taccept: (contribution, _ctx) => formatters.register(contribution),\n});\n\n// -----------------------------------------------------------------------------\n// Public layer factory\n// -----------------------------------------------------------------------------\n\n/**\n * Build the substrate's default CapabilitySinks layer. It supplies the\n * error-contribution sink and registers the caller's capability sinks\n * by kind. Unknown contribution kinds remain no-ops at the supervisor\n * call site unless a sink is registered.\n *\n * Plugin-author extension: provide an additional Layer that yields\n * `CapabilitySinksService` and calls `registerSink({ kind: 'my-kind', ... })`\n * before the supervisor starts harvesting. Last-write-wins on duplicate\n * kinds, with scope-bound restore — the built-in sink comes back when\n * the override's scope closes.\n */\nexport const layerCapabilitySinksDefault = (\n\torchestrator: OrchestratorSinks = [],\n): Layer.Layer<CapabilitySinksService | FormatterRegistryService, never, never> => {\n\tconst registerDefaults = Layer.effectDiscard(\n\t\tEffect.gen(function* () {\n\t\t\tconst sinks = yield* CapabilitySinksService;\n\t\t\tconst fmt = yield* FormatterRegistryService;\n\t\t\tconst defaults = [errorContributionSink(fmt), ...orchestrator];\n\t\t\tfor (const sink of defaults) {\n\t\t\t\tyield* sinks.registerSink(sink);\n\t\t\t}\n\t\t}),\n\t);\n\treturn registerDefaults.pipe(\n\t\tLayer.provideMerge(layerCapabilitySinks),\n\t\tLayer.provideMerge(layerFormatterRegistry),\n\t);\n};\n\n/** Re-exposed dependency: callers that want the formatter registry\n * available downstream (e.g. CLI / TUI / cascade-formatter consumers)\n * pull it from the default layer. */\nexport type CapabilitySinksRequirements = Context.Context<\n\tCapabilitySinksService | FormatterRegistryService\n>;\n"],"mappings":";;;;AAoCA,MAAM,yBAAyB,gBAEuC;CACrE,MAAM;CACN,SAAS,cAAc,SAAS,WAAW,SAAS,aAAa;CACjE;;;;;;;;;;;;;AAkBD,MAAa,+BACZ,eAAkC,EAAE,KAC8C;AAWlF,QAVyB,MAAM,cAC9B,OAAO,IAAI,aAAa;EACvB,MAAM,QAAQ,OAAO;EAErB,MAAM,WAAW,CAAC,sBAAsB,OADrB,yBACyB,EAAE,GAAG,aAAa;AAC9D,OAAK,MAAM,QAAQ,SAClB,QAAO,MAAM,aAAa,KAAK;GAE/B,CAEoB,CAAC,KACvB,MAAM,aAAa,qBAAqB,EACxC,MAAM,aAAa,uBAAuB,CAC1C"}
@@ -1,95 +0,0 @@
1
- import { PluginKey } from "../../brand.mjs";
2
- import { EngineEvent } from "../../events.mjs";
3
- import { StrategyContributorDecl } from "../../../contracts/strategy-contributor.mjs";
4
- import { CapabilityDecl } from "../../../contracts/capability-decl.mjs";
5
- import { Identity } from "../../identity.mjs";
6
- import { PluginErrorContribution } from "../../plugin.mjs";
7
- import { Context, Effect, Layer, Scope } from "effect";
8
- import * as _$effect_Cause0 from "effect/Cause";
9
- import * as _$effect_Types0 from "effect/Types";
10
-
11
- //#region src/substrate/runtime/capability-sinks/service.d.ts
12
- /** A single harvested item — either a capability decl OR an error
13
- * contribution. Discriminated by the literal `kind`. The supervisor
14
- * produces one of these for each item it pulls off a plugin during
15
- * the harvest loop. */
16
- type AnyContribution = {
17
- readonly source: 'capability';
18
- readonly decl: CapabilityDecl;
19
- } | {
20
- readonly source: 'error';
21
- readonly contribution: PluginErrorContribution;
22
- };
23
- /** The discriminator the sinks register against. Substrate-owned
24
- * literal vocabulary — plugins authoring a custom contract add a new
25
- * literal and a sink. */
26
- type ContributionKind = 'snapshotable' | 'routable' | 'codegenable' | 'projection' | 'strategy-contributor' | 'error-contribution' | (string & {
27
- readonly __extensionKind?: never;
28
- });
29
- /** Context the harvest loop supplies to each sink invocation. Carries
30
- * the plugin's key + identity so sinks can attribute their work
31
- * without naming the plugin. `publish` is the supervisor-owned event
32
- * path, so sink-emitted events keep the same ordering/projection
33
- * semantics as lifecycle/log/error events. The plugin scope is
34
- * exposed via `Scope.Scope` in the sink's R-channel — sinks
35
- * `addFinalizer` lands on the plugin's scope so registrations reap
36
- * on plugin teardown. */
37
- interface HarvestContext {
38
- readonly pluginKey: PluginKey;
39
- readonly identity: Identity;
40
- readonly publish: (event: EngineEvent) => Effect.Effect<void, never, never>;
41
- readonly registerStrategy: (decl: StrategyContributorDecl<string, unknown>) => Effect.Effect<void, never, Scope.Scope>;
42
- }
43
- /** A sink for a specific contribution kind. `accept` is the
44
- * registration body — runs on the plugin's scope so its finalizers
45
- * reap on plugin teardown. */
46
- interface CapabilitySink<K extends ContributionKind, TDecl> {
47
- readonly kind: K;
48
- readonly accept: (decl: TDecl, ctx: HarvestContext) => Effect.Effect<void, unknown, Scope.Scope>;
49
- }
50
- declare const UnknownContributionKind_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
51
- readonly _tag: "UnknownContributionKind";
52
- } & Readonly<A>;
53
- /** Surfaced when `dispatch` receives a kind no sink is registered for.
54
- * Substrate stays open by default — unknown kinds are no-ops at the
55
- * supervisor's call site (see `dispatchOrIgnore`); but tests + custom
56
- * callers can drive the strict surface via `dispatch`. */
57
- declare class UnknownContributionKind extends UnknownContributionKind_base<{
58
- readonly kind: string;
59
- readonly known: ReadonlyArray<string>;
60
- }> {}
61
- declare const ContributionSinkFailed_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
62
- readonly _tag: "ContributionSinkFailed";
63
- } & Readonly<A>;
64
- /** Surfaced when a registered sink rejects while handling a known
65
- * contribution kind. The original failure stays attached as `cause`
66
- * so the supervisor's structured error renderer shows the domain
67
- * error, such as `RouteCollision`, underneath the dispatch wrapper. */
68
- declare class ContributionSinkFailed extends ContributionSinkFailed_base<{
69
- readonly kind: string;
70
- readonly message: string;
71
- readonly cause: unknown;
72
- }> {}
73
- interface CapabilitySinksShape {
74
- /** Register a sink for a contribution kind. Last-write-wins on
75
- * duplicate kinds: a plugin-author overlay shadows the built-in
76
- * (the highest-seq surviving registration wins at `dispatch`).
77
- * Scope-bound: registering inside a `Layer` and providing the
78
- * layer to the supervisor's scope reaps the sink on shutdown.
79
- * Closing an overlay's scope un-shadows the built-in WITHOUT
80
- * clobbering any newer sibling registration for the same kind —
81
- * the scoped-multimap drops only this registration's own entry. */
82
- readonly registerSink: <K extends ContributionKind, TDecl>(sink: CapabilitySink<K, TDecl>) => Effect.Effect<void, never, Scope.Scope>;
83
- /** Dispatch a contribution to its registered sink. Errors with
84
- * `UnknownContributionKind` when no sink matches; the supervisor's
85
- * loop catches and downgrades to a no-op (per the
86
- * substrate-open-by-default rule). */
87
- readonly dispatch: (contribution: AnyContribution, ctx: HarvestContext) => Effect.Effect<void, UnknownContributionKind | ContributionSinkFailed, Scope.Scope>;
88
- /** Snapshot the kinds the registry currently knows. Diagnostic. */
89
- readonly knownKinds: Effect.Effect<ReadonlyArray<string>>;
90
- }
91
- declare const CapabilitySinksService_base: Context.ServiceClass<CapabilitySinksService, "@devstack/substrate/CapabilitySinks", CapabilitySinksShape>;
92
- declare class CapabilitySinksService extends CapabilitySinksService_base {}
93
- //#endregion
94
- export { AnyContribution, CapabilitySink, CapabilitySinksService, CapabilitySinksShape, ContributionKind, ContributionSinkFailed, HarvestContext, UnknownContributionKind };
95
- //# sourceMappingURL=service.d.mts.map
@@ -1,69 +0,0 @@
1
- import { SpanAttr } from "../observability/spans.mjs";
2
- import { makeScopedMultimap } from "../scoped-multimap/service.mjs";
3
- import "../scoped-multimap/index.mjs";
4
- import { Context, Data, Effect, Layer } from "effect";
5
- //#region src/substrate/runtime/capability-sinks/service.ts
6
- /** Surfaced when `dispatch` receives a kind no sink is registered for.
7
- * Substrate stays open by default — unknown kinds are no-ops at the
8
- * supervisor's call site (see `dispatchOrIgnore`); but tests + custom
9
- * callers can drive the strict surface via `dispatch`. */
10
- var UnknownContributionKind = class extends Data.TaggedError("UnknownContributionKind") {};
11
- /** Surfaced when a registered sink rejects while handling a known
12
- * contribution kind. The original failure stays attached as `cause`
13
- * so the supervisor's structured error renderer shows the domain
14
- * error, such as `RouteCollision`, underneath the dispatch wrapper. */
15
- var ContributionSinkFailed = class extends Data.TaggedError("ContributionSinkFailed") {};
16
- var CapabilitySinksService = class extends Context.Service()("@devstack/substrate/CapabilitySinks") {};
17
- /** Derive the discriminator literal from a harvested contribution.
18
- * Substrate name-blindness: this is the ONE place the substrate
19
- * reads a `kind` off a decl — every other site routes through the
20
- * registered sink, which interprets the payload. */
21
- const kindOf = (contribution) => {
22
- if (contribution.source === "error") return "error-contribution";
23
- return contribution.decl.kind;
24
- };
25
- /** Layer constructing an empty registry. Built-in sinks ship via the
26
- * composed `layerCapabilitySinksDefault` (see `layer.ts`); plugin-
27
- * authored sinks compose by providing a Layer that yields the
28
- * service and calls `registerSink`. */
29
- const layerCapabilitySinks = Layer.effect(CapabilitySinksService, Effect.gen(function* () {
30
- const store = yield* makeScopedMultimap();
31
- const registerSink = (sink) => Effect.gen(function* () {
32
- const accept = sink.accept;
33
- yield* store.register([{
34
- key: sink.kind,
35
- value: accept
36
- }]);
37
- yield* Effect.annotateCurrentSpan({ [SpanAttr.capabilitySinksKind]: sink.kind });
38
- }).pipe(Effect.withSpan("substrate.capabilitySinks.registerSink"));
39
- const dispatch = (contribution, ctx) => Effect.gen(function* () {
40
- const kind = kindOf(contribution);
41
- const entries = yield* store.entriesFor(kind);
42
- if (entries.length === 0) return yield* new UnknownContributionKind({
43
- kind,
44
- known: yield* store.keys
45
- });
46
- let chosen = entries[0];
47
- for (let i = 1; i < entries.length; i++) if (entries[i].seq > chosen.seq) chosen = entries[i];
48
- const accept = chosen.value;
49
- yield* accept(contribution.source === "error" ? contribution.contribution : contribution.decl, ctx).pipe(Effect.mapError((cause) => new ContributionSinkFailed({
50
- kind,
51
- message: `capability sink '${kind}' failed`,
52
- cause
53
- })));
54
- yield* Effect.annotateCurrentSpan({
55
- [SpanAttr.capabilitySinksKind]: kind,
56
- [SpanAttr.plugin]: ctx.pluginKey
57
- });
58
- }).pipe(Effect.withSpan("substrate.capabilitySinks.dispatch"));
59
- const knownKinds = store.keys;
60
- return CapabilitySinksService.of({
61
- registerSink,
62
- dispatch,
63
- knownKinds
64
- });
65
- }));
66
- //#endregion
67
- export { CapabilitySinksService, ContributionSinkFailed, UnknownContributionKind, kindOf, layerCapabilitySinks };
68
-
69
- //# sourceMappingURL=service.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.mjs","names":[],"sources":["../../../../src/substrate/runtime/capability-sinks/service.ts"],"sourcesContent":["// CapabilitySinks — kind→sink registry.\n//\n// Architecture § Substrate name-blindness (STYLE_GUIDE Open slot O6):\n// the supervisor used to import a hardcoded list of capability-decl\n// modules and dispatch by name on a switch. This module inverts that:\n// the substrate exposes an Effect.Service the supervisor consults\n// once per harvested contribution; plugin-authored kinds can be\n// registered via the same surface that ships the built-ins. Adding a\n// new capability contract is `registerSink({ kind, accept })` — no\n// supervisor edit required.\n//\n// The dispatch is structural on the `kind` literal of the contribution.\n// The substrate never inspects the contribution's payload; the sink's\n// `accept` body owns interpretation. The substrate never imports a\n// concrete plugin module.\n\nimport { Context, Data, Effect, Layer, Scope } from 'effect';\n\nimport type { CapabilityDecl } from '../../../contracts/capability-decl.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 { PluginErrorContribution } from '../../plugin.ts';\nimport { SpanAttr } from '../observability/spans.ts';\nimport { makeScopedMultimap } from '../scoped-multimap/index.ts';\n\n// -----------------------------------------------------------------------------\n// Contribution surface\n// -----------------------------------------------------------------------------\n\n/** A single harvested item — either a capability decl OR an error\n * contribution. Discriminated by the literal `kind`. The supervisor\n * produces one of these for each item it pulls off a plugin during\n * the harvest loop. */\nexport type AnyContribution =\n\t| { readonly source: 'capability'; readonly decl: CapabilityDecl }\n\t| { readonly source: 'error'; readonly contribution: PluginErrorContribution };\n\n/** The discriminator the sinks register against. Substrate-owned\n * literal vocabulary — plugins authoring a custom contract add a new\n * literal and a sink. */\nexport type ContributionKind =\n\t| 'snapshotable'\n\t| 'routable'\n\t| 'codegenable'\n\t| 'projection'\n\t| 'strategy-contributor'\n\t| 'error-contribution'\n\t| (string & { readonly __extensionKind?: never });\n\n// -----------------------------------------------------------------------------\n// Harvest context\n// -----------------------------------------------------------------------------\n\n/** Context the harvest loop supplies to each sink invocation. Carries\n * the plugin's key + identity so sinks can attribute their work\n * without naming the plugin. `publish` is the supervisor-owned event\n * path, so sink-emitted events keep the same ordering/projection\n * semantics as lifecycle/log/error events. The plugin scope is\n * exposed via `Scope.Scope` in the sink's R-channel — sinks\n * `addFinalizer` lands on the plugin's scope so registrations reap\n * on plugin teardown. */\nexport interface HarvestContext {\n\treadonly pluginKey: PluginKey;\n\treadonly identity: Identity;\n\treadonly publish: (event: EngineEvent) => Effect.Effect<void, never, never>;\n\treadonly registerStrategy: (\n\t\tdecl: StrategyContributorDecl<string, unknown>,\n\t) => Effect.Effect<void, never, Scope.Scope>;\n}\n\n// -----------------------------------------------------------------------------\n// Sink shape\n// -----------------------------------------------------------------------------\n\n/** A sink for a specific contribution kind. `accept` is the\n * registration body — runs on the plugin's scope so its finalizers\n * reap on plugin teardown. */\nexport interface CapabilitySink<K extends ContributionKind, TDecl> {\n\treadonly kind: K;\n\treadonly accept: (decl: TDecl, ctx: HarvestContext) => Effect.Effect<void, unknown, Scope.Scope>;\n}\n\n// -----------------------------------------------------------------------------\n// Dispatch errors\n// -----------------------------------------------------------------------------\n\n/** Surfaced when `dispatch` receives a kind no sink is registered for.\n * Substrate stays open by default — unknown kinds are no-ops at the\n * supervisor's call site (see `dispatchOrIgnore`); but tests + custom\n * callers can drive the strict surface via `dispatch`. */\nexport class UnknownContributionKind extends Data.TaggedError('UnknownContributionKind')<{\n\treadonly kind: string;\n\treadonly known: ReadonlyArray<string>;\n}> {}\n\n/** Surfaced when a registered sink rejects while handling a known\n * contribution kind. The original failure stays attached as `cause`\n * so the supervisor's structured error renderer shows the domain\n * error, such as `RouteCollision`, underneath the dispatch wrapper. */\nexport class ContributionSinkFailed extends Data.TaggedError('ContributionSinkFailed')<{\n\treadonly kind: string;\n\treadonly message: string;\n\treadonly cause: unknown;\n}> {}\n\n// -----------------------------------------------------------------------------\n// Public service shape\n// -----------------------------------------------------------------------------\n\nexport interface CapabilitySinksShape {\n\t/** Register a sink for a contribution kind. Last-write-wins on\n\t * duplicate kinds: a plugin-author overlay shadows the built-in\n\t * (the highest-seq surviving registration wins at `dispatch`).\n\t * Scope-bound: registering inside a `Layer` and providing the\n\t * layer to the supervisor's scope reaps the sink on shutdown.\n\t * Closing an overlay's scope un-shadows the built-in WITHOUT\n\t * clobbering any newer sibling registration for the same kind —\n\t * the scoped-multimap drops only this registration's own entry. */\n\treadonly registerSink: <K extends ContributionKind, TDecl>(\n\t\tsink: CapabilitySink<K, TDecl>,\n\t) => Effect.Effect<void, never, Scope.Scope>;\n\t/** Dispatch a contribution to its registered sink. Errors with\n\t * `UnknownContributionKind` when no sink matches; the supervisor's\n\t * loop catches and downgrades to a no-op (per the\n\t * substrate-open-by-default rule). */\n\treadonly dispatch: (\n\t\tcontribution: AnyContribution,\n\t\tctx: HarvestContext,\n\t) => Effect.Effect<void, UnknownContributionKind | ContributionSinkFailed, Scope.Scope>;\n\t/** Snapshot the kinds the registry currently knows. Diagnostic. */\n\treadonly knownKinds: Effect.Effect<ReadonlyArray<string>>;\n}\n\nexport class CapabilitySinksService extends Context.Service<\n\tCapabilitySinksService,\n\tCapabilitySinksShape\n>()('@devstack/substrate/CapabilitySinks') {}\n\n// -----------------------------------------------------------------------------\n// Implementation helper — kind extraction\n// -----------------------------------------------------------------------------\n\n/** Derive the discriminator literal from a harvested contribution.\n * Substrate name-blindness: this is the ONE place the substrate\n * reads a `kind` off a decl — every other site routes through the\n * registered sink, which interprets the payload. */\nexport const kindOf = (contribution: AnyContribution): ContributionKind => {\n\tif (contribution.source === 'error') return 'error-contribution';\n\t// `decl.kind` is a literal on every CapabilityDecl variant; we\n\t// trust the substrate-owned contract here.\n\treturn contribution.decl.kind;\n};\n\n// -----------------------------------------------------------------------------\n// Layer\n// -----------------------------------------------------------------------------\n\ntype SinkAccept = (decl: unknown, ctx: HarvestContext) => Effect.Effect<void, unknown, Scope.Scope>;\n\n/** Layer constructing an empty registry. Built-in sinks ship via the\n * composed `layerCapabilitySinksDefault` (see `layer.ts`); plugin-\n * authored sinks compose by providing a Layer that yields the\n * service and calls `registerSink`. */\nexport const layerCapabilitySinks: Layer.Layer<CapabilitySinksService> = Layer.effect(\n\tCapabilitySinksService,\n\tEffect.gen(function* () {\n\t\t// Seq-tagged multimap, NOT a single-value-per-kind map. The old\n\t\t// shape stored one accept per kind and restored a captured\n\t\t// `prior` on scope close — correct only under strict LIFO. With\n\t\t// sibling scopes (an overlay registered while another overlay for\n\t\t// the same kind is still live) the first to close would restore\n\t\t// ITS stale `prior` and clobber the live sibling. The multimap's\n\t\t// drop-by-seq finalizer removes only this registration's entry,\n\t\t// so the surviving highest-seq sink keeps winning regardless of\n\t\t// close order.\n\t\tconst store = yield* makeScopedMultimap<string, SinkAccept>();\n\n\t\tconst registerSink = <K extends ContributionKind, TDecl>(\n\t\t\tsink: CapabilitySink<K, TDecl>,\n\t\t): Effect.Effect<void, never, Scope.Scope> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst accept = sink.accept as SinkAccept;\n\t\t\t\t// The multimap's register is already uninterruptible and\n\t\t\t\t// wires the drop-by-seq finalizer atomically with the\n\t\t\t\t// append (mirrors `leaseBroker.tryAcquire`).\n\t\t\t\tyield* store.register([{ key: sink.kind, value: accept }]);\n\t\t\t\tyield* Effect.annotateCurrentSpan({\n\t\t\t\t\t[SpanAttr.capabilitySinksKind]: sink.kind,\n\t\t\t\t});\n\t\t\t}).pipe(Effect.withSpan('substrate.capabilitySinks.registerSink'));\n\n\t\tconst dispatch = (\n\t\t\tcontribution: AnyContribution,\n\t\t\tctx: HarvestContext,\n\t\t): Effect.Effect<void, UnknownContributionKind | ContributionSinkFailed, Scope.Scope> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst kind = kindOf(contribution);\n\t\t\t\tconst entries = yield* store.entriesFor(kind);\n\t\t\t\tif (entries.length === 0) {\n\t\t\t\t\tconst known = yield* store.keys;\n\t\t\t\t\treturn yield* new UnknownContributionKind({ kind, known });\n\t\t\t\t}\n\t\t\t\t// Last-write-wins: the highest-seq surviving registration\n\t\t\t\t// is the active sink for this kind.\n\t\t\t\tlet chosen = entries[0]!;\n\t\t\t\tfor (let i = 1; i < entries.length; i++) {\n\t\t\t\t\tif (entries[i]!.seq > chosen.seq) chosen = entries[i]!;\n\t\t\t\t}\n\t\t\t\tconst accept = chosen.value;\n\t\t\t\tconst payload: unknown =\n\t\t\t\t\tcontribution.source === 'error' ? contribution.contribution : contribution.decl;\n\t\t\t\tyield* accept(payload, ctx).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew ContributionSinkFailed({\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tmessage: `capability sink '${kind}' failed`,\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tyield* Effect.annotateCurrentSpan({\n\t\t\t\t\t[SpanAttr.capabilitySinksKind]: kind,\n\t\t\t\t\t[SpanAttr.plugin]: ctx.pluginKey,\n\t\t\t\t});\n\t\t\t}).pipe(Effect.withSpan('substrate.capabilitySinks.dispatch'));\n\n\t\tconst knownKinds: Effect.Effect<ReadonlyArray<string>> = store.keys;\n\n\t\treturn CapabilitySinksService.of({ registerSink, dispatch, knownKinds });\n\t}),\n);\n"],"mappings":";;;;;;;;;AA4FA,IAAa,0BAAb,cAA6C,KAAK,YAAY,0BAA0B,CAGrF;;;;;AAMH,IAAa,yBAAb,cAA4C,KAAK,YAAY,yBAAyB,CAInF;AA8BH,IAAa,yBAAb,cAA4C,QAAQ,SAGjD,CAAC,sCAAsC,CAAC;;;;;AAU3C,MAAa,UAAU,iBAAoD;AAC1E,KAAI,aAAa,WAAW,QAAS,QAAO;AAG5C,QAAO,aAAa,KAAK;;;;;;AAa1B,MAAa,uBAA4D,MAAM,OAC9E,wBACA,OAAO,IAAI,aAAa;CAUvB,MAAM,QAAQ,OAAO,oBAAwC;CAE7D,MAAM,gBACL,SAEA,OAAO,IAAI,aAAa;EACvB,MAAM,SAAS,KAAK;AAIpB,SAAO,MAAM,SAAS,CAAC;GAAE,KAAK,KAAK;GAAM,OAAO;GAAQ,CAAC,CAAC;AAC1D,SAAO,OAAO,oBAAoB,GAChC,SAAS,sBAAsB,KAAK,MACrC,CAAC;GACD,CAAC,KAAK,OAAO,SAAS,yCAAyC,CAAC;CAEnE,MAAM,YACL,cACA,QAEA,OAAO,IAAI,aAAa;EACvB,MAAM,OAAO,OAAO,aAAa;EACjC,MAAM,UAAU,OAAO,MAAM,WAAW,KAAK;AAC7C,MAAI,QAAQ,WAAW,EAEtB,QAAO,OAAO,IAAI,wBAAwB;GAAE;GAAM,OAAA,OAD7B,MAAM;GAC8B,CAAC;EAI3D,IAAI,SAAS,QAAQ;AACrB,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IACnC,KAAI,QAAQ,GAAI,MAAM,OAAO,IAAK,UAAS,QAAQ;EAEpD,MAAM,SAAS,OAAO;AAGtB,SAAO,OADN,aAAa,WAAW,UAAU,aAAa,eAAe,aAAa,MACrD,IAAI,CAAC,KAC3B,OAAO,UACL,UACA,IAAI,uBAAuB;GAC1B;GACA,SAAS,oBAAoB,KAAK;GAClC;GACA,CAAC,CACH,CACD;AACD,SAAO,OAAO,oBAAoB;IAChC,SAAS,sBAAsB;IAC/B,SAAS,SAAS,IAAI;GACvB,CAAC;GACD,CAAC,KAAK,OAAO,SAAS,qCAAqC,CAAC;CAE/D,MAAM,aAAmD,MAAM;AAE/D,QAAO,uBAAuB,GAAG;EAAE;EAAc;EAAU;EAAY,CAAC;EACvE,CACF"}
@@ -1 +0,0 @@
1
- import { Context, Effect, Layer } from "effect";
@@ -1,23 +0,0 @@
1
- import { StackPathsService } from "../paths.mjs";
2
- import { underLiveClock } from "./live-clock.mjs";
3
- import { acquireStackLock } from "./stack-lock.mjs";
4
- import { Context, Effect, Layer, Semaphore } from "effect";
5
- //#region src/substrate/runtime/cross-process/lock.ts
6
- var CrossProcessLock = class extends Context.Service()("@devstack/substrate/CrossProcessLock") {};
7
- Layer.effect(CrossProcessLock, Effect.gen(function* () {
8
- const paths = yield* StackPathsService;
9
- const semaphore = yield* Semaphore.make(1);
10
- const lockPath = paths.stackLockFile;
11
- return CrossProcessLock.of({ withLock: (effect) => semaphore.withPermits(1)(Effect.scoped(Effect.gen(function* () {
12
- yield* underLiveClock(acquireStackLock(lockPath));
13
- return yield* effect;
14
- }))) });
15
- }));
16
- Layer.effect(CrossProcessLock, Effect.gen(function* () {
17
- const semaphore = yield* Semaphore.make(1);
18
- return CrossProcessLock.of({ withLock: (effect) => semaphore.withPermits(1)(effect) });
19
- }));
20
- //#endregion
21
- export { CrossProcessLock };
22
-
23
- //# sourceMappingURL=lock.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lock.mjs","names":[],"sources":["../../../../src/substrate/runtime/cross-process/lock.ts"],"sourcesContent":["// Cross-process advisory lock — typed service + two Layers.\n//\n// Architecture § \"What's collapsed\" — three different locks in the\n// old codebase consolidate to ONE lock primitive. The on-disk\n// implementation (`stack.lock` via O_EXCL + PID/start-time liveness)\n// lives at `./stack-lock.ts` as a free function; THIS module wraps\n// it in a Layer satisfying the typed `CrossProcessLock` service so\n// consumers (state-store, cache, etc.) yield ONE name and let\n// wiring decide whether they get the OS-advisory implementation or\n// the in-process semaphore.\n//\n// The state-store uses this for read-modify-write critical sections\n// where two processes might race to mutate the JSON. The lock is\n// SHORT-CRITICAL-SECTION: hold across read+modify+atomic-write,\n// release immediately. Long lifetimes (whole-stack lifecycle) belong\n// to a separate lease, not this lock.\n\nimport { Context, Effect, Layer, Semaphore } from 'effect';\n\nimport { StackPathsService } from '../paths.ts';\nimport { underLiveClock } from './live-clock.ts';\nimport {\n\tacquireStackLock,\n\ttype StackLockIoError,\n\ttype StackLockTimeoutError,\n} from './stack-lock.ts';\n\n/**\n * Cross-process exclusive lock. `withLock(effect)` runs `effect`\n * with the lock held — semantically `Semaphore.withPermits(1)` plus\n * cross-process fanout via the OS.\n *\n * Acquisition is cancellable: an interrupt while waiting for the\n * lock unwinds without acquiring. Acquisition while another holder\n * dies (PID cleanup) is the lock primitive's job, not the\n * state-store's.\n *\n * Acquisition surfaces `StackLockTimeoutError` (peer contention\n * exceeded the acquire window) and `StackLockIoError` (disk failure\n * during acquire) in the `E` channel alongside the body's own errors.\n * Consumers MUST handle these typed failures — either degrade\n * gracefully via `Effect.catchTag` or widen their own `E` channel.\n * Surfacing them as defects (the prior `Effect.orDie` shape) was a\n * bug: a busy peer should not crash the supervisor's fiber. The\n * in-process Layer's typed `E` channel matches `never` for the\n * acquire surface so test wiring stays interchangeable with prod\n * (the union absorbs `never` cleanly).\n */\nexport interface CrossProcessLockShape {\n\treadonly withLock: <A, E, R>(\n\t\teffect: Effect.Effect<A, E, R>,\n\t) => Effect.Effect<A, E | StackLockTimeoutError | StackLockIoError, R>;\n}\n\nexport class CrossProcessLock extends Context.Service<CrossProcessLock, CrossProcessLockShape>()(\n\t'@devstack/substrate/CrossProcessLock',\n) {}\n\n/**\n * Production Layer — backed by `stack.lock` (O_EXCL + PID/start-time\n * liveness) per architecture § Cross-process safety protocol. Yields\n * `StackPathsService` to know which on-disk lock file represents\n * this stack; every `withLock` runs the body inside an\n * `Effect.scoped` that acquires + releases the OS-advisory lock.\n *\n * An in-process `Semaphore` sits in front of the disk acquire so\n * SAME-process concurrent yielders of `CrossProcessLock` serialize\n * before competing for the disk artifact. Without this, two fibers\n * in the same process race each other to `O_EXCL`-write the same\n * path; one wins, the other times out unnecessarily after backoff.\n *\n * Acquisition surfaces `StackLockTimeoutError` / `StackLockIoError`\n * in the `E` channel per `CrossProcessLockShape`; consumers catch\n * via `Effect.catchTag` or widen their own surface. The earlier\n * `Effect.orDie` here converted legitimate peer-contention timeouts\n * into supervisor defects — that was wrong; busy peers must be\n * recoverable through the typed channel.\n */\nexport const layerCrossProcessLockFlock: Layer.Layer<CrossProcessLock, never, StackPathsService> =\n\tLayer.effect(\n\t\tCrossProcessLock,\n\t\tEffect.gen(function* () {\n\t\t\tconst paths = yield* StackPathsService;\n\t\t\tconst semaphore = yield* Semaphore.make(1);\n\t\t\tconst lockPath = paths.stackLockFile;\n\t\t\treturn CrossProcessLock.of({\n\t\t\t\twithLock: <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n\t\t\t\t\t// Acquire/release infrastructure runs under live clock\n\t\t\t\t\t// (OS-advisory lock retry backoff needs wall time — see\n\t\t\t\t\t// LIVE_CLOCK). The user body inherits the caller's\n\t\t\t\t\t// clock so TestClock-driven tests can virtualize\n\t\t\t\t\t// `Effect.sleep` inside the critical section.\n\t\t\t\t\t//\n\t\t\t\t\t// `semaphore.withPermits(1)` keeps SAME-process fibers\n\t\t\t\t\t// serialized before they race for the on-disk artifact;\n\t\t\t\t\t// permit release fires on body completion, failure, AND\n\t\t\t\t\t// interrupt via the semaphore's own finalizer.\n\t\t\t\t\t// `Effect.scoped` owns the on-disk acquire so its\n\t\t\t\t\t// finalizer (registered by `acquireStackLock`) unlinks\n\t\t\t\t\t// `stack.lock` on the same lifecycle.\n\t\t\t\t\tsemaphore.withPermits(1)(\n\t\t\t\t\t\tEffect.scoped(\n\t\t\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t\t\tyield* underLiveClock(acquireStackLock(lockPath));\n\t\t\t\t\t\t\t\treturn yield* effect;\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});\n\t\t}),\n\t);\n\n/**\n * In-process-only fallback. Useful for tests and single-process dev\n * loops where no other OS process can interleave with this\n * supervisor. Production wiring uses `layerCrossProcessLockFlock`.\n *\n * Documented in the architecture as acceptable for \"no cross-process\n * safety needed\" use cases (one-shot CLI invocations, unit tests\n * with a tmpdir per-test, etc.). NOT safe under `pnpm dev` where\n * A dev server and devstack share a runtime root.\n */\nexport const layerCrossProcessLockInProcess: Layer.Layer<CrossProcessLock> = Layer.effect(\n\tCrossProcessLock,\n\tEffect.gen(function* () {\n\t\tconst semaphore = yield* Semaphore.make(1);\n\t\treturn CrossProcessLock.of({\n\t\t\t// No on-disk acquire here, so there's no wall-time backoff to\n\t\t\t// pin — `semaphore.withPermits(1)` parks on a queue without\n\t\t\t// `Effect.sleep`, so it tolerates TestClock natively. The\n\t\t\t// body inherits the caller's clock by construction; no\n\t\t\t// `underLiveClock` wrap.\n\t\t\twithLock: (effect) => semaphore.withPermits(1)(effect),\n\t\t});\n\t}),\n);\n"],"mappings":";;;;;AAsDA,IAAa,mBAAb,cAAsC,QAAQ,SAAkD,CAC/F,uCACA,CAAC;AAuBD,MAAM,OACL,kBACA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO;CACrB,MAAM,YAAY,OAAO,UAAU,KAAK,EAAE;CAC1C,MAAM,WAAW,MAAM;AACvB,QAAO,iBAAiB,GAAG,EAC1B,WAAoB,WAcnB,UAAU,YAAY,EAAE,CACvB,OAAO,OACN,OAAO,IAAI,aAAa;AACvB,SAAO,eAAe,iBAAiB,SAAS,CAAC;AACjD,SAAO,OAAO;GACb,CACF,CACD,EACF,CAAC;EACD,CACF;AAY2E,MAAM,OAClF,kBACA,OAAO,IAAI,aAAa;CACvB,MAAM,YAAY,OAAO,UAAU,KAAK,EAAE;AAC1C,QAAO,iBAAiB,GAAG,EAM1B,WAAW,WAAW,UAAU,YAAY,EAAE,CAAC,OAAO,EACtD,CAAC;EACD,CACF"}
@@ -1,113 +0,0 @@
1
- import { SpanAttr } from "../observability/spans.mjs";
2
- import { selfPid } from "./self-pid.mjs";
3
- import { SnapshotReservationSchema } from "../../cross-process.mjs";
4
- import { parseVersionedDocumentBodyOrNull } from "../../versioned-doc-sync.mjs";
5
- import { checkHolderLiveness } from "./liveness.mjs";
6
- import { reclaimUnparseableStaleFile } from "./reclaim-stale-file.mjs";
7
- import { Data, Effect } from "effect";
8
- import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
9
- import { hostname } from "node:os";
10
- //#region src/substrate/runtime/cross-process/snapshot-reservation.ts
11
- var SnapshotReservationHeldError = class extends Data.TaggedError("SnapshotReservationHeldError") {};
12
- var SnapshotReservationIoError = class extends Data.TaggedError("SnapshotReservationIoError") {};
13
- const parseReservation = (raw) => parseVersionedDocumentBodyOrNull(raw, SnapshotReservationSchema, "snapshot.reservation");
14
- const ownReservation = (startTime) => ({
15
- version: 1,
16
- creatorPid: selfPid(),
17
- creatorStartTime: startTime,
18
- createdAt: Date.now(),
19
- hostname: hostname()
20
- });
21
- /**
22
- * Sweep an orphaned reservation. If the file exists AND its creator is
23
- * dead, unlink it. Returns whether a sweep happened so callers can
24
- * observe / report.
25
- *
26
- * Architecture § Concurrent snapshot last paragraph:
27
- * "If the snapshotting process crashes mid-snapshot, the reservation
28
- * file persists. The next process's claim-protocol sweep detects an
29
- * orphan reservation (the holder whose pid matches the
30
- * reservation's creator entry is dead) and unlinks it."
31
- */
32
- const sweepOrphan = (path) => Effect.gen(function* () {
33
- yield* Effect.annotateCurrentSpan({ [SpanAttr.snapshotReservationPath]: path });
34
- if (!existsSync(path)) return { swept: false };
35
- const reservation = parseReservation(yield* Effect.try({
36
- try: () => readFileSync(path, "utf8"),
37
- catch: (cause) => new SnapshotReservationIoError({
38
- path,
39
- cause
40
- })
41
- }));
42
- if (reservation === null) return { swept: (yield* Effect.try({
43
- try: () => reclaimUnparseableStaleFile(path, parseReservation),
44
- catch: (cause) => new SnapshotReservationIoError({
45
- path,
46
- cause
47
- })
48
- })) === "reclaimed" };
49
- const ownHost = hostname();
50
- if (reservation.hostname !== ownHost) return { swept: false };
51
- if ((yield* checkHolderLiveness({
52
- pid: reservation.creatorPid,
53
- startTime: reservation.creatorStartTime,
54
- hostname: reservation.hostname,
55
- claimedAt: reservation.createdAt,
56
- heartbeatAt: reservation.createdAt,
57
- intent: "snapshot"
58
- }, ownHost).pipe(Effect.catch(() => Effect.succeed("alive")))) === "alive") return { swept: false };
59
- yield* Effect.try({
60
- try: () => unlinkSync(path),
61
- catch: (cause) => new SnapshotReservationIoError({
62
- path,
63
- cause
64
- })
65
- });
66
- return { swept: true };
67
- }).pipe(Effect.withSpan("cross-process.snapshot-reservation.sweepOrphan"));
68
- /**
69
- * Acquire the snapshot reservation as a scoped resource. The
70
- * reservation is unlinked when the surrounding Scope closes.
71
- *
72
- * Architecture § Concurrent snapshot step 1: O_EXCL create, no retry.
73
- * Callers that fail with `SnapshotReservationHeldError` propagate the
74
- * structured "snapshot in progress" error to the user — the typical
75
- * `Effect.catchTag` shape.
76
- *
77
- * `startTime` is the same value the roster carries for THIS process so
78
- * the orphan sweep's pid-startTime check resolves identically.
79
- */
80
- const acquireReservation = (path, startTime) => Effect.gen(function* () {
81
- yield* Effect.annotateCurrentSpan({ [SpanAttr.snapshotReservationPath]: path });
82
- yield* sweepOrphan(path);
83
- const body = ownReservation(startTime);
84
- yield* Effect.try({
85
- try: () => writeFileSync(path, JSON.stringify(body), { flag: "wx" }),
86
- catch: (cause) => {
87
- if (cause.code === "EEXIST") {
88
- let holder = null;
89
- try {
90
- holder = parseReservation(readFileSync(path, "utf8"));
91
- } catch {}
92
- return new SnapshotReservationHeldError({
93
- path,
94
- holder
95
- });
96
- }
97
- return new SnapshotReservationIoError({
98
- path,
99
- cause
100
- });
101
- }
102
- });
103
- yield* Effect.addFinalizer(() => Effect.sync(() => {
104
- try {
105
- unlinkSync(path);
106
- } catch {}
107
- }));
108
- return body;
109
- }).pipe(Effect.withSpan("cross-process.snapshot-reservation.acquire"));
110
- //#endregion
111
- export { SnapshotReservationHeldError, SnapshotReservationIoError, acquireReservation, sweepOrphan };
112
-
113
- //# sourceMappingURL=snapshot-reservation.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot-reservation.mjs","names":["nodeHostname"],"sources":["../../../../src/substrate/runtime/cross-process/snapshot-reservation.ts"],"sourcesContent":["// `snapshot.reservation` — presence-or-absence semaphore.\n//\n// Architecture § Cross-process safety protocol § Concurrent snapshot:\n// \"Snapshot requires exclusive control of the stack's container set\n// (pause-around-commit means peer processes' ready-probes would fail\n// if uncoordinated). The snapshotting process acquires\n// `snapshot.reservation` via O_EXCL create. If creation fails (peer\n// holds it), the snapshot refuses with a structured 'snapshot in\n// progress by peer pid X' error.\"\n//\n// Discipline:\n// - Acquire is atomic O_EXCL create with a JSON body carrying\n// `{ version: 1, creatorPid, creatorStartTime, createdAt, hostname }`.\n// - Release is `unlink`.\n// - Orphan sweep: on the next claim, the body's `hostname` is checked\n// first. Foreign-host reservations short-circuit as alive (NFS-safe\n// conservative default — `kill(pid, 0)` is meaningless on a remote\n// kernel). Same-host reservations fall through to the PID +\n// start-time check, which mirrors the roster's stale-PID reclaim.\n// - Acquire DOES NOT retry — snapshot is a one-shot intent; the\n// caller surfaces the structured error to the user immediately.\n\nimport { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { hostname as nodeHostname } from 'node:os';\n\nimport { Data, Effect, Scope } from 'effect';\n\nimport { type SnapshotReservation, SnapshotReservationSchema } from '../../cross-process.ts';\nimport { parseVersionedDocumentBodyOrNull } from '../../versioned-doc-sync.ts';\nimport { SpanAttr } from '../observability/spans.ts';\nimport { checkHolderLiveness } from './liveness.ts';\nimport { reclaimUnparseableStaleFile } from './reclaim-stale-file.ts';\nimport { selfPid } from './self-pid.ts';\n\n// -----------------------------------------------------------------------------\n// Errors\n// -----------------------------------------------------------------------------\n\nexport class SnapshotReservationHeldError extends Data.TaggedError('SnapshotReservationHeldError')<{\n\treadonly path: string;\n\treadonly holder: SnapshotReservation | null;\n}> {}\n\nexport class SnapshotReservationIoError extends Data.TaggedError('SnapshotReservationIoError')<{\n\treadonly path: string;\n\treadonly cause: unknown;\n}> {}\n\nexport type SnapshotReservationError = SnapshotReservationHeldError | SnapshotReservationIoError;\n\n// -----------------------------------------------------------------------------\n// Codec\n// -----------------------------------------------------------------------------\n\nconst parseReservation = (raw: string): SnapshotReservation | null =>\n\tparseVersionedDocumentBodyOrNull(raw, SnapshotReservationSchema, 'snapshot.reservation');\n\n// -----------------------------------------------------------------------------\n// Acquire / release\n// -----------------------------------------------------------------------------\n\nconst ownReservation = (startTime: number | null): SnapshotReservation => ({\n\tversion: 1,\n\tcreatorPid: selfPid(),\n\tcreatorStartTime: startTime,\n\tcreatedAt: Date.now(),\n\thostname: nodeHostname(),\n});\n\n/**\n * Sweep an orphaned reservation. If the file exists AND its creator is\n * dead, unlink it. Returns whether a sweep happened so callers can\n * observe / report.\n *\n * Architecture § Concurrent snapshot last paragraph:\n * \"If the snapshotting process crashes mid-snapshot, the reservation\n * file persists. The next process's claim-protocol sweep detects an\n * orphan reservation (the holder whose pid matches the\n * reservation's creator entry is dead) and unlinks it.\"\n */\nexport const sweepOrphan = (\n\tpath: string,\n): Effect.Effect<{ readonly swept: boolean }, SnapshotReservationError> =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.annotateCurrentSpan({ [SpanAttr.snapshotReservationPath]: path });\n\t\tif (!existsSync(path)) return { swept: false };\n\t\tconst raw = yield* Effect.try({\n\t\t\ttry: () => readFileSync(path, 'utf8'),\n\t\t\tcatch: (cause) => new SnapshotReservationIoError({ path, cause }),\n\t\t});\n\t\tconst reservation = parseReservation(raw);\n\t\tif (reservation === null) {\n\t\t\t// Malformed body — the creator may have written a half-written\n\t\t\t// file. Reclaim ONLY through the shared re-stat guard: gating a\n\t\t\t// bare mtime read + unlink races a competitor who legitimately\n\t\t\t// reclaims the garbage and writes a fresh valid O_EXCL body in\n\t\t\t// the window — the unlink would clobber that LIVE reservation.\n\t\t\t// `reclaimUnparseableStaleFile` honors the SAME mtime staleness\n\t\t\t// window stack-lock uses (a body younger than the window is\n\t\t\t// presumed mid-write and left alone) AND re-confirms the file\n\t\t\t// is still the same stale, unparseable inode immediately before\n\t\t\t// unlinking.\n\t\t\tconst outcome = yield* Effect.try({\n\t\t\t\ttry: () => reclaimUnparseableStaleFile(path, parseReservation),\n\t\t\t\tcatch: (cause) => new SnapshotReservationIoError({ path, cause }),\n\t\t\t});\n\t\t\treturn { swept: outcome === 'reclaimed' };\n\t\t}\n\t\t// Foreign-host reservation: NFS-safe — we cannot probe a remote\n\t\t// kernel for pid liveness, so treat the peer as alive (matches\n\t\t// the roster's `trustForeignHosts` policy). Before adding the\n\t\t// `hostname` field we synthesized a holder with hostname='' and\n\t\t// passed ownHost='', which bypassed the foreign-host fast-path\n\t\t// in `checkHolderLiveness` and probed PID/startTime locally — a\n\t\t// live remote process could be declared dead and its reservation\n\t\t// unlinked. The fix is to short-circuit here.\n\t\tconst ownHost = nodeHostname();\n\t\tif (reservation.hostname !== ownHost) return { swept: false };\n\t\t// PID-liveness check: synthesize a roster-shaped holder so the\n\t\t// shared liveness predicate applies.\n\t\tconst liveness = yield* checkHolderLiveness(\n\t\t\t{\n\t\t\t\tpid: reservation.creatorPid,\n\t\t\t\tstartTime: reservation.creatorStartTime,\n\t\t\t\thostname: reservation.hostname,\n\t\t\t\tclaimedAt: reservation.createdAt,\n\t\t\t\theartbeatAt: reservation.createdAt,\n\t\t\t\tintent: 'snapshot',\n\t\t\t},\n\t\t\townHost,\n\t\t).pipe(Effect.catch(() => Effect.succeed('alive' as const)));\n\t\tif (liveness === 'alive') return { swept: false };\n\t\tyield* Effect.try({\n\t\t\ttry: () => unlinkSync(path),\n\t\t\tcatch: (cause) => new SnapshotReservationIoError({ path, cause }),\n\t\t});\n\t\treturn { swept: true };\n\t}).pipe(Effect.withSpan('cross-process.snapshot-reservation.sweepOrphan'));\n\n/**\n * Acquire the snapshot reservation as a scoped resource. The\n * reservation is unlinked when the surrounding Scope closes.\n *\n * Architecture § Concurrent snapshot step 1: O_EXCL create, no retry.\n * Callers that fail with `SnapshotReservationHeldError` propagate the\n * structured \"snapshot in progress\" error to the user — the typical\n * `Effect.catchTag` shape.\n *\n * `startTime` is the same value the roster carries for THIS process so\n * the orphan sweep's pid-startTime check resolves identically.\n */\nexport const acquireReservation = (\n\tpath: string,\n\tstartTime: number | null,\n): Effect.Effect<SnapshotReservation, SnapshotReservationError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.annotateCurrentSpan({ [SpanAttr.snapshotReservationPath]: path });\n\t\t// One-shot orphan sweep before our O_EXCL attempt. The sweep is\n\t\t// idempotent: if a peer just wrote the reservation while we ran\n\t\t// the sweep, the O_EXCL create fails below and we surface the\n\t\t// structured \"held\" error.\n\t\tyield* sweepOrphan(path);\n\t\tconst body = ownReservation(startTime);\n\t\tyield* Effect.try({\n\t\t\ttry: () => writeFileSync(path, JSON.stringify(body), { flag: 'wx' }),\n\t\t\tcatch: (cause) => {\n\t\t\t\tconst code = (cause as NodeJS.ErrnoException).code;\n\t\t\t\tif (code === 'EEXIST') {\n\t\t\t\t\tlet holder: SnapshotReservation | null = null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tholder = parseReservation(readFileSync(path, 'utf8'));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Body unreadable; leave holder as null.\n\t\t\t\t\t}\n\t\t\t\t\treturn new SnapshotReservationHeldError({ path, holder });\n\t\t\t\t}\n\t\t\t\treturn new SnapshotReservationIoError({ path, cause });\n\t\t\t},\n\t\t});\n\t\t// Finalizer: best-effort unlink on scope close. Architecture §\n\t\t// Concurrent snapshot step 5: \"It unlinks `snapshot.reservation`.\"\n\t\tyield* Effect.addFinalizer(() =>\n\t\t\tEffect.sync(() => {\n\t\t\t\ttry {\n\t\t\t\t\tunlinkSync(path);\n\t\t\t\t} catch {\n\t\t\t\t\t// Already gone — ok. A peer's sweep may have unlinked our\n\t\t\t\t\t// stale reservation if we somehow lost the process between\n\t\t\t\t\t// acquire and the finalizer fire.\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\treturn body;\n\t}).pipe(Effect.withSpan('cross-process.snapshot-reservation.acquire'));\n\n/** Inspect (without acquiring) the current reservation. Returns the\n * parsed body or `null` if absent / malformed. Used by the supervisor\n * to decide whether to apply the \"snapshot-in-progress\" tolerance\n * window to ready probes. Architecture § Concurrent snapshot step 3. */\nexport const peekReservation = (\n\tpath: string,\n): Effect.Effect<SnapshotReservation | null, SnapshotReservationError> =>\n\tEffect.gen(function* () {\n\t\tif (!existsSync(path)) return null;\n\t\tconst raw = yield* Effect.try({\n\t\t\ttry: () => readFileSync(path, 'utf8'),\n\t\t\tcatch: (cause) => new SnapshotReservationIoError({ path, cause }),\n\t\t});\n\t\treturn parseReservation(raw);\n\t}).pipe(Effect.withSpan('cross-process.snapshot-reservation.peek'));\n"],"mappings":";;;;;;;;;;AAsCA,IAAa,+BAAb,cAAkD,KAAK,YAAY,+BAA+B,CAG/F;AAEH,IAAa,6BAAb,cAAgD,KAAK,YAAY,6BAA6B,CAG3F;AAQH,MAAM,oBAAoB,QACzB,iCAAiC,KAAK,2BAA2B,uBAAuB;AAMzF,MAAM,kBAAkB,eAAmD;CAC1E,SAAS;CACT,YAAY,SAAS;CACrB,kBAAkB;CAClB,WAAW,KAAK,KAAK;CACrB,UAAUA,UAAc;CACxB;;;;;;;;;;;;AAaD,MAAa,eACZ,SAEA,OAAO,IAAI,aAAa;AACvB,QAAO,OAAO,oBAAoB,GAAG,SAAS,0BAA0B,MAAM,CAAC;AAC/E,KAAI,CAAC,WAAW,KAAK,CAAE,QAAO,EAAE,OAAO,OAAO;CAK9C,MAAM,cAAc,iBAAiB,OAJlB,OAAO,IAAI;EAC7B,WAAW,aAAa,MAAM,OAAO;EACrC,QAAQ,UAAU,IAAI,2BAA2B;GAAE;GAAM;GAAO,CAAC;EACjE,CAAC,CACuC;AACzC,KAAI,gBAAgB,KAenB,QAAO,EAAE,QAAO,OAJO,OAAO,IAAI;EACjC,WAAW,4BAA4B,MAAM,iBAAiB;EAC9D,QAAQ,UAAU,IAAI,2BAA2B;GAAE;GAAM;GAAO,CAAC;EACjE,CAAC,MAC0B,aAAa;CAU1C,MAAM,UAAUA,UAAc;AAC9B,KAAI,YAAY,aAAa,QAAS,QAAO,EAAE,OAAO,OAAO;AAc7D,MAAI,OAXoB,oBACvB;EACC,KAAK,YAAY;EACjB,WAAW,YAAY;EACvB,UAAU,YAAY;EACtB,WAAW,YAAY;EACvB,aAAa,YAAY;EACzB,QAAQ;EACR,EACD,QACA,CAAC,KAAK,OAAO,YAAY,OAAO,QAAQ,QAAiB,CAAC,CAAC,MAC3C,QAAS,QAAO,EAAE,OAAO,OAAO;AACjD,QAAO,OAAO,IAAI;EACjB,WAAW,WAAW,KAAK;EAC3B,QAAQ,UAAU,IAAI,2BAA2B;GAAE;GAAM;GAAO,CAAC;EACjE,CAAC;AACF,QAAO,EAAE,OAAO,MAAM;EACrB,CAAC,KAAK,OAAO,SAAS,iDAAiD,CAAC;;;;;;;;;;;;;AAc3E,MAAa,sBACZ,MACA,cAEA,OAAO,IAAI,aAAa;AACvB,QAAO,OAAO,oBAAoB,GAAG,SAAS,0BAA0B,MAAM,CAAC;AAK/E,QAAO,YAAY,KAAK;CACxB,MAAM,OAAO,eAAe,UAAU;AACtC,QAAO,OAAO,IAAI;EACjB,WAAW,cAAc,MAAM,KAAK,UAAU,KAAK,EAAE,EAAE,MAAM,MAAM,CAAC;EACpE,QAAQ,UAAU;AAEjB,OADc,MAAgC,SACjC,UAAU;IACtB,IAAI,SAAqC;AACzC,QAAI;AACH,cAAS,iBAAiB,aAAa,MAAM,OAAO,CAAC;YAC9C;AAGR,WAAO,IAAI,6BAA6B;KAAE;KAAM;KAAQ,CAAC;;AAE1D,UAAO,IAAI,2BAA2B;IAAE;IAAM;IAAO,CAAC;;EAEvD,CAAC;AAGF,QAAO,OAAO,mBACb,OAAO,WAAW;AACjB,MAAI;AACH,cAAW,KAAK;UACT;GAKP,CACF;AACD,QAAO;EACN,CAAC,KAAK,OAAO,SAAS,6CAA6C,CAAC"}
@@ -1,31 +0,0 @@
1
- //#region src/substrate/runtime/lifecycle/lifecycle-fact.ts
2
- /** Project a lifecycle-shaped `EngineEvent` into a per-plugin delta.
3
- * Returns `null` for events that don't carry lifecycle information so
4
- * the reducer can short-circuit. The substrate stays event-name-blind
5
- * by routing through this single mapping table. */
6
- const factFromEvent = (event) => {
7
- switch (event.tag) {
8
- case "lifecycle.statusChanged": return {
9
- pluginKey: event.pluginKey,
10
- delta: { status: event.to }
11
- };
12
- case "lifecycle.phaseSet": return {
13
- pluginKey: event.pluginKey,
14
- delta: { phase: event.phase }
15
- };
16
- default: return null;
17
- }
18
- };
19
- /** Apply a fact delta to a row. Pure. Fields not in the delta are
20
- * preserved verbatim — the merge-not-replace shape `LifecycleFact`
21
- * promises. */
22
- const applyLifecycleFact = (row, delta) => ({
23
- ...row,
24
- ...delta.status !== void 0 ? { status: delta.status } : {},
25
- ...delta.phase !== void 0 ? { phase: delta.phase } : {},
26
- ...delta.selectiveRestartHighlight !== void 0 ? { selectiveRestartHighlight: delta.selectiveRestartHighlight } : {}
27
- });
28
- //#endregion
29
- export { applyLifecycleFact, factFromEvent };
30
-
31
- //# sourceMappingURL=lifecycle-fact.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lifecycle-fact.mjs","names":[],"sources":["../../../../src/substrate/runtime/lifecycle/lifecycle-fact.ts"],"sourcesContent":["// LifecycleFact bridge.\n//\n// `substrate/lifecycle.ts` declares `LifecycleFact` — the merge-not-\n// replace per-plugin lifecycle slice the projection consumes. Until\n// now the projection updater consumed raw `EngineEvent` cases directly\n// and the `LifecycleFact` type was orphan.\n//\n// This module is the typed bridge: it projects an `EngineEvent` into a\n// `LifecycleFact` delta (when the event represents a lifecycle change)\n// and exposes a single applier `applyLifecycleFact(row, fact)` the\n// projection updater calls instead of writing out each\n// status / phase / restart field independently. The reducer for non-\n// lifecycle events is unchanged.\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { Row } from '../../projection.ts';\nimport type { LifecycleFact, LifecycleStatus } from '../../lifecycle.ts';\nimport type { EngineEvent } from '../../events.ts';\n\n/** Per-plugin fact delta. Each field is optional — only the fields the\n * source event carries are populated. The projection's `applyLifecycleFact`\n * merges a delta into the existing `Row`. */\nexport interface LifecycleFactDelta {\n\treadonly status?: LifecycleStatus;\n\treadonly phase?: LifecycleFact['phase'];\n\treadonly selectiveRestartHighlight?: boolean;\n}\n\n/** Project a lifecycle-shaped `EngineEvent` into a per-plugin delta.\n * Returns `null` for events that don't carry lifecycle information so\n * the reducer can short-circuit. The substrate stays event-name-blind\n * by routing through this single mapping table. */\nexport const factFromEvent = (\n\tevent: EngineEvent,\n): { readonly pluginKey: PluginKey; readonly delta: LifecycleFactDelta } | null => {\n\tswitch (event.tag) {\n\t\tcase 'lifecycle.statusChanged':\n\t\t\treturn {\n\t\t\t\tpluginKey: event.pluginKey,\n\t\t\t\tdelta: { status: event.to },\n\t\t\t};\n\t\tcase 'lifecycle.phaseSet':\n\t\t\treturn {\n\t\t\t\tpluginKey: event.pluginKey,\n\t\t\t\tdelta: { phase: event.phase },\n\t\t\t};\n\t\tdefault:\n\t\t\t// `restart.requested` ALSO updates cycle.phase + clears\n\t\t\t// other rows' highlights — that's a multi-row reducer\n\t\t\t// concern the projection handles directly. We deliberately\n\t\t\t// keep the bridge scoped to the closed `LifecycleFact`\n\t\t\t// shape (status / phase / selectiveRestartHighlight) so\n\t\t\t// callers can derive per-plugin facts without rebuilding\n\t\t\t// the cycle phase too.\n\t\t\treturn null;\n\t}\n};\n\n/** Apply a fact delta to a row. Pure. Fields not in the delta are\n * preserved verbatim — the merge-not-replace shape `LifecycleFact`\n * promises. */\nexport const applyLifecycleFact = (row: Row, delta: LifecycleFactDelta): Row => ({\n\t...row,\n\t...(delta.status !== undefined ? { status: delta.status } : {}),\n\t...(delta.phase !== undefined ? { phase: delta.phase } : {}),\n\t...(delta.selectiveRestartHighlight !== undefined\n\t\t? { selectiveRestartHighlight: delta.selectiveRestartHighlight }\n\t\t: {}),\n});\n\n/** Reconstruct the closed `LifecycleFact` shape from a `Row`. Used by\n * diagnostic surfaces that want the typed fact instead of the wider\n * display Row. */\nexport const factFromRow = (row: Row): LifecycleFact => ({\n\tstatus: row.status,\n\tphase: row.phase,\n\tselectiveRestartHighlight: row.selectiveRestartHighlight,\n});\n"],"mappings":";;;;;AAgCA,MAAa,iBACZ,UACkF;AAClF,SAAQ,MAAM,KAAd;EACC,KAAK,0BACJ,QAAO;GACN,WAAW,MAAM;GACjB,OAAO,EAAE,QAAQ,MAAM,IAAI;GAC3B;EACF,KAAK,qBACJ,QAAO;GACN,WAAW,MAAM;GACjB,OAAO,EAAE,OAAO,MAAM,OAAO;GAC7B;EACF,QAQC,QAAO;;;;;;AAOV,MAAa,sBAAsB,KAAU,WAAoC;CAChF,GAAG;CACH,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,MAAM,QAAQ,GAAG,EAAE;CAC9D,GAAI,MAAM,UAAU,KAAA,IAAY,EAAE,OAAO,MAAM,OAAO,GAAG,EAAE;CAC3D,GAAI,MAAM,8BAA8B,KAAA,IACrC,EAAE,2BAA2B,MAAM,2BAA2B,GAC9D,EAAE;CACL"}
@@ -1 +0,0 @@
1
- import { Context, Effect, Layer, Scope } from "effect";
@@ -1,48 +0,0 @@
1
- import { makeScopedMultimap } from "../scoped-multimap/service.mjs";
2
- import "../scoped-multimap/index.mjs";
3
- import { emptyFormatterRegistry } from "./cascade-formatter.mjs";
4
- import { Context, Effect, Layer } from "effect";
5
- //#region src/substrate/runtime/observability/formatter-registry.ts
6
- var FormatterRegistryService = class extends Context.Service()("@devstack/substrate/FormatterRegistry") {};
7
- /** Layer constructing the per-stack formatter registry. Stateful;
8
- * the substrate provides one per supervisor scope.
9
- *
10
- * Storage is the shared scoped-multimap keyed by tag. The per-entry
11
- * value is the (optional) formatter — the registry may track a tag
12
- * with NO formatter (default rendering is enough), so `null` is a
13
- * legitimate value and the seq still tracks the registration. */
14
- const layerFormatterRegistry = Layer.effect(FormatterRegistryService, Effect.gen(function* () {
15
- const store = yield* makeScopedMultimap();
16
- const register = (contribution) => Effect.gen(function* () {
17
- const fmt = contribution.formatter !== void 0 ? (value, recurse) => contribution.formatter(value, recurse) : null;
18
- yield* store.register(contribution.errorTags.map((tag) => ({
19
- key: tag,
20
- value: fmt
21
- })));
22
- }).pipe(Effect.withSpan("substrate.formatterRegistry.register"));
23
- const snapshot = Effect.gen(function* () {
24
- const current = yield* store.snapshot;
25
- if (current.size === 0) return emptyFormatterRegistry;
26
- const out = /* @__PURE__ */ new Map();
27
- for (const [tag, entries] of current) {
28
- let chosen = null;
29
- let chosenSeq = -1;
30
- for (const e of entries) if (e.value !== null && e.seq > chosenSeq) {
31
- chosen = e.value;
32
- chosenSeq = e.seq;
33
- }
34
- if (chosen !== null) out.set(tag, chosen);
35
- }
36
- return out;
37
- });
38
- const tags = store.keys;
39
- return FormatterRegistryService.of({
40
- register,
41
- snapshot,
42
- tags
43
- });
44
- }));
45
- //#endregion
46
- export { FormatterRegistryService, layerFormatterRegistry };
47
-
48
- //# sourceMappingURL=formatter-registry.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatter-registry.mjs","names":[],"sources":["../../../../src/substrate/runtime/observability/formatter-registry.ts"],"sourcesContent":["// Formatter registry service.\n//\n// Architecture § L0 Observability: the cascade formatter consults a\n// per-tag `FormatterRegistry` for custom renderers. The registry is\n// substrate-owned and populated by the supervisor's harvest loop from\n// each acquired plugin's `errorContributions` field. The substrate\n// stays name-blind: it dispatches on `_tag` strings the plugins\n// declare, never on plugin identifiers.\n//\n// Two surfaces:\n// - `register(contribution)` — adds tags + optional formatter for a\n// single `PluginErrorContribution`. Idempotent on the tag set\n// when no formatter is provided; last-write-wins on the formatter\n// slot when one is.\n// - `snapshot()` — returns an immutable `FormatterRegistry` the\n// cascade formatter consumes.\n//\n// Scope-bound: callers `register` inside a plugin's scope so the\n// contribution dies with the plugin (selective restart, shutdown).\n// The supervisor uses `Effect.addFinalizer` at the dispatch site;\n// this service exposes the unregister side as a complement.\n\nimport { Context, Effect, Layer, Scope } from 'effect';\n\nimport type { PluginErrorContribution } from '../../plugin.ts';\nimport { makeScopedMultimap } from '../scoped-multimap/index.ts';\nimport {\n\temptyFormatterRegistry,\n\ttype FormatterRegistry,\n\ttype TagFormatter,\n} from './cascade-formatter.ts';\n\n/** Public shape of the formatter-registry service. */\nexport interface FormatterRegistryShape {\n\t/** Register a plugin's contribution. Scope-bound: the contribution\n\t * is reaped when the surrounding `Scope` closes. The supervisor\n\t * calls this inside each plugin's scope so selective-restart\n\t * cleans up the plugin's formatters automatically. */\n\treadonly register: (\n\t\tcontribution: PluginErrorContribution,\n\t) => Effect.Effect<void, never, Scope.Scope>;\n\t/** Snapshot the live registry as an immutable `FormatterRegistry`\n\t * the cascade formatter consumes. */\n\treadonly snapshot: Effect.Effect<FormatterRegistry>;\n\t/** Diagnostic: list every tag the registry currently tracks. */\n\treadonly tags: Effect.Effect<ReadonlyArray<string>>;\n}\n\nexport class FormatterRegistryService extends Context.Service<\n\tFormatterRegistryService,\n\tFormatterRegistryShape\n>()('@devstack/substrate/FormatterRegistry') {}\n\n/** Layer constructing the per-stack formatter registry. Stateful;\n * the substrate provides one per supervisor scope.\n *\n * Storage is the shared scoped-multimap keyed by tag. The per-entry\n * value is the (optional) formatter — the registry may track a tag\n * with NO formatter (default rendering is enough), so `null` is a\n * legitimate value and the seq still tracks the registration. */\nexport const layerFormatterRegistry: Layer.Layer<FormatterRegistryService> = Layer.effect(\n\tFormatterRegistryService,\n\tEffect.gen(function* () {\n\t\tconst store = yield* makeScopedMultimap<string, TagFormatter | null>();\n\n\t\tconst register = (\n\t\t\tcontribution: PluginErrorContribution,\n\t\t): Effect.Effect<void, never, Scope.Scope> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\t// Wrap the optional formatter so the cascade-formatter's\n\t\t\t\t// `TagFormatter` shape is consistent regardless of whether\n\t\t\t\t// the plugin provided one.\n\t\t\t\tconst fmt: TagFormatter | null =\n\t\t\t\t\tcontribution.formatter !== undefined\n\t\t\t\t\t\t? (value, recurse) => contribution.formatter!(value, recurse)\n\t\t\t\t\t\t: null;\n\t\t\t\t// One entry per declared tag, all sharing the multimap's\n\t\t\t\t// seq + finalizer — parallel plugin registrations stay\n\t\t\t\t// isolated and only drop what they added.\n\t\t\t\tyield* store.register(contribution.errorTags.map((tag) => ({ key: tag, value: fmt })));\n\t\t\t}).pipe(Effect.withSpan('substrate.formatterRegistry.register'));\n\n\t\tconst snapshot: Effect.Effect<FormatterRegistry> = Effect.gen(function* () {\n\t\t\tconst current = yield* store.snapshot;\n\t\t\tif (current.size === 0) return emptyFormatterRegistry;\n\t\t\tconst out = new Map<string, TagFormatter>();\n\t\t\tfor (const [tag, entries] of current) {\n\t\t\t\t// Last registration wins on the formatter slot — tags\n\t\t\t\t// without a custom formatter are still tracked so callers\n\t\t\t\t// can introspect via `tags()` even when no override is\n\t\t\t\t// registered.\n\t\t\t\tlet chosen: TagFormatter | null = null;\n\t\t\t\tlet chosenSeq = -1;\n\t\t\t\tfor (const e of entries) {\n\t\t\t\t\tif (e.value !== null && e.seq > chosenSeq) {\n\t\t\t\t\t\tchosen = e.value;\n\t\t\t\t\t\tchosenSeq = e.seq;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (chosen !== null) out.set(tag, chosen);\n\t\t\t}\n\t\t\treturn out as FormatterRegistry;\n\t\t});\n\n\t\tconst tags: Effect.Effect<ReadonlyArray<string>> = store.keys;\n\n\t\treturn FormatterRegistryService.of({ register, snapshot, tags });\n\t}),\n);\n"],"mappings":";;;;;AAgDA,IAAa,2BAAb,cAA8C,QAAQ,SAGnD,CAAC,wCAAwC,CAAC;;;;;;;;AAS7C,MAAa,yBAAgE,MAAM,OAClF,0BACA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,oBAAiD;CAEtE,MAAM,YACL,iBAEA,OAAO,IAAI,aAAa;EAIvB,MAAM,MACL,aAAa,cAAc,KAAA,KACvB,OAAO,YAAY,aAAa,UAAW,OAAO,QAAQ,GAC3D;AAIJ,SAAO,MAAM,SAAS,aAAa,UAAU,KAAK,SAAS;GAAE,KAAK;GAAK,OAAO;GAAK,EAAE,CAAC;GACrF,CAAC,KAAK,OAAO,SAAS,uCAAuC,CAAC;CAEjE,MAAM,WAA6C,OAAO,IAAI,aAAa;EAC1E,MAAM,UAAU,OAAO,MAAM;AAC7B,MAAI,QAAQ,SAAS,EAAG,QAAO;EAC/B,MAAM,sBAAM,IAAI,KAA2B;AAC3C,OAAK,MAAM,CAAC,KAAK,YAAY,SAAS;GAKrC,IAAI,SAA8B;GAClC,IAAI,YAAY;AAChB,QAAK,MAAM,KAAK,QACf,KAAI,EAAE,UAAU,QAAQ,EAAE,MAAM,WAAW;AAC1C,aAAS,EAAE;AACX,gBAAY,EAAE;;AAGhB,OAAI,WAAW,KAAM,KAAI,IAAI,KAAK,OAAO;;AAE1C,SAAO;GACN;CAEF,MAAM,OAA6C,MAAM;AAEzD,QAAO,yBAAyB,GAAG;EAAE;EAAU;EAAU;EAAM,CAAC;EAC/D,CACF"}
@@ -1 +0,0 @@
1
- import { Context, Effect, Layer, Tracer } from "effect";
@@ -1,110 +0,0 @@
1
- import { SpanAttr } from "./spans.mjs";
2
- import { Context, Effect, Exit, Layer, Option, Tracer } from "effect";
3
- //#region src/substrate/runtime/observability/span-store.ts
4
- /** Completed-span retention. Bounded so a long-lived stack stays flat. */
5
- const DEFAULT_SPAN_CAPACITY = 2e3;
6
- var SpanStore = class extends Context.Service()("@devstack/substrate/SpanStore") {};
7
- const pushRecord = (ring, record) => {
8
- ring.records.push(record);
9
- if (ring.records.length > ring.capacity) ring.records.shift();
10
- };
11
- const NANOS_PER_MILLI = 1000000n;
12
- const nanosToMillis = (n) => Number(n / NANOS_PER_MILLI);
13
- /** Derive the dashboard `service` for a span: prefer the canonical
14
- * `devstack.plugin` attribute, else fall back to the span name. Plugin
15
- * spans without the attribute use the dotted `devstack.plugin.<name>.…`
16
- * convention, so we special-case that prefix to recover `<name>` (e.g.
17
- * `devstack.plugin.postgres.acquire` → `postgres`) instead of bucketing
18
- * every plugin span under the shared `devstack` head. Other namespaced
19
- * spans fall back to the leading dotted/slashed segment
20
- * (`lifecycle.supervisor.runCommand` → `lifecycle`). `null` when neither
21
- * is informative. */
22
- const PLUGIN_SPAN_PREFIX = "devstack.plugin.";
23
- const deriveService = (name, attributes) => {
24
- const plugin = attributes.get(SpanAttr.plugin);
25
- if (typeof plugin === "string" && plugin.length > 0) return plugin;
26
- if (name.startsWith(PLUGIN_SPAN_PREFIX)) {
27
- const pluginName = name.slice(16).split(/[./]/, 1)[0];
28
- if (pluginName !== void 0 && pluginName.length > 0) return pluginName;
29
- }
30
- const head = name.split(/[./]/, 1)[0];
31
- return head !== void 0 && head.length > 0 && head !== name ? head : null;
32
- };
33
- const flattenAttributes = (attributes) => {
34
- const out = {};
35
- for (const [k, v] of attributes) out[k] = typeof v === "string" ? v : String(v);
36
- return out;
37
- };
38
- /** Build the recording span from the native span at end time. */
39
- const recordFrom = (span, endTime, exit) => {
40
- const parent = Option.getOrUndefined(span.parent);
41
- const startMillis = nanosToMillis(span.startTime);
42
- return {
43
- traceId: span.traceId,
44
- spanId: span.spanId,
45
- parentId: parent?.spanId ?? null,
46
- name: span.name,
47
- service: deriveService(span.name, span.attributes),
48
- startMillis,
49
- durationMillis: Math.max(0, nanosToMillis(endTime) - startMillis),
50
- status: Exit.isSuccess(exit) ? "ok" : "error",
51
- attributes: flattenAttributes(span.attributes)
52
- };
53
- };
54
- /** A `Tracer` that builds Effect's `NativeSpan` (so parent/trace propagation
55
- * and attribute capture behave exactly like the default) and records each
56
- * span into `ring` when it ends. */
57
- const recordingTracer = (ring) => Tracer.make({ span: (options) => {
58
- const span = new Tracer.NativeSpan(options);
59
- const originalEnd = span.end.bind(span);
60
- span.end = (endTime, exit) => {
61
- originalEnd(endTime, exit);
62
- try {
63
- pushRecord(ring, recordFrom(span, endTime, exit));
64
- } catch {}
65
- };
66
- return span;
67
- } });
68
- /** Build a `SpanStoreShape` over a fresh ring. The supervisor calls this so
69
- * the ring is process-scoped. `capacity` is injectable for tests. */
70
- const makeSpanStore = (capacity = DEFAULT_SPAN_CAPACITY) => Effect.sync(() => {
71
- const ring = {
72
- records: [],
73
- capacity
74
- };
75
- const query = (filter) => Effect.sync(() => applySpanFilter(ring.records, filter, capacity));
76
- const services = Effect.sync(() => {
77
- const seen = /* @__PURE__ */ new Set();
78
- for (const r of ring.records) if (r.service !== null) seen.add(r.service);
79
- return [...seen].sort();
80
- });
81
- return SpanStore.of({
82
- query,
83
- services,
84
- tracer: recordingTracer(ring)
85
- });
86
- });
87
- /** Pure filter application — exported for tests. Stored oldest-first; we
88
- * return newest-first and cap to `limit`. */
89
- const applySpanFilter = (records, filter, capacity) => {
90
- const serviceSet = filter?.services && filter.services.length > 0 ? new Set(filter.services) : null;
91
- const statusSet = filter?.statuses && filter.statuses.length > 0 ? new Set(filter.statuses) : null;
92
- const search = filter?.search?.trim().toLowerCase();
93
- const since = filter?.sinceMillis;
94
- const limit = filter?.limit ?? capacity;
95
- const out = [];
96
- for (let i = records.length - 1; i >= 0 && out.length < limit; i -= 1) {
97
- const r = records[i];
98
- if (serviceSet !== null && (r.service === null || !serviceSet.has(r.service))) continue;
99
- if (statusSet !== null && !statusSet.has(r.status)) continue;
100
- if (since !== void 0 && r.startMillis < since) continue;
101
- if (search !== void 0 && search.length > 0 && !r.name.toLowerCase().includes(search) && !(r.service ?? "").toLowerCase().includes(search)) continue;
102
- out.push(r);
103
- }
104
- return out;
105
- };
106
- Layer.effect(SpanStore, makeSpanStore());
107
- //#endregion
108
- export { DEFAULT_SPAN_CAPACITY, SpanStore, applySpanFilter, makeSpanStore };
109
-
110
- //# sourceMappingURL=span-store.mjs.map