@zlink-systems/framework 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Common/ZLinkMessage.js +5 -5
- package/dist/contracts/Configuration/CodecContentType.js +5 -7
- package/dist/contracts/Configuration/DiagnosticsValidation.js +1 -6
- package/dist/contracts/Configuration/EndpointNotation.js +4 -8
- package/dist/contracts/Configuration/Registration.js +14 -11
- package/dist/contracts/Configuration/RegistrationBuilders.js +32 -25
- package/dist/contracts/Configuration/RegistrationNormalizers.js +25 -26
- package/dist/contracts/Configuration/RegistrationValidators.js +36 -38
- package/dist/contracts/Configuration/SendTimeoutValidation.js +4 -4
- package/dist/contracts/Configuration/TimerRegistrationValidator.js +7 -7
- package/dist/contracts/Handlers/JsonContract.js +23 -11
- package/dist/contracts/Spots/SpotKind.js +16 -8
- package/dist/location-store-integration.js +16 -16
- package/dist/nest-integration.js +17 -11
- package/dist/runtime/abort.js +9 -5
- package/dist/runtime/actors/actor-authority-payload-codec.js +12 -16
- package/dist/runtime/actors/actor-authority-publication.js +18 -17
- package/dist/runtime/actors/actor-client.js +83 -63
- package/dist/runtime/actors/actor-context.js +24 -18
- package/dist/runtime/actors/actor-creation.js +4 -3
- package/dist/runtime/actors/actor-handoff.js +89 -92
- package/dist/runtime/actors/actor-local-native-join.js +18 -19
- package/dist/runtime/actors/actor-mailbox.js +1 -1
- package/dist/runtime/actors/actor-message-follow-context.js +24 -21
- package/dist/runtime/actors/actor-packet-relay-wire.js +1 -3
- package/dist/runtime/actors/actor-remote-joiner.js +20 -17
- package/dist/runtime/actors/actor-remote-wire.js +6 -7
- package/dist/runtime/actors/actor-runtime-state.js +87 -81
- package/dist/runtime/actors/actor-transfer-registry.js +3 -5
- package/dist/runtime/actors/bound-session-wire.js +14 -9
- package/dist/runtime/actors/deferred-join-accepted-journal.js +158 -124
- package/dist/runtime/actors/index.js +2 -5
- package/dist/runtime/actors/post-commit-actor-binder.js +3 -6
- package/dist/runtime/actors/post-commit-actor-location.js +1 -1
- package/dist/runtime/actors/spot-actor-dispatch.js +5 -5
- package/dist/runtime/actors/transferred-actor-rollback.js +4 -4
- package/dist/runtime/admission.js +2 -6
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +2 -6
- package/dist/runtime/application-jobs/receive-flow-controller.js +11 -12
- package/dist/runtime/backend/mesh-completion-table.js +1 -3
- package/dist/runtime/backend/mesh-dispatch-pump.js +12 -16
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +1 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +26 -17
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +4 -3
- package/dist/runtime/backend/node/node-raw-binding-port.js +7 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +116 -113
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +12 -13
- package/dist/runtime/backend/runtime-message.js +3 -3
- package/dist/runtime/backend/runtime-values.d.ts +2 -2
- package/dist/runtime/backend/runtime-values.js +4 -5
- package/dist/runtime/channels/channel-clients.js +27 -24
- package/dist/runtime/channels/channel-dispatch-pipeline.js +10 -18
- package/dist/runtime/channels/channel-dispatch-services.js +7 -4
- package/dist/runtime/channels/channel-dispatchers.js +9 -9
- package/dist/runtime/channels/channel-envelope-inspection.js +16 -13
- package/dist/runtime/channels/channel-envelope.js +83 -47
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-receive-loops.js +20 -22
- package/dist/runtime/channels/channel-receive-task-tracker.js +1 -1
- package/dist/runtime/channels/channel-runtime-lifecycle.js +61 -56
- package/dist/runtime/channels/channel-runtime-manager.js +18 -9
- package/dist/runtime/channels/channel-socket-registry.js +126 -123
- package/dist/runtime/channels/channel-transports.js +43 -33
- package/dist/runtime/channels/client-server-location-runtime.js +32 -40
- package/dist/runtime/channels/client-server-service-wire.js +29 -22
- package/dist/runtime/channels/dispatch-error-reporter.js +9 -7
- package/dist/runtime/channels/fanout-location-runtime.js +34 -47
- package/dist/runtime/channels/fanout-service-wire.js +3 -5
- package/dist/runtime/channels/local-spot-route-transport.js +7 -1
- package/dist/runtime/channels/route-member-snapshot.js +3 -3
- package/dist/runtime/channels/source-spot-router.js +6 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +5 -2
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +2 -2
- package/dist/runtime/channels/spot-route-target-resolver.js +6 -6
- package/dist/runtime/diagnostics/index.js +38 -10
- package/dist/runtime/diagnostics/message-flow.js +47 -39
- package/dist/runtime/diagnostics/runtime-metrics.js +18 -9
- package/dist/runtime/diagnostics/runtime-observation-queue.js +8 -10
- package/dist/runtime/diagnostics/topology-runtime-projections.js +17 -10
- package/dist/runtime/execution/index.js +7 -6
- package/dist/runtime/execution/serial-execution-queue.js +12 -18
- package/dist/runtime/execution/state-lane.js +2 -2
- package/dist/runtime/foundation/actor-join-recovery-codec.js +31 -23
- package/dist/runtime/foundation/event-loop-resources.js +4 -4
- package/dist/runtime/foundation/message-follow-suppression-registry.js +4 -4
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +136 -136
- package/dist/runtime/foundation/route-mesh-connection-policy.js +4 -4
- package/dist/runtime/foundation/runtime-state-projections.js +22 -11
- package/dist/runtime/foundation/service-authority-payload-codec.js +13 -15
- package/dist/runtime/foundation/service-discovery-registry.js +35 -33
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +20 -22
- package/dist/runtime/foundation/service-liveness-registry.js +16 -12
- package/dist/runtime/foundation/service-maintenance-runtime.js +2 -4
- package/dist/runtime/foundation/service-relocation-aggregate-committer.js +24 -24
- package/dist/runtime/foundation/service-relocation-object-owner.js +6 -6
- package/dist/runtime/foundation/service-relocation-runtime.js +137 -94
- package/dist/runtime/foundation/service-runtime-contracts.js +5 -5
- package/dist/runtime/foundation/service-stateful-registry.js +24 -23
- package/dist/runtime/foundation/service-stateful-runtime.js +416 -438
- package/dist/runtime/foundation/service-stateful-wire-codec.js +95 -98
- package/dist/runtime/foundation/service-topology-registry.js +96 -95
- package/dist/runtime/foundation/service-weighted-selection.js +6 -11
- package/dist/runtime/foundation/service-wire-binary-primitives.js +5 -6
- package/dist/runtime/foundation/service-wire-m6a-codec.js +46 -35
- package/dist/runtime/framework-errors-internal.js +7 -10
- package/dist/runtime/handlers/handler-instance-scope.js +4 -5
- package/dist/runtime/handlers/index.js +3 -1
- package/dist/runtime/host/actor-packet-relay.js +74 -70
- package/dist/runtime/host/actor-placement-coordinator.js +29 -31
- package/dist/runtime/host/actor-runtime-options-factory.js +12 -14
- package/dist/runtime/host/actor-transfer-authority-runtime.js +7 -9
- package/dist/runtime/host/actor-transfer-runtime.js +176 -153
- package/dist/runtime/host/application-job-queue.js +18 -22
- package/dist/runtime/host/bound-session-relay.js +3 -1
- package/dist/runtime/host/channel-runtime-options-factory.js +31 -14
- package/dist/runtime/host/host-capacity-status.js +8 -4
- package/dist/runtime/host/index.js +244 -227
- package/dist/runtime/host/instance-activation-authority.js +93 -96
- package/dist/runtime/host/location-runtime-owner.js +16 -14
- package/dist/runtime/host/mesh-router-resolver.js +11 -13
- package/dist/runtime/host/relocation-direct-transfer.js +10 -9
- package/dist/runtime/host/remote-actor-join-receiver.js +20 -15
- package/dist/runtime/host/remote-actor-packet-target-store.js +18 -22
- package/dist/runtime/host/remote-bound-session-relay.js +97 -73
- package/dist/runtime/host/route-mesh-runtime.js +64 -69
- package/dist/runtime/host/runtime-shutdown.js +1 -2
- package/dist/runtime/host/service-relocation-host-runtime.js +586 -511
- package/dist/runtime/host/spot-address-transport.js +69 -71
- package/dist/runtime/host/spot-runtime-options-factory.js +30 -29
- package/dist/runtime/host/stateful-authority-route-runtime.js +65 -68
- package/dist/runtime/host/user-spot-creation-coordinator.js +61 -67
- package/dist/runtime/locations/actor-location-claims.js +26 -20
- package/dist/runtime/locations/aggregate-inventory-store.js +72 -75
- package/dist/runtime/locations/authority-key-codec.js +7 -7
- package/dist/runtime/locations/auto-connect-loop.js +3 -3
- package/dist/runtime/locations/auto-connect-planner.js +25 -19
- package/dist/runtime/locations/auto-connect-reconciler.js +51 -31
- package/dist/runtime/locations/in-memory-authority-store.js +128 -118
- package/dist/runtime/locations/in-memory-location-store.js +195 -168
- package/dist/runtime/locations/in-memory-provider-location-store.js +8 -10
- package/dist/runtime/locations/key-codec.js +1 -1
- package/dist/runtime/locations/lease-tracker.js +23 -21
- package/dist/runtime/locations/lifecycle.js +4 -5
- package/dist/runtime/locations/location-store-repository.js +368 -324
- package/dist/runtime/locations/opaque-record-key.js +2 -2
- package/dist/runtime/locations/resolvers.js +73 -82
- package/dist/runtime/locations/runtime.js +68 -63
- package/dist/runtime/locations/spot-location-claims.js +39 -35
- package/dist/runtime/messaging/framework-json-v1.js +7 -7
- package/dist/runtime/messaging/packet-name.js +7 -6
- package/dist/runtime/messaging/payload-codec.js +21 -18
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +30 -2
- package/dist/runtime/protocol/service_wire_codec.generated.js +1671 -234
- package/dist/runtime/routing-id.js +3 -5
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +35 -31
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.js +1 -2
- package/dist/runtime/spots/index.js +208 -219
- package/dist/runtime/spots/spot-activation-registry.js +15 -14
- package/dist/runtime/spots/spot-activation-state.js +17 -15
- package/dist/runtime/spots/spot-activation.js +33 -16
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +18 -15
- package/dist/runtime/spots/spot-actor-membership.js +1 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +23 -20
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -10
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +10 -6
- package/dist/runtime/spots/spot-closing.js +3 -7
- package/dist/runtime/spots/spot-context.js +2 -2
- package/dist/runtime/spots/spot-entry-activation.js +13 -14
- package/dist/runtime/spots/spot-handle.js +6 -3
- package/dist/runtime/spots/spot-handler-registry.js +12 -12
- package/dist/runtime/spots/spot-manager-public.js +5 -6
- package/dist/runtime/spots/spot-native-actor-join-admission.js +4 -3
- package/dist/runtime/spots/spot-node-autoconnect.js +15 -18
- package/dist/runtime/spots/spot-node-runtime-manager.js +74 -85
- package/dist/runtime/spots/spot-outbound.js +10 -14
- package/dist/runtime/spots/spot-remote-codec.js +22 -26
- package/dist/runtime/spots/spot-remote-route-codec.js +5 -7
- package/dist/runtime/spots/spot-route-packet-dispatch.js +16 -14
- package/dist/runtime/spots/spot-route-replies.js +4 -6
- package/dist/runtime/spots/spot-routed-actor-admission.js +9 -7
- package/dist/runtime/spots/spot-routed-bound-session-dispatch.js +1 -2
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +5 -5
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +14 -10
- package/dist/runtime/spots/spot-serial-executor.js +5 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +4 -6
- package/dist/runtime/spots/spot-subscription-dispatch.js +5 -5
- package/dist/runtime/spots/spot-timer.js +25 -29
- package/dist/runtime/streams/actor-session-binding-registry.js +98 -107
- package/dist/runtime/streams/actor-session-lifecycle-coordinator.js +3 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +18 -16
- package/dist/runtime/streams/bound-session-service.js +8 -9
- package/dist/runtime/streams/index.js +20 -19
- package/dist/runtime/streams/managed-stream.js +32 -30
- package/dist/runtime/streams/native-fallback-bound-session.js +21 -17
- package/dist/runtime/streams/protocol.js +29 -18
- package/dist/runtime/streams/session-actor-coordinator.js +34 -37
- package/dist/runtime/streams/session-context.js +30 -28
- package/dist/runtime/streams/session-provider.js +2 -2
- package/dist/runtime/streams/session-serial-executor.js +1 -2
- package/dist/runtime/streams/stream-frame-factory.js +11 -5
- package/dist/runtime/streams/stream-session-runtime.js +70 -66
- package/dist/runtime/workers/index.js +15 -4
- package/package.json +2 -2
- package/src/contracts/Channels/RouteCalls.ts +6 -1
- package/src/contracts/Common/ZLinkMessage.ts +5 -5
- package/src/contracts/Common/ZLinkMessageMetadata.ts +4 -3
- package/src/contracts/Configuration/Builders.ts +14 -14
- package/src/contracts/Configuration/CodecContentType.ts +8 -10
- package/src/contracts/Configuration/DiagnosticsValidation.ts +1 -6
- package/src/contracts/Configuration/EndpointNotation.ts +11 -11
- package/src/contracts/Configuration/ObjectRoles.ts +1 -3
- package/src/contracts/Configuration/Registration.ts +46 -17
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +10 -8
- package/src/contracts/Configuration/RegistrationBuilders.ts +107 -96
- package/src/contracts/Configuration/RegistrationCodecRegistry.ts +9 -3
- package/src/contracts/Configuration/RegistrationNormalizers.ts +116 -84
- package/src/contracts/Configuration/RegistrationTypes.ts +21 -25
- package/src/contracts/Configuration/RegistrationValidators.ts +122 -73
- package/src/contracts/Configuration/RouteChannelInternalState.ts +1 -4
- package/src/contracts/Configuration/RuntimeEndpointConnections.ts +4 -1
- package/src/contracts/Configuration/SendTimeoutValidation.ts +6 -4
- package/src/contracts/Configuration/TimerRegistrationValidator.ts +8 -13
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -6
- package/src/contracts/Errors/index.ts +1 -4
- package/src/contracts/Handlers/Attributes.ts +15 -9
- package/src/contracts/Handlers/IZLinkChannelHandlers.ts +24 -4
- package/src/contracts/Handlers/JsonContract.ts +53 -19
- package/src/contracts/Locations/ActorTransfer.ts +1 -5
- package/src/contracts/Locations/Authority.ts +4 -11
- package/src/contracts/Locations/Keys.ts +6 -1
- package/src/contracts/Locations/Options.ts +3 -2
- package/src/contracts/Locations/RelocationStore.ts +1 -4
- package/src/contracts/Locations/Resolvers.ts +5 -5
- package/src/contracts/Locations/RuntimeQuery.ts +6 -2
- package/src/contracts/Locations/Stores.ts +1 -2
- package/src/contracts/Locations/index.ts +2 -8
- package/src/contracts/RouteMesh/Contracts.ts +1 -7
- package/src/contracts/RouteMesh/RuntimeTopology.ts +1 -4
- package/src/contracts/Spots/Contracts.ts +2 -8
- package/src/contracts/Spots/SpotKind.ts +16 -8
- package/src/contracts/Spots/ZLinkSpot.ts +8 -11
- package/src/contracts/Streams/IZLinkSession.ts +0 -1
- package/src/contracts/Streams/IZLinkSessionActor.ts +5 -1
- package/src/contracts/Streams/IZLinkSessionPacketHandler.ts +5 -1
- package/src/internal.ts +5 -4
- package/src/location-store-integration.ts +24 -16
- package/src/nest-integration.ts +40 -25
- package/src/runtime/abort.ts +10 -4
- package/src/runtime/actors/actor-authority-payload-codec.ts +20 -29
- package/src/runtime/actors/actor-authority-publication.ts +92 -77
- package/src/runtime/actors/actor-client.ts +162 -133
- package/src/runtime/actors/actor-context.ts +138 -130
- package/src/runtime/actors/actor-creation.ts +47 -44
- package/src/runtime/actors/actor-execution-context.ts +6 -4
- package/src/runtime/actors/actor-handoff.ts +269 -293
- package/src/runtime/actors/actor-join-deferred-scope.ts +5 -4
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +5 -8
- package/src/runtime/actors/actor-local-native-join.ts +131 -159
- package/src/runtime/actors/actor-mailbox.ts +16 -19
- package/src/runtime/actors/actor-message-follow-context.ts +46 -36
- package/src/runtime/actors/actor-packet-relay-wire.ts +32 -21
- package/src/runtime/actors/actor-remote-joiner.ts +50 -54
- package/src/runtime/actors/actor-remote-wire.ts +9 -13
- package/src/runtime/actors/actor-routed-join-transport.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -5
- package/src/runtime/actors/actor-runtime-state.ts +127 -124
- package/src/runtime/actors/actor-transfer-registry.ts +9 -14
- package/src/runtime/actors/actor-transport-delivery-gate.ts +4 -6
- package/src/runtime/actors/bound-session-wire.ts +37 -17
- package/src/runtime/actors/deferred-join-accepted-journal.ts +351 -320
- package/src/runtime/actors/index.ts +43 -86
- package/src/runtime/actors/post-commit-actor-binder.ts +10 -10
- package/src/runtime/actors/post-commit-actor-location.ts +30 -23
- package/src/runtime/actors/spot-actor-dispatch.ts +78 -53
- package/src/runtime/actors/transferred-actor-rollback.ts +18 -13
- package/src/runtime/admission.ts +9 -9
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +5 -15
- package/src/runtime/application-jobs/application-job-queue-handler-start-gate.ts +3 -2
- package/src/runtime/application-jobs/receive-flow-controller.ts +17 -14
- package/src/runtime/backend/contracts/index.ts +73 -52
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +4 -14
- package/src/runtime/backend/mesh-completion-table.ts +6 -9
- package/src/runtime/backend/mesh-dispatch-pump.ts +38 -30
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +23 -21
- package/src/runtime/backend/node/node-backend-adapter-support.ts +36 -22
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +59 -58
- package/src/runtime/backend/node/node-event-loop-poller.ts +2 -10
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +12 -5
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +4 -3
- package/src/runtime/backend/node/node-raw-binding-port.ts +29 -29
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +335 -383
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +101 -54
- package/src/runtime/backend/runtime-message.ts +5 -3
- package/src/runtime/backend/runtime-values.ts +10 -7
- package/src/runtime/channels/channel-autoconnect.ts +1 -4
- package/src/runtime/channels/channel-clients.ts +93 -73
- package/src/runtime/channels/channel-dispatch-pipeline.ts +40 -42
- package/src/runtime/channels/channel-dispatch-services.ts +51 -49
- package/src/runtime/channels/channel-dispatchers.ts +152 -96
- package/src/runtime/channels/channel-envelope-inspection.ts +20 -16
- package/src/runtime/channels/channel-envelope.ts +256 -150
- package/src/runtime/channels/channel-multipart.ts +13 -5
- package/src/runtime/channels/channel-outbound-operations.ts +37 -41
- package/src/runtime/channels/channel-receive-loops.ts +102 -98
- package/src/runtime/channels/channel-receive-task-tracker.ts +1 -1
- package/src/runtime/channels/channel-runtime-lifecycle.ts +248 -190
- package/src/runtime/channels/channel-runtime-manager.ts +63 -37
- package/src/runtime/channels/channel-socket-options.ts +3 -10
- package/src/runtime/channels/channel-socket-registry.ts +331 -273
- package/src/runtime/channels/channel-transports.ts +215 -197
- package/src/runtime/channels/client-server-location-runtime.ts +116 -100
- package/src/runtime/channels/client-server-service-wire.ts +37 -36
- package/src/runtime/channels/dispatch-error-reporter.ts +11 -8
- package/src/runtime/channels/fanout-location-runtime.ts +91 -94
- package/src/runtime/channels/fanout-service-wire.ts +5 -12
- package/src/runtime/channels/handler-filter-scope.ts +1 -4
- package/src/runtime/channels/index.ts +1 -4
- package/src/runtime/channels/local-spot-route-transport.ts +20 -5
- package/src/runtime/channels/route-member-snapshot.ts +11 -5
- package/src/runtime/channels/router-socket-spot-route-transport.ts +1 -7
- package/src/runtime/channels/source-spot-router.ts +26 -22
- package/src/runtime/channels/spot-direct-envelope.ts +10 -8
- package/src/runtime/channels/spot-node-route-transport.ts +13 -16
- package/src/runtime/channels/spot-route-bridge-transport.ts +26 -9
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +40 -13
- package/src/runtime/channels/spot-route-target-resolver.ts +18 -9
- package/src/runtime/codecs/index.ts +3 -2
- package/src/runtime/diagnostics/flow-context.ts +12 -3
- package/src/runtime/diagnostics/index.ts +96 -61
- package/src/runtime/diagnostics/internal-event-contracts.ts +87 -33
- package/src/runtime/diagnostics/message-flow.ts +95 -76
- package/src/runtime/diagnostics/runtime-metrics.ts +46 -24
- package/src/runtime/diagnostics/runtime-observation-queue.ts +17 -28
- package/src/runtime/diagnostics/topology-runtime-projections.ts +62 -43
- package/src/runtime/execution/index.ts +18 -26
- package/src/runtime/execution/serial-execution-queue.ts +31 -40
- package/src/runtime/execution/state-lane.ts +2 -2
- package/src/runtime/foundation/actor-join-recovery-codec.ts +69 -51
- package/src/runtime/foundation/event-loop-resources.ts +8 -4
- package/src/runtime/foundation/message-follow-suppression-registry.ts +7 -14
- package/src/runtime/foundation/operation-identity.ts +1 -2
- package/src/runtime/foundation/operation-registry.ts +8 -2
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +312 -385
- package/src/runtime/foundation/route-mesh-connection-policy.ts +7 -8
- package/src/runtime/foundation/runtime-state-projections.ts +24 -23
- package/src/runtime/foundation/service-authority-payload-codec.ts +54 -57
- package/src/runtime/foundation/service-discovery-registry.ts +67 -59
- package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +28 -29
- package/src/runtime/foundation/service-liveness-registry.ts +18 -13
- package/src/runtime/foundation/service-mailbox.ts +14 -14
- package/src/runtime/foundation/service-maintenance-runtime.ts +22 -21
- package/src/runtime/foundation/service-metadata-codec.ts +2 -9
- package/src/runtime/foundation/service-relocation-aggregate-committer.ts +39 -36
- package/src/runtime/foundation/service-relocation-coordinator.ts +1 -4
- package/src/runtime/foundation/service-relocation-object-owner.ts +40 -58
- package/src/runtime/foundation/service-relocation-runtime.ts +292 -216
- package/src/runtime/foundation/service-runtime-contracts.ts +8 -8
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +1 -4
- package/src/runtime/foundation/service-stateful-registry.ts +69 -59
- package/src/runtime/foundation/service-stateful-runtime.ts +1174 -1112
- package/src/runtime/foundation/service-stateful-wire-codec.ts +318 -270
- package/src/runtime/foundation/service-topology-registry.ts +157 -159
- package/src/runtime/foundation/service-weighted-selection.ts +9 -15
- package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -12
- package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -47
- package/src/runtime/framework-errors-internal.ts +31 -30
- package/src/runtime/handlers/handler-instance-scope.ts +18 -29
- package/src/runtime/handlers/index.ts +18 -8
- package/src/runtime/host/actor-packet-relay.ts +290 -261
- package/src/runtime/host/actor-placement-coordinator.ts +165 -150
- package/src/runtime/host/actor-runtime-options-factory.ts +89 -87
- package/src/runtime/host/actor-transfer-authority-runtime.ts +46 -38
- package/src/runtime/host/actor-transfer-runtime.ts +391 -395
- package/src/runtime/host/application-job-queue.ts +32 -48
- package/src/runtime/host/bound-session-relay.ts +7 -9
- package/src/runtime/host/channel-runtime-options-factory.ts +75 -35
- package/src/runtime/host/host-capacity-status.ts +10 -9
- package/src/runtime/host/index.ts +861 -789
- package/src/runtime/host/instance-activation-authority.ts +125 -143
- package/src/runtime/host/location-runtime-owner.ts +38 -26
- package/src/runtime/host/mesh-router-resolver.ts +30 -23
- package/src/runtime/host/relocation-direct-transfer.ts +15 -15
- package/src/runtime/host/relocation-integrity-fault-gate.ts +3 -2
- package/src/runtime/host/remote-actor-join-receiver.ts +43 -34
- package/src/runtime/host/remote-actor-packet-target-store.ts +54 -52
- package/src/runtime/host/remote-bound-session-relay.ts +274 -247
- package/src/runtime/host/route-mesh-runtime-options.ts +1 -3
- package/src/runtime/host/route-mesh-runtime.ts +227 -181
- package/src/runtime/host/runtime-shutdown.ts +4 -3
- package/src/runtime/host/service-relocation-control.ts +14 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1388 -1165
- package/src/runtime/host/spot-address-transport.ts +284 -237
- package/src/runtime/host/spot-node-runtime-options-factory.ts +14 -8
- package/src/runtime/host/spot-runtime-options-factory.ts +71 -62
- package/src/runtime/host/stateful-authority-route-runtime.ts +117 -116
- package/src/runtime/host/user-spot-creation-coordinator.ts +225 -220
- package/src/runtime/locations/actor-location-claims.ts +61 -49
- package/src/runtime/locations/actor-session-route-claims.ts +1 -4
- package/src/runtime/locations/aggregate-inventory-store.ts +105 -134
- package/src/runtime/locations/authority-key-codec.ts +13 -10
- package/src/runtime/locations/auto-connect-loop.ts +14 -11
- package/src/runtime/locations/auto-connect-planner.ts +42 -31
- package/src/runtime/locations/auto-connect-reconciler.ts +106 -63
- package/src/runtime/locations/canonical-codec.ts +3 -1
- package/src/runtime/locations/creation-operation-id.ts +4 -3
- package/src/runtime/locations/domain-store-contract.ts +13 -7
- package/src/runtime/locations/in-memory-authority-store.ts +232 -199
- package/src/runtime/locations/in-memory-location-store.ts +432 -250
- package/src/runtime/locations/in-memory-provider-location-store.ts +16 -17
- package/src/runtime/locations/internal-store-contracts.ts +95 -38
- package/src/runtime/locations/key-codec.ts +3 -4
- package/src/runtime/locations/lease-tracker.ts +36 -27
- package/src/runtime/locations/lifecycle-runtime.ts +15 -3
- package/src/runtime/locations/lifecycle.ts +33 -28
- package/src/runtime/locations/location-store-repository.ts +1329 -1185
- package/src/runtime/locations/opaque-record-key.ts +4 -9
- package/src/runtime/locations/resolvers.ts +201 -178
- package/src/runtime/locations/runtime.ts +251 -159
- package/src/runtime/locations/spot-location-claims.ts +110 -112
- package/src/runtime/messaging/creation-payload-codec.ts +4 -1
- package/src/runtime/messaging/framework-json-v1.ts +34 -15
- package/src/runtime/messaging/packet-name.ts +8 -6
- package/src/runtime/messaging/payload-codec.ts +70 -50
- package/src/runtime/messaging/submission-result.ts +6 -9
- package/src/runtime/protocol/service_wire_codec.generated.ts +1376 -159
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/routing-id.ts +10 -7
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +56 -62
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +23 -20
- package/src/runtime/spots/index.ts +593 -563
- package/src/runtime/spots/spot-activation-registry.ts +38 -34
- package/src/runtime/spots/spot-activation-state.ts +43 -51
- package/src/runtime/spots/spot-activation.ts +179 -116
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +110 -78
- package/src/runtime/spots/spot-actor-join-dispatch.ts +57 -41
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +5 -7
- package/src/runtime/spots/spot-actor-membership.ts +25 -27
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +184 -153
- package/src/runtime/spots/spot-actor-packet-drain.ts +54 -42
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +37 -39
- package/src/runtime/spots/spot-closing.ts +11 -12
- package/src/runtime/spots/spot-context.ts +46 -26
- package/src/runtime/spots/spot-entry-activation.ts +84 -65
- package/src/runtime/spots/spot-handle.ts +17 -15
- package/src/runtime/spots/spot-handler-registry.ts +44 -31
- package/src/runtime/spots/spot-location-claim.ts +5 -4
- package/src/runtime/spots/spot-manager-public.ts +62 -82
- package/src/runtime/spots/spot-native-actor-join-admission.ts +20 -16
- package/src/runtime/spots/spot-node-autoconnect.ts +54 -61
- package/src/runtime/spots/spot-node-runtime-manager.ts +230 -221
- package/src/runtime/spots/spot-outbound.ts +47 -59
- package/src/runtime/spots/spot-publisher-transport.ts +5 -4
- package/src/runtime/spots/spot-remote-codec.ts +66 -65
- package/src/runtime/spots/spot-remote-route-codec.ts +61 -41
- package/src/runtime/spots/spot-route-packet-dispatch.ts +128 -95
- package/src/runtime/spots/spot-route-replies.ts +23 -24
- package/src/runtime/spots/spot-route-reply-wire.ts +3 -2
- package/src/runtime/spots/spot-routed-actor-admission.ts +37 -27
- package/src/runtime/spots/spot-routed-bound-session-dispatch.ts +11 -17
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +18 -15
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +35 -26
- package/src/runtime/spots/spot-routing-internal.ts +1 -4
- package/src/runtime/spots/spot-runtime-ports.ts +5 -5
- package/src/runtime/spots/spot-serial-executor.ts +5 -9
- package/src/runtime/spots/spot-serial-turn-executor.ts +19 -26
- package/src/runtime/spots/spot-subscription-dispatch.ts +56 -46
- package/src/runtime/spots/spot-timer.ts +98 -91
- package/src/runtime/streams/actor-session-binding-registry.ts +277 -235
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +7 -4
- package/src/runtime/streams/actor-session-lifecycle-coordinator.ts +3 -1
- package/src/runtime/streams/bound-actor-relay-sender.ts +53 -51
- package/src/runtime/streams/bound-session-response-target.ts +29 -8
- package/src/runtime/streams/bound-session-service.ts +39 -39
- package/src/runtime/streams/index.ts +176 -100
- package/src/runtime/streams/managed-stream.ts +98 -87
- package/src/runtime/streams/native-fallback-bound-session.ts +57 -52
- package/src/runtime/streams/protocol.ts +73 -43
- package/src/runtime/streams/session-actor-coordinator.ts +97 -89
- package/src/runtime/streams/session-calls.ts +2 -8
- package/src/runtime/streams/session-context.ts +66 -48
- package/src/runtime/streams/session-provider.ts +5 -7
- package/src/runtime/streams/session-serial-executor.ts +7 -6
- package/src/runtime/streams/stream-binding-runtime-ports.ts +79 -29
- package/src/runtime/streams/stream-frame-factory.ts +55 -38
- package/src/runtime/streams/stream-session-runtime.ts +268 -210
- package/src/runtime/workers/index.ts +68 -29
|
@@ -352,11 +352,10 @@ export type ServiceSessionRelocationRoute =
|
|
|
352
352
|
};
|
|
353
353
|
|
|
354
354
|
export function serviceSessionRelocationIdentityKey(
|
|
355
|
-
value:
|
|
355
|
+
value:
|
|
356
|
+
ServiceSessionRelocationSeal | ServiceSessionRelocationSealed | ServiceSessionRelocationRoute
|
|
356
357
|
): string {
|
|
357
|
-
const actor = 'targetNodeGeneration' in value.actor
|
|
358
|
-
? value.actor.actor
|
|
359
|
-
: value.actor;
|
|
358
|
+
const actor = 'targetNodeGeneration' in value.actor ? value.actor.actor : value.actor;
|
|
360
359
|
// Session owner가 seal을 대조할 때 쓰는 값만 넣는다 — Session과 Actor binding
|
|
361
360
|
// §8.1 "Session owner는 다음 값만 검증한다". coordinator identity는 transport가
|
|
362
361
|
// 검증하는 wire fence이므로 여기서 다시 대조하지 않는다.
|
|
@@ -434,9 +433,7 @@ function toGeneratedUserSpotClose(
|
|
|
434
433
|
};
|
|
435
434
|
}
|
|
436
435
|
|
|
437
|
-
function fromGeneratedUserSpotClose(
|
|
438
|
-
value: GeneratedUserSpotClose48
|
|
439
|
-
): ServiceUserSpotCloseRecord {
|
|
436
|
+
function fromGeneratedUserSpotClose(value: GeneratedUserSpotClose48): ServiceUserSpotCloseRecord {
|
|
440
437
|
return {
|
|
441
438
|
kind: 'userSpotClose',
|
|
442
439
|
correlation: value.correlation,
|
|
@@ -696,12 +693,13 @@ function fromGeneratedSessionRelocationSealed(
|
|
|
696
693
|
function toGeneratedSessionRelocationRoute(
|
|
697
694
|
value: ServiceSessionRelocationRoute
|
|
698
695
|
): GeneratedSessionRelocationRoute44 {
|
|
699
|
-
const route =
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
696
|
+
const route =
|
|
697
|
+
value.route.action === 'commit'
|
|
698
|
+
? {
|
|
699
|
+
...value.route,
|
|
700
|
+
targetNodeRid: toGeneratedRoutingId(value.route.targetNodeRid, 'targetNodeRid')
|
|
701
|
+
}
|
|
702
|
+
: value.route;
|
|
705
703
|
return {
|
|
706
704
|
relocation: value.relocation,
|
|
707
705
|
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
@@ -855,13 +853,15 @@ function toGeneratedReplyRelay(value: ServiceMaintenanceReplyRelay): GeneratedRe
|
|
|
855
853
|
},
|
|
856
854
|
terminalResult: value.terminalResult,
|
|
857
855
|
failureCode: value.failureCode,
|
|
858
|
-
...(value.payload === undefined
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
856
|
+
...(value.payload === undefined
|
|
857
|
+
? {}
|
|
858
|
+
: {
|
|
859
|
+
payload: {
|
|
860
|
+
packetName: value.payload.packetName,
|
|
861
|
+
contentType: value.payload.contentType,
|
|
862
|
+
payload: value.payload.bytes
|
|
863
|
+
}
|
|
864
|
+
})
|
|
865
865
|
};
|
|
866
866
|
}
|
|
867
867
|
|
|
@@ -879,13 +879,15 @@ function fromGeneratedReplyRelay(value: GeneratedReplyRelay33): ServiceMaintenan
|
|
|
879
879
|
sequence: value.context.sequence,
|
|
880
880
|
terminalResult: value.terminalResult,
|
|
881
881
|
failureCode: value.failureCode,
|
|
882
|
-
...(value.payload === undefined
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
882
|
+
...(value.payload === undefined
|
|
883
|
+
? {}
|
|
884
|
+
: {
|
|
885
|
+
payload: {
|
|
886
|
+
packetName: value.payload.packetName,
|
|
887
|
+
contentType: value.payload.contentType,
|
|
888
|
+
bytes: Buffer.from(value.payload.payload)
|
|
889
|
+
}
|
|
890
|
+
})
|
|
889
891
|
};
|
|
890
892
|
}
|
|
891
893
|
|
|
@@ -1142,9 +1144,9 @@ export function encodeSpotHeader(
|
|
|
1142
1144
|
correlation?: bigint
|
|
1143
1145
|
): Buffer {
|
|
1144
1146
|
return concat(
|
|
1145
|
-
prefix(
|
|
1146
|
-
? M6bServiceWireCommand.spotSend
|
|
1147
|
-
|
|
1147
|
+
prefix(
|
|
1148
|
+
kind === 'spotSend' ? M6bServiceWireCommand.spotSend : M6bServiceWireCommand.spotRequest
|
|
1149
|
+
),
|
|
1148
1150
|
...(kind === 'spotRequest' ? [u64(requirePositive(correlation, 'correlation'))] : []),
|
|
1149
1151
|
rid(sourceSpotId, 'sourceSpotId'),
|
|
1150
1152
|
directSpotFence(target)
|
|
@@ -1158,14 +1160,13 @@ export function encodeActorHeader(
|
|
|
1158
1160
|
sourceActor?: ServiceActorRef,
|
|
1159
1161
|
boundSession?: ServiceBoundSessionSource
|
|
1160
1162
|
): Buffer {
|
|
1161
|
-
const flags =
|
|
1162
|
-
|
|
1163
|
-
|
|
1163
|
+
const flags =
|
|
1164
|
+
boundSession === undefined
|
|
1165
|
+
? 0
|
|
1166
|
+
: M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId;
|
|
1164
1167
|
return concat(
|
|
1165
1168
|
prefix(
|
|
1166
|
-
kind === 'actorSend'
|
|
1167
|
-
? M6bServiceWireCommand.actorSend
|
|
1168
|
-
: M6bServiceWireCommand.actorRequest,
|
|
1169
|
+
kind === 'actorSend' ? M6bServiceWireCommand.actorSend : M6bServiceWireCommand.actorRequest,
|
|
1169
1170
|
flags
|
|
1170
1171
|
),
|
|
1171
1172
|
...(kind === 'actorRequest' ? [u64(requirePositive(correlation, 'correlation'))] : []),
|
|
@@ -1226,9 +1227,8 @@ export function encodeBoundSessionBindHeader(
|
|
|
1226
1227
|
sessionRid: string,
|
|
1227
1228
|
binding: ServiceBoundSessionTransition
|
|
1228
1229
|
): Buffer {
|
|
1229
|
-
const body =
|
|
1230
|
-
? u64(binding.generation)
|
|
1231
|
-
: u64(binding.retiredGeneration);
|
|
1230
|
+
const body =
|
|
1231
|
+
binding.state === 'active' ? u64(binding.generation) : u64(binding.retiredGeneration);
|
|
1232
1232
|
return concat(
|
|
1233
1233
|
prefix(M6bServiceWireCommand.boundSessionBind),
|
|
1234
1234
|
u64(correlation),
|
|
@@ -1258,9 +1258,9 @@ export function encodeBoundSessionReplacedHeader(
|
|
|
1258
1258
|
|
|
1259
1259
|
/** Encodes canonical service-wire command 42. */
|
|
1260
1260
|
export function encodeSessionRelocationSeal(value: ServiceSessionRelocationSeal): Buffer {
|
|
1261
|
-
return Buffer.from(
|
|
1262
|
-
toGeneratedSessionRelocationSeal(value)
|
|
1263
|
-
)
|
|
1261
|
+
return Buffer.from(
|
|
1262
|
+
encodeGeneratedSessionRelocationSeal42(toGeneratedSessionRelocationSeal(value))
|
|
1263
|
+
);
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
1266
|
/** Decodes canonical service-wire command 42. */
|
|
@@ -1270,9 +1270,9 @@ export function decodeSessionRelocationSeal(frame: Uint8Array): ServiceSessionRe
|
|
|
1270
1270
|
|
|
1271
1271
|
/** Encodes canonical service-wire command 43. */
|
|
1272
1272
|
export function encodeSessionRelocationSealed(value: ServiceSessionRelocationSealed): Buffer {
|
|
1273
|
-
return Buffer.from(
|
|
1274
|
-
toGeneratedSessionRelocationSealed(value)
|
|
1275
|
-
)
|
|
1273
|
+
return Buffer.from(
|
|
1274
|
+
encodeGeneratedSessionRelocationSealed43(toGeneratedSessionRelocationSealed(value))
|
|
1275
|
+
);
|
|
1276
1276
|
}
|
|
1277
1277
|
|
|
1278
1278
|
/** Decodes canonical service-wire command 43. */
|
|
@@ -1282,9 +1282,9 @@ export function decodeSessionRelocationSealed(frame: Uint8Array): ServiceSession
|
|
|
1282
1282
|
|
|
1283
1283
|
/** Encodes canonical service-wire command 44. */
|
|
1284
1284
|
export function encodeSessionRelocationRoute(value: ServiceSessionRelocationRoute): Buffer {
|
|
1285
|
-
return Buffer.from(
|
|
1286
|
-
toGeneratedSessionRelocationRoute(value)
|
|
1287
|
-
)
|
|
1285
|
+
return Buffer.from(
|
|
1286
|
+
encodeGeneratedSessionRelocationRoute44(toGeneratedSessionRelocationRoute(value))
|
|
1287
|
+
);
|
|
1288
1288
|
}
|
|
1289
1289
|
|
|
1290
1290
|
/** Decodes canonical service-wire command 44. */
|
|
@@ -1313,8 +1313,8 @@ export function encodeInstanceSpotHeader(
|
|
|
1313
1313
|
text16(route.storeVersion, 'storeVersion')
|
|
1314
1314
|
);
|
|
1315
1315
|
if (
|
|
1316
|
-
operationKind === 'send'
|
|
1317
|
-
|
|
1316
|
+
operationKind === 'send' &&
|
|
1317
|
+
(operation.high !== 0n || operation.low !== 0n || replyRouteId !== undefined)
|
|
1318
1318
|
) {
|
|
1319
1319
|
throw new RangeError('Instance Spot send must not carry an operation or reply route.');
|
|
1320
1320
|
}
|
|
@@ -1322,10 +1322,7 @@ export function encodeInstanceSpotHeader(
|
|
|
1322
1322
|
throw new RangeError('Instance Spot request requires a non-zero operation.');
|
|
1323
1323
|
}
|
|
1324
1324
|
return concat(
|
|
1325
|
-
prefix(
|
|
1326
|
-
M6bServiceWireCommand.instanceSpot,
|
|
1327
|
-
hasMetadata ? M6bServiceWireFlag.metadata : 0
|
|
1328
|
-
),
|
|
1325
|
+
prefix(M6bServiceWireCommand.instanceSpot, hasMetadata ? M6bServiceWireFlag.metadata : 0),
|
|
1329
1326
|
Buffer.of(1),
|
|
1330
1327
|
u16(routeBody.byteLength),
|
|
1331
1328
|
routeBody,
|
|
@@ -1335,9 +1332,7 @@ export function encodeInstanceSpotHeader(
|
|
|
1335
1332
|
Buffer.of(operationKind === 'send' ? 1 : 2),
|
|
1336
1333
|
u64Any(operation.high),
|
|
1337
1334
|
u64Any(operation.low),
|
|
1338
|
-
...(operationKind === 'request'
|
|
1339
|
-
? [u64(requirePositive(replyRouteId, 'replyRouteId'))]
|
|
1340
|
-
: [])
|
|
1335
|
+
...(operationKind === 'request' ? [u64(requirePositive(replyRouteId, 'replyRouteId'))] : [])
|
|
1341
1336
|
);
|
|
1342
1337
|
}
|
|
1343
1338
|
|
|
@@ -1369,10 +1364,7 @@ export function encodeInstanceSpotActivationHeader(
|
|
|
1369
1364
|
text16(target.descriptorVersion, 'descriptorVersion')
|
|
1370
1365
|
);
|
|
1371
1366
|
return concat(
|
|
1372
|
-
prefix(
|
|
1373
|
-
M6bServiceWireCommand.instanceSpot,
|
|
1374
|
-
hasMetadata ? M6bServiceWireFlag.metadata : 0
|
|
1375
|
-
),
|
|
1367
|
+
prefix(M6bServiceWireCommand.instanceSpot, hasMetadata ? M6bServiceWireFlag.metadata : 0),
|
|
1376
1368
|
Buffer.of(2),
|
|
1377
1369
|
u16(targetBody.byteLength),
|
|
1378
1370
|
targetBody,
|
|
@@ -1383,13 +1375,13 @@ export function encodeInstanceSpotActivationHeader(
|
|
|
1383
1375
|
u64Any(operation.high),
|
|
1384
1376
|
u64Any(operation.low),
|
|
1385
1377
|
u64(deadlineUnixMs),
|
|
1386
|
-
...(operationKind === 'request'
|
|
1387
|
-
? [u64(requirePositive(replyRouteId, 'replyRouteId'))]
|
|
1388
|
-
: [])
|
|
1378
|
+
...(operationKind === 'request' ? [u64(requirePositive(replyRouteId, 'replyRouteId'))] : [])
|
|
1389
1379
|
);
|
|
1390
1380
|
}
|
|
1391
1381
|
|
|
1392
|
-
export function encodeUserSpotCreateHeader(
|
|
1382
|
+
export function encodeUserSpotCreateHeader(
|
|
1383
|
+
record: Omit<ServiceUserSpotCreateRecord, 'kind'>
|
|
1384
|
+
): Buffer {
|
|
1393
1385
|
return Buffer.from(encodeGeneratedUserSpotCreate47(toGeneratedUserSpotCreate(record)));
|
|
1394
1386
|
}
|
|
1395
1387
|
|
|
@@ -1397,7 +1389,9 @@ export function encodeActorCreateHeader(record: Omit<ServiceActorCreateRecord, '
|
|
|
1397
1389
|
return Buffer.from(encodeGeneratedActorCreate49(toGeneratedActorCreate(record)));
|
|
1398
1390
|
}
|
|
1399
1391
|
|
|
1400
|
-
export function encodeUserSpotCloseHeader(
|
|
1392
|
+
export function encodeUserSpotCloseHeader(
|
|
1393
|
+
record: Omit<ServiceUserSpotCloseRecord, 'kind'>
|
|
1394
|
+
): Buffer {
|
|
1401
1395
|
return Buffer.from(encodeGeneratedUserSpotClose48(toGeneratedUserSpotClose(record)));
|
|
1402
1396
|
}
|
|
1403
1397
|
|
|
@@ -1459,9 +1453,7 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1459
1453
|
const hasBinding = command.flags !== 0;
|
|
1460
1454
|
requireFlags(
|
|
1461
1455
|
command.flags,
|
|
1462
|
-
hasBinding
|
|
1463
|
-
? M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId
|
|
1464
|
-
: 0
|
|
1456
|
+
hasBinding ? M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId : 0
|
|
1465
1457
|
);
|
|
1466
1458
|
const correlation = request ? reader.nonZeroU64('correlation') : undefined;
|
|
1467
1459
|
const sourceActor = reader.optionalActor();
|
|
@@ -1565,9 +1557,10 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1565
1557
|
correlation,
|
|
1566
1558
|
actor,
|
|
1567
1559
|
sessionRid,
|
|
1568
|
-
binding:
|
|
1569
|
-
|
|
1570
|
-
|
|
1560
|
+
binding:
|
|
1561
|
+
state === 1
|
|
1562
|
+
? { state: 'active', generation }
|
|
1563
|
+
: { state: 'tombstone', retiredGeneration: generation }
|
|
1571
1564
|
};
|
|
1572
1565
|
}
|
|
1573
1566
|
case M6bServiceWireCommand.boundSessionReplaced: {
|
|
@@ -1580,9 +1573,7 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1580
1573
|
authorityOwnerGeneration: reader.nonZeroU64(
|
|
1581
1574
|
'actorAuthority.expectedAuthorityOwnerGeneration'
|
|
1582
1575
|
),
|
|
1583
|
-
ownerLeaseGeneration: reader.nonZeroU64(
|
|
1584
|
-
'actorAuthority.expectedOwnerLeaseGeneration'
|
|
1585
|
-
)
|
|
1576
|
+
ownerLeaseGeneration: reader.nonZeroU64('actorAuthority.expectedOwnerLeaseGeneration')
|
|
1586
1577
|
};
|
|
1587
1578
|
const retiredSession = {
|
|
1588
1579
|
sessionOwnerNodeRid: reader.rid('sessionOwnerNodeRid'),
|
|
@@ -1608,23 +1599,25 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1608
1599
|
targetNodeGeneration: reader.nonZeroU64('targetNodeGeneration'),
|
|
1609
1600
|
targetSpotId: reader.rid('targetSpotId')
|
|
1610
1601
|
};
|
|
1611
|
-
const route: ServiceInstanceRouteFence | undefined =
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1602
|
+
const route: ServiceInstanceRouteFence | undefined =
|
|
1603
|
+
version === 1
|
|
1604
|
+
? {
|
|
1605
|
+
...commonTarget,
|
|
1606
|
+
objectGeneration: reader.nonZeroU64('objectGeneration'),
|
|
1607
|
+
ownerId: reader.text8('ownerId'),
|
|
1608
|
+
authorityOwnerGeneration: reader.nonZeroU64('authorityOwnerGeneration'),
|
|
1609
|
+
leaseGeneration: reader.nonZeroU64('leaseGeneration'),
|
|
1610
|
+
storeVersion: reader.text16('storeVersion')
|
|
1611
|
+
}
|
|
1612
|
+
: undefined;
|
|
1613
|
+
const target: ServiceInstanceActivationTarget | undefined =
|
|
1614
|
+
version === 2
|
|
1615
|
+
? {
|
|
1616
|
+
...commonTarget,
|
|
1617
|
+
stableType: reader.text16('stableType'),
|
|
1618
|
+
descriptorVersion: reader.text16('descriptorVersion')
|
|
1619
|
+
}
|
|
1620
|
+
: undefined;
|
|
1628
1621
|
if (reader.offset !== routeEnd) fail('Invalid Instance route body length.');
|
|
1629
1622
|
const sourceNodeGeneration = reader.nonZeroU64('sourceNodeGeneration');
|
|
1630
1623
|
const sourceNodeRid = reader.rid('sourceNodeRid');
|
|
@@ -1635,22 +1628,20 @@ export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireReco
|
|
|
1635
1628
|
high: reader.u64('operation.high'),
|
|
1636
1629
|
low: reader.u64('operation.low')
|
|
1637
1630
|
};
|
|
1638
|
-
const operationKind = operationValue === 1 ? 'send' as const : 'request' as const;
|
|
1639
|
-
if (
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1631
|
+
const operationKind = operationValue === 1 ? ('send' as const) : ('request' as const);
|
|
1632
|
+
if (
|
|
1633
|
+
version === 1 &&
|
|
1634
|
+
((operationKind === 'send' && (operation.high !== 0n || operation.low !== 0n)) ||
|
|
1635
|
+
(operationKind === 'request' && operation.high === 0n && operation.low === 0n))
|
|
1636
|
+
) {
|
|
1643
1637
|
fail('Invalid Instance operation identity.');
|
|
1644
1638
|
}
|
|
1645
1639
|
if (version === 2 && operation.high === 0n && operation.low === 0n) {
|
|
1646
1640
|
fail('Instance activation requires a non-zero operation identity.');
|
|
1647
1641
|
}
|
|
1648
|
-
const deadlineUnixMs = version === 2
|
|
1649
|
-
|
|
1650
|
-
: undefined;
|
|
1651
|
-
const replyRouteId = operationKind === 'request'
|
|
1652
|
-
? reader.nonZeroU64('replyRouteId')
|
|
1653
|
-
: undefined;
|
|
1642
|
+
const deadlineUnixMs = version === 2 ? reader.nonZeroU64('deadlineUnixMs') : undefined;
|
|
1643
|
+
const replyRouteId =
|
|
1644
|
+
operationKind === 'request' ? reader.nonZeroU64('replyRouteId') : undefined;
|
|
1654
1645
|
reader.end();
|
|
1655
1646
|
const common = {
|
|
1656
1647
|
kind: 'instanceSpot' as const,
|
|
@@ -1722,56 +1713,68 @@ export function encodeMaintenanceRelocationControl(
|
|
|
1722
1713
|
): Buffer {
|
|
1723
1714
|
switch (value.kind) {
|
|
1724
1715
|
case 'prepare':
|
|
1725
|
-
return Buffer.from(
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1716
|
+
return Buffer.from(
|
|
1717
|
+
encodeGeneratedRelocationPrepare40({
|
|
1718
|
+
...toGeneratedRelocationBase(value),
|
|
1719
|
+
target: toGeneratedTargetFence(value.target),
|
|
1720
|
+
initiatorRole: value.initiatorRole,
|
|
1721
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1722
|
+
sourceNodeRid: toGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
1723
|
+
sourceNodeGeneration: value.sourceNodeGeneration,
|
|
1724
|
+
payloadTotalLength: value.payloadTotalLength,
|
|
1725
|
+
payloadChunkCount: value.payloadChunkCount,
|
|
1726
|
+
payloadChecksumCrc32c: value.payloadChecksumCrc32c,
|
|
1727
|
+
applicationVersion: value.applicationVersion
|
|
1728
|
+
})
|
|
1729
|
+
);
|
|
1737
1730
|
case 'ready':
|
|
1738
|
-
return Buffer.from(
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1731
|
+
return Buffer.from(
|
|
1732
|
+
encodeGeneratedRelocationReady30({
|
|
1733
|
+
...toGeneratedRelocationBase(value),
|
|
1734
|
+
target: toGeneratedTargetFence(value.target),
|
|
1735
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1736
|
+
senderRole: value.senderRole
|
|
1737
|
+
})
|
|
1738
|
+
);
|
|
1744
1739
|
case 'failed':
|
|
1745
|
-
return Buffer.from(
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1740
|
+
return Buffer.from(
|
|
1741
|
+
encodeGeneratedRelocationFailed53({
|
|
1742
|
+
...toGeneratedRelocationBase(value),
|
|
1743
|
+
target: toGeneratedTargetFence(value.target),
|
|
1744
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1745
|
+
senderRole: value.senderRole,
|
|
1746
|
+
failureCode: value.failureCode
|
|
1747
|
+
})
|
|
1748
|
+
);
|
|
1752
1749
|
case 'data':
|
|
1753
|
-
return Buffer.from(
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1750
|
+
return Buffer.from(
|
|
1751
|
+
encodeGeneratedRelocationData31({
|
|
1752
|
+
...toGeneratedRelocationBase(value),
|
|
1753
|
+
senderRole: value.senderRole,
|
|
1754
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1755
|
+
record: encodeServiceWireFrozenRecord(value.frozenRecord)
|
|
1756
|
+
})
|
|
1757
|
+
);
|
|
1759
1758
|
case 'cutover':
|
|
1760
|
-
return Buffer.from(
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1759
|
+
return Buffer.from(
|
|
1760
|
+
encodeGeneratedRelocationCutover34({
|
|
1761
|
+
...toGeneratedRelocationBase(value),
|
|
1762
|
+
senderRole: value.senderRole,
|
|
1763
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1764
|
+
boundaryRecordCount: value.boundaryRecordCount,
|
|
1765
|
+
boundaryChecksumCrc32c: value.boundaryChecksumCrc32c
|
|
1766
|
+
})
|
|
1767
|
+
);
|
|
1767
1768
|
case 'state':
|
|
1768
|
-
return Buffer.from(
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1769
|
+
return Buffer.from(
|
|
1770
|
+
encodeGeneratedRelocationState52({
|
|
1771
|
+
...toGeneratedRelocationBase(value),
|
|
1772
|
+
senderRole: value.senderRole,
|
|
1773
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1774
|
+
chunkOrdinal: value.chunkOrdinal,
|
|
1775
|
+
chunkData: value.chunkData
|
|
1776
|
+
})
|
|
1777
|
+
);
|
|
1775
1778
|
}
|
|
1776
1779
|
}
|
|
1777
1780
|
|
|
@@ -1813,14 +1816,16 @@ export function decodeMaintenanceReplyRelay(
|
|
|
1813
1816
|
|
|
1814
1817
|
/** Encodes canonical service-wire command 46. */
|
|
1815
1818
|
export function encodeMaintenanceReplyRelayAck(value: ServiceMaintenanceReplyRelayAck): Buffer {
|
|
1816
|
-
return Buffer.from(
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1819
|
+
return Buffer.from(
|
|
1820
|
+
encodeGeneratedReplyRelayAck46({
|
|
1821
|
+
relocation: value.relocation,
|
|
1822
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
1823
|
+
operation: value.operation,
|
|
1824
|
+
replyRouteId: value.replyRouteId,
|
|
1825
|
+
requestSource: toGeneratedRequestSourceFence(value.requestSource),
|
|
1826
|
+
status: value.status
|
|
1827
|
+
})
|
|
1828
|
+
);
|
|
1824
1829
|
}
|
|
1825
1830
|
|
|
1826
1831
|
/** Decodes canonical service-wire command 46. */
|
|
@@ -1839,9 +1844,18 @@ export function decodeMaintenanceReplyRelayAck(frame: Uint8Array): ServiceMainte
|
|
|
1839
1844
|
export function decodeStatefulReply(
|
|
1840
1845
|
frame: Uint8Array,
|
|
1841
1846
|
expectedCorrelation: bigint,
|
|
1842
|
-
operationKind:
|
|
1847
|
+
operationKind:
|
|
1848
|
+
| 'spotRequest'
|
|
1849
|
+
| 'actorRequest'
|
|
1850
|
+
| 'actorLookup'
|
|
1851
|
+
| 'actorDestroy'
|
|
1852
|
+
| 'actorJoin'
|
|
1853
|
+
| 'streamBind'
|
|
1843
1854
|
| 'streamUnbind'
|
|
1844
|
-
| 'instanceSpotRequest'
|
|
1855
|
+
| 'instanceSpotRequest'
|
|
1856
|
+
| 'userSpotCreate'
|
|
1857
|
+
| 'userSpotClose'
|
|
1858
|
+
| 'actorCreate',
|
|
1845
1859
|
hasPayload = false
|
|
1846
1860
|
): ServiceStatefulReply {
|
|
1847
1861
|
const reader = new Reader(frame);
|
|
@@ -1876,15 +1890,16 @@ export function decodeStatefulReply(
|
|
|
1876
1890
|
const membershipEpoch = reader.nonZeroU64('membershipEpoch');
|
|
1877
1891
|
// Tolerant of frames from an unpatched encoder that stops after
|
|
1878
1892
|
// membershipEpoch: 0 means "not advertised".
|
|
1879
|
-
const receiveChunkLimitBytes =
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1893
|
+
const receiveChunkLimitBytes =
|
|
1894
|
+
reader.offset === bodyEnd
|
|
1895
|
+
? 0
|
|
1896
|
+
: (() => {
|
|
1897
|
+
const value = reader.u32('receiveChunkLimitBytes');
|
|
1898
|
+
if (value > RELOCATION_STATE_CHUNK_DATA_MAX_BYTES) {
|
|
1899
|
+
fail('receiveChunkLimitBytes exceeds the relocation state chunk data bound.');
|
|
1900
|
+
}
|
|
1901
|
+
return value;
|
|
1902
|
+
})();
|
|
1888
1903
|
if (reader.offset !== bodyEnd) fail('Invalid actor join body length.');
|
|
1889
1904
|
tail = { kind: 'actorJoin', joinResult, spot, membershipEpoch, receiveChunkLimitBytes };
|
|
1890
1905
|
} else {
|
|
@@ -1923,13 +1938,14 @@ export function decodeStatefulReply(
|
|
|
1923
1938
|
const end = reader.offset + length;
|
|
1924
1939
|
if (end > reader.bytes.byteLength) fail('Truncated Actor create terminal.');
|
|
1925
1940
|
const result = (['existing', 'created', 'rejected'] as const)[createResult - 1]!;
|
|
1926
|
-
const actor =
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1941
|
+
const actor =
|
|
1942
|
+
result === 'rejected'
|
|
1943
|
+
? undefined
|
|
1944
|
+
: {
|
|
1945
|
+
nodeRid: reader.rid('actor.nodeRid'),
|
|
1946
|
+
actorId: reader.text8('actor.actorId'),
|
|
1947
|
+
generation: reader.nonZeroU64('actor.objectGeneration')
|
|
1948
|
+
};
|
|
1933
1949
|
if (reader.offset !== end) fail('Invalid Actor create terminal length.');
|
|
1934
1950
|
tail = {
|
|
1935
1951
|
kind: 'actorCreate',
|
|
@@ -1986,8 +2002,10 @@ function encodeReplyTail(tail: ServiceStatefulReplyTail): Buffer {
|
|
|
1986
2002
|
fail('Accepted actor join requires a membership epoch.');
|
|
1987
2003
|
}
|
|
1988
2004
|
const receiveChunkLimitBytes = tail.receiveChunkLimitBytes ?? 0;
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
2005
|
+
if (
|
|
2006
|
+
receiveChunkLimitBytes < 0 ||
|
|
2007
|
+
receiveChunkLimitBytes > RELOCATION_STATE_CHUNK_DATA_MAX_BYTES
|
|
2008
|
+
) {
|
|
1991
2009
|
fail('receiveChunkLimitBytes exceeds the relocation state chunk data bound.');
|
|
1992
2010
|
}
|
|
1993
2011
|
const body = concat(
|
|
@@ -1997,12 +2015,13 @@ function encodeReplyTail(tail: ServiceStatefulReplyTail): Buffer {
|
|
|
1997
2015
|
);
|
|
1998
2016
|
return concat(u32(0, 'joinResult'), u16(body.byteLength), body);
|
|
1999
2017
|
}
|
|
2000
|
-
const optional =
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2018
|
+
const optional =
|
|
2019
|
+
tail.spot === undefined
|
|
2020
|
+
? concat(Buffer.of(0), u16(0))
|
|
2021
|
+
: (() => {
|
|
2022
|
+
const body = spotRef(tail.spot);
|
|
2023
|
+
return concat(Buffer.of(1), u16(body.byteLength), body);
|
|
2024
|
+
})();
|
|
2006
2025
|
return concat(u32(1, 'joinResult'), u16(optional.byteLength), optional);
|
|
2007
2026
|
}
|
|
2008
2027
|
case 'streamBind':
|
|
@@ -2016,13 +2035,14 @@ function encodeReplyTail(tail: ServiceStatefulReplyTail): Buffer {
|
|
|
2016
2035
|
case 'userSpotClose':
|
|
2017
2036
|
return Buffer.of(tail.closed ? 1 : 0);
|
|
2018
2037
|
case 'actorCreate': {
|
|
2019
|
-
const selected =
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2038
|
+
const selected =
|
|
2039
|
+
tail.actor === undefined
|
|
2040
|
+
? Buffer.alloc(0)
|
|
2041
|
+
: concat(
|
|
2042
|
+
rid(tail.actor.nodeRid, 'actor.nodeRid'),
|
|
2043
|
+
text8(tail.actor.actorId, 'actor.actorId'),
|
|
2044
|
+
u64(tail.actor.generation)
|
|
2045
|
+
);
|
|
2026
2046
|
return concat(
|
|
2027
2047
|
Buffer.of((['existing', 'created', 'rejected'] as const).indexOf(tail.createResult) + 1),
|
|
2028
2048
|
u16(selected.byteLength),
|
|
@@ -2053,8 +2073,18 @@ function validateReplyTerminal(
|
|
|
2053
2073
|
}
|
|
2054
2074
|
|
|
2055
2075
|
function validateRelocationPhase(value: number): void {
|
|
2056
|
-
const phases = [
|
|
2057
|
-
'
|
|
2076
|
+
const phases = [
|
|
2077
|
+
'none',
|
|
2078
|
+
'preparing',
|
|
2079
|
+
'captured',
|
|
2080
|
+
'prepared',
|
|
2081
|
+
'committed',
|
|
2082
|
+
'activating',
|
|
2083
|
+
'activated',
|
|
2084
|
+
'cleaning',
|
|
2085
|
+
'completed',
|
|
2086
|
+
'aborted'
|
|
2087
|
+
] as const;
|
|
2058
2088
|
if (!Number.isInteger(value) || value < 0 || value >= phases.length) {
|
|
2059
2089
|
fail('Invalid relocationData control phase.');
|
|
2060
2090
|
}
|
|
@@ -2105,64 +2135,68 @@ function spotFence(value: ServiceSpotRouteFence): Buffer {
|
|
|
2105
2135
|
}
|
|
2106
2136
|
|
|
2107
2137
|
function directSpotFence(value: ServiceDirectSpotRouteFence): Buffer {
|
|
2108
|
-
return concat(
|
|
2109
|
-
spotFence(value),
|
|
2110
|
-
text16(value.storeVersion, 'storeVersion')
|
|
2111
|
-
);
|
|
2138
|
+
return concat(spotFence(value), text16(value.storeVersion, 'storeVersion'));
|
|
2112
2139
|
}
|
|
2113
2140
|
|
|
2114
2141
|
function messageFollowRoute(value: ServiceMessageFollowRoute): Buffer {
|
|
2115
|
-
const body =
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2142
|
+
const body =
|
|
2143
|
+
value.kind === 'actor'
|
|
2144
|
+
? concat(
|
|
2145
|
+
actorRef(value.actor),
|
|
2146
|
+
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2147
|
+
u64(value.targetNodeGeneration),
|
|
2148
|
+
u64(value.authorityOwnerGeneration),
|
|
2149
|
+
u64(value.ownerLeaseGeneration)
|
|
2150
|
+
)
|
|
2151
|
+
: concat(
|
|
2152
|
+
spotRef(value.spot),
|
|
2153
|
+
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2154
|
+
u64(value.targetNodeGeneration),
|
|
2155
|
+
u64(value.authorityOwnerGeneration),
|
|
2156
|
+
u64(value.ownerLeaseGeneration)
|
|
2157
|
+
);
|
|
2130
2158
|
return concat(Buffer.of(value.kind === 'actor' ? 1 : 2), u16(body.byteLength), body);
|
|
2131
2159
|
}
|
|
2132
2160
|
|
|
2133
2161
|
function validateMessageFollowRecord(
|
|
2134
2162
|
value: Omit<ServiceMessageFollowRecord, 'kind'>,
|
|
2135
|
-
invalid: (message: string) => never = (message) => {
|
|
2163
|
+
invalid: (message: string) => never = (message) => {
|
|
2164
|
+
throw new RangeError(message);
|
|
2165
|
+
}
|
|
2136
2166
|
): void {
|
|
2137
2167
|
if (value.source.kind !== value.target.kind) {
|
|
2138
2168
|
invalid('Message Follow source and target object kinds differ.');
|
|
2139
2169
|
}
|
|
2140
|
-
const sameObject =
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2170
|
+
const sameObject =
|
|
2171
|
+
value.source.kind === 'actor' && value.target.kind === 'actor'
|
|
2172
|
+
? value.source.actor.actorId === value.target.actor.actorId &&
|
|
2173
|
+
value.source.actor.generation === value.target.actor.generation
|
|
2174
|
+
: value.source.kind === 'spot' && value.target.kind === 'spot'
|
|
2175
|
+
? value.source.spot.spotId === value.target.spot.spotId &&
|
|
2176
|
+
value.source.spot.generation === value.target.spot.generation
|
|
2177
|
+
: false;
|
|
2147
2178
|
if (!sameObject) invalid('Message Follow source and target object identities differ.');
|
|
2148
2179
|
if (!Number.isInteger(value.hopCount) || value.hopCount < 1 || value.hopCount > 8) {
|
|
2149
2180
|
invalid('Message Follow hopCount must be in 1..8.');
|
|
2150
2181
|
}
|
|
2151
|
-
if (
|
|
2152
|
-
|
|
2153
|
-
|
|
2182
|
+
if (
|
|
2183
|
+
!Number.isInteger(value.queuedMessages) ||
|
|
2184
|
+
value.queuedMessages < 0 ||
|
|
2185
|
+
value.queuedMessages > 0xffff_ffff
|
|
2186
|
+
) {
|
|
2154
2187
|
invalid('Message Follow queuedMessages must be a u32.');
|
|
2155
2188
|
}
|
|
2156
|
-
if (
|
|
2157
|
-
|
|
2158
|
-
|
|
2189
|
+
if (
|
|
2190
|
+
!Number.isInteger(value.queuedBytes) ||
|
|
2191
|
+
value.queuedBytes < 0 ||
|
|
2192
|
+
value.queuedBytes > 0xffff_ffff
|
|
2193
|
+
) {
|
|
2159
2194
|
invalid('Message Follow queuedBytes must be a u32.');
|
|
2160
2195
|
}
|
|
2161
2196
|
if (value.originalOperation.high === 0n && value.originalOperation.low === 0n) {
|
|
2162
2197
|
invalid('Message Follow originalOperation must not be zero.');
|
|
2163
2198
|
}
|
|
2164
|
-
if (value.originalReplyRouteId < 0n
|
|
2165
|
-
|| value.originalReplyRouteId > 0xffff_ffff_ffff_ffffn) {
|
|
2199
|
+
if (value.originalReplyRouteId < 0n || value.originalReplyRouteId > 0xffff_ffff_ffff_ffffn) {
|
|
2166
2200
|
invalid('Message Follow originalReplyRouteId must be a u64.');
|
|
2167
2201
|
}
|
|
2168
2202
|
}
|
|
@@ -2248,7 +2282,7 @@ function requireFlags(actual: number, expected: number): void {
|
|
|
2248
2282
|
}
|
|
2249
2283
|
|
|
2250
2284
|
function concat(...parts: readonly Uint8Array[]): Buffer {
|
|
2251
|
-
return Buffer.concat(parts.map(part => Buffer.from(part)));
|
|
2285
|
+
return Buffer.concat(parts.map((part) => Buffer.from(part)));
|
|
2252
2286
|
}
|
|
2253
2287
|
|
|
2254
2288
|
function fail(message: string): never {
|
|
@@ -2280,9 +2314,9 @@ class Reader {
|
|
|
2280
2314
|
prefix(): { readonly command: number; readonly flags: number } {
|
|
2281
2315
|
this.need(PREFIX_SIZE, 'prefix');
|
|
2282
2316
|
if (
|
|
2283
|
-
this.bytes[this.offset] !== MAGIC_0
|
|
2284
|
-
|
|
2285
|
-
|
|
2317
|
+
this.bytes[this.offset] !== MAGIC_0 ||
|
|
2318
|
+
this.bytes[this.offset + 1] !== MAGIC_1 ||
|
|
2319
|
+
this.bytes[this.offset + 2] !== MAJOR
|
|
2286
2320
|
) {
|
|
2287
2321
|
fail('Invalid service wire prefix.');
|
|
2288
2322
|
}
|
|
@@ -2506,7 +2540,10 @@ export function decodeServiceWireFrozenRecordPrefix(
|
|
|
2506
2540
|
const reader = new FrozenReader(bytes.subarray(offset));
|
|
2507
2541
|
const record = decodeServiceWireFrozenRecordFrom(reader);
|
|
2508
2542
|
return {
|
|
2509
|
-
record: {
|
|
2543
|
+
record: {
|
|
2544
|
+
...record,
|
|
2545
|
+
canonicalBytes: Buffer.from(bytes.subarray(offset, offset + reader.position))
|
|
2546
|
+
},
|
|
2510
2547
|
length: reader.position
|
|
2511
2548
|
};
|
|
2512
2549
|
}
|
|
@@ -2547,8 +2584,12 @@ function decodeServiceWireFrozenRecordFrom(reader: FrozenReader): ServiceWireFro
|
|
|
2547
2584
|
}
|
|
2548
2585
|
const hasMetadata = reader.bool8('hasMetadata');
|
|
2549
2586
|
if (hasMetadata) {
|
|
2550
|
-
if (!(
|
|
2551
|
-
|
|
2587
|
+
if (!(
|
|
2588
|
+
(recordKind >= 1 && recordKind <= 7) ||
|
|
2589
|
+
recordKind === 9 ||
|
|
2590
|
+
recordKind === 10 ||
|
|
2591
|
+
recordKind === 14
|
|
2592
|
+
)) {
|
|
2552
2593
|
fail('Metadata is forbidden for this frozen record kind.');
|
|
2553
2594
|
}
|
|
2554
2595
|
reader.metadata();
|
|
@@ -2561,13 +2602,16 @@ function decodeServiceWireFrozenRecordFrom(reader: FrozenReader): ServiceWireFro
|
|
|
2561
2602
|
if (operationKind > 15) fail('Invalid frozen operation kind.');
|
|
2562
2603
|
const replyReader = reader.body16('frozen reply route');
|
|
2563
2604
|
const requiresReply = operationRequiresReply(operationKind);
|
|
2564
|
-
const replyRouteId = requiresReply
|
|
2565
|
-
? replyReader.nonZeroU64('replyRouteId')
|
|
2566
|
-
: undefined;
|
|
2605
|
+
const replyRouteId = requiresReply ? replyReader.nonZeroU64('replyRouteId') : undefined;
|
|
2567
2606
|
replyReader.end('frozen reply route');
|
|
2568
2607
|
const body = reader.frozenBody(recordKind);
|
|
2569
|
-
validateFrozenOperationMatrix(
|
|
2570
|
-
|
|
2608
|
+
validateFrozenOperationMatrix(
|
|
2609
|
+
recordKind,
|
|
2610
|
+
operationKind,
|
|
2611
|
+
operationId,
|
|
2612
|
+
replyRouteId,
|
|
2613
|
+
body.instanceOperationKind
|
|
2614
|
+
);
|
|
2571
2615
|
return {
|
|
2572
2616
|
recordKind,
|
|
2573
2617
|
sourceKind,
|
|
@@ -2624,11 +2668,14 @@ export function encodeServiceWireFrozenActorApplicationRecord(input: {
|
|
|
2624
2668
|
const replyBody = request ? u64(input.replyRouteId!) : Buffer.alloc(0);
|
|
2625
2669
|
const bytes = concat(
|
|
2626
2670
|
Buffer.of(request ? 10 : 9),
|
|
2627
|
-
Buffer.of(1),
|
|
2671
|
+
Buffer.of(1),
|
|
2672
|
+
u16(sourceBody.byteLength),
|
|
2673
|
+
sourceBody,
|
|
2628
2674
|
Buffer.of(0),
|
|
2629
2675
|
wireId(input.operationId, 'operationId'),
|
|
2630
2676
|
u32(request ? 4 : 0, 'operationKind'),
|
|
2631
|
-
u16(replyBody.byteLength),
|
|
2677
|
+
u16(replyBody.byteLength),
|
|
2678
|
+
replyBody,
|
|
2632
2679
|
text8(input.target.actorId, 'targetActorId'),
|
|
2633
2680
|
u64(input.target.objectGeneration),
|
|
2634
2681
|
rid(input.target.nodeRid, 'targetNodeRid'),
|
|
@@ -2640,25 +2687,30 @@ export function encodeServiceWireFrozenActorApplicationRecord(input: {
|
|
|
2640
2687
|
return decodeServiceWireFrozenRecord(bytes);
|
|
2641
2688
|
}
|
|
2642
2689
|
|
|
2643
|
-
function sameFrozenRecordSummary(
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2690
|
+
function sameFrozenRecordSummary(
|
|
2691
|
+
left: ServiceWireFrozenRecord,
|
|
2692
|
+
right: ServiceWireFrozenRecord
|
|
2693
|
+
): boolean {
|
|
2694
|
+
return (
|
|
2695
|
+
left.recordKind === right.recordKind &&
|
|
2696
|
+
left.sourceKind === right.sourceKind &&
|
|
2697
|
+
routingIdsEqual(left.source.nodeRid, right.source.nodeRid) &&
|
|
2698
|
+
left.source.nodeGeneration === right.source.nodeGeneration &&
|
|
2699
|
+
left.source.ownerId === right.source.ownerId &&
|
|
2700
|
+
left.source.leaseGeneration === right.source.leaseGeneration &&
|
|
2701
|
+
left.sourceSpotId === right.sourceSpotId &&
|
|
2702
|
+
left.sourceActor?.actorId === right.sourceActor?.actorId &&
|
|
2703
|
+
left.sourceActor?.generation === right.sourceActor?.generation &&
|
|
2704
|
+
left.sourceSessionRid === right.sourceSessionRid &&
|
|
2705
|
+
left.sourceBindingGeneration === right.sourceBindingGeneration &&
|
|
2706
|
+
left.sourceSessionSequence === right.sourceSessionSequence &&
|
|
2707
|
+
left.hasMetadata === right.hasMetadata &&
|
|
2708
|
+
left.operationId.high === right.operationId.high &&
|
|
2709
|
+
left.operationId.low === right.operationId.low &&
|
|
2710
|
+
left.operationKind === right.operationKind &&
|
|
2711
|
+
left.replyRouteId === right.replyRouteId &&
|
|
2712
|
+
left.canonicalBytes.equals(right.canonicalBytes)
|
|
2713
|
+
);
|
|
2662
2714
|
}
|
|
2663
2715
|
|
|
2664
2716
|
function validateFrozenOperationMatrix(
|
|
@@ -2677,13 +2729,11 @@ function validateFrozenOperationMatrix(
|
|
|
2677
2729
|
else if (recordKind === 6) valid = operationKind === 3 && !zero;
|
|
2678
2730
|
else if (recordKind === 10) valid = operationKind === 4 && !zero;
|
|
2679
2731
|
else if (recordKind === 8) {
|
|
2680
|
-
valid = operationKind === 0 && zero
|
|
2681
|
-
|| [6, 7, 8].includes(operationKind) && !zero;
|
|
2732
|
+
valid = (operationKind === 0 && zero) || ([6, 7, 8].includes(operationKind) && !zero);
|
|
2682
2733
|
} else if (recordKind === 11) valid = operationKind >= 1 && operationKind <= 15 && !zero;
|
|
2683
2734
|
else if (recordKind === 14 && instanceOperationKind !== undefined) {
|
|
2684
|
-
valid =
|
|
2685
|
-
? operationKind === 0 && zero
|
|
2686
|
-
: operationKind === 12 && !zero;
|
|
2735
|
+
valid =
|
|
2736
|
+
instanceOperationKind === 1 ? operationKind === 0 && zero : operationKind === 12 && !zero;
|
|
2687
2737
|
}
|
|
2688
2738
|
if (!valid) fail('Frozen record kind, operation kind, and operation ID do not match.');
|
|
2689
2739
|
if (operationRequiresReply(operationKind) !== (replyRouteId !== undefined)) {
|
|
@@ -2810,8 +2860,7 @@ class FrozenReader {
|
|
|
2810
2860
|
} {
|
|
2811
2861
|
if (recordKind === 1 || recordKind === 2) {
|
|
2812
2862
|
return { applicationPayload: this.applicationPayload() };
|
|
2813
|
-
}
|
|
2814
|
-
else if (recordKind === 3 || recordKind === 4) {
|
|
2863
|
+
} else if (recordKind === 3 || recordKind === 4) {
|
|
2815
2864
|
this.text8('channelName');
|
|
2816
2865
|
return { applicationPayload: this.applicationPayload() };
|
|
2817
2866
|
} else if (recordKind === 5 || recordKind === 6) {
|
|
@@ -2834,9 +2883,7 @@ class FrozenReader {
|
|
|
2834
2883
|
const failureCode = this.u32('failureCode');
|
|
2835
2884
|
const hasPayload = this.bool8('hasPayload');
|
|
2836
2885
|
validateReplyTerminal(terminalResult, failureCode, hasPayload);
|
|
2837
|
-
return hasPayload
|
|
2838
|
-
? { applicationPayload: this.applicationPayload() }
|
|
2839
|
-
: {};
|
|
2886
|
+
return hasPayload ? { applicationPayload: this.applicationPayload() } : {};
|
|
2840
2887
|
} else if (recordKind === 12) this.sendReadyDestination();
|
|
2841
2888
|
else if (recordKind === 13) {
|
|
2842
2889
|
validateRelocationPhase(this.u8('phase'));
|
|
@@ -2850,7 +2897,8 @@ class FrozenReader {
|
|
|
2850
2897
|
this.instanceRoute();
|
|
2851
2898
|
this.nonZeroU64('instanceSourceNodeGeneration');
|
|
2852
2899
|
const operationKind = this.u8('instanceOperationKind');
|
|
2853
|
-
if (operationKind < 1 || operationKind > 2)
|
|
2900
|
+
if (operationKind < 1 || operationKind > 2)
|
|
2901
|
+
fail('Invalid Instance activation operation kind.');
|
|
2854
2902
|
const applicationPayload = this.applicationPayload();
|
|
2855
2903
|
return { instanceOperationKind: operationKind, applicationPayload };
|
|
2856
2904
|
}
|