@zlink-systems/framework 0.30.0 → 0.30.2
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/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
- package/dist/contracts/Common/encoded-payload-storage.js +5 -2
- package/dist/contracts/Configuration/Builders.d.ts +1 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +6 -1
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/abort.d.ts +5 -0
- package/dist/runtime/abort.js +10 -0
- package/dist/runtime/actors/actor-authority-publication.js +3 -2
- package/dist/runtime/actors/actor-client.d.ts +1 -2
- package/dist/runtime/actors/actor-client.js +52 -57
- package/dist/runtime/actors/actor-context.d.ts +2 -0
- package/dist/runtime/actors/actor-context.js +46 -9
- package/dist/runtime/actors/actor-handoff.d.ts +8 -4
- package/dist/runtime/actors/actor-handoff.js +219 -92
- package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
- package/dist/runtime/actors/actor-local-native-join.js +13 -12
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-state.js +2 -20
- package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
- package/dist/runtime/actors/index.d.ts +8 -3
- package/dist/runtime/actors/index.js +55 -27
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +56 -23
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
- package/dist/runtime/application-jobs/contracts.d.ts +12 -1
- package/dist/runtime/backend/contracts/index.d.ts +37 -12
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +154 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
- package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +2 -0
- package/dist/runtime/channels/channel-clients.js +75 -23
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
- package/dist/runtime/channels/channel-dispatchers.js +62 -54
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +2 -0
- package/dist/runtime/channels/channel-envelope.js +146 -28
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
- package/dist/runtime/channels/channel-runtime-manager.d.ts +9 -8
- package/dist/runtime/channels/channel-runtime-manager.js +16 -16
- package/dist/runtime/channels/channel-transports.d.ts +18 -16
- package/dist/runtime/channels/channel-transports.js +77 -58
- package/dist/runtime/channels/client-server-location-runtime.js +5 -4
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/fanout-location-runtime.js +3 -3
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +33 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
- package/dist/runtime/execution/serial-execution-queue.js +22 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/operation-registry.d.ts +25 -1
- package/dist/runtime/foundation/operation-registry.js +86 -18
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +61 -8
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
- package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
- package/dist/runtime/foundation/service-liveness-registry.js +38 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +3 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
- package/dist/runtime/foundation/service-stateful-registry.js +24 -26
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +75 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
- package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +13 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
- package/dist/runtime/host/actor-packet-relay.js +59 -72
- package/dist/runtime/host/actor-placement-coordinator.js +25 -8
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
- package/dist/runtime/host/actor-transfer-runtime.js +85 -331
- package/dist/runtime/host/application-job-queue.d.ts +40 -7
- package/dist/runtime/host/application-job-queue.js +137 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +12 -2
- package/dist/runtime/host/index.js +300 -202
- package/dist/runtime/host/location-runtime-owner.js +2 -6
- package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
- package/dist/runtime/host/mesh-router-resolver.js +14 -6
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
- package/dist/runtime/host/remote-bound-session-relay.js +73 -208
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +6 -4
- package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
- package/dist/runtime/host/runtime-shutdown.js +3 -2
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
- package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +51 -1
- package/dist/runtime/locations/location-store-repository.js +363 -139
- package/dist/runtime/locations/relocation-blob.d.ts +18 -1
- package/dist/runtime/locations/relocation-blob.js +52 -1
- package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
- package/dist/runtime/locations/request-source-resolver.js +80 -0
- package/dist/runtime/locations/resolvers.js +1 -1
- package/dist/runtime/locations/runtime.d.ts +7 -3
- package/dist/runtime/locations/runtime.js +61 -53
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/payload-codec.d.ts +7 -1
- package/dist/runtime/messaging/payload-codec.js +7 -6
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +57 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
- package/dist/runtime/spots/index.d.ts +21 -11
- package/dist/runtime/spots/index.js +243 -178
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +21 -11
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +7 -7
- package/dist/runtime/spots/spot-activation.d.ts +7 -3
- package/dist/runtime/spots/spot-activation.js +140 -52
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
- package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-membership.js +0 -8
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
- package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
- package/dist/runtime/spots/spot-entry-activation.js +20 -11
- package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
- package/dist/runtime/spots/spot-handler-registry.js +24 -10
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
- package/dist/runtime/spots/spot-manager-public.js +2 -2
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -42
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
- package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +27 -18
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +288 -103
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
- package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
- package/dist/runtime/streams/bound-session-service.d.ts +1 -1
- package/dist/runtime/streams/bound-session-service.js +6 -11
- package/dist/runtime/streams/index.d.ts +3 -2
- package/dist/runtime/streams/index.js +6 -4
- package/dist/runtime/streams/managed-stream.js +3 -2
- package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
- package/dist/runtime/streams/session-actor-coordinator.js +15 -32
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -31
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Common/encoded-payload-storage.ts +6 -3
- package/src/contracts/Configuration/Builders.ts +4 -1
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +10 -1
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/nest-integration.ts +1 -0
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +100 -85
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +291 -110
- package/src/runtime/actors/actor-join-relocation.ts +3 -0
- package/src/runtime/actors/actor-local-native-join.ts +21 -26
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
- package/src/runtime/actors/actor-runtime-state.ts +2 -20
- package/src/runtime/actors/actor-source-transfer.ts +1 -34
- package/src/runtime/actors/index.ts +60 -32
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +69 -21
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
- package/src/runtime/application-jobs/contracts.ts +16 -1
- package/src/runtime/backend/contracts/index.ts +92 -18
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +160 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +132 -58
- package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +136 -90
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +225 -31
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +41 -17
- package/src/runtime/channels/channel-transports.ts +171 -112
- package/src/runtime/channels/client-server-location-runtime.ts +11 -10
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
- package/src/runtime/channels/fanout-location-runtime.ts +17 -9
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +33 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
- package/src/runtime/foundation/service-liveness-registry.ts +39 -0
- package/src/runtime/foundation/service-mailbox.ts +8 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
- package/src/runtime/foundation/service-relocation-object-owner.ts +55 -36
- package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
- package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +38 -35
- package/src/runtime/foundation/service-stateful-runtime.ts +732 -275
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +231 -76
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +113 -94
- package/src/runtime/host/actor-placement-coordinator.ts +31 -8
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +160 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +473 -271
- package/src/runtime/host/location-runtime-owner.ts +2 -6
- package/src/runtime/host/mesh-router-resolver.ts +13 -5
- package/src/runtime/host/remote-bound-session-relay.ts +88 -271
- package/src/runtime/host/route-mesh-runtime.ts +12 -6
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/auto-connect-loop.ts +22 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +628 -152
- package/src/runtime/locations/relocation-blob.ts +75 -1
- package/src/runtime/locations/request-source-resolver.ts +138 -0
- package/src/runtime/locations/resolvers.ts +2 -2
- package/src/runtime/locations/runtime.ts +98 -64
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +62 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
- package/src/runtime/spots/index.ts +389 -283
- package/src/runtime/spots/spot-activation-registry.ts +25 -13
- package/src/runtime/spots/spot-activation-state.ts +12 -19
- package/src/runtime/spots/spot-activation.ts +198 -96
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
- package/src/runtime/spots/spot-actor-membership.ts +0 -15
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
- package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
- package/src/runtime/spots/spot-entry-activation.ts +33 -21
- package/src/runtime/spots/spot-handler-registry.ts +56 -12
- package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
- package/src/runtime/spots/spot-manager-public.ts +2 -2
- package/src/runtime/spots/spot-node-autoconnect.ts +28 -47
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +39 -19
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
- package/src/runtime/spots/spot-timer.ts +418 -158
- package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
- package/src/runtime/streams/bound-session-service.ts +7 -10
- package/src/runtime/streams/index.ts +12 -6
- package/src/runtime/streams/managed-stream.ts +4 -2
- package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
- package/src/runtime/streams/session-actor-coordinator.ts +39 -88
- package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
- package/src/runtime/streams/stream-session-runtime.ts +13 -34
- package/src/runtime/workers/index.ts +1 -1
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type ActorRef,
|
|
4
4
|
type RoutingId,
|
|
5
5
|
type ZLinkActor,
|
|
6
|
+
type ZLinkMeshNodeDescriptor,
|
|
6
7
|
type ZLinkActorJoinOperationId,
|
|
7
8
|
type ZLinkMessageSerializer,
|
|
8
9
|
type ZLinkSpot,
|
|
@@ -18,10 +19,8 @@ import {
|
|
|
18
19
|
toFrameworkActorRef,
|
|
19
20
|
type ZLinkActorHandoffCoordinator,
|
|
20
21
|
type ZLinkActorHandoffPrefixAdmission,
|
|
21
|
-
type ZLinkActorHandoffPrefixQueue,
|
|
22
22
|
type ZLinkActorHandoffReplayPreparation,
|
|
23
23
|
type ZLinkActorRoutedJoinTransport,
|
|
24
|
-
type ZLinkActorTransferRegistry,
|
|
25
24
|
type ZLinkDeferredJoinCompletion,
|
|
26
25
|
type ZLinkRemoteBoundSessionTarget
|
|
27
26
|
} from '../actors';
|
|
@@ -179,7 +178,6 @@ export interface ZLinkActorTransferRuntimeActorManager {
|
|
|
179
178
|
): Promise<ZLinkActor>;
|
|
180
179
|
publishRelocationActor(actorId: string): void;
|
|
181
180
|
rollbackTransferredActor(actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
182
|
-
completeCoreRelocationSource(actorId: string): Promise<void>;
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
export interface ZLinkActorTransferRuntimeOptions {
|
|
@@ -189,44 +187,23 @@ export interface ZLinkActorTransferRuntimeOptions {
|
|
|
189
187
|
readonly actorManager: () => ZLinkActorTransferRuntimeActorManager | undefined;
|
|
190
188
|
readonly primaryMeshNode: () => ZLinkBackendMeshNode;
|
|
191
189
|
readonly notifyEntrySpotActorLeft: (actor: ZLinkActor, signal?: AbortSignal) => Promise<void>;
|
|
192
|
-
readonly restoreEntrySpotActorJoined: (actor: ZLinkActor, signal?: AbortSignal) => Promise<void>;
|
|
193
190
|
readonly locationLifecycle: () => ZLinkLocationLifecycle | undefined;
|
|
194
191
|
/** Resolves the authoritative Ready route for a target User/Instance Spot. */
|
|
195
192
|
readonly spotRouteResolver?: () => ZLinkSpotRouteResolver | undefined;
|
|
196
193
|
readonly actorHandoff: ZLinkActorHandoffCoordinator;
|
|
197
|
-
readonly actorTransferRegistry: ZLinkActorTransferRegistry;
|
|
198
194
|
readonly authorityStore: () =>
|
|
199
195
|
(ZLinkAuthorityStore & ZLinkObjectCreationStore & ZLinkOwnerLeaseStore) | undefined;
|
|
200
196
|
readonly currentOwner: () => ZLinkLocationOwnerToken | undefined;
|
|
201
|
-
/** Live admitted peers of a mesh; used to stop retries against a gone session owner. */
|
|
202
|
-
readonly liveDescriptors?: (
|
|
203
|
-
meshName: string,
|
|
204
|
-
signal?: AbortSignal
|
|
205
|
-
) => Promise<readonly import('../../contracts').ZLinkMeshNodeDescriptor[]>;
|
|
206
197
|
/** Service-wire command 42/43/44 bridge, installed after the host runtime is assembled. */
|
|
207
198
|
readonly sessionRelocationWire?: () => ZLinkSessionRelocationWirePort | undefined;
|
|
208
199
|
readonly clearRemoteActorPacketTarget: (actorId: string) => void;
|
|
209
200
|
/** Acquires that permit before the Actor FIFO claims the runnable child. */
|
|
210
201
|
readonly prepareApplicationJob?: ZLinkActorHandoffReplayPreparation;
|
|
211
202
|
readonly reportPostCommitError?: (error: unknown) => void;
|
|
212
|
-
readonly onSourceDepartureCompleted?: (actorId: string) => void;
|
|
213
203
|
readonly shutdownSignal?: () => AbortSignal | undefined;
|
|
214
|
-
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
215
204
|
}
|
|
216
205
|
|
|
217
206
|
export class ZLinkActorTransferRuntime {
|
|
218
|
-
private readonly coreSourceLeaves = new Map<
|
|
219
|
-
string,
|
|
220
|
-
{
|
|
221
|
-
readonly promise: Promise<void>;
|
|
222
|
-
readonly resolve: () => void;
|
|
223
|
-
readonly reject: (error: unknown) => void;
|
|
224
|
-
readonly submitted: Promise<void>;
|
|
225
|
-
readonly resolveSubmitted: () => void;
|
|
226
|
-
readonly rejectSubmitted: (error: unknown) => void;
|
|
227
|
-
notifySubmitted?: () => Promise<void>;
|
|
228
|
-
}
|
|
229
|
-
>();
|
|
230
207
|
// Spot Actor membership sections 4-5: Join completion idempotency is
|
|
231
208
|
// process-local. These maps end with the process; nothing is replayed.
|
|
232
209
|
private readonly activeDeferredJoinTerminals = new Map<string, Promise<void>>();
|
|
@@ -244,8 +221,28 @@ export class ZLinkActorTransferRuntime {
|
|
|
244
221
|
);
|
|
245
222
|
}
|
|
246
223
|
|
|
247
|
-
|
|
248
|
-
|
|
224
|
+
/** Relocation activation owns admission; handler terminals are observed independently. */
|
|
225
|
+
admitRelocationPrefix(
|
|
226
|
+
actor: ZLinkActor,
|
|
227
|
+
objectGeneration: bigint,
|
|
228
|
+
packets: readonly ZLinkActorHandoffPacket[],
|
|
229
|
+
start: Promise<void>,
|
|
230
|
+
onResult: (packet: ZLinkActorHandoffPacket, result: ZLinkActorHandoffResult) => Promise<void>
|
|
231
|
+
): void {
|
|
232
|
+
const manager = this.options.spotManager();
|
|
233
|
+
if (manager === undefined) throw new Error('Relocated Actor has no local FIFO owner.');
|
|
234
|
+
const admitted = this.options.actorHandoff.admitTransferredPrefix(
|
|
235
|
+
actor.context.actorId,
|
|
236
|
+
objectGeneration,
|
|
237
|
+
packets,
|
|
238
|
+
(records) => manager.admitSourceActorPacketPrefix(actor.context.actorId, records),
|
|
239
|
+
this.options.prepareApplicationJob,
|
|
240
|
+
start,
|
|
241
|
+
(packet, result) => {
|
|
242
|
+
void this.observeHandoffReplay(onResult(packet, result));
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
void this.observeHandoffReplay(admitted.terminal);
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
async completeDeferredActorHandoff(
|
|
@@ -269,9 +266,9 @@ export class ZLinkActorTransferRuntime {
|
|
|
269
266
|
|
|
270
267
|
async cancelDeferredActorHandoff(
|
|
271
268
|
actor: ZLinkActor,
|
|
272
|
-
|
|
269
|
+
_state: ZLinkActorRuntimeState
|
|
273
270
|
): Promise<void> {
|
|
274
|
-
const admitted = this.admitDeferredSourcePrefix(actor
|
|
271
|
+
const admitted = this.admitDeferredSourcePrefix(actor);
|
|
275
272
|
void this.observeHandoffReplay(admitted.terminal);
|
|
276
273
|
}
|
|
277
274
|
|
|
@@ -394,29 +391,10 @@ export class ZLinkActorTransferRuntime {
|
|
|
394
391
|
await this.options.notifyEntrySpotActorLeft(actor, signal);
|
|
395
392
|
}
|
|
396
393
|
|
|
397
|
-
private async restoreSourceActor(
|
|
398
|
-
actor: ZLinkActor,
|
|
399
|
-
sourceSpotId: RoutingId | undefined,
|
|
400
|
-
signal?: AbortSignal
|
|
401
|
-
): Promise<void> {
|
|
402
|
-
if (sourceSpotId !== undefined) {
|
|
403
|
-
const manager = this.options.spotManager();
|
|
404
|
-
if (manager !== undefined) {
|
|
405
|
-
await manager.restoreActorAfterFailedTransfer(sourceSpotId, actor, signal);
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
await this.options.restoreEntrySpotActorJoined(actor, signal);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
394
|
private async beginSourceActorMove(
|
|
413
395
|
actor: ZLinkActor,
|
|
414
|
-
state: ZLinkActorRuntimeState
|
|
415
|
-
deferredJoin = false
|
|
396
|
+
state: ZLinkActorRuntimeState
|
|
416
397
|
): Promise<void> {
|
|
417
|
-
if (deferredJoin && this.options.actorHandoff.isProvisional(actor.context.actorId)) {
|
|
418
|
-
this.promoteDeferredActorHandoff(actor, state);
|
|
419
|
-
}
|
|
420
398
|
state.beginMove();
|
|
421
399
|
if (!this.options.actorHandoff.isActive(actor.context.actorId)) {
|
|
422
400
|
this.options.actorHandoff.begin(
|
|
@@ -441,12 +419,7 @@ export class ZLinkActorTransferRuntime {
|
|
|
441
419
|
}
|
|
442
420
|
}
|
|
443
421
|
} catch (error) {
|
|
444
|
-
|
|
445
|
-
this.options.actorHandoff.cancel(actor.context.actorId);
|
|
446
|
-
} else {
|
|
447
|
-
const admitted = this.admitDeferredSourcePrefix(actor, state);
|
|
448
|
-
void this.observeHandoffReplay(admitted.terminal);
|
|
449
|
-
}
|
|
422
|
+
this.options.actorHandoff.cancel(actor.context.actorId);
|
|
450
423
|
state.endMove();
|
|
451
424
|
throw error;
|
|
452
425
|
}
|
|
@@ -455,7 +428,6 @@ export class ZLinkActorTransferRuntime {
|
|
|
455
428
|
private async cancelSourceActorMove(
|
|
456
429
|
actor: ZLinkActor,
|
|
457
430
|
state: ZLinkActorRuntimeState,
|
|
458
|
-
deferredJoin = false,
|
|
459
431
|
replayStart: Promise<void> = Promise.resolve()
|
|
460
432
|
): Promise<void> {
|
|
461
433
|
try {
|
|
@@ -464,13 +436,8 @@ export class ZLinkActorTransferRuntime {
|
|
|
464
436
|
}
|
|
465
437
|
} finally {
|
|
466
438
|
try {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
void this.observeHandoffReplay(admitted.terminal);
|
|
470
|
-
} else {
|
|
471
|
-
const admitted = this.admitDeferredSourcePrefix(actor, state, replayStart);
|
|
472
|
-
void this.observeHandoffReplay(admitted.terminal);
|
|
473
|
-
}
|
|
439
|
+
const admitted = this.admitCanceledSourcePrefix(actor, replayStart);
|
|
440
|
+
void this.observeHandoffReplay(admitted.terminal);
|
|
474
441
|
} finally {
|
|
475
442
|
state.endMove();
|
|
476
443
|
}
|
|
@@ -479,20 +446,19 @@ export class ZLinkActorTransferRuntime {
|
|
|
479
446
|
|
|
480
447
|
private admitCanceledSourcePrefix(
|
|
481
448
|
actor: ZLinkActor,
|
|
482
|
-
state: ZLinkActorRuntimeState,
|
|
483
449
|
replayStart: Promise<void> = Promise.resolve()
|
|
484
450
|
): ZLinkActorHandoffPrefixAdmission {
|
|
485
451
|
// The seal-era ingress hold returns to the source queue on a precommit
|
|
486
452
|
// abort. Rejection stays reserved for a source Actor whose dispatch is
|
|
487
453
|
// gone, because held packets then have no queue left to return to.
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
454
|
+
const manager = this.options.spotManager();
|
|
455
|
+
if (manager === undefined) {
|
|
490
456
|
this.options.actorHandoff.cancel(actor.context.actorId);
|
|
491
457
|
return { terminal: Promise.resolve() };
|
|
492
458
|
}
|
|
493
459
|
return this.options.actorHandoff.admitCanceledPrefix(
|
|
494
460
|
actor.context.actorId,
|
|
495
|
-
|
|
461
|
+
(records) => manager.admitSourceActorPacketPrefix(actor.context.actorId, records),
|
|
496
462
|
this.options.prepareApplicationJob,
|
|
497
463
|
replayStart
|
|
498
464
|
);
|
|
@@ -500,17 +466,16 @@ export class ZLinkActorTransferRuntime {
|
|
|
500
466
|
|
|
501
467
|
private admitDeferredSourcePrefix(
|
|
502
468
|
actor: ZLinkActor,
|
|
503
|
-
state: ZLinkActorRuntimeState,
|
|
504
469
|
replayStart: Promise<void> = Promise.resolve()
|
|
505
470
|
): ZLinkActorHandoffPrefixAdmission {
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
471
|
+
const manager = this.options.spotManager();
|
|
472
|
+
if (manager === undefined) {
|
|
508
473
|
this.options.actorHandoff.cancel(actor.context.actorId);
|
|
509
474
|
return { terminal: Promise.resolve() };
|
|
510
475
|
}
|
|
511
476
|
return this.options.actorHandoff.admitDeferredPrefix(
|
|
512
477
|
actor.context.actorId,
|
|
513
|
-
|
|
478
|
+
(records) => manager.admitSourceActorPacketPrefix(actor.context.actorId, records),
|
|
514
479
|
this.options.prepareApplicationJob,
|
|
515
480
|
replayStart
|
|
516
481
|
);
|
|
@@ -531,208 +496,13 @@ export class ZLinkActorTransferRuntime {
|
|
|
531
496
|
}
|
|
532
497
|
}
|
|
533
498
|
|
|
534
|
-
private sourceHandoffPrefixQueue(
|
|
535
|
-
actor: ZLinkActor,
|
|
536
|
-
state: ZLinkActorRuntimeState
|
|
537
|
-
): ZLinkActorHandoffPrefixQueue | undefined {
|
|
538
|
-
const sourceSpotId = state.spotId;
|
|
539
|
-
const manager = this.options.spotManager();
|
|
540
|
-
if (sourceSpotId === undefined || manager === undefined) {
|
|
541
|
-
return undefined;
|
|
542
|
-
}
|
|
543
|
-
return (drain) =>
|
|
544
|
-
manager.admitRoutedActorPacketPrefix(sourceSpotId, actor.context.actorId, drain);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
async prepareSource(
|
|
548
|
-
actor: ZLinkActor,
|
|
549
|
-
state: ZLinkActorRuntimeState,
|
|
550
|
-
signal?: AbortSignal,
|
|
551
|
-
lifecycleAuthority: 'framework' | 'core' = 'framework',
|
|
552
|
-
deferredJoin = false,
|
|
553
|
-
relocation?: ServiceWireOperationId
|
|
554
|
-
) {
|
|
555
|
-
await this.beginSourceActorMove(actor, state, deferredJoin);
|
|
556
|
-
const relocationMetric =
|
|
557
|
-
state.meshName === undefined
|
|
558
|
-
? undefined
|
|
559
|
-
: this.options.metrics?.startRelocation(
|
|
560
|
-
state.meshName,
|
|
561
|
-
'actor',
|
|
562
|
-
this.options.actorTransferRegistry.policy(state.actorType)
|
|
563
|
-
);
|
|
564
|
-
const sourceSpotId = state.spotId;
|
|
565
|
-
let sourceLeaveStarted = false;
|
|
566
|
-
// The relocation operation owns its Session seal; the Actor keeps only
|
|
567
|
-
// its current binding (Session–Actor binding §8.1).
|
|
568
|
-
let sealedSession: ZLinkRemoteBoundSessionTarget | undefined;
|
|
569
|
-
try {
|
|
570
|
-
if (state.boundSession !== undefined) {
|
|
571
|
-
sealedSession = await this.sealBoundSessionRoute(actor, state, signal, relocation);
|
|
572
|
-
this.options.actorHandoff.sealConnectionBoundIngress(actor.context.actorId);
|
|
573
|
-
}
|
|
574
|
-
const transfer = await this.options.actorTransferRegistry.transferOut(
|
|
575
|
-
actor,
|
|
576
|
-
state.actorType,
|
|
577
|
-
signal
|
|
578
|
-
);
|
|
579
|
-
// The captured state is handed off inline with the join request; the
|
|
580
|
-
// Relocation Store no longer carries relocation state payloads
|
|
581
|
-
// (spec 28 §2 — direct transfer is the only handoff original).
|
|
582
|
-
relocationMetric?.recordBytes(transfer.state.toEncodedPayload().toBytes().byteLength);
|
|
583
|
-
if (lifecycleAuthority === 'framework') {
|
|
584
|
-
sourceLeaveStarted = true;
|
|
585
|
-
await this.prepareSourceActorLeave(actor, sourceSpotId, signal);
|
|
586
|
-
}
|
|
587
|
-
const coreSourceLeave =
|
|
588
|
-
lifecycleAuthority === 'core'
|
|
589
|
-
? this.beginCoreSourceLeave(actor.context.actorId)
|
|
590
|
-
: undefined;
|
|
591
|
-
const sourceLeaveCompletion = coreSourceLeave?.completion;
|
|
592
|
-
const handoffBacklog =
|
|
593
|
-
lifecycleAuthority === 'core'
|
|
594
|
-
? this.options.actorHandoff.snapshotCoreBacklog(actor.context.actorId)
|
|
595
|
-
: this.options.actorHandoff.snapshot(actor.context.actorId);
|
|
596
|
-
let phase: 'prepared' | 'committed' | 'rolledBack' = 'prepared';
|
|
597
|
-
let committedTargetOwnerFence: ZLinkActorMessageFollowOwnerFence | undefined;
|
|
598
|
-
return {
|
|
599
|
-
...transfer,
|
|
600
|
-
handoffBacklog,
|
|
601
|
-
sourceLeaveCompletion,
|
|
602
|
-
sourceLeaveSubmitted: coreSourceLeave?.submitted,
|
|
603
|
-
onSourceLeaveSubmitted: (notify: () => Promise<void>) => {
|
|
604
|
-
const pending = this.coreSourceLeaves.get(actor.context.actorId);
|
|
605
|
-
if (pending === undefined) {
|
|
606
|
-
throw new Error(`Actor '${actor.context.actorId}' has no pending Core source leave.`);
|
|
607
|
-
}
|
|
608
|
-
pending.notifySubmitted = notify;
|
|
609
|
-
},
|
|
610
|
-
observeTargetAuthority: async (
|
|
611
|
-
target: ZLinkSpotRouteTarget,
|
|
612
|
-
targetActorRef: ActorRef,
|
|
613
|
-
observeSignal?: AbortSignal
|
|
614
|
-
) => {
|
|
615
|
-
const authority = this.options.authorityStore();
|
|
616
|
-
if (
|
|
617
|
-
authority === undefined ||
|
|
618
|
-
target.targetOwnerId === undefined ||
|
|
619
|
-
target.ownerLeaseGeneration === undefined ||
|
|
620
|
-
target.targetNodeGeneration === undefined
|
|
621
|
-
) {
|
|
622
|
-
throw new Error(
|
|
623
|
-
`Actor '${actor.context.actorId}' relocation target has no complete authority fence.`
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
const committed = await authority.readAuthority(
|
|
627
|
-
encodeAuthorityKey('actor', actor.context.actorId),
|
|
628
|
-
observeSignal
|
|
629
|
-
);
|
|
630
|
-
if (
|
|
631
|
-
committed.kind !== 'snapshot' ||
|
|
632
|
-
committed.ownerId !== target.targetOwnerId ||
|
|
633
|
-
committed.ownerLeaseGeneration !== target.ownerLeaseGeneration ||
|
|
634
|
-
committed.allocation.descriptorLifecycleGeneration !== target.targetNodeGeneration ||
|
|
635
|
-
!routingIdsEqual(committed.allocation.descriptor.rid, target.targetNodeRid) ||
|
|
636
|
-
committed.objectGeneration !== targetActorRef.objectGeneration
|
|
637
|
-
) {
|
|
638
|
-
throw new Error(
|
|
639
|
-
`Actor '${actor.context.actorId}' relocation target authority was not committed exactly.`
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
committedTargetOwnerFence = committedActorOwnerFence(
|
|
643
|
-
actor.context.actorId,
|
|
644
|
-
targetActorRef,
|
|
645
|
-
committed
|
|
646
|
-
);
|
|
647
|
-
},
|
|
648
|
-
commit: (
|
|
649
|
-
target: Parameters<ZLinkActorHandoffCoordinator['complete']>[1],
|
|
650
|
-
targetActorRef: ActorRef,
|
|
651
|
-
results: Parameters<ZLinkActorHandoffCoordinator['complete']>[3],
|
|
652
|
-
releaseLocation = true
|
|
653
|
-
) => {
|
|
654
|
-
if (phase !== 'prepared') return;
|
|
655
|
-
if (committedTargetOwnerFence === undefined) {
|
|
656
|
-
throw new Error(
|
|
657
|
-
`Actor '${actor.context.actorId}' handoff has no committed target authority fence.`
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
phase = 'committed';
|
|
661
|
-
relocationMetric?.complete('completed');
|
|
662
|
-
try {
|
|
663
|
-
this.options.actorHandoff.complete(
|
|
664
|
-
actor.context.actorId,
|
|
665
|
-
target,
|
|
666
|
-
targetActorRef,
|
|
667
|
-
results,
|
|
668
|
-
committedTargetOwnerFence
|
|
669
|
-
);
|
|
670
|
-
} catch (error) {
|
|
671
|
-
// The target has already committed. Local Message Follow setup is now
|
|
672
|
-
// post-commit work and must not turn the accepted transfer into a
|
|
673
|
-
// source rollback that can no longer undo the target.
|
|
674
|
-
this.options.reportPostCommitError?.(error);
|
|
675
|
-
} finally {
|
|
676
|
-
const releaseSourceLocation = lifecycleAuthority === 'core' && releaseLocation;
|
|
677
|
-
if (releaseSourceLocation && sourceLeaveCompletion !== undefined) {
|
|
678
|
-
// Core sends the source leave control after the authority
|
|
679
|
-
// transition. Keep the source shell available for that
|
|
680
|
-
// callback, then release the old location and registry entry.
|
|
681
|
-
void sourceLeaveCompletion.then(
|
|
682
|
-
() => this.scheduleSourceDeparture(actor, sourceSpotId, true),
|
|
683
|
-
(error) => {
|
|
684
|
-
this.scheduleSourceDeparture(actor, sourceSpotId, true, [error]);
|
|
685
|
-
}
|
|
686
|
-
);
|
|
687
|
-
} else {
|
|
688
|
-
this.scheduleSourceDeparture(actor, sourceSpotId, releaseSourceLocation);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
},
|
|
692
|
-
rollback: async () => {
|
|
693
|
-
if (phase !== 'prepared') return;
|
|
694
|
-
phase = 'rolledBack';
|
|
695
|
-
relocationMetric?.complete('aborted');
|
|
696
|
-
this.coreSourceLeaves.delete(actor.context.actorId);
|
|
697
|
-
const replayGate = createHandoffReplayGate();
|
|
698
|
-
try {
|
|
699
|
-
await this.cancelSourceActorMove(actor, state, deferredJoin, replayGate.start);
|
|
700
|
-
await this.restoreSourceActor(actor, sourceSpotId);
|
|
701
|
-
if (sealedSession !== undefined) {
|
|
702
|
-
await this.observeBoundSessionSealAbort(actor, state, sealedSession);
|
|
703
|
-
}
|
|
704
|
-
} finally {
|
|
705
|
-
replayGate.open();
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
} catch (error) {
|
|
710
|
-
relocationMetric?.complete('failed');
|
|
711
|
-
const replayGate = createHandoffReplayGate();
|
|
712
|
-
try {
|
|
713
|
-
await this.cancelSourceActorMove(actor, state, deferredJoin, replayGate.start);
|
|
714
|
-
if (sourceLeaveStarted) await this.restoreSourceActor(actor, sourceSpotId);
|
|
715
|
-
if (sealedSession !== undefined) {
|
|
716
|
-
await this.observeBoundSessionSealAbort(actor, state, sealedSession);
|
|
717
|
-
}
|
|
718
|
-
} catch (rollbackError) {
|
|
719
|
-
throw new AggregateError(
|
|
720
|
-
[error, rollbackError],
|
|
721
|
-
'Actor source leave and rollback both failed.'
|
|
722
|
-
);
|
|
723
|
-
} finally {
|
|
724
|
-
replayGate.open();
|
|
725
|
-
}
|
|
726
|
-
throw error;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
499
|
async prepareMaintenanceSession(
|
|
731
500
|
actor: ZLinkActor,
|
|
732
501
|
state: ZLinkActorRuntimeState,
|
|
733
502
|
signal?: AbortSignal,
|
|
734
503
|
manageMembership = true,
|
|
735
|
-
relocation?: ServiceWireOperationId
|
|
504
|
+
relocation?: ServiceWireOperationId,
|
|
505
|
+
relocationTarget?: Pick<ZLinkMeshNodeDescriptor, 'rid' | 'lifecycleGeneration'>
|
|
736
506
|
): Promise<{
|
|
737
507
|
readonly target?: ZLinkRemoteBoundSessionTarget;
|
|
738
508
|
readonly handoffBacklog: readonly import('../actors').ZLinkActorHandoffPacket[];
|
|
@@ -741,7 +511,7 @@ export class ZLinkActorTransferRuntime {
|
|
|
741
511
|
commit(
|
|
742
512
|
target: ZLinkSpotRouteTarget,
|
|
743
513
|
targetActorRef: ActorRef,
|
|
744
|
-
targetOwnerFence: ZLinkActorMessageFollowOwnerFence
|
|
514
|
+
targetOwnerFence: ZLinkActorMessageFollowOwnerFence | null
|
|
745
515
|
): Promise<void>;
|
|
746
516
|
rollback(): Promise<void>;
|
|
747
517
|
discard(reason: unknown): void;
|
|
@@ -752,26 +522,41 @@ export class ZLinkActorTransferRuntime {
|
|
|
752
522
|
spotId: state.spotId === undefined ? undefined : String(state.spotId)
|
|
753
523
|
});
|
|
754
524
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
525
|
+
// Relocation 04 §4.1: the Session owner seals a bound Actor's binding
|
|
526
|
+
// (command 42/43) before the source stops that Actor's application
|
|
527
|
+
// dispatch, so Session messages that arrive after the seal wait at the
|
|
528
|
+
// Session owner and never enter the source handoff backlog. A failed seal
|
|
529
|
+
// leaves the source dispatching; a dispatch stop that fails after the seal
|
|
530
|
+
// releases the matching seal with command 44 abort. The relocation
|
|
531
|
+
// operation owns this seal; the Actor keeps only its current binding
|
|
532
|
+
// (Session–Actor binding §8.1).
|
|
533
|
+
const bound = state.boundSession !== undefined;
|
|
534
|
+
const sealedSession = bound
|
|
535
|
+
? await this.sealBoundSessionRoute(actor, state, signal, relocation, relocationTarget)
|
|
536
|
+
: undefined;
|
|
537
|
+
try {
|
|
538
|
+
if (manageMembership) {
|
|
539
|
+
await this.beginSourceActorMove(actor, state);
|
|
540
|
+
} else {
|
|
541
|
+
state.beginMove();
|
|
542
|
+
this.options.actorHandoff.begin(
|
|
543
|
+
actor.context.actorId,
|
|
544
|
+
requireSourceObjectGeneration(actor.context.actorId, state)
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
} catch (error) {
|
|
548
|
+
if (sealedSession !== undefined) {
|
|
549
|
+
await this.observeBoundSessionSealAbort(actor, state, sealedSession);
|
|
550
|
+
}
|
|
551
|
+
throw error;
|
|
763
552
|
}
|
|
553
|
+
if (bound) this.options.actorHandoff.sealConnectionBoundIngress(actor.context.actorId);
|
|
764
554
|
if (isRelocationDebugEnabled()) {
|
|
765
555
|
relocationDebug('maintenance_session.source_move_complete', {
|
|
766
556
|
actorId: actor.context.actorId
|
|
767
557
|
});
|
|
768
558
|
}
|
|
769
|
-
let sealedSession: ZLinkRemoteBoundSessionTarget | undefined;
|
|
770
559
|
try {
|
|
771
|
-
if (state.boundSession !== undefined) {
|
|
772
|
-
sealedSession = await this.sealBoundSessionRoute(actor, state, signal, relocation);
|
|
773
|
-
this.options.actorHandoff.sealConnectionBoundIngress(actor.context.actorId);
|
|
774
|
-
}
|
|
775
560
|
const handoffBacklog = this.options.actorHandoff.snapshot(actor.context.actorId);
|
|
776
561
|
let terminal: 'prepared' | 'committed' | 'rolledBack' = 'prepared';
|
|
777
562
|
let replayResults: readonly import('../actors').ZLinkActorHandoffResult[] = [];
|
|
@@ -829,10 +614,10 @@ export class ZLinkActorTransferRuntime {
|
|
|
829
614
|
const replayGate = createHandoffReplayGate();
|
|
830
615
|
try {
|
|
831
616
|
if (manageMembership) {
|
|
832
|
-
await this.cancelSourceActorMove(actor, state,
|
|
617
|
+
await this.cancelSourceActorMove(actor, state, replayGate.start);
|
|
833
618
|
} else {
|
|
834
619
|
try {
|
|
835
|
-
const admitted = this.admitCanceledSourcePrefix(actor,
|
|
620
|
+
const admitted = this.admitCanceledSourcePrefix(actor, replayGate.start);
|
|
836
621
|
void this.observeHandoffReplay(admitted.terminal);
|
|
837
622
|
} finally {
|
|
838
623
|
state.endMove();
|
|
@@ -852,12 +637,12 @@ export class ZLinkActorTransferRuntime {
|
|
|
852
637
|
try {
|
|
853
638
|
if (manageMembership) {
|
|
854
639
|
try {
|
|
855
|
-
await this.cancelSourceActorMove(actor, state,
|
|
640
|
+
await this.cancelSourceActorMove(actor, state, replayGate.start);
|
|
856
641
|
sourceRestored = true;
|
|
857
642
|
} catch {}
|
|
858
643
|
} else {
|
|
859
644
|
try {
|
|
860
|
-
const admitted = this.admitCanceledSourcePrefix(actor,
|
|
645
|
+
const admitted = this.admitCanceledSourcePrefix(actor, replayGate.start);
|
|
861
646
|
void this.observeHandoffReplay(admitted.terminal);
|
|
862
647
|
sourceRestored = true;
|
|
863
648
|
} catch {
|
|
@@ -877,39 +662,6 @@ export class ZLinkActorTransferRuntime {
|
|
|
877
662
|
}
|
|
878
663
|
}
|
|
879
664
|
|
|
880
|
-
async notifyCoreSourceLeave(actor: ZLinkActor, callback: () => Promise<void>): Promise<void> {
|
|
881
|
-
const pending = this.coreSourceLeaves.get(actor.context.actorId);
|
|
882
|
-
let callbackResult: Promise<void>;
|
|
883
|
-
try {
|
|
884
|
-
callbackResult = Promise.resolve(callback());
|
|
885
|
-
} catch (error) {
|
|
886
|
-
callbackResult = Promise.reject(error);
|
|
887
|
-
}
|
|
888
|
-
// Submission, not the callback result, releases the target Join. Observe
|
|
889
|
-
// a fast rejection while the submission ACK is in flight without making
|
|
890
|
-
// that rejection an unhandled promise.
|
|
891
|
-
void callbackResult.catch(() => {});
|
|
892
|
-
try {
|
|
893
|
-
if (pending !== undefined) {
|
|
894
|
-
if (pending.notifySubmitted === undefined) {
|
|
895
|
-
throw new Error(
|
|
896
|
-
`Actor '${actor.context.actorId}' has no Core source leave submission notifier.`
|
|
897
|
-
);
|
|
898
|
-
}
|
|
899
|
-
await pending.notifySubmitted();
|
|
900
|
-
pending.resolveSubmitted();
|
|
901
|
-
}
|
|
902
|
-
await callbackResult;
|
|
903
|
-
pending?.resolve();
|
|
904
|
-
} catch (error) {
|
|
905
|
-
pending?.rejectSubmitted(error);
|
|
906
|
-
pending?.reject(error);
|
|
907
|
-
throw error;
|
|
908
|
-
} finally {
|
|
909
|
-
this.coreSourceLeaves.delete(actor.context.actorId);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
665
|
async completeRelocationSourceLeave(
|
|
914
666
|
actor: ZLinkActor,
|
|
915
667
|
sourceSpotId: RoutingId | undefined,
|
|
@@ -955,8 +707,9 @@ export class ZLinkActorTransferRuntime {
|
|
|
955
707
|
actor: ZLinkActor,
|
|
956
708
|
state: ZLinkActorRuntimeState,
|
|
957
709
|
signal?: AbortSignal,
|
|
958
|
-
relocation?: ServiceWireOperationId
|
|
959
|
-
|
|
710
|
+
relocation?: ServiceWireOperationId,
|
|
711
|
+
relocationTarget?: Pick<ZLinkMeshNodeDescriptor, 'rid' | 'lifecycleGeneration'>
|
|
712
|
+
): Promise<ZLinkRemoteBoundSessionTarget | undefined> {
|
|
960
713
|
const target = state.boundSession;
|
|
961
714
|
const actorRef = state.nativeActorRef;
|
|
962
715
|
if (
|
|
@@ -964,6 +717,9 @@ export class ZLinkActorTransferRuntime {
|
|
|
964
717
|
actorRef === undefined ||
|
|
965
718
|
target.bindingGeneration === undefined ||
|
|
966
719
|
target.bindingGeneration <= 0n ||
|
|
720
|
+
target.sessionOwnerNodeGeneration === undefined ||
|
|
721
|
+
target.sessionOwnerId === undefined ||
|
|
722
|
+
target.sessionOwnerLeaseGeneration === undefined ||
|
|
967
723
|
state.locationGeneration === undefined ||
|
|
968
724
|
state.locationGeneration < 0n ||
|
|
969
725
|
state.ownerLeaseGeneration === undefined ||
|
|
@@ -975,56 +731,58 @@ export class ZLinkActorTransferRuntime {
|
|
|
975
731
|
}
|
|
976
732
|
const serviceWire = this.options.sessionRelocationWire?.();
|
|
977
733
|
const authorityStore = this.options.authorityStore();
|
|
978
|
-
const descriptors = this.options.liveDescriptors;
|
|
979
734
|
if (
|
|
980
735
|
relocation === undefined ||
|
|
736
|
+
relocationTarget === undefined ||
|
|
981
737
|
serviceWire === undefined ||
|
|
982
738
|
authorityStore === undefined ||
|
|
983
|
-
descriptors === undefined ||
|
|
984
739
|
target.sessionRid === undefined
|
|
985
740
|
) {
|
|
986
741
|
throw new Error(
|
|
987
742
|
`Actor '${actor.context.actorId}' Session relocation requires the command 42/43 service-wire path.`
|
|
988
743
|
);
|
|
989
744
|
}
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
745
|
+
const authority = await authorityStore.readAuthority(
|
|
746
|
+
encodeAuthorityKey('actor', actor.context.actorId),
|
|
747
|
+
signal
|
|
748
|
+
);
|
|
994
749
|
const local = this.options.primaryMeshNode().status();
|
|
995
|
-
const sessionOwner = live.find((value) => String(value.rid) === String(target.targetNodeRid));
|
|
996
750
|
if (
|
|
997
751
|
authority.kind !== 'snapshot' ||
|
|
998
|
-
|
|
999
|
-
String(local.routingId) !== String(actorRef.nodeRid) ||
|
|
752
|
+
!routingIdsEqual(local.routingId, actorRef.nodeRid) ||
|
|
1000
753
|
authority.objectGeneration !== actorRef.generation ||
|
|
1001
754
|
authority.authorityOwnerGeneration !== state.locationGeneration ||
|
|
1002
755
|
authority.ownerLeaseGeneration !== state.ownerLeaseGeneration ||
|
|
1003
|
-
|
|
756
|
+
!routingIdsEqual(authority.allocation.descriptor.rid, actorRef.nodeRid) ||
|
|
1004
757
|
authority.allocation.descriptorLifecycleGeneration !== local.lifecycleGeneration ||
|
|
1005
758
|
(target.sessionNodeRid !== undefined &&
|
|
1006
|
-
|
|
759
|
+
!routingIdsEqual(target.sessionNodeRid, target.targetNodeRid))
|
|
1007
760
|
) {
|
|
1008
761
|
throw new Error(
|
|
1009
762
|
`Actor '${actor.context.actorId}' Session route service-wire source fence is stale.`
|
|
1010
763
|
);
|
|
1011
764
|
}
|
|
765
|
+
const sourceNodeRid = local.routingId;
|
|
1012
766
|
const coordinator = {
|
|
1013
767
|
ownerId: authority.ownerId,
|
|
1014
768
|
leaseGeneration: authority.ownerLeaseGeneration,
|
|
1015
|
-
nodeRid:
|
|
769
|
+
nodeRid: sourceNodeRid,
|
|
1016
770
|
nodeGeneration: local.lifecycleGeneration,
|
|
1017
771
|
expectedAuthorityStoreVersion: authority.storeVersion.value
|
|
1018
772
|
};
|
|
773
|
+
// Session-Actor binding §4: command 42 carries the Session owner identity
|
|
774
|
+
// stored at bind unchanged.
|
|
1019
775
|
const session = {
|
|
1020
|
-
sessionOwnerNodeRid:
|
|
1021
|
-
sessionOwnerNodeGeneration:
|
|
1022
|
-
sessionOwnerId:
|
|
1023
|
-
sessionOwnerLeaseGeneration:
|
|
1024
|
-
sessionRid:
|
|
776
|
+
sessionOwnerNodeRid: target.targetNodeRid,
|
|
777
|
+
sessionOwnerNodeGeneration: target.sessionOwnerNodeGeneration,
|
|
778
|
+
sessionOwnerId: target.sessionOwnerId,
|
|
779
|
+
sessionOwnerLeaseGeneration: target.sessionOwnerLeaseGeneration,
|
|
780
|
+
sessionRid: target.sessionRid,
|
|
1025
781
|
bindingGeneration: target.bindingGeneration
|
|
1026
782
|
};
|
|
1027
783
|
const request: ServiceSessionRelocationSeal = {
|
|
784
|
+
targetNodeRid: relocationTarget.rid as string,
|
|
785
|
+
targetNodeGeneration: relocationTarget.lifecycleGeneration,
|
|
1028
786
|
relocation,
|
|
1029
787
|
coordinator,
|
|
1030
788
|
senderRole: 'source',
|
|
@@ -1032,7 +790,7 @@ export class ZLinkActorTransferRuntime {
|
|
|
1032
790
|
actor: {
|
|
1033
791
|
actorId: actor.context.actorId,
|
|
1034
792
|
generation: actorRef.generation,
|
|
1035
|
-
nodeRid:
|
|
793
|
+
nodeRid: sourceNodeRid
|
|
1036
794
|
},
|
|
1037
795
|
targetNodeGeneration: local.lifecycleGeneration,
|
|
1038
796
|
authorityOwnerGeneration: authority.authorityOwnerGeneration,
|
|
@@ -1040,12 +798,13 @@ export class ZLinkActorTransferRuntime {
|
|
|
1040
798
|
},
|
|
1041
799
|
session
|
|
1042
800
|
};
|
|
1043
|
-
await serviceWire.requestSessionRelocationSeal(
|
|
801
|
+
const response = await serviceWire.requestSessionRelocationSeal(
|
|
1044
802
|
target.routerChannelId,
|
|
1045
803
|
target.targetNodeRid,
|
|
1046
804
|
request,
|
|
1047
805
|
signal
|
|
1048
806
|
);
|
|
807
|
+
if (response.sealResult === 'bindingAbsent') return undefined;
|
|
1049
808
|
return {
|
|
1050
809
|
...target,
|
|
1051
810
|
previousAuthorityOwnerGeneration: authority.authorityOwnerGeneration,
|
|
@@ -1085,7 +844,7 @@ export class ZLinkActorTransferRuntime {
|
|
|
1085
844
|
actor: {
|
|
1086
845
|
actorId: actor.context.actorId,
|
|
1087
846
|
generation: actorRef.generation,
|
|
1088
|
-
nodeRid:
|
|
847
|
+
nodeRid: actorRef.nodeRid
|
|
1089
848
|
},
|
|
1090
849
|
session: serviceFence.session,
|
|
1091
850
|
route: {
|
|
@@ -1122,92 +881,6 @@ export class ZLinkActorTransferRuntime {
|
|
|
1122
881
|
}
|
|
1123
882
|
}
|
|
1124
883
|
|
|
1125
|
-
private beginCoreSourceLeave(actorId: string): {
|
|
1126
|
-
readonly completion: Promise<void>;
|
|
1127
|
-
readonly submitted: Promise<void>;
|
|
1128
|
-
} {
|
|
1129
|
-
let resolve!: () => void;
|
|
1130
|
-
let reject!: (error: unknown) => void;
|
|
1131
|
-
const promise = new Promise<void>((accept, fail) => {
|
|
1132
|
-
resolve = accept;
|
|
1133
|
-
reject = fail;
|
|
1134
|
-
});
|
|
1135
|
-
let resolveSubmitted!: () => void;
|
|
1136
|
-
let rejectSubmitted!: (error: unknown) => void;
|
|
1137
|
-
const submitted = new Promise<void>((accept, fail) => {
|
|
1138
|
-
resolveSubmitted = accept;
|
|
1139
|
-
rejectSubmitted = fail;
|
|
1140
|
-
});
|
|
1141
|
-
void promise.catch(() => {});
|
|
1142
|
-
void submitted.catch(() => {});
|
|
1143
|
-
this.coreSourceLeaves.set(actorId, {
|
|
1144
|
-
promise,
|
|
1145
|
-
resolve,
|
|
1146
|
-
reject,
|
|
1147
|
-
submitted,
|
|
1148
|
-
resolveSubmitted,
|
|
1149
|
-
rejectSubmitted
|
|
1150
|
-
});
|
|
1151
|
-
return { completion: promise, submitted };
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
private scheduleSourceDeparture(
|
|
1155
|
-
actor: ZLinkActor,
|
|
1156
|
-
sourceSpotId: RoutingId | undefined,
|
|
1157
|
-
releaseLocation: boolean,
|
|
1158
|
-
failures: unknown[] = []
|
|
1159
|
-
): void {
|
|
1160
|
-
void this.finishSourceDeparture(actor, sourceSpotId, releaseLocation, failures);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
private async finishSourceDeparture(
|
|
1164
|
-
actor: ZLinkActor,
|
|
1165
|
-
sourceSpotId: RoutingId | undefined,
|
|
1166
|
-
releaseLocation: boolean,
|
|
1167
|
-
failures: unknown[]
|
|
1168
|
-
): Promise<void> {
|
|
1169
|
-
if (sourceSpotId !== undefined) {
|
|
1170
|
-
try {
|
|
1171
|
-
await this.options
|
|
1172
|
-
.spotManager()
|
|
1173
|
-
?.commitActorLeaveAfterTransfer(sourceSpotId, actor.context.actorId);
|
|
1174
|
-
} catch (error) {
|
|
1175
|
-
failures.push(error);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
if (releaseLocation) {
|
|
1179
|
-
try {
|
|
1180
|
-
const state = this.options.actorManager()?.getState(actor.context.actorId);
|
|
1181
|
-
if (state?.actorType !== undefined && state.ownsLocation) {
|
|
1182
|
-
await this.options
|
|
1183
|
-
.locationLifecycle()
|
|
1184
|
-
?.releaseActor(state.actorType, actor.context.actorId);
|
|
1185
|
-
state.markLocationReleased();
|
|
1186
|
-
}
|
|
1187
|
-
} catch (error) {
|
|
1188
|
-
failures.push(error);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
try {
|
|
1192
|
-
// Message Follow keeps its route separately from the retired application instance.
|
|
1193
|
-
await this.options.actorManager()?.completeCoreRelocationSource(actor.context.actorId);
|
|
1194
|
-
} catch (error) {
|
|
1195
|
-
failures.push(error);
|
|
1196
|
-
}
|
|
1197
|
-
try {
|
|
1198
|
-
this.options.onSourceDepartureCompleted?.(actor.context.actorId);
|
|
1199
|
-
} catch (error) {
|
|
1200
|
-
failures.push(error);
|
|
1201
|
-
}
|
|
1202
|
-
if (failures.length > 0) {
|
|
1203
|
-
this.options.reportPostCommitError?.(
|
|
1204
|
-
failures.length === 1
|
|
1205
|
-
? failures[0]
|
|
1206
|
-
: new AggregateError(failures, 'Actor source retirement failed.')
|
|
1207
|
-
);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
884
|
async getOrCreateRoutedActor(
|
|
1212
885
|
actorId: string,
|
|
1213
886
|
actorType: string,
|
|
@@ -1535,7 +1208,7 @@ export class ZLinkActorTransferRuntime {
|
|
|
1535
1208
|
if (
|
|
1536
1209
|
authority?.kind === 'snapshot' &&
|
|
1537
1210
|
authority.allocation.state === 'active' &&
|
|
1538
|
-
|
|
1211
|
+
routingIdsEqual(authority.allocation.descriptor.rid, node.status().routingId) &&
|
|
1539
1212
|
authority.allocation.descriptorLifecycleGeneration === ownerNodeGeneration
|
|
1540
1213
|
) {
|
|
1541
1214
|
state.setLocationGeneration(authority.authorityOwnerGeneration);
|
|
@@ -1700,10 +1373,11 @@ export class ZLinkActorTransferRuntime {
|
|
|
1700
1373
|
authority.objectGeneration !== actorRef.generation ||
|
|
1701
1374
|
authority.authorityOwnerGeneration !== ownershipGeneration ||
|
|
1702
1375
|
authority.ownerLeaseGeneration !== targetOwnerLeaseGeneration ||
|
|
1703
|
-
|
|
1376
|
+
!routingIdsEqual(authority.allocation.descriptor.rid, actorRef.nodeRid)
|
|
1704
1377
|
) {
|
|
1705
1378
|
throw new Error(`Actor '${actorId}' command 44 target authority fence is stale.`);
|
|
1706
1379
|
}
|
|
1380
|
+
const targetNodeRid = actorRef.nodeRid;
|
|
1707
1381
|
await serviceWire.sendSessionRelocationRoute(
|
|
1708
1382
|
target.routerChannelId,
|
|
1709
1383
|
target.targetNodeRid,
|
|
@@ -1714,14 +1388,14 @@ export class ZLinkActorTransferRuntime {
|
|
|
1714
1388
|
actor: {
|
|
1715
1389
|
actorId,
|
|
1716
1390
|
generation: actorRef.generation,
|
|
1717
|
-
nodeRid:
|
|
1391
|
+
nodeRid: targetNodeRid
|
|
1718
1392
|
},
|
|
1719
1393
|
session: serviceFence.session,
|
|
1720
1394
|
route: {
|
|
1721
1395
|
action: 'commit',
|
|
1722
1396
|
previousAuthorityOwnerGeneration: target.previousAuthorityOwnerGeneration,
|
|
1723
1397
|
targetAuthorityOwnerGeneration: ownershipGeneration,
|
|
1724
|
-
targetNodeRid
|
|
1398
|
+
targetNodeRid,
|
|
1725
1399
|
targetNodeGeneration: authority.allocation.descriptorLifecycleGeneration,
|
|
1726
1400
|
targetOwnerLeaseGeneration: authority.ownerLeaseGeneration
|
|
1727
1401
|
}
|