@zlink-systems/framework 0.29.1 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/LICENSE +150 -68
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
  4. package/dist/contracts/Channels/Calls.d.ts +2 -1
  5. package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
  6. package/dist/contracts/Configuration/Builders.d.ts +1 -2
  7. package/dist/contracts/Configuration/Configs.d.ts +0 -5
  8. package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
  9. package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
  10. package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
  11. package/dist/contracts/Configuration/index.d.ts +1 -1
  12. package/dist/contracts/Handlers/Attributes.d.ts +5 -13
  13. package/dist/contracts/Handlers/Attributes.js +7 -11
  14. package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
  15. package/dist/contracts/Handlers/JsonContract.js +4 -153
  16. package/dist/contracts/Spots/Contracts.d.ts +2 -1
  17. package/dist/internal.d.ts +1 -0
  18. package/dist/internal.js +3 -1
  19. package/dist/nest-integration.d.ts +1 -1
  20. package/dist/nest-integration.js +2 -1
  21. package/dist/runtime/actors/actor-client.d.ts +1 -1
  22. package/dist/runtime/actors/actor-client.js +14 -12
  23. package/dist/runtime/actors/actor-handoff.d.ts +3 -2
  24. package/dist/runtime/actors/actor-handoff.js +15 -7
  25. package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
  26. package/dist/runtime/actors/actor-local-native-join.js +9 -12
  27. package/dist/runtime/actors/actor-remote-wire.js +15 -0
  28. package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
  29. package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
  30. package/dist/runtime/actors/index.d.ts +2 -1
  31. package/dist/runtime/actors/index.js +18 -6
  32. package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
  33. package/dist/runtime/admission.d.ts +1 -1
  34. package/dist/runtime/admission.js +15 -5
  35. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +9 -9
  36. package/dist/runtime/application-jobs/application-ingress-record-owner.js +45 -23
  37. package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +5 -2
  38. package/dist/runtime/application-jobs/application-job-queue-scope.js +41 -21
  39. package/dist/runtime/application-jobs/contracts.d.ts +15 -2
  40. package/dist/runtime/backend/contracts/index.d.ts +27 -27
  41. package/dist/runtime/backend/mesh-completion-table.d.ts +15 -5
  42. package/dist/runtime/backend/mesh-completion-table.js +160 -50
  43. package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
  44. package/dist/runtime/backend/mesh-dispatch-pump.js +53 -36
  45. package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
  46. package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
  47. package/dist/runtime/backend/node/node-backend-adapter-support.js +33 -31
  48. package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
  49. package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
  50. package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
  51. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
  52. package/dist/runtime/backend/node/node-raw-binding-port.js +50 -25
  53. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +22 -16
  54. package/dist/runtime/backend/node/node-raw-mesh-backend.js +133 -149
  55. package/dist/runtime/backend/node/node-socket-backend-adapter.js +15 -10
  56. package/dist/runtime/backend/raw-binding-port.d.ts +10 -3
  57. package/dist/runtime/backend/runtime-message.d.ts +1 -0
  58. package/dist/runtime/backend/runtime-message.js +5 -0
  59. package/dist/runtime/backend/runtime-values.d.ts +1 -0
  60. package/dist/runtime/backend/runtime-values.js +2 -1
  61. package/dist/runtime/channels/channel-clients.d.ts +1 -0
  62. package/dist/runtime/channels/channel-clients.js +58 -21
  63. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
  64. package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
  65. package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
  66. package/dist/runtime/channels/channel-dispatch-services.js +45 -0
  67. package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
  68. package/dist/runtime/channels/channel-dispatchers.js +27 -26
  69. package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
  70. package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
  71. package/dist/runtime/channels/channel-envelope.d.ts +1 -0
  72. package/dist/runtime/channels/channel-envelope.js +83 -8
  73. package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
  74. package/dist/runtime/channels/channel-outbound-operations.js +8 -8
  75. package/dist/runtime/channels/channel-receive-loops.js +3 -3
  76. package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
  77. package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
  78. package/dist/runtime/channels/channel-runtime-manager.js +12 -12
  79. package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
  80. package/dist/runtime/channels/channel-socket-registry.js +59 -82
  81. package/dist/runtime/channels/channel-transports.d.ts +18 -15
  82. package/dist/runtime/channels/channel-transports.js +48 -31
  83. package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
  84. package/dist/runtime/channels/local-spot-route-transport.js +2 -1
  85. package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
  86. package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
  87. package/dist/runtime/channels/source-spot-router.d.ts +2 -2
  88. package/dist/runtime/channels/source-spot-router.js +4 -4
  89. package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
  90. package/dist/runtime/channels/spot-node-route-transport.js +4 -4
  91. package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
  92. package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
  93. package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
  94. package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
  95. package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
  96. package/dist/runtime/diagnostics/message-flow.js +3 -3
  97. package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
  98. package/dist/runtime/execution/serial-execution-queue.js +1 -0
  99. package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
  100. package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
  101. package/dist/runtime/foundation/durable-service-request.js +98 -0
  102. package/dist/runtime/foundation/operation-identity.d.ts +1 -0
  103. package/dist/runtime/foundation/operation-identity.js +5 -1
  104. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +37 -6
  105. package/dist/runtime/foundation/raw-service-mesh-runtime.js +473 -220
  106. package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
  107. package/dist/runtime/foundation/service-liveness-registry.js +57 -44
  108. package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
  109. package/dist/runtime/foundation/service-mailbox.js +2 -1
  110. package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
  111. package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
  112. package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
  113. package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
  114. package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
  115. package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -9
  116. package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
  117. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -7
  118. package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
  119. package/dist/runtime/foundation/service-topology-registry.d.ts +16 -4
  120. package/dist/runtime/foundation/service-topology-registry.js +69 -30
  121. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
  122. package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
  123. package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
  124. package/dist/runtime/handlers/handler-instance-scope.js +54 -11
  125. package/dist/runtime/host/actor-packet-relay.js +7 -7
  126. package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
  127. package/dist/runtime/host/application-job-queue.d.ts +28 -9
  128. package/dist/runtime/host/application-job-queue.js +214 -50
  129. package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
  130. package/dist/runtime/host/entry-actor-runtime.js +4 -1
  131. package/dist/runtime/host/index.d.ts +7 -1
  132. package/dist/runtime/host/index.js +154 -126
  133. package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
  134. package/dist/runtime/host/instance-activation-authority.js +89 -25
  135. package/dist/runtime/host/remote-bound-session-relay.js +2 -18
  136. package/dist/runtime/host/route-mesh-runtime.js +1 -1
  137. package/dist/runtime/host/service-relocation-control.d.ts +1 -0
  138. package/dist/runtime/host/service-relocation-control.js +10 -4
  139. package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
  140. package/dist/runtime/host/service-relocation-host-runtime.js +215 -243
  141. package/dist/runtime/host/spot-address-transport.d.ts +1 -0
  142. package/dist/runtime/host/spot-address-transport.js +28 -14
  143. package/dist/runtime/host/spot-runtime-options-factory.js +3 -2
  144. package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
  145. package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
  146. package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
  147. package/dist/runtime/locations/actor-location-claims.js +34 -19
  148. package/dist/runtime/locations/domain-store-contract.d.ts +2 -2
  149. package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
  150. package/dist/runtime/locations/in-memory-authority-store.js +80 -8
  151. package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
  152. package/dist/runtime/locations/in-memory-location-store.js +19 -3
  153. package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
  154. package/dist/runtime/locations/lifecycle.d.ts +1 -2
  155. package/dist/runtime/locations/lifecycle.js +2 -5
  156. package/dist/runtime/locations/location-store-repository.d.ts +3 -2
  157. package/dist/runtime/locations/location-store-repository.js +165 -22
  158. package/dist/runtime/locations/resolvers.d.ts +2 -1
  159. package/dist/runtime/locations/resolvers.js +10 -1
  160. package/dist/runtime/locations/runtime.d.ts +1 -1
  161. package/dist/runtime/locations/runtime.js +24 -23
  162. package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
  163. package/dist/runtime/messaging/framework-json-v1.js +38 -294
  164. package/dist/runtime/messaging/packet-name.d.ts +1 -1
  165. package/dist/runtime/messaging/packet-name.js +8 -24
  166. package/dist/runtime/messaging/request-result.d.ts +2 -0
  167. package/dist/runtime/messaging/request-result.js +54 -0
  168. package/dist/runtime/messaging/submission-result.d.ts +2 -1
  169. package/dist/runtime/messaging/submission-result.js +7 -4
  170. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
  171. package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
  172. package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
  173. package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
  174. package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +9 -2
  175. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
  176. package/dist/runtime/spots/index.d.ts +7 -3
  177. package/dist/runtime/spots/index.js +23 -16
  178. package/dist/runtime/spots/spot-activation.d.ts +3 -1
  179. package/dist/runtime/spots/spot-activation.js +21 -12
  180. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
  181. package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
  182. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
  183. package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
  184. package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
  185. package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
  186. package/dist/runtime/spots/spot-entry-activation.js +9 -3
  187. package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
  188. package/dist/runtime/spots/spot-handler-registry.js +18 -8
  189. package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
  190. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
  191. package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
  192. package/dist/runtime/spots/spot-outbound.d.ts +3 -0
  193. package/dist/runtime/spots/spot-outbound.js +24 -15
  194. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
  195. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
  196. package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
  197. package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -1
  198. package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
  199. package/dist/runtime/spots/spot-timer.js +1 -0
  200. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
  201. package/dist/runtime/streams/stream-session-runtime.js +14 -28
  202. package/package.json +3 -3
  203. package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
  204. package/src/contracts/Channels/Calls.ts +2 -1
  205. package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
  206. package/src/contracts/Configuration/Builders.ts +1 -2
  207. package/src/contracts/Configuration/Configs.ts +0 -6
  208. package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
  209. package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
  210. package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
  211. package/src/contracts/Configuration/index.ts +1 -6
  212. package/src/contracts/Handlers/Attributes.ts +14 -21
  213. package/src/contracts/Handlers/JsonContract.ts +8 -216
  214. package/src/contracts/Spots/Contracts.ts +2 -1
  215. package/src/internal.ts +1 -0
  216. package/src/nest-integration.ts +1 -0
  217. package/src/runtime/actors/actor-client.ts +40 -16
  218. package/src/runtime/actors/actor-handoff.ts +22 -8
  219. package/src/runtime/actors/actor-join-relocation.ts +1 -0
  220. package/src/runtime/actors/actor-local-native-join.ts +17 -26
  221. package/src/runtime/actors/actor-remote-wire.ts +17 -0
  222. package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
  223. package/src/runtime/actors/actor-routed-json-request.ts +10 -2
  224. package/src/runtime/actors/index.ts +19 -5
  225. package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
  226. package/src/runtime/admission.ts +18 -5
  227. package/src/runtime/application-jobs/application-ingress-record-owner.ts +53 -27
  228. package/src/runtime/application-jobs/application-job-queue-scope.ts +56 -22
  229. package/src/runtime/application-jobs/contracts.ts +28 -2
  230. package/src/runtime/backend/contracts/index.ts +63 -32
  231. package/src/runtime/backend/mesh-completion-table.ts +175 -59
  232. package/src/runtime/backend/mesh-dispatch-pump.ts +59 -32
  233. package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
  234. package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -31
  235. package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
  236. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
  237. package/src/runtime/backend/node/node-raw-binding-port.ts +73 -37
  238. package/src/runtime/backend/node/node-raw-mesh-backend.ts +209 -176
  239. package/src/runtime/backend/node/node-socket-backend-adapter.ts +32 -13
  240. package/src/runtime/backend/raw-binding-port.ts +18 -3
  241. package/src/runtime/backend/runtime-message.ts +6 -0
  242. package/src/runtime/backend/runtime-values.ts +1 -0
  243. package/src/runtime/channels/channel-clients.ts +90 -41
  244. package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
  245. package/src/runtime/channels/channel-dispatch-services.ts +69 -1
  246. package/src/runtime/channels/channel-dispatchers.ts +29 -27
  247. package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
  248. package/src/runtime/channels/channel-envelope.ts +133 -8
  249. package/src/runtime/channels/channel-outbound-operations.ts +22 -8
  250. package/src/runtime/channels/channel-receive-loops.ts +3 -3
  251. package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
  252. package/src/runtime/channels/channel-runtime-manager.ts +29 -12
  253. package/src/runtime/channels/channel-socket-registry.ts +84 -130
  254. package/src/runtime/channels/channel-transports.ts +128 -60
  255. package/src/runtime/channels/local-spot-route-transport.ts +3 -1
  256. package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
  257. package/src/runtime/channels/source-spot-router.ts +8 -4
  258. package/src/runtime/channels/spot-node-route-transport.ts +8 -4
  259. package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
  260. package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
  261. package/src/runtime/diagnostics/message-flow.ts +1 -1
  262. package/src/runtime/execution/serial-execution-queue.ts +2 -0
  263. package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
  264. package/src/runtime/foundation/durable-service-request.ts +137 -0
  265. package/src/runtime/foundation/operation-identity.ts +5 -1
  266. package/src/runtime/foundation/raw-service-mesh-runtime.ts +642 -253
  267. package/src/runtime/foundation/service-liveness-registry.ts +68 -59
  268. package/src/runtime/foundation/service-mailbox.ts +7 -1
  269. package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
  270. package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
  271. package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
  272. package/src/runtime/foundation/service-stateful-runtime.ts +128 -160
  273. package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -84
  274. package/src/runtime/foundation/service-topology-registry.ts +103 -42
  275. package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
  276. package/src/runtime/handlers/handler-instance-scope.ts +67 -16
  277. package/src/runtime/host/actor-packet-relay.ts +7 -0
  278. package/src/runtime/host/actor-runtime-options-factory.ts +14 -2
  279. package/src/runtime/host/application-job-queue.ts +249 -48
  280. package/src/runtime/host/entry-actor-runtime.ts +5 -0
  281. package/src/runtime/host/index.ts +224 -160
  282. package/src/runtime/host/instance-activation-authority.ts +132 -27
  283. package/src/runtime/host/remote-bound-session-relay.ts +2 -23
  284. package/src/runtime/host/route-mesh-runtime.ts +1 -1
  285. package/src/runtime/host/service-relocation-control.ts +11 -5
  286. package/src/runtime/host/service-relocation-host-runtime.ts +317 -291
  287. package/src/runtime/host/spot-address-transport.ts +49 -24
  288. package/src/runtime/host/spot-runtime-options-factory.ts +4 -0
  289. package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
  290. package/src/runtime/locations/actor-location-claims.ts +52 -30
  291. package/src/runtime/locations/domain-store-contract.ts +6 -2
  292. package/src/runtime/locations/in-memory-authority-store.ts +113 -9
  293. package/src/runtime/locations/in-memory-location-store.ts +25 -3
  294. package/src/runtime/locations/internal-location-contracts.ts +4 -0
  295. package/src/runtime/locations/lifecycle.ts +8 -26
  296. package/src/runtime/locations/location-store-repository.ts +220 -15
  297. package/src/runtime/locations/resolvers.ts +25 -2
  298. package/src/runtime/locations/runtime.ts +28 -24
  299. package/src/runtime/messaging/framework-json-v1.ts +5 -325
  300. package/src/runtime/messaging/packet-name.ts +5 -25
  301. package/src/runtime/messaging/request-result.ts +58 -0
  302. package/src/runtime/messaging/submission-result.ts +7 -3
  303. package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
  304. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
  305. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +45 -23
  306. package/src/runtime/spots/index.ts +30 -2
  307. package/src/runtime/spots/spot-activation.ts +33 -10
  308. package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
  309. package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
  310. package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
  311. package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
  312. package/src/runtime/spots/spot-entry-activation.ts +12 -2
  313. package/src/runtime/spots/spot-handler-registry.ts +41 -8
  314. package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
  315. package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
  316. package/src/runtime/spots/spot-outbound.ts +36 -16
  317. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
  318. package/src/runtime/spots/spot-routing-internal.ts +14 -0
  319. package/src/runtime/spots/spot-runtime-ports.ts +3 -0
  320. package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
  321. package/src/runtime/spots/spot-timer.ts +5 -1
  322. package/src/runtime/streams/stream-session-runtime.ts +13 -30
@@ -1,6 +1,9 @@
1
+ import type { ApplicationJobOrigin } from '../application-jobs/contracts';
2
+ import { currentApplicationJobOrigin } from '../application-jobs/application-job-queue-scope';
1
3
  import { listAllMeshNodeDescriptors } from '../locations/location-store-pages';
2
4
  import { ZlinkStreamContentType } from '@zlink-systems/stream-wire';
3
5
  import { randomBytes, randomUUID } from 'node:crypto';
6
+ import { isDeepStrictEqual } from 'node:util';
4
7
  import {
5
8
  type ActorRef,
6
9
  type RoutingId,
@@ -242,7 +245,7 @@ export class ZLinkFrameworkRuntimeHost
242
245
  private readonly lifecycleSink?: string[];
243
246
  private executionState?: ZLinkFrameworkExecutionState;
244
247
  private runtimeState = ZLinkFrameworkRuntimeState.Preparing;
245
- private runtimeSequence = 0n;
248
+ private runtimeStatus?: ZLinkFrameworkRuntimeStatus;
246
249
  private readonly runtimeObservationSource = Symbol('zlink.framework-runtime');
247
250
  private runtimeDeadline?: Date;
248
251
  private shutdownDeadline?: AbortController;
@@ -332,24 +335,20 @@ export class ZLinkFrameworkRuntimeHost
332
335
  this.runtimeEventPublisher =
333
336
  options.runtimeEventPublisher ?? new DefaultZLinkRuntimeEventPublisher();
334
337
  this.metrics = new ZLinkRuntimeMetrics(options.registration.metrics?.meterProvider);
338
+ const handlerStartGate = options.providerResolver?.get?.(
339
+ ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE as unknown as Type<ZLinkInternalApplicationJobQueueHandlerStartGate>
340
+ );
335
341
  this.applicationJobQueue = new ApplicationJobQueue(
336
342
  resolveApplicationJobQueueConfiguration(options.registration.applicationJobQueue, () =>
337
343
  nodeEffectiveProcessorCount(options.registration.worker?.maxThreads)
338
344
  ),
339
345
  undefined,
340
- () => {
341
- try {
342
- return (
343
- this.options.providerResolver
344
- ?.get?.(
345
- ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE as unknown as Type<ZLinkInternalApplicationJobQueueHandlerStartGate>
346
- )
347
- ?.shouldHoldPermitBeforeHandler() === true
348
- );
349
- } catch {
350
- return false;
351
- }
352
- }
346
+ handlerStartGate?.shouldHoldPermitBeforeHandler.bind(handlerStartGate),
347
+ (error) =>
348
+ (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException(
349
+ 'logger-provider',
350
+ error
351
+ )
353
352
  );
354
353
  this.capacityStatus = new HostCapacityStatusProjection(
355
354
  options.registration.coreHwm,
@@ -721,13 +720,13 @@ export class ZLinkFrameworkRuntimeHost
721
720
  sessionRelocationWire: () => this.serviceRelocation,
722
721
  clearRemoteActorPacketTarget: (actorId) =>
723
722
  this.boundSessionRelay.clearRemoteActorPacketTarget(actorId),
724
- prepareApplicationJob: async (preparationSignal) => {
723
+ prepareApplicationJob: async (preparationSignal, origin) => {
725
724
  const runtimeSignal = this.executionState?.abortController.signal;
726
725
  const signal =
727
726
  runtimeSignal === undefined
728
727
  ? preparationSignal
729
728
  : AbortSignal.any([runtimeSignal, preparationSignal]);
730
- const permit = await this.applicationJobQueue.acquire(signal);
729
+ const permit = await this.applicationJobQueue.acquire(signal, origin);
731
730
  let state: 'ready' | 'running' | 'closed' = 'ready';
732
731
  let closedReason: unknown;
733
732
  let abort: (() => void) | undefined;
@@ -779,6 +778,7 @@ export class ZLinkFrameworkRuntimeHost
779
778
  this.serviceRelocation = new ZLinkHostServiceRelocationRuntime({
780
779
  registration: options.registration,
781
780
  targetAdmissionSealed: () => this.shutdownOperationStartedAt !== undefined,
781
+ sourceQuiescenceChanged: () => this.publishCurrentRuntimeStatus(),
782
782
  providerResolver: options.providerResolver,
783
783
  locationStore: () => this.locationOwner.currentStores?.locationStore,
784
784
  currentOwner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
@@ -869,6 +869,10 @@ export class ZLinkFrameworkRuntimeHost
869
869
  }
870
870
 
871
871
  get status(): ZLinkFrameworkRuntimeStatus {
872
+ return this.publishCurrentRuntimeStatus();
873
+ }
874
+
875
+ private buildRuntimeStatus(): ZLinkFrameworkRuntimeStatus {
872
876
  return {
873
877
  state: this.runtimeState,
874
878
  isReady: runtimeStateIsReady(this.runtimeState),
@@ -878,8 +882,8 @@ export class ZLinkFrameworkRuntimeHost
878
882
  deadline: this.runtimeDeadline,
879
883
  relocationResult: this.runtimeRelocationResult,
880
884
  terminationResult: this.runtimeTerminationResult,
881
- sequence: this.runtimeSequence,
882
- observedAt: new Date()
885
+ sequence: this.runtimeStatus?.sequence ?? 0n,
886
+ observedAt: this.runtimeStatus?.observedAt ?? new Date()
883
887
  };
884
888
  }
885
889
 
@@ -897,10 +901,11 @@ export class ZLinkFrameworkRuntimeHost
897
901
  }
898
902
 
899
903
  observe(signal?: AbortSignal): AsyncIterable<ZLinkObservedStatus<ZLinkFrameworkRuntimeStatus>> {
904
+ const status = this.status;
900
905
  const queue = new RuntimeEventQueue<ZLinkFrameworkRuntimeStatus>(undefined, signal);
901
906
  this.runtimeObservers.add(queue);
902
907
  queue.onClose(() => this.runtimeObservers.delete(queue));
903
- this.publishRuntimeStatus(queue, this.status);
908
+ this.publishRuntimeStatus(queue, status);
904
909
  return queue;
905
910
  }
906
911
 
@@ -1123,6 +1128,9 @@ export class ZLinkFrameworkRuntimeHost
1123
1128
  );
1124
1129
  const drain = await shutdown;
1125
1130
  await unscopedStreamDrain;
1131
+ if (drain.kind === 'forceStopped' && drain.error !== undefined) {
1132
+ this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('host shutdown', drain.error);
1133
+ }
1126
1134
  await this.stop();
1127
1135
  if (drain.kind === 'forceStopped') {
1128
1136
  return this.completeTermination({
@@ -1270,12 +1278,25 @@ export class ZLinkFrameworkRuntimeHost
1270
1278
  private setRuntimeState(state: ZLinkFrameworkRuntimeState): void {
1271
1279
  if (this.runtimeState === state) return;
1272
1280
  this.runtimeState = state;
1273
- this.runtimeSequence += 1n;
1274
1281
  this.notifyTopologyHostStateChanged();
1275
- const status = this.status;
1282
+ this.publishCurrentRuntimeStatus();
1283
+ }
1284
+
1285
+ private publishCurrentRuntimeStatus(): ZLinkFrameworkRuntimeStatus {
1286
+ const current = this.buildRuntimeStatus();
1287
+ if (this.runtimeStatus !== undefined && isDeepStrictEqual(this.runtimeStatus, current)) {
1288
+ return this.runtimeStatus;
1289
+ }
1290
+ const status = {
1291
+ ...current,
1292
+ sequence: (this.runtimeStatus?.sequence ?? 0n) + 1n,
1293
+ observedAt: new Date()
1294
+ };
1295
+ this.runtimeStatus = status;
1276
1296
  for (const observer of this.runtimeObservers) {
1277
1297
  this.publishRuntimeStatus(observer, status);
1278
1298
  }
1299
+ return status;
1279
1300
  }
1280
1301
 
1281
1302
  private publishRuntimeStatus(
@@ -1722,6 +1743,10 @@ export class ZLinkFrameworkRuntimeHost
1722
1743
  activationNode.registerAsyncInstanceActivationAuthority?.(
1723
1744
  new ZLinkInstanceActivationAuthority({
1724
1745
  store: locationStore,
1746
+ relocationPolicy: (stableType) =>
1747
+ this.options.registration.spotNodes.get(meshName)?.instanceSpotFactoryRegistrations?.[
1748
+ stableType
1749
+ ]?.relocation.kind,
1725
1750
  relocationStore: this.options.registration.locations.relocationStoreInstance,
1726
1751
  meshName,
1727
1752
  owner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
@@ -2235,6 +2260,9 @@ export class ZLinkFrameworkRuntimeHost
2235
2260
  });
2236
2261
  const coordinator = (this.userSpotCoordinator = new ZLinkUserSpotCreationCoordinator({
2237
2262
  store: locationStore,
2263
+ relocationPolicy: (meshName, stableType) =>
2264
+ this.options.registration.spotNodes.get(meshName)?.spotFactoryRegistrations?.[stableType]
2265
+ ?.relocation.kind,
2238
2266
  publishReadyRoute: (meshName, route) => {
2239
2267
  this.cachedLocationSpotRouteResolver?.invalidate?.(route.spot.spotId);
2240
2268
  this.spotNodeRuntime?.meshNode(meshName)?.rememberSpotRoute?.(route);
@@ -2757,6 +2785,7 @@ export class ZLinkFrameworkRuntimeHost
2757
2785
  },
2758
2786
  meshRecordDispatcher: (meshName: string, owner: ReadyRecord, record: ReceiveRecord) =>
2759
2787
  this.dispatchMeshRecord(
2788
+ currentApplicationJobOrigin,
2760
2789
  meshName,
2761
2790
  owner,
2762
2791
  record,
@@ -2766,12 +2795,68 @@ export class ZLinkFrameworkRuntimeHost
2766
2795
  };
2767
2796
  }
2768
2797
 
2769
- private async dispatchMeshRecord(
2798
+ private dispatchMeshNodeRecord(
2799
+ meshName: string,
2800
+ record: ReceiveRecord,
2801
+ signal?: AbortSignal
2802
+ ): void | Promise<void> {
2803
+ const control = this.serviceRelocation.tryHandleControl(meshName, record, signal);
2804
+ if (control instanceof Promise)
2805
+ return control.then((handled) =>
2806
+ handled ? undefined : this.dispatchMeshNodePayload(meshName, record, signal)
2807
+ );
2808
+ if (!control) return this.dispatchMeshNodePayload(meshName, record, signal);
2809
+ }
2810
+
2811
+ private dispatchMeshNodePayload(
2770
2812
  meshName: string,
2771
- owner: ReadyRecord,
2772
2813
  record: ReceiveRecord,
2773
2814
  signal?: AbortSignal
2815
+ ): void | Promise<void> {
2816
+ if (record.kind === ReceiveKind.NodeRequest && record.parts.length === 1) {
2817
+ const terminal = decodeRemoteActorSourceLeaveTerminal(record.parts[0]!.data());
2818
+ if (terminal !== undefined) {
2819
+ return this.completeFormalSourceLeave(record, terminal);
2820
+ }
2821
+ }
2822
+ const channelRuntime = this.channelRuntime;
2823
+ if (channelRuntime === undefined) {
2824
+ throw new ZLinkConfigurationException(
2825
+ 'MeshNode node-direct dispatch requires the channel runtime.'
2826
+ );
2827
+ }
2828
+ return channelRuntime.dispatchMeshRoute(meshName, record, signal);
2829
+ }
2830
+
2831
+ private async completeFormalSourceLeave(
2832
+ record: ReceiveRecord,
2833
+ terminal: NonNullable<ReturnType<typeof decodeRemoteActorSourceLeaveTerminal>>
2774
2834
  ): Promise<void> {
2835
+ const completed = await this.spotManager?.completeFormalSourceLeaveTerminal(
2836
+ terminal.actorId,
2837
+ terminal.transferId,
2838
+ terminal.succeeded
2839
+ );
2840
+ if (completed !== true) {
2841
+ throw new ZLinkConfigurationException(
2842
+ `Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`
2843
+ );
2844
+ }
2845
+ if (record.reply(Buffer.alloc(0)) !== SubmitResult.Ok) {
2846
+ throw new ZLinkConfigurationException(
2847
+ `Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`
2848
+ );
2849
+ }
2850
+ return;
2851
+ }
2852
+
2853
+ private dispatchMeshRecord(
2854
+ applicationJobOrigin: () => ApplicationJobOrigin,
2855
+ meshName: string,
2856
+ owner: ReadyRecord,
2857
+ record: ReceiveRecord,
2858
+ signal?: AbortSignal
2859
+ ): void | Promise<void> {
2775
2860
  if (record.operationKind === OperationKind.ActorJoin) {
2776
2861
  if (this.spotManager === undefined) {
2777
2862
  throw new ZLinkConfigurationException(
@@ -2780,107 +2865,8 @@ export class ZLinkFrameworkRuntimeHost
2780
2865
  }
2781
2866
  return this.spotManager.dispatchMeshActorJoin(meshName, owner, record);
2782
2867
  }
2783
- if (record.kind === ReceiveKind.ActorBinding) {
2784
- if (record.kindData?.kind !== 'actorBinding') {
2785
- throw new ZLinkConfigurationException(
2786
- 'MeshNode Actor binding record has no binding generation.'
2787
- );
2788
- }
2789
- const binding = record.kindData;
2790
- const replyBindingFailure = (kind: ZLinkFrameworkInternalErrorKind): void => {
2791
- const terminal = internalFrameworkWireReply(kind);
2792
- if (
2793
- record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== SubmitResult.Ok
2794
- ) {
2795
- throw new ZLinkConfigurationException(
2796
- `MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`
2797
- );
2798
- }
2799
- };
2800
- const replyBindingSuccess = (): void => {
2801
- if (record.reply(Buffer.alloc(0)) !== SubmitResult.Ok) {
2802
- throw new ZLinkConfigurationException(
2803
- `MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`
2804
- );
2805
- }
2806
- };
2807
- const state = this.actorManager?.getState(binding.actor.actorId);
2808
- const nativeActorRef = state?.nativeActorRef;
2809
- if (
2810
- state === undefined ||
2811
- nativeActorRef === undefined ||
2812
- nativeActorRef.actorId !== binding.actor.actorId ||
2813
- !routingIdsEqual(nativeActorRef.nodeRid, binding.actor.nodeRid)
2814
- ) {
2815
- replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2816
- return;
2817
- }
2818
- if (nativeActorRef.generation !== binding.actor.generation) {
2819
- replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
2820
- return;
2821
- }
2822
- const node =
2823
- state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
2824
- const localStatus = node?.status();
2825
- // ownsLocation tracks local cleanup responsibility, not Actor authority.
2826
- // A relocation target can exact-read committed authority without owning that cleanup.
2827
- if (
2828
- localStatus === undefined ||
2829
- !routingIdsEqual(localStatus.routingId, binding.actor.nodeRid) ||
2830
- localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
2831
- state.locationGeneration !== binding.authorityOwnerGeneration ||
2832
- state.isMoving
2833
- ) {
2834
- replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2835
- return;
2836
- }
2837
- const sessionOwnerIsLocal =
2838
- routingIdsEqual(localStatus.routingId, binding.sessionNodeRid) &&
2839
- localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
2840
- if (binding.transition === 'tombstone') {
2841
- const actorRef: ActorRef = {
2842
- actorId: binding.actor.actorId,
2843
- objectGeneration: binding.actor.generation,
2844
- meshName,
2845
- nodeRid: binding.actor.nodeRid
2846
- };
2847
- if (sessionOwnerIsLocal) {
2848
- releaseApplicationJobPermitBeforeHandler();
2849
- await this.streamBindingRuntime.retireRemoteBinding(
2850
- actorRef,
2851
- binding.sessionRid,
2852
- binding.bindingGeneration,
2853
- signal
2854
- );
2855
- }
2856
- state.retireBoundSessionBinding(binding);
2857
- replyBindingSuccess();
2858
- return;
2859
- }
2860
- const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(
2861
- binding.sessionNodeRid,
2862
- binding.sessionRid
2863
- );
2864
- if (target === undefined) {
2865
- replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2866
- return;
2867
- }
2868
- const installed = state.installBoundSessionBinding({
2869
- ...target,
2870
- sessionNodeRid: binding.sessionNodeRid,
2871
- sessionRid: binding.sessionRid,
2872
- sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
2873
- sessionOwnerId: binding.sessionOwnerId,
2874
- sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
2875
- bindingGeneration: binding.bindingGeneration
2876
- });
2877
- if (!installed) {
2878
- replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2879
- return;
2880
- }
2881
- replyBindingSuccess();
2882
- return Promise.resolve();
2883
- }
2868
+ if (record.kind === ReceiveKind.ActorBinding)
2869
+ return this.dispatchMeshActorBinding(meshName, record, signal);
2884
2870
  switch (record.kind) {
2885
2871
  case ReceiveKind.TransferControl:
2886
2872
  if (record.kindData?.kind !== 'transferControl') {
@@ -2903,41 +2889,11 @@ export class ZLinkFrameworkRuntimeHost
2903
2889
  }
2904
2890
  case ReceiveKind.NodeSend:
2905
2891
  case ReceiveKind.NodeRequest: {
2906
- return this.admission.run(meshName, 'RouteMesh node dispatch', async () => {
2907
- if (await this.serviceRelocation.tryHandleControl(meshName, record, signal)) {
2908
- return;
2909
- }
2910
- if (record.kind === ReceiveKind.NodeRequest && record.parts.length === 1) {
2911
- const terminal = decodeRemoteActorSourceLeaveTerminal(record.parts[0]!.data());
2912
- if (terminal !== undefined) {
2913
- if (
2914
- (await this.spotManager?.completeFormalSourceLeaveTerminal(
2915
- terminal.actorId,
2916
- terminal.transferId,
2917
- terminal.succeeded
2918
- )) !== true
2919
- ) {
2920
- throw new ZLinkConfigurationException(
2921
- `Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`
2922
- );
2923
- }
2924
- if (record.reply(Buffer.alloc(0)) !== SubmitResult.Ok) {
2925
- throw new ZLinkConfigurationException(
2926
- `Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`
2927
- );
2928
- }
2929
- return;
2930
- }
2931
- }
2932
- const channelRuntime = this.channelRuntime;
2933
- if (channelRuntime === undefined) {
2934
- throw new ZLinkConfigurationException(
2935
- 'MeshNode node-direct dispatch requires the channel runtime.'
2936
- );
2937
- }
2938
- return await channelRuntime.dispatchMeshRoute(meshName, record, signal);
2939
- });
2892
+ return this.admission.run(meshName, 'RouteMesh node dispatch', () =>
2893
+ this.dispatchMeshNodeRecord(meshName, record, signal)
2894
+ );
2940
2895
  }
2896
+
2941
2897
  case ReceiveKind.SpotSend:
2942
2898
  case ReceiveKind.SpotRequest:
2943
2899
  case ReceiveKind.SpotMulticast:
@@ -2968,7 +2924,7 @@ export class ZLinkFrameworkRuntimeHost
2968
2924
  );
2969
2925
  }
2970
2926
  return this.admission.run(meshName, 'RouteMesh Actor dispatch', () =>
2971
- this.spotManager!.dispatchMeshActor(meshName, owner, record)
2927
+ this.spotManager!.dispatchMeshActor(applicationJobOrigin(), meshName, owner, record)
2972
2928
  );
2973
2929
  case ReceiveKind.SendReady:
2974
2930
  return Promise.resolve();
@@ -2979,6 +2935,111 @@ export class ZLinkFrameworkRuntimeHost
2979
2935
  }
2980
2936
  }
2981
2937
 
2938
+ private async dispatchMeshActorBinding(
2939
+ meshName: string,
2940
+ record: ReceiveRecord,
2941
+ signal?: AbortSignal
2942
+ ): Promise<void> {
2943
+ if (record.kindData?.kind !== 'actorBinding') {
2944
+ throw new ZLinkConfigurationException(
2945
+ 'MeshNode Actor binding record has no binding generation.'
2946
+ );
2947
+ }
2948
+ const binding = record.kindData;
2949
+ const replyBindingFailure = (kind: ZLinkFrameworkInternalErrorKind): void => {
2950
+ const terminal = internalFrameworkWireReply(kind);
2951
+ if (
2952
+ record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== SubmitResult.Ok
2953
+ ) {
2954
+ throw new ZLinkConfigurationException(
2955
+ `MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`
2956
+ );
2957
+ }
2958
+ };
2959
+ const replyBindingSuccess = (): void => {
2960
+ if (record.reply(Buffer.alloc(0)) !== SubmitResult.Ok) {
2961
+ throw new ZLinkConfigurationException(
2962
+ `MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`
2963
+ );
2964
+ }
2965
+ };
2966
+ const state = this.actorManager?.getState(binding.actor.actorId);
2967
+ const nativeActorRef = state?.nativeActorRef;
2968
+ if (
2969
+ state === undefined ||
2970
+ nativeActorRef === undefined ||
2971
+ nativeActorRef.actorId !== binding.actor.actorId ||
2972
+ !routingIdsEqual(nativeActorRef.nodeRid, binding.actor.nodeRid)
2973
+ ) {
2974
+ replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2975
+ return;
2976
+ }
2977
+ if (nativeActorRef.generation !== binding.actor.generation) {
2978
+ replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
2979
+ return;
2980
+ }
2981
+ const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
2982
+ const localStatus = node?.status();
2983
+ // ownsLocation tracks local cleanup responsibility, not Actor authority.
2984
+ // A relocation target can exact-read committed authority without owning that cleanup.
2985
+ if (
2986
+ localStatus === undefined ||
2987
+ !routingIdsEqual(localStatus.routingId, binding.actor.nodeRid) ||
2988
+ localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
2989
+ state.locationGeneration !== binding.authorityOwnerGeneration ||
2990
+ state.isMoving
2991
+ ) {
2992
+ replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2993
+ return;
2994
+ }
2995
+ const sessionOwnerIsLocal =
2996
+ routingIdsEqual(localStatus.routingId, binding.sessionNodeRid) &&
2997
+ localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
2998
+ if (binding.transition === 'tombstone') {
2999
+ const actorRef: ActorRef = {
3000
+ actorId: binding.actor.actorId,
3001
+ objectGeneration: binding.actor.generation,
3002
+ meshName,
3003
+ nodeRid: binding.actor.nodeRid
3004
+ };
3005
+ if (sessionOwnerIsLocal) {
3006
+ releaseApplicationJobPermitBeforeHandler();
3007
+ await this.streamBindingRuntime.retireRemoteBinding(
3008
+ actorRef,
3009
+ binding.sessionRid,
3010
+ binding.bindingGeneration,
3011
+ signal
3012
+ );
3013
+ }
3014
+ state.retireBoundSessionBinding(binding);
3015
+ replyBindingSuccess();
3016
+ return;
3017
+ }
3018
+ const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(
3019
+ binding.sessionNodeRid,
3020
+ binding.sessionRid
3021
+ );
3022
+ if (target === undefined) {
3023
+ replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
3024
+ return;
3025
+ }
3026
+ const installed = state.installBoundSessionBinding({
3027
+ ...target,
3028
+ sessionNodeRid: binding.sessionNodeRid,
3029
+ sessionRid: binding.sessionRid,
3030
+ sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
3031
+ sessionOwnerId: binding.sessionOwnerId,
3032
+ sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
3033
+ bindingGeneration: binding.bindingGeneration
3034
+ });
3035
+ if (!installed) {
3036
+ replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
3037
+ return;
3038
+ }
3039
+ replyBindingSuccess();
3040
+ return Promise.resolve();
3041
+ }
3042
+
2982
3043
  private submitLocalMeshRoute(
2983
3044
  meshName: string,
2984
3045
  sourceNodeRid: string,
@@ -3012,7 +3073,10 @@ export class ZLinkFrameworkRuntimeHost
3012
3073
  try {
3013
3074
  state.taskRunner.runDetached('mesh-node-local-route-dispatch', async () => {
3014
3075
  try {
3015
- const permit = await this.applicationJobQueue.acquire(state.abortController.signal);
3076
+ const permit = await this.applicationJobQueue.acquire(
3077
+ state.abortController.signal,
3078
+ 'local'
3079
+ );
3016
3080
  permit.markApplicationQueued();
3017
3081
  await runWithApplicationJobPermit(permit, () =>
3018
3082
  channelRuntime.dispatchLocalMeshRoute(meshName, sourceNodeRid, ownedParts)