@zlink-systems/framework 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (487) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Common/ZLinkMessage.js +5 -5
  3. package/dist/contracts/Configuration/CodecContentType.js +5 -7
  4. package/dist/contracts/Configuration/DiagnosticsValidation.js +1 -6
  5. package/dist/contracts/Configuration/EndpointNotation.js +4 -8
  6. package/dist/contracts/Configuration/Registration.js +14 -11
  7. package/dist/contracts/Configuration/RegistrationBuilders.js +32 -25
  8. package/dist/contracts/Configuration/RegistrationNormalizers.js +25 -26
  9. package/dist/contracts/Configuration/RegistrationValidators.js +36 -38
  10. package/dist/contracts/Configuration/SendTimeoutValidation.js +4 -4
  11. package/dist/contracts/Configuration/TimerRegistrationValidator.js +7 -7
  12. package/dist/contracts/Handlers/JsonContract.js +23 -11
  13. package/dist/contracts/Spots/SpotKind.js +16 -8
  14. package/dist/location-store-integration.js +16 -16
  15. package/dist/nest-integration.js +17 -11
  16. package/dist/runtime/abort.js +9 -5
  17. package/dist/runtime/actors/actor-authority-payload-codec.js +12 -16
  18. package/dist/runtime/actors/actor-authority-publication.js +18 -17
  19. package/dist/runtime/actors/actor-client.js +83 -63
  20. package/dist/runtime/actors/actor-context.js +24 -18
  21. package/dist/runtime/actors/actor-creation.js +4 -3
  22. package/dist/runtime/actors/actor-handoff.js +89 -92
  23. package/dist/runtime/actors/actor-local-native-join.js +18 -19
  24. package/dist/runtime/actors/actor-mailbox.js +1 -1
  25. package/dist/runtime/actors/actor-message-follow-context.js +24 -21
  26. package/dist/runtime/actors/actor-packet-relay-wire.js +1 -3
  27. package/dist/runtime/actors/actor-remote-joiner.js +20 -17
  28. package/dist/runtime/actors/actor-remote-wire.js +6 -7
  29. package/dist/runtime/actors/actor-runtime-state.js +87 -81
  30. package/dist/runtime/actors/actor-transfer-registry.js +3 -5
  31. package/dist/runtime/actors/bound-session-wire.js +14 -9
  32. package/dist/runtime/actors/deferred-join-accepted-journal.js +158 -124
  33. package/dist/runtime/actors/index.js +2 -5
  34. package/dist/runtime/actors/post-commit-actor-binder.js +3 -6
  35. package/dist/runtime/actors/post-commit-actor-location.js +1 -1
  36. package/dist/runtime/actors/spot-actor-dispatch.js +5 -5
  37. package/dist/runtime/actors/transferred-actor-rollback.js +4 -4
  38. package/dist/runtime/admission.js +2 -6
  39. package/dist/runtime/application-jobs/application-ingress-record-owner.js +2 -6
  40. package/dist/runtime/application-jobs/receive-flow-controller.js +11 -12
  41. package/dist/runtime/backend/mesh-completion-table.js +1 -3
  42. package/dist/runtime/backend/mesh-dispatch-pump.js +12 -16
  43. package/dist/runtime/backend/node/node-backend-adapter-factory.js +1 -3
  44. package/dist/runtime/backend/node/node-backend-adapter-support.js +26 -17
  45. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +4 -3
  46. package/dist/runtime/backend/node/node-raw-binding-port.js +7 -6
  47. package/dist/runtime/backend/node/node-raw-mesh-backend.js +116 -113
  48. package/dist/runtime/backend/node/node-socket-backend-adapter.js +12 -13
  49. package/dist/runtime/backend/runtime-message.js +3 -3
  50. package/dist/runtime/backend/runtime-values.d.ts +2 -2
  51. package/dist/runtime/backend/runtime-values.js +4 -5
  52. package/dist/runtime/channels/channel-clients.js +27 -24
  53. package/dist/runtime/channels/channel-dispatch-pipeline.js +10 -18
  54. package/dist/runtime/channels/channel-dispatch-services.js +7 -4
  55. package/dist/runtime/channels/channel-dispatchers.js +9 -9
  56. package/dist/runtime/channels/channel-envelope-inspection.js +16 -13
  57. package/dist/runtime/channels/channel-envelope.js +83 -47
  58. package/dist/runtime/channels/channel-outbound-operations.js +8 -8
  59. package/dist/runtime/channels/channel-receive-loops.js +20 -22
  60. package/dist/runtime/channels/channel-receive-task-tracker.js +1 -1
  61. package/dist/runtime/channels/channel-runtime-lifecycle.js +61 -56
  62. package/dist/runtime/channels/channel-runtime-manager.js +18 -9
  63. package/dist/runtime/channels/channel-socket-registry.js +126 -123
  64. package/dist/runtime/channels/channel-transports.js +43 -33
  65. package/dist/runtime/channels/client-server-location-runtime.js +32 -40
  66. package/dist/runtime/channels/client-server-service-wire.js +29 -22
  67. package/dist/runtime/channels/dispatch-error-reporter.js +9 -7
  68. package/dist/runtime/channels/fanout-location-runtime.js +34 -47
  69. package/dist/runtime/channels/fanout-service-wire.js +3 -5
  70. package/dist/runtime/channels/local-spot-route-transport.js +7 -1
  71. package/dist/runtime/channels/route-member-snapshot.js +3 -3
  72. package/dist/runtime/channels/source-spot-router.js +6 -2
  73. package/dist/runtime/channels/spot-route-bridge-transport.js +5 -2
  74. package/dist/runtime/channels/spot-route-dispatch-strategy.js +2 -2
  75. package/dist/runtime/channels/spot-route-target-resolver.js +6 -6
  76. package/dist/runtime/diagnostics/index.js +38 -10
  77. package/dist/runtime/diagnostics/message-flow.js +47 -39
  78. package/dist/runtime/diagnostics/runtime-metrics.js +18 -9
  79. package/dist/runtime/diagnostics/runtime-observation-queue.js +8 -10
  80. package/dist/runtime/diagnostics/topology-runtime-projections.js +17 -10
  81. package/dist/runtime/execution/index.js +7 -6
  82. package/dist/runtime/execution/serial-execution-queue.js +12 -18
  83. package/dist/runtime/execution/state-lane.js +2 -2
  84. package/dist/runtime/foundation/actor-join-recovery-codec.js +31 -23
  85. package/dist/runtime/foundation/event-loop-resources.js +4 -4
  86. package/dist/runtime/foundation/message-follow-suppression-registry.js +4 -4
  87. package/dist/runtime/foundation/raw-service-mesh-runtime.js +136 -136
  88. package/dist/runtime/foundation/route-mesh-connection-policy.js +4 -4
  89. package/dist/runtime/foundation/runtime-state-projections.js +22 -11
  90. package/dist/runtime/foundation/service-authority-payload-codec.js +13 -15
  91. package/dist/runtime/foundation/service-discovery-registry.js +35 -33
  92. package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +20 -22
  93. package/dist/runtime/foundation/service-liveness-registry.js +16 -12
  94. package/dist/runtime/foundation/service-maintenance-runtime.js +2 -4
  95. package/dist/runtime/foundation/service-relocation-aggregate-committer.js +24 -24
  96. package/dist/runtime/foundation/service-relocation-object-owner.js +6 -6
  97. package/dist/runtime/foundation/service-relocation-runtime.js +137 -94
  98. package/dist/runtime/foundation/service-runtime-contracts.js +5 -5
  99. package/dist/runtime/foundation/service-stateful-registry.js +24 -23
  100. package/dist/runtime/foundation/service-stateful-runtime.js +416 -438
  101. package/dist/runtime/foundation/service-stateful-wire-codec.js +95 -98
  102. package/dist/runtime/foundation/service-topology-registry.js +96 -95
  103. package/dist/runtime/foundation/service-weighted-selection.js +6 -11
  104. package/dist/runtime/foundation/service-wire-binary-primitives.js +5 -6
  105. package/dist/runtime/foundation/service-wire-m6a-codec.js +46 -35
  106. package/dist/runtime/framework-errors-internal.js +7 -10
  107. package/dist/runtime/handlers/handler-instance-scope.js +4 -5
  108. package/dist/runtime/handlers/index.js +3 -1
  109. package/dist/runtime/host/actor-packet-relay.js +74 -70
  110. package/dist/runtime/host/actor-placement-coordinator.js +29 -31
  111. package/dist/runtime/host/actor-runtime-options-factory.js +12 -14
  112. package/dist/runtime/host/actor-transfer-authority-runtime.js +7 -9
  113. package/dist/runtime/host/actor-transfer-runtime.js +176 -153
  114. package/dist/runtime/host/application-job-queue.js +18 -22
  115. package/dist/runtime/host/bound-session-relay.js +3 -1
  116. package/dist/runtime/host/channel-runtime-options-factory.js +31 -14
  117. package/dist/runtime/host/host-capacity-status.js +8 -4
  118. package/dist/runtime/host/index.js +244 -227
  119. package/dist/runtime/host/instance-activation-authority.js +93 -96
  120. package/dist/runtime/host/location-runtime-owner.js +16 -14
  121. package/dist/runtime/host/mesh-router-resolver.js +11 -13
  122. package/dist/runtime/host/relocation-direct-transfer.js +10 -9
  123. package/dist/runtime/host/remote-actor-join-receiver.js +20 -15
  124. package/dist/runtime/host/remote-actor-packet-target-store.js +18 -22
  125. package/dist/runtime/host/remote-bound-session-relay.js +97 -73
  126. package/dist/runtime/host/route-mesh-runtime.js +64 -69
  127. package/dist/runtime/host/runtime-shutdown.js +1 -2
  128. package/dist/runtime/host/service-relocation-host-runtime.js +586 -511
  129. package/dist/runtime/host/spot-address-transport.js +69 -71
  130. package/dist/runtime/host/spot-runtime-options-factory.js +30 -29
  131. package/dist/runtime/host/stateful-authority-route-runtime.js +65 -68
  132. package/dist/runtime/host/user-spot-creation-coordinator.js +61 -67
  133. package/dist/runtime/locations/actor-location-claims.js +26 -20
  134. package/dist/runtime/locations/aggregate-inventory-store.js +72 -75
  135. package/dist/runtime/locations/authority-key-codec.js +7 -7
  136. package/dist/runtime/locations/auto-connect-loop.js +3 -3
  137. package/dist/runtime/locations/auto-connect-planner.js +25 -19
  138. package/dist/runtime/locations/auto-connect-reconciler.js +51 -31
  139. package/dist/runtime/locations/in-memory-authority-store.js +128 -118
  140. package/dist/runtime/locations/in-memory-location-store.js +195 -168
  141. package/dist/runtime/locations/in-memory-provider-location-store.js +8 -10
  142. package/dist/runtime/locations/key-codec.js +1 -1
  143. package/dist/runtime/locations/lease-tracker.js +23 -21
  144. package/dist/runtime/locations/lifecycle.js +4 -5
  145. package/dist/runtime/locations/location-store-repository.js +368 -324
  146. package/dist/runtime/locations/opaque-record-key.js +2 -2
  147. package/dist/runtime/locations/resolvers.js +73 -82
  148. package/dist/runtime/locations/runtime.js +68 -63
  149. package/dist/runtime/locations/spot-location-claims.js +39 -35
  150. package/dist/runtime/messaging/framework-json-v1.js +7 -7
  151. package/dist/runtime/messaging/packet-name.js +7 -6
  152. package/dist/runtime/messaging/payload-codec.js +21 -18
  153. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +30 -2
  154. package/dist/runtime/protocol/service_wire_codec.generated.js +1671 -234
  155. package/dist/runtime/routing-id.js +3 -5
  156. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +35 -31
  157. package/dist/runtime/spots/formal-remote-actor-transfer-registry.js +1 -2
  158. package/dist/runtime/spots/index.js +208 -219
  159. package/dist/runtime/spots/spot-activation-registry.js +15 -14
  160. package/dist/runtime/spots/spot-activation-state.js +17 -15
  161. package/dist/runtime/spots/spot-activation.js +33 -16
  162. package/dist/runtime/spots/spot-actor-admission-coordinator.js +18 -15
  163. package/dist/runtime/spots/spot-actor-membership.js +1 -3
  164. package/dist/runtime/spots/spot-actor-packet-dispatch.js +23 -20
  165. package/dist/runtime/spots/spot-actor-packet-drain.js +12 -10
  166. package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +10 -6
  167. package/dist/runtime/spots/spot-closing.js +3 -7
  168. package/dist/runtime/spots/spot-context.js +2 -2
  169. package/dist/runtime/spots/spot-entry-activation.js +13 -14
  170. package/dist/runtime/spots/spot-handle.js +6 -3
  171. package/dist/runtime/spots/spot-handler-registry.js +12 -12
  172. package/dist/runtime/spots/spot-manager-public.js +5 -6
  173. package/dist/runtime/spots/spot-native-actor-join-admission.js +4 -3
  174. package/dist/runtime/spots/spot-node-autoconnect.js +15 -18
  175. package/dist/runtime/spots/spot-node-runtime-manager.js +74 -85
  176. package/dist/runtime/spots/spot-outbound.js +10 -14
  177. package/dist/runtime/spots/spot-remote-codec.js +22 -26
  178. package/dist/runtime/spots/spot-remote-route-codec.js +5 -7
  179. package/dist/runtime/spots/spot-route-packet-dispatch.js +16 -14
  180. package/dist/runtime/spots/spot-route-replies.js +4 -6
  181. package/dist/runtime/spots/spot-routed-actor-admission.js +9 -7
  182. package/dist/runtime/spots/spot-routed-bound-session-dispatch.js +1 -2
  183. package/dist/runtime/spots/spot-routed-frame-dispatch.js +5 -5
  184. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +14 -10
  185. package/dist/runtime/spots/spot-serial-executor.js +5 -8
  186. package/dist/runtime/spots/spot-serial-turn-executor.js +4 -6
  187. package/dist/runtime/spots/spot-subscription-dispatch.js +5 -5
  188. package/dist/runtime/spots/spot-timer.js +25 -29
  189. package/dist/runtime/streams/actor-session-binding-registry.js +98 -107
  190. package/dist/runtime/streams/actor-session-lifecycle-coordinator.js +3 -1
  191. package/dist/runtime/streams/bound-actor-relay-sender.js +18 -16
  192. package/dist/runtime/streams/bound-session-service.js +8 -9
  193. package/dist/runtime/streams/index.js +20 -19
  194. package/dist/runtime/streams/managed-stream.js +32 -30
  195. package/dist/runtime/streams/native-fallback-bound-session.js +21 -17
  196. package/dist/runtime/streams/protocol.js +29 -18
  197. package/dist/runtime/streams/session-actor-coordinator.js +34 -37
  198. package/dist/runtime/streams/session-context.js +30 -28
  199. package/dist/runtime/streams/session-provider.js +2 -2
  200. package/dist/runtime/streams/session-serial-executor.js +1 -2
  201. package/dist/runtime/streams/stream-frame-factory.js +11 -5
  202. package/dist/runtime/streams/stream-session-runtime.js +70 -66
  203. package/dist/runtime/workers/index.js +15 -4
  204. package/package.json +2 -2
  205. package/src/contracts/Channels/RouteCalls.ts +6 -1
  206. package/src/contracts/Common/ZLinkMessage.ts +5 -5
  207. package/src/contracts/Common/ZLinkMessageMetadata.ts +4 -3
  208. package/src/contracts/Configuration/Builders.ts +14 -14
  209. package/src/contracts/Configuration/CodecContentType.ts +8 -10
  210. package/src/contracts/Configuration/DiagnosticsValidation.ts +1 -6
  211. package/src/contracts/Configuration/EndpointNotation.ts +11 -11
  212. package/src/contracts/Configuration/ObjectRoles.ts +1 -3
  213. package/src/contracts/Configuration/Registration.ts +46 -17
  214. package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +10 -8
  215. package/src/contracts/Configuration/RegistrationBuilders.ts +107 -96
  216. package/src/contracts/Configuration/RegistrationCodecRegistry.ts +9 -3
  217. package/src/contracts/Configuration/RegistrationNormalizers.ts +116 -84
  218. package/src/contracts/Configuration/RegistrationTypes.ts +21 -25
  219. package/src/contracts/Configuration/RegistrationValidators.ts +122 -73
  220. package/src/contracts/Configuration/RouteChannelInternalState.ts +1 -4
  221. package/src/contracts/Configuration/RuntimeEndpointConnections.ts +4 -1
  222. package/src/contracts/Configuration/SendTimeoutValidation.ts +6 -4
  223. package/src/contracts/Configuration/TimerRegistrationValidator.ts +8 -13
  224. package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -6
  225. package/src/contracts/Errors/index.ts +1 -4
  226. package/src/contracts/Handlers/Attributes.ts +15 -9
  227. package/src/contracts/Handlers/IZLinkChannelHandlers.ts +24 -4
  228. package/src/contracts/Handlers/JsonContract.ts +53 -19
  229. package/src/contracts/Locations/ActorTransfer.ts +1 -5
  230. package/src/contracts/Locations/Authority.ts +4 -11
  231. package/src/contracts/Locations/Keys.ts +6 -1
  232. package/src/contracts/Locations/Options.ts +3 -2
  233. package/src/contracts/Locations/RelocationStore.ts +1 -4
  234. package/src/contracts/Locations/Resolvers.ts +5 -5
  235. package/src/contracts/Locations/RuntimeQuery.ts +6 -2
  236. package/src/contracts/Locations/Stores.ts +1 -2
  237. package/src/contracts/Locations/index.ts +2 -8
  238. package/src/contracts/RouteMesh/Contracts.ts +1 -7
  239. package/src/contracts/RouteMesh/RuntimeTopology.ts +1 -4
  240. package/src/contracts/Spots/Contracts.ts +2 -8
  241. package/src/contracts/Spots/SpotKind.ts +16 -8
  242. package/src/contracts/Spots/ZLinkSpot.ts +8 -11
  243. package/src/contracts/Streams/IZLinkSession.ts +0 -1
  244. package/src/contracts/Streams/IZLinkSessionActor.ts +5 -1
  245. package/src/contracts/Streams/IZLinkSessionPacketHandler.ts +5 -1
  246. package/src/internal.ts +5 -4
  247. package/src/location-store-integration.ts +24 -16
  248. package/src/nest-integration.ts +40 -25
  249. package/src/runtime/abort.ts +10 -4
  250. package/src/runtime/actors/actor-authority-payload-codec.ts +20 -29
  251. package/src/runtime/actors/actor-authority-publication.ts +92 -77
  252. package/src/runtime/actors/actor-client.ts +162 -133
  253. package/src/runtime/actors/actor-context.ts +138 -130
  254. package/src/runtime/actors/actor-creation.ts +47 -44
  255. package/src/runtime/actors/actor-execution-context.ts +6 -4
  256. package/src/runtime/actors/actor-handoff.ts +269 -293
  257. package/src/runtime/actors/actor-join-deferred-scope.ts +5 -4
  258. package/src/runtime/actors/actor-lifecycle-snapshot.ts +5 -8
  259. package/src/runtime/actors/actor-local-native-join.ts +131 -159
  260. package/src/runtime/actors/actor-mailbox.ts +16 -19
  261. package/src/runtime/actors/actor-message-follow-context.ts +46 -36
  262. package/src/runtime/actors/actor-packet-relay-wire.ts +32 -21
  263. package/src/runtime/actors/actor-remote-joiner.ts +50 -54
  264. package/src/runtime/actors/actor-remote-wire.ts +9 -13
  265. package/src/runtime/actors/actor-routed-join-transport.ts +10 -2
  266. package/src/runtime/actors/actor-runtime-contracts.ts +2 -5
  267. package/src/runtime/actors/actor-runtime-state.ts +127 -124
  268. package/src/runtime/actors/actor-transfer-registry.ts +9 -14
  269. package/src/runtime/actors/actor-transport-delivery-gate.ts +4 -6
  270. package/src/runtime/actors/bound-session-wire.ts +37 -17
  271. package/src/runtime/actors/deferred-join-accepted-journal.ts +351 -320
  272. package/src/runtime/actors/index.ts +43 -86
  273. package/src/runtime/actors/post-commit-actor-binder.ts +10 -10
  274. package/src/runtime/actors/post-commit-actor-location.ts +30 -23
  275. package/src/runtime/actors/spot-actor-dispatch.ts +78 -53
  276. package/src/runtime/actors/transferred-actor-rollback.ts +18 -13
  277. package/src/runtime/admission.ts +9 -9
  278. package/src/runtime/application-jobs/application-ingress-record-owner.ts +5 -15
  279. package/src/runtime/application-jobs/application-job-queue-handler-start-gate.ts +3 -2
  280. package/src/runtime/application-jobs/receive-flow-controller.ts +17 -14
  281. package/src/runtime/backend/contracts/index.ts +73 -52
  282. package/src/runtime/backend/mesh-actor-session-node-adapter.ts +4 -14
  283. package/src/runtime/backend/mesh-completion-table.ts +6 -9
  284. package/src/runtime/backend/mesh-dispatch-pump.ts +38 -30
  285. package/src/runtime/backend/node/node-backend-adapter-factory.ts +23 -21
  286. package/src/runtime/backend/node/node-backend-adapter-support.ts +36 -22
  287. package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +59 -58
  288. package/src/runtime/backend/node/node-event-loop-poller.ts +2 -10
  289. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +12 -5
  290. package/src/runtime/backend/node/node-monitor-backend-adapter.ts +4 -3
  291. package/src/runtime/backend/node/node-raw-binding-port.ts +29 -29
  292. package/src/runtime/backend/node/node-raw-mesh-backend.ts +335 -383
  293. package/src/runtime/backend/node/node-socket-backend-adapter.ts +101 -54
  294. package/src/runtime/backend/runtime-message.ts +5 -3
  295. package/src/runtime/backend/runtime-values.ts +10 -7
  296. package/src/runtime/channels/channel-autoconnect.ts +1 -4
  297. package/src/runtime/channels/channel-clients.ts +93 -73
  298. package/src/runtime/channels/channel-dispatch-pipeline.ts +40 -42
  299. package/src/runtime/channels/channel-dispatch-services.ts +51 -49
  300. package/src/runtime/channels/channel-dispatchers.ts +152 -96
  301. package/src/runtime/channels/channel-envelope-inspection.ts +20 -16
  302. package/src/runtime/channels/channel-envelope.ts +256 -150
  303. package/src/runtime/channels/channel-multipart.ts +13 -5
  304. package/src/runtime/channels/channel-outbound-operations.ts +37 -41
  305. package/src/runtime/channels/channel-receive-loops.ts +102 -98
  306. package/src/runtime/channels/channel-receive-task-tracker.ts +1 -1
  307. package/src/runtime/channels/channel-runtime-lifecycle.ts +248 -190
  308. package/src/runtime/channels/channel-runtime-manager.ts +63 -37
  309. package/src/runtime/channels/channel-socket-options.ts +3 -10
  310. package/src/runtime/channels/channel-socket-registry.ts +331 -273
  311. package/src/runtime/channels/channel-transports.ts +215 -197
  312. package/src/runtime/channels/client-server-location-runtime.ts +116 -100
  313. package/src/runtime/channels/client-server-service-wire.ts +37 -36
  314. package/src/runtime/channels/dispatch-error-reporter.ts +11 -8
  315. package/src/runtime/channels/fanout-location-runtime.ts +91 -94
  316. package/src/runtime/channels/fanout-service-wire.ts +5 -12
  317. package/src/runtime/channels/handler-filter-scope.ts +1 -4
  318. package/src/runtime/channels/index.ts +1 -4
  319. package/src/runtime/channels/local-spot-route-transport.ts +20 -5
  320. package/src/runtime/channels/route-member-snapshot.ts +11 -5
  321. package/src/runtime/channels/router-socket-spot-route-transport.ts +1 -7
  322. package/src/runtime/channels/source-spot-router.ts +26 -22
  323. package/src/runtime/channels/spot-direct-envelope.ts +10 -8
  324. package/src/runtime/channels/spot-node-route-transport.ts +13 -16
  325. package/src/runtime/channels/spot-route-bridge-transport.ts +26 -9
  326. package/src/runtime/channels/spot-route-dispatch-strategy.ts +40 -13
  327. package/src/runtime/channels/spot-route-target-resolver.ts +18 -9
  328. package/src/runtime/codecs/index.ts +3 -2
  329. package/src/runtime/diagnostics/flow-context.ts +12 -3
  330. package/src/runtime/diagnostics/index.ts +96 -61
  331. package/src/runtime/diagnostics/internal-event-contracts.ts +87 -33
  332. package/src/runtime/diagnostics/message-flow.ts +95 -76
  333. package/src/runtime/diagnostics/runtime-metrics.ts +46 -24
  334. package/src/runtime/diagnostics/runtime-observation-queue.ts +17 -28
  335. package/src/runtime/diagnostics/topology-runtime-projections.ts +62 -43
  336. package/src/runtime/execution/index.ts +18 -26
  337. package/src/runtime/execution/serial-execution-queue.ts +31 -40
  338. package/src/runtime/execution/state-lane.ts +2 -2
  339. package/src/runtime/foundation/actor-join-recovery-codec.ts +69 -51
  340. package/src/runtime/foundation/event-loop-resources.ts +8 -4
  341. package/src/runtime/foundation/message-follow-suppression-registry.ts +7 -14
  342. package/src/runtime/foundation/operation-identity.ts +1 -2
  343. package/src/runtime/foundation/operation-registry.ts +8 -2
  344. package/src/runtime/foundation/raw-service-mesh-runtime.ts +312 -385
  345. package/src/runtime/foundation/route-mesh-connection-policy.ts +7 -8
  346. package/src/runtime/foundation/runtime-state-projections.ts +24 -23
  347. package/src/runtime/foundation/service-authority-payload-codec.ts +54 -57
  348. package/src/runtime/foundation/service-discovery-registry.ts +67 -59
  349. package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +28 -29
  350. package/src/runtime/foundation/service-liveness-registry.ts +18 -13
  351. package/src/runtime/foundation/service-mailbox.ts +14 -14
  352. package/src/runtime/foundation/service-maintenance-runtime.ts +22 -21
  353. package/src/runtime/foundation/service-metadata-codec.ts +2 -9
  354. package/src/runtime/foundation/service-relocation-aggregate-committer.ts +39 -36
  355. package/src/runtime/foundation/service-relocation-coordinator.ts +1 -4
  356. package/src/runtime/foundation/service-relocation-object-owner.ts +40 -58
  357. package/src/runtime/foundation/service-relocation-runtime.ts +292 -216
  358. package/src/runtime/foundation/service-runtime-contracts.ts +8 -8
  359. package/src/runtime/foundation/service-session-binding-ingress-port.ts +1 -4
  360. package/src/runtime/foundation/service-stateful-registry.ts +69 -59
  361. package/src/runtime/foundation/service-stateful-runtime.ts +1174 -1112
  362. package/src/runtime/foundation/service-stateful-wire-codec.ts +318 -270
  363. package/src/runtime/foundation/service-topology-registry.ts +157 -159
  364. package/src/runtime/foundation/service-weighted-selection.ts +9 -15
  365. package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -12
  366. package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -47
  367. package/src/runtime/framework-errors-internal.ts +31 -30
  368. package/src/runtime/handlers/handler-instance-scope.ts +18 -29
  369. package/src/runtime/handlers/index.ts +18 -8
  370. package/src/runtime/host/actor-packet-relay.ts +290 -261
  371. package/src/runtime/host/actor-placement-coordinator.ts +165 -150
  372. package/src/runtime/host/actor-runtime-options-factory.ts +89 -87
  373. package/src/runtime/host/actor-transfer-authority-runtime.ts +46 -38
  374. package/src/runtime/host/actor-transfer-runtime.ts +391 -395
  375. package/src/runtime/host/application-job-queue.ts +32 -48
  376. package/src/runtime/host/bound-session-relay.ts +7 -9
  377. package/src/runtime/host/channel-runtime-options-factory.ts +75 -35
  378. package/src/runtime/host/host-capacity-status.ts +10 -9
  379. package/src/runtime/host/index.ts +861 -789
  380. package/src/runtime/host/instance-activation-authority.ts +125 -143
  381. package/src/runtime/host/location-runtime-owner.ts +38 -26
  382. package/src/runtime/host/mesh-router-resolver.ts +30 -23
  383. package/src/runtime/host/relocation-direct-transfer.ts +15 -15
  384. package/src/runtime/host/relocation-integrity-fault-gate.ts +3 -2
  385. package/src/runtime/host/remote-actor-join-receiver.ts +43 -34
  386. package/src/runtime/host/remote-actor-packet-target-store.ts +54 -52
  387. package/src/runtime/host/remote-bound-session-relay.ts +274 -247
  388. package/src/runtime/host/route-mesh-runtime-options.ts +1 -3
  389. package/src/runtime/host/route-mesh-runtime.ts +227 -181
  390. package/src/runtime/host/runtime-shutdown.ts +4 -3
  391. package/src/runtime/host/service-relocation-control.ts +14 -5
  392. package/src/runtime/host/service-relocation-host-runtime.ts +1388 -1165
  393. package/src/runtime/host/spot-address-transport.ts +284 -237
  394. package/src/runtime/host/spot-node-runtime-options-factory.ts +14 -8
  395. package/src/runtime/host/spot-runtime-options-factory.ts +71 -62
  396. package/src/runtime/host/stateful-authority-route-runtime.ts +117 -116
  397. package/src/runtime/host/user-spot-creation-coordinator.ts +225 -220
  398. package/src/runtime/locations/actor-location-claims.ts +61 -49
  399. package/src/runtime/locations/actor-session-route-claims.ts +1 -4
  400. package/src/runtime/locations/aggregate-inventory-store.ts +105 -134
  401. package/src/runtime/locations/authority-key-codec.ts +13 -10
  402. package/src/runtime/locations/auto-connect-loop.ts +14 -11
  403. package/src/runtime/locations/auto-connect-planner.ts +42 -31
  404. package/src/runtime/locations/auto-connect-reconciler.ts +106 -63
  405. package/src/runtime/locations/canonical-codec.ts +3 -1
  406. package/src/runtime/locations/creation-operation-id.ts +4 -3
  407. package/src/runtime/locations/domain-store-contract.ts +13 -7
  408. package/src/runtime/locations/in-memory-authority-store.ts +232 -199
  409. package/src/runtime/locations/in-memory-location-store.ts +432 -250
  410. package/src/runtime/locations/in-memory-provider-location-store.ts +16 -17
  411. package/src/runtime/locations/internal-store-contracts.ts +95 -38
  412. package/src/runtime/locations/key-codec.ts +3 -4
  413. package/src/runtime/locations/lease-tracker.ts +36 -27
  414. package/src/runtime/locations/lifecycle-runtime.ts +15 -3
  415. package/src/runtime/locations/lifecycle.ts +33 -28
  416. package/src/runtime/locations/location-store-repository.ts +1329 -1185
  417. package/src/runtime/locations/opaque-record-key.ts +4 -9
  418. package/src/runtime/locations/resolvers.ts +201 -178
  419. package/src/runtime/locations/runtime.ts +251 -159
  420. package/src/runtime/locations/spot-location-claims.ts +110 -112
  421. package/src/runtime/messaging/creation-payload-codec.ts +4 -1
  422. package/src/runtime/messaging/framework-json-v1.ts +34 -15
  423. package/src/runtime/messaging/packet-name.ts +8 -6
  424. package/src/runtime/messaging/payload-codec.ts +70 -50
  425. package/src/runtime/messaging/submission-result.ts +6 -9
  426. package/src/runtime/protocol/service_wire_codec.generated.ts +1376 -159
  427. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  428. package/src/runtime/routing-id.ts +10 -7
  429. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +56 -62
  430. package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +23 -20
  431. package/src/runtime/spots/index.ts +593 -563
  432. package/src/runtime/spots/spot-activation-registry.ts +38 -34
  433. package/src/runtime/spots/spot-activation-state.ts +43 -51
  434. package/src/runtime/spots/spot-activation.ts +179 -116
  435. package/src/runtime/spots/spot-actor-admission-coordinator.ts +110 -78
  436. package/src/runtime/spots/spot-actor-join-dispatch.ts +57 -41
  437. package/src/runtime/spots/spot-actor-lifecycle-drain.ts +5 -7
  438. package/src/runtime/spots/spot-actor-membership.ts +25 -27
  439. package/src/runtime/spots/spot-actor-packet-dispatch.ts +184 -153
  440. package/src/runtime/spots/spot-actor-packet-drain.ts +54 -42
  441. package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +37 -39
  442. package/src/runtime/spots/spot-closing.ts +11 -12
  443. package/src/runtime/spots/spot-context.ts +46 -26
  444. package/src/runtime/spots/spot-entry-activation.ts +84 -65
  445. package/src/runtime/spots/spot-handle.ts +17 -15
  446. package/src/runtime/spots/spot-handler-registry.ts +44 -31
  447. package/src/runtime/spots/spot-location-claim.ts +5 -4
  448. package/src/runtime/spots/spot-manager-public.ts +62 -82
  449. package/src/runtime/spots/spot-native-actor-join-admission.ts +20 -16
  450. package/src/runtime/spots/spot-node-autoconnect.ts +54 -61
  451. package/src/runtime/spots/spot-node-runtime-manager.ts +230 -221
  452. package/src/runtime/spots/spot-outbound.ts +47 -59
  453. package/src/runtime/spots/spot-publisher-transport.ts +5 -4
  454. package/src/runtime/spots/spot-remote-codec.ts +66 -65
  455. package/src/runtime/spots/spot-remote-route-codec.ts +61 -41
  456. package/src/runtime/spots/spot-route-packet-dispatch.ts +128 -95
  457. package/src/runtime/spots/spot-route-replies.ts +23 -24
  458. package/src/runtime/spots/spot-route-reply-wire.ts +3 -2
  459. package/src/runtime/spots/spot-routed-actor-admission.ts +37 -27
  460. package/src/runtime/spots/spot-routed-bound-session-dispatch.ts +11 -17
  461. package/src/runtime/spots/spot-routed-frame-dispatch.ts +18 -15
  462. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +35 -26
  463. package/src/runtime/spots/spot-routing-internal.ts +1 -4
  464. package/src/runtime/spots/spot-runtime-ports.ts +5 -5
  465. package/src/runtime/spots/spot-serial-executor.ts +5 -9
  466. package/src/runtime/spots/spot-serial-turn-executor.ts +19 -26
  467. package/src/runtime/spots/spot-subscription-dispatch.ts +56 -46
  468. package/src/runtime/spots/spot-timer.ts +98 -91
  469. package/src/runtime/streams/actor-session-binding-registry.ts +277 -235
  470. package/src/runtime/streams/actor-session-binding-runtime-owner.ts +7 -4
  471. package/src/runtime/streams/actor-session-lifecycle-coordinator.ts +3 -1
  472. package/src/runtime/streams/bound-actor-relay-sender.ts +53 -51
  473. package/src/runtime/streams/bound-session-response-target.ts +29 -8
  474. package/src/runtime/streams/bound-session-service.ts +39 -39
  475. package/src/runtime/streams/index.ts +176 -100
  476. package/src/runtime/streams/managed-stream.ts +98 -87
  477. package/src/runtime/streams/native-fallback-bound-session.ts +57 -52
  478. package/src/runtime/streams/protocol.ts +73 -43
  479. package/src/runtime/streams/session-actor-coordinator.ts +97 -89
  480. package/src/runtime/streams/session-calls.ts +2 -8
  481. package/src/runtime/streams/session-context.ts +66 -48
  482. package/src/runtime/streams/session-provider.ts +5 -7
  483. package/src/runtime/streams/session-serial-executor.ts +7 -6
  484. package/src/runtime/streams/stream-binding-runtime-ports.ts +79 -29
  485. package/src/runtime/streams/stream-frame-factory.ts +55 -38
  486. package/src/runtime/streams/stream-session-runtime.ts +268 -210
  487. package/src/runtime/workers/index.ts +68 -29
@@ -168,8 +168,8 @@ class DefaultZLinkSpotManager {
168
168
  return this.locationClaim.release(meshName, spotId);
169
169
  }
170
170
  const currentApplication = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
171
- if (currentApplication !== undefined
172
- && currentApplication.objectGeneration !== activation.domain.objectGeneration) {
171
+ if (currentApplication !== undefined &&
172
+ currentApplication.objectGeneration !== activation.domain.objectGeneration) {
173
173
  // A superseded local application must not release the authority row
174
174
  // that now belongs to the newer object generation.
175
175
  return Promise.resolve();
@@ -191,8 +191,10 @@ class DefaultZLinkSpotManager {
191
191
  return this.options.entrySpotIdProvider?.(meshName);
192
192
  }
193
193
  relocationActivations(meshName) {
194
- return this.activations.activeActivations().filter(activation => activation.meshName === meshName
195
- && this.activations.resolve(meshName, activation.spotId) === activation);
194
+ return this.activations
195
+ .activeActivations()
196
+ .filter((activation) => activation.meshName === meshName &&
197
+ this.activations.resolve(meshName, activation.spotId) === activation);
196
198
  }
197
199
  activeSpotCount(meshName) {
198
200
  return this.activations.list(meshName).length;
@@ -269,8 +271,7 @@ class DefaultZLinkSpotManager {
269
271
  }
270
272
  if (current.objectGeneration === objectGeneration)
271
273
  return;
272
- if (current.objectGeneration === undefined
273
- || current.objectGeneration > objectGeneration) {
274
+ if (current.objectGeneration === undefined || current.objectGeneration > objectGeneration) {
274
275
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale, `Instance Spot '${String(spotId)}' has a newer application generation.`);
275
276
  }
276
277
  // A newer authority route may become visible while the previous
@@ -281,16 +282,16 @@ class DefaultZLinkSpotManager {
281
282
  await this.discardInstance(meshName, spotId);
282
283
  continue;
283
284
  }
284
- const lifecycleActivation = this.activations.activeActivations().find((activation) => activation.meshName === meshName && String(activation.spotId) === String(spotId));
285
+ const lifecycleActivation = this.activations
286
+ .activeActivations()
287
+ .find((activation) => activation.meshName === meshName && String(activation.spotId) === String(spotId));
285
288
  if (lifecycleActivation?.isIdleEvicting === true) {
286
289
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale, `Instance Spot '${String(spotId)}' is entering idle eviction.`);
287
290
  }
288
291
  let pending = this.pendingInstanceMaterializations.get(materializationKey);
289
292
  if (pending === undefined) {
290
293
  const siblings = this.pendingInstanceMaterializationsByPrefix.get(materializationPrefix);
291
- const otherPending = siblings === undefined
292
- ? undefined
293
- : siblings.values().next().value;
294
+ const otherPending = siblings === undefined ? undefined : siblings.values().next().value;
294
295
  if (otherPending !== undefined) {
295
296
  await (0, abort_1.awaitWithAbort)(otherPending, signal);
296
297
  continue;
@@ -298,10 +299,12 @@ class DefaultZLinkSpotManager {
298
299
  }
299
300
  if (pending === undefined) {
300
301
  const metric = this.options.metrics?.startInstanceSpotActivation(meshName, instanceType);
301
- pending = this.activationLifecycle.materializeInstance(meshName, instanceType, factory, spotId, objectGeneration, signal).then(activation => {
302
+ pending = this.activationLifecycle
303
+ .materializeInstance(meshName, instanceType, factory, spotId, objectGeneration, signal)
304
+ .then((activation) => {
302
305
  metric?.complete('ready');
303
306
  return activation;
304
- }, error => {
307
+ }, (error) => {
305
308
  metric?.complete(instanceActivationOutcome(error));
306
309
  throw error;
307
310
  });
@@ -312,7 +315,8 @@ class DefaultZLinkSpotManager {
312
315
  this.pendingInstanceMaterializationsByPrefix.set(materializationPrefix, siblings);
313
316
  }
314
317
  siblings.set(materializationKey, pending);
315
- void pending.finally(() => {
318
+ void pending
319
+ .finally(() => {
316
320
  if (this.pendingInstanceMaterializations.get(materializationKey) === pending) {
317
321
  this.pendingInstanceMaterializations.delete(materializationKey);
318
322
  }
@@ -323,7 +327,8 @@ class DefaultZLinkSpotManager {
323
327
  this.pendingInstanceMaterializationsByPrefix.delete(materializationPrefix);
324
328
  }
325
329
  }
326
- }).catch(() => undefined);
330
+ })
331
+ .catch(() => undefined);
327
332
  }
328
333
  await pending;
329
334
  return;
@@ -383,8 +388,8 @@ class DefaultZLinkSpotManager {
383
388
  }
384
389
  isInstanceMaterialized(meshName, instanceType, spotId) {
385
390
  const activation = this.activations.resolve(meshName, spotId);
386
- return activation !== undefined
387
- && activation.spotType === this.requireInstanceFactory(meshName, instanceType);
391
+ return (activation !== undefined &&
392
+ activation.spotType === this.requireInstanceFactory(meshName, instanceType));
388
393
  }
389
394
  isInstanceMaterializing(meshName, spotId) {
390
395
  const prefix = instanceMaterializationPrefix(meshName, spotId);
@@ -392,8 +397,8 @@ class DefaultZLinkSpotManager {
392
397
  }
393
398
  isInstanceClosing(meshName, spotId) {
394
399
  const key = `${meshName}\0${String(spotId)}`;
395
- return this.pendingInstanceCloses.has(key)
396
- || this.activations.closingOperation(meshName, spotId) !== undefined;
400
+ return (this.pendingInstanceCloses.has(key) ||
401
+ this.activations.closingOperation(meshName, spotId) !== undefined);
397
402
  }
398
403
  async discardInstance(meshName, spotId) {
399
404
  const activation = this.activations.resolve(meshName, spotId);
@@ -404,16 +409,18 @@ class DefaultZLinkSpotManager {
404
409
  await operation?.ready;
405
410
  }
406
411
  isInstanceSpotIdleEvicting(meshName, spotId) {
407
- const activation = this.activations.activeActivations().find((candidate) => candidate.meshName === meshName && String(candidate.spotId) === String(spotId));
408
- return activation !== undefined
409
- && activation.domain.kind === 'instance'
410
- && activation.isIdleEvicting;
412
+ const activation = this.activations
413
+ .activeActivations()
414
+ .find((candidate) => candidate.meshName === meshName && String(candidate.spotId) === String(spotId));
415
+ return (activation !== undefined && activation.domain.kind === 'instance' && activation.isIdleEvicting);
411
416
  }
412
417
  beginInstanceSpotIdleEviction(meshName, spotId) {
413
- const activation = this.activations.activeActivations().find((candidate) => candidate.meshName === meshName && String(candidate.spotId) === String(spotId));
414
- if (activation === undefined
415
- || activation.domain.kind !== 'instance'
416
- || !activation.isIdleFor(performance.now(), this.options.instanceSpotIdleTimeoutMs?.get(meshName) ?? 0)) {
418
+ const activation = this.activations
419
+ .activeActivations()
420
+ .find((candidate) => candidate.meshName === meshName && String(candidate.spotId) === String(spotId));
421
+ if (activation === undefined ||
422
+ activation.domain.kind !== 'instance' ||
423
+ !activation.isIdleFor(performance.now(), this.options.instanceSpotIdleTimeoutMs?.get(meshName) ?? 0)) {
417
424
  return false;
418
425
  }
419
426
  return activation.beginIdleEviction();
@@ -437,13 +444,12 @@ class DefaultZLinkSpotManager {
437
444
  return true;
438
445
  }
439
446
  const deferredRelease = this.deferredInstanceAuthorityReleases.get(key)?.has(objectGeneration) === true;
440
- if (!deferredRelease
441
- && this.activations.closingOperation(meshName, spotId) === undefined) {
447
+ if (!deferredRelease && this.activations.closingOperation(meshName, spotId) === undefined) {
442
448
  return false;
443
449
  }
444
450
  const currentApplication = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
445
- if (currentApplication !== undefined
446
- && currentApplication.objectGeneration !== objectGeneration) {
451
+ if (currentApplication !== undefined &&
452
+ currentApplication.objectGeneration !== objectGeneration) {
447
453
  this.removeDeferredInstanceAuthorityRelease(key, objectGeneration);
448
454
  return false;
449
455
  }
@@ -484,8 +490,8 @@ class DefaultZLinkSpotManager {
484
490
  generations.set(generationKey, pending - 1);
485
491
  }
486
492
  releaseInstanceAuthority(meshName, spotId, objectGeneration) {
487
- return this.options.releaseInstanceAuthority?.(meshName, spotId, objectGeneration)
488
- ?? Promise.resolve();
493
+ return (this.options.releaseInstanceAuthority?.(meshName, spotId, objectGeneration) ??
494
+ Promise.resolve());
489
495
  }
490
496
  requireInstanceFactory(meshName, instanceType) {
491
497
  const factory = this.options.instanceSpotFactories?.get(meshName)?.get(instanceType);
@@ -499,8 +505,7 @@ class DefaultZLinkSpotManager {
499
505
  return;
500
506
  if (!this.hasIdleSweepTarget())
501
507
  return;
502
- const delays = [...(this.options.instanceSpotIdleTimeoutMs?.values() ?? [])]
503
- .filter((value) => value > 0);
508
+ const delays = [...(this.options.instanceSpotIdleTimeoutMs?.values() ?? [])].filter((value) => value > 0);
504
509
  if (delays.length === 0)
505
510
  return;
506
511
  const delay = Math.max(1, Math.min(...delays));
@@ -522,10 +527,10 @@ class DefaultZLinkSpotManager {
522
527
  const now = performance.now();
523
528
  for (const activation of this.activations.nextActiveActivationBatch()) {
524
529
  const timeoutMs = this.options.instanceSpotIdleTimeoutMs?.get(activation.meshName) ?? 0;
525
- if (timeoutMs <= 0
526
- || activation.domain.kind !== 'instance'
527
- || !activation.isIdleFor(now, timeoutMs)
528
- || !activation.beginIdleEviction()) {
530
+ if (timeoutMs <= 0 ||
531
+ activation.domain.kind !== 'instance' ||
532
+ !activation.isIdleFor(now, timeoutMs) ||
533
+ !activation.beginIdleEviction()) {
529
534
  continue;
530
535
  }
531
536
  let durableClosing;
@@ -613,12 +618,13 @@ class DefaultZLinkSpotManager {
613
618
  return this.activations.list(meshName);
614
619
  }
615
620
  async drainForShutdown(meshName, signal, deadline) {
616
- const results = await Promise.allSettled(this.activations.activeActivations()
617
- .filter(activation => activation.meshName === meshName)
618
- .map(activation => this.closeWithReason(meshName, activation.spotId, signal, contracts_1.ZLinkSpotCloseReason.HostShutdown, deadline)));
621
+ const results = await Promise.allSettled(this.activations
622
+ .activeActivations()
623
+ .filter((activation) => activation.meshName === meshName)
624
+ .map((activation) => this.closeWithReason(meshName, activation.spotId, signal, contracts_1.ZLinkSpotCloseReason.HostShutdown, deadline)));
619
625
  const errors = results
620
626
  .filter((result) => result.status === 'rejected')
621
- .map(result => result.reason);
627
+ .map((result) => result.reason);
622
628
  if (errors.length === 1)
623
629
  throw errors[0];
624
630
  if (errors.length > 1)
@@ -694,7 +700,9 @@ class DefaultZLinkSpotManager {
694
700
  // release the activation recovery fence and allow the durable close
695
701
  // CAS. The registered close gate prevents a second admission while
696
702
  // that detached close finishes.
697
- this.options.detachedTaskRunner?.runDetached(`instance spot close ${String(spotId)}`, async () => { await trackedClosePromise; });
703
+ this.options.detachedTaskRunner?.runDetached(`instance spot close ${String(spotId)}`, async () => {
704
+ await trackedClosePromise;
705
+ });
698
706
  if (this.options.detachedTaskRunner === undefined) {
699
707
  void trackedClosePromise.catch(() => undefined);
700
708
  }
@@ -708,7 +716,9 @@ class DefaultZLinkSpotManager {
708
716
  }
709
717
  if (currentTurn) {
710
718
  if (operation.started) {
711
- this.options.detachedTaskRunner?.runDetached(`spot close ${String(spotId)}`, async () => { await operation.ready; });
719
+ this.options.detachedTaskRunner?.runDetached(`spot close ${String(spotId)}`, async () => {
720
+ await operation.ready;
721
+ });
712
722
  if (this.options.detachedTaskRunner === undefined) {
713
723
  void operation.ready.catch(() => undefined);
714
724
  }
@@ -877,9 +887,9 @@ class DefaultZLinkSpotManager {
877
887
  return;
878
888
  for (;;) {
879
889
  const current = this.activations.resolve(meshName, spotId);
880
- if (current !== undefined
881
- && current.objectGeneration === target.objectGeneration
882
- && current.spotType === this.requireInstanceFactory(meshName, target.stableType))
890
+ if (current !== undefined &&
891
+ current.objectGeneration === target.objectGeneration &&
892
+ current.spotType === this.requireInstanceFactory(meshName, target.stableType))
883
893
  return;
884
894
  await this.materializeInstance(meshName, target.stableType, spotId, target.objectGeneration);
885
895
  const latest = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
@@ -908,8 +918,8 @@ class DefaultZLinkSpotManager {
908
918
  throw new configuration_1.ZLinkConfigurationException(`MeshNode Instance Spot target '${String(spotId)}' is not active.`);
909
919
  }
910
920
  const target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
911
- if (target !== undefined
912
- && activation.domain.objectGeneration !== target.objectGeneration) {
921
+ if (target !== undefined &&
922
+ activation.domain.objectGeneration !== target.objectGeneration) {
913
923
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale, `Instance Spot target '${String(spotId)}' application generation is stale.`);
914
924
  }
915
925
  const codecs = this.options.messageSerializers === undefined
@@ -920,7 +930,8 @@ class DefaultZLinkSpotManager {
920
930
  channelName: envelope.header.channelName,
921
931
  contentType: envelope.header.contentType,
922
932
  awaitFirstHandlerTurn: record.kind === service_runtime_contracts_1.ReceiveKind.InstanceSpotActivation,
923
- workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ?? (0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
933
+ workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ??
934
+ (0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
924
935
  };
925
936
  this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted, meshName, spotId, record, envelope, 'ready', target?.stableType);
926
937
  if (!request) {
@@ -949,7 +960,8 @@ class DefaultZLinkSpotManager {
949
960
  correlationId: envelope.header.correlationId ?? undefined,
950
961
  sourceRid: record.sourceNodeRid === null ? undefined : String(record.sourceNodeRid),
951
962
  spotId: String(spotId),
952
- instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)?.stableType,
963
+ instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)
964
+ ?.stableType,
953
965
  activationState: 'closing',
954
966
  flowId: envelope.header.flowId,
955
967
  flowOrigin: envelope.header.flowOrigin,
@@ -987,8 +999,7 @@ class DefaultZLinkSpotManager {
987
999
  async dispatchMeshActor(meshName, owner, record) {
988
1000
  const spotId = owner.spotId;
989
1001
  const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
990
- const targetsEntrySpot = spotId === null
991
- || (entrySpotId !== undefined && spotId === entrySpotId);
1002
+ const targetsEntrySpot = spotId === null || (entrySpotId !== undefined && spotId === entrySpotId);
992
1003
  const actor = owner.actor;
993
1004
  if (actor === null) {
994
1005
  throw new configuration_1.ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
@@ -1068,12 +1079,9 @@ class DefaultZLinkSpotManager {
1068
1079
  }
1069
1080
  const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
1070
1081
  let requestContentType = record.contentType ?? 'application/json';
1071
- const targetsEntrySpot = entrySpotId !== undefined
1072
- && String(spotId) === String(entrySpotId);
1082
+ const targetsEntrySpot = entrySpotId !== undefined && String(spotId) === String(entrySpotId);
1073
1083
  const activation = this.activations.resolve(meshName, spotId);
1074
- const transferRequest = record.parts.length === 0
1075
- ? undefined
1076
- : decodeFormalRemoteTransferRequest(record.parts[0]);
1084
+ const transferRequest = record.parts.length === 0 ? undefined : decodeFormalRemoteTransferRequest(record.parts[0]);
1077
1085
  const remoteJoinPhase = transferRequest?.phase;
1078
1086
  const isRemoteAdmission = remoteJoinPhase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION;
1079
1087
  const isRemoteCommit = remoteJoinPhase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_COMMIT;
@@ -1139,9 +1147,7 @@ class DefaultZLinkSpotManager {
1139
1147
  if (actor === undefined && admissionRecord?.actor !== undefined) {
1140
1148
  actor = admissionRecord.actor;
1141
1149
  }
1142
- let callbackRequest = record.parts.length === 0
1143
- ? undefined
1144
- : record.parts[0];
1150
+ let callbackRequest = record.parts.length === 0 ? undefined : record.parts[0];
1145
1151
  let ownedCallbackRequest;
1146
1152
  let materialized = false;
1147
1153
  let reply;
@@ -1149,11 +1155,10 @@ class DefaultZLinkSpotManager {
1149
1155
  let preparedTransferState;
1150
1156
  let admissionOutcome;
1151
1157
  let accepted = false;
1152
- let committedAdmissionReplay = isRemoteCommit
1153
- && admissionRecord?.state === 'committed';
1158
+ let committedAdmissionReplay = isRemoteCommit && admissionRecord?.state === 'committed';
1154
1159
  let targetCommitPublished;
1155
- const actorJoinIsCurrent = () => ((record.deadlineUnixMs === undefined || record.deadlineUnixMs > BigInt(Date.now()))
1156
- && (record.isPending?.() ?? true));
1160
+ const actorJoinIsCurrent = () => (record.deadlineUnixMs === undefined || record.deadlineUnixMs > BigInt(Date.now())) &&
1161
+ (record.isPending?.() ?? true);
1157
1162
  const abandonStaleAdmission = () => {
1158
1163
  if (isRemoteAdmission && transferRequest !== undefined) {
1159
1164
  this.formalRemoteActorAdmissions.abort(transferRequest.transferId);
@@ -1213,9 +1218,10 @@ class DefaultZLinkSpotManager {
1213
1218
  const response = await activation.serial.execute(async () => activation.spot.onActorJoin(actorRef.actorId, (0, payload_codec_1.wrapFrameworkPayloadMessage)(callbackRequest, this.options.messageSerializers, requestContentType)));
1214
1219
  let encodedReply;
1215
1220
  try {
1216
- encodedReply = response.reply === undefined
1217
- ? undefined
1218
- : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1221
+ encodedReply =
1222
+ response.reply === undefined
1223
+ ? undefined
1224
+ : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1219
1225
  admissionOutcome = {
1220
1226
  accepted: response.accepted,
1221
1227
  actorRef,
@@ -1233,17 +1239,16 @@ class DefaultZLinkSpotManager {
1233
1239
  }
1234
1240
  this.formalRemoteActorAdmissions.complete(control.canonicalActorJoin.handoffId, admissionOutcome);
1235
1241
  }
1236
- admissionOutcome = admissionRecord.result ?? await admissionRecord.resultTask;
1242
+ admissionOutcome = admissionRecord.result ?? (await admissionRecord.resultTask);
1237
1243
  if ('error' in admissionOutcome)
1238
1244
  throw admissionOutcome.error;
1239
1245
  accepted = admissionOutcome.accepted;
1240
- reply = admissionOutcome.reply === undefined
1241
- ? undefined
1242
- : runtime_message_1.ZLinkBufferMessage.from(admissionOutcome.reply);
1246
+ reply =
1247
+ admissionOutcome.reply === undefined
1248
+ ? undefined
1249
+ : runtime_message_1.ZLinkBufferMessage.from(admissionOutcome.reply);
1243
1250
  }
1244
- if (transferRequest !== undefined
1245
- && !targetsEntrySpot
1246
- && remoteJoinPhase === undefined) {
1251
+ if (transferRequest !== undefined && !targetsEntrySpot && remoteJoinPhase === undefined) {
1247
1252
  // User Spot transfers must carry the private admission/commit phases.
1248
1253
  // A legacy one-phase request would otherwise read relocation state
1249
1254
  // before the target application has accepted the Actor.
@@ -1272,11 +1277,11 @@ class DefaultZLinkSpotManager {
1272
1277
  if (admission.created) {
1273
1278
  try {
1274
1279
  if (targetsEntrySpot) {
1275
- if (this.options.dispatchEntryActorJoin !== undefined
1276
- && transferRequest.completionOperationId !== undefined
1277
- && this.options.actorTransferRuntime !== undefined) {
1278
- deferredJoinRoot = await this.options.actorTransferRuntime
1279
- .prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, Buffer.alloc(0));
1280
+ if (this.options.dispatchEntryActorJoin !== undefined &&
1281
+ transferRequest.completionOperationId !== undefined &&
1282
+ this.options.actorTransferRuntime !== undefined) {
1283
+ deferredJoinRoot =
1284
+ await this.options.actorTransferRuntime.prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, Buffer.alloc(0));
1280
1285
  }
1281
1286
  admissionOutcome = {
1282
1287
  accepted: this.options.dispatchEntryActorJoin !== undefined,
@@ -1295,16 +1300,17 @@ class DefaultZLinkSpotManager {
1295
1300
  const response = await activation.serial.execute(async () => activation.spot.onActorJoin(actorRef.actorId, (0, payload_codec_1.wrapFrameworkPayloadMessage)(ownedCallbackRequest, this.options.messageSerializers, transferRequest.requestContentType)));
1296
1301
  let encodedReply;
1297
1302
  try {
1298
- encodedReply = response.reply === undefined
1299
- ? undefined
1300
- : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1301
- if (response.accepted
1302
- && transferRequest.completionOperationId !== undefined
1303
- && this.options.actorTransferRuntime !== undefined) {
1304
- deferredJoinRoot = await this.options.actorTransferRuntime
1305
- .prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, encodedReply?.data() ?? Buffer.alloc(0), encodedReply === undefined
1303
+ encodedReply =
1304
+ response.reply === undefined
1306
1305
  ? undefined
1307
- : (0, payload_codec_1.frameworkPayloadContentType)(encodedReply));
1306
+ : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1307
+ if (response.accepted &&
1308
+ transferRequest.completionOperationId !== undefined &&
1309
+ this.options.actorTransferRuntime !== undefined) {
1310
+ deferredJoinRoot =
1311
+ await this.options.actorTransferRuntime.prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, encodedReply?.data() ?? Buffer.alloc(0), encodedReply === undefined
1312
+ ? undefined
1313
+ : (0, payload_codec_1.frameworkPayloadContentType)(encodedReply));
1308
1314
  this.options.runtimeEventPublisher?.publish({
1309
1315
  sourceName: 'zlink.framework.actor-handoff',
1310
1316
  timestamp: new Date(),
@@ -1344,9 +1350,10 @@ class DefaultZLinkSpotManager {
1344
1350
  throw admissionOutcome.error;
1345
1351
  }
1346
1352
  accepted = admissionOutcome.accepted;
1347
- reply = admissionOutcome.reply === undefined
1348
- ? undefined
1349
- : runtime_message_1.ZLinkBufferMessage.from(admissionOutcome.reply);
1353
+ reply =
1354
+ admissionOutcome.reply === undefined
1355
+ ? undefined
1356
+ : runtime_message_1.ZLinkBufferMessage.from(admissionOutcome.reply);
1350
1357
  }
1351
1358
  if (isRemoteCommit && admissionRecord !== undefined) {
1352
1359
  admissionOutcome = await admissionRecord.resultTask;
@@ -1355,13 +1362,13 @@ class DefaultZLinkSpotManager {
1355
1362
  }
1356
1363
  deferredJoinRoot = admissionOutcome.deferredJoinRoot;
1357
1364
  }
1358
- if (actor === undefined
1359
- && transferRequest !== undefined
1360
- && this.options.actorTransferRuntime !== undefined
1361
- && !isRemoteAdmission
1362
- && !commitAdmissionMissing
1363
- && admissionRecord?.state !== 'committed'
1364
- && (targetsEntrySpot || activation !== undefined)) {
1365
+ if (actor === undefined &&
1366
+ transferRequest !== undefined &&
1367
+ this.options.actorTransferRuntime !== undefined &&
1368
+ !isRemoteAdmission &&
1369
+ !commitAdmissionMissing &&
1370
+ admissionRecord?.state !== 'committed' &&
1371
+ (targetsEntrySpot || activation !== undefined)) {
1365
1372
  // Relocation state travels inline with the join request. The store
1366
1373
  // reference handoff was removed with the direct-transfer contract
1367
1374
  // (spec 28 §2 — Relocation Store keeps no relocation state payloads).
@@ -1371,14 +1378,14 @@ class DefaultZLinkSpotManager {
1371
1378
  preparedTransferState = runtime_message_1.ZLinkBufferMessage.from(Buffer.from(transferRequest.transferState, 'base64'));
1372
1379
  }
1373
1380
  if (isRemoteAdmission && targetsEntrySpot) {
1374
- accepted = admissionOutcome !== undefined
1375
- && !('error' in admissionOutcome)
1376
- && admissionOutcome.accepted;
1381
+ accepted =
1382
+ admissionOutcome !== undefined &&
1383
+ !('error' in admissionOutcome) &&
1384
+ admissionOutcome.accepted;
1377
1385
  }
1378
1386
  else if (isRemoteCommit && pendingAdmission !== undefined) {
1379
1387
  validateRemoteAdmissionCommit(pendingAdmission, transferRequest, actorId, control);
1380
- accepted = pendingAdmission.state === 'admitted'
1381
- || pendingAdmission.state === 'committed';
1388
+ accepted = pendingAdmission.state === 'admitted' || pendingAdmission.state === 'committed';
1382
1389
  }
1383
1390
  else if (commitAdmissionMissing) {
1384
1391
  accepted = false;
@@ -1388,15 +1395,15 @@ class DefaultZLinkSpotManager {
1388
1395
  // actor-manager transaction is committed after the Core reply below.
1389
1396
  // A formal transfer payload materializes the existing actor state at
1390
1397
  // the Entry owner before that transaction is committed.
1391
- accepted = actor !== undefined
1392
- || (transferRequest !== undefined && this.options.actorTransferRuntime !== undefined);
1398
+ accepted =
1399
+ actor !== undefined ||
1400
+ (transferRequest !== undefined && this.options.actorTransferRuntime !== undefined);
1393
1401
  }
1394
- else if (!isRemoteAdmission
1395
- && control.canonicalActorJoin === undefined
1396
- &&
1397
- activation !== undefined
1398
- && callbackRequest !== undefined
1399
- && (actor !== undefined || transferRequest !== undefined)) {
1402
+ else if (!isRemoteAdmission &&
1403
+ control.canonicalActorJoin === undefined &&
1404
+ activation !== undefined &&
1405
+ callbackRequest !== undefined &&
1406
+ (actor !== undefined || transferRequest !== undefined)) {
1400
1407
  if (!actorJoinIsCurrent())
1401
1408
  return;
1402
1409
  const request = callbackRequest;
@@ -1416,14 +1423,14 @@ class DefaultZLinkSpotManager {
1416
1423
  if (!actorJoinIsCurrent())
1417
1424
  return;
1418
1425
  accepted = response.accepted;
1419
- reply = response.reply === undefined
1420
- ? undefined
1421
- : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1422
- if (accepted
1423
- && transferRequest?.completionOperationId !== undefined
1424
- && this.options.actorTransferRuntime !== undefined) {
1425
- deferredJoinRoot = await this.options.actorTransferRuntime
1426
- .prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, reply?.data() ?? Buffer.alloc(0), reply === undefined ? undefined : (0, payload_codec_1.frameworkPayloadContentType)(reply));
1426
+ reply =
1427
+ response.reply === undefined
1428
+ ? undefined
1429
+ : (0, payload_codec_1.encodeFrameworkPayloadMessage)(response.reply, this.options.messageSerializers);
1430
+ if (accepted &&
1431
+ transferRequest?.completionOperationId !== undefined &&
1432
+ this.options.actorTransferRuntime !== undefined) {
1433
+ deferredJoinRoot = await this.options.actorTransferRuntime.prepareDeferredJoinAccepted(actorId, transferRequest.completionOperationId, actorRef, reply?.data() ?? Buffer.alloc(0), reply === undefined ? undefined : (0, payload_codec_1.frameworkPayloadContentType)(reply));
1427
1434
  this.options.runtimeEventPublisher?.publish({
1428
1435
  sourceName: 'zlink.framework.actor-handoff',
1429
1436
  timestamp: new Date(),
@@ -1432,11 +1439,11 @@ class DefaultZLinkSpotManager {
1432
1439
  });
1433
1440
  }
1434
1441
  }
1435
- if (accepted
1436
- && !isRemoteAdmission
1437
- && actor === undefined
1438
- && transferRequest !== undefined
1439
- && this.options.actorTransferRuntime !== undefined) {
1442
+ if (accepted &&
1443
+ !isRemoteAdmission &&
1444
+ actor === undefined &&
1445
+ transferRequest !== undefined &&
1446
+ this.options.actorTransferRuntime !== undefined) {
1440
1447
  if (!actorJoinIsCurrent())
1441
1448
  return;
1442
1449
  const transferState = preparedTransferState;
@@ -1461,21 +1468,21 @@ class DefaultZLinkSpotManager {
1461
1468
  return;
1462
1469
  }
1463
1470
  }
1464
- if (accepted
1465
- && transferRequest !== undefined
1466
- && this.options.actorTransferRuntime !== undefined
1467
- && !isRemoteAdmission) {
1471
+ if (accepted &&
1472
+ transferRequest !== undefined &&
1473
+ this.options.actorTransferRuntime !== undefined &&
1474
+ !isRemoteAdmission) {
1468
1475
  // A lightweight Core actor-join notification can create the Actor
1469
1476
  // before the formal transfer request reaches this branch. Preserve
1470
1477
  // the full relocation fence in that race so a later Session bind
1471
1478
  // refresh cannot erase the seal or accepted journal.
1472
1479
  this.options.actorTransferRuntime.rememberRoutedActorTransferTarget(actorId, transferRequest.remoteBoundSessionTarget);
1473
1480
  }
1474
- if (accepted
1475
- && actor !== undefined
1476
- && transferRequest !== undefined
1477
- && !isRemoteAdmission
1478
- && !committedAdmissionReplay) {
1481
+ if (accepted &&
1482
+ actor !== undefined &&
1483
+ transferRequest !== undefined &&
1484
+ !isRemoteAdmission &&
1485
+ !committedAdmissionReplay) {
1479
1486
  this.formalRemoteTransfers.begin({
1480
1487
  actor,
1481
1488
  spotId,
@@ -1508,9 +1515,7 @@ class DefaultZLinkSpotManager {
1508
1515
  }
1509
1516
  if (accepted && targetsEntrySpot && actor !== undefined) {
1510
1517
  const entryActor = actor;
1511
- const pendingTransfer = transferRequest === undefined
1512
- ? undefined
1513
- : this.formalRemoteTransfers.get(actorId);
1518
+ const pendingTransfer = transferRequest === undefined ? undefined : this.formalRemoteTransfers.get(actorId);
1514
1519
  if (committedAdmissionReplay) {
1515
1520
  if (!replyActorJoin())
1516
1521
  return;
@@ -1543,17 +1548,17 @@ class DefaultZLinkSpotManager {
1543
1548
  throw new Error('Entry Spot saved handoff replay requires its Actor packet runtime.');
1544
1549
  }
1545
1550
  return await this.options.dispatchEntryActorPacket(entryActor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
1546
- }, index => this.options.runtimeEventPublisher?.publish({
1551
+ }, (index) => this.options.runtimeEventPublisher?.publish({
1547
1552
  sourceName: 'zlink.framework.actor-handoff',
1548
1553
  timestamp: new Date(),
1549
1554
  marker: 'backlog_enqueued',
1550
1555
  actorId: entryActor.context.actorId,
1551
1556
  index
1552
1557
  }));
1553
- const failedHandoff = handoffResults.find(result => !result.ok);
1558
+ const failedHandoff = handoffResults.find((result) => !result.ok);
1554
1559
  if (failedHandoff !== undefined) {
1555
- throw new Error(`Actor '${entryActor.context.actorId}' saved Entry handoff packet `
1556
- + `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`);
1560
+ throw new Error(`Actor '${entryActor.context.actorId}' saved Entry handoff packet ` +
1561
+ `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`);
1557
1562
  }
1558
1563
  this.formalRemoteTransfers.delete(entryActor.context.actorId);
1559
1564
  };
@@ -1600,27 +1605,23 @@ class DefaultZLinkSpotManager {
1600
1605
  ? control.previousActor
1601
1606
  : control.currentActor;
1602
1607
  const actorId = actorRef?.actorId;
1603
- const pendingTransfer = actorId === undefined
1604
- ? undefined
1605
- : this.formalRemoteTransfers.get(actorId);
1608
+ const pendingTransfer = actorId === undefined ? undefined : this.formalRemoteTransfers.get(actorId);
1606
1609
  const sourceActivation = actorId === undefined || spotId === null
1607
1610
  ? undefined
1608
1611
  : this.activations.resolve(meshName, spotId);
1609
- const sourceJoinedActor = actorId === undefined
1610
- ? undefined
1611
- : sourceActivation?.resolveJoinedActor(actorId);
1612
+ const sourceJoinedActor = actorId === undefined ? undefined : sourceActivation?.resolveJoinedActor(actorId);
1612
1613
  const actor = actorId === undefined
1613
1614
  ? undefined
1614
- : pendingTransfer?.actor
1615
- ?? sourceJoinedActor
1616
- ?? this.options.actorLifecycleResolver?.(actorId)
1617
- ?? this.options.actorResolver?.(actorId);
1615
+ : (pendingTransfer?.actor ??
1616
+ sourceJoinedActor ??
1617
+ this.options.actorLifecycleResolver?.(actorId) ??
1618
+ this.options.actorResolver?.(actorId));
1618
1619
  const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
1619
1620
  if (actor === undefined) {
1620
1621
  return;
1621
1622
  }
1622
- if (control.lifecycleKind === service_runtime_contracts_1.ActorLifecycleKind.Left
1623
- && (spotId === null || (entrySpotId !== undefined && String(spotId) === String(entrySpotId)))) {
1623
+ if (control.lifecycleKind === service_runtime_contracts_1.ActorLifecycleKind.Left &&
1624
+ (spotId === null || (entrySpotId !== undefined && String(spotId) === String(entrySpotId)))) {
1624
1625
  const callback = async () => {
1625
1626
  await this.options.entrySpotCallbacks?.onLeaveActor(actor, undefined, actorRef, control.previousMembershipEpoch);
1626
1627
  };
@@ -1665,7 +1666,7 @@ class DefaultZLinkSpotManager {
1665
1666
  if (currentRef === null) {
1666
1667
  throw new Error(`Actor '${actor.context.actorId}' has no target ref for deferred Join completion.`);
1667
1668
  }
1668
- await this.options.actorTransferRuntime?.commitAndDeliverDeferredJoinAccepted(deferredJoinRoot, actor, currentRef, operation => activation.executeActor(actor.context.actorId, async () => await operation()));
1669
+ await this.options.actorTransferRuntime?.commitAndDeliverDeferredJoinAccepted(deferredJoinRoot, actor, currentRef, (operation) => activation.executeActor(actor.context.actorId, async () => await operation()));
1669
1670
  }
1670
1671
  };
1671
1672
  const completeTargetReady = async () => {
@@ -1677,10 +1678,10 @@ class DefaultZLinkSpotManager {
1677
1678
  actorId: actor.context.actorId,
1678
1679
  index
1679
1680
  }));
1680
- const failedHandoff = handoffResults.find(result => !result.ok);
1681
+ const failedHandoff = handoffResults.find((result) => !result.ok);
1681
1682
  if (failedHandoff !== undefined) {
1682
- throw new Error(`Actor '${actor.context.actorId}' saved handoff packet `
1683
- + `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`);
1683
+ throw new Error(`Actor '${actor.context.actorId}' saved handoff packet ` +
1684
+ `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`);
1684
1685
  }
1685
1686
  // Spec 15 §4.2 relocation temporary queue: arrivals parked at
1686
1687
  // this target directly (not relayed through the source's
@@ -1767,15 +1768,14 @@ class DefaultZLinkSpotManager {
1767
1768
  if (admission.admission.actorId !== actor.context.actorId) {
1768
1769
  throw new Error(`Actor Join relocation '${relocationId}' changed its admitted Actor.`);
1769
1770
  }
1770
- const outcome = admission.result ?? await admission.resultTask;
1771
+ const outcome = admission.result ?? (await admission.resultTask);
1771
1772
  if ('error' in outcome)
1772
1773
  throw outcome.error;
1773
1774
  if (!outcome.accepted || admission.state !== 'admitted') {
1774
1775
  throw new Error(`Actor Join relocation '${relocationId}' has no accepted admission.`);
1775
1776
  }
1776
1777
  const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
1777
- const targetsEntry = entrySpotId !== undefined
1778
- && String(admission.admission.spotId) === String(entrySpotId);
1778
+ const targetsEntry = entrySpotId !== undefined && String(admission.admission.spotId) === String(entrySpotId);
1779
1779
  if (targetsEntry) {
1780
1780
  await this.options.dispatchEntryActorJoin?.(meshName, actor, []);
1781
1781
  }
@@ -1808,7 +1808,7 @@ class DefaultZLinkSpotManager {
1808
1808
  if (admission === undefined) {
1809
1809
  throw new Error(`Actor Join recovery '${recovery.request.handoffId}' has no canonical command-28 admission.`);
1810
1810
  }
1811
- const outcome = admission.result ?? await admission.resultTask;
1811
+ const outcome = admission.result ?? (await admission.resultTask);
1812
1812
  if ('error' in outcome || !outcome.accepted || admission.state !== 'admitted') {
1813
1813
  throw new Error(`Actor Join recovery '${recovery.request.handoffId}' has no accepted admission.`);
1814
1814
  }
@@ -1817,13 +1817,13 @@ class DefaultZLinkSpotManager {
1817
1817
  throw new Error(`Actor Join recovery '${recovery.request.handoffId}' lost its command-28 source route.`);
1818
1818
  }
1819
1819
  const admittedNodeBytes = Buffer.from((0, routing_id_1.encodeRoutingIdStorageHex)(admitted.sourceActorNodeRid), 'hex');
1820
- if (admitted.actorId !== recovery.request.actorId
1821
- || admitted.actorType !== recovery.request.actorType
1822
- || admitted.requestFingerprint !== recovery.request.request.toString('base64')
1823
- || String(admitted.spotId) !== recovery.targetSpotId
1824
- || admitted.targetSpotGeneration !== recovery.targetSpotGeneration
1825
- || admitted.actorRef.objectGeneration !== recovery.request.actorGeneration
1826
- || !admittedNodeBytes.equals(recovery.request.sourceNodeRid)) {
1820
+ if (admitted.actorId !== recovery.request.actorId ||
1821
+ admitted.actorType !== recovery.request.actorType ||
1822
+ admitted.requestFingerprint !== recovery.request.request.toString('base64') ||
1823
+ String(admitted.spotId) !== recovery.targetSpotId ||
1824
+ admitted.targetSpotGeneration !== recovery.targetSpotGeneration ||
1825
+ admitted.actorRef.objectGeneration !== recovery.request.actorGeneration ||
1826
+ !admittedNodeBytes.equals(recovery.request.sourceNodeRid)) {
1827
1827
  throw new Error(`Actor Join recovery '${recovery.request.handoffId}' changed its command-28 identity.`);
1828
1828
  }
1829
1829
  const admittedReply = outcome.reply ?? Buffer.alloc(0);
@@ -1845,9 +1845,7 @@ class DefaultZLinkSpotManager {
1845
1845
  // Command 28 carries a present reply in one outer framework-multipart
1846
1846
  // part. The accepted target admission still owns the inner typed content
1847
1847
  // type, which the durable completion must retain for application decode.
1848
- const admittedContentType = admittedReply.byteLength === 0
1849
- ? recovery.replyContentType
1850
- : outcome.replyContentType;
1848
+ const admittedContentType = admittedReply.byteLength === 0 ? recovery.replyContentType : outcome.replyContentType;
1851
1849
  const transfer = this.options.actorTransferRuntime;
1852
1850
  if (transfer === undefined) {
1853
1851
  throw new Error('Canonical Actor Join recovery requires the Actor transfer runtime.');
@@ -1911,10 +1909,7 @@ class DefaultZLinkSpotManager {
1911
1909
  const drained = this.formalRemoteActorAdmissions.completeMigration(transferId);
1912
1910
  for (const arrival of drained) {
1913
1911
  try {
1914
- const response = await this.dispatchActorPacket(activation, actor.context.actorId, [
1915
- runtime_message_1.ZLinkBufferMessage.from(arrival.header),
1916
- runtime_message_1.ZLinkBufferMessage.from(arrival.payload)
1917
- ], arrival.returnResponse, arrival.remoteBoundSessionTarget, arrival.fallbackActorRef, arrival.requestTerminal);
1912
+ const response = await this.dispatchActorPacket(activation, actor.context.actorId, [runtime_message_1.ZLinkBufferMessage.from(arrival.header), runtime_message_1.ZLinkBufferMessage.from(arrival.payload)], arrival.returnResponse, arrival.remoteBoundSessionTarget, arrival.fallbackActorRef, arrival.requestTerminal);
1918
1913
  arrival.resolve(response);
1919
1914
  }
1920
1915
  catch (error) {
@@ -1934,10 +1929,10 @@ exports.DefaultZLinkSpotManager = DefaultZLinkSpotManager;
1934
1929
  function instanceDispatchErrorReason(error) {
1935
1930
  if (error instanceof contracts_1.ZLinkFrameworkException) {
1936
1931
  const kind = (0, framework_errors_internal_1.internalFrameworkErrorKind)(error);
1937
- if (kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale
1938
- || kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving
1939
- || kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotRouteNotFound
1940
- || kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestTargetNotFound) {
1932
+ if (kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale ||
1933
+ kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving ||
1934
+ kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotRouteNotFound ||
1935
+ kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestTargetNotFound) {
1941
1936
  return ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorReason.StaleTarget;
1942
1937
  }
1943
1938
  }
@@ -1954,34 +1949,30 @@ function decodeFormalRemoteTransferRequestBytes(bytes) {
1954
1949
  catch {
1955
1950
  return undefined;
1956
1951
  }
1957
- if (payload.packetName !== actor_remote_wire_1.REMOTE_ACTOR_JOIN_PACKET
1958
- || typeof payload.actorType !== 'string'
1959
- || typeof payload.transferId !== 'string'
1960
- || !(payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION
1961
- || payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT
1962
- || payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_COMMIT
1963
- || payload.phase === undefined)
1964
- || !(payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION
1965
- || payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT
1966
- || (typeof payload.transferState === 'string'))
1967
- || typeof payload.request !== 'string') {
1952
+ if (payload.packetName !== actor_remote_wire_1.REMOTE_ACTOR_JOIN_PACKET ||
1953
+ typeof payload.actorType !== 'string' ||
1954
+ typeof payload.transferId !== 'string' ||
1955
+ !(payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION ||
1956
+ payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT ||
1957
+ payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_COMMIT ||
1958
+ payload.phase === undefined) ||
1959
+ !(payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION ||
1960
+ payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT ||
1961
+ typeof payload.transferState === 'string') ||
1962
+ typeof payload.request !== 'string') {
1968
1963
  return undefined;
1969
1964
  }
1970
1965
  return {
1971
1966
  actorType: payload.actorType,
1972
1967
  actorId: typeof payload.actorId === 'string' ? payload.actorId : undefined,
1973
- phase: payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION
1974
- || payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_COMMIT
1975
- || payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT
1968
+ phase: payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ADMISSION ||
1969
+ payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_COMMIT ||
1970
+ payload.phase === actor_remote_wire_1.REMOTE_ACTOR_JOIN_ABORT
1976
1971
  ? payload.phase
1977
1972
  : undefined,
1978
1973
  transferId: payload.transferId,
1979
- transferAdapterKey: typeof payload.transferAdapterKey === 'string'
1980
- ? payload.transferAdapterKey
1981
- : undefined,
1982
- transferState: typeof payload.transferState === 'string'
1983
- ? payload.transferState
1984
- : undefined,
1974
+ transferAdapterKey: typeof payload.transferAdapterKey === 'string' ? payload.transferAdapterKey : undefined,
1975
+ transferState: typeof payload.transferState === 'string' ? payload.transferState : undefined,
1985
1976
  request: payload.request,
1986
1977
  requestContentType: typeof payload.requestContentType === 'string'
1987
1978
  ? payload.requestContentType
@@ -1989,17 +1980,15 @@ function decodeFormalRemoteTransferRequestBytes(bytes) {
1989
1980
  actorEntryNodeRid: typeof payload.actorEntryNodeRid === 'string'
1990
1981
  ? (0, routing_id_1.decodeRoutingId)(payload.actorEntryNodeRid, payload.actorEntryNodeRidHex)
1991
1982
  : undefined,
1992
- sourceSpotId: typeof payload.sourceSpotId === 'string'
1993
- ? payload.sourceSpotId
1994
- : undefined,
1983
+ sourceSpotId: typeof payload.sourceSpotId === 'string' ? payload.sourceSpotId : undefined,
1995
1984
  actorRef: decodeFormalRemoteActorRef(payload),
1996
1985
  remoteBoundSessionTarget: (0, spot_remote_codec_1.decodeRemoteBoundSessionTarget)(payload.boundSessionRouterChannelId, payload.boundSessionTargetNodeRid, payload.boundSessionTargetNodeRidHex, payload.boundSessionSpotId, payload.boundSessionNodeRid, payload.boundSessionNodeRidHex, payload.boundSessionRid, payload.boundSessionRidHex, payload.boundSessionBindingGeneration, payload.boundSessionPreviousAuthorityOwnerGeneration, payload.boundSessionPreviousOwnerLeaseGeneration, payload.boundSessionRelocationSealId, payload.boundSessionServiceWireRelocation),
1997
1986
  expectedMembershipEpoch: typeof payload.expectedMembershipEpoch === 'string'
1998
1987
  ? BigInt(payload.expectedMembershipEpoch)
1999
1988
  : 0n,
2000
1989
  handoffBacklog: (0, spot_remote_codec_1.decodeHandoffBacklog)(payload.handoffBacklog),
2001
- completionOperationId: typeof payload.completionOperationHigh === 'string'
2002
- && typeof payload.completionOperationLow === 'string'
1990
+ completionOperationId: typeof payload.completionOperationHigh === 'string' &&
1991
+ typeof payload.completionOperationLow === 'string'
2003
1992
  ? {
2004
1993
  high: BigInt(payload.completionOperationHigh),
2005
1994
  low: BigInt(payload.completionOperationLow)
@@ -2039,15 +2028,15 @@ function toFrameworkRemoteAdmissionActorRef(rawActorRef, meshName) {
2039
2028
  function validateRemoteAdmissionCommit(admission, request, actorId, control) {
2040
2029
  const expected = admission.admission;
2041
2030
  const actorRef = request.actorRef;
2042
- if (expected.actorId !== actorId
2043
- || expected.actorType !== request.actorType
2044
- || expected.expectedMembershipEpoch !== request.expectedMembershipEpoch
2045
- || expected.requestFingerprint !== request.request
2046
- || expected.targetSpotGeneration !== (control.currentSpotGeneration ?? 0n)
2047
- || actorRef === undefined
2048
- || actorRef.actorId !== expected.actorRef.actorId
2049
- || String(actorRef.nodeRid) !== String(expected.actorRef.nodeRid)
2050
- || actorRef.objectGeneration !== expected.actorRef.objectGeneration) {
2031
+ if (expected.actorId !== actorId ||
2032
+ expected.actorType !== request.actorType ||
2033
+ expected.expectedMembershipEpoch !== request.expectedMembershipEpoch ||
2034
+ expected.requestFingerprint !== request.request ||
2035
+ expected.targetSpotGeneration !== (control.currentSpotGeneration ?? 0n) ||
2036
+ actorRef === undefined ||
2037
+ actorRef.actorId !== expected.actorRef.actorId ||
2038
+ String(actorRef.nodeRid) !== String(expected.actorRef.nodeRid) ||
2039
+ actorRef.objectGeneration !== expected.actorRef.objectGeneration) {
2051
2040
  throw new configuration_1.ZLinkConfigurationException(`Remote Actor '${actorId}' commit does not match its target admission.`);
2052
2041
  }
2053
2042
  }
@@ -2069,10 +2058,10 @@ function instanceMaterializationKey(meshName, spotId, objectGeneration) {
2069
2058
  return `${instanceMaterializationPrefix(meshName, spotId)}\0${objectGeneration}`;
2070
2059
  }
2071
2060
  function isAbortSignal(value) {
2072
- return typeof value === 'object'
2073
- && value !== null
2074
- && typeof value.aborted === 'boolean'
2075
- && typeof value.addEventListener === 'function';
2061
+ return (typeof value === 'object' &&
2062
+ value !== null &&
2063
+ typeof value.aborted === 'boolean' &&
2064
+ typeof value.addEventListener === 'function');
2076
2065
  }
2077
2066
  function instanceActivationOutcome(error) {
2078
2067
  if ((0, abort_1.isAbortError)(error))
@@ -2082,8 +2071,8 @@ function instanceActivationOutcome(error) {
2082
2071
  return 'timed_out';
2083
2072
  if (error.kind === contracts_1.ZLinkFrameworkErrorKind.AlreadyExists)
2084
2073
  return 'conflict';
2085
- if (error.kind === contracts_1.ZLinkFrameworkErrorKind.InvalidOperation
2086
- || error.kind === contracts_1.ZLinkFrameworkErrorKind.Unavailable)
2074
+ if (error.kind === contracts_1.ZLinkFrameworkErrorKind.InvalidOperation ||
2075
+ error.kind === contracts_1.ZLinkFrameworkErrorKind.Unavailable)
2087
2076
  return 'fenced';
2088
2077
  }
2089
2078
  return 'failed';