@cadenza.io/service 2.17.77 → 2.17.78

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.
@@ -813,6 +813,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
813
813
  }
814
814
  return result;
815
815
  }
816
+ function shouldTraceIotDbRegistryPath(localServiceName, targetServiceName) {
817
+ return targetServiceName === "IotDbService" && localServiceName !== "IotDbService";
818
+ }
819
+ function summarizeTransportDescriptors(transports) {
820
+ return transports.map((transport) => ({
821
+ uuid: transport.uuid,
822
+ serviceInstanceId: transport.serviceInstanceId,
823
+ role: transport.role,
824
+ origin: transport.origin,
825
+ protocols: transport.protocols
826
+ }));
827
+ }
816
828
  function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
817
829
  const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
818
830
  tableName,
@@ -1203,6 +1215,21 @@ var ServiceRegistry = class _ServiceRegistry {
1203
1215
  trackedInstance.acceptingWork = snapshot.acceptingWork;
1204
1216
  trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
1205
1217
  }
1218
+ if (shouldTraceIotDbRegistryPath(this.serviceName, serviceName)) {
1219
+ console.log("[CADENZA_REGISTRY_DEBUG] handle_instance_update", {
1220
+ localServiceName: this.serviceName,
1221
+ localServiceInstanceId: this.serviceInstanceId,
1222
+ targetServiceName: serviceName,
1223
+ targetServiceInstanceId: uuid7,
1224
+ existingInstance: !!existing,
1225
+ deleted,
1226
+ remoteInterest: this.deputies.has(serviceName) || this.remoteIntents.has(serviceName) || this.remoteSignals.has(serviceName),
1227
+ hasDeputies: this.deputies.has(serviceName),
1228
+ hasRemoteIntents: this.remoteIntents.has(serviceName),
1229
+ hasRemoteSignals: this.remoteSignals.has(serviceName),
1230
+ transports: trackedInstance ? summarizeTransportDescriptors(trackedInstance.transports) : []
1231
+ });
1232
+ }
1206
1233
  if (!serviceInstance.isBootstrapPlaceholder) {
1207
1234
  this.reconcileBootstrapPlaceholderInstance(serviceName, uuid7, emit);
1208
1235
  }
@@ -1258,6 +1285,27 @@ var ServiceRegistry = class _ServiceRegistry {
1258
1285
  break;
1259
1286
  }
1260
1287
  }
1288
+ if (shouldTraceIotDbRegistryPath(
1289
+ this.serviceName,
1290
+ ownerInstance?.serviceName ?? ctx.serviceName ?? void 0
1291
+ )) {
1292
+ console.log("[CADENZA_REGISTRY_DEBUG] handle_transport_update", {
1293
+ localServiceName: this.serviceName,
1294
+ localServiceInstanceId: this.serviceInstanceId,
1295
+ transport: {
1296
+ uuid: transport.uuid,
1297
+ serviceInstanceId: transport.serviceInstanceId,
1298
+ role: transport.role,
1299
+ origin: transport.origin,
1300
+ protocols: transport.protocols,
1301
+ deleted: transport.deleted
1302
+ },
1303
+ ownerFound: !!ownerInstance,
1304
+ ownerServiceName: ownerInstance?.serviceName,
1305
+ ownerInstanceId: ownerInstance?.uuid,
1306
+ ownerTransports: ownerInstance ? summarizeTransportDescriptors(ownerInstance.transports) : []
1307
+ });
1308
+ }
1261
1309
  if (!ownerInstance) {
1262
1310
  return false;
1263
1311
  }
@@ -1672,6 +1720,44 @@ var ServiceRegistry = class _ServiceRegistry {
1672
1720
  let retries = __retries ?? 0;
1673
1721
  let triedInstances = __triedInstances ?? [];
1674
1722
  const preferredRole = this.getRoutingTransportRole();
1723
+ const allInstances = this.instances.get(__serviceName) ?? [];
1724
+ const candidateDiagnostics = shouldTraceIotDbRegistryPath(
1725
+ this.serviceName,
1726
+ __serviceName ?? void 0
1727
+ ) ? allInstances.map((instance) => ({
1728
+ uuid: instance.uuid,
1729
+ isActive: instance.isActive,
1730
+ isNonResponsive: instance.isNonResponsive,
1731
+ isBlocked: instance.isBlocked,
1732
+ isFrontend: instance.isFrontend,
1733
+ transports: summarizeTransportDescriptors(instance.transports),
1734
+ selectedTransport: instance.isFrontend ? null : this.selectTransportForInstance(
1735
+ instance,
1736
+ context,
1737
+ preferredRole
1738
+ ) ? {
1739
+ uuid: this.selectTransportForInstance(
1740
+ instance,
1741
+ context,
1742
+ preferredRole
1743
+ ).uuid,
1744
+ role: this.selectTransportForInstance(
1745
+ instance,
1746
+ context,
1747
+ preferredRole
1748
+ ).role,
1749
+ origin: this.selectTransportForInstance(
1750
+ instance,
1751
+ context,
1752
+ preferredRole
1753
+ ).origin,
1754
+ protocols: this.selectTransportForInstance(
1755
+ instance,
1756
+ context,
1757
+ preferredRole
1758
+ ).protocols
1759
+ } : null
1760
+ })) : void 0;
1675
1761
  const instances = this.instances.get(__serviceName)?.filter((instance) => {
1676
1762
  if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
1677
1763
  return false;
@@ -1704,6 +1790,20 @@ var ServiceRegistry = class _ServiceRegistry {
1704
1790
  }
1705
1791
  return (a.numberOfRunningGraphs ?? 0) - (b.numberOfRunningGraphs ?? 0);
1706
1792
  });
1793
+ if (candidateDiagnostics) {
1794
+ console.log("[CADENZA_REGISTRY_DEBUG] get_balanced_instance", {
1795
+ localServiceName: this.serviceName,
1796
+ localServiceInstanceId: this.serviceInstanceId,
1797
+ targetServiceName: __serviceName,
1798
+ preferredRole,
1799
+ useSocket: this.useSocket,
1800
+ targetServiceInstanceId,
1801
+ retries,
1802
+ triedInstances,
1803
+ candidateDiagnostics,
1804
+ filteredInstanceIds: instances?.map((instance) => instance.uuid) ?? []
1805
+ });
1806
+ }
1707
1807
  if (!instances || instances.length === 0 || retries > this.retryCount) {
1708
1808
  context.errored = true;
1709
1809
  context.__error = this.isFrontend && preferredRole === "public" ? `No public transport available for ${__serviceName}.` : `No routeable ${preferredRole} transport available for ${__serviceName}. Retries: ${retries}.`;
@@ -2830,6 +2930,27 @@ var ServiceRegistry = class _ServiceRegistry {
2830
2930
  instance,
2831
2931
  this.useSocket ? "socket" : "rest"
2832
2932
  );
2933
+ if (shouldTraceIotDbRegistryPath(this.serviceName, instance.serviceName)) {
2934
+ console.log("[CADENZA_REGISTRY_DEBUG] ensure_dependee_client_for_instance", {
2935
+ localServiceName: this.serviceName,
2936
+ localServiceInstanceId: this.serviceInstanceId,
2937
+ targetServiceName: instance.serviceName,
2938
+ targetServiceInstanceId: instance.uuid,
2939
+ useSocket: this.useSocket,
2940
+ routeableRole: this.getRoutingTransportRole(),
2941
+ hasDeputies: this.deputies.has(instance.serviceName),
2942
+ hasRemoteIntents: this.remoteIntents.has(instance.serviceName),
2943
+ hasRemoteSignals: this.remoteSignals.has(instance.serviceName),
2944
+ clientCreatedTransportIds: instance.clientCreatedTransportIds ?? [],
2945
+ transports: summarizeTransportDescriptors(instance.transports),
2946
+ selectedTransport: transport ? {
2947
+ uuid: transport.uuid,
2948
+ role: transport.role,
2949
+ origin: transport.origin,
2950
+ protocols: transport.protocols
2951
+ } : null
2952
+ });
2953
+ }
2833
2954
  if (!transport || this.hasTransportClientCreated(instance, transport.uuid)) {
2834
2955
  return false;
2835
2956
  }