@zlink-systems/framework 0.31.0 → 0.32.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 (181) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/Actors/ZLinkActor.d.ts +2 -0
  3. package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
  4. package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
  5. package/dist/contracts/Actors/index.d.ts +1 -0
  6. package/dist/contracts/Actors/index.js +1 -0
  7. package/dist/contracts/Common/payload-slab.d.ts +4 -0
  8. package/dist/contracts/Common/payload-slab.js +30 -0
  9. package/dist/contracts/Handlers/Contexts.d.ts +1 -0
  10. package/dist/internal.d.ts +9 -0
  11. package/dist/internal.js +23 -1
  12. package/dist/runtime/actors/actor-client.d.ts +1 -1
  13. package/dist/runtime/actors/actor-client.js +32 -23
  14. package/dist/runtime/actors/actor-context.js +1 -1
  15. package/dist/runtime/actors/actor-creation.js +1 -1
  16. package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
  17. package/dist/runtime/actors/actor-runtime-state.d.ts +3 -2
  18. package/dist/runtime/actors/actor-runtime-state.js +24 -8
  19. package/dist/runtime/actors/index.d.ts +3 -3
  20. package/dist/runtime/actors/index.js +19 -32
  21. package/dist/runtime/actors/spot-actor-dispatch.d.ts +4 -2
  22. package/dist/runtime/actors/spot-actor-dispatch.js +2 -1
  23. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
  24. package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
  25. package/dist/runtime/backend/contracts/index.d.ts +2 -0
  26. package/dist/runtime/backend/mesh-completion-table.d.ts +1 -0
  27. package/dist/runtime/backend/mesh-completion-table.js +1 -0
  28. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
  29. package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
  30. package/dist/runtime/backend/node/node-raw-binding-port.js +17 -11
  31. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +2 -2
  32. package/dist/runtime/backend/node/node-raw-mesh-backend.js +15 -8
  33. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +7 -6
  34. package/dist/runtime/channels/channel-dispatch-pipeline.js +1 -0
  35. package/dist/runtime/channels/channel-dispatchers.d.ts +7 -3
  36. package/dist/runtime/channels/channel-dispatchers.js +27 -19
  37. package/dist/runtime/channels/channel-envelope.js +543 -23
  38. package/dist/runtime/channels/channel-receive-loops.d.ts +9 -6
  39. package/dist/runtime/channels/channel-receive-loops.js +59 -18
  40. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +22 -3
  41. package/dist/runtime/channels/channel-socket-registry.d.ts +22 -4
  42. package/dist/runtime/diagnostics/runtime-metrics.d.ts +1 -1
  43. package/dist/runtime/diagnostics/runtime-metrics.js +2 -1
  44. package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
  45. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +27 -11
  46. package/dist/runtime/foundation/raw-service-mesh-runtime.js +29 -25
  47. package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
  48. package/dist/runtime/foundation/service-mailbox.d.ts +3 -1
  49. package/dist/runtime/foundation/service-mailbox.js +4 -1
  50. package/dist/runtime/foundation/service-runtime-contracts.d.ts +3 -1
  51. package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
  52. package/dist/runtime/foundation/service-stateful-registry.js +28 -12
  53. package/dist/runtime/foundation/service-stateful-runtime.d.ts +51 -19
  54. package/dist/runtime/foundation/service-stateful-runtime.js +54 -5
  55. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
  56. package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
  57. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  58. package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
  59. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
  60. package/dist/runtime/foundation/service-wire-m6a-codec.js +17 -7
  61. package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
  62. package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
  63. package/dist/runtime/host/application-job-queue.d.ts +1 -1
  64. package/dist/runtime/host/index.d.ts +89 -36
  65. package/dist/runtime/host/index.js +101 -7
  66. package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
  67. package/dist/runtime/host/service-relocation-host-runtime.d.ts +181 -44
  68. package/dist/runtime/host/service-relocation-host-runtime.js +47 -13
  69. package/dist/runtime/host/spot-address-transport.js +50 -42
  70. package/dist/runtime/locations/actor-location-claims.js +9 -10
  71. package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
  72. package/dist/runtime/locations/auto-connect-loop.js +25 -19
  73. package/dist/runtime/locations/auto-connect-planner.js +2 -5
  74. package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
  75. package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
  76. package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
  77. package/dist/runtime/locations/in-memory-location-store.js +1 -38
  78. package/dist/runtime/locations/location-store-repository.d.ts +0 -1
  79. package/dist/runtime/locations/location-store-repository.js +13 -115
  80. package/dist/runtime/locations/runtime.d.ts +3 -3
  81. package/dist/runtime/locations/runtime.js +12 -16
  82. package/dist/runtime/messaging/creation-payload-codec.js +2 -2
  83. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
  84. package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
  85. package/dist/runtime/spots/index.d.ts +20 -5
  86. package/dist/runtime/spots/index.js +14 -0
  87. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +3 -3
  88. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +1 -0
  89. package/dist/runtime/spots/spot-actor-packet-dispatch.js +13 -7
  90. package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
  91. package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
  92. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -1
  93. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +8 -6
  94. package/dist/runtime/spots/spot-node-runtime-manager.js +2 -0
  95. package/dist/runtime/spots/spot-route-packet-dispatch.js +7 -4
  96. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +3 -1
  97. package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
  98. package/dist/runtime/spots/spot-subscription-dispatch.js +3 -1
  99. package/dist/runtime/spots/spot-timer.d.ts +1 -1
  100. package/dist/runtime/streams/actor-session-binding-registry.d.ts +9 -3
  101. package/dist/runtime/streams/actor-session-binding-registry.js +17 -0
  102. package/dist/runtime/streams/index.d.ts +3 -3
  103. package/dist/runtime/streams/index.js +22 -2
  104. package/dist/runtime/streams/managed-stream.js +2 -1
  105. package/dist/runtime/streams/session-calls.d.ts +1 -1
  106. package/dist/runtime/streams/session-calls.js +3 -9
  107. package/dist/runtime/streams/session-context.d.ts +2 -2
  108. package/dist/runtime/streams/session-context.js +2 -2
  109. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
  110. package/dist/runtime/streams/stream-session-runtime.js +37 -12
  111. package/package.json +3 -3
  112. package/src/contracts/Actors/ZLinkActor.ts +6 -0
  113. package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
  114. package/src/contracts/Actors/index.ts +1 -0
  115. package/src/contracts/Common/payload-slab.ts +29 -0
  116. package/src/contracts/Handlers/Contexts.ts +1 -0
  117. package/src/internal.ts +17 -0
  118. package/src/runtime/actors/actor-client.ts +48 -23
  119. package/src/runtime/actors/actor-context.ts +1 -1
  120. package/src/runtime/actors/actor-creation.ts +1 -1
  121. package/src/runtime/actors/actor-mailbox.ts +1 -1
  122. package/src/runtime/actors/actor-runtime-state.ts +28 -10
  123. package/src/runtime/actors/index.ts +30 -35
  124. package/src/runtime/actors/spot-actor-dispatch.ts +4 -3
  125. package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
  126. package/src/runtime/backend/contracts/index.ts +2 -0
  127. package/src/runtime/backend/mesh-completion-table.ts +2 -0
  128. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
  129. package/src/runtime/backend/node/node-raw-binding-port.ts +20 -7
  130. package/src/runtime/backend/node/node-raw-mesh-backend.ts +18 -10
  131. package/src/runtime/channels/channel-dispatch-pipeline.ts +6 -5
  132. package/src/runtime/channels/channel-dispatchers.ts +39 -19
  133. package/src/runtime/channels/channel-envelope.ts +547 -20
  134. package/src/runtime/channels/channel-receive-loops.ts +93 -36
  135. package/src/runtime/channels/channel-runtime-lifecycle.ts +2 -2
  136. package/src/runtime/channels/channel-socket-registry.ts +3 -3
  137. package/src/runtime/diagnostics/runtime-metrics.ts +3 -1
  138. package/src/runtime/execution/serial-execution-queue.ts +13 -13
  139. package/src/runtime/foundation/raw-service-mesh-runtime.ts +40 -39
  140. package/src/runtime/foundation/service-liveness-registry.ts +1 -1
  141. package/src/runtime/foundation/service-mailbox.ts +6 -1
  142. package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
  143. package/src/runtime/foundation/service-stateful-registry.ts +39 -14
  144. package/src/runtime/foundation/service-stateful-runtime.ts +87 -21
  145. package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
  146. package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
  147. package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -7
  148. package/src/runtime/host/actor-placement-coordinator.ts +1 -1
  149. package/src/runtime/host/actor-transfer-runtime.ts +3 -3
  150. package/src/runtime/host/application-job-queue.ts +1 -1
  151. package/src/runtime/host/index.ts +183 -44
  152. package/src/runtime/host/location-runtime-owner.ts +2 -2
  153. package/src/runtime/host/service-relocation-host-runtime.ts +101 -65
  154. package/src/runtime/host/spot-address-transport.ts +67 -61
  155. package/src/runtime/locations/actor-location-claims.ts +14 -14
  156. package/src/runtime/locations/auto-connect-loop.ts +24 -16
  157. package/src/runtime/locations/auto-connect-planner.ts +2 -5
  158. package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
  159. package/src/runtime/locations/in-memory-location-store.ts +1 -74
  160. package/src/runtime/locations/location-store-repository.ts +32 -153
  161. package/src/runtime/locations/runtime.ts +16 -28
  162. package/src/runtime/messaging/creation-payload-codec.ts +3 -3
  163. package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
  164. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  165. package/src/runtime/spots/index.ts +28 -4
  166. package/src/runtime/spots/spot-actor-admission-coordinator.ts +1 -1
  167. package/src/runtime/spots/spot-actor-packet-dispatch.ts +16 -6
  168. package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
  169. package/src/runtime/spots/spot-entry-activation.ts +1 -1
  170. package/src/runtime/spots/spot-node-runtime-manager.ts +8 -6
  171. package/src/runtime/spots/spot-route-packet-dispatch.ts +8 -4
  172. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +3 -1
  173. package/src/runtime/spots/spot-serial-executor.ts +1 -1
  174. package/src/runtime/spots/spot-subscription-dispatch.ts +3 -1
  175. package/src/runtime/spots/spot-timer.ts +1 -1
  176. package/src/runtime/streams/actor-session-binding-registry.ts +30 -3
  177. package/src/runtime/streams/index.ts +30 -4
  178. package/src/runtime/streams/managed-stream.ts +2 -1
  179. package/src/runtime/streams/session-calls.ts +9 -14
  180. package/src/runtime/streams/session-context.ts +6 -11
  181. package/src/runtime/streams/stream-session-runtime.ts +49 -20
@@ -1,7 +1,9 @@
1
1
  import type { ZLinkActorContext } from './ZLinkActorContext';
2
2
  import type { ZLinkActorJoinCompletion } from './ZLinkActorFactory';
3
+ import type { ZLinkSessionBindingIdentity } from './ZLinkSessionBindingIdentity';
3
4
  export interface ZLinkActor {
4
5
  readonly context: ZLinkActorContext;
5
6
  configure?(): void;
6
7
  onJoinCompleted?(completion: ZLinkActorJoinCompletion): Promise<void>;
8
+ onDuplicateBind?(current: ZLinkSessionBindingIdentity, incoming: ZLinkSessionBindingIdentity, signal: AbortSignal): Promise<string | undefined>;
7
9
  }
@@ -0,0 +1,6 @@
1
+ import type { RoutingId } from '../Common';
2
+ export interface ZLinkSessionBindingIdentity {
3
+ readonly sessionOwnerNodeRid: RoutingId;
4
+ readonly sessionOwnerNodeGeneration: bigint;
5
+ readonly bindingGeneration: bigint;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  export * from './ZLinkActor';
2
+ export * from './ZLinkSessionBindingIdentity';
2
3
  export * from './ZLinkActorContext';
3
4
  export * from './ZLinkActorClient';
4
5
  export * from './ZLinkActorFactory';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ZLinkActor"), exports);
18
+ __exportStar(require("./ZLinkSessionBindingIdentity"), exports);
18
19
  __exportStar(require("./ZLinkActorContext"), exports);
19
20
  __exportStar(require("./ZLinkActorClient"), exports);
20
21
  __exportStar(require("./ZLinkActorFactory"), exports);
@@ -0,0 +1,4 @@
1
+ /** Allocates independent bytes; previously returned regions are never reused. */
2
+ export declare function allocatePayloadBytes(length: number): Buffer;
3
+ /** Copies bytes into an exact, standalone backing store with no Buffer pool. */
4
+ export declare function copyPayloadBytes(bytes: Uint8Array): Buffer;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allocatePayloadBytes = allocatePayloadBytes;
4
+ exports.copyPayloadBytes = copyPayloadBytes;
5
+ const SLAB_BYTES = 64 * 1024;
6
+ const MAX_POOLED_BYTES = 16 * 1024;
7
+ const ALIGNMENT = 8;
8
+ let slab;
9
+ let offset = 0;
10
+ /** Allocates independent bytes; previously returned regions are never reused. */
11
+ function allocatePayloadBytes(length) {
12
+ if (length > MAX_POOLED_BYTES || length < 0 || !Number.isInteger(length)) {
13
+ return Buffer.allocUnsafe(length);
14
+ }
15
+ if (slab === undefined || offset + length > SLAB_BYTES) {
16
+ slab = Buffer.allocUnsafe(SLAB_BYTES);
17
+ offset = 0;
18
+ }
19
+ const bytes = slab.subarray(offset, offset + length);
20
+ offset += Math.ceil(length / ALIGNMENT) * ALIGNMENT;
21
+ // Transient runtime frames only; local queues and application boundaries
22
+ // copy before they retain or expose these bytes.
23
+ return bytes;
24
+ }
25
+ /** Copies bytes into an exact, standalone backing store with no Buffer pool. */
26
+ function copyPayloadBytes(bytes) {
27
+ const copy = Buffer.allocUnsafeSlow(bytes.byteLength);
28
+ copy.set(bytes);
29
+ return copy;
30
+ }
@@ -6,6 +6,7 @@ export interface ZLinkMessageContext {
6
6
  readonly contentType?: string;
7
7
  readonly metadata: ZLinkMessageMetadata;
8
8
  readonly correlationId?: string;
9
+ readonly receivedAt: Date;
9
10
  }
10
11
  export interface ZLinkPublishMessageContext extends ZLinkMessageContext {
11
12
  readonly channelName: string;
@@ -3,6 +3,11 @@ export * from './index';
3
3
  export { requireValidSendTimeoutMs } from './contracts/Configuration/SendTimeoutValidation';
4
4
  export * from './runtime/diagnostics';
5
5
  export * from './runtime/host';
6
+ export { ZLinkActorPlacementCoordinator } from './runtime/host/actor-placement-coordinator';
7
+ export { ZLinkActorTransferRuntime } from './runtime/host/actor-transfer-runtime';
8
+ export { ApplicationJobQueue, ApplicationJobQueuePermit, nodeEffectiveProcessorCount, resolveApplicationJobQueueConfiguration } from './runtime/host/application-job-queue';
9
+ export { ZLinkLocationRuntimeOwner } from './runtime/host/location-runtime-owner';
10
+ export { relocationFailedFailureCode, ZLinkHostServiceRelocationRuntime } from './runtime/host/service-relocation-host-runtime';
6
11
  export * from './runtime/admission';
7
12
  export * from './runtime/activation-admission';
8
13
  export * from './runtime/streams';
@@ -17,9 +22,13 @@ export * from './runtime/locations/canonical-codec';
17
22
  export { ZLinkLocationAutoConnectType, ZLinkLocationKind, ZLinkRouteKind } from './contracts/Locations/Values';
18
23
  export { ZLinkLocationWriteIntent, ZLinkLocationWriteStatus } from './contracts/Locations/Writes';
19
24
  export * from './runtime/channels';
25
+ export { ZLinkChannelRuntimeLifecycle } from './runtime/channels/channel-runtime-lifecycle';
26
+ export { ZLinkChannelSocketRegistry } from './runtime/channels/channel-socket-registry';
27
+ export { ZLinkChannelDispatchPipeline } from './runtime/channels/channel-dispatch-pipeline';
20
28
  export * from './runtime/backend';
21
29
  export * from './runtime/codecs';
22
30
  export * from './runtime/execution';
31
+ export { ZLinkSerialExecutionQueue } from './runtime/execution/serial-execution-queue';
23
32
  export * from './runtime/handlers';
24
33
  export * from './runtime/messaging';
25
34
  export * from './runtime/foundation';
package/dist/internal.js CHANGED
@@ -14,13 +14,27 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.requirePublicWeight = exports.isValidCapacity = exports.isValidListenerPort = exports.isValidPositiveCapacity = exports.isValidPublicWeight = exports.ZLINK_MAX_CAPACITY = exports.ZLINK_MAX_PUBLIC_WEIGHT = exports.MAX_LISTENER_PORT = exports.ZLINK_MAX_STABLE_TYPE_BYTES = exports.ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = exports.ZLinkLocationWriteStatus = exports.ZLinkLocationWriteIntent = exports.ZLinkRouteKind = exports.ZLinkLocationKind = exports.ZLinkLocationAutoConnectType = exports.requireValidSendTimeoutMs = void 0;
17
+ exports.requirePublicWeight = exports.isValidCapacity = exports.isValidListenerPort = exports.isValidPositiveCapacity = exports.isValidPublicWeight = exports.ZLINK_MAX_CAPACITY = exports.ZLINK_MAX_PUBLIC_WEIGHT = exports.MAX_LISTENER_PORT = exports.ZLINK_MAX_STABLE_TYPE_BYTES = exports.ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = exports.ZLinkSerialExecutionQueue = exports.ZLinkChannelDispatchPipeline = exports.ZLinkChannelSocketRegistry = exports.ZLinkChannelRuntimeLifecycle = exports.ZLinkLocationWriteStatus = exports.ZLinkLocationWriteIntent = exports.ZLinkRouteKind = exports.ZLinkLocationKind = exports.ZLinkLocationAutoConnectType = exports.ZLinkHostServiceRelocationRuntime = exports.relocationFailedFailureCode = exports.ZLinkLocationRuntimeOwner = exports.resolveApplicationJobQueueConfiguration = exports.nodeEffectiveProcessorCount = exports.ApplicationJobQueuePermit = exports.ApplicationJobQueue = exports.ZLinkActorTransferRuntime = exports.ZLinkActorPlacementCoordinator = exports.requireValidSendTimeoutMs = void 0;
18
18
  /** Test and companion-package integration surface. It is not exported by package.json. */
19
19
  __exportStar(require("./index"), exports);
20
20
  var SendTimeoutValidation_1 = require("./contracts/Configuration/SendTimeoutValidation");
21
21
  Object.defineProperty(exports, "requireValidSendTimeoutMs", { enumerable: true, get: function () { return SendTimeoutValidation_1.requireValidSendTimeoutMs; } });
22
22
  __exportStar(require("./runtime/diagnostics"), exports);
23
23
  __exportStar(require("./runtime/host"), exports);
24
+ var actor_placement_coordinator_1 = require("./runtime/host/actor-placement-coordinator");
25
+ Object.defineProperty(exports, "ZLinkActorPlacementCoordinator", { enumerable: true, get: function () { return actor_placement_coordinator_1.ZLinkActorPlacementCoordinator; } });
26
+ var actor_transfer_runtime_1 = require("./runtime/host/actor-transfer-runtime");
27
+ Object.defineProperty(exports, "ZLinkActorTransferRuntime", { enumerable: true, get: function () { return actor_transfer_runtime_1.ZLinkActorTransferRuntime; } });
28
+ var application_job_queue_1 = require("./runtime/host/application-job-queue");
29
+ Object.defineProperty(exports, "ApplicationJobQueue", { enumerable: true, get: function () { return application_job_queue_1.ApplicationJobQueue; } });
30
+ Object.defineProperty(exports, "ApplicationJobQueuePermit", { enumerable: true, get: function () { return application_job_queue_1.ApplicationJobQueuePermit; } });
31
+ Object.defineProperty(exports, "nodeEffectiveProcessorCount", { enumerable: true, get: function () { return application_job_queue_1.nodeEffectiveProcessorCount; } });
32
+ Object.defineProperty(exports, "resolveApplicationJobQueueConfiguration", { enumerable: true, get: function () { return application_job_queue_1.resolveApplicationJobQueueConfiguration; } });
33
+ var location_runtime_owner_1 = require("./runtime/host/location-runtime-owner");
34
+ Object.defineProperty(exports, "ZLinkLocationRuntimeOwner", { enumerable: true, get: function () { return location_runtime_owner_1.ZLinkLocationRuntimeOwner; } });
35
+ var service_relocation_host_runtime_1 = require("./runtime/host/service-relocation-host-runtime");
36
+ Object.defineProperty(exports, "relocationFailedFailureCode", { enumerable: true, get: function () { return service_relocation_host_runtime_1.relocationFailedFailureCode; } });
37
+ Object.defineProperty(exports, "ZLinkHostServiceRelocationRuntime", { enumerable: true, get: function () { return service_relocation_host_runtime_1.ZLinkHostServiceRelocationRuntime; } });
24
38
  __exportStar(require("./runtime/admission"), exports);
25
39
  __exportStar(require("./runtime/activation-admission"), exports);
26
40
  __exportStar(require("./runtime/streams"), exports);
@@ -40,9 +54,17 @@ var Writes_1 = require("./contracts/Locations/Writes");
40
54
  Object.defineProperty(exports, "ZLinkLocationWriteIntent", { enumerable: true, get: function () { return Writes_1.ZLinkLocationWriteIntent; } });
41
55
  Object.defineProperty(exports, "ZLinkLocationWriteStatus", { enumerable: true, get: function () { return Writes_1.ZLinkLocationWriteStatus; } });
42
56
  __exportStar(require("./runtime/channels"), exports);
57
+ var channel_runtime_lifecycle_1 = require("./runtime/channels/channel-runtime-lifecycle");
58
+ Object.defineProperty(exports, "ZLinkChannelRuntimeLifecycle", { enumerable: true, get: function () { return channel_runtime_lifecycle_1.ZLinkChannelRuntimeLifecycle; } });
59
+ var channel_socket_registry_1 = require("./runtime/channels/channel-socket-registry");
60
+ Object.defineProperty(exports, "ZLinkChannelSocketRegistry", { enumerable: true, get: function () { return channel_socket_registry_1.ZLinkChannelSocketRegistry; } });
61
+ var channel_dispatch_pipeline_1 = require("./runtime/channels/channel-dispatch-pipeline");
62
+ Object.defineProperty(exports, "ZLinkChannelDispatchPipeline", { enumerable: true, get: function () { return channel_dispatch_pipeline_1.ZLinkChannelDispatchPipeline; } });
43
63
  __exportStar(require("./runtime/backend"), exports);
44
64
  __exportStar(require("./runtime/codecs"), exports);
45
65
  __exportStar(require("./runtime/execution"), exports);
66
+ var serial_execution_queue_1 = require("./runtime/execution/serial-execution-queue");
67
+ Object.defineProperty(exports, "ZLinkSerialExecutionQueue", { enumerable: true, get: function () { return serial_execution_queue_1.ZLinkSerialExecutionQueue; } });
46
68
  __exportStar(require("./runtime/handlers"), exports);
47
69
  __exportStar(require("./runtime/messaging"), exports);
48
70
  __exportStar(require("./runtime/foundation"), exports);
@@ -30,7 +30,7 @@ export declare class DefaultZLinkActorClient implements ZLinkActorClient {
30
30
  private send;
31
31
  private request;
32
32
  private resolveActorRoute;
33
- private invalidateActorRoute;
33
+ private mapActorFailure;
34
34
  private throwIfKnownStale;
35
35
  private createPacketParts;
36
36
  private submitActorSend;
@@ -42,10 +42,12 @@ class DefaultZLinkActorClient {
42
42
  async send(actorId, explicitPacketName, message, metadata) {
43
43
  const route = await this.resolveActorRoute(actorId);
44
44
  const { meshName, actorRef: actor } = route;
45
- this.throwIfKnownStale(meshName, actor);
45
+ this.throwIfKnownStale(route);
46
46
  const parts = this.createPacketParts(protocol_1.ZLinkStreamMessageKind.Send, undefined, explicitPacketName, message, metadata);
47
+ let routeFence;
47
48
  try {
48
49
  const messageFollow = createActorMessageFollowContext(route, parts, false);
50
+ routeFence = actorRouteInvalidationFence(route);
49
51
  const routedActor = (0, actor_message_follow_context_1.attachActorMessageFollowContext)(actor, messageFollow);
50
52
  const submissionCopies = (await this.options.transportDeliveryGate?.()?.waitBeforeSubmit(actorId, 'oneWay')) ?? 1;
51
53
  const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, false, routedActor);
@@ -76,12 +78,7 @@ class DefaultZLinkActorClient {
76
78
  return await this.submitActorSend(meshName, toBackendActorRef(actor), parts, route);
77
79
  }
78
80
  catch (error) {
79
- if (isStaleActorError(error)) {
80
- this.invalidateActorRoute(actorId);
81
- this.options.staleActorRefReporter?.(meshName, actor.actorId);
82
- throw actorLocationStale(actor.actorId, error);
83
- }
84
- throw error;
81
+ throw this.mapActorFailure(actorId, error, routeFence, meshName);
85
82
  }
86
83
  finally {
87
84
  closeMessages(parts);
@@ -92,6 +89,7 @@ class DefaultZLinkActorClient {
92
89
  const sourceSpotId = (0, actor_execution_context_1.currentZLinkActorExecution)()?.spotId ?? (0, execution_1.currentZLinkSpotSerialSourceId)();
93
90
  const effectiveTimeoutMs = timeoutMs ?? this.options.defaultRequestTimeoutMs;
94
91
  let meshName;
92
+ let routeFence;
95
93
  return this.requests.prepare(effectiveTimeoutMs, signal, (requestOperation, receiver) => {
96
94
  void (async () => {
97
95
  const deadlineMs = requestOperation.deadlineMs;
@@ -106,14 +104,17 @@ class DefaultZLinkActorClient {
106
104
  }
107
105
  const { actorRef: actor } = route;
108
106
  meshName = route.meshName;
109
- if (this.options.staleActorRefPredicate?.(meshName, actor) === true)
107
+ if (this.options.staleActorRefPredicate?.(meshName, actor) === true) {
108
+ routeFence = actorRouteInvalidationFence(route);
110
109
  throw actorLocationStale(actor.actorId, undefined);
110
+ }
111
111
  const operationId = (0, actor_message_follow_context_1.createMessageFollowId)();
112
112
  const correlationId = (0, actor_message_follow_context_1.createMessageFollowId)();
113
113
  const requestSequence = BigInt(`0x${operationId.slice(16)}`);
114
114
  const parts = this.createPacketParts(protocol_1.ZLinkStreamMessageKind.Request, requestSequence === 0n ? 1n : requestSequence, explicitPacketName, request, mergeActorRequestMetadata(metadata, deadlineUnixMs), correlationId);
115
115
  try {
116
116
  const messageFollow = createActorMessageFollowContext(route, parts, true, deadlineUnixMs, correlationId, operationId);
117
+ routeFence = actorRouteInvalidationFence(route);
117
118
  const routedActor = (0, actor_message_follow_context_1.attachActorMessageFollowContext)(actor, messageFollow);
118
119
  const delivery = this.options
119
120
  .transportDeliveryGate?.()
@@ -139,15 +140,7 @@ class DefaultZLinkActorClient {
139
140
  closeMessages(parts);
140
141
  }
141
142
  })().catch((error) => receiver.operationFailed(requestOperation.id, error, undefined));
142
- }, (value) => value, (error) => {
143
- if (isStaleActorError(error)) {
144
- this.invalidateActorRoute(actorId);
145
- if (meshName !== undefined)
146
- this.options.staleActorRefReporter?.(meshName, actorId);
147
- return actorLocationStale(actorId, error);
148
- }
149
- return error;
150
- });
143
+ }, (value) => value, (error) => this.mapActorFailure(actorId, error, routeFence, meshName));
151
144
  }
152
145
  async resolveActorRoute(actorId, signal, deadlineMs, requestOperation) {
153
146
  const resolver = this.options.locationResolver();
@@ -163,15 +156,21 @@ class DefaultZLinkActorClient {
163
156
  }
164
157
  return resolution.route;
165
158
  }
166
- invalidateActorRoute(actorId) {
167
- this.options.locationResolver()?.invalidateActorRoute(actorId);
159
+ mapActorFailure(actorId, error, routeFence, meshName) {
160
+ if (!isStaleActorError(error))
161
+ return error;
162
+ const resolver = this.options.locationResolver();
163
+ if (routeFence !== undefined && resolver !== undefined)
164
+ resolver.invalidateActorRouteIfMatches(routeFence);
165
+ if (meshName !== undefined)
166
+ this.options.staleActorRefReporter?.(meshName, actorId);
167
+ return actorLocationStale(actorId, error);
168
168
  }
169
- throwIfKnownStale(meshName, actor) {
169
+ throwIfKnownStale(route) {
170
+ const { meshName, actorRef: actor } = route;
170
171
  if (this.options.staleActorRefPredicate?.(meshName, actor) !== true)
171
172
  return;
172
- this.invalidateActorRoute(actor.actorId);
173
- this.options.staleActorRefReporter?.(meshName, actor.actorId);
174
- throw actorLocationStale(actor.actorId, undefined);
173
+ throw this.mapActorFailure(actor.actorId, actorLocationStale(actor.actorId, undefined), actorRouteInvalidationFence(route), meshName);
175
174
  }
176
175
  createPacketParts(kind, requestSeq, explicitPacketName, message, metadata, correlationId) {
177
176
  const packetName = (0, packet_name_1.resolveFrameworkPacketName)(message, explicitPacketName, 'Actor');
@@ -301,6 +300,16 @@ function nativeActorRouteFence(route, actor) {
301
300
  ownerLeaseGeneration: route.ownerLeaseGeneration
302
301
  };
303
302
  }
303
+ function actorRouteInvalidationFence(route) {
304
+ return {
305
+ actorId: route.actorRef.actorId,
306
+ objectGeneration: route.actorRef.objectGeneration,
307
+ targetNodeRid: route.actorRef.nodeRid,
308
+ targetNodeGeneration: route.ownerNodeGeneration,
309
+ authorityOwnerGeneration: route.authorityOwnerGeneration,
310
+ ownerLeaseGeneration: route.ownerLeaseGeneration
311
+ };
312
+ }
304
313
  function remoteActorRouteTarget(route) {
305
314
  if (route.enclosingSpotRoute !== undefined) {
306
315
  return route.enclosingSpotRoute;
@@ -59,7 +59,7 @@ class DefaultZLinkActorContext {
59
59
  return this.state.boundSession;
60
60
  }
61
61
  get objectGeneration() {
62
- return this.state.nativeActorRef?.generation ?? 1n;
62
+ return this.state.currentActorRef().generation;
63
63
  }
64
64
  get spotId() {
65
65
  return this.state.spotId;
@@ -116,7 +116,7 @@ class ZLinkActorCreationCoordinator {
116
116
  }
117
117
  }
118
118
  else if (nodeRid !== undefined && updateLocation) {
119
- await this.options.locationLifecycle?.setActorRef(actorType, actorId, { actorId, objectGeneration: 1n, meshName, nodeRid }, 0n);
119
+ await this.options.locationLifecycle?.setActorRef(actorType, actorId, (0, actor_runtime_state_1.toFrameworkActorRef)(state.currentActorRef(), meshName), 0n);
120
120
  }
121
121
  return { status: 'created', actor, reply: response.reply };
122
122
  }
@@ -2,7 +2,7 @@ import { ZLinkSerialExecutionQueue, type ZLinkSerialSchedulerOptions, type ZLink
2
2
  export declare class ZLinkActorSerialExecutor {
3
3
  private readonly actorId;
4
4
  private readonly sourceSpotId;
5
- private readonly scheduler;
5
+ readonly scheduler: ZLinkSerialExecutionQueue;
6
6
  constructor(actorId: string, sourceSpotId: unknown, options?: ZLinkSerialSchedulerOptions, sharedOwner?: ZLinkSerialExecutionQueue);
7
7
  execute<T>(operation: () => Promise<T> | T, workOptions?: ZLinkSerialWorkOptions): Promise<T>;
8
8
  close(): Promise<void>;
@@ -76,8 +76,9 @@ export declare class ZLinkActorRuntimeState {
76
76
  private spotGenerationValue;
77
77
  private spotMembershipEpochValue;
78
78
  private nativeActorRefValue;
79
+ private nativeActorDestroyed;
79
80
  private entryNodeRidValue;
80
- private boundSessionValue;
81
+ boundSessionValue: ZLinkRemoteBoundSessionTarget | undefined;
81
82
  private remoteActorPacketTargetValue;
82
83
  private createRequestPayloadValue;
83
84
  private ownsLocationValue;
@@ -96,6 +97,7 @@ export declare class ZLinkActorRuntimeState {
96
97
  get spotMembershipEpoch(): bigint;
97
98
  get spotGeneration(): bigint | undefined;
98
99
  get nativeActorRef(): ZLinkBackendActorRef | undefined;
100
+ currentActorRef(): ZLinkBackendActorRef;
99
101
  get boundSessionBindingGeneration(): bigint;
100
102
  get entryNodeRid(): RoutingId | undefined;
101
103
  /** The one current Session binding of this Actor (Session–Actor binding §6). */
@@ -124,7 +126,6 @@ export declare class ZLinkActorRuntimeState {
124
126
  setOwnerLeaseGeneration(generation: bigint): void;
125
127
  getOrStartDestroy(entryNodeRid: RoutingId, destroy: (actorRef: ZLinkBackendActorRef | undefined) => Promise<void>): Promise<void>;
126
128
  markNativeActorDestroyed(actorRef: ZLinkBackendActorRef): void;
127
- clearFailedDestroy(task: Promise<void>): void;
128
129
  ensureContext(createContext: () => ZLinkActorContext): ZLinkActorContext;
129
130
  getOrStartCreation(actorType: string, failIfExists: boolean, createActor: () => Promise<ZLinkActorCreationAttemptResult>): ZLinkActorCreationOperation;
130
131
  clearFailedCreation(task: Promise<ZLinkActorCreationAttemptResult>): boolean;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZLinkActorRuntimeState = void 0;
4
4
  exports.toFrameworkRoutingId = toFrameworkRoutingId;
5
5
  exports.toFrameworkActorRef = toFrameworkActorRef;
6
+ const configuration_1 = require("../configuration");
6
7
  const state_lane_1 = require("../execution/state-lane");
7
8
  const framework_errors_internal_1 = require("../framework-errors-internal");
8
9
  const routing_id_1 = require("../routing-id");
@@ -57,7 +58,9 @@ class ZLinkActorRuntimeState {
57
58
  spotIdValue;
58
59
  spotGenerationValue;
59
60
  spotMembershipEpochValue = 0n;
61
+ // Preserve the exact incarnation until teardown finalization, even after native removal.
60
62
  nativeActorRefValue;
63
+ nativeActorDestroyed = false;
61
64
  entryNodeRidValue;
62
65
  boundSessionValue;
63
66
  remoteActorPacketTargetValue;
@@ -103,6 +106,12 @@ class ZLinkActorRuntimeState {
103
106
  get nativeActorRef() {
104
107
  return this.nativeActorRefValue;
105
108
  }
109
+ currentActorRef() {
110
+ if (this.nativeActorRefValue === undefined) {
111
+ throw new configuration_1.ZLinkConfigurationException(`Actor '${this.actorId}' lifecycle identity is not initialized.`);
112
+ }
113
+ return this.nativeActorRefValue;
114
+ }
106
115
  get boundSessionBindingGeneration() {
107
116
  return this.boundSessionValue?.bindingGeneration ?? 0n;
108
117
  }
@@ -194,20 +203,23 @@ class ZLinkActorRuntimeState {
194
203
  !(0, routing_id_1.routingIdsEqual)(toFrameworkRoutingId(actorRef.nodeRid), entryNodeRid)) {
195
204
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound, `Actor '${this.actorId}' is not owned by this Entry Spot.`);
196
205
  }
197
- const task = Promise.resolve().then(() => destroy(actorRef));
206
+ const task = Promise.resolve()
207
+ .then(() => destroy(this.nativeActorDestroyed ? undefined : actorRef))
208
+ .catch((error) => {
209
+ // A caller may start another attempt only after this attempt has failed.
210
+ if (this.destroyTask === task) {
211
+ this.destroyTask = undefined;
212
+ this.movingValue = false;
213
+ }
214
+ throw error;
215
+ });
198
216
  this.destroyTask = task;
199
217
  return task;
200
218
  }
201
219
  markNativeActorDestroyed(actorRef) {
202
220
  if (this.nativeActorRefValue === actorRef) {
203
- this.nativeActorRefValue = undefined;
204
- }
205
- }
206
- clearFailedDestroy(task) {
207
- if (this.destroyTask === task) {
208
- this.destroyTask = undefined;
221
+ this.nativeActorDestroyed = true;
209
222
  }
210
- this.movingValue = false;
211
223
  }
212
224
  ensureContext(createContext) {
213
225
  this.context ??= createContext();
@@ -243,6 +255,7 @@ class ZLinkActorRuntimeState {
243
255
  this.createRequestPayloadValue = undefined;
244
256
  this.configured = false;
245
257
  this.nativeActorRefValue = undefined;
258
+ this.nativeActorDestroyed = false;
246
259
  this.entryNodeRidValue = undefined;
247
260
  return true;
248
261
  }
@@ -278,6 +291,7 @@ class ZLinkActorRuntimeState {
278
291
  }
279
292
  setNativeActorRef(actorRef) {
280
293
  this.nativeActorRefValue = actorRef;
294
+ this.nativeActorDestroyed = false;
281
295
  this.entryNodeRidValue ??= toFrameworkRoutingId(actorRef.nodeRid);
282
296
  }
283
297
  /** @internal Installs one authority-confirmed binding inside its Actor owner turn. */
@@ -344,6 +358,7 @@ class ZLinkActorRuntimeState {
344
358
  this.spotGenerationValue = undefined;
345
359
  this.spotMembershipEpochValue = 0n;
346
360
  this.nativeActorRefValue = undefined;
361
+ this.nativeActorDestroyed = false;
347
362
  this.entryNodeRidValue = undefined;
348
363
  this.boundSessionValue = undefined;
349
364
  this.remoteActorPacketTargetValue = undefined;
@@ -366,6 +381,7 @@ class ZLinkActorRuntimeState {
366
381
  this.spotValue = undefined;
367
382
  this.spotIdValue = undefined;
368
383
  this.nativeActorRefValue = undefined;
384
+ this.nativeActorDestroyed = false;
369
385
  // The arriving relocation installs the binding it carries.
370
386
  this.boundSessionValue = undefined;
371
387
  this.remoteActorPacketTargetValue = undefined;
@@ -64,7 +64,7 @@ export declare class DefaultZLinkActorManager implements ZLinkActorManager {
64
64
  private awaitActorDestroy;
65
65
  getOrCreateActor(actorId: string, actorType: string, signal?: AbortSignal): Promise<ZLinkActor>;
66
66
  getOrCreateWithNativeRef(actorId: string, actorType: string, actorRef: ZLinkBackendActorRef, createRequest?: unknown, signal?: AbortSignal): Promise<ZLinkActor>;
67
- getOrCreateActorResult(actorId: string, actorType: string, createRequest?: unknown, signal?: AbortSignal): Promise<ZLinkActorLocalCreateResult>;
67
+ getOrCreateActorResult(actorId: string, actorType: string, createRequest?: unknown, signal?: AbortSignal): Promise<ZLinkActorLocalCreateResult<ActorRef | undefined>>;
68
68
  createReservedActorResult(actorId: string, actorType: string, createRequest: unknown, signal?: AbortSignal, nativeActorRef?: ZLinkBackendActorRef): Promise<ZLinkActorLocalCreateResult>;
69
69
  adoptCreatedAuthority(actorId: string, authorityOwnerGeneration: bigint, ownerLeaseGeneration: bigint): void;
70
70
  getState(actorId: string): ZLinkActorRuntimeState | undefined;
@@ -77,10 +77,10 @@ export declare class DefaultZLinkActorManager implements ZLinkActorManager {
77
77
  private getOrCreateState;
78
78
  private actorRefForState;
79
79
  }
80
- export type ZLinkActorLocalCreateResult = {
80
+ export type ZLinkActorLocalCreateResult<TActorRef extends ActorRef | undefined = ActorRef> = {
81
81
  readonly status: 'existing' | 'created';
82
82
  readonly actor: ZLinkActor;
83
- readonly actorRef: ActorRef;
83
+ readonly actorRef: TActorRef;
84
84
  readonly reply?: unknown;
85
85
  } | {
86
86
  readonly status: 'rejected';
@@ -17,7 +17,6 @@ const actor_creation_1 = require("./actor-creation");
17
17
  const actor_runtime_state_1 = require("./actor-runtime-state");
18
18
  const transferred_actor_rollback_1 = require("./transferred-actor-rollback");
19
19
  const ACTOR_CREATION_RETRY_INTERVAL_MS = 5;
20
- const LOCAL_DIAGNOSTIC_NODE_RID = 'local';
21
20
  var actor_client_1 = require("./actor-client");
22
21
  Object.defineProperty(exports, "DefaultZLinkActorClient", { enumerable: true, get: function () { return actor_client_1.DefaultZLinkActorClient; } });
23
22
  var actor_context_1 = require("./actor-context");
@@ -100,7 +99,7 @@ class DefaultZLinkActorManager {
100
99
  if (this.relocationStaged.has(actorId))
101
100
  return undefined;
102
101
  const state = this.states.get(actorId);
103
- if (state?.actor !== undefined) {
102
+ if (state?.actor !== undefined && state.nativeActorRef !== undefined) {
104
103
  return this.actorRefForState(state);
105
104
  }
106
105
  return await this.options.actorRefResolver?.resolveActorRef(actorId, signal);
@@ -111,7 +110,9 @@ class DefaultZLinkActorManager {
111
110
  async findSpot(actorId, signal) {
112
111
  (0, abort_1.throwIfAborted)(signal);
113
112
  const state = this.states.get(actorId);
114
- if (state?.actor === undefined || state.spotId === undefined)
113
+ if (state?.actor === undefined ||
114
+ state.spotId === undefined ||
115
+ state.nativeActorRef === undefined)
115
116
  return undefined;
116
117
  const spotId = state.spotId;
117
118
  const actorRef = this.actorRefForState(state);
@@ -162,13 +163,7 @@ class DefaultZLinkActorManager {
162
163
  }
163
164
  await this.finalizeDestroyedActor(actor.actorId, state);
164
165
  }));
165
- try {
166
- await this.awaitActorDestroy(state, destroyTask);
167
- }
168
- catch (error) {
169
- state.clearFailedDestroy(destroyTask);
170
- throw error;
171
- }
166
+ await this.awaitActorDestroy(state, destroyTask);
172
167
  return true;
173
168
  }
174
169
  async materializeTransferredActor(actorId, actorType, adapterKey, transferState, signal) {
@@ -235,9 +230,10 @@ class DefaultZLinkActorManager {
235
230
  if (result.status === 'failed') {
236
231
  throw actorApplicationFailure(actorId, result.error);
237
232
  }
233
+ const actorRef = result.actorRef ?? this.actorRefForState(this.states.get(actorId));
238
234
  return result.reply === undefined
239
- ? { status: result.status, actor: result.actorRef }
240
- : { status: result.status, actor: result.actorRef, reply: result.reply };
235
+ ? { status: result.status, actor: actorRef }
236
+ : { status: result.status, actor: actorRef, reply: result.reply };
241
237
  }
242
238
  ensureActorTypeBelongsToMesh(meshName, actorType) {
243
239
  const registeredMesh = this.options.actorMeshNameProvider?.(actorType);
@@ -442,7 +438,13 @@ class DefaultZLinkActorManager {
442
438
  }
443
439
  async createReservedActorResult(actorId, actorType, createRequest, signal, nativeActorRef) {
444
440
  this.rememberActorMeshFromType(actorId, actorType);
445
- return await this.createOrGet(actorId, actorType, false, createRequest, signal, false, Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, nativeActorRef);
441
+ const result = await this.createOrGet(actorId, actorType, false, createRequest, signal, false, Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, nativeActorRef);
442
+ if (result.status === 'failed' || result.status === 'rejected')
443
+ return result;
444
+ return {
445
+ ...result,
446
+ actorRef: this.actorRefForState(this.states.get(actorId))
447
+ };
446
448
  }
447
449
  adoptCreatedAuthority(actorId, authorityOwnerGeneration, ownerLeaseGeneration) {
448
450
  const state = this.states.get(actorId);
@@ -473,7 +475,7 @@ class DefaultZLinkActorManager {
473
475
  throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound, `Actor '${actor.context.actorId}' must leave its current SPOT before destroy.`);
474
476
  }
475
477
  const destroyTask = state.getOrStartDestroy(entryNodeRid, (actorRef) => this.terminateActor(state, async () => {
476
- const destroyedActorRef = actorRef === undefined ? undefined : (0, actor_runtime_state_1.toFrameworkActorRef)(actorRef, state.meshName ?? '');
478
+ const destroyedActorRef = state.nativeActorRef === undefined ? undefined : this.actorRefForState(state);
477
479
  if (actorRef !== undefined) {
478
480
  await node.destroyActor(actorRef, 0, destroySignal);
479
481
  state.markNativeActorDestroyed(actorRef);
@@ -483,13 +485,7 @@ class DefaultZLinkActorManager {
483
485
  }
484
486
  await this.finalizeDestroyedActor(actor.context.actorId, state);
485
487
  }));
486
- try {
487
- await this.awaitActorDestroy(state, destroyTask);
488
- }
489
- catch (error) {
490
- state.clearFailedDestroy(destroyTask);
491
- throw error;
492
- }
488
+ await this.awaitActorDestroy(state, destroyTask);
493
489
  }
494
490
  async createOrGet(actorId, actorType, failIfExists, request, signal, claimLocation = true, timeoutMs = Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, nativeActorRef) {
495
491
  const deadline = performance.now() + timeoutMs;
@@ -533,7 +529,7 @@ class DefaultZLinkActorManager {
533
529
  try {
534
530
  const result = await operation.task;
535
531
  if (result.status === 'created') {
536
- const actorRef = this.actorRefForState(state);
532
+ const actorRef = state.nativeActorRef === undefined ? undefined : this.actorRefForState(state);
537
533
  return {
538
534
  status: operation.created ? 'created' : 'existing',
539
535
  actor: result.actor,
@@ -602,16 +598,7 @@ class DefaultZLinkActorManager {
602
598
  return state;
603
599
  }
604
600
  actorRefForState(state) {
605
- const nativeActorRef = state.nativeActorRef;
606
- if (nativeActorRef !== undefined) {
607
- return (0, actor_runtime_state_1.toFrameworkActorRef)(nativeActorRef, state.meshName ?? '');
608
- }
609
- return {
610
- actorId: state.actorId,
611
- objectGeneration: 1n,
612
- meshName: state.meshName ?? '',
613
- nodeRid: this.options.actorCreatedNodeRidProvider?.() ?? LOCAL_DIAGNOSTIC_NODE_RID
614
- };
601
+ return (0, actor_runtime_state_1.toFrameworkActorRef)(state.currentActorRef(), state.meshName ?? '');
615
602
  }
616
603
  }
617
604
  exports.DefaultZLinkActorManager = DefaultZLinkActorManager;
@@ -54,8 +54,10 @@ export declare class ZLinkSpotActorDispatcher {
54
54
  notifyDisconnectActor(actor: ZLinkActor): Promise<void>;
55
55
  private requirePacket;
56
56
  private ensureActorType;
57
- private invokeHandler;
57
+ invokeHandler<THandler, TResult>(actor: ZLinkActor, descriptor: Pick<ZLinkActorPacketDescriptor, 'handlerType' | 'methodName'>, callback: (handler: THandler, method: THandler extends {
58
+ handle: infer TMethod;
59
+ } ? TMethod : never) => Promise<TResult>): Promise<TResult>;
58
60
  private execute;
59
- private createContext;
61
+ createContext(packetName: string, context: Partial<ZLinkMessageContext> | undefined): ZLinkMessageContext;
60
62
  }
61
63
  export {};
@@ -205,7 +205,8 @@ class ZLinkSpotActorDispatcher {
205
205
  packetName,
206
206
  contentType: context?.contentType,
207
207
  metadata: context?.metadata ?? contracts_1.ZLinkMessageMetadataEmpty,
208
- correlationId: context?.correlationId
208
+ correlationId: context?.correlationId,
209
+ receivedAt: context?.receivedAt ?? new Date()
209
210
  };
210
211
  }
211
212
  }
@@ -29,6 +29,7 @@ export declare class ApplicationJobRecordLease implements ApplicationJobPermitPo
29
29
  private processingTerminal;
30
30
  detachedForHandlerTurn: boolean;
31
31
  constructor(shared: SharedIngressRecordState, permit: ApplicationJobPermitPort | undefined);
32
+ reacquire(signal: AbortSignal): Promise<ApplicationJobPermitPort>;
32
33
  get origin(): ApplicationJobOrigin;
33
34
  markApplicationQueued(): void;
34
35
  detachForHandlerTurn(): void;
@@ -84,6 +84,9 @@ class ApplicationJobRecordLease {
84
84
  this.shared = shared;
85
85
  this.permit = permit;
86
86
  }
87
+ reacquire(signal) {
88
+ return this.shared.acquirePermit(signal);
89
+ }
87
90
  get origin() {
88
91
  return this.shared.origin;
89
92
  }
@@ -472,6 +472,8 @@ export interface ZLinkMeshBackendAdapter {
472
472
  createMeshNode(context: ZLinkBackendContext, options: {
473
473
  readonly meshName: string;
474
474
  readonly routingId?: RoutingId;
475
+ readonly sendHighWaterMark?: number;
476
+ readonly receiveHighWaterMark?: number;
475
477
  readonly receiveTimeoutMs?: number;
476
478
  readonly trustProfile?: string;
477
479
  readonly applicationJobQueue: import('../../application-jobs/contracts').ApplicationJobQueuePort;