@zlink-systems/framework 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Common/CoreTypes.d.ts +6 -0
  3. package/dist/contracts/Common/CoreTypes.js +7 -0
  4. package/dist/contracts/Common/index.d.ts +1 -1
  5. package/dist/contracts/Common/index.js +0 -1
  6. package/dist/contracts/Configuration/InternalDefaults.d.ts +8 -0
  7. package/dist/contracts/Configuration/InternalDefaults.js +9 -1
  8. package/dist/contracts/Configuration/Registration.d.ts +13 -2
  9. package/dist/contracts/Configuration/Registration.js +58 -36
  10. package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +13 -1
  11. package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +38 -1
  12. package/dist/contracts/Configuration/RegistrationBuilders.d.ts +2 -3
  13. package/dist/contracts/Configuration/RegistrationBuilders.js +27 -32
  14. package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
  15. package/dist/contracts/Configuration/RegistrationValidators.js +15 -12
  16. package/dist/contracts/Configuration/TimerRegistrationValidator.js +3 -2
  17. package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +1 -1
  18. package/dist/contracts/Handlers/JsonContract.js +10 -4
  19. package/dist/contracts/Locations/Authority.d.ts +1 -1
  20. package/dist/contracts/Locations/Authority.js +3 -2
  21. package/dist/contracts/Locations/Options.js +1 -1
  22. package/dist/contracts/Locations/Stores.d.ts +12 -0
  23. package/dist/contracts/Locations/Stores.js +9 -0
  24. package/dist/contracts/Spots/Contracts.d.ts +1 -1
  25. package/dist/internal.d.ts +4 -0
  26. package/dist/internal.js +15 -1
  27. package/dist/nest-integration.d.ts +4 -2
  28. package/dist/nest-integration.js +14 -4
  29. package/dist/runtime/abort.d.ts +1 -0
  30. package/dist/runtime/abort.js +8 -5
  31. package/dist/runtime/activation-admission.d.ts +1 -2
  32. package/dist/runtime/activation-admission.js +2 -6
  33. package/dist/runtime/actors/actor-authority-payload-codec.d.ts +1 -2
  34. package/dist/runtime/actors/actor-authority-payload-codec.js +34 -18
  35. package/dist/runtime/actors/actor-client.d.ts +2 -2
  36. package/dist/runtime/actors/actor-client.js +42 -143
  37. package/dist/runtime/actors/actor-context.d.ts +3 -5
  38. package/dist/runtime/actors/actor-context.js +13 -11
  39. package/dist/runtime/actors/actor-handoff.d.ts +4 -4
  40. package/dist/runtime/actors/actor-handoff.js +8 -8
  41. package/dist/runtime/actors/actor-lifecycle-snapshot.js +2 -1
  42. package/dist/runtime/actors/actor-local-native-join.d.ts +11 -6
  43. package/dist/runtime/actors/actor-local-native-join.js +83 -105
  44. package/dist/runtime/actors/actor-native-lookup.js +2 -8
  45. package/dist/runtime/actors/actor-packet-relay-wire.d.ts +3 -3
  46. package/dist/runtime/actors/actor-packet-relay-wire.js +5 -3
  47. package/dist/runtime/actors/actor-remote-joiner.d.ts +1 -1
  48. package/dist/runtime/actors/actor-remote-joiner.js +5 -9
  49. package/dist/runtime/actors/actor-remote-wire.js +5 -3
  50. package/dist/runtime/actors/actor-request-deadline.d.ts +3 -0
  51. package/dist/runtime/actors/actor-request-deadline.js +31 -0
  52. package/dist/runtime/actors/actor-retry-delay.js +2 -1
  53. package/dist/runtime/actors/actor-runtime-state.d.ts +9 -21
  54. package/dist/runtime/actors/actor-runtime-state.js +70 -187
  55. package/dist/runtime/actors/bound-session-wire.js +2 -7
  56. package/dist/runtime/actors/deferred-join-completion.d.ts +11 -6
  57. package/dist/runtime/actors/deferred-join-completion.js +1 -0
  58. package/dist/runtime/actors/index.d.ts +9 -7
  59. package/dist/runtime/actors/index.js +87 -69
  60. package/dist/runtime/actors/spot-actor-dispatch.d.ts +3 -3
  61. package/dist/runtime/actors/spot-actor-dispatch.js +25 -10
  62. package/dist/runtime/actors/transferred-actor-rollback.d.ts +3 -5
  63. package/dist/runtime/actors/transferred-actor-rollback.js +9 -42
  64. package/dist/runtime/admission.d.ts +2 -0
  65. package/dist/runtime/admission.js +7 -1
  66. package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +1 -1
  67. package/dist/runtime/application-jobs/application-job-queue-scope.js +1 -1
  68. package/dist/runtime/backend/contracts/index.d.ts +6 -23
  69. package/dist/runtime/backend/mesh-actor-session-node-adapter.js +1 -17
  70. package/dist/runtime/backend/mesh-dispatch-pump.d.ts +1 -2
  71. package/dist/runtime/backend/mesh-dispatch-pump.js +95 -107
  72. package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +1 -1
  73. package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -6
  74. package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
  75. package/dist/runtime/backend/node/node-event-loop-poller.js +6 -7
  76. package/dist/runtime/backend/node/node-monitor-backend-adapter.js +1 -0
  77. package/dist/runtime/backend/node/node-raw-binding-port.js +40 -16
  78. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +14 -15
  79. package/dist/runtime/backend/node/node-raw-mesh-backend.js +146 -118
  80. package/dist/runtime/backend/node/node-socket-backend-adapter.js +3 -2
  81. package/dist/runtime/backend/raw-binding-port.d.ts +1 -1
  82. package/dist/runtime/backend/runtime-values.d.ts +4 -1
  83. package/dist/runtime/backend/runtime-values.js +2 -0
  84. package/dist/runtime/channels/channel-clients.d.ts +20 -8
  85. package/dist/runtime/channels/channel-clients.js +68 -52
  86. package/dist/runtime/channels/channel-envelope-inspection.js +2 -1
  87. package/dist/runtime/channels/channel-envelope.js +47 -29
  88. package/dist/runtime/channels/channel-outbound-operations.d.ts +3 -0
  89. package/dist/runtime/channels/channel-outbound-operations.js +9 -10
  90. package/dist/runtime/channels/channel-receive-loops.d.ts +8 -3
  91. package/dist/runtime/channels/channel-receive-loops.js +27 -6
  92. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +12 -1
  93. package/dist/runtime/channels/channel-runtime-lifecycle.js +48 -28
  94. package/dist/runtime/channels/channel-runtime-manager.js +5 -2
  95. package/dist/runtime/channels/channel-socket-options.js +3 -2
  96. package/dist/runtime/channels/channel-socket-registry.d.ts +14 -29
  97. package/dist/runtime/channels/channel-socket-registry.js +248 -174
  98. package/dist/runtime/channels/channel-transports.d.ts +11 -17
  99. package/dist/runtime/channels/channel-transports.js +68 -47
  100. package/dist/runtime/channels/client-server-location-runtime.d.ts +1 -1
  101. package/dist/runtime/channels/client-server-location-runtime.js +10 -11
  102. package/dist/runtime/channels/client-server-service-wire.d.ts +7 -2
  103. package/dist/runtime/channels/client-server-service-wire.js +32 -11
  104. package/dist/runtime/channels/dispatch-error-reporter.d.ts +1 -2
  105. package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
  106. package/dist/runtime/channels/fanout-location-runtime.d.ts +16 -3
  107. package/dist/runtime/channels/fanout-location-runtime.js +130 -72
  108. package/dist/runtime/channels/spot-direct-envelope.d.ts +1 -0
  109. package/dist/runtime/channels/spot-direct-envelope.js +4 -3
  110. package/dist/runtime/channels/spot-node-route-transport.js +3 -2
  111. package/dist/runtime/diagnostics/diagnostic-text.d.ts +2 -0
  112. package/dist/runtime/diagnostics/diagnostic-text.js +7 -0
  113. package/dist/runtime/diagnostics/dispatch-error-details.d.ts +3 -0
  114. package/dist/runtime/diagnostics/dispatch-error-details.js +30 -2
  115. package/dist/runtime/diagnostics/flow-context.d.ts +6 -0
  116. package/dist/runtime/diagnostics/flow-context.js +16 -2
  117. package/dist/runtime/diagnostics/index.d.ts +4 -2
  118. package/dist/runtime/diagnostics/index.js +14 -4
  119. package/dist/runtime/diagnostics/message-flow.d.ts +1 -1
  120. package/dist/runtime/diagnostics/message-flow.js +10 -19
  121. package/dist/runtime/diagnostics/runtime-metrics.d.ts +94 -31
  122. package/dist/runtime/diagnostics/runtime-metrics.js +168 -105
  123. package/dist/runtime/diagnostics/runtime-observation-queue.js +3 -2
  124. package/dist/runtime/diagnostics/topology-runtime-projections.d.ts +2 -4
  125. package/dist/runtime/diagnostics/topology-runtime-projections.js +135 -154
  126. package/dist/runtime/disposal.d.ts +5 -0
  127. package/dist/runtime/disposal.js +22 -0
  128. package/dist/runtime/execution/index.d.ts +12 -9
  129. package/dist/runtime/execution/index.js +58 -14
  130. package/dist/runtime/execution/serial-execution-queue.d.ts +8 -2
  131. package/dist/runtime/execution/serial-execution-queue.js +54 -15
  132. package/dist/runtime/execution/state-lane.d.ts +8 -1
  133. package/dist/runtime/execution/state-lane.js +118 -3
  134. package/dist/runtime/foundation/actor-join-recovery-codec.d.ts +3 -0
  135. package/dist/runtime/foundation/actor-join-recovery-codec.js +15 -11
  136. package/dist/runtime/foundation/event-loop-resources.d.ts +2 -24
  137. package/dist/runtime/foundation/event-loop-resources.js +6 -119
  138. package/dist/runtime/foundation/operation-identity.d.ts +2 -0
  139. package/dist/runtime/foundation/operation-identity.js +9 -5
  140. package/dist/runtime/foundation/operation-registry.d.ts +5 -7
  141. package/dist/runtime/foundation/operation-registry.js +34 -44
  142. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +8 -5
  143. package/dist/runtime/foundation/raw-service-mesh-runtime.js +62 -83
  144. package/dist/runtime/foundation/runtime-state-projections.d.ts +3 -1
  145. package/dist/runtime/foundation/runtime-state-projections.js +8 -0
  146. package/dist/runtime/foundation/service-authority-payload-codec.js +22 -12
  147. package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
  148. package/dist/runtime/foundation/service-discovery-registry.js +22 -3
  149. package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +8 -4
  150. package/dist/runtime/foundation/service-liveness-registry.js +2 -1
  151. package/dist/runtime/foundation/service-maintenance-runtime.d.ts +0 -1
  152. package/dist/runtime/foundation/service-maintenance-runtime.js +0 -6
  153. package/dist/runtime/foundation/service-metadata-codec.js +3 -3
  154. package/dist/runtime/foundation/service-relocation-aggregate-committer.d.ts +2 -5
  155. package/dist/runtime/foundation/service-relocation-aggregate-committer.js +1 -48
  156. package/dist/runtime/foundation/service-relocation-object-owner.js +3 -2
  157. package/dist/runtime/foundation/service-relocation-runtime.js +43 -32
  158. package/dist/runtime/foundation/service-runtime-contracts.d.ts +40 -8
  159. package/dist/runtime/foundation/service-runtime-contracts.js +25 -1
  160. package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +0 -12
  161. package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
  162. package/dist/runtime/foundation/service-stateful-registry.js +10 -2
  163. package/dist/runtime/foundation/service-stateful-runtime.d.ts +26 -25
  164. package/dist/runtime/foundation/service-stateful-runtime.js +217 -204
  165. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -3
  166. package/dist/runtime/foundation/service-stateful-wire-codec.js +89 -55
  167. package/dist/runtime/foundation/service-topology-registry.d.ts +0 -1
  168. package/dist/runtime/foundation/service-topology-registry.js +17 -32
  169. package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +5 -0
  170. package/dist/runtime/foundation/service-wire-binary-primitives.js +6 -0
  171. package/dist/runtime/foundation/service-wire-codec.js +10 -8
  172. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  173. package/dist/runtime/foundation/service-wire-constants.generated.js +2 -1
  174. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
  175. package/dist/runtime/foundation/service-wire-m6a-codec.js +23 -13
  176. package/dist/runtime/framework-errors-internal.d.ts +2 -1
  177. package/dist/runtime/framework-errors-internal.js +343 -122
  178. package/dist/runtime/handlers/handler-instance-scope.d.ts +3 -1
  179. package/dist/runtime/handlers/handler-instance-scope.js +61 -74
  180. package/dist/runtime/host/actor-packet-relay.d.ts +9 -6
  181. package/dist/runtime/host/actor-packet-relay.js +48 -91
  182. package/dist/runtime/host/actor-placement-coordinator.js +7 -5
  183. package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
  184. package/dist/runtime/host/actor-runtime-options-factory.js +17 -4
  185. package/dist/runtime/host/actor-transfer-runtime.d.ts +16 -18
  186. package/dist/runtime/host/actor-transfer-runtime.js +143 -176
  187. package/dist/runtime/host/application-job-queue.js +16 -33
  188. package/dist/runtime/host/bound-session-relay.js +1 -1
  189. package/dist/runtime/host/channel-runtime-options-factory.js +1 -1
  190. package/dist/runtime/host/index.d.ts +14 -13
  191. package/dist/runtime/host/index.js +190 -157
  192. package/dist/runtime/host/instance-activation-authority.d.ts +2 -3
  193. package/dist/runtime/host/instance-activation-authority.js +17 -45
  194. package/dist/runtime/host/location-runtime-owner.d.ts +1 -1
  195. package/dist/runtime/host/location-runtime-owner.js +2 -2
  196. package/dist/runtime/host/remote-actor-join-receiver.d.ts +2 -2
  197. package/dist/runtime/host/remote-actor-join-receiver.js +1 -14
  198. package/dist/runtime/host/remote-actor-packet-target-store.d.ts +3 -2
  199. package/dist/runtime/host/remote-actor-packet-target-store.js +8 -47
  200. package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -3
  201. package/dist/runtime/host/remote-bound-session-relay.js +7 -20
  202. package/dist/runtime/host/route-mesh-runtime.d.ts +13 -11
  203. package/dist/runtime/host/route-mesh-runtime.js +171 -252
  204. package/dist/runtime/host/runtime-shutdown.d.ts +2 -0
  205. package/dist/runtime/host/runtime-shutdown.js +18 -21
  206. package/dist/runtime/host/service-relocation-control.js +6 -1
  207. package/dist/runtime/host/service-relocation-host-runtime.d.ts +21 -30
  208. package/dist/runtime/host/service-relocation-host-runtime.js +508 -416
  209. package/dist/runtime/host/spot-address-transport.d.ts +2 -3
  210. package/dist/runtime/host/spot-address-transport.js +34 -136
  211. package/dist/runtime/host/spot-node-runtime-options-factory.d.ts +1 -1
  212. package/dist/runtime/host/spot-node-runtime-options-factory.js +3 -2
  213. package/dist/runtime/host/spot-runtime-options-factory.d.ts +4 -10
  214. package/dist/runtime/host/spot-runtime-options-factory.js +50 -14
  215. package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -3
  216. package/dist/runtime/host/user-spot-creation-coordinator.js +11 -8
  217. package/dist/runtime/locations/aggregate-inventory-store.js +13 -10
  218. package/dist/runtime/locations/authority-key-codec.js +4 -3
  219. package/dist/runtime/locations/auto-connect-reconciler.d.ts +4 -0
  220. package/dist/runtime/locations/auto-connect-reconciler.js +37 -25
  221. package/dist/runtime/locations/creation-operation-id.js +6 -4
  222. package/dist/runtime/locations/domain-store-contract.d.ts +3 -3
  223. package/dist/runtime/locations/in-memory-authority-store.js +31 -15
  224. package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
  225. package/dist/runtime/locations/in-memory-location-store.js +17 -14
  226. package/dist/runtime/locations/in-memory-provider-location-store.d.ts +1 -0
  227. package/dist/runtime/locations/in-memory-provider-location-store.js +72 -22
  228. package/dist/runtime/locations/key-codec.js +3 -2
  229. package/dist/runtime/locations/lease-tracker.d.ts +3 -5
  230. package/dist/runtime/locations/lease-tracker.js +7 -11
  231. package/dist/runtime/locations/lifecycle.d.ts +4 -9
  232. package/dist/runtime/locations/lifecycle.js +2 -31
  233. package/dist/runtime/locations/location-store-failure.d.ts +2 -0
  234. package/dist/runtime/locations/location-store-failure.js +7 -0
  235. package/dist/runtime/locations/location-store-pages.d.ts +3 -0
  236. package/dist/runtime/locations/location-store-pages.js +13 -0
  237. package/dist/runtime/locations/location-store-repository.d.ts +5 -7
  238. package/dist/runtime/locations/location-store-repository.js +303 -332
  239. package/dist/runtime/locations/relocation-blob.js +18 -5
  240. package/dist/runtime/locations/resolvers.d.ts +5 -5
  241. package/dist/runtime/locations/resolvers.js +37 -28
  242. package/dist/runtime/locations/runtime.d.ts +5 -4
  243. package/dist/runtime/locations/runtime.js +123 -92
  244. package/dist/runtime/locations/spot-location-claims.d.ts +6 -0
  245. package/dist/runtime/locations/spot-location-claims.js +42 -1
  246. package/dist/runtime/messaging/payload-codec.js +26 -20
  247. package/dist/runtime/messaging/submission-result.d.ts +3 -0
  248. package/dist/runtime/messaging/submission-result.js +48 -0
  249. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
  250. package/dist/runtime/protocol/service_wire_codec.generated.js +12 -7
  251. package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +4 -1
  252. package/dist/runtime/spots/index.d.ts +14 -20
  253. package/dist/runtime/spots/index.js +302 -176
  254. package/dist/runtime/spots/spot-activation-registry.d.ts +3 -5
  255. package/dist/runtime/spots/spot-activation-registry.js +14 -50
  256. package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
  257. package/dist/runtime/spots/spot-activation-state.js +2 -2
  258. package/dist/runtime/spots/spot-activation.d.ts +3 -4
  259. package/dist/runtime/spots/spot-activation.js +49 -32
  260. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -2
  261. package/dist/runtime/spots/spot-actor-admission-coordinator.js +3 -40
  262. package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +10 -18
  263. package/dist/runtime/spots/spot-actor-join-dispatch.js +4 -52
  264. package/dist/runtime/spots/spot-actor-membership.d.ts +4 -6
  265. package/dist/runtime/spots/spot-actor-membership.js +22 -45
  266. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +0 -1
  267. package/dist/runtime/spots/spot-actor-packet-dispatch.js +0 -9
  268. package/dist/runtime/spots/spot-actor-packet-relay-dispatch.d.ts +2 -2
  269. package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -7
  270. package/dist/runtime/spots/spot-context.d.ts +2 -2
  271. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -2
  272. package/dist/runtime/spots/spot-entry-activation.js +9 -20
  273. package/dist/runtime/spots/spot-lifecycle-metrics.js +3 -2
  274. package/dist/runtime/spots/spot-manager-public.d.ts +5 -6
  275. package/dist/runtime/spots/spot-manager-public.js +5 -4
  276. package/dist/runtime/spots/spot-node-autoconnect.js +22 -31
  277. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -18
  278. package/dist/runtime/spots/spot-node-runtime-manager.js +67 -72
  279. package/dist/runtime/spots/spot-outbound.d.ts +4 -3
  280. package/dist/runtime/spots/spot-outbound.js +9 -8
  281. package/dist/runtime/spots/spot-remote-codec.js +5 -3
  282. package/dist/runtime/spots/spot-route-packet-dispatch.d.ts +2 -2
  283. package/dist/runtime/spots/spot-route-packet-dispatch.js +8 -8
  284. package/dist/runtime/spots/spot-route-replies.d.ts +2 -2
  285. package/dist/runtime/spots/spot-route-replies.js +3 -1
  286. package/dist/runtime/spots/spot-routed-actor-admission.d.ts +3 -3
  287. package/dist/runtime/spots/spot-routed-actor-admission.js +3 -12
  288. package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +1 -2
  289. package/dist/runtime/spots/spot-routed-frame-dispatch.js +0 -1
  290. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +4 -0
  291. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +65 -15
  292. package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -16
  293. package/dist/runtime/spots/spot-serial-executor.js +2 -2
  294. package/dist/runtime/spots/spot-serial-turn-executor.d.ts +27 -7
  295. package/dist/runtime/spots/spot-serial-turn-executor.js +83 -11
  296. package/dist/runtime/spots/spot-timer.d.ts +3 -2
  297. package/dist/runtime/streams/actor-session-binding-registry.d.ts +16 -29
  298. package/dist/runtime/streams/actor-session-binding-registry.js +142 -212
  299. package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +1 -4
  300. package/dist/runtime/streams/bound-actor-relay-sender.d.ts +6 -2
  301. package/dist/runtime/streams/bound-actor-relay-sender.js +57 -33
  302. package/dist/runtime/streams/bound-session-service.d.ts +7 -0
  303. package/dist/runtime/streams/bound-session-service.js +11 -1
  304. package/dist/runtime/streams/index.d.ts +14 -15
  305. package/dist/runtime/streams/index.js +20 -21
  306. package/dist/runtime/streams/managed-stream.d.ts +3 -0
  307. package/dist/runtime/streams/managed-stream.js +17 -8
  308. package/dist/runtime/streams/native-fallback-bound-session.js +1 -3
  309. package/dist/runtime/streams/protocol.d.ts +6 -33
  310. package/dist/runtime/streams/protocol.js +38 -110
  311. package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -3
  312. package/dist/runtime/streams/session-actor-coordinator.js +12 -4
  313. package/dist/runtime/streams/session-calls.d.ts +1 -1
  314. package/dist/runtime/streams/session-calls.js +5 -4
  315. package/dist/runtime/streams/session-context.d.ts +6 -6
  316. package/dist/runtime/streams/session-context.js +22 -4
  317. package/dist/runtime/streams/session-requests.js +2 -1
  318. package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +16 -1
  319. package/dist/runtime/streams/stream-frame-factory.js +2 -2
  320. package/dist/runtime/streams/stream-session-runtime.d.ts +10 -11
  321. package/dist/runtime/streams/stream-session-runtime.js +25 -33
  322. package/dist/runtime/workers/index.d.ts +2 -2
  323. package/dist/runtime/workers/index.js +5 -4
  324. package/package.json +3 -3
  325. package/src/contracts/Common/CoreTypes.ts +7 -0
  326. package/src/contracts/Common/index.ts +1 -1
  327. package/src/contracts/Configuration/InternalDefaults.ts +12 -0
  328. package/src/contracts/Configuration/Registration.ts +92 -48
  329. package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +44 -2
  330. package/src/contracts/Configuration/RegistrationBuilders.ts +77 -68
  331. package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
  332. package/src/contracts/Configuration/RegistrationValidators.ts +19 -13
  333. package/src/contracts/Configuration/TimerRegistrationValidator.ts +4 -2
  334. package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -0
  335. package/src/contracts/Handlers/JsonContract.ts +14 -4
  336. package/src/contracts/Locations/Authority.ts +7 -3
  337. package/src/contracts/Locations/Options.ts +1 -1
  338. package/src/contracts/Locations/Stores.ts +14 -0
  339. package/src/contracts/Spots/Contracts.ts +1 -1
  340. package/src/internal.ts +14 -0
  341. package/src/nest-integration.ts +28 -10
  342. package/src/runtime/abort.ts +6 -5
  343. package/src/runtime/activation-admission.ts +2 -8
  344. package/src/runtime/actors/actor-authority-payload-codec.ts +58 -20
  345. package/src/runtime/actors/actor-client.ts +77 -204
  346. package/src/runtime/actors/actor-context.ts +39 -33
  347. package/src/runtime/actors/actor-handoff.ts +24 -22
  348. package/src/runtime/actors/actor-lifecycle-snapshot.ts +2 -1
  349. package/src/runtime/actors/actor-local-native-join.ts +172 -174
  350. package/src/runtime/actors/actor-native-lookup.ts +2 -9
  351. package/src/runtime/actors/actor-packet-relay-wire.ts +18 -12
  352. package/src/runtime/actors/actor-remote-joiner.ts +9 -11
  353. package/src/runtime/actors/actor-remote-wire.ts +5 -3
  354. package/src/runtime/actors/actor-request-deadline.ts +49 -0
  355. package/src/runtime/actors/actor-retry-delay.ts +2 -1
  356. package/src/runtime/actors/actor-runtime-state.ts +85 -247
  357. package/src/runtime/actors/bound-session-wire.ts +2 -8
  358. package/src/runtime/actors/deferred-join-completion.ts +10 -6
  359. package/src/runtime/actors/index.ts +100 -79
  360. package/src/runtime/actors/spot-actor-dispatch.ts +60 -29
  361. package/src/runtime/actors/transferred-actor-rollback.ts +11 -62
  362. package/src/runtime/admission.ts +8 -1
  363. package/src/runtime/application-jobs/application-job-queue-scope.ts +4 -4
  364. package/src/runtime/backend/contracts/index.ts +13 -29
  365. package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -18
  366. package/src/runtime/backend/mesh-dispatch-pump.ts +111 -117
  367. package/src/runtime/backend/node/node-backend-adapter-support.ts +23 -6
  368. package/src/runtime/backend/node/node-event-loop-poller.ts +8 -12
  369. package/src/runtime/backend/node/node-monitor-backend-adapter.ts +1 -0
  370. package/src/runtime/backend/node/node-raw-binding-port.ts +41 -20
  371. package/src/runtime/backend/node/node-raw-mesh-backend.ts +227 -170
  372. package/src/runtime/backend/node/node-socket-backend-adapter.ts +3 -2
  373. package/src/runtime/backend/raw-binding-port.ts +1 -1
  374. package/src/runtime/backend/runtime-values.ts +4 -1
  375. package/src/runtime/channels/channel-clients.ts +132 -85
  376. package/src/runtime/channels/channel-envelope-inspection.ts +2 -1
  377. package/src/runtime/channels/channel-envelope.ts +58 -29
  378. package/src/runtime/channels/channel-outbound-operations.ts +10 -23
  379. package/src/runtime/channels/channel-receive-loops.ts +39 -7
  380. package/src/runtime/channels/channel-runtime-lifecycle.ts +60 -27
  381. package/src/runtime/channels/channel-runtime-manager.ts +6 -2
  382. package/src/runtime/channels/channel-socket-options.ts +8 -2
  383. package/src/runtime/channels/channel-socket-registry.ts +301 -192
  384. package/src/runtime/channels/channel-transports.ts +161 -112
  385. package/src/runtime/channels/client-server-location-runtime.ts +17 -17
  386. package/src/runtime/channels/client-server-service-wire.ts +40 -12
  387. package/src/runtime/channels/dispatch-error-reporter.ts +7 -5
  388. package/src/runtime/channels/fanout-location-runtime.ts +172 -91
  389. package/src/runtime/channels/spot-direct-envelope.ts +1 -1
  390. package/src/runtime/channels/spot-node-route-transport.ts +5 -2
  391. package/src/runtime/diagnostics/diagnostic-text.ts +4 -0
  392. package/src/runtime/diagnostics/dispatch-error-details.ts +36 -1
  393. package/src/runtime/diagnostics/flow-context.ts +16 -2
  394. package/src/runtime/diagnostics/index.ts +27 -17
  395. package/src/runtime/diagnostics/message-flow.ts +15 -25
  396. package/src/runtime/diagnostics/runtime-metrics.ts +181 -113
  397. package/src/runtime/diagnostics/runtime-observation-queue.ts +3 -2
  398. package/src/runtime/diagnostics/topology-runtime-projections.ts +194 -162
  399. package/src/runtime/disposal.ts +19 -0
  400. package/src/runtime/execution/index.ts +60 -20
  401. package/src/runtime/execution/serial-execution-queue.ts +131 -18
  402. package/src/runtime/execution/state-lane.ts +142 -4
  403. package/src/runtime/foundation/actor-join-recovery-codec.ts +13 -8
  404. package/src/runtime/foundation/event-loop-resources.ts +5 -122
  405. package/src/runtime/foundation/operation-identity.ts +11 -5
  406. package/src/runtime/foundation/operation-registry.ts +33 -50
  407. package/src/runtime/foundation/raw-service-mesh-runtime.ts +110 -111
  408. package/src/runtime/foundation/runtime-state-projections.ts +9 -1
  409. package/src/runtime/foundation/service-authority-payload-codec.ts +31 -13
  410. package/src/runtime/foundation/service-discovery-registry.ts +32 -3
  411. package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +12 -4
  412. package/src/runtime/foundation/service-liveness-registry.ts +2 -1
  413. package/src/runtime/foundation/service-maintenance-runtime.ts +0 -10
  414. package/src/runtime/foundation/service-metadata-codec.ts +2 -2
  415. package/src/runtime/foundation/service-relocation-aggregate-committer.ts +3 -66
  416. package/src/runtime/foundation/service-relocation-object-owner.ts +5 -2
  417. package/src/runtime/foundation/service-relocation-runtime.ts +57 -35
  418. package/src/runtime/foundation/service-runtime-contracts.ts +46 -10
  419. package/src/runtime/foundation/service-session-binding-ingress-port.ts +0 -17
  420. package/src/runtime/foundation/service-stateful-registry.ts +14 -2
  421. package/src/runtime/foundation/service-stateful-runtime.ts +322 -276
  422. package/src/runtime/foundation/service-stateful-wire-codec.ts +128 -80
  423. package/src/runtime/foundation/service-topology-registry.ts +23 -32
  424. package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -0
  425. package/src/runtime/foundation/service-wire-codec.ts +15 -8
  426. package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
  427. package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -15
  428. package/src/runtime/framework-errors-internal.ts +380 -134
  429. package/src/runtime/handlers/handler-instance-scope.ts +68 -95
  430. package/src/runtime/host/actor-packet-relay.ts +57 -147
  431. package/src/runtime/host/actor-placement-coordinator.ts +8 -5
  432. package/src/runtime/host/actor-runtime-options-factory.ts +27 -8
  433. package/src/runtime/host/actor-transfer-runtime.ts +180 -260
  434. package/src/runtime/host/application-job-queue.ts +28 -34
  435. package/src/runtime/host/bound-session-relay.ts +1 -2
  436. package/src/runtime/host/channel-runtime-options-factory.ts +1 -2
  437. package/src/runtime/host/index.ts +327 -296
  438. package/src/runtime/host/instance-activation-authority.ts +89 -109
  439. package/src/runtime/host/location-runtime-owner.ts +4 -2
  440. package/src/runtime/host/remote-actor-join-receiver.ts +3 -31
  441. package/src/runtime/host/remote-actor-packet-target-store.ts +17 -58
  442. package/src/runtime/host/remote-bound-session-relay.ts +8 -41
  443. package/src/runtime/host/route-mesh-runtime.ts +228 -271
  444. package/src/runtime/host/runtime-shutdown.ts +17 -21
  445. package/src/runtime/host/service-relocation-control.ts +14 -1
  446. package/src/runtime/host/service-relocation-host-runtime.ts +699 -561
  447. package/src/runtime/host/spot-address-transport.ts +73 -195
  448. package/src/runtime/host/spot-node-runtime-options-factory.ts +6 -3
  449. package/src/runtime/host/spot-runtime-options-factory.ts +73 -22
  450. package/src/runtime/host/user-spot-creation-coordinator.ts +36 -22
  451. package/src/runtime/locations/aggregate-inventory-store.ts +16 -13
  452. package/src/runtime/locations/authority-key-codec.ts +7 -3
  453. package/src/runtime/locations/auto-connect-reconciler.ts +39 -26
  454. package/src/runtime/locations/creation-operation-id.ts +6 -3
  455. package/src/runtime/locations/domain-store-contract.ts +12 -3
  456. package/src/runtime/locations/in-memory-authority-store.ts +44 -15
  457. package/src/runtime/locations/in-memory-location-store.ts +50 -39
  458. package/src/runtime/locations/in-memory-provider-location-store.ts +100 -25
  459. package/src/runtime/locations/key-codec.ts +3 -2
  460. package/src/runtime/locations/lease-tracker.ts +8 -14
  461. package/src/runtime/locations/lifecycle.ts +13 -43
  462. package/src/runtime/locations/location-store-failure.ts +4 -0
  463. package/src/runtime/locations/location-store-pages.ts +18 -0
  464. package/src/runtime/locations/location-store-repository.ts +450 -478
  465. package/src/runtime/locations/relocation-blob.ts +17 -6
  466. package/src/runtime/locations/resolvers.ts +75 -49
  467. package/src/runtime/locations/runtime.ts +220 -110
  468. package/src/runtime/locations/spot-location-claims.ts +58 -1
  469. package/src/runtime/messaging/payload-codec.ts +35 -24
  470. package/src/runtime/messaging/submission-result.ts +57 -1
  471. package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
  472. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  473. package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +4 -1
  474. package/src/runtime/spots/index.ts +433 -229
  475. package/src/runtime/spots/spot-activation-registry.ts +30 -69
  476. package/src/runtime/spots/spot-activation-state.ts +2 -2
  477. package/src/runtime/spots/spot-activation.ts +67 -37
  478. package/src/runtime/spots/spot-actor-admission-coordinator.ts +5 -57
  479. package/src/runtime/spots/spot-actor-join-dispatch.ts +24 -77
  480. package/src/runtime/spots/spot-actor-membership.ts +40 -72
  481. package/src/runtime/spots/spot-actor-packet-dispatch.ts +0 -16
  482. package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +3 -15
  483. package/src/runtime/spots/spot-context.ts +3 -3
  484. package/src/runtime/spots/spot-entry-activation.ts +13 -30
  485. package/src/runtime/spots/spot-lifecycle-metrics.ts +3 -2
  486. package/src/runtime/spots/spot-manager-public.ts +21 -17
  487. package/src/runtime/spots/spot-node-autoconnect.ts +20 -26
  488. package/src/runtime/spots/spot-node-runtime-manager.ts +136 -125
  489. package/src/runtime/spots/spot-outbound.ts +45 -23
  490. package/src/runtime/spots/spot-remote-codec.ts +7 -3
  491. package/src/runtime/spots/spot-route-packet-dispatch.ts +25 -24
  492. package/src/runtime/spots/spot-route-replies.ts +6 -4
  493. package/src/runtime/spots/spot-routed-actor-admission.ts +13 -26
  494. package/src/runtime/spots/spot-routed-frame-dispatch.ts +2 -3
  495. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +95 -22
  496. package/src/runtime/spots/spot-runtime-ports.ts +5 -27
  497. package/src/runtime/spots/spot-serial-executor.ts +2 -2
  498. package/src/runtime/spots/spot-serial-turn-executor.ts +112 -11
  499. package/src/runtime/spots/spot-timer.ts +3 -2
  500. package/src/runtime/streams/actor-session-binding-registry.ts +179 -269
  501. package/src/runtime/streams/actor-session-binding-runtime-owner.ts +0 -8
  502. package/src/runtime/streams/bound-actor-relay-sender.ts +89 -43
  503. package/src/runtime/streams/bound-session-service.ts +21 -1
  504. package/src/runtime/streams/index.ts +76 -64
  505. package/src/runtime/streams/managed-stream.ts +29 -10
  506. package/src/runtime/streams/native-fallback-bound-session.ts +1 -3
  507. package/src/runtime/streams/protocol.ts +34 -88
  508. package/src/runtime/streams/session-actor-coordinator.ts +17 -5
  509. package/src/runtime/streams/session-calls.ts +6 -5
  510. package/src/runtime/streams/session-context.ts +54 -10
  511. package/src/runtime/streams/session-requests.ts +2 -1
  512. package/src/runtime/streams/stream-binding-runtime-ports.ts +22 -1
  513. package/src/runtime/streams/stream-frame-factory.ts +2 -3
  514. package/src/runtime/streams/stream-session-runtime.ts +57 -59
  515. package/src/runtime/workers/index.ts +13 -12
  516. package/dist/runtime/actors/post-commit-actor-location.d.ts +0 -19
  517. package/dist/runtime/actors/post-commit-actor-location.js +0 -72
  518. package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +0 -26
  519. package/dist/runtime/spots/spot-native-actor-join-admission.js +0 -106
  520. package/src/runtime/actors/post-commit-actor-location.ts +0 -121
  521. package/src/runtime/spots/spot-native-actor-join-admission.ts +0 -155
@@ -1,3 +1,4 @@
1
+ import { dispatchReasonFromError } from '../diagnostics/dispatch-error-details';
1
2
  import type {
2
3
  ActorRef,
3
4
  RoutingId,
@@ -32,6 +33,7 @@ import {
32
33
  ZLinkMessage,
33
34
  ZLinkFrameworkException,
34
35
  ZLinkFrameworkErrorKind,
36
+ ZLinkFrameworkRuntimeState,
35
37
  ZLinkSpotCloseReason,
36
38
  ZLinkSpotKind
37
39
  } from '../../contracts';
@@ -48,6 +50,7 @@ import {
48
50
  runWithFlow,
49
51
  type ZLinkRuntimeEventPublisher
50
52
  } from '../diagnostics';
53
+ import { diagnosticTextOrAbsent } from '../diagnostics/diagnostic-text';
51
54
  import { ZLinkBufferMessage as RuntimeMessage } from '../backend/runtime-message';
52
55
  import { SubmitResult } from '../backend/runtime-values';
53
56
  import {
@@ -59,10 +62,10 @@ import {
59
62
  } from '../foundation/service-runtime-contracts';
60
63
  import { zlinkMetadataByteLength, zlinkSerialWorkOptions } from '../execution/serial-work-size';
61
64
  import { ZLinkConfigurationException } from '../configuration';
65
+ import { releaseApplicationJobPermitBeforeHandler } from '../application-jobs/application-job-queue-scope';
62
66
  import {
63
67
  ZLinkFrameworkInternalErrorKind,
64
68
  createInternalFrameworkException,
65
- internalFrameworkErrorKind,
66
69
  internalFrameworkWireReply
67
70
  } from '../framework-errors-internal';
68
71
  import type { ZLinkBackendSpot, ZLinkBackendSpotNode } from '../backend/contracts';
@@ -132,7 +135,7 @@ export { ZLinkRuntimeSpotPublisherTransport } from './spot-publisher-transport';
132
135
  import { ZLinkSpotActivationRegistry } from './spot-activation-registry';
133
136
  import type { ZLinkSpotActivation } from './spot-activation-state';
134
137
  import { ZLinkSpotActivationLifecycle, type ZLinkNativeSpotAuthority } from './spot-activation';
135
- import { ZLinkSpotActorMembership, type ZLinkActorJoinRollback } from './spot-actor-membership';
138
+ import { ZLinkSpotActorMembership } from './spot-actor-membership';
136
139
  import { ZLinkFormalRemoteActorTransferRegistry } from './formal-remote-actor-transfer-registry';
137
140
  import {
138
141
  ZLinkFormalRemoteActorAdmissionRegistry,
@@ -204,6 +207,11 @@ export interface ZLinkSpotManagerOptions {
204
207
  actor: ZLinkActor,
205
208
  handoffBacklog?: readonly ZLinkActorHandoffPacket[]
206
209
  ) => Promise<void>;
210
+ readonly executeEntryActor?: <T>(
211
+ meshName: string,
212
+ actorId: string,
213
+ operation: () => Promise<T>
214
+ ) => Promise<T>;
207
215
  readonly actorCountProvider?: (spotId: RoutingId) => number;
208
216
  readonly userSpotExecutionMode?: (
209
217
  meshName: string,
@@ -217,7 +225,6 @@ export interface ZLinkSpotManagerOptions {
217
225
  readonly actorRef?: ActorRef;
218
226
  readonly spotId?: RoutingId;
219
227
  };
220
- readonly actorBindingGenerationObserver?: (actorId: string, generation: bigint) => void;
221
228
  readonly channelClient?: ZLinkChannelClient;
222
229
  readonly fanoutClient?: ZLinkFanoutClient;
223
230
  readonly spotPublisherClient?: ZLinkSpotPublisherClient;
@@ -225,7 +232,6 @@ export interface ZLinkSpotManagerOptions {
225
232
  readonly routedTransport?: ZLinkSpotRoutedTransport;
226
233
  readonly addressTransport?: import('./spot-outbound').ZLinkSpotAddressTransport;
227
234
  readonly spotRouterChannelIdForMesh?: (meshName: string) => string;
228
- readonly channelMeshNameForChannel?: (channelName: string) => string | undefined;
229
235
  readonly providerResolver?: ZLinkProviderResolver;
230
236
  readonly dispatchErrors?: ZLinkDispatchErrorReporter;
231
237
  readonly closeErrorSink?: import('../diagnostics/dispatch-error-port').ZLinkDispatchErrorSink;
@@ -242,19 +248,26 @@ export interface ZLinkSpotManagerOptions {
242
248
  meshName: string,
243
249
  spotId: RoutingId,
244
250
  onCommitted: () => void
245
- ) => Promise<{ release(): Promise<void> } | undefined>;
251
+ ) => Promise<
252
+ import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
253
+ >;
246
254
  readonly beginInstanceClosingAuthority?: (
247
255
  meshName: string,
248
256
  spotId: RoutingId,
249
- onCommitted: () => void
250
- ) => Promise<{ release(): Promise<void> } | undefined>;
257
+ onCommitted: () => void,
258
+ objectGeneration: bigint
259
+ ) => Promise<
260
+ import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
261
+ >;
251
262
  /** Moves a local User Spot incarnation's authority to Closing for a context Close. */
252
263
  readonly beginUserClosingAuthority?: (
253
264
  meshName: string,
254
265
  spotId: RoutingId,
255
266
  objectGeneration: bigint,
256
267
  onCommitted: () => void
257
- ) => Promise<{ release(): Promise<void> } | undefined>;
268
+ ) => Promise<
269
+ import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
270
+ >;
258
271
  readonly instanceSpotApplicationTargetProvider?: (
259
272
  meshName: string,
260
273
  spotId: RoutingId
@@ -284,13 +297,16 @@ export interface ZLinkSpotManagerOptions {
284
297
  readonly ownerLeaseGeneration: bigint;
285
298
  }) => Promise<{ readonly actorType: string }>;
286
299
  readonly actorLifecycleResolver?: (actorId: string) => ZLinkActor | undefined;
287
- readonly detachedTaskRunner?: ZLinkDetachedTaskRunner;
300
+ readonly detachedTaskRunner: ZLinkDetachedTaskRunner;
288
301
  readonly actorTransferRuntime?: ZLinkSpotActorTransferRuntime;
289
302
  readonly boundSessionRuntime?: ZLinkSpotBoundSessionRuntime;
290
303
  readonly actorHandoffRuntime?: ZLinkSpotActorHandoffRuntime;
291
304
  readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
292
305
  readonly admission?: ZLinkRuntimeAdmissionGate;
293
- readonly statefulExecutionAllowed?: () => boolean;
306
+ readonly statefulExecution?: {
307
+ readonly admissionOpen: () => boolean;
308
+ readonly hostState: () => ZLinkFrameworkRuntimeState;
309
+ };
294
310
  readonly activationAdmission?: ZLinkActivationAdmission;
295
311
  }
296
312
 
@@ -299,11 +315,15 @@ interface ZLinkTargetSpotCloseOperation {
299
315
  readonly reason: ZLinkSpotCloseReason;
300
316
  readonly beginAuthority: (
301
317
  onCommitted: () => void
302
- ) => Promise<{ release(): Promise<void> } | undefined>;
303
- committed: boolean;
304
- authority?: { release(): Promise<void> };
318
+ ) => Promise<
319
+ import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
320
+ >;
321
+ authority?: import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority;
305
322
  authorityDecision?: Promise<void>;
306
323
  ready?: Promise<boolean>;
324
+ canExecuteApplication?(
325
+ record: import('../execution/serial-execution-queue').ZLinkSerialWorkRecord<unknown>
326
+ ): boolean;
307
327
  }
308
328
 
309
329
  export class DefaultZLinkSpotManager {
@@ -338,9 +358,10 @@ export class DefaultZLinkSpotManager {
338
358
  private readonly options: ZLinkSpotManagerOptions,
339
359
  timerClock?: import('./spot-timer').ZLinkTimerClock
340
360
  ) {
341
- this.activations = new ZLinkSpotActivationRegistry(options.metrics, (meshName, spotId) =>
342
- this.isSpotClosing(meshName, spotId)
343
- );
361
+ if ((options.detachedTaskRunner as unknown) === undefined) {
362
+ throw new ZLinkConfigurationException('Spot manager requires a detached task runner.');
363
+ }
364
+ this.activations = new ZLinkSpotActivationRegistry(options.metrics);
344
365
  this.factories = new Set(options.spotFactories);
345
366
  this.workerRuntime = options.workerRuntime ?? new ZLinkWorkerRuntime();
346
367
  this.locationClaim = new ZLinkSpotLocationClaim({
@@ -350,7 +371,7 @@ export class DefaultZLinkSpotManager {
350
371
  nodeGenerationProvider: options.nodeGenerationProvider
351
372
  });
352
373
  this.routedSpotPackets = new ZLinkRoutedSpotPacketDispatch({
353
- resolveActivation: (spotId) => this.activations.resolveUnique(spotId),
374
+ resolveActivation: (spotId) => this.resolveApplicationActivation(spotId),
354
375
  claimApplicationWork:
355
376
  options.admission === undefined
356
377
  ? undefined
@@ -359,9 +380,6 @@ export class DefaultZLinkSpotManager {
359
380
  dispatchErrors: options.dispatchErrors
360
381
  });
361
382
  this.actorMembership = new ZLinkSpotActorMembership({
362
- isSpotClosing: (activation) =>
363
- this.isSpotClosing(activation.meshName, activation.spotId) ||
364
- this.activations.resolve(activation.meshName, activation.spotId) !== activation,
365
383
  resolveActivation: (spotId, meshName) =>
366
384
  meshName === undefined
367
385
  ? this.activations.resolveUnique(spotId)
@@ -412,14 +430,11 @@ export class DefaultZLinkSpotManager {
412
430
  boundSessionRuntime: options.boundSessionRuntime,
413
431
  actorHandoffRuntime: options.actorHandoffRuntime,
414
432
  admission: options.admission,
415
- statefulExecutionAllowed: options.statefulExecutionAllowed,
433
+ statefulExecutionAllowed: options.statefulExecution?.admissionOpen,
416
434
  leaveActor: (spotId, actor, signal, meshName) =>
417
435
  this.actorMembership.leaveActor(spotId, actor, signal, meshName),
418
436
  requestContextClose: (activation, objectGeneration, signal) =>
419
437
  this.closeFromContext(activation, objectGeneration, signal),
420
- isSpotClosing: (activation) =>
421
- this.isSpotClosing(activation.meshName, activation.spotId) ||
422
- this.activations.resolve(activation.meshName, activation.spotId) !== activation,
423
438
  registerActivation: (activation) => {
424
439
  this.activations.register(activation);
425
440
  this.scheduleIdleSweep();
@@ -597,10 +612,6 @@ export class DefaultZLinkSpotManager {
597
612
  await awaitWithAbort(pendingClose, signal);
598
613
  continue;
599
614
  }
600
- if (closeOperation?.committed === true) {
601
- await awaitWithAbort(this.closeWithReason(meshName, spotId), signal);
602
- continue;
603
- }
604
615
  const closing = this.activations.closingOperation(meshName, spotId);
605
616
  if (closing !== undefined) {
606
617
  await awaitWithAbort(closing.ready, signal);
@@ -694,31 +705,49 @@ export class DefaultZLinkSpotManager {
694
705
  }
695
706
 
696
707
  isInstanceMaterialized(meshName: string, instanceType: string, spotId: RoutingId): boolean {
697
- const activation = this.activations.resolve(meshName, spotId);
708
+ const activation = this.resolveApplicationActivation(spotId, meshName);
698
709
  return (
699
710
  activation !== undefined &&
700
711
  activation.spotType === this.requireInstanceFactory(meshName, instanceType)
701
712
  );
702
713
  }
703
714
 
715
+ private resolveApplicationActivation(
716
+ spotId: RoutingId,
717
+ meshName?: string
718
+ ): ZLinkSpotActivation | undefined {
719
+ const current =
720
+ meshName === undefined
721
+ ? this.activations.resolveUnique(spotId)
722
+ : this.activations.resolve(meshName, spotId);
723
+ if (current !== undefined) return current;
724
+ if (meshName !== undefined)
725
+ return this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.activation;
726
+ for (const operation of this.closeOperations.values()) {
727
+ if (String(operation.activation.spotId) === String(spotId)) return operation.activation;
728
+ }
729
+ return undefined;
730
+ }
731
+
704
732
  isInstanceMaterializing(meshName: string, spotId: RoutingId): boolean {
705
733
  const prefix = instanceMaterializationPrefix(meshName, spotId);
706
- return (this.pendingInstanceMaterializationsByPrefix.get(prefix)?.size ?? 0) > 0;
734
+ return (
735
+ (this.pendingInstanceMaterializationsByPrefix.get(prefix)?.size ?? 0) > 0 ||
736
+ this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined
737
+ );
707
738
  }
708
739
 
709
740
  isSpotClosing(meshName: string, spotId: RoutingId): boolean {
710
- const key = `${meshName}\0${String(spotId)}`;
711
- return this.closeOperations.get(key)?.committed === true;
741
+ return (
742
+ this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined ||
743
+ this.activations.activationForClose(meshName, spotId)?.executionBarrier.isCloseSealed === true
744
+ );
712
745
  }
713
746
 
714
747
  pendingSpotCloseDecision(meshName: string, spotId: RoutingId): Promise<void> | undefined {
715
748
  return this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authorityDecision;
716
749
  }
717
750
 
718
- isInstanceClosing(meshName: string, spotId: RoutingId): boolean {
719
- return this.closeOperations.has(`${meshName}\0${String(spotId)}`);
720
- }
721
-
722
751
  async discardInstance(meshName: string, spotId: RoutingId): Promise<void> {
723
752
  const activation = this.activations.resolve(meshName, spotId);
724
753
  if (activation === undefined) return;
@@ -910,13 +939,10 @@ export class DefaultZLinkSpotManager {
910
939
  throw error;
911
940
  }
912
941
  };
913
- this.options.detachedTaskRunner?.runDetached(
942
+ this.options.detachedTaskRunner.runDetached(
914
943
  `instance idle eviction ${String(activation.spotId)}`,
915
944
  run
916
945
  );
917
- if (this.options.detachedTaskRunner === undefined) {
918
- void run().catch(() => undefined);
919
- }
920
946
  }
921
947
  } finally {
922
948
  this.idleSweepRunning = false;
@@ -1010,8 +1036,8 @@ export class DefaultZLinkSpotManager {
1010
1036
  requireMeshName(meshName);
1011
1037
  const args = normalizeSpotCreateArgs(requestOrSignal, signal);
1012
1038
  throwIfAborted(args.signal);
1039
+ this.options.admission?.requireRequest('SPOT create', meshName);
1013
1040
  const operation = this.activations.getOrBegin(meshName, spotType, spotId, async () => {
1014
- this.options.admission?.requireRequest('SPOT create', meshName);
1015
1041
  const release = await this.options.activationAdmission?.acquire(meshName, args.signal);
1016
1042
  const ownedRequest =
1017
1043
  args.request === undefined
@@ -1036,12 +1062,16 @@ export class DefaultZLinkSpotManager {
1036
1062
 
1037
1063
  async find(meshName: string, spotId: RoutingId): Promise<ZLinkSpotInfo | null> {
1038
1064
  requireMeshName(meshName);
1039
- return this.activations.has(meshName, spotId) ? { spotId } : null;
1065
+ return this.activations.has(meshName, spotId) && !this.isSpotClosing(meshName, spotId)
1066
+ ? { spotId }
1067
+ : null;
1040
1068
  }
1041
1069
 
1042
1070
  async list(meshName: string): Promise<readonly ZLinkSpotInfo[]> {
1043
1071
  requireMeshName(meshName);
1044
- return this.activations.list(meshName);
1072
+ return this.activations
1073
+ .list(meshName)
1074
+ .filter(({ spotId }) => !this.isSpotClosing(meshName, spotId));
1045
1075
  }
1046
1076
 
1047
1077
  async drainForShutdown(meshName: string, signal?: AbortSignal, deadline?: Date): Promise<void> {
@@ -1073,7 +1103,9 @@ export class DefaultZLinkSpotManager {
1073
1103
  async closeUserWithAuthority(
1074
1104
  meshName: string,
1075
1105
  spotId: RoutingId,
1076
- beginAuthority: (onCommitted: () => void) => Promise<{ release(): Promise<void> }>,
1106
+ beginAuthority: (
1107
+ onCommitted: () => void
1108
+ ) => Promise<import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority>,
1077
1109
  signal?: AbortSignal
1078
1110
  ): Promise<boolean> {
1079
1111
  return await this.closeWithReason(
@@ -1128,7 +1160,9 @@ export class DefaultZLinkSpotManager {
1128
1160
  deadline?: Date,
1129
1161
  beginUserAuthority?: (
1130
1162
  onCommitted: () => void
1131
- ) => Promise<{ release(): Promise<void> } | undefined>
1163
+ ) => Promise<
1164
+ import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
1165
+ >
1132
1166
  ): Promise<boolean> {
1133
1167
  requireMeshName(meshName);
1134
1168
  const key = `${meshName}\0${String(spotId)}`;
@@ -1146,14 +1180,20 @@ export class DefaultZLinkSpotManager {
1146
1180
  `User Spot '${String(spotId)}' Close requires its authority owner.`
1147
1181
  );
1148
1182
  }
1183
+ const domain = activation.domain;
1149
1184
  const beginAuthority =
1150
1185
  beginUserAuthority ??
1151
- (activation.domain.kind === 'instance' &&
1186
+ (domain.kind === 'instance' &&
1152
1187
  reason === ZLinkSpotCloseReason.ExplicitClose &&
1153
1188
  this.options.beginInstanceClosingAuthority !== undefined
1154
1189
  ? (onCommitted) =>
1155
- this.options.beginInstanceClosingAuthority!(meshName, spotId, onCommitted)
1156
- : activation.domain.kind === 'instance' &&
1190
+ this.options.beginInstanceClosingAuthority!(
1191
+ meshName,
1192
+ spotId,
1193
+ onCommitted,
1194
+ domain.objectGeneration
1195
+ )
1196
+ : domain.kind === 'instance' &&
1157
1197
  reason === ZLinkSpotCloseReason.IdleEvicted &&
1158
1198
  this.options.beginInstanceIdleClosingAuthority !== undefined
1159
1199
  ? (onCommitted) =>
@@ -1165,15 +1205,24 @@ export class DefaultZLinkSpotManager {
1165
1205
  operation = {
1166
1206
  activation,
1167
1207
  reason,
1168
- beginAuthority,
1169
- committed: false
1208
+ beginAuthority
1170
1209
  };
1210
+ if (reason === ZLinkSpotCloseReason.ExplicitClose) {
1211
+ operation.canExecuteApplication = (record) => {
1212
+ const context = record.context as
1213
+ import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
1214
+ return context === undefined;
1215
+ };
1216
+ }
1171
1217
  this.closeOperations.set(key, operation);
1172
1218
  }
1173
1219
  if (operation.ready === undefined) {
1174
1220
  const active = operation;
1175
- const run = active.activation.serial.executeLifecycleOperation(() =>
1176
- this.runCloseOperation(meshName, spotId, active, signal, deadline)
1221
+ const run = active.activation.serial.executeControlLifecycleOperation(
1222
+ () => this.runCloseOperation(meshName, spotId, active, signal, deadline),
1223
+ active.canExecuteApplication === undefined
1224
+ ? undefined
1225
+ : (active as import('../execution/serial-execution-queue').ZLinkSerialLifecycleContext)
1177
1226
  );
1178
1227
  active.ready = run.finally(() => {
1179
1228
  active.ready = undefined;
@@ -1192,20 +1241,100 @@ export class DefaultZLinkSpotManager {
1192
1241
  signal?: AbortSignal,
1193
1242
  deadline?: Date
1194
1243
  ): Promise<boolean> {
1195
- const began = await this.beginCloseAuthority(meshName, spotId, operation, signal);
1196
- if (!began) return false;
1197
- const seal = operation.activation.sealExecution(true);
1198
- await this.activationLifecycle.sealForClose(operation.activation, seal);
1244
+ const seal = await this.beginCloseAuthority(meshName, spotId, operation, signal);
1245
+ if (seal === undefined) return false;
1246
+ if (seal !== true) {
1247
+ await this.activationLifecycle.sealForClose(operation.activation, seal);
1248
+ } else {
1249
+ await operation.activation.executionBarrier.waitForStartedTurns(signal);
1250
+ }
1199
1251
  const closingFailure = await this.activationLifecycle.cleanupClosedActivation(
1200
1252
  operation.activation,
1201
1253
  operation.reason,
1202
1254
  deadline
1203
1255
  );
1204
- await operation.authority?.release();
1205
- // The incarnation has no further lifecycle item once its authority is
1206
- // released, so its lifecycle lane admission closes with this Close.
1207
- operation.activation.serial.closeAdmission();
1208
1256
  this.activations.finishClose(meshName, spotId);
1257
+ const intentRecords: unknown[] = [];
1258
+ operation.activation.serial.visitPendingApplication((record) => {
1259
+ const context = record.context as
1260
+ import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
1261
+ if (context?.replay !== undefined) intentRecords.push(record);
1262
+ });
1263
+ const hasIntent = intentRecords.length > 0;
1264
+ // Spot messaging §7 step 3: with no Instance intent message waiting, the
1265
+ // release decision also ends this Instance incarnation's admission in this turn.
1266
+ if (!hasIntent && operation.activation.domain.kind === 'instance')
1267
+ operation.activation.serial.closeAdmission();
1268
+ const hostState = this.options.statefulExecution?.hostState();
1269
+ const intentFailure = !hasIntent
1270
+ ? undefined
1271
+ : hostState === ZLinkFrameworkRuntimeState.Draining
1272
+ ? createInternalFrameworkException(
1273
+ ZLinkFrameworkInternalErrorKind.RuntimeShutdown,
1274
+ 'Instance intent cannot continue while the host is draining.'
1275
+ )
1276
+ : hostState === ZLinkFrameworkRuntimeState.Relocating ||
1277
+ hostState === ZLinkFrameworkRuntimeState.Relocated ||
1278
+ this.options.statefulExecution?.admissionOpen() === false ||
1279
+ (operation.activation.executionBarrier.isSealed &&
1280
+ !operation.activation.executionBarrier.isCloseSealed)
1281
+ ? createInternalFrameworkException(
1282
+ ZLinkFrameworkInternalErrorKind.SpotMoving,
1283
+ 'Instance intent cannot continue on an unavailable or relocating owner.'
1284
+ )
1285
+ : undefined;
1286
+ if (
1287
+ operation.reason === ZLinkSpotCloseReason.ExplicitClose &&
1288
+ hasIntent &&
1289
+ intentFailure === undefined &&
1290
+ operation.authority?.reincarnate !== undefined
1291
+ ) {
1292
+ try {
1293
+ await operation.authority.reincarnate(async (authority) => {
1294
+ await this.activationLifecycle.materializeInstance(
1295
+ meshName,
1296
+ authority.stableType,
1297
+ operation.activation.spotType as Type<ZLinkInstanceSpot>,
1298
+ spotId,
1299
+ authority.objectGeneration,
1300
+ signal,
1301
+ operation.activation
1302
+ );
1303
+ });
1304
+ // The new incarnation shares this serial owner and admits membership work again.
1305
+ operation.activation.serial.setLifecycleAdmissionClosed(false);
1306
+ } catch (error) {
1307
+ const initialized = this.activations.resolve(meshName, spotId);
1308
+ if (initialized !== undefined && initialized !== operation.activation) {
1309
+ await this.activationLifecycle.cleanupFailedIncarnation(initialized);
1310
+ }
1311
+ this.activations.finishClose(meshName, spotId);
1312
+ operation.activation.serial.visitPendingApplication((record) => {
1313
+ const context = record.context as
1314
+ import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
1315
+ if (context?.replay !== undefined) record.operation = () => context.replay!(error);
1316
+ });
1317
+ operation.activation.serial.closeAdmission();
1318
+ throw error;
1319
+ }
1320
+ } else {
1321
+ await operation.authority?.release();
1322
+ operation.activation.serial.closeAdmission();
1323
+ if (!operation.activation.executionBarrier.isSealed) {
1324
+ const closed = operation.activation.sealExecution('close');
1325
+ operation.activation.commitExecutionSeal(closed);
1326
+ }
1327
+ }
1328
+ if (operation.reason === ZLinkSpotCloseReason.ExplicitClose) {
1329
+ operation.activation.serial.visitPendingApplication((record) => {
1330
+ const context = record.context as
1331
+ import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
1332
+ if (context?.replay !== undefined) {
1333
+ record.operation =
1334
+ intentFailure === undefined ? context.replay : () => context.replay!(intentFailure);
1335
+ }
1336
+ });
1337
+ }
1209
1338
  this.closeOperations.delete(`${meshName}\0${String(spotId)}`);
1210
1339
  // An OnClosing failure never changes a Close result; host shutdown alone
1211
1340
  // reports it as its teardown outcome after cleanup has finished.
@@ -1220,9 +1349,11 @@ export class DefaultZLinkSpotManager {
1220
1349
  spotId: RoutingId,
1221
1350
  operation: ZLinkTargetSpotCloseOperation,
1222
1351
  signal?: AbortSignal
1223
- ): Promise<boolean> {
1352
+ ): Promise<import('../execution').ZLinkExecutionBarrierSeal | true | undefined> {
1353
+ // Spot messaging §4 step 12 with §7 step 1: a Close of any reason begins its
1354
+ // Closing CAS only after the first terminal record of an activated message.
1224
1355
  await this.options.instanceSpotApplicationQuiescenceProvider?.(meshName, spotId, signal);
1225
- if (!operation.activation.canClose(operation.reason)) return false;
1356
+ if (!operation.activation.canClose(operation.reason)) return undefined;
1226
1357
  if (operation.activation.executionBarrier.isSealed) {
1227
1358
  throw createInternalFrameworkException(
1228
1359
  ZLinkFrameworkInternalErrorKind.SpotMoving,
@@ -1230,9 +1361,15 @@ export class DefaultZLinkSpotManager {
1230
1361
  true
1231
1362
  );
1232
1363
  }
1364
+ let seal: import('../execution').ZLinkExecutionBarrierSeal | true | undefined;
1233
1365
  const authorityPromise = Promise.resolve().then(() =>
1234
1366
  operation.beginAuthority(() => {
1235
- operation.committed = true;
1367
+ if (operation.reason === ZLinkSpotCloseReason.ExplicitClose) {
1368
+ operation.activation.serial.setLifecycleAdmissionClosed(true);
1369
+ seal = true;
1370
+ } else {
1371
+ seal = operation.activation.sealExecution('close');
1372
+ }
1236
1373
  })
1237
1374
  );
1238
1375
  operation.authorityDecision = authorityPromise.then(
@@ -1240,12 +1377,12 @@ export class DefaultZLinkSpotManager {
1240
1377
  () => undefined
1241
1378
  );
1242
1379
  const authority = await authorityPromise;
1243
- if (authority === undefined) return false;
1380
+ if (authority === undefined) return undefined;
1244
1381
  operation.authority = authority;
1245
- if (!this.isSpotClosing(meshName, spotId)) {
1382
+ if (seal === undefined) {
1246
1383
  throw new Error(`Spot '${String(spotId)}' Closing authority did not confirm its commit.`);
1247
1384
  }
1248
- return true;
1385
+ return seal;
1249
1386
  }
1250
1387
 
1251
1388
  async executeOnSpot<TSpot extends ZLinkSpot, TResult>(
@@ -1311,15 +1448,19 @@ export class DefaultZLinkSpotManager {
1311
1448
  spotId: RoutingId,
1312
1449
  actor: ZLinkActor,
1313
1450
  request: Message,
1314
- commit: (
1315
- spot: ZLinkSpot
1316
- ) => Promise<ZLinkActorJoinRollback | void> | ZLinkActorJoinRollback | void,
1451
+ commit: (spot: ZLinkSpot) => Promise<void> | void,
1317
1452
  signal?: AbortSignal,
1318
1453
  leaveSource?: () => Promise<void>,
1319
1454
  contentType = 'application/json'
1320
1455
  ): Promise<ZLinkSpotActorJoinResult> {
1321
1456
  const meshName = this.activations.resolveUnique(spotId)?.meshName;
1322
1457
  this.options.admission?.requireRequest('Actor join admission', meshName);
1458
+ if (meshName !== undefined && this.isSpotClosing(meshName, spotId)) {
1459
+ throw createInternalFrameworkException(
1460
+ ZLinkFrameworkInternalErrorKind.RequestRejected,
1461
+ `Spot '${String(spotId)}' is closing.`
1462
+ );
1463
+ }
1323
1464
  return await this.actorMembership.admitActorJoin(
1324
1465
  spotId,
1325
1466
  actor,
@@ -1558,7 +1699,7 @@ export class DefaultZLinkSpotManager {
1558
1699
  let target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
1559
1700
  if (target === undefined) return;
1560
1701
  for (;;) {
1561
- const current = this.activations.resolve(meshName, spotId);
1702
+ const current = this.resolveApplicationActivation(spotId, meshName);
1562
1703
  if (
1563
1704
  current !== undefined &&
1564
1705
  current.objectGeneration === target.objectGeneration &&
@@ -1612,7 +1753,7 @@ export class DefaultZLinkSpotManager {
1612
1753
  );
1613
1754
  try {
1614
1755
  await this.ensureInstanceApplicationActivation(meshName, spotId);
1615
- const activation = this.activations.resolve(meshName, spotId);
1756
+ const activation = this.resolveApplicationActivation(spotId, meshName);
1616
1757
  if (activation === undefined || activation.domain.kind !== 'instance') {
1617
1758
  throw new ZLinkConfigurationException(
1618
1759
  `MeshNode Instance Spot target '${String(spotId)}' is not active.`
@@ -1637,12 +1778,39 @@ export class DefaultZLinkSpotManager {
1637
1778
  channelName: envelope.header.channelName,
1638
1779
  contentType: envelope.header.contentType,
1639
1780
  awaitFirstHandlerTurn: record.kind === ReceiveKind.InstanceSpotActivation,
1781
+ activationRecord: record,
1782
+ onOneWayError:
1783
+ this.options.dispatchErrors?.captureEnabled() === true
1784
+ ? (error: unknown) =>
1785
+ this.reportInstanceDispatchFailure(
1786
+ meshName,
1787
+ spotId,
1788
+ record,
1789
+ envelope,
1790
+ false,
1791
+ error
1792
+ )
1793
+ : undefined,
1640
1794
  workOptions: zlinkSerialWorkOptions(
1641
1795
  envelope.payload.byteLength,
1642
1796
  record.applicationMetadata?.byteLength ??
1643
1797
  zlinkMetadataByteLength(envelope.header.metadata)
1644
1798
  )
1645
1799
  };
1800
+ // Spot messaging §7 step 3: an Instance intent request that reaches an
1801
+ // incarnation whose Close ended admission is refused before admission
1802
+ // with the owner fence terminal, so its caller re-reads authority.
1803
+ const instanceIntent =
1804
+ record.activationRecord?.activation === 'missing' ||
1805
+ (record.activationRecord?.activation === 'ready' &&
1806
+ record.activationRecord.instanceIntent);
1807
+ const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
1808
+ if (request && refusal !== undefined && record.replyFailure !== undefined) {
1809
+ this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, refusal);
1810
+ const terminal = internalFrameworkWireReply(refusal);
1811
+ requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
1812
+ return;
1813
+ }
1646
1814
  this.traceInstanceMessage(
1647
1815
  ZLinkMessageFlowOutcome.Admitted,
1648
1816
  meshName,
@@ -1707,7 +1875,8 @@ export class DefaultZLinkSpotManager {
1707
1875
  target?.stableType
1708
1876
  );
1709
1877
  } catch (error) {
1710
- const reason = instanceDispatchErrorReason(error);
1878
+ this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, error);
1879
+ const reason = dispatchReasonFromError(error);
1711
1880
  if (!request) {
1712
1881
  this.traceInstanceMessage(
1713
1882
  ZLinkMessageFlowOutcome.Dropped,
@@ -1721,29 +1890,42 @@ export class DefaultZLinkSpotManager {
1721
1890
  );
1722
1891
  return;
1723
1892
  }
1724
- this.options.dispatchErrors?.report({
1725
- surface: ZLinkDispatchErrorSurface.InstanceSpot,
1726
- messageKind: ZLinkDispatchMessageKind.Request,
1727
- packetName: envelope.packetName,
1728
- channelName: envelope.header.channelName,
1729
- meshName,
1730
- correlationId: envelope.header.correlationId ?? undefined,
1731
- sourceRid: record.sourceNodeRid === null ? undefined : String(record.sourceNodeRid),
1732
- spotId: String(spotId),
1733
- instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)
1734
- ?.stableType,
1735
- activationState: 'closing',
1736
- flowId: envelope.header.flowId,
1737
- flowOrigin: envelope.header.flowOrigin,
1738
- reason,
1739
- action: ZLinkDispatchErrorAction.ReplyError,
1740
- error
1741
- });
1893
+
1742
1894
  requireMeshSpotReply(record.reply(encodeChannelErrorReplyParts(envelope.header, error)));
1743
1895
  }
1744
1896
  });
1745
1897
  }
1746
1898
 
1899
+ private reportInstanceDispatchFailure(
1900
+ meshName: string,
1901
+ spotId: RoutingId,
1902
+ record: ReceiveRecord,
1903
+ envelope: ReturnType<typeof decodeChannelEnvelope>,
1904
+ request: boolean,
1905
+ error: unknown
1906
+ ): void {
1907
+ const reporter = this.options.dispatchErrors;
1908
+ if (reporter?.captureEnabled() !== true) return;
1909
+ reporter.report({
1910
+ surface: ZLinkDispatchErrorSurface.InstanceSpot,
1911
+ messageKind: request ? ZLinkDispatchMessageKind.Request : ZLinkDispatchMessageKind.Send,
1912
+ packetName: envelope.packetName,
1913
+ channelName: envelope.header.channelName,
1914
+ meshName,
1915
+ correlationId: envelope.header.correlationId ?? undefined,
1916
+ sourceRid: record.sourceNodeRid === null ? undefined : String(record.sourceNodeRid),
1917
+ spotId: String(spotId),
1918
+ instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)
1919
+ ?.stableType,
1920
+ activationState: 'closing',
1921
+ flowId: envelope.header.flowId,
1922
+ flowOrigin: envelope.header.flowOrigin,
1923
+ reason: dispatchReasonFromError(error),
1924
+ action: request ? ZLinkDispatchErrorAction.ReplyError : ZLinkDispatchErrorAction.Drop,
1925
+ error
1926
+ });
1927
+ }
1928
+
1747
1929
  private traceInstanceMessage(
1748
1930
  outcome: ZLinkMessageFlowOutcome,
1749
1931
  meshName: string,
@@ -1796,9 +1978,6 @@ export class DefaultZLinkSpotManager {
1796
1978
  throw new ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
1797
1979
  }
1798
1980
  const request = record.kind === ReceiveKind.ActorRequest;
1799
- if (record.sourceBindingGeneration > 0n) {
1800
- this.options.actorBindingGenerationObserver?.(actor.actorId, record.sourceBindingGeneration);
1801
- }
1802
1981
  const resolvedOwner = this.options.actorDispatchOwnerResolver?.(actor.actorId);
1803
1982
  const resolvedActorRef = resolvedOwner?.actorRef ?? {
1804
1983
  actorId: actor.actorId,
@@ -1889,10 +2068,7 @@ export class DefaultZLinkSpotManager {
1889
2068
  record.reply(
1890
2069
  this.encodeMeshActorReply(record.parts[0], ZLinkStreamMessageKind.Error, {
1891
2070
  message: error instanceof Error ? error.message : String(error),
1892
- kind:
1893
- error instanceof ZLinkFrameworkException
1894
- ? error.kind
1895
- : ZLinkFrameworkErrorKind.InternalFailure
2071
+ kind: spotActorFailureKind(error)
1896
2072
  })
1897
2073
  )
1898
2074
  );
@@ -1906,37 +2082,51 @@ export class DefaultZLinkSpotManager {
1906
2082
  ): Promise<void> {
1907
2083
  const spotId = owner.spotId as unknown as RoutingId | null;
1908
2084
  const activation = spotId === null ? undefined : this.activations.resolve(meshName, spotId);
1909
- if (activation?.domain.kind === 'user') {
1910
- await activation.serial.executeLifecycleOperation(async () => {
2085
+ const replyState = { targetCommitPublished: false };
2086
+ try {
2087
+ if (
2088
+ record.kindData?.kind === 'actorControl' &&
2089
+ record.kindData.canonicalActorJoin !== undefined
2090
+ ) {
2091
+ const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
1911
2092
  if (
1912
- this.isSpotClosing(meshName, activation.spotId) ||
1913
- this.activations.resolve(meshName, activation.spotId) !== activation
2093
+ spotId !== null && entrySpotId !== undefined && String(spotId) === String(entrySpotId)
2094
+ ? this.options.dispatchEntryActorJoin === undefined
2095
+ : activation === undefined
1914
2096
  ) {
1915
- const rejection = createInternalFrameworkException(
1916
- ZLinkFrameworkInternalErrorKind.RequestRejected,
1917
- `User Spot '${String(spotId)}' is closing.`
2097
+ throw createInternalFrameworkException(
2098
+ ZLinkFrameworkInternalErrorKind.RouteNotConnected,
2099
+ `Spot '${String(spotId)}' is not active on this node.`
1918
2100
  );
1919
- if (record.replyFailure !== undefined) {
1920
- const terminal = internalFrameworkWireReply(rejection);
1921
- requireMeshSpotReply(
1922
- record.replyFailure(terminal.terminalResult, terminal.failureCode)
1923
- );
1924
- } else {
1925
- requireMeshSpotReply(record.replyActorJoin(1, []));
1926
- }
1927
- return;
1928
2101
  }
1929
- await this.dispatchMeshActorJoinCore(meshName, owner, record);
1930
- });
1931
- return;
2102
+ }
2103
+ if (activation?.domain.kind === 'user') {
2104
+ await activation.serial.executeLifecycleOperation(() =>
2105
+ this.dispatchMeshActorJoinCore(meshName, owner, record, replyState)
2106
+ );
2107
+ return;
2108
+ }
2109
+ await this.dispatchMeshActorJoinCore(meshName, owner, record, replyState);
2110
+ } catch (error) {
2111
+ if (replyState.targetCommitPublished || record.replyFailure === undefined) throw error;
2112
+ const failure =
2113
+ error instanceof ZLinkFrameworkException
2114
+ ? error
2115
+ : createInternalFrameworkException(
2116
+ ZLinkFrameworkInternalErrorKind.RequestFailed,
2117
+ 'Actor Join target admission failed.',
2118
+ error
2119
+ );
2120
+ const terminal = internalFrameworkWireReply(failure);
2121
+ requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
1932
2122
  }
1933
- await this.dispatchMeshActorJoinCore(meshName, owner, record);
1934
2123
  }
1935
2124
 
1936
2125
  private async dispatchMeshActorJoinCore(
1937
2126
  meshName: string,
1938
2127
  owner: ReadyRecord,
1939
- record: ReceiveRecord
2128
+ record: ReceiveRecord,
2129
+ replyState: { targetCommitPublished: boolean }
1940
2130
  ): Promise<void> {
1941
2131
  const spotId = owner.spotId as unknown as RoutingId | null;
1942
2132
  const control = record.kindData;
@@ -2001,14 +2191,10 @@ export class DefaultZLinkSpotManager {
2001
2191
  admissionRecord = provisional.record;
2002
2192
  canonicalAdmissionCreated = provisional.created;
2003
2193
  try {
2194
+ releaseApplicationJobPermitBeforeHandler();
2004
2195
  canonicalActorType = (await resolver({ actorId, ...control.canonicalActorJoin })).actorType;
2005
2196
  } catch (error) {
2006
2197
  this.formalRemoteActorAdmissions.fail(control.canonicalActorJoin.handoffId, error);
2007
- if (error instanceof ZLinkFrameworkException && record.replyFailure !== undefined) {
2008
- const terminal = internalFrameworkWireReply(error);
2009
- requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
2010
- return;
2011
- }
2012
2198
  throw error;
2013
2199
  }
2014
2200
  }
@@ -2037,7 +2223,6 @@ export class DefaultZLinkSpotManager {
2037
2223
  let admissionOutcome: ZLinkFormalRemoteActorAdmissionResult | undefined;
2038
2224
  let accepted = false;
2039
2225
  let committedAdmissionReplay = isRemoteCommit && admissionRecord?.state === 'committed';
2040
- let targetCommitPublished: boolean | undefined;
2041
2226
  const actorJoinIsCurrent = (): boolean =>
2042
2227
  (record.deadlineUnixMs === undefined || record.deadlineUnixMs > BigInt(Date.now())) &&
2043
2228
  (record.isPending?.() ?? true);
@@ -2098,14 +2283,12 @@ export class DefaultZLinkSpotManager {
2098
2283
  if (canonicalAdmissionCreated) {
2099
2284
  if (targetsEntrySpot) {
2100
2285
  admissionOutcome = {
2101
- accepted: this.options.dispatchEntryActorJoin !== undefined,
2286
+ accepted: true,
2102
2287
  actorRef
2103
2288
  };
2104
- } else if (activation === undefined) {
2105
- admissionOutcome = { accepted: false, actorRef };
2106
2289
  } else {
2107
- const response: ZLinkSpotActorJoinResult = await activation.serial.execute(async () =>
2108
- activation.spot.onActorJoin(
2290
+ const response: ZLinkSpotActorJoinResult = await activation!.serial.execute(async () =>
2291
+ activation!.spot.onActorJoin(
2109
2292
  actorRef.actorId,
2110
2293
  wrapFrameworkPayloadMessage(
2111
2294
  callbackRequest!,
@@ -2429,21 +2612,6 @@ export class DefaultZLinkSpotManager {
2429
2612
  return;
2430
2613
  }
2431
2614
  }
2432
- if (
2433
- accepted &&
2434
- transferRequest !== undefined &&
2435
- this.options.actorTransferRuntime !== undefined &&
2436
- !isRemoteAdmission
2437
- ) {
2438
- // A lightweight Core actor-join notification can create the Actor
2439
- // before the formal transfer request reaches this branch. Preserve
2440
- // the full relocation fence in that race so a later Session bind
2441
- // refresh cannot erase the seal.
2442
- this.options.actorTransferRuntime.rememberRoutedActorTransferTarget(
2443
- actorId,
2444
- transferRequest.remoteBoundSessionTarget
2445
- );
2446
- }
2447
2615
  if (
2448
2616
  accepted &&
2449
2617
  actor !== undefined &&
@@ -2456,7 +2624,8 @@ export class DefaultZLinkSpotManager {
2456
2624
  spotId,
2457
2625
  transferId: transferRequest.transferId,
2458
2626
  handoffBacklog: transferRequest.handoffBacklog,
2459
- deferredJoinCompletion
2627
+ deferredJoinCompletion,
2628
+ sealedSession: transferRequest.remoteBoundSessionTarget
2460
2629
  });
2461
2630
  if (isRemoteCommit && admissionRecord !== undefined) {
2462
2631
  this.formalRemoteActorAdmissions.markCommitted(transferRequest.transferId, actor);
@@ -2476,7 +2645,7 @@ export class DefaultZLinkSpotManager {
2476
2645
  // Core commits the target membership while it accepts this reply.
2477
2646
  // From this call onward a later callback/transport failure is
2478
2647
  // post-commit and must not roll the materialized Actor back.
2479
- targetCommitPublished = true;
2648
+ replyState.targetCommitPublished = true;
2480
2649
  }
2481
2650
  requireMeshSpotReply(joinReplyResult);
2482
2651
  return true;
@@ -2501,60 +2670,85 @@ export class DefaultZLinkSpotManager {
2501
2670
  if (!replyActorJoin()) return;
2502
2671
  const commitEntryTransfer = async (): Promise<void> => {
2503
2672
  try {
2504
- await this.options.dispatchEntryActorJoin?.(meshName, entryActor, []);
2505
- } finally {
2506
- this.formalRemoteTransfers.completeTargetLifecycle(
2507
- entryActor.context.actorId,
2508
- pendingTransfer.transferId
2509
- );
2510
- }
2511
- const sourceLeaveSubmitted = await pendingTransfer.sourceLeaveSubmitted;
2512
- if (!sourceLeaveSubmitted) {
2513
- throw new Error(
2514
- `Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`
2515
- );
2516
- }
2517
- const handoffResults = await replayActorHandoffBacklog(
2518
- pendingTransfer.handoffBacklog,
2519
- async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
2520
- if (this.options.dispatchEntryActorPacket === undefined) {
2521
- throw new Error(
2522
- 'Entry Spot saved handoff replay requires its Actor packet runtime.'
2523
- );
2524
- }
2525
- return await this.options.dispatchEntryActorPacket(
2673
+ try {
2674
+ await this.options.dispatchEntryActorJoin?.(meshName, entryActor, []);
2675
+ } finally {
2676
+ this.formalRemoteTransfers.completeTargetLifecycle(
2526
2677
  entryActor.context.actorId,
2527
- parts,
2528
- returnResponse,
2529
- remoteBoundSessionTarget,
2530
- fallbackActorRef
2678
+ pendingTransfer.transferId
2531
2679
  );
2532
- },
2533
- (index) =>
2534
- this.options.runtimeEventPublisher?.publish({
2535
- sourceName: 'zlink.framework.actor-handoff',
2536
- timestamp: new Date(),
2537
- marker: 'backlog_enqueued',
2538
- actorId: entryActor.context.actorId,
2539
- index
2540
- })
2541
- );
2542
- const failedHandoff = handoffResults.find((result) => !result.ok);
2543
- if (failedHandoff !== undefined) {
2544
- throw new Error(
2545
- `Actor '${entryActor.context.actorId}' saved Entry handoff packet ` +
2546
- `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`
2680
+ }
2681
+ const sourceLeaveSubmitted = await pendingTransfer.sourceLeaveSubmitted;
2682
+ if (!sourceLeaveSubmitted) {
2683
+ throw new Error(
2684
+ `Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`
2685
+ );
2686
+ }
2687
+ const handoffResults = await replayActorHandoffBacklog(
2688
+ pendingTransfer.handoffBacklog,
2689
+ async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
2690
+ if (this.options.dispatchEntryActorPacket === undefined) {
2691
+ throw new Error(
2692
+ 'Entry Spot saved handoff replay requires its Actor packet runtime.'
2693
+ );
2694
+ }
2695
+ return await this.options.dispatchEntryActorPacket(
2696
+ entryActor.context.actorId,
2697
+ parts,
2698
+ returnResponse,
2699
+ remoteBoundSessionTarget,
2700
+ fallbackActorRef
2701
+ );
2702
+ },
2703
+ (index) =>
2704
+ this.options.runtimeEventPublisher?.publish({
2705
+ sourceName: 'zlink.framework.actor-handoff',
2706
+ timestamp: new Date(),
2707
+ marker: 'backlog_enqueued',
2708
+ actorId: entryActor.context.actorId,
2709
+ index
2710
+ })
2711
+ );
2712
+ const failedHandoff = handoffResults.find((result) => !result.ok);
2713
+ if (failedHandoff !== undefined) {
2714
+ throw new Error(
2715
+ `Actor '${entryActor.context.actorId}' saved Entry handoff packet ` +
2716
+ `${failedHandoff.index} failed: ${diagnosticTextOrAbsent(failedHandoff.error)}.`
2717
+ );
2718
+ }
2719
+ } catch (error) {
2720
+ const completion = pendingTransfer.deferredJoinCompletion;
2721
+ if (completion !== undefined) {
2722
+ await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
2723
+ {
2724
+ ...completion,
2725
+ status: 'failed',
2726
+ kind: spotActorFailureKind(error)
2727
+ },
2728
+ entryActor,
2729
+ completion.actor,
2730
+ (operation) =>
2731
+ this.options.executeEntryActor!(meshName, entryActor.context.actorId, operation)
2732
+ );
2733
+ }
2734
+ throw error;
2735
+ }
2736
+ const completion = pendingTransfer.deferredJoinCompletion;
2737
+ if (completion !== undefined) {
2738
+ await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
2739
+ completion,
2740
+ entryActor,
2741
+ completion.actor,
2742
+ (operation) =>
2743
+ this.options.executeEntryActor!(meshName, entryActor.context.actorId, operation)
2547
2744
  );
2548
2745
  }
2549
2746
  this.formalRemoteTransfers.delete(entryActor.context.actorId);
2550
2747
  };
2551
- this.options.detachedTaskRunner?.runDetached(
2748
+ this.options.detachedTaskRunner.runDetached(
2552
2749
  `actor Entry Spot transfer ${entryActor.context.actorId}`,
2553
2750
  commitEntryTransfer
2554
2751
  );
2555
- if (this.options.detachedTaskRunner === undefined) {
2556
- void commitEntryTransfer().catch(() => undefined);
2557
- }
2558
2752
  }
2559
2753
  } else {
2560
2754
  if (!replyActorJoin()) return;
@@ -2563,10 +2757,10 @@ export class DefaultZLinkSpotManager {
2563
2757
  if (control.canonicalActorJoin !== undefined) {
2564
2758
  this.formalRemoteActorAdmissions.fail(control.canonicalActorJoin.handoffId, error);
2565
2759
  }
2566
- if (targetCommitPublished !== true) {
2760
+ if (!replyState.targetCommitPublished) {
2567
2761
  this.formalRemoteTransfers.delete(actorId);
2568
2762
  }
2569
- if (materialized && targetCommitPublished !== true) {
2763
+ if (materialized && !replyState.targetCommitPublished) {
2570
2764
  await this.options.actorTransferRuntime?.rollbackRoutedActor(actor!);
2571
2765
  }
2572
2766
  throw error;
@@ -2601,11 +2795,10 @@ export class DefaultZLinkSpotManager {
2601
2795
  actorId !== undefined &&
2602
2796
  this.formalRemoteTransfers.get(actorId) !== undefined
2603
2797
  ) {
2604
- this.options.detachedTaskRunner?.runDetached(
2798
+ this.options.detachedTaskRunner.runDetached(
2605
2799
  `actor transfer target commit ${actorId}`,
2606
2800
  async () => await operation
2607
2801
  );
2608
- if (this.options.detachedTaskRunner === undefined) void operation.catch(() => undefined);
2609
2802
  return;
2610
2803
  }
2611
2804
  await operation;
@@ -2714,7 +2907,7 @@ export class DefaultZLinkSpotManager {
2714
2907
  `Actor '${actor.context.actorId}' has no target ref for deferred Join completion.`
2715
2908
  );
2716
2909
  }
2717
- await this.options.actorTransferRuntime?.deliverDeferredJoinAccepted(
2910
+ await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
2718
2911
  deferredJoinCompletion,
2719
2912
  actor,
2720
2913
  currentRef,
@@ -2749,7 +2942,7 @@ export class DefaultZLinkSpotManager {
2749
2942
  if (failedHandoff !== undefined) {
2750
2943
  throw new Error(
2751
2944
  `Actor '${actor.context.actorId}' saved handoff packet ` +
2752
- `${failedHandoff.index} failed: ${failedHandoff.error ?? 'unknown error'}.`
2945
+ `${failedHandoff.index} failed: ${diagnosticTextOrAbsent(failedHandoff.error)}.`
2753
2946
  );
2754
2947
  }
2755
2948
  // Spec 15 §4.2 relocation temporary queue: arrivals parked at
@@ -2763,13 +2956,17 @@ export class DefaultZLinkSpotManager {
2763
2956
  // the Session binding aggregate after this boundary.
2764
2957
  this.formalRemoteTransfers.delete(actor.context.actorId);
2765
2958
  }
2959
+ const sealedSession = pendingTransfer?.sealedSession;
2766
2960
  const updateBoundSessionRoute = async (): Promise<void> => {
2767
- await this.options.actorTransferRuntime?.publishRoutedActorOwnership(actor);
2961
+ await this.options.actorTransferRuntime?.publishRoutedActorOwnership(
2962
+ actor,
2963
+ sealedSession
2964
+ );
2768
2965
  await this.options.actorTransferRuntime?.openRoutedActorSession(actor);
2769
2966
  };
2770
- // Session routing is an independent post-Ready branch. Callback
2771
- // sends are retained by the Session owner seal until this converges.
2772
- if (pendingTransfer !== undefined && this.options.detachedTaskRunner !== undefined) {
2967
+ // Session routing is an independent post-Ready branch. The Session
2968
+ // owner submits current-binding pushes while the route seal remains installed.
2969
+ if (pendingTransfer !== undefined) {
2773
2970
  this.options.detachedTaskRunner.runDetached(
2774
2971
  `actor transfer Session route ${actor.context.actorId}`,
2775
2972
  updateBoundSessionRoute
@@ -2803,13 +3000,10 @@ export class DefaultZLinkSpotManager {
2803
3000
  if (onDetachedTerminal !== undefined) {
2804
3001
  onDetachedTerminal(terminal);
2805
3002
  } else {
2806
- this.options.detachedTaskRunner?.runDetached(
3003
+ this.options.detachedTaskRunner.runDetached(
2807
3004
  `actor transfer target commit ${actor.context.actorId}`,
2808
3005
  async () => await terminal
2809
3006
  );
2810
- if (this.options.detachedTaskRunner === undefined) {
2811
- void terminal.catch(() => undefined);
2812
- }
2813
3007
  }
2814
3008
  return;
2815
3009
  }
@@ -2876,16 +3070,29 @@ export class DefaultZLinkSpotManager {
2876
3070
  const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
2877
3071
  const targetsEntry =
2878
3072
  entrySpotId !== undefined && String(admission.admission.spotId) === String(entrySpotId);
2879
- if (targetsEntry) {
2880
- await this.options.dispatchEntryActorJoin?.(meshName, actor, []);
2881
- } else {
2882
- const activation = this.activations.resolve(meshName, admission.admission.spotId);
2883
- if (activation === undefined) {
2884
- throw new Error(`Actor Join relocation '${relocationId}' target Spot is not active.`);
3073
+ const activation = targetsEntry
3074
+ ? undefined
3075
+ : this.activations.resolve(meshName, admission.admission.spotId);
3076
+ let lifecycleFailure: { readonly error: unknown } | undefined;
3077
+ try {
3078
+ if (targetsEntry) {
3079
+ await this.options.dispatchEntryActorJoin?.(meshName, actor, []);
3080
+ } else {
3081
+ if (activation === undefined) {
3082
+ throw new Error(`Actor Join relocation '${relocationId}' target Spot is not active.`);
3083
+ }
3084
+ await activation.serial.execute(() => activation.spot.onJoinedActor(actor));
2885
3085
  }
2886
- await activation.serial.execute(() => activation.spot.onJoinedActor(actor));
3086
+ } catch (error) {
3087
+ lifecycleFailure = { error };
3088
+ }
3089
+ if (lifecycleFailure === undefined) {
3090
+ const sourceLeave = submitSourceLeave(admission.admission.actorRef.nodeRid);
3091
+ this.options.detachedTaskRunner.runDetached(
3092
+ `actor Join source leave ${actor.context.actorId}`,
3093
+ () => sourceLeave
3094
+ );
2887
3095
  }
2888
- await submitSourceLeave(admission.admission.actorRef.nodeRid);
2889
3096
  if (
2890
3097
  outcome.deferredJoinCompletion !== undefined &&
2891
3098
  this.options.actorTransferRuntime !== undefined
@@ -2893,20 +3100,26 @@ export class DefaultZLinkSpotManager {
2893
3100
  const submitMailbox = targetsEntry
2894
3101
  ? <T>(operation: () => Promise<T>): Promise<T> => operation()
2895
3102
  : <T>(operation: () => Promise<T>): Promise<T> => {
2896
- const activation = this.activations.resolve(meshName, admission.admission.spotId);
2897
3103
  if (activation === undefined) {
2898
3104
  throw new Error(`Actor Join relocation '${relocationId}' target mailbox is missing.`);
2899
3105
  }
2900
3106
  return activation.executeActor(actor.context.actorId, operation);
2901
3107
  };
2902
- await this.options.actorTransferRuntime.deliverDeferredJoinAccepted(
2903
- outcome.deferredJoinCompletion,
3108
+ await this.options.actorTransferRuntime.deliverDeferredJoinCompletion(
3109
+ lifecycleFailure === undefined
3110
+ ? outcome.deferredJoinCompletion
3111
+ : {
3112
+ ...outcome.deferredJoinCompletion,
3113
+ status: 'failed',
3114
+ kind: spotActorFailureKind(lifecycleFailure.error)
3115
+ },
2904
3116
  actor,
2905
3117
  actorRef,
2906
3118
  submitMailbox,
2907
3119
  signal
2908
3120
  );
2909
3121
  }
3122
+ if (lifecycleFailure !== undefined) throw lifecycleFailure.error;
2910
3123
  this.formalRemoteActorAdmissions.markCommitted(relocationId, actor);
2911
3124
  return true;
2912
3125
  }
@@ -3142,19 +3355,10 @@ export class DefaultZLinkSpotManager {
3142
3355
  }
3143
3356
  }
3144
3357
 
3145
- function instanceDispatchErrorReason(error: unknown): ZLinkDispatchErrorReason {
3146
- if (error instanceof ZLinkFrameworkException) {
3147
- const kind = internalFrameworkErrorKind(error);
3148
- if (
3149
- kind === ZLinkFrameworkInternalErrorKind.SpotGenerationStale ||
3150
- kind === ZLinkFrameworkInternalErrorKind.SpotMoving ||
3151
- kind === ZLinkFrameworkInternalErrorKind.SpotRouteNotFound ||
3152
- kind === ZLinkFrameworkInternalErrorKind.RequestTargetNotFound
3153
- ) {
3154
- return ZLinkDispatchErrorReason.StaleTarget;
3155
- }
3156
- }
3157
- return ZLinkDispatchErrorReason.HandlerException;
3358
+ function spotActorFailureKind(error: unknown): ZLinkFrameworkErrorKind {
3359
+ return error instanceof ZLinkFrameworkException
3360
+ ? error.kind
3361
+ : ZLinkFrameworkErrorKind.InternalFailure;
3158
3362
  }
3159
3363
 
3160
3364
  interface ZLinkFormalRemoteTransferRequest {