@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,250 @@
|
|
|
1
|
+
import { RuntimeRoot } from "../paths.mjs";
|
|
2
|
+
import { withStackSpan } from "../observability/spans.mjs";
|
|
3
|
+
import { CapabilitySinksService } from "../capability-sinks/service.mjs";
|
|
4
|
+
import { layerCapabilitySinksDefault } from "../capability-sinks/layer.mjs";
|
|
5
|
+
import "../capability-sinks/index.mjs";
|
|
6
|
+
import { SupervisorBootError } from "./errors.mjs";
|
|
7
|
+
import { Logger as Logger$1 } from "../observability/logger.mjs";
|
|
8
|
+
import { LogStore, makeLogStore } from "../observability/log-store.mjs";
|
|
9
|
+
import { SpanStore, makeSpanStore } from "../observability/span-store.mjs";
|
|
10
|
+
import "../observability/index.mjs";
|
|
11
|
+
import { ControlPlaneService } from "../control-plane/service.mjs";
|
|
12
|
+
import { controlPlaneDomainFromContext } from "../control-plane/domain.mjs";
|
|
13
|
+
import { declareAccount, setIdentity } from "../projection/update.mjs";
|
|
14
|
+
import { resolveGraph } from "../lifecycle/dep-graph.mjs";
|
|
15
|
+
import { buildWatchIndex, exactPrefixMatch } from "../lifecycle/watch-attribution.mjs";
|
|
16
|
+
import { planFullDrain } from "../lifecycle/selective-restart.mjs";
|
|
17
|
+
import { installSignalHandler } from "../lifecycle/signals.mjs";
|
|
18
|
+
import "../lifecycle/index.mjs";
|
|
19
|
+
import { OptionalService, buildTransitionEmitter, noopLogger, setCyclePhase, withEventPublishingLogger } from "./wiring.mjs";
|
|
20
|
+
import { acquireFullGraph, buildRegistry } from "./acquire-node.mjs";
|
|
21
|
+
import { runPostAcquireHook } from "./background-tasks.mjs";
|
|
22
|
+
import { teardownKeys } from "./teardown.mjs";
|
|
23
|
+
import { allReadyOrTerminal } from "./state.mjs";
|
|
24
|
+
import { commandLoop } from "./command-loop.mjs";
|
|
25
|
+
import { Context, Deferred, Effect, Exit, Layer, Queue, Ref, SubscriptionRef, Tracer } from "effect";
|
|
26
|
+
//#region src/substrate/runtime/supervisor/start-supervisor.ts
|
|
27
|
+
const loggerAccess = OptionalService(Logger$1);
|
|
28
|
+
const runtimeRootAccess = OptionalService(RuntimeRoot);
|
|
29
|
+
const sinksAccess = OptionalService(CapabilitySinksService);
|
|
30
|
+
const pendingAccountProjection = (rowKey, resourceId, updatedAt) => {
|
|
31
|
+
if (!resourceId.startsWith("account/")) return null;
|
|
32
|
+
const name = resourceId.slice(8);
|
|
33
|
+
if (name.length === 0) return null;
|
|
34
|
+
return {
|
|
35
|
+
key: resourceId,
|
|
36
|
+
rowKey,
|
|
37
|
+
name,
|
|
38
|
+
address: null,
|
|
39
|
+
scheme: null,
|
|
40
|
+
source: null,
|
|
41
|
+
funding: {
|
|
42
|
+
status: "pending",
|
|
43
|
+
balanceMist: null,
|
|
44
|
+
requestedMist: null,
|
|
45
|
+
entries: []
|
|
46
|
+
},
|
|
47
|
+
walletVisible: false,
|
|
48
|
+
updatedAt
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Prepare a supervisor for `stack` without running the initial acquire.
|
|
53
|
+
* The returned `SupervisorHandle` is Scope-managed; the supervisor's
|
|
54
|
+
* lifecycle is the surrounding Scope's lifecycle. Signal handlers,
|
|
55
|
+
* the command loop, and every plugin's scope are children of the
|
|
56
|
+
* supervisor scope. Callers that mount renderers can subscribe to the
|
|
57
|
+
* returned state before invoking `runInitialAcquire`.
|
|
58
|
+
*
|
|
59
|
+
* `pluginContext` carries the substrate-context services available to
|
|
60
|
+
* each plugin's `acquire` body (`IdentityContext`,
|
|
61
|
+
* `ContainerRuntimeService`, `RuntimeRoot`, `StackPathsService`, etc.).
|
|
62
|
+
* Plugins declare what they need by yielding the corresponding
|
|
63
|
+
* `Context.Service` tag from within `Effect.gen`; the supervisor
|
|
64
|
+
* provides this context before running the acquire effect so the
|
|
65
|
+
* plugin's R-channel narrows to `Scope.Scope` (then to `never` after
|
|
66
|
+
* the per-plugin Scope is provided).
|
|
67
|
+
*
|
|
68
|
+
* `CapabilitySinksService` extension (ARCHITECTURE.md § Plugin-author
|
|
69
|
+
* extension via Layer composition): if the caller layers a
|
|
70
|
+
* `CapabilitySinksService` into `pluginContext`, the supervisor
|
|
71
|
+
* harvests through THAT instance instead of building its own.
|
|
72
|
+
*/
|
|
73
|
+
const startSupervisor = (stack, identity, state, pluginContext = Context.empty(), sinks = [], commandHandler, postAcquireHook, options = {}) => Effect.gen(function* () {
|
|
74
|
+
yield* Effect.annotateCurrentSpan({ "devstack.stack.memberCount": stack.members.length });
|
|
75
|
+
const baseLogger = loggerAccess.read(pluginContext, noopLogger);
|
|
76
|
+
yield* baseLogger.log("supervisor", null, {
|
|
77
|
+
level: "debug",
|
|
78
|
+
message: "supervisor boot start",
|
|
79
|
+
fields: {
|
|
80
|
+
app: identity.app,
|
|
81
|
+
stack: identity.stack,
|
|
82
|
+
network: identity.chain,
|
|
83
|
+
memberCount: stack.members.length
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
yield* SubscriptionRef.update(state, (s) => ({
|
|
87
|
+
...setIdentity(s, {
|
|
88
|
+
app: identity.app,
|
|
89
|
+
stack: identity.stack,
|
|
90
|
+
network: identity.chain
|
|
91
|
+
}),
|
|
92
|
+
cycle: {
|
|
93
|
+
...s.cycle,
|
|
94
|
+
startedAt: s.cycle.startedAt === 0 ? Date.now() : s.cycle.startedAt,
|
|
95
|
+
phase: "booting"
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
const graph = yield* resolveGraph(stack.members).pipe(Effect.mapError((cause) => new SupervisorBootError({ cause })));
|
|
99
|
+
const hub = yield* Queue.unbounded();
|
|
100
|
+
const commands = yield* Queue.unbounded();
|
|
101
|
+
const queuedCommands = yield* Queue.unbounded();
|
|
102
|
+
const stackRestartTask = yield* Ref.make({ tag: "idle" });
|
|
103
|
+
const stackRestartSeq = yield* Ref.make(0);
|
|
104
|
+
const snapshotCaptureTask = yield* Ref.make({ tag: "idle" });
|
|
105
|
+
const snapshotCaptureSeq = yield* Ref.make(0);
|
|
106
|
+
const shutdownLatch = yield* Ref.make(false);
|
|
107
|
+
const shutdownComplete = yield* Deferred.make();
|
|
108
|
+
const initialAcquireStarted = yield* Ref.make(false);
|
|
109
|
+
const logStore = yield* makeLogStore(options.logStore ?? {});
|
|
110
|
+
const spanStore = yield* makeSpanStore();
|
|
111
|
+
const logger = withEventPublishingLogger(baseLogger, state, hub, logStore);
|
|
112
|
+
const traced = (eff) => Effect.provideService(eff, Tracer.Tracer, spanStore.tracer);
|
|
113
|
+
const registry = yield* buildRegistry(graph, yield* Effect.scope, buildTransitionEmitter(state, hub));
|
|
114
|
+
const controlPlaneDomain = controlPlaneDomainFromContext({
|
|
115
|
+
pluginContext,
|
|
116
|
+
graph,
|
|
117
|
+
registry,
|
|
118
|
+
logStore,
|
|
119
|
+
spanStore
|
|
120
|
+
});
|
|
121
|
+
const pluginRuntimeContext = pluginContext.pipe(Context.add(Logger$1, Logger$1.of(logger)), Context.add(LogStore, LogStore.of(logStore)), Context.add(SpanStore, SpanStore.of(spanStore)), Context.add(Tracer.Tracer, spanStore.tracer), Context.add(ControlPlaneService, ControlPlaneService.of({
|
|
122
|
+
state,
|
|
123
|
+
publishCommand: (command) => Effect.asVoid(Queue.offer(commands, command)),
|
|
124
|
+
domain: controlPlaneDomain
|
|
125
|
+
})));
|
|
126
|
+
for (const [key, node] of graph.nodes) {
|
|
127
|
+
const declaredAccount = pendingAccountProjection(key, node.member.id, Date.now());
|
|
128
|
+
yield* SubscriptionRef.update(state, (s) => ({
|
|
129
|
+
...declaredAccount === null ? s : declareAccount(s, declaredAccount),
|
|
130
|
+
rows: s.rows.some((r) => r.key === key) ? s.rows : [...s.rows, {
|
|
131
|
+
key,
|
|
132
|
+
role: node.member.role,
|
|
133
|
+
status: "pending",
|
|
134
|
+
phase: null,
|
|
135
|
+
lastError: null,
|
|
136
|
+
logTail: {
|
|
137
|
+
lines: [],
|
|
138
|
+
level: "info",
|
|
139
|
+
truncated: false
|
|
140
|
+
},
|
|
141
|
+
endpoints: [],
|
|
142
|
+
selectiveRestartHighlight: false,
|
|
143
|
+
section: node.member.section,
|
|
144
|
+
endpointSection: node.member.endpointSection ?? node.member.section
|
|
145
|
+
}]
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
const runtimeRootResolved = runtimeRootAccess.read(pluginContext, { root: "" });
|
|
149
|
+
if (runtimeRootResolved.root === "") yield* Effect.logWarning("supervisor: RuntimeRoot missing from pluginContext; falling back to empty root. Production wiring must layer `layerRuntimeRoot(...)` into pluginContext.");
|
|
150
|
+
const runtimeRoot = runtimeRootResolved.root;
|
|
151
|
+
const sinksService = yield* sinksAccess.readEffect(pluginRuntimeContext, Effect.gen(function* () {
|
|
152
|
+
return Context.get(yield* Layer.build(layerCapabilitySinksDefault(sinks)), CapabilitySinksService);
|
|
153
|
+
}));
|
|
154
|
+
const enableCommandLoop = options.commandLoop !== false;
|
|
155
|
+
if (enableCommandLoop) {
|
|
156
|
+
yield* Effect.forkScoped(traced(installSignalHandler(commands)));
|
|
157
|
+
yield* Effect.forkScoped(traced(Effect.gen(function* () {
|
|
158
|
+
while (true) {
|
|
159
|
+
const command = yield* Queue.take(commands);
|
|
160
|
+
yield* Queue.offer(queuedCommands, {
|
|
161
|
+
kind: "fire-and-forget",
|
|
162
|
+
command
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
const supervisorState = {
|
|
168
|
+
graph,
|
|
169
|
+
registry,
|
|
170
|
+
ref: state,
|
|
171
|
+
hub,
|
|
172
|
+
queuedCommands,
|
|
173
|
+
stackRestartTask,
|
|
174
|
+
stackRestartSeq,
|
|
175
|
+
snapshotCaptureTask,
|
|
176
|
+
snapshotCaptureSeq,
|
|
177
|
+
shutdownLatch,
|
|
178
|
+
shutdownComplete,
|
|
179
|
+
pluginContext: pluginRuntimeContext,
|
|
180
|
+
sinks: sinksService,
|
|
181
|
+
logger,
|
|
182
|
+
identity,
|
|
183
|
+
runtimeRoot,
|
|
184
|
+
commandHandler,
|
|
185
|
+
postAcquireHook
|
|
186
|
+
};
|
|
187
|
+
const runInitialAcquire = Effect.gen(function* () {
|
|
188
|
+
if (yield* Ref.modify(initialAcquireStarted, (started) => [started, true])) return;
|
|
189
|
+
if (yield* Ref.get(shutdownLatch)) return;
|
|
190
|
+
yield* acquireFullGraph(graph, registry, state, hub, pluginRuntimeContext, sinksService, logger, identity, runtimeRoot);
|
|
191
|
+
if (yield* Ref.get(shutdownLatch)) return;
|
|
192
|
+
if (yield* allReadyOrTerminal(graph, registry)) {
|
|
193
|
+
yield* runPostAcquireHook(supervisorState);
|
|
194
|
+
if (!(yield* Ref.get(shutdownLatch))) yield* setCyclePhase(state, "running");
|
|
195
|
+
} else if (!(yield* Ref.get(shutdownLatch))) yield* setCyclePhase(state, "running");
|
|
196
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.initialAcquire"), traced);
|
|
197
|
+
const watchIndex = buildWatchIndex(graph.nodes);
|
|
198
|
+
const notifyWatchFire = (path) => Effect.gen(function* () {
|
|
199
|
+
const matched = /* @__PURE__ */ new Set();
|
|
200
|
+
for (const entry of watchIndex) for (const pat of entry.paths) if (exactPrefixMatch(pat, path)) {
|
|
201
|
+
matched.add(entry.pluginKey);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (matched.size === 0) return;
|
|
205
|
+
for (const key of matched) yield* Queue.offer(commands, {
|
|
206
|
+
tag: "selective-restart.requested",
|
|
207
|
+
pluginKey: key
|
|
208
|
+
});
|
|
209
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.notifyWatchFire"));
|
|
210
|
+
if (enableCommandLoop) yield* Effect.forkScoped(traced(commandLoop(supervisorState)));
|
|
211
|
+
yield* Effect.addFinalizer(() => traced(Effect.gen(function* () {
|
|
212
|
+
yield* teardownKeys(graph, registry, planFullDrain(graph).teardownOrder).pipe(Effect.catch(() => Effect.void));
|
|
213
|
+
})));
|
|
214
|
+
const awaitShutdown = Deferred.await(shutdownComplete).pipe(Effect.withSpan("lifecycle.supervisor.awaitShutdown"), traced);
|
|
215
|
+
const runCommand = (command) => Effect.gen(function* () {
|
|
216
|
+
const completion = yield* Deferred.make();
|
|
217
|
+
yield* Queue.offer(queuedCommands, {
|
|
218
|
+
kind: "submitted",
|
|
219
|
+
submission: {
|
|
220
|
+
command,
|
|
221
|
+
completion
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const exit = yield* Deferred.await(completion);
|
|
225
|
+
if (Exit.isFailure(exit)) return yield* Effect.failCause(exit.cause);
|
|
226
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.runCommand"), traced);
|
|
227
|
+
return {
|
|
228
|
+
handle: {
|
|
229
|
+
identity,
|
|
230
|
+
graph,
|
|
231
|
+
registry,
|
|
232
|
+
events: hub,
|
|
233
|
+
commands,
|
|
234
|
+
runCommand,
|
|
235
|
+
state,
|
|
236
|
+
watchIndex,
|
|
237
|
+
notifyWatchFire,
|
|
238
|
+
awaitShutdown
|
|
239
|
+
},
|
|
240
|
+
runInitialAcquire
|
|
241
|
+
};
|
|
242
|
+
}).pipe(withStackSpan("lifecycle.supervisor.startSupervisor", {
|
|
243
|
+
app: identity.app,
|
|
244
|
+
stack: identity.stack,
|
|
245
|
+
network: identity.chain
|
|
246
|
+
}));
|
|
247
|
+
//#endregion
|
|
248
|
+
export { startSupervisor };
|
|
249
|
+
|
|
250
|
+
//# sourceMappingURL=start-supervisor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-supervisor.mjs","names":["Logger"],"sources":["../../../../src/substrate/runtime/supervisor/start-supervisor.ts"],"sourcesContent":["// Top-level supervisor entry — composes every per-concern module.\n//\n// Responsibilities (in order):\n// 1. Seed projection identity + booting slice so early-mounted\n// renderers see a complete baseline.\n// 2. Resolve the dep graph + boot the registry.\n// 3. Build the substrate-wiring bag: logger overlay, runtime root,\n// CapabilitySinks service (caller-pre-built or substrate-default).\n// 4. Compose the `SupervisorState` record (one bag passed to every\n// module).\n// 5. Build `runInitialAcquire` — the deferred initial-acquire body.\n// 6. Build the watch index + `notifyWatchFire`.\n// 7. Fork the command loop + signal handler.\n// 8. Install the scope-close finalizer (reverse-dep teardown).\n// 9. Return the handle.\n\nimport {\n\tContext,\n\tDeferred,\n\tEffect,\n\tExit,\n\tLayer,\n\tQueue,\n\tRef,\n\tScope,\n\tSubscriptionRef,\n\tTracer,\n} from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineCommand, EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport type { AccountProjection, SubscribableState } from '../../projection.ts';\nimport {\n\tCapabilitySinksService,\n\tlayerCapabilitySinksDefault,\n\ttype OrchestratorSinks,\n} from '../capability-sinks/index.ts';\nimport {\n\tLogger,\n\tLogStore,\n\tSpanStore,\n\tmakeLogStore,\n\tmakeSpanStore,\n\twithStackSpan,\n\ttype LoggerShape,\n\ttype LogStoreConfig,\n} from '../observability/index.ts';\nimport { ControlPlaneService } from '../control-plane/service.ts';\nimport { controlPlaneDomainFromContext } from '../control-plane/domain.ts';\nimport { RuntimeRoot } from '../paths.ts';\nimport { declareAccount, setIdentity } from '../projection/update.ts';\nimport {\n\tbuildWatchIndex,\n\texactPrefixMatch,\n\tinstallSignalHandler,\n\tplanFullDrain,\n\tresolveGraph,\n\ttype PluginRegistry,\n\ttype ResolvedGraph,\n\ttype UnknownDependency,\n\ttype WatchEntry,\n} from '../lifecycle/index.ts';\nimport { acquireFullGraph, buildRegistry } from './acquire-node.ts';\nimport { commandLoop } from './command-loop.ts';\nimport { runPostAcquireHook } from './background-tasks.ts';\nimport {\n\tSupervisorBootError,\n\ttype SupervisorError,\n\ttype SupervisorPostAcquireFailed,\n} from './errors.ts';\nimport {\n\tallReadyOrTerminal,\n\ttype QueuedCommand,\n\ttype SnapshotCaptureTaskState,\n\ttype StackRestartTaskState,\n\ttype SupervisorCommandHandler,\n\ttype SupervisorPostAcquireHook,\n\ttype SupervisorState,\n} from './state.ts';\nimport type { SupervisedStack } from './types.ts';\nimport { teardownKeys } from './teardown.ts';\nimport {\n\tbuildTransitionEmitter,\n\tnoopLogger,\n\tOptionalService,\n\tsetCyclePhase,\n\twithEventPublishingLogger,\n} from './wiring.ts';\n\nconst loggerAccess = OptionalService(Logger);\nconst runtimeRootAccess = OptionalService(RuntimeRoot);\nconst sinksAccess = OptionalService(CapabilitySinksService);\n\nexport interface SupervisorHandle {\n\treadonly identity: Identity;\n\treadonly graph: ResolvedGraph;\n\treadonly registry: PluginRegistry;\n\treadonly events: Queue.Dequeue<EngineEvent>;\n\treadonly commands: Queue.Enqueue<EngineCommand>;\n\treadonly runCommand: (command: EngineCommand) => Effect.Effect<void, unknown>;\n\treadonly state: SubscriptionRef.SubscriptionRef<SubscribableState>;\n\treadonly watchIndex: ReadonlyArray<WatchEntry>;\n\t/** Fire a watch event for the given path. Substrate-level glue:\n\t * the thick L0 watcher calls this; tests call it directly. */\n\treadonly notifyWatchFire: (path: string) => Effect.Effect<void>;\n\t/** Block until the supervisor's command loop sets the shutdown\n\t * latch. The outer runtime then closes the supervisor scope, which\n\t * tears down every plugin in reverse-dep order. */\n\treadonly awaitShutdown: Effect.Effect<void>;\n}\n\nexport interface SupervisorStartup {\n\treadonly handle: SupervisorHandle;\n\treadonly runInitialAcquire: Effect.Effect<void, SupervisorPostAcquireFailed, never>;\n}\n\nexport interface SupervisorStartupOptions {\n\treadonly commandLoop?: boolean;\n\t/** Per-service log-store tuning. Absent fields fall back to the\n\t * `DEVSTACK_DASHBOARD_LOG_*` env vars, then the module defaults\n\t * (2000 records/service, 256 services). Threaded into the\n\t * process-scoped `makeLogStore` below. */\n\treadonly logStore?: LogStoreConfig;\n}\n\nconst pendingAccountProjection = (\n\trowKey: PluginKey,\n\tresourceId: string,\n\tupdatedAt: number,\n): AccountProjection | null => {\n\tif (!resourceId.startsWith('account/')) return null;\n\tconst name = resourceId.slice('account/'.length);\n\tif (name.length === 0) return null;\n\treturn {\n\t\tkey: resourceId as `account/${string}`,\n\t\trowKey,\n\t\tname,\n\t\taddress: null,\n\t\tscheme: null,\n\t\tsource: null,\n\t\tfunding: { status: 'pending', balanceMist: null, requestedMist: null, entries: [] },\n\t\twalletVisible: false,\n\t\tupdatedAt,\n\t};\n};\n\n/**\n * Prepare a supervisor for `stack` without running the initial acquire.\n * The returned `SupervisorHandle` is Scope-managed; the supervisor's\n * lifecycle is the surrounding Scope's lifecycle. Signal handlers,\n * the command loop, and every plugin's scope are children of the\n * supervisor scope. Callers that mount renderers can subscribe to the\n * returned state before invoking `runInitialAcquire`.\n *\n * `pluginContext` carries the substrate-context services available to\n * each plugin's `acquire` body (`IdentityContext`,\n * `ContainerRuntimeService`, `RuntimeRoot`, `StackPathsService`, etc.).\n * Plugins declare what they need by yielding the corresponding\n * `Context.Service` tag from within `Effect.gen`; the supervisor\n * provides this context before running the acquire effect so the\n * plugin's R-channel narrows to `Scope.Scope` (then to `never` after\n * the per-plugin Scope is provided).\n *\n * `CapabilitySinksService` extension (ARCHITECTURE.md § Plugin-author\n * extension via Layer composition): if the caller layers a\n * `CapabilitySinksService` into `pluginContext`, the supervisor\n * harvests through THAT instance instead of building its own.\n */\nexport const startSupervisor = (\n\tstack: SupervisedStack,\n\tidentity: Identity,\n\tstate: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\tpluginContext: Context.Context<never> = Context.empty(),\n\tsinks: OrchestratorSinks = [],\n\tcommandHandler?: SupervisorCommandHandler,\n\tpostAcquireHook?: SupervisorPostAcquireHook,\n\toptions: SupervisorStartupOptions = {},\n): Effect.Effect<SupervisorStartup, SupervisorBootError | UnknownDependency, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tyield* Effect.annotateCurrentSpan({\n\t\t\t'devstack.stack.memberCount': stack.members.length,\n\t\t});\n\n\t\t// Optional Logger service — pull from the plugin context if the\n\t\t// caller layered it in (CLI / e2e do). Bare smoke tests get the\n\t\t// no-op fallback so they remain log-free.\n\t\tconst baseLogger: LoggerShape = loggerAccess.read(pluginContext, noopLogger);\n\n\t\tyield* baseLogger.log('supervisor', null, {\n\t\t\tlevel: 'debug',\n\t\t\tmessage: 'supervisor boot start',\n\t\t\tfields: {\n\t\t\t\tapp: identity.app,\n\t\t\t\tstack: identity.stack,\n\t\t\t\tnetwork: identity.chain,\n\t\t\t\tmemberCount: stack.members.length,\n\t\t\t},\n\t\t});\n\n\t\t// Seed the projection's identity and booting slices before\n\t\t// acquire starts so renderers mounting early have a complete\n\t\t// baseline.\n\t\tyield* SubscriptionRef.update(\n\t\t\tstate,\n\t\t\t(s) =>\n\t\t\t\t({\n\t\t\t\t\t...setIdentity(s, {\n\t\t\t\t\t\tapp: identity.app,\n\t\t\t\t\t\tstack: identity.stack,\n\t\t\t\t\t\tnetwork: identity.chain,\n\t\t\t\t\t}),\n\t\t\t\t\tcycle: {\n\t\t\t\t\t\t...s.cycle,\n\t\t\t\t\t\tstartedAt: s.cycle.startedAt === 0 ? Date.now() : s.cycle.startedAt,\n\t\t\t\t\t\tphase: 'booting',\n\t\t\t\t\t},\n\t\t\t\t}) satisfies SubscribableState,\n\t\t);\n\n\t\t// Resolve the dep graph.\n\t\tconst graph = yield* resolveGraph(stack.members).pipe(\n\t\t\tEffect.mapError((cause) => new SupervisorBootError({ cause })),\n\t\t);\n\n\t\t// Event hub + command channel.\n\t\tconst hub = yield* Queue.unbounded<EngineEvent>();\n\t\tconst commands = yield* Queue.unbounded<EngineCommand>();\n\t\tconst queuedCommands = yield* Queue.unbounded<QueuedCommand>();\n\t\tconst stackRestartTask = yield* Ref.make<StackRestartTaskState>({ tag: 'idle' });\n\t\tconst stackRestartSeq = yield* Ref.make(0);\n\t\tconst snapshotCaptureTask = yield* Ref.make<SnapshotCaptureTaskState>({ tag: 'idle' });\n\t\tconst snapshotCaptureSeq = yield* Ref.make(0);\n\t\tconst shutdownLatch = yield* Ref.make(false);\n\t\tconst shutdownComplete = yield* Deferred.make<void>();\n\t\tconst initialAcquireStarted = yield* Ref.make(false);\n\n\t\t// Observability stores (process-scoped, like `state`/`hub`): a\n\t\t// cross-service queryable log ring fed off the SAME logger path that\n\t\t// feeds the projection's per-row tail, and a completed-span ring fed\n\t\t// by a recording Tracer. Both survive `stack.restart` because they\n\t\t// live in this closure (only `cycle.id` bumps on restart). The\n\t\t// dashboard reads them via the control-plane `domain`.\n\t\tconst logStore = yield* makeLogStore(options.logStore ?? {});\n\t\tconst spanStore = yield* makeSpanStore();\n\t\tconst logger = withEventPublishingLogger(baseLogger, state, hub, logStore);\n\n\t\t// Provide the recording Tracer to the supervisor's OWN effects too.\n\t\t// `pluginRuntimeContext` below carries the tracer into plugin\n\t\t// acquire/boot, but the supervisor's forked fibers (command loop,\n\t\t// background snapshot/restart tasks), the teardown finalizer, and the\n\t\t// `lifecycle.supervisor.*` spans run under THIS fiber's ambient context\n\t\t// — which has no tracer unless we add one. Without this, exactly the\n\t\t// dashboard-triggered ops (restart/snapshot/prune) the Traces tab wants\n\t\t// would emit spans into the default no-op tracer and evaporate.\n\t\t// `forkScoped`/finalizers inherit the context at fork/install time, so\n\t\t// stamping the tracer onto each supervisor-owned effect captures them\n\t\t// without double-provisioning the plugin path or disturbing any\n\t\t// caller-provided OTel composition.\n\t\tconst traced = <A, E, R>(eff: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n\t\t\tEffect.provideService(eff, Tracer.Tracer, spanStore.tracer);\n\n\t\t// Per-plugin scopes parent off the supervisor scope.\n\t\tconst supervisorScope = yield* Effect.scope;\n\n\t\tconst emit = buildTransitionEmitter(state, hub);\n\t\tconst registry = yield* buildRegistry(graph, supervisorScope, emit);\n\n\t\t// Build the control-plane `domain` accessor surface from the data\n\t\t// the supervisor holds at wiring time: the resolved registry +\n\t\t// graph, plus the (optional) snapshot orchestrator / container\n\t\t// runtime / filesystem the caller may have layered into\n\t\t// `pluginContext`. The projection stays CLOSED — `domain` reads\n\t\t// resolved plugin VALUES via the name-blind registry seam, never\n\t\t// the projection. The registry is process-scoped, so the closure\n\t\t// stays valid across `stack.restart` (only `cycle.id` bumps).\n\t\tconst controlPlaneDomain = controlPlaneDomainFromContext({\n\t\t\tpluginContext,\n\t\t\tgraph,\n\t\t\tregistry,\n\t\t\tlogStore,\n\t\t\tspanStore,\n\t\t});\n\n\t\tconst pluginRuntimeContext = pluginContext.pipe(\n\t\t\tContext.add(Logger, Logger.of(logger)),\n\t\t\t// Observability stores + the recording Tracer. The Tracer is an\n\t\t\t// Effect `Context.Reference`, so adding it here makes every span\n\t\t\t// run with this context (all plugin acquire/boot/op spans —\n\t\t\t// `withSpan`/`spanWithLabels`) record into `spanStore` instead of\n\t\t\t// hitting the default no-op native tracer. The stores themselves\n\t\t\t// are exposed so the control-plane `domain` can query them.\n\t\t\tContext.add(LogStore, LogStore.of(logStore)),\n\t\t\tContext.add(SpanStore, SpanStore.of(spanStore)),\n\t\t\tContext.add(Tracer.Tracer, spanStore.tracer),\n\t\t\t// Expose the control plane (live projection + fire-and-forget\n\t\t\t// command dispatch + the plugin-domain accessor surface) to\n\t\t\t// in-process surfaces like the dashboard plugin. Reads the same\n\t\t\t// `state` ref and `commands` queue the supervisor itself drives.\n\t\t\tContext.add(\n\t\t\t\tControlPlaneService,\n\t\t\t\tControlPlaneService.of({\n\t\t\t\t\tstate,\n\t\t\t\t\tpublishCommand: (command) => Effect.asVoid(Queue.offer(commands, command)),\n\t\t\t\t\tdomain: controlPlaneDomain,\n\t\t\t\t}),\n\t\t\t),\n\t\t) as Context.Context<never>;\n\n\t\t// Declare a row for every plugin so the projection's\n\t\t// `lifecycle.statusChanged` events have a row to attach to.\n\t\t// `section` is plugin-declared at `definePlugin({ section })`\n\t\t// time; we stamp it onto the row here so the TUI groups rows\n\t\t// without pattern-matching on plugin-name substrings.\n\t\tfor (const [key, node] of graph.nodes) {\n\t\t\tconst declaredAccount = pendingAccountProjection(key, node.member.id, Date.now());\n\t\t\tyield* SubscriptionRef.update(state, (s) => ({\n\t\t\t\t...(declaredAccount === null ? s : declareAccount(s, declaredAccount)),\n\t\t\t\trows: s.rows.some((r) => r.key === key)\n\t\t\t\t\t? s.rows\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...s.rows,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\trole: node.member.role,\n\t\t\t\t\t\t\t\tstatus: 'pending' as LifecycleStatus,\n\t\t\t\t\t\t\t\tphase: null,\n\t\t\t\t\t\t\t\tlastError: null,\n\t\t\t\t\t\t\t\tlogTail: { lines: [], level: 'info' as const, truncated: false },\n\t\t\t\t\t\t\t\tendpoints: [],\n\t\t\t\t\t\t\t\tselectiveRestartHighlight: false,\n\t\t\t\t\t\t\t\tsection: node.member.section,\n\t\t\t\t\t\t\t\tendpointSection: node.member.endpointSection ?? node.member.section,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t}));\n\t\t}\n\n\t\t// Extract `RuntimeRoot` from the plugin context — needed to\n\t\t// build the `AcquireContext` handed to dynamic capability\n\t\t// factories. Fallback to '' for bare smoke tests that don't\n\t\t// wire RuntimeRoot; emit a logWarning when that path fires so\n\t\t// production-style misconfigurations are visible (plugins\n\t\t// computing `${runtimeRoot}/foo` would otherwise silently\n\t\t// resolve to host-filesystem root).\n\t\tconst runtimeRootResolved = runtimeRootAccess.read(pluginContext, { root: '' });\n\t\tif (runtimeRootResolved.root === '') {\n\t\t\tyield* Effect.logWarning(\n\t\t\t\t'supervisor: RuntimeRoot missing from pluginContext; falling back to empty root. ' +\n\t\t\t\t\t'Production wiring must layer `layerRuntimeRoot(...)` into pluginContext.',\n\t\t\t);\n\t\t}\n\t\tconst runtimeRoot = runtimeRootResolved.root;\n\n\t\t// Resolve the CapabilitySinks registry for this stack. Two paths:\n\t\t//\n\t\t// (a) Plugin-author / orchestrator pre-built path: the caller\n\t\t// layered a `CapabilitySinksService` into `pluginContext`\n\t\t// (typically by composing `layerCapabilitySinksDefault(...)`\n\t\t// PLUS one or more custom-sink Layers). The supervisor\n\t\t// harvests through THAT instance, so custom sinks\n\t\t// registered by plugin authors actually fire.\n\t\t//\n\t\t// (b) Bare path: no service in context — the supervisor builds\n\t\t// the substrate default with the orchestrator sinks passed\n\t\t// in. `Layer.build` opens the layer's resources on the\n\t\t// SURROUNDING scope (the supervisor's), so the sinks +\n\t\t// formatter registry live for the supervisor's lifetime\n\t\t// and reap on its scope close.\n\t\tconst sinksService = yield* sinksAccess.readEffect(\n\t\t\tpluginRuntimeContext,\n\t\t\tEffect.gen(function* () {\n\t\t\t\treturn Context.get(\n\t\t\t\t\tyield* Layer.build(layerCapabilitySinksDefault(sinks)),\n\t\t\t\t\tCapabilitySinksService,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\n\t\tconst enableCommandLoop = options.commandLoop !== false;\n\t\tif (enableCommandLoop) {\n\t\t\tyield* Effect.forkScoped(traced(installSignalHandler(commands)));\n\t\t\tyield* Effect.forkScoped(\n\t\t\t\ttraced(\n\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\tconst command = yield* Queue.take(commands);\n\t\t\t\t\t\t\tyield* Queue.offer(queuedCommands, { kind: 'fire-and-forget', command });\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst supervisorState: SupervisorState = {\n\t\t\tgraph,\n\t\t\tregistry,\n\t\t\tref: state,\n\t\t\thub,\n\t\t\tqueuedCommands,\n\t\t\tstackRestartTask,\n\t\t\tstackRestartSeq,\n\t\t\tsnapshotCaptureTask,\n\t\t\tsnapshotCaptureSeq,\n\t\t\tshutdownLatch,\n\t\t\tshutdownComplete,\n\t\t\tpluginContext: pluginRuntimeContext,\n\t\t\tsinks: sinksService,\n\t\t\tlogger,\n\t\t\tidentity,\n\t\t\truntimeRoot,\n\t\t\tcommandHandler,\n\t\t\tpostAcquireHook,\n\t\t};\n\n\t\tconst runInitialAcquire = Effect.gen(function* () {\n\t\t\tconst alreadyStarted = yield* Ref.modify(initialAcquireStarted, (started) => [started, true]);\n\t\t\tif (alreadyStarted) return;\n\t\t\tif (yield* Ref.get(shutdownLatch)) return;\n\t\t\tyield* acquireFullGraph(\n\t\t\t\tgraph,\n\t\t\t\tregistry,\n\t\t\t\tstate,\n\t\t\t\thub,\n\t\t\t\tpluginRuntimeContext,\n\t\t\t\tsinksService,\n\t\t\t\tlogger,\n\t\t\t\tidentity,\n\t\t\t\truntimeRoot,\n\t\t\t);\n\t\t\tif (yield* Ref.get(shutdownLatch)) return;\n\t\t\tconst initialReady = yield* allReadyOrTerminal(graph, registry);\n\t\t\tif (initialReady) {\n\t\t\t\tyield* runPostAcquireHook(supervisorState);\n\t\t\t\tif (!(yield* Ref.get(shutdownLatch))) {\n\t\t\t\t\tyield* setCyclePhase(state, 'running');\n\t\t\t\t}\n\t\t\t} else if (!(yield* Ref.get(shutdownLatch))) {\n\t\t\t\tyield* setCyclePhase(state, 'running');\n\t\t\t}\n\t\t}).pipe(Effect.withSpan('lifecycle.supervisor.initialAcquire'), traced);\n\n\t\t// Build the watch index up front; the supervisor exposes\n\t\t// `notifyWatchFire` so the L0 thick watcher can call into it.\n\t\tconst watchIndex = buildWatchIndex(graph.nodes);\n\n\t\tconst notifyWatchFire = (path: string): Effect.Effect<void> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst matched = new Set<PluginKey>();\n\t\t\t\tfor (const entry of watchIndex) {\n\t\t\t\t\tfor (const pat of entry.paths) {\n\t\t\t\t\t\tif (exactPrefixMatch(pat, path)) {\n\t\t\t\t\t\t\tmatched.add(entry.pluginKey);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (matched.size === 0) return;\n\t\t\t\t// One `selective-restart.requested` per matched plugin, in\n\t\t\t\t// match order. (Previously the head was offered separately\n\t\t\t\t// from the tail — identical behaviour, one fewer branch.)\n\t\t\t\tfor (const key of matched) {\n\t\t\t\t\tyield* Queue.offer(commands, {\n\t\t\t\t\t\ttag: 'selective-restart.requested',\n\t\t\t\t\t\tpluginKey: key,\n\t\t\t\t\t} satisfies EngineCommand);\n\t\t\t\t}\n\t\t\t}).pipe(Effect.withSpan('lifecycle.supervisor.notifyWatchFire'));\n\n\t\t// Fork the command loop.\n\t\tif (enableCommandLoop) {\n\t\t\tyield* Effect.forkScoped(traced(commandLoop(supervisorState)));\n\t\t}\n\n\t\t// Tear-down finalizer: closes every plugin scope in reverse-dep\n\t\t// order. The supervisor scope itself closes when the surrounding\n\t\t// caller closes — `Scope.close` cascades to plugin scopes.\n\t\tyield* Effect.addFinalizer(() =>\n\t\t\ttraced(\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst plan = planFullDrain(graph);\n\t\t\t\t\tyield* teardownKeys(graph, registry, plan.teardownOrder).pipe(\n\t\t\t\t\t\tEffect.catch(() => Effect.void),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\n\t\tconst awaitShutdown: Effect.Effect<void> = Deferred.await(shutdownComplete).pipe(\n\t\t\tEffect.withSpan('lifecycle.supervisor.awaitShutdown'),\n\t\t\ttraced,\n\t\t);\n\n\t\tconst runCommand = (command: EngineCommand): Effect.Effect<void, unknown> =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst completion = yield* Deferred.make<Exit.Exit<void, unknown>>();\n\t\t\t\tyield* Queue.offer(queuedCommands, {\n\t\t\t\t\tkind: 'submitted',\n\t\t\t\t\tsubmission: { command, completion },\n\t\t\t\t});\n\t\t\t\tconst exit = yield* Deferred.await(completion);\n\t\t\t\tif (Exit.isFailure(exit)) {\n\t\t\t\t\treturn yield* Effect.failCause(exit.cause);\n\t\t\t\t}\n\t\t\t}).pipe(Effect.withSpan('lifecycle.supervisor.runCommand'), traced);\n\n\t\tconst handle = {\n\t\t\tidentity,\n\t\t\tgraph,\n\t\t\tregistry,\n\t\t\tevents: hub,\n\t\t\tcommands,\n\t\t\trunCommand,\n\t\t\tstate,\n\t\t\twatchIndex,\n\t\t\tnotifyWatchFire,\n\t\t\tawaitShutdown,\n\t\t} satisfies SupervisorHandle;\n\t\treturn { handle, runInitialAcquire } satisfies SupervisorStartup;\n\t}).pipe(\n\t\twithStackSpan('lifecycle.supervisor.startSupervisor', {\n\t\t\tapp: identity.app,\n\t\t\tstack: identity.stack,\n\t\t\tnetwork: identity.chain,\n\t\t}),\n\t);\n\n/**\n * Boot a supervisor for `stack` and wait for the initial acquire to\n * finish before returning the handle. Existing callers that only need\n * a ready-or-failed handle keep this simpler entry point; live surfaces\n * that need startup display use `startSupervisor`.\n */\nexport const supervise = (\n\tstack: SupervisedStack,\n\tidentity: Identity,\n\tstate: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\tpluginContext: Context.Context<never> = Context.empty(),\n\tsinks: OrchestratorSinks = [],\n\tcommandHandler?: SupervisorCommandHandler,\n\tpostAcquireHook?: SupervisorPostAcquireHook,\n): Effect.Effect<SupervisorHandle, SupervisorError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst startup = yield* startSupervisor(\n\t\t\tstack,\n\t\t\tidentity,\n\t\t\tstate,\n\t\t\tpluginContext,\n\t\t\tsinks,\n\t\t\tcommandHandler,\n\t\t\tpostAcquireHook,\n\t\t\t{ commandLoop: true },\n\t\t);\n\t\tyield* startup.runInitialAcquire;\n\t\treturn startup.handle;\n\t}).pipe(\n\t\twithStackSpan('lifecycle.supervisor.supervise', {\n\t\t\tapp: identity.app,\n\t\t\tstack: identity.stack,\n\t\t\tnetwork: identity.chain,\n\t\t}),\n\t);\n\n/**\n * Block until the supervisor's shutdown latch fires OR the surrounding\n * scope is interrupted (signal-driven exit). Wraps `awaitShutdown` for\n * the common \"boot then wait\" shape.\n *\n * Returns the final supervisor state so callers (CLI, programmable\n * API) can inspect the projection after shutdown.\n */\nexport const runToShutdown = (\n\thandle: SupervisorHandle,\n): Effect.Effect<SubscribableState, never, never> =>\n\tEffect.gen(function* () {\n\t\tyield* handle.awaitShutdown;\n\t\treturn yield* SubscriptionRef.get(handle.state);\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.runToShutdown'));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,MAAM,eAAe,gBAAgBA,SAAO;AAC5C,MAAM,oBAAoB,gBAAgB,YAAY;AACtD,MAAM,cAAc,gBAAgB,uBAAuB;AAkC3D,MAAM,4BACL,QACA,YACA,cAC8B;AAC9B,KAAI,CAAC,WAAW,WAAW,WAAW,CAAE,QAAO;CAC/C,MAAM,OAAO,WAAW,MAAM,EAAkB;AAChD,KAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAO;EACN,KAAK;EACL;EACA;EACA,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS;GAAE,QAAQ;GAAW,aAAa;GAAM,eAAe;GAAM,SAAS,EAAE;GAAE;EACnF,eAAe;EACf;EACA;;;;;;;;;;;;;;;;;;;;;;;;AAyBF,MAAa,mBACZ,OACA,UACA,OACA,gBAAwC,QAAQ,OAAO,EACvD,QAA2B,EAAE,EAC7B,gBACA,iBACA,UAAoC,EAAE,KAEtC,OAAO,IAAI,aAAa;AACvB,QAAO,OAAO,oBAAoB,EACjC,8BAA8B,MAAM,QAAQ,QAC5C,CAAC;CAKF,MAAM,aAA0B,aAAa,KAAK,eAAe,WAAW;AAE5E,QAAO,WAAW,IAAI,cAAc,MAAM;EACzC,OAAO;EACP,SAAS;EACT,QAAQ;GACP,KAAK,SAAS;GACd,OAAO,SAAS;GAChB,SAAS,SAAS;GAClB,aAAa,MAAM,QAAQ;GAC3B;EACD,CAAC;AAKF,QAAO,gBAAgB,OACtB,QACC,OACC;EACA,GAAG,YAAY,GAAG;GACjB,KAAK,SAAS;GACd,OAAO,SAAS;GAChB,SAAS,SAAS;GAClB,CAAC;EACF,OAAO;GACN,GAAG,EAAE;GACL,WAAW,EAAE,MAAM,cAAc,IAAI,KAAK,KAAK,GAAG,EAAE,MAAM;GAC1D,OAAO;GACP;EACD,EACF;CAGD,MAAM,QAAQ,OAAO,aAAa,MAAM,QAAQ,CAAC,KAChD,OAAO,UAAU,UAAU,IAAI,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAC9D;CAGD,MAAM,MAAM,OAAO,MAAM,WAAwB;CACjD,MAAM,WAAW,OAAO,MAAM,WAA0B;CACxD,MAAM,iBAAiB,OAAO,MAAM,WAA0B;CAC9D,MAAM,mBAAmB,OAAO,IAAI,KAA4B,EAAE,KAAK,QAAQ,CAAC;CAChF,MAAM,kBAAkB,OAAO,IAAI,KAAK,EAAE;CAC1C,MAAM,sBAAsB,OAAO,IAAI,KAA+B,EAAE,KAAK,QAAQ,CAAC;CACtF,MAAM,qBAAqB,OAAO,IAAI,KAAK,EAAE;CAC7C,MAAM,gBAAgB,OAAO,IAAI,KAAK,MAAM;CAC5C,MAAM,mBAAmB,OAAO,SAAS,MAAY;CACrD,MAAM,wBAAwB,OAAO,IAAI,KAAK,MAAM;CAQpD,MAAM,WAAW,OAAO,aAAa,QAAQ,YAAY,EAAE,CAAC;CAC5D,MAAM,YAAY,OAAO,eAAe;CACxC,MAAM,SAAS,0BAA0B,YAAY,OAAO,KAAK,SAAS;CAc1E,MAAM,UAAmB,QACxB,OAAO,eAAe,KAAK,OAAO,QAAQ,UAAU,OAAO;CAM5D,MAAM,WAAW,OAAO,cAAc,OAAO,OAHd,OAAO,OAEzB,uBAAuB,OAAO,IACuB,CAAC;CAUnE,MAAM,qBAAqB,8BAA8B;EACxD;EACA;EACA;EACA;EACA;EACA,CAAC;CAEF,MAAM,uBAAuB,cAAc,KAC1C,QAAQ,IAAIA,UAAQA,SAAO,GAAG,OAAO,CAAC,EAOtC,QAAQ,IAAI,UAAU,SAAS,GAAG,SAAS,CAAC,EAC5C,QAAQ,IAAI,WAAW,UAAU,GAAG,UAAU,CAAC,EAC/C,QAAQ,IAAI,OAAO,QAAQ,UAAU,OAAO,EAK5C,QAAQ,IACP,qBACA,oBAAoB,GAAG;EACtB;EACA,iBAAiB,YAAY,OAAO,OAAO,MAAM,MAAM,UAAU,QAAQ,CAAC;EAC1E,QAAQ;EACR,CAAC,CACF,CACD;AAOD,MAAK,MAAM,CAAC,KAAK,SAAS,MAAM,OAAO;EACtC,MAAM,kBAAkB,yBAAyB,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,CAAC;AACjF,SAAO,gBAAgB,OAAO,QAAQ,OAAO;GAC5C,GAAI,oBAAoB,OAAO,IAAI,eAAe,GAAG,gBAAgB;GACrE,MAAM,EAAE,KAAK,MAAM,MAAM,EAAE,QAAQ,IAAI,GACpC,EAAE,OACF,CACA,GAAG,EAAE,MACL;IACC;IACA,MAAM,KAAK,OAAO;IAClB,QAAQ;IACR,OAAO;IACP,WAAW;IACX,SAAS;KAAE,OAAO,EAAE;KAAE,OAAO;KAAiB,WAAW;KAAO;IAChE,WAAW,EAAE;IACb,2BAA2B;IAC3B,SAAS,KAAK,OAAO;IACrB,iBAAiB,KAAK,OAAO,mBAAmB,KAAK,OAAO;IAC5D,CACD;GACH,EAAE;;CAUJ,MAAM,sBAAsB,kBAAkB,KAAK,eAAe,EAAE,MAAM,IAAI,CAAC;AAC/E,KAAI,oBAAoB,SAAS,GAChC,QAAO,OAAO,WACb,2JAEA;CAEF,MAAM,cAAc,oBAAoB;CAiBxC,MAAM,eAAe,OAAO,YAAY,WACvC,sBACA,OAAO,IAAI,aAAa;AACvB,SAAO,QAAQ,IACd,OAAO,MAAM,MAAM,4BAA4B,MAAM,CAAC,EACtD,uBACA;GACA,CACF;CAED,MAAM,oBAAoB,QAAQ,gBAAgB;AAClD,KAAI,mBAAmB;AACtB,SAAO,OAAO,WAAW,OAAO,qBAAqB,SAAS,CAAC,CAAC;AAChE,SAAO,OAAO,WACb,OACC,OAAO,IAAI,aAAa;AACvB,UAAO,MAAM;IACZ,MAAM,UAAU,OAAO,MAAM,KAAK,SAAS;AAC3C,WAAO,MAAM,MAAM,gBAAgB;KAAE,MAAM;KAAmB;KAAS,CAAC;;IAExE,CACF,CACD;;CAGF,MAAM,kBAAmC;EACxC;EACA;EACA,KAAK;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;CAED,MAAM,oBAAoB,OAAO,IAAI,aAAa;AAEjD,MAAI,OAD0B,IAAI,OAAO,wBAAwB,YAAY,CAAC,SAAS,KAAK,CAAC,CACzE;AACpB,MAAI,OAAO,IAAI,IAAI,cAAc,CAAE;AACnC,SAAO,iBACN,OACA,UACA,OACA,KACA,sBACA,cACA,QACA,UACA,YACA;AACD,MAAI,OAAO,IAAI,IAAI,cAAc,CAAE;AAEnC,MAAI,OADwB,mBAAmB,OAAO,SAAS,EAC7C;AACjB,UAAO,mBAAmB,gBAAgB;AAC1C,OAAI,EAAE,OAAO,IAAI,IAAI,cAAc,EAClC,QAAO,cAAc,OAAO,UAAU;aAE7B,EAAE,OAAO,IAAI,IAAI,cAAc,EACzC,QAAO,cAAc,OAAO,UAAU;GAEtC,CAAC,KAAK,OAAO,SAAS,sCAAsC,EAAE,OAAO;CAIvE,MAAM,aAAa,gBAAgB,MAAM,MAAM;CAE/C,MAAM,mBAAmB,SACxB,OAAO,IAAI,aAAa;EACvB,MAAM,0BAAU,IAAI,KAAgB;AACpC,OAAK,MAAM,SAAS,WACnB,MAAK,MAAM,OAAO,MAAM,MACvB,KAAI,iBAAiB,KAAK,KAAK,EAAE;AAChC,WAAQ,IAAI,MAAM,UAAU;AAC5B;;AAIH,MAAI,QAAQ,SAAS,EAAG;AAIxB,OAAK,MAAM,OAAO,QACjB,QAAO,MAAM,MAAM,UAAU;GAC5B,KAAK;GACL,WAAW;GACX,CAAyB;GAE1B,CAAC,KAAK,OAAO,SAAS,uCAAuC,CAAC;AAGjE,KAAI,kBACH,QAAO,OAAO,WAAW,OAAO,YAAY,gBAAgB,CAAC,CAAC;AAM/D,QAAO,OAAO,mBACb,OACC,OAAO,IAAI,aAAa;AAEvB,SAAO,aAAa,OAAO,UADd,cAAc,MACc,CAAC,cAAc,CAAC,KACxD,OAAO,YAAY,OAAO,KAAK,CAC/B;GACA,CACF,CACD;CAED,MAAM,gBAAqC,SAAS,MAAM,iBAAiB,CAAC,KAC3E,OAAO,SAAS,qCAAqC,EACrD,OACA;CAED,MAAM,cAAc,YACnB,OAAO,IAAI,aAAa;EACvB,MAAM,aAAa,OAAO,SAAS,MAAgC;AACnE,SAAO,MAAM,MAAM,gBAAgB;GAClC,MAAM;GACN,YAAY;IAAE;IAAS;IAAY;GACnC,CAAC;EACF,MAAM,OAAO,OAAO,SAAS,MAAM,WAAW;AAC9C,MAAI,KAAK,UAAU,KAAK,CACvB,QAAO,OAAO,OAAO,UAAU,KAAK,MAAM;GAE1C,CAAC,KAAK,OAAO,SAAS,kCAAkC,EAAE,OAAO;AAcpE,QAAO;EAAE,QAAA;GAXR;GACA;GACA;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;GACA;GAEc;EAAE;EAAmB;EACnC,CAAC,KACF,cAAc,wCAAwC;CACrD,KAAK,SAAS;CACd,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB,CAAC,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Context, Deferred, Effect, Exit, Fiber, Queue, Ref, SubscriptionRef } from "effect";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "../capability-sinks/index.mjs";
|
|
2
|
+
import { isReadyOrTerminal } from "../lifecycle/state-machine.mjs";
|
|
3
|
+
import "../lifecycle/index.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
//#region src/substrate/runtime/supervisor/state.ts
|
|
6
|
+
/**
|
|
7
|
+
* True when every node in `graph` has reached a `ready`-or-terminal
|
|
8
|
+
* lifecycle status. Used by the command-loop to gate the post-acquire
|
|
9
|
+
* hook after a (selective) restart and by the initial-acquire path to
|
|
10
|
+
* decide whether to transition the cycle phase to `running`.
|
|
11
|
+
*
|
|
12
|
+
* Failed status reads collapse to `'failed'` so a transient registry
|
|
13
|
+
* error doesn't block the readiness gate forever.
|
|
14
|
+
*/
|
|
15
|
+
const allReadyOrTerminal = (graph, registry) => Effect.gen(function* () {
|
|
16
|
+
for (const key of graph.nodes.keys()) if (!isReadyOrTerminal(yield* registry.getStatus(key).pipe(Effect.catch(() => Effect.succeed("failed"))))) return false;
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
export { allReadyOrTerminal };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=state.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/state.ts"],"sourcesContent":["// Supervisor shared-state record.\n//\n// `startSupervisor`'s `Effect.gen` body closes over ~20 locals. Rather\n// than thread each one through every helper individually, we group\n// them into a typed bag here so the per-concern modules (command-loop,\n// background-tasks, shutdown) take ONE argument.\n//\n// The shape originated as `CommandLoopDeps`; the split renames it and\n// extends with the post-acquire context (graph, registry, identity,\n// runtimeRoot) so the same record satisfies every module's needs.\n\nimport {\n\tEffect,\n\ttype Context,\n\ttype Deferred,\n\ttype Exit,\n\ttype Fiber,\n\ttype Queue,\n\ttype Ref,\n\ttype SubscriptionRef,\n} from 'effect';\n\nimport type { EngineCommand, EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport { type CapabilitySinksShape } from '../capability-sinks/index.ts';\nimport { isReadyOrTerminal } from '../lifecycle/index.ts';\nimport type { LoggerShape } from '../observability/index.ts';\nimport type { PluginRegistry, ResolvedGraph } from '../lifecycle/index.ts';\n\nexport type StackRestartTaskState =\n\t| { readonly tag: 'idle' }\n\t| { readonly tag: 'starting'; readonly token: number }\n\t| {\n\t\t\treadonly tag: 'running';\n\t\t\treadonly token: number;\n\t\t\treadonly fiber: Fiber.Fiber<void, never>;\n\t };\n\nexport type SnapshotCaptureTaskState =\n\t| { readonly tag: 'idle' }\n\t| { readonly tag: 'starting'; readonly token: number; readonly snapshotId: string | null }\n\t| {\n\t\t\treadonly tag: 'running';\n\t\t\treadonly token: number;\n\t\t\treadonly snapshotId: string | null;\n\t\t\treadonly fiber: Fiber.Fiber<void, never>;\n\t };\n\nexport interface SupervisorCommandHandlerContext {\n\treadonly publish: (event: EngineEvent) => Effect.Effect<void, never, never>;\n}\n\nexport type SupervisorCommandHandler = (\n\tcmd: EngineCommand,\n\tctx: SupervisorCommandHandlerContext,\n) => Effect.Effect<ReadonlyArray<EngineEvent>, unknown, never>;\n\nexport interface SupervisorPostAcquireContext {\n\treadonly graph: ResolvedGraph;\n\treadonly registry: PluginRegistry;\n\treadonly identity: Identity;\n\treadonly runtimeRoot: string;\n}\n\nexport type SupervisorPostAcquireHook = (\n\tctx: SupervisorPostAcquireContext,\n) => Effect.Effect<ReadonlyArray<EngineEvent>, unknown, never>;\n\nexport interface CommandSubmission {\n\treadonly command: EngineCommand;\n\treadonly completion: Deferred.Deferred<Exit.Exit<void, unknown>>;\n}\n\nexport type QueuedCommand =\n\t| { readonly kind: 'fire-and-forget'; readonly command: EngineCommand }\n\t| { readonly kind: 'submitted'; readonly submission: CommandSubmission };\n\n/**\n * True when every node in `graph` has reached a `ready`-or-terminal\n * lifecycle status. Used by the command-loop to gate the post-acquire\n * hook after a (selective) restart and by the initial-acquire path to\n * decide whether to transition the cycle phase to `running`.\n *\n * Failed status reads collapse to `'failed'` so a transient registry\n * error doesn't block the readiness gate forever.\n */\nexport const allReadyOrTerminal = (\n\tgraph: ResolvedGraph,\n\tregistry: PluginRegistry,\n): Effect.Effect<boolean, never, never> =>\n\tEffect.gen(function* () {\n\t\tfor (const key of graph.nodes.keys()) {\n\t\t\tconst status = yield* registry\n\t\t\t\t.getStatus(key)\n\t\t\t\t.pipe(Effect.catch(() => Effect.succeed<LifecycleStatus>('failed')));\n\t\t\tif (!isReadyOrTerminal(status)) return false;\n\t\t}\n\t\treturn true;\n\t});\n\n/**\n * The shared-state record threaded through command-loop, background\n * tasks, and shutdown. Built once at the top of `startSupervisor`.\n */\nexport interface SupervisorState {\n\treadonly graph: ResolvedGraph;\n\treadonly registry: PluginRegistry;\n\treadonly ref: SubscriptionRef.SubscriptionRef<SubscribableState>;\n\treadonly hub: Queue.Enqueue<EngineEvent>;\n\treadonly queuedCommands: Queue.Dequeue<QueuedCommand>;\n\treadonly stackRestartTask: Ref.Ref<StackRestartTaskState>;\n\treadonly stackRestartSeq: Ref.Ref<number>;\n\treadonly snapshotCaptureTask: Ref.Ref<SnapshotCaptureTaskState>;\n\treadonly snapshotCaptureSeq: Ref.Ref<number>;\n\treadonly shutdownLatch: Ref.Ref<boolean>;\n\treadonly shutdownComplete: Deferred.Deferred<void>;\n\treadonly pluginContext: Context.Context<never>;\n\treadonly sinks: CapabilitySinksShape;\n\treadonly logger: LoggerShape;\n\treadonly identity: Identity;\n\treadonly runtimeRoot: string;\n\treadonly commandHandler?: SupervisorCommandHandler;\n\treadonly postAcquireHook?: SupervisorPostAcquireHook;\n}\n"],"mappings":";;;;;;;;;;;;;;AAwFA,MAAa,sBACZ,OACA,aAEA,OAAO,IAAI,aAAa;AACvB,MAAK,MAAM,OAAO,MAAM,MAAM,MAAM,CAInC,KAAI,CAAC,kBAAkB,OAHD,SACpB,UAAU,IAAI,CACd,KAAK,OAAO,YAAY,OAAO,QAAyB,SAAS,CAAC,CAAC,CACvC,CAAE,QAAO;AAExC,QAAO;EACN"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import "../capability-sinks/index.mjs";
|
|
2
|
+
import { planRestart } from "../lifecycle/selective-restart.mjs";
|
|
3
|
+
import "../lifecycle/index.mjs";
|
|
4
|
+
import { bestEffort, publish } from "./wiring.mjs";
|
|
5
|
+
import { acquireKeys } from "./acquire-node.mjs";
|
|
6
|
+
import { Effect, Exit, Scope } from "effect";
|
|
7
|
+
//#region src/substrate/runtime/supervisor/teardown.ts
|
|
8
|
+
/**
|
|
9
|
+
* Tear down a slice in reverse-dep order, parallel within each level.
|
|
10
|
+
* Each node's scope close runs its finalizers; status transitions
|
|
11
|
+
* `ready → stopping → stopped` are emitted.
|
|
12
|
+
*
|
|
13
|
+
* Architecture § Stack lifecycle: "shutdown.requested → parallel
|
|
14
|
+
* teardown (max grace, not sum grace)".
|
|
15
|
+
*/
|
|
16
|
+
const teardownKeys = (graph, registry, keys) => Effect.gen(function* () {
|
|
17
|
+
const byLevel = graph.levels.map(() => []);
|
|
18
|
+
const keySet = new Set(keys);
|
|
19
|
+
for (let i = 0; i < graph.levels.length; i++) for (const key of graph.levels[i]) if (keySet.has(key)) byLevel[i].push(key);
|
|
20
|
+
for (let i = byLevel.length - 1; i >= 0; i--) {
|
|
21
|
+
const level = byLevel[i];
|
|
22
|
+
if (level.length === 0) continue;
|
|
23
|
+
yield* Effect.all(level.map((key) => teardownNode(registry, key)), {
|
|
24
|
+
concurrency: "unbounded",
|
|
25
|
+
discard: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.teardownKeys"));
|
|
29
|
+
const teardownNode = (registry, key) => Effect.gen(function* () {
|
|
30
|
+
const entry = registry.entries.get(key);
|
|
31
|
+
if (entry === void 0) return;
|
|
32
|
+
const status = yield* registry.getStatus(key).pipe(Effect.catch(() => Effect.succeed("pending")));
|
|
33
|
+
if (status === "ready") yield* bestEffort(registry.transition(key, "stopping"));
|
|
34
|
+
yield* Scope.close(entry.scope, Exit.void).pipe(Effect.catch(() => Effect.void));
|
|
35
|
+
if (status === "ready") yield* bestEffort(registry.transition(key, "stopped"));
|
|
36
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.teardownNode"));
|
|
37
|
+
const doSelectiveRestart = (graph, registry, ref, hub, roots, pluginContext, sinks, logger, identity, runtimeRoot, parentScope) => Effect.gen(function* () {
|
|
38
|
+
const plan = yield* planRestart(graph, roots);
|
|
39
|
+
const at = Date.now();
|
|
40
|
+
for (const root of roots) yield* publish(ref, hub, {
|
|
41
|
+
tag: "restart.requested",
|
|
42
|
+
target: { pluginKey: root },
|
|
43
|
+
at
|
|
44
|
+
});
|
|
45
|
+
yield* teardownKeys(graph, registry, plan.teardownOrder);
|
|
46
|
+
for (const key of plan.acquireOrder) yield* registry.resetForRestart(key, parentScope).pipe(Effect.catch(() => Effect.void));
|
|
47
|
+
yield* acquireKeys(registry, plan.acquireOrder, ref, hub, pluginContext, sinks, logger, identity, runtimeRoot);
|
|
48
|
+
for (const root of roots) yield* publish(ref, hub, {
|
|
49
|
+
tag: "restart.completed",
|
|
50
|
+
target: { pluginKey: root },
|
|
51
|
+
at: Date.now()
|
|
52
|
+
});
|
|
53
|
+
}).pipe(Effect.withSpan("lifecycle.supervisor.selectiveRestart"));
|
|
54
|
+
//#endregion
|
|
55
|
+
export { doSelectiveRestart, teardownKeys };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=teardown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teardown.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/teardown.ts"],"sourcesContent":["// Teardown + selective restart.\n//\n// Plugin scopes close in reverse-dep order, parallel within each level\n// (max grace, not sum grace, per architecture § Stack lifecycle).\n// Selective restart tears a slice down then re-acquires it in\n// dependency order, reusing the per-node acquire pipeline.\n\nimport { Context, Effect, Exit, Queue, Scope, SubscriptionRef } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport { type CapabilitySinksShape } from '../capability-sinks/index.ts';\nimport type { LoggerShape } from '../observability/index.ts';\nimport {\n\tplanRestart,\n\ttype PluginRegistry,\n\ttype ResolvedGraph,\n\ttype RestartTargetMissing,\n} from '../lifecycle/index.ts';\nimport { acquireKeys } from './acquire-node.ts';\nimport { bestEffort, publish } from './wiring.ts';\n\n// -----------------------------------------------------------------------------\n// Teardown\n// -----------------------------------------------------------------------------\n\n/**\n * Tear down a slice in reverse-dep order, parallel within each level.\n * Each node's scope close runs its finalizers; status transitions\n * `ready → stopping → stopped` are emitted.\n *\n * Architecture § Stack lifecycle: \"shutdown.requested → parallel\n * teardown (max grace, not sum grace)\".\n */\nexport const teardownKeys = (\n\tgraph: ResolvedGraph,\n\tregistry: PluginRegistry,\n\tkeys: ReadonlyArray<PluginKey>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst byLevel: Array<Array<PluginKey>> = graph.levels.map(() => []);\n\t\tconst keySet = new Set(keys);\n\t\tfor (let i = 0; i < graph.levels.length; i++) {\n\t\t\tfor (const key of graph.levels[i]!) {\n\t\t\t\tif (keySet.has(key)) byLevel[i]!.push(key);\n\t\t\t}\n\t\t}\n\t\tfor (let i = byLevel.length - 1; i >= 0; i--) {\n\t\t\tconst level = byLevel[i]!;\n\t\t\tif (level.length === 0) continue;\n\t\t\tyield* Effect.all(\n\t\t\t\tlevel.map((key) => teardownNode(registry, key)),\n\t\t\t\t{ concurrency: 'unbounded', discard: true },\n\t\t\t);\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.teardownKeys'));\n\nexport const teardownNode = (\n\tregistry: PluginRegistry,\n\tkey: PluginKey,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst entry = registry.entries.get(key);\n\t\tif (entry === undefined) return;\n\t\tconst status = yield* registry\n\t\t\t.getStatus(key)\n\t\t\t.pipe(Effect.catch(() => Effect.succeed<LifecycleStatus>('pending')));\n\t\t// Only `ready` plugins need stopping. `acquiring` plugins are\n\t\t// interrupted by the scope close. `failed` / `stopped` / `done`\n\t\t// are no-ops. `status` is a snapshot read above, so a concurrent\n\t\t// off-table move (e.g. a racing restart driving the node to\n\t\t// `failed`) can make `transition` hit `assertTransition` and\n\t\t// `Effect.die` — `bestEffort` (Effect.exit) swallows that defect\n\t\t// as well as the typed channel, keeping teardown's unbounded\n\t\t// fan-out from bubbling an unguarded die through the scope-close\n\t\t// finalizer.\n\t\tif (status === 'ready') {\n\t\t\tyield* bestEffort(registry.transition(key, 'stopping'));\n\t\t}\n\t\tyield* Scope.close(entry.scope, Exit.void).pipe(Effect.catch(() => Effect.void));\n\t\tif (status === 'ready') {\n\t\t\tyield* bestEffort(registry.transition(key, 'stopped'));\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.teardownNode'));\n\n// -----------------------------------------------------------------------------\n// Selective restart\n// -----------------------------------------------------------------------------\n\nexport const doSelectiveRestart = (\n\tgraph: ResolvedGraph,\n\tregistry: PluginRegistry,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\troots: ReadonlySet<PluginKey>,\n\tpluginContext: Context.Context<never>,\n\tsinks: CapabilitySinksShape,\n\tlogger: LoggerShape,\n\tidentity: Identity,\n\truntimeRoot: string,\n\tparentScope: Scope.Scope,\n): Effect.Effect<void, RestartTargetMissing> =>\n\tEffect.gen(function* () {\n\t\tconst plan = yield* planRestart(graph, roots);\n\t\tconst at = Date.now();\n\t\tfor (const root of roots) {\n\t\t\tyield* publish(ref, hub, {\n\t\t\t\ttag: 'restart.requested',\n\t\t\t\ttarget: { pluginKey: root },\n\t\t\t\tat,\n\t\t\t});\n\t\t}\n\t\tyield* teardownKeys(graph, registry, plan.teardownOrder);\n\t\t// Re-acquire the slice in parallel. Each node waits on its own\n\t\t// upstream ready gate, so a downstream node in the slice can't\n\t\t// acquire until its upstream is back to `ready`; unrelated\n\t\t// siblings do not act as a level barrier. Nodes outside the\n\t\t// slice are already `ready`. `resetForRestart` rebuilds each\n\t\t// node's scope + ready gate AND authoritatively resets its\n\t\t// status to `pending` regardless of prior state (a node may\n\t\t// still be `acquiring` when its scope close interrupts it), so\n\t\t// the acquire below performs a clean `pending → acquiring`\n\t\t// transition for every slice node.\n\t\tfor (const key of plan.acquireOrder) {\n\t\t\tyield* registry.resetForRestart(key, parentScope).pipe(Effect.catch(() => Effect.void));\n\t\t}\n\t\tyield* acquireKeys(\n\t\t\tregistry,\n\t\t\tplan.acquireOrder,\n\t\t\tref,\n\t\t\thub,\n\t\t\tpluginContext,\n\t\t\tsinks,\n\t\t\tlogger,\n\t\t\tidentity,\n\t\t\truntimeRoot,\n\t\t);\n\t\tfor (const root of roots) {\n\t\t\tyield* publish(ref, hub, {\n\t\t\t\ttag: 'restart.completed',\n\t\t\t\ttarget: { pluginKey: root },\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t}\n\t}).pipe(Effect.withSpan('lifecycle.supervisor.selectiveRestart'));\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,MAAa,gBACZ,OACA,UACA,SAEA,OAAO,IAAI,aAAa;CACvB,MAAM,UAAmC,MAAM,OAAO,UAAU,EAAE,CAAC;CACnE,MAAM,SAAS,IAAI,IAAI,KAAK;AAC5B,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,OAAO,QAAQ,IACxC,MAAK,MAAM,OAAO,MAAM,OAAO,GAC9B,KAAI,OAAO,IAAI,IAAI,CAAE,SAAQ,GAAI,KAAK,IAAI;AAG5C,MAAK,IAAI,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,QAAQ,QAAQ;AACtB,MAAI,MAAM,WAAW,EAAG;AACxB,SAAO,OAAO,IACb,MAAM,KAAK,QAAQ,aAAa,UAAU,IAAI,CAAC,EAC/C;GAAE,aAAa;GAAa,SAAS;GAAM,CAC3C;;EAED,CAAC,KAAK,OAAO,SAAS,oCAAoC,CAAC;AAE9D,MAAa,gBACZ,UACA,QAEA,OAAO,IAAI,aAAa;CACvB,MAAM,QAAQ,SAAS,QAAQ,IAAI,IAAI;AACvC,KAAI,UAAU,KAAA,EAAW;CACzB,MAAM,SAAS,OAAO,SACpB,UAAU,IAAI,CACd,KAAK,OAAO,YAAY,OAAO,QAAyB,UAAU,CAAC,CAAC;AAUtE,KAAI,WAAW,QACd,QAAO,WAAW,SAAS,WAAW,KAAK,WAAW,CAAC;AAExD,QAAO,MAAM,MAAM,MAAM,OAAO,KAAK,KAAK,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAChF,KAAI,WAAW,QACd,QAAO,WAAW,SAAS,WAAW,KAAK,UAAU,CAAC;EAEtD,CAAC,KAAK,OAAO,SAAS,oCAAoC,CAAC;AAM9D,MAAa,sBACZ,OACA,UACA,KACA,KACA,OACA,eACA,OACA,QACA,UACA,aACA,gBAEA,OAAO,IAAI,aAAa;CACvB,MAAM,OAAO,OAAO,YAAY,OAAO,MAAM;CAC7C,MAAM,KAAK,KAAK,KAAK;AACrB,MAAK,MAAM,QAAQ,MAClB,QAAO,QAAQ,KAAK,KAAK;EACxB,KAAK;EACL,QAAQ,EAAE,WAAW,MAAM;EAC3B;EACA,CAAC;AAEH,QAAO,aAAa,OAAO,UAAU,KAAK,cAAc;AAWxD,MAAK,MAAM,OAAO,KAAK,aACtB,QAAO,SAAS,gBAAgB,KAAK,YAAY,CAAC,KAAK,OAAO,YAAY,OAAO,KAAK,CAAC;AAExF,QAAO,YACN,UACA,KAAK,cACL,KACA,KACA,eACA,OACA,QACA,UACA,YACA;AACD,MAAK,MAAM,QAAQ,MAClB,QAAO,QAAQ,KAAK,KAAK;EACxB,KAAK;EACL,QAAQ,EAAE,WAAW,MAAM;EAC3B,IAAI,KAAK,KAAK;EACd,CAAC;EAEF,CAAC,KAAK,OAAO,SAAS,wCAAwC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { StrategyNotFoundError } from "../errors.mjs";
|
|
2
|
+
import { serviceKeyFor } from "../observability/log-store.mjs";
|
|
3
|
+
import "../observability/index.mjs";
|
|
4
|
+
import { updateRef } from "../projection/update.mjs";
|
|
5
|
+
import { Context, Effect, Option, Queue, SubscriptionRef } from "effect";
|
|
6
|
+
//#region src/substrate/runtime/supervisor/wiring.ts
|
|
7
|
+
/**
|
|
8
|
+
* Swallow BOTH the typed failure and any defect of a best-effort
|
|
9
|
+
* effect, discarding its outcome. Lifecycle mutations
|
|
10
|
+
* (`registry.transition` / `markReady` / `markFailed`) validate against
|
|
11
|
+
* the transition table via `assertTransition`, which `Effect.die`s (a
|
|
12
|
+
* DEFECT, not a typed failure) on an off-table move — reachable when a
|
|
13
|
+
* concurrent selective-restart races an in-flight acquire. `Effect.catch`
|
|
14
|
+
* only intercepts the typed `E` channel, so a die would escape and bubble
|
|
15
|
+
* unguarded through the unbounded acquire fan-out (supervisor wedge).
|
|
16
|
+
* `Effect.exit` captures failure AND defect into an `Exit` we discard,
|
|
17
|
+
* keeping these mutations genuinely best-effort.
|
|
18
|
+
*/
|
|
19
|
+
const bestEffort = (effect) => Effect.exit(effect);
|
|
20
|
+
/**
|
|
21
|
+
* Read an optional service from a `Context.Context<never>` or fall back
|
|
22
|
+
* to a default. The supervisor's `pluginContext` is name-blind: a
|
|
23
|
+
* caller may or may not have layered a `Logger`, `RuntimeRoot`, or
|
|
24
|
+
* `CapabilitySinksService`. The lookup pattern was open-coded in three
|
|
25
|
+
* sites until backlog #40 lifted it here.
|
|
26
|
+
*
|
|
27
|
+
* Two surfaces, mirroring the prior `getOrDefault` / `getOrDefaultEffect`
|
|
28
|
+
* helpers:
|
|
29
|
+
*
|
|
30
|
+
* - `read(ctx)` — value fallback (Logger, RuntimeRoot).
|
|
31
|
+
* - `readEffect(ctx)` — Effect fallback so the substrate only pays the
|
|
32
|
+
* "build the default Layer" cost when nothing is in context
|
|
33
|
+
* (CapabilitySinksService).
|
|
34
|
+
*
|
|
35
|
+
* Upstream-watch (Phase 5 reviewer): Effect v4 exposes `Context.getOption`
|
|
36
|
+
* (returns `Option<S>`) and `Context.getUnsafe` (throws on missing), but
|
|
37
|
+
* NO `getOptionUnchecked`-style variant that returns `Option<S>` over a
|
|
38
|
+
* `Context<never>` without the typed cast we perform here. The wrapper
|
|
39
|
+
* stays until upstream adds an unchecked optional getter — at which
|
|
40
|
+
* point the body collapses to a thin alias.
|
|
41
|
+
*/
|
|
42
|
+
const OptionalService = (tag) => ({
|
|
43
|
+
read: (ctx, fallback) => {
|
|
44
|
+
const opt = Context.getOption(ctx, tag);
|
|
45
|
+
return Option.isSome(opt) ? opt.value : fallback;
|
|
46
|
+
},
|
|
47
|
+
readEffect: (ctx, fallback) => {
|
|
48
|
+
const opt = Context.getOption(ctx, tag);
|
|
49
|
+
return Option.isSome(opt) ? Effect.succeed(opt.value) : fallback;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
/** Fallback used when the supervisor's `pluginContext` doesn't carry a
|
|
53
|
+
* Logger service. Swallows every line — the trade-off is that bare
|
|
54
|
+
* `supervise()` smoke tests stay log-free, while the wired CLI / e2e
|
|
55
|
+
* layer stack picks up the real Logger. */
|
|
56
|
+
const noopLogger = {
|
|
57
|
+
log: () => Effect.void,
|
|
58
|
+
readTag: () => Effect.succeed({
|
|
59
|
+
lines: [],
|
|
60
|
+
truncated: false
|
|
61
|
+
}),
|
|
62
|
+
readAll: Effect.succeed(/* @__PURE__ */ new Map()),
|
|
63
|
+
clearTag: () => Effect.void
|
|
64
|
+
};
|
|
65
|
+
const noopStrategyRegistry = {
|
|
66
|
+
get: (key) => Effect.fail(new StrategyNotFoundError({
|
|
67
|
+
capabilityKey: key,
|
|
68
|
+
registeredKeys: []
|
|
69
|
+
})),
|
|
70
|
+
list: () => Effect.succeed([]),
|
|
71
|
+
register: () => Effect.void
|
|
72
|
+
};
|
|
73
|
+
/** Publishing helper: writes the event to the projection ref AND
|
|
74
|
+
* enqueues it onto the live event hub for renderers that subscribe to
|
|
75
|
+
* the raw stream. */
|
|
76
|
+
const publish = (ref, hub, event) => Effect.gen(function* () {
|
|
77
|
+
yield* updateRef(ref, event);
|
|
78
|
+
yield* Queue.offer(hub, event);
|
|
79
|
+
});
|
|
80
|
+
const setCyclePhase = (ref, phase) => SubscriptionRef.update(ref, (state) => ({
|
|
81
|
+
...state,
|
|
82
|
+
cycle: {
|
|
83
|
+
...state.cycle,
|
|
84
|
+
startedAt: state.cycle.startedAt === 0 ? Date.now() : state.cycle.startedAt,
|
|
85
|
+
phase
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
const projectionLevel = (level) => {
|
|
89
|
+
switch (level) {
|
|
90
|
+
case "trace":
|
|
91
|
+
case "debug": return null;
|
|
92
|
+
case "info": return "info";
|
|
93
|
+
case "warn": return "warn";
|
|
94
|
+
case "error":
|
|
95
|
+
case "fatal": return "error";
|
|
96
|
+
default: return "info";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const withEventPublishingLogger = (base, ref, hub, logStore = null) => ({
|
|
100
|
+
...base,
|
|
101
|
+
log: (tag, pluginKey, payload) => Effect.gen(function* () {
|
|
102
|
+
yield* base.log(tag, pluginKey, payload);
|
|
103
|
+
if (logStore !== null) yield* logStore.append({
|
|
104
|
+
level: payload.level,
|
|
105
|
+
service: serviceKeyFor(tag, pluginKey),
|
|
106
|
+
message: payload.message,
|
|
107
|
+
fields: payload.fields
|
|
108
|
+
});
|
|
109
|
+
if (pluginKey === null) return;
|
|
110
|
+
const level = projectionLevel(payload.level);
|
|
111
|
+
if (level === null) return;
|
|
112
|
+
yield* publish(ref, hub, {
|
|
113
|
+
tag: "log.appended",
|
|
114
|
+
pluginKey,
|
|
115
|
+
line: payload.message,
|
|
116
|
+
level,
|
|
117
|
+
at: Date.now()
|
|
118
|
+
});
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
/** Build the registry's `onTransition` callback — turns status changes
|
|
122
|
+
* into typed events. */
|
|
123
|
+
const buildTransitionEmitter = (ref, hub) => (key, from, to) => publish(ref, hub, {
|
|
124
|
+
tag: "lifecycle.statusChanged",
|
|
125
|
+
pluginKey: key,
|
|
126
|
+
from,
|
|
127
|
+
to,
|
|
128
|
+
at: Date.now()
|
|
129
|
+
});
|
|
130
|
+
//#endregion
|
|
131
|
+
export { OptionalService, bestEffort, buildTransitionEmitter, noopLogger, noopStrategyRegistry, publish, setCyclePhase, withEventPublishingLogger };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=wiring.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiring.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/wiring.ts"],"sourcesContent":["// Supervisor wiring helpers.\n//\n// Tiny support module for the supervisor's substrate-wiring concerns:\n// fallback Logger, fallback StrategyRegistry, event publishing helpers,\n// projection-level mapping, the transition emitter builder, and the\n// OptionalService<T> helper that centralises the \"look up an optional\n// service in pluginContext, fall back if absent\" pattern endemic to\n// the supervisor boundary.\n//\n// Split out of the monolith per backlog #38 + #40.\n\nimport { Context, Effect, type Exit, Option, Queue, SubscriptionRef } from 'effect';\n\nimport type { StrategyRegistry } from '../../../contracts/strategy-contributor.ts';\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { LifecycleStatus } from '../../lifecycle.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport { StrategyNotFoundError } from '../errors.ts';\nimport type { LoggerShape, LogStoreShape } from '../observability/index.ts';\nimport { serviceKeyFor } from '../observability/index.ts';\nimport { updateRef } from '../projection/update.ts';\n\n// -----------------------------------------------------------------------------\n// Best-effort lifecycle mutation\n// -----------------------------------------------------------------------------\n\n/**\n * Swallow BOTH the typed failure and any defect of a best-effort\n * effect, discarding its outcome. Lifecycle mutations\n * (`registry.transition` / `markReady` / `markFailed`) validate against\n * the transition table via `assertTransition`, which `Effect.die`s (a\n * DEFECT, not a typed failure) on an off-table move — reachable when a\n * concurrent selective-restart races an in-flight acquire. `Effect.catch`\n * only intercepts the typed `E` channel, so a die would escape and bubble\n * unguarded through the unbounded acquire fan-out (supervisor wedge).\n * `Effect.exit` captures failure AND defect into an `Exit` we discard,\n * keeping these mutations genuinely best-effort.\n */\nexport const bestEffort = <A, E, R>(\n\teffect: Effect.Effect<A, E, R>,\n): Effect.Effect<Exit.Exit<A, E>, never, R> => Effect.exit(effect);\n\n// -----------------------------------------------------------------------------\n// OptionalService<T> — substrate-wide \"service-or-default\" helper\n// -----------------------------------------------------------------------------\n\n/**\n * Read an optional service from a `Context.Context<never>` or fall back\n * to a default. The supervisor's `pluginContext` is name-blind: a\n * caller may or may not have layered a `Logger`, `RuntimeRoot`, or\n * `CapabilitySinksService`. The lookup pattern was open-coded in three\n * sites until backlog #40 lifted it here.\n *\n * Two surfaces, mirroring the prior `getOrDefault` / `getOrDefaultEffect`\n * helpers:\n *\n * - `read(ctx)` — value fallback (Logger, RuntimeRoot).\n * - `readEffect(ctx)` — Effect fallback so the substrate only pays the\n * \"build the default Layer\" cost when nothing is in context\n * (CapabilitySinksService).\n *\n * Upstream-watch (Phase 5 reviewer): Effect v4 exposes `Context.getOption`\n * (returns `Option<S>`) and `Context.getUnsafe` (throws on missing), but\n * NO `getOptionUnchecked`-style variant that returns `Option<S>` over a\n * `Context<never>` without the typed cast we perform here. The wrapper\n * stays until upstream adds an unchecked optional getter — at which\n * point the body collapses to a thin alias.\n */\nexport const OptionalService = <S, I>(tag: Context.Key<I, S>) => ({\n\tread: (ctx: Context.Context<never>, fallback: S): S => {\n\t\tconst opt = Context.getOption(ctx as Context.Context<I>, tag);\n\t\treturn Option.isSome(opt) ? opt.value : fallback;\n\t},\n\treadEffect: <E, R>(\n\t\tctx: Context.Context<never>,\n\t\tfallback: Effect.Effect<S, E, R>,\n\t): Effect.Effect<S, E, R> => {\n\t\tconst opt = Context.getOption(ctx as Context.Context<I>, tag);\n\t\treturn Option.isSome(opt) ? Effect.succeed(opt.value) : fallback;\n\t},\n});\n\n// -----------------------------------------------------------------------------\n// Fallback services for bare smoke-test `supervise()` paths\n// -----------------------------------------------------------------------------\n\n/** Fallback used when the supervisor's `pluginContext` doesn't carry a\n * Logger service. Swallows every line — the trade-off is that bare\n * `supervise()` smoke tests stay log-free, while the wired CLI / e2e\n * layer stack picks up the real Logger. */\nexport const noopLogger: LoggerShape = {\n\tlog: () => Effect.void,\n\treadTag: () => Effect.succeed({ lines: [], truncated: false }),\n\treadAll: Effect.succeed(new Map()),\n\tclearTag: () => Effect.void,\n};\n\nexport const noopStrategyRegistry: StrategyRegistry = {\n\tget: (key) =>\n\t\tEffect.fail(\n\t\t\tnew StrategyNotFoundError({\n\t\t\t\tcapabilityKey: key,\n\t\t\t\tregisteredKeys: [],\n\t\t\t}),\n\t\t),\n\tlist: () => Effect.succeed([]),\n\tregister: () => Effect.void,\n};\n\n// -----------------------------------------------------------------------------\n// Event publishing\n// -----------------------------------------------------------------------------\n\n/** Publishing helper: writes the event to the projection ref AND\n * enqueues it onto the live event hub for renderers that subscribe to\n * the raw stream. */\nexport const publish = (\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\tevent: EngineEvent,\n): Effect.Effect<void> =>\n\tEffect.gen(function* () {\n\t\tyield* updateRef(ref, event);\n\t\tyield* Queue.offer(hub, event);\n\t});\n\nexport const setCyclePhase = (\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\tphase: SubscribableState['cycle']['phase'],\n): Effect.Effect<void> =>\n\tSubscriptionRef.update(ref, (state) => ({\n\t\t...state,\n\t\tcycle: {\n\t\t\t...state.cycle,\n\t\t\tstartedAt: state.cycle.startedAt === 0 ? Date.now() : state.cycle.startedAt,\n\t\t\tphase,\n\t\t},\n\t}));\n\n// -----------------------------------------------------------------------------\n// Logger overlay — projects structured log lines into `log.appended`\n// -----------------------------------------------------------------------------\n\nexport const projectionLevel = (\n\tlevel: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal',\n): Extract<EngineEvent, { tag: 'log.appended' }>['level'] | null => {\n\tswitch (level) {\n\t\tcase 'trace':\n\t\tcase 'debug':\n\t\t\treturn null;\n\t\tcase 'info':\n\t\t\treturn 'info';\n\t\tcase 'warn':\n\t\t\treturn 'warn';\n\t\tcase 'error':\n\t\tcase 'fatal':\n\t\t\treturn 'error';\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = level;\n\t\t\tvoid _exhaustive;\n\t\t\treturn 'info';\n\t\t}\n\t}\n};\n\nexport const withEventPublishingLogger = (\n\tbase: LoggerShape,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n\t/** Optional cross-service queryable store. Every logged line is teed\n\t * into it (the SAME source that feeds the projection's per-row tail —\n\t * see log-store.ts), so the dashboard's \"Logs\" tab gets a filterable\n\t * cross-service history without a second log reader. Absent in bare\n\t * smoke-test paths that don't wire a LogStore. */\n\tlogStore: LogStoreShape | null = null,\n): LoggerShape => ({\n\t...base,\n\tlog: (tag, pluginKey, payload) =>\n\t\tEffect.gen(function* () {\n\t\t\tyield* base.log(tag, pluginKey, payload);\n\t\t\t// Tee into the cross-service store regardless of plugin key —\n\t\t\t// the queryable surface keeps supervisor-level lines too (the\n\t\t\t// projection tail below is row-scoped, so it only takes\n\t\t\t// plugin-attributed lines).\n\t\t\tif (logStore !== null) {\n\t\t\t\tyield* logStore.append({\n\t\t\t\t\tlevel: payload.level,\n\t\t\t\t\tservice: serviceKeyFor(tag, pluginKey),\n\t\t\t\t\tmessage: payload.message,\n\t\t\t\t\tfields: payload.fields,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (pluginKey === null) return;\n\t\t\tconst level = projectionLevel(payload.level);\n\t\t\tif (level === null) return;\n\t\t\tyield* publish(ref, hub, {\n\t\t\t\ttag: 'log.appended',\n\t\t\t\tpluginKey,\n\t\t\t\tline: payload.message,\n\t\t\t\tlevel,\n\t\t\t\tat: Date.now(),\n\t\t\t});\n\t\t}),\n});\n\n// -----------------------------------------------------------------------------\n// Transition emitter\n// -----------------------------------------------------------------------------\n\n/** Build the registry's `onTransition` callback — turns status changes\n * into typed events. */\nexport const buildTransitionEmitter =\n\t(\n\t\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\t\thub: Queue.Enqueue<EngineEvent>,\n\t): ((key: PluginKey, from: LifecycleStatus, to: LifecycleStatus) => Effect.Effect<void>) =>\n\t(key, from, to) =>\n\t\tpublish(ref, hub, {\n\t\t\ttag: 'lifecycle.statusChanged',\n\t\t\tpluginKey: key,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tat: Date.now(),\n\t\t});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,MAAa,cACZ,WAC8C,OAAO,KAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;AA4BlE,MAAa,mBAAyB,SAA4B;CACjE,OAAO,KAA6B,aAAmB;EACtD,MAAM,MAAM,QAAQ,UAAU,KAA2B,IAAI;AAC7D,SAAO,OAAO,OAAO,IAAI,GAAG,IAAI,QAAQ;;CAEzC,aACC,KACA,aAC4B;EAC5B,MAAM,MAAM,QAAQ,UAAU,KAA2B,IAAI;AAC7D,SAAO,OAAO,OAAO,IAAI,GAAG,OAAO,QAAQ,IAAI,MAAM,GAAG;;CAEzD;;;;;AAUD,MAAa,aAA0B;CACtC,WAAW,OAAO;CAClB,eAAe,OAAO,QAAQ;EAAE,OAAO,EAAE;EAAE,WAAW;EAAO,CAAC;CAC9D,SAAS,OAAO,wBAAQ,IAAI,KAAK,CAAC;CAClC,gBAAgB,OAAO;CACvB;AAED,MAAa,uBAAyC;CACrD,MAAM,QACL,OAAO,KACN,IAAI,sBAAsB;EACzB,eAAe;EACf,gBAAgB,EAAE;EAClB,CAAC,CACF;CACF,YAAY,OAAO,QAAQ,EAAE,CAAC;CAC9B,gBAAgB,OAAO;CACvB;;;;AASD,MAAa,WACZ,KACA,KACA,UAEA,OAAO,IAAI,aAAa;AACvB,QAAO,UAAU,KAAK,MAAM;AAC5B,QAAO,MAAM,MAAM,KAAK,MAAM;EAC7B;AAEH,MAAa,iBACZ,KACA,UAEA,gBAAgB,OAAO,MAAM,WAAW;CACvC,GAAG;CACH,OAAO;EACN,GAAG,MAAM;EACT,WAAW,MAAM,MAAM,cAAc,IAAI,KAAK,KAAK,GAAG,MAAM,MAAM;EAClE;EACA;CACD,EAAE;AAMJ,MAAa,mBACZ,UACmE;AACnE,SAAQ,OAAR;EACC,KAAK;EACL,KAAK,QACJ,QAAO;EACR,KAAK,OACJ,QAAO;EACR,KAAK,OACJ,QAAO;EACR,KAAK;EACL,KAAK,QACJ,QAAO;EACR,QAGC,QAAO;;;AAKV,MAAa,6BACZ,MACA,KACA,KAMA,WAAiC,UACf;CAClB,GAAG;CACH,MAAM,KAAK,WAAW,YACrB,OAAO,IAAI,aAAa;AACvB,SAAO,KAAK,IAAI,KAAK,WAAW,QAAQ;AAKxC,MAAI,aAAa,KAChB,QAAO,SAAS,OAAO;GACtB,OAAO,QAAQ;GACf,SAAS,cAAc,KAAK,UAAU;GACtC,SAAS,QAAQ;GACjB,QAAQ,QAAQ;GAChB,CAAC;AAEH,MAAI,cAAc,KAAM;EACxB,MAAM,QAAQ,gBAAgB,QAAQ,MAAM;AAC5C,MAAI,UAAU,KAAM;AACpB,SAAO,QAAQ,KAAK,KAAK;GACxB,KAAK;GACL;GACA,MAAM,QAAQ;GACd;GACA,IAAI,KAAK,KAAK;GACd,CAAC;GACD;CACH;;;AAQD,MAAa,0BAEX,KACA,SAEA,KAAK,MAAM,OACX,QAAQ,KAAK,KAAK;CACjB,KAAK;CACL,WAAW;CACX;CACA;CACA,IAAI,KAAK,KAAK;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-env.mjs","names":[],"sources":["../../../src/substrate/runtime/typed-env.ts"],"sourcesContent":["// Typed `process.env` accessor.\n//\n// The devstack package is consumed from both Node and browser-like\n// runtimes (Playwright fixtures, vitest browser mode), so we can't\n// reach for `process.env` directly — TypeScript with `\"types\": []`\n// rejects the global. Callers used to inline a one-off\n// `globalThis as { process?: { env?: ... } }` cast every time they\n// needed to read an env var. This centralises the cast so the rest of\n// the code reads `readEnv('FOO')` cleanly.\n//\n// Returns `undefined` when the runtime has no `process.env` (browser),\n// or when the env var is unset. Callers treat `undefined` and `''` as\n// equivalent \"absent\" sentinels.\n\nexport const readEnv = (name: string): string | undefined => {\n\tconst process = (\n\t\tglobalThis as { process?: { env?: Record<string, string | undefined> } }\n\t).process;\n\treturn process?.env?.[name];\n};\n"],"mappings":";AAcA,MAAa,WAAW,SAAqC;AAI5D,QAFC,WACC,SACc,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/substrate/versioned-doc-schema.ts
|
|
3
|
+
/** Construct a versioned cross-process document schema —
|
|
4
|
+
* `{ version: Literal<N>, ...payloadFields }` in one call.
|
|
5
|
+
*
|
|
6
|
+
* The resulting schema is structurally identical to a hand-written
|
|
7
|
+
* `Schema.Struct({ version: Schema.Literal(N), ...payload })`; the
|
|
8
|
+
* `version` field becomes a literal-typed discriminator suitable for
|
|
9
|
+
* forward-compatible `Schema.Union`s. */
|
|
10
|
+
const versionedDocSchema = (version, payload) => Schema.Struct({
|
|
11
|
+
version: Schema.Literal(version),
|
|
12
|
+
...payload
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { versionedDocSchema };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=versioned-doc-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versioned-doc-schema.mjs","names":[],"sources":["../../src/substrate/versioned-doc-schema.ts"],"sourcesContent":["// Versioned cross-process document schema helper.\n//\n// Centralizes the `{ version: Literal<N>, ...payload }` discriminator\n// shape that every cross-process document the substrate persists shares\n// (roster, container claim, snapshot reservation, port reservation).\n//\n// Future v2 migration becomes mechanical: replace the call with\n// `Schema.Union(versionedDocSchema(1, ...), versionedDocSchema(2, ...))`\n// at exactly one site per document, rather than hand-rolling the\n// discriminator field in each consumer.\n//\n// Lives at substrate L0 (depends only on `effect`'s Schema) so L0\n// declarations such as `substrate/cross-process.ts` can use it without\n// reaching into the L1 runtime tree.\n\nimport { Schema } from 'effect';\n\n/** Construct a versioned cross-process document schema —\n * `{ version: Literal<N>, ...payloadFields }` in one call.\n *\n * The resulting schema is structurally identical to a hand-written\n * `Schema.Struct({ version: Schema.Literal(N), ...payload })`; the\n * `version` field becomes a literal-typed discriminator suitable for\n * forward-compatible `Schema.Union`s. */\nexport const versionedDocSchema = <const V extends number, Fields extends Schema.Struct.Fields>(\n\tversion: V,\n\tpayload: Fields,\n): Schema.Struct<{ readonly version: Schema.Literal<V> } & Fields> =>\n\t// Cast is load-bearing: spreading a generic `Fields` into an object\n\t// literal makes TS infer the resulting `Schema.Struct` over a widened\n\t// field type, not the precise `{ version } & Fields` intersection, so\n\t// the literal-typed `version` discriminator would be lost without it.\n\tSchema.Struct({\n\t\tversion: Schema.Literal(version),\n\t\t...payload,\n\t}) as unknown as Schema.Struct<{ readonly version: Schema.Literal<V> } & Fields>;\n"],"mappings":";;;;;;;;;AAwBA,MAAa,sBACZ,SACA,YAMA,OAAO,OAAO;CACb,SAAS,OAAO,QAAQ,QAAQ;CAChC,GAAG;CACH,CAAC"}
|