@zlink-systems/framework 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Channels/IZLinkFanoutClient.d.ts +0 -6
  3. package/dist/contracts/RouteMesh/RuntimeTopology.d.ts +8 -0
  4. package/dist/internal.d.ts +1 -0
  5. package/dist/internal.js +1 -0
  6. package/dist/runtime/activation-admission.d.ts +29 -0
  7. package/dist/runtime/activation-admission.js +61 -0
  8. package/dist/runtime/actors/actor-context.js +6 -6
  9. package/dist/runtime/actors/actor-handoff.d.ts +9 -3
  10. package/dist/runtime/actors/actor-handoff.js +28 -17
  11. package/dist/runtime/actors/actor-local-native-join.js +2 -18
  12. package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
  13. package/dist/runtime/actors/actor-remote-joiner.js +6 -8
  14. package/dist/runtime/actors/actor-runtime-contracts.d.ts +4 -2
  15. package/dist/runtime/actors/actor-source-transfer.d.ts +5 -5
  16. package/dist/runtime/actors/deferred-join-completion.d.ts +14 -0
  17. package/dist/runtime/actors/deferred-join-completion.js +20 -0
  18. package/dist/runtime/actors/index.d.ts +1 -1
  19. package/dist/runtime/actors/index.js +15 -5
  20. package/dist/runtime/admission.d.ts +5 -1
  21. package/dist/runtime/admission.js +4 -0
  22. package/dist/runtime/backend/contracts/index.d.ts +2 -10
  23. package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -9
  24. package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +1 -2
  25. package/dist/runtime/backend/node/node-backend-adapter-factory.js +4 -18
  26. package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +6 -3
  27. package/dist/runtime/backend/node/node-backend-adapter-support.js +12 -28
  28. package/dist/runtime/backend/node/node-event-loop-poller.d.ts +1 -1
  29. package/dist/runtime/backend/node/node-event-loop-poller.js +8 -2
  30. package/dist/runtime/backend/node/node-raw-binding-port.d.ts +1 -1
  31. package/dist/runtime/backend/node/node-raw-binding-port.js +11 -3
  32. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +12 -9
  33. package/dist/runtime/backend/node/node-raw-mesh-backend.js +61 -29
  34. package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
  35. package/dist/runtime/backend/raw-binding-port.d.ts +12 -0
  36. package/dist/runtime/channels/channel-clients.d.ts +0 -1
  37. package/dist/runtime/channels/channel-clients.js +0 -8
  38. package/dist/runtime/channels/channel-outbound-operations.js +2 -10
  39. package/dist/runtime/channels/channel-runtime-manager.d.ts +2 -5
  40. package/dist/runtime/channels/channel-runtime-manager.js +1 -12
  41. package/dist/runtime/channels/channel-socket-registry.d.ts +17 -4
  42. package/dist/runtime/channels/channel-socket-registry.js +49 -62
  43. package/dist/runtime/channels/channel-transports.d.ts +0 -3
  44. package/dist/runtime/channels/fanout-location-runtime.js +3 -9
  45. package/dist/runtime/execution/index.d.ts +18 -8
  46. package/dist/runtime/execution/index.js +55 -29
  47. package/dist/runtime/execution/serial-execution-queue.d.ts +5 -6
  48. package/dist/runtime/execution/serial-execution-queue.js +49 -15
  49. package/dist/runtime/foundation/listener-records.d.ts +11 -0
  50. package/dist/runtime/foundation/listener-records.js +20 -0
  51. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +10 -21
  52. package/dist/runtime/foundation/raw-service-mesh-runtime.js +66 -392
  53. package/dist/runtime/foundation/service-authority-payload-codec.d.ts +1 -0
  54. package/dist/runtime/foundation/service-authority-payload-codec.js +8 -0
  55. package/dist/runtime/foundation/service-maintenance-runtime.js +23 -2
  56. package/dist/runtime/foundation/service-relocation-coordinator.d.ts +9 -0
  57. package/dist/runtime/foundation/service-relocation-coordinator.js +14 -1
  58. package/dist/runtime/foundation/service-relocation-object-owner.d.ts +8 -0
  59. package/dist/runtime/foundation/service-relocation-object-owner.js +16 -4
  60. package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +6 -13
  61. package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -7
  62. package/dist/runtime/foundation/service-stateful-runtime.js +100 -60
  63. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +9 -4
  64. package/dist/runtime/foundation/service-stateful-wire-codec.js +153 -90
  65. package/dist/runtime/foundation/service-topology-registry.d.ts +1 -2
  66. package/dist/runtime/foundation/service-topology-registry.js +6 -30
  67. package/dist/runtime/host/actor-transfer-runtime.d.ts +17 -15
  68. package/dist/runtime/host/actor-transfer-runtime.js +73 -86
  69. package/dist/runtime/host/index.d.ts +6 -2
  70. package/dist/runtime/host/index.js +63 -37
  71. package/dist/runtime/host/remote-bound-session-relay.js +4 -3
  72. package/dist/runtime/host/route-mesh-runtime.d.ts +2 -0
  73. package/dist/runtime/host/route-mesh-runtime.js +7 -5
  74. package/dist/runtime/host/service-relocation-host-runtime.d.ts +50 -8
  75. package/dist/runtime/host/service-relocation-host-runtime.js +343 -270
  76. package/dist/runtime/host/spot-runtime-options-factory.d.ts +7 -4
  77. package/dist/runtime/host/spot-runtime-options-factory.js +4 -8
  78. package/dist/runtime/host/stateful-authority-route-runtime.js +6 -2
  79. package/dist/runtime/host/user-spot-creation-coordinator.d.ts +11 -3
  80. package/dist/runtime/host/user-spot-creation-coordinator.js +85 -87
  81. package/dist/runtime/locations/in-memory-provider-location-store.js +8 -6
  82. package/dist/runtime/locations/lifecycle.d.ts +1 -1
  83. package/dist/runtime/locations/lifecycle.js +2 -2
  84. package/dist/runtime/locations/resolvers.js +7 -2
  85. package/dist/runtime/locations/spot-location-claims.d.ts +2 -2
  86. package/dist/runtime/locations/spot-location-claims.js +3 -27
  87. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
  88. package/dist/runtime/protocol/service_wire_codec.generated.js +5 -1
  89. package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +1 -0
  90. package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +3 -2
  91. package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +3 -3
  92. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +4 -4
  93. package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +3 -3
  94. package/dist/runtime/spots/index.d.ts +25 -19
  95. package/dist/runtime/spots/index.js +207 -205
  96. package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
  97. package/dist/runtime/spots/spot-activation-registry.js +34 -31
  98. package/dist/runtime/spots/spot-activation-state.d.ts +2 -11
  99. package/dist/runtime/spots/spot-activation-state.js +4 -17
  100. package/dist/runtime/spots/spot-activation.d.ts +8 -6
  101. package/dist/runtime/spots/spot-activation.js +54 -49
  102. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -1
  103. package/dist/runtime/spots/spot-actor-admission-coordinator.js +1 -1
  104. package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +2 -2
  105. package/dist/runtime/spots/spot-actor-join-dispatch.js +3 -5
  106. package/dist/runtime/spots/spot-actor-lifecycle-drain.js +2 -2
  107. package/dist/runtime/spots/spot-actor-membership.d.ts +4 -0
  108. package/dist/runtime/spots/spot-actor-membership.js +26 -12
  109. package/dist/runtime/spots/spot-entry-activation.d.ts +1 -2
  110. package/dist/runtime/spots/spot-entry-activation.js +0 -1
  111. package/dist/runtime/spots/spot-manager-public.js +1 -1
  112. package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +1 -1
  113. package/dist/runtime/spots/spot-native-actor-join-admission.js +2 -2
  114. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +5 -5
  115. package/dist/runtime/spots/spot-node-runtime-manager.js +7 -11
  116. package/dist/runtime/spots/spot-outbound.js +1 -29
  117. package/dist/runtime/spots/spot-routed-actor-admission.d.ts +1 -0
  118. package/dist/runtime/spots/spot-routed-actor-admission.js +10 -0
  119. package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +2 -6
  120. package/dist/runtime/spots/spot-routed-frame-dispatch.js +2 -70
  121. package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -5
  122. package/dist/runtime/spots/spot-serial-executor.d.ts +5 -0
  123. package/dist/runtime/spots/spot-serial-executor.js +8 -1
  124. package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
  125. package/dist/runtime/spots/spot-serial-turn-executor.js +8 -4
  126. package/dist/runtime/streams/actor-session-binding-registry.d.ts +13 -15
  127. package/dist/runtime/streams/actor-session-binding-registry.js +19 -171
  128. package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +3 -4
  129. package/dist/runtime/streams/bound-session-service.js +1 -18
  130. package/dist/runtime/streams/index.d.ts +2 -0
  131. package/dist/runtime/streams/index.js +19 -19
  132. package/dist/runtime/streams/session-serial-executor.js +2 -2
  133. package/package.json +3 -3
  134. package/src/contracts/Channels/IZLinkFanoutClient.ts +0 -7
  135. package/src/contracts/RouteMesh/RuntimeTopology.ts +10 -0
  136. package/src/internal.ts +1 -0
  137. package/src/runtime/activation-admission.ts +78 -0
  138. package/src/runtime/actors/actor-context.ts +6 -6
  139. package/src/runtime/actors/actor-handoff.ts +31 -23
  140. package/src/runtime/actors/actor-local-native-join.ts +3 -42
  141. package/src/runtime/actors/actor-remote-joiner.ts +6 -25
  142. package/src/runtime/actors/actor-runtime-contracts.ts +4 -10
  143. package/src/runtime/actors/actor-source-transfer.ts +5 -18
  144. package/src/runtime/actors/deferred-join-completion.ts +40 -0
  145. package/src/runtime/actors/index.ts +22 -9
  146. package/src/runtime/admission.ts +5 -1
  147. package/src/runtime/backend/contracts/index.ts +2 -13
  148. package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -10
  149. package/src/runtime/backend/node/node-backend-adapter-factory.ts +5 -25
  150. package/src/runtime/backend/node/node-backend-adapter-support.ts +9 -29
  151. package/src/runtime/backend/node/node-event-loop-poller.ts +14 -2
  152. package/src/runtime/backend/node/node-raw-binding-port.ts +17 -3
  153. package/src/runtime/backend/node/node-raw-mesh-backend.ts +65 -32
  154. package/src/runtime/backend/node/node-socket-backend-adapter.ts +2 -2
  155. package/src/runtime/backend/raw-binding-port.ts +13 -0
  156. package/src/runtime/channels/channel-clients.ts +0 -11
  157. package/src/runtime/channels/channel-outbound-operations.ts +3 -11
  158. package/src/runtime/channels/channel-runtime-manager.ts +4 -15
  159. package/src/runtime/channels/channel-socket-registry.ts +69 -71
  160. package/src/runtime/channels/channel-transports.ts +0 -3
  161. package/src/runtime/channels/fanout-location-runtime.ts +4 -16
  162. package/src/runtime/execution/index.ts +68 -30
  163. package/src/runtime/execution/serial-execution-queue.ts +52 -20
  164. package/src/runtime/foundation/listener-records.ts +21 -0
  165. package/src/runtime/foundation/raw-service-mesh-runtime.ts +66 -466
  166. package/src/runtime/foundation/service-authority-payload-codec.ts +10 -0
  167. package/src/runtime/foundation/service-maintenance-runtime.ts +30 -9
  168. package/src/runtime/foundation/service-relocation-coordinator.ts +13 -0
  169. package/src/runtime/foundation/service-relocation-object-owner.ts +18 -5
  170. package/src/runtime/foundation/service-session-binding-ingress-port.ts +6 -14
  171. package/src/runtime/foundation/service-stateful-runtime.ts +151 -89
  172. package/src/runtime/foundation/service-stateful-wire-codec.ts +203 -121
  173. package/src/runtime/foundation/service-topology-registry.ts +8 -48
  174. package/src/runtime/host/actor-transfer-runtime.ts +94 -166
  175. package/src/runtime/host/index.ts +119 -54
  176. package/src/runtime/host/remote-bound-session-relay.ts +4 -3
  177. package/src/runtime/host/route-mesh-runtime.ts +9 -5
  178. package/src/runtime/host/service-relocation-host-runtime.ts +495 -376
  179. package/src/runtime/host/spot-runtime-options-factory.ts +24 -13
  180. package/src/runtime/host/stateful-authority-route-runtime.ts +8 -4
  181. package/src/runtime/host/user-spot-creation-coordinator.ts +147 -142
  182. package/src/runtime/locations/in-memory-provider-location-store.ts +11 -7
  183. package/src/runtime/locations/lifecycle.ts +3 -2
  184. package/src/runtime/locations/resolvers.ts +19 -13
  185. package/src/runtime/locations/spot-location-claims.ts +5 -34
  186. package/src/runtime/protocol/service_wire_codec.generated.ts +9 -2
  187. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
  188. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +6 -6
  189. package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +3 -3
  190. package/src/runtime/spots/index.ts +341 -295
  191. package/src/runtime/spots/spot-activation-registry.ts +41 -31
  192. package/src/runtime/spots/spot-activation-state.ts +4 -16
  193. package/src/runtime/spots/spot-activation.ts +102 -80
  194. package/src/runtime/spots/spot-actor-admission-coordinator.ts +2 -2
  195. package/src/runtime/spots/spot-actor-join-dispatch.ts +6 -7
  196. package/src/runtime/spots/spot-actor-lifecycle-drain.ts +20 -18
  197. package/src/runtime/spots/spot-actor-membership.ts +81 -17
  198. package/src/runtime/spots/spot-entry-activation.ts +0 -3
  199. package/src/runtime/spots/spot-manager-public.ts +8 -4
  200. package/src/runtime/spots/spot-native-actor-join-admission.ts +2 -2
  201. package/src/runtime/spots/spot-node-runtime-manager.ts +12 -18
  202. package/src/runtime/spots/spot-outbound.ts +4 -47
  203. package/src/runtime/spots/spot-routed-actor-admission.ts +20 -0
  204. package/src/runtime/spots/spot-routed-frame-dispatch.ts +6 -76
  205. package/src/runtime/spots/spot-runtime-ports.ts +6 -17
  206. package/src/runtime/spots/spot-serial-executor.ts +9 -1
  207. package/src/runtime/spots/spot-serial-turn-executor.ts +10 -4
  208. package/src/runtime/streams/actor-session-binding-registry.ts +20 -308
  209. package/src/runtime/streams/actor-session-binding-runtime-owner.ts +2 -12
  210. package/src/runtime/streams/bound-session-service.ts +2 -36
  211. package/src/runtime/streams/index.ts +29 -27
  212. package/src/runtime/streams/session-serial-executor.ts +2 -2
  213. package/dist/runtime/actors/deferred-join-accepted-journal.d.ts +0 -47
  214. package/dist/runtime/actors/deferred-join-accepted-journal.js +0 -992
  215. package/src/runtime/actors/deferred-join-accepted-journal.ts +0 -1346
@@ -20,13 +20,16 @@ export interface ZLinkSpotActorMembershipOptions {
20
20
  readonly entrySpotIdProvider?: (meshName: string) => string | undefined;
21
21
  readonly spotRouteResolver?: ZLinkSpotRouteResolver;
22
22
  readonly actorTransferRuntime?: ZLinkSpotActorTransferRuntime;
23
+ readonly isSpotClosing?: (activation: ZLinkSpotActivation) => boolean;
23
24
  }
24
25
  export type ZLinkActorJoinRollback = () => Promise<void> | void;
25
26
  export declare class ZLinkSpotActorMembership {
26
27
  private readonly options;
27
28
  constructor(options: ZLinkSpotActorMembershipOptions);
28
29
  admitActorJoin(spotId: RoutingId, actor: ZLinkActor, request: Message, commit: (spot: ZLinkSpot) => Promise<ZLinkActorJoinRollback | void> | ZLinkActorJoinRollback | void, signal?: AbortSignal, leaveSource?: () => Promise<void>, contentType?: string): Promise<ZLinkSpotActorJoinResult>;
30
+ private admitActorJoinCore;
29
31
  leaveActor(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal, meshName?: string): Promise<void>;
32
+ private leaveActorCore;
30
33
  notifyActorLeftAfterTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
31
34
  prepareActorLeaveForTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
32
35
  commitActorLeaveAfterTransfer(spotId: RoutingId, actorId: string): Promise<void>;
@@ -35,5 +38,6 @@ export declare class ZLinkSpotActorMembership {
35
38
  cancelActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
36
39
  notifyJoinedActorDisconnected(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<boolean>;
37
40
  private requireActivation;
41
+ private runLifecycleOperation;
38
42
  private createActorDispatcher;
39
43
  }
@@ -5,6 +5,7 @@ const contracts_1 = require("../../contracts");
5
5
  const abort_1 = require("../abort");
6
6
  const runtime_message_1 = require("../backend/runtime-message");
7
7
  const configuration_1 = require("../configuration");
8
+ const framework_errors_internal_1 = require("../framework-errors-internal");
8
9
  const actors_1 = require("../actors");
9
10
  const payload_codec_1 = require("../messaging/payload-codec");
10
11
  const routing_id_1 = require("../routing-id");
@@ -16,6 +17,14 @@ class ZLinkSpotActorMembership {
16
17
  async admitActorJoin(spotId, actor, request, commit, signal, leaveSource, contentType = 'application/json') {
17
18
  (0, abort_1.throwIfAborted)(signal);
18
19
  const activation = this.requireActivation(spotId);
20
+ return await this.runLifecycleOperation(activation, async () => {
21
+ if (this.options.isSpotClosing?.(activation) === true) {
22
+ throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `User Spot '${String(spotId)}' is closing.`);
23
+ }
24
+ return await this.admitActorJoinCore(activation, actor, request, commit, signal, leaveSource, contentType);
25
+ });
26
+ }
27
+ async admitActorJoinCore(activation, actor, request, commit, signal, leaveSource, contentType) {
19
28
  const dispatcher = this.createActorDispatcher(activation);
20
29
  const transaction = { committed: false };
21
30
  let response;
@@ -54,6 +63,9 @@ class ZLinkSpotActorMembership {
54
63
  async leaveActor(spotId, actor, signal, meshName) {
55
64
  (0, abort_1.throwIfAborted)(signal);
56
65
  const activation = this.requireActivation(spotId, meshName);
66
+ await this.runLifecycleOperation(activation, () => this.leaveActorCore(activation, actor, signal, meshName));
67
+ }
68
+ async leaveActorCore(activation, actor, signal, meshName) {
57
69
  const localEntryNodeRid = (meshName === undefined ? undefined : this.options.nodeRidProvider?.(meshName)) ??
58
70
  this.options.entryNodeRidProvider?.() ??
59
71
  this.options.entryNodeRid ??
@@ -109,40 +121,36 @@ class ZLinkSpotActorMembership {
109
121
  async notifyActorLeftAfterTransfer(spotId, actor, signal) {
110
122
  (0, abort_1.throwIfAborted)(signal);
111
123
  const activation = this.requireActivation(spotId);
112
- await activation.serial.execute(async () => {
124
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(async () => {
113
125
  activation.beginActorTransfer(actor.context.actorId);
114
126
  await activation.spot.onLeaveActor(actor);
115
127
  activation.commitActorDeparture(actor.context.actorId);
116
- });
128
+ }));
117
129
  }
118
130
  async prepareActorLeaveForTransfer(spotId, actor, signal) {
119
131
  (0, abort_1.throwIfAborted)(signal);
120
132
  const activation = this.requireActivation(spotId);
121
- await activation.serial.execute(() => activation.spot.onLeaveActor(actor));
133
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.spot.onLeaveActor(actor)));
122
134
  }
123
135
  async commitActorLeaveAfterTransfer(spotId, actorId) {
124
136
  const activation = this.requireActivation(spotId);
125
- await activation.serial.execute(() => activation.commitActorDeparture(actorId));
137
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.commitActorDeparture(actorId)));
126
138
  }
127
139
  async restoreActorAfterFailedTransfer(spotId, actor, signal) {
128
140
  (0, abort_1.throwIfAborted)(signal);
129
141
  const activation = this.requireActivation(spotId);
130
- await activation.serial.execute(async () => {
142
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(async () => {
131
143
  activation.cancelActorTransfer(actor.context.actorId);
132
144
  await activation.spot.onJoinedActor(actor);
133
- });
145
+ }));
134
146
  }
135
147
  async beginActorTransfer(spotId, actorId) {
136
148
  const activation = this.requireActivation(spotId);
137
- await activation.serial.execute(() => {
138
- activation.beginActorTransfer(actorId);
139
- });
149
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.beginActorTransfer(actorId)));
140
150
  }
141
151
  async cancelActorTransfer(spotId, actorId) {
142
152
  const activation = this.requireActivation(spotId);
143
- await activation.serial.execute(() => {
144
- activation.cancelActorTransfer(actorId);
145
- });
153
+ await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.cancelActorTransfer(actorId)));
146
154
  }
147
155
  async notifyJoinedActorDisconnected(spotId, actor, signal) {
148
156
  (0, abort_1.throwIfAborted)(signal);
@@ -164,6 +172,12 @@ class ZLinkSpotActorMembership {
164
172
  }
165
173
  return activation;
166
174
  }
175
+ async runLifecycleOperation(activation, operation) {
176
+ const pending = activation.serial.executeLifecycleOperation(operation);
177
+ return activation.serial.isCurrentTurn
178
+ ? await activation.serial.currentTurn.yieldFrameworkPromise(pending)
179
+ : await pending;
180
+ }
167
181
  createActorDispatcher(activation) {
168
182
  return new actors_1.ZLinkSpotActorDispatcher({
169
183
  registry: activation.actorHandlers,
@@ -3,7 +3,7 @@ import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProvider
3
3
  import type { ZLinkRuntimeEventPublisher } from '../diagnostics';
4
4
  import type { ZLinkEntrySpotActorRequestHandlerRegistration, ZLinkEntrySpotActorSendHandlerRegistration, ZLinkEntrySpotPacketHandlerRegistration, ZLinkEntrySpotSubscriptionHandlerRegistration, ZLinkEntrySpotTimerHandlerRegistration } from '../../contracts/Configuration/RegistrationTypes';
5
5
  import type { Message } from '../../contracts/Common/Message';
6
- import type { ZLinkBackendReceived, ZLinkBackendSpot, ZLinkBackendSpotNode, ZLinkBackendTopicMessage } from '../backend/contracts';
6
+ import type { ZLinkBackendSpot, ZLinkBackendSpotNode, ZLinkBackendTopicMessage } from '../backend/contracts';
7
7
  import type { ZLinkDispatchErrorReporter } from '../channels';
8
8
  import { ZLinkWorkerRuntime } from '../workers';
9
9
  import { type ZLinkActorPacketDelivery } from './spot-actor-packet-dispatch';
@@ -21,7 +21,6 @@ interface ZLinkEntrySpotActivationOptions {
21
21
  readonly actorRequestHandlers?: readonly ZLinkEntrySpotActorRequestHandlerRegistration[];
22
22
  readonly nativeSpot: ZLinkBackendSpot;
23
23
  readonly nativeNode: ZLinkBackendSpotNode;
24
- readonly createReceived: () => ZLinkBackendReceived;
25
24
  readonly createTopicMessage: () => ZLinkBackendTopicMessage;
26
25
  readonly nodeRid: RoutingId;
27
26
  readonly spotNodeName: string;
@@ -223,7 +223,6 @@ class ZLinkEntrySpotActivation {
223
223
  attachActorJoinDispatch() {
224
224
  const dispatch = new spot_actor_join_dispatch_1.ZLinkSpotActorJoinDispatch({
225
225
  nativeSpot: this.options.nativeSpot,
226
- createReceived: this.options.createReceived,
227
226
  createTopicMessage: this.options.createTopicMessage,
228
227
  serial: this.serial,
229
228
  actors: {
@@ -51,7 +51,7 @@ class ZLinkPublicSpotManager {
51
51
  return false;
52
52
  const current = resolved.spot;
53
53
  if (this.options.isLocalNode(current.meshName, current.nodeRid)) {
54
- const closed = await this.options.coordinator.close(spot, (local) => this.options.local.close(local.meshName, local.spotId, signal), signal, (local) => this.options.local.hasActiveSpot(local.spotId), (local) => this.options.local.canCloseUserSpot(local.meshName, local.spotId));
54
+ const closed = await this.options.coordinator.close(spot, (local, beginAuthority) => this.options.local.closeUserWithAuthority(local.meshName, local.spotId, beginAuthority, signal), signal);
55
55
  if (closed)
56
56
  this.options.resolver()?.invalidate?.(spot.spotId);
57
57
  return closed;
@@ -19,7 +19,7 @@ interface ZLinkSpotNativeActorJoinAdmissionOptions {
19
19
  export declare class ZLinkSpotNativeActorJoinAdmission {
20
20
  private readonly options;
21
21
  constructor(options: ZLinkSpotNativeActorJoinAdmissionOptions);
22
- admit(request: ZLinkBackendActorJoinRequest): Promise<void>;
22
+ admit(request: ZLinkBackendActorJoinRequest, rejectClosing?: boolean): Promise<void>;
23
23
  private decodeNativeActorJoinRequest;
24
24
  private reportHandlerException;
25
25
  }
@@ -10,7 +10,7 @@ class ZLinkSpotNativeActorJoinAdmission {
10
10
  constructor(options) {
11
11
  this.options = options;
12
12
  }
13
- async admit(request) {
13
+ async admit(request, rejectClosing = false) {
14
14
  const actorId = request.info.targetActor.actorId;
15
15
  let accepted = false;
16
16
  let acceptedActor;
@@ -21,7 +21,7 @@ class ZLinkSpotNativeActorJoinAdmission {
21
21
  throw new Error('Remote actor join requires the two-phase routed transfer protocol.');
22
22
  }
23
23
  const actor = this.options.resolveActor(actorId);
24
- if (actor !== undefined) {
24
+ if (!rejectClosing && actor !== undefined) {
25
25
  const target = this.options.getTarget();
26
26
  const joinRequest = request.message;
27
27
  const joinPayload = (0, payload_codec_1.wrapFrameworkPayloadMessage)(joinRequest, this.options.messageSerializers);
@@ -1,3 +1,4 @@
1
+ import type { ZLinkListenerRecords } from '../foundation/listener-records';
1
2
  import type { ZLinkLocationOptionOverrides } from '../../contracts/Locations/Options';
2
3
  import type { ActorRef, RoutingId, ZLinkActor, ZLinkChannelClient, ZLinkFanoutClient, ZLinkMessage, ZLinkMeshNodeDescriptor, ZLinkMessageSerializer, ZLinkSpotPublisherClient } from '../../contracts';
3
4
  import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
@@ -18,9 +19,11 @@ import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
18
19
  import type { ZLinkSpotRoutedTransport } from './spot-outbound';
19
20
  import type { ZLinkSpotRouteResolver } from './spot-routing-internal';
20
21
  import type { ZLinkEntryActorRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotActorHandoffRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
22
+ import type { ZLinkActivationConcurrency } from '../activation-admission';
21
23
  import type { ServiceMessageFollowRecord } from '../foundation/service-stateful-wire-codec';
22
24
  import { ApplicationJobQueue } from '../host/application-job-queue';
23
25
  export interface ZLinkSpotNodeRuntimeManagerOptions {
26
+ readonly listenerRecords?: ZLinkListenerRecords;
24
27
  readonly registration: ZLinkFrameworkRegistration;
25
28
  readonly primaryMeshName?: string;
26
29
  readonly backendAdapterFactory: ZLinkBackendAdapterFactory;
@@ -46,10 +49,8 @@ export interface ZLinkSpotNodeRuntimeManagerOptions {
46
49
  readonly peerAdmissionSealed?: (meshName: string) => boolean;
47
50
  readonly meshRecordDispatcher?: (meshName: string, owner: ReadyRecord, record: ReceiveRecord) => void | Promise<void>;
48
51
  readonly messageFollowReceiver?: (record: ServiceMessageFollowRecord) => void;
49
- readonly instanceActivationConcurrencyProvider?: (meshName: string) => {
50
- readonly active: number;
51
- readonly limit: number;
52
- };
52
+ /** MeshNode §5.1 activation admission record; the descriptor projects it for placement. */
53
+ readonly activationConcurrency?: (meshName: string) => ZLinkActivationConcurrency;
53
54
  }
54
55
  export declare class ZLinkSpotNodeRuntimeManager {
55
56
  private readonly options;
@@ -72,7 +73,6 @@ export declare class ZLinkSpotNodeRuntimeManager {
72
73
  private locationAutoConnect?;
73
74
  private readonly applicationJobQueue;
74
75
  constructor(options: ZLinkSpotNodeRuntimeManagerOptions);
75
- createReceived(): import("../backend/runtime-values").ZLinkBackendReceived;
76
76
  createTopicMessage(): import("../backend/runtime-values").ZLinkBackendTopicMessage;
77
77
  configureLocationAutoConnect(runtime: ZLinkLocationRuntime, stores: ZLinkLocationRuntimeStores, options: ZLinkLocationOptionOverrides, events?: ZLinkLocationEventSink): void;
78
78
  startLocationAutoConnect(signal?: AbortSignal): Promise<void>;
@@ -55,9 +55,6 @@ class ZLinkSpotNodeRuntimeManager {
55
55
  options.applicationJobQueue ??
56
56
  new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)());
57
57
  }
58
- createReceived() {
59
- return this.options.backendAdapterFactory.createReceived();
60
- }
61
58
  createTopicMessage() {
62
59
  return this.options.backendAdapterFactory.createTopicMessage();
63
60
  }
@@ -236,6 +233,10 @@ class ZLinkSpotNodeRuntimeManager {
236
233
  this.meshNodes.set(spotNodeName, node);
237
234
  this.meshPumps.set(spotNodeName, pump);
238
235
  this.meshCompletions.set(spotNodeName, completions);
236
+ const listenerEndpoint = node.status().localEndpoint;
237
+ if (listenerEndpoint.length > 0) {
238
+ this.options.listenerRecords?.record('routeMesh', spotNodeName, listenerEndpoint);
239
+ }
239
240
  }
240
241
  catch (error) {
241
242
  this.entryActivations.delete(spotNodeName);
@@ -333,13 +334,9 @@ class ZLinkSpotNodeRuntimeManager {
333
334
  };
334
335
  })
335
336
  },
336
- activationConcurrency: {
337
- active: this.options.instanceActivationConcurrencyProvider?.(meshName).active ??
338
- current?.activationConcurrency.active ??
339
- 0,
340
- limit: this.options.instanceActivationConcurrencyProvider?.(meshName).limit ??
341
- registration.activationConcurrencyLimit ??
342
- 128
337
+ activationConcurrency: this.options.activationConcurrency?.(meshName) ?? {
338
+ active: 0,
339
+ limit: registration.activationConcurrencyLimit ?? 128
343
340
  },
344
341
  channelWeights: Object.fromEntries(this.serverChannels(meshName).map(([channelName, channel]) => [
345
342
  channelName,
@@ -693,7 +690,6 @@ class ZLinkSpotNodeRuntimeManager {
693
690
  entrySpotType: spotNode.entrySpotType,
694
691
  nativeSpot: node.entrySpot(),
695
692
  nativeNode: node,
696
- createReceived: () => this.options.backendAdapterFactory.createReceived(),
697
693
  createTopicMessage: () => this.options.backendAdapterFactory.createTopicMessage(),
698
694
  nodeRid: String(node.status().routingId),
699
695
  spotNodeName,
@@ -5,7 +5,6 @@ exports.sendToSpotHandle = sendToSpotHandle;
5
5
  exports.requestToSpotHandle = requestToSpotHandle;
6
6
  const framework_errors_internal_1 = require("../framework-errors-internal");
7
7
  const contracts_1 = require("../../contracts");
8
- const Errors_1 = require("../../contracts/Errors");
9
8
  const submission_result_1 = require("../messaging/submission-result");
10
9
  const routing_id_1 = require("../routing-id");
11
10
  const configuration_1 = require("../configuration");
@@ -405,26 +404,7 @@ async function requestToSpotHandle(transport, spot, request, options = {}) {
405
404
  }
406
405
  return transport.requestToSpot(target, request, transportOptions);
407
406
  };
408
- const resolved = await requireSpotRef(spot, options.signal);
409
- try {
410
- return await requestResolved(resolved);
411
- }
412
- catch (error) {
413
- if (!shouldRefreshAfterRouteDisconnect(resolved, error)) {
414
- throw error;
415
- }
416
- let refreshed;
417
- try {
418
- refreshed = await (0, spot_handle_1.refreshSpotHandle)(spot, options.signal);
419
- }
420
- catch {
421
- throw error;
422
- }
423
- if (isShutdownTargetState(refreshed?.targetNodeState)) {
424
- throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown, `Spot '${String(spot.spotId)}' target host is shutting down.`, false, error);
425
- }
426
- throw error;
427
- }
407
+ return requestResolved(await requireSpotRef(spot, options.signal));
428
408
  }
429
409
  async function requireSpotRef(handle, signal) {
430
410
  const resolved = await (0, spot_handle_1.resolveSpotHandle)(handle, signal);
@@ -443,14 +423,6 @@ function spotRefToSpotRouteTarget(spot, spotRouterChannelIdForMesh = (meshName)
443
423
  targetNodeState: spot.targetNodeState
444
424
  };
445
425
  }
446
- function shouldRefreshAfterRouteDisconnect(target, error) {
447
- return (target.targetNodeState === contracts_1.ZLinkFrameworkRuntimeState.Serving &&
448
- error instanceof Errors_1.ZLinkFrameworkException &&
449
- (0, framework_errors_internal_1.internalFrameworkErrorKind)(error) === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected);
450
- }
451
- function isShutdownTargetState(state) {
452
- return (state === contracts_1.ZLinkFrameworkRuntimeState.Draining || state === contracts_1.ZLinkFrameworkRuntimeState.Stopped);
453
- }
454
426
  function normalizeSpotRefRoutingId(routingId) {
455
427
  return (0, routing_id_1.normalizeOpaqueRoutingId)(routingId);
456
428
  }
@@ -8,6 +8,7 @@ interface ZLinkRoutedActorAdmissionTarget {
8
8
  }
9
9
  interface ZLinkSpotRoutedActorAdmissionOptions {
10
10
  readonly serial: ZLinkSpotSerialTurnExecutor;
11
+ readonly isSpotClosing?: () => boolean;
11
12
  readonly getTarget: () => ZLinkRoutedActorAdmissionTarget;
12
13
  readonly defaultAccept: boolean;
13
14
  readonly routedActorTransferProvider?: ZLinkRoutedActorTransferProvider;
@@ -7,6 +7,7 @@ const payload_codec_1 = require("../messaging/payload-codec");
7
7
  const routing_id_1 = require("../routing-id");
8
8
  const spot_remote_codec_1 = require("./spot-remote-codec");
9
9
  const spot_route_replies_1 = require("./spot-route-replies");
10
+ const framework_errors_internal_1 = require("../framework-errors-internal");
10
11
  class ZLinkSpotRoutedActorAdmission {
11
12
  options;
12
13
  pending = new Map();
@@ -21,6 +22,15 @@ class ZLinkSpotRoutedActorAdmission {
21
22
  if (decoded === undefined) {
22
23
  return false;
23
24
  }
25
+ if (this.options.isSpotClosing?.() === true) {
26
+ try {
27
+ (0, spot_route_replies_1.submitRoutedActorJoinError)(received, decoded, (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `Actor '${decoded.actorId}' target Spot is closing.`));
28
+ }
29
+ finally {
30
+ this.closeDecoded(decoded);
31
+ }
32
+ return true;
33
+ }
24
34
  if (decoded.phase === 'admission') {
25
35
  await this.admitTransfer(decoded, received);
26
36
  return true;
@@ -3,7 +3,7 @@ import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProvider
3
3
  import type { RoutingId } from '../../contracts';
4
4
  import type { ActorRef } from '../../contracts/Common/ActorRef';
5
5
  import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget } from '../actors';
6
- import type { ZLinkBackendReceived, ZLinkBackendSpot } from '../backend/contracts';
6
+ import type { ZLinkBackendReceived } from '../backend/contracts';
7
7
  import type { ZLinkDispatchErrorReporter } from '../channels';
8
8
  import type { ZLinkActorPacketDelivery, ZLinkActorResponseOptions } from './spot-actor-packet-dispatch';
9
9
  import type { ZLinkSpotHandlerRegistration } from './spot-handler-registry';
@@ -15,10 +15,9 @@ interface ZLinkRoutedFrameAdmissionTarget {
15
15
  onActorJoin?(actorId: string, request: ZLinkMessage): Promise<ZLinkSpotActorJoinResult>;
16
16
  }
17
17
  interface ZLinkSpotRoutedFrameDispatchOptions {
18
- readonly nativeSpot: ZLinkBackendSpot;
19
- readonly createReceived: () => ZLinkBackendReceived;
20
18
  readonly nativeSpotId: string;
21
19
  readonly serial: ZLinkSpotSerialTurnExecutor;
20
+ readonly isSpotClosing?: () => boolean;
22
21
  readonly resolveActor: (actorId: string) => ZLinkActor | undefined;
23
22
  readonly getTarget: () => ZLinkRoutedFrameAdmissionTarget & ZLinkSpot;
24
23
  readonly defaultAccept: boolean;
@@ -34,11 +33,9 @@ interface ZLinkSpotRoutedFrameDispatchOptions {
34
33
  readonly providerResolver?: ZLinkProviderResolver;
35
34
  readonly dispatchErrors?: ZLinkDispatchErrorReporter;
36
35
  readonly claimApplicationWork?: () => ZLinkApplicationWorkClaim;
37
- readonly waitIdle: () => Promise<void>;
38
36
  }
39
37
  export declare class ZLinkSpotRoutedFrameDispatch {
40
38
  private readonly options;
41
- private routeDraining;
42
39
  private readonly packetHandlers;
43
40
  private readonly routedBoundSessionDispatch;
44
41
  private readonly actorPacketRelayDispatch;
@@ -46,7 +43,6 @@ export declare class ZLinkSpotRoutedFrameDispatch {
46
43
  private readonly routedActorAdmission;
47
44
  constructor(options: ZLinkSpotRoutedFrameDispatchOptions);
48
45
  configurePacketHandlers(registrations: readonly ZLinkSpotHandlerRegistration[]): void;
49
- drain(received?: ZLinkBackendReceived | undefined, retryDeadlineMs?: number): Promise<void>;
50
46
  dispatchFromEvent(received: ZLinkBackendReceived): Promise<void>;
51
47
  private channelCodecs;
52
48
  private dispatch;
@@ -2,14 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZLinkSpotRoutedFrameDispatch = void 0;
4
4
  const spot_remote_route_codec_1 = require("./spot-remote-route-codec");
5
- const spot_native_flags_1 = require("./spot-native-flags");
6
5
  const spot_actor_packet_relay_dispatch_1 = require("./spot-actor-packet-relay-dispatch");
7
6
  const spot_route_packet_dispatch_1 = require("./spot-route-packet-dispatch");
8
7
  const spot_routed_actor_admission_1 = require("./spot-routed-actor-admission");
9
8
  const spot_routed_bound_session_dispatch_1 = require("./spot-routed-bound-session-dispatch");
10
9
  class ZLinkSpotRoutedFrameDispatch {
11
10
  options;
12
- routeDraining = false;
13
11
  packetHandlers = new Map();
14
12
  routedBoundSessionDispatch;
15
13
  actorPacketRelayDispatch;
@@ -42,6 +40,7 @@ class ZLinkSpotRoutedFrameDispatch {
42
40
  });
43
41
  this.routedActorAdmission = new spot_routed_actor_admission_1.ZLinkSpotRoutedActorAdmission({
44
42
  serial: options.serial,
43
+ isSpotClosing: options.isSpotClosing,
45
44
  getTarget: options.getTarget,
46
45
  defaultAccept: options.defaultAccept,
47
46
  routedActorTransferProvider: options.routedActorTransferProvider,
@@ -61,62 +60,6 @@ class ZLinkSpotRoutedFrameDispatch {
61
60
  this.packetHandlers.set(packetName, existing);
62
61
  }
63
62
  }
64
- async drain(received = undefined, retryDeadlineMs = performance.now()) {
65
- if (this.routeDraining) {
66
- if (received !== undefined) {
67
- try {
68
- await this.dispatch(received);
69
- }
70
- finally {
71
- received.close();
72
- }
73
- }
74
- return;
75
- }
76
- this.routeDraining = true;
77
- try {
78
- if (received !== undefined) {
79
- try {
80
- await this.dispatch(received);
81
- }
82
- finally {
83
- received.close();
84
- }
85
- received = undefined;
86
- }
87
- for (;;) {
88
- received ??= this.options.createReceived();
89
- try {
90
- if (!this.options.nativeSpot.recvRoute(received, spot_native_flags_1.ZLINK_RECV_DONT_WAIT)) {
91
- received.close();
92
- await this.options.waitIdle();
93
- return;
94
- }
95
- }
96
- catch (error) {
97
- if (isRouteRecvRetryable(error)) {
98
- closeReceivedQuietly(received);
99
- if (performance.now() < retryDeadlineMs) {
100
- setTimeout(() => void this.drain(undefined, retryDeadlineMs), 10);
101
- }
102
- return;
103
- }
104
- received.close();
105
- throw error;
106
- }
107
- try {
108
- await this.dispatch(received);
109
- }
110
- finally {
111
- received.close();
112
- }
113
- received = this.options.createReceived();
114
- }
115
- }
116
- finally {
117
- this.routeDraining = false;
118
- }
119
- }
120
63
  async dispatchFromEvent(received) {
121
64
  try {
122
65
  await this.dispatch(received);
@@ -145,18 +88,7 @@ class ZLinkSpotRoutedFrameDispatch {
145
88
  if (await this.routePacketDispatch.dispatch(received)) {
146
89
  return;
147
90
  }
148
- await this.routedActorAdmission.admit(received);
91
+ await this.options.serial.executeLifecycleOperation(() => this.routedActorAdmission.admit(received));
149
92
  }
150
93
  }
151
94
  exports.ZLinkSpotRoutedFrameDispatch = ZLinkSpotRoutedFrameDispatch;
152
- function isRouteRecvRetryable(error) {
153
- return (typeof error === 'object' &&
154
- error !== null &&
155
- [201, 202, 204].includes(Number(error.result)));
156
- }
157
- function closeReceivedQuietly(received) {
158
- try {
159
- received.close();
160
- }
161
- catch { }
162
- }
@@ -1,7 +1,7 @@
1
1
  import type { ActorRef, RoutingId, ZLinkActor, ZLinkActorJoinOperationId, ZLinkSpot } from '../../contracts';
2
2
  import type { Message } from '../../contracts/Common/Message';
3
3
  import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
4
- import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget, ZLinkDeferredJoinAcceptedRoot } from '../actors';
4
+ import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget, ZLinkDeferredJoinCompletion } from '../actors';
5
5
  import type { ZLinkActorHandoffDispatch } from '../actors/actor-handoff';
6
6
  import type { ZLinkActorResponseOptions } from './spot-actor-packet-dispatch';
7
7
  import type { ZLinkRemoteActorJoinActor, ZLinkRoutedActorTransferProvider } from './spot-remote-codec';
@@ -16,10 +16,8 @@ export interface ZLinkEntryActorRuntime {
16
16
  }>;
17
17
  }
18
18
  export interface ZLinkSpotActorTransferRuntime {
19
- prepareDeferredJoinAccepted(actorId: string, operationId: ZLinkActorJoinOperationId, actorRef: ActorRef, rawReply: Uint8Array, replyContentType?: string, signal?: AbortSignal, canonicalInventoryDigest?: string): Promise<ZLinkDeferredJoinAcceptedRoot>;
20
- discardDeferredJoinAccepted(root: ZLinkDeferredJoinAcceptedRoot, signal?: AbortSignal): Promise<void>;
21
- markDeferredJoinAcceptedCommitted(root: ZLinkDeferredJoinAcceptedRoot, actorRef: ActorRef, signal?: AbortSignal): Promise<ZLinkDeferredJoinAcceptedRoot>;
22
- commitAndDeliverDeferredJoinAccepted(root: ZLinkDeferredJoinAcceptedRoot, actor: ZLinkActor, actorRef: ActorRef, submitMailbox: <T>(operation: () => Promise<T>) => Promise<T>, signal?: AbortSignal): Promise<ZLinkDeferredJoinAcceptedRoot>;
19
+ prepareDeferredJoinAccepted(actorId: string, operationId: ZLinkActorJoinOperationId, actorRef: ActorRef, rawReply: Uint8Array, replyContentType?: string): ZLinkDeferredJoinCompletion;
20
+ deliverDeferredJoinAccepted(completion: ZLinkDeferredJoinCompletion, actor: ZLinkActor, actorRef: ActorRef, submitMailbox: <T>(operation: () => Promise<T>) => Promise<T>, signal?: AbortSignal): Promise<void>;
23
21
  getOrCreateRoutedActor(actorId: string, actorType: string, actorRef?: ActorRef, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, actorCreateRequest?: Message, signal?: AbortSignal): Promise<ZLinkRemoteActorJoinActor>;
24
22
  materializeRoutedActor: ZLinkRoutedActorTransferProvider;
25
23
  commitRoutedActorAuthority(actor: ZLinkActor, sourceActorRef: ActorRef, transferId: string, spotId: RoutingId, spotGeneration: bigint, membershipEpoch: bigint, deadlineAtMs: number, signal?: AbortSignal): Promise<import('../locations/internal-location-contracts').ZLinkAuthoritySnapshot>;
@@ -31,6 +31,11 @@ export declare class ZLinkSpotSerialExecutor {
31
31
  * ownership turn. Already accepted work remains drainable.
32
32
  */
33
33
  close(): Promise<void>;
34
+ /**
35
+ * Closes the Actor and timer queues. The Spot queue stays open for the Spot
36
+ * Close lifecycle item that owns it; that Close closes it when it finishes.
37
+ */
38
+ closeChildren(): Promise<void>;
34
39
  private actorExecutor;
35
40
  private actorSerial;
36
41
  private timerSerial;
@@ -70,6 +70,14 @@ class ZLinkSpotSerialExecutor {
70
70
  * ownership turn. Already accepted work remains drainable.
71
71
  */
72
72
  close() {
73
+ const children = this.closeChildren();
74
+ return Promise.all([children, this.spotSerial.close()]).then(() => undefined);
75
+ }
76
+ /**
77
+ * Closes the Actor and timer queues. The Spot queue stays open for the Spot
78
+ * Close lifecycle item that owns it; that Close closes it when it finishes.
79
+ */
80
+ closeChildren() {
73
81
  if (this.closePromise !== undefined)
74
82
  return this.closePromise;
75
83
  this.closing = true;
@@ -79,7 +87,6 @@ class ZLinkSpotSerialExecutor {
79
87
  this.timerSerials.clear();
80
88
  this.actorExecutors.clear();
81
89
  this.closePromise = Promise.all([
82
- this.spotSerial.close(),
83
90
  ...childSerials.map((serial) => serial.close()),
84
91
  ...actorExecutors.map((executor) => executor.close())
85
92
  ]).then(() => undefined);
@@ -19,6 +19,7 @@ export declare class ZLinkSpotSerialTurnExecutor {
19
19
  get currentTurn(): ZLinkSpotSerialTurn | undefined;
20
20
  /** Stops new turns while allowing turns accepted before close to complete. */
21
21
  close(): Promise<void>;
22
+ closeAdmission(): void;
22
23
  /** Distinguishes a gate-owning turn from a suspended AsyncLocalStorage tail. */
23
24
  isActiveTurn(turn: ZLinkSpotSerialTurn, turnId: number): boolean;
24
25
  setExecutionBarrier(barrier: ZLinkExecutionBarrier): void;
@@ -43,6 +44,8 @@ export declare class ZLinkSpotSerialTurnExecutor {
43
44
  * barrier seal after this turn finishes.
44
45
  */
45
46
  postBarrierTurn<T>(operation: () => Promise<T> | T, workOptions?: ZLinkSerialWorkOptions): Promise<T>;
47
+ /** Holds this Spot's lifecycle FIFO until the full operation result settles. */
48
+ executeLifecycleOperation<T>(operation: () => Promise<T> | T): Promise<T>;
46
49
  private enqueueApplicationTurn;
47
50
  private enqueueFrameworkTurn;
48
51
  private enqueueContinuationTurn;
@@ -39,6 +39,9 @@ class ZLinkSpotSerialTurnExecutor {
39
39
  close() {
40
40
  return this.scheduler.close();
41
41
  }
42
+ closeAdmission() {
43
+ this.scheduler.closeAdmission();
44
+ }
42
45
  /** Distinguishes a gate-owning turn from a suspended AsyncLocalStorage tail. */
43
46
  isActiveTurn(turn, turnId) {
44
47
  return (this.depth > 0 &&
@@ -109,6 +112,10 @@ class ZLinkSpotSerialTurnExecutor {
109
112
  postBarrierTurn(operation, workOptions) {
110
113
  return this.enqueueFrameworkTurn(operation, workOptions);
111
114
  }
115
+ /** Holds this Spot's lifecycle FIFO until the full operation result settles. */
116
+ executeLifecycleOperation(operation) {
117
+ return this.scheduler.submitLifecycleOperation(operation);
118
+ }
112
119
  async enqueueApplicationTurn(operation, workOptions = {}) {
113
120
  this.lastActivityAtMs = performance.now();
114
121
  let barrierClaim;
@@ -186,13 +193,10 @@ class ZLinkSpotSerialTurnExecutor {
186
193
  ]);
187
194
  }
188
195
  postResume(turn, resume, reject) {
189
- const barrier = this.executionBarrier;
190
- const resumeClaim = barrier?.tryEnter();
191
- if (barrier !== undefined && resumeClaim === undefined) {
196
+ if (!turn.resumeExecutionClaim()) {
192
197
  reject((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving, 'The yielded Spot turn cannot resume after its execution unit was sealed.'));
193
198
  return true;
194
199
  }
195
- turn.bindExecutionClaim(resumeClaim);
196
200
  void this.enqueueContinuationTurn(async () => {
197
201
  this.resumedOwnerTurn = turn;
198
202
  try {