@zlink-systems/framework 0.29.1 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/LICENSE +150 -68
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
  4. package/dist/contracts/Channels/Calls.d.ts +2 -1
  5. package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
  6. package/dist/contracts/Configuration/Builders.d.ts +1 -2
  7. package/dist/contracts/Configuration/Configs.d.ts +0 -5
  8. package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
  9. package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
  10. package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
  11. package/dist/contracts/Configuration/index.d.ts +1 -1
  12. package/dist/contracts/Handlers/Attributes.d.ts +5 -13
  13. package/dist/contracts/Handlers/Attributes.js +7 -11
  14. package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
  15. package/dist/contracts/Handlers/JsonContract.js +4 -153
  16. package/dist/contracts/Spots/Contracts.d.ts +2 -1
  17. package/dist/internal.d.ts +1 -0
  18. package/dist/internal.js +3 -1
  19. package/dist/nest-integration.d.ts +1 -1
  20. package/dist/nest-integration.js +2 -1
  21. package/dist/runtime/actors/actor-client.d.ts +1 -1
  22. package/dist/runtime/actors/actor-client.js +14 -12
  23. package/dist/runtime/actors/actor-handoff.d.ts +3 -2
  24. package/dist/runtime/actors/actor-handoff.js +15 -7
  25. package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
  26. package/dist/runtime/actors/actor-local-native-join.js +9 -12
  27. package/dist/runtime/actors/actor-remote-wire.js +15 -0
  28. package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
  29. package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
  30. package/dist/runtime/actors/index.d.ts +2 -1
  31. package/dist/runtime/actors/index.js +18 -6
  32. package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
  33. package/dist/runtime/admission.d.ts +1 -1
  34. package/dist/runtime/admission.js +15 -5
  35. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +9 -9
  36. package/dist/runtime/application-jobs/application-ingress-record-owner.js +45 -23
  37. package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +5 -2
  38. package/dist/runtime/application-jobs/application-job-queue-scope.js +41 -21
  39. package/dist/runtime/application-jobs/contracts.d.ts +15 -2
  40. package/dist/runtime/backend/contracts/index.d.ts +27 -27
  41. package/dist/runtime/backend/mesh-completion-table.d.ts +15 -5
  42. package/dist/runtime/backend/mesh-completion-table.js +160 -50
  43. package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
  44. package/dist/runtime/backend/mesh-dispatch-pump.js +53 -36
  45. package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
  46. package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
  47. package/dist/runtime/backend/node/node-backend-adapter-support.js +33 -31
  48. package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
  49. package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
  50. package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
  51. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
  52. package/dist/runtime/backend/node/node-raw-binding-port.js +50 -25
  53. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +22 -16
  54. package/dist/runtime/backend/node/node-raw-mesh-backend.js +133 -149
  55. package/dist/runtime/backend/node/node-socket-backend-adapter.js +15 -10
  56. package/dist/runtime/backend/raw-binding-port.d.ts +10 -3
  57. package/dist/runtime/backend/runtime-message.d.ts +1 -0
  58. package/dist/runtime/backend/runtime-message.js +5 -0
  59. package/dist/runtime/backend/runtime-values.d.ts +1 -0
  60. package/dist/runtime/backend/runtime-values.js +2 -1
  61. package/dist/runtime/channels/channel-clients.d.ts +1 -0
  62. package/dist/runtime/channels/channel-clients.js +58 -21
  63. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
  64. package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
  65. package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
  66. package/dist/runtime/channels/channel-dispatch-services.js +45 -0
  67. package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
  68. package/dist/runtime/channels/channel-dispatchers.js +27 -26
  69. package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
  70. package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
  71. package/dist/runtime/channels/channel-envelope.d.ts +1 -0
  72. package/dist/runtime/channels/channel-envelope.js +83 -8
  73. package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
  74. package/dist/runtime/channels/channel-outbound-operations.js +8 -8
  75. package/dist/runtime/channels/channel-receive-loops.js +3 -3
  76. package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
  77. package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
  78. package/dist/runtime/channels/channel-runtime-manager.js +12 -12
  79. package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
  80. package/dist/runtime/channels/channel-socket-registry.js +59 -82
  81. package/dist/runtime/channels/channel-transports.d.ts +18 -15
  82. package/dist/runtime/channels/channel-transports.js +48 -31
  83. package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
  84. package/dist/runtime/channels/local-spot-route-transport.js +2 -1
  85. package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
  86. package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
  87. package/dist/runtime/channels/source-spot-router.d.ts +2 -2
  88. package/dist/runtime/channels/source-spot-router.js +4 -4
  89. package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
  90. package/dist/runtime/channels/spot-node-route-transport.js +4 -4
  91. package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
  92. package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
  93. package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
  94. package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
  95. package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
  96. package/dist/runtime/diagnostics/message-flow.js +3 -3
  97. package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
  98. package/dist/runtime/execution/serial-execution-queue.js +1 -0
  99. package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
  100. package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
  101. package/dist/runtime/foundation/durable-service-request.js +98 -0
  102. package/dist/runtime/foundation/operation-identity.d.ts +1 -0
  103. package/dist/runtime/foundation/operation-identity.js +5 -1
  104. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +37 -6
  105. package/dist/runtime/foundation/raw-service-mesh-runtime.js +473 -220
  106. package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
  107. package/dist/runtime/foundation/service-liveness-registry.js +57 -44
  108. package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
  109. package/dist/runtime/foundation/service-mailbox.js +2 -1
  110. package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
  111. package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
  112. package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
  113. package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
  114. package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
  115. package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -9
  116. package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
  117. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -7
  118. package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
  119. package/dist/runtime/foundation/service-topology-registry.d.ts +16 -4
  120. package/dist/runtime/foundation/service-topology-registry.js +69 -30
  121. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
  122. package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
  123. package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
  124. package/dist/runtime/handlers/handler-instance-scope.js +54 -11
  125. package/dist/runtime/host/actor-packet-relay.js +7 -7
  126. package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
  127. package/dist/runtime/host/application-job-queue.d.ts +28 -9
  128. package/dist/runtime/host/application-job-queue.js +214 -50
  129. package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
  130. package/dist/runtime/host/entry-actor-runtime.js +4 -1
  131. package/dist/runtime/host/index.d.ts +7 -1
  132. package/dist/runtime/host/index.js +154 -126
  133. package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
  134. package/dist/runtime/host/instance-activation-authority.js +89 -25
  135. package/dist/runtime/host/remote-bound-session-relay.js +2 -18
  136. package/dist/runtime/host/route-mesh-runtime.js +1 -1
  137. package/dist/runtime/host/service-relocation-control.d.ts +1 -0
  138. package/dist/runtime/host/service-relocation-control.js +10 -4
  139. package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
  140. package/dist/runtime/host/service-relocation-host-runtime.js +215 -243
  141. package/dist/runtime/host/spot-address-transport.d.ts +1 -0
  142. package/dist/runtime/host/spot-address-transport.js +28 -14
  143. package/dist/runtime/host/spot-runtime-options-factory.js +3 -2
  144. package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
  145. package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
  146. package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
  147. package/dist/runtime/locations/actor-location-claims.js +34 -19
  148. package/dist/runtime/locations/domain-store-contract.d.ts +2 -2
  149. package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
  150. package/dist/runtime/locations/in-memory-authority-store.js +80 -8
  151. package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
  152. package/dist/runtime/locations/in-memory-location-store.js +19 -3
  153. package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
  154. package/dist/runtime/locations/lifecycle.d.ts +1 -2
  155. package/dist/runtime/locations/lifecycle.js +2 -5
  156. package/dist/runtime/locations/location-store-repository.d.ts +3 -2
  157. package/dist/runtime/locations/location-store-repository.js +165 -22
  158. package/dist/runtime/locations/resolvers.d.ts +2 -1
  159. package/dist/runtime/locations/resolvers.js +10 -1
  160. package/dist/runtime/locations/runtime.d.ts +1 -1
  161. package/dist/runtime/locations/runtime.js +24 -23
  162. package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
  163. package/dist/runtime/messaging/framework-json-v1.js +38 -294
  164. package/dist/runtime/messaging/packet-name.d.ts +1 -1
  165. package/dist/runtime/messaging/packet-name.js +8 -24
  166. package/dist/runtime/messaging/request-result.d.ts +2 -0
  167. package/dist/runtime/messaging/request-result.js +54 -0
  168. package/dist/runtime/messaging/submission-result.d.ts +2 -1
  169. package/dist/runtime/messaging/submission-result.js +7 -4
  170. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
  171. package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
  172. package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
  173. package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
  174. package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +9 -2
  175. package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
  176. package/dist/runtime/spots/index.d.ts +7 -3
  177. package/dist/runtime/spots/index.js +23 -16
  178. package/dist/runtime/spots/spot-activation.d.ts +3 -1
  179. package/dist/runtime/spots/spot-activation.js +21 -12
  180. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
  181. package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
  182. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
  183. package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
  184. package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
  185. package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
  186. package/dist/runtime/spots/spot-entry-activation.js +9 -3
  187. package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
  188. package/dist/runtime/spots/spot-handler-registry.js +18 -8
  189. package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
  190. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
  191. package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
  192. package/dist/runtime/spots/spot-outbound.d.ts +3 -0
  193. package/dist/runtime/spots/spot-outbound.js +24 -15
  194. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
  195. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
  196. package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
  197. package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -1
  198. package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
  199. package/dist/runtime/spots/spot-timer.js +1 -0
  200. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
  201. package/dist/runtime/streams/stream-session-runtime.js +14 -28
  202. package/package.json +3 -3
  203. package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
  204. package/src/contracts/Channels/Calls.ts +2 -1
  205. package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
  206. package/src/contracts/Configuration/Builders.ts +1 -2
  207. package/src/contracts/Configuration/Configs.ts +0 -6
  208. package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
  209. package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
  210. package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
  211. package/src/contracts/Configuration/index.ts +1 -6
  212. package/src/contracts/Handlers/Attributes.ts +14 -21
  213. package/src/contracts/Handlers/JsonContract.ts +8 -216
  214. package/src/contracts/Spots/Contracts.ts +2 -1
  215. package/src/internal.ts +1 -0
  216. package/src/nest-integration.ts +1 -0
  217. package/src/runtime/actors/actor-client.ts +40 -16
  218. package/src/runtime/actors/actor-handoff.ts +22 -8
  219. package/src/runtime/actors/actor-join-relocation.ts +1 -0
  220. package/src/runtime/actors/actor-local-native-join.ts +17 -26
  221. package/src/runtime/actors/actor-remote-wire.ts +17 -0
  222. package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
  223. package/src/runtime/actors/actor-routed-json-request.ts +10 -2
  224. package/src/runtime/actors/index.ts +19 -5
  225. package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
  226. package/src/runtime/admission.ts +18 -5
  227. package/src/runtime/application-jobs/application-ingress-record-owner.ts +53 -27
  228. package/src/runtime/application-jobs/application-job-queue-scope.ts +56 -22
  229. package/src/runtime/application-jobs/contracts.ts +28 -2
  230. package/src/runtime/backend/contracts/index.ts +63 -32
  231. package/src/runtime/backend/mesh-completion-table.ts +175 -59
  232. package/src/runtime/backend/mesh-dispatch-pump.ts +59 -32
  233. package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
  234. package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -31
  235. package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
  236. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
  237. package/src/runtime/backend/node/node-raw-binding-port.ts +73 -37
  238. package/src/runtime/backend/node/node-raw-mesh-backend.ts +209 -176
  239. package/src/runtime/backend/node/node-socket-backend-adapter.ts +32 -13
  240. package/src/runtime/backend/raw-binding-port.ts +18 -3
  241. package/src/runtime/backend/runtime-message.ts +6 -0
  242. package/src/runtime/backend/runtime-values.ts +1 -0
  243. package/src/runtime/channels/channel-clients.ts +90 -41
  244. package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
  245. package/src/runtime/channels/channel-dispatch-services.ts +69 -1
  246. package/src/runtime/channels/channel-dispatchers.ts +29 -27
  247. package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
  248. package/src/runtime/channels/channel-envelope.ts +133 -8
  249. package/src/runtime/channels/channel-outbound-operations.ts +22 -8
  250. package/src/runtime/channels/channel-receive-loops.ts +3 -3
  251. package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
  252. package/src/runtime/channels/channel-runtime-manager.ts +29 -12
  253. package/src/runtime/channels/channel-socket-registry.ts +84 -130
  254. package/src/runtime/channels/channel-transports.ts +128 -60
  255. package/src/runtime/channels/local-spot-route-transport.ts +3 -1
  256. package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
  257. package/src/runtime/channels/source-spot-router.ts +8 -4
  258. package/src/runtime/channels/spot-node-route-transport.ts +8 -4
  259. package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
  260. package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
  261. package/src/runtime/diagnostics/message-flow.ts +1 -1
  262. package/src/runtime/execution/serial-execution-queue.ts +2 -0
  263. package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
  264. package/src/runtime/foundation/durable-service-request.ts +137 -0
  265. package/src/runtime/foundation/operation-identity.ts +5 -1
  266. package/src/runtime/foundation/raw-service-mesh-runtime.ts +642 -253
  267. package/src/runtime/foundation/service-liveness-registry.ts +68 -59
  268. package/src/runtime/foundation/service-mailbox.ts +7 -1
  269. package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
  270. package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
  271. package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
  272. package/src/runtime/foundation/service-stateful-runtime.ts +128 -160
  273. package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -84
  274. package/src/runtime/foundation/service-topology-registry.ts +103 -42
  275. package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
  276. package/src/runtime/handlers/handler-instance-scope.ts +67 -16
  277. package/src/runtime/host/actor-packet-relay.ts +7 -0
  278. package/src/runtime/host/actor-runtime-options-factory.ts +14 -2
  279. package/src/runtime/host/application-job-queue.ts +249 -48
  280. package/src/runtime/host/entry-actor-runtime.ts +5 -0
  281. package/src/runtime/host/index.ts +224 -160
  282. package/src/runtime/host/instance-activation-authority.ts +132 -27
  283. package/src/runtime/host/remote-bound-session-relay.ts +2 -23
  284. package/src/runtime/host/route-mesh-runtime.ts +1 -1
  285. package/src/runtime/host/service-relocation-control.ts +11 -5
  286. package/src/runtime/host/service-relocation-host-runtime.ts +317 -291
  287. package/src/runtime/host/spot-address-transport.ts +49 -24
  288. package/src/runtime/host/spot-runtime-options-factory.ts +4 -0
  289. package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
  290. package/src/runtime/locations/actor-location-claims.ts +52 -30
  291. package/src/runtime/locations/domain-store-contract.ts +6 -2
  292. package/src/runtime/locations/in-memory-authority-store.ts +113 -9
  293. package/src/runtime/locations/in-memory-location-store.ts +25 -3
  294. package/src/runtime/locations/internal-location-contracts.ts +4 -0
  295. package/src/runtime/locations/lifecycle.ts +8 -26
  296. package/src/runtime/locations/location-store-repository.ts +220 -15
  297. package/src/runtime/locations/resolvers.ts +25 -2
  298. package/src/runtime/locations/runtime.ts +28 -24
  299. package/src/runtime/messaging/framework-json-v1.ts +5 -325
  300. package/src/runtime/messaging/packet-name.ts +5 -25
  301. package/src/runtime/messaging/request-result.ts +58 -0
  302. package/src/runtime/messaging/submission-result.ts +7 -3
  303. package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
  304. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
  305. package/src/runtime/spots/formal-remote-actor-admission-registry.ts +45 -23
  306. package/src/runtime/spots/index.ts +30 -2
  307. package/src/runtime/spots/spot-activation.ts +33 -10
  308. package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
  309. package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
  310. package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
  311. package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
  312. package/src/runtime/spots/spot-entry-activation.ts +12 -2
  313. package/src/runtime/spots/spot-handler-registry.ts +41 -8
  314. package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
  315. package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
  316. package/src/runtime/spots/spot-outbound.ts +36 -16
  317. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
  318. package/src/runtime/spots/spot-routing-internal.ts +14 -0
  319. package/src/runtime/spots/spot-runtime-ports.ts +3 -0
  320. package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
  321. package/src/runtime/spots/spot-timer.ts +5 -1
  322. package/src/runtime/streams/stream-session-runtime.ts +13 -30
@@ -1,326 +1,6 @@
1
- import type { ZLinkJsonSchema } from '../../contracts/Handlers/JsonContract';
1
+ import * as profile from '@zlink-systems/stream-wire/internal/json';
2
2
 
3
- export const FRAMEWORK_JSON_V1_PROFILE = 'framework-json-v1';
4
-
5
- const SIGNED_64_MIN = -(1n << 63n);
6
- const UNSIGNED_64_MAX = (1n << 64n) - 1n;
7
-
8
- export interface FrameworkJsonParseOptions {
9
- readonly rejectPropertyName?: (name: string) => boolean;
10
- }
11
-
12
- export function stringifyFrameworkJsonV1(value: unknown, schema?: ZLinkJsonSchema): string {
13
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
14
- throw new TypeError('framework-json-v1 payload is not a JSON value.');
15
- }
16
- const encoded = JSON.stringify(value, frameworkJsonV1Replacer);
17
- if (schema !== undefined) {
18
- validateFrameworkJsonV1Value(JSON.parse(encoded), schema, '$', false);
19
- }
20
- return encoded;
21
- }
22
-
23
- // Module-level so JSON.stringify does not allocate a fresh closure per
24
- // encoded message. On the root call `this` is the {'': value} wrapper, so
25
- // this[key] resolves the raw (pre-toJSON) source for every key including ''.
26
- function frameworkJsonV1Replacer(
27
- this: Record<string, unknown>,
28
- key: string,
29
- item: unknown
30
- ): unknown {
31
- const source = this[key];
32
- if (typeof source === 'number' && !Number.isFinite(source)) {
33
- throw new TypeError('framework-json-v1 only accepts finite JSON numbers.');
34
- }
35
- if (typeof source === 'bigint') {
36
- if (source < SIGNED_64_MIN || source > UNSIGNED_64_MAX) {
37
- throw new RangeError('framework-json-v1 64-bit integer is outside the supported range.');
38
- }
39
- return source.toString(10);
40
- }
41
- if (source instanceof Uint8Array) {
42
- return Buffer.from(source.buffer, source.byteOffset, source.byteLength).toString('base64');
43
- }
44
- if (source instanceof Date) {
45
- throw new TypeError('framework-json-v1 does not implicitly encode Date values.');
46
- }
47
- if (
48
- typeof source === 'object' &&
49
- source !== null &&
50
- typeof (source as { readonly toJSON?: unknown }).toJSON === 'function'
51
- ) {
52
- throw new TypeError('framework-json-v1 does not implicitly invoke custom toJSON methods.');
53
- }
54
- return item;
55
- }
56
-
57
- export function parseFrameworkJsonV1(
58
- text: string,
59
- options: FrameworkJsonParseOptions = {},
60
- schema?: ZLinkJsonSchema
61
- ): unknown {
62
- if (text.charCodeAt(0) === 0xfeff) {
63
- throw new SyntaxError('framework-json-v1 does not allow a UTF-8 BOM.');
64
- }
65
- new JsonPropertyScanner(text, options).scan();
66
- const parsed = JSON.parse(text);
67
- return schema === undefined ? parsed : validateFrameworkJsonV1Value(parsed, schema, '$', true);
68
- }
69
-
70
- // Sticky pattern shared across scans; matching happens synchronously so the
71
- // mutable lastIndex never crosses calls.
72
- const NUMBER_TOKEN_PATTERN = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/uy;
73
-
74
- const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
75
- const INT32_MIN = -2_147_483_648;
76
- const INT32_MAX = 2_147_483_647;
77
- const UINT32_MAX = 4_294_967_295;
78
-
79
- function validateFrameworkJsonV1Value(
80
- value: unknown,
81
- schema: ZLinkJsonSchema,
82
- path: string,
83
- decode: boolean
84
- ): unknown {
85
- switch (schema.type) {
86
- case 'boolean':
87
- if (typeof value !== 'boolean') schemaFailure(path, 'a boolean');
88
- return value;
89
- case 'string':
90
- if (typeof value !== 'string') schemaFailure(path, 'a string');
91
- return value;
92
- case 'number':
93
- if (typeof value !== 'number' || !Number.isFinite(value))
94
- schemaFailure(path, 'a finite number');
95
- return value;
96
- case 'int32':
97
- if (
98
- !Number.isInteger(value) ||
99
- (value as number) < INT32_MIN ||
100
- (value as number) > INT32_MAX
101
- ) {
102
- schemaFailure(path, 'an int32 JSON number');
103
- }
104
- return value;
105
- case 'uint32':
106
- if (!Number.isInteger(value) || (value as number) < 0 || (value as number) > UINT32_MAX) {
107
- schemaFailure(path, 'a uint32 JSON number');
108
- }
109
- return value;
110
- case 'int64':
111
- return validateDecimalInteger(value, path, true, decode);
112
- case 'uint64':
113
- return validateDecimalInteger(value, path, false, decode);
114
- case 'bytes': {
115
- if (typeof value !== 'string' || !BASE64_PATTERN.test(value)) {
116
- schemaFailure(path, 'padded RFC 4648 base64');
117
- }
118
- const bytes = Buffer.from(value as string, 'base64');
119
- if (bytes.toString('base64') !== value)
120
- schemaFailure(path, 'canonical padded RFC 4648 base64');
121
- return decode ? Uint8Array.from(bytes) : value;
122
- }
123
- case 'enum':
124
- if (typeof value !== 'string' || !schema.names.includes(value)) {
125
- schemaFailure(path, `one of ${schema.names.join(', ')}`);
126
- }
127
- return value;
128
- case 'nullable':
129
- return value === null
130
- ? null
131
- : validateFrameworkJsonV1Value(value, schema.value, path, decode);
132
- case 'array':
133
- if (!Array.isArray(value)) schemaFailure(path, 'an array');
134
- return (value as unknown[]).map((item, index) =>
135
- validateFrameworkJsonV1Value(item, schema.items, `${path}[${index}]`, decode)
136
- );
137
- case 'record': {
138
- if (!isJsonObject(value)) schemaFailure(path, 'an object');
139
- const result: Record<string, unknown> = {};
140
- for (const [name, item] of Object.entries(value as Record<string, unknown>)) {
141
- result[name] = validateFrameworkJsonV1Value(item, schema.values, `${path}.${name}`, decode);
142
- }
143
- return decode ? result : value;
144
- }
145
- case 'object': {
146
- if (!isJsonObject(value)) schemaFailure(path, 'an object');
147
- const input = value as Record<string, unknown>;
148
- for (const name of schema.required) {
149
- if (!Object.prototype.hasOwnProperty.call(input, name)) {
150
- throw new TypeError(`framework-json-v1 required property '${path}.${name}' is missing.`);
151
- }
152
- }
153
- const result: Record<string, unknown> = {};
154
- for (const [name, item] of Object.entries(input)) {
155
- const propertySchema: unknown = schema.properties[name];
156
- if (propertySchema === undefined) {
157
- if (schema.additionalProperties === false) {
158
- throw new TypeError(`framework-json-v1 property '${path}.${name}' is not allowed.`);
159
- }
160
- continue;
161
- }
162
- result[name] = validateFrameworkJsonV1Value(
163
- item,
164
- propertySchema as ZLinkJsonSchema,
165
- `${path}.${name}`,
166
- decode
167
- );
168
- }
169
- return decode ? result : value;
170
- }
171
- }
172
- }
173
-
174
- function validateDecimalInteger(
175
- value: unknown,
176
- path: string,
177
- signed: boolean,
178
- decode: boolean
179
- ): unknown {
180
- if (typeof value !== 'string' || !/^(?:0|[1-9][0-9]*|-[1-9][0-9]*)$/u.test(value)) {
181
- schemaFailure(
182
- path,
183
- signed ? 'a canonical int64 decimal string' : 'a canonical uint64 decimal string'
184
- );
185
- }
186
- const parsed = BigInt(value as string);
187
- const minimum = signed ? SIGNED_64_MIN : 0n;
188
- const maximum = signed ? (1n << 63n) - 1n : UNSIGNED_64_MAX;
189
- if (parsed < minimum || parsed > maximum)
190
- schemaFailure(path, signed ? 'an int64 value' : 'a uint64 value');
191
- return decode ? parsed : value;
192
- }
193
-
194
- function isJsonObject(value: unknown): value is Record<string, unknown> {
195
- return typeof value === 'object' && value !== null && !Array.isArray(value);
196
- }
197
-
198
- function schemaFailure(path: string, expected: string): never {
199
- throw new TypeError(`framework-json-v1 value '${path}' must be ${expected}.`);
200
- }
201
-
202
- class JsonPropertyScanner {
203
- private index = 0;
204
-
205
- constructor(
206
- private readonly text: string,
207
- private readonly options: FrameworkJsonParseOptions
208
- ) {}
209
-
210
- scan(): void {
211
- this.skipWhitespace();
212
- this.scanValue();
213
- this.skipWhitespace();
214
- if (this.index !== this.text.length) this.fail('trailing data');
215
- }
216
-
217
- private scanValue(): void {
218
- this.skipWhitespace();
219
- const token = this.text[this.index];
220
- if (token === '{') return this.scanObject();
221
- if (token === '[') return this.scanArray();
222
- if (token === '"') {
223
- this.scanString();
224
- return;
225
- }
226
- if (token === 't') return this.scanLiteral('true');
227
- if (token === 'f') return this.scanLiteral('false');
228
- if (token === 'n') return this.scanLiteral('null');
229
- this.scanNumber();
230
- }
231
-
232
- private scanObject(): void {
233
- this.index++;
234
- this.skipWhitespace();
235
- if (this.text[this.index] === '}') {
236
- this.index++;
237
- return;
238
- }
239
- const properties = new Set<string>();
240
- for (;;) {
241
- this.skipWhitespace();
242
- if (this.text[this.index] !== '"') this.fail('object property name');
243
- const property = this.scanString();
244
- if (properties.has(property)) {
245
- throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
246
- }
247
- properties.add(property);
248
- if (this.options.rejectPropertyName?.(property) === true) {
249
- throw new SyntaxError(`framework-json-v1 property '${property}' is not allowed.`);
250
- }
251
- this.skipWhitespace();
252
- if (this.text[this.index] !== ':') this.fail("':' after object property");
253
- this.index++;
254
- this.scanValue();
255
- this.skipWhitespace();
256
- const delimiter = this.text[this.index++];
257
- if (delimiter === '}') return;
258
- if (delimiter !== ',') this.fail("',' or '}' after object property");
259
- }
260
- }
261
-
262
- private scanArray(): void {
263
- this.index++;
264
- this.skipWhitespace();
265
- if (this.text[this.index] === ']') {
266
- this.index++;
267
- return;
268
- }
269
- for (;;) {
270
- this.scanValue();
271
- this.skipWhitespace();
272
- const delimiter = this.text[this.index++];
273
- if (delimiter === ']') return;
274
- if (delimiter !== ',') this.fail("',' or ']' after array item");
275
- }
276
- }
277
-
278
- private scanString(): string {
279
- const start = this.index++;
280
- let sawEscape = false;
281
- for (;;) {
282
- if (this.index >= this.text.length) this.fail('unterminated string');
283
- const character = this.text[this.index++]!;
284
- if (character === '"') {
285
- // Without escapes the token content is verbatim; the outer
286
- // JSON.parse pass still rejects any raw control characters.
287
- return sawEscape
288
- ? (JSON.parse(this.text.slice(start, this.index)) as string)
289
- : this.text.slice(start + 1, this.index - 1);
290
- }
291
- if (character === '\\') {
292
- sawEscape = true;
293
- if (this.index >= this.text.length) this.fail('unterminated escape');
294
- const escaped = this.text[this.index++]!;
295
- if (escaped === 'u') this.index += 4;
296
- }
297
- }
298
- }
299
-
300
- private scanLiteral(value: 'true' | 'false' | 'null'): void {
301
- if (!this.text.startsWith(value, this.index)) this.fail(value);
302
- this.index += value.length;
303
- }
304
-
305
- private scanNumber(): void {
306
- NUMBER_TOKEN_PATTERN.lastIndex = this.index;
307
- const match = NUMBER_TOKEN_PATTERN.exec(this.text);
308
- if (match === null) this.fail('JSON value');
309
- this.index += match[0].length;
310
- }
311
-
312
- private skipWhitespace(): void {
313
- for (;;) {
314
- const code = this.text.charCodeAt(this.index);
315
- if (code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d) {
316
- this.index += 1;
317
- continue;
318
- }
319
- return;
320
- }
321
- }
322
-
323
- private fail(expected: string): never {
324
- throw new SyntaxError(`framework-json-v1 expected ${expected} at offset ${this.index}.`);
325
- }
326
- }
3
+ export const FRAMEWORK_JSON_V1_PROFILE = profile.FRAMEWORK_JSON_V1_PROFILE;
4
+ export const stringifyFrameworkJsonV1 = profile.stringifyFrameworkJsonV1;
5
+ export const parseFrameworkJsonV1 = profile.parseFrameworkJsonV1;
6
+ export type { FrameworkJsonParseOptions } from '@zlink-systems/stream-wire/internal/json';
@@ -1,3 +1,7 @@
1
+ import {
2
+ readFrameworkPacketJsonContract,
3
+ normalizePacketName
4
+ } from '@zlink-systems/stream-wire/internal/json';
1
5
  import { readZLinkDecoratorMetadata } from '../../contracts/Handlers/Attributes';
2
6
  import type { ZLinkPacketJsonContract } from '../../contracts/Handlers/JsonContract';
3
7
  import { ZLinkConfigurationException } from '../configuration';
@@ -42,23 +46,7 @@ export function resolveFrameworkPacketJsonContract(
42
46
  return readFrameworkPacketJsonContract(constructor, explicitPacketName);
43
47
  }
44
48
 
45
- export function readFrameworkPacketJsonContract(
46
- type: object,
47
- explicitPacketName?: string
48
- ): ZLinkPacketJsonContract | undefined {
49
- const expectedPacketName = normalizePacketName(explicitPacketName);
50
- for (const metadata of readZLinkDecoratorMetadata(type)) {
51
- if (
52
- metadata.kind === 'packet' &&
53
- metadata.jsonContract !== undefined &&
54
- (expectedPacketName === undefined ||
55
- normalizePacketName(metadata.packetName) === expectedPacketName)
56
- ) {
57
- return metadata.jsonContract;
58
- }
59
- }
60
- return undefined;
61
- }
49
+ export { readFrameworkPacketJsonContract } from '@zlink-systems/stream-wire/internal/json';
62
50
 
63
51
  function tryDecoratorPacketName(payload: unknown): string | undefined {
64
52
  if (typeof payload !== 'object' || payload === null) {
@@ -86,11 +74,3 @@ function tryConstructorPacketName(payload: unknown): string | undefined {
86
74
  }
87
75
  return normalizePacketName(name);
88
76
  }
89
-
90
- function normalizePacketName(value: unknown): string | undefined {
91
- if (typeof value !== 'string') {
92
- return undefined;
93
- }
94
- const trimmed = value.trim();
95
- return trimmed.length > 0 ? trimmed : undefined;
96
- }
@@ -0,0 +1,58 @@
1
+ import type { ZLinkRequest } from '../../contracts/Handlers/Attributes';
2
+
3
+ const completedAdmission = Promise.resolve();
4
+ const ignoreAdmissionFailure = (): void => {};
5
+
6
+ export function createZLinkRequest<TReply>(
7
+ start: (onAdmitted: () => void) => Promise<TReply>,
8
+ deliverReply?: (reply: Promise<TReply>) => Promise<TReply>
9
+ ): ZLinkRequest<TReply> {
10
+ let admitted: Promise<void> | undefined;
11
+ let resolveAdmission: (() => void) | undefined;
12
+ let rejectAdmission: ((error: unknown) => void) | undefined;
13
+ const confirmAdmission = (): void => {
14
+ admitted ??= completedAdmission;
15
+ resolveAdmission?.();
16
+ };
17
+ const failAdmission = (error: unknown): void => {
18
+ if (admitted === undefined) {
19
+ admitted = Promise.reject(error);
20
+ // Existing callers may observe only the reply Promise. Observing the
21
+ // rejection here leaves the public admission Promise rejected.
22
+ void admitted.catch(ignoreAdmissionFailure);
23
+ } else {
24
+ rejectAdmission?.(error);
25
+ }
26
+ };
27
+ const observeAdmission = (): Promise<void> => {
28
+ if (admitted === undefined) {
29
+ admitted = new Promise<void>((resolve, reject) => {
30
+ resolveAdmission = resolve;
31
+ rejectAdmission = reject;
32
+ });
33
+ void admitted.catch(ignoreAdmissionFailure);
34
+ }
35
+ return admitted;
36
+ };
37
+ let pending: Promise<TReply>;
38
+ try {
39
+ pending = start(confirmAdmission);
40
+ } catch (error) {
41
+ pending = Promise.reject(error);
42
+ }
43
+ const observed = pending.then(
44
+ (value) => {
45
+ // A successful reply proves admission even without an observation callback.
46
+ confirmAdmission();
47
+ return value;
48
+ },
49
+ (error: unknown) => {
50
+ failAdmission(error);
51
+ throw error;
52
+ }
53
+ );
54
+ const reply = deliverReply?.(observed) ?? observed;
55
+ return Object.defineProperty(reply, 'admitted', {
56
+ get: observeAdmission
57
+ }) as ZLinkRequest<TReply>;
58
+ }
@@ -18,13 +18,17 @@ export interface ZLinkSubmitResult {
18
18
  readonly status: ZLinkSubmitStatus;
19
19
  }
20
20
 
21
- /** Projects immediate refusal and pending admission failure from their Core phase. */
21
+ export const submittedResult: ZLinkSubmitResult = Object.freeze({
22
+ status: ZLinkSubmitStatus.Submitted
23
+ });
24
+
25
+ /** Projects typed submit failure; capacity refusal has no admission wait token. */
22
26
  export function submitToRequestResult(result: number, phase: 'submit' | 'completion'): number {
23
27
  switch (result) {
24
28
  case SubmitResult.Ok:
25
29
  return RequestResult.Ok;
26
30
  case SubmitResult.Backpressured:
27
- return phase === 'submit' ? RequestResult.NotConnected : RequestResult.TimedOut;
31
+ return RequestResult.NotConnected;
28
32
  case SubmitResult.NotConnected:
29
33
  return RequestResult.NotConnected;
30
34
  case SubmitResult.NotFound:
@@ -54,7 +58,7 @@ export function classifySubmitResult(
54
58
  const terminal = submitToRequestResult(result, phase);
55
59
  switch (terminal) {
56
60
  case RequestResult.Ok:
57
- return { status: ZLinkSubmitStatus.Submitted };
61
+ return submittedResult;
58
62
  case RequestResult.TimedOut:
59
63
  return { status: ZLinkSubmitStatus.TimedOut };
60
64
  case RequestResult.NotFound:
@@ -7584,7 +7584,127 @@ function writeRelocationPendingTimerTickVector(input: RelocationPendingTimerTick
7584
7584
  export function decodeRelocationPendingTimerTickVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationPendingTimerTickVector { const reader = new Reader(bytes); const value = readRelocationPendingTimerTickVector(reader, context, {}, 0); reader.done("relocation-pending-timer-tick-vector"); return value; }
7585
7585
  export function encodeRelocationPendingTimerTickVector(value: RelocationPendingTimerTickVector, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationPendingTimerTickVector(value, writer, context, {}, 0); return writer.result(); }
7586
7586
 
7587
- export type RelocationEnvelopeV1 = { readonly relocation: RelocationId; readonly object: RelocationObjectIdentity; readonly applicationVersion: ApplicationVersion; readonly applicationStates: RelocationParticipantApplicationStateVector; readonly savedWork: SavedWorkVector; readonly timerRegistrations: RelocationTimerRegistrationVector; readonly pendingTimerTicks: RelocationPendingTimerTickVector };
7587
+ export type RelocationSessionBinding = { readonly participantId: NonzeroU64; readonly sessionOwnerNodeRid: Rid; readonly sessionOwnerNodeGeneration: NonzeroU64; readonly sessionOwnerId: Text8; readonly sessionOwnerLeaseGeneration: NonzeroU64; readonly sessionRid: Rid; readonly bindingGeneration: NonzeroU64 };
7588
+
7589
+ function readRelocationSessionBinding(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationSessionBinding {
7590
+ void context; void enclosing; void flags;
7591
+ const value: any = {};
7592
+ value["participantId"] = readNonzeroU64(reader, context, value, flags);
7593
+
7594
+
7595
+ value["sessionOwnerNodeRid"] = readRid(reader, context, value, flags);
7596
+
7597
+
7598
+ value["sessionOwnerNodeGeneration"] = readNonzeroU64(reader, context, value, flags);
7599
+
7600
+
7601
+ value["sessionOwnerId"] = readText8(reader, context, value, flags);
7602
+
7603
+
7604
+ value["sessionOwnerLeaseGeneration"] = readNonzeroU64(reader, context, value, flags);
7605
+
7606
+
7607
+ value["sessionRid"] = readRid(reader, context, value, flags);
7608
+
7609
+
7610
+ value["bindingGeneration"] = readNonzeroU64(reader, context, value, flags);
7611
+
7612
+
7613
+
7614
+
7615
+ return value;
7616
+ }
7617
+ function* readIncrementalRelocationSessionBinding(reader: IncrementalInput, context: ServiceWireDecoderContext, enclosing: any, flags: number): Generator<void, RelocationSessionBinding, void> {
7618
+ void context; void enclosing; void flags;
7619
+ const value: any = {};
7620
+ value["participantId"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
7621
+
7622
+
7623
+ value["sessionOwnerNodeRid"] = yield* readIncrementalRid(reader, context, value, flags);
7624
+
7625
+
7626
+ value["sessionOwnerNodeGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
7627
+
7628
+
7629
+ value["sessionOwnerId"] = yield* readIncrementalText8(reader, context, value, flags);
7630
+
7631
+
7632
+ value["sessionOwnerLeaseGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
7633
+
7634
+
7635
+ value["sessionRid"] = yield* readIncrementalRid(reader, context, value, flags);
7636
+
7637
+
7638
+ value["bindingGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
7639
+
7640
+
7641
+
7642
+
7643
+ return value;
7644
+ }
7645
+ function writeRelocationSessionBinding(input: RelocationSessionBinding, writer: Writer, context: ServiceWireDecoderContext, enclosing: any, flags: number): void {
7646
+ void context; void enclosing; void flags; const value: any = input;
7647
+
7648
+
7649
+ if (value["participantId"] === undefined) fail("participantId required");
7650
+
7651
+
7652
+ writeNonzeroU64(numeric(value["participantId"]), writer, context, value, flags);
7653
+ if (value["sessionOwnerNodeRid"] === undefined) fail("sessionOwnerNodeRid required");
7654
+
7655
+
7656
+ writeRid(value["sessionOwnerNodeRid"], writer, context, value, flags);
7657
+ if (value["sessionOwnerNodeGeneration"] === undefined) fail("sessionOwnerNodeGeneration required");
7658
+
7659
+
7660
+ writeNonzeroU64(numeric(value["sessionOwnerNodeGeneration"]), writer, context, value, flags);
7661
+ if (value["sessionOwnerId"] === undefined) fail("sessionOwnerId required");
7662
+
7663
+
7664
+ writeText8(value["sessionOwnerId"], writer, context, value, flags);
7665
+ if (value["sessionOwnerLeaseGeneration"] === undefined) fail("sessionOwnerLeaseGeneration required");
7666
+
7667
+
7668
+ writeNonzeroU64(numeric(value["sessionOwnerLeaseGeneration"]), writer, context, value, flags);
7669
+ if (value["sessionRid"] === undefined) fail("sessionRid required");
7670
+
7671
+
7672
+ writeRid(value["sessionRid"], writer, context, value, flags);
7673
+ if (value["bindingGeneration"] === undefined) fail("bindingGeneration required");
7674
+
7675
+
7676
+ writeNonzeroU64(numeric(value["bindingGeneration"]), writer, context, value, flags);
7677
+ }
7678
+ export function decodeRelocationSessionBinding(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBinding { const reader = new Reader(bytes); const value = readRelocationSessionBinding(reader, context, {}, 0); reader.done("relocation-session-binding"); return value; }
7679
+ export function encodeRelocationSessionBinding(value: RelocationSessionBinding, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationSessionBinding(value, writer, context, {}, 0); return writer.result(); }
7680
+
7681
+ export type RelocationSessionBindingVector = readonly RelocationSessionBinding[];
7682
+
7683
+ function readRelocationSessionBindingVector(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationSessionBindingVector {
7684
+ void context; void enclosing; void flags;
7685
+ const count = Number(readU32(reader, context, enclosing, flags)); if (count > 1024) fail("relocation-session-binding-vector count"); const value: any = Array.from({ length: count }, () => readRelocationSessionBinding(reader, context, enclosing, flags));
7686
+ try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
7687
+
7688
+ return value;
7689
+ }
7690
+ function* readIncrementalRelocationSessionBindingVector(reader: IncrementalInput, context: ServiceWireDecoderContext, enclosing: any, flags: number): Generator<void, RelocationSessionBindingVector, void> {
7691
+ void context; void enclosing; void flags;
7692
+ const count = Number(yield* readIncrementalU32(reader, context, enclosing, flags)); if (count > 1024) fail("relocation-session-binding-vector count"); const value: any[] = []; for (let index = 0; index < count; ++index) { const item = yield* readIncrementalRelocationSessionBinding(reader, context, enclosing, flags); try { value.push(item); } catch { capacityFail("relocation-session-binding-vector capacity"); } }
7693
+ try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
7694
+
7695
+ return value;
7696
+ }
7697
+ function writeRelocationSessionBindingVector(input: RelocationSessionBindingVector, writer: Writer, context: ServiceWireDecoderContext, enclosing: any, flags: number): void {
7698
+ void context; void enclosing; void flags; const value: any = input;
7699
+ if (!Array.isArray(value) || value.length > 1024) fail("relocation-session-binding-vector count");
7700
+ try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
7701
+
7702
+ writeU32(value.length, writer, context, enclosing, flags); for (const item of value) writeRelocationSessionBinding(item, writer, context, enclosing, flags);
7703
+ }
7704
+ export function decodeRelocationSessionBindingVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBindingVector { const reader = new Reader(bytes); const value = readRelocationSessionBindingVector(reader, context, {}, 0); reader.done("relocation-session-binding-vector"); return value; }
7705
+ export function encodeRelocationSessionBindingVector(value: RelocationSessionBindingVector, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationSessionBindingVector(value, writer, context, {}, 0); return writer.result(); }
7706
+
7707
+ export type RelocationEnvelopeV1 = { readonly relocation: RelocationId; readonly object: RelocationObjectIdentity; readonly applicationVersion: ApplicationVersion; readonly applicationStates: RelocationParticipantApplicationStateVector; readonly savedWork: SavedWorkVector; readonly timerRegistrations: RelocationTimerRegistrationVector; readonly pendingTimerTicks: RelocationPendingTimerTickVector; readonly sessionBindings: RelocationSessionBindingVector };
7588
7708
 
7589
7709
  function readRelocationEnvelopeV1(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationEnvelopeV1 {
7590
7710
  void context; void enclosing; void flags;
@@ -7610,6 +7730,9 @@ function readRelocationEnvelopeV1(reader: Reader, context: ServiceWireDecoderCon
7610
7730
  value["pendingTimerTicks"] = readRelocationPendingTimerTickVector(reader, context, value, flags);
7611
7731
 
7612
7732
 
7733
+ value["sessionBindings"] = readRelocationSessionBindingVector(reader, context, value, flags);
7734
+
7735
+
7613
7736
 
7614
7737
 
7615
7738
  return value;
@@ -7638,6 +7761,9 @@ function* readIncrementalRelocationEnvelopeV1(reader: IncrementalInput, context:
7638
7761
  value["pendingTimerTicks"] = yield* readIncrementalRelocationPendingTimerTickVector(reader, context, value, flags);
7639
7762
 
7640
7763
 
7764
+ value["sessionBindings"] = yield* readIncrementalRelocationSessionBindingVector(reader, context, value, flags);
7765
+
7766
+
7641
7767
 
7642
7768
 
7643
7769
  return value;
@@ -7674,6 +7800,10 @@ function writeRelocationEnvelopeV1(input: RelocationEnvelopeV1, writer: Writer,
7674
7800
 
7675
7801
 
7676
7802
  writeRelocationPendingTimerTickVector(value["pendingTimerTicks"], writer, context, value, flags);
7803
+ if (value["sessionBindings"] === undefined) fail("sessionBindings required");
7804
+
7805
+
7806
+ writeRelocationSessionBindingVector(value["sessionBindings"], writer, context, value, flags);
7677
7807
  }
7678
7808
  export function decodeRelocationEnvelopeV1(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationEnvelopeV1 { const reader = new Reader(bytes); const value = readRelocationEnvelopeV1(reader, context, {}, 0); reader.done("relocation-envelope-v1"); return value; }
7679
7809
  export function encodeRelocationEnvelopeV1(value: RelocationEnvelopeV1, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationEnvelopeV1(value, writer, context, {}, 0); return writer.result(); }