@mysten-incubation/devstack 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (838) hide show
  1. package/README.md +8 -4
  2. package/dashboard-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  3. package/dashboard-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  4. package/dashboard-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  5. package/dashboard-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  6. package/dashboard-ui/assets/geist-mono-cyrillic-ext-wght-normal-I4S5GZfc.woff2 +0 -0
  7. package/dashboard-ui/assets/geist-mono-cyrillic-wght-normal-BmXc_FBt.woff2 +0 -0
  8. package/dashboard-ui/assets/geist-mono-latin-ext-wght-normal-DrnZ1wKl.woff2 +0 -0
  9. package/dashboard-ui/assets/geist-mono-latin-wght-normal-B_7UjwxQ.woff2 +0 -0
  10. package/dashboard-ui/assets/geist-mono-symbols2-wght-normal-GZpp1pK2.woff2 +0 -0
  11. package/dashboard-ui/assets/geist-mono-vietnamese-wght-normal-D8KDMBhC.woff2 +0 -0
  12. package/dashboard-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  13. package/dashboard-ui/assets/index-Bmi1UtAg.js +1356 -0
  14. package/dashboard-ui/assets/index-D5EShVt4.js +3 -0
  15. package/dashboard-ui/assets/index-Deml9drg.css +1 -0
  16. package/dashboard-ui/index.html +13 -0
  17. package/dist/api/define-capabilities.d.mts +14 -3
  18. package/dist/api/define-capabilities.mjs +18 -1
  19. package/dist/api/define-capabilities.mjs.map +1 -1
  20. package/dist/api/define-devstack.d.mts +1 -1
  21. package/dist/api/define-devstack.mjs +6 -26
  22. package/dist/api/define-devstack.mjs.map +1 -1
  23. package/dist/api/define-plugin.d.mts +1 -0
  24. package/dist/api/define-plugin.mjs +2 -0
  25. package/dist/api/inference-network.d.mts +132 -0
  26. package/dist/api/inference-network.mjs +105 -16
  27. package/dist/api/inference-network.mjs.map +1 -1
  28. package/dist/api/plugin-errors.d.mts +7 -0
  29. package/dist/api/run-stack.d.mts +20 -9
  30. package/dist/api/run-stack.mjs +56 -29
  31. package/dist/api/run-stack.mjs.map +1 -1
  32. package/dist/build-integrations/playwright/config.d.mts +6 -4
  33. package/dist/build-integrations/playwright/config.mjs +5 -3
  34. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  35. package/dist/build-integrations/playwright/errors.d.mts +1 -1
  36. package/dist/build-integrations/playwright/global-setup.d.mts +43 -17
  37. package/dist/build-integrations/playwright/global-setup.mjs +250 -13
  38. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  39. package/dist/build-integrations/playwright/index.d.mts +5 -3
  40. package/dist/build-integrations/playwright/index.mjs +4 -2
  41. package/dist/build-integrations/playwright/stack-context.d.mts +0 -1
  42. package/dist/build-integrations/playwright/stack-context.mjs +24 -63
  43. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  44. package/dist/build-integrations/playwright/wallet-context.d.mts +7 -10
  45. package/dist/build-integrations/playwright/wallet-context.mjs +8 -13
  46. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  47. package/dist/build-integrations/runtime/cold-start-url.d.mts +5 -0
  48. package/dist/build-integrations/runtime/cold-start-url.mjs +4 -3
  49. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/conventional-routes.d.mts +51 -0
  51. package/dist/build-integrations/runtime/conventional-routes.mjs +92 -0
  52. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -0
  53. package/dist/build-integrations/runtime/discover.d.mts +38 -30
  54. package/dist/build-integrations/runtime/discover.mjs +73 -70
  55. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/endpoint-registry.d.mts +3 -1
  57. package/dist/build-integrations/runtime/endpoint-registry.mjs +3 -1
  58. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  59. package/dist/build-integrations/runtime/index.d.mts +7 -2
  60. package/dist/build-integrations/runtime/index.mjs +9 -2
  61. package/dist/build-integrations/runtime/manifest-types.d.mts +2 -0
  62. package/dist/build-integrations/runtime/manifest-types.mjs +3 -0
  63. package/dist/build-integrations/runtime/playwright-stack-context-slot.d.mts +29 -0
  64. package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs +10 -0
  65. package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs.map +1 -0
  66. package/dist/build-integrations/runtime/read-stack-context.d.mts +1 -1
  67. package/dist/build-integrations/runtime/read-stack-context.mjs +10 -4
  68. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  69. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +48 -0
  70. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +42 -0
  71. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -0
  72. package/dist/build-integrations/runtime/stack-context.d.mts +1 -1
  73. package/dist/build-integrations/runtime/wallet-paths.mjs +2 -0
  74. package/dist/build-integrations/vite/index.d.mts +51 -0
  75. package/dist/build-integrations/vite/index.mjs +73 -0
  76. package/dist/build-integrations/vite/index.mjs.map +1 -0
  77. package/dist/build-integrations/vitest/env.d.mts +4 -3
  78. package/dist/build-integrations/vitest/env.mjs +6 -4
  79. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  80. package/dist/build-integrations/vitest/errors.d.mts +25 -4
  81. package/dist/build-integrations/vitest/errors.mjs +15 -2
  82. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  83. package/dist/build-integrations/vitest/index.d.mts +2 -2
  84. package/dist/build-integrations/vitest/index.mjs +3 -3
  85. package/dist/build-integrations/vitest/setup.d.mts +4 -2
  86. package/dist/build-integrations/vitest/setup.mjs +2 -2
  87. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  88. package/dist/build-integrations/vitest/stack-context.d.mts +0 -1
  89. package/dist/build-integrations/vitest/stack-context.mjs +33 -13
  90. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  91. package/dist/cli/bail.mjs +23 -0
  92. package/dist/cli/bail.mjs.map +1 -0
  93. package/dist/{surfaces/cli/commands → cli}/doctor-probes.mjs +26 -16
  94. package/dist/cli/doctor-probes.mjs.map +1 -0
  95. package/dist/cli/main.d.mts +15 -1
  96. package/dist/cli/main.mjs +166 -482
  97. package/dist/cli/main.mjs.map +1 -1
  98. package/dist/cli/prune-direct.mjs +31 -201
  99. package/dist/cli/prune-direct.mjs.map +1 -1
  100. package/dist/cli/snapshot-reader.mjs +14 -11
  101. package/dist/cli/snapshot-reader.mjs.map +1 -1
  102. package/dist/cli/up-lifecycle.mjs +4 -1
  103. package/dist/cli/up-lifecycle.mjs.map +1 -1
  104. package/dist/cli/wirings/apply.mjs +95 -0
  105. package/dist/cli/wirings/apply.mjs.map +1 -0
  106. package/dist/cli/wirings/build-verb-layers.mjs +42 -0
  107. package/dist/cli/wirings/build-verb-layers.mjs.map +1 -0
  108. package/dist/cli/wirings/config-loader.mjs +69 -0
  109. package/dist/cli/wirings/config-loader.mjs.map +1 -0
  110. package/dist/cli/wirings/engine-command.mjs +30 -0
  111. package/dist/cli/wirings/engine-command.mjs.map +1 -0
  112. package/dist/cli/wirings/identity.mjs +72 -0
  113. package/dist/cli/wirings/identity.mjs.map +1 -0
  114. package/dist/cli/wirings/provide-file-system.mjs +7 -0
  115. package/dist/cli/wirings/provide-file-system.mjs.map +1 -0
  116. package/dist/cli/wirings/snapshot.mjs +177 -0
  117. package/dist/cli/wirings/snapshot.mjs.map +1 -0
  118. package/dist/cli/wirings/up.mjs +287 -0
  119. package/dist/cli/wirings/up.mjs.map +1 -0
  120. package/dist/cli/wirings/wipe.mjs +40 -0
  121. package/dist/cli/wirings/wipe.mjs.map +1 -0
  122. package/dist/contracts/capability-decl.d.mts +0 -2
  123. package/dist/contracts/codegenable.d.mts +43 -0
  124. package/dist/contracts/container-runtime.d.mts +26 -1
  125. package/dist/contracts/faucet-strategy.d.mts +25 -0
  126. package/dist/contracts/funding-strategy.d.mts +42 -0
  127. package/dist/contracts/plugin-expander.mjs +60 -0
  128. package/dist/contracts/plugin-expander.mjs.map +1 -0
  129. package/dist/contracts/projection.d.mts +5 -3
  130. package/dist/contracts/renderer.d.mts +23 -0
  131. package/dist/contracts/routable.d.mts +14 -1
  132. package/dist/contracts/snapshotable.d.mts +25 -3
  133. package/dist/contracts/wallet-protocol.d.mts +52 -0
  134. package/dist/contracts/wallet-protocol.mjs +52 -0
  135. package/dist/contracts/wallet-protocol.mjs.map +1 -0
  136. package/dist/index.d.mts +26 -25
  137. package/dist/index.mjs +20 -13
  138. package/dist/{runtime → orchestrators}/built-in-plugin-layers.mjs +10 -5
  139. package/dist/orchestrators/built-in-plugin-layers.mjs.map +1 -0
  140. package/dist/orchestrators/codegen/bindings.d.mts +1 -2
  141. package/dist/orchestrators/codegen/bindings.mjs +52 -186
  142. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/emit.mjs +19 -1
  144. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  145. package/dist/orchestrators/codegen/errors.mjs +8 -3
  146. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/format.mjs +47 -39
  148. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/gitignore.mjs +3 -1
  150. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  151. package/dist/orchestrators/codegen/output-location.mjs +41 -0
  152. package/dist/orchestrators/codegen/output-location.mjs.map +1 -0
  153. package/dist/orchestrators/codegen/paths.d.mts +1 -1
  154. package/dist/orchestrators/codegen/paths.mjs +40 -14
  155. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  156. package/dist/orchestrators/codegen/permissions.mjs +3 -1
  157. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  158. package/dist/orchestrators/codegen/service.mjs +157 -105
  159. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  160. package/dist/orchestrators/lifecycle-prune/errors.mjs +31 -0
  161. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -0
  162. package/dist/orchestrators/lifecycle-prune/index.mjs +350 -0
  163. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -0
  164. package/dist/orchestrators/router/cleanup.mjs +26 -27
  165. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  166. package/dist/orchestrators/router/entrypoints.mjs +2 -2
  167. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  168. package/dist/orchestrators/router/file-provider.mjs +14 -5
  169. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  170. package/dist/orchestrators/router/hostname.mjs +19 -55
  171. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  172. package/dist/orchestrators/router/index.mjs +11 -0
  173. package/dist/orchestrators/router/profile.mjs +2 -2
  174. package/dist/orchestrators/router/sentinels.mjs +26 -0
  175. package/dist/orchestrators/router/sentinels.mjs.map +1 -0
  176. package/dist/orchestrators/router/service.mjs +40 -37
  177. package/dist/orchestrators/router/service.mjs.map +1 -1
  178. package/dist/orchestrators/router/traefik-container.mjs +27 -16
  179. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  180. package/dist/{substrate/runtime → orchestrators}/run.mjs +26 -21
  181. package/dist/orchestrators/run.mjs.map +1 -0
  182. package/dist/orchestrators/runtime-composition.d.mts +1 -1
  183. package/dist/orchestrators/runtime-composition.mjs +123 -39
  184. package/dist/orchestrators/runtime-composition.mjs.map +1 -1
  185. package/dist/orchestrators/snapshot/capture-command.d.mts +1 -0
  186. package/dist/orchestrators/snapshot/capture-command.mjs +25 -0
  187. package/dist/orchestrators/snapshot/capture-command.mjs.map +1 -0
  188. package/dist/orchestrators/snapshot/capture.mjs +42 -28
  189. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  190. package/dist/orchestrators/snapshot/descriptor.mjs +35 -10
  191. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  192. package/dist/orchestrators/snapshot/identity-guard.mjs +1 -1
  193. package/dist/orchestrators/snapshot/index.mjs +13 -0
  194. package/dist/orchestrators/snapshot/integrity.d.mts +1 -1
  195. package/dist/orchestrators/snapshot/integrity.mjs +73 -17
  196. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  197. package/dist/orchestrators/snapshot/pending-marker.d.mts +1 -0
  198. package/dist/orchestrators/snapshot/pending-marker.mjs +99 -0
  199. package/dist/orchestrators/snapshot/pending-marker.mjs.map +1 -0
  200. package/dist/orchestrators/snapshot/phase-error.mjs +23 -0
  201. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -0
  202. package/dist/orchestrators/snapshot/prune.mjs +20 -55
  203. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  204. package/dist/orchestrators/snapshot/recover-pending.d.mts +1 -0
  205. package/dist/orchestrators/snapshot/recover-pending.mjs +223 -0
  206. package/dist/orchestrators/snapshot/recover-pending.mjs.map +1 -0
  207. package/dist/orchestrators/snapshot/restore.mjs +118 -84
  208. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  209. package/dist/orchestrators/snapshot/service.mjs +53 -56
  210. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  211. package/dist/orchestrators/snapshot/state-document.d.mts +1 -0
  212. package/dist/orchestrators/snapshot/state-document.mjs +47 -7
  213. package/dist/orchestrators/snapshot/state-document.mjs.map +1 -1
  214. package/dist/orchestrators/snapshot/wipe.mjs +67 -10
  215. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  216. package/dist/plugins/account/codegen.mjs +9 -8
  217. package/dist/plugins/account/codegen.mjs.map +1 -1
  218. package/dist/plugins/account/errors.d.mts +33 -6
  219. package/dist/plugins/account/errors.mjs.map +1 -1
  220. package/dist/plugins/account/funding.d.mts +29 -19
  221. package/dist/plugins/account/funding.mjs +84 -66
  222. package/dist/plugins/account/funding.mjs.map +1 -1
  223. package/dist/plugins/account/index.d.mts +2 -4
  224. package/dist/plugins/account/index.mjs +64 -31
  225. package/dist/plugins/account/index.mjs.map +1 -1
  226. package/dist/plugins/account/keypair.mjs +6 -9
  227. package/dist/plugins/account/keypair.mjs.map +1 -1
  228. package/dist/plugins/account/lease.mjs +1 -0
  229. package/dist/plugins/account/lease.mjs.map +1 -1
  230. package/dist/plugins/account/registry.d.mts +14 -1
  231. package/dist/plugins/account/registry.mjs +18 -18
  232. package/dist/plugins/account/registry.mjs.map +1 -1
  233. package/dist/plugins/account/service.d.mts +23 -4
  234. package/dist/plugins/account/service.mjs +83 -45
  235. package/dist/plugins/account/service.mjs.map +1 -1
  236. package/dist/plugins/account/snapshot.mjs +2 -5
  237. package/dist/plugins/account/snapshot.mjs.map +1 -1
  238. package/dist/plugins/account/spans.mjs +16 -0
  239. package/dist/plugins/account/spans.mjs.map +1 -0
  240. package/dist/plugins/account/variants/keystore.mjs +6 -8
  241. package/dist/plugins/account/variants/keystore.mjs.map +1 -1
  242. package/dist/plugins/action/build-context.d.mts +3 -2
  243. package/dist/plugins/action/errors.d.mts +16 -12
  244. package/dist/plugins/action/errors.mjs.map +1 -1
  245. package/dist/plugins/action/execute.mjs +65 -103
  246. package/dist/plugins/action/execute.mjs.map +1 -1
  247. package/dist/plugins/action/index.d.mts +0 -2
  248. package/dist/plugins/action/index.mjs +17 -13
  249. package/dist/plugins/action/index.mjs.map +1 -1
  250. package/dist/plugins/action/service.mjs +38 -35
  251. package/dist/plugins/action/service.mjs.map +1 -1
  252. package/dist/plugins/action/spans.mjs +11 -0
  253. package/dist/plugins/action/spans.mjs.map +1 -0
  254. package/dist/plugins/coin/codegen.mjs +9 -8
  255. package/dist/plugins/coin/codegen.mjs.map +1 -1
  256. package/dist/plugins/coin/discovery.mjs +8 -4
  257. package/dist/plugins/coin/discovery.mjs.map +1 -1
  258. package/dist/plugins/coin/index.d.mts +11 -29
  259. package/dist/plugins/coin/index.mjs +56 -27
  260. package/dist/plugins/coin/index.mjs.map +1 -1
  261. package/dist/plugins/coin/metadata.mjs +8 -15
  262. package/dist/plugins/coin/metadata.mjs.map +1 -1
  263. package/dist/plugins/coin/mint.d.mts +30 -11
  264. package/dist/plugins/coin/mint.mjs +78 -74
  265. package/dist/plugins/coin/mint.mjs.map +1 -1
  266. package/dist/plugins/coin/registry.mjs +4 -7
  267. package/dist/plugins/coin/registry.mjs.map +1 -1
  268. package/dist/plugins/coin/service.d.mts +39 -1
  269. package/dist/plugins/coin/service.mjs +11 -4
  270. package/dist/plugins/coin/service.mjs.map +1 -1
  271. package/dist/plugins/coin/spans.mjs +20 -0
  272. package/dist/plugins/coin/spans.mjs.map +1 -0
  273. package/dist/plugins/dashboard/domain.mjs +402 -0
  274. package/dist/plugins/dashboard/domain.mjs.map +1 -0
  275. package/dist/plugins/dashboard/index.d.mts +29 -0
  276. package/dist/plugins/dashboard/index.mjs +91 -0
  277. package/dist/plugins/dashboard/index.mjs.map +1 -0
  278. package/dist/plugins/dashboard/origin-policy.mjs +36 -0
  279. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -0
  280. package/dist/plugins/dashboard/routable.mjs +27 -0
  281. package/dist/plugins/dashboard/routable.mjs.map +1 -0
  282. package/dist/plugins/dashboard/schema/builder.mjs +21 -0
  283. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -0
  284. package/dist/plugins/dashboard/schema/enums.mjs +72 -0
  285. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -0
  286. package/dist/plugins/dashboard/schema/root.mjs +351 -0
  287. package/dist/plugins/dashboard/schema/root.mjs.map +1 -0
  288. package/dist/plugins/dashboard/schema/types.mjs +508 -0
  289. package/dist/plugins/dashboard/schema/types.mjs.map +1 -0
  290. package/dist/plugins/dashboard/schema.mjs +11 -0
  291. package/dist/plugins/dashboard/schema.mjs.map +1 -0
  292. package/dist/plugins/dashboard/server.mjs +166 -0
  293. package/dist/plugins/dashboard/server.mjs.map +1 -0
  294. package/dist/plugins/deepbook/deploy.mjs +53 -115
  295. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  296. package/dist/plugins/deepbook/errors.mjs +1 -0
  297. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  298. package/dist/plugins/deepbook/faucet-strategy.mjs +47 -34
  299. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  300. package/dist/plugins/deepbook/hash.mjs +9 -0
  301. package/dist/plugins/deepbook/hash.mjs.map +1 -0
  302. package/dist/plugins/deepbook/index.d.mts +1 -10
  303. package/dist/plugins/deepbook/index.mjs +25 -22
  304. package/dist/plugins/deepbook/index.mjs.map +1 -1
  305. package/dist/plugins/deepbook/pyth/index.mjs +26 -55
  306. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  307. package/dist/plugins/deepbook/snapshot.mjs +17 -29
  308. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  309. package/dist/plugins/deepbook/spans.mjs +18 -0
  310. package/dist/plugins/deepbook/spans.mjs.map +1 -0
  311. package/dist/plugins/deepbook/type-strings.mjs +65 -0
  312. package/dist/plugins/deepbook/type-strings.mjs.map +1 -0
  313. package/dist/plugins/deepbook/types.d.mts +2 -3
  314. package/dist/plugins/deepbook/types.mjs.map +1 -1
  315. package/dist/plugins/faucet/dispatcher.d.mts +21 -2
  316. package/dist/plugins/faucet/dispatcher.mjs +1 -2
  317. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  318. package/dist/plugins/faucet/errors.d.mts +11 -24
  319. package/dist/plugins/faucet/errors.mjs.map +1 -1
  320. package/dist/plugins/faucet/http.mjs +33 -14
  321. package/dist/plugins/faucet/http.mjs.map +1 -1
  322. package/dist/plugins/faucet/index.d.mts +15 -5
  323. package/dist/plugins/faucet/index.mjs +3 -0
  324. package/dist/plugins/faucet/index.mjs.map +1 -1
  325. package/dist/plugins/faucet/spans.mjs +12 -0
  326. package/dist/plugins/faucet/spans.mjs.map +1 -0
  327. package/dist/plugins/host-service/errors.d.mts +1 -1
  328. package/dist/plugins/host-service/index.mjs +34 -8
  329. package/dist/plugins/host-service/index.mjs.map +1 -1
  330. package/dist/plugins/host-service/routable.mjs +2 -1
  331. package/dist/plugins/host-service/routable.mjs.map +1 -1
  332. package/dist/plugins/host-service/service.d.mts +21 -0
  333. package/dist/plugins/host-service/service.mjs +136 -81
  334. package/dist/plugins/host-service/service.mjs.map +1 -1
  335. package/dist/plugins/internal/acquire-on-chain-artifact.mjs +23 -0
  336. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -0
  337. package/dist/plugins/internal/codegen-helpers.mjs +18 -0
  338. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -0
  339. package/dist/plugins/internal/funding-failure-error.mjs +32 -0
  340. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -0
  341. package/dist/plugins/package/build.mjs +1 -1
  342. package/dist/plugins/package/build.mjs.map +1 -1
  343. package/dist/plugins/package/codegen.mjs +26 -0
  344. package/dist/plugins/package/codegen.mjs.map +1 -1
  345. package/dist/plugins/package/errors.d.mts +16 -6
  346. package/dist/plugins/package/errors.mjs.map +1 -1
  347. package/dist/plugins/package/index.d.mts +0 -4
  348. package/dist/plugins/package/index.mjs +27 -21
  349. package/dist/plugins/package/index.mjs.map +1 -1
  350. package/dist/plugins/package/mode-known.mjs +26 -12
  351. package/dist/plugins/package/mode-known.mjs.map +1 -1
  352. package/dist/plugins/package/mode-local.mjs +47 -41
  353. package/dist/plugins/package/mode-local.mjs.map +1 -1
  354. package/dist/plugins/package/publish-executor.mjs +55 -114
  355. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  356. package/dist/plugins/package/registry.mjs +2 -1
  357. package/dist/plugins/package/registry.mjs.map +1 -1
  358. package/dist/plugins/package/service.mjs.map +1 -1
  359. package/dist/plugins/package/spans.mjs +14 -0
  360. package/dist/plugins/package/spans.mjs.map +1 -0
  361. package/dist/plugins/postgres/db-ensure.mjs +19 -12
  362. package/dist/plugins/postgres/db-ensure.mjs.map +1 -1
  363. package/dist/plugins/postgres/errors.d.mts +5 -0
  364. package/dist/plugins/postgres/errors.mjs.map +1 -1
  365. package/dist/plugins/postgres/index.mjs +10 -17
  366. package/dist/plugins/postgres/index.mjs.map +1 -1
  367. package/dist/plugins/postgres/service.mjs +58 -24
  368. package/dist/plugins/postgres/service.mjs.map +1 -1
  369. package/dist/plugins/postgres/snapshot.mjs.map +1 -1
  370. package/dist/plugins/postgres/spans.mjs +11 -0
  371. package/dist/plugins/postgres/spans.mjs.map +1 -0
  372. package/dist/plugins/router-entrypoints.mjs +4 -4
  373. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  374. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +15 -13
  375. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  376. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +15 -19
  377. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  378. package/dist/plugins/seal/codegen.d.mts +2 -3
  379. package/dist/plugins/seal/codegen.mjs.map +1 -1
  380. package/dist/plugins/seal/config-render.mjs +35 -8
  381. package/dist/plugins/seal/config-render.mjs.map +1 -1
  382. package/dist/plugins/seal/deploy.mjs +31 -39
  383. package/dist/plugins/seal/deploy.mjs.map +1 -1
  384. package/dist/plugins/seal/errors.d.mts +1 -3
  385. package/dist/plugins/seal/errors.mjs +7 -1
  386. package/dist/plugins/seal/errors.mjs.map +1 -1
  387. package/dist/plugins/seal/index.d.mts +1 -6
  388. package/dist/plugins/seal/index.mjs +40 -14
  389. package/dist/plugins/seal/index.mjs.map +1 -1
  390. package/dist/plugins/seal/key-manager.d.mts +1 -9
  391. package/dist/plugins/seal/key-manager.mjs +2 -18
  392. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  393. package/dist/plugins/seal/key-server.mjs +37 -36
  394. package/dist/plugins/seal/key-server.mjs.map +1 -1
  395. package/dist/plugins/seal/keygen.mjs +16 -17
  396. package/dist/plugins/seal/keygen.mjs.map +1 -1
  397. package/dist/plugins/seal/mode/fork-known.mjs +36 -14
  398. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  399. package/dist/plugins/seal/mode/live.d.mts +6 -4
  400. package/dist/plugins/seal/mode/live.mjs +14 -21
  401. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  402. package/dist/plugins/seal/mode/local-keygen.mjs +57 -21
  403. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  404. package/dist/plugins/seal/registry-publish.mjs +1 -0
  405. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  406. package/dist/plugins/seal/routable.mjs.map +1 -1
  407. package/dist/plugins/seal/service.mjs.map +1 -1
  408. package/dist/plugins/seal/spans.mjs +18 -0
  409. package/dist/plugins/seal/spans.mjs.map +1 -0
  410. package/dist/plugins/sui/auto-tick.mjs +17 -23
  411. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  412. package/dist/plugins/sui/chain-build-container.mjs +18 -0
  413. package/dist/plugins/sui/chain-build-container.mjs.map +1 -0
  414. package/dist/plugins/sui/chain-probe.d.mts +5 -5
  415. package/dist/plugins/sui/chain-probe.mjs +28 -58
  416. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  417. package/dist/plugins/sui/codegen.mjs +26 -0
  418. package/dist/plugins/sui/codegen.mjs.map +1 -1
  419. package/dist/plugins/sui/errors.d.mts +2 -29
  420. package/dist/plugins/sui/errors.mjs +1 -3
  421. package/dist/plugins/sui/errors.mjs.map +1 -1
  422. package/dist/plugins/sui/fork-faucet-strategy.d.mts +1 -0
  423. package/dist/plugins/sui/fork-faucet-strategy.mjs +55 -0
  424. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -0
  425. package/dist/plugins/sui/fork-orchestration.d.mts +1 -0
  426. package/dist/plugins/sui/fork-orchestration.mjs +170 -2
  427. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  428. package/dist/plugins/sui/fork-transaction.d.mts +2 -0
  429. package/dist/plugins/sui/fork-transaction.mjs +92 -28
  430. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  431. package/dist/plugins/sui/index.d.mts +33 -70
  432. package/dist/plugins/sui/index.mjs +58 -35
  433. package/dist/plugins/sui/index.mjs.map +1 -1
  434. package/dist/plugins/{faucet/strategies/sui-local.mjs → sui/local-faucet-strategy.mjs} +10 -7
  435. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -0
  436. package/dist/plugins/sui/mode/external.mjs +7 -13
  437. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  438. package/dist/plugins/sui/mode/fork.mjs +136 -59
  439. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  440. package/dist/plugins/sui/mode/live.mjs +10 -16
  441. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  442. package/dist/plugins/sui/mode/local.mjs +37 -36
  443. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  444. package/dist/plugins/sui/mode/shared-boot.mjs +38 -115
  445. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  446. package/dist/plugins/sui/mode/shared.d.mts +1 -5
  447. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  448. package/dist/plugins/sui/mode/spec.d.mts +18 -0
  449. package/dist/plugins/sui/move-summary-runner.mjs +207 -0
  450. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -0
  451. package/dist/plugins/sui/network-resolver.d.mts +4 -3
  452. package/dist/plugins/sui/service.mjs.map +1 -1
  453. package/dist/plugins/sui/snapshot.mjs +3 -0
  454. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  455. package/dist/plugins/sui/spans.mjs +17 -0
  456. package/dist/plugins/sui/spans.mjs.map +1 -0
  457. package/dist/plugins/wallet/codegen.d.mts +0 -1
  458. package/dist/plugins/wallet/codegen.mjs +8 -9
  459. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  460. package/dist/plugins/wallet/index.d.mts +6 -8
  461. package/dist/plugins/wallet/index.mjs +46 -35
  462. package/dist/plugins/wallet/index.mjs.map +1 -1
  463. package/dist/plugins/wallet/origin-policy.mjs +12 -28
  464. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  465. package/dist/plugins/wallet/pairing.mjs +6 -4
  466. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  467. package/dist/plugins/wallet/protocol.d.mts +1 -0
  468. package/dist/plugins/wallet/protocol.mjs +5 -44
  469. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  470. package/dist/plugins/wallet/routable.mjs +2 -8
  471. package/dist/plugins/wallet/routable.mjs.map +1 -1
  472. package/dist/plugins/wallet/server.mjs +36 -44
  473. package/dist/plugins/wallet/server.mjs.map +1 -1
  474. package/dist/plugins/wallet/service.d.mts +1 -5
  475. package/dist/plugins/wallet/service.mjs +22 -18
  476. package/dist/plugins/wallet/service.mjs.map +1 -1
  477. package/dist/plugins/wallet/spans.mjs +22 -0
  478. package/dist/plugins/wallet/spans.mjs.map +1 -0
  479. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +33 -8
  480. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  481. package/dist/plugins/walrus/codegen.d.mts +3 -3
  482. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  483. package/dist/plugins/walrus/deploy-paths.mjs +21 -5
  484. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  485. package/dist/plugins/walrus/deploy.mjs +67 -69
  486. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  487. package/dist/plugins/walrus/errors.mjs +1 -0
  488. package/dist/plugins/walrus/errors.mjs.map +1 -1
  489. package/dist/plugins/walrus/faucet-strategy.mjs +12 -7
  490. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  491. package/dist/plugins/walrus/index.d.mts +2 -13
  492. package/dist/plugins/walrus/index.mjs +18 -23
  493. package/dist/plugins/walrus/index.mjs.map +1 -1
  494. package/dist/plugins/walrus/mode/known-deploy.mjs +7 -5
  495. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  496. package/dist/plugins/walrus/mode/local-cluster.mjs +26 -7
  497. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  498. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  499. package/dist/plugins/walrus/routable.mjs +7 -23
  500. package/dist/plugins/walrus/routable.mjs.map +1 -1
  501. package/dist/plugins/walrus/service.mjs.map +1 -1
  502. package/dist/plugins/walrus/spans.mjs +18 -0
  503. package/dist/plugins/walrus/spans.mjs.map +1 -0
  504. package/dist/plugins/walrus/storage-nodes.d.mts +6 -2
  505. package/dist/plugins/walrus/storage-nodes.mjs +15 -8
  506. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  507. package/dist/plugins/walrus/wal-swap.mjs +58 -15
  508. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  509. package/dist/primitives/artifact-publisher.d.mts +1 -1
  510. package/dist/primitives/artifact-publisher.mjs +15 -0
  511. package/dist/primitives/artifact-publisher.mjs.map +1 -0
  512. package/dist/runtime/docker/client.mjs +17 -4
  513. package/dist/runtime/docker/client.mjs.map +1 -1
  514. package/dist/runtime/docker/container.mjs +219 -132
  515. package/dist/runtime/docker/container.mjs.map +1 -1
  516. package/dist/runtime/docker/errors.mjs +0 -6
  517. package/dist/runtime/docker/errors.mjs.map +1 -1
  518. package/dist/runtime/docker/exec.mjs +21 -18
  519. package/dist/runtime/docker/exec.mjs.map +1 -1
  520. package/dist/runtime/docker/image.mjs +36 -13
  521. package/dist/runtime/docker/image.mjs.map +1 -1
  522. package/dist/runtime/docker/index.mjs +14 -0
  523. package/dist/runtime/docker/inspect-and-decode.mjs +51 -0
  524. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -0
  525. package/dist/runtime/docker/inventory.mjs +14 -11
  526. package/dist/runtime/docker/inventory.mjs.map +1 -1
  527. package/dist/runtime/docker/labels.mjs +38 -5
  528. package/dist/runtime/docker/labels.mjs.map +1 -1
  529. package/dist/runtime/docker/logs.d.mts +1 -1
  530. package/dist/runtime/docker/logs.mjs.map +1 -1
  531. package/dist/runtime/docker/network.mjs +83 -47
  532. package/dist/runtime/docker/network.mjs.map +1 -1
  533. package/dist/runtime/docker/render-run-args.mjs +82 -0
  534. package/dist/runtime/docker/render-run-args.mjs.map +1 -0
  535. package/dist/runtime/docker/service.d.mts +1 -1
  536. package/dist/runtime/docker/service.mjs +12 -7
  537. package/dist/runtime/docker/service.mjs.map +1 -1
  538. package/dist/runtime/docker/sweep.mjs +118 -43
  539. package/dist/runtime/docker/sweep.mjs.map +1 -1
  540. package/dist/runtime/docker/volume.mjs +2 -0
  541. package/dist/runtime/docker/volume.mjs.map +1 -1
  542. package/dist/runtime/docker/wrap.mjs +30 -1
  543. package/dist/runtime/docker/wrap.mjs.map +1 -1
  544. package/dist/substrate/cross-process.mjs +14 -8
  545. package/dist/substrate/cross-process.mjs.map +1 -1
  546. package/dist/substrate/event-time.mjs +33 -0
  547. package/dist/substrate/event-time.mjs.map +1 -0
  548. package/dist/substrate/events.d.mts +28 -8
  549. package/dist/substrate/identity.d.mts +2 -1
  550. package/dist/substrate/manifest.d.mts +68 -5
  551. package/dist/substrate/manifest.mjs +34 -5
  552. package/dist/substrate/manifest.mjs.map +1 -1
  553. package/dist/substrate/network.d.mts +3 -5
  554. package/dist/substrate/options.d.mts +0 -2
  555. package/dist/substrate/plugin.d.mts +13 -0
  556. package/dist/substrate/plugin.mjs +4 -2
  557. package/dist/substrate/plugin.mjs.map +1 -1
  558. package/dist/substrate/projection.d.mts +35 -3
  559. package/dist/substrate/runtime/artifact-publisher/index.mjs +19 -9
  560. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +1 -1
  561. package/dist/substrate/runtime/atomic-write.mjs +97 -32
  562. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  563. package/dist/substrate/runtime/cache/index.mjs +3 -0
  564. package/dist/substrate/runtime/cache/schema.mjs +2 -2
  565. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  566. package/dist/substrate/runtime/cache/service.mjs +9 -7
  567. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  568. package/dist/substrate/runtime/capability-sinks/index.d.mts +1 -1
  569. package/dist/substrate/runtime/capability-sinks/index.mjs +3 -0
  570. package/dist/substrate/runtime/capability-sinks/layer.mjs +1 -1
  571. package/dist/substrate/runtime/capability-sinks/service.d.mts +61 -2
  572. package/dist/substrate/runtime/capability-sinks/service.mjs +21 -26
  573. package/dist/substrate/runtime/capability-sinks/service.mjs.map +1 -1
  574. package/dist/substrate/runtime/config-validation.d.mts +1 -13
  575. package/dist/substrate/runtime/config-validation.mjs +2 -91
  576. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  577. package/dist/substrate/runtime/container-runtime.d.mts +1 -0
  578. package/dist/substrate/runtime/container-runtime.mjs +2 -0
  579. package/dist/substrate/runtime/control-plane/domain.mjs +101 -0
  580. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -0
  581. package/dist/substrate/runtime/control-plane/service.mjs +7 -0
  582. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -0
  583. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +46 -19
  584. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  585. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs +30 -12
  586. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  587. package/dist/substrate/runtime/cross-process/command-channel/index.mjs +5 -0
  588. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs +11 -2
  589. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  590. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs +1 -1
  591. package/dist/substrate/runtime/cross-process/index.mjs +11 -0
  592. package/dist/substrate/runtime/cross-process/live-clock.mjs +34 -0
  593. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -0
  594. package/dist/substrate/runtime/cross-process/liveness.mjs +52 -10
  595. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  596. package/dist/substrate/runtime/cross-process/lock.d.mts +1 -0
  597. package/dist/substrate/runtime/cross-process/lock.mjs +23 -0
  598. package/dist/substrate/runtime/cross-process/lock.mjs.map +1 -0
  599. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +64 -0
  600. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -0
  601. package/dist/substrate/runtime/cross-process/roster.mjs +97 -83
  602. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  603. package/dist/substrate/runtime/cross-process/self-pid.mjs +8 -0
  604. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -0
  605. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +24 -28
  606. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +1 -1
  607. package/dist/substrate/runtime/cross-process/stack-lock.mjs +41 -20
  608. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  609. package/dist/substrate/runtime/current-plugin.mjs +2 -2
  610. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  611. package/dist/substrate/runtime/errors.mjs +12 -6
  612. package/dist/substrate/runtime/errors.mjs.map +1 -1
  613. package/dist/substrate/runtime/format-unknown-error.mjs +30 -0
  614. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -0
  615. package/dist/substrate/runtime/host-bind-mount-owner.mjs +10 -0
  616. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -0
  617. package/dist/substrate/runtime/host-gateway.mjs +20 -0
  618. package/dist/substrate/runtime/host-gateway.mjs.map +1 -0
  619. package/dist/substrate/runtime/host-tree-tar/index.mjs +61 -50
  620. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  621. package/dist/substrate/runtime/http-probe.d.mts +1 -1
  622. package/dist/substrate/runtime/index.mjs +14 -0
  623. package/dist/substrate/runtime/lease-broker/index.d.mts +1 -1
  624. package/dist/substrate/runtime/lease-broker/index.mjs +2 -0
  625. package/dist/substrate/runtime/lease-broker/service.d.mts +1 -64
  626. package/dist/substrate/runtime/lease-broker/service.mjs +1 -1
  627. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  628. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +22 -3
  629. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  630. package/dist/substrate/runtime/lifecycle/index.mjs +9 -0
  631. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +1 -1
  632. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +20 -3
  633. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  634. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +1 -1
  635. package/dist/substrate/runtime/lifecycle/signals.mjs +5 -5
  636. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  637. package/dist/substrate/runtime/lifecycle/state-machine.mjs +1 -1
  638. package/dist/substrate/runtime/managed-container.d.mts +19 -1
  639. package/dist/substrate/runtime/managed-container.mjs +20 -1
  640. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  641. package/dist/substrate/runtime/manifest/index.mjs +3 -0
  642. package/dist/substrate/runtime/manifest/manifest.mjs +15 -11
  643. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  644. package/dist/substrate/runtime/mode-errors.mjs +20 -0
  645. package/dist/substrate/runtime/mode-errors.mjs.map +1 -0
  646. package/dist/substrate/runtime/observability/cascade-formatter.mjs +9 -13
  647. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  648. package/dist/substrate/runtime/observability/formatter-registry.mjs +19 -36
  649. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +1 -1
  650. package/dist/substrate/runtime/observability/ignore-with-log.d.mts +1 -0
  651. package/dist/substrate/runtime/observability/ignore-with-log.mjs +17 -0
  652. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -0
  653. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  654. package/dist/substrate/runtime/observability/index.mjs +13 -0
  655. package/dist/substrate/runtime/observability/log-store.d.mts +1 -0
  656. package/dist/substrate/runtime/observability/log-store.mjs +175 -0
  657. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -0
  658. package/dist/substrate/runtime/observability/logger.d.mts +2 -1
  659. package/dist/substrate/runtime/observability/logger.mjs +5 -9
  660. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  661. package/dist/substrate/runtime/observability/output-truncate.mjs +35 -0
  662. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -0
  663. package/dist/substrate/runtime/observability/pretty-error.mjs +9 -12
  664. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  665. package/dist/substrate/runtime/observability/redaction.d.mts +2 -13
  666. package/dist/substrate/runtime/observability/redaction.mjs +8 -14
  667. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  668. package/dist/substrate/runtime/observability/span-store.d.mts +1 -0
  669. package/dist/substrate/runtime/observability/span-store.mjs +110 -0
  670. package/dist/substrate/runtime/observability/span-store.mjs.map +1 -0
  671. package/dist/substrate/runtime/observability/spans.mjs +14 -14
  672. package/dist/substrate/runtime/observability/spans.mjs.map +1 -1
  673. package/dist/substrate/runtime/observability/subprocess-capture.mjs +1 -1
  674. package/dist/substrate/runtime/passthrough-or-wrap.mjs +33 -0
  675. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -0
  676. package/dist/substrate/runtime/paths.d.mts +1 -1
  677. package/dist/substrate/runtime/paths.mjs +4 -3
  678. package/dist/substrate/runtime/paths.mjs.map +1 -1
  679. package/dist/substrate/runtime/phase-preserving-produce.mjs +40 -0
  680. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -0
  681. package/dist/substrate/runtime/port-broker/index.mjs +3 -0
  682. package/dist/substrate/runtime/port-broker/service.mjs +170 -126
  683. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  684. package/dist/substrate/runtime/post-acquire-tasks.mjs +1 -1
  685. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  686. package/dist/substrate/runtime/probes.d.mts +7 -5
  687. package/dist/substrate/runtime/probes.mjs +3 -1
  688. package/dist/substrate/runtime/probes.mjs.map +1 -1
  689. package/dist/substrate/runtime/projection/index.mjs +4 -0
  690. package/dist/substrate/runtime/projection/operational-endpoints.mjs +1 -2
  691. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  692. package/dist/substrate/runtime/projection/persisted.mjs +33 -15
  693. package/dist/substrate/runtime/projection/persisted.mjs.map +1 -1
  694. package/dist/substrate/runtime/projection/state-ref.mjs +26 -2
  695. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  696. package/dist/substrate/runtime/projection/update.mjs +88 -24
  697. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  698. package/dist/substrate/runtime/random-suffix.mjs +11 -0
  699. package/dist/substrate/runtime/random-suffix.mjs.map +1 -0
  700. package/dist/substrate/runtime/retry-policy.d.mts +59 -1
  701. package/dist/substrate/runtime/retry-policy.mjs +66 -1
  702. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  703. package/dist/substrate/runtime/routed-url.d.mts +1 -0
  704. package/dist/substrate/runtime/routed-url.mjs +79 -0
  705. package/dist/substrate/runtime/routed-url.mjs.map +1 -0
  706. package/dist/substrate/runtime/runtime-decode.d.mts +1 -1
  707. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  708. package/dist/substrate/runtime/scoped-http-server.mjs +2 -3
  709. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  710. package/dist/substrate/runtime/scoped-multimap/index.mjs +2 -0
  711. package/dist/substrate/runtime/scoped-multimap/service.mjs +52 -0
  712. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +1 -0
  713. package/dist/substrate/runtime/scoped-ref-map/index.mjs +2 -0
  714. package/dist/substrate/runtime/scoped-ref-map/service.mjs +2 -2
  715. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +1 -1
  716. package/dist/substrate/runtime/stage-and-swap/index.mjs +72 -4
  717. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  718. package/dist/substrate/runtime/state-store/index.d.mts +1 -0
  719. package/dist/substrate/runtime/state-store/index.mjs +3 -0
  720. package/dist/substrate/runtime/state-store/schema.d.mts +1 -0
  721. package/dist/substrate/runtime/state-store/schema.mjs +19 -14
  722. package/dist/substrate/runtime/state-store/schema.mjs.map +1 -1
  723. package/dist/substrate/runtime/state-store/service.d.mts +1 -0
  724. package/dist/substrate/runtime/state-store/service.mjs +145 -0
  725. package/dist/substrate/runtime/state-store/service.mjs.map +1 -0
  726. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.d.mts +1 -0
  727. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs +33 -0
  728. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -0
  729. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs +1 -1
  730. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  731. package/dist/substrate/runtime/strategy-registry/index.mjs +4 -0
  732. package/dist/substrate/runtime/strategy-registry/service.mjs +19 -33
  733. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  734. package/dist/substrate/runtime/subnet-broker.mjs +60 -0
  735. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -0
  736. package/dist/substrate/runtime/sui-execute/index.d.mts +21 -1
  737. package/dist/substrate/runtime/sui-execute/index.mjs +84 -20
  738. package/dist/substrate/runtime/sui-execute/index.mjs.map +1 -1
  739. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.d.mts +1 -0
  740. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs +32 -0
  741. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +1 -0
  742. package/dist/substrate/runtime/sui-ledger/object-ref.mjs +32 -0
  743. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +1 -0
  744. package/dist/substrate/runtime/sui-move-build/index.mjs +93 -19
  745. package/dist/substrate/runtime/sui-move-build/index.mjs.map +1 -1
  746. package/dist/substrate/runtime/supervisor/acquire-node.mjs +181 -0
  747. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -0
  748. package/dist/substrate/runtime/supervisor/background-tasks.mjs +144 -0
  749. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -0
  750. package/dist/substrate/runtime/supervisor/command-loop.mjs +68 -0
  751. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -0
  752. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +151 -0
  753. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +1 -0
  754. package/dist/substrate/runtime/supervisor/errors.d.mts +1 -0
  755. package/dist/substrate/runtime/supervisor/errors.mjs +9 -0
  756. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -0
  757. package/dist/substrate/runtime/supervisor/index.d.mts +1 -0
  758. package/dist/substrate/runtime/supervisor/index.mjs +3 -0
  759. package/dist/substrate/runtime/supervisor/shutdown.mjs +51 -0
  760. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -0
  761. package/dist/substrate/runtime/supervisor/start-supervisor.d.mts +1 -0
  762. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +250 -0
  763. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -0
  764. package/dist/substrate/runtime/supervisor/state.d.mts +1 -0
  765. package/dist/substrate/runtime/supervisor/state.mjs +22 -0
  766. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -0
  767. package/dist/substrate/runtime/supervisor/teardown.mjs +57 -0
  768. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -0
  769. package/dist/substrate/runtime/supervisor/types.d.mts +1 -0
  770. package/dist/substrate/runtime/supervisor/wiring.mjs +133 -0
  771. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -0
  772. package/dist/substrate/runtime/typed-env.mjs +8 -0
  773. package/dist/substrate/runtime/typed-env.mjs.map +1 -0
  774. package/dist/substrate/state-store.d.mts +1 -0
  775. package/dist/substrate/versioned-doc-schema.mjs +17 -0
  776. package/dist/substrate/versioned-doc-schema.mjs.map +1 -0
  777. package/dist/substrate/versioned-doc-sync.mjs +94 -0
  778. package/dist/substrate/versioned-doc-sync.mjs.map +1 -0
  779. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  780. package/dist/surfaces/cli/commands/index.mjs +9 -0
  781. package/dist/surfaces/cli/commands/prune-picker-entry.mjs +13 -0
  782. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -0
  783. package/dist/surfaces/cli/commands/prune-picker.mjs +3 -2
  784. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  785. package/dist/surfaces/cli/commands/prune.mjs +34 -17
  786. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  787. package/dist/surfaces/cli/commands/status.mjs +2 -2
  788. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  789. package/dist/surfaces/cli/commands/supervisor-presence.mjs +5 -3
  790. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  791. package/dist/surfaces/cli/commands/wipe.mjs +38 -4
  792. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  793. package/dist/surfaces/cli/errors.mjs +1 -1
  794. package/dist/surfaces/cli/errors.mjs.map +1 -1
  795. package/dist/surfaces/cli/flags.mjs +0 -1
  796. package/dist/surfaces/cli/flags.mjs.map +1 -1
  797. package/dist/surfaces/cli/index.mjs +98 -18
  798. package/dist/surfaces/cli/index.mjs.map +1 -1
  799. package/dist/surfaces/cli/output.mjs +1 -0
  800. package/dist/surfaces/cli/output.mjs.map +1 -1
  801. package/dist/surfaces/cli/sysexits.mjs +2 -1
  802. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  803. package/dist/surfaces/tui/app.mjs +25 -3
  804. package/dist/surfaces/tui/app.mjs.map +1 -1
  805. package/dist/surfaces/tui/display-derivation.mjs +23 -74
  806. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  807. package/dist/surfaces/tui/event-log.mjs +35 -23
  808. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  809. package/dist/surfaces/tui/input.mjs +5 -1
  810. package/dist/surfaces/tui/input.mjs.map +1 -1
  811. package/dist/surfaces/tui/plain-renderer.mjs +70 -34
  812. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  813. package/package.json +24 -4
  814. package/dist/contracts/liveness-classifier.d.mts +0 -19
  815. package/dist/contracts/network-resolver.d.mts +0 -15
  816. package/dist/contracts/network-resolver.mjs +0 -7
  817. package/dist/contracts/network-resolver.mjs.map +0 -1
  818. package/dist/orchestrators/codegen/extras.mjs +0 -16
  819. package/dist/orchestrators/codegen/extras.mjs.map +0 -1
  820. package/dist/plugins/deepbook/routable.mjs +0 -21
  821. package/dist/plugins/deepbook/routable.mjs.map +0 -1
  822. package/dist/plugins/faucet/service.d.mts +0 -20
  823. package/dist/plugins/faucet/strategies/sui-local.d.mts +0 -23
  824. package/dist/plugins/faucet/strategies/sui-local.mjs.map +0 -1
  825. package/dist/plugins/sui/seed-objects.d.mts +0 -18
  826. package/dist/plugins/sui/seed-objects.mjs +0 -25
  827. package/dist/plugins/sui/seed-objects.mjs.map +0 -1
  828. package/dist/runtime/built-in-plugin-layers.mjs.map +0 -1
  829. package/dist/substrate/runtime/context-helpers.mjs +0 -32
  830. package/dist/substrate/runtime/context-helpers.mjs.map +0 -1
  831. package/dist/substrate/runtime/run.mjs.map +0 -1
  832. package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs +0 -30
  833. package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs.map +0 -1
  834. package/dist/substrate/runtime/supervisor.d.mts +0 -1
  835. package/dist/substrate/runtime/supervisor.mjs +0 -831
  836. package/dist/substrate/runtime/supervisor.mjs.map +0 -1
  837. package/dist/surfaces/cli/commands/doctor-probes.mjs.map +0 -1
  838. /package/dist/{substrate/runtime/strategy-registry/faucet-capability-for.d.mts → plugins/faucet/http.d.mts} +0 -0
@@ -0,0 +1,11 @@
1
+ import { randomUUID } from "node:crypto";
2
+ //#region src/substrate/runtime/random-suffix.ts
3
+ /** Mint a random hex suffix of `length` chars. Uses
4
+ * `crypto.randomUUID()` so collisions are cryptographically
5
+ * negligible (STYLE_GUIDE §17). `length` is bounded by the UUID's
6
+ * 32 hex chars; callers MUST pass `1..=32`. */
7
+ const mintRandomSuffix = (length) => randomUUID().replace(/-/g, "").slice(0, length);
8
+ //#endregion
9
+ export { mintRandomSuffix };
10
+
11
+ //# sourceMappingURL=random-suffix.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-suffix.mjs","names":[],"sources":["../../../src/substrate/runtime/random-suffix.ts"],"sourcesContent":["// Random hex-suffix helper.\n//\n// Snapshot capture names, codegen cycle ids, and restore staging tags\n// all want the same shape: a random hex string of a chosen length,\n// derived from `crypto.randomUUID()` so collisions are\n// cryptographically negligible across same-process parallel callers\n// (the `Math.random()`-based predecessors flagged in STYLE_GUIDE §17\n// did NOT have that guarantee).\n//\n// The choice of length is intentionally a caller knob — different\n// surfaces have different staleness windows and collision tolerance:\n//\n// - 8 chars: operator-visible names (snapshot id, snap-* prefix).\n// Short enough to type/share.\n// - 12 chars: per-stack container-tag suffixes. Wide enough that\n// two concurrent restores under the same stack don't clash.\n// - 16 chars: codegen cycle ids — transient staging-directory names\n// (`.staging.<id>` / `.bak.<id>`) that the substrate rm's\n// after publish. Defense-in-depth for the race window\n// where two emit cycles under a custom-CLI caller could\n// mint overlapping staging dirs against the same shared\n// outputDir; a collision there would corrupt a half-built\n// tree, not just clash an operator-visible name.\n// - 24 chars: restore staging image tags. Image tags are global to\n// the docker daemon — two parallel restores across stacks\n// share the namespace, so the extra entropy keeps them\n// from clashing under heavy CI parallelism.\n\nimport { randomUUID } from 'node:crypto';\n\n/** Mint a random hex suffix of `length` chars. Uses\n * `crypto.randomUUID()` so collisions are cryptographically\n * negligible (STYLE_GUIDE §17). `length` is bounded by the UUID's\n * 32 hex chars; callers MUST pass `1..=32`. */\nexport const mintRandomSuffix = (length: number): string =>\n\trandomUUID().replace(/-/g, '').slice(0, length);\n"],"mappings":";;;;;;AAkCA,MAAa,oBAAoB,WAChC,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,MAAM,GAAG,OAAO"}
@@ -3,7 +3,7 @@ import * as _$effect_Duration0 from "effect/Duration";
3
3
 
4
4
  //#region src/substrate/runtime/retry-policy.d.ts
5
5
  declare namespace retry_policy_d_exports {
6
- export { ExponentialRetryOptions, makeExponentialRetrySchedule, makeSpacedRetrySchedule };
6
+ export { BALANCE_POLL_PROFILE, DEPLOY_BIND_SOURCE_RETRY_PROFILE, ExponentialRetryOptions, FAUCET_HTTP_RETRY_PROFILE, FUNDING_BALANCE_READ_TIMEOUT_MS, NETWORK_REMOVE_RETRY_PROFILE, STALE_OBJECT_VERSION_RETRY_PROFILE, makeBoundedSpacedSchedule, makeExponentialRetrySchedule, makeSpacedRetrySchedule };
7
7
  }
8
8
  interface ExponentialRetryOptions {
9
9
  readonly initialDelayMs: number;
@@ -13,6 +13,64 @@ interface ExponentialRetryOptions {
13
13
  }
14
14
  declare const makeExponentialRetrySchedule: (options: ExponentialRetryOptions) => Schedule.Schedule<[_$effect_Duration0.Duration, number], unknown, never, never>;
15
15
  declare const makeSpacedRetrySchedule: (delayMs: number, maxRetries: number) => Schedule.Schedule<[number, number], unknown, never, never>;
16
+ /** Wall-clock-bounded fixed-interval poll. Selects "poll every
17
+ * `intervalMs` until total elapsed ≥ `timeoutMs`". Returns a
18
+ * schedule that callers compose with `Effect.repeat` /
19
+ * `Effect.retry` for poll-until-ready loops where the exit
20
+ * condition is owned by the caller body.
21
+ *
22
+ * Use for balance polls, post-funding settlement waits, and any
23
+ * similar wall-clock-bounded reconciliation loops. */
24
+ declare const makeBoundedSpacedSchedule: (intervalMs: number, timeoutMs: number) => Schedule.Schedule<[number, _$effect_Duration0.Duration], unknown, never, never>;
25
+ /** Balance-poll profile shared by funding settlement waits. The
26
+ * interval is short enough to keep wall-clock overshoot small;
27
+ * the timeout is the canonical funding settlement budget. */
28
+ declare const BALANCE_POLL_PROFILE: {
29
+ readonly intervalMs: 250;
30
+ readonly timeoutMs: 30000;
31
+ };
32
+ /** Single-call deadline for the per-poll balance-reader. Faucet
33
+ * RPC calls occasionally hang; the deadline keeps a stalled
34
+ * read from starving the surrounding poll loop. */
35
+ declare const FUNDING_BALANCE_READ_TIMEOUT_MS = 5000;
36
+ /** Docker Desktop bind-mount visibility race. The host directory
37
+ * is just-created but the Docker VFS hasn't surfaced it yet;
38
+ * attempts cap at 5s total (10 × 500ms). */
39
+ declare const DEPLOY_BIND_SOURCE_RETRY_PROFILE: {
40
+ readonly attempts: 10;
41
+ readonly delayMs: 500;
42
+ };
43
+ /** HTTP faucet POST retry profile. The faucet's TCP socket binds
44
+ * before the validator can transfer coins (a 60s cold-warm
45
+ * window). `attempts × backoff` saturates well inside the
46
+ * surrounding wall-clock budget. */
47
+ declare const FAUCET_HTTP_RETRY_PROFILE: {
48
+ readonly maxAttempts: 15;
49
+ readonly initialDelayMs: 500;
50
+ readonly backoffFactor: 1.5;
51
+ readonly wallClockBudgetMs: 90000;
52
+ readonly perRequestDeadlineMs: 5000;
53
+ };
54
+ /** Sui "stale object version" retry profile — used when a Move call
55
+ * references an object that's been mutated by a concurrent transaction
56
+ * (deepbook pool seeding hits this when the registry / pool object is
57
+ * re-versioned mid-flight). The retry rebuilds the transaction with
58
+ * fresh refs each attempt; 20 × 500ms keeps the worst case under 10s. */
59
+ declare const STALE_OBJECT_VERSION_RETRY_PROFILE: {
60
+ readonly attempts: 20;
61
+ readonly delayMs: 500;
62
+ };
63
+ /** Docker `network rm` retry profile — used by best-effort network
64
+ * prune after our own endpoints are force-disconnected. Foreign
65
+ * holders and stale bridge-driver endpoints may keep the network
66
+ * busy for a short window; 6 × 250ms saturates well inside the
67
+ * prune wall-clock budget while letting transient races resolve.
68
+ * Callers may override per-invocation via
69
+ * `DevstackNetworkRemovalOptions`. */
70
+ declare const NETWORK_REMOVE_RETRY_PROFILE: {
71
+ readonly attempts: 6;
72
+ readonly delayMs: 250;
73
+ };
16
74
  //#endregion
17
75
  export { retry_policy_d_exports };
18
76
  //# sourceMappingURL=retry-policy.d.mts.map
@@ -2,6 +2,13 @@ import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
2
2
  import { Schedule } from "effect";
3
3
  //#region src/substrate/runtime/retry-policy.ts
4
4
  var retry_policy_exports = /* @__PURE__ */ __exportAll({
5
+ BALANCE_POLL_PROFILE: () => BALANCE_POLL_PROFILE,
6
+ DEPLOY_BIND_SOURCE_RETRY_PROFILE: () => DEPLOY_BIND_SOURCE_RETRY_PROFILE,
7
+ FAUCET_HTTP_RETRY_PROFILE: () => FAUCET_HTTP_RETRY_PROFILE,
8
+ FUNDING_BALANCE_READ_TIMEOUT_MS: () => FUNDING_BALANCE_READ_TIMEOUT_MS,
9
+ NETWORK_REMOVE_RETRY_PROFILE: () => NETWORK_REMOVE_RETRY_PROFILE,
10
+ STALE_OBJECT_VERSION_RETRY_PROFILE: () => STALE_OBJECT_VERSION_RETRY_PROFILE,
11
+ makeBoundedSpacedSchedule: () => makeBoundedSpacedSchedule,
5
12
  makeExponentialRetrySchedule: () => makeExponentialRetrySchedule,
6
13
  makeSpacedRetrySchedule: () => makeSpacedRetrySchedule
7
14
  });
@@ -10,7 +17,65 @@ const makeExponentialRetrySchedule = (options) => {
10
17
  return (options.jitter === false ? schedule : schedule.pipe(Schedule.jittered)).pipe(Schedule.both(Schedule.recurs(options.maxRetries)));
11
18
  };
12
19
  const makeSpacedRetrySchedule = (delayMs, maxRetries) => Schedule.spaced(`${delayMs} millis`).pipe(Schedule.both(Schedule.recurs(maxRetries)));
20
+ /** Wall-clock-bounded fixed-interval poll. Selects "poll every
21
+ * `intervalMs` until total elapsed ≥ `timeoutMs`". Returns a
22
+ * schedule that callers compose with `Effect.repeat` /
23
+ * `Effect.retry` for poll-until-ready loops where the exit
24
+ * condition is owned by the caller body.
25
+ *
26
+ * Use for balance polls, post-funding settlement waits, and any
27
+ * similar wall-clock-bounded reconciliation loops. */
28
+ const makeBoundedSpacedSchedule = (intervalMs, timeoutMs) => Schedule.both(Schedule.spaced(`${intervalMs} millis`), Schedule.during(`${timeoutMs} millis`));
29
+ /** Balance-poll profile shared by funding settlement waits. The
30
+ * interval is short enough to keep wall-clock overshoot small;
31
+ * the timeout is the canonical funding settlement budget. */
32
+ const BALANCE_POLL_PROFILE = {
33
+ intervalMs: 250,
34
+ timeoutMs: 3e4
35
+ };
36
+ /** Single-call deadline for the per-poll balance-reader. Faucet
37
+ * RPC calls occasionally hang; the deadline keeps a stalled
38
+ * read from starving the surrounding poll loop. */
39
+ const FUNDING_BALANCE_READ_TIMEOUT_MS = 5e3;
40
+ /** Docker Desktop bind-mount visibility race. The host directory
41
+ * is just-created but the Docker VFS hasn't surfaced it yet;
42
+ * attempts cap at 5s total (10 × 500ms). */
43
+ const DEPLOY_BIND_SOURCE_RETRY_PROFILE = {
44
+ attempts: 10,
45
+ delayMs: 500
46
+ };
47
+ /** HTTP faucet POST retry profile. The faucet's TCP socket binds
48
+ * before the validator can transfer coins (a 60s cold-warm
49
+ * window). `attempts × backoff` saturates well inside the
50
+ * surrounding wall-clock budget. */
51
+ const FAUCET_HTTP_RETRY_PROFILE = {
52
+ maxAttempts: 15,
53
+ initialDelayMs: 500,
54
+ backoffFactor: 1.5,
55
+ wallClockBudgetMs: 9e4,
56
+ perRequestDeadlineMs: 5e3
57
+ };
58
+ /** Sui "stale object version" retry profile — used when a Move call
59
+ * references an object that's been mutated by a concurrent transaction
60
+ * (deepbook pool seeding hits this when the registry / pool object is
61
+ * re-versioned mid-flight). The retry rebuilds the transaction with
62
+ * fresh refs each attempt; 20 × 500ms keeps the worst case under 10s. */
63
+ const STALE_OBJECT_VERSION_RETRY_PROFILE = {
64
+ attempts: 20,
65
+ delayMs: 500
66
+ };
67
+ /** Docker `network rm` retry profile — used by best-effort network
68
+ * prune after our own endpoints are force-disconnected. Foreign
69
+ * holders and stale bridge-driver endpoints may keep the network
70
+ * busy for a short window; 6 × 250ms saturates well inside the
71
+ * prune wall-clock budget while letting transient races resolve.
72
+ * Callers may override per-invocation via
73
+ * `DevstackNetworkRemovalOptions`. */
74
+ const NETWORK_REMOVE_RETRY_PROFILE = {
75
+ attempts: 6,
76
+ delayMs: 250
77
+ };
13
78
  //#endregion
14
- export { makeExponentialRetrySchedule, makeSpacedRetrySchedule, retry_policy_exports };
79
+ export { BALANCE_POLL_PROFILE, DEPLOY_BIND_SOURCE_RETRY_PROFILE, FAUCET_HTTP_RETRY_PROFILE, FUNDING_BALANCE_READ_TIMEOUT_MS, NETWORK_REMOVE_RETRY_PROFILE, STALE_OBJECT_VERSION_RETRY_PROFILE, makeBoundedSpacedSchedule, makeExponentialRetrySchedule, makeSpacedRetrySchedule, retry_policy_exports };
15
80
 
16
81
  //# sourceMappingURL=retry-policy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry-policy.mjs","names":[],"sources":["../../../src/substrate/runtime/retry-policy.ts"],"sourcesContent":["import { Schedule } from 'effect';\n\nexport interface ExponentialRetryOptions {\n\treadonly initialDelayMs: number;\n\treadonly maxRetries: number;\n\treadonly factor?: number;\n\treadonly jitter?: boolean;\n}\n\nexport const makeExponentialRetrySchedule = (options: ExponentialRetryOptions) => {\n\tconst schedule = Schedule.exponential(`${options.initialDelayMs} millis`, options.factor ?? 2);\n\tconst jittered = options.jitter === false ? schedule : schedule.pipe(Schedule.jittered);\n\treturn jittered.pipe(Schedule.both(Schedule.recurs(options.maxRetries)));\n};\n\nexport const makeSpacedRetrySchedule = (delayMs: number, maxRetries: number) =>\n\tSchedule.spaced(`${delayMs} millis`).pipe(Schedule.both(Schedule.recurs(maxRetries)));\n"],"mappings":";;;;;;;AASA,MAAa,gCAAgC,YAAqC;CACjF,MAAM,WAAW,SAAS,YAAY,GAAG,QAAQ,eAAe,UAAU,QAAQ,UAAU,EAAE;AAE9F,SADiB,QAAQ,WAAW,QAAQ,WAAW,SAAS,KAAK,SAAS,SAAS,EACvE,KAAK,SAAS,KAAK,SAAS,OAAO,QAAQ,WAAW,CAAC,CAAC;;AAGzE,MAAa,2BAA2B,SAAiB,eACxD,SAAS,OAAO,GAAG,QAAQ,SAAS,CAAC,KAAK,SAAS,KAAK,SAAS,OAAO,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"retry-policy.mjs","names":[],"sources":["../../../src/substrate/runtime/retry-policy.ts"],"sourcesContent":["import { Schedule } from 'effect';\n\nexport interface ExponentialRetryOptions {\n\treadonly initialDelayMs: number;\n\treadonly maxRetries: number;\n\treadonly factor?: number;\n\treadonly jitter?: boolean;\n}\n\nexport const makeExponentialRetrySchedule = (options: ExponentialRetryOptions) => {\n\tconst schedule = Schedule.exponential(`${options.initialDelayMs} millis`, options.factor ?? 2);\n\tconst jittered = options.jitter === false ? schedule : schedule.pipe(Schedule.jittered);\n\treturn jittered.pipe(Schedule.both(Schedule.recurs(options.maxRetries)));\n};\n\nexport const makeSpacedRetrySchedule = (delayMs: number, maxRetries: number) =>\n\tSchedule.spaced(`${delayMs} millis`).pipe(Schedule.both(Schedule.recurs(maxRetries)));\n\n/** Wall-clock-bounded fixed-interval poll. Selects \"poll every\n * `intervalMs` until total elapsed ≥ `timeoutMs`\". Returns a\n * schedule that callers compose with `Effect.repeat` /\n * `Effect.retry` for poll-until-ready loops where the exit\n * condition is owned by the caller body.\n *\n * Use for balance polls, post-funding settlement waits, and any\n * similar wall-clock-bounded reconciliation loops. */\nexport const makeBoundedSpacedSchedule = (intervalMs: number, timeoutMs: number) =>\n\tSchedule.both(Schedule.spaced(`${intervalMs} millis`), Schedule.during(`${timeoutMs} millis`));\n\n/** Balance-poll profile shared by funding settlement waits. The\n * interval is short enough to keep wall-clock overshoot small;\n * the timeout is the canonical funding settlement budget. */\nexport const BALANCE_POLL_PROFILE = {\n\tintervalMs: 250,\n\ttimeoutMs: 30_000,\n} as const;\n\n/** Single-call deadline for the per-poll balance-reader. Faucet\n * RPC calls occasionally hang; the deadline keeps a stalled\n * read from starving the surrounding poll loop. */\nexport const FUNDING_BALANCE_READ_TIMEOUT_MS = 5_000;\n\n/** Docker Desktop bind-mount visibility race. The host directory\n * is just-created but the Docker VFS hasn't surfaced it yet;\n * attempts cap at 5s total (10 × 500ms). */\nexport const DEPLOY_BIND_SOURCE_RETRY_PROFILE = {\n\tattempts: 10,\n\tdelayMs: 500,\n} as const;\n\n/** HTTP faucet POST retry profile. The faucet's TCP socket binds\n * before the validator can transfer coins (a 60s cold-warm\n * window). `attempts × backoff` saturates well inside the\n * surrounding wall-clock budget. */\nexport const FAUCET_HTTP_RETRY_PROFILE = {\n\tmaxAttempts: 15,\n\tinitialDelayMs: 500,\n\tbackoffFactor: 1.5,\n\twallClockBudgetMs: 90_000,\n\tperRequestDeadlineMs: 5_000,\n} as const;\n\n/** Sui \"stale object version\" retry profile — used when a Move call\n * references an object that's been mutated by a concurrent transaction\n * (deepbook pool seeding hits this when the registry / pool object is\n * re-versioned mid-flight). The retry rebuilds the transaction with\n * fresh refs each attempt; 20 × 500ms keeps the worst case under 10s. */\nexport const STALE_OBJECT_VERSION_RETRY_PROFILE = {\n\tattempts: 20,\n\tdelayMs: 500,\n} as const;\n\n/** Docker `network rm` retry profile — used by best-effort network\n * prune after our own endpoints are force-disconnected. Foreign\n * holders and stale bridge-driver endpoints may keep the network\n * busy for a short window; 6 × 250ms saturates well inside the\n * prune wall-clock budget while letting transient races resolve.\n * Callers may override per-invocation via\n * `DevstackNetworkRemovalOptions`. */\nexport const NETWORK_REMOVE_RETRY_PROFILE = {\n\tattempts: 6,\n\tdelayMs: 250,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,gCAAgC,YAAqC;CACjF,MAAM,WAAW,SAAS,YAAY,GAAG,QAAQ,eAAe,UAAU,QAAQ,UAAU,EAAE;AAE9F,SADiB,QAAQ,WAAW,QAAQ,WAAW,SAAS,KAAK,SAAS,SAAS,EACvE,KAAK,SAAS,KAAK,SAAS,OAAO,QAAQ,WAAW,CAAC,CAAC;;AAGzE,MAAa,2BAA2B,SAAiB,eACxD,SAAS,OAAO,GAAG,QAAQ,SAAS,CAAC,KAAK,SAAS,KAAK,SAAS,OAAO,WAAW,CAAC,CAAC;;;;;;;;;AAUtF,MAAa,6BAA6B,YAAoB,cAC7D,SAAS,KAAK,SAAS,OAAO,GAAG,WAAW,SAAS,EAAE,SAAS,OAAO,GAAG,UAAU,SAAS,CAAC;;;;AAK/F,MAAa,uBAAuB;CACnC,YAAY;CACZ,WAAW;CACX;;;;AAKD,MAAa,kCAAkC;;;;AAK/C,MAAa,mCAAmC;CAC/C,UAAU;CACV,SAAS;CACT;;;;;AAMD,MAAa,4BAA4B;CACxC,aAAa;CACb,gBAAgB;CAChB,eAAe;CACf,mBAAmB;CACnB,sBAAsB;CACtB;;;;;;AAOD,MAAa,qCAAqC;CACjD,UAAU;CACV,SAAS;CACT;;;;;;;;AASD,MAAa,+BAA+B;CAC3C,UAAU;CACV,SAAS;CACT"}
@@ -0,0 +1 @@
1
+ import { Effect, Schema } from "effect";
@@ -0,0 +1,79 @@
1
+ import { Effect, Schema } from "effect";
2
+ //#region src/substrate/runtime/routed-url.ts
3
+ /** The conventional "default" stack name. Hostnames for this stack omit
4
+ * the stack segment per the architecture's UX rule. */
5
+ const DEFAULT_STACK = "main";
6
+ const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
7
+ const MAX_HOSTNAME_LEN = 200;
8
+ /** A user-influenceable hostname-segment string did not pass
9
+ * validation. Substrate-blind shape mirroring the orchestrator's
10
+ * `RouterValidationError`; L3 orchestrators wrap this into their
11
+ * richer error union for internal composition. */
12
+ var HostnameValidationError = class extends Schema.TaggedErrorClass()("HostnameValidationError", {
13
+ field: Schema.Literals([
14
+ "hostname",
15
+ "dispatchId",
16
+ "entrypointName",
17
+ "upstreamUrl"
18
+ ]),
19
+ value: Schema.String,
20
+ detail: Schema.String
21
+ }) {};
22
+ /** Validate a single label-shaped string. */
23
+ const validateLabel = (field, value) => {
24
+ if (!LABEL.test(value)) return Effect.fail(new HostnameValidationError({
25
+ field,
26
+ value,
27
+ detail: "expected lower-case RFC-1035 label (alphanumeric + internal hyphens, 1-63 chars)"
28
+ }));
29
+ return Effect.succeed(value);
30
+ };
31
+ /** Fold dots → hyphens (architecture invariant #8) and lower-case.
32
+ * Pure, no validation. The output is fed to `validateLabel`. */
33
+ const normalizeServiceSegment = (raw) => raw.toLowerCase().replace(/\./g, "-");
34
+ /** Mint the per-Routable hostname from `(identity, role)`.
35
+ *
36
+ * Default stack: `<role>.<app>.localhost`
37
+ * Other stacks: `<role>.<stack>.<app>.localhost`
38
+ *
39
+ * Substrate-blind: the substrate knows about identities (app, stack)
40
+ * and arbitrary role strings — it does not know about specific plugins
41
+ * or services. L2 plugins call this directly; L3 orchestrators wrap
42
+ * the failure case into their richer error union. */
43
+ const routedHostname = (identity, role) => Effect.gen(function* () {
44
+ const app = yield* validateLabel("hostname", identity.app);
45
+ const roleSafe = yield* validateLabel("hostname", normalizeServiceSegment(role));
46
+ const stackSafe = identity.stack === "main" ? null : yield* validateLabel("hostname", identity.stack.toLowerCase());
47
+ const assembled = stackSafe === null ? `${roleSafe}.${app}.localhost` : `${roleSafe}.${stackSafe}.${app}.localhost`;
48
+ if (assembled.length > MAX_HOSTNAME_LEN) return yield* Effect.fail(new HostnameValidationError({
49
+ field: "hostname",
50
+ value: assembled,
51
+ detail: `exceeds ${MAX_HOSTNAME_LEN}-char limit`
52
+ }));
53
+ return assembled;
54
+ });
55
+ /** Pure URL composer.
56
+ *
57
+ * - `http` / `h2c` → `http://…` (h2c is HTTP/2 cleartext; Traefik
58
+ * handles upstream selection internally, the URL scheme stays
59
+ * `http`).
60
+ * - `https` → `https://…`.
61
+ * - `tcp` → `tcp://…` — used by the file-provider renderer
62
+ * to distinguish from HTTP at YAML-emit time. Consumers of the
63
+ * resolved URL (manifest, codegen) translate back to whatever
64
+ * scheme their protocol expects (e.g. `postgres://`, `redis://`).
65
+ *
66
+ * The port is always included in the rendered URL (no well-known-port
67
+ * omission); the file-provider renderer parses the URL back into
68
+ * `(assembled, port)` for the TCP `address:` field and would reject a
69
+ * port-less form. `path` is appended verbatim when supplied (it MUST
70
+ * include the leading slash). */
71
+ const renderUrl = (parts) => {
72
+ const scheme = parts.protocol === "https" ? "https" : parts.protocol === "tcp" ? "tcp" : "http";
73
+ const path = parts.path ?? "";
74
+ return `${scheme}://${parts.hostname}:${parts.port}${path}`;
75
+ };
76
+ //#endregion
77
+ export { DEFAULT_STACK, normalizeServiceSegment, renderUrl, routedHostname };
78
+
79
+ //# sourceMappingURL=routed-url.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routed-url.mjs","names":[],"sources":["../../../src/substrate/runtime/routed-url.ts"],"sourcesContent":["// Substrate-blind URL composer + routed-hostname accessor.\n//\n// Consumed by L2 plugins (wallet, sui modes, future authors) so plugin\n// code does not reach across the L2→L3 boundary into\n// `orchestrators/router/hostname.ts`. The pure URL composition and\n// hostname-minting logic depends only on `substrate/identity.ts` and is\n// genuinely substrate-level; lifting it here removes a long-standing\n// boundary violation flagged in ARCHITECTURE.md (L2 row: \"NEVER imports\n// from … L3 orchestrators\").\n//\n// Architecture invariants honoured (mirrored from the original\n// orchestrators/router/hostname.ts authoritative comment):\n//\n// #7 — Distinct `(app, stack, role)` triples MUST produce distinct\n// hostnames. Default stack ('main') omits the stack segment;\n// every other stack includes it.\n// #8 — Hostname service labels fold dots to a label-safe separator\n// before validation.\n// #13 — User-influenceable strings are validated against a\n// conservative character set before render.\n//\n// The L3 router orchestrator imports from here and adapts the\n// substrate-blind `HostnameValidationError` into its richer\n// `RouterError` union for orchestrator-internal callers (file-provider,\n// resolveRoute) that compose with `UnknownEntrypoint`, `RouteCollision`,\n// etc. Substrate stays name-blind: this module mentions no plugin or\n// orchestrator identifiers.\n\nimport { Effect, Schema } from 'effect';\n\nimport type { Identity } from '../identity.ts';\n\n/** The conventional \"default\" stack name. Hostnames for this stack omit\n * the stack segment per the architecture's UX rule. */\nexport const DEFAULT_STACK = 'main';\n\n// RFC-1035 single-label regex: starts/ends with alphanumeric, allows\n// internal hyphens, length 1-63. Used for app, role, and (post-fold)\n// stack labels.\nconst LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;\n// 253 chars is the RFC-1035 full-name max. We stay well below.\nconst MAX_HOSTNAME_LEN = 200;\n\n/** A user-influenceable hostname-segment string did not pass\n * validation. Substrate-blind shape mirroring the orchestrator's\n * `RouterValidationError`; L3 orchestrators wrap this into their\n * richer error union for internal composition. */\nexport class HostnameValidationError extends Schema.TaggedErrorClass<HostnameValidationError>()(\n\t'HostnameValidationError',\n\t{\n\t\tfield: Schema.Literals(['hostname', 'dispatchId', 'entrypointName', 'upstreamUrl']),\n\t\tvalue: Schema.String,\n\t\tdetail: Schema.String,\n\t},\n) {}\n\n/** Validate a single label-shaped string. */\nconst validateLabel = (\n\tfield: HostnameValidationError['field'],\n\tvalue: string,\n): Effect.Effect<string, HostnameValidationError> => {\n\tif (!LABEL.test(value)) {\n\t\treturn Effect.fail(\n\t\t\tnew HostnameValidationError({\n\t\t\t\tfield,\n\t\t\t\tvalue,\n\t\t\t\tdetail: 'expected lower-case RFC-1035 label (alphanumeric + internal hyphens, 1-63 chars)',\n\t\t\t}),\n\t\t);\n\t}\n\treturn Effect.succeed(value);\n};\n\n/** Fold dots → hyphens (architecture invariant #8) and lower-case.\n * Pure, no validation. The output is fed to `validateLabel`. */\nexport const normalizeServiceSegment = (raw: string): string =>\n\traw.toLowerCase().replace(/\\./g, '-');\n\n/** Mint the per-Routable hostname from `(identity, role)`.\n *\n * Default stack: `<role>.<app>.localhost`\n * Other stacks: `<role>.<stack>.<app>.localhost`\n *\n * Substrate-blind: the substrate knows about identities (app, stack)\n * and arbitrary role strings — it does not know about specific plugins\n * or services. L2 plugins call this directly; L3 orchestrators wrap\n * the failure case into their richer error union. */\nexport const routedHostname = (\n\tidentity: Identity,\n\trole: string,\n): Effect.Effect<string, HostnameValidationError> =>\n\tEffect.gen(function* () {\n\t\tconst app = yield* validateLabel('hostname', identity.app);\n\t\tconst folded = normalizeServiceSegment(role);\n\t\tconst roleSafe = yield* validateLabel('hostname', folded);\n\t\t// The `StackName` brand does NOT character-validate at construction\n\t\t// (`brand.ts` / `api/inference-network.ts:resolveStackName`), so we\n\t\t// re-validate here for parity with `app`. A malformed stack name\n\t\t// (uppercase / underscores / out-of-RFC-1035 chars) must fail at\n\t\t// hostname assembly, not silently pass through.\n\t\tconst stackSafe =\n\t\t\tidentity.stack === DEFAULT_STACK\n\t\t\t\t? null\n\t\t\t\t: yield* validateLabel('hostname', identity.stack.toLowerCase());\n\t\tconst assembled =\n\t\t\tstackSafe === null\n\t\t\t\t? `${roleSafe}.${app}.localhost`\n\t\t\t\t: `${roleSafe}.${stackSafe}.${app}.localhost`;\n\t\tif (assembled.length > MAX_HOSTNAME_LEN) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tnew HostnameValidationError({\n\t\t\t\t\tfield: 'hostname',\n\t\t\t\t\tvalue: assembled,\n\t\t\t\t\tdetail: `exceeds ${MAX_HOSTNAME_LEN}-char limit`,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn assembled;\n\t});\n\n/** Pure URL composer.\n *\n * - `http` / `h2c` → `http://…` (h2c is HTTP/2 cleartext; Traefik\n * handles upstream selection internally, the URL scheme stays\n * `http`).\n * - `https` → `https://…`.\n * - `tcp` → `tcp://…` — used by the file-provider renderer\n * to distinguish from HTTP at YAML-emit time. Consumers of the\n * resolved URL (manifest, codegen) translate back to whatever\n * scheme their protocol expects (e.g. `postgres://`, `redis://`).\n *\n * The port is always included in the rendered URL (no well-known-port\n * omission); the file-provider renderer parses the URL back into\n * `(assembled, port)` for the TCP `address:` field and would reject a\n * port-less form. `path` is appended verbatim when supplied (it MUST\n * include the leading slash). */\nexport const renderUrl = (parts: {\n\treadonly protocol: 'http' | 'https' | 'h2c' | 'tcp';\n\treadonly hostname: string;\n\treadonly port: number;\n\treadonly path?: string;\n}): string => {\n\tconst scheme = parts.protocol === 'https' ? 'https' : parts.protocol === 'tcp' ? 'tcp' : 'http';\n\tconst path = parts.path ?? '';\n\treturn `${scheme}://${parts.hostname}:${parts.port}${path}`;\n};\n"],"mappings":";;;;AAkCA,MAAa,gBAAgB;AAK7B,MAAM,QAAQ;AAEd,MAAM,mBAAmB;;;;;AAMzB,IAAa,0BAAb,cAA6C,OAAO,kBAA2C,CAC9F,2BACA;CACC,OAAO,OAAO,SAAS;EAAC;EAAY;EAAc;EAAkB;EAAc,CAAC;CACnF,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,CACD,CAAC;;AAGF,MAAM,iBACL,OACA,UACoD;AACpD,KAAI,CAAC,MAAM,KAAK,MAAM,CACrB,QAAO,OAAO,KACb,IAAI,wBAAwB;EAC3B;EACA;EACA,QAAQ;EACR,CAAC,CACF;AAEF,QAAO,OAAO,QAAQ,MAAM;;;;AAK7B,MAAa,2BAA2B,QACvC,IAAI,aAAa,CAAC,QAAQ,OAAO,IAAI;;;;;;;;;;AAWtC,MAAa,kBACZ,UACA,SAEA,OAAO,IAAI,aAAa;CACvB,MAAM,MAAM,OAAO,cAAc,YAAY,SAAS,IAAI;CAE1D,MAAM,WAAW,OAAO,cAAc,YADvB,wBAAwB,KACiB,CAAC;CAMzD,MAAM,YACL,SAAS,UAAA,SACN,OACA,OAAO,cAAc,YAAY,SAAS,MAAM,aAAa,CAAC;CAClE,MAAM,YACL,cAAc,OACX,GAAG,SAAS,GAAG,IAAI,cACnB,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI;AACpC,KAAI,UAAU,SAAS,iBACtB,QAAO,OAAO,OAAO,KACpB,IAAI,wBAAwB;EAC3B,OAAO;EACP,OAAO;EACP,QAAQ,WAAW,iBAAiB;EACpC,CAAC,CACF;AAEF,QAAO;EACN;;;;;;;;;;;;;;;;;AAkBH,MAAa,aAAa,UAKZ;CACb,MAAM,SAAS,MAAM,aAAa,UAAU,UAAU,MAAM,aAAa,QAAQ,QAAQ;CACzF,MAAM,OAAO,MAAM,QAAQ;AAC3B,QAAO,GAAG,OAAO,KAAK,MAAM,SAAS,GAAG,MAAM,OAAO"}
@@ -28,5 +28,5 @@ declare const decodeJsonTextSync: <S extends Schema.Decoder<unknown>, E>(schema:
28
28
  declare const decodeJsonArrayElementSync: <S extends Schema.Decoder<unknown>, E>(schema: S, text: string, options: JsonArrayElementDecodeOptions<E>) => S["Type"];
29
29
  declare const decodeJsonLines: <S extends Schema.Decoder<unknown>, E>(schema: S, text: string, options: DecodeOptions<E>) => Effect.Effect<ReadonlyArray<S["Type"]>, E>;
30
30
  //#endregion
31
- export { runtime_decode_d_exports };
31
+ export { decodeUnknownSync, parseJsonTextSync, runtime_decode_d_exports };
32
32
  //# sourceMappingURL=runtime-decode.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-decode.mjs","names":[],"sources":["../../../src/substrate/runtime/runtime-decode.ts"],"sourcesContent":["import { Effect, Schema } from 'effect';\n\nexport interface RuntimeDecodeIssue {\n\treadonly source: string;\n\treadonly message: string;\n\treadonly cause?: unknown;\n}\n\nexport type RuntimeDecodeErrorFactory<E> = (issue: RuntimeDecodeIssue) => E;\n\nexport interface DecodeOptions<E> {\n\treadonly source: string;\n\treadonly mkError: RuntimeDecodeErrorFactory<E>;\n\treadonly message?: string;\n}\n\nexport interface JsonArrayElementDecodeOptions<E> extends DecodeOptions<E> {\n\treadonly index?: number;\n\treadonly missingMessage?: string;\n}\n\nconst issue = <E>(\n\toptions: DecodeOptions<E>,\n\tmessage: string,\n\tcause?: unknown,\n): RuntimeDecodeIssue => ({\n\tsource: options.source,\n\tmessage: options.message ?? message,\n\t...(cause === undefined ? {} : { cause }),\n});\n\nexport const parseJsonText = <E>(\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<unknown, E> =>\n\tEffect.try({\n\t\ttry: () => JSON.parse(text) as unknown,\n\t\tcatch: (cause) => options.mkError(issue(options, 'failed to parse JSON', cause)),\n\t});\n\nexport const parseJsonTextSync = <E>(text: string, options: DecodeOptions<E>): unknown => {\n\ttry {\n\t\treturn JSON.parse(text) as unknown;\n\t} catch (cause) {\n\t\tthrow options.mkError(issue(options, 'failed to parse JSON', cause));\n\t}\n};\n\nexport const decodeUnknown = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\tvalue: unknown,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<S['Type'], E> =>\n\tSchema.decodeUnknownEffect(schema)(value).pipe(\n\t\tEffect.mapError((cause) => options.mkError(issue(options, 'failed to decode value', cause))),\n\t);\n\nexport const decodeUnknownSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\tvalue: unknown,\n\toptions: DecodeOptions<E>,\n): S['Type'] => {\n\ttry {\n\t\treturn Schema.decodeUnknownSync(schema)(value);\n\t} catch (cause) {\n\t\tthrow options.mkError(issue(options, 'failed to decode value', cause));\n\t}\n};\n\nexport const decodeJsonText = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<S['Type'], E> =>\n\tparseJsonText(text, options).pipe(\n\t\tEffect.flatMap((value) => decodeUnknown(schema, value, options)),\n\t);\n\nexport const decodeJsonTextSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): S['Type'] => decodeUnknownSync(schema, parseJsonTextSync(text, options), options);\n\nexport const decodeJsonArrayElementSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: JsonArrayElementDecodeOptions<E>,\n): S['Type'] => {\n\tconst index = options.index ?? 0;\n\tconst value = parseJsonTextSync(text, options);\n\tif (!Array.isArray(value) || value[index] === undefined) {\n\t\tthrow options.mkError(\n\t\t\tissue(\n\t\t\t\toptions,\n\t\t\t\toptions.missingMessage ?? `expected JSON array element at index ${index}`,\n\t\t\t\tvalue,\n\t\t\t),\n\t\t);\n\t}\n\treturn decodeUnknownSync(schema, value[index], options);\n};\n\nexport const decodeJsonLines = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<ReadonlyArray<S['Type']>, E> =>\n\tEffect.forEach(\n\t\ttext\n\t\t\t.split(/\\r?\\n/u)\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line.length > 0),\n\t\t(line, index) =>\n\t\t\tdecodeJsonText(schema, line, {\n\t\t\t\t...options,\n\t\t\t\tsource: `${options.source}:${index + 1}`,\n\t\t\t}),\n\t);\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAM,SACL,SACA,SACA,WACyB;CACzB,QAAQ,QAAQ;CAChB,SAAS,QAAQ,WAAW;CAC5B,GAAI,UAAU,KAAA,IAAY,EAAE,GAAG,EAAE,OAAO;CACxC;AAED,MAAa,iBACZ,MACA,YAEA,OAAO,IAAI;CACV,WAAW,KAAK,MAAM,KAAK;CAC3B,QAAQ,UAAU,QAAQ,QAAQ,MAAM,SAAS,wBAAwB,MAAM,CAAC;CAChF,CAAC;AAEH,MAAa,qBAAwB,MAAc,YAAuC;AACzF,KAAI;AACH,SAAO,KAAK,MAAM,KAAK;UACf,OAAO;AACf,QAAM,QAAQ,QAAQ,MAAM,SAAS,wBAAwB,MAAM,CAAC;;;AAItE,MAAa,iBACZ,QACA,OACA,YAEA,OAAO,oBAAoB,OAAO,CAAC,MAAM,CAAC,KACzC,OAAO,UAAU,UAAU,QAAQ,QAAQ,MAAM,SAAS,0BAA0B,MAAM,CAAC,CAAC,CAC5F;AAEF,MAAa,qBACZ,QACA,OACA,YACe;AACf,KAAI;AACH,SAAO,OAAO,kBAAkB,OAAO,CAAC,MAAM;UACtC,OAAO;AACf,QAAM,QAAQ,QAAQ,MAAM,SAAS,0BAA0B,MAAM,CAAC;;;AAIxE,MAAa,kBACZ,QACA,MACA,YAEA,cAAc,MAAM,QAAQ,CAAC,KAC5B,OAAO,SAAS,UAAU,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAChE;AAEF,MAAa,sBACZ,QACA,MACA,YACe,kBAAkB,QAAQ,kBAAkB,MAAM,QAAQ,EAAE,QAAQ;AAEpF,MAAa,8BACZ,QACA,MACA,YACe;CACf,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,QAAQ,kBAAkB,MAAM,QAAQ;AAC9C,KAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,KAAA,EAC7C,OAAM,QAAQ,QACb,MACC,SACA,QAAQ,kBAAkB,wCAAwC,SAClE,MACA,CACD;AAEF,QAAO,kBAAkB,QAAQ,MAAM,QAAQ,QAAQ;;AAGxD,MAAa,mBACZ,QACA,MACA,YAEA,OAAO,QACN,KACE,MAAM,SAAS,CACf,KAAK,SAAS,KAAK,MAAM,CAAC,CAC1B,QAAQ,SAAS,KAAK,SAAS,EAAE,GAClC,MAAM,UACN,eAAe,QAAQ,MAAM;CAC5B,GAAG;CACH,QAAQ,GAAG,QAAQ,OAAO,GAAG,QAAQ;CACrC,CAAC,CACH"}
1
+ {"version":3,"file":"runtime-decode.mjs","names":[],"sources":["../../../src/substrate/runtime/runtime-decode.ts"],"sourcesContent":["// Compound Schema decode at trust boundaries — JSON / unknown →\n// typed values, with one parse/decode issue shape and typed error\n// projection. Reach for `decodeUnknown(Sync)` /\n// `decodeJsonText(Sync)` when you have a Schema and want to decode\n// a whole shape (multi-field, refinements, transforms).\n//\n// For one-field shape checks (\"port must be a positive integer\",\n// \"name must be a non-empty string\") that throw on bad input,\n// reach for the `expect*` helpers in `config-validation.ts` instead.\n\nimport { Effect, Schema } from 'effect';\n\nexport interface RuntimeDecodeIssue {\n\treadonly source: string;\n\treadonly message: string;\n\treadonly cause?: unknown;\n}\n\nexport type RuntimeDecodeErrorFactory<E> = (issue: RuntimeDecodeIssue) => E;\n\nexport interface DecodeOptions<E> {\n\treadonly source: string;\n\treadonly mkError: RuntimeDecodeErrorFactory<E>;\n\treadonly message?: string;\n}\n\nexport interface JsonArrayElementDecodeOptions<E> extends DecodeOptions<E> {\n\treadonly index?: number;\n\treadonly missingMessage?: string;\n}\n\nconst issue = <E>(\n\toptions: DecodeOptions<E>,\n\tmessage: string,\n\tcause?: unknown,\n): RuntimeDecodeIssue => ({\n\tsource: options.source,\n\tmessage: options.message ?? message,\n\t...(cause === undefined ? {} : { cause }),\n});\n\nexport const parseJsonText = <E>(\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<unknown, E> =>\n\tEffect.try({\n\t\ttry: () => JSON.parse(text) as unknown,\n\t\tcatch: (cause) => options.mkError(issue(options, 'failed to parse JSON', cause)),\n\t});\n\nexport const parseJsonTextSync = <E>(text: string, options: DecodeOptions<E>): unknown => {\n\ttry {\n\t\treturn JSON.parse(text) as unknown;\n\t} catch (cause) {\n\t\tthrow options.mkError(issue(options, 'failed to parse JSON', cause));\n\t}\n};\n\nexport const decodeUnknown = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\tvalue: unknown,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<S['Type'], E> =>\n\tSchema.decodeUnknownEffect(schema)(value).pipe(\n\t\tEffect.mapError((cause) => options.mkError(issue(options, 'failed to decode value', cause))),\n\t);\n\nexport const decodeUnknownSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\tvalue: unknown,\n\toptions: DecodeOptions<E>,\n): S['Type'] => {\n\ttry {\n\t\treturn Schema.decodeUnknownSync(schema)(value);\n\t} catch (cause) {\n\t\tthrow options.mkError(issue(options, 'failed to decode value', cause));\n\t}\n};\n\nexport const decodeJsonText = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<S['Type'], E> =>\n\tparseJsonText(text, options).pipe(\n\t\tEffect.flatMap((value) => decodeUnknown(schema, value, options)),\n\t);\n\nexport const decodeJsonTextSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): S['Type'] => decodeUnknownSync(schema, parseJsonTextSync(text, options), options);\n\nexport const decodeJsonArrayElementSync = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: JsonArrayElementDecodeOptions<E>,\n): S['Type'] => {\n\tconst index = options.index ?? 0;\n\tconst value = parseJsonTextSync(text, options);\n\tif (!Array.isArray(value) || value[index] === undefined) {\n\t\tthrow options.mkError(\n\t\t\tissue(\n\t\t\t\toptions,\n\t\t\t\toptions.missingMessage ?? `expected JSON array element at index ${index}`,\n\t\t\t\tvalue,\n\t\t\t),\n\t\t);\n\t}\n\treturn decodeUnknownSync(schema, value[index], options);\n};\n\nexport const decodeJsonLines = <S extends Schema.Decoder<unknown>, E>(\n\tschema: S,\n\ttext: string,\n\toptions: DecodeOptions<E>,\n): Effect.Effect<ReadonlyArray<S['Type']>, E> =>\n\tEffect.forEach(\n\t\ttext\n\t\t\t.split(/\\r?\\n/u)\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line.length > 0),\n\t\t(line, index) =>\n\t\t\tdecodeJsonText(schema, line, {\n\t\t\t\t...options,\n\t\t\t\tsource: `${options.source}:${index + 1}`,\n\t\t\t}),\n\t);\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,SACL,SACA,SACA,WACyB;CACzB,QAAQ,QAAQ;CAChB,SAAS,QAAQ,WAAW;CAC5B,GAAI,UAAU,KAAA,IAAY,EAAE,GAAG,EAAE,OAAO;CACxC;AAED,MAAa,iBACZ,MACA,YAEA,OAAO,IAAI;CACV,WAAW,KAAK,MAAM,KAAK;CAC3B,QAAQ,UAAU,QAAQ,QAAQ,MAAM,SAAS,wBAAwB,MAAM,CAAC;CAChF,CAAC;AAEH,MAAa,qBAAwB,MAAc,YAAuC;AACzF,KAAI;AACH,SAAO,KAAK,MAAM,KAAK;UACf,OAAO;AACf,QAAM,QAAQ,QAAQ,MAAM,SAAS,wBAAwB,MAAM,CAAC;;;AAItE,MAAa,iBACZ,QACA,OACA,YAEA,OAAO,oBAAoB,OAAO,CAAC,MAAM,CAAC,KACzC,OAAO,UAAU,UAAU,QAAQ,QAAQ,MAAM,SAAS,0BAA0B,MAAM,CAAC,CAAC,CAC5F;AAEF,MAAa,qBACZ,QACA,OACA,YACe;AACf,KAAI;AACH,SAAO,OAAO,kBAAkB,OAAO,CAAC,MAAM;UACtC,OAAO;AACf,QAAM,QAAQ,QAAQ,MAAM,SAAS,0BAA0B,MAAM,CAAC;;;AAIxE,MAAa,kBACZ,QACA,MACA,YAEA,cAAc,MAAM,QAAQ,CAAC,KAC5B,OAAO,SAAS,UAAU,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAChE;AAEF,MAAa,sBACZ,QACA,MACA,YACe,kBAAkB,QAAQ,kBAAkB,MAAM,QAAQ,EAAE,QAAQ;AAEpF,MAAa,8BACZ,QACA,MACA,YACe;CACf,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,QAAQ,kBAAkB,MAAM,QAAQ;AAC9C,KAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,KAAA,EAC7C,OAAM,QAAQ,QACb,MACC,SACA,QAAQ,kBAAkB,wCAAwC,SAClE,MACA,CACD;AAEF,QAAO,kBAAkB,QAAQ,MAAM,QAAQ,QAAQ;;AAGxD,MAAa,mBACZ,QACA,MACA,YAEA,OAAO,QACN,KACE,MAAM,SAAS,CACf,KAAK,SAAS,KAAK,MAAM,CAAC,CAC1B,QAAQ,SAAS,KAAK,SAAS,EAAE,GAClC,MAAM,UACN,eAAe,QAAQ,MAAM;CAC5B,GAAG;CACH,QAAQ,GAAG,QAAQ,OAAO,GAAG,QAAQ;CACrC,CAAC,CACH"}
@@ -11,7 +11,7 @@ const gracefulCloseHttpServer = (server) => Effect.callback((resume) => {
11
11
  server.close(() => resume(Effect.void));
12
12
  });
13
13
  const listenScopedHttpServer = (options) => Effect.gen(function* () {
14
- const server = yield* Effect.tryPromise({
14
+ const server = yield* Effect.acquireRelease(Effect.tryPromise({
15
15
  try: () => new Promise((resolve, reject) => {
16
16
  const srv = createServer(options.listener);
17
17
  const onError = (err) => reject(err);
@@ -22,8 +22,7 @@ const listenScopedHttpServer = (options) => Effect.gen(function* () {
22
22
  });
23
23
  }),
24
24
  catch: options.onListenError
25
- });
26
- yield* Effect.addFinalizer(() => gracefulCloseHttpServer(server).pipe(Effect.uninterruptible));
25
+ }), (srv) => gracefulCloseHttpServer(srv).pipe(Effect.uninterruptible));
27
26
  return {
28
27
  url: `http://${options.bindAddress}:${options.port}`,
29
28
  server,
@@ -1 +1 @@
1
- {"version":3,"file":"scoped-http-server.mjs","names":[],"sources":["../../../src/substrate/runtime/scoped-http-server.ts"],"sourcesContent":["// Scoped host HTTP server primitive.\n//\n// Generic ownership for in-process host HTTP listeners: bind, surface\n// listen failures through a caller-owned error mapper, and install a\n// scope finalizer that drops idle keepalive sockets before awaiting\n// close. Domain routing stays with the plugin that supplies the\n// Node request listener.\n\nimport { Effect } from 'effect';\nimport type { Scope } from 'effect';\nimport { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport type HttpRequestListener = (req: IncomingMessage, res: ServerResponse) => void;\n\nexport interface ScopedHttpServerOptions<E> {\n\treadonly bindAddress: string;\n\treadonly port: number;\n\treadonly listener: HttpRequestListener;\n\treadonly onListenError: (cause: unknown) => E;\n}\n\nexport interface ScopedHttpServerHandle {\n\treadonly url: string;\n\treadonly server: Server;\n\treadonly close: () => Effect.Effect<void>;\n}\n\n/** Best-effort graceful close. `closeAllConnections()` drops idle\n * keepalive sockets so `close()` resolves; older Node versions\n * without `closeAllConnections` rely on `close()` alone. */\nexport const gracefulCloseHttpServer = (server: Server): Effect.Effect<void> =>\n\tEffect.callback<void>((resume) => {\n\t\ttry {\n\t\t\tserver.closeAllConnections();\n\t\t} catch {\n\t\t\t// Older Node versions don't expose closeAllConnections;\n\t\t\t// `close()` alone will still terminate.\n\t\t}\n\t\tserver.close(() => resume(Effect.void));\n\t});\n\nexport const listenScopedHttpServer = <E>(\n\toptions: ScopedHttpServerOptions<E>,\n): Effect.Effect<ScopedHttpServerHandle, E, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst server = yield* Effect.tryPromise({\n\t\t\ttry: () =>\n\t\t\t\tnew Promise<Server>((resolve, reject) => {\n\t\t\t\t\tconst srv = createServer(options.listener);\n\t\t\t\t\tconst onError = (err: Error) => reject(err);\n\t\t\t\t\tsrv.once('error', onError);\n\t\t\t\t\tsrv.listen(options.port, options.bindAddress, () => {\n\t\t\t\t\t\tsrv.removeListener('error', onError);\n\t\t\t\t\t\tresolve(srv);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\tcatch: options.onListenError,\n\t\t});\n\n\t\tyield* Effect.addFinalizer(() => gracefulCloseHttpServer(server).pipe(Effect.uninterruptible));\n\n\t\treturn {\n\t\t\turl: `http://${options.bindAddress}:${options.port}`,\n\t\t\tserver,\n\t\t\tclose: () => gracefulCloseHttpServer(server),\n\t\t};\n\t});\n"],"mappings":";;;;;;AA8BA,MAAa,2BAA2B,WACvC,OAAO,UAAgB,WAAW;AACjC,KAAI;AACH,SAAO,qBAAqB;SACrB;AAIR,QAAO,YAAY,OAAO,OAAO,KAAK,CAAC;EACtC;AAEH,MAAa,0BACZ,YAEA,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO,OAAO,WAAW;EACvC,WACC,IAAI,SAAiB,SAAS,WAAW;GACxC,MAAM,MAAM,aAAa,QAAQ,SAAS;GAC1C,MAAM,WAAW,QAAe,OAAO,IAAI;AAC3C,OAAI,KAAK,SAAS,QAAQ;AAC1B,OAAI,OAAO,QAAQ,MAAM,QAAQ,mBAAmB;AACnD,QAAI,eAAe,SAAS,QAAQ;AACpC,YAAQ,IAAI;KACX;IACD;EACH,OAAO,QAAQ;EACf,CAAC;AAEF,QAAO,OAAO,mBAAmB,wBAAwB,OAAO,CAAC,KAAK,OAAO,gBAAgB,CAAC;AAE9F,QAAO;EACN,KAAK,UAAU,QAAQ,YAAY,GAAG,QAAQ;EAC9C;EACA,aAAa,wBAAwB,OAAO;EAC5C;EACA"}
1
+ {"version":3,"file":"scoped-http-server.mjs","names":[],"sources":["../../../src/substrate/runtime/scoped-http-server.ts"],"sourcesContent":["// Scoped host HTTP server primitive.\n//\n// Generic ownership for in-process host HTTP listeners: bind, surface\n// listen failures through a caller-owned error mapper, and install a\n// scope finalizer that drops idle keepalive sockets before awaiting\n// close. Domain routing stays with the plugin that supplies the\n// Node request listener.\n\nimport { Effect } from 'effect';\nimport type { Scope } from 'effect';\nimport { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport type HttpRequestListener = (req: IncomingMessage, res: ServerResponse) => void;\n\nexport interface ScopedHttpServerOptions<E> {\n\treadonly bindAddress: string;\n\treadonly port: number;\n\treadonly listener: HttpRequestListener;\n\treadonly onListenError: (cause: unknown) => E;\n}\n\nexport interface ScopedHttpServerHandle {\n\treadonly url: string;\n\treadonly server: Server;\n\treadonly close: () => Effect.Effect<void>;\n}\n\n/** Best-effort graceful close. `closeAllConnections()` drops idle\n * keepalive sockets so `close()` resolves; older Node versions\n * without `closeAllConnections` rely on `close()` alone. */\nexport const gracefulCloseHttpServer = (server: Server): Effect.Effect<void> =>\n\tEffect.callback<void>((resume) => {\n\t\ttry {\n\t\t\tserver.closeAllConnections();\n\t\t} catch {\n\t\t\t// Older Node versions don't expose closeAllConnections;\n\t\t\t// `close()` alone will still terminate.\n\t\t}\n\t\tserver.close(() => resume(Effect.void));\n\t});\n\nexport const listenScopedHttpServer = <E>(\n\toptions: ScopedHttpServerOptions<E>,\n): Effect.Effect<ScopedHttpServerHandle, E, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\t// `acquireRelease` pairs the bound server with its close finalizer\n\t\t// atomically: the moment `listen` resolves, the graceful-close\n\t\t// finalizer is registered, so an interruption between bind and\n\t\t// finalizer registration can no longer leak a listener holding the\n\t\t// port.\n\t\tconst server = yield* Effect.acquireRelease(\n\t\t\tEffect.tryPromise({\n\t\t\t\ttry: () =>\n\t\t\t\t\tnew Promise<Server>((resolve, reject) => {\n\t\t\t\t\t\tconst srv = createServer(options.listener);\n\t\t\t\t\t\tconst onError = (err: Error) => reject(err);\n\t\t\t\t\t\tsrv.once('error', onError);\n\t\t\t\t\t\tsrv.listen(options.port, options.bindAddress, () => {\n\t\t\t\t\t\t\tsrv.removeListener('error', onError);\n\t\t\t\t\t\t\tresolve(srv);\n\t\t\t\t\t\t});\n\t\t\t\t\t}),\n\t\t\t\tcatch: options.onListenError,\n\t\t\t}),\n\t\t\t(srv) => gracefulCloseHttpServer(srv).pipe(Effect.uninterruptible),\n\t\t);\n\n\t\treturn {\n\t\t\turl: `http://${options.bindAddress}:${options.port}`,\n\t\t\tserver,\n\t\t\tclose: () => gracefulCloseHttpServer(server),\n\t\t};\n\t});\n"],"mappings":";;;;;;AA8BA,MAAa,2BAA2B,WACvC,OAAO,UAAgB,WAAW;AACjC,KAAI;AACH,SAAO,qBAAqB;SACrB;AAIR,QAAO,YAAY,OAAO,OAAO,KAAK,CAAC;EACtC;AAEH,MAAa,0BACZ,YAEA,OAAO,IAAI,aAAa;CAMvB,MAAM,SAAS,OAAO,OAAO,eAC5B,OAAO,WAAW;EACjB,WACC,IAAI,SAAiB,SAAS,WAAW;GACxC,MAAM,MAAM,aAAa,QAAQ,SAAS;GAC1C,MAAM,WAAW,QAAe,OAAO,IAAI;AAC3C,OAAI,KAAK,SAAS,QAAQ;AAC1B,OAAI,OAAO,QAAQ,MAAM,QAAQ,mBAAmB;AACnD,QAAI,eAAe,SAAS,QAAQ;AACpC,YAAQ,IAAI;KACX;IACD;EACH,OAAO,QAAQ;EACf,CAAC,GACD,QAAQ,wBAAwB,IAAI,CAAC,KAAK,OAAO,gBAAgB,CAClE;AAED,QAAO;EACN,KAAK,UAAU,QAAQ,YAAY,GAAG,QAAQ;EAC9C;EACA,aAAa,wBAAwB,OAAO;EAC5C;EACA"}
@@ -0,0 +1,2 @@
1
+ import "./service.mjs";
2
+ export {};
@@ -0,0 +1,52 @@
1
+ import { Effect, Ref } from "effect";
2
+ //#region src/substrate/runtime/scoped-multimap/service.ts
3
+ /**
4
+ * Construct a fresh scoped multimap. Call this inside a Layer build
5
+ * effect (the registry's `Layer.effect` body); the returned ops close
6
+ * over a private `Ref` that lives for that Layer's scope.
7
+ *
8
+ * `register` is interruption-safe: the append + finalizer-wire pair is
9
+ * `uninterruptible`, so an interrupt arriving between the two can't
10
+ * leak an entry past scope close (mirrors `leaseBroker.tryAcquire`).
11
+ */
12
+ const makeScopedMultimap = () => Effect.gen(function* () {
13
+ const state = yield* Ref.make(/* @__PURE__ */ new Map());
14
+ const seqRef = yield* Ref.make(0);
15
+ const register = (items) => Effect.gen(function* () {
16
+ const seq = yield* Ref.updateAndGet(seqRef, (n) => n + 1);
17
+ yield* Ref.update(state, (current) => {
18
+ const next = new Map(current);
19
+ for (const item of items) {
20
+ const existing = next.get(item.key) ?? [];
21
+ next.set(item.key, [...existing, {
22
+ value: item.value,
23
+ seq
24
+ }]);
25
+ }
26
+ return next;
27
+ });
28
+ yield* Effect.addFinalizer((_exit) => Ref.update(state, (current) => {
29
+ const next = new Map(current);
30
+ for (const item of items) {
31
+ const existing = next.get(item.key);
32
+ if (!existing) continue;
33
+ const filtered = existing.filter((e) => e.seq !== seq);
34
+ if (filtered.length === 0) next.delete(item.key);
35
+ else next.set(item.key, filtered);
36
+ }
37
+ return next;
38
+ }));
39
+ return seq;
40
+ }).pipe(Effect.uninterruptible);
41
+ const entriesFor = (key) => Ref.get(state).pipe(Effect.map((current) => current.get(key) ?? []));
42
+ return {
43
+ register,
44
+ entriesFor,
45
+ snapshot: Ref.get(state),
46
+ keys: Ref.get(state).pipe(Effect.map((current) => [...current.keys()]))
47
+ };
48
+ });
49
+ //#endregion
50
+ export { makeScopedMultimap };
51
+
52
+ //# sourceMappingURL=service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.mjs","names":[],"sources":["../../../../src/substrate/runtime/scoped-multimap/service.ts"],"sourcesContent":["// Scoped seq-tagged multimap primitive.\n//\n// Three substrate registries — `StrategyRegistry`, `FormatterRegistry`,\n// `CapabilitySinks` — independently grew the same shape: a `Ref` of a\n// per-key LIST of seq-tagged entries, plus a per-registration scope\n// finalizer that drops the entries it added when the surrounding scope\n// closes. This module is the ONE place that shape lives.\n//\n// Why a per-key LIST tagged by a monotonic seq (rather than a single\n// value-per-key with prior-restore):\n//\n// - Parallel / sibling-scope safety. The naive \"remember the prior\n// value, restore it on close\" finalizer is only correct under\n// strict LIFO nesting. With sibling scopes it clobbers a still-live\n// registration: scope A installs `X`, sibling B overwrites `X`\n// (capturing A's value as its `prior`), then A closes first and its\n// finalizer — holding `prior = nothing` — DELETES `X`, dropping B's\n// live overlay. capability-sinks had exactly this bug.\n//\n// - The seq-tagged list makes every finalizer remove ONLY the entry\n// (or entries) it added — it never touches a newer registration for\n// the same key. \"Who wins right now\" is a pure function of the\n// surviving entries (highest seq = last-write-wins), so close order\n// no longer matters.\n//\n// The primitive deliberately stops at the storage + finalizer layer.\n// The \"winner\" policy differs per registry (priority+seq, non-null\n// formatter+seq, plain last-seq), so each call site folds the surviving\n// entries with its own rule over the snapshot this primitive exposes.\n//\n// Scope-local, like every substrate registry: the `Ref` is private to\n// the build effect, so it dies with the stack scope.\n\nimport { Effect, Ref, type Scope } from 'effect';\n\n/** One stored entry: the caller's `value` plus the monotonic `seq` the\n * multimap stamped it with. The `seq` is the identity the finalizer\n * drops on and the tiebreaker call sites fold on. */\nexport interface MultimapEntry<V> {\n\treadonly value: V;\n\treadonly seq: number;\n}\n\n/** A single `(key, value)` pair to register. A registration may carry\n * several pairs (formatter-registry contributes one tag-entry per\n * declared error tag); all pairs in one `register` call share one\n * `seq` and one finalizer. */\nexport interface MultimapItem<K extends string, V> {\n\treadonly key: K;\n\treadonly value: V;\n}\n\n/** Operations on a scoped seq-tagged multimap. Generic over `K`\n * (string-shaped, used as a Map key) and the opaque per-entry `V`. */\nexport interface ScopedMultimap<K extends string, V> {\n\t/** Append one or more `(key, value)` pairs under a single fresh\n\t * `seq`, and register a scope finalizer that drops exactly those\n\t * entries (by `seq`) on scope close. Returns the assigned `seq` so\n\t * callers that need to span-annotate or correlate can.\n\t *\n\t * Requires `Scope.Scope`: the finalizer lands on the caller's\n\t * scope, so the registration is reaped on that scope's close. */\n\treadonly register: (\n\t\titems: ReadonlyArray<MultimapItem<K, V>>,\n\t) => Effect.Effect<number, never, Scope.Scope>;\n\t/** Surviving entries under one key, in registration order\n\t * (ascending `seq`). Empty array when the key is absent. */\n\treadonly entriesFor: (key: K) => Effect.Effect<ReadonlyArray<MultimapEntry<V>>>;\n\t/** Full snapshot: every key mapped to its surviving entries. */\n\treadonly snapshot: Effect.Effect<ReadonlyMap<K, ReadonlyArray<MultimapEntry<V>>>>;\n\t/** Keys with at least one surviving entry. */\n\treadonly keys: Effect.Effect<ReadonlyArray<K>>;\n}\n\ntype State<K extends string, V> = ReadonlyMap<K, ReadonlyArray<MultimapEntry<V>>>;\n\n/**\n * Construct a fresh scoped multimap. Call this inside a Layer build\n * effect (the registry's `Layer.effect` body); the returned ops close\n * over a private `Ref` that lives for that Layer's scope.\n *\n * `register` is interruption-safe: the append + finalizer-wire pair is\n * `uninterruptible`, so an interrupt arriving between the two can't\n * leak an entry past scope close (mirrors `leaseBroker.tryAcquire`).\n */\nexport const makeScopedMultimap = <K extends string, V>(): Effect.Effect<ScopedMultimap<K, V>> =>\n\tEffect.gen(function* () {\n\t\tconst state = yield* Ref.make<State<K, V>>(new Map());\n\t\tconst seqRef = yield* Ref.make(0);\n\n\t\tconst register: ScopedMultimap<K, V>['register'] = (items) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst seq = yield* Ref.updateAndGet(seqRef, (n) => n + 1);\n\t\t\t\tyield* Ref.update(state, (current) => {\n\t\t\t\t\tconst next = new Map(current);\n\t\t\t\t\tfor (const item of items) {\n\t\t\t\t\t\tconst existing = next.get(item.key) ?? [];\n\t\t\t\t\t\tnext.set(item.key, [...existing, { value: item.value, seq }]);\n\t\t\t\t\t}\n\t\t\t\t\treturn next;\n\t\t\t\t});\n\t\t\t\t// Drop-by-seq finalizer. Touches only the entries THIS\n\t\t\t\t// registration added — never a newer registration for the\n\t\t\t\t// same key — so sibling-scope close order is irrelevant.\n\t\t\t\tyield* Effect.addFinalizer((_exit) =>\n\t\t\t\t\tRef.update(state, (current) => {\n\t\t\t\t\t\tconst next = new Map(current);\n\t\t\t\t\t\tfor (const item of items) {\n\t\t\t\t\t\t\tconst existing = next.get(item.key);\n\t\t\t\t\t\t\tif (!existing) continue;\n\t\t\t\t\t\t\tconst filtered = existing.filter((e) => e.seq !== seq);\n\t\t\t\t\t\t\tif (filtered.length === 0) next.delete(item.key);\n\t\t\t\t\t\t\telse next.set(item.key, filtered);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn seq;\n\t\t\t}).pipe(Effect.uninterruptible);\n\n\t\tconst entriesFor: ScopedMultimap<K, V>['entriesFor'] = (key) =>\n\t\t\tRef.get(state).pipe(Effect.map((current) => current.get(key) ?? []));\n\n\t\tconst snapshot: ScopedMultimap<K, V>['snapshot'] = Ref.get(state);\n\n\t\tconst keys: ScopedMultimap<K, V>['keys'] = Ref.get(state).pipe(\n\t\t\tEffect.map((current) => [...current.keys()]),\n\t\t);\n\n\t\treturn { register, entriesFor, snapshot, keys } as const;\n\t});\n"],"mappings":";;;;;;;;;;;AAqFA,MAAa,2BACZ,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,IAAI,qBAAkB,IAAI,KAAK,CAAC;CACrD,MAAM,SAAS,OAAO,IAAI,KAAK,EAAE;CAEjC,MAAM,YAA8C,UACnD,OAAO,IAAI,aAAa;EACvB,MAAM,MAAM,OAAO,IAAI,aAAa,SAAS,MAAM,IAAI,EAAE;AACzD,SAAO,IAAI,OAAO,QAAQ,YAAY;GACrC,MAAM,OAAO,IAAI,IAAI,QAAQ;AAC7B,QAAK,MAAM,QAAQ,OAAO;IACzB,MAAM,WAAW,KAAK,IAAI,KAAK,IAAI,IAAI,EAAE;AACzC,SAAK,IAAI,KAAK,KAAK,CAAC,GAAG,UAAU;KAAE,OAAO,KAAK;KAAO;KAAK,CAAC,CAAC;;AAE9D,UAAO;IACN;AAIF,SAAO,OAAO,cAAc,UAC3B,IAAI,OAAO,QAAQ,YAAY;GAC9B,MAAM,OAAO,IAAI,IAAI,QAAQ;AAC7B,QAAK,MAAM,QAAQ,OAAO;IACzB,MAAM,WAAW,KAAK,IAAI,KAAK,IAAI;AACnC,QAAI,CAAC,SAAU;IACf,MAAM,WAAW,SAAS,QAAQ,MAAM,EAAE,QAAQ,IAAI;AACtD,QAAI,SAAS,WAAW,EAAG,MAAK,OAAO,KAAK,IAAI;QAC3C,MAAK,IAAI,KAAK,KAAK,SAAS;;AAElC,UAAO;IACN,CACF;AACD,SAAO;GACN,CAAC,KAAK,OAAO,gBAAgB;CAEhC,MAAM,cAAkD,QACvD,IAAI,IAAI,MAAM,CAAC,KAAK,OAAO,KAAK,YAAY,QAAQ,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;AAQrE,QAAO;EAAE;EAAU;EAAY,UANoB,IAAI,IAAI,MAMpB;EAAE,MAJE,IAAI,IAAI,MAAM,CAAC,KACzD,OAAO,KAAK,YAAY,CAAC,GAAG,QAAQ,MAAM,CAAC,CAAC,CAGA;EAAE;EAC9C"}
@@ -0,0 +1,2 @@
1
+ import "./service.mjs";
2
+ export {};
@@ -40,7 +40,7 @@ var ScopedRefMapKeyMissingError = class extends Schema.TaggedErrorClass()("Scope
40
40
  * ```
41
41
  */
42
42
  const defineScopedRefMap = (name) => {
43
- const serviceId = `@devstack-rewrite/substrate/ScopedRefMap/${name}`;
43
+ const serviceId = `@devstack/substrate/ScopedRefMap/${name}`;
44
44
  class Service extends Context.Service()(serviceId) {}
45
45
  const layer = Layer.effect(Service, Effect.gen(function* () {
46
46
  const ref = yield* SubscriptionRef.make([]);
@@ -78,6 +78,6 @@ const defineScopedRefMap = (name) => {
78
78
  };
79
79
  };
80
80
  //#endregion
81
- export { defineScopedRefMap };
81
+ export { ScopedRefMapKeyMissingError, defineScopedRefMap };
82
82
 
83
83
  //# sourceMappingURL=service.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.mjs","names":[],"sources":["../../../../src/substrate/runtime/scoped-ref-map/service.ts"],"sourcesContent":["// Generic scoped Ref-Map registry primitive.\n//\n// Architecture (ARCHITECTURE.md § Substrate primitives roster /\n// § Substrate name-blindness): a name-blind, per-stack-scoped\n// in-memory `K -> V` lookup table. Substrate exposes ONLY the\n// generic primitive; L2 plugins (Sui-coin, Move-package, future\n// chain plugins) instantiate it with their domain-specific\n// `K` and `V` shapes to author their own typed Context.Service.\n//\n// Why the factory `defineScopedRefMap<K, V>(name)` shape rather\n// than a single `ScopedRefMapService` tag:\n//\n// - One service per plugin domain — `PackageRegistry`,\n// `CoinRegistry`, etc. — gives each plugin its own typed\n// tag instead of every consumer reaching into a single map\n// and narrowing.\n// - Substrate stays name-blind: it doesn't know `coin` or\n// `package`; it only knows \"give me a Layer + Service for\n// `<K, V>`\". The plugin chooses the name.\n// - The substrate Service-class identity is the namespace —\n// two `defineScopedRefMap('Foo')` and `defineScopedRefMap('Bar')`\n// calls return distinct services that can coexist in the\n// same scope.\n//\n// Lifetime: each instantiated service is materialized by a\n// Layer that lives for the stack scope. When the scope closes,\n// the in-memory `SubscriptionRef` drops with it — the ref is\n// closure-private to the Layer's build effect, so the GC\n// reclaims it once no subscribers hold the stream.\n\nimport { Context, Effect, Layer, Schema, Stream, SubscriptionRef } from 'effect';\n\n/** Lookup failure for a missing key. Schema-tagged so consumers\n * may `Effect.catchTag('ScopedRefMapKeyMissingError', ...)` and\n * the cascade-formatter can render it without importing the class. */\nexport class ScopedRefMapKeyMissingError extends Schema.TaggedErrorClass<ScopedRefMapKeyMissingError>()(\n\t'ScopedRefMapKeyMissingError',\n\t{\n\t\tregistryName: Schema.String,\n\t\tkey: Schema.String,\n\t},\n) {}\n\n/** Operations on a scoped `K -> V` ref-map. Generic over `K`\n * (constrained to `string`-shaped brands so it can be used as\n * a Map key) and `V` (fully opaque to substrate). */\nexport interface ScopedRefMap<K extends string, V> {\n\t/** Insert / overwrite. Last-write-wins on `K`. */\n\treadonly set: (key: K, value: V) => Effect.Effect<void>;\n\t/** Strict lookup. Fails with `ScopedRefMapKeyMissingError`\n\t * when the key isn't present. */\n\treadonly get: (key: K) => Effect.Effect<V, ScopedRefMapKeyMissingError>;\n\t/** Non-failing lookup — `null` when absent. */\n\treadonly find: (key: K) => Effect.Effect<V | null>;\n\t/** Presence check without an error projection. */\n\treadonly has: (key: K) => Effect.Effect<boolean>;\n\t/** Snapshot of all `(key, value)` pairs. Iteration order is\n\t * insertion order. */\n\treadonly entries: () => Effect.Effect<ReadonlyArray<readonly [K, V]>>;\n\t/** Stream of full-snapshot states. Each emission is the\n\t * current `entries` array; consumers diff if they need\n\t * incremental updates. */\n\treadonly changes: Stream.Stream<ReadonlyArray<readonly [K, V]>>;\n}\n\n/**\n * Factory: declare a typed `K -> V` scoped ref-map service.\n *\n * The `name` becomes both the human-readable registry name (used\n * in `ScopedRefMapKeyMissingError.registryName`) and the\n * Context.Service identifier (prefixed with the substrate\n * namespace). Each call returns a fresh Service class; calling\n * twice with the same name produces two distinct services\n * (Context.Service identity is per-class, not per-id-string —\n * the id string is a debugging aid).\n *\n * Return shape — typed via inference so the inner Service class's\n * identity flows through to callers:\n * - `Service` — the `Context.Service` tag class. Plugin authors\n * yield this from their `acquire` body via `yield* MyRegistry.Service`.\n * - `layer` — scope-bound Layer constructing one ref-map per\n * stack scope.\n * - `changes` — stream helper mirroring `routesStream(router)`.\n *\n * Example (in an L2 plugin):\n *\n * ```ts\n * const PackageRegistry = defineScopedRefMap<PackageKey, PackageRecord>('PackageRegistry');\n *\n * // In the plugin's acquire body:\n * const registry = yield* PackageRegistry.Service;\n * yield* registry.set(name, resolved);\n *\n * // In the boot Layer:\n * Layer.mergeAll(PackageRegistry.layer, ...)\n * ```\n */\nexport const defineScopedRefMap = <K extends string, V>(name: string) => {\n\tconst serviceId = `@devstack-rewrite/substrate/ScopedRefMap/${name}`;\n\n\tclass Service extends Context.Service<Service, ScopedRefMap<K, V>>()(serviceId) {}\n\n\tconst layer: Layer.Layer<Service> = Layer.effect(\n\t\tService,\n\t\tEffect.gen(function* () {\n\t\t\tconst ref = yield* SubscriptionRef.make<ReadonlyArray<readonly [K, V]>>([]);\n\n\t\t\tconst set: ScopedRefMap<K, V>['set'] = (key, value) =>\n\t\t\t\tSubscriptionRef.update(ref, (current) => {\n\t\t\t\t\tconst filtered = current.filter(([k]) => k !== key);\n\t\t\t\t\treturn [...filtered, [key, value] as const];\n\t\t\t\t});\n\n\t\t\tconst find: ScopedRefMap<K, V>['find'] = (key) =>\n\t\t\t\tSubscriptionRef.get(ref).pipe(\n\t\t\t\t\tEffect.map((current) => {\n\t\t\t\t\t\tconst hit = current.find(([k]) => k === key);\n\t\t\t\t\t\treturn hit ? hit[1] : null;\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tconst get: ScopedRefMap<K, V>['get'] = (key) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst value = yield* find(key);\n\t\t\t\t\tif (value === null) {\n\t\t\t\t\t\treturn yield* new ScopedRefMapKeyMissingError({\n\t\t\t\t\t\t\tregistryName: name,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\n\t\t\tconst has: ScopedRefMap<K, V>['has'] = (key) =>\n\t\t\t\tSubscriptionRef.get(ref).pipe(Effect.map((current) => current.some(([k]) => k === key)));\n\n\t\t\tconst entries: ScopedRefMap<K, V>['entries'] = () => SubscriptionRef.get(ref);\n\n\t\t\treturn Service.of({\n\t\t\t\tset,\n\t\t\t\tget,\n\t\t\t\tfind,\n\t\t\t\thas,\n\t\t\t\tentries,\n\t\t\t\tchanges: SubscriptionRef.changes(ref),\n\t\t\t});\n\t\t}),\n\t);\n\n\tconst changes = (svc: ScopedRefMap<K, V>): Stream.Stream<ReadonlyArray<readonly [K, V]>> =>\n\t\tsvc.changes;\n\n\treturn {\n\t\tService,\n\t\tlayer,\n\t\tchanges,\n\t} as const;\n};\n"],"mappings":";;;;;AAmCA,IAAa,8BAAb,cAAiD,OAAO,kBAA+C,CACtG,+BACA;CACC,cAAc,OAAO;CACrB,KAAK,OAAO;CACZ,CACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDF,MAAa,sBAA2C,SAAiB;CACxE,MAAM,YAAY,4CAA4C;CAE9D,MAAM,gBAAgB,QAAQ,SAAsC,CAAC,UAAU,CAAC;CAEhF,MAAM,QAA8B,MAAM,OACzC,SACA,OAAO,IAAI,aAAa;EACvB,MAAM,MAAM,OAAO,gBAAgB,KAAqC,EAAE,CAAC;EAE3E,MAAM,OAAkC,KAAK,UAC5C,gBAAgB,OAAO,MAAM,YAAY;AAExC,UAAO,CAAC,GADS,QAAQ,QAAQ,CAAC,OAAO,MAAM,IAC5B,EAAE,CAAC,KAAK,MAAM,CAAU;IAC1C;EAEH,MAAM,QAAoC,QACzC,gBAAgB,IAAI,IAAI,CAAC,KACxB,OAAO,KAAK,YAAY;GACvB,MAAM,MAAM,QAAQ,MAAM,CAAC,OAAO,MAAM,IAAI;AAC5C,UAAO,MAAM,IAAI,KAAK;IACrB,CACF;EAEF,MAAM,OAAkC,QACvC,OAAO,IAAI,aAAa;GACvB,MAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,OAAI,UAAU,KACb,QAAO,OAAO,IAAI,4BAA4B;IAC7C,cAAc;IACd;IACA,CAAC;AAEH,UAAO;IACN;EAEH,MAAM,OAAkC,QACvC,gBAAgB,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,YAAY,QAAQ,MAAM,CAAC,OAAO,MAAM,IAAI,CAAC,CAAC;EAEzF,MAAM,gBAA+C,gBAAgB,IAAI,IAAI;AAE7E,SAAO,QAAQ,GAAG;GACjB;GACA;GACA;GACA;GACA;GACA,SAAS,gBAAgB,QAAQ,IAAI;GACrC,CAAC;GACD,CACF;CAED,MAAM,WAAW,QAChB,IAAI;AAEL,QAAO;EACN;EACA;EACA;EACA"}
1
+ {"version":3,"file":"service.mjs","names":[],"sources":["../../../../src/substrate/runtime/scoped-ref-map/service.ts"],"sourcesContent":["// Generic scoped Ref-Map registry primitive.\n//\n// Architecture (ARCHITECTURE.md § Substrate primitives roster /\n// § Substrate name-blindness): a name-blind, per-stack-scoped\n// in-memory `K -> V` lookup table. Substrate exposes ONLY the\n// generic primitive; L2 plugins (Sui-coin, Move-package, future\n// chain plugins) instantiate it with their domain-specific\n// `K` and `V` shapes to author their own typed Context.Service.\n//\n// Why the factory `defineScopedRefMap<K, V>(name)` shape rather\n// than a single `ScopedRefMapService` tag:\n//\n// - One service per plugin domain — `PackageRegistry`,\n// `CoinRegistry`, etc. — gives each plugin its own typed\n// tag instead of every consumer reaching into a single map\n// and narrowing.\n// - Substrate stays name-blind: it doesn't know `coin` or\n// `package`; it only knows \"give me a Layer + Service for\n// `<K, V>`\". The plugin chooses the name.\n// - The substrate Service-class identity is the namespace —\n// two `defineScopedRefMap('Foo')` and `defineScopedRefMap('Bar')`\n// calls return distinct services that can coexist in the\n// same scope.\n//\n// Lifetime: each instantiated service is materialized by a\n// Layer that lives for the stack scope. When the scope closes,\n// the in-memory `SubscriptionRef` drops with it — the ref is\n// closure-private to the Layer's build effect, so the GC\n// reclaims it once no subscribers hold the stream.\n\nimport { Context, Effect, Layer, Schema, Stream, SubscriptionRef } from 'effect';\n\n/** Lookup failure for a missing key. Schema-tagged so consumers\n * may `Effect.catchTag('ScopedRefMapKeyMissingError', ...)` and\n * the cascade-formatter can render it without importing the class. */\nexport class ScopedRefMapKeyMissingError extends Schema.TaggedErrorClass<ScopedRefMapKeyMissingError>()(\n\t'ScopedRefMapKeyMissingError',\n\t{\n\t\tregistryName: Schema.String,\n\t\tkey: Schema.String,\n\t},\n) {}\n\n/** Operations on a scoped `K -> V` ref-map. Generic over `K`\n * (constrained to `string`-shaped brands so it can be used as\n * a Map key) and `V` (fully opaque to substrate). */\nexport interface ScopedRefMap<K extends string, V> {\n\t/** Insert / overwrite. Last-write-wins on `K`. */\n\treadonly set: (key: K, value: V) => Effect.Effect<void>;\n\t/** Strict lookup. Fails with `ScopedRefMapKeyMissingError`\n\t * when the key isn't present. */\n\treadonly get: (key: K) => Effect.Effect<V, ScopedRefMapKeyMissingError>;\n\t/** Non-failing lookup — `null` when absent. */\n\treadonly find: (key: K) => Effect.Effect<V | null>;\n\t/** Presence check without an error projection. */\n\treadonly has: (key: K) => Effect.Effect<boolean>;\n\t/** Snapshot of all `(key, value)` pairs. Iteration order is\n\t * insertion order. */\n\treadonly entries: () => Effect.Effect<ReadonlyArray<readonly [K, V]>>;\n\t/** Stream of full-snapshot states. Each emission is the\n\t * current `entries` array; consumers diff if they need\n\t * incremental updates. */\n\treadonly changes: Stream.Stream<ReadonlyArray<readonly [K, V]>>;\n}\n\n/**\n * Factory: declare a typed `K -> V` scoped ref-map service.\n *\n * The `name` becomes both the human-readable registry name (used\n * in `ScopedRefMapKeyMissingError.registryName`) and the\n * Context.Service identifier (prefixed with the substrate\n * namespace). Each call returns a fresh Service class; calling\n * twice with the same name produces two distinct services\n * (Context.Service identity is per-class, not per-id-string —\n * the id string is a debugging aid).\n *\n * Return shape — typed via inference so the inner Service class's\n * identity flows through to callers:\n * - `Service` — the `Context.Service` tag class. Plugin authors\n * yield this from their `acquire` body via `yield* MyRegistry.Service`.\n * - `layer` — scope-bound Layer constructing one ref-map per\n * stack scope.\n * - `changes` — stream helper mirroring `routesStream(router)`.\n *\n * Example (in an L2 plugin):\n *\n * ```ts\n * const PackageRegistry = defineScopedRefMap<PackageKey, PackageRecord>('PackageRegistry');\n *\n * // In the plugin's acquire body:\n * const registry = yield* PackageRegistry.Service;\n * yield* registry.set(name, resolved);\n *\n * // In the boot Layer:\n * Layer.mergeAll(PackageRegistry.layer, ...)\n * ```\n */\nexport const defineScopedRefMap = <K extends string, V>(name: string) => {\n\tconst serviceId = `@devstack/substrate/ScopedRefMap/${name}`;\n\n\tclass Service extends Context.Service<Service, ScopedRefMap<K, V>>()(serviceId) {}\n\n\tconst layer: Layer.Layer<Service> = Layer.effect(\n\t\tService,\n\t\tEffect.gen(function* () {\n\t\t\tconst ref = yield* SubscriptionRef.make<ReadonlyArray<readonly [K, V]>>([]);\n\n\t\t\tconst set: ScopedRefMap<K, V>['set'] = (key, value) =>\n\t\t\t\tSubscriptionRef.update(ref, (current) => {\n\t\t\t\t\tconst filtered = current.filter(([k]) => k !== key);\n\t\t\t\t\treturn [...filtered, [key, value] as const];\n\t\t\t\t});\n\n\t\t\tconst find: ScopedRefMap<K, V>['find'] = (key) =>\n\t\t\t\tSubscriptionRef.get(ref).pipe(\n\t\t\t\t\tEffect.map((current) => {\n\t\t\t\t\t\tconst hit = current.find(([k]) => k === key);\n\t\t\t\t\t\treturn hit ? hit[1] : null;\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tconst get: ScopedRefMap<K, V>['get'] = (key) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst value = yield* find(key);\n\t\t\t\t\tif (value === null) {\n\t\t\t\t\t\treturn yield* new ScopedRefMapKeyMissingError({\n\t\t\t\t\t\t\tregistryName: name,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\n\t\t\tconst has: ScopedRefMap<K, V>['has'] = (key) =>\n\t\t\t\tSubscriptionRef.get(ref).pipe(Effect.map((current) => current.some(([k]) => k === key)));\n\n\t\t\tconst entries: ScopedRefMap<K, V>['entries'] = () => SubscriptionRef.get(ref);\n\n\t\t\treturn Service.of({\n\t\t\t\tset,\n\t\t\t\tget,\n\t\t\t\tfind,\n\t\t\t\thas,\n\t\t\t\tentries,\n\t\t\t\tchanges: SubscriptionRef.changes(ref),\n\t\t\t});\n\t\t}),\n\t);\n\n\tconst changes = (svc: ScopedRefMap<K, V>): Stream.Stream<ReadonlyArray<readonly [K, V]>> =>\n\t\tsvc.changes;\n\n\treturn {\n\t\tService,\n\t\tlayer,\n\t\tchanges,\n\t} as const;\n};\n"],"mappings":";;;;;AAmCA,IAAa,8BAAb,cAAiD,OAAO,kBAA+C,CACtG,+BACA;CACC,cAAc,OAAO;CACrB,KAAK,OAAO;CACZ,CACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDF,MAAa,sBAA2C,SAAiB;CACxE,MAAM,YAAY,oCAAoC;CAEtD,MAAM,gBAAgB,QAAQ,SAAsC,CAAC,UAAU,CAAC;CAEhF,MAAM,QAA8B,MAAM,OACzC,SACA,OAAO,IAAI,aAAa;EACvB,MAAM,MAAM,OAAO,gBAAgB,KAAqC,EAAE,CAAC;EAE3E,MAAM,OAAkC,KAAK,UAC5C,gBAAgB,OAAO,MAAM,YAAY;AAExC,UAAO,CAAC,GADS,QAAQ,QAAQ,CAAC,OAAO,MAAM,IAC5B,EAAE,CAAC,KAAK,MAAM,CAAU;IAC1C;EAEH,MAAM,QAAoC,QACzC,gBAAgB,IAAI,IAAI,CAAC,KACxB,OAAO,KAAK,YAAY;GACvB,MAAM,MAAM,QAAQ,MAAM,CAAC,OAAO,MAAM,IAAI;AAC5C,UAAO,MAAM,IAAI,KAAK;IACrB,CACF;EAEF,MAAM,OAAkC,QACvC,OAAO,IAAI,aAAa;GACvB,MAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,OAAI,UAAU,KACb,QAAO,OAAO,IAAI,4BAA4B;IAC7C,cAAc;IACd;IACA,CAAC;AAEH,UAAO;IACN;EAEH,MAAM,OAAkC,QACvC,gBAAgB,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,YAAY,QAAQ,MAAM,CAAC,OAAO,MAAM,IAAI,CAAC,CAAC;EAEzF,MAAM,gBAA+C,gBAAgB,IAAI,IAAI;AAE7E,SAAO,QAAQ,GAAG;GACjB;GACA;GACA;GACA;GACA;GACA,SAAS,gBAAgB,QAAQ,IAAI;GACrC,CAAC;GACD,CACF;CAED,MAAM,WAAW,QAChB,IAAI;AAEL,QAAO;EACN;EACA;EACA;EACA"}