@zlink-systems/framework 0.30.0 → 0.30.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) 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/ZLinkEncodedPayload.d.ts +6 -0
  6. package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
  7. package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
  8. package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
  9. package/dist/contracts/Common/encoded-payload-storage.js +5 -2
  10. package/dist/contracts/Configuration/Builders.d.ts +1 -1
  11. package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
  12. package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
  13. package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
  14. package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
  15. package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
  16. package/dist/contracts/Handlers/Attributes.d.ts +5 -13
  17. package/dist/contracts/Handlers/Attributes.js +7 -11
  18. package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
  19. package/dist/contracts/Handlers/JsonContract.js +4 -153
  20. package/dist/contracts/Locations/Rows.d.ts +2 -0
  21. package/dist/contracts/Spots/Contracts.d.ts +6 -1
  22. package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
  23. package/dist/nest-integration.d.ts +1 -1
  24. package/dist/nest-integration.js +2 -1
  25. package/dist/runtime/abort.d.ts +5 -0
  26. package/dist/runtime/abort.js +10 -0
  27. package/dist/runtime/actors/actor-authority-publication.js +3 -2
  28. package/dist/runtime/actors/actor-client.d.ts +1 -2
  29. package/dist/runtime/actors/actor-client.js +52 -57
  30. package/dist/runtime/actors/actor-context.d.ts +2 -0
  31. package/dist/runtime/actors/actor-context.js +46 -9
  32. package/dist/runtime/actors/actor-handoff.d.ts +8 -4
  33. package/dist/runtime/actors/actor-handoff.js +219 -92
  34. package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
  35. package/dist/runtime/actors/actor-local-native-join.js +13 -12
  36. package/dist/runtime/actors/actor-mailbox.js +27 -1
  37. package/dist/runtime/actors/actor-remote-joiner.js +3 -1
  38. package/dist/runtime/actors/actor-remote-wire.js +15 -0
  39. package/dist/runtime/actors/actor-reply.d.ts +4 -0
  40. package/dist/runtime/actors/actor-reply.js +29 -0
  41. package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
  42. package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
  43. package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
  44. package/dist/runtime/actors/actor-runtime-state.js +2 -20
  45. package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
  46. package/dist/runtime/actors/index.d.ts +8 -3
  47. package/dist/runtime/actors/index.js +55 -27
  48. package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
  49. package/dist/runtime/actors/session-disconnected-wire.js +48 -0
  50. package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
  51. package/dist/runtime/admission.d.ts +9 -1
  52. package/dist/runtime/admission.js +56 -23
  53. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
  54. package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
  55. package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
  56. package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
  57. package/dist/runtime/application-jobs/contracts.d.ts +12 -1
  58. package/dist/runtime/backend/contracts/index.d.ts +37 -12
  59. package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
  60. package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
  61. package/dist/runtime/backend/mesh-completion-table.js +154 -49
  62. package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
  63. package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
  64. package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
  65. package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
  66. package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
  67. package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
  68. package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
  69. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
  70. package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
  71. package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
  72. package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
  73. package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
  74. package/dist/runtime/backend/runtime-message.d.ts +1 -0
  75. package/dist/runtime/backend/runtime-message.js +5 -0
  76. package/dist/runtime/backend/runtime-values.d.ts +1 -0
  77. package/dist/runtime/backend/runtime-values.js +2 -1
  78. package/dist/runtime/channels/channel-clients.d.ts +2 -0
  79. package/dist/runtime/channels/channel-clients.js +75 -23
  80. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
  81. package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
  82. package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
  83. package/dist/runtime/channels/channel-dispatch-services.js +45 -0
  84. package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
  85. package/dist/runtime/channels/channel-dispatchers.js +62 -54
  86. package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
  87. package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
  88. package/dist/runtime/channels/channel-envelope.d.ts +2 -0
  89. package/dist/runtime/channels/channel-envelope.js +146 -28
  90. package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
  91. package/dist/runtime/channels/channel-outbound-operations.js +8 -8
  92. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
  93. package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
  94. package/dist/runtime/channels/channel-runtime-manager.d.ts +9 -8
  95. package/dist/runtime/channels/channel-runtime-manager.js +16 -16
  96. package/dist/runtime/channels/channel-transports.d.ts +18 -16
  97. package/dist/runtime/channels/channel-transports.js +77 -58
  98. package/dist/runtime/channels/client-server-location-runtime.js +5 -4
  99. package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
  100. package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
  101. package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
  102. package/dist/runtime/channels/fanout-location-runtime.js +3 -3
  103. package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
  104. package/dist/runtime/channels/local-spot-route-transport.js +2 -1
  105. package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
  106. package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
  107. package/dist/runtime/channels/source-spot-router.d.ts +2 -2
  108. package/dist/runtime/channels/source-spot-router.js +4 -4
  109. package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
  110. package/dist/runtime/channels/spot-node-route-transport.js +4 -4
  111. package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
  112. package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
  113. package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
  114. package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
  115. package/dist/runtime/diagnostics/flow-context.js +19 -7
  116. package/dist/runtime/diagnostics/index.js +4 -9
  117. package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
  118. package/dist/runtime/diagnostics/message-flow.js +35 -5
  119. package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
  120. package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
  121. package/dist/runtime/execution/index.d.ts +4 -2
  122. package/dist/runtime/execution/index.js +33 -10
  123. package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
  124. package/dist/runtime/execution/serial-execution-queue.js +22 -2
  125. package/dist/runtime/execution/state-lane.d.ts +2 -0
  126. package/dist/runtime/execution/state-lane.js +5 -0
  127. package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
  128. package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
  129. package/dist/runtime/foundation/durable-service-request.js +98 -0
  130. package/dist/runtime/foundation/operation-identity.d.ts +1 -0
  131. package/dist/runtime/foundation/operation-identity.js +5 -1
  132. package/dist/runtime/foundation/operation-registry.d.ts +25 -1
  133. package/dist/runtime/foundation/operation-registry.js +86 -18
  134. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +61 -8
  135. package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
  136. package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
  137. package/dist/runtime/foundation/service-liveness-registry.js +38 -0
  138. package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
  139. package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
  140. package/dist/runtime/foundation/service-relocation-object-owner.d.ts +3 -3
  141. package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
  142. package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
  143. package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
  144. package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -1
  145. package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
  146. package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
  147. package/dist/runtime/foundation/service-stateful-registry.js +24 -26
  148. package/dist/runtime/foundation/service-stateful-runtime.d.ts +75 -9
  149. package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
  150. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
  151. package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
  152. package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
  153. package/dist/runtime/foundation/service-topology-registry.js +61 -27
  154. package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
  155. package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
  156. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  157. package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
  158. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +13 -3
  159. package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
  160. package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
  161. package/dist/runtime/handlers/handler-instance-scope.js +54 -11
  162. package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
  163. package/dist/runtime/host/actor-packet-relay.js +59 -72
  164. package/dist/runtime/host/actor-placement-coordinator.js +25 -8
  165. package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
  166. package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
  167. package/dist/runtime/host/actor-transfer-runtime.js +85 -331
  168. package/dist/runtime/host/application-job-queue.d.ts +40 -7
  169. package/dist/runtime/host/application-job-queue.js +137 -42
  170. package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
  171. package/dist/runtime/host/entry-actor-runtime.js +3 -0
  172. package/dist/runtime/host/index.d.ts +12 -2
  173. package/dist/runtime/host/index.js +300 -202
  174. package/dist/runtime/host/location-runtime-owner.js +2 -6
  175. package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
  176. package/dist/runtime/host/mesh-router-resolver.js +14 -6
  177. package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
  178. package/dist/runtime/host/remote-bound-session-relay.js +73 -208
  179. package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
  180. package/dist/runtime/host/route-mesh-runtime.js +6 -4
  181. package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
  182. package/dist/runtime/host/runtime-shutdown.js +3 -2
  183. package/dist/runtime/host/service-relocation-control.d.ts +1 -0
  184. package/dist/runtime/host/service-relocation-control.js +10 -4
  185. package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
  186. package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
  187. package/dist/runtime/host/spot-address-transport.js +3 -2
  188. package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
  189. package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
  190. package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
  191. package/dist/runtime/locations/actor-location-claims.js +34 -19
  192. package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
  193. package/dist/runtime/locations/auto-connect-loop.js +22 -14
  194. package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
  195. package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
  196. package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
  197. package/dist/runtime/locations/descriptor-publication.js +11 -0
  198. package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
  199. package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
  200. package/dist/runtime/locations/in-memory-authority-store.js +56 -19
  201. package/dist/runtime/locations/in-memory-location-store.js +1 -10
  202. package/dist/runtime/locations/index.d.ts +1 -0
  203. package/dist/runtime/locations/index.js +1 -0
  204. package/dist/runtime/locations/lease-tracker.js +1 -6
  205. package/dist/runtime/locations/lifecycle.d.ts +1 -2
  206. package/dist/runtime/locations/lifecycle.js +2 -5
  207. package/dist/runtime/locations/location-store-repository.d.ts +51 -1
  208. package/dist/runtime/locations/location-store-repository.js +363 -139
  209. package/dist/runtime/locations/relocation-blob.d.ts +18 -1
  210. package/dist/runtime/locations/relocation-blob.js +52 -1
  211. package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
  212. package/dist/runtime/locations/request-source-resolver.js +80 -0
  213. package/dist/runtime/locations/resolvers.js +1 -1
  214. package/dist/runtime/locations/runtime.d.ts +7 -3
  215. package/dist/runtime/locations/runtime.js +61 -53
  216. package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
  217. package/dist/runtime/messaging/framework-json-v1.js +38 -294
  218. package/dist/runtime/messaging/packet-name.d.ts +1 -1
  219. package/dist/runtime/messaging/packet-name.js +8 -24
  220. package/dist/runtime/messaging/payload-codec.d.ts +7 -1
  221. package/dist/runtime/messaging/payload-codec.js +7 -6
  222. package/dist/runtime/messaging/request-result.d.ts +2 -0
  223. package/dist/runtime/messaging/request-result.js +57 -0
  224. package/dist/runtime/messaging/submission-result.d.ts +1 -0
  225. package/dist/runtime/messaging/submission-result.js +5 -2
  226. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
  227. package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
  228. package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
  229. package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
  230. package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
  231. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
  232. package/dist/runtime/spots/index.d.ts +21 -11
  233. package/dist/runtime/spots/index.js +243 -178
  234. package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
  235. package/dist/runtime/spots/spot-activation-registry.js +21 -11
  236. package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
  237. package/dist/runtime/spots/spot-activation-state.js +7 -7
  238. package/dist/runtime/spots/spot-activation.d.ts +7 -3
  239. package/dist/runtime/spots/spot-activation.js +140 -52
  240. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
  241. package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
  242. package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
  243. package/dist/runtime/spots/spot-actor-membership.js +0 -8
  244. package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
  245. package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
  246. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
  247. package/dist/runtime/spots/spot-entry-activation.js +20 -11
  248. package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
  249. package/dist/runtime/spots/spot-handler-registry.js +24 -10
  250. package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
  251. package/dist/runtime/spots/spot-manager-public.js +2 -2
  252. package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
  253. package/dist/runtime/spots/spot-node-autoconnect.js +22 -42
  254. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
  255. package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
  256. package/dist/runtime/spots/spot-outbound.d.ts +3 -0
  257. package/dist/runtime/spots/spot-outbound.js +27 -18
  258. package/dist/runtime/spots/spot-remote-codec.js +5 -1
  259. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
  260. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
  261. package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
  262. package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
  263. package/dist/runtime/spots/spot-serial-executor.js +61 -8
  264. package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
  265. package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
  266. package/dist/runtime/spots/spot-timer.d.ts +57 -5
  267. package/dist/runtime/spots/spot-timer.js +288 -103
  268. package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
  269. package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
  270. package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
  271. package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
  272. package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
  273. package/dist/runtime/streams/bound-session-service.d.ts +1 -1
  274. package/dist/runtime/streams/bound-session-service.js +6 -11
  275. package/dist/runtime/streams/index.d.ts +3 -2
  276. package/dist/runtime/streams/index.js +6 -4
  277. package/dist/runtime/streams/managed-stream.js +3 -2
  278. package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
  279. package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
  280. package/dist/runtime/streams/session-actor-coordinator.js +15 -32
  281. package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
  282. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
  283. package/dist/runtime/streams/stream-session-runtime.js +14 -31
  284. package/dist/runtime/workers/index.js +1 -1
  285. package/package.json +3 -3
  286. package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
  287. package/src/contracts/Channels/Calls.ts +2 -1
  288. package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
  289. package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
  290. package/src/contracts/Common/encoded-payload-storage.ts +6 -3
  291. package/src/contracts/Configuration/Builders.ts +4 -1
  292. package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
  293. package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
  294. package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
  295. package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
  296. package/src/contracts/Handlers/Attributes.ts +14 -21
  297. package/src/contracts/Handlers/JsonContract.ts +8 -216
  298. package/src/contracts/Locations/Rows.ts +2 -0
  299. package/src/contracts/Spots/Contracts.ts +10 -1
  300. package/src/contracts/Spots/ZLinkSpot.ts +3 -3
  301. package/src/nest-integration.ts +1 -0
  302. package/src/runtime/abort.ts +12 -0
  303. package/src/runtime/actors/actor-authority-publication.ts +3 -2
  304. package/src/runtime/actors/actor-client.ts +100 -85
  305. package/src/runtime/actors/actor-context.ts +49 -9
  306. package/src/runtime/actors/actor-handoff.ts +291 -110
  307. package/src/runtime/actors/actor-join-relocation.ts +3 -0
  308. package/src/runtime/actors/actor-local-native-join.ts +21 -26
  309. package/src/runtime/actors/actor-mailbox.ts +40 -2
  310. package/src/runtime/actors/actor-remote-joiner.ts +6 -1
  311. package/src/runtime/actors/actor-remote-wire.ts +17 -0
  312. package/src/runtime/actors/actor-reply.ts +42 -0
  313. package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
  314. package/src/runtime/actors/actor-routed-json-request.ts +10 -2
  315. package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
  316. package/src/runtime/actors/actor-runtime-state.ts +2 -20
  317. package/src/runtime/actors/actor-source-transfer.ts +1 -34
  318. package/src/runtime/actors/index.ts +60 -32
  319. package/src/runtime/actors/session-disconnected-wire.ts +66 -0
  320. package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
  321. package/src/runtime/admission.ts +69 -21
  322. package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
  323. package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
  324. package/src/runtime/application-jobs/contracts.ts +16 -1
  325. package/src/runtime/backend/contracts/index.ts +92 -18
  326. package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
  327. package/src/runtime/backend/mesh-completion-table.ts +160 -57
  328. package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
  329. package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
  330. package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
  331. package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
  332. package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
  333. package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
  334. package/src/runtime/backend/raw-binding-port.ts +7 -2
  335. package/src/runtime/backend/runtime-message.ts +6 -0
  336. package/src/runtime/backend/runtime-values.ts +1 -0
  337. package/src/runtime/channels/channel-clients.ts +132 -58
  338. package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
  339. package/src/runtime/channels/channel-dispatch-services.ts +69 -1
  340. package/src/runtime/channels/channel-dispatchers.ts +136 -90
  341. package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
  342. package/src/runtime/channels/channel-envelope.ts +225 -31
  343. package/src/runtime/channels/channel-outbound-operations.ts +22 -8
  344. package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
  345. package/src/runtime/channels/channel-runtime-manager.ts +41 -17
  346. package/src/runtime/channels/channel-transports.ts +171 -112
  347. package/src/runtime/channels/client-server-location-runtime.ts +11 -10
  348. package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
  349. package/src/runtime/channels/fanout-location-runtime.ts +17 -9
  350. package/src/runtime/channels/local-spot-route-transport.ts +3 -1
  351. package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
  352. package/src/runtime/channels/source-spot-router.ts +8 -4
  353. package/src/runtime/channels/spot-node-route-transport.ts +8 -4
  354. package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
  355. package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
  356. package/src/runtime/diagnostics/flow-context.ts +20 -7
  357. package/src/runtime/diagnostics/index.ts +1 -7
  358. package/src/runtime/diagnostics/message-flow.ts +47 -9
  359. package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
  360. package/src/runtime/execution/index.ts +40 -14
  361. package/src/runtime/execution/serial-execution-queue.ts +33 -4
  362. package/src/runtime/execution/state-lane.ts +7 -0
  363. package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
  364. package/src/runtime/foundation/durable-service-request.ts +137 -0
  365. package/src/runtime/foundation/operation-identity.ts +5 -1
  366. package/src/runtime/foundation/operation-registry.ts +98 -20
  367. package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
  368. package/src/runtime/foundation/service-liveness-registry.ts +39 -0
  369. package/src/runtime/foundation/service-mailbox.ts +8 -0
  370. package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
  371. package/src/runtime/foundation/service-relocation-object-owner.ts +55 -36
  372. package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
  373. package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
  374. package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
  375. package/src/runtime/foundation/service-stateful-registry.ts +38 -35
  376. package/src/runtime/foundation/service-stateful-runtime.ts +732 -275
  377. package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
  378. package/src/runtime/foundation/service-topology-registry.ts +91 -36
  379. package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
  380. package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
  381. package/src/runtime/foundation/service-wire-m6a-codec.ts +231 -76
  382. package/src/runtime/handlers/handler-instance-scope.ts +67 -16
  383. package/src/runtime/host/actor-packet-relay.ts +113 -94
  384. package/src/runtime/host/actor-placement-coordinator.ts +31 -8
  385. package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
  386. package/src/runtime/host/actor-transfer-runtime.ts +104 -430
  387. package/src/runtime/host/application-job-queue.ts +160 -41
  388. package/src/runtime/host/entry-actor-runtime.ts +4 -0
  389. package/src/runtime/host/index.ts +473 -271
  390. package/src/runtime/host/location-runtime-owner.ts +2 -6
  391. package/src/runtime/host/mesh-router-resolver.ts +13 -5
  392. package/src/runtime/host/remote-bound-session-relay.ts +88 -271
  393. package/src/runtime/host/route-mesh-runtime.ts +12 -6
  394. package/src/runtime/host/runtime-shutdown.ts +15 -4
  395. package/src/runtime/host/service-relocation-control.ts +11 -5
  396. package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
  397. package/src/runtime/host/spot-address-transport.ts +4 -2
  398. package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
  399. package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
  400. package/src/runtime/locations/actor-location-claims.ts +52 -30
  401. package/src/runtime/locations/auto-connect-loop.ts +22 -14
  402. package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
  403. package/src/runtime/locations/auto-connect-types.ts +0 -1
  404. package/src/runtime/locations/descriptor-publication.ts +7 -0
  405. package/src/runtime/locations/domain-store-contract.ts +5 -0
  406. package/src/runtime/locations/in-memory-authority-store.ts +85 -23
  407. package/src/runtime/locations/in-memory-location-store.ts +1 -12
  408. package/src/runtime/locations/index.ts +1 -0
  409. package/src/runtime/locations/lease-tracker.ts +2 -9
  410. package/src/runtime/locations/lifecycle.ts +8 -26
  411. package/src/runtime/locations/location-store-repository.ts +628 -152
  412. package/src/runtime/locations/relocation-blob.ts +75 -1
  413. package/src/runtime/locations/request-source-resolver.ts +138 -0
  414. package/src/runtime/locations/resolvers.ts +2 -2
  415. package/src/runtime/locations/runtime.ts +98 -64
  416. package/src/runtime/messaging/framework-json-v1.ts +5 -325
  417. package/src/runtime/messaging/packet-name.ts +5 -25
  418. package/src/runtime/messaging/payload-codec.ts +8 -11
  419. package/src/runtime/messaging/request-result.ts +62 -0
  420. package/src/runtime/messaging/submission-result.ts +5 -1
  421. package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
  422. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
  423. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
  424. package/src/runtime/spots/index.ts +389 -283
  425. package/src/runtime/spots/spot-activation-registry.ts +25 -13
  426. package/src/runtime/spots/spot-activation-state.ts +12 -19
  427. package/src/runtime/spots/spot-activation.ts +198 -96
  428. package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
  429. package/src/runtime/spots/spot-actor-membership.ts +0 -15
  430. package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
  431. package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
  432. package/src/runtime/spots/spot-entry-activation.ts +33 -21
  433. package/src/runtime/spots/spot-handler-registry.ts +56 -12
  434. package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
  435. package/src/runtime/spots/spot-manager-public.ts +2 -2
  436. package/src/runtime/spots/spot-node-autoconnect.ts +28 -47
  437. package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
  438. package/src/runtime/spots/spot-outbound.ts +39 -19
  439. package/src/runtime/spots/spot-remote-codec.ts +9 -2
  440. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
  441. package/src/runtime/spots/spot-runtime-ports.ts +1 -1
  442. package/src/runtime/spots/spot-serial-executor.ts +97 -25
  443. package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
  444. package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
  445. package/src/runtime/spots/spot-timer.ts +418 -158
  446. package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
  447. package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
  448. package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
  449. package/src/runtime/streams/bound-session-service.ts +7 -10
  450. package/src/runtime/streams/index.ts +12 -6
  451. package/src/runtime/streams/managed-stream.ts +4 -2
  452. package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
  453. package/src/runtime/streams/session-actor-coordinator.ts +39 -88
  454. package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
  455. package/src/runtime/streams/stream-session-runtime.ts +13 -34
  456. package/src/runtime/workers/index.ts +1 -1
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZLinkUserSpotCreationCoordinator = exports.ZLinkHostSpotAddressTransport = exports.ZLinkRelocationStateIncompatibleError = exports.ZLinkRouteMeshRuntimeCoordinator = exports.ZLinkRetiringRollbackError = exports.ZLinkDrainingStatePublishError = exports.transferIdString = exports.ZLinkActorTransferAuthorityRuntime = exports.ZLinkFrameworkRuntimeHost = void 0;
4
4
  exports.hasUnsupportedManualTopology = hasUnsupportedManualTopology;
5
5
  exports.hasExactPeerReadiness = hasExactPeerReadiness;
6
+ const relocation_blob_1 = require("../locations/relocation-blob");
6
7
  const application_job_queue_scope_1 = require("../application-jobs/application-job-queue-scope");
7
8
  const location_store_pages_1 = require("../locations/location-store-pages");
9
+ const descriptor_publication_1 = require("../locations/descriptor-publication");
8
10
  const stream_wire_1 = require("@zlink-systems/stream-wire");
9
11
  const node_crypto_1 = require("node:crypto");
12
+ const node_util_1 = require("node:util");
10
13
  const contracts_1 = require("../../contracts");
11
14
  const ConfigurationException_1 = require("../../contracts/Configuration/ConfigurationException");
12
15
  const DiagnosticsValidation_1 = require("../../contracts/Configuration/DiagnosticsValidation");
@@ -19,6 +22,7 @@ const abort_1 = require("../abort");
19
22
  const activation_admission_1 = require("../activation-admission");
20
23
  const actors_1 = require("../actors");
21
24
  const actor_message_follow_context_1 = require("../actors/actor-message-follow-context");
25
+ const actor_packet_relay_wire_1 = require("../actors/actor-packet-relay-wire");
22
26
  const actor_transport_delivery_gate_1 = require("../actors/actor-transport-delivery-gate");
23
27
  const admission_1 = require("../admission");
24
28
  const application_job_queue_handler_start_gate_1 = require("../application-jobs/application-job-queue-handler-start-gate");
@@ -68,6 +72,8 @@ const spot_node_runtime_options_factory_1 = require("./spot-node-runtime-options
68
72
  const spot_runtime_options_factory_1 = require("./spot-runtime-options-factory");
69
73
  const stateful_authority_route_runtime_1 = require("./stateful-authority-route-runtime");
70
74
  const user_spot_creation_coordinator_1 = require("./user-spot-creation-coordinator");
75
+ const spot_remote_route_codec_1 = require("../spots/spot-remote-route-codec");
76
+ const protocol_1 = require("../streams/protocol");
71
77
  const HOST_SHUTDOWN_POLL_INTERVAL_MS = 100;
72
78
  const HANDOFF_ACCEPTANCE_POLL_INTERVAL_MS = 10;
73
79
  const DEFAULT_HOST_CONTROL_TIMEOUT_MS = 30_000;
@@ -77,7 +83,7 @@ class ZLinkFrameworkRuntimeHost {
77
83
  lifecycleSink;
78
84
  executionState;
79
85
  runtimeState = contracts_1.ZLinkFrameworkRuntimeState.Preparing;
80
- runtimeSequence = 0n;
86
+ runtimeStatus;
81
87
  runtimeObservationSource = Symbol('zlink.framework-runtime');
82
88
  runtimeDeadline;
83
89
  shutdownDeadline;
@@ -145,6 +151,7 @@ class ZLinkFrameworkRuntimeHost {
145
151
  routeMeshRuntime;
146
152
  clientServerRuntime;
147
153
  fanoutRuntime;
154
+ relocationStore;
148
155
  routeMeshCoordinator;
149
156
  constructor(options, internalOptions) {
150
157
  this.options = options;
@@ -153,16 +160,13 @@ class ZLinkFrameworkRuntimeHost {
153
160
  this.runtimeEventPublisher =
154
161
  options.runtimeEventPublisher ?? new diagnostics_1.DefaultZLinkRuntimeEventPublisher();
155
162
  this.metrics = new diagnostics_1.ZLinkRuntimeMetrics(options.registration.metrics?.meterProvider);
156
- this.applicationJobQueue = new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)(options.registration.applicationJobQueue, () => (0, application_job_queue_1.nodeEffectiveProcessorCount)(options.registration.worker?.maxThreads)), undefined, () => {
157
- try {
158
- return (this.options.providerResolver
159
- ?.get?.(application_job_queue_handler_start_gate_1.ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE)
160
- ?.shouldHoldPermitBeforeHandler() === true);
161
- }
162
- catch {
163
- return false;
164
- }
165
- }, (error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException('logger-provider', error));
163
+ const relocationProvider = options.registration.locations.relocationStoreInstance;
164
+ this.relocationStore =
165
+ relocationProvider === undefined
166
+ ? undefined
167
+ : new relocation_blob_1.ZLinkProviderRelocationRepository(relocationProvider, this.metrics);
168
+ const handlerStartGate = options.providerResolver?.get?.(application_job_queue_handler_start_gate_1.ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE);
169
+ this.applicationJobQueue = new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)(options.registration.applicationJobQueue, () => (0, application_job_queue_1.nodeEffectiveProcessorCount)(options.registration.worker?.maxThreads)), undefined, handlerStartGate?.shouldHoldPermitBeforeHandler.bind(handlerStartGate), (error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException('logger-provider', error));
166
170
  this.capacityStatus = new host_capacity_status_1.HostCapacityStatusProjection(options.registration.coreHwm, this.applicationJobQueue);
167
171
  this.clientServerRuntime = new topology_runtime_projections_1.ZLinkClientServerRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
168
172
  this.fanoutRuntime = new topology_runtime_projections_1.ZLinkFanoutRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
@@ -221,7 +225,7 @@ class ZLinkFrameworkRuntimeHost {
221
225
  : this.boundSessionRelay.actorPackets.confirmRemoteSessionBinding(actor, sessionNode.status().routingId, sessionRid, signal, options);
222
226
  },
223
227
  relay: (actor, header, payload) => this.boundSessionRelay.actorPackets.relayActorPacket(actor, header, payload),
224
- notifyDisconnected: (actor, signal) => this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(actor, signal)
228
+ notifyDisconnected: (actor, signal, binding) => this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(actor, signal, binding)
225
229
  });
226
230
  this.actorHandoff = new actors_1.ZLinkActorHandoffCoordinator({
227
231
  routedTransport: this.routeTransport,
@@ -437,20 +441,11 @@ class ZLinkFrameworkRuntimeHost {
437
441
  actorManager: () => this.actorManager,
438
442
  primaryMeshNode: () => this.requirePrimaryMeshNode(),
439
443
  notifyEntrySpotActorLeft: (actor, signal) => this.spotNodeRuntime?.notifyPrimaryEntrySpotActorLeft(actor, signal) ?? Promise.resolve(),
440
- restoreEntrySpotActorJoined: (actor, signal) => this.spotNodeRuntime?.notifyPrimaryEntrySpotActorJoined(actor, signal) ?? Promise.resolve(),
441
444
  locationLifecycle: () => this.locationOwner.currentLifecycle,
442
445
  spotRouteResolver: () => this.createLocationSpotRouteResolver(),
443
446
  actorHandoff: this.actorHandoff,
444
- actorTransferRegistry: this.actorTransferRegistry,
445
447
  authorityStore: () => this.locationOwner.currentStores?.locationStore,
446
448
  currentOwner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
447
- liveDescriptors: (meshName, signal) => {
448
- const runtime = this.locationOwner.currentRuntime;
449
- if (runtime === undefined) {
450
- throw new Error('Session owner liveness is unavailable without a Location runtime.');
451
- }
452
- return runtime.listLiveMeshNodes(meshName, signal);
453
- },
454
449
  sessionRelocationWire: () => this.serviceRelocation,
455
450
  clearRemoteActorPacketTarget: (actorId) => this.boundSessionRelay.clearRemoteActorPacketTarget(actorId),
456
451
  prepareApplicationJob: async (preparationSignal, origin) => {
@@ -502,13 +497,15 @@ class ZLinkFrameworkRuntimeHost {
502
497
  };
503
498
  },
504
499
  reportPostCommitError: (error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException('source actor departure', error),
505
- onSourceDepartureCompleted: (actorId) => this.publishActorHandoffEvent({ marker: 'source_cleanup', actorId }),
506
- shutdownSignal: () => this.executionState?.abortController.signal,
507
- metrics: this.metrics
500
+ shutdownSignal: () => this.executionState?.abortController.signal
508
501
  });
509
502
  this.serviceRelocation = new service_relocation_host_runtime_1.ZLinkHostServiceRelocationRuntime({
503
+ flowCreationEnabled: () => this.flowCreationEnabled(),
504
+ messageFlow: () => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow,
510
505
  registration: options.registration,
511
506
  targetAdmissionSealed: () => this.shutdownOperationStartedAt !== undefined,
507
+ requestPeerReconcile: (meshName, peerRid) => this.spotNodeRuntime?.requestPeerReconcile(meshName, peerRid) ?? Promise.resolve(),
508
+ sourceQuiescenceChanged: () => this.publishCurrentRuntimeStatus(),
512
509
  providerResolver: options.providerResolver,
513
510
  locationStore: () => this.locationOwner.currentStores?.locationStore,
514
511
  currentOwner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
@@ -518,11 +515,10 @@ class ZLinkFrameworkRuntimeHost {
518
515
  meshNode: (meshName) => this.spotNodeRuntime?.meshNode(meshName),
519
516
  completions: (meshName) => this.spotNodeRuntime?.meshCompletionTable(meshName),
520
517
  spotManager: () => this.spotManager,
521
- spotNodeRuntime: () => this.spotNodeRuntime,
522
518
  actorManager: () => this.actorManager,
523
519
  actorTransfer: this.actorTransferRuntime,
524
520
  boundSessionRelocation: {
525
- receiveSeal: (value, signal) => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationSeal(value, signal),
521
+ receiveSeal: (value, signal, onInstalled) => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationSeal(value, signal, onInstalled),
526
522
  receiveRoute: (value) => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationRoute(value),
527
523
  clear: () => this.boundSessionRelay.boundSessions.clearServiceWireSessionRelocations()
528
524
  },
@@ -573,7 +569,7 @@ class ZLinkFrameworkRuntimeHost {
573
569
  drainResources: (meshName, signal, stopStartingSignal) => this.performMeshDrain(meshName, signal, stopStartingSignal),
574
570
  shutdownResources: (meshName, signal) => this.performMeshShutdown(meshName, signal),
575
571
  cleanupHostResources: (signal) => this.cleanupOwnerForDrain(signal),
576
- forceStopResources: (meshName) => this.forceStopMesh(meshName)
572
+ forceStopResources: (meshName, reason, signal) => this.performMeshShutdown(meshName, signal, reason)
577
573
  });
578
574
  this.metricRegistrations.push(this.metrics.registerHostState(() => runtimeStateMetricName(this.runtimeState)), this.metrics.registerHostCapacity(() => this.capacityStatus.snapshot(this.context?.getCoreHwmBudgetSnapshot())), this.metrics.registerApplicationJobQueuePressure(() => this.applicationJobQueue.snapshot()), this.metrics.registerMeshSnapshots(() => this.runtimeMetricMeshSnapshots()));
579
575
  this.routeMeshRuntime = this.routeMeshCoordinator;
@@ -582,6 +578,9 @@ class ZLinkFrameworkRuntimeHost {
582
578
  return this.executionState !== undefined && !this.executionState.abortController.signal.aborted;
583
579
  }
584
580
  get status() {
581
+ return this.publishCurrentRuntimeStatus();
582
+ }
583
+ buildRuntimeStatus() {
585
584
  return {
586
585
  state: this.runtimeState,
587
586
  isReady: (0, runtime_state_projections_1.runtimeStateIsReady)(this.runtimeState),
@@ -591,8 +590,8 @@ class ZLinkFrameworkRuntimeHost {
591
590
  deadline: this.runtimeDeadline,
592
591
  relocationResult: this.runtimeRelocationResult,
593
592
  terminationResult: this.runtimeTerminationResult,
594
- sequence: this.runtimeSequence,
595
- observedAt: new Date()
593
+ sequence: this.runtimeStatus?.sequence ?? 0n,
594
+ observedAt: this.runtimeStatus?.observedAt ?? new Date()
596
595
  };
597
596
  }
598
597
  // Bound listener records of the current runtime generation.
@@ -605,10 +604,11 @@ class ZLinkFrameworkRuntimeHost {
605
604
  return { kind, name, endpoint, observedAt: new Date() };
606
605
  }
607
606
  observe(signal) {
607
+ const status = this.status;
608
608
  const queue = new runtime_observation_queue_1.RuntimeEventQueue(undefined, signal);
609
609
  this.runtimeObservers.add(queue);
610
610
  queue.onClose(() => this.runtimeObservers.delete(queue));
611
- this.publishRuntimeStatus(queue, this.status);
611
+ this.publishRuntimeStatus(queue, status);
612
612
  return queue;
613
613
  }
614
614
  resetCapacityMetrics() {
@@ -771,6 +771,9 @@ class ZLinkFrameworkRuntimeHost {
771
771
  const shutdown = this.routeMeshCoordinator.shutdownHost(this.runtimeDeadline, this.shutdownDeadline.signal);
772
772
  const drain = await shutdown;
773
773
  await unscopedStreamDrain;
774
+ if (drain.kind === 'forceStopped' && drain.error !== undefined) {
775
+ this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('host shutdown', drain.error);
776
+ }
774
777
  await this.stop();
775
778
  if (drain.kind === 'forceStopped') {
776
779
  return this.completeTermination({
@@ -892,12 +895,24 @@ class ZLinkFrameworkRuntimeHost {
892
895
  if (this.runtimeState === state)
893
896
  return;
894
897
  this.runtimeState = state;
895
- this.runtimeSequence += 1n;
896
898
  this.notifyTopologyHostStateChanged();
897
- const status = this.status;
899
+ this.publishCurrentRuntimeStatus();
900
+ }
901
+ publishCurrentRuntimeStatus() {
902
+ const current = this.buildRuntimeStatus();
903
+ if (this.runtimeStatus !== undefined && (0, node_util_1.isDeepStrictEqual)(this.runtimeStatus, current)) {
904
+ return this.runtimeStatus;
905
+ }
906
+ const status = {
907
+ ...current,
908
+ sequence: (this.runtimeStatus?.sequence ?? 0n) + 1n,
909
+ observedAt: new Date()
910
+ };
911
+ this.runtimeStatus = status;
898
912
  for (const observer of this.runtimeObservers) {
899
913
  this.publishRuntimeStatus(observer, status);
900
914
  }
915
+ return status;
901
916
  }
902
917
  publishRuntimeStatus(observer, status) {
903
918
  if ((0, runtime_state_projections_1.runtimeObservationIsTerminal)(status.state)) {
@@ -1003,7 +1018,6 @@ class ZLinkFrameworkRuntimeHost {
1003
1018
  let spotNodeRuntime;
1004
1019
  let streamRuntime;
1005
1020
  let startedLocationRuntime;
1006
- let statefulAuthorityRoutes;
1007
1021
  try {
1008
1022
  this.executionState = new execution_1.ZLinkFrameworkExecutionState(context);
1009
1023
  // Seed the shared live-mode cell from the configured mode (default errorsOnly).
@@ -1026,18 +1040,13 @@ class ZLinkFrameworkRuntimeHost {
1026
1040
  this.executionState.listenerTasks.push(...channelRuntime.start(this.executionState.taskRunner));
1027
1041
  const locationRuntime = await this.locationOwner.startForRuntime(this.meshRouters.primaryMeshName(), spotNodeRuntime, channelRuntime, this.executionState.abortController.signal, () => this.shutdownDeadline.signal);
1028
1042
  startedLocationRuntime = locationRuntime;
1029
- if (locationRuntime !== undefined) {
1030
- this.installOwnerLeaseRecoveryPublication(locationRuntime, spotNodeRuntime, channelRuntime);
1031
- }
1032
1043
  const locationStore = this.locationOwner.currentStores?.locationStore;
1033
1044
  if (locationStore !== undefined && locationRuntime?.ownerLeaseUsable !== false) {
1034
- await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Preparing, this.executionState.abortController.signal);
1035
- if (this.requiresStatefulAuthorityRuntime()) {
1036
- this.installLocationBackedAuthorities(locationStore, spotNodeRuntime);
1037
- statefulAuthorityRoutes = this.createStatefulAuthorityRoutes(locationStore, spotNodeRuntime);
1038
- await statefulAuthorityRoutes.start(this.executionState.abortController.signal);
1039
- this.statefulAuthorityRoutes = statefulAuthorityRoutes;
1040
- }
1045
+ await this.publishOrStayPreparing(locationRuntime, async (publishSignal) => {
1046
+ await spotNodeRuntime.startLocationAutoConnect(publishSignal);
1047
+ await channelRuntime.startLocationAutoConnect(publishSignal);
1048
+ await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Preparing, publishSignal);
1049
+ });
1041
1050
  }
1042
1051
  streamRuntime = new streams_1.ZLinkStreamRuntimeManager({
1043
1052
  listenerRecords,
@@ -1058,17 +1067,20 @@ class ZLinkFrameworkRuntimeHost {
1058
1067
  });
1059
1068
  streamRuntime.start();
1060
1069
  this.streamRuntime = streamRuntime;
1070
+ // Location runtime §5: a host without an owner lease stays Preparing;
1071
+ // owner lease recovery enters Serving once it publishes descriptors.
1061
1072
  if (locationRuntime === undefined || locationRuntime.ownerLeaseUsable) {
1062
- await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Serving, this.executionState.abortController.signal);
1073
+ await this.publishOrStayPreparing(locationRuntime, (publishSignal) => this.enterServing(spotNodeRuntime, publishSignal));
1074
+ }
1075
+ if (locationRuntime !== undefined) {
1076
+ this.installOwnerLeaseRecoveryPublication(locationRuntime, spotNodeRuntime, channelRuntime);
1063
1077
  }
1064
- this.routeMeshCoordinator.markServing();
1065
- this.setRuntimeState(contracts_1.ZLinkFrameworkRuntimeState.Serving);
1066
1078
  this.lifecycleSink?.push('framework:started');
1067
1079
  }
1068
1080
  catch (error) {
1069
1081
  if (this.shutdownDeadline !== undefined && (0, abort_1.isAbortError)(error))
1070
1082
  throw error;
1071
- await statefulAuthorityRoutes?.stop();
1083
+ await this.statefulAuthorityRoutes?.stop();
1072
1084
  try {
1073
1085
  await this.runWithShutdownDeadline(DEFAULT_HOST_CONTROL_TIMEOUT_MS, async () => (0, runtime_shutdown_1.rollbackRuntimeStart)({
1074
1086
  context,
@@ -1114,7 +1126,9 @@ class ZLinkFrameworkRuntimeHost {
1114
1126
  (options.pubSub?.manualConnections?.length ?? 0) > 0;
1115
1127
  const hasDiscovery = hasConfiguredLocationStore(this.options.registration);
1116
1128
  const source = hasManual && hasDiscovery ? 'manual_and_redis' : hasManual ? 'manual' : 'redis';
1117
- const emptyCapacity = { active: 0, reserved: 0, limit: 0 };
1129
+ const capacity = descriptor === undefined
1130
+ ? undefined
1131
+ : this.locationOwner.currentStores?.locationStore.confirmedCapacity?.({ meshName, rid: descriptor.rid }, descriptor.populationCapacity);
1118
1132
  snapshots.push({
1119
1133
  meshName,
1120
1134
  source,
@@ -1126,9 +1140,9 @@ class ZLinkFrameworkRuntimeHost {
1126
1140
  channelName: channel.channelName,
1127
1141
  readyMembers: channel.readyTargetCount
1128
1142
  })),
1129
- actorCapacity: descriptor?.populationCapacity.actors ?? emptyCapacity,
1130
- spotCapacity: descriptor?.populationCapacity.spots ?? emptyCapacity,
1131
- spotTypeCapacities: (descriptor?.populationCapacity.spotTypes ?? []).map((capacity) => ({
1143
+ actorCapacity: capacity?.actors,
1144
+ spotCapacity: capacity?.spots,
1145
+ spotTypeCapacities: (capacity?.spotTypes ?? []).map((capacity) => ({
1132
1146
  spotKind: capacity.objectKind === 'instance_spot' ? 'instance' : 'user',
1133
1147
  stableType: capacity.stableType,
1134
1148
  active: capacity.active,
@@ -1180,12 +1194,21 @@ class ZLinkFrameworkRuntimeHost {
1180
1194
  }
1181
1195
  }
1182
1196
  installOwnerLeaseRecoveryPublication(runtime, spotNodeRuntime, channelRuntime) {
1183
- const handler = () => {
1197
+ let recoveryOperation;
1198
+ const handler = (_renewal, wasOwnerLeaseUsable) => {
1184
1199
  if (!this.ownerAdmissionOpen())
1185
1200
  return;
1186
- void this.resumeOwnerLeaseOwnedWork(runtime, spotNodeRuntime, channelRuntime).catch((error) => {
1201
+ if (wasOwnerLeaseUsable && this.runtimeState !== contracts_1.ZLinkFrameworkRuntimeState.Preparing)
1202
+ return;
1203
+ if (recoveryOperation !== undefined)
1204
+ return;
1205
+ recoveryOperation = this.resumeOwnerLeaseOwnedWork(runtime, spotNodeRuntime, channelRuntime)
1206
+ .catch((error) => {
1187
1207
  runtime.closeOwnerLeaseAdmission(error);
1188
1208
  this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('owner lease recovery', error);
1209
+ })
1210
+ .finally(() => {
1211
+ recoveryOperation = undefined;
1189
1212
  });
1190
1213
  };
1191
1214
  this.ownerLeaseRecoveryRuntime = runtime;
@@ -1195,30 +1218,64 @@ class ZLinkFrameworkRuntimeHost {
1195
1218
  async resumeOwnerLeaseOwnedWork(runtime, spotNodeRuntime, channelRuntime) {
1196
1219
  if (!this.ownerAdmissionOpen())
1197
1220
  return;
1198
- const signal = this.executionState?.abortController.signal;
1199
- await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Preparing, signal);
1221
+ await this.publishOrStayPreparing(runtime, async (signal) => {
1222
+ await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Preparing, signal);
1223
+ if (runtime.ownerLeaseUsable === false)
1224
+ return;
1225
+ if (this.runtimeState !== contracts_1.ZLinkFrameworkRuntimeState.Preparing) {
1226
+ await spotNodeRuntime.publishMeshNodeState(this.runtimeState, signal);
1227
+ }
1228
+ await spotNodeRuntime.startLocationAutoConnect(signal);
1229
+ await channelRuntime.startLocationAutoConnect(signal);
1230
+ await channelRuntime.reclaimLocationOwnerRows(signal);
1231
+ await this.locationOwner.currentLifecycle?.reclaimOwnerRows();
1232
+ if (this.runtimeState === contracts_1.ZLinkFrameworkRuntimeState.Preparing) {
1233
+ await this.enterServing(spotNodeRuntime, signal);
1234
+ }
1235
+ });
1236
+ }
1237
+ // The one transition from Preparing to Serving: the host publishes its
1238
+ // Serving descriptors first, then takes new application work.
1239
+ async enterServing(spotNodeRuntime, signal) {
1200
1240
  const store = this.locationOwner.currentStores?.locationStore;
1201
- if (this.statefulAuthorityRoutes === undefined &&
1202
- store !== undefined &&
1203
- this.executionState !== undefined &&
1204
- this.requiresStatefulAuthorityRuntime()) {
1205
- const routes = this.createStatefulAuthorityRoutes(store, spotNodeRuntime);
1206
- await routes.start(signal);
1207
- this.statefulAuthorityRoutes = routes;
1208
- }
1209
- if (runtime.ownerLeaseUsable === false)
1241
+ if (store !== undefined) {
1242
+ await this.startStatefulAuthority(store, spotNodeRuntime, signal);
1243
+ }
1244
+ await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Serving, signal);
1245
+ this.routeMeshCoordinator.markServing();
1246
+ this.setRuntimeState(contracts_1.ZLinkFrameworkRuntimeState.Serving);
1247
+ }
1248
+ // Location runtime §5: a startup publication the Store does not confirm (a
1249
+ // provider error, or no answer within the renew timeout) leaves the host in
1250
+ // Preparing. The owner lease renewal handler retries publication while the
1251
+ // host stays Preparing; only a settled rejection fails startup.
1252
+ async publishOrStayPreparing(runtime, publish) {
1253
+ const signal = this.executionState?.abortController.signal;
1254
+ try {
1255
+ await publish(signal);
1256
+ return true;
1257
+ }
1258
+ catch (error) {
1259
+ if (runtime === undefined || !(error instanceof descriptor_publication_1.ZLinkDescriptorPublicationUnconfirmedError))
1260
+ throw error;
1261
+ this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('startup descriptor publication', error);
1262
+ return false;
1263
+ }
1264
+ }
1265
+ async startStatefulAuthority(locationStore, spotNodeRuntime, signal) {
1266
+ if (this.statefulAuthorityRoutes !== undefined || !this.requiresStatefulAuthorityRuntime()) {
1210
1267
  return;
1211
- await spotNodeRuntime.publishMeshNodeState(this.runtimeState, signal);
1212
- await spotNodeRuntime.startLocationAutoConnect(signal);
1213
- await channelRuntime.startLocationAutoConnect(signal);
1214
- await channelRuntime.reclaimLocationOwnerRows(signal);
1215
- await this.locationOwner.currentLifecycle?.reclaimOwnerRows();
1268
+ }
1269
+ this.installLocationBackedAuthorities(locationStore, spotNodeRuntime);
1270
+ const routes = this.createStatefulAuthorityRoutes(locationStore, spotNodeRuntime);
1271
+ await routes.start(signal);
1272
+ this.statefulAuthorityRoutes = routes;
1216
1273
  }
1217
1274
  createStatefulAuthorityRoutes(locationStore, spotNodeRuntime) {
1218
1275
  return new stateful_authority_route_runtime_1.ZLinkStatefulAuthorityRouteRuntime({
1219
1276
  store: locationStore,
1220
1277
  creationStore: locationStore,
1221
- relocationStore: this.options.registration.locations.relocationStoreInstance,
1278
+ relocationStore: this.relocationStore,
1222
1279
  meshNodes: spotNodeRuntime.meshNodesByName,
1223
1280
  pollingIntervalMs: this.options.registration.locations.options.pollingIntervalMs ??
1224
1281
  Locations_1.zlinkDefaultLocationOptions.pollingIntervalMs,
@@ -1247,7 +1304,7 @@ class ZLinkFrameworkRuntimeHost {
1247
1304
  activationNode.registerAsyncInstanceActivationAuthority?.(new instance_activation_authority_1.ZLinkInstanceActivationAuthority({
1248
1305
  store: locationStore,
1249
1306
  relocationPolicy: (stableType) => this.options.registration.spotNodes.get(meshName)?.instanceSpotFactoryRegistrations?.[stableType]?.relocation.kind,
1250
- relocationStore: this.options.registration.locations.relocationStoreInstance,
1307
+ relocationStore: this.relocationStore,
1251
1308
  meshName,
1252
1309
  owner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
1253
1310
  metrics: this.metrics,
@@ -1295,7 +1352,16 @@ class ZLinkFrameworkRuntimeHost {
1295
1352
  async performMeshDrain(meshName, signal, stopStartingSignal) {
1296
1353
  await this.serviceRelocation.relocateMesh(meshName, this.relocationTargetApplicationVersion, signal, stopStartingSignal);
1297
1354
  }
1298
- async performMeshShutdown(meshName, signal) {
1355
+ async performMeshShutdown(meshName, signal, forceReason) {
1356
+ if (forceReason !== undefined) {
1357
+ this.spotNodeRuntime
1358
+ ?.meshNode(meshName)
1359
+ ?.cancelPendingOperations?.((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown, 'The host stopped before the request completed.'));
1360
+ await waitForForcedSessionNotification(this.streamRuntime?.notifyServerDrain(meshName));
1361
+ }
1362
+ else {
1363
+ await awaitWithDrainSignal(this.serviceRelocation.drainActorJoinSources(meshName), signal);
1364
+ }
1299
1365
  await this.spotManager?.drainForShutdown(meshName, signal, this.runtimeDeadline);
1300
1366
  await awaitWithDrainSignal(this.streamRuntime?.notifyServerDrain(meshName), signal);
1301
1367
  }
@@ -1406,10 +1472,6 @@ class ZLinkFrameworkRuntimeHost {
1406
1472
  throw new locations_1.ZLinkOwnerCleanupError(error);
1407
1473
  }
1408
1474
  }
1409
- async forceStopMesh(meshName) {
1410
- await waitForForcedSessionNotification(this.streamRuntime?.notifyServerDrain(meshName));
1411
- await this.spotManager?.drainForShutdown(meshName, undefined, this.runtimeDeadline);
1412
- }
1413
1475
  registerInstanceApplicationLifecycle(meshName, node, spotManager) {
1414
1476
  const activationNode = node;
1415
1477
  activationNode.registerInstanceApplicationLifecycle?.({
@@ -1417,7 +1479,8 @@ class ZLinkFrameworkRuntimeHost {
1417
1479
  isMaterializing: (target) => spotManager.isInstanceMaterializing(meshName, target.targetSpotId),
1418
1480
  isIdleEvicting: (target) => spotManager.isInstanceSpotIdleEvicting(meshName, target.targetSpotId),
1419
1481
  beginIdleEviction: (target) => spotManager.beginInstanceSpotIdleEviction(meshName, target.targetSpotId),
1420
- materialize: (target, objectGeneration) => spotManager.materializeInstance(meshName, target.stableType, target.targetSpotId, objectGeneration, this.executionState?.abortController.signal),
1482
+ materialize: (target, objectGeneration) => spotManager.materializeInstance(meshName, target.stableType, target.targetSpotId, objectGeneration, this.executionState?.abortController.signal, 'first-terminal'),
1483
+ publish: (target) => spotManager.publishInstance(target, meshName),
1421
1484
  discard: (target) => spotManager.discardInstance(meshName, target.targetSpotId),
1422
1485
  beginTerminal: (target) => spotManager.beginInstanceTerminal(meshName, target.targetSpotId, target.objectGeneration),
1423
1486
  completeTerminal: (target) => spotManager.completeInstanceTerminal(meshName, target.targetSpotId, target.objectGeneration)
@@ -1554,8 +1617,8 @@ class ZLinkFrameworkRuntimeHost {
1554
1617
  descriptor.objectRole === 'server' &&
1555
1618
  descriptor.placementWeight > 0 &&
1556
1619
  descriptor.entrySpotId !== undefined &&
1557
- excludedNodeRids?.has(String(descriptor.rid)) !== true &&
1558
- capability !== undefined);
1620
+ excludedNodeRids?.has((0, routing_id_1.encodeRoutingIdStorageHex)(descriptor.rid)) !== true &&
1621
+ capability?.entryAccepted === true);
1559
1622
  });
1560
1623
  if (selected === undefined)
1561
1624
  return undefined;
@@ -1574,7 +1637,7 @@ class ZLinkFrameworkRuntimeHost {
1574
1637
  ownerId: selected.ownerId,
1575
1638
  leaseGeneration: selected.leaseGeneration
1576
1639
  },
1577
- isLocal: String(localStatus.routingId) === String(selected.rid) &&
1640
+ isLocal: (0, routing_id_1.routingIdsEqual)(localStatus.routingId, selected.rid) &&
1578
1641
  localStatus.lifecycleGeneration === selected.lifecycleGeneration
1579
1642
  };
1580
1643
  }
@@ -1636,7 +1699,7 @@ class ZLinkFrameworkRuntimeHost {
1636
1699
  return (descriptor.state === 1 &&
1637
1700
  descriptor.objectRole === 'server' &&
1638
1701
  descriptor.placementWeight > 0 &&
1639
- excludedNodeRids?.has(String(descriptor.rid)) !== true &&
1702
+ excludedNodeRids?.has((0, routing_id_1.encodeRoutingIdStorageHex)(descriptor.rid)) !== true &&
1640
1703
  (spots.limit === 0 || spots.active + spots.reserved < spots.limit) &&
1641
1704
  capability !== undefined &&
1642
1705
  (spotTypeCapacity === undefined ||
@@ -1655,7 +1718,7 @@ class ZLinkFrameworkRuntimeHost {
1655
1718
  leaseGeneration: selected.leaseGeneration
1656
1719
  },
1657
1720
  isLocal: localStatus !== undefined &&
1658
- String(localStatus.routingId) === String(selected.rid) &&
1721
+ (0, routing_id_1.routingIdsEqual)(localStatus.routingId, selected.rid) &&
1659
1722
  localStatus.lifecycleGeneration === selected.lifecycleGeneration
1660
1723
  };
1661
1724
  }
@@ -1737,6 +1800,13 @@ class ZLinkFrameworkRuntimeHost {
1737
1800
  throw new ConfigurationException_1.ZLinkConfigurationException('Actor placement target runtime is not initialized.');
1738
1801
  }
1739
1802
  return await actorPlacement.handleRemoteCreate(record, async (requestPayload, authority, createSignal) => {
1803
+ const registration = this.options.registration.spotNodes.get(meshName);
1804
+ if (registration === undefined ||
1805
+ !(0, spots_1.registrationAcceptsNewActor)(registration, record.stableType)) {
1806
+ // Framework failure before the callback (Actor model §6.3): the reservation is
1807
+ // cancelled and the requester excludes this host run.
1808
+ throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `RouteMesh '${meshName}' registers no Entry Spot type that accepts Actor type '${record.stableType}'.`);
1809
+ }
1740
1810
  const request = (0, creation_payload_codec_1.decodeFrameworkCreationPayload)(requestPayload, this.options.registration.messageSerializers);
1741
1811
  const entrySpotId = this.spotNodeRuntime?.meshNodeDescriptor(meshName)?.entrySpotId;
1742
1812
  if (entrySpotId === undefined) {
@@ -1768,7 +1838,7 @@ class ZLinkFrameworkRuntimeHost {
1768
1838
  };
1769
1839
  }
1770
1840
  if (local.actorRef.objectGeneration !== authority.objectGeneration ||
1771
- String(local.actorRef.nodeRid) !== record.reservation.targetNodeRid) {
1841
+ !(0, routing_id_1.routingIdsEqual)(local.actorRef.nodeRid, record.reservation.targetNodeRid)) {
1772
1842
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorCreateFailed, `Actor '${record.actorId}' native authority does not match its placement reservation.`);
1773
1843
  }
1774
1844
  let reply;
@@ -1821,7 +1891,7 @@ class ZLinkFrameworkRuntimeHost {
1821
1891
  },
1822
1892
  isLocalNode: (meshName, nodeRid) => {
1823
1893
  const status = this.spotNodeRuntime?.meshNode(meshName)?.status();
1824
- return status !== undefined && String(status.routingId) === String(nodeRid);
1894
+ return status !== undefined && (0, routing_id_1.routingIdsEqual)(status.routingId, nodeRid);
1825
1895
  },
1826
1896
  remoteClose: (meshName, targetNodeRid, request, timeoutMs) => {
1827
1897
  const node = this.spotNodeRuntime?.meshNode(meshName);
@@ -1969,92 +2039,45 @@ class ZLinkFrameworkRuntimeHost {
1969
2039
  activationConcurrency: (meshName) => this.activationAdmission.current(meshName)
1970
2040
  };
1971
2041
  }
1972
- async dispatchMeshRecord(applicationJobOrigin, meshName, owner, record, signal) {
2042
+ dispatchMeshNodeRecord(meshName, record, signal, admit) {
2043
+ const control = this.serviceRelocation.tryHandleControl(meshName, record, signal);
2044
+ if (control instanceof Promise)
2045
+ return control.then((handled) => handled ? undefined : this.dispatchMeshNodePayload(meshName, record, signal, admit));
2046
+ if (!control)
2047
+ return this.dispatchMeshNodePayload(meshName, record, signal, admit);
2048
+ }
2049
+ dispatchMeshNodePayload(meshName, record, signal, admit) {
2050
+ if (record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest && record.parts.length === 1) {
2051
+ const terminal = (0, actors_1.decodeRemoteActorSourceLeaveTerminal)(record.parts[0].data());
2052
+ if (terminal !== undefined) {
2053
+ return this.completeFormalSourceLeave(record, terminal);
2054
+ }
2055
+ }
2056
+ const channelRuntime = this.channelRuntime;
2057
+ if (channelRuntime === undefined) {
2058
+ throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode node-direct dispatch requires the channel runtime.');
2059
+ }
2060
+ return channelRuntime.dispatchMeshRoute(meshName, record, signal, admit);
2061
+ }
2062
+ async completeFormalSourceLeave(record, terminal) {
2063
+ const completed = await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded);
2064
+ if (completed !== true) {
2065
+ throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`);
2066
+ }
2067
+ if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
2068
+ throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`);
2069
+ }
2070
+ return;
2071
+ }
2072
+ dispatchMeshRecord(applicationJobOrigin, meshName, owner, record, signal) {
1973
2073
  if (record.operationKind === service_runtime_contracts_1.OperationKind.ActorJoin) {
1974
2074
  if (this.spotManager === undefined) {
1975
2075
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor join dispatch requires the Spot manager.');
1976
2076
  }
1977
2077
  return this.spotManager.dispatchMeshActorJoin(meshName, owner, record);
1978
2078
  }
1979
- if (record.kind === service_runtime_contracts_1.ReceiveKind.ActorBinding) {
1980
- if (record.kindData?.kind !== 'actorBinding') {
1981
- throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor binding record has no binding generation.');
1982
- }
1983
- const binding = record.kindData;
1984
- const replyBindingFailure = (kind) => {
1985
- const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(kind);
1986
- if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== runtime_values_1.SubmitResult.Ok) {
1987
- throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`);
1988
- }
1989
- };
1990
- const replyBindingSuccess = () => {
1991
- if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
1992
- throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`);
1993
- }
1994
- };
1995
- const state = this.actorManager?.getState(binding.actor.actorId);
1996
- const nativeActorRef = state?.nativeActorRef;
1997
- if (state === undefined ||
1998
- nativeActorRef === undefined ||
1999
- nativeActorRef.actorId !== binding.actor.actorId ||
2000
- !(0, routing_id_1.routingIdsEqual)(nativeActorRef.nodeRid, binding.actor.nodeRid)) {
2001
- replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2002
- return;
2003
- }
2004
- if (nativeActorRef.generation !== binding.actor.generation) {
2005
- replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
2006
- return;
2007
- }
2008
- const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
2009
- const localStatus = node?.status();
2010
- // ownsLocation tracks local cleanup responsibility, not Actor authority.
2011
- // A relocation target can exact-read committed authority without owning that cleanup.
2012
- if (localStatus === undefined ||
2013
- !(0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.actor.nodeRid) ||
2014
- localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
2015
- state.locationGeneration !== binding.authorityOwnerGeneration ||
2016
- state.isMoving) {
2017
- replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2018
- return;
2019
- }
2020
- const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
2021
- localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
2022
- if (binding.transition === 'tombstone') {
2023
- const actorRef = {
2024
- actorId: binding.actor.actorId,
2025
- objectGeneration: binding.actor.generation,
2026
- meshName,
2027
- nodeRid: binding.actor.nodeRid
2028
- };
2029
- if (sessionOwnerIsLocal) {
2030
- (0, application_job_queue_scope_2.releaseApplicationJobPermitBeforeHandler)();
2031
- await this.streamBindingRuntime.retireRemoteBinding(actorRef, binding.sessionRid, binding.bindingGeneration, signal);
2032
- }
2033
- state.retireBoundSessionBinding(binding);
2034
- replyBindingSuccess();
2035
- return;
2036
- }
2037
- const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(binding.sessionNodeRid, binding.sessionRid);
2038
- if (target === undefined) {
2039
- replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2040
- return;
2041
- }
2042
- const installed = state.installBoundSessionBinding({
2043
- ...target,
2044
- sessionNodeRid: binding.sessionNodeRid,
2045
- sessionRid: binding.sessionRid,
2046
- sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
2047
- sessionOwnerId: binding.sessionOwnerId,
2048
- sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
2049
- bindingGeneration: binding.bindingGeneration
2050
- });
2051
- if (!installed) {
2052
- replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2053
- return;
2054
- }
2055
- replyBindingSuccess();
2056
- return Promise.resolve();
2057
- }
2079
+ if (record.kind === service_runtime_contracts_1.ReceiveKind.ActorBinding)
2080
+ return this.dispatchMeshActorBinding(meshName, record, signal);
2058
2081
  switch (record.kind) {
2059
2082
  case service_runtime_contracts_1.ReceiveKind.TransferControl:
2060
2083
  if (record.kindData?.kind !== 'transferControl') {
@@ -2067,42 +2090,21 @@ class ZLinkFrameworkRuntimeHost {
2067
2090
  if (channelRuntime === undefined) {
2068
2091
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode channel dispatch requires the channel runtime.');
2069
2092
  }
2070
- return this.admission.run(meshName, 'RouteMesh channel dispatch', () => channelRuntime.dispatchMeshChannel(meshName, record, signal));
2093
+ return channelRuntime.dispatchMeshChannel(meshName, record, signal, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh channel dispatch', dispatch, onRejected));
2071
2094
  }
2072
2095
  case service_runtime_contracts_1.ReceiveKind.NodeSend:
2073
2096
  case service_runtime_contracts_1.ReceiveKind.NodeRequest: {
2074
- return this.admission.run(meshName, 'RouteMesh node dispatch', async () => {
2075
- if (await this.serviceRelocation.tryHandleControl(meshName, record, signal)) {
2076
- return;
2077
- }
2078
- if (record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest && record.parts.length === 1) {
2079
- const terminal = (0, actors_1.decodeRemoteActorSourceLeaveTerminal)(record.parts[0].data());
2080
- if (terminal !== undefined) {
2081
- if ((await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded)) !== true) {
2082
- throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`);
2083
- }
2084
- if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
2085
- throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`);
2086
- }
2087
- return;
2088
- }
2089
- }
2090
- const channelRuntime = this.channelRuntime;
2091
- if (channelRuntime === undefined) {
2092
- throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode node-direct dispatch requires the channel runtime.');
2093
- }
2094
- return await channelRuntime.dispatchMeshRoute(meshName, record, signal);
2095
- });
2097
+ return this.dispatchMeshNodeRecord(meshName, record, signal, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh node dispatch', dispatch, onRejected));
2096
2098
  }
2097
2099
  case service_runtime_contracts_1.ReceiveKind.SpotSend:
2098
2100
  case service_runtime_contracts_1.ReceiveKind.SpotRequest:
2099
2101
  case service_runtime_contracts_1.ReceiveKind.SpotMulticast:
2100
- return this.admission.run(meshName, 'RouteMesh Spot dispatch', () => this.dispatchMeshSpotRecord(meshName, owner, record));
2102
+ return this.dispatchMeshSpotRecord(meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Spot dispatch', dispatch, onRejected));
2101
2103
  case service_runtime_contracts_1.ReceiveKind.InstanceSpotActivation:
2102
2104
  if (this.spotManager === undefined) {
2103
2105
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Instance Spot dispatch requires the Spot manager.');
2104
2106
  }
2105
- return this.admission.run(meshName, 'RouteMesh Instance Spot dispatch', () => this.spotManager.dispatchMeshInstance(meshName, owner, record));
2107
+ return this.spotManager.dispatchMeshInstance(meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Instance Spot dispatch', dispatch, onRejected));
2106
2108
  case service_runtime_contracts_1.ReceiveKind.SpotControl:
2107
2109
  if (this.spotManager === undefined) {
2108
2110
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Spot control dispatch requires the Spot manager.');
@@ -2113,13 +2115,107 @@ class ZLinkFrameworkRuntimeHost {
2113
2115
  if (this.spotManager === undefined) {
2114
2116
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor dispatch requires the Spot manager.');
2115
2117
  }
2116
- return this.admission.run(meshName, 'RouteMesh Actor dispatch', () => this.spotManager.dispatchMeshActor(applicationJobOrigin(), meshName, owner, record));
2118
+ return this.spotManager.dispatchMeshActor(applicationJobOrigin(), meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Actor dispatch', dispatch, onRejected));
2117
2119
  case service_runtime_contracts_1.ReceiveKind.SendReady:
2118
2120
  return Promise.resolve();
2119
2121
  default:
2120
2122
  throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode record kind '${record.kind}' does not yet have a registered framework consumer.`);
2121
2123
  }
2122
2124
  }
2125
+ admitMeshDispatch(meshName, record, operation, dispatch, onRejected) {
2126
+ // Execution gate §13 and host relocation §14 keep control progress independent
2127
+ // of new application admission. Disconnect callbacks still use their owner gate.
2128
+ if (record.domain === service_runtime_contracts_1.ReadyDomain.Infrastructure)
2129
+ return dispatch();
2130
+ if (!this.admission.accepts(meshName) &&
2131
+ (record.kind === service_runtime_contracts_1.ReceiveKind.NodeSend ||
2132
+ record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest ||
2133
+ record.kind === service_runtime_contracts_1.ReceiveKind.SpotSend ||
2134
+ record.kind === service_runtime_contracts_1.ReceiveKind.SpotRequest)) {
2135
+ const relay = (0, spot_remote_route_codec_1.decodeRemoteActorPacketRelay)(record.parts, { serializers: this.options.registration.messageSerializers }, this.flowCreationEnabled());
2136
+ if (relay !== undefined &&
2137
+ (0, protocol_1.decodeStreamHeader)(Buffer.from(relay.header, 'base64'), this.flowCreationEnabled()).name ===
2138
+ actor_packet_relay_wire_1.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET) {
2139
+ return dispatch();
2140
+ }
2141
+ }
2142
+ return this.admission.run(meshName, operation, dispatch, onRejected);
2143
+ }
2144
+ async dispatchMeshActorBinding(meshName, record, signal) {
2145
+ if (record.kindData?.kind !== 'actorBinding') {
2146
+ throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor binding record has no binding generation.');
2147
+ }
2148
+ const binding = record.kindData;
2149
+ const replyBindingFailure = (kind) => {
2150
+ const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(kind);
2151
+ if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== runtime_values_1.SubmitResult.Ok) {
2152
+ throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`);
2153
+ }
2154
+ };
2155
+ const replyBindingSuccess = () => {
2156
+ if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
2157
+ throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`);
2158
+ }
2159
+ };
2160
+ const state = this.actorManager?.getState(binding.actor.actorId);
2161
+ const nativeActorRef = state?.nativeActorRef;
2162
+ if (state === undefined ||
2163
+ nativeActorRef === undefined ||
2164
+ nativeActorRef.actorId !== binding.actor.actorId ||
2165
+ !(0, routing_id_1.routingIdsEqual)(nativeActorRef.nodeRid, binding.actor.nodeRid)) {
2166
+ replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2167
+ return;
2168
+ }
2169
+ if (nativeActorRef.generation !== binding.actor.generation) {
2170
+ replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
2171
+ return;
2172
+ }
2173
+ const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
2174
+ const localStatus = node?.status();
2175
+ // ownsLocation tracks local cleanup responsibility, not Actor authority.
2176
+ // A relocation target can exact-read committed authority without owning that cleanup.
2177
+ if (localStatus === undefined ||
2178
+ !(0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.actor.nodeRid) ||
2179
+ localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
2180
+ state.locationGeneration !== binding.authorityOwnerGeneration ||
2181
+ state.isMoving) {
2182
+ replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2183
+ return;
2184
+ }
2185
+ const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
2186
+ localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
2187
+ if (binding.transition === 'tombstone') {
2188
+ const actorRef = {
2189
+ actorId: binding.actor.actorId,
2190
+ objectGeneration: binding.actor.generation,
2191
+ meshName,
2192
+ nodeRid: binding.actor.nodeRid
2193
+ };
2194
+ if (sessionOwnerIsLocal) {
2195
+ (0, application_job_queue_scope_2.releaseApplicationJobPermitBeforeHandler)();
2196
+ await this.streamBindingRuntime.retireRemoteBinding(actorRef, binding.sessionRid, binding.bindingGeneration, signal);
2197
+ }
2198
+ state.retireBoundSessionBinding(binding);
2199
+ replyBindingSuccess();
2200
+ return;
2201
+ }
2202
+ const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(binding.sessionNodeRid, binding.sessionRid);
2203
+ if (target === undefined) {
2204
+ replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
2205
+ return;
2206
+ }
2207
+ replyBindingSuccess();
2208
+ state.installBoundSessionBinding({
2209
+ ...target,
2210
+ sessionNodeRid: binding.sessionNodeRid,
2211
+ sessionRid: binding.sessionRid,
2212
+ sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
2213
+ sessionOwnerId: binding.sessionOwnerId,
2214
+ sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
2215
+ bindingGeneration: binding.bindingGeneration
2216
+ });
2217
+ return Promise.resolve();
2218
+ }
2123
2219
  submitLocalMeshRoute(meshName, sourceNodeRid, parts) {
2124
2220
  const state = this.executionState;
2125
2221
  const channelRuntime = this.channelRuntime;
@@ -2166,7 +2262,7 @@ class ZLinkFrameworkRuntimeHost {
2166
2262
  }
2167
2263
  return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
2168
2264
  }
2169
- async dispatchMeshSpotRecord(meshName, owner, record) {
2265
+ async dispatchMeshSpotRecord(meshName, owner, record, admit) {
2170
2266
  const envelope = (0, channel_envelope_1.decodeChannelEnvelope)(record.parts, undefined, this.flowCreationEnabled());
2171
2267
  if (envelope.packetName === actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET) {
2172
2268
  const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, {
@@ -2181,26 +2277,28 @@ class ZLinkFrameworkRuntimeHost {
2181
2277
  correlationId: envelope.header.correlationId ?? undefined
2182
2278
  };
2183
2279
  try {
2184
- const response = await this.boundSessionRelay.actorPackets.receiveRemoteActorPacketRelay(payload, context);
2185
- if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotRequest) {
2186
- record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response));
2187
- }
2280
+ const dispatch = async () => {
2281
+ const response = await this.boundSessionRelay.actorPackets.receiveRemoteActorPacketRelay(payload, context);
2282
+ if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotRequest)
2283
+ record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response));
2284
+ };
2285
+ await (admit === undefined ? dispatch() : admit(dispatch));
2188
2286
  }
2189
2287
  catch (error) {
2190
2288
  if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest) {
2191
2289
  throw error;
2192
2290
  }
2193
- record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error instanceof Error ? error.message : String(error)));
2291
+ record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error));
2194
2292
  }
2195
2293
  return;
2196
2294
  }
2197
- if ((await this.spotNodeRuntime?.dispatchEntrySpotRecord(meshName, owner, record)) === true) {
2295
+ if ((await this.spotNodeRuntime?.dispatchEntrySpotRecord(meshName, owner, record, admit)) === true) {
2198
2296
  return;
2199
2297
  }
2200
2298
  if (this.spotManager === undefined) {
2201
2299
  throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Spot dispatch requires the Spot manager.');
2202
2300
  }
2203
- await this.spotManager.dispatchMeshSpot(meshName, owner, record);
2301
+ await this.spotManager.dispatchMeshSpot(meshName, owner, record, admit);
2204
2302
  }
2205
2303
  createDispatchErrorReporter(errorSink) {
2206
2304
  const existing = this.dispatchErrorReporters.get(errorSink);
@@ -2231,7 +2329,7 @@ class ZLinkFrameworkRuntimeHost {
2231
2329
  const mode = this.executionState === undefined
2232
2330
  ? (this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors')
2233
2331
  : this.messageFlowModeCell.mode;
2234
- return mode !== 'off';
2332
+ return (0, diagnostics_1.messageFlowTracingEnabled)(mode);
2235
2333
  }
2236
2334
  runLifecycle(operation) {
2237
2335
  const current = (0, diagnostics_1.currentOrCreateFlow)('Lifecycle', false);
@@ -2300,7 +2398,7 @@ function hasConfiguredLocationStore(registration) {
2300
2398
  return (registration.locations.useInMemoryStores || registration.locations.storeInstance !== undefined);
2301
2399
  }
2302
2400
  function hasExactPeerReadiness(descriptors, local, peers) {
2303
- const replacementDescriptors = descriptors.filter((descriptor) => !(String(descriptor.rid) === String(local.routingId) &&
2401
+ const replacementDescriptors = descriptors.filter((descriptor) => !((0, routing_id_1.routingIdsEqual)(descriptor.rid, (0, routing_id_1.toBackendRoutingId)(local.routingId)) &&
2304
2402
  descriptor.lifecycleGeneration === local.lifecycleGeneration) &&
2305
2403
  descriptor.state === contracts_1.ZLinkFrameworkRuntimeState.Serving &&
2306
2404
  local.applicationVersion !== undefined &&
@@ -2309,7 +2407,7 @@ function hasExactPeerReadiness(descriptors, local, peers) {
2309
2407
  (local.maintenanceWave === undefined || descriptor.maintenanceWave !== local.maintenanceWave));
2310
2408
  return (replacementDescriptors.length > 0 &&
2311
2409
  replacementDescriptors.some((descriptor) => peers.some((peer) => peer.routingId !== null &&
2312
- String(peer.routingId) === String(descriptor.rid) &&
2410
+ (0, routing_id_1.routingIdsEqual)((0, routing_id_1.toBackendRoutingId)(peer.routingId), descriptor.rid) &&
2313
2411
  peer.lifecycleGeneration === descriptor.lifecycleGeneration &&
2314
2412
  peer.state === service_runtime_contracts_1.MeshPeerRuntimeState.Serving)));
2315
2413
  }
@@ -2476,7 +2574,7 @@ function isPlacementTargetReady(node, localStatus, descriptor) {
2476
2574
  if (node === undefined)
2477
2575
  return true;
2478
2576
  if (localStatus !== undefined &&
2479
- String(localStatus.routingId) === String(descriptor.rid) &&
2577
+ (0, routing_id_1.routingIdsEqual)(localStatus.routingId, descriptor.rid) &&
2480
2578
  localStatus.lifecycleGeneration === descriptor.lifecycleGeneration) {
2481
2579
  return true;
2482
2580
  }