@cadenza.io/service 2.21.0 → 2.21.2
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.
- package/dist/{Cadenza-Cq1mscQf.d.mts → Cadenza-CRVK2HUv.d.mts} +46 -1
- package/dist/{Cadenza-Cq1mscQf.d.ts → Cadenza-CRVK2HUv.d.ts} +46 -1
- package/dist/browser/index.js +1369 -482
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1368 -479
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +1480 -568
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1476 -568
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt/index.d.mts +2 -2
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/vue/index.d.mts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -46,8 +46,10 @@ __export(src_exports, {
|
|
|
46
46
|
DeputyTask: () => DeputyTask,
|
|
47
47
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL: () => EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
48
48
|
EphemeralTask: () => import_core7.EphemeralTask,
|
|
49
|
+
GlobalDefinition: () => import_core7.GlobalDefinition,
|
|
49
50
|
GraphMetadataController: () => GraphMetadataController,
|
|
50
51
|
GraphRoutine: () => import_core7.GraphRoutine,
|
|
52
|
+
HelperDefinition: () => import_core7.HelperDefinition,
|
|
51
53
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL: () => RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
52
54
|
RUNTIME_VALIDATION_INTENTS: () => RUNTIME_VALIDATION_INTENTS,
|
|
53
55
|
RUNTIME_VALIDATION_SIGNALS: () => RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -67,6 +69,10 @@ __export(src_exports, {
|
|
|
67
69
|
createCadenzaService: () => createCadenzaService,
|
|
68
70
|
createDatabaseService: () => createDatabaseService,
|
|
69
71
|
createExecutionPersistenceBundle: () => createExecutionPersistenceBundle,
|
|
72
|
+
createGlobal: () => createGlobal,
|
|
73
|
+
createHelper: () => createHelper,
|
|
74
|
+
createMetaGlobal: () => createMetaGlobal,
|
|
75
|
+
createMetaHelper: () => createMetaHelper,
|
|
70
76
|
createMetaTask: () => createMetaTask,
|
|
71
77
|
createSSRInquiryBridge: () => createSSRInquiryBridge,
|
|
72
78
|
createTask: () => createTask,
|
|
@@ -288,6 +294,16 @@ var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
|
288
294
|
"transportProtocols",
|
|
289
295
|
"transportProtocol"
|
|
290
296
|
];
|
|
297
|
+
var ACTOR_SESSION_STATE_REMOTE_ROUTINE = "Insert actor_session_state";
|
|
298
|
+
var ACTOR_SESSION_SNAPSHOT_ROOT_KEYS = [
|
|
299
|
+
"__remoteRoutineName",
|
|
300
|
+
"__serviceName",
|
|
301
|
+
"__localTaskName",
|
|
302
|
+
"__localTaskVersion",
|
|
303
|
+
"__localServiceName",
|
|
304
|
+
"__timeout",
|
|
305
|
+
...ROOT_METADATA_PASSTHROUGH_KEYS
|
|
306
|
+
];
|
|
291
307
|
function isPlainObject(value) {
|
|
292
308
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
293
309
|
return false;
|
|
@@ -312,6 +328,9 @@ function cloneDelegationValue(value) {
|
|
|
312
328
|
return value;
|
|
313
329
|
}
|
|
314
330
|
function buildDelegationRequestSnapshot(context) {
|
|
331
|
+
if (typeof context.__remoteRoutineName === "string" && context.__remoteRoutineName.trim() === ACTOR_SESSION_STATE_REMOTE_ROUTINE) {
|
|
332
|
+
return buildActorSessionDelegationSnapshot(context);
|
|
333
|
+
}
|
|
315
334
|
const snapshot = {};
|
|
316
335
|
for (const [key, value] of Object.entries(context)) {
|
|
317
336
|
if (key === DELEGATION_REQUEST_SNAPSHOT_KEY || key === "task" || key === "routine") {
|
|
@@ -321,6 +340,21 @@ function buildDelegationRequestSnapshot(context) {
|
|
|
321
340
|
}
|
|
322
341
|
return snapshot;
|
|
323
342
|
}
|
|
343
|
+
function buildActorSessionDelegationSnapshot(context) {
|
|
344
|
+
const snapshot = {};
|
|
345
|
+
for (const key of ACTOR_SESSION_SNAPSHOT_ROOT_KEYS) {
|
|
346
|
+
if (context[key] !== void 0) {
|
|
347
|
+
snapshot[key] = cloneDelegationValue(context[key]);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (context.data !== void 0) {
|
|
351
|
+
snapshot.data = cloneDelegationValue(context.data);
|
|
352
|
+
}
|
|
353
|
+
if (context.queryData !== void 0) {
|
|
354
|
+
snapshot.queryData = cloneDelegationValue(context.queryData);
|
|
355
|
+
}
|
|
356
|
+
return snapshot;
|
|
357
|
+
}
|
|
324
358
|
function hoistDelegationMetadataFields(input, metadataInput) {
|
|
325
359
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
326
360
|
const mutableContext = context;
|
|
@@ -429,6 +463,12 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
429
463
|
return;
|
|
430
464
|
}
|
|
431
465
|
const processId = (0, import_uuid2.v4)();
|
|
466
|
+
const resolvedTimeoutMs = Math.max(
|
|
467
|
+
1e3,
|
|
468
|
+
Number(context.__timeout ?? task.timeout ?? 0) || 6e4
|
|
469
|
+
);
|
|
470
|
+
let settled = false;
|
|
471
|
+
let timeoutHandle = null;
|
|
432
472
|
context.__metadata.__deputyExecId = processId;
|
|
433
473
|
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
434
474
|
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
@@ -445,7 +485,37 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
445
485
|
emit2("meta.deputy.delegation_requested", {
|
|
446
486
|
...context
|
|
447
487
|
});
|
|
448
|
-
|
|
488
|
+
let progressTask = null;
|
|
489
|
+
let resolveTask = null;
|
|
490
|
+
const cleanup = () => {
|
|
491
|
+
if (timeoutHandle) {
|
|
492
|
+
clearTimeout(timeoutHandle);
|
|
493
|
+
timeoutHandle = null;
|
|
494
|
+
}
|
|
495
|
+
if (progressTask && !progressTask.destroyed) {
|
|
496
|
+
progressTask.destroy();
|
|
497
|
+
}
|
|
498
|
+
if (resolveTask && !resolveTask.destroyed) {
|
|
499
|
+
resolveTask.destroy();
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
const settleSuccess = (value) => {
|
|
503
|
+
if (settled) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
settled = true;
|
|
507
|
+
cleanup();
|
|
508
|
+
resolve(value);
|
|
509
|
+
};
|
|
510
|
+
const settleFailure = (error) => {
|
|
511
|
+
if (settled) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
settled = true;
|
|
515
|
+
cleanup();
|
|
516
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
517
|
+
};
|
|
518
|
+
progressTask = CadenzaService.createEphemeralMetaTask(
|
|
449
519
|
`On progress deputy ${task.remoteRoutineName}`,
|
|
450
520
|
(ctx) => {
|
|
451
521
|
if (typeof progressCallback === "function" && ctx.progress) {
|
|
@@ -464,7 +534,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
464
534
|
`meta.fetch.delegated:${processId}`,
|
|
465
535
|
`meta.service_registry.load_balance_failed:${processId}`
|
|
466
536
|
);
|
|
467
|
-
CadenzaService.createEphemeralMetaTask(
|
|
537
|
+
resolveTask = CadenzaService.createEphemeralMetaTask(
|
|
468
538
|
`Resolve deputy ${task.remoteRoutineName}`,
|
|
469
539
|
(responseCtx) => {
|
|
470
540
|
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
@@ -472,7 +542,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
472
542
|
...responseCtx
|
|
473
543
|
} : responseCtx;
|
|
474
544
|
if (responseCtx?.errored) {
|
|
475
|
-
|
|
545
|
+
settleFailure(new Error(responseCtx.__error));
|
|
476
546
|
} else {
|
|
477
547
|
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
478
548
|
console.log(
|
|
@@ -489,7 +559,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
489
559
|
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
490
560
|
delete mergedResponseCtx.__isDeputy;
|
|
491
561
|
}
|
|
492
|
-
|
|
562
|
+
settleSuccess(mergedResponseCtx);
|
|
493
563
|
}
|
|
494
564
|
},
|
|
495
565
|
`Ephemeral resolver for deputy process ${processId}`,
|
|
@@ -499,6 +569,14 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
499
569
|
`meta.fetch.delegated:${processId}`,
|
|
500
570
|
`meta.service_registry.load_balance_failed:${processId}`
|
|
501
571
|
);
|
|
572
|
+
timeoutHandle = setTimeout(() => {
|
|
573
|
+
settleFailure(
|
|
574
|
+
new Error(
|
|
575
|
+
`Deputy task '${task.name}' timed out waiting for remote resolution after ${resolvedTimeoutMs}ms.`
|
|
576
|
+
)
|
|
577
|
+
);
|
|
578
|
+
}, resolvedTimeoutMs);
|
|
579
|
+
timeoutHandle.unref?.();
|
|
502
580
|
});
|
|
503
581
|
}
|
|
504
582
|
var DeputyTask = class extends import_core.Task {
|
|
@@ -644,6 +722,21 @@ var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
|
644
722
|
"Insert task_execution",
|
|
645
723
|
"Insert inquiry"
|
|
646
724
|
]);
|
|
725
|
+
var ROOT_DB_OPERATION_CONTEXT_KEYS = [
|
|
726
|
+
"data",
|
|
727
|
+
"batch",
|
|
728
|
+
"transaction",
|
|
729
|
+
"onConflict",
|
|
730
|
+
"filter",
|
|
731
|
+
"fields",
|
|
732
|
+
"joins",
|
|
733
|
+
"sort",
|
|
734
|
+
"limit",
|
|
735
|
+
"offset",
|
|
736
|
+
"queryMode",
|
|
737
|
+
"aggregates",
|
|
738
|
+
"groupBy"
|
|
739
|
+
];
|
|
647
740
|
var DatabaseTask = class extends DeputyTask {
|
|
648
741
|
/**
|
|
649
742
|
* Constructs an instance of the class with the provided parameters, defining
|
|
@@ -752,6 +845,27 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
752
845
|
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
753
846
|
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
754
847
|
}
|
|
848
|
+
const shouldCompactAuthorityBootstrapContext = this.serviceName === "CadenzaDB" && (ctx.__authorityBootstrapChannel === true || metadata.__authorityBootstrapChannel === true || ctx.__metadata?.__authorityBootstrapChannel === true);
|
|
849
|
+
const rootDbOperationContext = shouldCompactAuthorityBootstrapContext ? {} : {
|
|
850
|
+
data: nextQueryData.data ?? ctx.data,
|
|
851
|
+
batch: nextQueryData.batch ?? ctx.batch,
|
|
852
|
+
transaction: nextQueryData.transaction ?? ctx.transaction,
|
|
853
|
+
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
854
|
+
filter: nextQueryData.filter ?? ctx.filter,
|
|
855
|
+
fields: nextQueryData.fields ?? ctx.fields,
|
|
856
|
+
joins: nextQueryData.joins ?? ctx.joins,
|
|
857
|
+
sort: nextQueryData.sort ?? ctx.sort,
|
|
858
|
+
limit: nextQueryData.limit ?? ctx.limit,
|
|
859
|
+
offset: nextQueryData.offset ?? ctx.offset,
|
|
860
|
+
queryMode: nextQueryData.queryMode ?? ctx.queryMode,
|
|
861
|
+
aggregates: nextQueryData.aggregates ?? ctx.aggregates,
|
|
862
|
+
groupBy: nextQueryData.groupBy ?? ctx.groupBy
|
|
863
|
+
};
|
|
864
|
+
if (shouldCompactAuthorityBootstrapContext) {
|
|
865
|
+
for (const key of ROOT_DB_OPERATION_CONTEXT_KEYS) {
|
|
866
|
+
delete ctx[key];
|
|
867
|
+
}
|
|
868
|
+
}
|
|
755
869
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
756
870
|
stripDelegationRequestSnapshot(
|
|
757
871
|
hoistDelegationMetadataFields({
|
|
@@ -771,12 +885,7 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
771
885
|
__blockRemoteExecution: metadata.__blockRemoteExecution ?? ctx.__blockRemoteExecution ?? false,
|
|
772
886
|
__deputyTaskName: this.name
|
|
773
887
|
},
|
|
774
|
-
|
|
775
|
-
batch: nextQueryData.batch ?? ctx.batch,
|
|
776
|
-
transaction: nextQueryData.transaction ?? ctx.transaction,
|
|
777
|
-
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
778
|
-
filter: nextQueryData.filter ?? ctx.filter,
|
|
779
|
-
fields: nextQueryData.fields ?? ctx.fields,
|
|
888
|
+
...rootDbOperationContext,
|
|
780
889
|
queryData: nextQueryData
|
|
781
890
|
})
|
|
782
891
|
)
|
|
@@ -874,6 +983,76 @@ var SCHEMA_TYPES = [
|
|
|
874
983
|
// src/database/DatabaseController.ts
|
|
875
984
|
var import_pg = require("pg");
|
|
876
985
|
var import_lodash_es = require("lodash-es");
|
|
986
|
+
|
|
987
|
+
// src/utils/inquiry.ts
|
|
988
|
+
var META_INTENT_PREFIX = "meta-";
|
|
989
|
+
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
990
|
+
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
991
|
+
var META_READINESS_INTENT = "meta-readiness";
|
|
992
|
+
function isPlainObject2(value) {
|
|
993
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
994
|
+
}
|
|
995
|
+
function deepMergeDeterministic(left, right) {
|
|
996
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
997
|
+
return [...left, ...right];
|
|
998
|
+
}
|
|
999
|
+
if (isPlainObject2(left) && isPlainObject2(right)) {
|
|
1000
|
+
const merged = { ...left };
|
|
1001
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
1002
|
+
for (const key of keys) {
|
|
1003
|
+
if (!(key in left)) {
|
|
1004
|
+
merged[key] = right[key];
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
if (!(key in right)) {
|
|
1008
|
+
merged[key] = left[key];
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
merged[key] = deepMergeDeterministic(left[key], right[key]);
|
|
1012
|
+
}
|
|
1013
|
+
return merged;
|
|
1014
|
+
}
|
|
1015
|
+
return right;
|
|
1016
|
+
}
|
|
1017
|
+
function mergeInquiryContexts(contexts) {
|
|
1018
|
+
return contexts.reduce((acc, next) => deepMergeDeterministic(acc, next), {});
|
|
1019
|
+
}
|
|
1020
|
+
function isMetaIntentName(intentName) {
|
|
1021
|
+
return intentName.startsWith(META_INTENT_PREFIX);
|
|
1022
|
+
}
|
|
1023
|
+
function shouldExecuteInquiryResponder(inquiry, responderIsMeta) {
|
|
1024
|
+
if (!isMetaIntentName(inquiry)) {
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
return responderIsMeta;
|
|
1028
|
+
}
|
|
1029
|
+
function compareResponderDescriptors(left, right) {
|
|
1030
|
+
if (left.serviceName !== right.serviceName) {
|
|
1031
|
+
return left.serviceName.localeCompare(right.serviceName);
|
|
1032
|
+
}
|
|
1033
|
+
if (left.taskName !== right.taskName) {
|
|
1034
|
+
return left.taskName.localeCompare(right.taskName);
|
|
1035
|
+
}
|
|
1036
|
+
if (left.taskVersion !== right.taskVersion) {
|
|
1037
|
+
return left.taskVersion - right.taskVersion;
|
|
1038
|
+
}
|
|
1039
|
+
return left.localTaskName.localeCompare(right.localTaskName);
|
|
1040
|
+
}
|
|
1041
|
+
function summarizeResponderStatuses(statuses) {
|
|
1042
|
+
let responded = 0;
|
|
1043
|
+
let failed = 0;
|
|
1044
|
+
let timedOut = 0;
|
|
1045
|
+
let pending = 0;
|
|
1046
|
+
for (const status of statuses) {
|
|
1047
|
+
if (status.status === "fulfilled") responded++;
|
|
1048
|
+
if (status.status === "failed") failed++;
|
|
1049
|
+
if (status.status === "timed_out") timedOut++;
|
|
1050
|
+
}
|
|
1051
|
+
pending = Math.max(0, statuses.length - responded - failed - timedOut);
|
|
1052
|
+
return { responded, failed, timedOut, pending };
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// src/database/DatabaseController.ts
|
|
877
1056
|
var AUTHORITY_SYNC_DEBUG_PREFIX = "[CADENZA_DB_TASK_DEBUG]";
|
|
878
1057
|
var AUTHORITY_SYNC_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env === "object" && process.env.CADENZA_DB_TASK_DEBUG === "true";
|
|
879
1058
|
var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -914,7 +1093,7 @@ var POSTGRES_SETUP_DEBUG_ENABLED = process.env.CADENZA_POSTGRES_SETUP_DEBUG ===
|
|
|
914
1093
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
915
1094
|
var ACTOR_SESSION_TRACE_LIMIT = 20;
|
|
916
1095
|
var actorSessionTraceCount = 0;
|
|
917
|
-
var GENERATED_POSTGRES_WRITE_TASK_CONCURRENCY =
|
|
1096
|
+
var GENERATED_POSTGRES_WRITE_TASK_CONCURRENCY = 1;
|
|
918
1097
|
var GENERATED_POSTGRES_WRITE_TASK_TIMEOUT_MS = 12e4;
|
|
919
1098
|
var EXECUTION_OBSERVABILITY_TABLES = /* @__PURE__ */ new Set([
|
|
920
1099
|
"execution_trace",
|
|
@@ -1017,6 +1196,9 @@ function normalizeIntentToken(value) {
|
|
|
1017
1196
|
}
|
|
1018
1197
|
return normalized;
|
|
1019
1198
|
}
|
|
1199
|
+
function prefixMetaIntentName(intentName, isMeta) {
|
|
1200
|
+
return isMeta ? `${META_INTENT_PREFIX}${intentName}` : intentName;
|
|
1201
|
+
}
|
|
1020
1202
|
function shouldValidateGeneratedDbTaskInput(registration) {
|
|
1021
1203
|
return registration.options.securityProfile !== "low" && !registration.options.isMeta;
|
|
1022
1204
|
}
|
|
@@ -1144,9 +1326,9 @@ function readCustomIntentConfig(customIntent) {
|
|
|
1144
1326
|
input: customIntent.input
|
|
1145
1327
|
};
|
|
1146
1328
|
}
|
|
1147
|
-
function resolveTableOperationIntents(actorName, tableName, table, operation, defaultInputSchema) {
|
|
1329
|
+
function resolveTableOperationIntents(actorName, tableName, table, operation, defaultInputSchema, options) {
|
|
1148
1330
|
const actorToken = normalizeIntentToken(actorName);
|
|
1149
|
-
const defaultIntentName = `${operation}-pg-${actorToken}-${tableName}`;
|
|
1331
|
+
const defaultIntentName = `${options?.isMeta ? META_INTENT_PREFIX : ""}${operation}-pg-${actorToken}-${tableName}`;
|
|
1150
1332
|
validateIntentName(defaultIntentName);
|
|
1151
1333
|
const intents = [
|
|
1152
1334
|
{
|
|
@@ -1165,6 +1347,11 @@ function resolveTableOperationIntents(actorName, tableName, table, operation, de
|
|
|
1165
1347
|
`Invalid custom ${operation} intent on table '${tableName}': intent must be a non-empty string`
|
|
1166
1348
|
);
|
|
1167
1349
|
}
|
|
1350
|
+
if (options?.isMeta && !intentName.startsWith(META_INTENT_PREFIX)) {
|
|
1351
|
+
throw new Error(
|
|
1352
|
+
`Invalid custom ${operation} intent '${intentName}' on table '${tableName}': meta PostgresActor intents must start with '${META_INTENT_PREFIX}'`
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1168
1355
|
validateIntentName(intentName);
|
|
1169
1356
|
if (seenNames.has(intentName)) {
|
|
1170
1357
|
throw new Error(
|
|
@@ -1207,14 +1394,14 @@ function errorMessage(error) {
|
|
|
1207
1394
|
}
|
|
1208
1395
|
return String(error);
|
|
1209
1396
|
}
|
|
1210
|
-
function
|
|
1397
|
+
function isPlainObject3(value) {
|
|
1211
1398
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1212
1399
|
}
|
|
1213
1400
|
function stableStringify(value) {
|
|
1214
1401
|
if (Array.isArray(value)) {
|
|
1215
1402
|
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
1216
1403
|
}
|
|
1217
|
-
if (
|
|
1404
|
+
if (isPlainObject3(value)) {
|
|
1218
1405
|
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
1219
1406
|
}
|
|
1220
1407
|
return JSON.stringify(value);
|
|
@@ -3165,7 +3352,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3165
3352
|
"aggregate"
|
|
3166
3353
|
];
|
|
3167
3354
|
for (const macroOperation of queryMacroOperations) {
|
|
3168
|
-
const intentName =
|
|
3355
|
+
const intentName = prefixMetaIntentName(
|
|
3356
|
+
`${macroOperation}-pg-${registration.actorToken}-${tableName}`,
|
|
3357
|
+
registration.options.isMeta
|
|
3358
|
+
);
|
|
3169
3359
|
if (registration.intentNames.has(intentName)) {
|
|
3170
3360
|
throw new Error(
|
|
3171
3361
|
`Duplicate macro intent '${intentName}' detected for table '${tableName}' in actor '${registration.actorName}'`
|
|
@@ -3203,7 +3393,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3203
3393
|
}
|
|
3204
3394
|
).respondsTo(intentName);
|
|
3205
3395
|
}
|
|
3206
|
-
const upsertIntentName =
|
|
3396
|
+
const upsertIntentName = prefixMetaIntentName(
|
|
3397
|
+
`upsert-pg-${registration.actorToken}-${tableName}`,
|
|
3398
|
+
registration.options.isMeta
|
|
3399
|
+
);
|
|
3207
3400
|
if (registration.intentNames.has(upsertIntentName)) {
|
|
3208
3401
|
throw new Error(
|
|
3209
3402
|
`Duplicate macro intent '${upsertIntentName}' detected for table '${tableName}' in actor '${registration.actorName}'`
|
|
@@ -3473,7 +3666,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3473
3666
|
tableName,
|
|
3474
3667
|
table,
|
|
3475
3668
|
op,
|
|
3476
|
-
schema
|
|
3669
|
+
schema,
|
|
3670
|
+
{
|
|
3671
|
+
isMeta: Boolean(registration.options.isMeta)
|
|
3672
|
+
}
|
|
3477
3673
|
);
|
|
3478
3674
|
for (const intent of intents) {
|
|
3479
3675
|
if (!registration.intentNames.has(intent.name)) {
|
|
@@ -4034,74 +4230,6 @@ function tableFieldTypeToSchemaType(type) {
|
|
|
4034
4230
|
var isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
4035
4231
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4036
4232
|
|
|
4037
|
-
// src/utils/inquiry.ts
|
|
4038
|
-
var META_INTENT_PREFIX = "meta-";
|
|
4039
|
-
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
4040
|
-
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
4041
|
-
var META_READINESS_INTENT = "meta-readiness";
|
|
4042
|
-
function isPlainObject3(value) {
|
|
4043
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
4044
|
-
}
|
|
4045
|
-
function deepMergeDeterministic(left, right) {
|
|
4046
|
-
if (Array.isArray(left) && Array.isArray(right)) {
|
|
4047
|
-
return [...left, ...right];
|
|
4048
|
-
}
|
|
4049
|
-
if (isPlainObject3(left) && isPlainObject3(right)) {
|
|
4050
|
-
const merged = { ...left };
|
|
4051
|
-
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
4052
|
-
for (const key of keys) {
|
|
4053
|
-
if (!(key in left)) {
|
|
4054
|
-
merged[key] = right[key];
|
|
4055
|
-
continue;
|
|
4056
|
-
}
|
|
4057
|
-
if (!(key in right)) {
|
|
4058
|
-
merged[key] = left[key];
|
|
4059
|
-
continue;
|
|
4060
|
-
}
|
|
4061
|
-
merged[key] = deepMergeDeterministic(left[key], right[key]);
|
|
4062
|
-
}
|
|
4063
|
-
return merged;
|
|
4064
|
-
}
|
|
4065
|
-
return right;
|
|
4066
|
-
}
|
|
4067
|
-
function mergeInquiryContexts(contexts) {
|
|
4068
|
-
return contexts.reduce((acc, next) => deepMergeDeterministic(acc, next), {});
|
|
4069
|
-
}
|
|
4070
|
-
function isMetaIntentName(intentName) {
|
|
4071
|
-
return intentName.startsWith(META_INTENT_PREFIX);
|
|
4072
|
-
}
|
|
4073
|
-
function shouldExecuteInquiryResponder(inquiry, responderIsMeta) {
|
|
4074
|
-
if (!isMetaIntentName(inquiry)) {
|
|
4075
|
-
return true;
|
|
4076
|
-
}
|
|
4077
|
-
return responderIsMeta;
|
|
4078
|
-
}
|
|
4079
|
-
function compareResponderDescriptors(left, right) {
|
|
4080
|
-
if (left.serviceName !== right.serviceName) {
|
|
4081
|
-
return left.serviceName.localeCompare(right.serviceName);
|
|
4082
|
-
}
|
|
4083
|
-
if (left.taskName !== right.taskName) {
|
|
4084
|
-
return left.taskName.localeCompare(right.taskName);
|
|
4085
|
-
}
|
|
4086
|
-
if (left.taskVersion !== right.taskVersion) {
|
|
4087
|
-
return left.taskVersion - right.taskVersion;
|
|
4088
|
-
}
|
|
4089
|
-
return left.localTaskName.localeCompare(right.localTaskName);
|
|
4090
|
-
}
|
|
4091
|
-
function summarizeResponderStatuses(statuses) {
|
|
4092
|
-
let responded = 0;
|
|
4093
|
-
let failed = 0;
|
|
4094
|
-
let timedOut = 0;
|
|
4095
|
-
let pending = 0;
|
|
4096
|
-
for (const status of statuses) {
|
|
4097
|
-
if (status.status === "fulfilled") responded++;
|
|
4098
|
-
if (status.status === "failed") failed++;
|
|
4099
|
-
if (status.status === "timed_out") timedOut++;
|
|
4100
|
-
}
|
|
4101
|
-
pending = Math.max(0, statuses.length - responded - failed - timedOut);
|
|
4102
|
-
return { responded, failed, timedOut, pending };
|
|
4103
|
-
}
|
|
4104
|
-
|
|
4105
4233
|
// src/utils/transport.ts
|
|
4106
4234
|
var DEFAULT_PROTOCOLS = ["rest", "socket"];
|
|
4107
4235
|
var TRANSPORT_HANDLE_ROUTE_KEY_BY_HANDLE = /* @__PURE__ */ new Map();
|
|
@@ -5076,24 +5204,181 @@ function getAuthorityBootstrapIntentSpec(intentName) {
|
|
|
5076
5204
|
if (!normalizedIntentName) {
|
|
5077
5205
|
return null;
|
|
5078
5206
|
}
|
|
5079
|
-
return AUTHORITY_BOOTSTRAP_INTENT_SPEC_BY_NAME.get(normalizedIntentName) ?? null;
|
|
5080
|
-
}
|
|
5081
|
-
function isAuthorityBootstrapIntent(intentName) {
|
|
5082
|
-
return getAuthorityBootstrapIntentSpec(intentName) !== null;
|
|
5083
|
-
}
|
|
5084
|
-
function isAuthorityBootstrapSignal(signalName) {
|
|
5085
|
-
return AUTHORITY_BOOTSTRAP_SIGNAL_NAME_SET.has(String(signalName ?? "").trim());
|
|
5207
|
+
return AUTHORITY_BOOTSTRAP_INTENT_SPEC_BY_NAME.get(normalizedIntentName) ?? null;
|
|
5208
|
+
}
|
|
5209
|
+
function isAuthorityBootstrapIntent(intentName) {
|
|
5210
|
+
return getAuthorityBootstrapIntentSpec(intentName) !== null;
|
|
5211
|
+
}
|
|
5212
|
+
function isAuthorityBootstrapSignal(signalName) {
|
|
5213
|
+
return AUTHORITY_BOOTSTRAP_SIGNAL_NAME_SET.has(String(signalName ?? "").trim());
|
|
5214
|
+
}
|
|
5215
|
+
function getAuthorityBootstrapInsertIntentSpecForTable(tableName) {
|
|
5216
|
+
const normalizedTableName = String(tableName ?? "").trim();
|
|
5217
|
+
if (!normalizedTableName) {
|
|
5218
|
+
return null;
|
|
5219
|
+
}
|
|
5220
|
+
const intentName = AUTHORITY_BOOTSTRAP_INSERT_INTENT_BY_TABLE.get(normalizedTableName);
|
|
5221
|
+
if (!intentName) {
|
|
5222
|
+
return null;
|
|
5223
|
+
}
|
|
5224
|
+
return getAuthorityBootstrapIntentSpec(intentName);
|
|
5225
|
+
}
|
|
5226
|
+
|
|
5227
|
+
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
5228
|
+
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
5229
|
+
function readString(value) {
|
|
5230
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
5231
|
+
}
|
|
5232
|
+
function readRecord(value) {
|
|
5233
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
5234
|
+
}
|
|
5235
|
+
function normalizeRoutineExecutionTraceFields(data) {
|
|
5236
|
+
if (!data) {
|
|
5237
|
+
return null;
|
|
5238
|
+
}
|
|
5239
|
+
const normalizedData = { ...data };
|
|
5240
|
+
const traceId = readString(
|
|
5241
|
+
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
5242
|
+
);
|
|
5243
|
+
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
5244
|
+
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
5245
|
+
const serviceName = readString(
|
|
5246
|
+
normalizedData.service_name ?? normalizedData.serviceName
|
|
5247
|
+
);
|
|
5248
|
+
const serviceInstanceId = readString(
|
|
5249
|
+
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
5250
|
+
);
|
|
5251
|
+
if (traceId) {
|
|
5252
|
+
normalizedData.execution_trace_id = traceId;
|
|
5253
|
+
}
|
|
5254
|
+
if (metaContext) {
|
|
5255
|
+
normalizedData.meta_context = metaContext;
|
|
5256
|
+
}
|
|
5257
|
+
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
5258
|
+
normalizedData.is_meta = isMeta;
|
|
5259
|
+
}
|
|
5260
|
+
if (serviceName) {
|
|
5261
|
+
normalizedData.service_name = serviceName;
|
|
5262
|
+
}
|
|
5263
|
+
if (serviceInstanceId) {
|
|
5264
|
+
normalizedData.service_instance_id = serviceInstanceId;
|
|
5265
|
+
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
5266
|
+
normalizedData.service_instance_id = null;
|
|
5267
|
+
}
|
|
5268
|
+
delete normalizedData.executionTraceId;
|
|
5269
|
+
delete normalizedData.traceId;
|
|
5270
|
+
delete normalizedData.metaContext;
|
|
5271
|
+
delete normalizedData.isMeta;
|
|
5272
|
+
delete normalizedData.serviceName;
|
|
5273
|
+
delete normalizedData.serviceInstanceId;
|
|
5274
|
+
return normalizedData;
|
|
5275
|
+
}
|
|
5276
|
+
function stripExecutionTraceServiceInstanceFields(data) {
|
|
5277
|
+
if (!data) {
|
|
5278
|
+
return null;
|
|
5279
|
+
}
|
|
5280
|
+
const normalizedData = { ...data };
|
|
5281
|
+
delete normalizedData.serviceInstanceId;
|
|
5282
|
+
delete normalizedData.service_instance_id;
|
|
5283
|
+
return normalizedData;
|
|
5284
|
+
}
|
|
5285
|
+
function normalizeEnsureData(entityType, data) {
|
|
5286
|
+
switch (entityType) {
|
|
5287
|
+
case "execution_trace":
|
|
5288
|
+
return stripExecutionTraceServiceInstanceFields(data);
|
|
5289
|
+
case "routine_execution":
|
|
5290
|
+
return normalizeRoutineExecutionTraceFields(data);
|
|
5291
|
+
default:
|
|
5292
|
+
return data;
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
5296
|
+
const normalizedEntityId = readString(entityId);
|
|
5297
|
+
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
5298
|
+
}
|
|
5299
|
+
function resolveEnsureEntityId(entityType, data) {
|
|
5300
|
+
switch (entityType) {
|
|
5301
|
+
default:
|
|
5302
|
+
return readString(data.uuid);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5305
|
+
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
5306
|
+
return readString(
|
|
5307
|
+
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
5308
|
+
);
|
|
5309
|
+
}
|
|
5310
|
+
function dedupeDependencies(values) {
|
|
5311
|
+
return Array.from(
|
|
5312
|
+
new Set(values.filter((value) => typeof value === "string"))
|
|
5313
|
+
);
|
|
5314
|
+
}
|
|
5315
|
+
function resolveTraceIdFromData(data) {
|
|
5316
|
+
if (!data) {
|
|
5317
|
+
return null;
|
|
5318
|
+
}
|
|
5319
|
+
return readString(
|
|
5320
|
+
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
5321
|
+
);
|
|
5322
|
+
}
|
|
5323
|
+
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
5324
|
+
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
5325
|
+
if (!normalizedData) {
|
|
5326
|
+
return null;
|
|
5327
|
+
}
|
|
5328
|
+
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
5329
|
+
if (!entityId) {
|
|
5330
|
+
return null;
|
|
5331
|
+
}
|
|
5332
|
+
return {
|
|
5333
|
+
kind: "ensure",
|
|
5334
|
+
entityType,
|
|
5335
|
+
entityId,
|
|
5336
|
+
data: normalizedData,
|
|
5337
|
+
deps: dedupeDependencies(deps)
|
|
5338
|
+
};
|
|
5339
|
+
}
|
|
5340
|
+
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
5341
|
+
const normalizedData = readRecord(data);
|
|
5342
|
+
const normalizedFilter = readRecord(filter);
|
|
5343
|
+
if (!normalizedData || !normalizedFilter) {
|
|
5344
|
+
return null;
|
|
5345
|
+
}
|
|
5346
|
+
const entityId = resolveUpdateEntityId(
|
|
5347
|
+
entityType,
|
|
5348
|
+
normalizedData,
|
|
5349
|
+
normalizedFilter
|
|
5350
|
+
);
|
|
5351
|
+
if (!entityId) {
|
|
5352
|
+
return null;
|
|
5353
|
+
}
|
|
5354
|
+
return {
|
|
5355
|
+
kind: "update",
|
|
5356
|
+
entityType,
|
|
5357
|
+
entityId,
|
|
5358
|
+
data: normalizedData,
|
|
5359
|
+
filter: normalizedFilter,
|
|
5360
|
+
deps: dedupeDependencies(deps)
|
|
5361
|
+
};
|
|
5086
5362
|
}
|
|
5087
|
-
function
|
|
5088
|
-
const
|
|
5089
|
-
|
|
5363
|
+
function createExecutionPersistenceBundle(input) {
|
|
5364
|
+
const ensures = (input.ensures ?? []).filter(
|
|
5365
|
+
(event) => Boolean(event)
|
|
5366
|
+
);
|
|
5367
|
+
const updates = (input.updates ?? []).filter(
|
|
5368
|
+
(event) => Boolean(event)
|
|
5369
|
+
);
|
|
5370
|
+
if (ensures.length === 0 && updates.length === 0) {
|
|
5090
5371
|
return null;
|
|
5091
5372
|
}
|
|
5092
|
-
const
|
|
5093
|
-
if (!
|
|
5373
|
+
const traceId = readString(input.traceId) ?? ensures.map((event) => resolveTraceIdFromData(event.data)).find((value) => Boolean(value)) ?? updates.map((event) => resolveTraceIdFromData(event.data)).find((value) => Boolean(value));
|
|
5374
|
+
if (!traceId) {
|
|
5094
5375
|
return null;
|
|
5095
5376
|
}
|
|
5096
|
-
return
|
|
5377
|
+
return {
|
|
5378
|
+
traceId,
|
|
5379
|
+
ensures,
|
|
5380
|
+
updates
|
|
5381
|
+
};
|
|
5097
5382
|
}
|
|
5098
5383
|
|
|
5099
5384
|
// src/utils/tools.ts
|
|
@@ -5326,12 +5611,24 @@ function listManifestGlobals() {
|
|
|
5326
5611
|
(globalDefinition) => Boolean(globalDefinition && !globalDefinition.destroyed)
|
|
5327
5612
|
);
|
|
5328
5613
|
}
|
|
5329
|
-
function isRoutingCriticalMetaSignal(
|
|
5330
|
-
return
|
|
5614
|
+
function isRoutingCriticalMetaSignal(signal) {
|
|
5615
|
+
return ROUTING_CRITICAL_META_SIGNALS.has(signal.name);
|
|
5331
5616
|
}
|
|
5332
|
-
function isRoutingCriticalMetaIntent(
|
|
5333
|
-
return
|
|
5617
|
+
function isRoutingCriticalMetaIntent(intent) {
|
|
5618
|
+
return ROUTING_CRITICAL_META_INTENTS.has(intent.name);
|
|
5334
5619
|
}
|
|
5620
|
+
var ROUTING_CRITICAL_META_INTENTS = /* @__PURE__ */ new Set([
|
|
5621
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
5622
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
5623
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
5624
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
5625
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
5626
|
+
]);
|
|
5627
|
+
var ROUTING_CRITICAL_META_SIGNALS = /* @__PURE__ */ new Set([
|
|
5628
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
5629
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
5630
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
5631
|
+
]);
|
|
5335
5632
|
function buildServiceManifestSnapshot(params) {
|
|
5336
5633
|
const {
|
|
5337
5634
|
serviceName,
|
|
@@ -5741,87 +6038,9 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5741
6038
|
`${right.routine_name}:${right.task_name}`
|
|
5742
6039
|
)
|
|
5743
6040
|
);
|
|
5744
|
-
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
5745
|
-
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
5746
|
-
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
5747
|
-
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
5748
|
-
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
5749
|
-
for (const map of localMetaSignalTaskMaps) {
|
|
5750
|
-
businessLocalMetaSignalNames.add(map.signal_name);
|
|
5751
|
-
businessLocalMetaTaskKeys.add(
|
|
5752
|
-
buildTaskKey({
|
|
5753
|
-
service_name: map.service_name,
|
|
5754
|
-
name: map.task_name,
|
|
5755
|
-
version: map.task_version
|
|
5756
|
-
})
|
|
5757
|
-
);
|
|
5758
|
-
}
|
|
5759
|
-
for (const map of localMetaIntentTaskMaps) {
|
|
5760
|
-
businessLocalMetaIntentNames.add(map.intent_name);
|
|
5761
|
-
businessLocalMetaTaskKeys.add(
|
|
5762
|
-
buildTaskKey({
|
|
5763
|
-
service_name: map.service_name,
|
|
5764
|
-
name: map.task_name,
|
|
5765
|
-
version: map.task_version
|
|
5766
|
-
})
|
|
5767
|
-
);
|
|
5768
|
-
}
|
|
5769
|
-
for (const map of localMetaActorTaskMaps) {
|
|
5770
|
-
businessLocalMetaActorKeys.add(
|
|
5771
|
-
buildActorKey({
|
|
5772
|
-
service_name: map.service_name,
|
|
5773
|
-
name: map.actor_name,
|
|
5774
|
-
version: map.actor_version
|
|
5775
|
-
})
|
|
5776
|
-
);
|
|
5777
|
-
businessLocalMetaTaskKeys.add(
|
|
5778
|
-
buildTaskKey({
|
|
5779
|
-
service_name: map.service_name,
|
|
5780
|
-
name: map.task_name,
|
|
5781
|
-
version: map.task_version
|
|
5782
|
-
})
|
|
5783
|
-
);
|
|
5784
|
-
}
|
|
5785
|
-
for (const map of localMetaTaskToRoutineMaps) {
|
|
5786
|
-
businessLocalMetaRoutineKeys.add(
|
|
5787
|
-
buildRoutineKey({
|
|
5788
|
-
service_name: map.service_name,
|
|
5789
|
-
name: map.routine_name,
|
|
5790
|
-
version: map.routine_version
|
|
5791
|
-
})
|
|
5792
|
-
);
|
|
5793
|
-
businessLocalMetaTaskKeys.add(
|
|
5794
|
-
buildTaskKey({
|
|
5795
|
-
service_name: map.service_name,
|
|
5796
|
-
name: map.task_name,
|
|
5797
|
-
version: map.task_version
|
|
5798
|
-
})
|
|
5799
|
-
);
|
|
5800
|
-
}
|
|
5801
|
-
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
5802
|
-
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
5803
|
-
).sort(
|
|
5804
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5805
|
-
);
|
|
5806
|
-
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
5807
|
-
(signal) => signal !== null && signal.is_meta === true
|
|
5808
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5809
|
-
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
5810
|
-
(intent) => intent !== null && intent.is_meta === true
|
|
5811
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5812
|
-
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
5813
|
-
(actor) => actor !== null && actor.is_meta === true
|
|
5814
|
-
).sort(
|
|
5815
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5816
|
-
);
|
|
5817
|
-
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
5818
|
-
(routine) => routine !== null && routine.is_meta === true
|
|
5819
|
-
).sort(
|
|
5820
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5821
|
-
);
|
|
5822
6041
|
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
5823
6042
|
new Map(
|
|
5824
|
-
[...routingTasks, ...businessTasks
|
|
6043
|
+
[...routingTasks, ...businessTasks].map((task) => [
|
|
5825
6044
|
buildTaskKey(task),
|
|
5826
6045
|
task
|
|
5827
6046
|
])
|
|
@@ -5840,7 +6059,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5840
6059
|
);
|
|
5841
6060
|
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
5842
6061
|
new Map(
|
|
5843
|
-
[...routingSignals, ...businessSignals
|
|
6062
|
+
[...routingSignals, ...businessSignals].map(
|
|
5844
6063
|
(signal) => [signal.name, signal]
|
|
5845
6064
|
)
|
|
5846
6065
|
).values()
|
|
@@ -5854,7 +6073,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5854
6073
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5855
6074
|
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
5856
6075
|
new Map(
|
|
5857
|
-
[...routingIntents, ...businessIntents
|
|
6076
|
+
[...routingIntents, ...businessIntents].map(
|
|
5858
6077
|
(intent) => [intent.name, intent]
|
|
5859
6078
|
)
|
|
5860
6079
|
).values()
|
|
@@ -5866,16 +6085,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5866
6085
|
])
|
|
5867
6086
|
).values()
|
|
5868
6087
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5869
|
-
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5870
|
-
new Map(
|
|
5871
|
-
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
5872
|
-
buildActorKey(actor),
|
|
5873
|
-
actor
|
|
5874
|
-
])
|
|
5875
|
-
).values()
|
|
5876
|
-
).sort(
|
|
5877
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5878
|
-
) : Array.from(
|
|
6088
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActors : Array.from(
|
|
5879
6089
|
new Map(
|
|
5880
6090
|
[...businessActors, ...localMetaActors].map((actor) => [
|
|
5881
6091
|
buildActorKey(actor),
|
|
@@ -5885,16 +6095,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5885
6095
|
).sort(
|
|
5886
6096
|
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5887
6097
|
);
|
|
5888
|
-
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5889
|
-
new Map(
|
|
5890
|
-
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
5891
|
-
buildRoutineKey(routine),
|
|
5892
|
-
routine
|
|
5893
|
-
])
|
|
5894
|
-
).values()
|
|
5895
|
-
).sort(
|
|
5896
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5897
|
-
) : Array.from(
|
|
6098
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessRoutines : Array.from(
|
|
5898
6099
|
new Map(
|
|
5899
6100
|
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
5900
6101
|
buildRoutineKey(routine),
|
|
@@ -6020,14 +6221,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
6020
6221
|
)
|
|
6021
6222
|
).values()
|
|
6022
6223
|
);
|
|
6023
|
-
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
6024
|
-
new Map(
|
|
6025
|
-
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
6026
|
-
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
6027
|
-
map
|
|
6028
|
-
])
|
|
6029
|
-
).values()
|
|
6030
|
-
) : Array.from(
|
|
6224
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActorTaskMaps : Array.from(
|
|
6031
6225
|
new Map(
|
|
6032
6226
|
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
6033
6227
|
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
@@ -6055,8 +6249,8 @@ function buildServiceManifestSnapshot(params) {
|
|
|
6055
6249
|
helpers: cumulativeHelpers,
|
|
6056
6250
|
globals: cumulativeGlobals,
|
|
6057
6251
|
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
6058
|
-
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] :
|
|
6059
|
-
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] :
|
|
6252
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : publishedSignalTaskMaps,
|
|
6253
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : publishedIntentTaskMaps,
|
|
6060
6254
|
actorTaskMaps: cumulativeActorTaskMaps,
|
|
6061
6255
|
taskToRoutineMaps: cumulativeTaskToRoutineMaps,
|
|
6062
6256
|
taskToHelperMaps: cumulativeTaskToHelperMaps,
|
|
@@ -6220,6 +6414,13 @@ var META_SERVICE_INSTANCE_SHUTDOWN_TRANSPORT_DEACTIVATION_SIGNAL = "meta.service
|
|
|
6220
6414
|
var META_AUTHORITY_BOOTSTRAP_HANDSHAKE_REQUESTED_SIGNAL = "meta.service_registry.authority_bootstrap_handshake_requested";
|
|
6221
6415
|
var META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL = "meta.service_registry.runtime_status.rest_refresh_tick";
|
|
6222
6416
|
var AUTHORITY_BOOTSTRAP_HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
6417
|
+
var AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS = [
|
|
6418
|
+
1e3,
|
|
6419
|
+
3e3,
|
|
6420
|
+
7e3,
|
|
6421
|
+
15e3
|
|
6422
|
+
];
|
|
6423
|
+
var AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS = 6e4;
|
|
6223
6424
|
var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
6224
6425
|
100,
|
|
6225
6426
|
1500,
|
|
@@ -6229,25 +6430,41 @@ var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
|
6229
6430
|
45e3,
|
|
6230
6431
|
7e4
|
|
6231
6432
|
];
|
|
6433
|
+
var PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS = [
|
|
6434
|
+
50,
|
|
6435
|
+
125,
|
|
6436
|
+
250,
|
|
6437
|
+
500
|
|
6438
|
+
];
|
|
6232
6439
|
var MIN_BOOTSTRAP_FULL_SYNC_ATTEMPTS = 4;
|
|
6233
|
-
var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
6234
|
-
"Track local routine start",
|
|
6235
|
-
"Track local routine end",
|
|
6236
|
-
"Start runtime status sharing intervals",
|
|
6237
|
-
"Broadcast runtime status",
|
|
6238
|
-
"Flush local runtime status to authority",
|
|
6239
|
-
"Monitor dependee heartbeat freshness",
|
|
6240
|
-
"Refresh REST dependee runtime status",
|
|
6241
|
-
"Resolve runtime status fallback inquiry",
|
|
6242
|
-
"Respond runtime status inquiry",
|
|
6243
|
-
"Respond readiness inquiry",
|
|
6244
|
-
"Collect distributed readiness",
|
|
6245
|
-
"Get status"
|
|
6246
|
-
]);
|
|
6247
6440
|
var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRACE_SERVICE ?? "").trim();
|
|
6248
6441
|
function shouldTraceServiceRegistry(serviceName) {
|
|
6249
6442
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
6250
6443
|
}
|
|
6444
|
+
function getFetchFailureText(ctx) {
|
|
6445
|
+
return String(ctx?.__error ?? ctx?.error ?? ctx?.message ?? "").trim();
|
|
6446
|
+
}
|
|
6447
|
+
function isTerminalFetchTransportFailure(ctx) {
|
|
6448
|
+
const errorText = getFetchFailureText(ctx);
|
|
6449
|
+
if (!errorText) {
|
|
6450
|
+
return false;
|
|
6451
|
+
}
|
|
6452
|
+
return errorText.includes("ENOTFOUND") || errorText.includes("ECONNREFUSED") || errorText.includes("EHOSTUNREACH");
|
|
6453
|
+
}
|
|
6454
|
+
function isRecoverableFetchTransportFailure(ctx, options = {}) {
|
|
6455
|
+
const errorText = getFetchFailureText(ctx);
|
|
6456
|
+
if (!errorText) {
|
|
6457
|
+
return false;
|
|
6458
|
+
}
|
|
6459
|
+
return errorText.includes("AbortError") || errorText.includes("The operation was aborted") || errorText.includes("socket hang up") || errorText.includes("ECONNRESET") || errorText.includes("ETIMEDOUT") || options.includeConnectionRefused === true && errorText.includes("ECONNREFUSED");
|
|
6460
|
+
}
|
|
6461
|
+
function isHardFetchHandshakeFailure(ctx) {
|
|
6462
|
+
const errorText = getFetchFailureText(ctx);
|
|
6463
|
+
if (!errorText) {
|
|
6464
|
+
return false;
|
|
6465
|
+
}
|
|
6466
|
+
return isTerminalFetchTransportFailure(ctx) || isRecoverableFetchTransportFailure(ctx);
|
|
6467
|
+
}
|
|
6251
6468
|
function normalizeLeaseStatus(value) {
|
|
6252
6469
|
const status = String(value ?? "").trim();
|
|
6253
6470
|
if (status === "active" || status === "non_responsive" || status === "inactive" || status === "deleted") {
|
|
@@ -6393,18 +6610,28 @@ function compactAuthorityBootstrapRequestBody(ctx) {
|
|
|
6393
6610
|
if (!isBootstrapDbOperationRoutineName(ctx.__remoteRoutineName)) {
|
|
6394
6611
|
return ctx;
|
|
6395
6612
|
}
|
|
6396
|
-
const
|
|
6397
|
-
|
|
6398
|
-
|
|
6613
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? { ...ctx.queryData } : {};
|
|
6614
|
+
const compactQueryData = {};
|
|
6615
|
+
for (const key of BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS) {
|
|
6616
|
+
if (Object.prototype.hasOwnProperty.call(existingQueryData, key)) {
|
|
6617
|
+
compactQueryData[key] = existingQueryData[key];
|
|
6618
|
+
continue;
|
|
6619
|
+
}
|
|
6620
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key)) {
|
|
6621
|
+
compactQueryData[key] = ctx[key];
|
|
6622
|
+
}
|
|
6399
6623
|
}
|
|
6400
6624
|
const compacted = {
|
|
6401
|
-
|
|
6402
|
-
|
|
6625
|
+
__remoteRoutineName: ctx.__remoteRoutineName,
|
|
6626
|
+
__serviceName: ctx.__serviceName,
|
|
6627
|
+
__localServiceName: ctx.__localServiceName,
|
|
6628
|
+
__timeout: ctx.__timeout,
|
|
6629
|
+
__syncing: true,
|
|
6630
|
+
__authorityBootstrapChannel: true,
|
|
6631
|
+
queryData: compactQueryData
|
|
6403
6632
|
};
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
delete compacted[key];
|
|
6407
|
-
}
|
|
6633
|
+
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
6634
|
+
compacted.__reason = ctx.__reason;
|
|
6408
6635
|
}
|
|
6409
6636
|
return compacted;
|
|
6410
6637
|
}
|
|
@@ -7124,6 +7351,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7124
7351
|
handshakeEstablished: false
|
|
7125
7352
|
};
|
|
7126
7353
|
this.authorityBootstrapHandshakeInFlight = false;
|
|
7354
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
7355
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
7356
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
7357
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
7358
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
7127
7359
|
this.authorityFullSyncResponderTask = null;
|
|
7128
7360
|
this.authorityServiceCommunicationPersistenceTask = null;
|
|
7129
7361
|
this.localLifecycleFlushActor = CadenzaService.createActor(
|
|
@@ -7659,7 +7891,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7659
7891
|
return false;
|
|
7660
7892
|
}
|
|
7661
7893
|
this.clearTransportReadyFromContext(ctx);
|
|
7662
|
-
const
|
|
7894
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
7895
|
+
const serviceInstanceId = String(
|
|
7896
|
+
ctx.serviceInstanceId ?? ctx.__instance ?? ctx.filter?.uuid ?? ""
|
|
7897
|
+
).trim();
|
|
7898
|
+
const serviceTransportId = String(
|
|
7899
|
+
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
7900
|
+
).trim();
|
|
7663
7901
|
if (serviceName === "CadenzaDB" && this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
7664
7902
|
const currentAuthorityInstanceId = String(
|
|
7665
7903
|
this.authorityBootstrapRoute.serviceInstanceId ?? ""
|
|
@@ -7675,6 +7913,26 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7675
7913
|
return true;
|
|
7676
7914
|
}
|
|
7677
7915
|
}
|
|
7916
|
+
const signalName = String(
|
|
7917
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
7918
|
+
).trim();
|
|
7919
|
+
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
7920
|
+
const hardFetchHandshakeFailure = isFetchHandshakeFailure && isHardFetchHandshakeFailure(ctx);
|
|
7921
|
+
const recoverableFetchHandshakeFailure = isFetchHandshakeFailure && isRecoverableFetchTransportFailure(ctx, {
|
|
7922
|
+
includeConnectionRefused: true
|
|
7923
|
+
});
|
|
7924
|
+
const isFetchDelegateFailure = signalName === "meta.fetch.delegate_failed" || signalName.startsWith("meta.fetch.delegate_failed:");
|
|
7925
|
+
const hardFetchDelegateFailure = isFetchDelegateFailure && isHardFetchHandshakeFailure(ctx);
|
|
7926
|
+
const recoverableFetchDelegateFailure = isFetchDelegateFailure && isRecoverableFetchTransportFailure(ctx);
|
|
7927
|
+
if (isFetchDelegateFailure && !hardFetchDelegateFailure) {
|
|
7928
|
+
return false;
|
|
7929
|
+
}
|
|
7930
|
+
if (serviceName === "CadenzaDB" && (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure)) {
|
|
7931
|
+
return false;
|
|
7932
|
+
}
|
|
7933
|
+
if (serviceName === "CadenzaDB" && this.authorityBootstrapRecoveryActive) {
|
|
7934
|
+
return false;
|
|
7935
|
+
}
|
|
7678
7936
|
const serviceInstances = this.instances.get(serviceName);
|
|
7679
7937
|
const instances = serviceInstances?.filter((instance) => {
|
|
7680
7938
|
if (serviceInstanceId && instance.uuid === serviceInstanceId) {
|
|
@@ -7698,6 +7956,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7698
7956
|
"warning",
|
|
7699
7957
|
serviceName
|
|
7700
7958
|
);
|
|
7959
|
+
if (serviceName === "CadenzaDB") {
|
|
7960
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
7961
|
+
}
|
|
7701
7962
|
for (const instance of instances ?? []) {
|
|
7702
7963
|
if (instance.serviceName === this.serviceName && instance.uuid === this.serviceInstanceId) {
|
|
7703
7964
|
continue;
|
|
@@ -7706,13 +7967,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7706
7967
|
if (affectedTransport && this.hasAnyReadyClientProtocolForTransport(instance, affectedTransport)) {
|
|
7707
7968
|
continue;
|
|
7708
7969
|
}
|
|
7709
|
-
|
|
7710
|
-
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
7711
|
-
).trim();
|
|
7712
|
-
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
7713
|
-
if (isFetchHandshakeFailure && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
7970
|
+
if ((isFetchHandshakeFailure && (!hardFetchHandshakeFailure || recoverableFetchHandshakeFailure) || isFetchDelegateFailure && (!hardFetchDelegateFailure || recoverableFetchDelegateFailure)) && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
7714
7971
|
...ctx,
|
|
7715
|
-
__reason: "fetch_handshake_failed_retry"
|
|
7972
|
+
__reason: isFetchDelegateFailure ? "fetch_delegate_failed_retry" : "fetch_handshake_failed_retry"
|
|
7716
7973
|
})) {
|
|
7717
7974
|
continue;
|
|
7718
7975
|
}
|
|
@@ -7723,10 +7980,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7723
7980
|
});
|
|
7724
7981
|
continue;
|
|
7725
7982
|
}
|
|
7983
|
+
if (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure) {
|
|
7984
|
+
continue;
|
|
7985
|
+
}
|
|
7726
7986
|
this.applyInstanceLifecycleState(instance, {
|
|
7727
7987
|
isActive: false,
|
|
7728
7988
|
isNonResponsive: true
|
|
7729
7989
|
});
|
|
7990
|
+
const transportsToClear = affectedTransport ? [affectedTransport] : (instance.transports ?? []).filter((transport) => !transport.deleted);
|
|
7991
|
+
for (const transport of transportsToClear) {
|
|
7992
|
+
this.clearTransportFailureState(instance.uuid, transport.uuid);
|
|
7993
|
+
this.clearTransportClientState(instance, transport);
|
|
7994
|
+
this.clearRemoteRouteRecordIfCurrent(
|
|
7995
|
+
instance.serviceName,
|
|
7996
|
+
instance.uuid,
|
|
7997
|
+
transport
|
|
7998
|
+
);
|
|
7999
|
+
this.emitTransportHandleShutdowns(
|
|
8000
|
+
emit2,
|
|
8001
|
+
this.buildTransportRouteKey(instance.serviceName, transport),
|
|
8002
|
+
transport
|
|
8003
|
+
);
|
|
8004
|
+
}
|
|
8005
|
+
emit2("meta.service_registry.service_not_responding", {
|
|
8006
|
+
...ctx,
|
|
8007
|
+
serviceName: instance.serviceName,
|
|
8008
|
+
serviceInstanceId: instance.uuid,
|
|
8009
|
+
serviceTransportId: affectedTransport?.uuid ?? serviceTransportId ?? void 0,
|
|
8010
|
+
routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.routeKey ?? ctx.__routeKey,
|
|
8011
|
+
__routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.__routeKey ?? ctx.routeKey
|
|
8012
|
+
});
|
|
7730
8013
|
emit2("global.meta.service_registry.service_not_responding", {
|
|
7731
8014
|
data: {
|
|
7732
8015
|
isActive: false,
|
|
@@ -7755,6 +8038,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7755
8038
|
).doOn(
|
|
7756
8039
|
"meta.fetch.handshake_failed",
|
|
7757
8040
|
"meta.fetch.handshake_failed.*",
|
|
8041
|
+
"meta.fetch.delegate_failed",
|
|
8042
|
+
"meta.fetch.delegate_failed.*",
|
|
7758
8043
|
"meta.socket_client.disconnected",
|
|
7759
8044
|
"meta.socket_client.disconnected.*",
|
|
7760
8045
|
"meta.service_registry.runtime_status_unreachable"
|
|
@@ -7940,12 +8225,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7940
8225
|
return false;
|
|
7941
8226
|
}
|
|
7942
8227
|
}
|
|
7943
|
-
this.
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
__reason: "cadenza_db_unreachable"
|
|
7948
|
-
});
|
|
8228
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
8229
|
+
return false;
|
|
8230
|
+
}
|
|
8231
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
7949
8232
|
return true;
|
|
7950
8233
|
},
|
|
7951
8234
|
"Clears bootstrap full-sync retry satisfaction when the authority becomes unreachable."
|
|
@@ -7965,7 +8248,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7965
8248
|
return false;
|
|
7966
8249
|
}
|
|
7967
8250
|
this.ensureBootstrapAuthorityControlPlane(ctx, emit2);
|
|
7968
|
-
return this.
|
|
8251
|
+
return this.scheduleNextBootstrapFullSyncRetry(
|
|
7969
8252
|
"cadenza_db_fetch_handshake"
|
|
7970
8253
|
);
|
|
7971
8254
|
},
|
|
@@ -8332,12 +8615,24 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8332
8615
|
preferredRole,
|
|
8333
8616
|
preferredProtocol
|
|
8334
8617
|
);
|
|
8618
|
+
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
8619
|
+
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
8620
|
+
}
|
|
8621
|
+
const hasPendingRouteableInstance = Boolean(__serviceName) && __serviceName !== "CadenzaDB" && this.hasPendingRouteableInstanceForSelection(
|
|
8622
|
+
__serviceName,
|
|
8623
|
+
context,
|
|
8624
|
+
preferredRole,
|
|
8625
|
+
targetServiceInstanceId
|
|
8626
|
+
);
|
|
8335
8627
|
const activeRoutingCooldown = __serviceName && !targetServiceInstanceId ? this.getActiveRoutingCooldown(
|
|
8336
8628
|
__serviceName,
|
|
8337
8629
|
preferredRole,
|
|
8338
8630
|
preferredProtocol
|
|
8339
8631
|
) : null;
|
|
8340
8632
|
if (activeRoutingCooldown) {
|
|
8633
|
+
if (hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
8634
|
+
return false;
|
|
8635
|
+
}
|
|
8341
8636
|
context.errored = true;
|
|
8342
8637
|
context.__error = `No routeable ${preferredRole} transport available for ${__serviceName}. Waiting for authority route updates before retrying.`;
|
|
8343
8638
|
emit2(
|
|
@@ -8379,9 +8674,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8379
8674
|
}
|
|
8380
8675
|
let retries = __retries ?? 0;
|
|
8381
8676
|
let triedInstances = __triedInstances ?? [];
|
|
8382
|
-
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
8383
|
-
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
8384
|
-
}
|
|
8385
8677
|
const filteredInstances = this.instances.get(__serviceName)?.filter((instance) => {
|
|
8386
8678
|
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
8387
8679
|
return false;
|
|
@@ -8400,6 +8692,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8400
8692
|
)
|
|
8401
8693
|
);
|
|
8402
8694
|
}) ?? [];
|
|
8695
|
+
if (filteredInstances.length === 0 && __serviceName && hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
8696
|
+
return false;
|
|
8697
|
+
}
|
|
8403
8698
|
const instances = this.collapseInstancesByRouteOrigin(
|
|
8404
8699
|
filteredInstances,
|
|
8405
8700
|
context,
|
|
@@ -8743,10 +9038,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8743
9038
|
CadenzaService.createMetaTask(
|
|
8744
9039
|
"Track local routine start",
|
|
8745
9040
|
(ctx, emit2) => {
|
|
8746
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
8747
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
8748
|
-
return false;
|
|
8749
|
-
}
|
|
8750
9041
|
const routineId = String(
|
|
8751
9042
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
8752
9043
|
);
|
|
@@ -8777,10 +9068,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8777
9068
|
CadenzaService.createMetaTask(
|
|
8778
9069
|
"Track local routine end",
|
|
8779
9070
|
(ctx, emit2) => {
|
|
8780
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
8781
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
8782
|
-
return false;
|
|
8783
|
-
}
|
|
8784
9071
|
const routineId = String(
|
|
8785
9072
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
8786
9073
|
);
|
|
@@ -9414,6 +9701,19 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9414
9701
|
}
|
|
9415
9702
|
return false;
|
|
9416
9703
|
}
|
|
9704
|
+
if (this.serviceName && normalizedLocalInstance.serviceName !== this.serviceName || this.serviceInstanceId && normalizedLocalInstance.uuid !== this.serviceInstanceId) {
|
|
9705
|
+
if (shouldTraceServiceRegistry(
|
|
9706
|
+
resolveServiceNameFromContext(ctx) || this.serviceName
|
|
9707
|
+
)) {
|
|
9708
|
+
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service_ignored_non_local_instance", {
|
|
9709
|
+
localServiceName: this.serviceName,
|
|
9710
|
+
localServiceInstanceId: this.serviceInstanceId,
|
|
9711
|
+
resolvedServiceName: normalizedLocalInstance.serviceName,
|
|
9712
|
+
resolvedServiceInstanceId: normalizedLocalInstance.uuid
|
|
9713
|
+
});
|
|
9714
|
+
}
|
|
9715
|
+
return false;
|
|
9716
|
+
}
|
|
9417
9717
|
if (shouldTraceServiceRegistry(normalizedLocalInstance.serviceName)) {
|
|
9418
9718
|
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service", {
|
|
9419
9719
|
localServiceName: this.serviceName,
|
|
@@ -9629,7 +9929,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9629
9929
|
security_profile: "excluded",
|
|
9630
9930
|
auth_strategy: "excluded",
|
|
9631
9931
|
deleted: "false"
|
|
9632
|
-
}
|
|
9932
|
+
},
|
|
9933
|
+
where: "service_instance_transport.deleted IS DISTINCT FROM FALSE OR service_instance_transport.protocols IS DISTINCT FROM excluded.protocols OR service_instance_transport.security_profile IS DISTINCT FROM excluded.security_profile OR service_instance_transport.auth_strategy IS DISTINCT FROM excluded.auth_strategy"
|
|
9633
9934
|
}
|
|
9634
9935
|
}
|
|
9635
9936
|
},
|
|
@@ -10561,6 +10862,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10561
10862
|
serviceTransportId: String(ctx.serviceTransportId ?? "").trim() || null,
|
|
10562
10863
|
handshakeEstablished: true
|
|
10563
10864
|
};
|
|
10865
|
+
this.markAuthorityBootstrapHandshakeSatisfied();
|
|
10564
10866
|
return true;
|
|
10565
10867
|
}
|
|
10566
10868
|
getAuthorityBootstrapRestTarget() {
|
|
@@ -10589,6 +10891,92 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10589
10891
|
handshakeEstablished: false
|
|
10590
10892
|
};
|
|
10591
10893
|
}
|
|
10894
|
+
clearAuthorityBootstrapHandshakeRetryTimer() {
|
|
10895
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
10896
|
+
clearTimeout(this.authorityBootstrapHandshakeRetryTimer);
|
|
10897
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
10898
|
+
}
|
|
10899
|
+
}
|
|
10900
|
+
invalidateAuthorityBootstrapHandshakeRetryState(reason) {
|
|
10901
|
+
this.authorityBootstrapHandshakeRetryGeneration += 1;
|
|
10902
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
10903
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
10904
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10905
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10906
|
+
}
|
|
10907
|
+
}
|
|
10908
|
+
markAuthorityBootstrapHandshakeSatisfied() {
|
|
10909
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
10910
|
+
this.authorityBootstrapHandshakeRetryIndex = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length;
|
|
10911
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
10912
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
10913
|
+
}
|
|
10914
|
+
buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(baseDelayMs, attempt) {
|
|
10915
|
+
return buildDeterministicJitteredDelayMs(
|
|
10916
|
+
baseDelayMs,
|
|
10917
|
+
this.bootstrapFullSyncRetryJitterRatio,
|
|
10918
|
+
this.buildDeterministicInstanceJitterKey(
|
|
10919
|
+
`authority-bootstrap-handshake-retry-${attempt}`
|
|
10920
|
+
)
|
|
10921
|
+
);
|
|
10922
|
+
}
|
|
10923
|
+
scheduleAuthorityBootstrapHandshakeRetry(reason) {
|
|
10924
|
+
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
10925
|
+
return false;
|
|
10926
|
+
}
|
|
10927
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
10928
|
+
return false;
|
|
10929
|
+
}
|
|
10930
|
+
if (this.authorityBootstrapHandshakeInFlight) {
|
|
10931
|
+
return false;
|
|
10932
|
+
}
|
|
10933
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10934
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10935
|
+
}
|
|
10936
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
10937
|
+
return false;
|
|
10938
|
+
}
|
|
10939
|
+
const retryGeneration = this.authorityBootstrapHandshakeRetryGeneration;
|
|
10940
|
+
const retryReason = this.authorityBootstrapHandshakeRetryReason ?? "authority_bootstrap_handshake_retry";
|
|
10941
|
+
const attempt = this.authorityBootstrapHandshakeRetryIndex + 1;
|
|
10942
|
+
const baseDelayMs = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS[Math.min(
|
|
10943
|
+
this.authorityBootstrapHandshakeRetryIndex,
|
|
10944
|
+
AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length - 1
|
|
10945
|
+
)] ?? AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.at(-1);
|
|
10946
|
+
const delayMs = this.buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(
|
|
10947
|
+
baseDelayMs,
|
|
10948
|
+
attempt
|
|
10949
|
+
);
|
|
10950
|
+
this.authorityBootstrapHandshakeRetryIndex += 1;
|
|
10951
|
+
this.authorityBootstrapHandshakeRetryTimer = setTimeout(() => {
|
|
10952
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
10953
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished() || this.authorityBootstrapHandshakeInFlight || retryGeneration !== this.authorityBootstrapHandshakeRetryGeneration) {
|
|
10954
|
+
return;
|
|
10955
|
+
}
|
|
10956
|
+
this.requestAuthorityBootstrapHandshake({
|
|
10957
|
+
__reason: retryReason,
|
|
10958
|
+
__authorityBootstrapRetry: true,
|
|
10959
|
+
__authorityBootstrapRetryAttempt: attempt
|
|
10960
|
+
});
|
|
10961
|
+
}, delayMs);
|
|
10962
|
+
return true;
|
|
10963
|
+
}
|
|
10964
|
+
restartAuthorityBootstrapHandshakeRetryChain(reason) {
|
|
10965
|
+
this.invalidateAuthorityBootstrapHandshakeRetryState(reason);
|
|
10966
|
+
return this.scheduleAuthorityBootstrapHandshakeRetry(reason);
|
|
10967
|
+
}
|
|
10968
|
+
restartAuthorityBootstrapRecovery(reason) {
|
|
10969
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
10970
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10971
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10972
|
+
}
|
|
10973
|
+
return false;
|
|
10974
|
+
}
|
|
10975
|
+
this.authorityBootstrapRecoveryActive = true;
|
|
10976
|
+
this.invalidateAuthorityBootstrapHandshake();
|
|
10977
|
+
this.invalidateBootstrapFullSyncRetryState(reason);
|
|
10978
|
+
return this.restartAuthorityBootstrapHandshakeRetryChain(reason);
|
|
10979
|
+
}
|
|
10592
10980
|
requestAuthorityBootstrapHandshake(ctx) {
|
|
10593
10981
|
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
10594
10982
|
return false;
|
|
@@ -10795,12 +11183,16 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10795
11183
|
return;
|
|
10796
11184
|
}
|
|
10797
11185
|
const deputyTaskName = `Inquire ${map.intentName} via ${map.serviceName} (${map.taskName} v${map.taskVersion})`;
|
|
10798
|
-
const
|
|
11186
|
+
const shouldUseAuthorityBootstrapTimeout = map.serviceName === "CadenzaDB" && isMetaIntentName(map.intentName);
|
|
11187
|
+
const effectiveTimeout = shouldUseAuthorityBootstrapTimeout ? Math.max(map.timeout ?? 0, AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS) : map.timeout;
|
|
11188
|
+
const authorityBootstrapIntentSpec = map.serviceName === "CadenzaDB" ? getAuthorityBootstrapIntentSpec(map.intentName) : null;
|
|
11189
|
+
const authorityBootstrapTaskName = authorityBootstrapIntentSpec?.authorityTaskName ?? map.taskName;
|
|
11190
|
+
const deputyTask = authorityBootstrapIntentSpec ? CadenzaService.createMetaTask(
|
|
10799
11191
|
deputyTaskName,
|
|
10800
11192
|
async (ctx) => this.invokeAuthorityBootstrapRoutine(
|
|
10801
|
-
|
|
11193
|
+
authorityBootstrapTaskName,
|
|
10802
11194
|
ctx,
|
|
10803
|
-
|
|
11195
|
+
effectiveTimeout ?? AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS
|
|
10804
11196
|
),
|
|
10805
11197
|
"Routes reserved authority bootstrap inquiries directly through the post-handshake authority control-plane channel.",
|
|
10806
11198
|
{
|
|
@@ -10810,14 +11202,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10810
11202
|
) : isMetaIntentName(map.intentName) ? CadenzaService.createMetaDeputyTask(map.taskName, map.serviceName, {
|
|
10811
11203
|
register: false,
|
|
10812
11204
|
isHidden: true,
|
|
10813
|
-
timeout:
|
|
11205
|
+
timeout: effectiveTimeout,
|
|
10814
11206
|
retryCount: 1,
|
|
10815
11207
|
retryDelay: 50,
|
|
10816
11208
|
retryDelayFactor: 1.2
|
|
10817
11209
|
}) : CadenzaService.createDeputyTask(map.taskName, map.serviceName, {
|
|
10818
11210
|
register: false,
|
|
10819
11211
|
isHidden: true,
|
|
10820
|
-
timeout:
|
|
11212
|
+
timeout: effectiveTimeout,
|
|
10821
11213
|
retryCount: 1,
|
|
10822
11214
|
retryDelay: 50,
|
|
10823
11215
|
retryDelayFactor: 1.2
|
|
@@ -10831,7 +11223,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10831
11223
|
key,
|
|
10832
11224
|
intentName: map.intentName,
|
|
10833
11225
|
serviceName: map.serviceName,
|
|
10834
|
-
remoteTaskName:
|
|
11226
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
10835
11227
|
remoteTaskVersion: map.taskVersion,
|
|
10836
11228
|
localTaskName: deputyTask.name || deputyTaskName,
|
|
10837
11229
|
localTask: deputyTask
|
|
@@ -10843,7 +11235,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10843
11235
|
localServiceName: this.serviceName,
|
|
10844
11236
|
intentName: map.intentName,
|
|
10845
11237
|
remoteServiceName: map.serviceName,
|
|
10846
|
-
remoteTaskName:
|
|
11238
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
10847
11239
|
remoteTaskVersion: map.taskVersion
|
|
10848
11240
|
});
|
|
10849
11241
|
}
|
|
@@ -11543,6 +11935,50 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
11543
11935
|
);
|
|
11544
11936
|
});
|
|
11545
11937
|
}
|
|
11938
|
+
hasPendingRouteableInstanceForSelection(serviceName, ctx, role, targetServiceInstanceId) {
|
|
11939
|
+
return (this.instances.get(serviceName) ?? []).some((instance) => {
|
|
11940
|
+
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
11941
|
+
return false;
|
|
11942
|
+
}
|
|
11943
|
+
if (!instance.isActive || instance.isNonResponsive || instance.isBlocked) {
|
|
11944
|
+
return false;
|
|
11945
|
+
}
|
|
11946
|
+
if (instance.isFrontend) {
|
|
11947
|
+
return false;
|
|
11948
|
+
}
|
|
11949
|
+
const transport = this.selectTransportForInstance(instance, ctx, role);
|
|
11950
|
+
if (!transport) {
|
|
11951
|
+
return false;
|
|
11952
|
+
}
|
|
11953
|
+
return !this.hasTransportClientReady(instance, transport);
|
|
11954
|
+
});
|
|
11955
|
+
}
|
|
11956
|
+
maybeSchedulePendingRouteSelectionRetry(ctx, serviceName) {
|
|
11957
|
+
const signalName = String(
|
|
11958
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
11959
|
+
).trim();
|
|
11960
|
+
if (!signalName) {
|
|
11961
|
+
return false;
|
|
11962
|
+
}
|
|
11963
|
+
const attempt = Math.max(
|
|
11964
|
+
0,
|
|
11965
|
+
Number(ctx.__pendingRouteSelectionAttempt ?? 0) || 0
|
|
11966
|
+
);
|
|
11967
|
+
const delayMs = PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS[attempt];
|
|
11968
|
+
if (delayMs === void 0) {
|
|
11969
|
+
return false;
|
|
11970
|
+
}
|
|
11971
|
+
CadenzaService.schedule(
|
|
11972
|
+
signalName,
|
|
11973
|
+
{
|
|
11974
|
+
...ctx,
|
|
11975
|
+
__pendingRouteSelectionAttempt: attempt + 1,
|
|
11976
|
+
__pendingRouteSelectionServiceName: serviceName
|
|
11977
|
+
},
|
|
11978
|
+
delayMs
|
|
11979
|
+
);
|
|
11980
|
+
return true;
|
|
11981
|
+
}
|
|
11546
11982
|
refreshRoutingCooldownsForService(serviceName) {
|
|
11547
11983
|
if (!serviceName) {
|
|
11548
11984
|
return;
|
|
@@ -12362,8 +12798,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
12362
12798
|
this.refreshRoutingCooldownsForService(serviceName);
|
|
12363
12799
|
}
|
|
12364
12800
|
clearTransportReadyFromContext(ctx) {
|
|
12365
|
-
const serviceName =
|
|
12366
|
-
const explicitRouteKey = String(ctx.routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
12801
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
12802
|
+
const explicitRouteKey = String(ctx.routeKey ?? ctx.__routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
12367
12803
|
const serviceTransportId = String(
|
|
12368
12804
|
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
12369
12805
|
).trim();
|
|
@@ -13958,6 +14394,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
13958
14394
|
this.bootstrapFullSyncRetryGeneration = 0;
|
|
13959
14395
|
this.bootstrapFullSyncSatisfied = false;
|
|
13960
14396
|
this.bootstrapFullSyncRetryReason = null;
|
|
14397
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
14398
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
14399
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
14400
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
13961
14401
|
this.knownGlobalSignalMaps.clear();
|
|
13962
14402
|
this.authorityBootstrapRoute = {
|
|
13963
14403
|
origin: null,
|
|
@@ -17151,163 +17591,6 @@ var SocketController = class _SocketController {
|
|
|
17151
17591
|
}
|
|
17152
17592
|
};
|
|
17153
17593
|
|
|
17154
|
-
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
17155
|
-
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
17156
|
-
function readString(value) {
|
|
17157
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
17158
|
-
}
|
|
17159
|
-
function readRecord(value) {
|
|
17160
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
17161
|
-
}
|
|
17162
|
-
function normalizeRoutineExecutionTraceFields(data) {
|
|
17163
|
-
if (!data) {
|
|
17164
|
-
return null;
|
|
17165
|
-
}
|
|
17166
|
-
const normalizedData = { ...data };
|
|
17167
|
-
const traceId = readString(
|
|
17168
|
-
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
17169
|
-
);
|
|
17170
|
-
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
17171
|
-
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
17172
|
-
const serviceName = readString(
|
|
17173
|
-
normalizedData.service_name ?? normalizedData.serviceName
|
|
17174
|
-
);
|
|
17175
|
-
const serviceInstanceId = readString(
|
|
17176
|
-
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
17177
|
-
);
|
|
17178
|
-
if (traceId) {
|
|
17179
|
-
normalizedData.execution_trace_id = traceId;
|
|
17180
|
-
}
|
|
17181
|
-
if (metaContext) {
|
|
17182
|
-
normalizedData.meta_context = metaContext;
|
|
17183
|
-
}
|
|
17184
|
-
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
17185
|
-
normalizedData.is_meta = isMeta;
|
|
17186
|
-
}
|
|
17187
|
-
if (serviceName) {
|
|
17188
|
-
normalizedData.service_name = serviceName;
|
|
17189
|
-
}
|
|
17190
|
-
if (serviceInstanceId) {
|
|
17191
|
-
normalizedData.service_instance_id = serviceInstanceId;
|
|
17192
|
-
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
17193
|
-
normalizedData.service_instance_id = null;
|
|
17194
|
-
}
|
|
17195
|
-
delete normalizedData.executionTraceId;
|
|
17196
|
-
delete normalizedData.traceId;
|
|
17197
|
-
delete normalizedData.metaContext;
|
|
17198
|
-
delete normalizedData.isMeta;
|
|
17199
|
-
delete normalizedData.serviceName;
|
|
17200
|
-
delete normalizedData.serviceInstanceId;
|
|
17201
|
-
return normalizedData;
|
|
17202
|
-
}
|
|
17203
|
-
function stripExecutionTraceServiceInstanceFields(data) {
|
|
17204
|
-
if (!data) {
|
|
17205
|
-
return null;
|
|
17206
|
-
}
|
|
17207
|
-
const normalizedData = { ...data };
|
|
17208
|
-
delete normalizedData.serviceInstanceId;
|
|
17209
|
-
delete normalizedData.service_instance_id;
|
|
17210
|
-
return normalizedData;
|
|
17211
|
-
}
|
|
17212
|
-
function normalizeEnsureData(entityType, data) {
|
|
17213
|
-
switch (entityType) {
|
|
17214
|
-
case "execution_trace":
|
|
17215
|
-
return stripExecutionTraceServiceInstanceFields(data);
|
|
17216
|
-
case "routine_execution":
|
|
17217
|
-
return normalizeRoutineExecutionTraceFields(data);
|
|
17218
|
-
default:
|
|
17219
|
-
return data;
|
|
17220
|
-
}
|
|
17221
|
-
}
|
|
17222
|
-
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
17223
|
-
const normalizedEntityId = readString(entityId);
|
|
17224
|
-
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
17225
|
-
}
|
|
17226
|
-
function resolveEnsureEntityId(entityType, data) {
|
|
17227
|
-
switch (entityType) {
|
|
17228
|
-
default:
|
|
17229
|
-
return readString(data.uuid);
|
|
17230
|
-
}
|
|
17231
|
-
}
|
|
17232
|
-
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
17233
|
-
return readString(
|
|
17234
|
-
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
17235
|
-
);
|
|
17236
|
-
}
|
|
17237
|
-
function dedupeDependencies(values) {
|
|
17238
|
-
return Array.from(
|
|
17239
|
-
new Set(values.filter((value) => typeof value === "string"))
|
|
17240
|
-
);
|
|
17241
|
-
}
|
|
17242
|
-
function resolveTraceIdFromData(data) {
|
|
17243
|
-
if (!data) {
|
|
17244
|
-
return null;
|
|
17245
|
-
}
|
|
17246
|
-
return readString(
|
|
17247
|
-
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
17248
|
-
);
|
|
17249
|
-
}
|
|
17250
|
-
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
17251
|
-
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
17252
|
-
if (!normalizedData) {
|
|
17253
|
-
return null;
|
|
17254
|
-
}
|
|
17255
|
-
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
17256
|
-
if (!entityId) {
|
|
17257
|
-
return null;
|
|
17258
|
-
}
|
|
17259
|
-
return {
|
|
17260
|
-
kind: "ensure",
|
|
17261
|
-
entityType,
|
|
17262
|
-
entityId,
|
|
17263
|
-
data: normalizedData,
|
|
17264
|
-
deps: dedupeDependencies(deps)
|
|
17265
|
-
};
|
|
17266
|
-
}
|
|
17267
|
-
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
17268
|
-
const normalizedData = readRecord(data);
|
|
17269
|
-
const normalizedFilter = readRecord(filter);
|
|
17270
|
-
if (!normalizedData || !normalizedFilter) {
|
|
17271
|
-
return null;
|
|
17272
|
-
}
|
|
17273
|
-
const entityId = resolveUpdateEntityId(
|
|
17274
|
-
entityType,
|
|
17275
|
-
normalizedData,
|
|
17276
|
-
normalizedFilter
|
|
17277
|
-
);
|
|
17278
|
-
if (!entityId) {
|
|
17279
|
-
return null;
|
|
17280
|
-
}
|
|
17281
|
-
return {
|
|
17282
|
-
kind: "update",
|
|
17283
|
-
entityType,
|
|
17284
|
-
entityId,
|
|
17285
|
-
data: normalizedData,
|
|
17286
|
-
filter: normalizedFilter,
|
|
17287
|
-
deps: dedupeDependencies(deps)
|
|
17288
|
-
};
|
|
17289
|
-
}
|
|
17290
|
-
function createExecutionPersistenceBundle(input) {
|
|
17291
|
-
const ensures = (input.ensures ?? []).filter(
|
|
17292
|
-
(event) => Boolean(event)
|
|
17293
|
-
);
|
|
17294
|
-
const updates = (input.updates ?? []).filter(
|
|
17295
|
-
(event) => Boolean(event)
|
|
17296
|
-
);
|
|
17297
|
-
if (ensures.length === 0 && updates.length === 0) {
|
|
17298
|
-
return null;
|
|
17299
|
-
}
|
|
17300
|
-
const traceId = readString(input.traceId) ?? ensures.map((event) => resolveTraceIdFromData(event.data)).find((value) => Boolean(value)) ?? updates.map((event) => resolveTraceIdFromData(event.data)).find((value) => Boolean(value));
|
|
17301
|
-
if (!traceId) {
|
|
17302
|
-
return null;
|
|
17303
|
-
}
|
|
17304
|
-
return {
|
|
17305
|
-
traceId,
|
|
17306
|
-
ensures,
|
|
17307
|
-
updates
|
|
17308
|
-
};
|
|
17309
|
-
}
|
|
17310
|
-
|
|
17311
17594
|
// src/signals/SignalController.ts
|
|
17312
17595
|
var import_uuid6 = require("uuid");
|
|
17313
17596
|
function resolveExecutionObservabilityServiceInstanceId() {
|
|
@@ -17460,7 +17743,7 @@ var SignalController = class _SignalController {
|
|
|
17460
17743
|
intent: traceContext.__metadata?.__intent ?? traceContext.__intent ?? null,
|
|
17461
17744
|
context: {
|
|
17462
17745
|
id: (0, import_uuid6.v4)(),
|
|
17463
|
-
context:
|
|
17746
|
+
context: sanitizedTraceContext
|
|
17464
17747
|
},
|
|
17465
17748
|
is_meta: signalEmission.isMeta,
|
|
17466
17749
|
service_name: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -18050,6 +18333,18 @@ function registerActorSessionPersistenceTasks() {
|
|
|
18050
18333
|
var import_core5 = require("@cadenza.io/core");
|
|
18051
18334
|
var import_uuid7 = require("uuid");
|
|
18052
18335
|
var ACTOR_TASK_METADATA2 = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
18336
|
+
var ROUTING_CRITICAL_META_INTENTS2 = /* @__PURE__ */ new Set([
|
|
18337
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
18338
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
18339
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
18340
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
18341
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
18342
|
+
]);
|
|
18343
|
+
var ROUTING_CRITICAL_META_SIGNALS2 = /* @__PURE__ */ new Set([
|
|
18344
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
18345
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
18346
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
18347
|
+
]);
|
|
18053
18348
|
function getActorTaskRuntimeMetadata2(taskFunction) {
|
|
18054
18349
|
if (typeof taskFunction !== "function") {
|
|
18055
18350
|
return void 0;
|
|
@@ -18141,7 +18436,7 @@ function buildIntentRegistryData(intent) {
|
|
|
18141
18436
|
};
|
|
18142
18437
|
}
|
|
18143
18438
|
function isLocalOnlySyncIntent(intentName) {
|
|
18144
|
-
return intentName === import_core5.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
18439
|
+
return intentName === import_core5.META_ACTOR_SESSION_STATE_PERSIST_INTENT || intentName.startsWith("meta-") || intentName.startsWith("global.meta-");
|
|
18145
18440
|
}
|
|
18146
18441
|
function getJoinedContextValue(ctx, key) {
|
|
18147
18442
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
@@ -18181,6 +18476,32 @@ function buildMinimalSyncSignalContext(ctx, extra = {}) {
|
|
|
18181
18476
|
}
|
|
18182
18477
|
return nextContext;
|
|
18183
18478
|
}
|
|
18479
|
+
function buildMinimalSyncShardContext(ctx, extra = {}) {
|
|
18480
|
+
return {
|
|
18481
|
+
...buildMinimalSyncSignalContext(ctx, extra),
|
|
18482
|
+
tasks: void 0,
|
|
18483
|
+
signals: void 0,
|
|
18484
|
+
intents: void 0,
|
|
18485
|
+
actors: void 0,
|
|
18486
|
+
routines: void 0,
|
|
18487
|
+
serviceInstances: void 0,
|
|
18488
|
+
service_instance_rows: void 0,
|
|
18489
|
+
service_instance_transport_rows: void 0,
|
|
18490
|
+
serviceManifests: void 0,
|
|
18491
|
+
manifests: void 0,
|
|
18492
|
+
signalToTaskMaps: void 0,
|
|
18493
|
+
signal_to_task_maps: void 0,
|
|
18494
|
+
intentToTaskMaps: void 0,
|
|
18495
|
+
intent_to_task_maps: void 0,
|
|
18496
|
+
actorTaskMaps: void 0,
|
|
18497
|
+
actor_task_maps: void 0,
|
|
18498
|
+
directionalTaskMaps: void 0,
|
|
18499
|
+
directional_task_maps: void 0,
|
|
18500
|
+
taskToRoutineMaps: void 0,
|
|
18501
|
+
task_to_routine_maps: void 0,
|
|
18502
|
+
task: void 0
|
|
18503
|
+
};
|
|
18504
|
+
}
|
|
18184
18505
|
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
18185
18506
|
const pickQueryData = (source, allowedKeys) => {
|
|
18186
18507
|
const next = {};
|
|
@@ -18218,7 +18539,40 @@ var DEFAULT_SYNC_CYCLE_RUNTIME_STATE = {
|
|
|
18218
18539
|
activeSyncCycleStartedAt: 0,
|
|
18219
18540
|
phase: "idle"
|
|
18220
18541
|
};
|
|
18221
|
-
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY =
|
|
18542
|
+
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY = 2;
|
|
18543
|
+
function stripSyncResolverPayload(ctx) {
|
|
18544
|
+
const nextContext = {
|
|
18545
|
+
...ctx
|
|
18546
|
+
};
|
|
18547
|
+
const bulkyStructuralKeys = [
|
|
18548
|
+
"tasks",
|
|
18549
|
+
"helpers",
|
|
18550
|
+
"globals",
|
|
18551
|
+
"signals",
|
|
18552
|
+
"intents",
|
|
18553
|
+
"actors",
|
|
18554
|
+
"routines",
|
|
18555
|
+
"serviceInstances",
|
|
18556
|
+
"serviceInstanceTransports",
|
|
18557
|
+
"serviceManifests",
|
|
18558
|
+
"signalToTaskMaps",
|
|
18559
|
+
"intentToTaskMaps",
|
|
18560
|
+
"actorTaskMaps",
|
|
18561
|
+
"directionalTaskMaps",
|
|
18562
|
+
"taskToRoutineMaps",
|
|
18563
|
+
"registeredGlobalSignals",
|
|
18564
|
+
"registeredGlobalIntents",
|
|
18565
|
+
"registeredActors",
|
|
18566
|
+
"registeredRoutines"
|
|
18567
|
+
];
|
|
18568
|
+
delete nextContext.__resolverOriginalContext;
|
|
18569
|
+
delete nextContext.__resolverQueryData;
|
|
18570
|
+
delete nextContext.joinedContexts;
|
|
18571
|
+
for (const key of bulkyStructuralKeys) {
|
|
18572
|
+
delete nextContext[key];
|
|
18573
|
+
}
|
|
18574
|
+
return nextContext;
|
|
18575
|
+
}
|
|
18222
18576
|
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
18223
18577
|
if (!graph) {
|
|
18224
18578
|
return void 0;
|
|
@@ -18230,28 +18584,14 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
|
18230
18584
|
return graph.completionTask;
|
|
18231
18585
|
}
|
|
18232
18586
|
function buildSyncExecutionEnvelope(ctx, queryData) {
|
|
18233
|
-
const originalContext =
|
|
18587
|
+
const originalContext = stripSyncResolverPayload(ctx);
|
|
18234
18588
|
const syncSourceServiceName = typeof ctx.__syncSourceServiceName === "string" && ctx.__syncSourceServiceName.trim().length > 0 ? ctx.__syncSourceServiceName : typeof ctx.__serviceName === "string" && ctx.__serviceName.trim().length > 0 ? ctx.__serviceName : resolveSyncServiceName();
|
|
18235
|
-
const rootDbOperationFields = {};
|
|
18236
|
-
for (const key of [
|
|
18237
|
-
"data",
|
|
18238
|
-
"batch",
|
|
18239
|
-
"transaction",
|
|
18240
|
-
"onConflict",
|
|
18241
|
-
"filter",
|
|
18242
|
-
"fields"
|
|
18243
|
-
]) {
|
|
18244
|
-
if (Object.prototype.hasOwnProperty.call(queryData, key)) {
|
|
18245
|
-
rootDbOperationFields[key] = queryData[key];
|
|
18246
|
-
}
|
|
18247
|
-
}
|
|
18248
18589
|
const nextContext = {
|
|
18249
18590
|
__syncing: ctx.__syncing === true || ctx.__metadata?.__syncing === true || false,
|
|
18250
18591
|
__syncSourceServiceName: syncSourceServiceName,
|
|
18251
18592
|
__preferredTransportProtocol: "rest",
|
|
18252
18593
|
__resolverOriginalContext: originalContext,
|
|
18253
18594
|
__resolverQueryData: queryData,
|
|
18254
|
-
...rootDbOperationFields,
|
|
18255
18595
|
queryData
|
|
18256
18596
|
};
|
|
18257
18597
|
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
@@ -18270,6 +18610,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
18270
18610
|
Number(options.concurrency),
|
|
18271
18611
|
REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY
|
|
18272
18612
|
) : REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY,
|
|
18613
|
+
timeout: Number(options.timeout) > 0 ? Number(options.timeout) : 6e4,
|
|
18273
18614
|
register: false,
|
|
18274
18615
|
isHidden: true
|
|
18275
18616
|
});
|
|
@@ -18309,13 +18650,15 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
18309
18650
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
18310
18651
|
`Finalize graph sync insert for ${tableName}`,
|
|
18311
18652
|
(ctx) => {
|
|
18312
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ?
|
|
18653
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? stripSyncResolverPayload(
|
|
18654
|
+
ctx.__resolverOriginalContext
|
|
18655
|
+
) : {};
|
|
18313
18656
|
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
18314
|
-
const normalizedContext = {
|
|
18657
|
+
const normalizedContext = stripSyncResolverPayload({
|
|
18315
18658
|
...originalContext,
|
|
18316
18659
|
...ctx,
|
|
18317
18660
|
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : originalQueryData
|
|
18318
|
-
};
|
|
18661
|
+
});
|
|
18319
18662
|
if (originalContext.__syncing === true && !didSyncInsertSucceed(normalizedContext)) {
|
|
18320
18663
|
CadenzaService.debounce("meta.sync_requested", {}, 1e3);
|
|
18321
18664
|
}
|
|
@@ -18389,22 +18732,103 @@ function isBootstrapLocalOnlySignal(signalName) {
|
|
|
18389
18732
|
function hasNonZeroPending(summary) {
|
|
18390
18733
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
18391
18734
|
}
|
|
18735
|
+
function shouldSkipIdleBootstrapSyncTrigger(input) {
|
|
18736
|
+
if (input?.__forceSyncCycle === true) {
|
|
18737
|
+
return false;
|
|
18738
|
+
}
|
|
18739
|
+
const triggerSignal = typeof input?.__signal === "string" ? input.__signal.trim() : "";
|
|
18740
|
+
const reason = typeof input?.__reason === "string" ? input.__reason.trim() : "";
|
|
18741
|
+
if (!triggerSignal) {
|
|
18742
|
+
return input?.__bootstrapFullSync === true || reason.length > 0;
|
|
18743
|
+
}
|
|
18744
|
+
return triggerSignal === "meta.sync_controller.sync_tick" || triggerSignal === "meta.sync_requested";
|
|
18745
|
+
}
|
|
18392
18746
|
function isRegistrableRoutine(routine) {
|
|
18393
18747
|
return routine?.name !== "RestServer";
|
|
18394
18748
|
}
|
|
18395
18749
|
function scheduleSyncPassEvaluation(delayMs = SYNC_PASS_SETTLE_DELAY_MS) {
|
|
18396
18750
|
CadenzaService.debounce(SYNC_PASS_EVALUATION_SIGNAL, {}, delayMs);
|
|
18397
18751
|
}
|
|
18752
|
+
function isRoutingCriticalMetaSignalName(signalName) {
|
|
18753
|
+
return ROUTING_CRITICAL_META_SIGNALS2.has(canonicalizeSignalName2(signalName));
|
|
18754
|
+
}
|
|
18755
|
+
function isRoutingCriticalMetaIntentName(intentName) {
|
|
18756
|
+
return ROUTING_CRITICAL_META_INTENTS2.has(String(intentName ?? "").trim());
|
|
18757
|
+
}
|
|
18758
|
+
function isRoutingCapabilityBootstrapSignalName(signalName) {
|
|
18759
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18760
|
+
if (!canonicalSignalName) {
|
|
18761
|
+
return false;
|
|
18762
|
+
}
|
|
18763
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
18764
|
+
if (!signalParts.isGlobal) {
|
|
18765
|
+
return false;
|
|
18766
|
+
}
|
|
18767
|
+
if (signalParts.isMeta) {
|
|
18768
|
+
return isRoutingCriticalMetaSignalName(canonicalSignalName);
|
|
18769
|
+
}
|
|
18770
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
18771
|
+
}
|
|
18772
|
+
function isRouteableBusinessBootstrapSignalName(signalName) {
|
|
18773
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18774
|
+
if (!canonicalSignalName) {
|
|
18775
|
+
return false;
|
|
18776
|
+
}
|
|
18777
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
18778
|
+
if (!signalParts.isGlobal || signalParts.isMeta) {
|
|
18779
|
+
return false;
|
|
18780
|
+
}
|
|
18781
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
18782
|
+
}
|
|
18783
|
+
function isRouteableBusinessBootstrapIntentName(intentName) {
|
|
18784
|
+
const normalizedIntentName = String(intentName ?? "").trim();
|
|
18785
|
+
return normalizedIntentName.length > 0 && !isLocalOnlySyncIntent(normalizedIntentName) && !isMetaIntentName(normalizedIntentName);
|
|
18786
|
+
}
|
|
18787
|
+
function isRoutingCapabilityBootstrapTask(task) {
|
|
18788
|
+
if (!task || !task.register || task.isHidden || task.isDeputy) {
|
|
18789
|
+
return false;
|
|
18790
|
+
}
|
|
18791
|
+
const isMetaTask = task.isMeta === true || task.isSubMeta === true;
|
|
18792
|
+
for (const signalName of task.observedSignals) {
|
|
18793
|
+
if (isMetaTask ? isRoutingCriticalMetaSignalName(signalName) : isRouteableBusinessBootstrapSignalName(signalName)) {
|
|
18794
|
+
return true;
|
|
18795
|
+
}
|
|
18796
|
+
}
|
|
18797
|
+
for (const intentName of task.handlesIntents) {
|
|
18798
|
+
if (isMetaTask ? isRoutingCriticalMetaIntentName(intentName) : isRouteableBusinessBootstrapIntentName(intentName)) {
|
|
18799
|
+
return true;
|
|
18800
|
+
}
|
|
18801
|
+
}
|
|
18802
|
+
return false;
|
|
18803
|
+
}
|
|
18804
|
+
function shouldDirectSyncSignalTaskMapForBootstrap(task, signalName) {
|
|
18805
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18806
|
+
if (!task || !canonicalSignalName || task.isHidden || !task.register || !task.registered) {
|
|
18807
|
+
return false;
|
|
18808
|
+
}
|
|
18809
|
+
if (!decomposeSignalName(canonicalSignalName).isGlobal) {
|
|
18810
|
+
return false;
|
|
18811
|
+
}
|
|
18812
|
+
if (!isRegistrableBootstrapTask(task)) {
|
|
18813
|
+
return false;
|
|
18814
|
+
}
|
|
18815
|
+
return isRoutingCapabilityBootstrapSignalName(canonicalSignalName);
|
|
18816
|
+
}
|
|
18817
|
+
function isRegistrableBootstrapTask(task) {
|
|
18818
|
+
return isRoutingCapabilityBootstrapTask(task);
|
|
18819
|
+
}
|
|
18398
18820
|
function getRegistrableTasks() {
|
|
18399
18821
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
18400
|
-
|
|
18822
|
+
isRegistrableBootstrapTask
|
|
18401
18823
|
);
|
|
18402
18824
|
}
|
|
18403
18825
|
function getBootstrapBlockingTasks() {
|
|
18404
|
-
return getRegistrableTasks()
|
|
18826
|
+
return getRegistrableTasks();
|
|
18405
18827
|
}
|
|
18406
18828
|
function getRegistrableRoutines() {
|
|
18407
|
-
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
18829
|
+
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
18830
|
+
isRegistrableRoutine
|
|
18831
|
+
);
|
|
18408
18832
|
}
|
|
18409
18833
|
function getRegistrableSignalObservers() {
|
|
18410
18834
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
@@ -18414,19 +18838,23 @@ function getRegistrableSignalObservers() {
|
|
|
18414
18838
|
const canonicalObservers = /* @__PURE__ */ new Map();
|
|
18415
18839
|
for (const [rawSignalName, observer] of signalObservers.entries()) {
|
|
18416
18840
|
const signalName = canonicalizeSignalName2(rawSignalName);
|
|
18417
|
-
|
|
18841
|
+
const isRoutingCriticalMetaSignal2 = signalName.length > 0 && isRoutingCriticalMetaSignalName(signalName);
|
|
18842
|
+
if (!signalName || isBootstrapLocalOnlySignal(signalName) && !isRoutingCriticalMetaSignal2) {
|
|
18843
|
+
continue;
|
|
18844
|
+
}
|
|
18845
|
+
if (!decomposeSignalName(signalName).isGlobal) {
|
|
18418
18846
|
continue;
|
|
18419
18847
|
}
|
|
18420
18848
|
const observerTasks = Array.isArray(observer?.tasks) ? observer.tasks : observer?.tasks instanceof Set ? Array.from(observer.tasks) : [];
|
|
18421
|
-
if (observerTasks.length > 0 && !observerTasks.some(
|
|
18422
|
-
(task) => task?.register && !task.isHidden && !task.isDeputy
|
|
18423
|
-
)) {
|
|
18849
|
+
if (observerTasks.length > 0 && !observerTasks.some((task) => isRegistrableBootstrapTask(task))) {
|
|
18424
18850
|
continue;
|
|
18425
18851
|
}
|
|
18852
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
18426
18853
|
const existing = canonicalObservers.get(signalName);
|
|
18427
18854
|
canonicalObservers.set(signalName, {
|
|
18428
18855
|
signalName,
|
|
18429
|
-
registered: existing?.registered === true || observer?.registered === true
|
|
18856
|
+
registered: existing?.registered === true || observer?.registered === true,
|
|
18857
|
+
metadata: existing?.metadata ?? metadata
|
|
18430
18858
|
});
|
|
18431
18859
|
}
|
|
18432
18860
|
return Array.from(canonicalObservers.values());
|
|
@@ -18437,7 +18865,10 @@ function isLocallyHandledIntentName(intentName) {
|
|
|
18437
18865
|
return false;
|
|
18438
18866
|
}
|
|
18439
18867
|
for (const task of observer.tasks) {
|
|
18440
|
-
if (
|
|
18868
|
+
if (!task) {
|
|
18869
|
+
continue;
|
|
18870
|
+
}
|
|
18871
|
+
if (isRegistrableBootstrapTask(task)) {
|
|
18441
18872
|
return true;
|
|
18442
18873
|
}
|
|
18443
18874
|
}
|
|
@@ -18468,8 +18899,12 @@ function buildActorRegistrationKey(actor, serviceName) {
|
|
|
18468
18899
|
return `${name}|${data.version}|${serviceName}`;
|
|
18469
18900
|
}
|
|
18470
18901
|
function isBootstrapRegistrableActor(actor) {
|
|
18471
|
-
const
|
|
18472
|
-
|
|
18902
|
+
const actorData = buildActorRegistrationData(actor);
|
|
18903
|
+
const actorName = String(actorData.name ?? "").trim();
|
|
18904
|
+
if (!actorName || isBootstrapLocalOnlyActorName(actorName)) {
|
|
18905
|
+
return false;
|
|
18906
|
+
}
|
|
18907
|
+
return false;
|
|
18473
18908
|
}
|
|
18474
18909
|
function buildSignalTaskMapRegistrationKey(input) {
|
|
18475
18910
|
return `${canonicalizeSignalName2(input.signalName)}|${input.serviceName}|${input.taskName}|${input.taskVersion ?? 1}`;
|
|
@@ -18636,6 +19071,7 @@ function resolveSignalNameFromSyncContext(ctx) {
|
|
|
18636
19071
|
var GraphSyncController = class _GraphSyncController {
|
|
18637
19072
|
constructor() {
|
|
18638
19073
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
19074
|
+
this.requestedActorRegistrations = /* @__PURE__ */ new Set();
|
|
18639
19075
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
18640
19076
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
18641
19077
|
this.authoritativeSignalTaskMaps = /* @__PURE__ */ new Set();
|
|
@@ -18964,9 +19400,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18964
19400
|
for (const routine of routines) {
|
|
18965
19401
|
if (!isRegistrableRoutine(routine)) continue;
|
|
18966
19402
|
if (routine.registered) continue;
|
|
19403
|
+
if (routine.registrationRequested === true) continue;
|
|
19404
|
+
routine.registrationRequested = true;
|
|
18967
19405
|
this.routinesSynced = false;
|
|
18968
|
-
yield {
|
|
18969
|
-
__syncing: ctx.__syncing,
|
|
19406
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
18970
19407
|
data: {
|
|
18971
19408
|
name: routine.name,
|
|
18972
19409
|
version: routine.version,
|
|
@@ -18975,7 +19412,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18975
19412
|
is_meta: routine.isMeta
|
|
18976
19413
|
},
|
|
18977
19414
|
__routineName: routine.name
|
|
18978
|
-
};
|
|
19415
|
+
});
|
|
18979
19416
|
}
|
|
18980
19417
|
}.bind(this)
|
|
18981
19418
|
);
|
|
@@ -18993,15 +19430,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18993
19430
|
{ concurrency: 30 }
|
|
18994
19431
|
);
|
|
18995
19432
|
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
19433
|
+
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
18996
19434
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19435
|
+
if (routine) {
|
|
19436
|
+
routine.registrationRequested = false;
|
|
19437
|
+
}
|
|
18997
19438
|
return;
|
|
18998
19439
|
}
|
|
18999
19440
|
scheduleSyncPassEvaluation();
|
|
19000
|
-
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
19001
19441
|
if (!routine) {
|
|
19002
19442
|
return true;
|
|
19003
19443
|
}
|
|
19004
19444
|
routine.registered = true;
|
|
19445
|
+
routine.registrationRequested = false;
|
|
19005
19446
|
return true;
|
|
19006
19447
|
}).then(gatherRoutineRegistrationTask);
|
|
19007
19448
|
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
@@ -19028,8 +19469,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19028
19469
|
if (!nextTask?.registered) {
|
|
19029
19470
|
continue;
|
|
19030
19471
|
}
|
|
19031
|
-
yield {
|
|
19032
|
-
__syncing: ctx.__syncing,
|
|
19472
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19033
19473
|
data: {
|
|
19034
19474
|
task_name: nextTask.name,
|
|
19035
19475
|
task_version: nextTask.version,
|
|
@@ -19039,7 +19479,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19039
19479
|
},
|
|
19040
19480
|
__routineName: routine.name,
|
|
19041
19481
|
__taskName: nextTask.name
|
|
19042
|
-
};
|
|
19482
|
+
});
|
|
19043
19483
|
}
|
|
19044
19484
|
}
|
|
19045
19485
|
}
|
|
@@ -19093,7 +19533,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19093
19533
|
signalName: canonicalizeSignalName2(signal.signal),
|
|
19094
19534
|
data: signal.data
|
|
19095
19535
|
})).filter((signal) => {
|
|
19096
|
-
|
|
19536
|
+
const isRoutingCriticalMetaSignal2 = isRoutingCriticalMetaSignalName(signal.signalName);
|
|
19537
|
+
if (!signal.signalName || signal.data?.registered || isBootstrapLocalOnlySignal(signal.signalName) && !isRoutingCriticalMetaSignal2 || signal.data?.metadata?.is_meta === true && !isRoutingCriticalMetaSignal2) {
|
|
19097
19538
|
return false;
|
|
19098
19539
|
}
|
|
19099
19540
|
if (seenSignals.has(signal.signalName)) {
|
|
@@ -19103,10 +19544,20 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19103
19544
|
return true;
|
|
19104
19545
|
}).map((signal) => signal.signalName);
|
|
19105
19546
|
for (const signal of filteredSignals) {
|
|
19547
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19548
|
+
if (!signalObservers?.has(signal)) {
|
|
19549
|
+
CadenzaService.signalBroker.addSignal(signal);
|
|
19550
|
+
}
|
|
19551
|
+
const observer = signalObservers?.get(signal);
|
|
19552
|
+
if (observer?.registrationRequested === true) {
|
|
19553
|
+
continue;
|
|
19554
|
+
}
|
|
19555
|
+
if (observer) {
|
|
19556
|
+
observer.registrationRequested = true;
|
|
19557
|
+
}
|
|
19106
19558
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
19107
19559
|
this.signalsSynced = false;
|
|
19108
|
-
yield {
|
|
19109
|
-
__syncing: ctx.__syncing,
|
|
19560
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19110
19561
|
data: {
|
|
19111
19562
|
name: signal,
|
|
19112
19563
|
is_global: isGlobal,
|
|
@@ -19115,7 +19566,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19115
19566
|
is_meta: isMeta
|
|
19116
19567
|
},
|
|
19117
19568
|
__signal: signal
|
|
19118
|
-
};
|
|
19569
|
+
});
|
|
19119
19570
|
}
|
|
19120
19571
|
}.bind(this)
|
|
19121
19572
|
);
|
|
@@ -19137,21 +19588,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19137
19588
|
(ctx, emit2) => {
|
|
19138
19589
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
19139
19590
|
const signalName = resolveSignalNameFromSyncContext(ctx);
|
|
19591
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19592
|
+
const observer = signalName ? signalObservers?.get(signalName) : void 0;
|
|
19140
19593
|
if (!insertSucceeded) {
|
|
19594
|
+
if (observer) {
|
|
19595
|
+
observer.registrationRequested = false;
|
|
19596
|
+
}
|
|
19141
19597
|
return;
|
|
19142
19598
|
}
|
|
19143
19599
|
scheduleSyncPassEvaluation();
|
|
19144
19600
|
if (!signalName) {
|
|
19145
19601
|
return false;
|
|
19146
19602
|
}
|
|
19147
|
-
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19148
19603
|
if (!signalObservers?.has(signalName)) {
|
|
19149
19604
|
CadenzaService.signalBroker.addSignal(signalName);
|
|
19150
19605
|
}
|
|
19151
|
-
const
|
|
19152
|
-
if (
|
|
19153
|
-
|
|
19154
|
-
|
|
19606
|
+
const resolvedObserver = signalObservers?.get(signalName);
|
|
19607
|
+
if (resolvedObserver) {
|
|
19608
|
+
resolvedObserver.registered = true;
|
|
19609
|
+
resolvedObserver.registrationRequested = false;
|
|
19155
19610
|
}
|
|
19156
19611
|
emit2(
|
|
19157
19612
|
"meta.sync_controller.signal_registered",
|
|
@@ -19231,8 +19686,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19231
19686
|
return;
|
|
19232
19687
|
}
|
|
19233
19688
|
for (const task of tasks) {
|
|
19234
|
-
if (
|
|
19689
|
+
if (!task) {
|
|
19690
|
+
continue;
|
|
19691
|
+
}
|
|
19692
|
+
if (!isRegistrableBootstrapTask(task)) continue;
|
|
19235
19693
|
if (task.registered) continue;
|
|
19694
|
+
if (task.registrationRequested === true) continue;
|
|
19695
|
+
task.registrationRequested = true;
|
|
19236
19696
|
const { __functionString, __getTagCallback } = task.export();
|
|
19237
19697
|
this.tasksSynced = false;
|
|
19238
19698
|
const taskRegistrationData = sanitizePersistedTaskSourceFields(task, {
|
|
@@ -19267,11 +19727,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19267
19727
|
},
|
|
19268
19728
|
intents: Array.from(task.handlesIntents)
|
|
19269
19729
|
});
|
|
19270
|
-
yield {
|
|
19271
|
-
__syncing: ctx.__syncing,
|
|
19730
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19272
19731
|
data: taskRegistrationData,
|
|
19273
19732
|
__taskName: task.name
|
|
19274
|
-
};
|
|
19733
|
+
});
|
|
19275
19734
|
}
|
|
19276
19735
|
}.bind(this)
|
|
19277
19736
|
);
|
|
@@ -19292,9 +19751,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19292
19751
|
"Record registration",
|
|
19293
19752
|
(ctx, emit2) => {
|
|
19294
19753
|
const task = resolveLocalTaskFromSyncContext(ctx);
|
|
19295
|
-
const serviceName2 = resolveSyncServiceName(task);
|
|
19296
19754
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
19297
19755
|
if (!insertSucceeded) {
|
|
19756
|
+
if (task) {
|
|
19757
|
+
task.registrationRequested = false;
|
|
19758
|
+
}
|
|
19298
19759
|
return;
|
|
19299
19760
|
}
|
|
19300
19761
|
scheduleSyncPassEvaluation();
|
|
@@ -19336,11 +19797,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19336
19797
|
if (this.registeredActors.has(registrationKey)) {
|
|
19337
19798
|
continue;
|
|
19338
19799
|
}
|
|
19800
|
+
if (this.requestedActorRegistrations.has(registrationKey)) {
|
|
19801
|
+
continue;
|
|
19802
|
+
}
|
|
19803
|
+
this.requestedActorRegistrations.add(registrationKey);
|
|
19339
19804
|
this.actorsSynced = false;
|
|
19340
|
-
yield {
|
|
19805
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19341
19806
|
data,
|
|
19342
19807
|
__actorRegistrationKey: registrationKey
|
|
19343
|
-
};
|
|
19808
|
+
});
|
|
19344
19809
|
}
|
|
19345
19810
|
}.bind(this)
|
|
19346
19811
|
);
|
|
@@ -19360,11 +19825,18 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19360
19825
|
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
19361
19826
|
"Record actor registration",
|
|
19362
19827
|
(ctx) => {
|
|
19828
|
+
const registrationKey = typeof ctx.__actorRegistrationKey === "string" ? ctx.__actorRegistrationKey : "";
|
|
19363
19829
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19830
|
+
if (registrationKey) {
|
|
19831
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
19832
|
+
}
|
|
19364
19833
|
return;
|
|
19365
19834
|
}
|
|
19366
19835
|
scheduleSyncPassEvaluation();
|
|
19367
|
-
|
|
19836
|
+
if (registrationKey) {
|
|
19837
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
19838
|
+
this.registeredActors.add(registrationKey);
|
|
19839
|
+
}
|
|
19368
19840
|
return true;
|
|
19369
19841
|
}
|
|
19370
19842
|
).then(gatherActorRegistrationTask);
|
|
@@ -19383,17 +19855,95 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19383
19855
|
}
|
|
19384
19856
|
);
|
|
19385
19857
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
19386
|
-
"
|
|
19387
|
-
()
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19858
|
+
"Register routing-critical signal task maps to DB",
|
|
19859
|
+
function* (ctx) {
|
|
19860
|
+
const task = ctx.task;
|
|
19861
|
+
if (!task) {
|
|
19862
|
+
return;
|
|
19863
|
+
}
|
|
19864
|
+
const serviceName2 = resolveSyncServiceName(task);
|
|
19865
|
+
if (!serviceName2) {
|
|
19866
|
+
return;
|
|
19867
|
+
}
|
|
19868
|
+
for (const signal of task.observedSignals) {
|
|
19869
|
+
const signalName = canonicalizeSignalName2(signal);
|
|
19870
|
+
if (!shouldDirectSyncSignalTaskMapForBootstrap(task, signalName)) {
|
|
19871
|
+
continue;
|
|
19872
|
+
}
|
|
19873
|
+
if (task.registeredSignals.has(signalName)) {
|
|
19874
|
+
continue;
|
|
19875
|
+
}
|
|
19876
|
+
const registrationKey = buildSignalTaskMapRegistrationKey({
|
|
19877
|
+
signalName,
|
|
19878
|
+
serviceName: serviceName2,
|
|
19879
|
+
taskName: task.name,
|
|
19880
|
+
taskVersion: task.version
|
|
19881
|
+
});
|
|
19882
|
+
if (this.authoritativeSignalTaskMaps.has(registrationKey)) {
|
|
19883
|
+
continue;
|
|
19884
|
+
}
|
|
19885
|
+
if (!CadenzaService.signalBroker.signalObservers?.get(signalName)?.registered) {
|
|
19886
|
+
continue;
|
|
19887
|
+
}
|
|
19888
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19889
|
+
data: {
|
|
19890
|
+
signal_name: signalName,
|
|
19891
|
+
is_global: true,
|
|
19892
|
+
task_name: task.name,
|
|
19893
|
+
task_version: task.version,
|
|
19894
|
+
service_name: serviceName2
|
|
19895
|
+
},
|
|
19896
|
+
__taskName: task.name,
|
|
19897
|
+
__signalName: signalName
|
|
19898
|
+
});
|
|
19899
|
+
}
|
|
19900
|
+
}.bind(this),
|
|
19901
|
+
"Routing-critical meta signal-task maps are persisted during bootstrap so authority can route required control-plane signals before deferred manifest replay completes.",
|
|
19392
19902
|
{
|
|
19393
19903
|
register: false,
|
|
19394
19904
|
isHidden: true
|
|
19395
19905
|
}
|
|
19396
19906
|
);
|
|
19907
|
+
const signalTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
19908
|
+
this.isCadenzaDBReady,
|
|
19909
|
+
"signal_to_task_map",
|
|
19910
|
+
{
|
|
19911
|
+
onConflict: {
|
|
19912
|
+
target: [
|
|
19913
|
+
"signal_name",
|
|
19914
|
+
"is_global",
|
|
19915
|
+
"task_name",
|
|
19916
|
+
"task_version",
|
|
19917
|
+
"service_name"
|
|
19918
|
+
],
|
|
19919
|
+
action: {
|
|
19920
|
+
do: "nothing"
|
|
19921
|
+
}
|
|
19922
|
+
}
|
|
19923
|
+
},
|
|
19924
|
+
{ concurrency: 30 }
|
|
19925
|
+
);
|
|
19926
|
+
const recordSignalTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
19927
|
+
"Record signal task map registration",
|
|
19928
|
+
(ctx) => {
|
|
19929
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
19930
|
+
return;
|
|
19931
|
+
}
|
|
19932
|
+
scheduleSyncPassEvaluation();
|
|
19933
|
+
const task = CadenzaService.get(ctx.__taskName);
|
|
19934
|
+
const signalName = typeof ctx.__signalName === "string" ? canonicalizeSignalName2(ctx.__signalName) : "";
|
|
19935
|
+
if (!task || !signalName) {
|
|
19936
|
+
return true;
|
|
19937
|
+
}
|
|
19938
|
+
task.registeredSignals.add(signalName);
|
|
19939
|
+
return true;
|
|
19940
|
+
}
|
|
19941
|
+
);
|
|
19942
|
+
wireSyncTaskGraph(
|
|
19943
|
+
this.registerSignalToTaskMapTask,
|
|
19944
|
+
signalTaskMapRegistrationGraph,
|
|
19945
|
+
recordSignalTaskMapRegistrationTask
|
|
19946
|
+
);
|
|
19397
19947
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
19398
19948
|
"Split intents for registration",
|
|
19399
19949
|
function* (ctx) {
|
|
@@ -19409,25 +19959,31 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19409
19959
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
19410
19960
|
continue;
|
|
19411
19961
|
}
|
|
19962
|
+
if (intent.registrationRequested === true) {
|
|
19963
|
+
continue;
|
|
19964
|
+
}
|
|
19965
|
+
intent.registrationRequested = true;
|
|
19412
19966
|
this.intentsSynced = false;
|
|
19413
|
-
yield {
|
|
19414
|
-
__syncing: ctx.__syncing,
|
|
19967
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19415
19968
|
data: intentData,
|
|
19416
19969
|
__intentName: intentData.name
|
|
19417
|
-
};
|
|
19970
|
+
});
|
|
19418
19971
|
}
|
|
19419
19972
|
}.bind(this)
|
|
19420
19973
|
);
|
|
19421
19974
|
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
19422
19975
|
"Record intent definition registration",
|
|
19423
19976
|
(ctx, emit2) => {
|
|
19977
|
+
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
19978
|
+
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
19424
19979
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19980
|
+
if (intentDefinition) {
|
|
19981
|
+
intentDefinition.registrationRequested = false;
|
|
19982
|
+
}
|
|
19425
19983
|
return;
|
|
19426
19984
|
}
|
|
19427
19985
|
scheduleSyncPassEvaluation();
|
|
19428
|
-
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
19429
19986
|
this.registeredIntentDefinitions.add(intentName);
|
|
19430
|
-
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
19431
19987
|
if (intentDefinition) {
|
|
19432
19988
|
intentDefinition.registered = true;
|
|
19433
19989
|
intentDefinition.registrationRequested = false;
|
|
@@ -19687,6 +20243,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19687
20243
|
"Register task map to DB",
|
|
19688
20244
|
function* (ctx) {
|
|
19689
20245
|
const task = ctx.task;
|
|
20246
|
+
if (!task) {
|
|
20247
|
+
return;
|
|
20248
|
+
}
|
|
19690
20249
|
if (task.hidden || !task.register || task.isDeputy || !task.registered) {
|
|
19691
20250
|
return;
|
|
19692
20251
|
}
|
|
@@ -19695,6 +20254,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19695
20254
|
return;
|
|
19696
20255
|
}
|
|
19697
20256
|
for (const t of task.nextTasks) {
|
|
20257
|
+
if (!t) {
|
|
20258
|
+
continue;
|
|
20259
|
+
}
|
|
19698
20260
|
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
19699
20261
|
continue;
|
|
19700
20262
|
}
|
|
@@ -19702,7 +20264,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19702
20264
|
if (!serviceName2) {
|
|
19703
20265
|
continue;
|
|
19704
20266
|
}
|
|
19705
|
-
yield {
|
|
20267
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19706
20268
|
data: {
|
|
19707
20269
|
task_name: t.name,
|
|
19708
20270
|
task_version: t.version,
|
|
@@ -19713,7 +20275,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19713
20275
|
},
|
|
19714
20276
|
__taskName: task.name,
|
|
19715
20277
|
__nextTaskName: t.name
|
|
19716
|
-
};
|
|
20278
|
+
});
|
|
19717
20279
|
}
|
|
19718
20280
|
}
|
|
19719
20281
|
);
|
|
@@ -20301,19 +20863,6 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20301
20863
|
if (!ServiceRegistry.instance.hasLocalInstanceRegistered()) {
|
|
20302
20864
|
return false;
|
|
20303
20865
|
}
|
|
20304
|
-
if (ctx.__bootstrapFullSync === true) {
|
|
20305
|
-
if (shouldTraceSyncPhase(serviceName2)) {
|
|
20306
|
-
console.log(
|
|
20307
|
-
"[CADENZA_SYNC_PHASE_TRACE] sync_cycle_ignored_bootstrap_full_sync",
|
|
20308
|
-
{
|
|
20309
|
-
serviceName: serviceName2,
|
|
20310
|
-
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
20311
|
-
attempt: typeof ctx.__bootstrapFullSyncAttempt === "number" ? ctx.__bootstrapFullSyncAttempt : void 0
|
|
20312
|
-
}
|
|
20313
|
-
);
|
|
20314
|
-
}
|
|
20315
|
-
return false;
|
|
20316
|
-
}
|
|
20317
20866
|
if (state.activeSyncCycleId) {
|
|
20318
20867
|
const activeCycleAgeMs = now - state.activeSyncCycleStartedAt;
|
|
20319
20868
|
if (activeCycleAgeMs < BOOTSTRAP_SYNC_STALE_CYCLE_MS) {
|
|
@@ -20340,6 +20889,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20340
20889
|
});
|
|
20341
20890
|
}
|
|
20342
20891
|
}
|
|
20892
|
+
const primitivePendingSummary = buildPrimitivePendingSummary();
|
|
20893
|
+
const mapPendingSummary = buildMapPendingSummary();
|
|
20894
|
+
const hasPendingWork = hasNonZeroPending(primitivePendingSummary) || hasNonZeroPending(mapPendingSummary);
|
|
20895
|
+
if (!hasPendingWork && shouldSkipIdleBootstrapSyncTrigger(ctx)) {
|
|
20896
|
+
if (shouldTraceSyncPhase(serviceName2)) {
|
|
20897
|
+
console.log("[CADENZA_SYNC_PHASE_TRACE] sync_cycle_skipped_idle", {
|
|
20898
|
+
serviceName: serviceName2,
|
|
20899
|
+
triggerSignal: typeof ctx.__signal === "string" ? ctx.__signal : void 0,
|
|
20900
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0
|
|
20901
|
+
});
|
|
20902
|
+
}
|
|
20903
|
+
return false;
|
|
20904
|
+
}
|
|
20343
20905
|
const syncCycleId = `${now}-${(0, import_uuid7.v4)()}`;
|
|
20344
20906
|
setRuntimeState({
|
|
20345
20907
|
activeSyncCycleId: syncCycleId,
|
|
@@ -20448,22 +21010,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20448
21010
|
const getSignalsForSyncTask = CadenzaService.createMetaTask(
|
|
20449
21011
|
"Get signals for sync",
|
|
20450
21012
|
(ctx) => {
|
|
20451
|
-
const
|
|
20452
|
-
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
21013
|
+
const canonicalSignals = /* @__PURE__ */ new Map();
|
|
21014
|
+
for (const observer of getRegistrableSignalObservers()) {
|
|
21015
|
+
const signalName = canonicalizeSignalName2(observer.signalName);
|
|
21016
|
+
if (!signalName || signalName.includes(":")) {
|
|
21017
|
+
continue;
|
|
21018
|
+
}
|
|
21019
|
+
canonicalSignals.set(signalName, {
|
|
21020
|
+
signal: signalName,
|
|
21021
|
+
data: {
|
|
21022
|
+
registered: observer.registered ?? false,
|
|
21023
|
+
metadata: observer.metadata ?? null
|
|
21024
|
+
}
|
|
21025
|
+
});
|
|
21026
|
+
}
|
|
21027
|
+
for (const emittedSignal of CadenzaService.signalBroker.emittedSignalsRegistry) {
|
|
21028
|
+
const signalName = canonicalizeSignalName2(emittedSignal);
|
|
21029
|
+
if (!signalName || signalName.includes(":")) {
|
|
21030
|
+
continue;
|
|
21031
|
+
}
|
|
21032
|
+
if (canonicalSignals.has(signalName)) {
|
|
21033
|
+
continue;
|
|
20462
21034
|
}
|
|
20463
|
-
|
|
21035
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
21036
|
+
if (metadata?.is_meta === true || isBootstrapLocalOnlySignal(signalName)) {
|
|
21037
|
+
continue;
|
|
21038
|
+
}
|
|
21039
|
+
canonicalSignals.set(signalName, {
|
|
21040
|
+
signal: signalName,
|
|
21041
|
+
data: {
|
|
21042
|
+
registered: CadenzaService.signalBroker.signalObservers.get(signalName)?.registered ?? false,
|
|
21043
|
+
metadata
|
|
21044
|
+
}
|
|
21045
|
+
});
|
|
21046
|
+
}
|
|
20464
21047
|
return {
|
|
20465
21048
|
...ctx,
|
|
20466
|
-
signals:
|
|
21049
|
+
signals: Array.from(canonicalSignals.values())
|
|
20467
21050
|
};
|
|
20468
21051
|
},
|
|
20469
21052
|
"Collects local signals for the primitive sync phase.",
|
|
@@ -20500,9 +21083,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20500
21083
|
"Get all actors for sync",
|
|
20501
21084
|
(ctx) => ({
|
|
20502
21085
|
...ctx,
|
|
20503
|
-
actors:
|
|
21086
|
+
actors: []
|
|
20504
21087
|
}),
|
|
20505
|
-
"
|
|
21088
|
+
"Actor definitions are staged through service-manifest publication rather than the bootstrap primitive sync phase.",
|
|
20506
21089
|
{
|
|
20507
21090
|
register: false,
|
|
20508
21091
|
isHidden: true
|
|
@@ -20534,7 +21117,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20534
21117
|
"Iterate tasks for directional task map sync",
|
|
20535
21118
|
function* (ctx) {
|
|
20536
21119
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20537
|
-
yield
|
|
21120
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20538
21121
|
}
|
|
20539
21122
|
},
|
|
20540
21123
|
"Iterates local tasks for directional task-map sync.",
|
|
@@ -20553,7 +21136,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20553
21136
|
"Iterate tasks for signal task map sync",
|
|
20554
21137
|
function* (ctx) {
|
|
20555
21138
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20556
|
-
yield
|
|
21139
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20557
21140
|
}
|
|
20558
21141
|
},
|
|
20559
21142
|
"Iterates local tasks for signal-to-task map sync.",
|
|
@@ -20567,12 +21150,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20567
21150
|
gatherSignalTaskMapRegistrationTask
|
|
20568
21151
|
);
|
|
20569
21152
|
iterateTasksForSignalTaskMapSyncTask.then(this.registerSignalToTaskMapTask);
|
|
20570
|
-
|
|
21153
|
+
recordSignalTaskMapRegistrationTask.then(gatherSignalTaskMapRegistrationTask);
|
|
20571
21154
|
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
20572
21155
|
"Iterate tasks for intent task map sync",
|
|
20573
21156
|
function* (ctx) {
|
|
20574
21157
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20575
|
-
yield
|
|
21158
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20576
21159
|
}
|
|
20577
21160
|
},
|
|
20578
21161
|
"Iterates local tasks for intent-to-task map sync.",
|
|
@@ -20591,7 +21174,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20591
21174
|
"Iterate tasks for actor task map sync",
|
|
20592
21175
|
function* (ctx) {
|
|
20593
21176
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20594
|
-
yield
|
|
21177
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20595
21178
|
}
|
|
20596
21179
|
},
|
|
20597
21180
|
"Iterates local tasks for actor-to-task map sync.",
|
|
@@ -20724,7 +21307,7 @@ function sanitizePersistedTaskSourceFields2(task, data) {
|
|
|
20724
21307
|
};
|
|
20725
21308
|
}
|
|
20726
21309
|
function shouldSkipDirectTaskMetadata(task) {
|
|
20727
|
-
return !task || !task.register || task.isHidden || task.isDeputy;
|
|
21310
|
+
return !task || !task.register || task.isHidden || task.isDeputy || task.isMeta || task.isSubMeta;
|
|
20728
21311
|
}
|
|
20729
21312
|
function isManagedRouteRecoveryTaskError(errorMessage2) {
|
|
20730
21313
|
if (typeof errorMessage2 !== "string") {
|
|
@@ -20738,7 +21321,10 @@ function isLocallyHandledIntentName2(intentName) {
|
|
|
20738
21321
|
return false;
|
|
20739
21322
|
}
|
|
20740
21323
|
for (const task of observer.tasks) {
|
|
20741
|
-
if (
|
|
21324
|
+
if (!task) {
|
|
21325
|
+
continue;
|
|
21326
|
+
}
|
|
21327
|
+
if (task.register && !task.isHidden && !task.isDeputy && !task.isMeta && !task.isSubMeta) {
|
|
20742
21328
|
return true;
|
|
20743
21329
|
}
|
|
20744
21330
|
}
|
|
@@ -20977,7 +21563,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
20977
21563
|
return false;
|
|
20978
21564
|
}
|
|
20979
21565
|
const helper = resolveHelperFromMetadataContext(ctx);
|
|
20980
|
-
if (!helper) {
|
|
21566
|
+
if (!helper || helper.isMeta) {
|
|
20981
21567
|
return false;
|
|
20982
21568
|
}
|
|
20983
21569
|
return buildDatabaseTriggerContext({
|
|
@@ -20992,7 +21578,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
20992
21578
|
return false;
|
|
20993
21579
|
}
|
|
20994
21580
|
const globalDefinition = resolveGlobalFromMetadataContext(ctx);
|
|
20995
|
-
if (!globalDefinition) {
|
|
21581
|
+
if (!globalDefinition || globalDefinition.isMeta) {
|
|
20996
21582
|
return false;
|
|
20997
21583
|
}
|
|
20998
21584
|
return buildDatabaseTriggerContext({
|
|
@@ -21094,6 +21680,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21094
21680
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21095
21681
|
return false;
|
|
21096
21682
|
}
|
|
21683
|
+
if (ctx.data?.isMeta === true) {
|
|
21684
|
+
return false;
|
|
21685
|
+
}
|
|
21097
21686
|
return buildDatabaseTriggerContext({
|
|
21098
21687
|
...ctx.data,
|
|
21099
21688
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
@@ -21103,6 +21692,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21103
21692
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21104
21693
|
return false;
|
|
21105
21694
|
}
|
|
21695
|
+
if (ctx.data?.isMeta === true) {
|
|
21696
|
+
return false;
|
|
21697
|
+
}
|
|
21106
21698
|
return buildDatabaseTriggerContext(
|
|
21107
21699
|
ctx.data ?? void 0,
|
|
21108
21700
|
{
|
|
@@ -21771,6 +22363,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21771
22363
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21772
22364
|
return false;
|
|
21773
22365
|
}
|
|
22366
|
+
if (ctx.data?.is_meta === true) {
|
|
22367
|
+
return false;
|
|
22368
|
+
}
|
|
21774
22369
|
if (shouldSkipDirectActorMetadata(ctx?.data?.name)) {
|
|
21775
22370
|
return false;
|
|
21776
22371
|
}
|
|
@@ -21783,6 +22378,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21783
22378
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21784
22379
|
return false;
|
|
21785
22380
|
}
|
|
22381
|
+
if (ctx.data?.is_meta === true) {
|
|
22382
|
+
return false;
|
|
22383
|
+
}
|
|
21786
22384
|
if (shouldSkipDirectActorMetadata(ctx?.data?.actor_name)) {
|
|
21787
22385
|
return false;
|
|
21788
22386
|
}
|
|
@@ -22248,6 +22846,8 @@ function resetBrowserRuntimeActorHandles() {
|
|
|
22248
22846
|
|
|
22249
22847
|
// src/Cadenza.ts
|
|
22250
22848
|
var POSTGRES_SETUP_DEBUG_ENABLED2 = process.env.CADENZA_POSTGRES_SETUP_DEBUG === "1" || process.env.CADENZA_POSTGRES_SETUP_DEBUG === "true";
|
|
22849
|
+
var DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 15e3;
|
|
22850
|
+
var LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 6e4;
|
|
22251
22851
|
function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE__ */ new Set()) {
|
|
22252
22852
|
if (depth < 0 || value === null || value === void 0) {
|
|
22253
22853
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
@@ -22309,6 +22909,10 @@ var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
|
22309
22909
|
"business_structural",
|
|
22310
22910
|
"local_meta_structural"
|
|
22311
22911
|
];
|
|
22912
|
+
var ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS = 250;
|
|
22913
|
+
var BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 1500;
|
|
22914
|
+
var LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 15e3;
|
|
22915
|
+
var MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS = 1e3;
|
|
22312
22916
|
function getServiceManifestPublicationLayerRank(layer) {
|
|
22313
22917
|
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
22314
22918
|
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
@@ -22442,43 +23046,250 @@ var CadenzaService = class {
|
|
|
22442
23046
|
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
22443
23047
|
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
22444
23048
|
}
|
|
23049
|
+
static clampServiceManifestPublicationLayer(targetLayer) {
|
|
23050
|
+
const maximumLayer = this.isLocalAuthorityService() ? "routing_capability" : "local_meta_structural";
|
|
23051
|
+
return getServiceManifestPublicationLayerRank(targetLayer) > getServiceManifestPublicationLayerRank(maximumLayer) ? maximumLayer : targetLayer;
|
|
23052
|
+
}
|
|
22445
23053
|
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
22446
23054
|
this.serviceManifestPublicationPendingReason = reason;
|
|
23055
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22447
23056
|
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
22448
|
-
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(
|
|
23057
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? normalizedTargetLayer : currentTargetLayer;
|
|
23058
|
+
}
|
|
23059
|
+
static getServiceManifestPublicationGate(publicationLayer) {
|
|
23060
|
+
if (!this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
23061
|
+
return {
|
|
23062
|
+
ready: false,
|
|
23063
|
+
delayMs: ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS
|
|
23064
|
+
};
|
|
23065
|
+
}
|
|
23066
|
+
if (publicationLayer === "routing_capability") {
|
|
23067
|
+
return {
|
|
23068
|
+
ready: true,
|
|
23069
|
+
delayMs: 0
|
|
23070
|
+
};
|
|
23071
|
+
}
|
|
23072
|
+
if (!this.bootstrapSyncCompleted || this.bootstrapSyncCompletedAt <= 0) {
|
|
23073
|
+
return {
|
|
23074
|
+
ready: false,
|
|
23075
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
23076
|
+
};
|
|
23077
|
+
}
|
|
23078
|
+
const now = Date.now();
|
|
23079
|
+
if (publicationLayer === "business_structural") {
|
|
23080
|
+
const allowedAt2 = this.bootstrapSyncCompletedAt + BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
23081
|
+
return {
|
|
23082
|
+
ready: now >= allowedAt2,
|
|
23083
|
+
delayMs: Math.max(1, allowedAt2 - now)
|
|
23084
|
+
};
|
|
23085
|
+
}
|
|
23086
|
+
const businessPublishedAt = this.serviceManifestPublishedAt.business_structural ?? 0;
|
|
23087
|
+
if (!this.lastPublishedServiceManifestHashes.business_structural || businessPublishedAt <= 0) {
|
|
23088
|
+
return {
|
|
23089
|
+
ready: false,
|
|
23090
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
23091
|
+
};
|
|
23092
|
+
}
|
|
23093
|
+
const allowedAt = businessPublishedAt + LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
23094
|
+
return {
|
|
23095
|
+
ready: now >= allowedAt,
|
|
23096
|
+
delayMs: Math.max(1, allowedAt - now)
|
|
23097
|
+
};
|
|
22449
23098
|
}
|
|
22450
23099
|
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
22451
23100
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22452
23101
|
return;
|
|
22453
23102
|
}
|
|
23103
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22454
23104
|
const signalName = "meta.service_manifest.publish_requested";
|
|
22455
23105
|
const payload = {
|
|
22456
23106
|
__reason: reason,
|
|
22457
23107
|
__serviceName: this.serviceRegistry.serviceName,
|
|
22458
23108
|
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
22459
|
-
__publicationLayer:
|
|
23109
|
+
__publicationLayer: normalizedTargetLayer
|
|
22460
23110
|
};
|
|
22461
23111
|
if (immediate) {
|
|
22462
|
-
this.
|
|
23112
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
23113
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
23114
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
23115
|
+
}
|
|
23116
|
+
void this.publishServiceManifestIfNeeded(reason, normalizedTargetLayer);
|
|
22463
23117
|
return;
|
|
22464
23118
|
}
|
|
22465
23119
|
this.debounce(signalName, payload, 100);
|
|
22466
23120
|
}
|
|
22467
|
-
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
23121
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural", options) {
|
|
22468
23122
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22469
23123
|
return;
|
|
22470
23124
|
}
|
|
23125
|
+
this.serviceManifestPublicationRetryReason = reason;
|
|
23126
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
23127
|
+
const currentRetryLayer = this.serviceManifestPublicationRetryLayer ?? "routing_capability";
|
|
23128
|
+
this.serviceManifestPublicationRetryLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentRetryLayer) ? normalizedTargetLayer : currentRetryLayer;
|
|
23129
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
23130
|
+
return;
|
|
23131
|
+
}
|
|
23132
|
+
const retryReason = this.serviceManifestPublicationRetryReason ?? reason;
|
|
23133
|
+
const retryTargetLayer = this.serviceManifestPublicationRetryLayer ?? targetLayer;
|
|
23134
|
+
const shouldIncrementRetryCount = options?.incrementRetryCount !== false;
|
|
23135
|
+
const delayMs = options?.delayMs ?? Math.min(
|
|
23136
|
+
1e4,
|
|
23137
|
+
1e3 * Math.max(1, 2 ** this.serviceManifestPublicationRetryCount)
|
|
23138
|
+
);
|
|
23139
|
+
if (shouldIncrementRetryCount) {
|
|
23140
|
+
this.serviceManifestPublicationRetryCount += 1;
|
|
23141
|
+
}
|
|
23142
|
+
this.serviceManifestPublicationRetryTimer = setTimeout(() => {
|
|
23143
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
23144
|
+
const pendingReason = this.serviceManifestPublicationRetryReason ?? retryReason;
|
|
23145
|
+
const pendingLayer = this.serviceManifestPublicationRetryLayer ?? retryTargetLayer;
|
|
23146
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
23147
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
23148
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
23149
|
+
}, delayMs);
|
|
23150
|
+
}
|
|
23151
|
+
static shouldPublishBusinessManifestForTaskContext(ctx) {
|
|
23152
|
+
const task = ctx?.taskInstance ?? (typeof ctx?.data?.name === "string" ? this.get(ctx.data.name) : void 0);
|
|
23153
|
+
if (task) {
|
|
23154
|
+
if (this.isRoutingCriticalManifestTask(task)) {
|
|
23155
|
+
return true;
|
|
23156
|
+
}
|
|
23157
|
+
return task.register === true && task.isMeta !== true && task.isSubMeta !== true && task.isHidden !== true && task.isEphemeral !== true;
|
|
23158
|
+
}
|
|
23159
|
+
if (this.hasRoutingCriticalManifestBindingInContext(ctx)) {
|
|
23160
|
+
return true;
|
|
23161
|
+
}
|
|
23162
|
+
return ctx?.data?.isMeta !== true && ctx?.data?.isSubMeta !== true && ctx?.data?.isHidden !== true && ctx?.data?.isEphemeral !== true && ctx?.__isSubMeta !== true;
|
|
23163
|
+
}
|
|
23164
|
+
static isRoutingCriticalManifestSignalName(signalName) {
|
|
23165
|
+
const normalizedSignalName = String(signalName ?? "").trim();
|
|
23166
|
+
if (!normalizedSignalName) {
|
|
23167
|
+
return false;
|
|
23168
|
+
}
|
|
23169
|
+
return normalizedSignalName === EXECUTION_PERSISTENCE_BUNDLE_SIGNAL || isAuthorityBootstrapSignal(normalizedSignalName);
|
|
23170
|
+
}
|
|
23171
|
+
static isRoutingCriticalManifestIntentName(intentName) {
|
|
23172
|
+
return isAuthorityBootstrapIntent(intentName);
|
|
23173
|
+
}
|
|
23174
|
+
static isRoutingCriticalManifestTask(task) {
|
|
23175
|
+
for (const signalName of task.observedSignals ?? []) {
|
|
23176
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
23177
|
+
return true;
|
|
23178
|
+
}
|
|
23179
|
+
}
|
|
23180
|
+
for (const intentName of task.handlesIntents ?? []) {
|
|
23181
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
23182
|
+
return true;
|
|
23183
|
+
}
|
|
23184
|
+
}
|
|
23185
|
+
return false;
|
|
23186
|
+
}
|
|
23187
|
+
static hasRoutingCriticalManifestBindingInContext(ctx) {
|
|
23188
|
+
const signalCandidates = [
|
|
23189
|
+
ctx?.signalName,
|
|
23190
|
+
ctx?.data?.signalName,
|
|
23191
|
+
ctx?.data?.signal_name
|
|
23192
|
+
];
|
|
23193
|
+
for (const signalName of signalCandidates) {
|
|
23194
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
23195
|
+
return true;
|
|
23196
|
+
}
|
|
23197
|
+
}
|
|
23198
|
+
const intentCandidates = [
|
|
23199
|
+
ctx?.intentName,
|
|
23200
|
+
ctx?.data?.intentName,
|
|
23201
|
+
ctx?.data?.intent_name
|
|
23202
|
+
];
|
|
23203
|
+
for (const intentName of intentCandidates) {
|
|
23204
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
23205
|
+
return true;
|
|
23206
|
+
}
|
|
23207
|
+
}
|
|
23208
|
+
return false;
|
|
23209
|
+
}
|
|
23210
|
+
static shouldPublishBusinessManifestForHelperContext(ctx) {
|
|
23211
|
+
const helperName = typeof ctx?.data?.name === "string" ? ctx.data.name : typeof ctx?.data?.helperName === "string" ? ctx.data.helperName : typeof ctx?.data?.dependencyHelperName === "string" ? ctx.data.dependencyHelperName : "";
|
|
23212
|
+
const helper = helperName ? import_core6.default.getHelper(helperName) : void 0;
|
|
23213
|
+
if (helper) {
|
|
23214
|
+
return helper.isMeta !== true;
|
|
23215
|
+
}
|
|
23216
|
+
return ctx?.data?.isMeta !== true;
|
|
23217
|
+
}
|
|
23218
|
+
static shouldPublishBusinessManifestForGlobalContext(ctx) {
|
|
23219
|
+
const globalName = typeof ctx?.data?.name === "string" ? ctx.data.name : typeof ctx?.data?.globalName === "string" ? ctx.data.globalName : "";
|
|
23220
|
+
const globalDefinition = globalName ? import_core6.default.getGlobal(globalName) : void 0;
|
|
23221
|
+
if (globalDefinition) {
|
|
23222
|
+
return globalDefinition.isMeta !== true;
|
|
23223
|
+
}
|
|
23224
|
+
return ctx?.data?.isMeta !== true;
|
|
23225
|
+
}
|
|
23226
|
+
static shouldPublishBusinessManifestForRoutineContext(ctx) {
|
|
23227
|
+
const routineName = typeof ctx?.data?.name === "string" ? ctx.data.name : "";
|
|
23228
|
+
const routine = routineName ? this.getRoutine(routineName) : void 0;
|
|
23229
|
+
if (routine) {
|
|
23230
|
+
return routine.isMeta !== true;
|
|
23231
|
+
}
|
|
23232
|
+
return ctx?.data?.isMeta !== true;
|
|
23233
|
+
}
|
|
23234
|
+
static shouldRequestServiceManifestPublicationForSignal(ctx) {
|
|
23235
|
+
const signalName = typeof ctx?.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal.trim() : "";
|
|
23236
|
+
switch (signalName) {
|
|
23237
|
+
case "meta.task.created":
|
|
23238
|
+
case "meta.task.destroyed":
|
|
23239
|
+
case "meta.task.relationship_added":
|
|
23240
|
+
case "meta.task.relationship_removed":
|
|
23241
|
+
case "meta.task.intent_associated":
|
|
23242
|
+
case "meta.task.helper_associated":
|
|
23243
|
+
case "meta.task.global_associated":
|
|
23244
|
+
case "meta.task.observed_signal":
|
|
23245
|
+
case "meta.task.attached_signal":
|
|
23246
|
+
case "meta.task.detached_signal":
|
|
23247
|
+
return this.shouldPublishBusinessManifestForTaskContext(ctx);
|
|
23248
|
+
case "meta.helper.created":
|
|
23249
|
+
case "meta.helper.updated":
|
|
23250
|
+
case "meta.helper.helper_associated":
|
|
23251
|
+
case "meta.helper.global_associated":
|
|
23252
|
+
return this.shouldPublishBusinessManifestForHelperContext(ctx);
|
|
23253
|
+
case "meta.global.created":
|
|
23254
|
+
case "meta.global.updated":
|
|
23255
|
+
return this.shouldPublishBusinessManifestForGlobalContext(ctx);
|
|
23256
|
+
case "meta.actor.created":
|
|
23257
|
+
case "meta.actor.task_associated":
|
|
23258
|
+
return ctx?.data?.is_meta !== true && ctx?.__isSubMeta !== true;
|
|
23259
|
+
case "global.meta.graph_metadata.routine_created":
|
|
23260
|
+
case "global.meta.graph_metadata.routine_updated":
|
|
23261
|
+
return this.shouldPublishBusinessManifestForRoutineContext(ctx);
|
|
23262
|
+
default:
|
|
23263
|
+
return false;
|
|
23264
|
+
}
|
|
23265
|
+
}
|
|
23266
|
+
static maybeRequestInitialServiceManifestPublication(reason, targetLayer = "business_structural") {
|
|
23267
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId || !this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
23268
|
+
return false;
|
|
23269
|
+
}
|
|
23270
|
+
this.initialServiceManifestPublicationRequested = true;
|
|
23271
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
23272
|
+
return true;
|
|
23273
|
+
}
|
|
23274
|
+
static scheduleInitialServiceManifestPublicationFallback(reason, targetLayer = "business_structural") {
|
|
23275
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
23276
|
+
return;
|
|
23277
|
+
}
|
|
22471
23278
|
setTimeout(() => {
|
|
22472
|
-
this.
|
|
23279
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
23280
|
+
return;
|
|
23281
|
+
}
|
|
23282
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
22473
23283
|
}, 1e3);
|
|
22474
23284
|
}
|
|
22475
23285
|
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
22476
|
-
if (!this.
|
|
23286
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22477
23287
|
return false;
|
|
22478
23288
|
}
|
|
22479
23289
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
23290
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22480
23291
|
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
22481
|
-
|
|
23292
|
+
normalizedTargetLayer
|
|
22482
23293
|
);
|
|
22483
23294
|
if (this.serviceManifestPublicationInFlight) {
|
|
22484
23295
|
this.mergeServiceManifestPublicationRequest(
|
|
@@ -22511,13 +23322,23 @@ var CadenzaService = class {
|
|
|
22511
23322
|
const hasPendingFollowupLayer = publicationPlan.some(
|
|
22512
23323
|
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
22513
23324
|
);
|
|
23325
|
+
const publicationGate = this.getServiceManifestPublicationGate(publicationLayer);
|
|
23326
|
+
if (!publicationGate.ready) {
|
|
23327
|
+
this.scheduleServiceManifestPublicationRetry(publishReason, publishTargetLayer, {
|
|
23328
|
+
delayMs: publicationGate.delayMs,
|
|
23329
|
+
incrementRetryCount: false
|
|
23330
|
+
});
|
|
23331
|
+
return false;
|
|
23332
|
+
}
|
|
22514
23333
|
this.serviceManifestPublicationInFlight = true;
|
|
22515
23334
|
try {
|
|
22516
|
-
this.
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
23335
|
+
if (!this.isLocalAuthorityService()) {
|
|
23336
|
+
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
23337
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
23338
|
+
snapshot
|
|
23339
|
+
);
|
|
23340
|
+
}
|
|
23341
|
+
if (this.shouldRequireAuthorityBootstrapHandshakeForManifestPublication() && !this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
22521
23342
|
this.scheduleServiceManifestPublicationRetry(
|
|
22522
23343
|
publishReason,
|
|
22523
23344
|
publishTargetLayer
|
|
@@ -22525,11 +23346,13 @@ var CadenzaService = class {
|
|
|
22525
23346
|
return false;
|
|
22526
23347
|
}
|
|
22527
23348
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
22528
|
-
timeout:
|
|
23349
|
+
timeout: this.isLocalAuthorityService() ? LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS : DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS,
|
|
22529
23350
|
requireComplete: true
|
|
22530
23351
|
});
|
|
22531
23352
|
this.serviceManifestRevision = snapshot.revision;
|
|
22532
23353
|
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
23354
|
+
this.serviceManifestPublishedAt[publicationLayer] = Date.now();
|
|
23355
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
22533
23356
|
if (hasPendingFollowupLayer) {
|
|
22534
23357
|
this.mergeServiceManifestPublicationRequest(
|
|
22535
23358
|
publishReason,
|
|
@@ -22565,14 +23388,7 @@ var CadenzaService = class {
|
|
|
22565
23388
|
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
22566
23389
|
this.serviceManifestPublicationPendingReason = null;
|
|
22567
23390
|
this.serviceManifestPublicationPendingLayer = null;
|
|
22568
|
-
this.
|
|
22569
|
-
"meta.service_manifest.publish_requested",
|
|
22570
|
-
{
|
|
22571
|
-
__reason: pendingReason,
|
|
22572
|
-
__publicationLayer: pendingLayer
|
|
22573
|
-
},
|
|
22574
|
-
100
|
|
22575
|
-
);
|
|
23391
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
22576
23392
|
}
|
|
22577
23393
|
}
|
|
22578
23394
|
}
|
|
@@ -22586,7 +23402,7 @@ var CadenzaService = class {
|
|
|
22586
23402
|
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
22587
23403
|
this.normalizeServiceManifestPublicationLayer(
|
|
22588
23404
|
ctx.__publicationLayer,
|
|
22589
|
-
"
|
|
23405
|
+
"local_meta_structural"
|
|
22590
23406
|
)
|
|
22591
23407
|
),
|
|
22592
23408
|
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
@@ -22598,14 +23414,17 @@ var CadenzaService = class {
|
|
|
22598
23414
|
this.createMetaTask(
|
|
22599
23415
|
"Request manifest publication after structural change",
|
|
22600
23416
|
(ctx) => {
|
|
23417
|
+
if (!this.shouldRequestServiceManifestPublicationForSignal(ctx)) {
|
|
23418
|
+
return false;
|
|
23419
|
+
}
|
|
22601
23420
|
const reason = typeof ctx.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal : typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason : "manifest_structural_update";
|
|
22602
|
-
const targetLayer =
|
|
23421
|
+
const targetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
22603
23422
|
ctx.__publicationLayer,
|
|
22604
|
-
"
|
|
23423
|
+
"local_meta_structural"
|
|
22605
23424
|
);
|
|
22606
23425
|
this.requestServiceManifestPublication(
|
|
22607
23426
|
reason,
|
|
22608
|
-
|
|
23427
|
+
false,
|
|
22609
23428
|
targetLayer
|
|
22610
23429
|
);
|
|
22611
23430
|
return true;
|
|
@@ -22616,7 +23435,6 @@ var CadenzaService = class {
|
|
|
22616
23435
|
isHidden: true
|
|
22617
23436
|
}
|
|
22618
23437
|
).doOn(
|
|
22619
|
-
"meta.service_registry.instance_inserted",
|
|
22620
23438
|
"meta.task.created",
|
|
22621
23439
|
"meta.task.destroyed",
|
|
22622
23440
|
"meta.task.relationship_added",
|
|
@@ -22635,14 +23453,21 @@ var CadenzaService = class {
|
|
|
22635
23453
|
"meta.helper.global_associated",
|
|
22636
23454
|
"meta.actor.created",
|
|
22637
23455
|
"meta.actor.task_associated",
|
|
22638
|
-
"meta.fetch.handshake_complete",
|
|
22639
23456
|
"meta.service_registry.registered_global_signals",
|
|
22640
23457
|
"meta.service_registry.registered_global_intents",
|
|
22641
|
-
"meta.service_registry.initial_sync_complete",
|
|
22642
23458
|
"global.meta.graph_metadata.routine_created",
|
|
22643
23459
|
"global.meta.graph_metadata.routine_updated"
|
|
22644
23460
|
);
|
|
22645
23461
|
}
|
|
23462
|
+
static isLocalAuthorityService() {
|
|
23463
|
+
return this.serviceRegistry.serviceName === "CadenzaDB";
|
|
23464
|
+
}
|
|
23465
|
+
static canPublishServiceManifestToAuthority() {
|
|
23466
|
+
return this.serviceRegistry.connectsToCadenzaDB || this.isLocalAuthorityService();
|
|
23467
|
+
}
|
|
23468
|
+
static shouldRequireAuthorityBootstrapHandshakeForManifestPublication() {
|
|
23469
|
+
return !this.isLocalAuthorityService();
|
|
23470
|
+
}
|
|
22646
23471
|
static buildLegacyLocalCadenzaDBTaskName(tableName, operation) {
|
|
22647
23472
|
const operationPrefix = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
22648
23473
|
const helperSuffix = (0, import_lodash_es2.camelCase)(String(tableName ?? "").trim());
|
|
@@ -22809,6 +23634,7 @@ var CadenzaService = class {
|
|
|
22809
23634
|
}
|
|
22810
23635
|
static markBootstrapSyncCompleted() {
|
|
22811
23636
|
this.bootstrapSyncCompleted = true;
|
|
23637
|
+
this.bootstrapSyncCompletedAt = Date.now();
|
|
22812
23638
|
}
|
|
22813
23639
|
/**
|
|
22814
23640
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -23639,6 +24465,7 @@ var CadenzaService = class {
|
|
|
23639
24465
|
this.validateServiceName(serviceName);
|
|
23640
24466
|
const serviceId = options.customServiceId ?? (0, import_uuid8.v4)();
|
|
23641
24467
|
this.bootstrapSyncCompleted = false;
|
|
24468
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
23642
24469
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
23643
24470
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
23644
24471
|
this.serviceRegistry.serviceName = serviceName;
|
|
@@ -23874,6 +24701,7 @@ var CadenzaService = class {
|
|
|
23874
24701
|
__declaredTransports: declaredTransports
|
|
23875
24702
|
};
|
|
23876
24703
|
let bootstrapServiceCreationRequested = false;
|
|
24704
|
+
const emitLocalServiceCreationImmediately = !options.cadenzaDB?.connect;
|
|
23877
24705
|
if (options.cadenzaDB?.connect) {
|
|
23878
24706
|
this.createMetaTask(
|
|
23879
24707
|
"Create service",
|
|
@@ -23896,7 +24724,6 @@ var CadenzaService = class {
|
|
|
23896
24724
|
}
|
|
23897
24725
|
).doOn("meta.fetch.handshake_complete");
|
|
23898
24726
|
} else {
|
|
23899
|
-
this.emit("meta.create_service_requested", initContext);
|
|
23900
24727
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
23901
24728
|
emit2(
|
|
23902
24729
|
"meta.service_registry.gathered_sync_transmission_reconcile_requested",
|
|
@@ -23908,6 +24735,20 @@ var CadenzaService = class {
|
|
|
23908
24735
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
23909
24736
|
}
|
|
23910
24737
|
let serviceSetupCompletedHandled = false;
|
|
24738
|
+
this.createMetaTask("Handle local service definition insertion", (ctx) => {
|
|
24739
|
+
const insertedServiceName = String(
|
|
24740
|
+
ctx?.__serviceName ?? ctx?.serviceName ?? ctx?.service_name ?? ctx?.data?.name ?? ""
|
|
24741
|
+
).trim();
|
|
24742
|
+
if (!insertedServiceName || insertedServiceName !== serviceName) {
|
|
24743
|
+
return false;
|
|
24744
|
+
}
|
|
24745
|
+
this.localServiceManifestDefinitionInserted = true;
|
|
24746
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
24747
|
+
"service_setup_completed",
|
|
24748
|
+
"local_meta_structural"
|
|
24749
|
+
);
|
|
24750
|
+
return true;
|
|
24751
|
+
}).doOn("meta.service_registry.service_inserted");
|
|
23911
24752
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
23912
24753
|
if (serviceSetupCompletedHandled) {
|
|
23913
24754
|
return false;
|
|
@@ -23928,13 +24769,18 @@ var CadenzaService = class {
|
|
|
23928
24769
|
return false;
|
|
23929
24770
|
}
|
|
23930
24771
|
serviceSetupCompletedHandled = true;
|
|
24772
|
+
this.localServiceManifestInstanceInserted = true;
|
|
23931
24773
|
if (options.cadenzaDB?.connect) {
|
|
23932
24774
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
23933
|
-
void this.publishServiceManifestIfNeeded(
|
|
23934
|
-
"service_setup_completed",
|
|
23935
|
-
"business_structural"
|
|
23936
|
-
);
|
|
23937
24775
|
}
|
|
24776
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
24777
|
+
"service_setup_completed",
|
|
24778
|
+
"local_meta_structural"
|
|
24779
|
+
);
|
|
24780
|
+
this.scheduleInitialServiceManifestPublicationFallback(
|
|
24781
|
+
"service_setup_completed",
|
|
24782
|
+
"local_meta_structural"
|
|
24783
|
+
);
|
|
23938
24784
|
if (isFrontend) {
|
|
23939
24785
|
registerActorSessionPersistenceTasks();
|
|
23940
24786
|
this.ensureFrontendSyncLoop();
|
|
@@ -23942,6 +24788,9 @@ var CadenzaService = class {
|
|
|
23942
24788
|
this.log("Service created.");
|
|
23943
24789
|
return true;
|
|
23944
24790
|
}).doOn("meta.service_registry.instance_inserted");
|
|
24791
|
+
if (emitLocalServiceCreationImmediately) {
|
|
24792
|
+
this.emit("meta.create_service_requested", initContext);
|
|
24793
|
+
}
|
|
23945
24794
|
if (!options.cadenzaDB?.connect) {
|
|
23946
24795
|
import_core6.default.schedule(
|
|
23947
24796
|
"meta.service_registry.instance_registration_requested",
|
|
@@ -24406,6 +25255,30 @@ var CadenzaService = class {
|
|
|
24406
25255
|
this.bootstrap();
|
|
24407
25256
|
return import_core6.default.createTask(name, func, description, options);
|
|
24408
25257
|
}
|
|
25258
|
+
static createHelper(name, func, description = "") {
|
|
25259
|
+
this.bootstrap();
|
|
25260
|
+
return import_core6.default.createHelper(name, func, description);
|
|
25261
|
+
}
|
|
25262
|
+
static createMetaHelper(name, func, description = "") {
|
|
25263
|
+
this.bootstrap();
|
|
25264
|
+
return import_core6.default.createMetaHelper(name, func, description);
|
|
25265
|
+
}
|
|
25266
|
+
static createHelperFromDefinition(definition) {
|
|
25267
|
+
this.bootstrap();
|
|
25268
|
+
return import_core6.default.createHelperFromDefinition(definition);
|
|
25269
|
+
}
|
|
25270
|
+
static createGlobal(name, value, description = "") {
|
|
25271
|
+
this.bootstrap();
|
|
25272
|
+
return import_core6.default.createGlobal(name, value, description);
|
|
25273
|
+
}
|
|
25274
|
+
static createMetaGlobal(name, value, description = "") {
|
|
25275
|
+
this.bootstrap();
|
|
25276
|
+
return import_core6.default.createMetaGlobal(name, value, description);
|
|
25277
|
+
}
|
|
25278
|
+
static createGlobalFromDefinition(definition) {
|
|
25279
|
+
this.bootstrap();
|
|
25280
|
+
return import_core6.default.createGlobalFromDefinition(definition);
|
|
25281
|
+
}
|
|
24409
25282
|
/**
|
|
24410
25283
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
24411
25284
|
* This is used for creating tasks that lives on the meta layer.
|
|
@@ -24742,6 +25615,7 @@ var CadenzaService = class {
|
|
|
24742
25615
|
this.isBootstrapped = false;
|
|
24743
25616
|
this.serviceCreated = false;
|
|
24744
25617
|
this.bootstrapSyncCompleted = false;
|
|
25618
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
24745
25619
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
24746
25620
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
24747
25621
|
this.defaultDatabaseServiceName = null;
|
|
@@ -24750,15 +25624,27 @@ var CadenzaService = class {
|
|
|
24750
25624
|
this.frontendSyncScheduled = false;
|
|
24751
25625
|
this.serviceManifestRevision = 0;
|
|
24752
25626
|
this.lastPublishedServiceManifestHashes = {};
|
|
25627
|
+
this.serviceManifestPublishedAt = {};
|
|
24753
25628
|
this.serviceManifestPublicationInFlight = false;
|
|
24754
25629
|
this.serviceManifestPublicationPendingReason = null;
|
|
24755
25630
|
this.serviceManifestPublicationPendingLayer = null;
|
|
25631
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
25632
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
25633
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
25634
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
25635
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
25636
|
+
}
|
|
25637
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
25638
|
+
this.localServiceManifestDefinitionInserted = false;
|
|
25639
|
+
this.localServiceManifestInstanceInserted = false;
|
|
25640
|
+
this.initialServiceManifestPublicationRequested = false;
|
|
24756
25641
|
resetBrowserRuntimeActorHandles();
|
|
24757
25642
|
}
|
|
24758
25643
|
};
|
|
24759
25644
|
CadenzaService.isBootstrapped = false;
|
|
24760
25645
|
CadenzaService.serviceCreated = false;
|
|
24761
25646
|
CadenzaService.bootstrapSyncCompleted = false;
|
|
25647
|
+
CadenzaService.bootstrapSyncCompletedAt = 0;
|
|
24762
25648
|
CadenzaService.bootstrapSignalRegistrationsCompleted = false;
|
|
24763
25649
|
CadenzaService.bootstrapIntentRegistrationsCompleted = false;
|
|
24764
25650
|
CadenzaService.defaultDatabaseServiceName = null;
|
|
@@ -24767,9 +25653,17 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
24767
25653
|
CadenzaService.frontendSyncScheduled = false;
|
|
24768
25654
|
CadenzaService.serviceManifestRevision = 0;
|
|
24769
25655
|
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
25656
|
+
CadenzaService.serviceManifestPublishedAt = {};
|
|
24770
25657
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
24771
25658
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
24772
25659
|
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
25660
|
+
CadenzaService.serviceManifestPublicationRetryReason = null;
|
|
25661
|
+
CadenzaService.serviceManifestPublicationRetryLayer = null;
|
|
25662
|
+
CadenzaService.serviceManifestPublicationRetryTimer = null;
|
|
25663
|
+
CadenzaService.serviceManifestPublicationRetryCount = 0;
|
|
25664
|
+
CadenzaService.localServiceManifestDefinitionInserted = false;
|
|
25665
|
+
CadenzaService.localServiceManifestInstanceInserted = false;
|
|
25666
|
+
CadenzaService.initialServiceManifestPublicationRequested = false;
|
|
24773
25667
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
24774
25668
|
CadenzaService.shutdownInFlight = false;
|
|
24775
25669
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -25071,6 +25965,18 @@ var createTask = CadenzaService.createTask.bind(
|
|
|
25071
25965
|
var createMetaTask = CadenzaService.createMetaTask.bind(
|
|
25072
25966
|
CadenzaService
|
|
25073
25967
|
);
|
|
25968
|
+
var createHelper = CadenzaService.createHelper.bind(
|
|
25969
|
+
CadenzaService
|
|
25970
|
+
);
|
|
25971
|
+
var createMetaHelper = CadenzaService.createMetaHelper.bind(
|
|
25972
|
+
CadenzaService
|
|
25973
|
+
);
|
|
25974
|
+
var createGlobal = CadenzaService.createGlobal.bind(
|
|
25975
|
+
CadenzaService
|
|
25976
|
+
);
|
|
25977
|
+
var createMetaGlobal = CadenzaService.createMetaGlobal.bind(
|
|
25978
|
+
CadenzaService
|
|
25979
|
+
);
|
|
25074
25980
|
var createActor = CadenzaService.createActor.bind(
|
|
25075
25981
|
CadenzaService
|
|
25076
25982
|
);
|
|
@@ -25106,8 +26012,10 @@ var serviceRegistry = CadenzaService.serviceRegistry;
|
|
|
25106
26012
|
DeputyTask,
|
|
25107
26013
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
25108
26014
|
EphemeralTask,
|
|
26015
|
+
GlobalDefinition,
|
|
25109
26016
|
GraphMetadataController,
|
|
25110
26017
|
GraphRoutine,
|
|
26018
|
+
HelperDefinition,
|
|
25111
26019
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
25112
26020
|
RUNTIME_VALIDATION_INTENTS,
|
|
25113
26021
|
RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -25127,6 +26035,10 @@ var serviceRegistry = CadenzaService.serviceRegistry;
|
|
|
25127
26035
|
createCadenzaService,
|
|
25128
26036
|
createDatabaseService,
|
|
25129
26037
|
createExecutionPersistenceBundle,
|
|
26038
|
+
createGlobal,
|
|
26039
|
+
createHelper,
|
|
26040
|
+
createMetaGlobal,
|
|
26041
|
+
createMetaHelper,
|
|
25130
26042
|
createMetaTask,
|
|
25131
26043
|
createSSRInquiryBridge,
|
|
25132
26044
|
createTask,
|