@zlink-systems/framework 0.31.0 → 0.32.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 (171) 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-mailbox.d.ts +1 -1
  15. package/dist/runtime/actors/actor-runtime-state.d.ts +1 -1
  16. package/dist/runtime/actors/spot-actor-dispatch.d.ts +4 -2
  17. package/dist/runtime/actors/spot-actor-dispatch.js +2 -1
  18. package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
  19. package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
  20. package/dist/runtime/backend/contracts/index.d.ts +2 -0
  21. package/dist/runtime/backend/mesh-completion-table.d.ts +1 -0
  22. package/dist/runtime/backend/mesh-completion-table.js +1 -0
  23. package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
  24. package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
  25. package/dist/runtime/backend/node/node-raw-binding-port.js +17 -11
  26. package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +2 -2
  27. package/dist/runtime/backend/node/node-raw-mesh-backend.js +15 -8
  28. package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +7 -6
  29. package/dist/runtime/channels/channel-dispatch-pipeline.js +1 -0
  30. package/dist/runtime/channels/channel-dispatchers.d.ts +7 -3
  31. package/dist/runtime/channels/channel-dispatchers.js +27 -19
  32. package/dist/runtime/channels/channel-envelope.js +543 -23
  33. package/dist/runtime/channels/channel-receive-loops.d.ts +9 -6
  34. package/dist/runtime/channels/channel-receive-loops.js +59 -18
  35. package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +22 -3
  36. package/dist/runtime/channels/channel-socket-registry.d.ts +22 -4
  37. package/dist/runtime/diagnostics/runtime-metrics.d.ts +1 -1
  38. package/dist/runtime/diagnostics/runtime-metrics.js +2 -1
  39. package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
  40. package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +27 -11
  41. package/dist/runtime/foundation/raw-service-mesh-runtime.js +29 -25
  42. package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
  43. package/dist/runtime/foundation/service-mailbox.d.ts +3 -1
  44. package/dist/runtime/foundation/service-mailbox.js +4 -1
  45. package/dist/runtime/foundation/service-runtime-contracts.d.ts +3 -1
  46. package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
  47. package/dist/runtime/foundation/service-stateful-registry.js +28 -12
  48. package/dist/runtime/foundation/service-stateful-runtime.d.ts +51 -19
  49. package/dist/runtime/foundation/service-stateful-runtime.js +54 -5
  50. package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
  51. package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
  52. package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
  53. package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
  54. package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
  55. package/dist/runtime/foundation/service-wire-m6a-codec.js +17 -7
  56. package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
  57. package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
  58. package/dist/runtime/host/application-job-queue.d.ts +1 -1
  59. package/dist/runtime/host/index.d.ts +89 -36
  60. package/dist/runtime/host/index.js +101 -7
  61. package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
  62. package/dist/runtime/host/service-relocation-host-runtime.d.ts +181 -44
  63. package/dist/runtime/host/service-relocation-host-runtime.js +47 -13
  64. package/dist/runtime/host/spot-address-transport.js +50 -42
  65. package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
  66. package/dist/runtime/locations/auto-connect-loop.js +25 -19
  67. package/dist/runtime/locations/auto-connect-planner.js +2 -5
  68. package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
  69. package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
  70. package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
  71. package/dist/runtime/locations/in-memory-location-store.js +1 -38
  72. package/dist/runtime/locations/location-store-repository.d.ts +0 -1
  73. package/dist/runtime/locations/location-store-repository.js +13 -115
  74. package/dist/runtime/locations/runtime.d.ts +3 -3
  75. package/dist/runtime/locations/runtime.js +12 -16
  76. package/dist/runtime/messaging/creation-payload-codec.js +2 -2
  77. package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
  78. package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
  79. package/dist/runtime/spots/index.d.ts +20 -5
  80. package/dist/runtime/spots/index.js +14 -0
  81. package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +3 -3
  82. package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +1 -0
  83. package/dist/runtime/spots/spot-actor-packet-dispatch.js +13 -7
  84. package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
  85. package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
  86. package/dist/runtime/spots/spot-entry-activation.d.ts +2 -1
  87. package/dist/runtime/spots/spot-node-runtime-manager.d.ts +8 -6
  88. package/dist/runtime/spots/spot-node-runtime-manager.js +2 -0
  89. package/dist/runtime/spots/spot-route-packet-dispatch.js +7 -4
  90. package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +3 -1
  91. package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
  92. package/dist/runtime/spots/spot-subscription-dispatch.js +3 -1
  93. package/dist/runtime/spots/spot-timer.d.ts +1 -1
  94. package/dist/runtime/streams/actor-session-binding-registry.d.ts +9 -3
  95. package/dist/runtime/streams/actor-session-binding-registry.js +17 -0
  96. package/dist/runtime/streams/index.d.ts +3 -3
  97. package/dist/runtime/streams/index.js +22 -2
  98. package/dist/runtime/streams/managed-stream.js +2 -1
  99. package/dist/runtime/streams/session-calls.d.ts +1 -1
  100. package/dist/runtime/streams/session-calls.js +3 -9
  101. package/dist/runtime/streams/session-context.d.ts +2 -2
  102. package/dist/runtime/streams/session-context.js +2 -2
  103. package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
  104. package/dist/runtime/streams/stream-session-runtime.js +37 -12
  105. package/package.json +3 -3
  106. package/src/contracts/Actors/ZLinkActor.ts +6 -0
  107. package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
  108. package/src/contracts/Actors/index.ts +1 -0
  109. package/src/contracts/Common/payload-slab.ts +29 -0
  110. package/src/contracts/Handlers/Contexts.ts +1 -0
  111. package/src/internal.ts +17 -0
  112. package/src/runtime/actors/actor-client.ts +48 -23
  113. package/src/runtime/actors/actor-mailbox.ts +1 -1
  114. package/src/runtime/actors/actor-runtime-state.ts +1 -1
  115. package/src/runtime/actors/spot-actor-dispatch.ts +4 -3
  116. package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
  117. package/src/runtime/backend/contracts/index.ts +2 -0
  118. package/src/runtime/backend/mesh-completion-table.ts +2 -0
  119. package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
  120. package/src/runtime/backend/node/node-raw-binding-port.ts +20 -7
  121. package/src/runtime/backend/node/node-raw-mesh-backend.ts +18 -10
  122. package/src/runtime/channels/channel-dispatch-pipeline.ts +6 -5
  123. package/src/runtime/channels/channel-dispatchers.ts +39 -19
  124. package/src/runtime/channels/channel-envelope.ts +547 -20
  125. package/src/runtime/channels/channel-receive-loops.ts +93 -36
  126. package/src/runtime/channels/channel-runtime-lifecycle.ts +2 -2
  127. package/src/runtime/channels/channel-socket-registry.ts +3 -3
  128. package/src/runtime/diagnostics/runtime-metrics.ts +3 -1
  129. package/src/runtime/execution/serial-execution-queue.ts +13 -13
  130. package/src/runtime/foundation/raw-service-mesh-runtime.ts +40 -39
  131. package/src/runtime/foundation/service-liveness-registry.ts +1 -1
  132. package/src/runtime/foundation/service-mailbox.ts +6 -1
  133. package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
  134. package/src/runtime/foundation/service-stateful-registry.ts +39 -14
  135. package/src/runtime/foundation/service-stateful-runtime.ts +87 -21
  136. package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
  137. package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
  138. package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -7
  139. package/src/runtime/host/actor-placement-coordinator.ts +1 -1
  140. package/src/runtime/host/actor-transfer-runtime.ts +3 -3
  141. package/src/runtime/host/application-job-queue.ts +1 -1
  142. package/src/runtime/host/index.ts +183 -44
  143. package/src/runtime/host/location-runtime-owner.ts +2 -2
  144. package/src/runtime/host/service-relocation-host-runtime.ts +101 -65
  145. package/src/runtime/host/spot-address-transport.ts +67 -61
  146. package/src/runtime/locations/auto-connect-loop.ts +24 -16
  147. package/src/runtime/locations/auto-connect-planner.ts +2 -5
  148. package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
  149. package/src/runtime/locations/in-memory-location-store.ts +1 -74
  150. package/src/runtime/locations/location-store-repository.ts +32 -153
  151. package/src/runtime/locations/runtime.ts +16 -28
  152. package/src/runtime/messaging/creation-payload-codec.ts +3 -3
  153. package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
  154. package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
  155. package/src/runtime/spots/index.ts +28 -4
  156. package/src/runtime/spots/spot-actor-admission-coordinator.ts +1 -1
  157. package/src/runtime/spots/spot-actor-packet-dispatch.ts +16 -6
  158. package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
  159. package/src/runtime/spots/spot-entry-activation.ts +1 -1
  160. package/src/runtime/spots/spot-node-runtime-manager.ts +8 -6
  161. package/src/runtime/spots/spot-route-packet-dispatch.ts +8 -4
  162. package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +3 -1
  163. package/src/runtime/spots/spot-serial-executor.ts +1 -1
  164. package/src/runtime/spots/spot-subscription-dispatch.ts +3 -1
  165. package/src/runtime/spots/spot-timer.ts +1 -1
  166. package/src/runtime/streams/actor-session-binding-registry.ts +30 -3
  167. package/src/runtime/streams/index.ts +30 -4
  168. package/src/runtime/streams/managed-stream.ts +2 -1
  169. package/src/runtime/streams/session-calls.ts +9 -14
  170. package/src/runtime/streams/session-context.ts +6 -11
  171. package/src/runtime/streams/stream-session-runtime.ts +49 -20
@@ -13,6 +13,7 @@ import { type ZLinkOneWayDispatch, type ZLinkRequestDispatch } from './channel-d
13
13
  export interface ZLinkChannelRequestDispatcherOptions {
14
14
  readonly meshName?: string;
15
15
  readonly channelName: string;
16
+ readonly receivedAtClock?: () => Date;
16
17
  /**
17
18
  * Mesh channels use the routed message context so a handler can associate
18
19
  * a report with the node that sent it.
@@ -57,7 +58,7 @@ export declare class ZLinkChannelRequestDispatcher {
57
58
  send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
58
59
  }, router: {
59
60
  reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
60
- }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<boolean | void>;
61
+ }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<boolean | void>;
61
62
  dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
62
63
  private submitReply;
63
64
  private createMeshContext;
@@ -65,6 +66,7 @@ export declare class ZLinkChannelRequestDispatcher {
65
66
  export interface ZLinkChannelPublishDispatcherOptions {
66
67
  readonly meshName?: string;
67
68
  readonly channelName: string;
69
+ readonly receivedAtClock?: () => Date;
68
70
  readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
69
71
  readonly dispatchErrors: ZLinkDispatchErrorReporter;
70
72
  readonly handlers: ReadonlyMap<string, Pick<ZLinkOneWayDispatch<ZLinkPublishMessageContext>, 'handler' | 'messageType'>>;
@@ -82,10 +84,11 @@ export declare class ZLinkChannelPublishDispatcher {
82
84
  dispatch(topicMessage: {
83
85
  readonly topic: string;
84
86
  readonly parts: readonly Message[];
85
- }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<void>;
87
+ }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<void>;
86
88
  }
87
89
  export interface ZLinkRoutePacketDispatcherOptions {
88
90
  readonly routerChannelId: string;
91
+ readonly receivedAtClock?: () => Date;
89
92
  readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
90
93
  readonly dispatchErrors: ZLinkDispatchErrorReporter;
91
94
  readonly handlers: readonly ZLinkRouteHandlerRegistration[];
@@ -98,6 +101,7 @@ export declare class ZLinkRoutePacketDispatcher {
98
101
  private readonly sendHandlers;
99
102
  private readonly requestHandlers;
100
103
  private readonly codecs?;
104
+ private readonly receivedAtClock;
101
105
  private readonly pipeline;
102
106
  constructor(options: ZLinkRoutePacketDispatcherOptions);
103
107
  private readonly routerChannelId;
@@ -120,7 +124,7 @@ export declare class ZLinkRoutePacketDispatcher {
120
124
  send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
121
125
  }, router: {
122
126
  reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
123
- }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean): Promise<boolean | void>;
127
+ }, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean, receivedAt?: Date): Promise<boolean | void>;
124
128
  dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
125
129
  dispatchLocalCommand(parts: readonly Message[], sourceNodeRid: RoutingId, signal?: AbortSignal): Promise<void>;
126
130
  private dispatchMeshCommand;
@@ -30,7 +30,7 @@ class ZLinkChannelRequestDispatcher {
30
30
  flowEnabled() {
31
31
  return this.options.dispatchErrors.flow.flowCreationEnabled();
32
32
  }
33
- async dispatch(received, router, signal, decodedHeader) {
33
+ async dispatch(received, router, signal, decodedHeader, receivedAt = this.options.receivedAtClock?.() ?? new Date()) {
34
34
  if (received.spotId !== null && received.spotId !== undefined) {
35
35
  if (received.send === undefined) {
36
36
  throw new configuration_1.ZLinkConfigurationException('Routed SPOT packet is missing a local SPOT delivery context.');
@@ -78,7 +78,8 @@ class ZLinkChannelRequestDispatcher {
78
78
  contentType: envelope.header.contentType,
79
79
  packetName,
80
80
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
81
- correlationId
81
+ correlationId,
82
+ receivedAt
82
83
  };
83
84
  await this.pipeline.dispatchOneWay({
84
85
  fields,
@@ -113,7 +114,8 @@ class ZLinkChannelRequestDispatcher {
113
114
  contentType: envelope.header.contentType,
114
115
  packetName,
115
116
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
116
- correlationId
117
+ correlationId,
118
+ receivedAt
117
119
  };
118
120
  await this.pipeline.dispatchRequest({
119
121
  fields: requestFields,
@@ -167,7 +169,7 @@ class ZLinkChannelRequestDispatcher {
167
169
  codecs: this.options.codecs,
168
170
  handler: handler?.handler,
169
171
  messageType: handler?.messageType,
170
- context: this.createMeshContext(envelope, record.sourceNodeRid),
172
+ context: this.createMeshContext(envelope, record.sourceNodeRid, record.receivedAt),
171
173
  signal
172
174
  }, admit);
173
175
  }
@@ -181,7 +183,7 @@ class ZLinkChannelRequestDispatcher {
181
183
  flowId: envelope.header.flowId,
182
184
  flowOrigin: envelope.header.flowOrigin
183
185
  };
184
- return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, this.options.codecs, this.options.handlers.get(packetName), this.createMeshContext(envelope, record.sourceNodeRid), signal, record, 'channel', this.options.channelName), admit);
186
+ return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, this.options.codecs, this.options.handlers.get(packetName), this.createMeshContext(envelope, record.sourceNodeRid, record.receivedAt), signal, record, 'channel', this.options.channelName), admit);
185
187
  }
186
188
  submitReply(operation, signal) {
187
189
  void signal;
@@ -190,14 +192,15 @@ class ZLinkChannelRequestDispatcher {
190
192
  }
191
193
  return completedChannelReply;
192
194
  }
193
- createMeshContext(envelope, sourceNodeRid) {
195
+ createMeshContext(envelope, sourceNodeRid, receivedAt) {
194
196
  const base = {
195
197
  meshName: this.options.meshName,
196
198
  channelName: this.options.channelName,
197
199
  contentType: envelope.header.contentType,
198
200
  packetName: envelope.packetName,
199
201
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
200
- correlationId: envelope.header.correlationId ?? undefined
202
+ correlationId: envelope.header.correlationId ?? undefined,
203
+ receivedAt: receivedAt ?? this.options.receivedAtClock?.() ?? new Date()
201
204
  };
202
205
  if (this.options.routeMesh !== true) {
203
206
  return base;
@@ -270,7 +273,7 @@ class ZLinkChannelPublishDispatcher {
270
273
  unhandled: options.unhandled
271
274
  });
272
275
  }
273
- async dispatch(topicMessage, signal, decodedHeader) {
276
+ async dispatch(topicMessage, signal, decodedHeader, receivedAt = this.options.receivedAtClock?.() ?? new Date()) {
274
277
  if (topicMessage.parts.length === 0 || topicMessage.parts[0].data().length === 0) {
275
278
  return;
276
279
  }
@@ -315,7 +318,8 @@ class ZLinkChannelPublishDispatcher {
315
318
  topic: publishTopic,
316
319
  source: publishSource,
317
320
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
318
- correlationId: publishCorr
321
+ correlationId: publishCorr,
322
+ receivedAt
319
323
  };
320
324
  await this.pipeline.dispatchOneWay({
321
325
  fields,
@@ -346,10 +350,12 @@ class ZLinkRoutePacketDispatcher {
346
350
  sendHandlers = new Map();
347
351
  requestHandlers = new Map();
348
352
  codecs;
353
+ receivedAtClock;
349
354
  pipeline;
350
355
  constructor(options) {
351
356
  this.routerChannelId = options.routerChannelId;
352
357
  this.codecs = options.codecs;
358
+ this.receivedAtClock = options.receivedAtClock ?? (() => new Date());
353
359
  this.dispatchErrors = options.dispatchErrors;
354
360
  this.pipeline = new channel_dispatch_pipeline_1.ZLinkChannelDispatchPipeline({
355
361
  dispatchErrors: options.dispatchErrors,
@@ -389,7 +395,7 @@ class ZLinkRoutePacketDispatcher {
389
395
  }
390
396
  return false;
391
397
  }
392
- async dispatch(received, router, signal, decodedHeader, infrastructureChecked = false) {
398
+ async dispatch(received, router, signal, decodedHeader, infrastructureChecked = false, receivedAt = this.receivedAtClock()) {
393
399
  const channelHeader = decodedHeader ?? (0, channel_envelope_inspection_1.tryDecodeChannelHeader)(received.parts, this.flowEnabled());
394
400
  if (!infrastructureChecked) {
395
401
  const infrastructure = this.dispatchInfrastructure(received);
@@ -442,7 +448,7 @@ class ZLinkRoutePacketDispatcher {
442
448
  codecs: (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs),
443
449
  handler: handler?.handler,
444
450
  messageType: handler?.messageType,
445
- context: this.createRouteContext(envelope, received.routingId),
451
+ context: this.createRouteContext(envelope, received.routingId, receivedAt),
446
452
  signal
447
453
  });
448
454
  return;
@@ -478,7 +484,7 @@ class ZLinkRoutePacketDispatcher {
478
484
  codecs,
479
485
  handler: handler?.handler,
480
486
  messageType: handler?.messageType,
481
- context: this.createRouteContext(envelope, received.routingId),
487
+ context: this.createRouteContext(envelope, received.routingId, receivedAt),
482
488
  signal,
483
489
  missingHandlerMessage: `No routed request handler is registered for '${this.routerChannelId}:${packetName}'.`,
484
490
  writeReply: (reply) => this.submitReply((0, channel_multipart_1.appendParts)(router.reply(received.routingId, replyToken), (0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, reply, codecs))),
@@ -512,7 +518,7 @@ class ZLinkRoutePacketDispatcher {
512
518
  const sourceNodeRid = String(record.sourceNodeRid ?? '');
513
519
  const correlationId = envelope.header.correlationId ?? undefined;
514
520
  if (envelope.header.kind === 3 /* ZLinkChannelMessageKind.Command */) {
515
- return this.dispatchMeshCommand(envelope, packetName, sourceNodeRid, record.sourceNodeRid, signal, admit);
521
+ return this.dispatchMeshCommand(envelope, packetName, sourceNodeRid, record.sourceNodeRid, signal, admit, record.receivedAt ?? this.receivedAtClock());
516
522
  }
517
523
  if (envelope.header.kind !== 1 /* ZLinkChannelMessageKind.Request */) {
518
524
  return completedChannelReply;
@@ -525,9 +531,10 @@ class ZLinkRoutePacketDispatcher {
525
531
  flowId: envelope.header.flowId,
526
532
  flowOrigin: envelope.header.flowOrigin
527
533
  };
528
- return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs), this.requestHandlers.get(packetName), this.createRouteContext(envelope, record.sourceNodeRid), signal, record, 'routed', this.routerChannelId), admit);
534
+ return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs), this.requestHandlers.get(packetName), this.createRouteContext(envelope, record.sourceNodeRid, record.receivedAt), signal, record, 'routed', this.routerChannelId), admit);
529
535
  }
530
536
  async dispatchLocalCommand(parts, sourceNodeRid, signal) {
537
+ const receivedAt = this.receivedAtClock();
531
538
  if (parts.length === 0 || parts[0].data().length === 0)
532
539
  return;
533
540
  let envelope;
@@ -551,9 +558,9 @@ class ZLinkRoutePacketDispatcher {
551
558
  if (packetName === undefined) {
552
559
  throw new configuration_1.ZLinkConfigurationException('Route packet is missing packetName.');
553
560
  }
554
- await this.dispatchMeshCommand(envelope, packetName, String(sourceNodeRid), sourceNodeRid, signal);
561
+ await this.dispatchMeshCommand(envelope, packetName, String(sourceNodeRid), sourceNodeRid, signal, undefined, receivedAt);
555
562
  }
556
- dispatchMeshCommand(envelope, packetName, sourceRid, sourceNodeRid, signal, admit) {
563
+ dispatchMeshCommand(envelope, packetName, sourceRid, sourceNodeRid, signal, admit, receivedAt = this.receivedAtClock()) {
557
564
  const handler = this.sendHandlers.get(packetName);
558
565
  return this.pipeline.dispatchOneWay({
559
566
  fields: {
@@ -568,7 +575,7 @@ class ZLinkRoutePacketDispatcher {
568
575
  codecs: (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs),
569
576
  handler: handler?.handler,
570
577
  messageType: handler?.messageType,
571
- context: this.createRouteContext(envelope, sourceNodeRid),
578
+ context: this.createRouteContext(envelope, sourceNodeRid, receivedAt),
572
579
  signal
573
580
  }, admit);
574
581
  }
@@ -578,7 +585,7 @@ class ZLinkRoutePacketDispatcher {
578
585
  }
579
586
  return completedChannelReply;
580
587
  }
581
- createRouteContext(envelope, sourceRid) {
588
+ createRouteContext(envelope, sourceRid, receivedAt = this.receivedAtClock()) {
582
589
  const sourceNodeRid = String(sourceRid ?? '');
583
590
  return {
584
591
  meshName: this.routerChannelId,
@@ -586,7 +593,8 @@ class ZLinkRoutePacketDispatcher {
586
593
  contentType: envelope.header.contentType,
587
594
  sourceNodeRid,
588
595
  metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
589
- correlationId: envelope.header.correlationId ?? undefined
596
+ correlationId: envelope.header.correlationId ?? undefined,
597
+ receivedAt
590
598
  };
591
599
  }
592
600
  }