@zlink-systems/framework 0.30.1 → 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 (340) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
  3. package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
  4. package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
  5. package/dist/contracts/Common/encoded-payload-storage.js +5 -2
  6. package/dist/contracts/Configuration/Builders.d.ts +1 -1
  7. package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
  8. package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
  9. package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
  10. package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
  11. package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
  12. package/dist/contracts/Locations/Rows.d.ts +2 -0
  13. package/dist/contracts/Spots/Contracts.d.ts +4 -0
  14. package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
  15. package/dist/runtime/abort.d.ts +5 -0
  16. package/dist/runtime/abort.js +10 -0
  17. package/dist/runtime/actors/actor-authority-publication.js +3 -2
  18. package/dist/runtime/actors/actor-client.d.ts +0 -1
  19. package/dist/runtime/actors/actor-client.js +38 -45
  20. package/dist/runtime/actors/actor-context.d.ts +2 -0
  21. package/dist/runtime/actors/actor-context.js +46 -9
  22. package/dist/runtime/actors/actor-handoff.d.ts +7 -3
  23. package/dist/runtime/actors/actor-handoff.js +212 -88
  24. package/dist/runtime/actors/actor-join-relocation.d.ts +2 -0
  25. package/dist/runtime/actors/actor-local-native-join.js +4 -0
  26. package/dist/runtime/actors/actor-mailbox.js +27 -1
  27. package/dist/runtime/actors/actor-remote-joiner.js +3 -1
  28. package/dist/runtime/actors/actor-reply.d.ts +4 -0
  29. package/dist/runtime/actors/actor-reply.js +29 -0
  30. package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
  31. package/dist/runtime/actors/actor-runtime-state.js +2 -20
  32. package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
  33. package/dist/runtime/actors/index.d.ts +6 -2
  34. package/dist/runtime/actors/index.js +37 -21
  35. package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
  36. package/dist/runtime/actors/session-disconnected-wire.js +48 -0
  37. package/dist/runtime/admission.d.ts +9 -1
  38. package/dist/runtime/admission.js +55 -32
  39. package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +13 -0
  40. package/dist/runtime/application-jobs/application-job-queue-scope.js +27 -1
  41. package/dist/runtime/application-jobs/contracts.d.ts +2 -0
  42. package/dist/runtime/backend/contracts/index.d.ts +19 -3
  43. package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
  44. package/dist/runtime/backend/mesh-completion-table.js +5 -0
  45. package/dist/runtime/backend/mesh-dispatch-pump.d.ts +26 -2
  46. package/dist/runtime/backend/mesh-dispatch-pump.js +193 -107
  47. package/dist/runtime/backend/node/node-raw-binding-port.js +90 -58
  48. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +33 -8
  49. package/dist/runtime/backend/node/node-raw-mesh-backend.js +142 -143
  50. package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
  51. package/dist/runtime/backend/node/node-socket-backend-adapter.js +5 -5
  52. package/dist/runtime/channels/channel-clients.d.ts +1 -0
  53. package/dist/runtime/channels/channel-clients.js +20 -5
  54. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +22 -3
  55. package/dist/runtime/channels/channel-dispatch-pipeline.js +103 -57
  56. package/dist/runtime/channels/channel-dispatchers.d.ts +3 -2
  57. package/dist/runtime/channels/channel-dispatchers.js +44 -37
  58. package/dist/runtime/channels/channel-envelope.d.ts +1 -0
  59. package/dist/runtime/channels/channel-envelope.js +74 -31
  60. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
  61. package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
  62. package/dist/runtime/channels/channel-runtime-manager.d.ts +3 -2
  63. package/dist/runtime/channels/channel-runtime-manager.js +4 -4
  64. package/dist/runtime/channels/channel-transports.d.ts +0 -1
  65. package/dist/runtime/channels/channel-transports.js +35 -33
  66. package/dist/runtime/channels/client-server-location-runtime.js +5 -4
  67. package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
  68. package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
  69. package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
  70. package/dist/runtime/channels/fanout-location-runtime.js +3 -3
  71. package/dist/runtime/diagnostics/flow-context.js +19 -7
  72. package/dist/runtime/diagnostics/index.js +4 -9
  73. package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
  74. package/dist/runtime/diagnostics/message-flow.js +35 -5
  75. package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
  76. package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
  77. package/dist/runtime/execution/index.d.ts +4 -2
  78. package/dist/runtime/execution/index.js +33 -10
  79. package/dist/runtime/execution/serial-execution-queue.d.ts +4 -0
  80. package/dist/runtime/execution/serial-execution-queue.js +21 -2
  81. package/dist/runtime/execution/state-lane.d.ts +2 -0
  82. package/dist/runtime/execution/state-lane.js +5 -0
  83. package/dist/runtime/foundation/operation-registry.d.ts +25 -1
  84. package/dist/runtime/foundation/operation-registry.js +86 -18
  85. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +39 -3
  86. package/dist/runtime/foundation/raw-service-mesh-runtime.js +151 -55
  87. package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
  88. package/dist/runtime/foundation/service-liveness-registry.js +38 -0
  89. package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
  90. package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
  91. package/dist/runtime/foundation/service-relocation-object-owner.d.ts +2 -3
  92. package/dist/runtime/foundation/service-relocation-object-owner.js +48 -35
  93. package/dist/runtime/foundation/service-relocation-runtime.js +7 -3
  94. package/dist/runtime/foundation/service-runtime-contracts.d.ts +8 -1
  95. package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
  96. package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
  97. package/dist/runtime/foundation/service-stateful-registry.js +24 -26
  98. package/dist/runtime/foundation/service-stateful-runtime.d.ts +72 -6
  99. package/dist/runtime/foundation/service-stateful-runtime.js +444 -117
  100. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -1
  101. package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
  102. package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
  103. package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
  104. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  105. package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
  106. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +10 -0
  107. package/dist/runtime/foundation/service-wire-m6a-codec.js +166 -53
  108. package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
  109. package/dist/runtime/host/actor-packet-relay.js +59 -72
  110. package/dist/runtime/host/actor-placement-coordinator.js +25 -8
  111. package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
  112. package/dist/runtime/host/actor-transfer-runtime.js +85 -331
  113. package/dist/runtime/host/application-job-queue.d.ts +24 -3
  114. package/dist/runtime/host/application-job-queue.js +28 -41
  115. package/dist/runtime/host/index.d.ts +5 -1
  116. package/dist/runtime/host/index.js +171 -97
  117. package/dist/runtime/host/location-runtime-owner.js +2 -6
  118. package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
  119. package/dist/runtime/host/mesh-router-resolver.js +14 -6
  120. package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
  121. package/dist/runtime/host/remote-bound-session-relay.js +71 -190
  122. package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
  123. package/dist/runtime/host/route-mesh-runtime.js +5 -3
  124. package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
  125. package/dist/runtime/host/runtime-shutdown.js +3 -2
  126. package/dist/runtime/host/service-relocation-host-runtime.d.ts +17 -7
  127. package/dist/runtime/host/service-relocation-host-runtime.js +550 -367
  128. package/dist/runtime/host/spot-runtime-options-factory.js +15 -7
  129. package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
  130. package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
  131. package/dist/runtime/locations/auto-connect-loop.js +22 -14
  132. package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
  133. package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
  134. package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
  135. package/dist/runtime/locations/descriptor-publication.js +11 -0
  136. package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
  137. package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
  138. package/dist/runtime/locations/in-memory-authority-store.js +56 -19
  139. package/dist/runtime/locations/in-memory-location-store.js +1 -10
  140. package/dist/runtime/locations/index.d.ts +1 -0
  141. package/dist/runtime/locations/index.js +1 -0
  142. package/dist/runtime/locations/lease-tracker.js +1 -6
  143. package/dist/runtime/locations/location-store-repository.d.ts +51 -1
  144. package/dist/runtime/locations/location-store-repository.js +363 -139
  145. package/dist/runtime/locations/relocation-blob.d.ts +18 -1
  146. package/dist/runtime/locations/relocation-blob.js +52 -1
  147. package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
  148. package/dist/runtime/locations/request-source-resolver.js +80 -0
  149. package/dist/runtime/locations/resolvers.js +1 -1
  150. package/dist/runtime/locations/runtime.d.ts +6 -2
  151. package/dist/runtime/locations/runtime.js +37 -30
  152. package/dist/runtime/messaging/payload-codec.d.ts +7 -1
  153. package/dist/runtime/messaging/payload-codec.js +7 -6
  154. package/dist/runtime/messaging/request-result.js +29 -26
  155. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +19 -1
  156. package/dist/runtime/protocol/service_wire_codec.generated.js +85 -0
  157. package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +7 -1
  158. package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +23 -7
  159. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +3 -2
  160. package/dist/runtime/spots/index.d.ts +18 -11
  161. package/dist/runtime/spots/index.js +234 -176
  162. package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
  163. package/dist/runtime/spots/spot-activation-registry.js +21 -11
  164. package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
  165. package/dist/runtime/spots/spot-activation-state.js +7 -7
  166. package/dist/runtime/spots/spot-activation.d.ts +6 -3
  167. package/dist/runtime/spots/spot-activation.js +123 -44
  168. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
  169. package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
  170. package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
  171. package/dist/runtime/spots/spot-actor-membership.js +0 -8
  172. package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
  173. package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
  174. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
  175. package/dist/runtime/spots/spot-entry-activation.js +14 -9
  176. package/dist/runtime/spots/spot-handler-registry.d.ts +4 -3
  177. package/dist/runtime/spots/spot-handler-registry.js +6 -2
  178. package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
  179. package/dist/runtime/spots/spot-manager-public.js +2 -2
  180. package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
  181. package/dist/runtime/spots/spot-node-autoconnect.js +18 -39
  182. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
  183. package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
  184. package/dist/runtime/spots/spot-outbound.js +3 -3
  185. package/dist/runtime/spots/spot-remote-codec.js +5 -1
  186. package/dist/runtime/spots/spot-runtime-ports.d.ts +0 -1
  187. package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
  188. package/dist/runtime/spots/spot-serial-executor.js +61 -8
  189. package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
  190. package/dist/runtime/spots/spot-subscription-dispatch.js +1 -1
  191. package/dist/runtime/spots/spot-timer.d.ts +57 -5
  192. package/dist/runtime/spots/spot-timer.js +287 -103
  193. package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
  194. package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
  195. package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
  196. package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
  197. package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
  198. package/dist/runtime/streams/bound-session-service.d.ts +1 -1
  199. package/dist/runtime/streams/bound-session-service.js +6 -11
  200. package/dist/runtime/streams/index.d.ts +3 -2
  201. package/dist/runtime/streams/index.js +6 -4
  202. package/dist/runtime/streams/managed-stream.js +3 -2
  203. package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
  204. package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
  205. package/dist/runtime/streams/session-actor-coordinator.js +15 -32
  206. package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
  207. package/dist/runtime/streams/stream-session-runtime.js +1 -4
  208. package/dist/runtime/workers/index.js +1 -1
  209. package/package.json +3 -3
  210. package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
  211. package/src/contracts/Common/encoded-payload-storage.ts +6 -3
  212. package/src/contracts/Configuration/Builders.ts +4 -1
  213. package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
  214. package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
  215. package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
  216. package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
  217. package/src/contracts/Locations/Rows.ts +2 -0
  218. package/src/contracts/Spots/Contracts.ts +8 -0
  219. package/src/contracts/Spots/ZLinkSpot.ts +3 -3
  220. package/src/runtime/abort.ts +12 -0
  221. package/src/runtime/actors/actor-authority-publication.ts +3 -2
  222. package/src/runtime/actors/actor-client.ts +61 -70
  223. package/src/runtime/actors/actor-context.ts +49 -9
  224. package/src/runtime/actors/actor-handoff.ts +282 -106
  225. package/src/runtime/actors/actor-join-relocation.ts +2 -0
  226. package/src/runtime/actors/actor-local-native-join.ts +4 -0
  227. package/src/runtime/actors/actor-mailbox.ts +40 -2
  228. package/src/runtime/actors/actor-remote-joiner.ts +6 -1
  229. package/src/runtime/actors/actor-reply.ts +42 -0
  230. package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
  231. package/src/runtime/actors/actor-runtime-state.ts +2 -20
  232. package/src/runtime/actors/actor-source-transfer.ts +1 -34
  233. package/src/runtime/actors/index.ts +41 -27
  234. package/src/runtime/actors/session-disconnected-wire.ts +66 -0
  235. package/src/runtime/admission.ts +69 -34
  236. package/src/runtime/application-jobs/application-job-queue-scope.ts +33 -1
  237. package/src/runtime/application-jobs/contracts.ts +2 -0
  238. package/src/runtime/backend/contracts/index.ts +39 -4
  239. package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
  240. package/src/runtime/backend/mesh-completion-table.ts +4 -0
  241. package/src/runtime/backend/mesh-dispatch-pump.ts +223 -124
  242. package/src/runtime/backend/node/node-raw-binding-port.ts +106 -70
  243. package/src/runtime/backend/node/node-raw-mesh-backend.ts +221 -170
  244. package/src/runtime/backend/node/node-socket-backend-adapter.ts +5 -5
  245. package/src/runtime/channels/channel-clients.ts +49 -24
  246. package/src/runtime/channels/channel-dispatch-pipeline.ts +173 -124
  247. package/src/runtime/channels/channel-dispatchers.ts +116 -72
  248. package/src/runtime/channels/channel-envelope.ts +105 -36
  249. package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
  250. package/src/runtime/channels/channel-runtime-manager.ts +12 -5
  251. package/src/runtime/channels/channel-transports.ts +49 -58
  252. package/src/runtime/channels/client-server-location-runtime.ts +11 -10
  253. package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
  254. package/src/runtime/channels/fanout-location-runtime.ts +17 -9
  255. package/src/runtime/diagnostics/flow-context.ts +20 -7
  256. package/src/runtime/diagnostics/index.ts +1 -7
  257. package/src/runtime/diagnostics/message-flow.ts +47 -9
  258. package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
  259. package/src/runtime/execution/index.ts +40 -14
  260. package/src/runtime/execution/serial-execution-queue.ts +31 -4
  261. package/src/runtime/execution/state-lane.ts +7 -0
  262. package/src/runtime/foundation/operation-registry.ts +98 -20
  263. package/src/runtime/foundation/raw-service-mesh-runtime.ts +244 -67
  264. package/src/runtime/foundation/service-liveness-registry.ts +39 -0
  265. package/src/runtime/foundation/service-mailbox.ts +8 -0
  266. package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
  267. package/src/runtime/foundation/service-relocation-object-owner.ts +54 -37
  268. package/src/runtime/foundation/service-relocation-runtime.ts +7 -3
  269. package/src/runtime/foundation/service-runtime-contracts.ts +12 -1
  270. package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
  271. package/src/runtime/foundation/service-stateful-registry.ts +38 -35
  272. package/src/runtime/foundation/service-stateful-runtime.ts +667 -152
  273. package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -11
  274. package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
  275. package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
  276. package/src/runtime/foundation/service-wire-m6a-codec.ts +187 -51
  277. package/src/runtime/host/actor-packet-relay.ts +113 -94
  278. package/src/runtime/host/actor-placement-coordinator.ts +31 -8
  279. package/src/runtime/host/actor-transfer-runtime.ts +104 -430
  280. package/src/runtime/host/application-job-queue.ts +29 -44
  281. package/src/runtime/host/index.ts +286 -129
  282. package/src/runtime/host/location-runtime-owner.ts +2 -6
  283. package/src/runtime/host/mesh-router-resolver.ts +13 -5
  284. package/src/runtime/host/remote-bound-session-relay.ts +86 -248
  285. package/src/runtime/host/route-mesh-runtime.ts +11 -5
  286. package/src/runtime/host/runtime-shutdown.ts +15 -4
  287. package/src/runtime/host/service-relocation-host-runtime.ts +784 -475
  288. package/src/runtime/host/spot-runtime-options-factory.ts +18 -7
  289. package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
  290. package/src/runtime/locations/auto-connect-loop.ts +22 -14
  291. package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
  292. package/src/runtime/locations/auto-connect-types.ts +0 -1
  293. package/src/runtime/locations/descriptor-publication.ts +7 -0
  294. package/src/runtime/locations/domain-store-contract.ts +5 -0
  295. package/src/runtime/locations/in-memory-authority-store.ts +85 -23
  296. package/src/runtime/locations/in-memory-location-store.ts +1 -12
  297. package/src/runtime/locations/index.ts +1 -0
  298. package/src/runtime/locations/lease-tracker.ts +2 -9
  299. package/src/runtime/locations/location-store-repository.ts +628 -152
  300. package/src/runtime/locations/relocation-blob.ts +75 -1
  301. package/src/runtime/locations/request-source-resolver.ts +138 -0
  302. package/src/runtime/locations/resolvers.ts +2 -2
  303. package/src/runtime/locations/runtime.ts +70 -40
  304. package/src/runtime/messaging/payload-codec.ts +8 -11
  305. package/src/runtime/messaging/request-result.ts +33 -29
  306. package/src/runtime/protocol/service_wire_codec.generated.ts +87 -4
  307. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +13 -10
  308. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +3 -2
  309. package/src/runtime/spots/index.ts +375 -281
  310. package/src/runtime/spots/spot-activation-registry.ts +25 -13
  311. package/src/runtime/spots/spot-activation-state.ts +12 -19
  312. package/src/runtime/spots/spot-activation.ts +170 -86
  313. package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
  314. package/src/runtime/spots/spot-actor-membership.ts +0 -15
  315. package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
  316. package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
  317. package/src/runtime/spots/spot-entry-activation.ts +24 -19
  318. package/src/runtime/spots/spot-handler-registry.ts +15 -4
  319. package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
  320. package/src/runtime/spots/spot-manager-public.ts +2 -2
  321. package/src/runtime/spots/spot-node-autoconnect.ts +22 -45
  322. package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
  323. package/src/runtime/spots/spot-outbound.ts +3 -3
  324. package/src/runtime/spots/spot-remote-codec.ts +9 -2
  325. package/src/runtime/spots/spot-runtime-ports.ts +0 -1
  326. package/src/runtime/spots/spot-serial-executor.ts +97 -25
  327. package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
  328. package/src/runtime/spots/spot-subscription-dispatch.ts +1 -1
  329. package/src/runtime/spots/spot-timer.ts +413 -157
  330. package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
  331. package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
  332. package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
  333. package/src/runtime/streams/bound-session-service.ts +7 -10
  334. package/src/runtime/streams/index.ts +12 -6
  335. package/src/runtime/streams/managed-stream.ts +4 -2
  336. package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
  337. package/src/runtime/streams/session-actor-coordinator.ts +39 -88
  338. package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
  339. package/src/runtime/streams/stream-session-runtime.ts +1 -5
  340. package/src/runtime/workers/index.ts +1 -1
@@ -212,6 +212,10 @@ export type SourceCleanupState = "pending" | "completed" | "sourceLeaseExpired";
212
212
  export declare function enumWireSourceCleanupState(value: SourceCleanupState): number;
213
213
  export declare function decodeSourceCleanupState(bytes: Uint8Array, context: ServiceWireDecoderContext): SourceCleanupState;
214
214
  export declare function encodeSourceCleanupState(value: SourceCleanupState, context: ServiceWireDecoderContext): Uint8Array;
215
+ export type SessionSealResult = "sealed" | "bindingAbsent";
216
+ export declare function enumWireSessionSealResult(value: SessionSealResult): number;
217
+ export declare function decodeSessionSealResult(bytes: Uint8Array, context: ServiceWireDecoderContext): SessionSealResult;
218
+ export declare function encodeSessionSealResult(value: SessionSealResult, context: ServiceWireDecoderContext): Uint8Array;
215
219
  export type ReplyRelayAckStatus = "terminalReceived" | "alreadyTerminal";
216
220
  export declare function enumWireReplyRelayAckStatus(value: ReplyRelayAckStatus): number;
217
221
  export declare function decodeReplyRelayAckStatus(bytes: Uint8Array, context: ServiceWireDecoderContext): ReplyRelayAckStatus;
@@ -1519,6 +1523,7 @@ export type RelocationPrepareCommand = {
1519
1523
  readonly payloadChunkCount: RelocationChunkCount;
1520
1524
  readonly payloadChecksumCrc32c: U32;
1521
1525
  readonly applicationVersion: ApplicationVersion;
1526
+ readonly deadlineUnixMs: NonzeroU64;
1522
1527
  };
1523
1528
  export declare function decodeRelocationPrepareCommand(frames: readonly Uint8Array[], context: ServiceWireDecoderContext): RelocationPrepareCommand;
1524
1529
  export declare function encodeRelocationPrepareCommand(value: RelocationPrepareCommand, context: ServiceWireDecoderContext): readonly Uint8Array[];
@@ -1536,6 +1541,8 @@ export type SessionRelocationSealCommand = {
1536
1541
  readonly sessionOwnerLeaseGeneration: NonzeroU64;
1537
1542
  readonly sessionRid: Rid;
1538
1543
  readonly bindingGeneration: NonzeroU64;
1544
+ readonly targetNodeRid: Rid;
1545
+ readonly targetNodeGeneration: NonzeroU64;
1539
1546
  };
1540
1547
  export declare function decodeSessionRelocationSealCommand(frames: readonly Uint8Array[], context: ServiceWireDecoderContext): SessionRelocationSealCommand;
1541
1548
  export declare function encodeSessionRelocationSealCommand(value: SessionRelocationSealCommand, context: ServiceWireDecoderContext): readonly Uint8Array[];
@@ -1552,6 +1559,7 @@ export type SessionRelocationSealedCommand = {
1552
1559
  readonly sessionOwnerLeaseGeneration: NonzeroU64;
1553
1560
  readonly sessionRid: Rid;
1554
1561
  readonly bindingGeneration: NonzeroU64;
1562
+ readonly sealResult: SessionSealResult;
1555
1563
  };
1556
1564
  export declare function decodeSessionRelocationSealedCommand(frames: readonly Uint8Array[], context: ServiceWireDecoderContext): SessionRelocationSealedCommand;
1557
1565
  export declare function encodeSessionRelocationSealedCommand(value: SessionRelocationSealedCommand, context: ServiceWireDecoderContext): readonly Uint8Array[];
@@ -1675,7 +1683,17 @@ export type RelocationFailedCommand = {
1675
1683
  export declare function decodeRelocationFailedCommand(frames: readonly Uint8Array[], context: ServiceWireDecoderContext): RelocationFailedCommand;
1676
1684
  export declare function encodeRelocationFailedCommand(value: RelocationFailedCommand, context: ServiceWireDecoderContext): readonly Uint8Array[];
1677
1685
  export declare function validateRelocationFailedCommandRuntimePredicates(value: any, context: ServiceWireDecoderContext): void;
1678
- export type ServiceWireCommand = HelloCommand | AdmitCommand | RejectCommand | UpdateCommand | LivenessProbeCommand | LivenessAckCommand | NodeSendCommand | NodeRequestCommand | ChannelSendCommand | ChannelRequestCommand | ReplyCommand | SpotSendCommand | SpotRequestCommand | LogicalMulticastCommand | ActorSendCommand | ActorRequestCommand | ActorLookupCommand | ActorDestroyCommand | ActorJoinCommand | ActorLeftCommand | RelocationReadyCommand | RelocationDataCommand | ReplyRelayCommand | RelocationCutoverCommand | BoundSessionSendCommand | ActorJoinedCommand | BoundSessionBindCommand | InstanceSpotCommand | RelocationPrepareCommand | SessionRelocationSealCommand | SessionRelocationSealedCommand | SessionRelocationRouteCommand | ReplyRelayAckCommand | UserSpotCreateCommand | UserSpotCloseCommand | ActorCreateCommand | MessageFollowCommand | BoundSessionReplacedCommand | RelocationStateCommand | RelocationFailedCommand;
1686
+ export type BoundSessionCloseCommand = {
1687
+ readonly command: "boundSessionClose";
1688
+ readonly flags: number;
1689
+ readonly correlation: NonzeroU64;
1690
+ readonly actor: ActorRef;
1691
+ readonly session: RetiredBoundSessionRouteFence;
1692
+ };
1693
+ export declare function decodeBoundSessionCloseCommand(frames: readonly Uint8Array[], context: ServiceWireDecoderContext): BoundSessionCloseCommand;
1694
+ export declare function encodeBoundSessionCloseCommand(value: BoundSessionCloseCommand, context: ServiceWireDecoderContext): readonly Uint8Array[];
1695
+ export declare function validateBoundSessionCloseCommandRuntimePredicates(value: any, context: ServiceWireDecoderContext): void;
1696
+ export type ServiceWireCommand = HelloCommand | AdmitCommand | RejectCommand | UpdateCommand | LivenessProbeCommand | LivenessAckCommand | NodeSendCommand | NodeRequestCommand | ChannelSendCommand | ChannelRequestCommand | ReplyCommand | SpotSendCommand | SpotRequestCommand | LogicalMulticastCommand | ActorSendCommand | ActorRequestCommand | ActorLookupCommand | ActorDestroyCommand | ActorJoinCommand | ActorLeftCommand | RelocationReadyCommand | RelocationDataCommand | ReplyRelayCommand | RelocationCutoverCommand | BoundSessionSendCommand | ActorJoinedCommand | BoundSessionBindCommand | InstanceSpotCommand | RelocationPrepareCommand | SessionRelocationSealCommand | SessionRelocationSealedCommand | SessionRelocationRouteCommand | ReplyRelayAckCommand | UserSpotCreateCommand | UserSpotCloseCommand | ActorCreateCommand | MessageFollowCommand | BoundSessionReplacedCommand | RelocationStateCommand | RelocationFailedCommand | BoundSessionCloseCommand;
1679
1697
  export declare function decodeAuthorityPayloadV1DurableFormat(bytes: Uint8Array, context: ServiceWireDecoderContext): AuthorityPayloadV1;
1680
1698
  export declare function encodeAuthorityPayloadV1DurableFormat(value: AuthorityPayloadV1, context: ServiceWireDecoderContext): Uint8Array;
1681
1699
  export declare function decodeInstanceActivationRecoveryV1DurableFormat(bytes: Uint8Array, context: ServiceWireDecoderContext): InstanceActivationRecoveryV1;
@@ -137,6 +137,9 @@ exports.encodeRelocationPhase = encodeRelocationPhase;
137
137
  exports.enumWireSourceCleanupState = enumWireSourceCleanupState;
138
138
  exports.decodeSourceCleanupState = decodeSourceCleanupState;
139
139
  exports.encodeSourceCleanupState = encodeSourceCleanupState;
140
+ exports.enumWireSessionSealResult = enumWireSessionSealResult;
141
+ exports.decodeSessionSealResult = decodeSessionSealResult;
142
+ exports.encodeSessionSealResult = encodeSessionSealResult;
140
143
  exports.enumWireReplyRelayAckStatus = enumWireReplyRelayAckStatus;
141
144
  exports.decodeReplyRelayAckStatus = decodeReplyRelayAckStatus;
142
145
  exports.encodeReplyRelayAckStatus = encodeReplyRelayAckStatus;
@@ -477,6 +480,9 @@ exports.validateRelocationStateCommandRuntimePredicates = validateRelocationStat
477
480
  exports.decodeRelocationFailedCommand = decodeRelocationFailedCommand;
478
481
  exports.encodeRelocationFailedCommand = encodeRelocationFailedCommand;
479
482
  exports.validateRelocationFailedCommandRuntimePredicates = validateRelocationFailedCommandRuntimePredicates;
483
+ exports.decodeBoundSessionCloseCommand = decodeBoundSessionCloseCommand;
484
+ exports.encodeBoundSessionCloseCommand = encodeBoundSessionCloseCommand;
485
+ exports.validateBoundSessionCloseCommandRuntimePredicates = validateBoundSessionCloseCommandRuntimePredicates;
480
486
  exports.decodeAuthorityPayloadV1DurableFormat = decodeAuthorityPayloadV1DurableFormat;
481
487
  exports.encodeAuthorityPayloadV1DurableFormat = encodeAuthorityPayloadV1DurableFormat;
482
488
  exports.decodeInstanceActivationRecoveryV1DurableFormat = decodeInstanceActivationRecoveryV1DurableFormat;
@@ -2721,6 +2727,32 @@ function writeSourceCleanupState(input, writer, context, enclosing, flags) {
2721
2727
  }
2722
2728
  function decodeSourceCleanupState(bytes, context) { const reader = new Reader(bytes); const value = readSourceCleanupState(reader, context, {}, 0); reader.done("source-cleanup-state"); return value; }
2723
2729
  function encodeSourceCleanupState(value, context) { const writer = new Writer(); writeSourceCleanupState(value, writer, context, {}, 0); return writer.result(); }
2730
+ function enumWireSessionSealResult(value) {
2731
+ switch (value) {
2732
+ case "sealed": return 1;
2733
+ case "bindingAbsent": return 2;
2734
+ }
2735
+ }
2736
+ function readSessionSealResult(reader, context, enclosing, flags) {
2737
+ void context;
2738
+ void enclosing;
2739
+ void flags;
2740
+ const raw = reader.u(1);
2741
+ switch (Number(raw)) {
2742
+ case 1: return "sealed";
2743
+ case 2: return "bindingAbsent";
2744
+ default: fail("session-seal-result enum");
2745
+ }
2746
+ }
2747
+ function writeSessionSealResult(input, writer, context, enclosing, flags) {
2748
+ void context;
2749
+ void enclosing;
2750
+ void flags;
2751
+ const value = input;
2752
+ writer.u(numeric(enumWireSessionSealResult(value)), 1);
2753
+ }
2754
+ function decodeSessionSealResult(bytes, context) { const reader = new Reader(bytes); const value = readSessionSealResult(reader, context, {}, 0); reader.done("session-seal-result"); return value; }
2755
+ function encodeSessionSealResult(value, context) { const writer = new Writer(); writeSessionSealResult(value, writer, context, {}, 0); return writer.result(); }
2724
2756
  function enumWireReplyRelayAckStatus(value) {
2725
2757
  switch (value) {
2726
2758
  case "terminalReceived": return 1;
@@ -10024,6 +10056,7 @@ function decodeRelocationPrepareCommand(frames, context) {
10024
10056
  value["payloadChunkCount"] = readRelocationChunkCount(reader, context, value, flags);
10025
10057
  value["payloadChecksumCrc32c"] = readU32(reader, context, value, flags);
10026
10058
  value["applicationVersion"] = readApplicationVersion(reader, context, value, flags);
10059
+ value["deadlineUnixMs"] = readNonzeroU64(reader, context, value, flags);
10027
10060
  reader.done("relocationPrepare");
10028
10061
  let frameIndex = 1;
10029
10062
  if (frameIndex !== frames.length)
@@ -10071,6 +10104,9 @@ function encodeRelocationPrepareCommand(value, context) {
10071
10104
  if (value["applicationVersion"] === undefined)
10072
10105
  fail("applicationVersion required");
10073
10106
  writeApplicationVersion(numeric(value["applicationVersion"]), writer, context, value, value.flags);
10107
+ if (value["deadlineUnixMs"] === undefined)
10108
+ fail("deadlineUnixMs required");
10109
+ writeNonzeroU64(numeric(value["deadlineUnixMs"]), writer, context, value, value.flags);
10074
10110
  const frames = [writer.result()];
10075
10111
  return frames;
10076
10112
  }
@@ -10095,6 +10131,8 @@ function decodeSessionRelocationSealCommand(frames, context) {
10095
10131
  value["sessionOwnerLeaseGeneration"] = readNonzeroU64(reader, context, value, flags);
10096
10132
  value["sessionRid"] = readRid(reader, context, value, flags);
10097
10133
  value["bindingGeneration"] = readNonzeroU64(reader, context, value, flags);
10134
+ value["targetNodeRid"] = readRid(reader, context, value, flags);
10135
+ value["targetNodeGeneration"] = readNonzeroU64(reader, context, value, flags);
10098
10136
  reader.done("sessionRelocationSeal");
10099
10137
  let frameIndex = 1;
10100
10138
  if (frameIndex !== frames.length)
@@ -10136,6 +10174,12 @@ function encodeSessionRelocationSealCommand(value, context) {
10136
10174
  if (value["bindingGeneration"] === undefined)
10137
10175
  fail("bindingGeneration required");
10138
10176
  writeNonzeroU64(numeric(value["bindingGeneration"]), writer, context, value, value.flags);
10177
+ if (value["targetNodeRid"] === undefined)
10178
+ fail("targetNodeRid required");
10179
+ writeRid(value["targetNodeRid"], writer, context, value, value.flags);
10180
+ if (value["targetNodeGeneration"] === undefined)
10181
+ fail("targetNodeGeneration required");
10182
+ writeNonzeroU64(numeric(value["targetNodeGeneration"]), writer, context, value, value.flags);
10139
10183
  const frames = [writer.result()];
10140
10184
  return frames;
10141
10185
  }
@@ -10159,6 +10203,7 @@ function decodeSessionRelocationSealedCommand(frames, context) {
10159
10203
  value["sessionOwnerLeaseGeneration"] = readNonzeroU64(reader, context, value, flags);
10160
10204
  value["sessionRid"] = readRid(reader, context, value, flags);
10161
10205
  value["bindingGeneration"] = readNonzeroU64(reader, context, value, flags);
10206
+ value["sealResult"] = readSessionSealResult(reader, context, value, flags);
10162
10207
  reader.done("sessionRelocationSealed");
10163
10208
  let frameIndex = 1;
10164
10209
  if (frameIndex !== frames.length)
@@ -10197,6 +10242,9 @@ function encodeSessionRelocationSealedCommand(value, context) {
10197
10242
  if (value["bindingGeneration"] === undefined)
10198
10243
  fail("bindingGeneration required");
10199
10244
  writeNonzeroU64(numeric(value["bindingGeneration"]), writer, context, value, value.flags);
10245
+ if (value["sealResult"] === undefined)
10246
+ fail("sealResult required");
10247
+ writeSessionSealResult(value["sealResult"], writer, context, value, value.flags);
10200
10248
  const frames = [writer.result()];
10201
10249
  return frames;
10202
10250
  }
@@ -10650,6 +10698,43 @@ function encodeRelocationFailedCommand(value, context) {
10650
10698
  return frames;
10651
10699
  }
10652
10700
  function validateRelocationFailedCommandRuntimePredicates(value, context) { void value; void context; }
10701
+ function decodeBoundSessionCloseCommand(frames, context) {
10702
+ if (!frames.length)
10703
+ fail("boundSessionClose frames");
10704
+ const reader = new Reader(frames[0]);
10705
+ if (Number(reader.u(1)) !== 90 || Number(reader.u(1)) !== 77 || Number(reader.u(1)) !== 1 || Number(reader.u(1)) !== 54)
10706
+ fail("boundSessionClose header");
10707
+ const flags = Number(reader.u(1));
10708
+ if ((flags & ~0) !== 0 || (flags & 0) !== 0)
10709
+ fail("boundSessionClose flags");
10710
+ const value = { command: "boundSessionClose", flags };
10711
+ value["correlation"] = readNonzeroU64(reader, context, value, flags);
10712
+ value["actor"] = readActorRef(reader, context, value, flags);
10713
+ value["session"] = readRetiredBoundSessionRouteFence(reader, context, value, flags);
10714
+ reader.done("boundSessionClose");
10715
+ let frameIndex = 1;
10716
+ if (frameIndex !== frames.length)
10717
+ fail("boundSessionClose frames");
10718
+ return value;
10719
+ }
10720
+ function encodeBoundSessionCloseCommand(value, context) {
10721
+ if ((value.flags & ~0) !== 0 || (value.flags & 0) !== 0)
10722
+ fail("boundSessionClose flags");
10723
+ const writer = new Writer();
10724
+ writer.put([90, 77, 1, 54, value.flags]);
10725
+ if (value["correlation"] === undefined)
10726
+ fail("correlation required");
10727
+ writeNonzeroU64(numeric(value["correlation"]), writer, context, value, value.flags);
10728
+ if (value["actor"] === undefined)
10729
+ fail("actor required");
10730
+ writeActorRef(value["actor"], writer, context, value, value.flags);
10731
+ if (value["session"] === undefined)
10732
+ fail("session required");
10733
+ writeRetiredBoundSessionRouteFence(value["session"], writer, context, value, value.flags);
10734
+ const frames = [writer.result()];
10735
+ return frames;
10736
+ }
10737
+ function validateBoundSessionCloseCommandRuntimePredicates(value, context) { void value; void context; }
10653
10738
  function decodeAuthorityPayloadV1DurableFormat(bytes, context) { if (bytes.length > 1048576)
10654
10739
  fail("authority-payload-v1 maximum"); const reader = new Reader(bytes); if (Number(reader.u(1)) !== 90 || Number(reader.u(1)) !== 76 || Number(reader.u(1)) !== 65 || Number(reader.u(1)) !== 85 || Number(reader.u(1)) !== 1)
10655
10740
  fail("authority-payload-v1 header"); const flags = readU16(reader, context, {}, 0); if (!same(flags, 0))
@@ -268,6 +268,7 @@ export interface RelocationPrepare40 {
268
268
  readonly payloadChunkCount: number;
269
269
  readonly payloadChecksumCrc32c: number;
270
270
  readonly applicationVersion: bigint;
271
+ readonly deadlineUnixMs: bigint;
271
272
  }
272
273
  export interface SessionRelocationSeal42 {
273
274
  readonly relocation: ServiceWireRelocationId;
@@ -280,8 +281,13 @@ export interface SessionRelocationSeal42 {
280
281
  readonly sessionOwnerLeaseGeneration: bigint;
281
282
  readonly sessionRid: Uint8Array;
282
283
  readonly bindingGeneration: bigint;
284
+ readonly targetNodeRid: Uint8Array;
285
+ readonly targetNodeGeneration: bigint;
283
286
  }
284
- export type SessionRelocationSealed43 = Omit<SessionRelocationSeal42, "senderRole">;
287
+ export type ServiceWireSessionSealResult = "sealed" | "bindingAbsent";
288
+ export type SessionRelocationSealed43 = Omit<SessionRelocationSeal42, "senderRole" | "targetNodeRid" | "targetNodeGeneration"> & {
289
+ readonly sealResult: ServiceWireSessionSealResult;
290
+ };
285
291
  export interface SessionRelocationRoute44 {
286
292
  readonly relocation: ServiceWireRelocationId;
287
293
  readonly coordinator: ServiceWireCoordinatorFence;
@@ -472,6 +472,20 @@ function decodeActorDestroy27(bytes) { const at = { value: 0 }; if (bytes.length
472
472
  throw new RangeError("actorDestroy header"); const correlation = read64(bytes, at); if (correlation === 0n)
473
473
  throw new RangeError("correlation"); const actor = readFence(bytes, at); if (at.value !== bytes.length)
474
474
  throw new RangeError("actorDestroy trailing"); return { correlation, actor }; }
475
+ function b3WriteSealResult(o, v) { switch (v) {
476
+ case "sealed":
477
+ o.push(1);
478
+ return;
479
+ case "bindingAbsent":
480
+ o.push(2);
481
+ return;
482
+ default: throw new RangeError("sealResult");
483
+ } }
484
+ function b3ReadSealResult(bytes, at) { switch (read8(bytes, at)) {
485
+ case 1: return "sealed";
486
+ case 2: return "bindingAbsent";
487
+ default: throw new RangeError("sealResult");
488
+ } }
475
489
  function b3Header(id) { return [90, 77, 1, id, 0]; }
476
490
  function b3ReadHeader(bytes, id, name) { const at = { value: 0 }; if (bytes.length < 5 || bytes[at.value++] !== 90 || bytes[at.value++] !== 77 || bytes[at.value++] !== 1 || bytes[at.value++] !== id || bytes[at.value++] !== 0)
477
491
  throw new RangeError(name + " header"); return at; }
@@ -597,10 +611,11 @@ function decodeRelocationState52(bytes) { const at = b3ReadHeader(bytes, 52, "re
597
611
  function encodeRelocationPrepare40(v) { const o = b3Header(40); b3WriteId(o, v.relocation, "relocation"); if (v.targetAttemptGeneration === 0n || v.sourceNodeGeneration === 0n)
598
612
  throw new RangeError("prepare"); u64(o, v.targetAttemptGeneration); b3WriteCoordinator(o, v.coordinator); b3WriteTarget(o, v.target); b3WriteRole(o, v.initiatorRole); if (v.initiatorRole !== "source")
599
613
  throw new RangeError("initiator role"); writeRelocationObject(o, v.object); rid(o, v.sourceNodeRid); u64(o, v.sourceNodeGeneration); if (v.payloadTotalLength < 0n || v.payloadTotalLength > 274877906944n || v.payloadChunkCount > 4096 || v.applicationVersion < 0n || v.applicationVersion > 9223372036854775807n)
600
- throw new RangeError("prepare bounds"); u64(o, v.payloadTotalLength); u32(o, v.payloadChunkCount); u32(o, v.payloadChecksumCrc32c); u64(o, v.applicationVersion); return Uint8Array.from(o); }
614
+ throw new RangeError("prepare bounds"); u64(o, v.payloadTotalLength); u32(o, v.payloadChunkCount); u32(o, v.payloadChecksumCrc32c); u64(o, v.applicationVersion); if (v.deadlineUnixMs === 0n)
615
+ throw new RangeError("deadline"); u64(o, v.deadlineUnixMs); return Uint8Array.from(o); }
601
616
  function decodeRelocationPrepare40(bytes) { const at = b3ReadHeader(bytes, 40, "relocationPrepare"), relocation = b3ReadId(bytes, at, "relocation"), targetAttemptGeneration = nonzero64(bytes, at, "target attempt"), coordinator = b3ReadCoordinator(bytes, at), target = b3ReadTarget(bytes, at), initiatorRole = b3ReadRole(bytes, at); if (initiatorRole !== "source")
602
- throw new RangeError("initiator role"); const object = readRelocationObject(bytes, at), sourceNodeRid = readRid(bytes, at), sourceNodeGeneration = nonzero64(bytes, at, "source node"), payloadTotalLength = read64(bytes, at), payloadChunkCount = read32(bytes, at), payloadChecksumCrc32c = read32(bytes, at), applicationVersion = read64(bytes, at); if (payloadTotalLength > 274877906944n || payloadChunkCount > 4096 || applicationVersion > 9223372036854775807n)
603
- throw new RangeError("prepare bounds"); b3Finish(at, bytes, "relocationPrepare"); return { relocation, targetAttemptGeneration, coordinator, target, initiatorRole, object, sourceNodeRid, sourceNodeGeneration, payloadTotalLength, payloadChunkCount, payloadChecksumCrc32c, applicationVersion }; }
617
+ throw new RangeError("initiator role"); const object = readRelocationObject(bytes, at), sourceNodeRid = readRid(bytes, at), sourceNodeGeneration = nonzero64(bytes, at, "source node"), payloadTotalLength = read64(bytes, at), payloadChunkCount = read32(bytes, at), payloadChecksumCrc32c = read32(bytes, at), applicationVersion = read64(bytes, at), deadlineUnixMs = nonzero64(bytes, at, "deadline"); if (payloadTotalLength > 274877906944n || payloadChunkCount > 4096 || applicationVersion > 9223372036854775807n)
618
+ throw new RangeError("prepare bounds"); b3Finish(at, bytes, "relocationPrepare"); return { relocation, targetAttemptGeneration, coordinator, target, initiatorRole, object, sourceNodeRid, sourceNodeGeneration, payloadTotalLength, payloadChunkCount, payloadChecksumCrc32c, applicationVersion, deadlineUnixMs }; }
604
619
  function b3WriteSealBase(o, v, includeRole) { b3WriteId(o, v.relocation, "relocation"); b3WriteCoordinator(o, v.coordinator); if (includeRole) {
605
620
  const role = v.senderRole;
606
621
  b3WriteRole(o, role);
@@ -612,10 +627,11 @@ function b3ReadSealBase(bytes, at, includeRole) { const relocation = b3ReadId(by
612
627
  if (senderRole !== "source")
613
628
  throw new RangeError("sender role");
614
629
  } const actor = readFence(bytes, at), session = b3ReadSession(bytes, at); return senderRole === undefined ? { relocation, coordinator, actor, ...session } : { relocation, coordinator, senderRole, actor, ...session }; }
615
- function encodeSessionRelocationSeal42(v) { const o = b3Header(42); b3WriteSealBase(o, v, true); return Uint8Array.from(o); }
616
- function decodeSessionRelocationSeal42(bytes) { const at = b3ReadHeader(bytes, 42, "sessionRelocationSeal"), v = b3ReadSealBase(bytes, at, true); b3Finish(at, bytes, "sessionRelocationSeal"); return v; }
617
- function encodeSessionRelocationSealed43(v) { const o = b3Header(43); b3WriteSealBase(o, v, false); return Uint8Array.from(o); }
618
- function decodeSessionRelocationSealed43(bytes) { const at = b3ReadHeader(bytes, 43, "sessionRelocationSealed"), v = b3ReadSealBase(bytes, at, false); b3Finish(at, bytes, "sessionRelocationSealed"); return v; }
630
+ function encodeSessionRelocationSeal42(v) { const o = b3Header(42); b3WriteSealBase(o, v, true); rid(o, v.targetNodeRid); if (v.targetNodeGeneration === 0n)
631
+ throw new RangeError("target node"); u64(o, v.targetNodeGeneration); return Uint8Array.from(o); }
632
+ function decodeSessionRelocationSeal42(bytes) { const at = b3ReadHeader(bytes, 42, "sessionRelocationSeal"), v = b3ReadSealBase(bytes, at, true); const targetNodeRid = readRid(bytes, at), targetNodeGeneration = nonzero64(bytes, at, "target node"); b3Finish(at, bytes, "sessionRelocationSeal"); return { ...v, targetNodeRid, targetNodeGeneration }; }
633
+ function encodeSessionRelocationSealed43(v) { const o = b3Header(43); b3WriteSealBase(o, v, false); b3WriteSealResult(o, v.sealResult); return Uint8Array.from(o); }
634
+ function decodeSessionRelocationSealed43(bytes) { const at = b3ReadHeader(bytes, 43, "sessionRelocationSealed"), v = { ...b3ReadSealBase(bytes, at, false), sealResult: b3ReadSealResult(bytes, at) }; b3Finish(at, bytes, "sessionRelocationSealed"); return v; }
619
635
  function encodeSessionRelocationRoute44(v) { const o = b3Header(44); b3WriteId(o, v.relocation, "relocation"); b3WriteCoordinator(o, v.coordinator); b3WriteRole(o, v.senderRole); if ((v.route.action === "commit" && v.senderRole !== "target") || (v.route.action === "abort" && v.senderRole !== "source"))
620
636
  throw new RangeError("route sender"); b3WriteActorRef(o, v.actor); b3WriteSession(o, v); b3WriteRoute(o, v.route); return Uint8Array.from(o); }
621
637
  function decodeSessionRelocationRoute44(bytes) { const at = b3ReadHeader(bytes, 44, "sessionRelocationRoute"), relocation = b3ReadId(bytes, at, "relocation"), coordinator = b3ReadCoordinator(bytes, at), senderRole = b3ReadRole(bytes, at), actor = b3ReadActorRef(bytes, at), session = b3ReadSession(bytes, at), route = b3ReadRoute(bytes, at); if ((route.action === "commit" && senderRole !== "target") || (route.action === "abort" && senderRole !== "source"))
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZLinkFormalRemoteActorAdmissionRegistry = void 0;
4
+ const routing_id_1 = require("../routing-id");
4
5
  const ADMISSION_RETENTION_MS = 30_000;
5
6
  /** Identifies the object one admission attempt belongs to. */
6
7
  function objectKey(actorId, objectGeneration) {
@@ -275,9 +276,9 @@ function sameProvisionalAdmission(left, right) {
275
276
  left.requestFingerprint === right.requestFingerprint &&
276
277
  sameOperationId(left.completionOperationId, right.completionOperationId) &&
277
278
  String(left.sourceSpotId ?? '') === String(right.sourceSpotId ?? '') &&
278
- String(left.sourceActorNodeRid ?? '') === String(right.sourceActorNodeRid ?? '') &&
279
+ (0, routing_id_1.routingIdsEqual)(left.sourceActorNodeRid, right.sourceActorNodeRid) &&
279
280
  left.actorRef.actorId === right.actorRef.actorId &&
280
- String(left.actorRef.nodeRid) === String(right.actorRef.nodeRid) &&
281
+ (0, routing_id_1.routingIdsEqual)(left.actorRef.nodeRid, right.actorRef.nodeRid) &&
281
282
  left.actorRef.objectGeneration === right.actorRef.objectGeneration);
282
283
  }
283
284
  function sameOperationId(left, right) {
@@ -15,7 +15,7 @@ import { type ReadyRecord, type ReceiveRecord } from '../foundation/service-runt
15
15
  import type { ZLinkBackendSpot, ZLinkBackendSpotNode } from '../backend/contracts';
16
16
  import { ZLinkDispatchErrorReporter } from '../channels';
17
17
  import { ZLinkWorkerRuntime } from '../workers';
18
- import { type ZLinkRemoteBoundSessionTarget } from '../actors';
18
+ import { type ZLinkActorHandoffPrefixAdmission, type ZLinkActorHandoffPrefixRecord, type ZLinkRemoteBoundSessionTarget } from '../actors';
19
19
  import type { ZLinkLocationLifecycle } from '../locations';
20
20
  import { type ZLinkActorHandoffPacket } from '../actors/actor-handoff';
21
21
  import type { CanonicalActorJoinRecovery } from '../foundation/actor-join-recovery-codec';
@@ -27,16 +27,17 @@ import { type ZLinkSpotRoutedTransport } from './spot-outbound';
27
27
  export { DefaultZLinkSpotHandlerRegistry, type ZLinkSpotHandlerRegistration } from './spot-handler-registry';
28
28
  export { ZLinkRuntimeSpotPublisherTransport } from './spot-publisher-transport';
29
29
  import type { ZLinkSpotActivation } from './spot-activation-state';
30
+ import type { ZLinkSpotPreparationCompletion } from './spot-serial-executor';
30
31
  import { type ZLinkNativeSpotAuthority } from './spot-activation';
31
32
  import type { ZLinkSpotActorHandoffRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
32
- import type { ZLinkRuntimeAdmissionGate } from '../admission';
33
+ import type { ZLinkRuntimeAdmissionGate, ZLinkMeshDispatchAdmission } from '../admission';
33
34
  import type { ZLinkActivationAdmission } from '../activation-admission';
34
35
  import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
35
36
  import type { ZLinkLocalSpotCreateResult } from './spot-manager-internal-contracts';
36
37
  export type { ZLinkLocalSpotCreateResult } from './spot-manager-internal-contracts';
37
38
  export type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
38
39
  export { ZLinkEntrySpotActivation } from './spot-entry-activation';
39
- export { createFrameworkEntrySpotId, ZLinkSpotNodeRuntimeManager, type ZLinkSpotNodeRuntimeManagerOptions } from './spot-node-runtime-manager';
40
+ export { createFrameworkEntrySpotId, registrationAcceptsNewActor, ZLinkSpotNodeRuntimeManager, type ZLinkSpotNodeRuntimeManagerOptions } from './spot-node-runtime-manager';
40
41
  export { ZLinkPublicSpotManager, type ZLinkPublicSpotManagerOptions } from './spot-manager-public';
41
42
  export interface ZLinkSpotManagerOptions {
42
43
  readonly spotFactories: readonly Type<ZLinkSpot>[];
@@ -62,6 +63,7 @@ export interface ZLinkSpotManagerOptions {
62
63
  * stateful reply has committed Core membership.
63
64
  */
64
65
  readonly dispatchEntryActorJoin?: (meshName: string, actor: ZLinkActor, handoffBacklog?: readonly ZLinkActorHandoffPacket[]) => Promise<void>;
66
+ readonly admitEntryActorPacketPrefix?: (meshName: string, actorId: string, records: readonly ZLinkActorHandoffPrefixRecord[]) => ZLinkActorHandoffPrefixAdmission;
65
67
  readonly executeEntryActor?: <T>(meshName: string, actorId: string, operation: () => Promise<T>) => Promise<T>;
66
68
  readonly actorCountProvider?: (spotId: RoutingId) => number;
67
69
  readonly releaseActorMembers?: (meshName: string, spotId: RoutingId) => Promise<void>;
@@ -146,11 +148,11 @@ export declare class DefaultZLinkSpotManager {
146
148
  relocationActivations(meshName: string): readonly ZLinkSpotActivation[];
147
149
  activeSpotCount(meshName: string): number;
148
150
  resolveRelocationActivation(meshName: string, spotId: RoutingId): ZLinkSpotActivation | undefined;
149
- prepareRelocationSpot(meshName: string, objectKind: 'user_spot' | 'instance_spot', stableType: string, implementation: Type<ZLinkSpot | ZLinkInstanceSpot>, spotId: RoutingId, objectGeneration: bigint, authorityOwnerGeneration: bigint, signal?: AbortSignal): Promise<ZLinkSpotActivation>;
151
+ prepareRelocationSpot(meshName: string, objectKind: 'user_spot' | 'instance_spot', stableType: string, implementation: Type<ZLinkSpot | ZLinkInstanceSpot>, spotId: RoutingId, objectGeneration: bigint, authorityOwnerGeneration: bigint, restoredTimers: readonly import('./spot-timer').ZLinkTimerRelocationState[], signal?: AbortSignal): Promise<ZLinkSpotActivation>;
150
152
  publishRelocationSpot(activation: ZLinkSpotActivation, beforeAdmission?: () => Promise<void>): Promise<void>;
151
153
  abortRelocationSpot(activation: ZLinkSpotActivation): Promise<void>;
152
154
  completeRelocationSource(activation: ZLinkSpotActivation): Promise<void>;
153
- materializeInstance(meshName: string, instanceType: string, spotId: RoutingId, objectGeneration: bigint, signal?: AbortSignal): Promise<void>;
155
+ materializeInstance(meshName: string, instanceType: string, spotId: RoutingId, objectGeneration: bigint, signal?: AbortSignal, completion?: ZLinkSpotPreparationCompletion): Promise<void>;
154
156
  private materializeInstanceCore;
155
157
  isInstanceMaterialized(meshName: string, instanceType: string, spotId: RoutingId): boolean;
156
158
  private resolveApplicationActivation;
@@ -162,6 +164,10 @@ export declare class DefaultZLinkSpotManager {
162
164
  beginInstanceSpotIdleEviction(meshName: string, spotId: RoutingId): boolean;
163
165
  completeInstanceTerminal(meshName: string, spotId: RoutingId, objectGeneration: bigint): Promise<boolean>;
164
166
  beginInstanceTerminal(meshName: string, spotId: RoutingId, objectGeneration: bigint): void;
167
+ publishInstance(target: {
168
+ readonly targetSpotId: string;
169
+ readonly objectGeneration: bigint;
170
+ }, meshName: string): void;
165
171
  private deferInstanceAuthorityRelease;
166
172
  private removeDeferredInstanceAuthorityRelease;
167
173
  private removePendingInstanceTerminalGeneration;
@@ -189,8 +195,8 @@ export declare class DefaultZLinkSpotManager {
189
195
  executeOnSpot<TSpot extends ZLinkSpot, TResult>(spotType: Type<TSpot>, spotId: RoutingId, operation: (spot: TSpot) => Promise<TResult> | TResult, signal?: AbortSignal): Promise<TResult>;
190
196
  hasActiveSpot(spotId: RoutingId): boolean;
191
197
  beginUserSpotPublication(meshName: string, spotId: RoutingId): void;
192
- publishUserSpot(meshName: string, spotId: RoutingId): void;
193
- abortUserSpotPublication(meshName: string, spotId: RoutingId): void;
198
+ publishUserSpot(meshName: string, spotId: RoutingId): Promise<void>;
199
+ abortUserSpotPublication(meshName: string, spotId: RoutingId): Promise<void>;
194
200
  resolveLocalSpotRoute(spotId: RoutingId): ZLinkSpotRouteTarget | undefined;
195
201
  admitActorJoin(spotId: RoutingId, actor: ZLinkActor, request: Message, commit: (spot: ZLinkSpot) => Promise<void> | void, signal?: AbortSignal, leaveSource?: () => Promise<void>, contentType?: string): Promise<ZLinkSpotActorJoinResult>;
196
202
  leaveActor(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
@@ -198,11 +204,12 @@ export declare class DefaultZLinkSpotManager {
198
204
  notifyActorLeftAfterTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
199
205
  prepareActorLeaveForTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
200
206
  commitActorLeaveAfterTransfer(spotId: RoutingId, actorId: string): Promise<void>;
201
- restoreActorAfterFailedTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
202
207
  beginActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
203
208
  cancelActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
204
209
  notifyJoinedSpotActorDisconnected(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<boolean>;
205
210
  dispatchRoutedActorPacket(origin: ApplicationJobOrigin, spotId: RoutingId, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef): Promise<unknown>;
211
+ /** Resolves the current Actor FIFO owner for both Entry and User membership. */
212
+ admitSourceActorPacketPrefix(actorId: string, records: readonly ZLinkActorHandoffPrefixRecord[]): ZLinkActorHandoffPrefixAdmission;
206
213
  dispatchRoutedSpotSend(spotId: RoutingId, packetName: string | undefined, message: unknown, context: {
207
214
  readonly channelName: string;
208
215
  readonly contentType?: string;
@@ -218,12 +225,12 @@ export declare class DefaultZLinkSpotManager {
218
225
  readonly signal?: AbortSignal;
219
226
  readonly onAdmitted?: () => void;
220
227
  }): Promise<TReply>;
221
- dispatchMeshSpot(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
228
+ dispatchMeshSpot(meshName: string, owner: ReadyRecord, record: ReceiveRecord, admit?: ZLinkMeshDispatchAdmission): Promise<void>;
222
229
  private ensureInstanceApplicationActivation;
223
- dispatchMeshInstance(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
230
+ dispatchMeshInstance(meshName: string, owner: ReadyRecord, record: ReceiveRecord, admit?: ZLinkMeshDispatchAdmission): Promise<void>;
224
231
  private reportInstanceDispatchFailure;
225
232
  private traceInstanceMessage;
226
- dispatchMeshActor(origin: ApplicationJobOrigin, meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
233
+ dispatchMeshActor(origin: ApplicationJobOrigin, meshName: string, owner: ReadyRecord, record: ReceiveRecord, admit?: ZLinkMeshDispatchAdmission): Promise<void>;
227
234
  dispatchMeshActorJoin(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
228
235
  private dispatchMeshActorJoinCore;
229
236
  dispatchMeshSpotControl(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;