@mysten-incubation/devstack 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/dashboard-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dashboard-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dashboard-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dashboard-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-cyrillic-ext-wght-normal-I4S5GZfc.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-cyrillic-wght-normal-BmXc_FBt.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-latin-ext-wght-normal-DrnZ1wKl.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-latin-wght-normal-B_7UjwxQ.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-symbols2-wght-normal-GZpp1pK2.woff2 +0 -0
- package/dashboard-ui/assets/geist-mono-vietnamese-wght-normal-D8KDMBhC.woff2 +0 -0
- package/dashboard-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dashboard-ui/assets/index-Bmi1UtAg.js +1356 -0
- package/dashboard-ui/assets/index-D5EShVt4.js +3 -0
- package/dashboard-ui/assets/index-Deml9drg.css +1 -0
- package/dashboard-ui/index.html +13 -0
- package/dist/api/define-capabilities.d.mts +14 -3
- package/dist/api/define-capabilities.mjs +18 -1
- package/dist/api/define-capabilities.mjs.map +1 -1
- package/dist/api/define-devstack.d.mts +1 -1
- package/dist/api/define-devstack.mjs +6 -26
- package/dist/api/define-devstack.mjs.map +1 -1
- package/dist/api/define-plugin.d.mts +1 -0
- package/dist/api/define-plugin.mjs +2 -0
- package/dist/api/inference-network.d.mts +132 -0
- package/dist/api/inference-network.mjs +105 -16
- package/dist/api/inference-network.mjs.map +1 -1
- package/dist/api/plugin-errors.d.mts +7 -0
- package/dist/api/run-stack.d.mts +20 -9
- package/dist/api/run-stack.mjs +56 -29
- package/dist/api/run-stack.mjs.map +1 -1
- package/dist/build-integrations/playwright/config.d.mts +6 -4
- package/dist/build-integrations/playwright/config.mjs +5 -3
- package/dist/build-integrations/playwright/config.mjs.map +1 -1
- package/dist/build-integrations/playwright/errors.d.mts +1 -1
- package/dist/build-integrations/playwright/global-setup.d.mts +43 -17
- package/dist/build-integrations/playwright/global-setup.mjs +250 -13
- package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
- package/dist/build-integrations/playwright/index.d.mts +5 -3
- package/dist/build-integrations/playwright/index.mjs +4 -2
- package/dist/build-integrations/playwright/stack-context.d.mts +0 -1
- package/dist/build-integrations/playwright/stack-context.mjs +24 -63
- package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
- package/dist/build-integrations/playwright/wallet-context.d.mts +7 -10
- package/dist/build-integrations/playwright/wallet-context.mjs +8 -13
- package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/cold-start-url.d.mts +5 -0
- package/dist/build-integrations/runtime/cold-start-url.mjs +4 -3
- package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
- package/dist/build-integrations/runtime/conventional-routes.d.mts +51 -0
- package/dist/build-integrations/runtime/conventional-routes.mjs +92 -0
- package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -0
- package/dist/build-integrations/runtime/discover.d.mts +38 -30
- package/dist/build-integrations/runtime/discover.mjs +73 -70
- package/dist/build-integrations/runtime/discover.mjs.map +1 -1
- package/dist/build-integrations/runtime/endpoint-registry.d.mts +3 -1
- package/dist/build-integrations/runtime/endpoint-registry.mjs +3 -1
- package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
- package/dist/build-integrations/runtime/index.d.mts +7 -2
- package/dist/build-integrations/runtime/index.mjs +9 -2
- package/dist/build-integrations/runtime/manifest-types.d.mts +2 -0
- package/dist/build-integrations/runtime/manifest-types.mjs +3 -0
- package/dist/build-integrations/runtime/playwright-stack-context-slot.d.mts +29 -0
- package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs +10 -0
- package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs.map +1 -0
- package/dist/build-integrations/runtime/read-stack-context.d.mts +1 -1
- package/dist/build-integrations/runtime/read-stack-context.mjs +10 -4
- package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +48 -0
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs +42 -0
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -0
- package/dist/build-integrations/runtime/stack-context.d.mts +1 -1
- package/dist/build-integrations/runtime/wallet-paths.mjs +2 -0
- package/dist/build-integrations/vite/index.d.mts +51 -0
- package/dist/build-integrations/vite/index.mjs +73 -0
- package/dist/build-integrations/vite/index.mjs.map +1 -0
- package/dist/build-integrations/vitest/env.d.mts +4 -3
- package/dist/build-integrations/vitest/env.mjs +6 -4
- package/dist/build-integrations/vitest/env.mjs.map +1 -1
- package/dist/build-integrations/vitest/errors.d.mts +25 -4
- package/dist/build-integrations/vitest/errors.mjs +15 -2
- package/dist/build-integrations/vitest/errors.mjs.map +1 -1
- package/dist/build-integrations/vitest/index.d.mts +2 -2
- package/dist/build-integrations/vitest/index.mjs +3 -3
- package/dist/build-integrations/vitest/setup.d.mts +4 -2
- package/dist/build-integrations/vitest/setup.mjs +2 -2
- package/dist/build-integrations/vitest/setup.mjs.map +1 -1
- package/dist/build-integrations/vitest/stack-context.d.mts +0 -1
- package/dist/build-integrations/vitest/stack-context.mjs +33 -13
- package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
- package/dist/cli/bail.mjs +23 -0
- package/dist/cli/bail.mjs.map +1 -0
- package/dist/{surfaces/cli/commands → cli}/doctor-probes.mjs +26 -16
- package/dist/cli/doctor-probes.mjs.map +1 -0
- package/dist/cli/main.d.mts +15 -1
- package/dist/cli/main.mjs +166 -482
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/prune-direct.mjs +31 -201
- package/dist/cli/prune-direct.mjs.map +1 -1
- package/dist/cli/snapshot-reader.mjs +14 -11
- package/dist/cli/snapshot-reader.mjs.map +1 -1
- package/dist/cli/up-lifecycle.mjs +4 -1
- package/dist/cli/up-lifecycle.mjs.map +1 -1
- package/dist/cli/wirings/apply.mjs +95 -0
- package/dist/cli/wirings/apply.mjs.map +1 -0
- package/dist/cli/wirings/build-verb-layers.mjs +42 -0
- package/dist/cli/wirings/build-verb-layers.mjs.map +1 -0
- package/dist/cli/wirings/config-loader.mjs +69 -0
- package/dist/cli/wirings/config-loader.mjs.map +1 -0
- package/dist/cli/wirings/engine-command.mjs +30 -0
- package/dist/cli/wirings/engine-command.mjs.map +1 -0
- package/dist/cli/wirings/identity.mjs +72 -0
- package/dist/cli/wirings/identity.mjs.map +1 -0
- package/dist/cli/wirings/provide-file-system.mjs +7 -0
- package/dist/cli/wirings/provide-file-system.mjs.map +1 -0
- package/dist/cli/wirings/snapshot.mjs +177 -0
- package/dist/cli/wirings/snapshot.mjs.map +1 -0
- package/dist/cli/wirings/up.mjs +287 -0
- package/dist/cli/wirings/up.mjs.map +1 -0
- package/dist/cli/wirings/wipe.mjs +40 -0
- package/dist/cli/wirings/wipe.mjs.map +1 -0
- package/dist/contracts/capability-decl.d.mts +0 -2
- package/dist/contracts/codegenable.d.mts +43 -0
- package/dist/contracts/container-runtime.d.mts +26 -1
- package/dist/contracts/faucet-strategy.d.mts +25 -0
- package/dist/contracts/funding-strategy.d.mts +42 -0
- package/dist/contracts/plugin-expander.mjs +60 -0
- package/dist/contracts/plugin-expander.mjs.map +1 -0
- package/dist/contracts/projection.d.mts +5 -3
- package/dist/contracts/renderer.d.mts +23 -0
- package/dist/contracts/routable.d.mts +14 -1
- package/dist/contracts/snapshotable.d.mts +25 -3
- package/dist/contracts/wallet-protocol.d.mts +52 -0
- package/dist/contracts/wallet-protocol.mjs +52 -0
- package/dist/contracts/wallet-protocol.mjs.map +1 -0
- package/dist/index.d.mts +26 -25
- package/dist/index.mjs +20 -13
- package/dist/{runtime → orchestrators}/built-in-plugin-layers.mjs +10 -5
- package/dist/orchestrators/built-in-plugin-layers.mjs.map +1 -0
- package/dist/orchestrators/codegen/bindings.d.mts +1 -2
- package/dist/orchestrators/codegen/bindings.mjs +52 -186
- package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
- package/dist/orchestrators/codegen/emit.mjs +19 -1
- package/dist/orchestrators/codegen/emit.mjs.map +1 -1
- package/dist/orchestrators/codegen/errors.mjs +8 -3
- package/dist/orchestrators/codegen/errors.mjs.map +1 -1
- package/dist/orchestrators/codegen/format.mjs +47 -39
- package/dist/orchestrators/codegen/format.mjs.map +1 -1
- package/dist/orchestrators/codegen/gitignore.mjs +3 -1
- package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
- package/dist/orchestrators/codegen/output-location.mjs +41 -0
- package/dist/orchestrators/codegen/output-location.mjs.map +1 -0
- package/dist/orchestrators/codegen/paths.d.mts +1 -1
- package/dist/orchestrators/codegen/paths.mjs +40 -14
- package/dist/orchestrators/codegen/paths.mjs.map +1 -1
- package/dist/orchestrators/codegen/permissions.mjs +3 -1
- package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
- package/dist/orchestrators/codegen/service.mjs +157 -105
- package/dist/orchestrators/codegen/service.mjs.map +1 -1
- package/dist/orchestrators/lifecycle-prune/errors.mjs +31 -0
- package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -0
- package/dist/orchestrators/lifecycle-prune/index.mjs +350 -0
- package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -0
- package/dist/orchestrators/router/cleanup.mjs +26 -27
- package/dist/orchestrators/router/cleanup.mjs.map +1 -1
- package/dist/orchestrators/router/entrypoints.mjs +2 -2
- package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
- package/dist/orchestrators/router/file-provider.mjs +14 -5
- package/dist/orchestrators/router/file-provider.mjs.map +1 -1
- package/dist/orchestrators/router/hostname.mjs +19 -55
- package/dist/orchestrators/router/hostname.mjs.map +1 -1
- package/dist/orchestrators/router/index.mjs +11 -0
- package/dist/orchestrators/router/profile.mjs +2 -2
- package/dist/orchestrators/router/sentinels.mjs +26 -0
- package/dist/orchestrators/router/sentinels.mjs.map +1 -0
- package/dist/orchestrators/router/service.mjs +40 -37
- package/dist/orchestrators/router/service.mjs.map +1 -1
- package/dist/orchestrators/router/traefik-container.mjs +27 -16
- package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
- package/dist/{substrate/runtime → orchestrators}/run.mjs +26 -21
- package/dist/orchestrators/run.mjs.map +1 -0
- package/dist/orchestrators/runtime-composition.d.mts +1 -1
- package/dist/orchestrators/runtime-composition.mjs +123 -39
- package/dist/orchestrators/runtime-composition.mjs.map +1 -1
- package/dist/orchestrators/snapshot/capture-command.d.mts +1 -0
- package/dist/orchestrators/snapshot/capture-command.mjs +25 -0
- package/dist/orchestrators/snapshot/capture-command.mjs.map +1 -0
- package/dist/orchestrators/snapshot/capture.mjs +42 -28
- package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
- package/dist/orchestrators/snapshot/descriptor.mjs +35 -10
- package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
- package/dist/orchestrators/snapshot/identity-guard.mjs +1 -1
- package/dist/orchestrators/snapshot/index.mjs +13 -0
- package/dist/orchestrators/snapshot/integrity.d.mts +1 -1
- package/dist/orchestrators/snapshot/integrity.mjs +73 -17
- package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
- package/dist/orchestrators/snapshot/pending-marker.d.mts +1 -0
- package/dist/orchestrators/snapshot/pending-marker.mjs +99 -0
- package/dist/orchestrators/snapshot/pending-marker.mjs.map +1 -0
- package/dist/orchestrators/snapshot/phase-error.mjs +23 -0
- package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -0
- package/dist/orchestrators/snapshot/prune.mjs +20 -55
- package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
- package/dist/orchestrators/snapshot/recover-pending.d.mts +1 -0
- package/dist/orchestrators/snapshot/recover-pending.mjs +223 -0
- package/dist/orchestrators/snapshot/recover-pending.mjs.map +1 -0
- package/dist/orchestrators/snapshot/restore.mjs +118 -84
- package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
- package/dist/orchestrators/snapshot/service.mjs +53 -56
- package/dist/orchestrators/snapshot/service.mjs.map +1 -1
- package/dist/orchestrators/snapshot/state-document.d.mts +1 -0
- package/dist/orchestrators/snapshot/state-document.mjs +47 -7
- package/dist/orchestrators/snapshot/state-document.mjs.map +1 -1
- package/dist/orchestrators/snapshot/wipe.mjs +67 -10
- package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
- package/dist/plugins/account/codegen.mjs +9 -8
- package/dist/plugins/account/codegen.mjs.map +1 -1
- package/dist/plugins/account/errors.d.mts +33 -6
- package/dist/plugins/account/errors.mjs.map +1 -1
- package/dist/plugins/account/funding.d.mts +29 -19
- package/dist/plugins/account/funding.mjs +84 -66
- package/dist/plugins/account/funding.mjs.map +1 -1
- package/dist/plugins/account/index.d.mts +2 -4
- package/dist/plugins/account/index.mjs +64 -31
- package/dist/plugins/account/index.mjs.map +1 -1
- package/dist/plugins/account/keypair.mjs +6 -9
- package/dist/plugins/account/keypair.mjs.map +1 -1
- package/dist/plugins/account/lease.mjs +1 -0
- package/dist/plugins/account/lease.mjs.map +1 -1
- package/dist/plugins/account/registry.d.mts +14 -1
- package/dist/plugins/account/registry.mjs +18 -18
- package/dist/plugins/account/registry.mjs.map +1 -1
- package/dist/plugins/account/service.d.mts +23 -4
- package/dist/plugins/account/service.mjs +83 -45
- package/dist/plugins/account/service.mjs.map +1 -1
- package/dist/plugins/account/snapshot.mjs +2 -5
- package/dist/plugins/account/snapshot.mjs.map +1 -1
- package/dist/plugins/account/spans.mjs +16 -0
- package/dist/plugins/account/spans.mjs.map +1 -0
- package/dist/plugins/account/variants/keystore.mjs +6 -8
- package/dist/plugins/account/variants/keystore.mjs.map +1 -1
- package/dist/plugins/action/build-context.d.mts +3 -2
- package/dist/plugins/action/errors.d.mts +16 -12
- package/dist/plugins/action/errors.mjs.map +1 -1
- package/dist/plugins/action/execute.mjs +65 -103
- package/dist/plugins/action/execute.mjs.map +1 -1
- package/dist/plugins/action/index.d.mts +0 -2
- package/dist/plugins/action/index.mjs +17 -13
- package/dist/plugins/action/index.mjs.map +1 -1
- package/dist/plugins/action/service.mjs +38 -35
- package/dist/plugins/action/service.mjs.map +1 -1
- package/dist/plugins/action/spans.mjs +11 -0
- package/dist/plugins/action/spans.mjs.map +1 -0
- package/dist/plugins/coin/codegen.mjs +9 -8
- package/dist/plugins/coin/codegen.mjs.map +1 -1
- package/dist/plugins/coin/discovery.mjs +8 -4
- package/dist/plugins/coin/discovery.mjs.map +1 -1
- package/dist/plugins/coin/index.d.mts +11 -29
- package/dist/plugins/coin/index.mjs +56 -27
- package/dist/plugins/coin/index.mjs.map +1 -1
- package/dist/plugins/coin/metadata.mjs +8 -15
- package/dist/plugins/coin/metadata.mjs.map +1 -1
- package/dist/plugins/coin/mint.d.mts +30 -11
- package/dist/plugins/coin/mint.mjs +78 -74
- package/dist/plugins/coin/mint.mjs.map +1 -1
- package/dist/plugins/coin/registry.mjs +4 -7
- package/dist/plugins/coin/registry.mjs.map +1 -1
- package/dist/plugins/coin/service.d.mts +39 -1
- package/dist/plugins/coin/service.mjs +11 -4
- package/dist/plugins/coin/service.mjs.map +1 -1
- package/dist/plugins/coin/spans.mjs +20 -0
- package/dist/plugins/coin/spans.mjs.map +1 -0
- package/dist/plugins/dashboard/domain.mjs +402 -0
- package/dist/plugins/dashboard/domain.mjs.map +1 -0
- package/dist/plugins/dashboard/index.d.mts +29 -0
- package/dist/plugins/dashboard/index.mjs +91 -0
- package/dist/plugins/dashboard/index.mjs.map +1 -0
- package/dist/plugins/dashboard/origin-policy.mjs +36 -0
- package/dist/plugins/dashboard/origin-policy.mjs.map +1 -0
- package/dist/plugins/dashboard/routable.mjs +27 -0
- package/dist/plugins/dashboard/routable.mjs.map +1 -0
- package/dist/plugins/dashboard/schema/builder.mjs +21 -0
- package/dist/plugins/dashboard/schema/builder.mjs.map +1 -0
- package/dist/plugins/dashboard/schema/enums.mjs +72 -0
- package/dist/plugins/dashboard/schema/enums.mjs.map +1 -0
- package/dist/plugins/dashboard/schema/root.mjs +351 -0
- package/dist/plugins/dashboard/schema/root.mjs.map +1 -0
- package/dist/plugins/dashboard/schema/types.mjs +508 -0
- package/dist/plugins/dashboard/schema/types.mjs.map +1 -0
- package/dist/plugins/dashboard/schema.mjs +11 -0
- package/dist/plugins/dashboard/schema.mjs.map +1 -0
- package/dist/plugins/dashboard/server.mjs +166 -0
- package/dist/plugins/dashboard/server.mjs.map +1 -0
- package/dist/plugins/deepbook/deploy.mjs +53 -115
- package/dist/plugins/deepbook/deploy.mjs.map +1 -1
- package/dist/plugins/deepbook/errors.mjs +1 -0
- package/dist/plugins/deepbook/errors.mjs.map +1 -1
- package/dist/plugins/deepbook/faucet-strategy.mjs +47 -34
- package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/deepbook/hash.mjs +9 -0
- package/dist/plugins/deepbook/hash.mjs.map +1 -0
- package/dist/plugins/deepbook/index.d.mts +1 -10
- package/dist/plugins/deepbook/index.mjs +25 -22
- package/dist/plugins/deepbook/index.mjs.map +1 -1
- package/dist/plugins/deepbook/pyth/index.mjs +26 -55
- package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
- package/dist/plugins/deepbook/snapshot.mjs +17 -29
- package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
- package/dist/plugins/deepbook/spans.mjs +18 -0
- package/dist/plugins/deepbook/spans.mjs.map +1 -0
- package/dist/plugins/deepbook/type-strings.mjs +65 -0
- package/dist/plugins/deepbook/type-strings.mjs.map +1 -0
- package/dist/plugins/deepbook/types.d.mts +2 -3
- package/dist/plugins/deepbook/types.mjs.map +1 -1
- package/dist/plugins/faucet/dispatcher.d.mts +21 -2
- package/dist/plugins/faucet/dispatcher.mjs +1 -2
- package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
- package/dist/plugins/faucet/errors.d.mts +11 -24
- package/dist/plugins/faucet/errors.mjs.map +1 -1
- package/dist/plugins/faucet/http.mjs +33 -14
- package/dist/plugins/faucet/http.mjs.map +1 -1
- package/dist/plugins/faucet/index.d.mts +15 -5
- package/dist/plugins/faucet/index.mjs +3 -0
- package/dist/plugins/faucet/index.mjs.map +1 -1
- package/dist/plugins/faucet/spans.mjs +12 -0
- package/dist/plugins/faucet/spans.mjs.map +1 -0
- package/dist/plugins/host-service/errors.d.mts +1 -1
- package/dist/plugins/host-service/index.mjs +34 -8
- package/dist/plugins/host-service/index.mjs.map +1 -1
- package/dist/plugins/host-service/routable.mjs +2 -1
- package/dist/plugins/host-service/routable.mjs.map +1 -1
- package/dist/plugins/host-service/service.d.mts +21 -0
- package/dist/plugins/host-service/service.mjs +136 -81
- package/dist/plugins/host-service/service.mjs.map +1 -1
- package/dist/plugins/internal/acquire-on-chain-artifact.mjs +23 -0
- package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -0
- package/dist/plugins/internal/codegen-helpers.mjs +18 -0
- package/dist/plugins/internal/codegen-helpers.mjs.map +1 -0
- package/dist/plugins/internal/funding-failure-error.mjs +32 -0
- package/dist/plugins/internal/funding-failure-error.mjs.map +1 -0
- package/dist/plugins/package/build.mjs +1 -1
- package/dist/plugins/package/build.mjs.map +1 -1
- package/dist/plugins/package/codegen.mjs +26 -0
- package/dist/plugins/package/codegen.mjs.map +1 -1
- package/dist/plugins/package/errors.d.mts +16 -6
- package/dist/plugins/package/errors.mjs.map +1 -1
- package/dist/plugins/package/index.d.mts +0 -4
- package/dist/plugins/package/index.mjs +27 -21
- package/dist/plugins/package/index.mjs.map +1 -1
- package/dist/plugins/package/mode-known.mjs +26 -12
- package/dist/plugins/package/mode-known.mjs.map +1 -1
- package/dist/plugins/package/mode-local.mjs +47 -41
- package/dist/plugins/package/mode-local.mjs.map +1 -1
- package/dist/plugins/package/publish-executor.mjs +55 -114
- package/dist/plugins/package/publish-executor.mjs.map +1 -1
- package/dist/plugins/package/registry.mjs +2 -1
- package/dist/plugins/package/registry.mjs.map +1 -1
- package/dist/plugins/package/service.mjs.map +1 -1
- package/dist/plugins/package/spans.mjs +14 -0
- package/dist/plugins/package/spans.mjs.map +1 -0
- package/dist/plugins/postgres/db-ensure.mjs +19 -12
- package/dist/plugins/postgres/db-ensure.mjs.map +1 -1
- package/dist/plugins/postgres/errors.d.mts +5 -0
- package/dist/plugins/postgres/errors.mjs.map +1 -1
- package/dist/plugins/postgres/index.mjs +10 -17
- package/dist/plugins/postgres/index.mjs.map +1 -1
- package/dist/plugins/postgres/service.mjs +58 -24
- package/dist/plugins/postgres/service.mjs.map +1 -1
- package/dist/plugins/postgres/snapshot.mjs.map +1 -1
- package/dist/plugins/postgres/spans.mjs +11 -0
- package/dist/plugins/postgres/spans.mjs.map +1 -0
- package/dist/plugins/router-entrypoints.mjs +4 -4
- package/dist/plugins/router-entrypoints.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +15 -13
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +15 -19
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
- package/dist/plugins/seal/codegen.d.mts +2 -3
- package/dist/plugins/seal/codegen.mjs.map +1 -1
- package/dist/plugins/seal/config-render.mjs +35 -8
- package/dist/plugins/seal/config-render.mjs.map +1 -1
- package/dist/plugins/seal/deploy.mjs +31 -39
- package/dist/plugins/seal/deploy.mjs.map +1 -1
- package/dist/plugins/seal/errors.d.mts +1 -3
- package/dist/plugins/seal/errors.mjs +7 -1
- package/dist/plugins/seal/errors.mjs.map +1 -1
- package/dist/plugins/seal/index.d.mts +1 -6
- package/dist/plugins/seal/index.mjs +40 -14
- package/dist/plugins/seal/index.mjs.map +1 -1
- package/dist/plugins/seal/key-manager.d.mts +1 -9
- package/dist/plugins/seal/key-manager.mjs +2 -18
- package/dist/plugins/seal/key-manager.mjs.map +1 -1
- package/dist/plugins/seal/key-server.mjs +37 -36
- package/dist/plugins/seal/key-server.mjs.map +1 -1
- package/dist/plugins/seal/keygen.mjs +16 -17
- package/dist/plugins/seal/keygen.mjs.map +1 -1
- package/dist/plugins/seal/mode/fork-known.mjs +36 -14
- package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
- package/dist/plugins/seal/mode/live.d.mts +6 -4
- package/dist/plugins/seal/mode/live.mjs +14 -21
- package/dist/plugins/seal/mode/live.mjs.map +1 -1
- package/dist/plugins/seal/mode/local-keygen.mjs +57 -21
- package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
- package/dist/plugins/seal/registry-publish.mjs +1 -0
- package/dist/plugins/seal/registry-publish.mjs.map +1 -1
- package/dist/plugins/seal/routable.mjs.map +1 -1
- package/dist/plugins/seal/service.mjs.map +1 -1
- package/dist/plugins/seal/spans.mjs +18 -0
- package/dist/plugins/seal/spans.mjs.map +1 -0
- package/dist/plugins/sui/auto-tick.mjs +17 -23
- package/dist/plugins/sui/auto-tick.mjs.map +1 -1
- package/dist/plugins/sui/chain-build-container.mjs +18 -0
- package/dist/plugins/sui/chain-build-container.mjs.map +1 -0
- package/dist/plugins/sui/chain-probe.d.mts +5 -5
- package/dist/plugins/sui/chain-probe.mjs +28 -58
- package/dist/plugins/sui/chain-probe.mjs.map +1 -1
- package/dist/plugins/sui/codegen.mjs +26 -0
- package/dist/plugins/sui/codegen.mjs.map +1 -1
- package/dist/plugins/sui/errors.d.mts +2 -29
- package/dist/plugins/sui/errors.mjs +1 -3
- package/dist/plugins/sui/errors.mjs.map +1 -1
- package/dist/plugins/sui/fork-faucet-strategy.d.mts +1 -0
- package/dist/plugins/sui/fork-faucet-strategy.mjs +55 -0
- package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -0
- package/dist/plugins/sui/fork-orchestration.d.mts +1 -0
- package/dist/plugins/sui/fork-orchestration.mjs +170 -2
- package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
- package/dist/plugins/sui/fork-transaction.d.mts +2 -0
- package/dist/plugins/sui/fork-transaction.mjs +92 -28
- package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
- package/dist/plugins/sui/index.d.mts +33 -70
- package/dist/plugins/sui/index.mjs +58 -35
- package/dist/plugins/sui/index.mjs.map +1 -1
- package/dist/plugins/{faucet/strategies/sui-local.mjs → sui/local-faucet-strategy.mjs} +10 -7
- package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -0
- package/dist/plugins/sui/mode/external.mjs +7 -13
- package/dist/plugins/sui/mode/external.mjs.map +1 -1
- package/dist/plugins/sui/mode/fork.mjs +136 -59
- package/dist/plugins/sui/mode/fork.mjs.map +1 -1
- package/dist/plugins/sui/mode/live.mjs +10 -16
- package/dist/plugins/sui/mode/live.mjs.map +1 -1
- package/dist/plugins/sui/mode/local.mjs +37 -36
- package/dist/plugins/sui/mode/local.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared-boot.mjs +38 -115
- package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared.d.mts +1 -5
- package/dist/plugins/sui/mode/shared.mjs.map +1 -1
- package/dist/plugins/sui/mode/spec.d.mts +18 -0
- package/dist/plugins/sui/move-summary-runner.mjs +207 -0
- package/dist/plugins/sui/move-summary-runner.mjs.map +1 -0
- package/dist/plugins/sui/network-resolver.d.mts +4 -3
- package/dist/plugins/sui/service.mjs.map +1 -1
- package/dist/plugins/sui/snapshot.mjs +3 -0
- package/dist/plugins/sui/snapshot.mjs.map +1 -1
- package/dist/plugins/sui/spans.mjs +17 -0
- package/dist/plugins/sui/spans.mjs.map +1 -0
- package/dist/plugins/wallet/codegen.d.mts +0 -1
- package/dist/plugins/wallet/codegen.mjs +8 -9
- package/dist/plugins/wallet/codegen.mjs.map +1 -1
- package/dist/plugins/wallet/index.d.mts +6 -8
- package/dist/plugins/wallet/index.mjs +46 -35
- package/dist/plugins/wallet/index.mjs.map +1 -1
- package/dist/plugins/wallet/origin-policy.mjs +12 -28
- package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
- package/dist/plugins/wallet/pairing.mjs +6 -4
- package/dist/plugins/wallet/pairing.mjs.map +1 -1
- package/dist/plugins/wallet/protocol.d.mts +1 -0
- package/dist/plugins/wallet/protocol.mjs +5 -44
- package/dist/plugins/wallet/protocol.mjs.map +1 -1
- package/dist/plugins/wallet/routable.mjs +2 -8
- package/dist/plugins/wallet/routable.mjs.map +1 -1
- package/dist/plugins/wallet/server.mjs +36 -44
- package/dist/plugins/wallet/server.mjs.map +1 -1
- package/dist/plugins/wallet/service.d.mts +1 -5
- package/dist/plugins/wallet/service.mjs +22 -18
- package/dist/plugins/wallet/service.mjs.map +1 -1
- package/dist/plugins/wallet/spans.mjs +22 -0
- package/dist/plugins/wallet/spans.mjs.map +1 -0
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +33 -8
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/walrus/codegen.d.mts +3 -3
- package/dist/plugins/walrus/codegen.mjs.map +1 -1
- package/dist/plugins/walrus/deploy-paths.mjs +21 -5
- package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
- package/dist/plugins/walrus/deploy.mjs +67 -69
- package/dist/plugins/walrus/deploy.mjs.map +1 -1
- package/dist/plugins/walrus/errors.mjs +1 -0
- package/dist/plugins/walrus/errors.mjs.map +1 -1
- package/dist/plugins/walrus/faucet-strategy.mjs +12 -7
- package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/walrus/index.d.mts +2 -13
- package/dist/plugins/walrus/index.mjs +18 -23
- package/dist/plugins/walrus/index.mjs.map +1 -1
- package/dist/plugins/walrus/mode/known-deploy.mjs +7 -5
- package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
- package/dist/plugins/walrus/mode/local-cluster.mjs +26 -7
- package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
- package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
- package/dist/plugins/walrus/routable.mjs +7 -23
- package/dist/plugins/walrus/routable.mjs.map +1 -1
- package/dist/plugins/walrus/service.mjs.map +1 -1
- package/dist/plugins/walrus/spans.mjs +18 -0
- package/dist/plugins/walrus/spans.mjs.map +1 -0
- package/dist/plugins/walrus/storage-nodes.d.mts +6 -2
- package/dist/plugins/walrus/storage-nodes.mjs +15 -8
- package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
- package/dist/plugins/walrus/wal-swap.mjs +58 -15
- package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
- package/dist/primitives/artifact-publisher.d.mts +1 -1
- package/dist/primitives/artifact-publisher.mjs +15 -0
- package/dist/primitives/artifact-publisher.mjs.map +1 -0
- package/dist/runtime/docker/client.mjs +17 -4
- package/dist/runtime/docker/client.mjs.map +1 -1
- package/dist/runtime/docker/container.mjs +219 -132
- package/dist/runtime/docker/container.mjs.map +1 -1
- package/dist/runtime/docker/errors.mjs +0 -6
- package/dist/runtime/docker/errors.mjs.map +1 -1
- package/dist/runtime/docker/exec.mjs +21 -18
- package/dist/runtime/docker/exec.mjs.map +1 -1
- package/dist/runtime/docker/image.mjs +36 -13
- package/dist/runtime/docker/image.mjs.map +1 -1
- package/dist/runtime/docker/index.mjs +14 -0
- package/dist/runtime/docker/inspect-and-decode.mjs +51 -0
- package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -0
- package/dist/runtime/docker/inventory.mjs +14 -11
- package/dist/runtime/docker/inventory.mjs.map +1 -1
- package/dist/runtime/docker/labels.mjs +38 -5
- package/dist/runtime/docker/labels.mjs.map +1 -1
- package/dist/runtime/docker/logs.d.mts +1 -1
- package/dist/runtime/docker/logs.mjs.map +1 -1
- package/dist/runtime/docker/network.mjs +83 -47
- package/dist/runtime/docker/network.mjs.map +1 -1
- package/dist/runtime/docker/render-run-args.mjs +82 -0
- package/dist/runtime/docker/render-run-args.mjs.map +1 -0
- package/dist/runtime/docker/service.d.mts +1 -1
- package/dist/runtime/docker/service.mjs +12 -7
- package/dist/runtime/docker/service.mjs.map +1 -1
- package/dist/runtime/docker/sweep.mjs +118 -43
- package/dist/runtime/docker/sweep.mjs.map +1 -1
- package/dist/runtime/docker/volume.mjs +2 -0
- package/dist/runtime/docker/volume.mjs.map +1 -1
- package/dist/runtime/docker/wrap.mjs +30 -1
- package/dist/runtime/docker/wrap.mjs.map +1 -1
- package/dist/substrate/cross-process.mjs +14 -8
- package/dist/substrate/cross-process.mjs.map +1 -1
- package/dist/substrate/event-time.mjs +33 -0
- package/dist/substrate/event-time.mjs.map +1 -0
- package/dist/substrate/events.d.mts +28 -8
- package/dist/substrate/identity.d.mts +2 -1
- package/dist/substrate/manifest.d.mts +68 -5
- package/dist/substrate/manifest.mjs +34 -5
- package/dist/substrate/manifest.mjs.map +1 -1
- package/dist/substrate/network.d.mts +3 -5
- package/dist/substrate/options.d.mts +0 -2
- package/dist/substrate/plugin.d.mts +13 -0
- package/dist/substrate/plugin.mjs +4 -2
- package/dist/substrate/plugin.mjs.map +1 -1
- package/dist/substrate/projection.d.mts +35 -3
- package/dist/substrate/runtime/artifact-publisher/index.mjs +19 -9
- package/dist/substrate/runtime/artifact-publisher/index.mjs.map +1 -1
- package/dist/substrate/runtime/atomic-write.mjs +97 -32
- package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
- package/dist/substrate/runtime/cache/index.mjs +3 -0
- package/dist/substrate/runtime/cache/schema.mjs +2 -2
- package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
- package/dist/substrate/runtime/cache/service.mjs +9 -7
- package/dist/substrate/runtime/cache/service.mjs.map +1 -1
- package/dist/substrate/runtime/capability-sinks/index.d.mts +1 -1
- package/dist/substrate/runtime/capability-sinks/index.mjs +3 -0
- package/dist/substrate/runtime/capability-sinks/layer.mjs +1 -1
- package/dist/substrate/runtime/capability-sinks/service.d.mts +61 -2
- package/dist/substrate/runtime/capability-sinks/service.mjs +21 -26
- package/dist/substrate/runtime/capability-sinks/service.mjs.map +1 -1
- package/dist/substrate/runtime/config-validation.d.mts +1 -13
- package/dist/substrate/runtime/config-validation.mjs +2 -91
- package/dist/substrate/runtime/config-validation.mjs.map +1 -1
- package/dist/substrate/runtime/container-runtime.d.mts +1 -0
- package/dist/substrate/runtime/container-runtime.mjs +2 -0
- package/dist/substrate/runtime/control-plane/domain.mjs +101 -0
- package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -0
- package/dist/substrate/runtime/control-plane/service.mjs +7 -0
- package/dist/substrate/runtime/control-plane/service.mjs.map +1 -0
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +46 -19
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs +30 -12
- package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/index.mjs +5 -0
- package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs +11 -2
- package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs +1 -1
- package/dist/substrate/runtime/cross-process/index.mjs +11 -0
- package/dist/substrate/runtime/cross-process/live-clock.mjs +34 -0
- package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -0
- package/dist/substrate/runtime/cross-process/liveness.mjs +52 -10
- package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/lock.d.mts +1 -0
- package/dist/substrate/runtime/cross-process/lock.mjs +23 -0
- package/dist/substrate/runtime/cross-process/lock.mjs.map +1 -0
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +64 -0
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -0
- package/dist/substrate/runtime/cross-process/roster.mjs +97 -83
- package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/self-pid.mjs +8 -0
- package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -0
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +24 -28
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/stack-lock.mjs +41 -20
- package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
- package/dist/substrate/runtime/current-plugin.mjs +2 -2
- package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
- package/dist/substrate/runtime/errors.mjs +12 -6
- package/dist/substrate/runtime/errors.mjs.map +1 -1
- package/dist/substrate/runtime/format-unknown-error.mjs +30 -0
- package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -0
- package/dist/substrate/runtime/host-bind-mount-owner.mjs +10 -0
- package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -0
- package/dist/substrate/runtime/host-gateway.mjs +20 -0
- package/dist/substrate/runtime/host-gateway.mjs.map +1 -0
- package/dist/substrate/runtime/host-tree-tar/index.mjs +61 -50
- package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
- package/dist/substrate/runtime/http-probe.d.mts +1 -1
- package/dist/substrate/runtime/index.mjs +14 -0
- package/dist/substrate/runtime/lease-broker/index.d.mts +1 -1
- package/dist/substrate/runtime/lease-broker/index.mjs +2 -0
- package/dist/substrate/runtime/lease-broker/service.d.mts +1 -64
- package/dist/substrate/runtime/lease-broker/service.mjs +1 -1
- package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs +22 -3
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/index.mjs +9 -0
- package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +20 -3
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/selective-restart.mjs +1 -1
- package/dist/substrate/runtime/lifecycle/signals.mjs +5 -5
- package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/state-machine.mjs +1 -1
- package/dist/substrate/runtime/managed-container.d.mts +19 -1
- package/dist/substrate/runtime/managed-container.mjs +20 -1
- package/dist/substrate/runtime/managed-container.mjs.map +1 -1
- package/dist/substrate/runtime/manifest/index.mjs +3 -0
- package/dist/substrate/runtime/manifest/manifest.mjs +15 -11
- package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
- package/dist/substrate/runtime/mode-errors.mjs +20 -0
- package/dist/substrate/runtime/mode-errors.mjs.map +1 -0
- package/dist/substrate/runtime/observability/cascade-formatter.mjs +9 -13
- package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
- package/dist/substrate/runtime/observability/formatter-registry.mjs +19 -36
- package/dist/substrate/runtime/observability/formatter-registry.mjs.map +1 -1
- package/dist/substrate/runtime/observability/ignore-with-log.d.mts +1 -0
- package/dist/substrate/runtime/observability/ignore-with-log.mjs +17 -0
- package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -0
- package/dist/substrate/runtime/observability/index.d.mts +1 -1
- package/dist/substrate/runtime/observability/index.mjs +13 -0
- package/dist/substrate/runtime/observability/log-store.d.mts +1 -0
- package/dist/substrate/runtime/observability/log-store.mjs +175 -0
- package/dist/substrate/runtime/observability/log-store.mjs.map +1 -0
- package/dist/substrate/runtime/observability/logger.d.mts +2 -1
- package/dist/substrate/runtime/observability/logger.mjs +5 -9
- package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
- package/dist/substrate/runtime/observability/output-truncate.mjs +35 -0
- package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -0
- package/dist/substrate/runtime/observability/pretty-error.mjs +9 -12
- package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
- package/dist/substrate/runtime/observability/redaction.d.mts +2 -13
- package/dist/substrate/runtime/observability/redaction.mjs +8 -14
- package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
- package/dist/substrate/runtime/observability/span-store.d.mts +1 -0
- package/dist/substrate/runtime/observability/span-store.mjs +110 -0
- package/dist/substrate/runtime/observability/span-store.mjs.map +1 -0
- package/dist/substrate/runtime/observability/spans.mjs +14 -14
- package/dist/substrate/runtime/observability/spans.mjs.map +1 -1
- package/dist/substrate/runtime/observability/subprocess-capture.mjs +1 -1
- package/dist/substrate/runtime/passthrough-or-wrap.mjs +33 -0
- package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -0
- package/dist/substrate/runtime/paths.d.mts +1 -1
- package/dist/substrate/runtime/paths.mjs +4 -3
- package/dist/substrate/runtime/paths.mjs.map +1 -1
- package/dist/substrate/runtime/phase-preserving-produce.mjs +40 -0
- package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -0
- package/dist/substrate/runtime/port-broker/index.mjs +3 -0
- package/dist/substrate/runtime/port-broker/service.mjs +170 -126
- package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/post-acquire-tasks.mjs +1 -1
- package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
- package/dist/substrate/runtime/probes.d.mts +7 -5
- package/dist/substrate/runtime/probes.mjs +3 -1
- package/dist/substrate/runtime/probes.mjs.map +1 -1
- package/dist/substrate/runtime/projection/index.mjs +4 -0
- package/dist/substrate/runtime/projection/operational-endpoints.mjs +1 -2
- package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
- package/dist/substrate/runtime/projection/persisted.mjs +33 -15
- package/dist/substrate/runtime/projection/persisted.mjs.map +1 -1
- package/dist/substrate/runtime/projection/state-ref.mjs +26 -2
- package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
- package/dist/substrate/runtime/projection/update.mjs +88 -24
- package/dist/substrate/runtime/projection/update.mjs.map +1 -1
- package/dist/substrate/runtime/random-suffix.mjs +11 -0
- package/dist/substrate/runtime/random-suffix.mjs.map +1 -0
- package/dist/substrate/runtime/retry-policy.d.mts +59 -1
- package/dist/substrate/runtime/retry-policy.mjs +66 -1
- package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
- package/dist/substrate/runtime/routed-url.d.mts +1 -0
- package/dist/substrate/runtime/routed-url.mjs +79 -0
- package/dist/substrate/runtime/routed-url.mjs.map +1 -0
- package/dist/substrate/runtime/runtime-decode.d.mts +1 -1
- package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
- package/dist/substrate/runtime/scoped-http-server.mjs +2 -3
- package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
- package/dist/substrate/runtime/scoped-multimap/index.mjs +2 -0
- package/dist/substrate/runtime/scoped-multimap/service.mjs +52 -0
- package/dist/substrate/runtime/scoped-multimap/service.mjs.map +1 -0
- package/dist/substrate/runtime/scoped-ref-map/index.mjs +2 -0
- package/dist/substrate/runtime/scoped-ref-map/service.mjs +2 -2
- package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +1 -1
- package/dist/substrate/runtime/stage-and-swap/index.mjs +72 -4
- package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
- package/dist/substrate/runtime/state-store/index.d.mts +1 -0
- package/dist/substrate/runtime/state-store/index.mjs +3 -0
- package/dist/substrate/runtime/state-store/schema.d.mts +1 -0
- package/dist/substrate/runtime/state-store/schema.mjs +19 -14
- package/dist/substrate/runtime/state-store/schema.mjs.map +1 -1
- package/dist/substrate/runtime/state-store/service.d.mts +1 -0
- package/dist/substrate/runtime/state-store/service.mjs +145 -0
- package/dist/substrate/runtime/state-store/service.mjs.map +1 -0
- package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.d.mts +1 -0
- package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs +33 -0
- package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -0
- package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs +1 -1
- package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/index.mjs +4 -0
- package/dist/substrate/runtime/strategy-registry/service.mjs +19 -33
- package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
- package/dist/substrate/runtime/subnet-broker.mjs +60 -0
- package/dist/substrate/runtime/subnet-broker.mjs.map +1 -0
- package/dist/substrate/runtime/sui-execute/index.d.mts +21 -1
- package/dist/substrate/runtime/sui-execute/index.mjs +84 -20
- package/dist/substrate/runtime/sui-execute/index.mjs.map +1 -1
- package/dist/substrate/runtime/sui-execute/sign-and-dispatch.d.mts +1 -0
- package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs +32 -0
- package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +1 -0
- package/dist/substrate/runtime/sui-ledger/object-ref.mjs +32 -0
- package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +1 -0
- package/dist/substrate/runtime/sui-move-build/index.mjs +93 -19
- package/dist/substrate/runtime/sui-move-build/index.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/acquire-node.mjs +181 -0
- package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/background-tasks.mjs +144 -0
- package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/command-loop.mjs +68 -0
- package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +151 -0
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/errors.d.mts +1 -0
- package/dist/substrate/runtime/supervisor/errors.mjs +9 -0
- package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/index.d.mts +1 -0
- package/dist/substrate/runtime/supervisor/index.mjs +3 -0
- package/dist/substrate/runtime/supervisor/shutdown.mjs +51 -0
- package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/start-supervisor.d.mts +1 -0
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs +250 -0
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/state.d.mts +1 -0
- package/dist/substrate/runtime/supervisor/state.mjs +22 -0
- package/dist/substrate/runtime/supervisor/state.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/teardown.mjs +57 -0
- package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/types.d.mts +1 -0
- package/dist/substrate/runtime/supervisor/wiring.mjs +133 -0
- package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -0
- package/dist/substrate/runtime/typed-env.mjs +8 -0
- package/dist/substrate/runtime/typed-env.mjs.map +1 -0
- package/dist/substrate/state-store.d.mts +1 -0
- package/dist/substrate/versioned-doc-schema.mjs +17 -0
- package/dist/substrate/versioned-doc-schema.mjs.map +1 -0
- package/dist/substrate/versioned-doc-sync.mjs +94 -0
- package/dist/substrate/versioned-doc-sync.mjs.map +1 -0
- package/dist/surfaces/cli/command-tree.mjs.map +1 -1
- package/dist/surfaces/cli/commands/index.mjs +9 -0
- package/dist/surfaces/cli/commands/prune-picker-entry.mjs +13 -0
- package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -0
- package/dist/surfaces/cli/commands/prune-picker.mjs +3 -2
- package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune.mjs +34 -17
- package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
- package/dist/surfaces/cli/commands/status.mjs +2 -2
- package/dist/surfaces/cli/commands/status.mjs.map +1 -1
- package/dist/surfaces/cli/commands/supervisor-presence.mjs +5 -3
- package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
- package/dist/surfaces/cli/commands/wipe.mjs +38 -4
- package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
- package/dist/surfaces/cli/errors.mjs +1 -1
- package/dist/surfaces/cli/errors.mjs.map +1 -1
- package/dist/surfaces/cli/flags.mjs +0 -1
- package/dist/surfaces/cli/flags.mjs.map +1 -1
- package/dist/surfaces/cli/index.mjs +98 -18
- package/dist/surfaces/cli/index.mjs.map +1 -1
- package/dist/surfaces/cli/output.mjs +1 -0
- package/dist/surfaces/cli/output.mjs.map +1 -1
- package/dist/surfaces/cli/sysexits.mjs +2 -1
- package/dist/surfaces/cli/sysexits.mjs.map +1 -1
- package/dist/surfaces/tui/app.mjs +25 -3
- package/dist/surfaces/tui/app.mjs.map +1 -1
- package/dist/surfaces/tui/display-derivation.mjs +23 -74
- package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
- package/dist/surfaces/tui/event-log.mjs +35 -23
- package/dist/surfaces/tui/event-log.mjs.map +1 -1
- package/dist/surfaces/tui/input.mjs +5 -1
- package/dist/surfaces/tui/input.mjs.map +1 -1
- package/dist/surfaces/tui/plain-renderer.mjs +70 -34
- package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
- package/package.json +24 -4
- package/dist/contracts/liveness-classifier.d.mts +0 -19
- package/dist/contracts/network-resolver.d.mts +0 -15
- package/dist/contracts/network-resolver.mjs +0 -7
- package/dist/contracts/network-resolver.mjs.map +0 -1
- package/dist/orchestrators/codegen/extras.mjs +0 -16
- package/dist/orchestrators/codegen/extras.mjs.map +0 -1
- package/dist/plugins/deepbook/routable.mjs +0 -21
- package/dist/plugins/deepbook/routable.mjs.map +0 -1
- package/dist/plugins/faucet/service.d.mts +0 -20
- package/dist/plugins/faucet/strategies/sui-local.d.mts +0 -23
- package/dist/plugins/faucet/strategies/sui-local.mjs.map +0 -1
- package/dist/plugins/sui/seed-objects.d.mts +0 -18
- package/dist/plugins/sui/seed-objects.mjs +0 -25
- package/dist/plugins/sui/seed-objects.mjs.map +0 -1
- package/dist/runtime/built-in-plugin-layers.mjs.map +0 -1
- package/dist/substrate/runtime/context-helpers.mjs +0 -32
- package/dist/substrate/runtime/context-helpers.mjs.map +0 -1
- package/dist/substrate/runtime/run.mjs.map +0 -1
- package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs +0 -30
- package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs.map +0 -1
- package/dist/substrate/runtime/supervisor.d.mts +0 -1
- package/dist/substrate/runtime/supervisor.mjs +0 -831
- package/dist/substrate/runtime/supervisor.mjs.map +0 -1
- package/dist/surfaces/cli/commands/doctor-probes.mjs.map +0 -1
- /package/dist/{substrate/runtime/strategy-registry/faucet-capability-for.d.mts → plugins/faucet/http.d.mts} +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { SupervisorPostAcquireFailed } from "./errors.mjs";
|
|
2
|
+
import { prettyErrorStructured } from "../observability/pretty-error.mjs";
|
|
3
|
+
import "../observability/index.mjs";
|
|
4
|
+
import { bestEffort, publish } from "./wiring.mjs";
|
|
5
|
+
import { PostAcquireTaskFailed } from "../post-acquire-tasks.mjs";
|
|
6
|
+
import { Cause, Effect, Exit, Fiber, Ref } from "effect";
|
|
7
|
+
//#region src/substrate/runtime/supervisor/background-tasks.ts
|
|
8
|
+
/** `snapshot.captureFailed` / `snapshot.captureSkipped` carry a REQUIRED
|
|
9
|
+
* `snapshotId`. When the originating command carried an id, surfaces
|
|
10
|
+
* correlate the outcome with it (the CLI's pending-capture map keys on
|
|
11
|
+
* it). When the command omitted an id there is nothing to correlate
|
|
12
|
+
* against — the CLI's bridge does NOT register a pending-capture entry
|
|
13
|
+
* for an id-less capture (`cli/wirings/up.ts` falls through to a
|
|
14
|
+
* legacy auto-ack and never keys this synthetic id) — so the minted
|
|
15
|
+
* `snap-<ts>` here only satisfies the event's required field. */
|
|
16
|
+
const effectiveSnapshotId = (cmd) => cmd.snapshotId ?? `snap-${Date.now()}`;
|
|
17
|
+
const runInjectedCommandHandler = (deps, cmd) => Effect.gen(function* () {
|
|
18
|
+
if (deps.commandHandler === void 0) return;
|
|
19
|
+
const publishFromHandler = (event) => publish(deps.ref, deps.hub, event);
|
|
20
|
+
const exit = yield* Effect.exit(deps.commandHandler(cmd, { publish: publishFromHandler }));
|
|
21
|
+
if (Exit.isSuccess(exit)) {
|
|
22
|
+
for (const event of exit.value) yield* publish(deps.ref, deps.hub, event);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (Cause.hasInterruptsOnly(exit.cause)) return;
|
|
26
|
+
if (cmd.tag === "snapshot.capture") yield* publish(deps.ref, deps.hub, {
|
|
27
|
+
tag: "snapshot.captureFailed",
|
|
28
|
+
snapshotId: effectiveSnapshotId(cmd),
|
|
29
|
+
...cmd.name === void 0 ? {} : { name: cmd.name },
|
|
30
|
+
summary: Cause.pretty(exit.cause).split("\n")[0] ?? "snapshot capture failed",
|
|
31
|
+
at: Date.now()
|
|
32
|
+
});
|
|
33
|
+
yield* publish(deps.ref, deps.hub, {
|
|
34
|
+
tag: "error.reported",
|
|
35
|
+
error: prettyErrorStructured(exit.cause, {
|
|
36
|
+
pluginKey: null,
|
|
37
|
+
severity: "error",
|
|
38
|
+
at: Date.now()
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
yield* deps.logger.log("supervisor", null, {
|
|
42
|
+
level: "error",
|
|
43
|
+
message: `command handler failed for ${cmd.tag}`
|
|
44
|
+
});
|
|
45
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.injectedCommandHandler"));
|
|
46
|
+
const startBackgroundSnapshotCapture = (deps, cmd) => Effect.gen(function* () {
|
|
47
|
+
const token = yield* Ref.updateAndGet(deps.snapshotCaptureSeq, (n) => n + 1);
|
|
48
|
+
if (!(yield* Ref.modify(deps.snapshotCaptureTask, (state) => state.tag === "idle" ? [true, {
|
|
49
|
+
tag: "starting",
|
|
50
|
+
token,
|
|
51
|
+
snapshotId: cmd.snapshotId ?? null
|
|
52
|
+
}] : [false, state]))) {
|
|
53
|
+
yield* publish(deps.ref, deps.hub, {
|
|
54
|
+
tag: "snapshot.captureSkipped",
|
|
55
|
+
reason: "already-running",
|
|
56
|
+
snapshotId: effectiveSnapshotId(cmd),
|
|
57
|
+
...cmd.name === void 0 ? {} : { name: cmd.name },
|
|
58
|
+
at: Date.now()
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
yield* publish(deps.ref, deps.hub, {
|
|
63
|
+
tag: "snapshot.captureStarted",
|
|
64
|
+
...cmd.snapshotId === void 0 ? {} : { snapshotId: cmd.snapshotId },
|
|
65
|
+
...cmd.name === void 0 ? {} : { name: cmd.name },
|
|
66
|
+
at: Date.now()
|
|
67
|
+
});
|
|
68
|
+
const fiber = yield* runInjectedCommandHandler(deps, cmd).pipe(Effect.ensuring(Ref.update(deps.snapshotCaptureTask, (state) => state.tag !== "idle" && state.token === token ? { tag: "idle" } : state)), Effect.forkScoped);
|
|
69
|
+
yield* Ref.update(deps.snapshotCaptureTask, (state) => state.tag === "starting" && state.token === token ? {
|
|
70
|
+
tag: "running",
|
|
71
|
+
token,
|
|
72
|
+
snapshotId: cmd.snapshotId ?? null,
|
|
73
|
+
fiber
|
|
74
|
+
} : state);
|
|
75
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.backgroundSnapshotCapture"));
|
|
76
|
+
const requestBackgroundSnapshotInterrupt = (deps) => Effect.gen(function* () {
|
|
77
|
+
const fiber = yield* Ref.modify(deps.snapshotCaptureTask, (state) => state.tag === "running" ? [state.fiber, { tag: "idle" }] : [null, state]);
|
|
78
|
+
if (fiber !== null) yield* Fiber.interrupt(fiber);
|
|
79
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.interruptSnapshotCapture"));
|
|
80
|
+
const startBackgroundStackRestart = (deps, handleCommand) => Effect.gen(function* () {
|
|
81
|
+
const token = yield* Ref.updateAndGet(deps.stackRestartSeq, (n) => n + 1);
|
|
82
|
+
if (!(yield* Ref.modify(deps.stackRestartTask, (state) => state.tag === "idle" ? [true, {
|
|
83
|
+
tag: "starting",
|
|
84
|
+
token
|
|
85
|
+
}] : [false, state]))) {
|
|
86
|
+
yield* deps.logger.log("supervisor", null, {
|
|
87
|
+
level: "debug",
|
|
88
|
+
message: "stack restart skipped because one is already running"
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const fiber = yield* handleCommand(deps, { tag: "stack.restart" }).pipe(Effect.catch(() => Effect.void), Effect.ensuring(Ref.update(deps.stackRestartTask, (state) => state.tag !== "idle" && state.token === token ? { tag: "idle" } : state)), Effect.forkScoped);
|
|
93
|
+
yield* Ref.update(deps.stackRestartTask, (state) => state.tag === "starting" && state.token === token ? {
|
|
94
|
+
tag: "running",
|
|
95
|
+
token,
|
|
96
|
+
fiber
|
|
97
|
+
} : state);
|
|
98
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.backgroundStackRestart"));
|
|
99
|
+
const requestBackgroundStackRestartInterrupt = (deps) => Effect.gen(function* () {
|
|
100
|
+
const fiber = yield* Ref.modify(deps.stackRestartTask, (state) => state.tag === "running" ? [state.fiber, { tag: "idle" }] : [null, state]);
|
|
101
|
+
if (fiber !== null) yield* Fiber.interrupt(fiber);
|
|
102
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.interruptStackRestart"));
|
|
103
|
+
const publishHookFailure = (deps, cause, message, pluginKey = null) => Effect.gen(function* () {
|
|
104
|
+
yield* publish(deps.ref, deps.hub, {
|
|
105
|
+
tag: "error.reported",
|
|
106
|
+
error: prettyErrorStructured(cause, {
|
|
107
|
+
pluginKey,
|
|
108
|
+
severity: "error",
|
|
109
|
+
at: Date.now()
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
yield* deps.logger.log("supervisor", null, {
|
|
113
|
+
level: "error",
|
|
114
|
+
message
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const findPostAcquireTaskFailure = (cause) => {
|
|
118
|
+
for (const reason of cause.reasons) {
|
|
119
|
+
if (!Cause.isFailReason(reason)) continue;
|
|
120
|
+
if (reason.error instanceof PostAcquireTaskFailed) return reason.error;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
const runPostAcquireHook = (deps) => Effect.gen(function* () {
|
|
125
|
+
if (deps.postAcquireHook === void 0) return;
|
|
126
|
+
const exit = yield* Effect.exit(deps.postAcquireHook({
|
|
127
|
+
graph: deps.graph,
|
|
128
|
+
registry: deps.registry,
|
|
129
|
+
identity: deps.identity,
|
|
130
|
+
runtimeRoot: deps.runtimeRoot
|
|
131
|
+
}));
|
|
132
|
+
if (Exit.isSuccess(exit)) {
|
|
133
|
+
for (const event of exit.value) yield* publish(deps.ref, deps.hub, event);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const taskFailure = findPostAcquireTaskFailure(exit.cause);
|
|
137
|
+
if (taskFailure !== null) yield* bestEffort(deps.registry.markFailed(taskFailure.pluginKey, taskFailure.cause));
|
|
138
|
+
yield* publishHookFailure(deps, exit.cause, taskFailure === null ? "post-acquire hook failed" : `post-acquire task failed: ${taskFailure.label}`, taskFailure?.pluginKey ?? null);
|
|
139
|
+
return yield* Effect.fail(new SupervisorPostAcquireFailed({ cause: exit.cause }));
|
|
140
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.postAcquireHook"));
|
|
141
|
+
//#endregion
|
|
142
|
+
export { requestBackgroundSnapshotInterrupt, requestBackgroundStackRestartInterrupt, runInjectedCommandHandler, runPostAcquireHook, startBackgroundSnapshotCapture, startBackgroundStackRestart };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=background-tasks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-tasks.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/background-tasks.ts"],"sourcesContent":["// Background tasks: injected command handler runner, snapshot capture,\n// stack restart, and post-acquire hook.\n//\n// Each background task is forked into the supervisor's parent scope so\n// it rides the supervisor's lifetime rather than the command-loop\n// fiber. Interrupt requests use a Ref-typed handle (`idle`/`starting`/\n// `running`) so a sibling command can interrupt a running task without\n// racing the fork.\n\nimport { Cause, Effect, Exit, Fiber, Ref, Scope } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineCommand, EngineEvent } from '../../events.ts';\nimport { prettyErrorStructured } from '../observability/index.ts';\nimport { PostAcquireTaskFailed } from '../post-acquire-tasks.ts';\nimport { SupervisorPostAcquireFailed } from './errors.ts';\nimport type { SnapshotCaptureTaskState, StackRestartTaskState, SupervisorState } from './state.ts';\nimport { bestEffort, publish } from './wiring.ts';\n\n// Forward reference: the stack-restart background task runs through\n// the same `handleCommand` dispatch path that the command loop uses;\n// imports cycle if we hoist it directly, so we accept a runner from the\n// caller.\ntype HandleCommandRunner = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n) => Effect.Effect<void, SupervisorPostAcquireFailed, Scope.Scope>;\n\n/** `snapshot.captureFailed` / `snapshot.captureSkipped` carry a REQUIRED\n * `snapshotId`. When the originating command carried an id, surfaces\n * correlate the outcome with it (the CLI's pending-capture map keys on\n * it). When the command omitted an id there is nothing to correlate\n * against — the CLI's bridge does NOT register a pending-capture entry\n * for an id-less capture (`cli/wirings/up.ts` falls through to a\n * legacy auto-ack and never keys this synthetic id) — so the minted\n * `snap-<ts>` here only satisfies the event's required field. */\nconst effectiveSnapshotId = (\n\tcmd: Extract<EngineCommand, { readonly tag: 'snapshot.capture' }>,\n): string => cmd.snapshotId ?? `snap-${Date.now()}`;\n\nexport const runInjectedCommandHandler = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tif (deps.commandHandler === undefined) return;\n\t\tconst publishFromHandler = (event: EngineEvent): Effect.Effect<void, never, never> =>\n\t\t\tpublish(deps.ref, deps.hub, event);\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.commandHandler(cmd, {\n\t\t\t\tpublish: publishFromHandler,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (Cause.hasInterruptsOnly(exit.cause)) return;\n\t\tif (cmd.tag === 'snapshot.capture') {\n\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\ttag: 'snapshot.captureFailed',\n\t\t\t\tsnapshotId: effectiveSnapshotId(cmd),\n\t\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\t\tsummary: Cause.pretty(exit.cause).split('\\n')[0] ?? 'snapshot capture failed',\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t}\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(exit.cause, {\n\t\t\t\tpluginKey: null,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage: `command handler failed for ${cmd.tag}`,\n\t\t});\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.injectedCommandHandler'));\n\nexport const startBackgroundSnapshotCapture = (\n\tdeps: SupervisorState,\n\tcmd: Extract<EngineCommand, { readonly tag: 'snapshot.capture' }>,\n): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst token = yield* Ref.updateAndGet(deps.snapshotCaptureSeq, (n) => n + 1);\n\t\tconst started = yield* Ref.modify(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'idle'\n\t\t\t\t? [\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttag: 'starting' as const,\n\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\tsnapshotId: cmd.snapshotId ?? null,\n\t\t\t\t\t\t} satisfies SnapshotCaptureTaskState,\n\t\t\t\t\t]\n\t\t\t\t: [false, state],\n\t\t);\n\n\t\tif (!started) {\n\t\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\t\ttag: 'snapshot.captureSkipped',\n\t\t\t\treason: 'already-running',\n\t\t\t\tsnapshotId: effectiveSnapshotId(cmd),\n\t\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'snapshot.captureStarted',\n\t\t\t...(cmd.snapshotId === undefined ? {} : { snapshotId: cmd.snapshotId }),\n\t\t\t...(cmd.name === undefined ? {} : { name: cmd.name }),\n\t\t\tat: Date.now(),\n\t\t});\n\n\t\tconst fiber = yield* runInjectedCommandHandler(deps, cmd).pipe(\n\t\t\tEffect.ensuring(\n\t\t\t\tRef.update(deps.snapshotCaptureTask, (state) =>\n\t\t\t\t\tstate.tag !== 'idle' && state.token === token\n\t\t\t\t\t\t? ({ tag: 'idle' } satisfies SnapshotCaptureTaskState)\n\t\t\t\t\t\t: state,\n\t\t\t\t),\n\t\t\t),\n\t\t\tEffect.forkScoped,\n\t\t);\n\n\t\tyield* Ref.update(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'starting' && state.token === token\n\t\t\t\t? ({\n\t\t\t\t\t\ttag: 'running',\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tsnapshotId: cmd.snapshotId ?? null,\n\t\t\t\t\t\tfiber,\n\t\t\t\t\t} satisfies SnapshotCaptureTaskState)\n\t\t\t\t: state,\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.backgroundSnapshotCapture'));\n\nexport const requestBackgroundSnapshotInterrupt = (\n\tdeps: Pick<SupervisorState, 'snapshotCaptureTask'>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fiber = yield* Ref.modify(deps.snapshotCaptureTask, (state) =>\n\t\t\tstate.tag === 'running'\n\t\t\t\t? [state.fiber, { tag: 'idle' } as SnapshotCaptureTaskState]\n\t\t\t\t: [null, state],\n\t\t);\n\t\t// Await the interrupt so a follow-up snapshot capture cannot begin\n\t\t// while the previous fiber is still inside `pauseAndCommit` /\n\t\t// `saveImages`. Mirrors `requestBackgroundStackRestartInterrupt`.\n\t\tif (fiber !== null) {\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.interruptSnapshotCapture'));\n\nexport const startBackgroundStackRestart = (\n\tdeps: SupervisorState,\n\thandleCommand: HandleCommandRunner,\n): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst token = yield* Ref.updateAndGet(deps.stackRestartSeq, (n) => n + 1);\n\t\tconst started = yield* Ref.modify(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'idle' ? [true, { tag: 'starting' as const, token }] : [false, state],\n\t\t);\n\n\t\tif (!started) {\n\t\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\t\tlevel: 'debug',\n\t\t\t\tmessage: 'stack restart skipped because one is already running',\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst fiber = yield* handleCommand(deps, { tag: 'stack.restart' }).pipe(\n\t\t\tEffect.catch(() => Effect.void),\n\t\t\tEffect.ensuring(\n\t\t\t\tRef.update(deps.stackRestartTask, (state) =>\n\t\t\t\t\tstate.tag !== 'idle' && state.token === token\n\t\t\t\t\t\t? ({ tag: 'idle' } satisfies StackRestartTaskState)\n\t\t\t\t\t\t: state,\n\t\t\t\t),\n\t\t\t),\n\t\t\tEffect.forkScoped,\n\t\t);\n\n\t\tyield* Ref.update(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'starting' && state.token === token\n\t\t\t\t? ({ tag: 'running', token, fiber } satisfies StackRestartTaskState)\n\t\t\t\t: state,\n\t\t);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.backgroundStackRestart'));\n\nexport const requestBackgroundStackRestartInterrupt = (\n\tdeps: Pick<SupervisorState, 'stackRestartTask'>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst fiber = yield* Ref.modify(deps.stackRestartTask, (state) =>\n\t\t\tstate.tag === 'running'\n\t\t\t\t? [state.fiber, { tag: 'idle' } as StackRestartTaskState]\n\t\t\t\t: [null, state],\n\t\t);\n\t\tif (fiber !== null) {\n\t\t\tyield* Fiber.interrupt(fiber);\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.interruptStackRestart'));\n\n// -----------------------------------------------------------------------------\n// Post-acquire hook\n// -----------------------------------------------------------------------------\n\nconst publishHookFailure = (\n\tdeps: SupervisorState,\n\tcause: Cause.Cause<unknown>,\n\tmessage: string,\n\tpluginKey: PluginKey | null = null,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* publish(deps.ref, deps.hub, {\n\t\t\ttag: 'error.reported',\n\t\t\terror: prettyErrorStructured(cause, {\n\t\t\t\tpluginKey,\n\t\t\t\tseverity: 'error',\n\t\t\t\tat: Date.now(),\n\t\t\t}),\n\t\t});\n\t\tyield* deps.logger.log('supervisor', null, {\n\t\t\tlevel: 'error',\n\t\t\tmessage,\n\t\t});\n\t});\n\nconst findPostAcquireTaskFailure = (cause: Cause.Cause<unknown>): PostAcquireTaskFailed | null => {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) continue;\n\t\tif (reason.error instanceof PostAcquireTaskFailed) return reason.error;\n\t}\n\treturn null;\n};\n\nexport const runPostAcquireHook = (\n\tdeps: SupervisorState,\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\tEffect.gen(function* () {\n\t\tif (deps.postAcquireHook === undefined) return;\n\t\tconst exit = yield* Effect.exit(\n\t\t\tdeps.postAcquireHook({\n\t\t\t\tgraph: deps.graph,\n\t\t\t\tregistry: deps.registry,\n\t\t\t\tidentity: deps.identity,\n\t\t\t\truntimeRoot: deps.runtimeRoot,\n\t\t\t}),\n\t\t);\n\t\tif (Exit.isSuccess(exit)) {\n\t\t\tfor (const event of exit.value) {\n\t\t\t\tyield* publish(deps.ref, deps.hub, event);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst taskFailure = findPostAcquireTaskFailure(exit.cause);\n\t\tif (taskFailure !== null) {\n\t\t\tyield* bestEffort(deps.registry.markFailed(taskFailure.pluginKey, taskFailure.cause));\n\t\t}\n\t\tyield* publishHookFailure(\n\t\t\tdeps,\n\t\t\texit.cause,\n\t\t\ttaskFailure === null\n\t\t\t\t? 'post-acquire hook failed'\n\t\t\t\t: `post-acquire task failed: ${taskFailure.label}`,\n\t\t\ttaskFailure?.pluginKey ?? null,\n\t\t);\n\t\treturn yield* Effect.fail(new SupervisorPostAcquireFailed({ cause: exit.cause }));\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.postAcquireHook'));\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAM,uBACL,QACY,IAAI,cAAc,QAAQ,KAAK,KAAK;AAEjD,MAAa,6BACZ,MACA,QAEA,OAAO,IAAI,aAAa;AACvB,KAAI,KAAK,mBAAmB,KAAA,EAAW;CACvC,MAAM,sBAAsB,UAC3B,QAAQ,KAAK,KAAK,KAAK,KAAK,MAAM;CACnC,MAAM,OAAO,OAAO,OAAO,KAC1B,KAAK,eAAe,KAAK,EACxB,SAAS,oBACT,CAAC,CACF;AACD,KAAI,KAAK,UAAU,KAAK,EAAE;AACzB,OAAK,MAAM,SAAS,KAAK,MACxB,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK,MAAM;AAE1C;;AAED,KAAI,MAAM,kBAAkB,KAAK,MAAM,CAAE;AACzC,KAAI,IAAI,QAAQ,mBACf,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK;EAClC,KAAK;EACL,YAAY,oBAAoB,IAAI;EACpC,GAAI,IAAI,SAAS,KAAA,IAAY,EAAE,GAAG,EAAE,MAAM,IAAI,MAAM;EACpD,SAAS,MAAM,OAAO,KAAK,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM;EACpD,IAAI,KAAK,KAAK;EACd,CAAC;AAEH,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK;EAClC,KAAK;EACL,OAAO,sBAAsB,KAAK,OAAO;GACxC,WAAW;GACX,UAAU;GACV,IAAI,KAAK,KAAK;GACd,CAAC;EACF,CAAC;AACF,QAAO,KAAK,OAAO,IAAI,cAAc,MAAM;EAC1C,OAAO;EACP,SAAS,8BAA8B,IAAI;EAC3C,CAAC;EACD,CAAC,KAAK,OAAO,SAAS,8CAA8C,CAAC;AAExE,MAAa,kCACZ,MACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,IAAI,aAAa,KAAK,qBAAqB,MAAM,IAAI,EAAE;AAc5E,KAAI,EAAC,OAbkB,IAAI,OAAO,KAAK,sBAAsB,UAC5D,MAAM,QAAQ,SACX,CACA,MACA;EACC,KAAK;EACL;EACA,YAAY,IAAI,cAAc;EAC9B,CACD,GACA,CAAC,OAAO,MAAM,CACjB,GAEa;AACb,SAAO,QAAQ,KAAK,KAAK,KAAK,KAAK;GAClC,KAAK;GACL,QAAQ;GACR,YAAY,oBAAoB,IAAI;GACpC,GAAI,IAAI,SAAS,KAAA,IAAY,EAAE,GAAG,EAAE,MAAM,IAAI,MAAM;GACpD,IAAI,KAAK,KAAK;GACd,CAAC;AACF;;AAGD,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK;EAClC,KAAK;EACL,GAAI,IAAI,eAAe,KAAA,IAAY,EAAE,GAAG,EAAE,YAAY,IAAI,YAAY;EACtE,GAAI,IAAI,SAAS,KAAA,IAAY,EAAE,GAAG,EAAE,MAAM,IAAI,MAAM;EACpD,IAAI,KAAK,KAAK;EACd,CAAC;CAEF,MAAM,QAAQ,OAAO,0BAA0B,MAAM,IAAI,CAAC,KACzD,OAAO,SACN,IAAI,OAAO,KAAK,sBAAsB,UACrC,MAAM,QAAQ,UAAU,MAAM,UAAU,QACpC,EAAE,KAAK,QAAQ,GAChB,MACH,CACD,EACD,OAAO,WACP;AAED,QAAO,IAAI,OAAO,KAAK,sBAAsB,UAC5C,MAAM,QAAQ,cAAc,MAAM,UAAU,QACxC;EACD,KAAK;EACL;EACA,YAAY,IAAI,cAAc;EAC9B;EACA,GACA,MACH;EACA,CAAC,KAAK,OAAO,SAAS,iDAAiD,CAAC;AAE3E,MAAa,sCACZ,SAEA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,IAAI,OAAO,KAAK,sBAAsB,UAC1D,MAAM,QAAQ,YACX,CAAC,MAAM,OAAO,EAAE,KAAK,QAAQ,CAA6B,GAC1D,CAAC,MAAM,MAAM,CAChB;AAID,KAAI,UAAU,KACb,QAAO,MAAM,UAAU,MAAM;EAE7B,CAAC,KAAK,OAAO,SAAS,gDAAgD,CAAC;AAE1E,MAAa,+BACZ,MACA,kBAEA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,IAAI,aAAa,KAAK,kBAAkB,MAAM,IAAI,EAAE;AAKzE,KAAI,EAAC,OAJkB,IAAI,OAAO,KAAK,mBAAmB,UACzD,MAAM,QAAQ,SAAS,CAAC,MAAM;EAAE,KAAK;EAAqB;EAAO,CAAC,GAAG,CAAC,OAAO,MAAM,CACnF,GAEa;AACb,SAAO,KAAK,OAAO,IAAI,cAAc,MAAM;GAC1C,OAAO;GACP,SAAS;GACT,CAAC;AACF;;CAGD,MAAM,QAAQ,OAAO,cAAc,MAAM,EAAE,KAAK,iBAAiB,CAAC,CAAC,KAClE,OAAO,YAAY,OAAO,KAAK,EAC/B,OAAO,SACN,IAAI,OAAO,KAAK,mBAAmB,UAClC,MAAM,QAAQ,UAAU,MAAM,UAAU,QACpC,EAAE,KAAK,QAAQ,GAChB,MACH,CACD,EACD,OAAO,WACP;AAED,QAAO,IAAI,OAAO,KAAK,mBAAmB,UACzC,MAAM,QAAQ,cAAc,MAAM,UAAU,QACxC;EAAE,KAAK;EAAW;EAAO;EAAO,GACjC,MACH;EACA,CAAC,KAAK,OAAO,SAAS,8CAA8C,CAAC;AAExE,MAAa,0CACZ,SAEA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,OAAO,IAAI,OAAO,KAAK,mBAAmB,UACvD,MAAM,QAAQ,YACX,CAAC,MAAM,OAAO,EAAE,KAAK,QAAQ,CAA0B,GACvD,CAAC,MAAM,MAAM,CAChB;AACD,KAAI,UAAU,KACb,QAAO,MAAM,UAAU,MAAM;EAE7B,CAAC,KAAK,OAAO,SAAS,6CAA6C,CAAC;AAMvE,MAAM,sBACL,MACA,OACA,SACA,YAA8B,SAE9B,OAAO,IAAI,aAAa;AACvB,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK;EAClC,KAAK;EACL,OAAO,sBAAsB,OAAO;GACnC;GACA,UAAU;GACV,IAAI,KAAK,KAAK;GACd,CAAC;EACF,CAAC;AACF,QAAO,KAAK,OAAO,IAAI,cAAc,MAAM;EAC1C,OAAO;EACP;EACA,CAAC;EACD;AAEH,MAAM,8BAA8B,UAA8D;AACjG,MAAK,MAAM,UAAU,MAAM,SAAS;AACnC,MAAI,CAAC,MAAM,aAAa,OAAO,CAAE;AACjC,MAAI,OAAO,iBAAiB,sBAAuB,QAAO,OAAO;;AAElE,QAAO;;AAGR,MAAa,sBACZ,SAEA,OAAO,IAAI,aAAa;AACvB,KAAI,KAAK,oBAAoB,KAAA,EAAW;CACxC,MAAM,OAAO,OAAO,OAAO,KAC1B,KAAK,gBAAgB;EACpB,OAAO,KAAK;EACZ,UAAU,KAAK;EACf,UAAU,KAAK;EACf,aAAa,KAAK;EAClB,CAAC,CACF;AACD,KAAI,KAAK,UAAU,KAAK,EAAE;AACzB,OAAK,MAAM,SAAS,KAAK,MACxB,QAAO,QAAQ,KAAK,KAAK,KAAK,KAAK,MAAM;AAE1C;;CAED,MAAM,cAAc,2BAA2B,KAAK,MAAM;AAC1D,KAAI,gBAAgB,KACnB,QAAO,WAAW,KAAK,SAAS,WAAW,YAAY,WAAW,YAAY,MAAM,CAAC;AAEtF,QAAO,mBACN,MACA,KAAK,OACL,gBAAgB,OACb,6BACA,6BAA6B,YAAY,SAC5C,aAAa,aAAa,KAC1B;AACD,QAAO,OAAO,OAAO,KAAK,IAAI,4BAA4B,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;EAChF,CAAC,KAAK,OAAO,SAAS,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import "./errors.mjs";
|
|
2
|
+
import { planFullDrain } from "../lifecycle/selective-restart.mjs";
|
|
3
|
+
import "../lifecycle/index.mjs";
|
|
4
|
+
import { runInjectedCommandHandler, runPostAcquireHook, startBackgroundSnapshotCapture, startBackgroundStackRestart } from "./background-tasks.mjs";
|
|
5
|
+
import { doSelectiveRestart } from "./teardown.mjs";
|
|
6
|
+
import { handleHardKillRequested, handleShutdownRequested } from "./shutdown.mjs";
|
|
7
|
+
import { allReadyOrTerminal } from "./state.mjs";
|
|
8
|
+
import { Deferred, Effect, Queue, Ref } from "effect";
|
|
9
|
+
//#region src/substrate/runtime/supervisor/command-loop.ts
|
|
10
|
+
const maybeRunPostAcquire = (deps, options) => options.failOnPostAcquireHook === true ? runPostAcquireHook(deps) : runPostAcquireHook(deps).pipe(Effect.catch(() => Effect.void));
|
|
11
|
+
const handleCommand = (deps, cmd, options = {}) => Effect.gen(function* () {
|
|
12
|
+
const { graph, registry, pluginContext, sinks, logger, identity, runtimeRoot } = deps;
|
|
13
|
+
const parentScope = yield* Effect.scope;
|
|
14
|
+
switch (cmd.tag) {
|
|
15
|
+
case "shutdown.requested":
|
|
16
|
+
case "stack.stop":
|
|
17
|
+
yield* handleShutdownRequested(deps);
|
|
18
|
+
return;
|
|
19
|
+
case "shutdown.hardKillRequested":
|
|
20
|
+
yield* handleHardKillRequested(deps, cmd);
|
|
21
|
+
return;
|
|
22
|
+
case "stack.restart": {
|
|
23
|
+
const plan = planFullDrain(graph);
|
|
24
|
+
if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set(plan.slice), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
case "selective-restart.requested":
|
|
28
|
+
if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
|
|
29
|
+
return;
|
|
30
|
+
case "apply.requested":
|
|
31
|
+
if (cmd.pluginKey !== void 0) {
|
|
32
|
+
if ((yield* doSelectiveRestart(graph, registry, deps.ref, deps.hub, new Set([cmd.pluginKey]), pluginContext, sinks, logger, identity, runtimeRoot, parentScope).pipe(Effect.as(true), Effect.catch(() => Effect.succeed(false)))) && (yield* allReadyOrTerminal(graph, registry))) yield* maybeRunPostAcquire(deps, options);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
|
|
36
|
+
return;
|
|
37
|
+
case "codegen.requested":
|
|
38
|
+
if (yield* allReadyOrTerminal(graph, registry)) yield* maybeRunPostAcquire(deps, options);
|
|
39
|
+
return;
|
|
40
|
+
case "snapshot.capture":
|
|
41
|
+
yield* startBackgroundSnapshotCapture(deps, cmd);
|
|
42
|
+
return;
|
|
43
|
+
case "snapshot.restore":
|
|
44
|
+
case "snapshot.list":
|
|
45
|
+
case "snapshot.delete":
|
|
46
|
+
case "wipe.requested":
|
|
47
|
+
case "prune.requested":
|
|
48
|
+
yield* runInjectedCommandHandler(deps, cmd);
|
|
49
|
+
return;
|
|
50
|
+
case "advance-clock.requested":
|
|
51
|
+
case "stack.start": return;
|
|
52
|
+
}
|
|
53
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.handleCommand"));
|
|
54
|
+
const commandLoop = (deps) => Effect.gen(function* () {
|
|
55
|
+
while (true) {
|
|
56
|
+
const next = yield* Queue.take(deps.queuedCommands);
|
|
57
|
+
if (next.kind === "submitted") {
|
|
58
|
+
const exit = yield* Effect.exit(handleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }));
|
|
59
|
+
yield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);
|
|
60
|
+
} else if (next.command.tag === "stack.restart") yield* startBackgroundStackRestart(deps, handleCommand);
|
|
61
|
+
else yield* handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));
|
|
62
|
+
if (yield* Ref.get(deps.shutdownLatch)) return;
|
|
63
|
+
}
|
|
64
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.commandLoop"));
|
|
65
|
+
//#endregion
|
|
66
|
+
export { commandLoop };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=command-loop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-loop.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/command-loop.ts"],"sourcesContent":["// Supervisor command-loop.\n//\n// One consumer of the `queuedCommands` channel. Each iteration:\n// 1. Take the next queued command (fire-and-forget OR submitted).\n// 2. Dispatch via `handleCommand`. Submitted commands carry a\n// `completion` deferred so the publisher can await the exit.\n// 3. Re-check the shutdown latch — exit the loop when set.\n//\n// `handleCommand` switches by tag and delegates to the per-concern\n// modules (shutdown, teardown, selective-restart, background-tasks).\n\nimport { Deferred, Effect, Queue, Ref, Scope } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport {\n\trunInjectedCommandHandler,\n\trunPostAcquireHook,\n\tstartBackgroundSnapshotCapture,\n\tstartBackgroundStackRestart,\n} from './background-tasks.ts';\nimport { SupervisorPostAcquireFailed } from './errors.ts';\nimport { handleHardKillRequested, handleShutdownRequested } from './shutdown.ts';\nimport { allReadyOrTerminal, type SupervisorState } from './state.ts';\nimport { doSelectiveRestart } from './teardown.ts';\nimport { planFullDrain } from '../lifecycle/index.ts';\n\nconst maybeRunPostAcquire = (\n\tdeps: SupervisorState,\n\toptions: { readonly failOnPostAcquireHook?: boolean },\n): Effect.Effect<void, SupervisorPostAcquireFailed, never> =>\n\toptions.failOnPostAcquireHook === true\n\t\t? runPostAcquireHook(deps)\n\t\t: runPostAcquireHook(deps).pipe(Effect.catch(() => Effect.void));\n\nexport const handleCommand = (\n\tdeps: SupervisorState,\n\tcmd: EngineCommand,\n\toptions: { readonly failOnPostAcquireHook?: boolean } = {},\n): Effect.Effect<void, SupervisorPostAcquireFailed, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, pluginContext, sinks, logger, identity, runtimeRoot } = deps;\n\t\tconst parentScope = yield* Effect.scope;\n\t\tswitch (cmd.tag) {\n\t\t\tcase 'shutdown.requested':\n\t\t\tcase 'stack.stop': {\n\t\t\t\tyield* handleShutdownRequested(deps);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'shutdown.hardKillRequested': {\n\t\t\t\tyield* handleHardKillRequested(deps, cmd);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'stack.restart': {\n\t\t\t\tconst plan = planFullDrain(graph);\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set(plan.slice),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tsinks,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\truntimeRoot,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'selective-restart.requested': {\n\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\tgraph,\n\t\t\t\t\tregistry,\n\t\t\t\t\tdeps.ref,\n\t\t\t\t\tdeps.hub,\n\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\tpluginContext,\n\t\t\t\t\tsinks,\n\t\t\t\t\tlogger,\n\t\t\t\t\tidentity,\n\t\t\t\t\truntimeRoot,\n\t\t\t\t\tparentScope,\n\t\t\t\t).pipe(\n\t\t\t\t\tEffect.as(true),\n\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t);\n\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'apply.requested': {\n\t\t\t\t// Re-acquire after watch invalidation. Caller may target a\n\t\t\t\t// specific plugin; otherwise no-op (the watcher already fed\n\t\t\t\t// `selective-restart.requested` for the affected keys).\n\t\t\t\tif (cmd.pluginKey !== undefined) {\n\t\t\t\t\tconst restarted = yield* doSelectiveRestart(\n\t\t\t\t\t\tgraph,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tdeps.ref,\n\t\t\t\t\t\tdeps.hub,\n\t\t\t\t\t\tnew Set([cmd.pluginKey]),\n\t\t\t\t\t\tpluginContext,\n\t\t\t\t\t\tsinks,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\truntimeRoot,\n\t\t\t\t\t\tparentScope,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.as(true),\n\t\t\t\t\t\tEffect.catch(() => Effect.succeed(false)),\n\t\t\t\t\t);\n\t\t\t\t\tif (restarted && (yield* allReadyOrTerminal(graph, registry))) {\n\t\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'codegen.requested': {\n\t\t\t\tif (yield* allReadyOrTerminal(graph, registry)) {\n\t\t\t\t\tyield* maybeRunPostAcquire(deps, options);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Snapshot/wipe/prune are owned by injected L3 handlers. The\n\t\t\t// supervisor keeps one consumer of the command queue and only\n\t\t\t// publishes the handler's typed events / errors.\n\t\t\tcase 'snapshot.capture':\n\t\t\t\tyield* startBackgroundSnapshotCapture(deps, cmd);\n\t\t\t\treturn;\n\t\t\tcase 'snapshot.restore':\n\t\t\tcase 'snapshot.list':\n\t\t\tcase 'snapshot.delete':\n\t\t\tcase 'wipe.requested':\n\t\t\tcase 'prune.requested':\n\t\t\t\tyield* runInjectedCommandHandler(deps, cmd);\n\t\t\t\treturn;\n\t\t\tcase 'advance-clock.requested':\n\t\t\tcase 'stack.start':\n\t\t\t\treturn;\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.handleCommand'));\n\nexport const commandLoop = (deps: SupervisorState): Effect.Effect<void, never, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\twhile (true) {\n\t\t\tconst next = yield* Queue.take(deps.queuedCommands);\n\t\t\tif (next.kind === 'submitted') {\n\t\t\t\tconst exit = yield* Effect.exit(\n\t\t\t\t\thandleCommand(deps, next.submission.command, { failOnPostAcquireHook: true }),\n\t\t\t\t);\n\t\t\t\tyield* Deferred.succeed(next.submission.completion, exit).pipe(Effect.ignore);\n\t\t\t} else if (next.command.tag === 'stack.restart') {\n\t\t\t\tyield* startBackgroundStackRestart(deps, handleCommand);\n\t\t\t} else {\n\t\t\t\tyield* handleCommand(deps, next.command).pipe(Effect.catch(() => Effect.void));\n\t\t\t}\n\t\t\tconst drained = yield* Ref.get(deps.shutdownLatch);\n\t\t\tif (drained) return;\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.commandLoop'));\n"],"mappings":";;;;;;;;;AA0BA,MAAM,uBACL,MACA,YAEA,QAAQ,0BAA0B,OAC/B,mBAAmB,KAAK,GACxB,mBAAmB,KAAK,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAElE,MAAa,iBACZ,MACA,KACA,UAAwD,EAAE,KAE1D,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,OAAO,UAAU,eAAe,OAAO,QAAQ,UAAU,gBAAgB;CACjF,MAAM,cAAc,OAAO,OAAO;AAClC,SAAQ,IAAI,KAAZ;EACC,KAAK;EACL,KAAK;AACJ,UAAO,wBAAwB,KAAK;AACpC;EAED,KAAK;AACJ,UAAO,wBAAwB,MAAM,IAAI;AACzC;EAED,KAAK,iBAAiB;GACrB,MAAM,OAAO,cAAc,MAAM;AAiBjC,QAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,KAAK,MAAM,EACnB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;;EAED,KAAK;AAiBJ,QAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,CAAC,IAAI,UAAU,CAAC,EACxB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAED,KAAK;AAIJ,OAAI,IAAI,cAAc,KAAA,GAAW;AAiBhC,SAAI,OAhBqB,mBACxB,OACA,UACA,KAAK,KACL,KAAK,KACL,IAAI,IAAI,CAAC,IAAI,UAAU,CAAC,EACxB,eACA,OACA,QACA,UACA,aACA,YACA,CAAC,KACD,OAAO,GAAG,KAAK,EACf,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CACzC,MACiB,OAAO,mBAAmB,OAAO,SAAS,EAC3D,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;;AAED,OAAI,OAAO,mBAAmB,OAAO,SAAS,CAC7C,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAED,KAAK;AACJ,OAAI,OAAO,mBAAmB,OAAO,SAAS,CAC7C,QAAO,oBAAoB,MAAM,QAAQ;AAE1C;EAKD,KAAK;AACJ,UAAO,+BAA+B,MAAM,IAAI;AAChD;EACD,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;AACJ,UAAO,0BAA0B,MAAM,IAAI;AAC3C;EACD,KAAK;EACL,KAAK,cACJ;;EAED,CAAC,KAAK,OAAO,SAAS,qCAAqC,CAAC;AAE/D,MAAa,eAAe,SAC3B,OAAO,IAAI,aAAa;AACvB,QAAO,MAAM;EACZ,MAAM,OAAO,OAAO,MAAM,KAAK,KAAK,eAAe;AACnD,MAAI,KAAK,SAAS,aAAa;GAC9B,MAAM,OAAO,OAAO,OAAO,KAC1B,cAAc,MAAM,KAAK,WAAW,SAAS,EAAE,uBAAuB,MAAM,CAAC,CAC7E;AACD,UAAO,SAAS,QAAQ,KAAK,WAAW,YAAY,KAAK,CAAC,KAAK,OAAO,OAAO;aACnE,KAAK,QAAQ,QAAQ,gBAC/B,QAAO,4BAA4B,MAAM,cAAc;MAEvD,QAAO,cAAc,MAAM,KAAK,QAAQ,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAG/E,MAAI,OADmB,IAAI,IAAI,KAAK,cAAc,CACrC;;EAEb,CAAC,KAAK,OAAO,SAAS,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { withPluginSpan } from "../observability/spans.mjs";
|
|
2
|
+
import "../capability-sinks/index.mjs";
|
|
3
|
+
import { CapabilityFactoryFailed } from "./errors.mjs";
|
|
4
|
+
import "../observability/index.mjs";
|
|
5
|
+
import { StrategyRegistryService } from "../strategy-registry/service.mjs";
|
|
6
|
+
import { OptionalService, noopStrategyRegistry, publish } from "./wiring.mjs";
|
|
7
|
+
import { Cause, Effect, Scope } from "effect";
|
|
8
|
+
//#region src/substrate/runtime/supervisor/dispatch-contributions.ts
|
|
9
|
+
const strategyRegistryAccess = OptionalService(StrategyRegistryService);
|
|
10
|
+
/**
|
|
11
|
+
* Render the underlying cause of a `ContributionSinkFailed` to a single
|
|
12
|
+
* human string for the operator-facing warning log.
|
|
13
|
+
*
|
|
14
|
+
* `ContributionSinkFailed.cause` is `unknown` — the failing sink may
|
|
15
|
+
* reject with an Effect `Cause`, a tagged domain error (e.g.
|
|
16
|
+
* `RouterBootFailed`, which carries the spec-mismatch `detail`), a plain
|
|
17
|
+
* `Error`, or an arbitrary value. The original wrapper only logged its
|
|
18
|
+
* own generic `err.message` ("capability sink 'routable' failed") and
|
|
19
|
+
* DROPPED this cause, so an operator saw a healthy-looking stack with
|
|
20
|
+
* dead RPC/wallet routing and no way to learn why. This recovers the
|
|
21
|
+
* real detail across all of those shapes:
|
|
22
|
+
* - `Cause` → `Cause.pretty` (full failure tree).
|
|
23
|
+
* - `Error` → `.stack ?? .message` (keeps the tag + detail; a
|
|
24
|
+
* `TaggedError`'s `toString()` includes `_tag` and its fields).
|
|
25
|
+
* - anything else → `JSON.stringify`, falling back to `String` when
|
|
26
|
+
* the value is not serializable (cyclic / BigInt).
|
|
27
|
+
*/
|
|
28
|
+
const formatCause = (cause) => {
|
|
29
|
+
if (Cause.isCause(cause)) return Cause.pretty(cause);
|
|
30
|
+
if (cause instanceof Error) return cause.stack ?? cause.message;
|
|
31
|
+
if (typeof cause === "string") return cause;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify(cause) ?? String(cause);
|
|
34
|
+
} catch {
|
|
35
|
+
return String(cause);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Best-effort discriminator for the wrapped cause — the failing sink
|
|
40
|
+
* error's `_tag` (e.g. `RouterBootFailed`) when present. Feeds the
|
|
41
|
+
* additive optional `causeType` on the `dispatchFailed` event so a
|
|
42
|
+
* renderer/log consumer can route on the failure category without
|
|
43
|
+
* parsing the message. Returns `undefined` for untagged causes so the
|
|
44
|
+
* field is simply omitted.
|
|
45
|
+
*/
|
|
46
|
+
const causeTagOf = (cause) => {
|
|
47
|
+
if (typeof cause === "object" && cause !== null && "_tag" in cause && typeof cause._tag === "string") return cause._tag;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Resolve a plugin's `capabilities` field to a concrete decl tuple.
|
|
51
|
+
*
|
|
52
|
+
* Two accepted shapes (see `Plugin.capabilities` for the
|
|
53
|
+
* authoring-side contract):
|
|
54
|
+
*
|
|
55
|
+
* (a) Static — a plain `ReadonlyArray<CapabilityDecl>`. Returned
|
|
56
|
+
* as-is.
|
|
57
|
+
*
|
|
58
|
+
* (b) Dynamic — a `CapabilitiesFactory<…>` function. Invoked with
|
|
59
|
+
* the resolved plugin value + the acquire context built from
|
|
60
|
+
* the supervisor's identity + runtime root. The function is
|
|
61
|
+
* called once per acquire (post-success); the returned tuple
|
|
62
|
+
* flows into `dispatchContributions` like a static one.
|
|
63
|
+
*
|
|
64
|
+
* The dynamic seam exists so plugins' snapshot subtrees, codegen
|
|
65
|
+
* bindings, routable URLs, strategy contributions, etc. can stamp
|
|
66
|
+
* the REAL chain id / package id / network alias produced by their
|
|
67
|
+
* acquire body, instead of the factory-time placeholder strings the
|
|
68
|
+
* static form forces.
|
|
69
|
+
*
|
|
70
|
+
* The substrate stays generic: this resolver doesn't know any
|
|
71
|
+
* service name; the discrimination is purely structural
|
|
72
|
+
* (`typeof === 'function'`).
|
|
73
|
+
*/
|
|
74
|
+
const resolveCapabilities = (pluginKey, field, resolved, acquireContext) => {
|
|
75
|
+
if (field === void 0) return Effect.succeed([]);
|
|
76
|
+
if (typeof field === "function") return Effect.try({
|
|
77
|
+
try: () => field(resolved, acquireContext),
|
|
78
|
+
catch: (cause) => new CapabilityFactoryFailed({
|
|
79
|
+
pluginKey,
|
|
80
|
+
message: `capability factory failed for ${pluginKey}`,
|
|
81
|
+
cause
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
return Effect.succeed(field);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Walk a plugin's `capabilities` tuple + `errorContributions` after a
|
|
88
|
+
* successful acquire, route every contribution through the
|
|
89
|
+
* substrate-owned `CapabilitySinksService`. The plugin's scope is
|
|
90
|
+
* provided so each sink's `addFinalizer` lands on the plugin's scope —
|
|
91
|
+
* registrations reap on selective-restart / shutdown.
|
|
92
|
+
*
|
|
93
|
+
* The supervisor stays kind-blind: it builds the contribution union
|
|
94
|
+
* (`{source: 'capability'|'error', ...}`) and the dispatch happens
|
|
95
|
+
* inside the service. Unknown kinds are downgraded to no-ops here so
|
|
96
|
+
* the substrate-open-by-default contract holds — plugin authors can
|
|
97
|
+
* emit a custom-kind decl that is observed only by the orchestrators
|
|
98
|
+
* that registered the matching sink.
|
|
99
|
+
*
|
|
100
|
+
* Sink failures (`ContributionSinkFailed`) are routed through a
|
|
101
|
+
* separate `engine.orchestrator.dispatchFailed` event so the plugin
|
|
102
|
+
* remains ready and the orchestrator's broken sink is the visible
|
|
103
|
+
* fault (backlog #39).
|
|
104
|
+
*/
|
|
105
|
+
const dispatchContributions = (pluginKey, capabilities, errorContributions, pluginRole, identity, pluginContext, pluginScope, sinks, ref, hub) => Effect.gen(function* () {
|
|
106
|
+
const strategyRegistry = strategyRegistryAccess.read(pluginContext, noopStrategyRegistry);
|
|
107
|
+
const harvestCtx = {
|
|
108
|
+
pluginKey,
|
|
109
|
+
identity,
|
|
110
|
+
publish: (event) => publish(ref, hub, event),
|
|
111
|
+
registerStrategy: (decl) => strategyRegistry.register(decl.capabilityKey, decl.strategy, {
|
|
112
|
+
autoMounted: decl.autoMounted,
|
|
113
|
+
...decl.priority === void 0 ? {} : { priority: decl.priority }
|
|
114
|
+
})
|
|
115
|
+
};
|
|
116
|
+
const items = [...capabilities.map((decl) => ({
|
|
117
|
+
source: "capability",
|
|
118
|
+
decl
|
|
119
|
+
})), ...errorContributions.map((contribution) => ({
|
|
120
|
+
source: "error",
|
|
121
|
+
contribution
|
|
122
|
+
}))];
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
const dispatch = sinks.dispatch(item, harvestCtx).pipe(Effect.catchTags({
|
|
125
|
+
UnknownContributionKind: () => Effect.void,
|
|
126
|
+
ContributionSinkFailed: (err) => Effect.gen(function* () {
|
|
127
|
+
const causeType = causeTagOf(err.cause);
|
|
128
|
+
yield* publish(ref, hub, {
|
|
129
|
+
tag: "engine.orchestrator.dispatchFailed",
|
|
130
|
+
pluginKey,
|
|
131
|
+
kind: err.kind,
|
|
132
|
+
message: err.message,
|
|
133
|
+
...causeType === void 0 ? {} : { causeType },
|
|
134
|
+
at: Date.now()
|
|
135
|
+
});
|
|
136
|
+
yield* Effect.logWarning(`capability sink '${err.kind}' failed for plugin '${pluginKey}': ${formatCause(err.cause)}`);
|
|
137
|
+
})
|
|
138
|
+
}));
|
|
139
|
+
yield* Scope.provide(dispatch, pluginScope);
|
|
140
|
+
}
|
|
141
|
+
}).pipe(withPluginSpan("lifecycle.supervisor.dispatchContributions", {
|
|
142
|
+
app: identity.app,
|
|
143
|
+
stack: identity.stack,
|
|
144
|
+
network: identity.chain,
|
|
145
|
+
pluginKey,
|
|
146
|
+
role: pluginRole
|
|
147
|
+
}));
|
|
148
|
+
//#endregion
|
|
149
|
+
export { dispatchContributions, resolveCapabilities };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=dispatch-contributions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-contributions.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/dispatch-contributions.ts"],"sourcesContent":["// Supervisor capability-dispatch path.\n//\n// Walks a plugin's `capabilities` tuple + `errorContributions` after a\n// successful acquire and routes each item through the substrate-owned\n// `CapabilitySinksService`.\n//\n// Bug-fix history (backlog #39): the original implementation only\n// caught `UnknownContributionKind` from `sinks.dispatch()`. The error\n// channel also yields `ContributionSinkFailed` (a registered sink\n// rejected while handling a known kind — router/codegen collisions,\n// upstream IO faults). The wrapping `Effect.exit` at the acquire-node\n// callsite then projected the failure through `registry.markFailed`,\n// attributing the orchestrator's bug to the plugin.\n//\n// Fix: catch BOTH tags here and route them DIFFERENTLY.\n// - `UnknownContributionKind` → no-op (substrate-open-by-default;\n// the plugin emitted a contribution shape no sink claims).\n// - `ContributionSinkFailed` → publish the typed\n// `engine.orchestrator.dispatchFailed` event + log a warning; the\n// plugin stays ready.\n\nimport { Cause, Context, Effect, Queue, Scope, SubscriptionRef } from 'effect';\n\nimport type { CapabilityDecl } from '../../../contracts/capability-decl.ts';\nimport type { StrategyContributorDecl } from '../../../contracts/strategy-contributor.ts';\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { PluginRole } from '../../lifecycle.ts';\nimport type { AcquireContext, PluginErrorContribution } from '../../plugin.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport {\n\ttype AnyContribution,\n\ttype CapabilitySinksShape,\n\ttype HarvestContext,\n} from '../capability-sinks/index.ts';\nimport { withPluginSpan } from '../observability/index.ts';\nimport { StrategyRegistryService } from '../strategy-registry/service.ts';\nimport { CapabilityFactoryFailed } from './errors.ts';\nimport { noopStrategyRegistry, OptionalService, publish } from './wiring.ts';\n\nconst strategyRegistryAccess = OptionalService(StrategyRegistryService);\n\n/**\n * Render the underlying cause of a `ContributionSinkFailed` to a single\n * human string for the operator-facing warning log.\n *\n * `ContributionSinkFailed.cause` is `unknown` — the failing sink may\n * reject with an Effect `Cause`, a tagged domain error (e.g.\n * `RouterBootFailed`, which carries the spec-mismatch `detail`), a plain\n * `Error`, or an arbitrary value. The original wrapper only logged its\n * own generic `err.message` (\"capability sink 'routable' failed\") and\n * DROPPED this cause, so an operator saw a healthy-looking stack with\n * dead RPC/wallet routing and no way to learn why. This recovers the\n * real detail across all of those shapes:\n * - `Cause` → `Cause.pretty` (full failure tree).\n * - `Error` → `.stack ?? .message` (keeps the tag + detail; a\n * `TaggedError`'s `toString()` includes `_tag` and its fields).\n * - anything else → `JSON.stringify`, falling back to `String` when\n * the value is not serializable (cyclic / BigInt).\n */\nconst formatCause = (cause: unknown): string => {\n\tif (Cause.isCause(cause)) return Cause.pretty(cause);\n\tif (cause instanceof Error) return cause.stack ?? cause.message;\n\tif (typeof cause === 'string') return cause;\n\ttry {\n\t\treturn JSON.stringify(cause) ?? String(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n};\n\n/**\n * Best-effort discriminator for the wrapped cause — the failing sink\n * error's `_tag` (e.g. `RouterBootFailed`) when present. Feeds the\n * additive optional `causeType` on the `dispatchFailed` event so a\n * renderer/log consumer can route on the failure category without\n * parsing the message. Returns `undefined` for untagged causes so the\n * field is simply omitted.\n */\nconst causeTagOf = (cause: unknown): string | undefined => {\n\tif (\n\t\ttypeof cause === 'object' &&\n\t\tcause !== null &&\n\t\t'_tag' in cause &&\n\t\ttypeof (cause as { _tag: unknown })._tag === 'string'\n\t) {\n\t\treturn (cause as { _tag: string })._tag;\n\t}\n\treturn undefined;\n};\n\n/**\n * Resolve a plugin's `capabilities` field to a concrete decl tuple.\n *\n * Two accepted shapes (see `Plugin.capabilities` for the\n * authoring-side contract):\n *\n * (a) Static — a plain `ReadonlyArray<CapabilityDecl>`. Returned\n * as-is.\n *\n * (b) Dynamic — a `CapabilitiesFactory<…>` function. Invoked with\n * the resolved plugin value + the acquire context built from\n * the supervisor's identity + runtime root. The function is\n * called once per acquire (post-success); the returned tuple\n * flows into `dispatchContributions` like a static one.\n *\n * The dynamic seam exists so plugins' snapshot subtrees, codegen\n * bindings, routable URLs, strategy contributions, etc. can stamp\n * the REAL chain id / package id / network alias produced by their\n * acquire body, instead of the factory-time placeholder strings the\n * static form forces.\n *\n * The substrate stays generic: this resolver doesn't know any\n * service name; the discrimination is purely structural\n * (`typeof === 'function'`).\n */\nexport const resolveCapabilities = (\n\tpluginKey: PluginKey,\n\tfield:\n\t\t| ReadonlyArray<CapabilityDecl>\n\t\t| ((resolved: unknown, ctx: AcquireContext) => ReadonlyArray<CapabilityDecl>)\n\t\t| undefined,\n\tresolved: unknown,\n\tacquireContext: AcquireContext,\n): Effect.Effect<ReadonlyArray<CapabilityDecl>, CapabilityFactoryFailed> => {\n\tif (field === undefined) return Effect.succeed([]);\n\tif (typeof field === 'function') {\n\t\treturn Effect.try({\n\t\t\ttry: () => field(resolved, acquireContext),\n\t\t\tcatch: (cause) =>\n\t\t\t\tnew CapabilityFactoryFailed({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tmessage: `capability factory failed for ${pluginKey}`,\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t});\n\t}\n\treturn Effect.succeed(field);\n};\n\n/**\n * Walk a plugin's `capabilities` tuple + `errorContributions` after a\n * successful acquire, route every contribution through the\n * substrate-owned `CapabilitySinksService`. The plugin's scope is\n * provided so each sink's `addFinalizer` lands on the plugin's scope —\n * registrations reap on selective-restart / shutdown.\n *\n * The supervisor stays kind-blind: it builds the contribution union\n * (`{source: 'capability'|'error', ...}`) and the dispatch happens\n * inside the service. Unknown kinds are downgraded to no-ops here so\n * the substrate-open-by-default contract holds — plugin authors can\n * emit a custom-kind decl that is observed only by the orchestrators\n * that registered the matching sink.\n *\n * Sink failures (`ContributionSinkFailed`) are routed through a\n * separate `engine.orchestrator.dispatchFailed` event so the plugin\n * remains ready and the orchestrator's broken sink is the visible\n * fault (backlog #39).\n */\nexport const dispatchContributions = (\n\tpluginKey: PluginKey,\n\tcapabilities: ReadonlyArray<CapabilityDecl>,\n\terrorContributions: ReadonlyArray<PluginErrorContribution>,\n\tpluginRole: PluginRole,\n\tidentity: Identity,\n\tpluginContext: Context.Context<never>,\n\tpluginScope: Scope.Scope,\n\tsinks: CapabilitySinksShape,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst strategyRegistry = strategyRegistryAccess.read(pluginContext, noopStrategyRegistry);\n\t\tconst harvestCtx: HarvestContext = {\n\t\t\tpluginKey,\n\t\t\tidentity,\n\t\t\tpublish: (event) => publish(ref, hub, event),\n\t\t\tregisterStrategy: (decl: StrategyContributorDecl<string, unknown>) =>\n\t\t\t\tstrategyRegistry.register(decl.capabilityKey, decl.strategy, {\n\t\t\t\t\tautoMounted: decl.autoMounted,\n\t\t\t\t\t...(decl.priority === undefined ? {} : { priority: decl.priority }),\n\t\t\t\t}),\n\t\t};\n\n\t\tconst items: ReadonlyArray<AnyContribution> = [\n\t\t\t...capabilities.map<AnyContribution>((decl) => ({\n\t\t\t\tsource: 'capability',\n\t\t\t\tdecl,\n\t\t\t})),\n\t\t\t...errorContributions.map<AnyContribution>((contribution) => ({\n\t\t\t\tsource: 'error',\n\t\t\t\tcontribution,\n\t\t\t})),\n\t\t];\n\n\t\tfor (const item of items) {\n\t\t\tconst dispatch = sinks.dispatch(item, harvestCtx).pipe(\n\t\t\t\tEffect.catchTags({\n\t\t\t\t\tUnknownContributionKind: () => Effect.void,\n\t\t\t\t\tContributionSinkFailed: (err) =>\n\t\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t\t// Orchestrator-fault path: surface the typed event so\n\t\t\t\t\t\t\t// renderers + log consumers see WHICH sink failed\n\t\t\t\t\t\t\t// without misattributing to the plugin. The plugin's\n\t\t\t\t\t\t\t// lifecycle state is untouched; the markFailed path\n\t\t\t\t\t\t\t// in `acquireNode` is NOT taken for this branch.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// The underlying cause MUST travel with the warning:\n\t\t\t\t\t\t\t// a non-fatal sink (e.g. `routable`) leaves the plugin\n\t\t\t\t\t\t\t// `ready`, so without the cause an operator sees a\n\t\t\t\t\t\t\t// healthy-looking stack with dead RPC/wallet routing\n\t\t\t\t\t\t\t// and no diagnosis. `err.cause` holds the real domain\n\t\t\t\t\t\t\t// error (e.g. `RouterBootFailed` + its spec-mismatch\n\t\t\t\t\t\t\t// `detail`); we stringify it for the log and lift its\n\t\t\t\t\t\t\t// `_tag` onto the event's additive `causeType`.\n\t\t\t\t\t\t\tconst causeType = causeTagOf(err.cause);\n\t\t\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\t\t\ttag: 'engine.orchestrator.dispatchFailed',\n\t\t\t\t\t\t\t\tpluginKey,\n\t\t\t\t\t\t\t\tkind: err.kind,\n\t\t\t\t\t\t\t\tmessage: err.message,\n\t\t\t\t\t\t\t\t...(causeType === undefined ? {} : { causeType }),\n\t\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t\t\t\t`capability sink '${err.kind}' failed for plugin '${pluginKey}': ${formatCause(err.cause)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tyield* Scope.provide(dispatch, pluginScope);\n\t\t}\n\t}).pipe(\n\t\twithPluginSpan('lifecycle.supervisor.dispatchContributions', {\n\t\t\tapp: identity.app,\n\t\t\tstack: identity.stack,\n\t\t\tnetwork: identity.chain,\n\t\t\tpluginKey,\n\t\t\trole: pluginRole,\n\t\t}),\n\t);\n"],"mappings":";;;;;;;;AAyCA,MAAM,yBAAyB,gBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;AAoBvE,MAAM,eAAe,UAA2B;AAC/C,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,OAAO,MAAM;AACpD,KAAI,iBAAiB,MAAO,QAAO,MAAM,SAAS,MAAM;AACxD,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,KAAI;AACH,SAAO,KAAK,UAAU,MAAM,IAAI,OAAO,MAAM;SACtC;AACP,SAAO,OAAO,MAAM;;;;;;;;;;;AAYtB,MAAM,cAAc,UAAuC;AAC1D,KACC,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAQ,MAA4B,SAAS,SAE7C,QAAQ,MAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BrC,MAAa,uBACZ,WACA,OAIA,UACA,mBAC2E;AAC3E,KAAI,UAAU,KAAA,EAAW,QAAO,OAAO,QAAQ,EAAE,CAAC;AAClD,KAAI,OAAO,UAAU,WACpB,QAAO,OAAO,IAAI;EACjB,WAAW,MAAM,UAAU,eAAe;EAC1C,QAAQ,UACP,IAAI,wBAAwB;GAC3B;GACA,SAAS,iCAAiC;GAC1C;GACA,CAAC;EACH,CAAC;AAEH,QAAO,OAAO,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;AAsB7B,MAAa,yBACZ,WACA,cACA,oBACA,YACA,UACA,eACA,aACA,OACA,KACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,mBAAmB,uBAAuB,KAAK,eAAe,qBAAqB;CACzF,MAAM,aAA6B;EAClC;EACA;EACA,UAAU,UAAU,QAAQ,KAAK,KAAK,MAAM;EAC5C,mBAAmB,SAClB,iBAAiB,SAAS,KAAK,eAAe,KAAK,UAAU;GAC5D,aAAa,KAAK;GAClB,GAAI,KAAK,aAAa,KAAA,IAAY,EAAE,GAAG,EAAE,UAAU,KAAK,UAAU;GAClE,CAAC;EACH;CAED,MAAM,QAAwC,CAC7C,GAAG,aAAa,KAAsB,UAAU;EAC/C,QAAQ;EACR;EACA,EAAE,EACH,GAAG,mBAAmB,KAAsB,kBAAkB;EAC7D,QAAQ;EACR;EACA,EAAE,CACH;AAED,MAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,WAAW,MAAM,SAAS,MAAM,WAAW,CAAC,KACjD,OAAO,UAAU;GAChB,+BAA+B,OAAO;GACtC,yBAAyB,QACxB,OAAO,IAAI,aAAa;IAevB,MAAM,YAAY,WAAW,IAAI,MAAM;AACvC,WAAO,QAAQ,KAAK,KAAK;KACxB,KAAK;KACL;KACA,MAAM,IAAI;KACV,SAAS,IAAI;KACb,GAAI,cAAc,KAAA,IAAY,EAAE,GAAG,EAAE,WAAW;KAChD,IAAI,KAAK,KAAK;KACd,CAAC;AACF,WAAO,OAAO,WACb,oBAAoB,IAAI,KAAK,uBAAuB,UAAU,KAAK,YAAY,IAAI,MAAM,GACzF;KACA;GACH,CAAC,CACF;AACD,SAAO,MAAM,QAAQ,UAAU,YAAY;;EAE3C,CAAC,KACF,eAAe,8CAA8C;CAC5D,KAAK,SAAS;CACd,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB;CACA,MAAM;CACN,CAAC,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Cause } from "effect";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Data } from "effect";
|
|
2
|
+
//#region src/substrate/runtime/supervisor/errors.ts
|
|
3
|
+
var SupervisorBootError = class extends Data.TaggedError("SupervisorBootError") {};
|
|
4
|
+
var SupervisorPostAcquireFailed = class extends Data.TaggedError("SupervisorPostAcquireFailed") {};
|
|
5
|
+
var CapabilityFactoryFailed = class extends Data.TaggedError("CapabilityFactoryFailed") {};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { CapabilityFactoryFailed, SupervisorBootError, SupervisorPostAcquireFailed };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/errors.ts"],"sourcesContent":["// Supervisor-owned typed errors.\n//\n// Split out of the monolith. These shapes are part of the public\n// supervisor surface (re-exported from `./index.ts`).\n\nimport { Cause, Data } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { DepGraphError } from '../lifecycle/index.ts';\nimport type {\n\tPluginAcquireFailed,\n\tRestartTargetMissing,\n\tUnknownDependency,\n} from '../lifecycle/index.ts';\n\nexport class SupervisorBootError extends Data.TaggedError('SupervisorBootError')<{\n\treadonly cause: DepGraphError;\n}> {}\n\nexport class SupervisorPostAcquireFailed extends Data.TaggedError('SupervisorPostAcquireFailed')<{\n\treadonly cause: Cause.Cause<unknown>;\n}> {}\n\nexport class CapabilityFactoryFailed extends Data.TaggedError('CapabilityFactoryFailed')<{\n\treadonly pluginKey: PluginKey;\n\treadonly message: string;\n\treadonly cause: unknown;\n}> {}\n\nexport type SupervisorError =\n\t| SupervisorBootError\n\t| SupervisorPostAcquireFailed\n\t| CapabilityFactoryFailed\n\t| PluginAcquireFailed\n\t| RestartTargetMissing\n\t| UnknownDependency;\n"],"mappings":";;AAeA,IAAa,sBAAb,cAAyC,KAAK,YAAY,sBAAsB,CAE7E;AAEH,IAAa,8BAAb,cAAiD,KAAK,YAAY,8BAA8B,CAE7F;AAEH,IAAa,0BAAb,cAA6C,KAAK,YAAY,0BAA0B,CAIrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { planFullDrain } from "../lifecycle/selective-restart.mjs";
|
|
2
|
+
import "../lifecycle/index.mjs";
|
|
3
|
+
import { publish, setCyclePhase } from "./wiring.mjs";
|
|
4
|
+
import { requestBackgroundSnapshotInterrupt, requestBackgroundStackRestartInterrupt } from "./background-tasks.mjs";
|
|
5
|
+
import { teardownKeys } from "./teardown.mjs";
|
|
6
|
+
import { Deferred, Effect, Ref } from "effect";
|
|
7
|
+
//#region src/substrate/runtime/supervisor/shutdown.ts
|
|
8
|
+
const handleShutdownRequested = (deps) => Effect.gen(function* () {
|
|
9
|
+
const { graph, registry, ref, shutdownLatch, logger } = deps;
|
|
10
|
+
yield* Effect.uninterruptible(Effect.gen(function* () {
|
|
11
|
+
yield* requestBackgroundSnapshotInterrupt(deps);
|
|
12
|
+
yield* setCyclePhase(ref, "shutting-down");
|
|
13
|
+
yield* Ref.set(shutdownLatch, true);
|
|
14
|
+
yield* logger.log("supervisor", null, {
|
|
15
|
+
level: "info",
|
|
16
|
+
message: "shutdown requested"
|
|
17
|
+
});
|
|
18
|
+
yield* requestBackgroundStackRestartInterrupt(deps);
|
|
19
|
+
yield* teardownKeys(graph, registry, planFullDrain(graph).teardownOrder);
|
|
20
|
+
yield* Effect.yieldNow;
|
|
21
|
+
yield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
const handleHardKillRequested = (deps, cmd) => Effect.gen(function* () {
|
|
25
|
+
const { ref, hub, shutdownLatch, logger } = deps;
|
|
26
|
+
yield* requestBackgroundSnapshotInterrupt(deps);
|
|
27
|
+
yield* publish(ref, hub, {
|
|
28
|
+
tag: "shutdown.escalated",
|
|
29
|
+
signal: cmd.signal,
|
|
30
|
+
exitCode: cmd.exitCode,
|
|
31
|
+
at: cmd.at
|
|
32
|
+
});
|
|
33
|
+
yield* setCyclePhase(ref, "shutting-down");
|
|
34
|
+
yield* Ref.set(shutdownLatch, true);
|
|
35
|
+
yield* requestBackgroundStackRestartInterrupt(deps);
|
|
36
|
+
yield* Effect.uninterruptible(Effect.gen(function* () {
|
|
37
|
+
yield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);
|
|
38
|
+
yield* logger.log("supervisor", null, {
|
|
39
|
+
level: "fatal",
|
|
40
|
+
message: `shutdown escalated by ${cmd.signal}`,
|
|
41
|
+
fields: {
|
|
42
|
+
signal: cmd.signal,
|
|
43
|
+
exitCode: cmd.exitCode
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { handleHardKillRequested, handleShutdownRequested };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=shutdown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/shutdown.ts"],"sourcesContent":["// Shutdown branches.\n//\n// Two paths handled here:\n//\n// - `shutdown.requested` / `stack.stop` — graceful drain. Teardown +\n// the deferred resolution live in one `Effect.uninterruptible`\n// block (Bug #13 fix, regression test in\n// `test/substrate/runtime/supervisor-hard-shutdown.test.ts`).\n//\n// - `shutdown.hardKillRequested` — escalated shutdown. The graceful\n// teardown is owned by the supervisor's scope-close finalizer\n// (which is already uninterruptible); this branch atomically\n// signals `shutdownComplete` + emits the fatal log so a third SIGINT\n// can't slip an Effect-level interrupt between the two writes.\n// `process.exit` from `signals.ts` IS still a hard kill — that\n// escape hatch is intentional double-Ctrl-C semantics.\n\nimport { Deferred, Effect, Ref } from 'effect';\n\nimport type { EngineCommand } from '../../events.ts';\nimport { planFullDrain } from '../lifecycle/index.ts';\nimport {\n\trequestBackgroundSnapshotInterrupt,\n\trequestBackgroundStackRestartInterrupt,\n} from './background-tasks.ts';\nimport type { SupervisorState } from './state.ts';\nimport { publish, setCyclePhase } from './wiring.ts';\nimport { teardownKeys } from './teardown.ts';\n\nexport const handleShutdownRequested = (deps: SupervisorState): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { graph, registry, ref, shutdownLatch, logger } = deps;\n\t\t// Uninterruptible covers the Effect-level interrupt a second\n\t\t// SIGINT would inject anywhere between the awaited snapshot/restart\n\t\t// interrupts, the latch set, and the shutdownComplete signal —\n\t\t// scope close racing the in-loop teardown leaks Docker containers,\n\t\t// and a second SIGINT landing during the awaited snapshot-interrupt\n\t\t// must not interrupt the command loop before teardown runs. The\n\t\t// latch set + deferred resolution live in the same block so callers\n\t\t// blocked on `awaitShutdown` only release AFTER teardown has run.\n\t\t// The signal handler's `process.exit` (signals.ts:75-102) is\n\t\t// still a hard kill — that's intentional; double-Ctrl-C is\n\t\t// the operator asking for abort.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* requestBackgroundSnapshotInterrupt(deps);\n\t\t\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\t\t\tyield* Ref.set(shutdownLatch, true);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'info',\n\t\t\t\t\tmessage: 'shutdown requested',\n\t\t\t\t});\n\t\t\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t\t\tconst plan = planFullDrain(graph);\n\t\t\t\tyield* teardownKeys(graph, registry, plan.teardownOrder);\n\t\t\t\tyield* Effect.yieldNow;\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t}),\n\t\t);\n\t});\n\nexport const handleHardKillRequested = (\n\tdeps: SupervisorState,\n\tcmd: Extract<EngineCommand, { readonly tag: 'shutdown.hardKillRequested' }>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst { ref, hub, shutdownLatch, logger } = deps;\n\t\tyield* requestBackgroundSnapshotInterrupt(deps);\n\t\tyield* publish(ref, hub, {\n\t\t\ttag: 'shutdown.escalated',\n\t\t\tsignal: cmd.signal,\n\t\t\texitCode: cmd.exitCode,\n\t\t\tat: cmd.at,\n\t\t});\n\t\tyield* setCyclePhase(ref, 'shutting-down');\n\t\tyield* Ref.set(shutdownLatch, true);\n\t\tyield* requestBackgroundStackRestartInterrupt(deps);\n\t\t// Hard-kill path: graceful teardown is owned by the\n\t\t// scope-close finalizer (start-supervisor.ts addFinalizer) which\n\t\t// already runs uninterruptibly. We only need to atomically signal\n\t\t// `shutdownComplete` + emit the fatal log so a third SIGINT\n\t\t// can't slip an Effect-level interrupt between the two.\n\t\t// `process.exit` from signals.ts:75-102 IS still the hard\n\t\t// kill — that escape hatch is intentional.\n\t\tyield* Effect.uninterruptible(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tyield* Deferred.succeed(deps.shutdownComplete, void 0).pipe(Effect.ignore);\n\t\t\t\tyield* logger.log('supervisor', null, {\n\t\t\t\t\tlevel: 'fatal',\n\t\t\t\t\tmessage: `shutdown escalated by ${cmd.signal}`,\n\t\t\t\t\tfields: { signal: cmd.signal, exitCode: cmd.exitCode },\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t});\n"],"mappings":";;;;;;;AA6BA,MAAa,2BAA2B,SACvC,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,OAAO,UAAU,KAAK,eAAe,WAAW;AAYxD,QAAO,OAAO,gBACb,OAAO,IAAI,aAAa;AACvB,SAAO,mCAAmC,KAAK;AAC/C,SAAO,cAAc,KAAK,gBAAgB;AAC1C,SAAO,IAAI,IAAI,eAAe,KAAK;AACnC,SAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS;GACT,CAAC;AACF,SAAO,uCAAuC,KAAK;AAEnD,SAAO,aAAa,OAAO,UADd,cAAc,MACc,CAAC,cAAc;AACxD,SAAO,OAAO;AACd,SAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,EAAE,CAAC,KAAK,OAAO,OAAO;GACzE,CACF;EACA;AAEH,MAAa,2BACZ,MACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,EAAE,KAAK,KAAK,eAAe,WAAW;AAC5C,QAAO,mCAAmC,KAAK;AAC/C,QAAO,QAAQ,KAAK,KAAK;EACxB,KAAK;EACL,QAAQ,IAAI;EACZ,UAAU,IAAI;EACd,IAAI,IAAI;EACR,CAAC;AACF,QAAO,cAAc,KAAK,gBAAgB;AAC1C,QAAO,IAAI,IAAI,eAAe,KAAK;AACnC,QAAO,uCAAuC,KAAK;AAQnD,QAAO,OAAO,gBACb,OAAO,IAAI,aAAa;AACvB,SAAO,SAAS,QAAQ,KAAK,kBAAkB,KAAK,EAAE,CAAC,KAAK,OAAO,OAAO;AAC1E,SAAO,OAAO,IAAI,cAAc,MAAM;GACrC,OAAO;GACP,SAAS,yBAAyB,IAAI;GACtC,QAAQ;IAAE,QAAQ,IAAI;IAAQ,UAAU,IAAI;IAAU;GACtD,CAAC;GACD,CACF;EACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Context, Effect, Queue, Scope, SubscriptionRef } from "effect";
|