@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
|
@@ -84,12 +84,20 @@ class ZLinkSerialExecutionQueue {
|
|
|
84
84
|
submitLifecycleOperation(operation, context) {
|
|
85
85
|
return this.admit(operation, { lane: 'lifecycle' }, context, undefined, true);
|
|
86
86
|
}
|
|
87
|
+
get retainsApplicationForLifecycle() {
|
|
88
|
+
return this.activeLifecycle?.context !== undefined;
|
|
89
|
+
}
|
|
87
90
|
visitPendingApplication(visitor) {
|
|
88
91
|
for (const record of this.application.records) {
|
|
89
92
|
if (record.mailbox === undefined)
|
|
90
93
|
visitor(record);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
get hasPendingDurableApplication() {
|
|
97
|
+
// Every application record accepted behind durable work inherits durable
|
|
98
|
+
// ownership, so the tail answers this without scanning the FIFO.
|
|
99
|
+
return this.application.records.at(-1)?.preparation !== undefined;
|
|
100
|
+
}
|
|
93
101
|
get hasPendingWork() {
|
|
94
102
|
return (this.consumer?.running === true ||
|
|
95
103
|
this.activeRecord !== undefined ||
|
|
@@ -181,6 +189,18 @@ class ZLinkSerialExecutionQueue {
|
|
|
181
189
|
release();
|
|
182
190
|
throw error;
|
|
183
191
|
}
|
|
192
|
+
options.onAdmitted?.();
|
|
193
|
+
options.onWithdrawable?.(() => {
|
|
194
|
+
const index = target.records.indexOf(record);
|
|
195
|
+
if (index < 0)
|
|
196
|
+
return false;
|
|
197
|
+
target.records.splice(index, 1);
|
|
198
|
+
record.preparationController?.abort(new Error('Durable record transferred to another handoff.'));
|
|
199
|
+
record.preparation?.cancel();
|
|
200
|
+
resolve(undefined);
|
|
201
|
+
release();
|
|
202
|
+
return true;
|
|
203
|
+
});
|
|
184
204
|
this.scheduleDrain();
|
|
185
205
|
return result;
|
|
186
206
|
}
|
|
@@ -198,10 +218,10 @@ class ZLinkSerialExecutionQueue {
|
|
|
198
218
|
if (consumer.scheduled || consumer.running)
|
|
199
219
|
return;
|
|
200
220
|
consumer.scheduled = true;
|
|
201
|
-
queueMicrotask(() => {
|
|
221
|
+
(0, state_lane_1.startOutsideStateLane)(() => queueMicrotask(() => {
|
|
202
222
|
consumer.scheduled = false;
|
|
203
223
|
void this.drain();
|
|
204
|
-
});
|
|
224
|
+
}));
|
|
205
225
|
}
|
|
206
226
|
/** Notifications carry no payload, admission sequence, result Promise, or host permit. */
|
|
207
227
|
enqueueMailboxTurn(operation) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
type ZLinkStateLaneWork<T> = () => Promise<T> | T;
|
|
2
2
|
export declare function isStructuralGuardEnabled(): boolean;
|
|
3
|
+
/** Detaches lane ownership while preserving the caller's other execution contexts. */
|
|
4
|
+
export declare function startOutsideStateLane<T>(work: () => T): T;
|
|
3
5
|
/**
|
|
4
6
|
* Single-owner execution lane for a component's mutable state.
|
|
5
7
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkStateLane = void 0;
|
|
4
4
|
exports.isStructuralGuardEnabled = isStructuralGuardEnabled;
|
|
5
|
+
exports.startOutsideStateLane = startOutsideStateLane;
|
|
5
6
|
exports.guardStateLaneCompletion = guardStateLaneCompletion;
|
|
6
7
|
exports.trackDiagnosticCompletion = trackDiagnosticCompletion;
|
|
7
8
|
exports.debugPendingWorkNames = debugPendingWorkNames;
|
|
@@ -11,6 +12,10 @@ const UNKNOWN_DIAGNOSTIC_CALLER = '<unknown caller>';
|
|
|
11
12
|
function isStructuralGuardEnabled() {
|
|
12
13
|
return process.env.ZLINK_NODE_STRUCTURAL_GUARD === '1' || process.env.NODE_ENV === 'test';
|
|
13
14
|
}
|
|
15
|
+
/** Detaches lane ownership while preserving the caller's other execution contexts. */
|
|
16
|
+
function startOutsideStateLane(work) {
|
|
17
|
+
return currentLaneStorage.exit(() => diagnosticTurnStorage === undefined ? work() : diagnosticTurnStorage.exit(work));
|
|
18
|
+
}
|
|
14
19
|
const currentLaneStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
15
20
|
const diagnosticPending = isStructuralGuardEnabled() ? new Map() : undefined;
|
|
16
21
|
let nextDiagnosticWork = 0;
|
|
@@ -56,7 +56,7 @@ function encodeCanonicalActorJoinRecoverySavedWork(input) {
|
|
|
56
56
|
const request = Buffer.from(input.request);
|
|
57
57
|
const replyContentType = operationId === undefined
|
|
58
58
|
? null
|
|
59
|
-
:
|
|
59
|
+
: (nullableText(input.replyContentType ?? null, 'Actor Join reply content type') ?? null);
|
|
60
60
|
const metadata = encodeMetadataJson({
|
|
61
61
|
Request: {
|
|
62
62
|
ActorId: requireText(input.actorId, 'Actor id'),
|
|
@@ -167,7 +167,7 @@ function decodeCanonicalActorJoinRecoverySavedWork(encoded) {
|
|
|
167
167
|
const operationLow = integer(metadata.OperationIdLow, 'OperationIdLow');
|
|
168
168
|
const hasOperation = operationHigh !== 0n || operationLow !== 0n;
|
|
169
169
|
const replyContentType = nullableText(metadata.ReplyContentType, 'ReplyContentType');
|
|
170
|
-
if (hasOperation
|
|
170
|
+
if (!hasOperation && replyContentType !== undefined) {
|
|
171
171
|
throw new TypeError('Canonical Actor Join recovery reply identity is invalid.');
|
|
172
172
|
}
|
|
173
173
|
const targetNodeRid = base64(metadata.TargetNodeRid, 'TargetNodeRid');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PeerRouteObservation {
|
|
2
|
+
readonly generation?: bigint;
|
|
3
|
+
readonly ready: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface DurableServiceRequestPort {
|
|
6
|
+
readonly requestStopSignal?: AbortSignal;
|
|
7
|
+
observePeerRoute(target: string): PeerRouteObservation;
|
|
8
|
+
observePeerRouteChanged(listener: (target: string) => void): () => void;
|
|
9
|
+
observePeerConnectionIntentRemoved(listener: (target: string) => void): () => void;
|
|
10
|
+
requestService(target: string, parts: readonly Uint8Array[], timeoutMs: number, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
11
|
+
}
|
|
12
|
+
/** Actor model §8.1: a ready edge or a typed transport failure owns replay. */
|
|
13
|
+
export declare function requestDurableService(port: DurableServiceRequestPort, target: string, parts: readonly Uint8Array[], deadlineMs: number, operationKind: string, signal?: AbortSignal, onSubmitted?: (signal: AbortSignal) => Promise<void>): Promise<readonly Buffer[]>;
|
|
14
|
+
export declare function durableRequestCanReplay(error: unknown): boolean;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestDurableService = requestDurableService;
|
|
4
|
+
exports.durableRequestCanReplay = durableRequestCanReplay;
|
|
5
|
+
const abort_1 = require("../abort");
|
|
6
|
+
const runtime_values_1 = require("../backend/runtime-values");
|
|
7
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
|
+
/** Actor model §8.1: a ready edge or a typed transport failure owns replay. */
|
|
9
|
+
async function requestDurableService(port, target, parts, deadlineMs, operationKind, signal, onSubmitted) {
|
|
10
|
+
let wasAdmitted = false;
|
|
11
|
+
const stop = new AbortController();
|
|
12
|
+
const exhausted = (cause) => (0, framework_errors_internal_1.createInternalFrameworkException)(wasAdmitted
|
|
13
|
+
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded
|
|
14
|
+
: framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `${operationKind} exhausted its end-to-end deadline.`, true, cause);
|
|
15
|
+
const timer = setTimeout(() => stop.abort(exhausted()), Math.max(0, Math.ceil(deadlineMs - performance.now())));
|
|
16
|
+
const unobserveIntent = port.observePeerConnectionIntentRemoved((rid) => {
|
|
17
|
+
if (rid === target)
|
|
18
|
+
stop.abort((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `${operationKind} target node lifecycle ended.`, true));
|
|
19
|
+
});
|
|
20
|
+
const cancellation = AbortSignal.any([
|
|
21
|
+
stop.signal,
|
|
22
|
+
...(signal === undefined ? [] : [signal]),
|
|
23
|
+
...(port.requestStopSignal === undefined ? [] : [port.requestStopSignal])
|
|
24
|
+
]);
|
|
25
|
+
try {
|
|
26
|
+
for (;;) {
|
|
27
|
+
cancellation.throwIfAborted();
|
|
28
|
+
const remainingMs = Math.ceil(deadlineMs - performance.now());
|
|
29
|
+
if (remainingMs <= 0)
|
|
30
|
+
throw exhausted();
|
|
31
|
+
let changed;
|
|
32
|
+
const transition = new Promise((resolve) => {
|
|
33
|
+
changed = resolve;
|
|
34
|
+
});
|
|
35
|
+
let submittedGeneration;
|
|
36
|
+
const attemptStop = new AbortController();
|
|
37
|
+
const attemptSignal = AbortSignal.any([cancellation, attemptStop.signal]);
|
|
38
|
+
const unobserveRoute = port.observePeerRouteChanged((rid) => {
|
|
39
|
+
if (rid !== target)
|
|
40
|
+
return;
|
|
41
|
+
const route = port.observePeerRoute(target);
|
|
42
|
+
if (submittedGeneration === undefined
|
|
43
|
+
? route.ready
|
|
44
|
+
: route.generation !== undefined && route.generation !== submittedGeneration) {
|
|
45
|
+
changed();
|
|
46
|
+
attemptStop.abort();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const route = port.observePeerRoute(target);
|
|
51
|
+
if (!route.ready) {
|
|
52
|
+
await (0, abort_1.awaitWithAbort)(transition, cancellation);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
submittedGeneration = route.generation;
|
|
56
|
+
const reply = port.requestService(target, parts, remainingMs, () => {
|
|
57
|
+
wasAdmitted = true;
|
|
58
|
+
});
|
|
59
|
+
const request = onSubmitted === undefined
|
|
60
|
+
? reply
|
|
61
|
+
: Promise.race([
|
|
62
|
+
reply,
|
|
63
|
+
Promise.resolve()
|
|
64
|
+
.then(() => onSubmitted(attemptSignal))
|
|
65
|
+
.then(() => reply)
|
|
66
|
+
]);
|
|
67
|
+
const result = await (0, abort_1.awaitWithAbort)(Promise.race([request.then((parts) => ({ parts })), transition.then(() => undefined)]), cancellation);
|
|
68
|
+
if (result !== undefined)
|
|
69
|
+
return result.parts;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
cancellation.throwIfAborted();
|
|
73
|
+
if (!durableRequestCanReplay(error))
|
|
74
|
+
throw error;
|
|
75
|
+
if ((0, runtime_values_1.isZLinkBackendResultError)(error) && error.operation === 'request')
|
|
76
|
+
wasAdmitted = true;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
attemptStop.abort();
|
|
80
|
+
unobserveRoute();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
unobserveIntent();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function durableRequestCanReplay(error) {
|
|
90
|
+
if (!(0, runtime_values_1.isZLinkBackendResultError)(error))
|
|
91
|
+
return false;
|
|
92
|
+
return error.operation === 'request'
|
|
93
|
+
? error.result === runtime_values_1.RequestResult.NotConnected || error.result === runtime_values_1.RequestResult.TimedOut
|
|
94
|
+
: error.result === runtime_values_1.SubmitResult.NotConnected ||
|
|
95
|
+
error.result === runtime_values_1.SubmitResult.NotFound ||
|
|
96
|
+
error.result === runtime_values_1.SubmitResult.NotAdmitted ||
|
|
97
|
+
error.result === runtime_values_1.SubmitResult.Backpressured;
|
|
98
|
+
}
|
|
@@ -10,5 +10,6 @@ export type ZLinkOperationIdentityKey = string & {
|
|
|
10
10
|
readonly [operationKeyBrand]: true;
|
|
11
11
|
};
|
|
12
12
|
export declare function operationIdentityKey(operationId: ZLinkOperationIdentity128): ZLinkOperationIdentityKey;
|
|
13
|
+
export declare function validateOperationIdentity(operationId: ZLinkOperationIdentity128): void;
|
|
13
14
|
export declare function createRandomOperationIdentity(source?: (size: number) => Buffer): ZLinkOperationIdentity128;
|
|
14
15
|
export {};
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE = exports.OPERATION_IDENTITY_BYTES = void 0;
|
|
4
4
|
exports.operationIdentityKey = operationIdentityKey;
|
|
5
|
+
exports.validateOperationIdentity = validateOperationIdentity;
|
|
5
6
|
exports.createRandomOperationIdentity = createRandomOperationIdentity;
|
|
6
7
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
7
8
|
const node_crypto_1 = require("node:crypto");
|
|
8
9
|
exports.OPERATION_IDENTITY_BYTES = 16;
|
|
9
10
|
exports.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE = 2n;
|
|
10
11
|
function operationIdentityKey(operationId) {
|
|
12
|
+
validateOperationIdentity(operationId);
|
|
13
|
+
return `${operationId.high.toString(16)}:${operationId.low.toString(16)}`;
|
|
14
|
+
}
|
|
15
|
+
function validateOperationIdentity(operationId) {
|
|
11
16
|
requireUnsigned64(operationId.high, 'operationId.high');
|
|
12
17
|
requireUnsigned64(operationId.low, 'operationId.low');
|
|
13
18
|
if (operationId.high === 0n && operationId.low === 0n) {
|
|
14
19
|
throw new RangeError('Operation identity must not be all zero.');
|
|
15
20
|
}
|
|
16
|
-
return `${operationId.high.toString(16)}:${operationId.low.toString(16)}`;
|
|
17
21
|
}
|
|
18
22
|
function createRandomOperationIdentity(source = node_crypto_1.randomBytes) {
|
|
19
23
|
for (;;) {
|
|
@@ -13,6 +13,15 @@ export interface PendingOperation<T> {
|
|
|
13
13
|
readonly id: bigint;
|
|
14
14
|
readonly promise: Promise<T>;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Receives an operation's terminal at the place it is taken from the
|
|
18
|
+
* registry. One long-lived observer serves every observed operation, so an
|
|
19
|
+
* observed registration creates no Promise or per-operation callback.
|
|
20
|
+
*/
|
|
21
|
+
export interface OperationObserver<T, Context> {
|
|
22
|
+
operationCompleted(id: bigint, value: T, context: Context | undefined): void;
|
|
23
|
+
operationFailed(id: bigint, reason: unknown, context: Context | undefined): void;
|
|
24
|
+
}
|
|
16
25
|
/** Owns request completion so reply, timeout, cancellation, and shutdown race safely. */
|
|
17
26
|
export declare class OperationRegistry<T, Context = unknown> {
|
|
18
27
|
private readonly clock;
|
|
@@ -20,16 +29,31 @@ export declare class OperationRegistry<T, Context = unknown> {
|
|
|
20
29
|
private readonly entries;
|
|
21
30
|
private nextId;
|
|
22
31
|
private deadlineCursor?;
|
|
32
|
+
/**
|
|
33
|
+
* A lower bound of the earliest pending deadline. Completed entries only
|
|
34
|
+
* leave it early; a full expiry pass replaces it with the exact value.
|
|
35
|
+
*/
|
|
36
|
+
private earliestDeadlineMs;
|
|
37
|
+
private scanEarliestDeadlineMs;
|
|
23
38
|
private closed;
|
|
39
|
+
private pendingCount;
|
|
24
40
|
constructor(clock?: OperationClock, onPendingChanged?: (() => void) | undefined);
|
|
25
41
|
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender', context?: Context): PendingOperation<T>;
|
|
26
|
-
|
|
42
|
+
/** Registers an operation whose terminal goes to `observer` instead of a Promise. */
|
|
43
|
+
registerObserved(timeoutMs: number, observer: OperationObserver<T, Context>, context?: Context): bigint;
|
|
44
|
+
/** The time the next expiry pass has work, as a lower bound (spec 08 §4.2). */
|
|
45
|
+
nextDeadlineMs(): number;
|
|
46
|
+
private notePending;
|
|
47
|
+
complete(id: bigint, value: T, terminalContextRetentionMs?: number): boolean;
|
|
27
48
|
fail(id: bigint, reason: unknown): boolean;
|
|
28
49
|
cancel(id: bigint, message?: string): boolean;
|
|
29
50
|
isPending(id: bigint): boolean;
|
|
30
51
|
context(id: bigint): Context | undefined;
|
|
31
52
|
close(reason?: string): void;
|
|
53
|
+
failAll(reason: unknown): void;
|
|
32
54
|
get size(): number;
|
|
33
55
|
expire(nowMs: number, turnDeadlineMs: number): number;
|
|
34
56
|
private take;
|
|
57
|
+
private pendingEntry;
|
|
58
|
+
private retainTerminal;
|
|
35
59
|
}
|
|
@@ -29,7 +29,14 @@ class OperationRegistry {
|
|
|
29
29
|
entries = new Map();
|
|
30
30
|
nextId = 1n;
|
|
31
31
|
deadlineCursor;
|
|
32
|
+
/**
|
|
33
|
+
* A lower bound of the earliest pending deadline. Completed entries only
|
|
34
|
+
* leave it early; a full expiry pass replaces it with the exact value.
|
|
35
|
+
*/
|
|
36
|
+
earliestDeadlineMs = Number.POSITIVE_INFINITY;
|
|
37
|
+
scanEarliestDeadlineMs = Number.POSITIVE_INFINITY;
|
|
32
38
|
closed = false;
|
|
39
|
+
pendingCount = 0;
|
|
33
40
|
constructor(clock = systemClock, onPendingChanged) {
|
|
34
41
|
this.clock = clock;
|
|
35
42
|
this.onPendingChanged = onPendingChanged;
|
|
@@ -47,36 +54,63 @@ class OperationRegistry {
|
|
|
47
54
|
resolve = onResolve;
|
|
48
55
|
reject = onReject;
|
|
49
56
|
});
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
deadlineMs: timeoutOwner === 'registry' ? this.clock.now() + timeoutMs : undefined,
|
|
53
|
-
resolve,
|
|
54
|
-
reject
|
|
55
|
-
};
|
|
57
|
+
const deadlineMs = timeoutOwner === 'registry' ? this.clock.now() + timeoutMs : undefined;
|
|
58
|
+
const entry = { context, deadlineMs, resolve, reject };
|
|
56
59
|
this.entries.set(id, entry);
|
|
57
|
-
|
|
58
|
-
this.onPendingChanged?.();
|
|
60
|
+
this.notePending(deadlineMs);
|
|
59
61
|
return { id, promise };
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
/** Registers an operation whose terminal goes to `observer` instead of a Promise. */
|
|
64
|
+
registerObserved(timeoutMs, observer, context) {
|
|
65
|
+
if (this.closed)
|
|
66
|
+
throw new Error('Operation registry is closed.');
|
|
67
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
68
|
+
throw new RangeError('timeoutMs must be a non-negative finite number.');
|
|
69
|
+
}
|
|
70
|
+
const id = this.nextId++;
|
|
71
|
+
const deadlineMs = this.clock.now() + timeoutMs;
|
|
72
|
+
this.entries.set(id, { context, deadlineMs, observer });
|
|
73
|
+
this.notePending(deadlineMs);
|
|
74
|
+
return id;
|
|
75
|
+
}
|
|
76
|
+
/** The time the next expiry pass has work, as a lower bound (spec 08 §4.2). */
|
|
77
|
+
nextDeadlineMs() {
|
|
78
|
+
return this.earliestDeadlineMs;
|
|
79
|
+
}
|
|
80
|
+
notePending(deadlineMs) {
|
|
81
|
+
this.pendingCount++;
|
|
82
|
+
const earlier = deadlineMs !== undefined && deadlineMs < this.earliestDeadlineMs;
|
|
83
|
+
if (earlier)
|
|
84
|
+
this.earliestDeadlineMs = deadlineMs;
|
|
85
|
+
if (earlier || this.pendingCount === 1)
|
|
86
|
+
this.onPendingChanged?.();
|
|
87
|
+
}
|
|
88
|
+
complete(id, value, terminalContextRetentionMs = 0) {
|
|
62
89
|
const entry = this.take(id);
|
|
63
90
|
if (entry === undefined)
|
|
64
91
|
return false;
|
|
65
|
-
entry.
|
|
92
|
+
if (entry.observer !== undefined)
|
|
93
|
+
entry.observer.operationCompleted(id, value, entry.context);
|
|
94
|
+
else
|
|
95
|
+
entry.resolve(value);
|
|
96
|
+
this.retainTerminal(id, entry, terminalContextRetentionMs);
|
|
66
97
|
return true;
|
|
67
98
|
}
|
|
68
99
|
fail(id, reason) {
|
|
69
100
|
const entry = this.take(id);
|
|
70
101
|
if (entry === undefined)
|
|
71
102
|
return false;
|
|
72
|
-
entry.
|
|
103
|
+
if (entry.observer !== undefined)
|
|
104
|
+
entry.observer.operationFailed(id, reason, entry.context);
|
|
105
|
+
else
|
|
106
|
+
entry.reject(reason);
|
|
73
107
|
return true;
|
|
74
108
|
}
|
|
75
109
|
cancel(id, message) {
|
|
76
110
|
return this.fail(id, new OperationCancelledError(id, message));
|
|
77
111
|
}
|
|
78
112
|
isPending(id) {
|
|
79
|
-
return this.
|
|
113
|
+
return this.pendingEntry(id) !== undefined;
|
|
80
114
|
}
|
|
81
115
|
context(id) {
|
|
82
116
|
return this.entries.get(id)?.context;
|
|
@@ -87,36 +121,70 @@ class OperationRegistry {
|
|
|
87
121
|
this.closed = true;
|
|
88
122
|
for (const id of this.entries.keys())
|
|
89
123
|
this.cancel(id, reason);
|
|
124
|
+
this.entries.clear();
|
|
90
125
|
this.deadlineCursor = undefined;
|
|
91
126
|
}
|
|
127
|
+
failAll(reason) {
|
|
128
|
+
for (const id of this.entries.keys())
|
|
129
|
+
this.fail(id, reason);
|
|
130
|
+
}
|
|
92
131
|
get size() {
|
|
93
|
-
return this.
|
|
132
|
+
return this.pendingCount;
|
|
94
133
|
}
|
|
95
134
|
expire(nowMs, turnDeadlineMs) {
|
|
96
135
|
let expired = 0;
|
|
97
136
|
while (this.clock.now() < turnDeadlineMs) {
|
|
98
|
-
this.deadlineCursor
|
|
137
|
+
if (this.deadlineCursor === undefined) {
|
|
138
|
+
this.deadlineCursor = this.entries.entries();
|
|
139
|
+
this.scanEarliestDeadlineMs = Number.POSITIVE_INFINITY;
|
|
140
|
+
}
|
|
99
141
|
const current = this.deadlineCursor.next();
|
|
100
142
|
if (current.done === true) {
|
|
101
143
|
this.deadlineCursor = undefined;
|
|
144
|
+
// Entries registered during the pass are appended and were scanned.
|
|
145
|
+
this.earliestDeadlineMs = this.scanEarliestDeadlineMs;
|
|
102
146
|
break;
|
|
103
147
|
}
|
|
104
148
|
const [id, entry] = current.value;
|
|
105
|
-
if (entry.deadlineMs
|
|
106
|
-
|
|
149
|
+
if (entry.deadlineMs === undefined)
|
|
150
|
+
continue;
|
|
151
|
+
if (entry.deadlineMs <= nowMs) {
|
|
152
|
+
if (!this.isPending(id))
|
|
153
|
+
this.entries.delete(id);
|
|
154
|
+
else if (this.fail(id, new OperationTimeoutError(id)))
|
|
107
155
|
expired++;
|
|
108
156
|
}
|
|
157
|
+
else if (entry.deadlineMs < this.scanEarliestDeadlineMs) {
|
|
158
|
+
this.scanEarliestDeadlineMs = entry.deadlineMs;
|
|
159
|
+
}
|
|
109
160
|
}
|
|
110
161
|
return expired;
|
|
111
162
|
}
|
|
112
163
|
take(id) {
|
|
113
|
-
const entry = this.
|
|
164
|
+
const entry = this.pendingEntry(id);
|
|
114
165
|
if (entry === undefined)
|
|
115
166
|
return undefined;
|
|
116
167
|
this.entries.delete(id);
|
|
117
|
-
|
|
168
|
+
this.pendingCount--;
|
|
169
|
+
if (this.pendingCount === 0)
|
|
118
170
|
this.onPendingChanged?.();
|
|
119
171
|
return entry;
|
|
120
172
|
}
|
|
173
|
+
pendingEntry(id) {
|
|
174
|
+
const entry = this.entries.get(id);
|
|
175
|
+
return entry !== undefined && (entry.resolve !== undefined || entry.observer !== undefined)
|
|
176
|
+
? entry
|
|
177
|
+
: undefined;
|
|
178
|
+
}
|
|
179
|
+
retainTerminal(id, entry, retentionMs) {
|
|
180
|
+
if (this.closed || entry.context === undefined || retentionMs === 0)
|
|
181
|
+
return;
|
|
182
|
+
entry.resolve = undefined;
|
|
183
|
+
entry.reject = undefined;
|
|
184
|
+
entry.observer = undefined;
|
|
185
|
+
entry.deadlineMs = this.clock.now() + retentionMs;
|
|
186
|
+
this.entries.set(id, entry);
|
|
187
|
+
this.earliestDeadlineMs = Math.min(this.earliestDeadlineMs, entry.deadlineMs);
|
|
188
|
+
}
|
|
121
189
|
}
|
|
122
190
|
exports.OperationRegistry = OperationRegistry;
|
|
@@ -2,7 +2,7 @@ import { ApplicationIngressRecordOwner } from '../application-jobs/application-i
|
|
|
2
2
|
import type { ApplicationJobQueuePort } from '../application-jobs/contracts';
|
|
3
3
|
import type { ZLinkRawBindingPort } from '../backend/raw-binding-port';
|
|
4
4
|
import { SubmitResult } from '../backend/runtime-values';
|
|
5
|
-
import { type PendingOperation } from './operation-registry';
|
|
5
|
+
import { type OperationObserver, type PendingOperation } from './operation-registry';
|
|
6
6
|
import { ServiceLivenessRegistry, type ServiceLivenessTick } from './service-liveness-registry';
|
|
7
7
|
import { ServiceMailbox, type ServiceMailboxRecord } from './service-mailbox';
|
|
8
8
|
import { ServiceTopologyRegistry, type ServiceNodeDescriptor } from './service-topology-registry';
|
|
@@ -14,9 +14,23 @@ export interface RawServiceRequestResult {
|
|
|
14
14
|
readonly failureCode: number;
|
|
15
15
|
readonly payload?: ServiceApplicationPayload;
|
|
16
16
|
}
|
|
17
|
+
/** Receives observed request terminals; the context is the caller's operation kind. */
|
|
18
|
+
export type RawServiceRequestObserver = OperationObserver<RawServiceRequestResult, number>;
|
|
19
|
+
/**
|
|
20
|
+
* A registered request. An observed remote request has no Promise; its
|
|
21
|
+
* terminal reaches the observer. Local and Promise-contract requests carry
|
|
22
|
+
* the Promise.
|
|
23
|
+
*/
|
|
24
|
+
export interface RawServiceObservedRequest {
|
|
25
|
+
readonly id: bigint;
|
|
26
|
+
readonly promise?: Promise<RawServiceRequestResult>;
|
|
27
|
+
}
|
|
17
28
|
/** An M6A application frame already owned by the Framework runtime. */
|
|
18
29
|
type ServiceApplicationPayloadInput = ServiceApplicationPayload | Buffer;
|
|
19
30
|
export interface RawServiceIngressRecord {
|
|
31
|
+
/** Source identity recorded once by the first accepting owner (Location runtime §9.3). */
|
|
32
|
+
requestSource?: import('../locations/request-source-resolver').ZLinkRequestSourceFence;
|
|
33
|
+
readonly onAdmitted?: () => void;
|
|
20
34
|
readonly command: number;
|
|
21
35
|
readonly flags: number;
|
|
22
36
|
readonly sourceRoutingId: string;
|
|
@@ -63,6 +77,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
63
77
|
private readonly expectedPeers;
|
|
64
78
|
private readonly endpointOnlyPeers;
|
|
65
79
|
private readonly peerConnectionIntentRemoved;
|
|
80
|
+
private readonly peerRouteChanged;
|
|
66
81
|
/**
|
|
67
82
|
* The last observed Core selected route of each RID (Core ROUTER §10.1):
|
|
68
83
|
* RID -> route generation. Only `observeSelectedRoutes` replaces it.
|
|
@@ -70,10 +85,12 @@ export declare class RawServiceMeshRuntime {
|
|
|
70
85
|
private selectedRoutes;
|
|
71
86
|
private readonly bindingPort;
|
|
72
87
|
private readonly applicationJobQueue;
|
|
88
|
+
private readonly nodeMailboxOwner;
|
|
73
89
|
private readonly peerAdmissionSealed?;
|
|
74
90
|
private readonly applicationJobStop;
|
|
75
91
|
private receiveAcquisition?;
|
|
76
92
|
private receivePermit?;
|
|
93
|
+
private receiveRotation?;
|
|
77
94
|
private readonly controlSends;
|
|
78
95
|
private infrastructureFailure?;
|
|
79
96
|
private readonly onReceiveReady?;
|
|
@@ -88,6 +105,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
88
105
|
private router?;
|
|
89
106
|
private nextCorrelation;
|
|
90
107
|
private serviceIngress?;
|
|
108
|
+
private serviceIngressAccepts?;
|
|
91
109
|
private closed;
|
|
92
110
|
constructor(options: RawServiceMeshRuntimeOptions);
|
|
93
111
|
start(): void;
|
|
@@ -98,8 +116,15 @@ export declare class RawServiceMeshRuntime {
|
|
|
98
116
|
disconnectPeer(endpoint: string, nodeRoutingId: string, lifecycleGeneration?: bigint): void;
|
|
99
117
|
disconnectPeerEndpoint(endpoint: string): void;
|
|
100
118
|
observePeerConnectionIntentRemoved(listener: (nodeRoutingId: string) => void): () => void;
|
|
119
|
+
observePeerRoute(nodeRoutingId: string): import('./durable-service-request').PeerRouteObservation;
|
|
120
|
+
waitForPeerRoute(nodeRoutingId: string, lifecycleGeneration: bigint, deadlineUnixMs: bigint, signal?: AbortSignal): Promise<void>;
|
|
121
|
+
get requestStopSignal(): AbortSignal;
|
|
122
|
+
observePeerRouteChanged(listener: (nodeRoutingId: string) => void): () => void;
|
|
123
|
+
hasSelectedPeerRoute(nodeRoutingId: string): boolean;
|
|
124
|
+
private notifyPeerRouteChanged;
|
|
101
125
|
private notifyPeerConnectionIntentRemoved;
|
|
102
|
-
announcePeer(nodeRoutingId: string):
|
|
126
|
+
announcePeer(nodeRoutingId: string): boolean;
|
|
127
|
+
private isPeerAnnouncementCurrent;
|
|
103
128
|
isPeerRouteReady(nodeRoutingId: string, lifecycleGeneration?: bigint): boolean;
|
|
104
129
|
announceExpectedPeers(): Promise<number>;
|
|
105
130
|
updateLocalDescriptor(options: {
|
|
@@ -108,17 +133,31 @@ export declare class RawServiceMeshRuntime {
|
|
|
108
133
|
readonly channelWeight?: number;
|
|
109
134
|
readonly state?: 'draining';
|
|
110
135
|
}): Promise<void>;
|
|
136
|
+
private publishLocalDescriptor;
|
|
111
137
|
replaceDiscoveredNotRequired(descriptors: readonly ServiceNodeDescriptor[]): void;
|
|
112
138
|
isObjectClientNodeDirectTarget(nodeRoutingId: string): boolean;
|
|
113
|
-
sendToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput): Promise<boolean>;
|
|
139
|
+
sendToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput): boolean | Promise<boolean>;
|
|
114
140
|
sendToChannel(channelName: string, payload: ServiceApplicationPayloadInput): Promise<SubmitResult>;
|
|
115
|
-
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number): PendingOperation<RawServiceRequestResult>;
|
|
116
|
-
|
|
141
|
+
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted?: () => void): PendingOperation<RawServiceRequestResult>;
|
|
142
|
+
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted: (() => void) | undefined, observer: RawServiceRequestObserver, operationKind: number): RawServiceObservedRequest;
|
|
143
|
+
requestToChannel(channelName: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted?: () => void): PendingOperation<RawServiceRequestResult>;
|
|
144
|
+
requestToChannel(channelName: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted: (() => void) | undefined, observer: RawServiceRequestObserver, operationKind: number): RawServiceObservedRequest;
|
|
145
|
+
/**
|
|
146
|
+
* One pending entry per request: an observed request reports its terminal
|
|
147
|
+
* to the caller's observer; any other request keeps the Promise contract.
|
|
148
|
+
*/
|
|
149
|
+
private registerRequest;
|
|
150
|
+
/**
|
|
151
|
+
* An observed caller learns the operation id only when the request call
|
|
152
|
+
* returns, so a terminal decided inside that call is delivered after it.
|
|
153
|
+
*/
|
|
154
|
+
private completeRequest;
|
|
155
|
+
private failRequest;
|
|
117
156
|
private selectChannelTarget;
|
|
118
|
-
setServiceIngress(handler: RawServiceIngressHandler): void;
|
|
157
|
+
setServiceIngress(handler: RawServiceIngressHandler, accepts?: (command: number) => boolean): void;
|
|
119
158
|
reserveLocalIngress(signal?: AbortSignal): Promise<ApplicationIngressRecordOwner>;
|
|
120
159
|
sendService(targetNodeRoutingId: string, parts: readonly Uint8Array[]): Promise<boolean>;
|
|
121
|
-
requestService(targetNodeRoutingId: string, parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]>;
|
|
160
|
+
requestService(targetNodeRoutingId: string, parts: readonly Uint8Array[], timeoutMs: number, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
122
161
|
replyService(record: Pick<RawServiceIngressRecord, 'sourceRoutingId' | 'sourceRoute' | 'requestSequence' | 'reply'>, parts: readonly Uint8Array[]): void;
|
|
123
162
|
reply(request: ServiceMailboxRecord, payload: ServiceApplicationPayloadInput, terminalResult?: number, failureCode?: number): void;
|
|
124
163
|
pumpOne(nowMs?: number, observe?: RawServicePumpObserver): Promise<RawServicePumpResult>;
|
|
@@ -126,11 +165,25 @@ export declare class RawServiceMeshRuntime {
|
|
|
126
165
|
/** Returns whether a receive budget ended before no-data; idle ticks only maintain peers. */
|
|
127
166
|
pumpBatch(receiveReady?: boolean, routeReady?: boolean): Promise<boolean>;
|
|
128
167
|
private receiveOne;
|
|
168
|
+
private finishReceive;
|
|
129
169
|
private reportProtocolError;
|
|
130
170
|
private replyGenericProtocolError;
|
|
131
171
|
private processReceived;
|
|
172
|
+
private receiveProtocolFailure;
|
|
173
|
+
private processAdmission;
|
|
174
|
+
private processLiveness;
|
|
175
|
+
private processApplicationReceived;
|
|
176
|
+
private enqueueOrdinaryRecord;
|
|
132
177
|
expireOperations(nowMs: number, turnDeadlineMs: number): number;
|
|
133
178
|
get pendingOperationCount(): number;
|
|
179
|
+
cancelPendingOperations(reason: unknown): void;
|
|
180
|
+
/**
|
|
181
|
+
* The next management deadline of this node (spec 08 §4.2): request expiry,
|
|
182
|
+
* liveness probe or timeout, or an owned HELLO exchange still awaiting
|
|
183
|
+
* ADMIT, which keeps the existing announce cadence.
|
|
184
|
+
*/
|
|
185
|
+
nextMaintenanceDeadlineMs(nowMs: number): number;
|
|
186
|
+
private refreshAdmissionPending;
|
|
134
187
|
tickLiveness(nowMs?: number): ServiceLivenessTick;
|
|
135
188
|
/**
|
|
136
189
|
* The socket's one route observer (Core ROUTER §10.1). It replaces the
|
|
@@ -155,7 +208,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
155
208
|
private sendControl;
|
|
156
209
|
private submitControl;
|
|
157
210
|
private startControlSend;
|
|
158
|
-
|
|
211
|
+
reportInfrastructureFailure(error: unknown): void;
|
|
159
212
|
private observeInfrastructureFailure;
|
|
160
213
|
private send;
|
|
161
214
|
private sendFailure;
|