@mysten-incubation/devstack 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (858) hide show
  1. package/README.md +6 -3
  2. package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
  3. package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
  4. package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
  5. package/dashboard-ui/index.html +2 -2
  6. package/dist/api/define-capabilities.d.mts +1 -20
  7. package/dist/api/define-capabilities.mjs +15 -22
  8. package/dist/api/define-capabilities.mjs.map +1 -1
  9. package/dist/api/define-devstack-with.d.mts +7 -1
  10. package/dist/api/define-devstack-with.mjs.map +1 -1
  11. package/dist/api/define-devstack.mjs.map +1 -1
  12. package/dist/api/define-plugin.d.mts +2 -1
  13. package/dist/api/inference-network.d.mts +31 -17
  14. package/dist/api/inference-network.mjs +40 -43
  15. package/dist/api/inference-network.mjs.map +1 -1
  16. package/dist/api/load-config.mjs +88 -0
  17. package/dist/api/load-config.mjs.map +1 -0
  18. package/dist/api/mode-narrowed-factory.d.mts +1 -1
  19. package/dist/api/mode-narrowed-factory.mjs.map +1 -1
  20. package/dist/api/run-stack-internal.mjs +202 -0
  21. package/dist/api/run-stack-internal.mjs.map +1 -0
  22. package/dist/api/run-stack.d.mts +82 -31
  23. package/dist/api/run-stack.mjs +22 -141
  24. package/dist/api/run-stack.mjs.map +1 -1
  25. package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
  26. package/dist/build-integrations/dapp-kit/index.mjs +58 -0
  27. package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
  28. package/dist/build-integrations/playwright/config.d.mts +1 -30
  29. package/dist/build-integrations/playwright/config.mjs +1 -27
  30. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  31. package/dist/build-integrations/playwright/errors.d.mts +4 -7
  32. package/dist/build-integrations/playwright/errors.mjs.map +1 -1
  33. package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
  34. package/dist/build-integrations/playwright/global-setup.mjs +142 -218
  35. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  36. package/dist/build-integrations/playwright/index.d.mts +2 -2
  37. package/dist/build-integrations/playwright/index.mjs +2 -2
  38. package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
  39. package/dist/build-integrations/playwright/stack-context.mjs +4 -2
  40. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  41. package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
  42. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  43. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  44. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
  45. package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
  46. package/dist/build-integrations/runtime/discover.d.mts +6 -4
  47. package/dist/build-integrations/runtime/discover.mjs +15 -4
  48. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  49. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/errors.mjs.map +1 -1
  51. package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
  52. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  53. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
  54. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
  55. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
  57. package/dist/build-integrations/vite/index.d.mts +84 -19
  58. package/dist/build-integrations/vite/index.mjs +203 -28
  59. package/dist/build-integrations/vite/index.mjs.map +1 -1
  60. package/dist/build-integrations/vitest/config.d.mts +20 -2
  61. package/dist/build-integrations/vitest/config.mjs +16 -4
  62. package/dist/build-integrations/vitest/config.mjs.map +1 -1
  63. package/dist/build-integrations/vitest/env.d.mts +18 -10
  64. package/dist/build-integrations/vitest/env.mjs +11 -10
  65. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  66. package/dist/build-integrations/vitest/errors.d.mts +7 -11
  67. package/dist/build-integrations/vitest/errors.mjs +3 -4
  68. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  69. package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
  70. package/dist/build-integrations/vitest/global-setup.mjs +156 -0
  71. package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
  72. package/dist/build-integrations/vitest/index.d.mts +3 -2
  73. package/dist/build-integrations/vitest/index.mjs +3 -2
  74. package/dist/build-integrations/vitest/setup.mjs +2 -2
  75. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  76. package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
  77. package/dist/build-integrations/vitest/stack-context.mjs +3 -2
  78. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  79. package/dist/cli/bail.mjs.map +1 -1
  80. package/dist/cli/doctor-probes.mjs +1 -3
  81. package/dist/cli/doctor-probes.mjs.map +1 -1
  82. package/dist/cli/main.d.mts +23 -1
  83. package/dist/cli/main.mjs +63 -8
  84. package/dist/cli/main.mjs.map +1 -1
  85. package/dist/cli/prune-direct.mjs.map +1 -1
  86. package/dist/cli/snapshot-reader.mjs.map +1 -1
  87. package/dist/cli/up-lifecycle.mjs.map +1 -1
  88. package/dist/cli/wirings/apply.mjs +28 -21
  89. package/dist/cli/wirings/apply.mjs.map +1 -1
  90. package/dist/cli/wirings/codegen.mjs +108 -0
  91. package/dist/cli/wirings/codegen.mjs.map +1 -0
  92. package/dist/cli/wirings/config-loader.mjs +12 -62
  93. package/dist/cli/wirings/config-loader.mjs.map +1 -1
  94. package/dist/cli/wirings/dump-ids.mjs +86 -0
  95. package/dist/cli/wirings/dump-ids.mjs.map +1 -0
  96. package/dist/cli/wirings/engine-command.mjs +1 -1
  97. package/dist/cli/wirings/engine-command.mjs.map +1 -1
  98. package/dist/cli/wirings/identity.mjs +2 -2
  99. package/dist/cli/wirings/identity.mjs.map +1 -1
  100. package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
  101. package/dist/cli/wirings/read-devstack-version.mjs +17 -0
  102. package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
  103. package/dist/cli/wirings/snapshot.mjs +27 -34
  104. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  105. package/dist/cli/wirings/up-ipc.mjs +147 -0
  106. package/dist/cli/wirings/up-ipc.mjs.map +1 -0
  107. package/dist/cli/wirings/up.mjs +218 -198
  108. package/dist/cli/wirings/up.mjs.map +1 -1
  109. package/dist/cli/wirings/wipe.mjs +1 -1
  110. package/dist/cli/wirings/wipe.mjs.map +1 -1
  111. package/dist/contracts/chain-probe.d.mts +1 -1
  112. package/dist/contracts/chain-probe.mjs +1 -1
  113. package/dist/contracts/chain-probe.mjs.map +1 -1
  114. package/dist/contracts/codegenable.d.mts +60 -6
  115. package/dist/contracts/codegenable.mjs +28 -0
  116. package/dist/contracts/codegenable.mjs.map +1 -0
  117. package/dist/contracts/config-bindings.mjs +162 -0
  118. package/dist/contracts/config-bindings.mjs.map +1 -0
  119. package/dist/contracts/container-runtime.d.mts +23 -17
  120. package/dist/contracts/plugin-expander.mjs.map +1 -1
  121. package/dist/contracts/snapshotable.d.mts +5 -7
  122. package/dist/contracts/wallet-protocol.d.mts +2 -5
  123. package/dist/contracts/wallet-protocol.mjs +2 -5
  124. package/dist/contracts/wallet-protocol.mjs.map +1 -1
  125. package/dist/index.d.mts +21 -26
  126. package/dist/index.mjs +8 -9
  127. package/dist/orchestrators/boot.d.mts +28 -0
  128. package/dist/orchestrators/boot.mjs +440 -0
  129. package/dist/orchestrators/boot.mjs.map +1 -0
  130. package/dist/orchestrators/codegen/bindings.d.mts +13 -1
  131. package/dist/orchestrators/codegen/bindings.mjs +23 -9
  132. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  133. package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
  134. package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
  135. package/dist/orchestrators/codegen/emit.mjs +1 -1
  136. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  137. package/dist/orchestrators/codegen/errors.mjs +21 -1
  138. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  139. package/dist/orchestrators/codegen/format.mjs +2 -0
  140. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  141. package/dist/orchestrators/codegen/gitignore.mjs +30 -11
  142. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/id-config.mjs +107 -0
  144. package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
  145. package/dist/orchestrators/codegen/output-location.mjs +23 -32
  146. package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/paths.mjs +8 -1
  148. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  150. package/dist/orchestrators/codegen/service.mjs +286 -58
  151. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  152. package/dist/orchestrators/layers.mjs +31 -0
  153. package/dist/orchestrators/layers.mjs.map +1 -0
  154. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
  155. package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
  156. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
  157. package/dist/orchestrators/network-options.d.mts +52 -0
  158. package/dist/orchestrators/network-options.mjs +43 -0
  159. package/dist/orchestrators/network-options.mjs.map +1 -0
  160. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  161. package/dist/orchestrators/router/cors.mjs.map +1 -1
  162. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  163. package/dist/orchestrators/router/errors.mjs.map +1 -1
  164. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  165. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  166. package/dist/orchestrators/router/profile.mjs +1 -1
  167. package/dist/orchestrators/router/profile.mjs.map +1 -1
  168. package/dist/orchestrators/router/service.d.mts +2 -2
  169. package/dist/orchestrators/router/service.mjs +12 -27
  170. package/dist/orchestrators/router/service.mjs.map +1 -1
  171. package/dist/orchestrators/router/traefik-container.mjs +1 -1
  172. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  173. package/dist/orchestrators/snapshot/capture.mjs +171 -195
  174. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  175. package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
  176. package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
  177. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  178. package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
  179. package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
  180. package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
  181. package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
  182. package/dist/orchestrators/snapshot/index.mjs +1 -4
  183. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  184. package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
  185. package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
  186. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
  187. package/dist/orchestrators/snapshot/prune.mjs +40 -31
  188. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  189. package/dist/orchestrators/snapshot/restore.mjs +221 -196
  190. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  191. package/dist/orchestrators/snapshot/service.mjs +72 -62
  192. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  193. package/dist/orchestrators/snapshot/wipe.mjs +67 -56
  194. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  195. package/dist/plugins/account/codegen.mjs +3 -0
  196. package/dist/plugins/account/codegen.mjs.map +1 -1
  197. package/dist/plugins/account/errors.d.mts +2 -2
  198. package/dist/plugins/account/errors.mjs +1 -4
  199. package/dist/plugins/account/errors.mjs.map +1 -1
  200. package/dist/plugins/account/funding.mjs +3 -27
  201. package/dist/plugins/account/funding.mjs.map +1 -1
  202. package/dist/plugins/account/index.d.mts +3 -8
  203. package/dist/plugins/account/index.mjs +71 -35
  204. package/dist/plugins/account/index.mjs.map +1 -1
  205. package/dist/plugins/account/keypair.d.mts +8 -7
  206. package/dist/plugins/account/keypair.mjs +5 -18
  207. package/dist/plugins/account/keypair.mjs.map +1 -1
  208. package/dist/plugins/account/lease.mjs.map +1 -1
  209. package/dist/plugins/account/registry.d.mts +1 -46
  210. package/dist/plugins/account/registry.mjs.map +1 -1
  211. package/dist/plugins/account/service.d.mts +43 -34
  212. package/dist/plugins/account/service.mjs +9 -54
  213. package/dist/plugins/account/service.mjs.map +1 -1
  214. package/dist/plugins/account/snapshot.mjs.map +1 -1
  215. package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
  216. package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
  217. package/dist/plugins/account/variants/signer.mjs.map +1 -1
  218. package/dist/plugins/action/discriminator.mjs.map +1 -1
  219. package/dist/plugins/action/errors.mjs +1 -4
  220. package/dist/plugins/action/errors.mjs.map +1 -1
  221. package/dist/plugins/action/execute.mjs +3 -4
  222. package/dist/plugins/action/execute.mjs.map +1 -1
  223. package/dist/plugins/action/index.d.mts +2 -2
  224. package/dist/plugins/action/index.mjs +7 -11
  225. package/dist/plugins/action/index.mjs.map +1 -1
  226. package/dist/plugins/action/service.d.mts +5 -7
  227. package/dist/plugins/action/service.mjs +2 -16
  228. package/dist/plugins/action/service.mjs.map +1 -1
  229. package/dist/plugins/coin/address-resolution.mjs.map +1 -1
  230. package/dist/plugins/coin/codegen.mjs +97 -16
  231. package/dist/plugins/coin/codegen.mjs.map +1 -1
  232. package/dist/plugins/coin/discovery.mjs.map +1 -1
  233. package/dist/plugins/coin/errors.mjs +1 -4
  234. package/dist/plugins/coin/errors.mjs.map +1 -1
  235. package/dist/plugins/coin/index.d.mts +4 -34
  236. package/dist/plugins/coin/index.mjs +47 -28
  237. package/dist/plugins/coin/index.mjs.map +1 -1
  238. package/dist/plugins/coin/metadata.d.mts +1 -0
  239. package/dist/plugins/coin/metadata.mjs +8 -9
  240. package/dist/plugins/coin/metadata.mjs.map +1 -1
  241. package/dist/plugins/coin/mint.mjs +7 -21
  242. package/dist/plugins/coin/mint.mjs.map +1 -1
  243. package/dist/plugins/coin/registry.mjs +33 -20
  244. package/dist/plugins/coin/registry.mjs.map +1 -1
  245. package/dist/plugins/coin/service.d.mts +1 -1
  246. package/dist/plugins/coin/service.mjs +1 -8
  247. package/dist/plugins/coin/service.mjs.map +1 -1
  248. package/dist/plugins/coin/snapshot.mjs.map +1 -1
  249. package/dist/plugins/coin/type-strings.mjs.map +1 -1
  250. package/dist/plugins/dashboard/domain.mjs +106 -167
  251. package/dist/plugins/dashboard/domain.mjs.map +1 -1
  252. package/dist/plugins/dashboard/index.mjs +13 -13
  253. package/dist/plugins/dashboard/index.mjs.map +1 -1
  254. package/dist/plugins/dashboard/origin-policy.mjs +3 -3
  255. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
  256. package/dist/plugins/dashboard/routable.mjs.map +1 -1
  257. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
  258. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
  259. package/dist/plugins/dashboard/schema/root.mjs +23 -44
  260. package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
  261. package/dist/plugins/dashboard/schema/types.mjs +37 -91
  262. package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
  263. package/dist/plugins/dashboard/schema.mjs.map +1 -1
  264. package/dist/plugins/dashboard/server.mjs.map +1 -1
  265. package/dist/plugins/deepbook/codegen.d.mts +12 -11
  266. package/dist/plugins/deepbook/codegen.mjs +108 -11
  267. package/dist/plugins/deepbook/codegen.mjs.map +1 -1
  268. package/dist/plugins/deepbook/deploy.mjs +7 -14
  269. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  270. package/dist/plugins/deepbook/errors.mjs +4 -2
  271. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  272. package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
  273. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  274. package/dist/plugins/deepbook/hash.mjs.map +1 -1
  275. package/dist/plugins/deepbook/index.d.mts +38 -34
  276. package/dist/plugins/deepbook/index.mjs +133 -64
  277. package/dist/plugins/deepbook/index.mjs.map +1 -1
  278. package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
  279. package/dist/plugins/deepbook/pyth/index.mjs +4 -8
  280. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  281. package/dist/plugins/deepbook/snapshot.mjs +0 -1
  282. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  283. package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
  284. package/dist/plugins/deepbook/types.d.mts +2 -1
  285. package/dist/plugins/deepbook/types.mjs.map +1 -1
  286. package/dist/plugins/faucet/dispatcher.d.mts +3 -3
  287. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  288. package/dist/plugins/faucet/errors.mjs.map +1 -1
  289. package/dist/plugins/faucet/http.mjs +2 -10
  290. package/dist/plugins/faucet/http.mjs.map +1 -1
  291. package/dist/plugins/faucet/index.mjs +0 -1
  292. package/dist/plugins/faucet/index.mjs.map +1 -1
  293. package/dist/plugins/host-service/errors.d.mts +1 -3
  294. package/dist/plugins/host-service/errors.mjs +1 -2
  295. package/dist/plugins/host-service/errors.mjs.map +1 -1
  296. package/dist/plugins/host-service/index.d.mts +1 -2
  297. package/dist/plugins/host-service/index.mjs +11 -11
  298. package/dist/plugins/host-service/index.mjs.map +1 -1
  299. package/dist/plugins/host-service/routable.mjs.map +1 -1
  300. package/dist/plugins/host-service/service.mjs +13 -13
  301. package/dist/plugins/host-service/service.mjs.map +1 -1
  302. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
  303. package/dist/plugins/internal/codegen-helpers.mjs +2 -0
  304. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
  305. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
  306. package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
  307. package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
  308. package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
  309. package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
  310. package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
  311. package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
  312. package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
  313. package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
  314. package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
  315. package/dist/plugins/package/build.mjs +2 -2
  316. package/dist/plugins/package/build.mjs.map +1 -1
  317. package/dist/plugins/package/codegen.d.mts +7 -14
  318. package/dist/plugins/package/codegen.mjs +187 -59
  319. package/dist/plugins/package/codegen.mjs.map +1 -1
  320. package/dist/plugins/package/dep-resolution.mjs +51 -3
  321. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  322. package/dist/plugins/package/errors.mjs +1 -4
  323. package/dist/plugins/package/errors.mjs.map +1 -1
  324. package/dist/plugins/package/git-source.d.mts +18 -0
  325. package/dist/plugins/package/git-source.mjs +119 -0
  326. package/dist/plugins/package/git-source.mjs.map +1 -0
  327. package/dist/plugins/package/index.d.mts +28 -19
  328. package/dist/plugins/package/index.mjs +107 -32
  329. package/dist/plugins/package/index.mjs.map +1 -1
  330. package/dist/plugins/package/mode-known.mjs +2 -2
  331. package/dist/plugins/package/mode-known.mjs.map +1 -1
  332. package/dist/plugins/package/mode-local.mjs +18 -35
  333. package/dist/plugins/package/mode-local.mjs.map +1 -1
  334. package/dist/plugins/package/publish-executor.mjs +13 -8
  335. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  336. package/dist/plugins/package/publish-output.d.mts +1 -11
  337. package/dist/plugins/package/publish-output.mjs +1 -9
  338. package/dist/plugins/package/publish-output.mjs.map +1 -1
  339. package/dist/plugins/package/registry.d.mts +1 -1
  340. package/dist/plugins/package/registry.mjs +26 -14
  341. package/dist/plugins/package/registry.mjs.map +1 -1
  342. package/dist/plugins/package/service.mjs.map +1 -1
  343. package/dist/plugins/package/snapshot.mjs.map +1 -1
  344. package/dist/plugins/router-entrypoints.mjs +1 -3
  345. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  346. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
  347. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  348. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
  349. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  350. package/dist/plugins/seal/codegen.d.mts +1 -5
  351. package/dist/plugins/seal/codegen.mjs +83 -12
  352. package/dist/plugins/seal/codegen.mjs.map +1 -1
  353. package/dist/plugins/seal/config-render.mjs +2 -6
  354. package/dist/plugins/seal/config-render.mjs.map +1 -1
  355. package/dist/plugins/seal/deploy.mjs +18 -29
  356. package/dist/plugins/seal/deploy.mjs.map +1 -1
  357. package/dist/plugins/seal/errors.d.mts +4 -5
  358. package/dist/plugins/seal/errors.mjs +1 -8
  359. package/dist/plugins/seal/errors.mjs.map +1 -1
  360. package/dist/plugins/seal/index.d.mts +7 -28
  361. package/dist/plugins/seal/index.mjs +69 -47
  362. package/dist/plugins/seal/index.mjs.map +1 -1
  363. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  364. package/dist/plugins/seal/key-server.mjs +1 -6
  365. package/dist/plugins/seal/key-server.mjs.map +1 -1
  366. package/dist/plugins/seal/keygen.mjs +2 -3
  367. package/dist/plugins/seal/keygen.mjs.map +1 -1
  368. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  369. package/dist/plugins/seal/mode/live.mjs +1 -1
  370. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  371. package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
  372. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  373. package/dist/plugins/seal/plugin-key.mjs.map +1 -1
  374. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  375. package/dist/plugins/seal/routable.mjs.map +1 -1
  376. package/dist/plugins/seal/service.mjs.map +1 -1
  377. package/dist/plugins/seal/snapshot.mjs +1 -2
  378. package/dist/plugins/seal/snapshot.mjs.map +1 -1
  379. package/dist/plugins/sui/auto-tick.mjs +5 -5
  380. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  381. package/dist/plugins/sui/chain-build-container.mjs +2 -2
  382. package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
  383. package/dist/plugins/sui/chain-probe.mjs +4 -4
  384. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  385. package/dist/plugins/sui/codegen.d.mts +9 -7
  386. package/dist/plugins/sui/codegen.mjs +49 -46
  387. package/dist/plugins/sui/codegen.mjs.map +1 -1
  388. package/dist/plugins/sui/errors.d.mts +1 -1
  389. package/dist/plugins/sui/errors.mjs +1 -9
  390. package/dist/plugins/sui/errors.mjs.map +1 -1
  391. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
  392. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
  393. package/dist/plugins/sui/exec/index.mjs.map +1 -0
  394. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
  395. package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
  396. package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
  397. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
  398. package/dist/plugins/sui/fork-orchestration.mjs +13 -23
  399. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  400. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  401. package/dist/plugins/sui/index.d.mts +34 -83
  402. package/dist/plugins/sui/index.mjs +200 -68
  403. package/dist/plugins/sui/index.mjs.map +1 -1
  404. package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
  405. package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
  406. package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
  407. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
  408. package/dist/plugins/sui/log-attrs.mjs +11 -0
  409. package/dist/plugins/sui/log-attrs.mjs.map +1 -0
  410. package/dist/plugins/sui/mode/external.mjs +4 -12
  411. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  412. package/dist/plugins/sui/mode/fork.mjs +19 -16
  413. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  414. package/dist/plugins/sui/mode/live.mjs +4 -17
  415. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  416. package/dist/plugins/sui/mode/local.d.mts +1 -0
  417. package/dist/plugins/sui/mode/local.mjs +203 -61
  418. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  419. package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
  420. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  421. package/dist/plugins/sui/mode/shared.d.mts +6 -7
  422. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  423. package/dist/plugins/sui/mode/spec.d.mts +23 -6
  424. package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
  425. package/dist/plugins/sui/move/index.mjs.map +1 -0
  426. package/dist/plugins/sui/move-summary-runner.mjs +8 -4
  427. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
  428. package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
  429. package/dist/plugins/sui/network-resolver.d.mts +6 -6
  430. package/dist/plugins/sui/routable.mjs.map +1 -1
  431. package/dist/plugins/sui/service.mjs +10 -6
  432. package/dist/plugins/sui/service.mjs.map +1 -1
  433. package/dist/plugins/sui/snapshot.mjs +10 -5
  434. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  435. package/dist/plugins/wallet/codegen.d.mts +8 -6
  436. package/dist/plugins/wallet/codegen.mjs +4 -10
  437. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  438. package/dist/plugins/wallet/errors.mjs +1 -4
  439. package/dist/plugins/wallet/errors.mjs.map +1 -1
  440. package/dist/plugins/wallet/index.d.mts +3 -6
  441. package/dist/plugins/wallet/index.mjs +16 -21
  442. package/dist/plugins/wallet/index.mjs.map +1 -1
  443. package/dist/plugins/wallet/origin-policy.mjs +3 -3
  444. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  445. package/dist/plugins/wallet/pairing.mjs +6 -24
  446. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  447. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  448. package/dist/plugins/wallet/routable.mjs.map +1 -1
  449. package/dist/plugins/wallet/server.mjs +17 -24
  450. package/dist/plugins/wallet/server.mjs.map +1 -1
  451. package/dist/plugins/wallet/service.d.mts +2 -2
  452. package/dist/plugins/wallet/service.mjs +4 -15
  453. package/dist/plugins/wallet/service.mjs.map +1 -1
  454. package/dist/plugins/wallet/snapshot.mjs.map +1 -1
  455. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
  456. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  457. package/dist/plugins/walrus/codegen.d.mts +2 -13
  458. package/dist/plugins/walrus/codegen.mjs +93 -28
  459. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  460. package/dist/plugins/walrus/deploy-paths.mjs +2 -3
  461. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  462. package/dist/plugins/walrus/deploy.mjs +26 -19
  463. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  464. package/dist/plugins/walrus/errors.mjs +1 -8
  465. package/dist/plugins/walrus/errors.mjs.map +1 -1
  466. package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
  467. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  468. package/dist/plugins/walrus/index.d.mts +13 -44
  469. package/dist/plugins/walrus/index.mjs +119 -122
  470. package/dist/plugins/walrus/index.mjs.map +1 -1
  471. package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
  472. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  473. package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
  474. package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
  475. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  476. package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
  477. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  478. package/dist/plugins/walrus/routable.mjs.map +1 -1
  479. package/dist/plugins/walrus/service.mjs.map +1 -1
  480. package/dist/plugins/walrus/snapshot.mjs +3 -3
  481. package/dist/plugins/walrus/snapshot.mjs.map +1 -1
  482. package/dist/plugins/walrus/storage-nodes.mjs +53 -14
  483. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  484. package/dist/plugins/walrus/wal-swap.mjs +4 -8
  485. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  486. package/dist/primitives/artifact-publisher.mjs.map +1 -1
  487. package/dist/primitives/cache.d.mts +1 -1
  488. package/dist/runtime/docker/client.mjs +47 -3
  489. package/dist/runtime/docker/client.mjs.map +1 -1
  490. package/dist/runtime/docker/container.mjs +37 -57
  491. package/dist/runtime/docker/container.mjs.map +1 -1
  492. package/dist/runtime/docker/errors.mjs.map +1 -1
  493. package/dist/runtime/docker/exec.mjs +2 -2
  494. package/dist/runtime/docker/exec.mjs.map +1 -1
  495. package/dist/runtime/docker/image.mjs +10 -11
  496. package/dist/runtime/docker/image.mjs.map +1 -1
  497. package/dist/runtime/docker/index.mjs +0 -1
  498. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
  499. package/dist/runtime/docker/inventory.mjs +9 -9
  500. package/dist/runtime/docker/inventory.mjs.map +1 -1
  501. package/dist/runtime/docker/labels.mjs +12 -1
  502. package/dist/runtime/docker/labels.mjs.map +1 -1
  503. package/dist/runtime/docker/network.mjs +6 -6
  504. package/dist/runtime/docker/network.mjs.map +1 -1
  505. package/dist/runtime/docker/render-run-args.mjs.map +1 -1
  506. package/dist/runtime/docker/service.mjs +31 -45
  507. package/dist/runtime/docker/service.mjs.map +1 -1
  508. package/dist/runtime/docker/sweep.mjs +14 -64
  509. package/dist/runtime/docker/sweep.mjs.map +1 -1
  510. package/dist/runtime/docker/volume.mjs +1 -1
  511. package/dist/runtime/docker/volume.mjs.map +1 -1
  512. package/dist/runtime/docker/wrap.mjs +14 -2
  513. package/dist/runtime/docker/wrap.mjs.map +1 -1
  514. package/dist/substrate/brand.d.mts +2 -5
  515. package/dist/substrate/brand.mjs +3 -2
  516. package/dist/substrate/brand.mjs.map +1 -1
  517. package/dist/substrate/cross-process.mjs +2 -16
  518. package/dist/substrate/cross-process.mjs.map +1 -1
  519. package/dist/substrate/event-time.mjs +0 -2
  520. package/dist/substrate/event-time.mjs.map +1 -1
  521. package/dist/substrate/events.d.mts +46 -16
  522. package/dist/substrate/identity.d.mts +11 -5
  523. package/dist/substrate/manifest.d.mts +33 -26
  524. package/dist/substrate/manifest.mjs +8 -3
  525. package/dist/substrate/manifest.mjs.map +1 -1
  526. package/dist/substrate/options.d.mts +33 -4
  527. package/dist/substrate/plugin-ctx.d.mts +70 -0
  528. package/dist/substrate/plugin-ctx.mjs +66 -0
  529. package/dist/substrate/plugin-ctx.mjs.map +1 -0
  530. package/dist/substrate/plugin.d.mts +46 -38
  531. package/dist/substrate/plugin.mjs +13 -9
  532. package/dist/substrate/plugin.mjs.map +1 -1
  533. package/dist/substrate/projection.d.mts +1 -1
  534. package/dist/substrate/runtime/atomic-write.mjs +3 -4
  535. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  536. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  537. package/dist/substrate/runtime/cache/service.mjs +50 -20
  538. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  539. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  540. package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
  541. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
  542. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
  543. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
  544. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  545. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  546. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  547. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
  548. package/dist/substrate/runtime/cross-process/index.mjs +0 -2
  549. package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
  550. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
  551. package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
  552. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  553. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
  554. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
  555. package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
  556. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  557. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
  558. package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
  559. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  560. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  561. package/dist/substrate/runtime/errors.mjs +1 -13
  562. package/dist/substrate/runtime/errors.mjs.map +1 -1
  563. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
  564. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
  565. package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
  566. package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
  567. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  568. package/dist/substrate/runtime/http-probe.d.mts +1 -3
  569. package/dist/substrate/runtime/http-probe.mjs.map +1 -1
  570. package/dist/substrate/runtime/index.mjs +1 -6
  571. package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
  572. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  573. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
  574. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  575. package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
  576. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
  577. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
  578. package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
  579. package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
  580. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
  581. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  582. package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
  583. package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
  584. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
  585. package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
  586. package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
  587. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  588. package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
  589. package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
  590. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
  591. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
  592. package/dist/substrate/runtime/managed-container.d.mts +5 -1
  593. package/dist/substrate/runtime/managed-container.mjs +8 -10
  594. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  595. package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
  596. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  597. package/dist/substrate/runtime/mode-errors.d.mts +1 -2
  598. package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
  599. package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
  600. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  601. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
  602. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  603. package/dist/substrate/runtime/observability/index.mjs +4 -6
  604. package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
  605. package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
  606. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
  607. package/dist/substrate/runtime/observability/logger.mjs +3 -3
  608. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  609. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
  610. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  611. package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
  612. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  613. package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
  614. package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
  615. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
  616. package/dist/substrate/runtime/paths.mjs +27 -9
  617. package/dist/substrate/runtime/paths.mjs.map +1 -1
  618. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
  619. package/dist/substrate/runtime/port-broker/service.mjs +10 -27
  620. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  621. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  622. package/dist/substrate/runtime/probes.d.mts +2 -3
  623. package/dist/substrate/runtime/probes.mjs.map +1 -1
  624. package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
  625. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  626. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  627. package/dist/substrate/runtime/projection/update.mjs +87 -11
  628. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  629. package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
  630. package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
  631. package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
  632. package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
  633. package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
  634. package/dist/substrate/runtime/reconcile/index.mjs +5 -0
  635. package/dist/substrate/runtime/reconcile/label.mjs +41 -0
  636. package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
  637. package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
  638. package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
  639. package/dist/substrate/runtime/retry-policy.d.mts +2 -3
  640. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  641. package/dist/substrate/runtime/routed-url.mjs.map +1 -1
  642. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  643. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  644. package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
  645. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  646. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
  647. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  648. package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
  649. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  650. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
  651. package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
  652. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
  653. package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
  654. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
  655. package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
  656. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
  657. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
  658. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
  659. package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
  660. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
  661. package/dist/substrate/runtime/supervisor/index.mjs +2 -0
  662. package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
  663. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
  664. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
  665. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
  666. package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
  667. package/dist/substrate/runtime/supervisor/state.mjs +1 -1
  668. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
  669. package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
  670. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
  671. package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
  672. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
  673. package/dist/substrate/runtime/tar/reader.mjs +216 -0
  674. package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
  675. package/dist/substrate/runtime/typed-env.mjs.map +1 -1
  676. package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
  677. package/dist/substrate/versioned-doc-sync.mjs +5 -5
  678. package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
  679. package/dist/surfaces/cli/command-tree.mjs +49 -7
  680. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  681. package/dist/surfaces/cli/commands/config.mjs +1 -1
  682. package/dist/surfaces/cli/commands/config.mjs.map +1 -1
  683. package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
  684. package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
  685. package/dist/surfaces/cli/commands/doctor.mjs +1 -1
  686. package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
  687. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
  688. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  689. package/dist/surfaces/cli/commands/prune.mjs +1 -1
  690. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  691. package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
  692. package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
  693. package/dist/surfaces/cli/commands/status.mjs +1 -1
  694. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  695. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  696. package/dist/surfaces/cli/commands/wipe.mjs +3 -4
  697. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  698. package/dist/surfaces/cli/envelope.mjs.map +1 -1
  699. package/dist/surfaces/cli/errors.mjs.map +1 -1
  700. package/dist/surfaces/cli/flags.mjs.map +1 -1
  701. package/dist/surfaces/cli/index.mjs +45 -14
  702. package/dist/surfaces/cli/index.mjs.map +1 -1
  703. package/dist/surfaces/cli/output.mjs.map +1 -1
  704. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  705. package/dist/surfaces/tui/app.mjs +0 -21
  706. package/dist/surfaces/tui/app.mjs.map +1 -1
  707. package/dist/surfaces/tui/dashboard.mjs +0 -48
  708. package/dist/surfaces/tui/dashboard.mjs.map +1 -1
  709. package/dist/surfaces/tui/display-derivation.mjs +80 -16
  710. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  711. package/dist/surfaces/tui/errors.mjs.map +1 -1
  712. package/dist/surfaces/tui/event-log.mjs +0 -9
  713. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  714. package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
  715. package/dist/surfaces/tui/index.mjs +2 -2
  716. package/dist/surfaces/tui/index.mjs.map +1 -1
  717. package/dist/surfaces/tui/input.mjs.map +1 -1
  718. package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
  719. package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
  720. package/dist/surfaces/tui/plain-renderer.mjs +26 -19
  721. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  722. package/dist/surfaces/tui/resource-table.mjs +8 -10
  723. package/dist/surfaces/tui/resource-table.mjs.map +1 -1
  724. package/images/postgres/Dockerfile +0 -1
  725. package/images/sui/Dockerfile +27 -54
  726. package/images/sui/entrypoint.sh +17 -179
  727. package/package.json +23 -15
  728. package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
  729. package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
  730. package/dashboard-ui/assets/index-Deml9drg.css +0 -1
  731. package/dist/api/plugin-errors.d.mts +0 -7
  732. package/dist/api/plugin-errors.mjs +0 -10
  733. package/dist/api/plugin-errors.mjs.map +0 -1
  734. package/dist/cli/wirings/build-verb-layers.mjs +0 -42
  735. package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
  736. package/dist/contracts/capability-decl.d.mts +0 -40
  737. package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
  738. package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
  739. package/dist/orchestrators/run.mjs +0 -91
  740. package/dist/orchestrators/run.mjs.map +0 -1
  741. package/dist/orchestrators/runtime-composition.d.mts +0 -10
  742. package/dist/orchestrators/runtime-composition.mjs +0 -252
  743. package/dist/orchestrators/runtime-composition.mjs.map +0 -1
  744. package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
  745. package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
  746. package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
  747. package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
  748. package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
  749. package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
  750. package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
  751. package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
  752. package/dist/orchestrators/snapshot/state-document.mjs +0 -58
  753. package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
  754. package/dist/plugins/account/spans.mjs +0 -16
  755. package/dist/plugins/account/spans.mjs.map +0 -1
  756. package/dist/plugins/account/variants/env.mjs +0 -24
  757. package/dist/plugins/account/variants/env.mjs.map +0 -1
  758. package/dist/plugins/account/variants/inline.mjs +0 -13
  759. package/dist/plugins/account/variants/inline.mjs.map +0 -1
  760. package/dist/plugins/account/variants/keystore.mjs +0 -91
  761. package/dist/plugins/account/variants/keystore.mjs.map +0 -1
  762. package/dist/plugins/action/spans.mjs +0 -11
  763. package/dist/plugins/action/spans.mjs.map +0 -1
  764. package/dist/plugins/coin/spans.mjs +0 -20
  765. package/dist/plugins/coin/spans.mjs.map +0 -1
  766. package/dist/plugins/deepbook/spans.mjs +0 -18
  767. package/dist/plugins/deepbook/spans.mjs.map +0 -1
  768. package/dist/plugins/faucet/spans.mjs +0 -12
  769. package/dist/plugins/faucet/spans.mjs.map +0 -1
  770. package/dist/plugins/package/spans.mjs +0 -14
  771. package/dist/plugins/package/spans.mjs.map +0 -1
  772. package/dist/plugins/postgres/codegen.mjs +0 -42
  773. package/dist/plugins/postgres/codegen.mjs.map +0 -1
  774. package/dist/plugins/postgres/connection.d.mts +0 -33
  775. package/dist/plugins/postgres/connection.mjs.map +0 -1
  776. package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
  777. package/dist/plugins/postgres/errors.d.mts +0 -60
  778. package/dist/plugins/postgres/errors.mjs +0 -29
  779. package/dist/plugins/postgres/errors.mjs.map +0 -1
  780. package/dist/plugins/postgres/index.d.mts +0 -37
  781. package/dist/plugins/postgres/index.mjs +0 -68
  782. package/dist/plugins/postgres/index.mjs.map +0 -1
  783. package/dist/plugins/postgres/routable.mjs +0 -33
  784. package/dist/plugins/postgres/routable.mjs.map +0 -1
  785. package/dist/plugins/postgres/service.d.mts +0 -50
  786. package/dist/plugins/postgres/service.mjs +0 -179
  787. package/dist/plugins/postgres/service.mjs.map +0 -1
  788. package/dist/plugins/postgres/snapshot.mjs +0 -32
  789. package/dist/plugins/postgres/snapshot.mjs.map +0 -1
  790. package/dist/plugins/postgres/spans.mjs +0 -11
  791. package/dist/plugins/postgres/spans.mjs.map +0 -1
  792. package/dist/plugins/seal/spans.mjs +0 -18
  793. package/dist/plugins/seal/spans.mjs.map +0 -1
  794. package/dist/plugins/sui/spans.mjs +0 -17
  795. package/dist/plugins/sui/spans.mjs.map +0 -1
  796. package/dist/plugins/wallet/spans.mjs +0 -22
  797. package/dist/plugins/wallet/spans.mjs.map +0 -1
  798. package/dist/plugins/walrus/registry-publish.d.mts +0 -24
  799. package/dist/plugins/walrus/spans.mjs +0 -18
  800. package/dist/plugins/walrus/spans.mjs.map +0 -1
  801. package/dist/runtime/docker/logs.d.mts +0 -1
  802. package/dist/runtime/docker/logs.mjs +0 -34
  803. package/dist/runtime/docker/logs.mjs.map +0 -1
  804. package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
  805. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
  806. package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
  807. package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
  808. package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
  809. package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
  810. package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
  811. package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
  812. package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
  813. package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
  814. package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
  815. package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
  816. package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
  817. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
  818. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
  819. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
  820. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
  821. package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
  822. package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
  823. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
  824. package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
  825. package/dist/substrate/runtime/observability/span-store.mjs +0 -110
  826. package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
  827. package/dist/substrate/runtime/observability/spans.d.mts +0 -1
  828. package/dist/substrate/runtime/observability/spans.mjs +0 -87
  829. package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
  830. package/dist/substrate/runtime/projection/index.mjs +0 -4
  831. package/dist/substrate/runtime/projection/persisted.mjs +0 -213
  832. package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
  833. package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
  834. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
  835. package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
  836. package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
  837. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
  838. package/dist/substrate/runtime/state-store/index.mjs +0 -3
  839. package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
  840. package/dist/substrate/runtime/state-store/schema.mjs +0 -41
  841. package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
  842. package/dist/substrate/runtime/state-store/service.d.mts +0 -1
  843. package/dist/substrate/runtime/state-store/service.mjs +0 -145
  844. package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
  845. package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
  846. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
  847. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
  848. package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
  849. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
  850. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
  851. package/dist/substrate/state-store.d.mts +0 -1
  852. /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
  853. /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
  854. /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
  855. /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
  856. /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
  857. /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
  858. /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/package/index.ts"],"sourcesContent":["// Package plugin — barrel + factories.\n//\n// Architecture: Package is the canonical implementation of the\n// `ArtifactPublisher` substrate primitive. Many service\n// plugins depend on its publish output (Coin types, Walrus/Seal/\n// Deepbook contracts, Action outputs).\n//\n// Public surface:\n//\n// - `localPackage(name, opts)` — build + publish a Move source tree.\n// - `knownPackage(name, opts)` — verify-only against a fixed id.\n//\n// Type split (distilled doc Invariant 9): `localPackage` resolves to\n// `LocalPackage`; `knownPackage` resolves to `KnownPackage`. The\n// bindings emitter (in the codegen orchestrator) types-out KnownPackage\n// at compose time, so misuse fails at compile time rather than at\n// emit time.\n//\n// Resource id: `'package:<name>'` — one tag per user-declared package\n// (the symbolic name is part of the identity so two `localPackage`\n// calls in the same stack don't collide on the substrate's tag\n// registry). Substrate-side plugin key is the same string.\n\nimport { Effect } from 'effect';\n\nimport { projection } from '../../api/define-capabilities.ts';\nimport { definePlugin, resource, type ResourceRef } from '../../api/define-plugin.ts';\nimport { pluginErrorContributions } from '../../api/plugin-errors.ts';\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport type { ProjectionDecl } from '../../contracts/projection.ts';\nimport {\n\tmakeLocalPackagePublishedDecl,\n\tpickCreatedByType,\n\ttype LocalPackagePublishOutput,\n} from './publish-output.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport { ContainerRuntimeService } from '../../runtime/docker/service.ts';\nimport type { ChainId } from '../../substrate/brand.ts';\nimport { ArtifactPublisherService } from '../../substrate/runtime/artifact-publisher/index.ts';\nimport { chainProbeFor } from '../../substrate/runtime/strategy-registry/index.ts';\nimport { suiResource, type SuiProbeKey } from '../sui/index.ts';\nimport type { AccountResourceId, AccountValue } from '../account/index.ts';\nimport { makeKnownCodegenable, makeLocalCodegenable } from './codegen.ts';\nimport { makePublishExecutor } from './publish-executor.ts';\nimport { bootPackageService, type PackageMode } from './service.ts';\nimport {\n\tPACKAGE_REGISTRY_CAPABILITY_KEY,\n\tPackageRegistryService,\n\ttype ResolvedKnownPackage,\n\ttype ResolvedLocalPackage,\n} from './registry.ts';\nimport { makeSnapshotable } from './snapshot.ts';\nimport { PACKAGE_ERROR_TAGS } from './errors.ts';\n\nconst packageErrorContributions = pluginErrorContributions(PACKAGE_ERROR_TAGS);\n\n// ---------------------------------------------------------------------------\n// Publisher account ref — explicit upstream\n// ---------------------------------------------------------------------------\n\n/** A user-supplied publisher account ref. The user passes the result\n * of `account('alice')` — NOT a bare string. Generic over the\n * literal account name so the package dependency preserves the\n * per-account resource id. */\nexport type PublisherAccountMember<Name extends string = string> = ResourceRef<\n\tAccountResourceId<Name>,\n\tAccountValue\n>;\n\n// ---------------------------------------------------------------------------\n// Resource — one per declared package, keyed by symbolic name\n// ---------------------------------------------------------------------------\n\n/** Resource id constructor. The symbolic package name is part of the tag\n * identity so the substrate's compose-time dedup detects collisions\n * cleanly (two `localPackage('foo', ...)` calls in one stack → typed\n * error at compose time). */\nexport const packageResourceId = <Name extends string>(name: Name): `package:${Name}` =>\n\t`package:${name}`;\n\n/** The literal-template resource id for a package by symbolic name. */\nexport type PackageResourceId<Name extends string> = `package:${Name}`;\n\n/** Public resolved value shapes — re-exported from `registry.ts` to\n * give consumers one stable import path. */\nexport type { ResolvedLocalPackage, ResolvedKnownPackage, ResolvedPackage } from './registry.ts';\nexport type {\n\tPickCreatedByTypeOptions,\n\tLocalPackagePublishOutput,\n\tPackagePublishObjectChange,\n} from './publish-output.ts';\nexport { pickCreatedByType } from './publish-output.ts';\nexport type { PublishError } from './errors.ts';\nexport { PACKAGE_ERROR_TAGS } from './errors.ts';\nexport type { PackageBindings } from './codegen.ts';\nexport type { PublishExecutor } from './mode-local.ts';\nexport { PackageSpans } from './spans.ts';\n\n/** Resolved value carried by the package resource. Local packages also\n * expose the publish output so manifest emitters and capture-spec\n * callers can read it. Sibling plugin folds consume the package-owned\n * extension contribution instead of importing package internals. */\nexport type PackageCaptureMap = Readonly<Record<string, string>>;\n\ntype PackageCaptureCallback = (\n\toutput: LocalPackagePublishOutput,\n) => Readonly<Record<string, string>>;\n\nexport type PackageCapture = PackageCaptureMap;\n\nexport type CapturedPackageValues<Capture> = Capture extends PackageCaptureCallback\n\t? Readonly<Record<string, string>>\n\t: Capture extends PackageCaptureMap\n\t\t? { readonly [K in keyof Capture]: string }\n\t\t: Readonly<Record<string, string>>;\n\nexport interface LocalPackageResolved<Capture = undefined> extends Omit<\n\tResolvedLocalPackage,\n\t'captured'\n> {\n\t/** Captured object ids keyed by the user's `capture` option. */\n\treadonly captured: CapturedPackageValues<Capture>;\n\t/** Publisher account that signed this package. Kept on the live\n\t * resource value so downstream local coin plugins can mint from\n\t * publisher-owned TreasuryCaps through the centralized funding\n\t * strategy path. It is intentionally not written to generated\n\t * bindings or the package registry. */\n\treadonly publisher: AccountValue;\n\t/** Publish output — present after a fresh publish, null on\n\t * cache hit (verify-only path). Consumers that need the\n\t * output MUST tolerate null and fall back to chain reads via\n\t * the ChainProbe. */\n\treadonly publishResult: LocalPackagePublishOutput | null;\n}\n\nexport type KnownPackageResolved = ResolvedKnownPackage;\n\nexport type PackageResolved = LocalPackageResolved | KnownPackageResolved;\n\n// ---------------------------------------------------------------------------\n// Factory options\n// ---------------------------------------------------------------------------\n\nexport interface LocalPackageOptions<\n\tPublisher extends PublisherAccountMember = PublisherAccountMember,\n\tCapture extends PackageCapture | undefined = undefined,\n> {\n\treadonly sourcePath: string;\n\treadonly mvrPlaceholder?: string;\n\treadonly excludeFromCodegen?: boolean;\n\t/** Capture created objects from the publish output. The record\n\t * form maps output keys to object-type suffixes, e.g.\n\t * `{ boardId: '::board::Board' }`. */\n\treadonly capture?: Capture;\n\t/** Publisher account — the signer for the publish tx. Pass the\n\t * result of `account('alice')` (the same plugin/resource ref used\n\t * in the rest of the stack — NOT a duplicate factory call).\n\t *\n\t * Required for local packages: a publish tx must be signed by\n\t * SOMEONE; we make the choice explicit so two packages in the\n\t * same stack can publish under different accounts (no implicit\n\t * \"first account\" convention to memorise). Distilled doc Invariant\n\t * 4 — \"Signer MUST be an explicit upstream\". */\n\treadonly publisher: Publisher;\n}\n\nexport interface KnownPackageOptions {\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly mvrPlaceholder?: string;\n}\n\ninterface PackageRegistryProjectionContribution {\n\treadonly kind: 'local' | 'known';\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly upgradeCapId: string | null;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n}\n\nconst makePackageProjectionContribution = (\n\tcontribution: PackageRegistryProjectionContribution,\n): ProjectionDecl => {\n\tconst updatedAt = Date.now();\n\tconst key = `package/${contribution.name}` as `package/${string}`;\n\treturn projection({\n\t\tkind: 'package',\n\t\tkey,\n\t\tpayload: {\n\t\t\tkey,\n\t\t\trowKey: null,\n\t\t\tname: contribution.name,\n\t\t\tkind: contribution.kind,\n\t\t\tpackageId: contribution.packageId,\n\t\t\tupgradeCapId: contribution.upgradeCapId,\n\t\t\tmvrPlaceholder: contribution.mvrPlaceholder,\n\t\t\tsourcePath: contribution.sourcePath,\n\t\t\tupdatedAt,\n\t\t},\n\t\tat: updatedAt,\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Internal builders\n// ---------------------------------------------------------------------------\n\nconst normalizeCapture = <Capture extends PackageCapture | undefined>(\n\tpackageName: string,\n\tcapture: Capture,\n): PackageCaptureCallback | undefined => {\n\tif (capture === undefined) return undefined;\n\treturn (output) => {\n\t\tconst captured: Record<string, string> = {};\n\t\tfor (const [key, suffix] of Object.entries(capture)) {\n\t\t\tconst objectId = pickCreatedByType(output.objectChanges, { suffix });\n\t\t\tif (objectId === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`localPackage('${packageName}') capture '${key}' matched no created object with suffix '${suffix}'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcaptured[key] = objectId;\n\t\t}\n\t\treturn captured;\n\t};\n};\n\nconst buildLocalPlugin = <\n\tName extends string,\n\tconst Publisher extends PublisherAccountMember,\n\tCapture extends PackageCapture | undefined,\n>(\n\tname: Name,\n\topts: LocalPackageOptions<Publisher, Capture>,\n) => {\n\tconst packageRef = resource<PackageResourceId<Name>, LocalPackageResolved<Capture>>(\n\t\tpackageResourceId(name),\n\t);\n\tconst capture = normalizeCapture(name, opts.capture);\n\n\treturn definePlugin({\n\t\tid: packageRef.id,\n\t\tdependsOn: { sui: suiResource, publisher: opts.publisher },\n\t\trole: 'task',\n\t\tsection: 'package',\n\t\twatch: {\n\t\t\t// File-watcher contribution — restart on Move source edits.\n\t\t\t// Distilled doc §Outputs: literal-path Packages contribute\n\t\t\t// watch roots. Effect-resolved paths do NOT auto-attach.\n\t\t\tpaths: [\n\t\t\t\t`${opts.sourcePath}/**/*.move`,\n\t\t\t\t`${opts.sourcePath}/Move.toml`,\n\t\t\t\t`${opts.sourcePath}/Move.lock`,\n\t\t\t],\n\t\t\tcascade: true,\n\t\t},\n\t\tstart: ({ sui, publisher: publisherAccount }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\t// Substrate-context primitives: ArtifactPublisher\n\t\t\t\t// is provided by the supervisor's pluginContext;\n\t\t\t\t// ChainProbe is looked up via the StrategyRegistry\n\t\t\t\t// (Sui registered itself there at acquire). The\n\t\t\t\t// PackageRegistry is a per-stack plugin-owned service\n\t\t\t\t// (instantiated from the substrate's generic\n\t\t\t\t// ScopedRefMap primitive — see `registry.ts`) — every\n\t\t\t\t// package plugin in the stack yields the SAME instance\n\t\t\t\t// via `PackageRegistryService`, so cross-plugin lookups\n\t\t\t\t// stay consistent and warm-restart verify can use the\n\t\t\t\t// previous packageId as a hint.\n\t\t\t\tconst publisher = yield* ArtifactPublisherService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chain);\n\t\t\t\tconst registry = yield* PackageRegistryService;\n\t\t\t\t// ContainerRuntime + the Sui plugin's resolved image feed\n\t\t\t\t// `runMoveBuild`'s path-(b) (`docker run --rm`) build path.\n\t\t\t\t// Sui surfaces `buildImage` on its resolved client; modes\n\t\t\t\t// without an in-stack image (external, live) surface null\n\t\t\t\t// — runMoveBuild then surfaces a typed error from path (c)\n\t\t\t\t// (host CLI not routed).\n\t\t\t\tconst containerRuntime = yield* ContainerRuntimeService;\n\n\t\t\t\t// Build the concrete `PublishExecutor` once per acquire.\n\t\t\t\t// Hands the resolved SuiSdkShim (for `Transaction.build`,\n\t\t\t\t// `executeTransaction`, `waitForTransaction`) and the\n\t\t\t\t// publisher account (for `signAndExecute`) to the executor\n\t\t\t\t// methods; mode-local's produce body drives them.\n\t\t\t\tconst executor = makePublishExecutor({\n\t\t\t\t\tsdk: sui.sdk,\n\t\t\t\t\taccount: publisherAccount,\n\t\t\t\t\truntime: containerRuntime,\n\t\t\t\t\tforkMode: sui.fork !== null,\n\t\t\t\t\t...(sui.buildImage !== null ? { buildImage: sui.buildImage } : {}),\n\t\t\t\t});\n\n\t\t\t\tconst mode = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tpackageName: name,\n\t\t\t\t\tsourcePath: opts.sourcePath,\n\t\t\t\t\tchainId: sui.chain,\n\t\t\t\t\tpublisherAddress: publisherAccount.address,\n\t\t\t\t\tmvrOverride: opts.mvrPlaceholder,\n\t\t\t\t\t...(capture !== undefined ? { capture } : {}),\n\t\t\t\t\texecutor,\n\t\t\t\t} satisfies PackageMode;\n\n\t\t\t\tconst { resolved, output } = yield* bootPackageService(publisher, probe, registry, mode);\n\n\t\t\t\tconst projected: LocalPackageResolved<Capture> = {\n\t\t\t\t\t...resolved,\n\t\t\t\t\tcaptured: resolved.captured as CapturedPackageValues<Capture>,\n\t\t\t\t\tpublisher: publisherAccount,\n\t\t\t\t\tpublishResult: output,\n\t\t\t\t};\n\t\t\t\treturn projected;\n\t\t\t}),\n\t\terrorContributions: packageErrorContributions,\n\t\tcapabilities: ({ value, runtime }) => makeLocalCapabilities(name, opts, value, runtime.chain),\n\t});\n};\n\nconst buildKnownPlugin = <Name extends string>(name: Name, opts: KnownPackageOptions) => {\n\tconst packageRef = resource<PackageResourceId<Name>, KnownPackageResolved>(\n\t\tpackageResourceId(name),\n\t);\n\treturn definePlugin({\n\t\tid: packageRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'package',\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst publisher = yield* ArtifactPublisherService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chain);\n\t\t\t\tconst registry = yield* PackageRegistryService;\n\t\t\t\tconst mode = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tpackageName: name,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tupgradeCapId: opts.upgradeCapId,\n\t\t\t\t\tmvrOverride: opts.mvrPlaceholder,\n\t\t\t\t} satisfies PackageMode;\n\t\t\t\tconst { resolved } = yield* bootPackageService(publisher, probe, registry, mode);\n\t\t\t\t// Known mode never publishes — no output to walk, so\n\t\t\t\t// the coin-discovery hook is skipped here. Users who\n\t\t\t\t// want coin records for a knownPackage point a\n\t\t\t\t// `coin.known('0xPKG::module::Witness')` at the\n\t\t\t\t// fully-qualified type directly; the bare-type path\n\t\t\t\t// hits the live RPC for metadata rather than the\n\t\t\t\t// output-walker.\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t\terrorContributions: packageErrorContributions,\n\t\tcapabilities: ({ value }) => makeKnownCapabilities(name, opts, value),\n\t});\n};\n\nconst makeLocalCapabilities = (\n\tname: string,\n\topts: { readonly excludeFromCodegen?: boolean },\n\tresolved: LocalPackageResolved,\n\tchain: ChainId,\n) => {\n\t// Snapshot + codegen lift their typed fields off the resolved\n\t// publish (real packageId + captured object ids). The static-form\n\t// placeholders are gone.\n\tconst snap: SnapshotableDecl = makeSnapshotable(\n\t\tname,\n\t\tresolved.publishResult?.packageId ?? resolved.packageId,\n\t);\n\tconst codegen: CodegenableDecl<'package'> = makeLocalCodegenable(\n\t\t{\n\t\t\tkind: 'local',\n\t\t\tname,\n\t\t\tpackageId: resolved.packageId,\n\t\t\tupgradeCapId: resolved.upgradeCapId,\n\t\t\tsourcePath: resolved.sourcePath,\n\t\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\t\tcaptured: resolved.captured,\n\t\t},\n\t\t{ excluded: opts.excludeFromCodegen ?? false },\n\t);\n\t// The plugin contributes to the package-registry strategy under a\n\t// fixed key — the substrate orchestrator wires all packages'\n\t// contributions into the same per-stack registry.\n\tconst projection: PackageRegistryProjectionContribution = {\n\t\tkind: 'local',\n\t\tname,\n\t\tpackageId: resolved.packageId,\n\t\tupgradeCapId: resolved.upgradeCapId ?? null,\n\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\tsourcePath: resolved.sourcePath,\n\t};\n\tconst registryContribution: StrategyContributorDecl<\n\t\ttypeof PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tPackageRegistryProjectionContribution\n\t> = {\n\t\tkind: 'strategy-contributor',\n\t\tcapabilityKey: PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tstrategy: projection,\n\t\tautoMounted: true,\n\t};\n\treturn [\n\t\tsnap,\n\t\tcodegen,\n\t\tregistryContribution,\n\t\tmakePackageProjectionContribution(projection),\n\t\t...(resolved.publishResult === null\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\tmakeLocalPackagePublishedDecl({\n\t\t\t\t\t\tpackageName: name,\n\t\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\t\tchain,\n\t\t\t\t\t\toutput: resolved.publishResult,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t] as const;\n};\n\nconst makeKnownCapabilities = (\n\tname: string,\n\topts: KnownPackageOptions,\n\tresolved: KnownPackageResolved,\n) => {\n\tconst snap: SnapshotableDecl = makeSnapshotable(name, `known:${resolved.packageId}`);\n\tconst codegen: CodegenableDecl<'package'> = makeKnownCodegenable({\n\t\tkind: 'known',\n\t\tname,\n\t\tpackageId: resolved.packageId,\n\t\tupgradeCapId: resolved.upgradeCapId ?? opts.upgradeCapId,\n\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t});\n\tconst projection: PackageRegistryProjectionContribution = {\n\t\tkind: 'known',\n\t\tname,\n\t\tpackageId: resolved.packageId,\n\t\tupgradeCapId: resolved.upgradeCapId ?? opts.upgradeCapId ?? null,\n\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\tsourcePath: null,\n\t};\n\tconst registryContribution: StrategyContributorDecl<\n\t\ttypeof PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tPackageRegistryProjectionContribution\n\t> = {\n\t\tkind: 'strategy-contributor',\n\t\tcapabilityKey: PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tstrategy: projection,\n\t\tautoMounted: true,\n\t};\n\treturn [\n\t\tsnap,\n\t\tcodegen,\n\t\tregistryContribution,\n\t\tmakePackageProjectionContribution(projection),\n\t] as const;\n};\n\n// ---------------------------------------------------------------------------\n// Public factories\n// ---------------------------------------------------------------------------\n\n/** Build + publish a local Move package. The resolved value is\n * `LocalPackageResolved` so consumers that need bindings / source\n * path are typed correctly.\n *\n * Required `opts.publisher`: the account that signs the publish tx.\n * Pass the same `account('alice')` reference used elsewhere in the\n * stack — the package.s `dependsOn` includes `account/<publisher>`\n * so the substrate orders the publisher's keypair + funding strictly\n * before publish. */\nexport const localPackage = <\n\tName extends string,\n\tconst Publisher extends PublisherAccountMember,\n\tconst Capture extends PackageCapture | undefined = undefined,\n>(\n\tname: Name,\n\topts: LocalPackageOptions<Publisher, Capture>,\n) => buildLocalPlugin(name, opts);\n\n/** Verify-only against a fixed on-chain package id. The resolved\n * value is `KnownPackageResolved` — narrower than local, so the\n * bindings emitter rejects this at compose time. */\nexport const knownPackage = <Name extends string>(name: Name, opts: KnownPackageOptions) =>\n\tbuildKnownPlugin(name, opts);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,MAAM,4BAA4B,yBAAyB,mBAAmB;;;;;AAuB9E,MAAa,qBAA0C,SACtD,WAAW;AAuGZ,MAAM,qCACL,iBACoB;CACpB,MAAM,YAAY,KAAK,KAAK;CAC5B,MAAM,MAAM,WAAW,aAAa;AACpC,QAAO,WAAW;EACjB,MAAM;EACN;EACA,SAAS;GACR;GACA,QAAQ;GACR,MAAM,aAAa;GACnB,MAAM,aAAa;GACnB,WAAW,aAAa;GACxB,cAAc,aAAa;GAC3B,gBAAgB,aAAa;GAC7B,YAAY,aAAa;GACzB;GACA;EACD,IAAI;EACJ,CAAC;;AAOH,MAAM,oBACL,aACA,YACwC;AACxC,KAAI,YAAY,KAAA,EAAW,QAAO,KAAA;AAClC,SAAQ,WAAW;EAClB,MAAM,WAAmC,EAAE;AAC3C,OAAK,MAA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L,MACA,MACA,aACI;CACJ,MAAM,OAAyB,iBAAiB,MAAM,SAAS,SAAS,YAAY;CACpF,MAAM,UAAsC,qBAAqB;EAChE,MAAM;EACN;EACA,WAAW,SAAS;EACpB,cAAc,SAAS,gBAAgB,KAAK;EAC5C,gBAAgB,SAAS;EACzB,CAAC;CACF,MAAM,aAAoD;EACzD,MAAM;EACN;EACA,WAAW,SAAS;EACpB,cAAc,SAAS,gBAAgB,KAAK,gBAAgB;EAC5D,gBAAgB,SAAS;EACzB,YAAY;EACZ;AAUD,QAAO;EACN;EACA;EACA;GARA,MAAM;GACN,eAAe;GACf,UAAU;GACV,aAAa;GAKO;EACpB,kCAAkC,WAAW;EAC7C;;;;;;;;;;;AAgBF,MAAa,gBAKZ,MACA,SACI,iBAAiB,MAAM,KAAK;;;;AAKjC,MAAa,gBAAqC,MAAY,SAC7D,iBAAiB,MAAM,KAAK"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/package/index.ts"],"sourcesContent":["// Package plugin — barrel + factories.\n//\n// Architecture: Package is the canonical implementation of the\n// `ArtifactPublisher` substrate primitive. Many service\n// plugins depend on its publish output (Coin types, Walrus/Seal/\n// Deepbook contracts, Action outputs).\n//\n// Public surface:\n//\n// - `localPackage(name, opts)` — build + publish a Move source tree.\n// - `knownPackage(name, opts)` — verify-only against a fixed id.\n//\n// Type split (distilled doc Invariant 9): `localPackage` resolves to\n// `LocalPackage`; `knownPackage` resolves to `KnownPackage`. The\n// bindings emitter (in the codegen orchestrator) types-out KnownPackage\n// at compose time, so misuse fails at compile time rather than at\n// emit time.\n//\n// Resource id: `'package:<name>'` — one tag per user-declared package\n// (the symbolic name is part of the identity so two `localPackage`\n// calls in the same stack don't collide on the substrate's tag\n// registry). Substrate-side plugin key is the same string.\n\nimport { Effect } from 'effect';\n\nimport { projection } from '../../api/define-capabilities.ts';\nimport {\n\tcomputedInputIdentity,\n\tdefinePlugin,\n\tresource,\n\tstaticInputIdentity,\n\ttype ResourceRef,\n} from '../../api/define-plugin.ts';\nimport type { Contribution } from '../../substrate/plugin-ctx.ts';\nimport type { CodegenableDecl } from '../../contracts/codegenable.ts';\nimport type { ProjectionDecl } from '../../contracts/projection.ts';\nimport { pickCreatedByType, type LocalPackagePublishOutput } from './publish-output.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport type { StrategyContributorDecl } from '../../contracts/strategy-contributor.ts';\nimport { emitContributions, PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { ContainerRuntimeService } from '../../runtime/docker/service.ts';\nimport {\n\tCoinRegistryService,\n\tdiscoverCoinsFromPublish,\n\ttype CoinRecord,\n\ttype CoinRegistry,\n} from '../coin/index.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { chainProbeFor } from '../../substrate/runtime/strategy-registry/index.ts';\nimport { suiResource, type SuiProbeKey } from '../sui/index.ts';\nimport type { AccountResourceId, AccountValue } from '../account/index.ts';\nimport {\n\tmakeKnownCodegenable,\n\tmakeKnownStaticCodegen,\n\tmakeLocalCodegenable,\n\tmakeLocalStaticCodegen,\n\ttype PackageNetworks,\n} from './codegen.ts';\nimport { hashMoveSources } from './build.ts';\nimport type { PublishError } from './errors.ts';\nimport { materializeGitSource, type GitSource } from './git-source.ts';\nimport { makePublishExecutor } from './publish-executor.ts';\nimport { bootPackageService, type PackageMode } from './service.ts';\nimport {\n\tPACKAGE_REGISTRY_CAPABILITY_KEY,\n\tPackageRegistryService,\n\ttype ResolvedKnownPackage,\n\ttype ResolvedLocalPackage,\n} from './registry.ts';\nimport { makeSnapshotable } from './snapshot.ts';\n\n// ---------------------------------------------------------------------------\n// Publisher account ref — explicit upstream\n// ---------------------------------------------------------------------------\n\n/** A user-supplied publisher account ref. The user passes the result\n * of `account('alice')` — NOT a bare string. Generic over the\n * literal account name so the package dependency preserves the\n * per-account resource id. */\nexport type PublisherAccountMember<Name extends string = string> = ResourceRef<\n\tAccountResourceId<Name>,\n\tAccountValue\n>;\n\n// ---------------------------------------------------------------------------\n// Resource — one per declared package, keyed by symbolic name\n// ---------------------------------------------------------------------------\n\n/** Resource id constructor. The symbolic package name is part of the tag\n * identity so the substrate's compose-time dedup detects collisions\n * cleanly (two `localPackage('foo', ...)` calls in one stack → typed\n * error at compose time). */\nexport const packageResourceId = <Name extends string>(name: Name): `package:${Name}` =>\n\t`package:${name}`;\n\n/** The literal-template resource id for a package by symbolic name. */\nexport type PackageResourceId<Name extends string> = `package:${Name}`;\n\n/** Public resolved value shapes — re-exported from `registry.ts` to\n * give consumers one stable import path. */\nexport type { ResolvedLocalPackage, ResolvedKnownPackage, ResolvedPackage } from './registry.ts';\nexport type {\n\tPickCreatedByTypeOptions,\n\tLocalPackagePublishOutput,\n\tPackagePublishObjectChange,\n} from './publish-output.ts';\nexport { pickCreatedByType } from './publish-output.ts';\nexport type { PublishError } from './errors.ts';\nexport type { PackageBindings, PackageNetworks, PackageNetworkEntry } from './codegen.ts';\nexport type { PublishExecutor } from './mode-local.ts';\n\n/** Resolved value carried by the package resource. Local packages also\n * expose the publish output so manifest emitters and capture-spec\n * callers can read it. Sibling plugin folds consume the package-owned\n * extension contribution instead of importing package internals. */\nexport type PackageCaptureMap = Readonly<Record<string, string>>;\n\ntype PackageCaptureCallback = (\n\toutput: LocalPackagePublishOutput,\n) => Readonly<Record<string, string>>;\n\nexport type PackageCapture = PackageCaptureMap;\n\nexport type CapturedPackageValues<Capture> = Capture extends PackageCaptureCallback\n\t? Readonly<Record<string, string>>\n\t: Capture extends PackageCaptureMap\n\t\t? { readonly [K in keyof Capture]: string }\n\t\t: Readonly<Record<string, string>>;\n\nexport interface LocalPackageResolved<Capture = undefined> extends Omit<\n\tResolvedLocalPackage,\n\t'captured'\n> {\n\t/** Captured object ids keyed by the user's `capture` option. */\n\treadonly captured: CapturedPackageValues<Capture>;\n\t/** Publisher account that signed this package. Kept on the live\n\t * resource value so downstream local coin plugins can mint from\n\t * publisher-owned TreasuryCaps through the centralized funding\n\t * strategy path. It is intentionally not written to generated\n\t * bindings or the package registry. */\n\treadonly publisher: AccountValue;\n\t/** Publish output — present after a fresh publish, null on\n\t * cache hit (verify-only path). Consumers that need the\n\t * output MUST tolerate null and fall back to chain reads via\n\t * the ChainProbe. */\n\treadonly publishResult: LocalPackagePublishOutput | null;\n}\n\nexport type KnownPackageResolved = ResolvedKnownPackage;\n\nexport type PackageResolved = LocalPackageResolved | KnownPackageResolved;\n\n// ---------------------------------------------------------------------------\n// Factory options\n// ---------------------------------------------------------------------------\n\nexport interface LocalPackageOptions<\n\tPublisher extends PublisherAccountMember = PublisherAccountMember,\n\tCapture extends PackageCapture | undefined = undefined,\n> {\n\t/** Local on-disk path to the Move package. Provide EXACTLY ONE of\n\t * `sourcePath` or `git`. */\n\treadonly sourcePath?: string;\n\t/** Remote git source — clone a repo and build a sub-path of it instead of\n\t * vendoring the Move tree. Cloned once into a host cache keyed by\n\t * `url + rev` (see `git-source.ts`); pin `rev` to a commit SHA or tag for\n\t * reproducibility. Mutually exclusive with `sourcePath`. */\n\treadonly git?: GitSource;\n\treadonly mvrPlaceholder?: string;\n\treadonly excludeFromCodegen?: boolean;\n\t/** Capture created objects from the publish output. The record\n\t * form maps output keys to object-type suffixes, e.g.\n\t * `{ boardId: '::board::Board' }`. */\n\treadonly capture?: Capture;\n\t/** Per-network declared package ids (+ optional object ids) for\n\t * prod-targeting. Pure literals, no resolution: codegen merges the\n\t * resolved-local id into `config.packages.<name>.byNetwork.localnet`\n\t * and these literals into `byNetwork.testnet` / `byNetwork.mainnet`.\n\t * A consumer flips `config.network` (env) to select active ids. */\n\treadonly networks?: PackageNetworks;\n\t/** Publisher account — the signer for the publish tx. Pass the\n\t * result of `account('alice')` (the same plugin/resource ref used\n\t * in the rest of the stack — NOT a duplicate factory call).\n\t *\n\t * Required for local packages: a publish tx must be signed by\n\t * SOMEONE; we make the choice explicit so two packages in the\n\t * same stack can publish under different accounts (no implicit\n\t * \"first account\" convention to memorise). Distilled doc Invariant\n\t * 4 — \"Signer MUST be an explicit upstream\". */\n\treadonly publisher: Publisher;\n}\n\nexport interface KnownPackageOptions {\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly mvrPlaceholder?: string;\n\t/** Per-network declared package ids (+ optional object ids) for\n\t * prod-targeting — same as `LocalPackageOptions.networks`. Pure\n\t * literals; codegen fills `config.packages.<name>.byNetwork`. */\n\treadonly networks?: PackageNetworks;\n}\n\ninterface PackageRegistryProjectionContribution {\n\treadonly kind: 'local' | 'known';\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly upgradeCapId: string | null;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n}\n\nconst makePackageProjectionContribution = (\n\tcontribution: PackageRegistryProjectionContribution,\n): ProjectionDecl => {\n\tconst updatedAt = Date.now();\n\tconst key = `package/${contribution.name}` as `package/${string}`;\n\treturn projection({\n\t\tkind: 'package',\n\t\tkey,\n\t\tpayload: {\n\t\t\tkey,\n\t\t\trowKey: null,\n\t\t\tname: contribution.name,\n\t\t\tkind: contribution.kind,\n\t\t\tpackageId: contribution.packageId,\n\t\t\tupgradeCapId: contribution.upgradeCapId,\n\t\t\tmvrPlaceholder: contribution.mvrPlaceholder,\n\t\t\tsourcePath: contribution.sourcePath,\n\t\t\tupdatedAt,\n\t\t},\n\t\tat: updatedAt,\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Internal builders\n// ---------------------------------------------------------------------------\n\nconst normalizeCapture = <Capture extends PackageCapture | undefined>(\n\tpackageName: string,\n\tcapture: Capture,\n): PackageCaptureCallback | undefined => {\n\tif (capture === undefined) return undefined;\n\treturn (output) => {\n\t\tconst captured: Record<string, string> = {};\n\t\tfor (const [key, suffix] of Object.entries(capture)) {\n\t\t\tconst objectId = pickCreatedByType(output.objectChanges, { suffix });\n\t\t\tif (objectId === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`localPackage('${packageName}') capture '${key}' matched no created object with suffix '${suffix}'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcaptured[key] = objectId;\n\t\t}\n\t\treturn captured;\n\t};\n};\n\nconst buildLocalPlugin = <\n\tName extends string,\n\tconst Publisher extends PublisherAccountMember,\n\tCapture extends PackageCapture | undefined,\n>(\n\tname: Name,\n\topts: LocalPackageOptions<Publisher, Capture>,\n) => {\n\tconst packageRef = resource<PackageResourceId<Name>, LocalPackageResolved<Capture>>(\n\t\tpackageResourceId(name),\n\t);\n\tconst capture = normalizeCapture(name, opts.capture);\n\n\t// Exactly one source is required. Validated at config-evaluation time (like\n\t// `normalizeCapture`) so a typo surfaces immediately, not mid-boot.\n\tif (opts.sourcePath === undefined && opts.git === undefined) {\n\t\tthrow new Error(`localPackage('${name}'): provide either 'sourcePath' or 'git'.`);\n\t}\n\tif (opts.sourcePath !== undefined && opts.git !== undefined) {\n\t\tthrow new Error(`localPackage('${name}'): 'sourcePath' and 'git' are mutually exclusive.`);\n\t}\n\n\t// Resolve the on-disk path to build from: a local `sourcePath` is used\n\t// verbatim; a `git` source is cloned into the host cache (idempotent —\n\t// see `materializeGitSource`) and the cached path returned. Called from\n\t// both `inputIdentity` and `start`; the second call is a cache hit.\n\tconst resolveSourcePath = (): Effect.Effect<string, PublishError> =>\n\t\topts.git !== undefined\n\t\t\t? materializeGitSource(opts.git, name)\n\t\t\t: Effect.succeed(opts.sourcePath as string);\n\n\treturn definePlugin({\n\t\tid: packageRef.id,\n\t\tdependsOn: { sui: suiResource, publisher: opts.publisher },\n\t\trole: 'task',\n\t\tsection: 'package',\n\t\tinputIdentity: computedInputIdentity(() =>\n\t\t\tresolveSourcePath().pipe(\n\t\t\t\tEffect.flatMap((sourcePath) =>\n\t\t\t\t\thashMoveSources(sourcePath).pipe(\n\t\t\t\t\t\tEffect.map((sourceHash) => ({\n\t\t\t\t\t\t\tplugin: 'package',\n\t\t\t\t\t\t\tkind: 'local',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t// The MATERIALIZED path: for a git source this is the\n\t\t\t\t\t\t\t// cache dir, so the hash + identity reflect what is built.\n\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\tsourceHash,\n\t\t\t\t\t\t\tpublisher: opts.publisher.id,\n\t\t\t\t\t\t\tmvrPlaceholder: opts.mvrPlaceholder ?? null,\n\t\t\t\t\t\t\texcludeFromCodegen: opts.excludeFromCodegen === true,\n\t\t\t\t\t\t\tcapture: opts.capture ?? null,\n\t\t\t\t\t\t\tnetworks: opts.networks ?? null,\n\t\t\t\t\t\t\t// url+rev change → new identity → re-clone + rebuild.\n\t\t\t\t\t\t\tgit: opts.git ?? null,\n\t\t\t\t\t\t})),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tEffect.orDie,\n\t\t\t),\n\t\t),\n\t\twatch: {\n\t\t\t// File-watcher contribution — restart on Move source edits.\n\t\t\t// Distilled doc §Outputs: literal-path Packages contribute\n\t\t\t// watch roots. Effect-resolved paths do NOT auto-attach. A git\n\t\t\t// source lives in the read-only host cache, not the dev tree, so\n\t\t\t// it contributes no watch roots (nothing local to edit).\n\t\t\tpaths:\n\t\t\t\topts.sourcePath !== undefined\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t`${opts.sourcePath}/**/*.move`,\n\t\t\t\t\t\t\t`${opts.sourcePath}/Move.toml`,\n\t\t\t\t\t\t\t`${opts.sourcePath}/Move.lock`,\n\t\t\t\t\t\t]\n\t\t\t\t\t: [],\n\t\t\tcascade: true,\n\t\t},\n\t\t// Stack-free codegen: the `codegen` verb derives this package's\n\t\t// committed-projection decls from config alone, drawing the\n\t\t// `packageId` from the projection resolver (sentinel / pinned). The\n\t\t// bindings emitter compiles a local `sourcePath` verbatim; a git\n\t\t// source's tree is only materialized at acquire, so it contributes no\n\t\t// stub bindings until the source is on disk (the live `.devstack`\n\t\t// overlay carries them when a stack is running).\n\t\tstaticCodegen: makeLocalStaticCodegen({\n\t\t\tname,\n\t\t\tsourcePath: opts.sourcePath ?? null,\n\t\t\tmvrPlaceholder: opts.mvrPlaceholder,\n\t\t\texcluded: opts.excludeFromCodegen ?? false,\n\t\t\tnetworks: opts.networks,\n\t\t\t// Capture KEYS (config-known) so the committed stub carries\n\t\t\t// `resolveValue('package:<name>:objects', '<key>')` references —\n\t\t\t// no live-only `objects` field, no baked object id.\n\t\t\t...(opts.capture !== undefined ? { objectKeys: Object.keys(opts.capture) } : {}),\n\t\t}),\n\t\t// `deps` auto-infers the resolved `{ sui, publisher }` dependency\n\t\t// object; `ctx` arrives via the `PluginContext` service.\n\t\tstart: ({ sui, publisher: publisherAccount }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\t// Resolve the build path first: clone a git source into the host\n\t\t\t\t// cache (cache hit after `inputIdentity` already materialized it),\n\t\t\t\t// or use the local `sourcePath` verbatim. Everything below — and\n\t\t\t\t// the contributions derived from `resolved.sourcePath` — then sees\n\t\t\t\t// a plain local directory.\n\t\t\t\tconst sourcePath = yield* resolveSourcePath();\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\t// Substrate-context primitives: ArtifactPublisher\n\t\t\t\t// is provided by the supervisor's pluginContext;\n\t\t\t\t// ChainProbe is looked up via the StrategyRegistry\n\t\t\t\t// (Sui registered itself there at acquire). The\n\t\t\t\t// PackageRegistry is a per-stack plugin-owned service\n\t\t\t\t// (a self-contained last-write-wins map — see\n\t\t\t\t// `registry.ts`) — every\n\t\t\t\t// package plugin in the stack yields the SAME instance\n\t\t\t\t// via `PackageRegistryService`, so cross-plugin lookups\n\t\t\t\t// stay consistent and warm-restart verify can use the\n\t\t\t\t// previous packageId as a hint.\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chainId);\n\t\t\t\tconst registry = yield* PackageRegistryService;\n\t\t\t\t// The per-stack CoinRegistry — same instance every plugin in\n\t\t\t\t// the stack yields via `CoinRegistryService` (the boot wiring\n\t\t\t\t// adds it to the plugin context via\n\t\t\t\t// `extendBuiltInPluginContext`). Local publish folds its\n\t\t\t\t// discovered coins into it directly (was the orchestrator's\n\t\t\t\t// `publishResultSink`).\n\t\t\t\tconst coinRegistry = yield* CoinRegistryService;\n\t\t\t\t// ContainerRuntime + the Sui plugin's resolved image feed\n\t\t\t\t// `runMoveBuild`'s path-(b) (`docker run --rm`) build path.\n\t\t\t\t// Sui surfaces `buildImage` on its resolved client; modes\n\t\t\t\t// without an in-stack image (external, live) surface null\n\t\t\t\t// — runMoveBuild then surfaces a typed error from path (c)\n\t\t\t\t// (host CLI not routed).\n\t\t\t\tconst containerRuntime = yield* ContainerRuntimeService;\n\n\t\t\t\t// Build the concrete `PublishExecutor` once per acquire.\n\t\t\t\t// Hands the resolved SuiSdkShim (for `Transaction.build`,\n\t\t\t\t// `executeTransaction`, `waitForTransaction`) and the\n\t\t\t\t// publisher account (for `signAndExecute`) to the executor\n\t\t\t\t// methods; mode-local's produce body drives them.\n\t\t\t\tconst executor = makePublishExecutor({\n\t\t\t\t\tsdk: sui.sdk,\n\t\t\t\t\taccount: publisherAccount,\n\t\t\t\t\truntime: containerRuntime,\n\t\t\t\t\tforkMode: sui.fork !== null,\n\t\t\t\t\t...(sui.buildImage !== null ? { buildImage: sui.buildImage } : {}),\n\t\t\t\t});\n\n\t\t\t\tconst mode = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tpackageName: name,\n\t\t\t\t\tsourcePath,\n\t\t\t\t\tchainId: sui.chainId,\n\t\t\t\t\tpublisherAddress: publisherAccount.address,\n\t\t\t\t\tmvrOverride: opts.mvrPlaceholder,\n\t\t\t\t\t...(capture !== undefined ? { capture } : {}),\n\t\t\t\t\texecutor,\n\t\t\t\t} satisfies PackageMode;\n\n\t\t\t\tconst { resolved, output } = yield* bootPackageService(publisher, probe, registry, mode);\n\n\t\t\t\tconst projected: LocalPackageResolved<Capture> = {\n\t\t\t\t\t...resolved,\n\t\t\t\t\tcaptured: resolved.captured as CapturedPackageValues<Capture>,\n\t\t\t\t\tpublisher: publisherAccount,\n\t\t\t\t\tpublishResult: output,\n\t\t\t\t};\n\t\t\t\t// Emit the resolved package's contributions inline via the\n\t\t\t\t// shared `emitContributions` router. `projected` is the\n\t\t\t\t// just-resolved local value; `makeLocalCapabilities` builds the\n\t\t\t\t// ordered decl list (snapshot, codegen, registry, projection).\n\t\t\t\temitContributions(ctx, makeLocalCapabilities(name, opts, projected));\n\t\t\t\t// Part 2 (custom-kind re-home): on a fresh publish, fold the\n\t\t\t\t// output's coins into the per-stack CoinRegistry DIRECTLY (was\n\t\t\t\t// the orchestrator's `publishResultSink` consuming the now-\n\t\t\t\t// dead `LOCAL_PACKAGE_PUBLISHED` decl). `output` is null on a\n\t\t\t\t// cache hit (verify path), so discovery is skipped then — the\n\t\t\t\t// registry was already populated on the fresh-publish run that\n\t\t\t\t// seeded the cache.\n\t\t\t\tif (output !== null) {\n\t\t\t\t\tyield* discoverPublishedCoins(coinRegistry, name, projected.packageId, output);\n\t\t\t\t}\n\t\t\t\treturn projected;\n\t\t\t}),\n\t});\n};\n\nconst buildKnownPlugin = <Name extends string>(name: Name, opts: KnownPackageOptions) => {\n\tconst packageRef = resource<PackageResourceId<Name>, KnownPackageResolved>(\n\t\tpackageResourceId(name),\n\t);\n\treturn definePlugin({\n\t\tid: packageRef.id,\n\t\tdependsOn: { sui: suiResource },\n\t\trole: 'task',\n\t\tsection: 'package',\n\t\tinputIdentity: staticInputIdentity({\n\t\t\tplugin: 'package',\n\t\t\tkind: 'known',\n\t\t\tname,\n\t\t\tpackageId: opts.packageId,\n\t\t\tupgradeCapId: opts.upgradeCapId ?? null,\n\t\t\tmvrPlaceholder: opts.mvrPlaceholder ?? null,\n\t\t\tnetworks: opts.networks ?? null,\n\t\t}),\n\t\t// Stack-free codegen: a known package's `packageId` is already a\n\t\t// config literal, so the committed stub emits it verbatim (no chain\n\t\t// contact, no sentinel substitution).\n\t\tstaticCodegen: makeKnownStaticCodegen({\n\t\t\tname,\n\t\t\tpackageId: opts.packageId,\n\t\t\tmvrPlaceholder: opts.mvrPlaceholder,\n\t\t\t...(opts.upgradeCapId !== undefined ? { upgradeCapId: opts.upgradeCapId } : {}),\n\t\t\tnetworks: opts.networks,\n\t\t}),\n\t\tstart: ({ sui }) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst publisher = yield* CacheService;\n\t\t\t\tconst probe = yield* chainProbeFor<SuiProbeKey>(sui.chainId);\n\t\t\t\tconst registry = yield* PackageRegistryService;\n\t\t\t\tconst mode = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tpackageName: name,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tupgradeCapId: opts.upgradeCapId,\n\t\t\t\t\tmvrOverride: opts.mvrPlaceholder,\n\t\t\t\t} satisfies PackageMode;\n\t\t\t\tconst { resolved } = yield* bootPackageService(publisher, probe, registry, mode);\n\t\t\t\t// Emit the resolved package's contributions inline via the\n\t\t\t\t// shared `emitContributions` router. `makeKnownCapabilities`\n\t\t\t\t// builds the ordered decl list (snapshot, codegen, registry,\n\t\t\t\t// projection).\n\t\t\t\temitContributions(ctx, makeKnownCapabilities(name, opts, resolved));\n\t\t\t\t// Known mode never publishes — no output to walk, so\n\t\t\t\t// the coin-discovery hook is skipped here. Users who\n\t\t\t\t// want coin records for a knownPackage point a\n\t\t\t\t// `coin.known('0xPKG::module::Witness')` at the\n\t\t\t\t// fully-qualified type directly; the bare-type path\n\t\t\t\t// hits the live RPC for metadata rather than the\n\t\t\t\t// output-walker.\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Capability builders — pure helpers returning the ordered decl list.\n//\n// The package `start` bodies feed these into the shared `emitContributions`\n// router after resolving the value. Decl shapes + emit ORDER are load-bearing.\n//\n// NOTE: the LOCAL builder does NOT append a custom published-coin decl.\n// Coin discovery runs DIRECTLY in the local `start` body (see\n// `discoverPublishedCoins`); appending a decl here would double-discover.\n// ---------------------------------------------------------------------------\n\nconst makeLocalCapabilities = (\n\tname: string,\n\topts: { readonly excludeFromCodegen?: boolean; readonly networks?: PackageNetworks },\n\tresolved: LocalPackageResolved,\n): ReadonlyArray<Contribution> => {\n\t// Snapshot + codegen lift their typed fields off the resolved\n\t// publish (real packageId + captured object ids). The static-form\n\t// placeholders are gone.\n\tconst snap: SnapshotableDecl = makeSnapshotable(\n\t\tname,\n\t\tresolved.publishResult?.packageId ?? resolved.packageId,\n\t);\n\tconst codegen: CodegenableDecl<'package'> = makeLocalCodegenable(\n\t\t{\n\t\t\tkind: 'local',\n\t\t\tname,\n\t\t\tpackageId: resolved.packageId,\n\t\t\tupgradeCapId: resolved.upgradeCapId,\n\t\t\tsourcePath: resolved.sourcePath,\n\t\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\t\tcaptured: resolved.captured,\n\t\t},\n\t\t{\n\t\t\texcluded: opts.excludeFromCodegen ?? false,\n\t\t\t...(opts.networks !== undefined ? { networks: opts.networks } : {}),\n\t\t},\n\t);\n\t// The plugin contributes to the package-registry strategy under a\n\t// fixed key — the substrate orchestrator wires all packages'\n\t// contributions into the same per-stack registry.\n\tconst projection: PackageRegistryProjectionContribution = {\n\t\tkind: 'local',\n\t\tname,\n\t\tpackageId: resolved.packageId,\n\t\tupgradeCapId: resolved.upgradeCapId ?? null,\n\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\tsourcePath: resolved.sourcePath,\n\t};\n\tconst registryContribution: StrategyContributorDecl<\n\t\ttypeof PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tPackageRegistryProjectionContribution\n\t> = {\n\t\tkind: 'strategy-contributor',\n\t\tcapabilityKey: PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tstrategy: projection,\n\t\tautoMounted: true,\n\t};\n\treturn [snap, codegen, registryContribution, makePackageProjectionContribution(projection)];\n};\n\nconst makeKnownCapabilities = (\n\tname: string,\n\topts: KnownPackageOptions,\n\tresolved: KnownPackageResolved,\n): ReadonlyArray<Contribution> => {\n\tconst snap: SnapshotableDecl = makeSnapshotable(name, `known:${resolved.packageId}`);\n\tconst codegen: CodegenableDecl<'package'> = makeKnownCodegenable(\n\t\t{\n\t\t\tkind: 'known',\n\t\t\tname,\n\t\t\tpackageId: resolved.packageId,\n\t\t\tupgradeCapId: resolved.upgradeCapId ?? opts.upgradeCapId,\n\t\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\t},\n\t\topts.networks !== undefined ? { networks: opts.networks } : {},\n\t);\n\tconst projection: PackageRegistryProjectionContribution = {\n\t\tkind: 'known',\n\t\tname,\n\t\tpackageId: resolved.packageId,\n\t\tupgradeCapId: resolved.upgradeCapId ?? opts.upgradeCapId ?? null,\n\t\tmvrPlaceholder: resolved.mvrPlaceholder,\n\t\tsourcePath: null,\n\t};\n\tconst registryContribution: StrategyContributorDecl<\n\t\ttypeof PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tPackageRegistryProjectionContribution\n\t> = {\n\t\tkind: 'strategy-contributor',\n\t\tcapabilityKey: PACKAGE_REGISTRY_CAPABILITY_KEY,\n\t\tstrategy: projection,\n\t\tautoMounted: true,\n\t};\n\treturn [snap, codegen, registryContribution, makePackageProjectionContribution(projection)];\n};\n\n/** Fold a fresh local-package publish output into the per-stack\n * `CoinRegistry`. Lifted VERBATIM from the orchestrator's former\n * `publishResultSink` (orchestrators/boot.ts): the same\n * `discoverCoinsFromPublish` walk + the same `CoinRecord` projection\n * (including the publisher-owns-cap gate on `treasuryCapId`).\n *\n * Re-homing this into the local `start` body — AFTER the publish output\n * is known, BEFORE `start` returns — preserves discovery timing: the\n * coin plugin `dependsOn` package, so it acquires only after package\n * readies, by which point the registry is already populated. The\n * previous decl-driven sink ran at the same point in the lifecycle\n * (post-`start` dispatch), so consumers see no ordering change. */\nexport const discoverPublishedCoins = (\n\tcoinRegistry: CoinRegistry,\n\tpackageName: string,\n\tpackageId: string,\n\toutput: LocalPackagePublishOutput,\n): Effect.Effect<void> =>\n\tEffect.gen(function* () {\n\t\tfor (const discovered of discoverCoinsFromPublish(output)) {\n\t\t\tconst record: CoinRecord = {\n\t\t\t\tkey: (discovered.symbol ?? discovered.witness).toLowerCase(),\n\t\t\t\ttype: discovered.fullCoinType,\n\t\t\t\twitness: discovered.witness,\n\t\t\t\tmoduleName: discovered.moduleName,\n\t\t\t\tdecimals: discovered.decimals ?? 0,\n\t\t\t\t...(discovered.symbol === undefined ? {} : { symbol: discovered.symbol }),\n\t\t\t\t...(discovered.displayName === undefined ? {} : { displayName: discovered.displayName }),\n\t\t\t\t...(discovered.iconUrl === undefined ? {} : { iconUrl: discovered.iconUrl }),\n\t\t\t\t...(!discovered.publisherOwnsCap || discovered.treasuryCapId === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { treasuryCapId: discovered.treasuryCapId }),\n\t\t\t\t...(discovered.metadataId === undefined ? {} : { metadataId: discovered.metadataId }),\n\t\t\t\tpackageId,\n\t\t\t\tpublishingPackageName: packageName,\n\t\t\t};\n\t\t\tyield* coinRegistry.register(record);\n\t\t}\n\t});\n\n// ---------------------------------------------------------------------------\n// Public factories\n// ---------------------------------------------------------------------------\n\n/** Build + publish a local Move package. The resolved value is\n * `LocalPackageResolved` so consumers that need bindings / source\n * path are typed correctly.\n *\n * Required `opts.publisher`: the account that signs the publish tx.\n * Pass the same `account('alice')` reference used elsewhere in the\n * stack — the package.s `dependsOn` includes `account/<publisher>`\n * so the substrate orders the publisher's keypair + funding strictly\n * before publish. */\nexport const localPackage = <\n\tName extends string,\n\tconst Publisher extends PublisherAccountMember,\n\tconst Capture extends PackageCapture | undefined = undefined,\n>(\n\tname: Name,\n\topts: LocalPackageOptions<Publisher, Capture>,\n) => buildLocalPlugin(name, opts);\n\n/** Verify-only against a fixed on-chain package id. The resolved\n * value is `KnownPackageResolved` — narrower than local, so the\n * bindings emitter rejects this at compose time. */\nexport const knownPackage = <Name extends string>(name: Name, opts: KnownPackageOptions) =>\n\tbuildKnownPlugin(name, opts);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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EAC1D,MAAM,SAAqB;GAC1B,MAAM,WAAW,UAAU,WAAW,QAAA,CAAS,YAAY;GAC3D,MAAM,WAAW;GACjB,SAAS,WAAW;GACpB,YAAY,WAAW;GACvB,UAAU,WAAW,YAAY;GACjC,GAAI,WAAW,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,WAAW,OAAO;GACvE,GAAI,WAAW,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,WAAW,YAAY;GACtF,GAAI,WAAW,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,WAAW,QAAQ;GAC1E,GAAI,CAAC,WAAW,oBAAoB,WAAW,kBAAkB,KAAA,IAC9D,CAAC,IACD,EAAE,eAAe,WAAW,cAAc;GAC7C,GAAI,WAAW,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,WAAW,WAAW;GACnF;GACA,uBAAuB;EACxB;EACA,OAAO,aAAa,SAAS,MAAM;CACpC;AACD,CAAC;;;;;;;;;;AAeF,MAAa,gBAKZ,MACA,SACI,iBAAiB,MAAM,IAAI;;;;AAKhC,MAAa,gBAAqC,MAAY,SAC7D,iBAAiB,MAAM,IAAI"}
@@ -1,6 +1,6 @@
1
1
  import "./registry.mjs";
2
+ import { mvrNamedForm } from "./dep-resolution.mjs";
2
3
  import { publishError } from "./errors.mjs";
3
- import { mvrSlugify } from "./dep-resolution.mjs";
4
4
  import { Effect, Schema } from "effect";
5
5
  //#region src/plugins/package/mode-known.ts
6
6
  /** Verify-schema for known mode — minimum signal: object exists at
@@ -23,7 +23,7 @@ const KnownObjectShape = Schema.Struct({ objectId: Schema.String });
23
23
  * verify failure.
24
24
  */
25
25
  const acquireKnown = (probe, registry, inputs) => Effect.gen(function* () {
26
- const mvrPlaceholder = mvrSlugify(inputs.mvrOverride ?? inputs.packageName);
26
+ const mvrPlaceholder = mvrNamedForm(inputs.mvrOverride ?? inputs.packageName);
27
27
  const verifyError = (message) => publishError("verify", {
28
28
  sourcePath: `known:${inputs.packageId}`,
29
29
  packageName: inputs.packageName,
@@ -1 +1 @@
1
- {"version":3,"file":"mode-known.mjs","names":[],"sources":["../../../src/plugins/package/mode-known.ts"],"sourcesContent":["// Known mode — skip publish; load existing package id from on-chain.\n//\n// Distilled doc §Responsibilities + §Inputs/dependencies §KnownPackage-\n// only: a `KnownPackage` declares a fixed `packageId` (optionally\n// `upgradeCapId`, `mvrPlaceholder`) and threads through the same\n// registries as a freshly published one. No build, no publish-tx, no\n// cache key folding by content-hash — the id IS the identity.\n//\n// What we still do:\n//\n// 1. Strict verify probe (chain reachable + object exists). Strict\n// mode lets the ChainProbe distinguish an authoritative miss from a\n// transient RPC failure. Two miss shapes surface a\n// PublishError(phase='verify') so the user catches the typo /\n// wrong-network mistake at boot:\n// - `reason: 'not-found'` — no object at the id.\n// - `reason: 'decode-failed'` — an object exists at the id but\n// its on-chain shape does not satisfy `KnownObjectShape`\n// (a wrong-kind object — the typical wrong-network / copy-paste\n// mistake). This is a THROWN `ChainProbeError`, not a `null`\n// result, because the real Sui probe fails Schema decode on a\n// wrong-shape id.\n// Only genuinely-transient reasons (`'transient'`,\n// `'no-probe-registered'`) are masked (no abort) — the id re-verifies\n// on the next cycle rather than failing boot on a flaky RPC. A `null`\n// strict result (object decodes against the minimal shape but the\n// probe still reports absence) is also treated as a verify failure.\n// 2. Register the resolved value on EVERY cycle.\n//\n// Bindings: KnownPackage cannot be bound by `@mysten/codegen` (no\n// source tree). The codegen contribution emitted for known packages\n// has `sourcePath: null`; the codegen orchestrator filters those\n// out before invoking the bindings emitter. The user-facing type\n// split (`localPackage` vs `knownPackage` factories) enforces this\n// at compose time per distilled doc Invariant 9.\n\nimport { Effect, Schema, type Scope } from 'effect';\n\nimport type { ChainProbe } from '../../contracts/chain-probe.ts';\nimport type { SuiProbeKey } from '../sui/index.ts';\nimport { mvrSlugify } from './dep-resolution.ts';\nimport { type PackageRegistry, type ResolvedKnownPackage } from './registry.ts';\nimport { publishError, type PublishError } from './errors.ts';\n\n/** Verify-schema for known mode — minimum signal: object exists at\n * the given id. */\nconst KnownObjectShape = Schema.Struct({\n\tobjectId: Schema.String,\n});\n\nexport interface KnownModeInputs {\n\treadonly packageName: string;\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly mvrOverride?: string;\n}\n\nexport interface KnownModeOutputs {\n\treadonly resolved: ResolvedKnownPackage;\n}\n\n/**\n * Acquire body for known mode.\n *\n * Runs a strict ChainProbe verify and registers the resolved value.\n * Strict mode surfaces a typed `ChainProbeError` whose `reason`\n * discriminates an authoritative miss from a transient RPC failure, so we\n * can fail boot on a real typo / wrong-network mistake while masking\n * transient failures so a flaky RPC does not abort boot:\n * - `reason: 'not-found'` → verify failure (no object at the id).\n * - `reason: 'decode-failed'` → verify failure (an object exists but is\n * the wrong object kind — its on-chain shape fails `KnownObjectShape`).\n * - `reason: 'transient' | 'no-probe-registered'` → masked; the verify\n * re-runs on the next cycle.\n * A `null` strict payload (probe reports absence after decode) is also a\n * verify failure.\n */\nexport const acquireKnown = (\n\tprobe: ChainProbe<SuiProbeKey>,\n\tregistry: PackageRegistry,\n\tinputs: KnownModeInputs,\n): Effect.Effect<KnownModeOutputs, PublishError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst mvrPlaceholder = mvrSlugify(inputs.mvrOverride ?? inputs.packageName);\n\n\t\tconst verifyError = (message: string): PublishError =>\n\t\t\tpublishError('verify', {\n\t\t\t\tsourcePath: `known:${inputs.packageId}`,\n\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\tmessage,\n\t\t\t});\n\t\t// `'transient'` is a sentinel for \"masked transient RPC failure —\n\t\t// skip the verify aborts and re-derive next cycle\".\n\t\tconst found: { readonly objectId: string } | null | 'transient' = yield* probe\n\t\t\t.get({ kind: 'object', objectId: inputs.packageId }, KnownObjectShape, 'strict')\n\t\t\t.pipe(\n\t\t\t\t// Classify the strict-probe failure. An authoritative miss\n\t\t\t\t// (`not-found`) and a wrong-kind object (`decode-failed` — an\n\t\t\t\t// object exists at the id but its shape does not satisfy\n\t\t\t\t// `KnownObjectShape`) BOTH surface a verify error: they are the\n\t\t\t\t// typo / wrong-network mistakes strict mode exists to catch. Only\n\t\t\t\t// genuinely-transient reasons (`transient`, `no-probe-registered`)\n\t\t\t\t// are masked so the id re-verifies next cycle rather than aborting\n\t\t\t\t// boot on a flaky RPC.\n\t\t\t\tEffect.catch((err) => {\n\t\t\t\t\tswitch (err.reason) {\n\t\t\t\t\t\tcase 'not-found':\n\t\t\t\t\t\t\treturn Effect.fail(\n\t\t\t\t\t\t\t\tverifyError(\n\t\t\t\t\t\t\t\t\t`known package id ${inputs.packageId} does not exist on this chain — check for a typo or wrong network.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tcase 'decode-failed':\n\t\t\t\t\t\t\treturn Effect.fail(\n\t\t\t\t\t\t\t\tverifyError(\n\t\t\t\t\t\t\t\t\t`known package id ${inputs.packageId} resolved to an unexpected object shape on this chain — check for a typo or wrong network.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn Effect.succeed('transient' as const);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t// A `null` strict result means the id exists but is not the\n\t\t// expected object kind — also a verify failure.\n\t\tif (found === null) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tverifyError(\n\t\t\t\t\t`known package id ${inputs.packageId} resolved to an unexpected object shape on this chain.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst resolved: ResolvedKnownPackage = {\n\t\t\tkind: 'known',\n\t\t\tname: inputs.packageName,\n\t\t\tpackageId: inputs.packageId,\n\t\t\tupgradeCapId: inputs.upgradeCapId,\n\t\t\tmvrPlaceholder,\n\t\t};\n\n\t\t// Distilled doc Invariant 6: register on EVERY cycle (here\n\t\t// always — known mode has no \"miss\" branch).\n\t\tyield* registry.set(resolved.name, resolved);\n\n\t\treturn { resolved };\n\t});\n"],"mappings":";;;;;;;AA8CA,MAAM,mBAAmB,OAAO,OAAO,EACtC,UAAU,OAAO,QACjB,CAAC;;;;;;;;;;;;;;;;;AA6BF,MAAa,gBACZ,OACA,UACA,WAEA,OAAO,IAAI,aAAa;CACvB,MAAM,iBAAiB,WAAW,OAAO,eAAe,OAAO,YAAY;CAE3E,MAAM,eAAe,YACpB,aAAa,UAAU;EACtB,YAAY,SAAS,OAAO;EAC5B,aAAa,OAAO;EACpB;EACA,CAAC;AAmCH,MAAI,OAhCqE,MACvE,IAAI;EAAE,MAAM;EAAU,UAAU,OAAO;EAAW,EAAE,kBAAkB,SAAS,CAC/E,KASA,OAAO,OAAO,QAAQ;AACrB,UAAQ,IAAI,QAAZ;GACC,KAAK,YACJ,QAAO,OAAO,KACb,YACC,oBAAoB,OAAO,UAAU,oEACrC,CACD;GACF,KAAK,gBACJ,QAAO,OAAO,KACb,YACC,oBAAoB,OAAO,UAAU,4FACrC,CACD;GACF,QACC,QAAO,OAAO,QAAQ,YAAqB;;GAE5C,CACF,MAGY,KACb,QAAO,OAAO,OAAO,KACpB,YACC,oBAAoB,OAAO,UAAU,wDACrC,CACD;CAGF,MAAM,WAAiC;EACtC,MAAM;EACN,MAAM,OAAO;EACb,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB;EACA;AAID,QAAO,SAAS,IAAI,SAAS,MAAM,SAAS;AAE5C,QAAO,EAAE,UAAU;EAClB"}
1
+ {"version":3,"file":"mode-known.mjs","names":[],"sources":["../../../src/plugins/package/mode-known.ts"],"sourcesContent":["// Known mode — skip publish; load existing package id from on-chain.\n//\n// Distilled doc §Responsibilities + §Inputs/dependencies §KnownPackage-\n// only: a `KnownPackage` declares a fixed `packageId` (optionally\n// `upgradeCapId`, `mvrPlaceholder`) and threads through the same\n// registries as a freshly published one. No build, no publish-tx, no\n// cache key folding by content-hash — the id IS the identity.\n//\n// What we still do:\n//\n// 1. Strict verify probe (chain reachable + object exists). Strict\n// mode lets the ChainProbe distinguish an authoritative miss from a\n// transient RPC failure. Two miss shapes surface a\n// PublishError(phase='verify') so the user catches the typo /\n// wrong-network mistake at boot:\n// - `reason: 'not-found'` — no object at the id.\n// - `reason: 'decode-failed'` — an object exists at the id but\n// its on-chain shape does not satisfy `KnownObjectShape`\n// (a wrong-kind object — the typical wrong-network / copy-paste\n// mistake). This is a THROWN `ChainProbeError`, not a `null`\n// result, because the real Sui probe fails Schema decode on a\n// wrong-shape id.\n// Only genuinely-transient reasons (`'transient'`,\n// `'no-probe-registered'`) are masked (no abort) — the id re-verifies\n// on the next cycle rather than failing boot on a flaky RPC. A `null`\n// strict result (object decodes against the minimal shape but the\n// probe still reports absence) is also treated as a verify failure.\n// 2. Register the resolved value on EVERY cycle.\n//\n// Bindings: KnownPackage cannot be bound by `@mysten/codegen` (no\n// source tree). The codegen contribution emitted for known packages\n// has `sourcePath: null`; the codegen orchestrator filters those\n// out before invoking the bindings emitter. The user-facing type\n// split (`localPackage` vs `knownPackage` factories) enforces this\n// at compose time per distilled doc Invariant 9.\n\nimport { Effect, Schema, type Scope } from 'effect';\n\nimport type { ChainProbe } from '../../contracts/chain-probe.ts';\nimport type { SuiProbeKey } from '../sui/index.ts';\nimport { mvrNamedForm } from './dep-resolution.ts';\nimport { type PackageRegistry, type ResolvedKnownPackage } from './registry.ts';\nimport { publishError, type PublishError } from './errors.ts';\n\n/** Verify-schema for known mode — minimum signal: object exists at\n * the given id. */\nconst KnownObjectShape = Schema.Struct({\n\tobjectId: Schema.String,\n});\n\nexport interface KnownModeInputs {\n\treadonly packageName: string;\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly mvrOverride?: string;\n}\n\nexport interface KnownModeOutputs {\n\treadonly resolved: ResolvedKnownPackage;\n}\n\n/**\n * Acquire body for known mode.\n *\n * Runs a strict ChainProbe verify and registers the resolved value.\n * Strict mode surfaces a typed `ChainProbeError` whose `reason`\n * discriminates an authoritative miss from a transient RPC failure, so we\n * can fail boot on a real typo / wrong-network mistake while masking\n * transient failures so a flaky RPC does not abort boot:\n * - `reason: 'not-found'` → verify failure (no object at the id).\n * - `reason: 'decode-failed'` → verify failure (an object exists but is\n * the wrong object kind — its on-chain shape fails `KnownObjectShape`).\n * - `reason: 'transient' | 'no-probe-registered'` → masked; the verify\n * re-runs on the next cycle.\n * A `null` strict payload (probe reports absence after decode) is also a\n * verify failure.\n */\nexport const acquireKnown = (\n\tprobe: ChainProbe<SuiProbeKey>,\n\tregistry: PackageRegistry,\n\tinputs: KnownModeInputs,\n): Effect.Effect<KnownModeOutputs, PublishError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\t// Named MVR form (`@local/<slug>`) — see mode-local.ts. Mirrors the\n\t\t// local path so known + local packages key the override map the\n\t\t// same way.\n\t\tconst mvrPlaceholder = mvrNamedForm(inputs.mvrOverride ?? inputs.packageName);\n\n\t\tconst verifyError = (message: string): PublishError =>\n\t\t\tpublishError('verify', {\n\t\t\t\tsourcePath: `known:${inputs.packageId}`,\n\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\tmessage,\n\t\t\t});\n\t\t// `'transient'` is a sentinel for \"masked transient RPC failure —\n\t\t// skip the verify aborts and re-derive next cycle\".\n\t\tconst found: { readonly objectId: string } | null | 'transient' = yield* probe\n\t\t\t.get({ kind: 'object', objectId: inputs.packageId }, KnownObjectShape, 'strict')\n\t\t\t.pipe(\n\t\t\t\t// Classify the strict-probe failure. An authoritative miss\n\t\t\t\t// (`not-found`) and a wrong-kind object (`decode-failed` — an\n\t\t\t\t// object exists at the id but its shape does not satisfy\n\t\t\t\t// `KnownObjectShape`) BOTH surface a verify error: they are the\n\t\t\t\t// typo / wrong-network mistakes strict mode exists to catch. Only\n\t\t\t\t// genuinely-transient reasons (`transient`, `no-probe-registered`)\n\t\t\t\t// are masked so the id re-verifies next cycle rather than aborting\n\t\t\t\t// boot on a flaky RPC.\n\t\t\t\tEffect.catch((err) => {\n\t\t\t\t\tswitch (err.reason) {\n\t\t\t\t\t\tcase 'not-found':\n\t\t\t\t\t\t\treturn Effect.fail(\n\t\t\t\t\t\t\t\tverifyError(\n\t\t\t\t\t\t\t\t\t`known package id ${inputs.packageId} does not exist on this chain — check for a typo or wrong network.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tcase 'decode-failed':\n\t\t\t\t\t\t\treturn Effect.fail(\n\t\t\t\t\t\t\t\tverifyError(\n\t\t\t\t\t\t\t\t\t`known package id ${inputs.packageId} resolved to an unexpected object shape on this chain — check for a typo or wrong network.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn Effect.succeed('transient' as const);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t// A `null` strict result means the id exists but is not the\n\t\t// expected object kind — also a verify failure.\n\t\tif (found === null) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tverifyError(\n\t\t\t\t\t`known package id ${inputs.packageId} resolved to an unexpected object shape on this chain.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst resolved: ResolvedKnownPackage = {\n\t\t\tkind: 'known',\n\t\t\tname: inputs.packageName,\n\t\t\tpackageId: inputs.packageId,\n\t\t\tupgradeCapId: inputs.upgradeCapId,\n\t\t\tmvrPlaceholder,\n\t\t};\n\n\t\t// Distilled doc Invariant 6: register on EVERY cycle (here\n\t\t// always — known mode has no \"miss\" branch).\n\t\tyield* registry.set(resolved.name, resolved);\n\n\t\treturn { resolved };\n\t});\n"],"mappings":";;;;;;;AA8CA,MAAM,mBAAmB,OAAO,OAAO,EACtC,UAAU,OAAO,OAClB,CAAC;;;;;;;;;;;;;;;;;AA6BD,MAAa,gBACZ,OACA,UACA,WAEA,OAAO,IAAI,aAAa;CAIvB,MAAM,iBAAiB,aAAa,OAAO,eAAe,OAAO,WAAW;CAE5E,MAAM,eAAe,YACpB,aAAa,UAAU;EACtB,YAAY,SAAS,OAAO;EAC5B,aAAa,OAAO;EACpB;CACD,CAAC;CAmCF,KAAI,OAhCqE,MACvE,IAAI;EAAE,MAAM;EAAU,UAAU,OAAO;CAAU,GAAG,kBAAkB,QAAQ,CAAC,CAC/E,KASA,OAAO,OAAO,QAAQ;EACrB,QAAQ,IAAI,QAAZ;GACC,KAAK,aACJ,OAAO,OAAO,KACb,YACC,oBAAoB,OAAO,UAAU,mEACtC,CACD;GACD,KAAK,iBACJ,OAAO,OAAO,KACb,YACC,oBAAoB,OAAO,UAAU,2FACtC,CACD;GACD,SACC,OAAO,OAAO,QAAQ,WAAoB;EAC5C;CACD,CAAC,CACF,OAGa,MACb,OAAO,OAAO,OAAO,KACpB,YACC,oBAAoB,OAAO,UAAU,uDACtC,CACD;CAGD,MAAM,WAAiC;EACtC,MAAM;EACN,MAAM,OAAO;EACb,WAAW,OAAO;EAClB,cAAc,OAAO;EACrB;CACD;CAIA,OAAO,SAAS,IAAI,SAAS,MAAM,QAAQ;CAE3C,OAAO,EAAE,SAAS;AACnB,CAAC"}
@@ -1,11 +1,10 @@
1
1
  import { contentHash } from "../../substrate/brand.mjs";
2
- import { pickPublishedChange, pickUpgradeCapChange } from "./publish-output.mjs";
2
+ import { withMoveBuildLock } from "../sui/move/index.mjs";
3
3
  import "./registry.mjs";
4
+ import { artifactPublishError } from "../../primitives/artifact-publisher.mjs";
5
+ import { mvrNamedForm } from "./dep-resolution.mjs";
4
6
  import { publishError } from "./errors.mjs";
5
7
  import { hashMoveSources, scrubLocksHost } from "./build.mjs";
6
- import { PackageSpans } from "./spans.mjs";
7
- import { mvrSlugify } from "./dep-resolution.mjs";
8
- import { artifactPublishError } from "../../primitives/artifact-publisher.mjs";
9
8
  import { Duration, Effect, Schema } from "effect";
10
9
  //#region src/plugins/package/mode-local.ts
11
10
  /** Verify-schema: what we expect when probing `getObject(packageId)`.
@@ -77,7 +76,7 @@ const acquireLocal = (publisher, probe, registry, inputs) => Effect.gen(function
77
76
  message: `localPackage('${inputs.packageName}') is declared twice in the same stack with different sourcePaths (${existing.sourcePath} vs ${inputs.sourcePath}). The substrate is name-blind at runtime and the second declaration would silently overwrite the first registry entry. Pick distinct package names (the symbolic name is the registry key consumers look up).`
78
77
  }));
79
78
  const inputsHash = combineInputsHash(yield* hashMoveSources(inputs.sourcePath), inputs.publisherAddress);
80
- const mvrPlaceholder = mvrSlugify(inputs.mvrOverride ?? inputs.packageName);
79
+ const mvrPlaceholder = mvrNamedForm(inputs.mvrOverride ?? inputs.packageName);
81
80
  let producedOutput = null;
82
81
  const entry = yield* publisher.publish({
83
82
  namespace: "package",
@@ -85,25 +84,18 @@ const acquireLocal = (publisher, probe, registry, inputs) => Effect.gen(function
85
84
  contentHash: inputsHash,
86
85
  verify: (cached) => cached.output === void 0 ? Effect.succeed(null) : buildVerifyProbe(probe, cached.packageId),
87
86
  produce: Effect.gen(function* () {
88
- yield* Effect.annotateCurrentSpan({
89
- [PackageSpans.publish.package]: inputs.packageName,
90
- [PackageSpans.publish.sourcePath]: inputs.sourcePath,
91
- [PackageSpans.publish.chainId]: inputs.chainId,
92
- [PackageSpans.publish.publisher]: inputs.publisherAddress
93
- });
94
- yield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: "scrub" });
95
- yield* scrubLocksHost(inputs.sourcePath, "~/.move");
96
- yield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: "build" });
97
- const buildOutput = yield* inputs.executor.build({
98
- sourcePath: inputs.sourcePath,
99
- packageName: inputs.packageName,
100
- chainId: inputs.chainId
101
- }).pipe(Effect.catchTag("PublishError", (err) => Effect.fail(err.sourcePath ? err : {
102
- ...err,
103
- sourcePath: inputs.sourcePath,
104
- packageName: inputs.packageName
105
- })));
106
- yield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: "publish-tx" });
87
+ const buildOutput = yield* withMoveBuildLock(Effect.gen(function* () {
88
+ yield* scrubLocksHost(inputs.sourcePath, "~/.move");
89
+ return yield* inputs.executor.build({
90
+ sourcePath: inputs.sourcePath,
91
+ packageName: inputs.packageName,
92
+ chainId: inputs.chainId
93
+ }).pipe(Effect.catchTag("PublishError", (err) => Effect.fail(err.sourcePath ? err : {
94
+ ...err,
95
+ sourcePath: inputs.sourcePath,
96
+ packageName: inputs.packageName
97
+ })));
98
+ }));
107
99
  const output = yield* inputs.executor.publishTx({
108
100
  modules: buildOutput.modules,
109
101
  dependencies: buildOutput.dependencies,
@@ -111,16 +103,7 @@ const acquireLocal = (publisher, probe, registry, inputs) => Effect.gen(function
111
103
  packageName: inputs.packageName
112
104
  });
113
105
  producedOutput = output;
114
- yield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: "waiting-for-index" });
115
106
  yield* inputs.executor.postPublishReadyHint(output.packageId);
116
- yield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: "parse" });
117
- const published = pickPublishedChange(output.objectChanges);
118
- if (!published?.objectId) return yield* Effect.fail(publishError("parse", {
119
- sourcePath: inputs.sourcePath,
120
- packageName: inputs.packageName,
121
- message: "no \"published\" change in output — SDK shape drift (distilled doc §Edge cases)"
122
- }));
123
- const upgradeCap = pickUpgradeCapChange(output.objectChanges);
124
107
  const captured = inputs.capture ? yield* Effect.try({
125
108
  try: () => inputs.capture(output),
126
109
  catch: (cause) => publishError("parse", {
@@ -131,8 +114,8 @@ const acquireLocal = (publisher, probe, registry, inputs) => Effect.gen(function
131
114
  })
132
115
  }) : {};
133
116
  return {
134
- packageId: published.objectId,
135
- upgradeCapId: upgradeCap?.objectId,
117
+ packageId: output.packageId,
118
+ upgradeCapId: output.upgradeCapId,
136
119
  publisher: inputs.publisherAddress,
137
120
  mvrPlaceholder,
138
121
  captured,
@@ -1 +1 @@
1
- {"version":3,"file":"mode-local.mjs","names":["brandContentHash"],"sources":["../../../src/plugins/package/mode-local.ts"],"sourcesContent":["// Local mode — build from source + publish.\n//\n// This is the canonical implementation of the\n// `ArtifactPublisher` substrate primitive (distilled doc\n// §Generic artifact-publisher-publish pattern). The five-phase shape:\n//\n// 1. Inputs — `{ sourceHash, signerAddress }` →\n// `contentHash(inputs)`.\n// 2. Cache key — `<namespace=package>/<chainId>/<contentHash>`.\n// Substrate folds in chainId for us; we hand\n// it the namespace + contentHash.\n// 3. Verify — `chainProbe.get({ objectId: cachedId },\n// PackageObjectSchema, 'lenient')`. Lenient mode\n// coerces transient RPC failure → null\n// → re-derive (cheap over-derive vs spurious\n// eviction — distilled doc §Constraint \"lenient\n// verify is cheaper than aggressive eviction\").\n// 4. Produce — scrub locks → build → publish-tx → wait-for-\n// index. Each phase narrates to TUI via span\n// annotation.\n// 5. Register — write registry entry on EVERY cycle (hit AND\n// miss). Distilled doc Invariant 6.\n//\n// The publish output is exposed on the resolved value and emitted as a\n// package-owned extension contribution for sibling folds.\n\nimport { Duration, Effect, Schema, type Scope } from 'effect';\n\nimport { contentHash as brandContentHash, type ChainId } from '../../substrate/brand.ts';\nimport {\n\tpickPublishedChange,\n\tpickUpgradeCapChange,\n\ttype PackagePublishObjectChange,\n\ttype LocalPackagePublishOutput,\n} from './publish-output.ts';\nimport {\n\tartifactPublishError,\n\ttype ArtifactPublishError,\n\ttype ArtifactPublisher,\n} from '../../primitives/artifact-publisher.ts';\nimport type { ChainProbe } from '../../contracts/chain-probe.ts';\nimport type { SuiProbeKey } from '../sui/index.ts';\nimport { hashMoveSources, scrubLocksHost, type BuildOutput } from './build.ts';\nimport { mvrSlugify } from './dep-resolution.ts';\nimport { type PackageRegistry, type ResolvedLocalPackage } from './registry.ts';\nimport { publishError, type PublishError } from './errors.ts';\nimport { PackageSpans } from './spans.ts';\n\n/** Cache-stored payload — the stable id verify re-confirms on\n * every cycle. Distilled doc Invariant 8: the probe MUST consume\n * a stable identifier (the packageId), NOT a derived hash. */\nexport interface CachedPackageEntry {\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly publisher: string;\n\treadonly mvrPlaceholder: string;\n\treadonly captured: Readonly<Record<string, string>>;\n\treadonly output?: LocalPackagePublishOutput;\n}\n\n/** Verify-schema: what we expect when probing `getObject(packageId)`.\n * Minimal — the substrate's `ChainProbe` decodes against this; any\n * decode failure surfaces structured. */\nexport const PackageVerifyShape = Schema.Struct({\n\tobjectId: Schema.String,\n\t// A Move package's `type` is the literal `\"package\"` wrapper;\n\t// the SDK's exact shape varies — we keep it open as `Unknown`\n\t// and rely on objectId presence for the \"exists\" signal.\n\ttype: Schema.Unknown,\n});\n\n/**\n * Publish-tx executor — narrow shim that abstracts the concrete\n * `@mysten/sui` wiring (Transaction builder, signer, fullnode\n * ready-probe). The mode-local produce body composes its 5-phase\n * shape against this interface; the concrete implementation lives in\n * `publish-executor.ts` and is constructed once per acquire by the\n * barrel from the resolved `SuiClient` + publisher `AccountValue` +\n * `ContainerRuntime`.\n *\n * The shim parallels `coin/mint.ts::MintSigner` + `MintSdkShim`. We\n * keep them split (publish vs sign vs ready-probe) so the produce\n * body can attribute span annotations per phase + so failures map\n * back to a typed `PublishError` phase enum.\n */\nexport interface PublishExecutor {\n\treadonly scrubsInsideContainer: boolean;\n\n\t/** Build the Move source tree into `{ modules, dependencies }`.\n\t * Dispatches between (a) per-app build container, (b) fresh\n\t * `docker run --rm`, (c) host `sui` CLI. The produce body just\n\t * calls and propagates `PublishError`. */\n\treadonly build: (inputs: {\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t\treadonly chainId: ChainId;\n\t}) => Effect.Effect<BuildOutput, PublishError, Scope.Scope>;\n\n\t/** Construct + sign + execute a `Transaction.publish({modules,\n\t * dependencies})` against the publisher account. Returns the\n\t * output projection that downstream consumers (Coin, manifest,\n\t * capture spec) need. Distilled doc §Move-specific concerns —\n\t * the output is the source of `published` change + the\n\t * `UpgradeCap` `created` change. */\n\treadonly publishTx: (inputs: {\n\t\treadonly modules: ReadonlyArray<Uint8Array>;\n\t\treadonly dependencies: ReadonlyArray<string>;\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t}) => Effect.Effect<LocalPackagePublishOutput, PublishError, Scope.Scope>;\n\n\t/** Post-publish fullnode/indexer ready HINT. Distilled doc\n\t * Invariant 5: publish-tx commit precedes index visibility. This\n\t * is BEST-EFFORT — the concrete executor swallows transient\n\t * `getObject` misses (cold index races) because the publisher\n\t * account's `signAndExecute` already calls `waitForTransaction`\n\t * before returning, AND the downstream `parse` phase only\n\t * inspects the publish output. A typed `PublishError('parse')`\n\t * surfaces only when the `getObject` infrastructure itself\n\t * faults (network down / SDK throws non-recoverably), NOT when\n\t * the object is merely not-yet-indexed.\n\t *\n\t * The \"Hint\" suffix encodes the contract: callers MUST NOT treat\n\t * a successful return as \"package definitely queryable now\". */\n\treadonly postPublishReadyHint: (\n\t\tpackageId: string,\n\t) => Effect.Effect<void, PublishError, Scope.Scope>;\n}\n\nexport interface LocalModeInputs {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly chainId: ChainId;\n\treadonly publisherAddress: string;\n\treadonly mvrOverride?: string;\n\treadonly capture?: (output: LocalPackagePublishOutput) => Readonly<Record<string, string>>;\n\t/** Publish executor — constructed per-acquire by the barrel from\n\t * the resolved SuiClient + publisher account + ContainerRuntime\n\t * (see `publish-executor.ts`). */\n\treadonly executor: PublishExecutor;\n}\n\nexport interface LocalModeOutputs {\n\treadonly resolved: ResolvedLocalPackage;\n\treadonly output: LocalPackagePublishOutput | null;\n}\n\n/**\n * Build the content hash for the publish cache key. Distilled doc\n * §Move-specific: inputs are `(sourceHash, signerAddress)`. The\n * `hashMoveSources` helper already normalises Move.lock pinned\n * sections via the shared `stripPinnedSections`; we fold the\n * publisher address in here as a stable string so reusing the\n * same source under a different signer correctly misses (Invariant\n * 4: \"Signer MUST be an explicit upstream\").\n */\nconst LOCAL_PACKAGE_CACHE_SCHEMA_VERSION = 'v3';\nconst PACKAGE_CACHE_VERIFY_MAX_ATTEMPTS = 20;\nconst PACKAGE_CACHE_VERIFY_DELAY_MS = 250;\n\nconst combineInputsHash = (sourceHash: string, publisherAddress: string) =>\n\tbrandContentHash(\n\t\t`${LOCAL_PACKAGE_CACHE_SCHEMA_VERSION}::source=${sourceHash}::publisher=${publisherAddress}`,\n\t);\n\n/**\n * Verify probe — lenient `getObject(packageId)`. Returns the decoded\n * shape on success; null for BOTH not-found AND transient (distilled\n * doc Invariant 7 + the \"lenient verify cheaper than aggressive\n * eviction\" Constraint).\n *\n * The cached id is hinted in via parameter. The artifact publisher substrate is\n * expected to thread the cached payload through to this closure on\n * cache hit; today we get the id from the registry's previous-cycle\n * entry (in-process, per-supervisor lookup — see `acquireLocal`\n * below). When no hint exists (first cycle / cold boot), we\n * short-circuit to null so the substrate runs `produce`.\n *\n * Mirrors `coin/mint.ts::buildVerifyProbe` exactly so the two artifact publisher\n * consumers stay shape-aligned.\n */\nexport const buildVerifyProbe = (\n\tprobe: ChainProbe<SuiProbeKey>,\n\tcachedPackageIdHint: string | null,\n\topts?: { readonly maxAttempts?: number; readonly delayMs?: number },\n): Effect.Effect<typeof PackageVerifyShape.Type | null, never> =>\n\tEffect.gen(function* () {\n\t\tif (cachedPackageIdHint === null) return null;\n\t\tconst maxAttempts = opts?.maxAttempts ?? PACKAGE_CACHE_VERIFY_MAX_ATTEMPTS;\n\t\tconst delayMs = opts?.delayMs ?? PACKAGE_CACHE_VERIFY_DELAY_MS;\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\t// Lenient mode in the underlying probe already coerces\n\t\t\t// not-found AND transient → null. We retry nulls briefly\n\t\t\t// because local Sui restart can report ready before package\n\t\t\t// objects are immediately queryable, and a false cache miss\n\t\t\t// turns a warm restart into an unnecessary publish.\n\t\t\tconst result: typeof PackageVerifyShape.Type | null = yield* probe\n\t\t\t\t.get({ kind: 'object', objectId: cachedPackageIdHint }, PackageVerifyShape, 'lenient')\n\t\t\t\t.pipe(\n\t\t\t\t\t// The probe's own error channel is `ChainProbeError`; under\n\t\t\t\t\t// lenient mode only `decode-failed` surfaces (not-found +\n\t\t\t\t\t// transient already coerce to null). A decode failure on\n\t\t\t\t\t// verify is treated as \"stale shape\" — null so the substrate\n\t\t\t\t\t// re-publishes rather than carry forward a mismatch.\n\t\t\t\t\tEffect.catch(() => Effect.succeed(null as typeof PackageVerifyShape.Type | null)),\n\t\t\t\t);\n\t\t\tif (result !== null) return result;\n\t\t\tif (attempt < maxAttempts && delayMs > 0) {\n\t\t\t\tyield* Effect.sleep(Duration.millis(delayMs));\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t});\n\n/**\n * Compose the ArtifactSpec for a local publish.\n *\n * The substrate-side `ArtifactPublisher.publish` consumes\n * this spec and handles:\n *\n * - cache lookup under `<namespace>/<chainId>/<contentHash>`;\n * - verify (lenient) when there's a hit;\n * - re-running `produce` on miss OR verify-fail;\n * - calling `register` on EVERY cycle.\n */\nexport const acquireLocal = (\n\tpublisher: ArtifactPublisher,\n\tprobe: ChainProbe<SuiProbeKey>,\n\tregistry: PackageRegistry,\n\tinputs: LocalModeInputs,\n): Effect.Effect<LocalModeOutputs, PublishError | ArtifactPublishError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\t// Intra-stack name collision guard.\n\t\t//\n\t\t// The registry is keyed by symbolic `packageName`; two\n\t\t// `localPackage('foo', ...)` calls in the same stack would both\n\t\t// call `register({ name: 'foo', ... })` and the second `set`\n\t\t// would silently overwrite the first. Upstream's\n\t\t// `resolveGraph` (substrate/runtime/lifecycle/dep-graph.ts:127)\n\t\t// explicitly documents \"we don't enforce uniqueness at runtime;\n\t\t// the duplicate just resolves to the latest declaration\" —\n\t\t// compile-time `MissingProviders` only catches collisions on\n\t\t// the user-typed dependency path, NOT two members declared on\n\t\t// the same stack with the same id. We catch the collision here\n\t\t// so the user sees a typed parse-phase failure instead of a\n\t\t// confusing \"wrong packageId\" downstream.\n\t\t//\n\t\t// The check tolerates re-entry from the SAME `localPackage(...)`\n\t\t// call (warm restart / re-acquire on the same scope): a\n\t\t// pre-existing entry with the SAME `sourcePath` is the\n\t\t// previous cycle's register, not a collision.\n\t\tconst existing = yield* registry.find(inputs.packageName);\n\t\tif (\n\t\t\texisting !== null &&\n\t\t\texisting.kind === 'local' &&\n\t\t\texisting.sourcePath !== inputs.sourcePath\n\t\t) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpublishError('parse', {\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`localPackage('${inputs.packageName}') is declared twice in the same stack ` +\n\t\t\t\t\t\t`with different sourcePaths (${existing.sourcePath} vs ${inputs.sourcePath}). ` +\n\t\t\t\t\t\t`The substrate is name-blind at runtime and the second declaration would ` +\n\t\t\t\t\t\t`silently overwrite the first registry entry. Pick distinct package names ` +\n\t\t\t\t\t\t`(the symbolic name is the registry key consumers look up).`,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\t// Distilled doc §Move-specific: hash inputs are `(sourceHash,\n\t\t// signerAddress)`. The hashing helper strips Move.lock pinned\n\t\t// sections (Invariant 2) so warm restarts hit the cache.\n\t\tconst sourceHash = yield* hashMoveSources(inputs.sourcePath);\n\t\tconst inputsHash = combineInputsHash(sourceHash, inputs.publisherAddress);\n\n\t\tconst mvrPlaceholder = mvrSlugify(inputs.mvrOverride ?? inputs.packageName);\n\n\t\t// We capture the produce-side output out-of-band so the\n\t\t// returned `LocalModeOutputs.output` can expose it. The\n\t\t// substrate hands back the decoded `CachedPackageEntry` on\n\t\t// every path; `producedOutput` is the freshly-emitted output\n\t\t// from THIS cycle (cache miss only).\n\t\tlet producedOutput: LocalPackagePublishOutput | null = null;\n\n\t\tconst entry: CachedPackageEntry = yield* publisher.publish<\n\t\t\tCachedPackageEntry,\n\t\t\ttypeof PackageVerifyShape.Type\n\t\t>({\n\t\t\tnamespace: 'package',\n\t\t\tchain: inputs.chainId,\n\t\t\tcontentHash: inputsHash,\n\t\t\tverify: (cached) =>\n\t\t\t\tcached.output === undefined\n\t\t\t\t\t? Effect.succeed(null)\n\t\t\t\t\t: buildVerifyProbe(probe, cached.packageId),\n\t\t\t// Produce: scrub → build → publish-tx → wait-for-index → parse.\n\t\t\t// PublishError is the plugin-internal phase taxonomy; we map\n\t\t\t// it to `ArtifactPublishError` at the substrate boundary.\n\t\t\tproduce: Effect.gen(function* () {\n\t\t\t\tyield* Effect.annotateCurrentSpan({\n\t\t\t\t\t[PackageSpans.publish.package]: inputs.packageName,\n\t\t\t\t\t[PackageSpans.publish.sourcePath]: inputs.sourcePath,\n\t\t\t\t\t[PackageSpans.publish.chainId]: inputs.chainId,\n\t\t\t\t\t[PackageSpans.publish.publisher]: inputs.publisherAddress,\n\t\t\t\t});\n\n\t\t\t\t// Produce 1/5 — scrub locks. Distilled doc §Move-specific\n\t\t\t\t// concerns + Invariant 14: strip pinned sections from every\n\t\t\t\t// `~/.move/git/**/Move.lock` (vendored dep caches) before\n\t\t\t\t// invoking the build. The package's own Move.lock is scrubbed\n\t\t\t\t// inside the container on a disposable copy, so the developer's\n\t\t\t\t// checked-in source is left untouched host-side. Uses the\n\t\t\t\t// unified `stripPinnedSections` (re-exported through `build.ts`\n\t\t\t\t// → from `../sui/move-lock-scrub.ts`) — NO duplicate.\n\t\t\t\tyield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: 'scrub' });\n\t\t\t\tyield* scrubLocksHost(inputs.sourcePath, '~/.move');\n\n\t\t\t\t// Produce 2/5 — build. Executor dispatches between (a)\n\t\t\t\t// per-app build container, (b) `docker run --rm`, (c) host\n\t\t\t\t// `sui` CLI.\n\t\t\t\tyield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: 'build' });\n\t\t\t\tconst buildOutput: BuildOutput = yield* inputs.executor\n\t\t\t\t\t.build({\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\tchainId: inputs.chainId,\n\t\t\t\t\t})\n\t\t\t\t\t.pipe(\n\t\t\t\t\t\tEffect.catchTag(\n\t\t\t\t\t\t\t'PublishError',\n\t\t\t\t\t\t\t(err): Effect.Effect<BuildOutput, PublishError> =>\n\t\t\t\t\t\t\t\t// Re-stamp sourcePath/packageName if the underlying\n\t\t\t\t\t\t\t\t// caller omitted them (every throw site MUST surface\n\t\t\t\t\t\t\t\t// the context — see distilled doc §Opportunities).\n\t\t\t\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\t\t\t\terr.sourcePath\n\t\t\t\t\t\t\t\t\t\t? err\n\t\t\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t\t\t...err,\n\t\t\t\t\t\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t// Produce 3/5 — publish-tx. Construct `Transaction.publish`,\n\t\t\t\t// sign + execute via the publisher's account signer, decode\n\t\t\t\t// the output.\n\t\t\t\tyield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: 'publish-tx' });\n\t\t\t\tconst output: LocalPackagePublishOutput = yield* inputs.executor.publishTx({\n\t\t\t\t\tmodules: buildOutput.modules,\n\t\t\t\t\tdependencies: buildOutput.dependencies,\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t});\n\t\t\t\tproducedOutput = output;\n\n\t\t\t\t// Produce 4/5 — wait-for-index. Distilled doc Invariant 5:\n\t\t\t\t// publish-tx commit precedes index visibility. This is a\n\t\t\t\t// hint-only probe (see `postPublishReadyHint` doc on\n\t\t\t\t// `PublishExecutor`): the publisher account's\n\t\t\t\t// `signAndExecute` already awaits `waitForTransaction`, so\n\t\t\t\t// the typical race is closed before we reach here.\n\t\t\t\tyield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: 'waiting-for-index' });\n\t\t\t\t// Best-effort only: the executor's hint swallows transient\n\t\t\t\t// `getObject` misses and logs at debug, so its error channel\n\t\t\t\t// collapses to `never` (see `publish-executor.ts →\n\t\t\t\t// postPublishReadyHint`). No re-stamp is needed because no\n\t\t\t\t// failure surfaces here.\n\t\t\t\tyield* inputs.executor.postPublishReadyHint(output.packageId);\n\n\t\t\t\t// Produce 5/5 — parse. Distilled doc §Move-specific\n\t\t\t\t// concerns: pick the `'published'` change for packageId;\n\t\t\t\t// pick the `UpgradeCap`-typed `'created'` change for the\n\t\t\t\t// upgrade cap.\n\t\t\t\tyield* Effect.annotateCurrentSpan({ [PackageSpans.publish.phase]: 'parse' });\n\t\t\t\tconst published = pickPublishedChange(output.objectChanges);\n\t\t\t\tif (!published?.objectId) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t'no \"published\" change in output — SDK shape drift (distilled doc §Edge cases)',\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst upgradeCap: PackagePublishObjectChange | undefined = pickUpgradeCapChange(\n\t\t\t\t\toutput.objectChanges,\n\t\t\t\t);\n\n\t\t\t\t// Capture spec — user-declared projection from output to\n\t\t\t\t// typed object id map. Distilled doc §Outputs: the callback\n\t\t\t\t// is user code, so a throw is a USER BUG (typo / missing\n\t\t\t\t// field) — surface as `PublishError('parse')` so the user\n\t\t\t\t// catches the mistake instead of silently shipping a stale\n\t\t\t\t// captured map. The cache-HIT path performs the symmetric\n\t\t\t\t// recompute post-`publisher.publish` (see comment block\n\t\t\t\t// below the `publisher.publish` call) — both paths bubble\n\t\t\t\t// the same `PublishError('parse')` shape.\n\t\t\t\tconst captured: Readonly<Record<string, string>> = inputs.capture\n\t\t\t\t\t? yield* Effect.try({\n\t\t\t\t\t\t\ttry: () => inputs.capture!(output),\n\t\t\t\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\t\t\tmessage: 'capture callback threw',\n\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t})\n\t\t\t\t\t: {};\n\n\t\t\t\tconst entry: CachedPackageEntry = {\n\t\t\t\t\tpackageId: published.objectId,\n\t\t\t\t\tupgradeCapId: upgradeCap?.objectId,\n\t\t\t\t\tpublisher: inputs.publisherAddress,\n\t\t\t\t\tmvrPlaceholder,\n\t\t\t\t\tcaptured,\n\t\t\t\t\toutput,\n\t\t\t\t};\n\t\t\t\treturn entry;\n\t\t\t}).pipe(\n\t\t\t\tEffect.mapError(\n\t\t\t\t\t(err): ArtifactPublishError =>\n\t\t\t\t\t\tartifactPublishError('produce-failed', `package.publish ${err.phase}: ${err.message}`),\n\t\t\t\t),\n\t\t\t),\n\t\t\t// Register: on EVERY cycle. Distilled doc Invariant 6. The\n\t\t\t// substrate hands the decoded `CachedPackageEntry` payload\n\t\t\t// here on both verify-hit and freshly-produced paths.\n\t\t\t//\n\t\t\t// Register writes the entry verbatim using `artifact.captured`\n\t\t\t// (produce-time on miss; cached on hit). The user's `capture`\n\t\t\t// callback is NOT re-run here — `register`'s contract is\n\t\t\t// `Effect.Effect<void, never>` (primitives/artifact-publisher.ts)\n\t\t\t// and a user-bug throw needs a typed failure channel. The\n\t\t\t// post-publish recompute below (cache-hit branch) re-runs\n\t\t\t// `capture` so renamed/typo keys surface IDENTICALLY to the\n\t\t\t// cache-miss path (mode-local.ts:346-357) — i.e., as\n\t\t\t// `PublishError('parse')`.\n\t\t\tregister: (artifact) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst r: ResolvedLocalPackage = {\n\t\t\t\t\t\tkind: 'local',\n\t\t\t\t\t\tname: inputs.packageName,\n\t\t\t\t\t\tpackageId: artifact.packageId,\n\t\t\t\t\t\tupgradeCapId: artifact.upgradeCapId,\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tmvrPlaceholder: artifact.mvrPlaceholder,\n\t\t\t\t\t\tcaptured: artifact.captured,\n\t\t\t\t\t};\n\t\t\t\t\tyield* registry.set(r.name, r);\n\t\t\t\t}),\n\t\t});\n\n\t\t// Post-publish capture recompute — cache-hit ONLY.\n\t\t//\n\t\t// Symmetric with the produce-time capture (L346-357): the user's\n\t\t// `capture` callback is user code; a throw is a user bug (typo /\n\t\t// renamed key against a stale cached output) and MUST surface as\n\t\t// `PublishError('parse')` so the user sees the mistake instead of\n\t\t// silently carrying forward `artifact.captured` (the historical\n\t\t// `try { ... } catch { return artifact.captured }` hid renamed\n\t\t// keys behind stale data — A5 of the remediation plan).\n\t\t//\n\t\t// Cache miss: `producedOutput` was set inside `produce`, the\n\t\t// produce-time capture already ran (Effect.try → PublishError),\n\t\t// and the substrate cached the produced entry. Re-running here\n\t\t// would be redundant and would double-throw on user bugs.\n\t\t//\n\t\t// Cache hit: `producedOutput` is null, `entry.output` came from\n\t\t// the cached payload, and `entry.captured` is whatever the user's\n\t\t// `capture` returned at the time of the original publish. We\n\t\t// re-run `capture(entry.output)` so warm restarts with renamed\n\t\t// capture keys (a) reflect the new shape in the registry without\n\t\t// requiring a republish, and (b) FAIL LOUDLY on user-callback\n\t\t// throws — the symmetric counterpart to the produce-time guard.\n\t\tconst cacheHit = producedOutput === null;\n\t\tif (cacheHit && inputs.capture !== undefined && entry.output !== undefined) {\n\t\t\tconst recomputedCaptured: Readonly<Record<string, string>> = yield* Effect.try({\n\t\t\t\ttry: () => inputs.capture!(entry.output!),\n\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\tmessage: 'capture callback threw',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t}).pipe(\n\t\t\t\t// Match the produce-body `mapError` projection (L373-379)\n\t\t\t\t// so callers see ONE consistent failure shape on\n\t\t\t\t// `capture` throws — `ArtifactPublishError('produce-failed')`\n\t\t\t\t// with `detail: \"package.publish parse: capture callback\n\t\t\t\t// threw\"` — regardless of whether the bug surfaces on a\n\t\t\t\t// cache miss (inside `produce`) or a cache hit (here).\n\t\t\t\tEffect.mapError(\n\t\t\t\t\t(err): ArtifactPublishError =>\n\t\t\t\t\t\tartifactPublishError('produce-failed', `package.publish ${err.phase}: ${err.message}`),\n\t\t\t\t),\n\t\t\t);\n\t\t\tyield* registry.set(inputs.packageName, {\n\t\t\t\tkind: 'local',\n\t\t\t\tname: inputs.packageName,\n\t\t\t\tpackageId: entry.packageId,\n\t\t\t\tupgradeCapId: entry.upgradeCapId,\n\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\tmvrPlaceholder: entry.mvrPlaceholder,\n\t\t\t\tcaptured: recomputedCaptured,\n\t\t\t});\n\t\t}\n\n\t\t// Project the cached entry back to the resolved shape. The\n\t\t// publisher returned the decoded `CachedPackageEntry`; re-read\n\t\t// the registry to recover the canonical `ResolvedLocalPackage`\n\t\t// shape (`register` ran on every cycle and wrote it).\n\t\tconst final = yield* registry.find(inputs.packageName);\n\t\tif (!final || final.kind !== 'local') {\n\t\t\t// Defensive — register fires unconditionally; missing entry\n\t\t\t// here would mean substrate skipped register, violating\n\t\t\t// Invariant 6. Surface as a parse-phase failure since it's\n\t\t\t// indistinguishable from a missing 'published' change from\n\t\t\t// the consumer's perspective.\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpublishError('parse', {\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'register did not surface entry — artifact publisher register invariant violation',\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n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a;GACvC,MAAM;GACN,MAAM,OAAO;GACb,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,YAAY,OAAO;GACnB,gBAAgB,MAAM;GACtB,UAAU;GACV,CAAC;;CAOH,MAAM,QAAQ,OAAO,SAAS,KAAK,OAAO,YAAY;AACtD,KAAI,CAAC,SAAS,MAAM,SAAS,QAM5B,QAAO,OAAO,OAAO,KACpB,aAAa,SAAS;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,SACC;EACD,CAAC,CACF;AAGF,QAAO;EACN,UAAU;EACV,QAAQ,kBAAkB,MAAM,UAAU;EAC1C;EACA"}
1
+ {"version":3,"file":"mode-local.mjs","names":["brandContentHash"],"sources":["../../../src/plugins/package/mode-local.ts"],"sourcesContent":["// Local mode — build from source + publish.\n//\n// This is the canonical implementation of the\n// `ArtifactPublisher` substrate primitive (distilled doc\n// §Generic artifact-publisher-publish pattern). The five-phase shape:\n//\n// 1. Inputs — `{ sourceHash, signerAddress }` →\n// `contentHash(inputs)`.\n// 2. Cache key — `<namespace=package>/<chainId>/<contentHash>`.\n// Substrate folds in chainId for us; we hand\n// it the namespace + contentHash.\n// 3. Verify — `chainProbe.get({ objectId: cachedId },\n// PackageObjectSchema, 'lenient')`. Lenient mode\n// coerces transient RPC failure → null\n// → re-derive (cheap over-derive vs spurious\n// eviction — distilled doc §Constraint \"lenient\n// verify is cheaper than aggressive eviction\").\n// 4. Produce — scrub locks → build → publish-tx → wait-for-\n// index. Each phase narrates to TUI via span\n// annotation.\n// 5. Register — write registry entry on EVERY cycle (hit AND\n// miss). Distilled doc Invariant 6.\n//\n// The publish output is exposed on the resolved value and emitted as a\n// package-owned extension contribution for sibling folds.\n\nimport { Duration, Effect, Schema, type Scope } from 'effect';\n\nimport { contentHash as brandContentHash } from '../../substrate/brand.ts';\nimport type { LocalPackagePublishOutput } from './publish-output.ts';\nimport {\n\tartifactPublishError,\n\ttype ArtifactPublishError,\n\ttype ArtifactPublisher,\n} from '../../primitives/artifact-publisher.ts';\nimport type { ChainProbe } from '../../contracts/chain-probe.ts';\nimport type { SuiProbeKey } from '../sui/index.ts';\nimport { hashMoveSources, scrubLocksHost, withMoveBuildLock, type BuildOutput } from './build.ts';\nimport { mvrNamedForm } from './dep-resolution.ts';\nimport { type PackageRegistry, type ResolvedLocalPackage } from './registry.ts';\nimport { publishError, type PublishError } from './errors.ts';\n\n/** Cache-stored payload — the stable id verify re-confirms on\n * every cycle. Distilled doc Invariant 8: the probe MUST consume\n * a stable identifier (the packageId), NOT a derived hash. */\nexport interface CachedPackageEntry {\n\treadonly packageId: string;\n\treadonly upgradeCapId?: string;\n\treadonly publisher: string;\n\treadonly mvrPlaceholder: string;\n\treadonly captured: Readonly<Record<string, string>>;\n\treadonly output?: LocalPackagePublishOutput;\n}\n\n/** Verify-schema: what we expect when probing `getObject(packageId)`.\n * Minimal — the substrate's `ChainProbe` decodes against this; any\n * decode failure surfaces structured. */\nexport const PackageVerifyShape = Schema.Struct({\n\tobjectId: Schema.String,\n\t// A Move package's `type` is the literal `\"package\"` wrapper;\n\t// the SDK's exact shape varies — we keep it open as `Unknown`\n\t// and rely on objectId presence for the \"exists\" signal.\n\ttype: Schema.Unknown,\n});\n\n/**\n * Publish-tx executor — narrow shim that abstracts the concrete\n * `@mysten/sui` wiring (Transaction builder, signer, fullnode\n * ready-probe). The mode-local produce body composes its 5-phase\n * shape against this interface; the concrete implementation lives in\n * `publish-executor.ts` and is constructed once per acquire by the\n * barrel from the resolved `SuiClient` + publisher `AccountValue` +\n * `ContainerRuntime`.\n *\n * The shim parallels `coin/mint.ts::MintSigner` + `MintSdkShim`. We\n * keep them split (publish vs sign vs ready-probe) so the produce\n * body can attribute span annotations per phase + so failures map\n * back to a typed `PublishError` phase enum.\n */\nexport interface PublishExecutor {\n\treadonly scrubsInsideContainer: boolean;\n\n\t/** Build the Move source tree into `{ modules, dependencies }`.\n\t * Dispatches between (a) per-app build container, (b) fresh\n\t * `docker run --rm`, (c) host `sui` CLI. The produce body just\n\t * calls and propagates `PublishError`. */\n\treadonly build: (inputs: {\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t\treadonly chainId: string;\n\t}) => Effect.Effect<BuildOutput, PublishError, Scope.Scope>;\n\n\t/** Construct + sign + execute a `Transaction.publish({modules,\n\t * dependencies})` against the publisher account. Returns the\n\t * output projection that downstream consumers (Coin, manifest,\n\t * capture spec) need. Distilled doc §Move-specific concerns —\n\t * the output is the source of `published` change + the\n\t * `UpgradeCap` `created` change. */\n\treadonly publishTx: (inputs: {\n\t\treadonly modules: ReadonlyArray<Uint8Array>;\n\t\treadonly dependencies: ReadonlyArray<string>;\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t}) => Effect.Effect<LocalPackagePublishOutput, PublishError, Scope.Scope>;\n\n\t/** Post-publish fullnode/indexer ready HINT. Distilled doc\n\t * Invariant 5: publish-tx commit precedes index visibility. This\n\t * is BEST-EFFORT — the concrete executor swallows transient\n\t * `getObject` misses (cold index races) because the publisher\n\t * account's `signAndExecute` already calls `waitForTransaction`\n\t * before returning, AND the downstream `parse` phase only\n\t * inspects the publish output. A typed `PublishError('parse')`\n\t * surfaces only when the `getObject` infrastructure itself\n\t * faults (network down / SDK throws non-recoverably), NOT when\n\t * the object is merely not-yet-indexed.\n\t *\n\t * The \"Hint\" suffix encodes the contract: callers MUST NOT treat\n\t * a successful return as \"package definitely queryable now\". */\n\treadonly postPublishReadyHint: (\n\t\tpackageId: string,\n\t) => Effect.Effect<void, PublishError, Scope.Scope>;\n}\n\nexport interface LocalModeInputs {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly chainId: string;\n\treadonly publisherAddress: string;\n\treadonly mvrOverride?: string;\n\treadonly capture?: (output: LocalPackagePublishOutput) => Readonly<Record<string, string>>;\n\t/** Publish executor — constructed per-acquire by the barrel from\n\t * the resolved SuiClient + publisher account + ContainerRuntime\n\t * (see `publish-executor.ts`). */\n\treadonly executor: PublishExecutor;\n}\n\nexport interface LocalModeOutputs {\n\treadonly resolved: ResolvedLocalPackage;\n\treadonly output: LocalPackagePublishOutput | null;\n}\n\n/**\n * Build the content hash for the publish cache key. Distilled doc\n * §Move-specific: inputs are `(sourceHash, signerAddress)`. The\n * `hashMoveSources` helper already normalises Move.lock pinned\n * sections via the shared `stripPinnedSections`; we fold the\n * publisher address in here as a stable string so reusing the\n * same source under a different signer correctly misses (Invariant\n * 4: \"Signer MUST be an explicit upstream\").\n */\nconst LOCAL_PACKAGE_CACHE_SCHEMA_VERSION = 'v3';\n// Short verify budget covering RPC index-visibility lag only. The big\n// post-restore catch-up window — `sui start` re-executes its committed\n// checkpoint store from seq=0, and `getObject(packageId)` reads not-found\n// until the replay reaches the publish checkpoint — is now absorbed by the\n// sui plugin's caught-up-to-head ready-gate (`waitForCheckpointCatchUp` in\n// plugins/sui/mode/local.ts): the validator does not report ready until its\n// head stabilizes to live cadence, so by the time this verify runs the\n// committed package object is already served. This budget only needs to ride\n// out the small fullnode/index lag between publish-tx commit and `getObject`\n// visibility — NOT the whole replay. If it gives up too soon it returns null →\n// the substrate re-PRODUCES (re-publishes) the package, minting a FRESH\n// packageId (codegen `config.ts` loses the stable id; downstream\n// `deepbookOf(...).packageId` churns). A truly-wiped chain genuinely has no\n// package and re-publishes once the budget lapses. Mirrors\n// WALRUS_DEPLOY_VERIFY_READINESS_* in plugins/walrus/deploy.ts — the on-chain\n// artifact-publisher consumers share the same short RPC-lag tolerance.\nconst PACKAGE_CACHE_VERIFY_MAX_ATTEMPTS = 20;\nconst PACKAGE_CACHE_VERIFY_DELAY_MS = 250;\n\nconst combineInputsHash = (sourceHash: string, publisherAddress: string) =>\n\tbrandContentHash(\n\t\t`${LOCAL_PACKAGE_CACHE_SCHEMA_VERSION}::source=${sourceHash}::publisher=${publisherAddress}`,\n\t);\n\n/**\n * Verify probe — lenient `getObject(packageId)`. Returns the decoded\n * shape on success; null for BOTH not-found AND transient (distilled\n * doc Invariant 7 + the \"lenient verify cheaper than aggressive\n * eviction\" Constraint).\n *\n * The cached id is hinted in via parameter. The artifact publisher substrate is\n * expected to thread the cached payload through to this closure on\n * cache hit; today we get the id from the registry's previous-cycle\n * entry (in-process, per-supervisor lookup — see `acquireLocal`\n * below). When no hint exists (first cycle / cold boot), we\n * short-circuit to null so the substrate runs `produce`.\n *\n * Mirrors `coin/mint.ts::buildVerifyProbe` exactly so the two artifact publisher\n * consumers stay shape-aligned.\n */\nexport const buildVerifyProbe = (\n\tprobe: ChainProbe<SuiProbeKey>,\n\tcachedPackageIdHint: string | null,\n\topts?: { readonly maxAttempts?: number; readonly delayMs?: number },\n): Effect.Effect<typeof PackageVerifyShape.Type | null, never> =>\n\tEffect.gen(function* () {\n\t\tif (cachedPackageIdHint === null) return null;\n\t\tconst maxAttempts = opts?.maxAttempts ?? PACKAGE_CACHE_VERIFY_MAX_ATTEMPTS;\n\t\tconst delayMs = opts?.delayMs ?? PACKAGE_CACHE_VERIFY_DELAY_MS;\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\t// Lenient mode in the underlying probe already coerces\n\t\t\t// not-found AND transient → null. We retry nulls briefly to\n\t\t\t// ride out the small fullnode/index lag between publish-tx\n\t\t\t// commit and `getObject` visibility; the validator's larger\n\t\t\t// post-restore replay is already gated upstream by the sui\n\t\t\t// plugin's caught-up-to-head ready-gate, so a false cache miss\n\t\t\t// does not turn a warm restart into an unnecessary publish.\n\t\t\tconst result: typeof PackageVerifyShape.Type | null = yield* probe\n\t\t\t\t.get({ kind: 'object', objectId: cachedPackageIdHint }, PackageVerifyShape, 'lenient')\n\t\t\t\t.pipe(\n\t\t\t\t\t// The probe's own error channel is `ChainProbeError`; under\n\t\t\t\t\t// lenient mode only `decode-failed` surfaces (not-found +\n\t\t\t\t\t// transient already coerce to null). A decode failure on\n\t\t\t\t\t// verify is treated as \"stale shape\" — null so the substrate\n\t\t\t\t\t// re-publishes rather than carry forward a mismatch.\n\t\t\t\t\tEffect.catch(() => Effect.succeed(null as typeof PackageVerifyShape.Type | null)),\n\t\t\t\t);\n\t\t\tif (result !== null) return result;\n\t\t\tif (attempt < maxAttempts && delayMs > 0) {\n\t\t\t\tyield* Effect.sleep(Duration.millis(delayMs));\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t});\n\n/**\n * Compose the ArtifactSpec for a local publish.\n *\n * The substrate-side `ArtifactPublisher.publish` consumes\n * this spec and handles:\n *\n * - cache lookup under `<namespace>/<chainId>/<contentHash>`;\n * - verify (lenient) when there's a hit;\n * - re-running `produce` on miss OR verify-fail;\n * - calling `register` on EVERY cycle.\n */\nexport const acquireLocal = (\n\tpublisher: ArtifactPublisher,\n\tprobe: ChainProbe<SuiProbeKey>,\n\tregistry: PackageRegistry,\n\tinputs: LocalModeInputs,\n): Effect.Effect<LocalModeOutputs, PublishError | ArtifactPublishError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\t// Intra-stack name collision guard.\n\t\t//\n\t\t// The registry is keyed by symbolic `packageName`; two\n\t\t// `localPackage('foo', ...)` calls in the same stack would both\n\t\t// call `register({ name: 'foo', ... })` and the second `set`\n\t\t// would silently overwrite the first. Upstream's\n\t\t// `resolveGraph` (substrate/runtime/lifecycle/dep-graph.ts:127)\n\t\t// explicitly documents \"we don't enforce uniqueness at runtime;\n\t\t// the duplicate just resolves to the latest declaration\" —\n\t\t// compile-time `MissingProviders` only catches collisions on\n\t\t// the user-typed dependency path, NOT two members declared on\n\t\t// the same stack with the same id. We catch the collision here\n\t\t// so the user sees a typed parse-phase failure instead of a\n\t\t// confusing \"wrong packageId\" downstream.\n\t\t//\n\t\t// The check tolerates re-entry from the SAME `localPackage(...)`\n\t\t// call (warm restart / re-acquire on the same scope): a\n\t\t// pre-existing entry with the SAME `sourcePath` is the\n\t\t// previous cycle's register, not a collision.\n\t\tconst existing = yield* registry.find(inputs.packageName);\n\t\tif (\n\t\t\texisting !== null &&\n\t\t\texisting.kind === 'local' &&\n\t\t\texisting.sourcePath !== inputs.sourcePath\n\t\t) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpublishError('parse', {\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`localPackage('${inputs.packageName}') is declared twice in the same stack ` +\n\t\t\t\t\t\t`with different sourcePaths (${existing.sourcePath} vs ${inputs.sourcePath}). ` +\n\t\t\t\t\t\t`The substrate is name-blind at runtime and the second declaration would ` +\n\t\t\t\t\t\t`silently overwrite the first registry entry. Pick distinct package names ` +\n\t\t\t\t\t\t`(the symbolic name is the registry key consumers look up).`,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\t// Distilled doc §Move-specific: hash inputs are `(sourceHash,\n\t\t// signerAddress)`. The hashing helper strips Move.lock pinned\n\t\t// sections (Invariant 2) so warm restarts hit the cache.\n\t\tconst sourceHash = yield* hashMoveSources(inputs.sourcePath);\n\t\tconst inputsHash = combineInputsHash(sourceHash, inputs.publisherAddress);\n\n\t\t// The MVR placeholder is the NAMED form (`@local/<slug>`), not the\n\t\t// bare slug — it is emitted as BOTH the generated-binding package\n\t\t// default (`options.package ?? '@local/<slug>'`) and\n\t\t// `config.packages.<name>.mvr`, so apps can resolve bindings by\n\t\t// name alone via an MvrClient override keyed on that string. The\n\t\t// bare slug survives only as file stems / Move `[addresses]`\n\t\t// resolution, which `mvrNamedForm` derives internally.\n\t\tconst mvrPlaceholder = mvrNamedForm(inputs.mvrOverride ?? inputs.packageName);\n\n\t\t// We capture the produce-side output out-of-band so the\n\t\t// returned `LocalModeOutputs.output` can expose it. The\n\t\t// substrate hands back the decoded `CachedPackageEntry` on\n\t\t// every path; `producedOutput` is the freshly-emitted output\n\t\t// from THIS cycle (cache miss only).\n\t\tlet producedOutput: LocalPackagePublishOutput | null = null;\n\n\t\tconst entry: CachedPackageEntry = yield* publisher.publish<\n\t\t\tCachedPackageEntry,\n\t\t\ttypeof PackageVerifyShape.Type\n\t\t>({\n\t\t\tnamespace: 'package',\n\t\t\tchain: inputs.chainId,\n\t\t\tcontentHash: inputsHash,\n\t\t\tverify: (cached) =>\n\t\t\t\tcached.output === undefined\n\t\t\t\t\t? Effect.succeed(null)\n\t\t\t\t\t: buildVerifyProbe(probe, cached.packageId),\n\t\t\t// Produce: scrub → build → publish-tx → wait-for-index → parse.\n\t\t\t// PublishError is the plugin-internal phase taxonomy; we map\n\t\t\t// it to `ArtifactPublishError` at the substrate boundary.\n\t\t\tproduce: Effect.gen(function* () {\n\t\t\t\t// Produce 1/5 + 2/5 — scrub locks, then build. Both touch the\n\t\t\t\t// shared `~/.move` git cache, so they run together under the\n\t\t\t\t// process-wide Move-build permit (`withMoveBuildLock`): otherwise a\n\t\t\t\t// concurrent build's host scrub (`gawk -i inplace`) races a sibling\n\t\t\t\t// container's live `git clone` into the same cache dir and corrupts\n\t\t\t\t// the in-flight fetch. Publish-tx (3/5 below) stays OUTSIDE the lock\n\t\t\t\t// so on-chain work of different packages still overlaps.\n\t\t\t\tconst buildOutput: BuildOutput = yield* withMoveBuildLock(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t// Produce 1/5 — scrub locks. Distilled doc §Move-specific\n\t\t\t\t\t\t// concerns + Invariant 14: strip pinned sections from every\n\t\t\t\t\t\t// `~/.move/git/**/Move.lock` (vendored dep caches) before\n\t\t\t\t\t\t// invoking the build. The package's own Move.lock is scrubbed\n\t\t\t\t\t\t// inside the container on a disposable copy, so the developer's\n\t\t\t\t\t\t// checked-in source is left untouched host-side. Uses the\n\t\t\t\t\t\t// unified `stripPinnedSections` (re-exported through `build.ts`\n\t\t\t\t\t\t// → from `../sui/move-lock-scrub.ts`) — NO duplicate.\n\t\t\t\t\t\tyield* scrubLocksHost(inputs.sourcePath, '~/.move');\n\n\t\t\t\t\t\t// Produce 2/5 — build. Executor dispatches between (a)\n\t\t\t\t\t\t// per-app build container, (b) `docker run --rm`, (c) host\n\t\t\t\t\t\t// `sui` CLI.\n\t\t\t\t\t\treturn yield* inputs.executor\n\t\t\t\t\t\t\t.build({\n\t\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\t\tchainId: inputs.chainId,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.pipe(\n\t\t\t\t\t\t\t\tEffect.catchTag(\n\t\t\t\t\t\t\t\t\t'PublishError',\n\t\t\t\t\t\t\t\t\t(err): Effect.Effect<BuildOutput, PublishError> =>\n\t\t\t\t\t\t\t\t\t\t// Re-stamp sourcePath/packageName if the underlying\n\t\t\t\t\t\t\t\t\t\t// caller omitted them (every throw site MUST surface\n\t\t\t\t\t\t\t\t\t\t// the context — see distilled doc §Opportunities).\n\t\t\t\t\t\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\t\t\t\t\t\terr.sourcePath\n\t\t\t\t\t\t\t\t\t\t\t\t? err\n\t\t\t\t\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...err,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\t// Produce 3/5 — publish-tx. Construct `Transaction.publish`,\n\t\t\t\t// sign + execute via the publisher's account signer, decode\n\t\t\t\t// the output.\n\t\t\t\tconst output: LocalPackagePublishOutput = yield* inputs.executor.publishTx({\n\t\t\t\t\tmodules: buildOutput.modules,\n\t\t\t\t\tdependencies: buildOutput.dependencies,\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t});\n\t\t\t\tproducedOutput = output;\n\n\t\t\t\t// Produce 4/5 — wait-for-index. Distilled doc Invariant 5:\n\t\t\t\t// publish-tx commit precedes index visibility. This is a\n\t\t\t\t// hint-only probe (see `postPublishReadyHint` doc on\n\t\t\t\t// `PublishExecutor`): the publisher account's\n\t\t\t\t// `signAndExecute` already awaits `waitForTransaction`, so\n\t\t\t\t// the typical race is closed before we reach here.\n\t\t\t\t// Best-effort only: the executor's hint swallows transient\n\t\t\t\t// `getObject` misses and logs at debug, so its error channel\n\t\t\t\t// collapses to `never` (see `publish-executor.ts →\n\t\t\t\t// postPublishReadyHint`). No re-stamp is needed because no\n\t\t\t\t// failure surfaces here.\n\t\t\t\tyield* inputs.executor.postPublishReadyHint(output.packageId);\n\n\t\t\t\t// Capture spec — user-declared projection from output to\n\t\t\t\t// typed object id map. Distilled doc §Outputs: the callback\n\t\t\t\t// is user code, so a throw is a USER BUG (typo / missing\n\t\t\t\t// field) — surface as `PublishError('parse')` so the user\n\t\t\t\t// catches the mistake instead of silently shipping a stale\n\t\t\t\t// captured map. The cache-HIT path performs the symmetric\n\t\t\t\t// recompute post-`publisher.publish` (see comment block\n\t\t\t\t// below the `publisher.publish` call) — both paths bubble\n\t\t\t\t// the same `PublishError('parse')` shape.\n\t\t\t\tconst captured: Readonly<Record<string, string>> = inputs.capture\n\t\t\t\t\t? yield* Effect.try({\n\t\t\t\t\t\t\ttry: () => inputs.capture!(output),\n\t\t\t\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\t\t\tmessage: 'capture callback threw',\n\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t})\n\t\t\t\t\t: {};\n\n\t\t\t\tconst entry: CachedPackageEntry = {\n\t\t\t\t\tpackageId: output.packageId,\n\t\t\t\t\tupgradeCapId: output.upgradeCapId,\n\t\t\t\t\tpublisher: inputs.publisherAddress,\n\t\t\t\t\tmvrPlaceholder,\n\t\t\t\t\tcaptured,\n\t\t\t\t\toutput,\n\t\t\t\t};\n\t\t\t\treturn entry;\n\t\t\t}).pipe(\n\t\t\t\tEffect.mapError(\n\t\t\t\t\t(err): ArtifactPublishError =>\n\t\t\t\t\t\tartifactPublishError('produce-failed', `package.publish ${err.phase}: ${err.message}`),\n\t\t\t\t),\n\t\t\t),\n\t\t\t// Register: on EVERY cycle. Distilled doc Invariant 6. The\n\t\t\t// substrate hands the decoded `CachedPackageEntry` payload\n\t\t\t// here on both verify-hit and freshly-produced paths.\n\t\t\t//\n\t\t\t// Register writes the entry verbatim using `artifact.captured`\n\t\t\t// (produce-time on miss; cached on hit). The user's `capture`\n\t\t\t// callback is NOT re-run here — `register`'s contract is\n\t\t\t// `Effect.Effect<void, never>` (primitives/artifact-publisher.ts)\n\t\t\t// and a user-bug throw needs a typed failure channel. The\n\t\t\t// post-publish recompute below (cache-hit branch) re-runs\n\t\t\t// `capture` so renamed/typo keys surface IDENTICALLY to the\n\t\t\t// cache-miss path (mode-local.ts:346-357) — i.e., as\n\t\t\t// `PublishError('parse')`.\n\t\t\tregister: (artifact) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst r: ResolvedLocalPackage = {\n\t\t\t\t\t\tkind: 'local',\n\t\t\t\t\t\tname: inputs.packageName,\n\t\t\t\t\t\tpackageId: artifact.packageId,\n\t\t\t\t\t\tupgradeCapId: artifact.upgradeCapId,\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tmvrPlaceholder: artifact.mvrPlaceholder,\n\t\t\t\t\t\tcaptured: artifact.captured,\n\t\t\t\t\t};\n\t\t\t\t\tyield* registry.set(r.name, r);\n\t\t\t\t}),\n\t\t});\n\n\t\t// Post-publish capture recompute — cache-hit ONLY.\n\t\t//\n\t\t// Symmetric with the produce-time capture (L346-357): the user's\n\t\t// `capture` callback is user code; a throw is a user bug (typo /\n\t\t// renamed key against a stale cached output) and MUST surface as\n\t\t// `PublishError('parse')` so the user sees the mistake instead of\n\t\t// silently carrying forward `artifact.captured` — swallowing the\n\t\t// throw with `catch { return artifact.captured }` would hide\n\t\t// renamed keys behind stale data.\n\t\t//\n\t\t// Cache miss: `producedOutput` was set inside `produce`, the\n\t\t// produce-time capture already ran (Effect.try → PublishError),\n\t\t// and the substrate cached the produced entry. Re-running here\n\t\t// would be redundant and would double-throw on user bugs.\n\t\t//\n\t\t// Cache hit: `producedOutput` is null, `entry.output` came from\n\t\t// the cached payload, and `entry.captured` is whatever the user's\n\t\t// `capture` returned at the time of the original publish. We\n\t\t// re-run `capture(entry.output)` so warm restarts with renamed\n\t\t// capture keys (a) reflect the new shape in the registry without\n\t\t// requiring a republish, and (b) FAIL LOUDLY on user-callback\n\t\t// throws — the symmetric counterpart to the produce-time guard.\n\t\tconst cacheHit = producedOutput === null;\n\t\tif (cacheHit && inputs.capture !== undefined && entry.output !== undefined) {\n\t\t\tconst recomputedCaptured: Readonly<Record<string, string>> = yield* Effect.try({\n\t\t\t\ttry: () => inputs.capture!(entry.output!),\n\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\tmessage: 'capture callback threw',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t}).pipe(\n\t\t\t\t// Match the produce-body `mapError` projection (L373-379)\n\t\t\t\t// so callers see ONE consistent failure shape on\n\t\t\t\t// `capture` throws — `ArtifactPublishError('produce-failed')`\n\t\t\t\t// with `detail: \"package.publish parse: capture callback\n\t\t\t\t// threw\"` — regardless of whether the bug surfaces on a\n\t\t\t\t// cache miss (inside `produce`) or a cache hit (here).\n\t\t\t\tEffect.mapError(\n\t\t\t\t\t(err): ArtifactPublishError =>\n\t\t\t\t\t\tartifactPublishError('produce-failed', `package.publish ${err.phase}: ${err.message}`),\n\t\t\t\t),\n\t\t\t);\n\t\t\tyield* registry.set(inputs.packageName, {\n\t\t\t\tkind: 'local',\n\t\t\t\tname: inputs.packageName,\n\t\t\t\tpackageId: entry.packageId,\n\t\t\t\tupgradeCapId: entry.upgradeCapId,\n\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\tmvrPlaceholder: entry.mvrPlaceholder,\n\t\t\t\tcaptured: recomputedCaptured,\n\t\t\t});\n\t\t}\n\n\t\t// Project the cached entry back to the resolved shape. The\n\t\t// publisher returned the decoded `CachedPackageEntry`; re-read\n\t\t// the registry to recover the canonical `ResolvedLocalPackage`\n\t\t// shape (`register` ran on every cycle and wrote it).\n\t\tconst final = yield* registry.find(inputs.packageName);\n\t\tif (!final || final.kind !== 'local') {\n\t\t\t// Defensive — register fires unconditionally; missing entry\n\t\t\t// here would mean substrate skipped register, violating\n\t\t\t// Invariant 6. Surface as a parse-phase failure since it's\n\t\t\t// indistinguishable from a missing 'published' change from\n\t\t\t// the consumer's perspective.\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpublishError('parse', {\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'register did not surface entry — artifact publisher register invariant violation',\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tresolved: final,\n\t\t\toutput: producedOutput ?? entry.output ?? null,\n\t\t};\n\t});\n"],"mappings":";;;;;;;;;;;;AAyDA,MAAa,qBAAqB,OAAO,OAAO;CAC/C,UAAU,OAAO;CAIjB,MAAM,OAAO;AACd,CAAC;;;;;;;;;;AAuFD,MAAM,qCAAqC;AAiB3C,MAAM,oCAAoC;AAC1C,MAAM,gCAAgC;AAEtC,MAAM,qBAAqB,YAAoB,qBAC9CA,YACC,GAAG,mCAAmC,WAAW,WAAW,cAAc,kBAC3E;;;;;;;;;;;;;;;;;AAkBD,MAAa,oBACZ,OACA,qBACA,SAEA,OAAO,IAAI,aAAa;C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AS;IACrB,YAAY,OAAO;IACnB,aAAa,OAAO;IACpB,SAAS;IACT;GACD,CAAC;EACH,CAAC,CAAC,CAAC,KAOF,OAAO,UACL,QACA,qBAAqB,kBAAkB,mBAAmB,IAAI,MAAM,IAAI,IAAI,SAAS,CACvF,CACD;EACA,OAAO,SAAS,IAAI,OAAO,aAAa;GACvC,MAAM;GACN,MAAM,OAAO;GACb,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,YAAY,OAAO;GACnB,gBAAgB,MAAM;GACtB,UAAU;EACX,CAAC;CACF;CAMA,MAAM,QAAQ,OAAO,SAAS,KAAK,OAAO,WAAW;CACrD,IAAI,CAAC,SAAS,MAAM,SAAS,SAM5B,OAAO,OAAO,OAAO,KACpB,aAAa,SAAS;EACrB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,SACC;CACF,CAAC,CACF;CAGD,OAAO;EACN,UAAU;EACV,QAAQ,kBAAkB,MAAM,UAAU;CAC3C;AACD,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { formatUnknownError } from "../../substrate/runtime/format-unknown-error.mjs";
2
- import { signAndDispatch } from "../../substrate/runtime/sui-execute/sign-and-dispatch.mjs";
3
- import { formatExecutedFailure } from "../../substrate/runtime/sui-execute/index.mjs";
2
+ import { formatExecutedFailure } from "../sui/exec/index.mjs";
4
3
  import { buildForkImpersonationTransactionBytes } from "../sui/fork-transaction.mjs";
4
+ import { signAndDispatch } from "../sui/exec/sign-and-dispatch.mjs";
5
5
  import "../sui/index.mjs";
6
+ import { pickPublishedChange, pickUpgradeCapChange } from "./publish-output.mjs";
6
7
  import { publishError } from "./errors.mjs";
7
8
  import { runMoveBuild } from "./build.mjs";
8
- import { PackageSpans } from "./spans.mjs";
9
9
  import { Effect } from "effect";
10
10
  import { Transaction } from "@mysten/sui/transactions";
11
11
  //#region src/plugins/package/publish-executor.ts
@@ -121,21 +121,26 @@ const makePublishExecutor = (inputs) => ({
121
121
  objectChanges: publishChangesFromTxResult(txResult)
122
122
  })
123
123
  });
124
- const published = objectChanges.find((c) => c.type === "published");
125
- const upgradeCap = objectChanges.find((c) => c.type === "created" && (c.objectType?.endsWith("::package::UpgradeCap") ?? false));
124
+ const published = pickPublishedChange(objectChanges);
125
+ if (!published?.objectId) return yield* Effect.fail(publishError("parse", {
126
+ sourcePath,
127
+ packageName,
128
+ message: "no \"published\" change in output — SDK shape drift (distilled doc §Edge cases)"
129
+ }));
130
+ const upgradeCap = pickUpgradeCapChange(objectChanges);
126
131
  const hydratedObjectChanges = yield* hydrateCreatedObjects(inputs.sdk, objectChanges);
127
132
  return {
128
133
  digest,
129
- packageId: published?.objectId ?? "",
134
+ packageId: published.objectId,
130
135
  publisher: inputs.account.address,
131
136
  ...upgradeCap?.objectId !== void 0 ? { upgradeCapId: upgradeCap.objectId } : {},
132
137
  objectChanges: hydratedObjectChanges
133
138
  };
134
- }).pipe(Effect.withSpan("devstack.plugin.package.publish-tx", { attributes: { [PackageSpans.publish.packageName]: packageName } })),
139
+ }),
135
140
  postPublishReadyHint: (packageId) => Effect.tryPromise(() => inputs.sdk.core.getObject({ objectId: packageId })).pipe(Effect.asVoid, Effect.catch((cause) => Effect.logDebug("package: post-publish ready-hint read failed").pipe(Effect.annotateLogs({
136
141
  packageId,
137
142
  cause: String(cause)
138
- }))), Effect.withSpan("devstack.plugin.package.post-publish-ready-hint", { attributes: { [PackageSpans.publish.packageId]: packageId } }))
143
+ }))))
139
144
  });
140
145
  //#endregion
141
146
  export { makePublishExecutor };
@@ -1 +1 @@
1
- {"version":3,"file":"publish-executor.mjs","names":[],"sources":["../../../src/plugins/package/publish-executor.ts"],"sourcesContent":["// Concrete `PublishExecutor` — wires the Move build, publish-tx\n// builder, and post-publish ready-probe over (a) the resolved\n// `SuiClient` from the Sui dependency and (b) the publisher account's signer\n// from the account dependency.\n//\n// Architecture: the executor is a small adapter — `mode-local.ts`\n// owns the 5-phase produce body (scrub → build → publish-tx → wait-\n// for-index → parse); this file just satisfies the `PublishExecutor`\n// interface by:\n//\n// 1. Delegating `build` to `runMoveBuild` (the existing path-(a)/\n// path-(b)/path-(c) dispatcher in `build.ts`).\n// 2. Constructing a `Transaction.publish({modules, dependencies})`\n// for `publishTx`, serialising via `tx.build({ client })`,\n// signing/executing inside the publisher account's transaction\n// critical section, and projecting the response to a\n// `LocalPackagePublishOutput`.\n// 3. Wrapping `sdk.core.waitForTransaction({ digest })` for\n// `postPublishReadyHint` — the SDK already retries / waits for\n// index visibility internally. The probe is hint-only: transient\n// `getObject` misses (cold index race) are intentionally\n// swallowed because the publisher account's `signAndExecute` has\n// already awaited `waitForTransaction(digest)`.\n//\n// Errors:\n// - Each method maps its concrete failure → a typed `PublishError`\n// whose `phase:` matches the produce-step taxonomy\n// (`build` / `publish-tx` / `parse`).\n// - Account sign failures roll into `publish-tx` with cause-chain\n// preserved; the cascade formatter unwraps them.\n\nimport { Effect, type Scope } from 'effect';\n\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport type { AccountValue, TxResult } from '../account/index.ts';\nimport type { ContainerRuntime, ImageRef } from '../../contracts/container-runtime.ts';\nimport type { ChainId } from '../../substrate/brand.ts';\nimport { formatUnknownError } from '../../substrate/runtime/format-unknown-error.ts';\nimport { formatExecutedFailure } from '../../substrate/runtime/sui-execute/index.ts';\nimport { signAndDispatch } from '../../substrate/runtime/sui-execute/sign-and-dispatch.ts';\nimport { buildForkImpersonationTransactionBytes } from '../sui/index.ts';\nimport { runMoveBuild, type BuildOutput } from './build.ts';\nimport type { LocalPackagePublishOutput, PackagePublishObjectChange } from './publish-output.ts';\nimport { publishError, type PublishError } from './errors.ts';\nimport type { PublishExecutor } from './mode-local.ts';\nimport { PackageSpans } from './spans.ts';\nimport type { SuiSdkShim } from '../sui/index.ts';\n\nconst shouldHydrateCreatedObject = (change: PackagePublishObjectChange): boolean =>\n\tchange.type === 'created' &&\n\tchange.objectId !== undefined &&\n\tchange.objectType !== undefined &&\n\t(change.objectType.includes('::coin::TreasuryCap<') ||\n\t\tchange.objectType.includes('::coin::CoinMetadata<') ||\n\t\tchange.objectType.includes('::coin_registry::Currency<'));\n\nconst projectObjectPayload = (raw: unknown): unknown => {\n\tif (raw !== null && typeof raw === 'object' && 'object' in raw) {\n\t\treturn (raw as { readonly object?: unknown }).object;\n\t}\n\treturn raw;\n};\n\nconst projectHydratedObjectFields = (\n\traw: unknown,\n): Pick<PackagePublishObjectChange, 'owner' | 'json'> => {\n\tconst object = projectObjectPayload(raw);\n\tif (object === null || typeof object !== 'object') return {};\n\tconst payload = object as { readonly owner?: unknown; readonly json?: unknown };\n\treturn {\n\t\t...(payload.owner === undefined ? {} : { owner: payload.owner }),\n\t\t...(payload.json === undefined ? {} : { json: payload.json }),\n\t};\n};\n\nconst hydrateCreatedObject = (\n\tsdk: SuiSdkShim,\n\tchange: PackagePublishObjectChange,\n): Effect.Effect<PackagePublishObjectChange> => {\n\tif (!shouldHydrateCreatedObject(change) || change.objectId === undefined) {\n\t\treturn Effect.succeed(change);\n\t}\n\tconst objectId = change.objectId;\n\treturn Effect.tryPromise({\n\t\ttry: () =>\n\t\t\tsdk.core.getObject({\n\t\t\t\tobjectId,\n\t\t\t\tinclude: { json: true },\n\t\t\t}),\n\t\tcatch: (cause) => cause,\n\t}).pipe(\n\t\tEffect.map((raw) => ({\n\t\t\t...change,\n\t\t\t...(raw === null ? {} : projectHydratedObjectFields(raw)),\n\t\t})),\n\t\t// Hydration is best-effort — a cold-cache `getObject` miss must\n\t\t// not fail the publish. Log at debug so the miss is visible (the\n\t\t// `tryPromise` catch wraps the original cause; cause-detail\n\t\t// extraction is non-trivial here, so we log the objectId — the\n\t\t// fact that this happened is the actionable signal).\n\t\tEffect.catch((cause) =>\n\t\t\tEffect.logDebug('package: hydrate-created-object cache miss').pipe(\n\t\t\t\tEffect.annotateLogs({ objectId, cause: String(cause) }),\n\t\t\t\tEffect.as(change),\n\t\t\t),\n\t\t),\n\t);\n};\n\nconst hydrateCreatedObjects = (\n\tsdk: SuiSdkShim,\n\tchanges: ReadonlyArray<PackagePublishObjectChange>,\n): Effect.Effect<ReadonlyArray<PackagePublishObjectChange>> =>\n\tEffect.forEach(changes, (change) => hydrateCreatedObject(sdk, change), {\n\t\tconcurrency: 'unbounded',\n\t});\n\n/** Project an account TxResult's flat `objectChanges` (`{type,\n * objectId, objectType?, ...}`) into the publish-output\n * `PackagePublishObjectChange[]` shape. The account plugin's\n * projection already classifies entries by `type`\n * (`published` for `outputState: 'PackageWrite'`, `created` for\n * `idOperation: 'Created'`, `mutated` otherwise); we just narrow\n * to the entries we care about (published + created) and drop the\n * extras. */\nconst publishChangesFromTxResult = (tx: TxResult): ReadonlyArray<PackagePublishObjectChange> => {\n\tconst out: Array<PackagePublishObjectChange> = [];\n\tfor (const change of tx.objectChanges) {\n\t\tif (typeof change !== 'object' || change === null) continue;\n\t\tconst projected = change as {\n\t\t\treadonly type?: string;\n\t\t\treadonly objectId?: unknown;\n\t\t\treadonly objectType?: unknown;\n\t\t};\n\t\tif (typeof projected.objectId !== 'string') continue;\n\t\tif (projected.type !== 'published' && projected.type !== 'created') continue;\n\t\tconst objectType = typeof projected.objectType === 'string' ? projected.objectType : undefined;\n\t\tout.push({\n\t\t\ttype: projected.type,\n\t\t\tobjectId: projected.objectId,\n\t\t\t...(objectType !== undefined ? { objectType } : {}),\n\t\t});\n\t}\n\treturn out;\n};\n\n// ---------------------------------------------------------------------------\n// Per-acquire inputs threaded by the barrel\n// ---------------------------------------------------------------------------\n\nexport interface PublishExecutorInputs {\n\t/** The resolved SDK shim from the Sui dependency. Carries `core.executeTransaction`,\n\t * `core.waitForTransaction`, plus the opaque `client` ref used by\n\t * `Transaction.build({ client })`. */\n\treadonly sdk: SuiSdkShim;\n\t/** Publisher account — provides `signAndExecute` (which internally\n\t * signs, submits via `executeTransaction`, and awaits finality via\n\t * `waitForTransaction`). The address surfaces as the publisher on\n\t * the output. */\n\treadonly account: AccountValue;\n\t/** Container runtime + image consumed by `runMoveBuild`'s path-(b)\n\t * (`docker run --rm`). Absent → path-(c) (host CLI). */\n\treadonly runtime?: ContainerRuntime | undefined;\n\treadonly buildImage?: ImageRef | undefined;\n\t/** Fork mode — real signers (not just impersonate) must build offline\n\t * with explicit gas, because the sui-fork binary has no\n\t * `simulate_transaction` for the SDK's gas-estimating `tx.build`. */\n\treadonly forkMode?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Executor factory\n// ---------------------------------------------------------------------------\n\n/**\n * Construct a `PublishExecutor` from the barrel's resolved inputs.\n *\n * The factory exists so the barrel can compose the executor once per\n * acquire and hand the result to `acquireLocal`. Internally the three\n * methods are closures over the inputs; no per-call construction.\n */\nexport const makePublishExecutor = (inputs: PublishExecutorInputs): PublishExecutor => ({\n\tscrubsInsideContainer: inputs.runtime !== undefined && inputs.buildImage !== undefined,\n\n\t// Build step — delegate to the Move-build dispatcher in `build.ts`.\n\tbuild: ({\n\t\tsourcePath,\n\t\tpackageName,\n\t\tchainId,\n\t}: {\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t\treadonly chainId: ChainId;\n\t}): Effect.Effect<BuildOutput, PublishError, Scope.Scope> =>\n\t\trunMoveBuild({\n\t\t\tsourcePath,\n\t\t\tpackageName,\n\t\t\tchainId,\n\t\t\t...(inputs.runtime !== undefined ? { runtime: inputs.runtime } : {}),\n\t\t\t...(inputs.buildImage !== undefined ? { buildImage: inputs.buildImage } : {}),\n\t\t}),\n\n\t// Publish step — build + sign + execute the publish tx.\n\tpublishTx: ({\n\t\tmodules,\n\t\tdependencies,\n\t\tsourcePath,\n\t\tpackageName,\n\t}: {\n\t\treadonly modules: ReadonlyArray<Uint8Array>;\n\t\treadonly dependencies: ReadonlyArray<string>;\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t}): Effect.Effect<LocalPackagePublishOutput, PublishError, Scope.Scope> =>\n\t\tEffect.gen(function* () {\n\t\t\t// Build the publish transaction. `tx.publish` accepts\n\t\t\t// `modules: number[][] | string[]` — coerce Uint8Array → number[].\n\t\t\t// `dependencies` is the array of dependency package ids from the\n\t\t\t// build output.\n\t\t\t//\n\t\t\t// `tx.publish` RETURNS the `UpgradeCap` (a value of `package::\n\t\t\t// UpgradeCap` — `key + store`, NO `drop`). The Move VM refuses\n\t\t\t// transactions that leave such values unused\n\t\t\t// (`UnusedValueWithoutDrop`); we MUST transfer the cap to a\n\t\t\t// concrete owner. Convention (matches v3 + dev-wallet's\n\t\t\t// MintNFT demo): transfer to the publisher account so the\n\t\t\t// stack-owner retains upgrade authority.\n\t\t\tconst tx = new Transaction();\n\t\t\ttx.setSender(inputs.account.address);\n\t\t\tconst upgradeCapArg = tx.publish({\n\t\t\t\tmodules: modules.map((m) => Array.from(m)),\n\t\t\t\tdependencies: [...dependencies],\n\t\t\t});\n\t\t\ttx.transferObjects([upgradeCapArg], inputs.account.address);\n\n\t\t\t// Both real-signer and impersonate paths route through the\n\t\t\t// account's `signAndExecute` (which signs, executes, waits,\n\t\t\t// and projects to the SDK-shaped `SignAndExecuteResult`\n\t\t\t// discriminated union). The impersonate path internally\n\t\t\t// hands off to `fork.impersonate`; the real-signer path\n\t\t\t// goes through the SDK directly. `signAndDispatch` compacts\n\t\t\t// the build → sign → execute → $kind dispatch boilerplate.\n\t\t\tconst { digest, objectChanges } = yield* signAndDispatch({\n\t\t\t\tsignerSource: inputs.account,\n\t\t\t\tbuildTxBytes: () =>\n\t\t\t\t\t// Serialise while the account lease is held. Non-fork real\n\t\t\t\t\t// signers use the SDK resolver. Fork mode (impersonate OR real\n\t\t\t\t\t// signer) must build offline with explicit gas fields: the\n\t\t\t\t\t// sui-fork binary has no simulate_transaction, so the SDK's\n\t\t\t\t\t// gas-estimating build path fails. The real-vs-empty-signature\n\t\t\t\t\t// split happens later in the account's signAndExecute.\n\t\t\t\t\tinputs.account.source === 'impersonate' || inputs.forkMode === true\n\t\t\t\t\t\t? buildForkImpersonationTransactionBytes(\n\t\t\t\t\t\t\t\ttx,\n\t\t\t\t\t\t\t\tinputs.account.address,\n\t\t\t\t\t\t\t\tinputs.sdk.core,\n\t\t\t\t\t\t\t).pipe(\n\t\t\t\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t\t\t\t(cause): PublishError =>\n\t\t\t\t\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\t\t`Fork impersonation Transaction.build failed for package '${packageName}': ` +\n\t\t\t\t\t\t\t\t\t\t\t\tcause.message,\n\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: Effect.tryPromise({\n\t\t\t\t\t\t\t\ttry: () => tx.build({ client: inputs.sdk.client }),\n\t\t\t\t\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\t`Transaction.build failed for package '${packageName}': ` +\n\t\t\t\t\t\t\t\t\t\t\t(formatUnknownError(cause)),\n\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t}),\n\t\t\t\tmapSignError: (cause): PublishError =>\n\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`account.signAndExecute failed for publisher '${inputs.account.name}' ` +\n\t\t\t\t\t\t\t`(address=${inputs.account.address}): ${\n\t\t\t\t\t\t\t\tformatUnknownError(cause)\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t\tonFailed: (failure) =>\n\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`executeTransaction returned FailedTransaction ` + formatExecutedFailure(failure),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\tonSuccess: (txResult: TxResult) =>\n\t\t\t\t\tEffect.succeed({\n\t\t\t\t\t\tdigest: txResult.digest,\n\t\t\t\t\t\tobjectChanges: publishChangesFromTxResult(txResult),\n\t\t\t\t\t}),\n\t\t\t});\n\n\t\t\tconst published = objectChanges.find((c) => c.type === 'published');\n\t\t\tconst upgradeCap = objectChanges.find(\n\t\t\t\t(c) => c.type === 'created' && (c.objectType?.endsWith('::package::UpgradeCap') ?? false),\n\t\t\t);\n\t\t\tconst hydratedObjectChanges = yield* hydrateCreatedObjects(inputs.sdk, objectChanges);\n\n\t\t\tconst output: LocalPackagePublishOutput = {\n\t\t\t\tdigest,\n\t\t\t\tpackageId: published?.objectId ?? '',\n\t\t\t\tpublisher: inputs.account.address,\n\t\t\t\t...(upgradeCap?.objectId !== undefined ? { upgradeCapId: upgradeCap.objectId } : {}),\n\t\t\t\tobjectChanges: hydratedObjectChanges,\n\t\t\t};\n\n\t\t\treturn output;\n\t\t}).pipe(\n\t\t\tEffect.withSpan('devstack.plugin.package.publish-tx', {\n\t\t\t\tattributes: { [PackageSpans.publish.packageName]: packageName },\n\t\t\t}),\n\t\t),\n\n\t// Post-publish ready HINT — a best-effort second-layer probe. The publish\n\t// account's `signAndExecute` already calls `waitForTransaction(digest)`\n\t// before returning, so the read on `packageId` here only catches the\n\t// \"tx written but object not yet queryable\" race. It MUST NOT fail the\n\t// publish: a transient / not-yet-indexed read is expected. The failure is\n\t// logged at debug (§18) so the miss stays visible rather than silently\n\t// swallowed, then the hint succeeds regardless.\n\tpostPublishReadyHint: (packageId: string): Effect.Effect<void, PublishError, Scope.Scope> =>\n\t\tEffect.tryPromise(() => inputs.sdk.core.getObject({ objectId: packageId })).pipe(\n\t\t\tEffect.asVoid,\n\t\t\tEffect.catch((cause) =>\n\t\t\t\tEffect.logDebug('package: post-publish ready-hint read failed').pipe(\n\t\t\t\t\tEffect.annotateLogs({ packageId, cause: String(cause) }),\n\t\t\t\t),\n\t\t\t),\n\t\t\tEffect.withSpan('devstack.plugin.package.post-publish-ready-hint', {\n\t\t\t\tattributes: { [PackageSpans.publish.packageId]: packageId },\n\t\t\t}),\n\t\t),\n});\n"],"mappings":";;;;;;;;;;;AAiDA,MAAM,8BAA8B,WACnC,OAAO,SAAS,aAChB,OAAO,aAAa,KAAA,KACpB,OAAO,eAAe,KAAA,MACrB,OAAO,WAAW,SAAS,uBAAuB,IAClD,OAAO,WAAW,SAAS,wBAAwB,IACnD,OAAO,WAAW,SAAS,6BAA6B;AAE1D,MAAM,wBAAwB,QAA0B;AACvD,KAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,YAAY,IAC1D,QAAQ,IAAsC;AAE/C,QAAO;;AAGR,MAAM,+BACL,QACwD;CACxD,MAAM,SAAS,qBAAqB,IAAI;AACxC,KAAI,WAAW,QAAQ,OAAO,WAAW,SAAU,QAAO,EAAE;CAC5D,MAAM,UAAU;AAChB,QAAO;EACN,GAAI,QAAQ,UAAU,KAAA,IAAY,EAAE,GAAG,EAAE,OAAO,QAAQ,OAAO;EAC/D,GAAI,QAAQ,SAAS,KAAA,IAAY,EAAE,GAAG,EAAE,MAAM,QAAQ,MAAM;EAC5D;;AAGF,MAAM,wBACL,KACA,WAC+C;AAC/C,KAAI,CAAC,2BAA2B,OAAO,IAAI,OAAO,aAAa,KAAA,EAC9D,QAAO,OAAO,QAAQ,OAAO;CAE9B,MAAM,WAAW,OAAO;AACxB,QAAO,OAAO,WAAW;EACxB,WACC,IAAI,KAAK,UAAU;GAClB;GACA,SAAS,EAAE,MAAM,MAAM;GACvB,CAAC;EACH,QAAQ,UAAU;EAClB,C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N;GACA,WAAW,WAAW,YAAY;GAClC,WAAW,OAAO,QAAQ;GAC1B,GAAI,YAAY,aAAa,KAAA,IAAY,EAAE,cAAc,WAAW,UAAU,GAAG,EAAE;GACnF,eAAe;GAGH;GACZ,CAAC,KACF,OAAO,SAAS,sCAAsC,EACrD,YAAY,GAAG,aAAa,QAAQ,cAAc,aAAa,EAC/D,CAAC,CACF;CASF,uBAAuB,cACtB,OAAO,iBAAiB,OAAO,IAAI,KAAK,UAAU,EAAE,UAAU,WAAW,CAAC,CAAC,CAAC,KAC3E,OAAO,QACP,OAAO,OAAO,UACb,OAAO,SAAS,+CAA+C,CAAC,KAC/D,OAAO,aAAa;EAAE;EAAW,OAAO,OAAO,MAAM;EAAE,CAAC,CACxD,CACD,EACD,OAAO,SAAS,mDAAmD,EAClE,YAAY,GAAG,aAAa,QAAQ,YAAY,WAAW,EAC3D,CAAC,CACF;CACF"}
1
+ {"version":3,"file":"publish-executor.mjs","names":[],"sources":["../../../src/plugins/package/publish-executor.ts"],"sourcesContent":["// Concrete `PublishExecutor` — wires the Move build, publish-tx\n// builder, and post-publish ready-probe over (a) the resolved\n// `SuiClient` from the Sui dependency and (b) the publisher account's signer\n// from the account dependency.\n//\n// Architecture: the executor is a small adapter — `mode-local.ts`\n// owns the 5-phase produce body (scrub → build → publish-tx → wait-\n// for-index → parse); this file just satisfies the `PublishExecutor`\n// interface by:\n//\n// 1. Delegating `build` to `runMoveBuild` (the existing path-(a)/\n// path-(b)/path-(c) dispatcher in `build.ts`).\n// 2. Constructing a `Transaction.publish({modules, dependencies})`\n// for `publishTx`, serialising via `tx.build({ client })`,\n// signing/executing inside the publisher account's transaction\n// critical section, and projecting the response to a\n// `LocalPackagePublishOutput`.\n// 3. Wrapping `sdk.core.waitForTransaction({ digest })` for\n// `postPublishReadyHint` — the SDK already retries / waits for\n// index visibility internally. The probe is hint-only: transient\n// `getObject` misses (cold index race) are intentionally\n// swallowed because the publisher account's `signAndExecute` has\n// already awaited `waitForTransaction(digest)`.\n//\n// Errors:\n// - Each method maps its concrete failure → a typed `PublishError`\n// whose `phase:` matches the produce-step taxonomy\n// (`build` / `publish-tx` / `parse`).\n// - Account sign failures roll into `publish-tx` with cause-chain\n// preserved; the cascade formatter unwraps them.\n\nimport { Effect, type Scope } from 'effect';\n\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport type { AccountValue, TxResult } from '../account/index.ts';\nimport type { ContainerRuntime, ImageRef } from '../../contracts/container-runtime.ts';\nimport { formatUnknownError } from '../../substrate/runtime/format-unknown-error.ts';\nimport {\n\tbuildForkImpersonationTransactionBytes,\n\tformatExecutedFailure,\n\tsignAndDispatch,\n\ttype SuiSdkShim,\n} from '../sui/index.ts';\nimport { runMoveBuild, type BuildOutput } from './build.ts';\nimport {\n\tpickPublishedChange,\n\tpickUpgradeCapChange,\n\ttype LocalPackagePublishOutput,\n\ttype PackagePublishObjectChange,\n} from './publish-output.ts';\nimport { publishError, type PublishError } from './errors.ts';\nimport type { PublishExecutor } from './mode-local.ts';\n\nconst shouldHydrateCreatedObject = (change: PackagePublishObjectChange): boolean =>\n\tchange.type === 'created' &&\n\tchange.objectId !== undefined &&\n\tchange.objectType !== undefined &&\n\t(change.objectType.includes('::coin::TreasuryCap<') ||\n\t\tchange.objectType.includes('::coin::CoinMetadata<') ||\n\t\tchange.objectType.includes('::coin_registry::Currency<'));\n\nconst projectObjectPayload = (raw: unknown): unknown => {\n\tif (raw !== null && typeof raw === 'object' && 'object' in raw) {\n\t\treturn (raw as { readonly object?: unknown }).object;\n\t}\n\treturn raw;\n};\n\nconst projectHydratedObjectFields = (\n\traw: unknown,\n): Pick<PackagePublishObjectChange, 'owner' | 'json'> => {\n\tconst object = projectObjectPayload(raw);\n\tif (object === null || typeof object !== 'object') return {};\n\tconst payload = object as { readonly owner?: unknown; readonly json?: unknown };\n\treturn {\n\t\t...(payload.owner === undefined ? {} : { owner: payload.owner }),\n\t\t...(payload.json === undefined ? {} : { json: payload.json }),\n\t};\n};\n\nconst hydrateCreatedObject = (\n\tsdk: SuiSdkShim,\n\tchange: PackagePublishObjectChange,\n): Effect.Effect<PackagePublishObjectChange> => {\n\tif (!shouldHydrateCreatedObject(change) || change.objectId === undefined) {\n\t\treturn Effect.succeed(change);\n\t}\n\tconst objectId = change.objectId;\n\treturn Effect.tryPromise({\n\t\ttry: () =>\n\t\t\tsdk.core.getObject({\n\t\t\t\tobjectId,\n\t\t\t\tinclude: { json: true },\n\t\t\t}),\n\t\tcatch: (cause) => cause,\n\t}).pipe(\n\t\tEffect.map((raw) => ({\n\t\t\t...change,\n\t\t\t...(raw === null ? {} : projectHydratedObjectFields(raw)),\n\t\t})),\n\t\t// Hydration is best-effort — a cold-cache `getObject` miss must\n\t\t// not fail the publish. Log at debug so the miss is visible (the\n\t\t// `tryPromise` catch wraps the original cause; cause-detail\n\t\t// extraction is non-trivial here, so we log the objectId — the\n\t\t// fact that this happened is the actionable signal).\n\t\tEffect.catch((cause) =>\n\t\t\tEffect.logDebug('package: hydrate-created-object cache miss').pipe(\n\t\t\t\tEffect.annotateLogs({ objectId, cause: String(cause) }),\n\t\t\t\tEffect.as(change),\n\t\t\t),\n\t\t),\n\t);\n};\n\nconst hydrateCreatedObjects = (\n\tsdk: SuiSdkShim,\n\tchanges: ReadonlyArray<PackagePublishObjectChange>,\n): Effect.Effect<ReadonlyArray<PackagePublishObjectChange>> =>\n\tEffect.forEach(changes, (change) => hydrateCreatedObject(sdk, change), {\n\t\tconcurrency: 'unbounded',\n\t});\n\n/** Project an account TxResult's flat `objectChanges` (`{type,\n * objectId, objectType?, ...}`) into the publish-output\n * `PackagePublishObjectChange[]` shape. The account plugin's\n * projection already classifies entries by `type`\n * (`published` for `outputState: 'PackageWrite'`, `created` for\n * `idOperation: 'Created'`, `mutated` otherwise); we just narrow\n * to the entries we care about (published + created) and drop the\n * extras. */\nconst publishChangesFromTxResult = (tx: TxResult): ReadonlyArray<PackagePublishObjectChange> => {\n\tconst out: Array<PackagePublishObjectChange> = [];\n\tfor (const change of tx.objectChanges) {\n\t\tif (typeof change !== 'object' || change === null) continue;\n\t\tconst projected = change as {\n\t\t\treadonly type?: string;\n\t\t\treadonly objectId?: unknown;\n\t\t\treadonly objectType?: unknown;\n\t\t};\n\t\tif (typeof projected.objectId !== 'string') continue;\n\t\tif (projected.type !== 'published' && projected.type !== 'created') continue;\n\t\tconst objectType = typeof projected.objectType === 'string' ? projected.objectType : undefined;\n\t\tout.push({\n\t\t\ttype: projected.type,\n\t\t\tobjectId: projected.objectId,\n\t\t\t...(objectType !== undefined ? { objectType } : {}),\n\t\t});\n\t}\n\treturn out;\n};\n\n// ---------------------------------------------------------------------------\n// Per-acquire inputs threaded by the barrel\n// ---------------------------------------------------------------------------\n\nexport interface PublishExecutorInputs {\n\t/** The resolved SDK shim from the Sui dependency. Carries `core.executeTransaction`,\n\t * `core.waitForTransaction`, plus the opaque `client` ref used by\n\t * `Transaction.build({ client })`. */\n\treadonly sdk: SuiSdkShim;\n\t/** Publisher account — provides `signAndExecute` (which internally\n\t * signs, submits via `executeTransaction`, and awaits finality via\n\t * `waitForTransaction`). The address surfaces as the publisher on\n\t * the output. */\n\treadonly account: AccountValue;\n\t/** Container runtime + image consumed by `runMoveBuild`'s path-(b)\n\t * (`docker run --rm`). Absent → path-(c) (host CLI). */\n\treadonly runtime?: ContainerRuntime | undefined;\n\treadonly buildImage?: ImageRef | undefined;\n\t/** Fork mode — real signers (not just impersonate) must build offline\n\t * with explicit gas, because the sui-fork binary has no\n\t * `simulate_transaction` for the SDK's gas-estimating `tx.build`. */\n\treadonly forkMode?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Executor factory\n// ---------------------------------------------------------------------------\n\n/**\n * Construct a `PublishExecutor` from the barrel's resolved inputs.\n *\n * The factory exists so the barrel can compose the executor once per\n * acquire and hand the result to `acquireLocal`. Internally the three\n * methods are closures over the inputs; no per-call construction.\n */\nexport const makePublishExecutor = (inputs: PublishExecutorInputs): PublishExecutor => ({\n\tscrubsInsideContainer: inputs.runtime !== undefined && inputs.buildImage !== undefined,\n\n\t// Build step — delegate to the Move-build dispatcher in `build.ts`.\n\tbuild: ({\n\t\tsourcePath,\n\t\tpackageName,\n\t\tchainId,\n\t}: {\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t\treadonly chainId: string;\n\t}): Effect.Effect<BuildOutput, PublishError, Scope.Scope> =>\n\t\trunMoveBuild({\n\t\t\tsourcePath,\n\t\t\tpackageName,\n\t\t\tchainId,\n\t\t\t...(inputs.runtime !== undefined ? { runtime: inputs.runtime } : {}),\n\t\t\t...(inputs.buildImage !== undefined ? { buildImage: inputs.buildImage } : {}),\n\t\t}),\n\n\t// Publish step — build + sign + execute the publish tx.\n\tpublishTx: ({\n\t\tmodules,\n\t\tdependencies,\n\t\tsourcePath,\n\t\tpackageName,\n\t}: {\n\t\treadonly modules: ReadonlyArray<Uint8Array>;\n\t\treadonly dependencies: ReadonlyArray<string>;\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t}): Effect.Effect<LocalPackagePublishOutput, PublishError, Scope.Scope> =>\n\t\tEffect.gen(function* () {\n\t\t\t// Build the publish transaction. `tx.publish` accepts\n\t\t\t// `modules: number[][] | string[]` — coerce Uint8Array → number[].\n\t\t\t// `dependencies` is the array of dependency package ids from the\n\t\t\t// build output.\n\t\t\t//\n\t\t\t// `tx.publish` RETURNS the `UpgradeCap` (a value of `package::\n\t\t\t// UpgradeCap` — `key + store`, NO `drop`). The Move VM refuses\n\t\t\t// transactions that leave such values unused\n\t\t\t// (`UnusedValueWithoutDrop`); we MUST transfer the cap to a\n\t\t\t// concrete owner. Convention: transfer to the publisher account\n\t\t\t// so the stack-owner retains upgrade authority.\n\t\t\tconst tx = new Transaction();\n\t\t\ttx.setSender(inputs.account.address);\n\t\t\tconst upgradeCapArg = tx.publish({\n\t\t\t\tmodules: modules.map((m) => Array.from(m)),\n\t\t\t\tdependencies: [...dependencies],\n\t\t\t});\n\t\t\ttx.transferObjects([upgradeCapArg], inputs.account.address);\n\n\t\t\t// Both real-signer and impersonate paths route through the\n\t\t\t// account's `signAndExecute` (which signs, executes, waits,\n\t\t\t// and projects to the SDK-shaped `SignAndExecuteResult`\n\t\t\t// discriminated union). The impersonate path internally\n\t\t\t// hands off to `fork.impersonate`; the real-signer path\n\t\t\t// goes through the SDK directly. `signAndDispatch` compacts\n\t\t\t// the build → sign → execute → $kind dispatch boilerplate.\n\t\t\tconst { digest, objectChanges } = yield* signAndDispatch({\n\t\t\t\tsignerSource: inputs.account,\n\t\t\t\tbuildTxBytes: () =>\n\t\t\t\t\t// Serialise while the account lease is held. Non-fork real\n\t\t\t\t\t// signers use the SDK resolver. Fork mode (impersonate OR real\n\t\t\t\t\t// signer) must build offline with explicit gas fields: the\n\t\t\t\t\t// sui-fork binary has no simulate_transaction, so the SDK's\n\t\t\t\t\t// gas-estimating build path fails. The real-vs-empty-signature\n\t\t\t\t\t// split happens later in the account's signAndExecute.\n\t\t\t\t\tinputs.account.source === 'impersonate' || inputs.forkMode === true\n\t\t\t\t\t\t? buildForkImpersonationTransactionBytes(\n\t\t\t\t\t\t\t\ttx,\n\t\t\t\t\t\t\t\tinputs.account.address,\n\t\t\t\t\t\t\t\tinputs.sdk.core,\n\t\t\t\t\t\t\t).pipe(\n\t\t\t\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t\t\t\t(cause): PublishError =>\n\t\t\t\t\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\t\t`Fork impersonation Transaction.build failed for package '${packageName}': ` +\n\t\t\t\t\t\t\t\t\t\t\t\tcause.message,\n\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: Effect.tryPromise({\n\t\t\t\t\t\t\t\ttry: () => tx.build({ client: inputs.sdk.client }),\n\t\t\t\t\t\t\t\tcatch: (cause): PublishError =>\n\t\t\t\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\t`Transaction.build failed for package '${packageName}': ` +\n\t\t\t\t\t\t\t\t\t\t\tformatUnknownError(cause),\n\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t}),\n\t\t\t\tmapSignError: (cause): PublishError =>\n\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t`account.signAndExecute failed for publisher '${inputs.account.name}' ` +\n\t\t\t\t\t\t\t`(address=${inputs.account.address}): ${formatUnknownError(cause)}`,\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t\tonFailed: (failure) =>\n\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\tpublishError('publish-tx', {\n\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`executeTransaction returned FailedTransaction ` + formatExecutedFailure(failure),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\tonSuccess: (txResult: TxResult) =>\n\t\t\t\t\tEffect.succeed({\n\t\t\t\t\t\tdigest: txResult.digest,\n\t\t\t\t\t\tobjectChanges: publishChangesFromTxResult(txResult),\n\t\t\t\t\t}),\n\t\t\t});\n\n\t\t\tconst published = pickPublishedChange(objectChanges);\n\t\t\tif (!published?.objectId) {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tpublishError('parse', {\n\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t'no \"published\" change in output — SDK shape drift (distilled doc §Edge cases)',\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst upgradeCap = pickUpgradeCapChange(objectChanges);\n\t\t\tconst hydratedObjectChanges = yield* hydrateCreatedObjects(inputs.sdk, objectChanges);\n\n\t\t\tconst output: LocalPackagePublishOutput = {\n\t\t\t\tdigest,\n\t\t\t\tpackageId: published.objectId,\n\t\t\t\tpublisher: inputs.account.address,\n\t\t\t\t...(upgradeCap?.objectId !== undefined ? { upgradeCapId: upgradeCap.objectId } : {}),\n\t\t\t\tobjectChanges: hydratedObjectChanges,\n\t\t\t};\n\n\t\t\treturn output;\n\t\t}),\n\n\t// Post-publish ready HINT — a best-effort second-layer probe. The publish\n\t// account's `signAndExecute` already calls `waitForTransaction(digest)`\n\t// before returning, so the read on `packageId` here only catches the\n\t// \"tx written but object not yet queryable\" race. It MUST NOT fail the\n\t// publish: a transient / not-yet-indexed read is expected. The failure is\n\t// logged at debug (§18) so the miss stays visible rather than silently\n\t// swallowed, then the hint succeeds regardless.\n\tpostPublishReadyHint: (packageId: string): Effect.Effect<void, PublishError, Scope.Scope> =>\n\t\tEffect.tryPromise(() => inputs.sdk.core.getObject({ objectId: packageId })).pipe(\n\t\t\tEffect.asVoid,\n\t\t\tEffect.catch((cause) =>\n\t\t\t\tEffect.logDebug('package: post-publish ready-hint read failed').pipe(\n\t\t\t\t\tEffect.annotateLogs({ packageId, cause: String(cause) }),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n});\n"],"mappings":";;;;;;;;;;;AAsDA,MAAM,8BAA8B,WACnC,OAAO,SAAS,aAChB,OAAO,aAAa,KAAA,KACpB,OAAO,eAAe,KAAA,MACrB,OAAO,WAAW,SAAS,sBAAsB,KACjD,OAAO,WAAW,SAAS,uBAAuB,KAClD,OAAO,WAAW,SAAS,4BAA4B;AAEzD,MAAM,wBAAwB,QAA0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