@zlink-systems/framework 0.31.0 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Actors/ZLinkActor.d.ts +2 -0
  3. package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
  4. package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
  5. package/dist/contracts/Actors/index.d.ts +1 -0
  6. package/dist/contracts/Actors/index.js +1 -0
  7. package/dist/contracts/Common/payload-slab.d.ts +4 -0
  8. package/dist/contracts/Common/payload-slab.js +30 -0
  9. package/dist/contracts/Handlers/Contexts.d.ts +1 -0
  10. package/dist/internal.d.ts +9 -0
  11. package/dist/internal.js +23 -1
  12. package/dist/runtime/actors/actor-client.d.ts +1 -1
  13. package/dist/runtime/actors/actor-client.js +32 -23
  14. package/dist/runtime/actors/actor-context.js +1 -1
  15. package/dist/runtime/actors/actor-creation.js +1 -1
  16. package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
  17. package/dist/runtime/actors/actor-runtime-state.d.ts +3 -2
  18. package/dist/runtime/actors/actor-runtime-state.js +24 -8
  19. package/dist/runtime/actors/index.d.ts +3 -3
  20. package/dist/runtime/actors/index.js +19 -32
  21. package/dist/runtime/actors/spot-actor-dispatch.d.ts +4 -2
  22. package/dist/runtime/actors/spot-actor-dispatch.js +2 -1
  23. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
  24. package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
  25. package/dist/runtime/backend/contracts/index.d.ts +2 -0
  26. package/dist/runtime/backend/mesh-completion-table.d.ts +1 -0
  27. package/dist/runtime/backend/mesh-completion-table.js +1 -0
  28. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
  29. package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
  30. package/dist/runtime/backend/node/node-raw-binding-port.js +17 -11
  31. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +2 -2
  32. package/dist/runtime/backend/node/node-raw-mesh-backend.js +15 -8
  33. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +7 -6
  34. package/dist/runtime/channels/channel-dispatch-pipeline.js +1 -0
  35. package/dist/runtime/channels/channel-dispatchers.d.ts +7 -3
  36. package/dist/runtime/channels/channel-dispatchers.js +27 -19
  37. package/dist/runtime/channels/channel-envelope.js +543 -23
  38. package/dist/runtime/channels/channel-receive-loops.d.ts +9 -6
  39. package/dist/runtime/channels/channel-receive-loops.js +59 -18
  40. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +22 -3
  41. package/dist/runtime/channels/channel-socket-registry.d.ts +22 -4
  42. package/dist/runtime/diagnostics/runtime-metrics.d.ts +1 -1
  43. package/dist/runtime/diagnostics/runtime-metrics.js +2 -1
  44. package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
  45. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +27 -11
  46. package/dist/runtime/foundation/raw-service-mesh-runtime.js +29 -25
  47. package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
  48. package/dist/runtime/foundation/service-mailbox.d.ts +3 -1
  49. package/dist/runtime/foundation/service-mailbox.js +4 -1
  50. package/dist/runtime/foundation/service-runtime-contracts.d.ts +3 -1
  51. package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
  52. package/dist/runtime/foundation/service-stateful-registry.js +28 -12
  53. package/dist/runtime/foundation/service-stateful-runtime.d.ts +51 -19
  54. package/dist/runtime/foundation/service-stateful-runtime.js +54 -5
  55. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
  56. package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
  57. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  58. package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
  59. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
  60. package/dist/runtime/foundation/service-wire-m6a-codec.js +17 -7
  61. package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
  62. package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
  63. package/dist/runtime/host/application-job-queue.d.ts +1 -1
  64. package/dist/runtime/host/index.d.ts +89 -36
  65. package/dist/runtime/host/index.js +101 -7
  66. package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
  67. package/dist/runtime/host/service-relocation-host-runtime.d.ts +181 -44
  68. package/dist/runtime/host/service-relocation-host-runtime.js +47 -13
  69. package/dist/runtime/host/spot-address-transport.js +50 -42
  70. package/dist/runtime/locations/actor-location-claims.js +9 -10
  71. package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
  72. package/dist/runtime/locations/auto-connect-loop.js +25 -19
  73. package/dist/runtime/locations/auto-connect-planner.js +2 -5
  74. package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
  75. package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
  76. package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
  77. package/dist/runtime/locations/in-memory-location-store.js +1 -38
  78. package/dist/runtime/locations/location-store-repository.d.ts +0 -1
  79. package/dist/runtime/locations/location-store-repository.js +13 -115
  80. package/dist/runtime/locations/runtime.d.ts +3 -3
  81. package/dist/runtime/locations/runtime.js +12 -16
  82. package/dist/runtime/messaging/creation-payload-codec.js +2 -2
  83. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
  84. package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
  85. package/dist/runtime/spots/index.d.ts +20 -5
  86. package/dist/runtime/spots/index.js +14 -0
  87. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +3 -3
  88. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +1 -0
  89. package/dist/runtime/spots/spot-actor-packet-dispatch.js +13 -7
  90. package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
  91. package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
  92. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -1
  93. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +8 -6
  94. package/dist/runtime/spots/spot-node-runtime-manager.js +2 -0
  95. package/dist/runtime/spots/spot-route-packet-dispatch.js +7 -4
  96. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +3 -1
  97. package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
  98. package/dist/runtime/spots/spot-subscription-dispatch.js +3 -1
  99. package/dist/runtime/spots/spot-timer.d.ts +1 -1
  100. package/dist/runtime/streams/actor-session-binding-registry.d.ts +9 -3
  101. package/dist/runtime/streams/actor-session-binding-registry.js +17 -0
  102. package/dist/runtime/streams/index.d.ts +3 -3
  103. package/dist/runtime/streams/index.js +22 -2
  104. package/dist/runtime/streams/managed-stream.js +2 -1
  105. package/dist/runtime/streams/session-calls.d.ts +1 -1
  106. package/dist/runtime/streams/session-calls.js +3 -9
  107. package/dist/runtime/streams/session-context.d.ts +2 -2
  108. package/dist/runtime/streams/session-context.js +2 -2
  109. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
  110. package/dist/runtime/streams/stream-session-runtime.js +37 -12
  111. package/package.json +3 -3
  112. package/src/contracts/Actors/ZLinkActor.ts +6 -0
  113. package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
  114. package/src/contracts/Actors/index.ts +1 -0
  115. package/src/contracts/Common/payload-slab.ts +29 -0
  116. package/src/contracts/Handlers/Contexts.ts +1 -0
  117. package/src/internal.ts +17 -0
  118. package/src/runtime/actors/actor-client.ts +48 -23
  119. package/src/runtime/actors/actor-context.ts +1 -1
  120. package/src/runtime/actors/actor-creation.ts +1 -1
  121. package/src/runtime/actors/actor-mailbox.ts +1 -1
  122. package/src/runtime/actors/actor-runtime-state.ts +28 -10
  123. package/src/runtime/actors/index.ts +30 -35
  124. package/src/runtime/actors/spot-actor-dispatch.ts +4 -3
  125. package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
  126. package/src/runtime/backend/contracts/index.ts +2 -0
  127. package/src/runtime/backend/mesh-completion-table.ts +2 -0
  128. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
  129. package/src/runtime/backend/node/node-raw-binding-port.ts +20 -7
  130. package/src/runtime/backend/node/node-raw-mesh-backend.ts +18 -10
  131. package/src/runtime/channels/channel-dispatch-pipeline.ts +6 -5
  132. package/src/runtime/channels/channel-dispatchers.ts +39 -19
  133. package/src/runtime/channels/channel-envelope.ts +547 -20
  134. package/src/runtime/channels/channel-receive-loops.ts +93 -36
  135. package/src/runtime/channels/channel-runtime-lifecycle.ts +2 -2
  136. package/src/runtime/channels/channel-socket-registry.ts +3 -3
  137. package/src/runtime/diagnostics/runtime-metrics.ts +3 -1
  138. package/src/runtime/execution/serial-execution-queue.ts +13 -13
  139. package/src/runtime/foundation/raw-service-mesh-runtime.ts +40 -39
  140. package/src/runtime/foundation/service-liveness-registry.ts +1 -1
  141. package/src/runtime/foundation/service-mailbox.ts +6 -1
  142. package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
  143. package/src/runtime/foundation/service-stateful-registry.ts +39 -14
  144. package/src/runtime/foundation/service-stateful-runtime.ts +87 -21
  145. package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
  146. package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
  147. package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -7
  148. package/src/runtime/host/actor-placement-coordinator.ts +1 -1
  149. package/src/runtime/host/actor-transfer-runtime.ts +3 -3
  150. package/src/runtime/host/application-job-queue.ts +1 -1
  151. package/src/runtime/host/index.ts +183 -44
  152. package/src/runtime/host/location-runtime-owner.ts +2 -2
  153. package/src/runtime/host/service-relocation-host-runtime.ts +101 -65
  154. package/src/runtime/host/spot-address-transport.ts +67 -61
  155. package/src/runtime/locations/actor-location-claims.ts +14 -14
  156. package/src/runtime/locations/auto-connect-loop.ts +24 -16
  157. package/src/runtime/locations/auto-connect-planner.ts +2 -5
  158. package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
  159. package/src/runtime/locations/in-memory-location-store.ts +1 -74
  160. package/src/runtime/locations/location-store-repository.ts +32 -153
  161. package/src/runtime/locations/runtime.ts +16 -28
  162. package/src/runtime/messaging/creation-payload-codec.ts +3 -3
  163. package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
  164. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  165. package/src/runtime/spots/index.ts +28 -4
  166. package/src/runtime/spots/spot-actor-admission-coordinator.ts +1 -1
  167. package/src/runtime/spots/spot-actor-packet-dispatch.ts +16 -6
  168. package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
  169. package/src/runtime/spots/spot-entry-activation.ts +1 -1
  170. package/src/runtime/spots/spot-node-runtime-manager.ts +8 -6
  171. package/src/runtime/spots/spot-route-packet-dispatch.ts +8 -4
  172. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +3 -1
  173. package/src/runtime/spots/spot-serial-executor.ts +1 -1
  174. package/src/runtime/spots/spot-subscription-dispatch.ts +3 -1
  175. package/src/runtime/spots/spot-timer.ts +1 -1
  176. package/src/runtime/streams/actor-session-binding-registry.ts +30 -3
  177. package/src/runtime/streams/index.ts +30 -4
  178. package/src/runtime/streams/managed-stream.ts +2 -1
  179. package/src/runtime/streams/session-calls.ts +9 -14
  180. package/src/runtime/streams/session-context.ts +6 -11
  181. package/src/runtime/streams/stream-session-runtime.ts +49 -20
@@ -6601,6 +6601,9 @@ function readRequestSpecificTail(reader, context, enclosing, flags) {
6601
6601
  value["bindingGeneration"] = readNonzeroU64(body, context, value, flags);
6602
6602
  value["authorityOwnerGeneration"] = readNonzeroU64(body, context, value, flags);
6603
6603
  }
6604
+ else if (same(value["originalOperationKind"], "streamBind") && same(value["terminalResult"], "rejected")) {
6605
+ value["rejectionMessage"] = readNonemptyText16(body, context, value, flags);
6606
+ }
6604
6607
  else if (same(value["originalOperationKind"], "userSpotCreate") && same(value["terminalResult"], "ok")) {
6605
6608
  value["createResult"] = readUserSpotCreateResult(body, context, value, flags);
6606
6609
  value["spot"] = readSpotRef(body, context, value, flags);
@@ -6622,7 +6625,7 @@ function writeRequestSpecificTail(input, writer, context, enclosing, flags) {
6622
6625
  const value = input;
6623
6626
  const body = writer;
6624
6627
  if (same(value["originalOperationKind"], "actorLookup") && same(value["terminalResult"], "ok")) {
6625
- if (value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6628
+ if (value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6626
6629
  fail("request-specific-tail discriminator agreement");
6627
6630
  if (value["actor"] === undefined)
6628
6631
  fail("actor required");
@@ -6641,14 +6644,14 @@ function writeRequestSpecificTail(input, writer, context, enclosing, flags) {
6641
6644
  writeNonzeroU64(numeric(value["authorityOwnerGeneration"]), body, context, value, flags);
6642
6645
  }
6643
6646
  else if (same(value["originalOperationKind"], "actorJoin") && same(value["terminalResult"], "ok")) {
6644
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6647
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6645
6648
  fail("request-specific-tail discriminator agreement");
6646
6649
  if (value["join"] === undefined)
6647
6650
  fail("join required");
6648
6651
  writeActorJoinReplyTail(value["join"], body, context, value, flags);
6649
6652
  }
6650
6653
  else if (same(value["originalOperationKind"], "streamBind") && same(value["terminalResult"], "ok")) {
6651
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["join"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6654
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["join"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6652
6655
  fail("request-specific-tail discriminator agreement");
6653
6656
  if (value["bindingGeneration"] === undefined)
6654
6657
  fail("bindingGeneration required");
@@ -6657,8 +6660,15 @@ function writeRequestSpecificTail(input, writer, context, enclosing, flags) {
6657
6660
  fail("authorityOwnerGeneration required");
6658
6661
  writeNonzeroU64(numeric(value["authorityOwnerGeneration"]), body, context, value, flags);
6659
6662
  }
6663
+ else if (same(value["originalOperationKind"], "streamBind") && same(value["terminalResult"], "rejected")) {
6664
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6665
+ fail("request-specific-tail discriminator agreement");
6666
+ if (value["rejectionMessage"] === undefined)
6667
+ fail("rejectionMessage required");
6668
+ writeNonemptyText16(value["rejectionMessage"], body, context, value, flags);
6669
+ }
6660
6670
  else if (same(value["originalOperationKind"], "userSpotCreate") && same(value["terminalResult"], "ok")) {
6661
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6671
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6662
6672
  fail("request-specific-tail discriminator agreement");
6663
6673
  if (value["createResult"] === undefined)
6664
6674
  fail("createResult required");
@@ -6668,21 +6678,21 @@ function writeRequestSpecificTail(input, writer, context, enclosing, flags) {
6668
6678
  writeSpotRef(value["spot"], body, context, value, flags);
6669
6679
  }
6670
6680
  else if (same(value["originalOperationKind"], "userSpotClose") && same(value["terminalResult"], "ok")) {
6671
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["creation"] !== undefined)
6681
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["creation"] !== undefined)
6672
6682
  fail("request-specific-tail discriminator agreement");
6673
6683
  if (value["closed"] === undefined)
6674
6684
  fail("closed required");
6675
6685
  writeBool8(value["closed"], body, context, value, flags);
6676
6686
  }
6677
6687
  else if (same(value["originalOperationKind"], "actorCreate") && same(value["terminalResult"], "ok")) {
6678
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined)
6688
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined)
6679
6689
  fail("request-specific-tail discriminator agreement");
6680
6690
  if (value["creation"] === undefined)
6681
6691
  fail("creation required");
6682
6692
  writeActorCreateTerminal(value["creation"], body, context, value, flags);
6683
6693
  }
6684
6694
  else {
6685
- if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6695
+ if (value["actor"] !== undefined || value["spotId"] !== undefined || value["spotGeneration"] !== undefined || value["membershipEpoch"] !== undefined || value["authorityOwnerGeneration"] !== undefined || value["join"] !== undefined || value["bindingGeneration"] !== undefined || value["rejectionMessage"] !== undefined || value["createResult"] !== undefined || value["spot"] !== undefined || value["closed"] !== undefined || value["creation"] !== undefined)
6686
6696
  fail("request-specific-tail discriminator agreement");
6687
6697
  }
6688
6698
  }
@@ -10,7 +10,7 @@ export { ZLinkSpotActorAdmissionCoordinator } from './spot-actor-admission-coord
10
10
  import type { ZLinkSpotRouteResolver, ZLinkSpotRouteTarget } from './spot-routing-internal';
11
11
  import type { Message } from '../../contracts/Common/Message';
12
12
  import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
13
- import { ZLinkMessage, ZLinkFrameworkRuntimeState } from '../../contracts';
13
+ import { ZLinkMessage, ZLinkFrameworkRuntimeState, ZLinkSpotCloseReason } from '../../contracts';
14
14
  import { type ZLinkRuntimeEventPublisher } from '../diagnostics';
15
15
  import { type ReadyRecord, type ReceiveRecord } from '../foundation/service-runtime-contracts';
16
16
  import type { ZLinkBackendSpot, ZLinkBackendSpotNode } from '../backend/contracts';
@@ -27,9 +27,11 @@ export { DefaultZLinkSpotOutbound, type ZLinkSpotAddressCallOptions, type ZLinkS
27
27
  import { type ZLinkSpotRoutedTransport } from './spot-outbound';
28
28
  export { DefaultZLinkSpotHandlerRegistry, type ZLinkSpotHandlerRegistration } from './spot-handler-registry';
29
29
  export { ZLinkRuntimeSpotPublisherTransport } from './spot-publisher-transport';
30
+ import { ZLinkSpotActivationRegistry } from './spot-activation-registry';
30
31
  import type { ZLinkSpotActivation } from './spot-activation-state';
31
32
  import type { ZLinkSpotPreparationCompletion } from './spot-serial-executor';
32
33
  import { type ZLinkNativeSpotAuthority } from './spot-activation';
34
+ import { ZLinkFormalRemoteActorAdmissionRegistry } from './formal-remote-actor-admission-registry';
33
35
  import type { ZLinkSpotActorHandoffRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
34
36
  import type { ZLinkRuntimeAdmissionGate, ZLinkMeshDispatchAdmission } from '../admission';
35
37
  import type { ZLinkActivationAdmission } from '../activation-admission';
@@ -126,6 +128,15 @@ export interface ZLinkSpotManagerOptions {
126
128
  };
127
129
  readonly activationAdmission?: ZLinkActivationAdmission;
128
130
  }
131
+ interface ZLinkTargetSpotCloseOperation {
132
+ readonly activation: ZLinkSpotActivation;
133
+ readonly reason: ZLinkSpotCloseReason;
134
+ readonly beginAuthority: (onCommitted: () => void) => Promise<import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined>;
135
+ authority?: import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority;
136
+ authorityDecision?: Promise<void>;
137
+ ready?: Promise<boolean>;
138
+ canExecuteApplication?(record: import('../execution/serial-execution-queue').ZLinkSerialWorkRecord<unknown>): boolean;
139
+ }
129
140
  export declare class DefaultZLinkSpotManager {
130
141
  private readonly options;
131
142
  [inspectRuntime](): Readonly<{
@@ -133,17 +144,17 @@ export declare class DefaultZLinkSpotManager {
133
144
  hasCloseableActivation: (meshName: string, spotId: RoutingId) => boolean;
134
145
  }>;
135
146
  private readonly factories;
136
- private readonly activations;
147
+ readonly activations: ZLinkSpotActivationRegistry;
137
148
  private readonly workerRuntime;
138
149
  private readonly locationClaim;
139
150
  private readonly routedSpotPackets;
140
151
  private readonly actorMembership;
141
152
  private readonly activationLifecycle;
142
153
  private readonly formalRemoteTransfers;
143
- private readonly formalRemoteActorAdmissions;
154
+ readonly formalRemoteActorAdmissions: ZLinkFormalRemoteActorAdmissionRegistry;
144
155
  private readonly pendingInstanceMaterializations;
145
156
  private readonly pendingInstanceMaterializationsByPrefix;
146
- private readonly closeOperations;
157
+ readonly closeOperations: Map<string, ZLinkTargetSpotCloseOperation>;
147
158
  private readonly pendingInstanceTerminals;
148
159
  private readonly pendingInstanceTerminalGenerations;
149
160
  private readonly deferredInstanceAuthorityReleases;
@@ -216,6 +227,8 @@ export declare class DefaultZLinkSpotManager {
216
227
  dispatchRoutedActorPacket(origin: ApplicationJobOrigin, spotId: RoutingId, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
217
228
  /** Resolves the current Actor FIFO owner for both Entry and User membership. */
218
229
  admitSourceActorPacketPrefix(actorId: string, records: readonly ZLinkActorHandoffPrefixRecord[]): ZLinkActorHandoffPrefixAdmission;
230
+ /** Runs an owner-side lifecycle decision in the Actor's existing execution gate. */
231
+ executeActorTurn<T>(meshName: string, spotId: RoutingId | undefined, actorId: string, operation: () => Promise<T>): Promise<T>;
219
232
  dispatchRoutedSpotSend(spotId: RoutingId, packetName: string | undefined, message: unknown, context: {
220
233
  readonly channelName: string;
221
234
  readonly contentType?: string;
@@ -238,7 +251,9 @@ export declare class DefaultZLinkSpotManager {
238
251
  private traceInstanceMessage;
239
252
  dispatchMeshActor(origin: ApplicationJobOrigin, meshName: string, owner: ReadyRecord, record: ReceiveRecord, admit?: ZLinkMeshDispatchAdmission): Promise<void>;
240
253
  dispatchMeshActorJoin(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
241
- private dispatchMeshActorJoinCore;
254
+ dispatchMeshActorJoinCore(meshName: string, owner: ReadyRecord, record: ReceiveRecord, replyState: {
255
+ targetCommitPublished: boolean;
256
+ }): Promise<void>;
242
257
  dispatchMeshSpotControl(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
243
258
  private dispatchMeshSpotControlCore;
244
259
  completeFormalSourceLeaveTerminal(actorId: string, transferId: string, succeeded: boolean): Promise<boolean>;
@@ -950,6 +950,20 @@ class DefaultZLinkSpotManager {
950
950
  }
951
951
  return this.admitRoutedActorPacketPrefix(owner.spotId, actorId, records);
952
952
  }
953
+ /** Runs an owner-side lifecycle decision in the Actor's existing execution gate. */
954
+ executeActorTurn(meshName, spotId, actorId, operation) {
955
+ if (spotId === undefined) {
956
+ if (this.options.executeEntryActor === undefined) {
957
+ throw new configuration_1.ZLinkConfigurationException(`Entry Spot Actor '${actorId}' has no execution gate for MeshNode '${meshName}'.`);
958
+ }
959
+ return this.options.executeEntryActor(meshName, actorId, operation);
960
+ }
961
+ const activation = this.resolveApplicationActivation(spotId, meshName);
962
+ if (activation === undefined) {
963
+ throw new configuration_1.ZLinkConfigurationException(`Actor '${actorId}' has no active Spot execution gate for '${String(spotId)}'.`);
964
+ }
965
+ return activation.executeActor(actorId, operation);
966
+ }
953
967
  async dispatchRoutedSpotSend(spotId, packetName, message, context) {
954
968
  await this.routedSpotPackets.send(spotId, packetName, message, context);
955
969
  }
@@ -1,9 +1,9 @@
1
1
  import type { ApplicationJobOrigin } from '../application-jobs/contracts';
2
- import type { ActorRef } from '../../contracts';
2
+ import type { ActorRef, ZLinkActor } from '../../contracts';
3
3
  import type { Message } from '../../contracts/Common/Message';
4
4
  import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
5
5
  import type { ZLinkBackendSpot } from '../backend/contracts';
6
- import { type ZLinkRemoteBoundSessionTarget } from '../actors';
6
+ import { type ZLinkActorHandoffPacket, type ZLinkActorHandoffResult, type ZLinkRemoteBoundSessionTarget } from '../actors';
7
7
  import type { ZLinkSpotActivationLifecycleOptions } from './spot-activation';
8
8
  import { ZLinkSpotActivation } from './spot-activation-state';
9
9
  import { ZLinkSpotActorJoinDispatch } from './spot-actor-join-dispatch';
@@ -18,7 +18,7 @@ export declare class ZLinkSpotActorAdmissionCoordinator {
18
18
  private actorPacketDispatch;
19
19
  /** Resolves native lifecycle records; messages use resolveActorIngress. */
20
20
  private resolveLifecycleActor;
21
- private commitTransferredActorTransaction;
21
+ commitTransferredActorTransaction(activation: ZLinkSpotActivation, actor: ZLinkActor, backlog: readonly ZLinkActorHandoffPacket[], sealedSession: ZLinkRemoteBoundSessionTarget | undefined): Promise<readonly ZLinkActorHandoffResult[]>;
22
22
  private replayActorBacklog;
23
23
  }
24
24
  /** Releases the Actor FIFO before awaiting a transferred admission terminal. */
@@ -21,6 +21,7 @@ export interface ZLinkActorRequestTerminal {
21
21
  /** One admitted Actor packet and the routing context that must move with it. */
22
22
  export interface ZLinkActorPacketDelivery {
23
23
  readonly origin: ApplicationJobOrigin;
24
+ readonly receivedAt?: Date;
24
25
  readonly actorId: string;
25
26
  readonly parts: readonly Message[];
26
27
  readonly returnResponse: boolean;
@@ -26,6 +26,7 @@ class ZLinkSpotActorPacketDispatch {
26
26
  dispatch(serial, origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
27
27
  return this.dispatchDelivery(serial, {
28
28
  origin,
29
+ receivedAt: new Date(),
29
30
  actorId,
30
31
  parts,
31
32
  returnResponse,
@@ -39,7 +40,8 @@ class ZLinkSpotActorPacketDispatch {
39
40
  return 'terminal' in result ? await result.terminal : result.response;
40
41
  }
41
42
  async admitDelivery(serial, delivery, handoffRuntime) {
42
- const { actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal } = delivery;
43
+ const { actorId, parts, returnResponse, receivedAt: deliveryReceivedAt, remoteBoundSessionTarget, fallbackActorRef, requestTerminal } = delivery;
44
+ const receivedAt = deliveryReceivedAt ?? new Date();
43
45
  if (parts.length < 2) {
44
46
  this.reportInvalidFrame(actorId, ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorSend);
45
47
  return { response: undefined };
@@ -113,7 +115,7 @@ class ZLinkSpotActorPacketDispatch {
113
115
  }
114
116
  const decodePayload = this.createPayloadDecoder(parts[1], header);
115
117
  return {
116
- response: await this.dispatchActorPacket(actor, actorId, decodePayload, header, messageKind, action, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, requestDeadlineUnixMs, serial, (0, serial_work_size_1.zlinkSerialWorkOptions)(parts[1].data().byteLength, (0, serial_work_size_1.zlinkMetadataByteLength)(header.metadata)))
118
+ response: await this.dispatchActorPacket(actor, actorId, decodePayload, header, messageKind, action, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, requestDeadlineUnixMs, serial, (0, serial_work_size_1.zlinkSerialWorkOptions)(parts[1].data().byteLength, (0, serial_work_size_1.zlinkMetadataByteLength)(header.metadata)), receivedAt)
117
119
  };
118
120
  });
119
121
  }
@@ -143,7 +145,7 @@ class ZLinkSpotActorPacketDispatch {
143
145
  createPayloadDecoder(message, header) {
144
146
  return (messageType) => (0, payload_codec_1.decodeFrameworkTypedPayloadMessage)(message, this.options.messageSerializers, messageType, (0, protocol_1.streamCodecContentType)(header.codec), header.name);
145
147
  }
146
- async dispatchActorPacket(actor, actorId, decodePayload, header, messageKind, action, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal, requestDeadlineUnixMs, serial, workOptions) {
148
+ async dispatchActorPacket(actor, actorId, decodePayload, header, messageKind, action, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal, requestDeadlineUnixMs, serial, workOptions, receivedAt) {
147
149
  const spot = typeof this.options.spot === 'function' ? this.options.spot() : this.options.spot;
148
150
  const dispatcher = new actors_1.ZLinkSpotActorDispatcher({
149
151
  registry: this.options.registry,
@@ -174,7 +176,8 @@ class ZLinkSpotActorPacketDispatch {
174
176
  await dispatcher.dispatchSendDecoded(actor, header.name, decodePayload, {
175
177
  meshName: spot.context.meshName,
176
178
  metadata: (0, contracts_1.zlinkMessageMetadata)(header.metadata),
177
- correlationId: header.correlationId ?? undefined
179
+ correlationId: header.correlationId ?? undefined,
180
+ receivedAt
178
181
  });
179
182
  this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed, actorId, header, ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorSend);
180
183
  return undefined;
@@ -198,7 +201,8 @@ class ZLinkSpotActorPacketDispatch {
198
201
  await dispatcher.dispatchRequestThenDecoded(actor, header.name, decodePayload, {
199
202
  meshName: spot.context.meshName,
200
203
  metadata: (0, contracts_1.zlinkMessageMetadata)(header.metadata),
201
- correlationId: header.correlationId ?? header.requestSeq.toString()
204
+ correlationId: header.correlationId ?? header.requestSeq.toString(),
205
+ receivedAt
202
206
  }, async (response) => {
203
207
  this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, actorId, header, ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest);
204
208
  await requestTerminal(response, preparedReplyReady ? preparedReply : undefined);
@@ -214,7 +218,8 @@ class ZLinkSpotActorPacketDispatch {
214
218
  const response = await dispatcher.dispatchRequestDecoded(actor, header.name, decodePayload, {
215
219
  meshName: spot.context.meshName,
216
220
  metadata: (0, contracts_1.zlinkMessageMetadata)(header.metadata),
217
- correlationId: header.correlationId ?? header.requestSeq.toString()
221
+ correlationId: header.correlationId ?? header.requestSeq.toString(),
222
+ receivedAt
218
223
  });
219
224
  this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, actorId, header, ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest);
220
225
  return response;
@@ -222,7 +227,8 @@ class ZLinkSpotActorPacketDispatch {
222
227
  await dispatcher.dispatchRequestThenDecoded(actor, header.name, decodePayload, {
223
228
  meshName: spot.context.meshName,
224
229
  metadata: (0, contracts_1.zlinkMessageMetadata)(header.metadata),
225
- correlationId: header.correlationId ?? header.requestSeq.toString()
230
+ correlationId: header.correlationId ?? header.requestSeq.toString(),
231
+ receivedAt
226
232
  }, async (response, replyOptions) => {
227
233
  this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, actorId, header, ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest);
228
234
  await this.options.actorResponseSender?.(actor, header.name, requestSeq, response, replyOptions, fallbackBoundSessionTarget, fallbackActorRef, undefined);
@@ -21,6 +21,7 @@ interface ZLinkSpotActorPacketDrainOptions {
21
21
  readonly replyActorNoBind?: (info: ZLinkBackendActorRecvInfo, parts: readonly Message[], result: RequestResult) => void;
22
22
  readonly waitIdle: () => Promise<void>;
23
23
  readonly flowEnabled?: () => boolean;
24
+ readonly receivedAtClock?: () => Date;
24
25
  }
25
26
  export declare class ZLinkSpotActorPacketDrain {
26
27
  private readonly options;
@@ -9,6 +9,7 @@ const protocol_1 = require("../streams/protocol");
9
9
  const actor_reply_1 = require("../actors/actor-reply");
10
10
  const bound_session_response_target_1 = require("../streams/bound-session-response-target");
11
11
  const ZLINK_SPOT_ACTOR_RECV_INFO_NO_BIND = 1;
12
+ const systemReceivedAtClock = () => new Date();
12
13
  class ZLinkSpotActorPacketDrain {
13
14
  options;
14
15
  continuations = new Map();
@@ -24,6 +25,7 @@ class ZLinkSpotActorPacketDrain {
24
25
  let requestId;
25
26
  let flags;
26
27
  let packetKey;
28
+ let receivedAt;
27
29
  try {
28
30
  for (;;) {
29
31
  const part = info.recvActorPart(spot_native_flags_1.ZLINK_RECV_DONT_WAIT);
@@ -31,7 +33,8 @@ class ZLinkSpotActorPacketDrain {
31
33
  if (parts.length > 0 && packetKey !== undefined) {
32
34
  this.continuations.set(packetKey, {
33
35
  owner: continuationOwner(parts[0], this.flowEnabled()),
34
- parts: parts.splice(0)
36
+ parts: parts.splice(0),
37
+ receivedAt: receivedAt ?? (this.options.receivedAtClock ?? systemReceivedAtClock)()
35
38
  });
36
39
  return;
37
40
  }
@@ -42,6 +45,8 @@ class ZLinkSpotActorPacketDrain {
42
45
  if (packetKey === undefined) {
43
46
  packetKey = currentPacketKey;
44
47
  const pending = this.continuations.get(currentPacketKey);
48
+ receivedAt =
49
+ pending?.receivedAt ?? (this.options.receivedAtClock ?? systemReceivedAtClock)();
45
50
  if (pending !== undefined) {
46
51
  if (isStreamHeaderMessage(part.message, this.flowEnabled())) {
47
52
  closeMessages(pending.parts);
@@ -79,7 +84,7 @@ class ZLinkSpotActorPacketDrain {
79
84
  return;
80
85
  }
81
86
  if (noBindInfo !== undefined) {
82
- await this.dispatchNoBindActorRequest(noBindInfo, actorId, parts, actorRef);
87
+ await this.dispatchNoBindActorRequest(noBindInfo, actorId, parts, actorRef, receivedAt ?? (this.options.receivedAtClock ?? systemReceivedAtClock)());
83
88
  }
84
89
  else {
85
90
  await this.options.actorPacketHandler({
@@ -88,7 +93,8 @@ class ZLinkSpotActorPacketDrain {
88
93
  parts,
89
94
  returnResponse: false,
90
95
  sourceSessionRid,
91
- fallbackActorRef: actorRef
96
+ fallbackActorRef: actorRef,
97
+ receivedAt
92
98
  });
93
99
  }
94
100
  }
@@ -129,7 +135,7 @@ class ZLinkSpotActorPacketDrain {
129
135
  return false;
130
136
  }
131
137
  }
132
- async dispatchNoBindActorRequest(info, actorId, parts, actorRef) {
138
+ async dispatchNoBindActorRequest(info, actorId, parts, actorRef, receivedAt) {
133
139
  try {
134
140
  const response = await this.options.actorPacketHandler?.({
135
141
  origin: 'remote',
@@ -137,7 +143,8 @@ class ZLinkSpotActorPacketDrain {
137
143
  parts,
138
144
  returnResponse: true,
139
145
  sourceSessionRid: info.sourceSessionRid,
140
- fallbackActorRef: actorRef
146
+ fallbackActorRef: actorRef,
147
+ receivedAt
141
148
  });
142
149
  this.options.replyActorNoBind?.(info, [this.encodeActorReplyFrame(parts[0], protocol_1.ZLinkStreamMessageKind.Response, response)], runtime_values_1.RequestResult.Ok);
143
150
  }
@@ -10,6 +10,7 @@ import { type ZLinkActorPacketDelivery } from './spot-actor-packet-dispatch';
10
10
  import { type ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
11
11
  import { type ZLinkSpotRoutedTransport } from './spot-outbound';
12
12
  import { ZLinkSpotSerialTurnExecutor } from './spot-serial-turn-executor';
13
+ import { ZLinkSpotSerialExecutor } from './spot-serial-executor';
13
14
  import { type ZLinkActorHandoffPacket } from '../actors/actor-handoff';
14
15
  import type { ZLinkEntryActorRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotActorHandoffRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
15
16
  interface ZLinkEntrySpotActivationOptions {
@@ -45,7 +46,7 @@ interface ZLinkEntrySpotActivationOptions {
45
46
  export declare class ZLinkEntrySpotActivation {
46
47
  private readonly options;
47
48
  private readonly serial;
48
- private readonly spotSerialExecutor;
49
+ readonly spotSerialExecutor: ZLinkSpotSerialExecutor;
49
50
  private readonly timers;
50
51
  private readonly actorHandlers;
51
52
  private readonly handlers;
@@ -20,6 +20,8 @@ import { ApplicationJobQueue } from '../host/application-job-queue';
20
20
  import { ZLinkLocationRuntime, type ZLinkLocationEventSink, type ZLinkLocationRuntimeStores } from '../locations';
21
21
  import { type ZLinkSubmitResult } from '../messaging/submission-result';
22
22
  import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
23
+ import { ZLinkEntrySpotActivation } from './spot-entry-activation';
24
+ import { type ZLinkSpotNodeLocationAutoConnectContext } from './spot-node-autoconnect';
23
25
  import type { ZLinkSpotRoutedTransport } from './spot-outbound';
24
26
  import type { ZLinkSpotRouteResolver } from './spot-routing-internal';
25
27
  import type { ZLinkEntryActorRuntime, ZLinkSpotActorHandoffRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
@@ -57,11 +59,11 @@ export interface ZLinkSpotNodeRuntimeManagerOptions {
57
59
  readonly activationConcurrency?: (meshName: string) => ZLinkActivationConcurrency;
58
60
  }
59
61
  export declare class ZLinkSpotNodeRuntimeManager {
60
- private readonly options;
61
- private readonly meshNodes;
62
+ readonly options: ZLinkSpotNodeRuntimeManagerOptions;
63
+ readonly meshNodes: Map<string, ZLinkBackendMeshNode>;
62
64
  private readonly meshPumps;
63
65
  private readonly meshCompletions;
64
- private readonly entryActivations;
66
+ readonly entryActivations: Map<string, ZLinkEntrySpotActivation>;
65
67
  private readonly entryActivationStarts;
66
68
  private readonly publishers;
67
69
  private readonly disposal;
@@ -73,8 +75,8 @@ export declare class ZLinkSpotNodeRuntimeManager {
73
75
  private readonly runtimeChannelWeights;
74
76
  private readonly entrySpotIds;
75
77
  private runtimeWeightPublication;
76
- private statePublication;
77
- private locationAutoConnect?;
78
+ statePublication: Promise<void>;
79
+ locationAutoConnect?: ZLinkSpotNodeLocationAutoConnectContext;
78
80
  private readonly applicationJobQueue;
79
81
  constructor(options: ZLinkSpotNodeRuntimeManagerOptions);
80
82
  createTopicMessage(): import("../backend/runtime-values").ZLinkBackendTopicMessage;
@@ -128,7 +130,7 @@ export declare class ZLinkSpotNodeRuntimeManager {
128
130
  private dispatchFrameworkRecord;
129
131
  dispatchEntrySpotRecord(meshName: string, owner: ReadyRecord, record: ReceiveRecord, admit?: ZLinkMeshDispatchAdmission): Promise<boolean>;
130
132
  private ensureEntryActivation;
131
- private initializeEntrySpot;
133
+ initializeEntrySpot(spotNodeName: string, node: ZLinkBackendMeshNode, spotNode: ZLinkSpotNodeOptions): Promise<void>;
132
134
  private primaryEntryActivation;
133
135
  dispatchEntryActorPacket(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
134
136
  dispatchEntryActorJoin(meshName: string, actor: ZLinkActor, handoffBacklog?: readonly ZLinkActorHandoffPacket[]): Promise<void>;
@@ -148,6 +148,8 @@ class ZLinkSpotNodeRuntimeManager {
148
148
  const node = meshAdapter.createMeshNode(this.options.context, {
149
149
  meshName: spotNodeName,
150
150
  routingId,
151
+ sendHighWaterMark: spotNode.router?.sendHighWaterMark,
152
+ receiveHighWaterMark: spotNode.router?.receiveHighWaterMark,
151
153
  receiveTimeoutMs: spotNode.router?.receiveTimeoutMs,
152
154
  applicationJobQueue: this.applicationJobQueue,
153
155
  infrastructureTaskRunner: this.options.detachedTaskRunner,
@@ -25,9 +25,10 @@ class ZLinkSpotRoutePacketDispatch {
25
25
  this.options = options;
26
26
  }
27
27
  async dispatch(received) {
28
+ const receivedAt = new Date();
28
29
  const directEnvelope = decodeSpotDirectEnvelope(received.parts);
29
30
  if (directEnvelope !== undefined) {
30
- await this.dispatchSpotDirectEnvelope(received, directEnvelope);
31
+ await this.dispatchSpotDirectEnvelope(received, directEnvelope, receivedAt);
31
32
  return true;
32
33
  }
33
34
  let envelope;
@@ -78,7 +79,8 @@ class ZLinkSpotRoutePacketDispatch {
78
79
  contentType: envelope.header.contentType,
79
80
  packetName: envelope.packetName,
80
81
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
81
- correlationId: envelope.header.correlationId ?? undefined
82
+ correlationId: envelope.header.correlationId ?? undefined,
83
+ receivedAt
82
84
  };
83
85
  try {
84
86
  let response;
@@ -133,7 +135,7 @@ class ZLinkSpotRoutePacketDispatch {
133
135
  return true;
134
136
  }
135
137
  }
136
- async dispatchSpotDirectEnvelope(received, envelope) {
138
+ async dispatchSpotDirectEnvelope(received, envelope, receivedAt) {
137
139
  const replyable = envelope.kind === 1 /* ZLinkChannelMessageKind.Request */ && (0, spot_route_replies_1.hasReplyToken)(received.replyToken);
138
140
  const messageKind = replyable
139
141
  ? ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Request
@@ -166,7 +168,8 @@ class ZLinkSpotRoutePacketDispatch {
166
168
  channelName: envelope.channelName,
167
169
  packetName: envelope.packetName,
168
170
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.metadata),
169
- correlationId: undefined
171
+ correlationId: undefined,
172
+ receivedAt
170
173
  };
171
174
  (0, application_job_queue_scope_1.releaseApplicationJobPermitBeforeHandler)();
172
175
  response = await handler.handle(spot, envelope.payload, handlerContext);
@@ -27,6 +27,7 @@ class ZLinkRoutedSpotPacketDispatch {
27
27
  return (await this.dispatch(spotId, packetName, decodePayload, context, true));
28
28
  }
29
29
  async dispatch(spotId, packetName, decodePayload, context, returnResponse) {
30
+ const receivedAt = new Date();
30
31
  const activation = this.options.resolveActivation(spotId);
31
32
  if (activation === undefined) {
32
33
  this.reportMissing(spotId, packetName, context, returnResponse);
@@ -98,7 +99,8 @@ class ZLinkRoutedSpotPacketDispatch {
98
99
  channelName: context.channelName,
99
100
  contentType: context.contentType,
100
101
  packetName: packetName,
101
- metadata: (0, contracts_1.zlinkMessageMetadata)({})
102
+ metadata: (0, contracts_1.zlinkMessageMetadata)({}),
103
+ receivedAt
102
104
  };
103
105
  (0, application_job_queue_scope_1.releaseApplicationJobPermitBeforeHandler)();
104
106
  response = await handler.handle(current.spot, payload, handlerContext);
@@ -1,4 +1,5 @@
1
1
  import { ZLinkUserSpotExecutionMode } from '../../contracts';
2
+ import { ZLinkActorSerialExecutor } from '../actors';
2
3
  import type { ZLinkActorHandoffDispatch, ZLinkActorHandoffPrefixAdmission, ZLinkActorHandoffPrefixRecord } from '../actors/actor-handoff';
3
4
  import type { ZLinkExecutionBarrier } from '../execution';
4
5
  import type { ZLinkSerialSchedulerOptions, ZLinkSerialWorkOptions } from '../execution/serial-execution-queue';
@@ -18,7 +19,7 @@ export declare class ZLinkSpotSerialExecutor {
18
19
  private readonly actorOptions?;
19
20
  private readonly actorSerials;
20
21
  private readonly timerSerials;
21
- private readonly actorExecutors;
22
+ readonly actorExecutors: Map<string, ZLinkActorSerialExecutor>;
22
23
  private executionBarrier;
23
24
  private closing;
24
25
  private closePromise;
@@ -86,6 +86,7 @@ class ZLinkSpotSubscriptionDispatch {
86
86
  }
87
87
  }
88
88
  async dispatch(message) {
89
+ const receivedAt = new Date();
89
90
  if (message.parts.length === 0) {
90
91
  this.options.dispatchErrors?.report({
91
92
  surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.SpotSubscription,
@@ -145,7 +146,8 @@ class ZLinkSpotSubscriptionDispatch {
145
146
  topic: message.topic,
146
147
  source: subSource,
147
148
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
148
- correlationId: envelope.header.correlationId ?? undefined
149
+ correlationId: envelope.header.correlationId ?? undefined,
150
+ receivedAt
149
151
  });
150
152
  }
151
153
  catch (error) {
@@ -123,7 +123,7 @@ export declare class ZLinkManagedTimer implements ZLinkTimer {
123
123
  private pendingScheduledIndex;
124
124
  private timeout;
125
125
  /** The dispatch in flight, from its timer callback until `completeFireCore`. */
126
- private running;
126
+ running: Promise<void> | undefined;
127
127
  private dispatchFailure;
128
128
  private finalization;
129
129
  constructor(name: string, periodMs: number, options: Required<ZLinkTimerOptions>, onTick: (tick: ZLinkTimerTick) => Promise<void>, onFailure?: ZLinkTimerFailureReporter | undefined, shouldWaitForRunningOnCancel?: () => boolean, clock?: ZLinkTimerClock, start?: ZLinkManagedTimerStart);
@@ -1,3 +1,5 @@
1
+ import { type ZLinkStreamFrameHeader } from './protocol';
2
+ import { ZLinkStateLane } from '../execution/state-lane';
1
3
  import type { RoutingId } from '../../contracts';
2
4
  import { type ServiceSessionRelocationRoute, type ServiceSessionRelocationSeal, type ServiceSessionRelocationSealed } from '../foundation/service-stateful-wire-codec';
3
5
  export interface ZLinkPreparedSessionRelocationSeal {
@@ -100,13 +102,16 @@ export declare class ZLinkActorSessionBindingRegistry<TContext extends ZLinkActo
100
102
  private readonly terminalRelocationCapacity;
101
103
  private readonly sealWaitTimeoutMs;
102
104
  private readonly errorSink?;
103
- private readonly lane;
105
+ readonly lane: ZLinkStateLane;
104
106
  private readonly routes;
105
- private readonly nextActorSlots;
107
+ readonly nextActorSlots: WeakMap<TContext, number>;
106
108
  private readonly sealWaiters;
107
109
  private readonly activeFrameWaiters;
108
110
  private readonly relocations;
109
- private readonly absentSessionRelocationResults;
111
+ readonly absentSessionRelocationResults: Map<string, {
112
+ readonly result: SessionRelocationResult;
113
+ readonly expiry: ReturnType<typeof setTimeout>;
114
+ }>;
110
115
  private readonly terminalRelocations;
111
116
  constructor(terminalRelocationCapacity?: number, sealWaitTimeoutMs?: number, errorSink?: (() => {
112
117
  reportRuntimeTaskException(taskName: string, error: unknown): void;
@@ -120,6 +125,7 @@ export declare class ZLinkActorSessionBindingRegistry<TContext extends ZLinkActo
120
125
  find(actorId: string): Promise<TActor | undefined>;
121
126
  private findCore;
122
127
  route(actorId: string): Promise<ZLinkActorSessionRoute<TContext, TActor> | undefined>;
128
+ submitReply<T>(context: TContext, header: ZLinkStreamFrameHeader, submit: (header: ZLinkStreamFrameHeader) => Promise<T>): Promise<T>;
123
129
  /** Registers a current binding's frame in the same turn that can retire its slot. */
124
130
  submitCurrent<T>(actorId: string, bindingToken: string, submit: (route: ZLinkActorSessionRoute<TContext, TActor>) => Promise<T>): Promise<T | undefined>;
125
131
  /** Selects the route only when it is the exact Session binding (§8.1 validation values). */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZLinkActorSessionBindingRegistry = exports.ZLinkActorSessionBindingTermination = exports.DEFAULT_TERMINAL_RELOCATION_CAPACITY = void 0;
4
+ const protocol_1 = require("./protocol");
4
5
  const ZLinkFrameworkException_1 = require("../../contracts/Errors/ZLinkFrameworkException");
5
6
  const Options_1 = require("../../contracts/Locations/Options");
6
7
  const abort_1 = require("../abort");
@@ -139,6 +140,22 @@ class ZLinkActorSessionBindingRegistry {
139
140
  async route(actorId) {
140
141
  return await this.lane.run(() => this.routeCore(actorId));
141
142
  }
143
+ async submitReply(context, header, submit) {
144
+ const { submission } = await this.lane.run(() => {
145
+ const current = header.actorSlot === undefined ||
146
+ [...this.routes.values()].some((route) => route.context === context && route.actorSlot === header.actorSlot);
147
+ return {
148
+ submission: submit(current
149
+ ? header
150
+ : {
151
+ ...header,
152
+ actorSlot: undefined,
153
+ flags: header.flags & ~protocol_1.ZLinkStreamHeaderFlags.HasActorSlot
154
+ })
155
+ };
156
+ });
157
+ return await submission;
158
+ }
142
159
  /** Registers a current binding's frame in the same turn that can retire its slot. */
143
160
  async submitCurrent(actorId, bindingToken, submit) {
144
161
  const { submission } = await this.lane.run(() => {