@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.mjs
CHANGED
|
@@ -204,6 +204,16 @@ var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
|
204
204
|
"transportProtocols",
|
|
205
205
|
"transportProtocol"
|
|
206
206
|
];
|
|
207
|
+
var ACTOR_SESSION_STATE_REMOTE_ROUTINE = "Insert actor_session_state";
|
|
208
|
+
var ACTOR_SESSION_SNAPSHOT_ROOT_KEYS = [
|
|
209
|
+
"__remoteRoutineName",
|
|
210
|
+
"__serviceName",
|
|
211
|
+
"__localTaskName",
|
|
212
|
+
"__localTaskVersion",
|
|
213
|
+
"__localServiceName",
|
|
214
|
+
"__timeout",
|
|
215
|
+
...ROOT_METADATA_PASSTHROUGH_KEYS
|
|
216
|
+
];
|
|
207
217
|
function isPlainObject(value) {
|
|
208
218
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
209
219
|
return false;
|
|
@@ -228,6 +238,9 @@ function cloneDelegationValue(value) {
|
|
|
228
238
|
return value;
|
|
229
239
|
}
|
|
230
240
|
function buildDelegationRequestSnapshot(context) {
|
|
241
|
+
if (typeof context.__remoteRoutineName === "string" && context.__remoteRoutineName.trim() === ACTOR_SESSION_STATE_REMOTE_ROUTINE) {
|
|
242
|
+
return buildActorSessionDelegationSnapshot(context);
|
|
243
|
+
}
|
|
231
244
|
const snapshot = {};
|
|
232
245
|
for (const [key, value] of Object.entries(context)) {
|
|
233
246
|
if (key === DELEGATION_REQUEST_SNAPSHOT_KEY || key === "task" || key === "routine") {
|
|
@@ -237,6 +250,21 @@ function buildDelegationRequestSnapshot(context) {
|
|
|
237
250
|
}
|
|
238
251
|
return snapshot;
|
|
239
252
|
}
|
|
253
|
+
function buildActorSessionDelegationSnapshot(context) {
|
|
254
|
+
const snapshot = {};
|
|
255
|
+
for (const key of ACTOR_SESSION_SNAPSHOT_ROOT_KEYS) {
|
|
256
|
+
if (context[key] !== void 0) {
|
|
257
|
+
snapshot[key] = cloneDelegationValue(context[key]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (context.data !== void 0) {
|
|
261
|
+
snapshot.data = cloneDelegationValue(context.data);
|
|
262
|
+
}
|
|
263
|
+
if (context.queryData !== void 0) {
|
|
264
|
+
snapshot.queryData = cloneDelegationValue(context.queryData);
|
|
265
|
+
}
|
|
266
|
+
return snapshot;
|
|
267
|
+
}
|
|
240
268
|
function hoistDelegationMetadataFields(input, metadataInput) {
|
|
241
269
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
242
270
|
const mutableContext = context;
|
|
@@ -345,6 +373,12 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
345
373
|
return;
|
|
346
374
|
}
|
|
347
375
|
const processId = uuid2();
|
|
376
|
+
const resolvedTimeoutMs = Math.max(
|
|
377
|
+
1e3,
|
|
378
|
+
Number(context.__timeout ?? task.timeout ?? 0) || 6e4
|
|
379
|
+
);
|
|
380
|
+
let settled = false;
|
|
381
|
+
let timeoutHandle = null;
|
|
348
382
|
context.__metadata.__deputyExecId = processId;
|
|
349
383
|
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
350
384
|
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
@@ -361,7 +395,37 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
361
395
|
emit2("meta.deputy.delegation_requested", {
|
|
362
396
|
...context
|
|
363
397
|
});
|
|
364
|
-
|
|
398
|
+
let progressTask = null;
|
|
399
|
+
let resolveTask = null;
|
|
400
|
+
const cleanup = () => {
|
|
401
|
+
if (timeoutHandle) {
|
|
402
|
+
clearTimeout(timeoutHandle);
|
|
403
|
+
timeoutHandle = null;
|
|
404
|
+
}
|
|
405
|
+
if (progressTask && !progressTask.destroyed) {
|
|
406
|
+
progressTask.destroy();
|
|
407
|
+
}
|
|
408
|
+
if (resolveTask && !resolveTask.destroyed) {
|
|
409
|
+
resolveTask.destroy();
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
const settleSuccess = (value) => {
|
|
413
|
+
if (settled) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
settled = true;
|
|
417
|
+
cleanup();
|
|
418
|
+
resolve(value);
|
|
419
|
+
};
|
|
420
|
+
const settleFailure = (error) => {
|
|
421
|
+
if (settled) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
settled = true;
|
|
425
|
+
cleanup();
|
|
426
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
427
|
+
};
|
|
428
|
+
progressTask = CadenzaService.createEphemeralMetaTask(
|
|
365
429
|
`On progress deputy ${task.remoteRoutineName}`,
|
|
366
430
|
(ctx) => {
|
|
367
431
|
if (typeof progressCallback === "function" && ctx.progress) {
|
|
@@ -380,7 +444,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
380
444
|
`meta.fetch.delegated:${processId}`,
|
|
381
445
|
`meta.service_registry.load_balance_failed:${processId}`
|
|
382
446
|
);
|
|
383
|
-
CadenzaService.createEphemeralMetaTask(
|
|
447
|
+
resolveTask = CadenzaService.createEphemeralMetaTask(
|
|
384
448
|
`Resolve deputy ${task.remoteRoutineName}`,
|
|
385
449
|
(responseCtx) => {
|
|
386
450
|
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
@@ -388,7 +452,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
388
452
|
...responseCtx
|
|
389
453
|
} : responseCtx;
|
|
390
454
|
if (responseCtx?.errored) {
|
|
391
|
-
|
|
455
|
+
settleFailure(new Error(responseCtx.__error));
|
|
392
456
|
} else {
|
|
393
457
|
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
394
458
|
console.log(
|
|
@@ -405,7 +469,7 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
405
469
|
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
406
470
|
delete mergedResponseCtx.__isDeputy;
|
|
407
471
|
}
|
|
408
|
-
|
|
472
|
+
settleSuccess(mergedResponseCtx);
|
|
409
473
|
}
|
|
410
474
|
},
|
|
411
475
|
`Ephemeral resolver for deputy process ${processId}`,
|
|
@@ -415,6 +479,14 @@ function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
|
415
479
|
`meta.fetch.delegated:${processId}`,
|
|
416
480
|
`meta.service_registry.load_balance_failed:${processId}`
|
|
417
481
|
);
|
|
482
|
+
timeoutHandle = setTimeout(() => {
|
|
483
|
+
settleFailure(
|
|
484
|
+
new Error(
|
|
485
|
+
`Deputy task '${task.name}' timed out waiting for remote resolution after ${resolvedTimeoutMs}ms.`
|
|
486
|
+
)
|
|
487
|
+
);
|
|
488
|
+
}, resolvedTimeoutMs);
|
|
489
|
+
timeoutHandle.unref?.();
|
|
418
490
|
});
|
|
419
491
|
}
|
|
420
492
|
var DeputyTask = class extends Task {
|
|
@@ -560,6 +632,21 @@ var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
|
560
632
|
"Insert task_execution",
|
|
561
633
|
"Insert inquiry"
|
|
562
634
|
]);
|
|
635
|
+
var ROOT_DB_OPERATION_CONTEXT_KEYS = [
|
|
636
|
+
"data",
|
|
637
|
+
"batch",
|
|
638
|
+
"transaction",
|
|
639
|
+
"onConflict",
|
|
640
|
+
"filter",
|
|
641
|
+
"fields",
|
|
642
|
+
"joins",
|
|
643
|
+
"sort",
|
|
644
|
+
"limit",
|
|
645
|
+
"offset",
|
|
646
|
+
"queryMode",
|
|
647
|
+
"aggregates",
|
|
648
|
+
"groupBy"
|
|
649
|
+
];
|
|
563
650
|
var DatabaseTask = class extends DeputyTask {
|
|
564
651
|
/**
|
|
565
652
|
* Constructs an instance of the class with the provided parameters, defining
|
|
@@ -668,6 +755,27 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
668
755
|
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
669
756
|
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
670
757
|
}
|
|
758
|
+
const shouldCompactAuthorityBootstrapContext = this.serviceName === "CadenzaDB" && (ctx.__authorityBootstrapChannel === true || metadata.__authorityBootstrapChannel === true || ctx.__metadata?.__authorityBootstrapChannel === true);
|
|
759
|
+
const rootDbOperationContext = shouldCompactAuthorityBootstrapContext ? {} : {
|
|
760
|
+
data: nextQueryData.data ?? ctx.data,
|
|
761
|
+
batch: nextQueryData.batch ?? ctx.batch,
|
|
762
|
+
transaction: nextQueryData.transaction ?? ctx.transaction,
|
|
763
|
+
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
764
|
+
filter: nextQueryData.filter ?? ctx.filter,
|
|
765
|
+
fields: nextQueryData.fields ?? ctx.fields,
|
|
766
|
+
joins: nextQueryData.joins ?? ctx.joins,
|
|
767
|
+
sort: nextQueryData.sort ?? ctx.sort,
|
|
768
|
+
limit: nextQueryData.limit ?? ctx.limit,
|
|
769
|
+
offset: nextQueryData.offset ?? ctx.offset,
|
|
770
|
+
queryMode: nextQueryData.queryMode ?? ctx.queryMode,
|
|
771
|
+
aggregates: nextQueryData.aggregates ?? ctx.aggregates,
|
|
772
|
+
groupBy: nextQueryData.groupBy ?? ctx.groupBy
|
|
773
|
+
};
|
|
774
|
+
if (shouldCompactAuthorityBootstrapContext) {
|
|
775
|
+
for (const key of ROOT_DB_OPERATION_CONTEXT_KEYS) {
|
|
776
|
+
delete ctx[key];
|
|
777
|
+
}
|
|
778
|
+
}
|
|
671
779
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
672
780
|
stripDelegationRequestSnapshot(
|
|
673
781
|
hoistDelegationMetadataFields({
|
|
@@ -687,12 +795,7 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
687
795
|
__blockRemoteExecution: metadata.__blockRemoteExecution ?? ctx.__blockRemoteExecution ?? false,
|
|
688
796
|
__deputyTaskName: this.name
|
|
689
797
|
},
|
|
690
|
-
|
|
691
|
-
batch: nextQueryData.batch ?? ctx.batch,
|
|
692
|
-
transaction: nextQueryData.transaction ?? ctx.transaction,
|
|
693
|
-
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
694
|
-
filter: nextQueryData.filter ?? ctx.filter,
|
|
695
|
-
fields: nextQueryData.fields ?? ctx.fields,
|
|
798
|
+
...rootDbOperationContext,
|
|
696
799
|
queryData: nextQueryData
|
|
697
800
|
})
|
|
698
801
|
)
|
|
@@ -790,6 +893,76 @@ var SCHEMA_TYPES = [
|
|
|
790
893
|
// src/database/DatabaseController.ts
|
|
791
894
|
import { Pool } from "pg";
|
|
792
895
|
import { camelCase, kebabCase, snakeCase } from "lodash-es";
|
|
896
|
+
|
|
897
|
+
// src/utils/inquiry.ts
|
|
898
|
+
var META_INTENT_PREFIX = "meta-";
|
|
899
|
+
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
900
|
+
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
901
|
+
var META_READINESS_INTENT = "meta-readiness";
|
|
902
|
+
function isPlainObject2(value) {
|
|
903
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
904
|
+
}
|
|
905
|
+
function deepMergeDeterministic(left, right) {
|
|
906
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
907
|
+
return [...left, ...right];
|
|
908
|
+
}
|
|
909
|
+
if (isPlainObject2(left) && isPlainObject2(right)) {
|
|
910
|
+
const merged = { ...left };
|
|
911
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
912
|
+
for (const key of keys) {
|
|
913
|
+
if (!(key in left)) {
|
|
914
|
+
merged[key] = right[key];
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
if (!(key in right)) {
|
|
918
|
+
merged[key] = left[key];
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
merged[key] = deepMergeDeterministic(left[key], right[key]);
|
|
922
|
+
}
|
|
923
|
+
return merged;
|
|
924
|
+
}
|
|
925
|
+
return right;
|
|
926
|
+
}
|
|
927
|
+
function mergeInquiryContexts(contexts) {
|
|
928
|
+
return contexts.reduce((acc, next) => deepMergeDeterministic(acc, next), {});
|
|
929
|
+
}
|
|
930
|
+
function isMetaIntentName(intentName) {
|
|
931
|
+
return intentName.startsWith(META_INTENT_PREFIX);
|
|
932
|
+
}
|
|
933
|
+
function shouldExecuteInquiryResponder(inquiry, responderIsMeta) {
|
|
934
|
+
if (!isMetaIntentName(inquiry)) {
|
|
935
|
+
return true;
|
|
936
|
+
}
|
|
937
|
+
return responderIsMeta;
|
|
938
|
+
}
|
|
939
|
+
function compareResponderDescriptors(left, right) {
|
|
940
|
+
if (left.serviceName !== right.serviceName) {
|
|
941
|
+
return left.serviceName.localeCompare(right.serviceName);
|
|
942
|
+
}
|
|
943
|
+
if (left.taskName !== right.taskName) {
|
|
944
|
+
return left.taskName.localeCompare(right.taskName);
|
|
945
|
+
}
|
|
946
|
+
if (left.taskVersion !== right.taskVersion) {
|
|
947
|
+
return left.taskVersion - right.taskVersion;
|
|
948
|
+
}
|
|
949
|
+
return left.localTaskName.localeCompare(right.localTaskName);
|
|
950
|
+
}
|
|
951
|
+
function summarizeResponderStatuses(statuses) {
|
|
952
|
+
let responded = 0;
|
|
953
|
+
let failed = 0;
|
|
954
|
+
let timedOut = 0;
|
|
955
|
+
let pending = 0;
|
|
956
|
+
for (const status of statuses) {
|
|
957
|
+
if (status.status === "fulfilled") responded++;
|
|
958
|
+
if (status.status === "failed") failed++;
|
|
959
|
+
if (status.status === "timed_out") timedOut++;
|
|
960
|
+
}
|
|
961
|
+
pending = Math.max(0, statuses.length - responded - failed - timedOut);
|
|
962
|
+
return { responded, failed, timedOut, pending };
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/database/DatabaseController.ts
|
|
793
966
|
var AUTHORITY_SYNC_DEBUG_PREFIX = "[CADENZA_DB_TASK_DEBUG]";
|
|
794
967
|
var AUTHORITY_SYNC_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env === "object" && process.env.CADENZA_DB_TASK_DEBUG === "true";
|
|
795
968
|
var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -830,7 +1003,7 @@ var POSTGRES_SETUP_DEBUG_ENABLED = process.env.CADENZA_POSTGRES_SETUP_DEBUG ===
|
|
|
830
1003
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
831
1004
|
var ACTOR_SESSION_TRACE_LIMIT = 20;
|
|
832
1005
|
var actorSessionTraceCount = 0;
|
|
833
|
-
var GENERATED_POSTGRES_WRITE_TASK_CONCURRENCY =
|
|
1006
|
+
var GENERATED_POSTGRES_WRITE_TASK_CONCURRENCY = 1;
|
|
834
1007
|
var GENERATED_POSTGRES_WRITE_TASK_TIMEOUT_MS = 12e4;
|
|
835
1008
|
var EXECUTION_OBSERVABILITY_TABLES = /* @__PURE__ */ new Set([
|
|
836
1009
|
"execution_trace",
|
|
@@ -933,6 +1106,9 @@ function normalizeIntentToken(value) {
|
|
|
933
1106
|
}
|
|
934
1107
|
return normalized;
|
|
935
1108
|
}
|
|
1109
|
+
function prefixMetaIntentName(intentName, isMeta) {
|
|
1110
|
+
return isMeta ? `${META_INTENT_PREFIX}${intentName}` : intentName;
|
|
1111
|
+
}
|
|
936
1112
|
function shouldValidateGeneratedDbTaskInput(registration) {
|
|
937
1113
|
return registration.options.securityProfile !== "low" && !registration.options.isMeta;
|
|
938
1114
|
}
|
|
@@ -1060,9 +1236,9 @@ function readCustomIntentConfig(customIntent) {
|
|
|
1060
1236
|
input: customIntent.input
|
|
1061
1237
|
};
|
|
1062
1238
|
}
|
|
1063
|
-
function resolveTableOperationIntents(actorName, tableName, table, operation, defaultInputSchema) {
|
|
1239
|
+
function resolveTableOperationIntents(actorName, tableName, table, operation, defaultInputSchema, options) {
|
|
1064
1240
|
const actorToken = normalizeIntentToken(actorName);
|
|
1065
|
-
const defaultIntentName = `${operation}-pg-${actorToken}-${tableName}`;
|
|
1241
|
+
const defaultIntentName = `${options?.isMeta ? META_INTENT_PREFIX : ""}${operation}-pg-${actorToken}-${tableName}`;
|
|
1066
1242
|
validateIntentName(defaultIntentName);
|
|
1067
1243
|
const intents = [
|
|
1068
1244
|
{
|
|
@@ -1081,6 +1257,11 @@ function resolveTableOperationIntents(actorName, tableName, table, operation, de
|
|
|
1081
1257
|
`Invalid custom ${operation} intent on table '${tableName}': intent must be a non-empty string`
|
|
1082
1258
|
);
|
|
1083
1259
|
}
|
|
1260
|
+
if (options?.isMeta && !intentName.startsWith(META_INTENT_PREFIX)) {
|
|
1261
|
+
throw new Error(
|
|
1262
|
+
`Invalid custom ${operation} intent '${intentName}' on table '${tableName}': meta PostgresActor intents must start with '${META_INTENT_PREFIX}'`
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1084
1265
|
validateIntentName(intentName);
|
|
1085
1266
|
if (seenNames.has(intentName)) {
|
|
1086
1267
|
throw new Error(
|
|
@@ -1123,14 +1304,14 @@ function errorMessage(error) {
|
|
|
1123
1304
|
}
|
|
1124
1305
|
return String(error);
|
|
1125
1306
|
}
|
|
1126
|
-
function
|
|
1307
|
+
function isPlainObject3(value) {
|
|
1127
1308
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1128
1309
|
}
|
|
1129
1310
|
function stableStringify(value) {
|
|
1130
1311
|
if (Array.isArray(value)) {
|
|
1131
1312
|
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
1132
1313
|
}
|
|
1133
|
-
if (
|
|
1314
|
+
if (isPlainObject3(value)) {
|
|
1134
1315
|
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
1135
1316
|
}
|
|
1136
1317
|
return JSON.stringify(value);
|
|
@@ -3081,7 +3262,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3081
3262
|
"aggregate"
|
|
3082
3263
|
];
|
|
3083
3264
|
for (const macroOperation of queryMacroOperations) {
|
|
3084
|
-
const intentName =
|
|
3265
|
+
const intentName = prefixMetaIntentName(
|
|
3266
|
+
`${macroOperation}-pg-${registration.actorToken}-${tableName}`,
|
|
3267
|
+
registration.options.isMeta
|
|
3268
|
+
);
|
|
3085
3269
|
if (registration.intentNames.has(intentName)) {
|
|
3086
3270
|
throw new Error(
|
|
3087
3271
|
`Duplicate macro intent '${intentName}' detected for table '${tableName}' in actor '${registration.actorName}'`
|
|
@@ -3119,7 +3303,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3119
3303
|
}
|
|
3120
3304
|
).respondsTo(intentName);
|
|
3121
3305
|
}
|
|
3122
|
-
const upsertIntentName =
|
|
3306
|
+
const upsertIntentName = prefixMetaIntentName(
|
|
3307
|
+
`upsert-pg-${registration.actorToken}-${tableName}`,
|
|
3308
|
+
registration.options.isMeta
|
|
3309
|
+
);
|
|
3123
3310
|
if (registration.intentNames.has(upsertIntentName)) {
|
|
3124
3311
|
throw new Error(
|
|
3125
3312
|
`Duplicate macro intent '${upsertIntentName}' detected for table '${tableName}' in actor '${registration.actorName}'`
|
|
@@ -3389,7 +3576,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
3389
3576
|
tableName,
|
|
3390
3577
|
table,
|
|
3391
3578
|
op,
|
|
3392
|
-
schema
|
|
3579
|
+
schema,
|
|
3580
|
+
{
|
|
3581
|
+
isMeta: Boolean(registration.options.isMeta)
|
|
3582
|
+
}
|
|
3393
3583
|
);
|
|
3394
3584
|
for (const intent of intents) {
|
|
3395
3585
|
if (!registration.intentNames.has(intent.name)) {
|
|
@@ -3950,74 +4140,6 @@ function tableFieldTypeToSchemaType(type) {
|
|
|
3950
4140
|
var isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
3951
4141
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
3952
4142
|
|
|
3953
|
-
// src/utils/inquiry.ts
|
|
3954
|
-
var META_INTENT_PREFIX = "meta-";
|
|
3955
|
-
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
3956
|
-
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
3957
|
-
var META_READINESS_INTENT = "meta-readiness";
|
|
3958
|
-
function isPlainObject3(value) {
|
|
3959
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
3960
|
-
}
|
|
3961
|
-
function deepMergeDeterministic(left, right) {
|
|
3962
|
-
if (Array.isArray(left) && Array.isArray(right)) {
|
|
3963
|
-
return [...left, ...right];
|
|
3964
|
-
}
|
|
3965
|
-
if (isPlainObject3(left) && isPlainObject3(right)) {
|
|
3966
|
-
const merged = { ...left };
|
|
3967
|
-
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
3968
|
-
for (const key of keys) {
|
|
3969
|
-
if (!(key in left)) {
|
|
3970
|
-
merged[key] = right[key];
|
|
3971
|
-
continue;
|
|
3972
|
-
}
|
|
3973
|
-
if (!(key in right)) {
|
|
3974
|
-
merged[key] = left[key];
|
|
3975
|
-
continue;
|
|
3976
|
-
}
|
|
3977
|
-
merged[key] = deepMergeDeterministic(left[key], right[key]);
|
|
3978
|
-
}
|
|
3979
|
-
return merged;
|
|
3980
|
-
}
|
|
3981
|
-
return right;
|
|
3982
|
-
}
|
|
3983
|
-
function mergeInquiryContexts(contexts) {
|
|
3984
|
-
return contexts.reduce((acc, next) => deepMergeDeterministic(acc, next), {});
|
|
3985
|
-
}
|
|
3986
|
-
function isMetaIntentName(intentName) {
|
|
3987
|
-
return intentName.startsWith(META_INTENT_PREFIX);
|
|
3988
|
-
}
|
|
3989
|
-
function shouldExecuteInquiryResponder(inquiry, responderIsMeta) {
|
|
3990
|
-
if (!isMetaIntentName(inquiry)) {
|
|
3991
|
-
return true;
|
|
3992
|
-
}
|
|
3993
|
-
return responderIsMeta;
|
|
3994
|
-
}
|
|
3995
|
-
function compareResponderDescriptors(left, right) {
|
|
3996
|
-
if (left.serviceName !== right.serviceName) {
|
|
3997
|
-
return left.serviceName.localeCompare(right.serviceName);
|
|
3998
|
-
}
|
|
3999
|
-
if (left.taskName !== right.taskName) {
|
|
4000
|
-
return left.taskName.localeCompare(right.taskName);
|
|
4001
|
-
}
|
|
4002
|
-
if (left.taskVersion !== right.taskVersion) {
|
|
4003
|
-
return left.taskVersion - right.taskVersion;
|
|
4004
|
-
}
|
|
4005
|
-
return left.localTaskName.localeCompare(right.localTaskName);
|
|
4006
|
-
}
|
|
4007
|
-
function summarizeResponderStatuses(statuses) {
|
|
4008
|
-
let responded = 0;
|
|
4009
|
-
let failed = 0;
|
|
4010
|
-
let timedOut = 0;
|
|
4011
|
-
let pending = 0;
|
|
4012
|
-
for (const status of statuses) {
|
|
4013
|
-
if (status.status === "fulfilled") responded++;
|
|
4014
|
-
if (status.status === "failed") failed++;
|
|
4015
|
-
if (status.status === "timed_out") timedOut++;
|
|
4016
|
-
}
|
|
4017
|
-
pending = Math.max(0, statuses.length - responded - failed - timedOut);
|
|
4018
|
-
return { responded, failed, timedOut, pending };
|
|
4019
|
-
}
|
|
4020
|
-
|
|
4021
4143
|
// src/utils/transport.ts
|
|
4022
4144
|
var DEFAULT_PROTOCOLS = ["rest", "socket"];
|
|
4023
4145
|
var TRANSPORT_HANDLE_ROUTE_KEY_BY_HANDLE = /* @__PURE__ */ new Map();
|
|
@@ -4992,24 +5114,181 @@ function getAuthorityBootstrapIntentSpec(intentName) {
|
|
|
4992
5114
|
if (!normalizedIntentName) {
|
|
4993
5115
|
return null;
|
|
4994
5116
|
}
|
|
4995
|
-
return AUTHORITY_BOOTSTRAP_INTENT_SPEC_BY_NAME.get(normalizedIntentName) ?? null;
|
|
4996
|
-
}
|
|
4997
|
-
function isAuthorityBootstrapIntent(intentName) {
|
|
4998
|
-
return getAuthorityBootstrapIntentSpec(intentName) !== null;
|
|
4999
|
-
}
|
|
5000
|
-
function isAuthorityBootstrapSignal(signalName) {
|
|
5001
|
-
return AUTHORITY_BOOTSTRAP_SIGNAL_NAME_SET.has(String(signalName ?? "").trim());
|
|
5117
|
+
return AUTHORITY_BOOTSTRAP_INTENT_SPEC_BY_NAME.get(normalizedIntentName) ?? null;
|
|
5118
|
+
}
|
|
5119
|
+
function isAuthorityBootstrapIntent(intentName) {
|
|
5120
|
+
return getAuthorityBootstrapIntentSpec(intentName) !== null;
|
|
5121
|
+
}
|
|
5122
|
+
function isAuthorityBootstrapSignal(signalName) {
|
|
5123
|
+
return AUTHORITY_BOOTSTRAP_SIGNAL_NAME_SET.has(String(signalName ?? "").trim());
|
|
5124
|
+
}
|
|
5125
|
+
function getAuthorityBootstrapInsertIntentSpecForTable(tableName) {
|
|
5126
|
+
const normalizedTableName = String(tableName ?? "").trim();
|
|
5127
|
+
if (!normalizedTableName) {
|
|
5128
|
+
return null;
|
|
5129
|
+
}
|
|
5130
|
+
const intentName = AUTHORITY_BOOTSTRAP_INSERT_INTENT_BY_TABLE.get(normalizedTableName);
|
|
5131
|
+
if (!intentName) {
|
|
5132
|
+
return null;
|
|
5133
|
+
}
|
|
5134
|
+
return getAuthorityBootstrapIntentSpec(intentName);
|
|
5135
|
+
}
|
|
5136
|
+
|
|
5137
|
+
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
5138
|
+
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
5139
|
+
function readString(value) {
|
|
5140
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
5141
|
+
}
|
|
5142
|
+
function readRecord(value) {
|
|
5143
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
5144
|
+
}
|
|
5145
|
+
function normalizeRoutineExecutionTraceFields(data) {
|
|
5146
|
+
if (!data) {
|
|
5147
|
+
return null;
|
|
5148
|
+
}
|
|
5149
|
+
const normalizedData = { ...data };
|
|
5150
|
+
const traceId = readString(
|
|
5151
|
+
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
5152
|
+
);
|
|
5153
|
+
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
5154
|
+
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
5155
|
+
const serviceName = readString(
|
|
5156
|
+
normalizedData.service_name ?? normalizedData.serviceName
|
|
5157
|
+
);
|
|
5158
|
+
const serviceInstanceId = readString(
|
|
5159
|
+
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
5160
|
+
);
|
|
5161
|
+
if (traceId) {
|
|
5162
|
+
normalizedData.execution_trace_id = traceId;
|
|
5163
|
+
}
|
|
5164
|
+
if (metaContext) {
|
|
5165
|
+
normalizedData.meta_context = metaContext;
|
|
5166
|
+
}
|
|
5167
|
+
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
5168
|
+
normalizedData.is_meta = isMeta;
|
|
5169
|
+
}
|
|
5170
|
+
if (serviceName) {
|
|
5171
|
+
normalizedData.service_name = serviceName;
|
|
5172
|
+
}
|
|
5173
|
+
if (serviceInstanceId) {
|
|
5174
|
+
normalizedData.service_instance_id = serviceInstanceId;
|
|
5175
|
+
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
5176
|
+
normalizedData.service_instance_id = null;
|
|
5177
|
+
}
|
|
5178
|
+
delete normalizedData.executionTraceId;
|
|
5179
|
+
delete normalizedData.traceId;
|
|
5180
|
+
delete normalizedData.metaContext;
|
|
5181
|
+
delete normalizedData.isMeta;
|
|
5182
|
+
delete normalizedData.serviceName;
|
|
5183
|
+
delete normalizedData.serviceInstanceId;
|
|
5184
|
+
return normalizedData;
|
|
5185
|
+
}
|
|
5186
|
+
function stripExecutionTraceServiceInstanceFields(data) {
|
|
5187
|
+
if (!data) {
|
|
5188
|
+
return null;
|
|
5189
|
+
}
|
|
5190
|
+
const normalizedData = { ...data };
|
|
5191
|
+
delete normalizedData.serviceInstanceId;
|
|
5192
|
+
delete normalizedData.service_instance_id;
|
|
5193
|
+
return normalizedData;
|
|
5194
|
+
}
|
|
5195
|
+
function normalizeEnsureData(entityType, data) {
|
|
5196
|
+
switch (entityType) {
|
|
5197
|
+
case "execution_trace":
|
|
5198
|
+
return stripExecutionTraceServiceInstanceFields(data);
|
|
5199
|
+
case "routine_execution":
|
|
5200
|
+
return normalizeRoutineExecutionTraceFields(data);
|
|
5201
|
+
default:
|
|
5202
|
+
return data;
|
|
5203
|
+
}
|
|
5204
|
+
}
|
|
5205
|
+
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
5206
|
+
const normalizedEntityId = readString(entityId);
|
|
5207
|
+
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
5208
|
+
}
|
|
5209
|
+
function resolveEnsureEntityId(entityType, data) {
|
|
5210
|
+
switch (entityType) {
|
|
5211
|
+
default:
|
|
5212
|
+
return readString(data.uuid);
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
5216
|
+
return readString(
|
|
5217
|
+
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
5218
|
+
);
|
|
5219
|
+
}
|
|
5220
|
+
function dedupeDependencies(values) {
|
|
5221
|
+
return Array.from(
|
|
5222
|
+
new Set(values.filter((value) => typeof value === "string"))
|
|
5223
|
+
);
|
|
5224
|
+
}
|
|
5225
|
+
function resolveTraceIdFromData(data) {
|
|
5226
|
+
if (!data) {
|
|
5227
|
+
return null;
|
|
5228
|
+
}
|
|
5229
|
+
return readString(
|
|
5230
|
+
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
5231
|
+
);
|
|
5232
|
+
}
|
|
5233
|
+
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
5234
|
+
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
5235
|
+
if (!normalizedData) {
|
|
5236
|
+
return null;
|
|
5237
|
+
}
|
|
5238
|
+
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
5239
|
+
if (!entityId) {
|
|
5240
|
+
return null;
|
|
5241
|
+
}
|
|
5242
|
+
return {
|
|
5243
|
+
kind: "ensure",
|
|
5244
|
+
entityType,
|
|
5245
|
+
entityId,
|
|
5246
|
+
data: normalizedData,
|
|
5247
|
+
deps: dedupeDependencies(deps)
|
|
5248
|
+
};
|
|
5249
|
+
}
|
|
5250
|
+
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
5251
|
+
const normalizedData = readRecord(data);
|
|
5252
|
+
const normalizedFilter = readRecord(filter);
|
|
5253
|
+
if (!normalizedData || !normalizedFilter) {
|
|
5254
|
+
return null;
|
|
5255
|
+
}
|
|
5256
|
+
const entityId = resolveUpdateEntityId(
|
|
5257
|
+
entityType,
|
|
5258
|
+
normalizedData,
|
|
5259
|
+
normalizedFilter
|
|
5260
|
+
);
|
|
5261
|
+
if (!entityId) {
|
|
5262
|
+
return null;
|
|
5263
|
+
}
|
|
5264
|
+
return {
|
|
5265
|
+
kind: "update",
|
|
5266
|
+
entityType,
|
|
5267
|
+
entityId,
|
|
5268
|
+
data: normalizedData,
|
|
5269
|
+
filter: normalizedFilter,
|
|
5270
|
+
deps: dedupeDependencies(deps)
|
|
5271
|
+
};
|
|
5002
5272
|
}
|
|
5003
|
-
function
|
|
5004
|
-
const
|
|
5005
|
-
|
|
5273
|
+
function createExecutionPersistenceBundle(input) {
|
|
5274
|
+
const ensures = (input.ensures ?? []).filter(
|
|
5275
|
+
(event) => Boolean(event)
|
|
5276
|
+
);
|
|
5277
|
+
const updates = (input.updates ?? []).filter(
|
|
5278
|
+
(event) => Boolean(event)
|
|
5279
|
+
);
|
|
5280
|
+
if (ensures.length === 0 && updates.length === 0) {
|
|
5006
5281
|
return null;
|
|
5007
5282
|
}
|
|
5008
|
-
const
|
|
5009
|
-
if (!
|
|
5283
|
+
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));
|
|
5284
|
+
if (!traceId) {
|
|
5010
5285
|
return null;
|
|
5011
5286
|
}
|
|
5012
|
-
return
|
|
5287
|
+
return {
|
|
5288
|
+
traceId,
|
|
5289
|
+
ensures,
|
|
5290
|
+
updates
|
|
5291
|
+
};
|
|
5013
5292
|
}
|
|
5014
5293
|
|
|
5015
5294
|
// src/utils/tools.ts
|
|
@@ -5242,12 +5521,24 @@ function listManifestGlobals() {
|
|
|
5242
5521
|
(globalDefinition) => Boolean(globalDefinition && !globalDefinition.destroyed)
|
|
5243
5522
|
);
|
|
5244
5523
|
}
|
|
5245
|
-
function isRoutingCriticalMetaSignal(
|
|
5246
|
-
return
|
|
5524
|
+
function isRoutingCriticalMetaSignal(signal) {
|
|
5525
|
+
return ROUTING_CRITICAL_META_SIGNALS.has(signal.name);
|
|
5247
5526
|
}
|
|
5248
|
-
function isRoutingCriticalMetaIntent(
|
|
5249
|
-
return
|
|
5527
|
+
function isRoutingCriticalMetaIntent(intent) {
|
|
5528
|
+
return ROUTING_CRITICAL_META_INTENTS.has(intent.name);
|
|
5250
5529
|
}
|
|
5530
|
+
var ROUTING_CRITICAL_META_INTENTS = /* @__PURE__ */ new Set([
|
|
5531
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
5532
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
5533
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
5534
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
5535
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
5536
|
+
]);
|
|
5537
|
+
var ROUTING_CRITICAL_META_SIGNALS = /* @__PURE__ */ new Set([
|
|
5538
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
5539
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
5540
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
5541
|
+
]);
|
|
5251
5542
|
function buildServiceManifestSnapshot(params) {
|
|
5252
5543
|
const {
|
|
5253
5544
|
serviceName,
|
|
@@ -5657,87 +5948,9 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5657
5948
|
`${right.routine_name}:${right.task_name}`
|
|
5658
5949
|
)
|
|
5659
5950
|
);
|
|
5660
|
-
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
5661
|
-
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
5662
|
-
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
5663
|
-
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
5664
|
-
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
5665
|
-
for (const map of localMetaSignalTaskMaps) {
|
|
5666
|
-
businessLocalMetaSignalNames.add(map.signal_name);
|
|
5667
|
-
businessLocalMetaTaskKeys.add(
|
|
5668
|
-
buildTaskKey({
|
|
5669
|
-
service_name: map.service_name,
|
|
5670
|
-
name: map.task_name,
|
|
5671
|
-
version: map.task_version
|
|
5672
|
-
})
|
|
5673
|
-
);
|
|
5674
|
-
}
|
|
5675
|
-
for (const map of localMetaIntentTaskMaps) {
|
|
5676
|
-
businessLocalMetaIntentNames.add(map.intent_name);
|
|
5677
|
-
businessLocalMetaTaskKeys.add(
|
|
5678
|
-
buildTaskKey({
|
|
5679
|
-
service_name: map.service_name,
|
|
5680
|
-
name: map.task_name,
|
|
5681
|
-
version: map.task_version
|
|
5682
|
-
})
|
|
5683
|
-
);
|
|
5684
|
-
}
|
|
5685
|
-
for (const map of localMetaActorTaskMaps) {
|
|
5686
|
-
businessLocalMetaActorKeys.add(
|
|
5687
|
-
buildActorKey({
|
|
5688
|
-
service_name: map.service_name,
|
|
5689
|
-
name: map.actor_name,
|
|
5690
|
-
version: map.actor_version
|
|
5691
|
-
})
|
|
5692
|
-
);
|
|
5693
|
-
businessLocalMetaTaskKeys.add(
|
|
5694
|
-
buildTaskKey({
|
|
5695
|
-
service_name: map.service_name,
|
|
5696
|
-
name: map.task_name,
|
|
5697
|
-
version: map.task_version
|
|
5698
|
-
})
|
|
5699
|
-
);
|
|
5700
|
-
}
|
|
5701
|
-
for (const map of localMetaTaskToRoutineMaps) {
|
|
5702
|
-
businessLocalMetaRoutineKeys.add(
|
|
5703
|
-
buildRoutineKey({
|
|
5704
|
-
service_name: map.service_name,
|
|
5705
|
-
name: map.routine_name,
|
|
5706
|
-
version: map.routine_version
|
|
5707
|
-
})
|
|
5708
|
-
);
|
|
5709
|
-
businessLocalMetaTaskKeys.add(
|
|
5710
|
-
buildTaskKey({
|
|
5711
|
-
service_name: map.service_name,
|
|
5712
|
-
name: map.task_name,
|
|
5713
|
-
version: map.task_version
|
|
5714
|
-
})
|
|
5715
|
-
);
|
|
5716
|
-
}
|
|
5717
|
-
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
5718
|
-
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
5719
|
-
).sort(
|
|
5720
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5721
|
-
);
|
|
5722
|
-
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
5723
|
-
(signal) => signal !== null && signal.is_meta === true
|
|
5724
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5725
|
-
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
5726
|
-
(intent) => intent !== null && intent.is_meta === true
|
|
5727
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5728
|
-
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
5729
|
-
(actor) => actor !== null && actor.is_meta === true
|
|
5730
|
-
).sort(
|
|
5731
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5732
|
-
);
|
|
5733
|
-
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
5734
|
-
(routine) => routine !== null && routine.is_meta === true
|
|
5735
|
-
).sort(
|
|
5736
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5737
|
-
);
|
|
5738
5951
|
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
5739
5952
|
new Map(
|
|
5740
|
-
[...routingTasks, ...businessTasks
|
|
5953
|
+
[...routingTasks, ...businessTasks].map((task) => [
|
|
5741
5954
|
buildTaskKey(task),
|
|
5742
5955
|
task
|
|
5743
5956
|
])
|
|
@@ -5756,7 +5969,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5756
5969
|
);
|
|
5757
5970
|
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
5758
5971
|
new Map(
|
|
5759
|
-
[...routingSignals, ...businessSignals
|
|
5972
|
+
[...routingSignals, ...businessSignals].map(
|
|
5760
5973
|
(signal) => [signal.name, signal]
|
|
5761
5974
|
)
|
|
5762
5975
|
).values()
|
|
@@ -5770,7 +5983,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5770
5983
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5771
5984
|
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
5772
5985
|
new Map(
|
|
5773
|
-
[...routingIntents, ...businessIntents
|
|
5986
|
+
[...routingIntents, ...businessIntents].map(
|
|
5774
5987
|
(intent) => [intent.name, intent]
|
|
5775
5988
|
)
|
|
5776
5989
|
).values()
|
|
@@ -5782,16 +5995,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5782
5995
|
])
|
|
5783
5996
|
).values()
|
|
5784
5997
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5785
|
-
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5786
|
-
new Map(
|
|
5787
|
-
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
5788
|
-
buildActorKey(actor),
|
|
5789
|
-
actor
|
|
5790
|
-
])
|
|
5791
|
-
).values()
|
|
5792
|
-
).sort(
|
|
5793
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5794
|
-
) : Array.from(
|
|
5998
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActors : Array.from(
|
|
5795
5999
|
new Map(
|
|
5796
6000
|
[...businessActors, ...localMetaActors].map((actor) => [
|
|
5797
6001
|
buildActorKey(actor),
|
|
@@ -5801,16 +6005,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5801
6005
|
).sort(
|
|
5802
6006
|
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5803
6007
|
);
|
|
5804
|
-
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5805
|
-
new Map(
|
|
5806
|
-
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
5807
|
-
buildRoutineKey(routine),
|
|
5808
|
-
routine
|
|
5809
|
-
])
|
|
5810
|
-
).values()
|
|
5811
|
-
).sort(
|
|
5812
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5813
|
-
) : Array.from(
|
|
6008
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessRoutines : Array.from(
|
|
5814
6009
|
new Map(
|
|
5815
6010
|
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
5816
6011
|
buildRoutineKey(routine),
|
|
@@ -5936,14 +6131,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5936
6131
|
)
|
|
5937
6132
|
).values()
|
|
5938
6133
|
);
|
|
5939
|
-
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5940
|
-
new Map(
|
|
5941
|
-
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
5942
|
-
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
5943
|
-
map
|
|
5944
|
-
])
|
|
5945
|
-
).values()
|
|
5946
|
-
) : Array.from(
|
|
6134
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActorTaskMaps : Array.from(
|
|
5947
6135
|
new Map(
|
|
5948
6136
|
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
5949
6137
|
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
@@ -5971,8 +6159,8 @@ function buildServiceManifestSnapshot(params) {
|
|
|
5971
6159
|
helpers: cumulativeHelpers,
|
|
5972
6160
|
globals: cumulativeGlobals,
|
|
5973
6161
|
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
5974
|
-
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] :
|
|
5975
|
-
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] :
|
|
6162
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : publishedSignalTaskMaps,
|
|
6163
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : publishedIntentTaskMaps,
|
|
5976
6164
|
actorTaskMaps: cumulativeActorTaskMaps,
|
|
5977
6165
|
taskToRoutineMaps: cumulativeTaskToRoutineMaps,
|
|
5978
6166
|
taskToHelperMaps: cumulativeTaskToHelperMaps,
|
|
@@ -6136,6 +6324,13 @@ var META_SERVICE_INSTANCE_SHUTDOWN_TRANSPORT_DEACTIVATION_SIGNAL = "meta.service
|
|
|
6136
6324
|
var META_AUTHORITY_BOOTSTRAP_HANDSHAKE_REQUESTED_SIGNAL = "meta.service_registry.authority_bootstrap_handshake_requested";
|
|
6137
6325
|
var META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL = "meta.service_registry.runtime_status.rest_refresh_tick";
|
|
6138
6326
|
var AUTHORITY_BOOTSTRAP_HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
6327
|
+
var AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS = [
|
|
6328
|
+
1e3,
|
|
6329
|
+
3e3,
|
|
6330
|
+
7e3,
|
|
6331
|
+
15e3
|
|
6332
|
+
];
|
|
6333
|
+
var AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS = 6e4;
|
|
6139
6334
|
var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
6140
6335
|
100,
|
|
6141
6336
|
1500,
|
|
@@ -6145,25 +6340,41 @@ var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
|
6145
6340
|
45e3,
|
|
6146
6341
|
7e4
|
|
6147
6342
|
];
|
|
6343
|
+
var PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS = [
|
|
6344
|
+
50,
|
|
6345
|
+
125,
|
|
6346
|
+
250,
|
|
6347
|
+
500
|
|
6348
|
+
];
|
|
6148
6349
|
var MIN_BOOTSTRAP_FULL_SYNC_ATTEMPTS = 4;
|
|
6149
|
-
var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
6150
|
-
"Track local routine start",
|
|
6151
|
-
"Track local routine end",
|
|
6152
|
-
"Start runtime status sharing intervals",
|
|
6153
|
-
"Broadcast runtime status",
|
|
6154
|
-
"Flush local runtime status to authority",
|
|
6155
|
-
"Monitor dependee heartbeat freshness",
|
|
6156
|
-
"Refresh REST dependee runtime status",
|
|
6157
|
-
"Resolve runtime status fallback inquiry",
|
|
6158
|
-
"Respond runtime status inquiry",
|
|
6159
|
-
"Respond readiness inquiry",
|
|
6160
|
-
"Collect distributed readiness",
|
|
6161
|
-
"Get status"
|
|
6162
|
-
]);
|
|
6163
6350
|
var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRACE_SERVICE ?? "").trim();
|
|
6164
6351
|
function shouldTraceServiceRegistry(serviceName) {
|
|
6165
6352
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
6166
6353
|
}
|
|
6354
|
+
function getFetchFailureText(ctx) {
|
|
6355
|
+
return String(ctx?.__error ?? ctx?.error ?? ctx?.message ?? "").trim();
|
|
6356
|
+
}
|
|
6357
|
+
function isTerminalFetchTransportFailure(ctx) {
|
|
6358
|
+
const errorText = getFetchFailureText(ctx);
|
|
6359
|
+
if (!errorText) {
|
|
6360
|
+
return false;
|
|
6361
|
+
}
|
|
6362
|
+
return errorText.includes("ENOTFOUND") || errorText.includes("ECONNREFUSED") || errorText.includes("EHOSTUNREACH");
|
|
6363
|
+
}
|
|
6364
|
+
function isRecoverableFetchTransportFailure(ctx, options = {}) {
|
|
6365
|
+
const errorText = getFetchFailureText(ctx);
|
|
6366
|
+
if (!errorText) {
|
|
6367
|
+
return false;
|
|
6368
|
+
}
|
|
6369
|
+
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");
|
|
6370
|
+
}
|
|
6371
|
+
function isHardFetchHandshakeFailure(ctx) {
|
|
6372
|
+
const errorText = getFetchFailureText(ctx);
|
|
6373
|
+
if (!errorText) {
|
|
6374
|
+
return false;
|
|
6375
|
+
}
|
|
6376
|
+
return isTerminalFetchTransportFailure(ctx) || isRecoverableFetchTransportFailure(ctx);
|
|
6377
|
+
}
|
|
6167
6378
|
function normalizeLeaseStatus(value) {
|
|
6168
6379
|
const status = String(value ?? "").trim();
|
|
6169
6380
|
if (status === "active" || status === "non_responsive" || status === "inactive" || status === "deleted") {
|
|
@@ -6309,18 +6520,28 @@ function compactAuthorityBootstrapRequestBody(ctx) {
|
|
|
6309
6520
|
if (!isBootstrapDbOperationRoutineName(ctx.__remoteRoutineName)) {
|
|
6310
6521
|
return ctx;
|
|
6311
6522
|
}
|
|
6312
|
-
const
|
|
6313
|
-
|
|
6314
|
-
|
|
6523
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? { ...ctx.queryData } : {};
|
|
6524
|
+
const compactQueryData = {};
|
|
6525
|
+
for (const key of BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS) {
|
|
6526
|
+
if (Object.prototype.hasOwnProperty.call(existingQueryData, key)) {
|
|
6527
|
+
compactQueryData[key] = existingQueryData[key];
|
|
6528
|
+
continue;
|
|
6529
|
+
}
|
|
6530
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key)) {
|
|
6531
|
+
compactQueryData[key] = ctx[key];
|
|
6532
|
+
}
|
|
6315
6533
|
}
|
|
6316
6534
|
const compacted = {
|
|
6317
|
-
|
|
6318
|
-
|
|
6535
|
+
__remoteRoutineName: ctx.__remoteRoutineName,
|
|
6536
|
+
__serviceName: ctx.__serviceName,
|
|
6537
|
+
__localServiceName: ctx.__localServiceName,
|
|
6538
|
+
__timeout: ctx.__timeout,
|
|
6539
|
+
__syncing: true,
|
|
6540
|
+
__authorityBootstrapChannel: true,
|
|
6541
|
+
queryData: compactQueryData
|
|
6319
6542
|
};
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
delete compacted[key];
|
|
6323
|
-
}
|
|
6543
|
+
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
6544
|
+
compacted.__reason = ctx.__reason;
|
|
6324
6545
|
}
|
|
6325
6546
|
return compacted;
|
|
6326
6547
|
}
|
|
@@ -7040,6 +7261,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7040
7261
|
handshakeEstablished: false
|
|
7041
7262
|
};
|
|
7042
7263
|
this.authorityBootstrapHandshakeInFlight = false;
|
|
7264
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
7265
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
7266
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
7267
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
7268
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
7043
7269
|
this.authorityFullSyncResponderTask = null;
|
|
7044
7270
|
this.authorityServiceCommunicationPersistenceTask = null;
|
|
7045
7271
|
this.localLifecycleFlushActor = CadenzaService.createActor(
|
|
@@ -7575,7 +7801,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7575
7801
|
return false;
|
|
7576
7802
|
}
|
|
7577
7803
|
this.clearTransportReadyFromContext(ctx);
|
|
7578
|
-
const
|
|
7804
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
7805
|
+
const serviceInstanceId = String(
|
|
7806
|
+
ctx.serviceInstanceId ?? ctx.__instance ?? ctx.filter?.uuid ?? ""
|
|
7807
|
+
).trim();
|
|
7808
|
+
const serviceTransportId = String(
|
|
7809
|
+
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
7810
|
+
).trim();
|
|
7579
7811
|
if (serviceName === "CadenzaDB" && this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
7580
7812
|
const currentAuthorityInstanceId = String(
|
|
7581
7813
|
this.authorityBootstrapRoute.serviceInstanceId ?? ""
|
|
@@ -7591,6 +7823,26 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7591
7823
|
return true;
|
|
7592
7824
|
}
|
|
7593
7825
|
}
|
|
7826
|
+
const signalName = String(
|
|
7827
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
7828
|
+
).trim();
|
|
7829
|
+
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
7830
|
+
const hardFetchHandshakeFailure = isFetchHandshakeFailure && isHardFetchHandshakeFailure(ctx);
|
|
7831
|
+
const recoverableFetchHandshakeFailure = isFetchHandshakeFailure && isRecoverableFetchTransportFailure(ctx, {
|
|
7832
|
+
includeConnectionRefused: true
|
|
7833
|
+
});
|
|
7834
|
+
const isFetchDelegateFailure = signalName === "meta.fetch.delegate_failed" || signalName.startsWith("meta.fetch.delegate_failed:");
|
|
7835
|
+
const hardFetchDelegateFailure = isFetchDelegateFailure && isHardFetchHandshakeFailure(ctx);
|
|
7836
|
+
const recoverableFetchDelegateFailure = isFetchDelegateFailure && isRecoverableFetchTransportFailure(ctx);
|
|
7837
|
+
if (isFetchDelegateFailure && !hardFetchDelegateFailure) {
|
|
7838
|
+
return false;
|
|
7839
|
+
}
|
|
7840
|
+
if (serviceName === "CadenzaDB" && (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure)) {
|
|
7841
|
+
return false;
|
|
7842
|
+
}
|
|
7843
|
+
if (serviceName === "CadenzaDB" && this.authorityBootstrapRecoveryActive) {
|
|
7844
|
+
return false;
|
|
7845
|
+
}
|
|
7594
7846
|
const serviceInstances = this.instances.get(serviceName);
|
|
7595
7847
|
const instances = serviceInstances?.filter((instance) => {
|
|
7596
7848
|
if (serviceInstanceId && instance.uuid === serviceInstanceId) {
|
|
@@ -7614,6 +7866,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7614
7866
|
"warning",
|
|
7615
7867
|
serviceName
|
|
7616
7868
|
);
|
|
7869
|
+
if (serviceName === "CadenzaDB") {
|
|
7870
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
7871
|
+
}
|
|
7617
7872
|
for (const instance of instances ?? []) {
|
|
7618
7873
|
if (instance.serviceName === this.serviceName && instance.uuid === this.serviceInstanceId) {
|
|
7619
7874
|
continue;
|
|
@@ -7622,13 +7877,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7622
7877
|
if (affectedTransport && this.hasAnyReadyClientProtocolForTransport(instance, affectedTransport)) {
|
|
7623
7878
|
continue;
|
|
7624
7879
|
}
|
|
7625
|
-
|
|
7626
|
-
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
7627
|
-
).trim();
|
|
7628
|
-
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
7629
|
-
if (isFetchHandshakeFailure && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
7880
|
+
if ((isFetchHandshakeFailure && (!hardFetchHandshakeFailure || recoverableFetchHandshakeFailure) || isFetchDelegateFailure && (!hardFetchDelegateFailure || recoverableFetchDelegateFailure)) && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
7630
7881
|
...ctx,
|
|
7631
|
-
__reason: "fetch_handshake_failed_retry"
|
|
7882
|
+
__reason: isFetchDelegateFailure ? "fetch_delegate_failed_retry" : "fetch_handshake_failed_retry"
|
|
7632
7883
|
})) {
|
|
7633
7884
|
continue;
|
|
7634
7885
|
}
|
|
@@ -7639,10 +7890,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7639
7890
|
});
|
|
7640
7891
|
continue;
|
|
7641
7892
|
}
|
|
7893
|
+
if (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure) {
|
|
7894
|
+
continue;
|
|
7895
|
+
}
|
|
7642
7896
|
this.applyInstanceLifecycleState(instance, {
|
|
7643
7897
|
isActive: false,
|
|
7644
7898
|
isNonResponsive: true
|
|
7645
7899
|
});
|
|
7900
|
+
const transportsToClear = affectedTransport ? [affectedTransport] : (instance.transports ?? []).filter((transport) => !transport.deleted);
|
|
7901
|
+
for (const transport of transportsToClear) {
|
|
7902
|
+
this.clearTransportFailureState(instance.uuid, transport.uuid);
|
|
7903
|
+
this.clearTransportClientState(instance, transport);
|
|
7904
|
+
this.clearRemoteRouteRecordIfCurrent(
|
|
7905
|
+
instance.serviceName,
|
|
7906
|
+
instance.uuid,
|
|
7907
|
+
transport
|
|
7908
|
+
);
|
|
7909
|
+
this.emitTransportHandleShutdowns(
|
|
7910
|
+
emit2,
|
|
7911
|
+
this.buildTransportRouteKey(instance.serviceName, transport),
|
|
7912
|
+
transport
|
|
7913
|
+
);
|
|
7914
|
+
}
|
|
7915
|
+
emit2("meta.service_registry.service_not_responding", {
|
|
7916
|
+
...ctx,
|
|
7917
|
+
serviceName: instance.serviceName,
|
|
7918
|
+
serviceInstanceId: instance.uuid,
|
|
7919
|
+
serviceTransportId: affectedTransport?.uuid ?? serviceTransportId ?? void 0,
|
|
7920
|
+
routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.routeKey ?? ctx.__routeKey,
|
|
7921
|
+
__routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.__routeKey ?? ctx.routeKey
|
|
7922
|
+
});
|
|
7646
7923
|
emit2("global.meta.service_registry.service_not_responding", {
|
|
7647
7924
|
data: {
|
|
7648
7925
|
isActive: false,
|
|
@@ -7671,6 +7948,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7671
7948
|
).doOn(
|
|
7672
7949
|
"meta.fetch.handshake_failed",
|
|
7673
7950
|
"meta.fetch.handshake_failed.*",
|
|
7951
|
+
"meta.fetch.delegate_failed",
|
|
7952
|
+
"meta.fetch.delegate_failed.*",
|
|
7674
7953
|
"meta.socket_client.disconnected",
|
|
7675
7954
|
"meta.socket_client.disconnected.*",
|
|
7676
7955
|
"meta.service_registry.runtime_status_unreachable"
|
|
@@ -7856,12 +8135,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7856
8135
|
return false;
|
|
7857
8136
|
}
|
|
7858
8137
|
}
|
|
7859
|
-
this.
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
__reason: "cadenza_db_unreachable"
|
|
7864
|
-
});
|
|
8138
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
8139
|
+
return false;
|
|
8140
|
+
}
|
|
8141
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
7865
8142
|
return true;
|
|
7866
8143
|
},
|
|
7867
8144
|
"Clears bootstrap full-sync retry satisfaction when the authority becomes unreachable."
|
|
@@ -7881,7 +8158,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7881
8158
|
return false;
|
|
7882
8159
|
}
|
|
7883
8160
|
this.ensureBootstrapAuthorityControlPlane(ctx, emit2);
|
|
7884
|
-
return this.
|
|
8161
|
+
return this.scheduleNextBootstrapFullSyncRetry(
|
|
7885
8162
|
"cadenza_db_fetch_handshake"
|
|
7886
8163
|
);
|
|
7887
8164
|
},
|
|
@@ -8248,12 +8525,24 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8248
8525
|
preferredRole,
|
|
8249
8526
|
preferredProtocol
|
|
8250
8527
|
);
|
|
8528
|
+
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
8529
|
+
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
8530
|
+
}
|
|
8531
|
+
const hasPendingRouteableInstance = Boolean(__serviceName) && __serviceName !== "CadenzaDB" && this.hasPendingRouteableInstanceForSelection(
|
|
8532
|
+
__serviceName,
|
|
8533
|
+
context,
|
|
8534
|
+
preferredRole,
|
|
8535
|
+
targetServiceInstanceId
|
|
8536
|
+
);
|
|
8251
8537
|
const activeRoutingCooldown = __serviceName && !targetServiceInstanceId ? this.getActiveRoutingCooldown(
|
|
8252
8538
|
__serviceName,
|
|
8253
8539
|
preferredRole,
|
|
8254
8540
|
preferredProtocol
|
|
8255
8541
|
) : null;
|
|
8256
8542
|
if (activeRoutingCooldown) {
|
|
8543
|
+
if (hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
8544
|
+
return false;
|
|
8545
|
+
}
|
|
8257
8546
|
context.errored = true;
|
|
8258
8547
|
context.__error = `No routeable ${preferredRole} transport available for ${__serviceName}. Waiting for authority route updates before retrying.`;
|
|
8259
8548
|
emit2(
|
|
@@ -8295,9 +8584,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8295
8584
|
}
|
|
8296
8585
|
let retries = __retries ?? 0;
|
|
8297
8586
|
let triedInstances = __triedInstances ?? [];
|
|
8298
|
-
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
8299
|
-
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
8300
|
-
}
|
|
8301
8587
|
const filteredInstances = this.instances.get(__serviceName)?.filter((instance) => {
|
|
8302
8588
|
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
8303
8589
|
return false;
|
|
@@ -8316,6 +8602,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8316
8602
|
)
|
|
8317
8603
|
);
|
|
8318
8604
|
}) ?? [];
|
|
8605
|
+
if (filteredInstances.length === 0 && __serviceName && hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
8606
|
+
return false;
|
|
8607
|
+
}
|
|
8319
8608
|
const instances = this.collapseInstancesByRouteOrigin(
|
|
8320
8609
|
filteredInstances,
|
|
8321
8610
|
context,
|
|
@@ -8659,10 +8948,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8659
8948
|
CadenzaService.createMetaTask(
|
|
8660
8949
|
"Track local routine start",
|
|
8661
8950
|
(ctx, emit2) => {
|
|
8662
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
8663
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
8664
|
-
return false;
|
|
8665
|
-
}
|
|
8666
8951
|
const routineId = String(
|
|
8667
8952
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
8668
8953
|
);
|
|
@@ -8693,10 +8978,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8693
8978
|
CadenzaService.createMetaTask(
|
|
8694
8979
|
"Track local routine end",
|
|
8695
8980
|
(ctx, emit2) => {
|
|
8696
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
8697
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
8698
|
-
return false;
|
|
8699
|
-
}
|
|
8700
8981
|
const routineId = String(
|
|
8701
8982
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
8702
8983
|
);
|
|
@@ -9330,6 +9611,19 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9330
9611
|
}
|
|
9331
9612
|
return false;
|
|
9332
9613
|
}
|
|
9614
|
+
if (this.serviceName && normalizedLocalInstance.serviceName !== this.serviceName || this.serviceInstanceId && normalizedLocalInstance.uuid !== this.serviceInstanceId) {
|
|
9615
|
+
if (shouldTraceServiceRegistry(
|
|
9616
|
+
resolveServiceNameFromContext(ctx) || this.serviceName
|
|
9617
|
+
)) {
|
|
9618
|
+
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service_ignored_non_local_instance", {
|
|
9619
|
+
localServiceName: this.serviceName,
|
|
9620
|
+
localServiceInstanceId: this.serviceInstanceId,
|
|
9621
|
+
resolvedServiceName: normalizedLocalInstance.serviceName,
|
|
9622
|
+
resolvedServiceInstanceId: normalizedLocalInstance.uuid
|
|
9623
|
+
});
|
|
9624
|
+
}
|
|
9625
|
+
return false;
|
|
9626
|
+
}
|
|
9333
9627
|
if (shouldTraceServiceRegistry(normalizedLocalInstance.serviceName)) {
|
|
9334
9628
|
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service", {
|
|
9335
9629
|
localServiceName: this.serviceName,
|
|
@@ -9545,7 +9839,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9545
9839
|
security_profile: "excluded",
|
|
9546
9840
|
auth_strategy: "excluded",
|
|
9547
9841
|
deleted: "false"
|
|
9548
|
-
}
|
|
9842
|
+
},
|
|
9843
|
+
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"
|
|
9549
9844
|
}
|
|
9550
9845
|
}
|
|
9551
9846
|
},
|
|
@@ -10477,6 +10772,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10477
10772
|
serviceTransportId: String(ctx.serviceTransportId ?? "").trim() || null,
|
|
10478
10773
|
handshakeEstablished: true
|
|
10479
10774
|
};
|
|
10775
|
+
this.markAuthorityBootstrapHandshakeSatisfied();
|
|
10480
10776
|
return true;
|
|
10481
10777
|
}
|
|
10482
10778
|
getAuthorityBootstrapRestTarget() {
|
|
@@ -10505,6 +10801,92 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10505
10801
|
handshakeEstablished: false
|
|
10506
10802
|
};
|
|
10507
10803
|
}
|
|
10804
|
+
clearAuthorityBootstrapHandshakeRetryTimer() {
|
|
10805
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
10806
|
+
clearTimeout(this.authorityBootstrapHandshakeRetryTimer);
|
|
10807
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
10808
|
+
}
|
|
10809
|
+
}
|
|
10810
|
+
invalidateAuthorityBootstrapHandshakeRetryState(reason) {
|
|
10811
|
+
this.authorityBootstrapHandshakeRetryGeneration += 1;
|
|
10812
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
10813
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
10814
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10815
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10816
|
+
}
|
|
10817
|
+
}
|
|
10818
|
+
markAuthorityBootstrapHandshakeSatisfied() {
|
|
10819
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
10820
|
+
this.authorityBootstrapHandshakeRetryIndex = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length;
|
|
10821
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
10822
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
10823
|
+
}
|
|
10824
|
+
buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(baseDelayMs, attempt) {
|
|
10825
|
+
return buildDeterministicJitteredDelayMs(
|
|
10826
|
+
baseDelayMs,
|
|
10827
|
+
this.bootstrapFullSyncRetryJitterRatio,
|
|
10828
|
+
this.buildDeterministicInstanceJitterKey(
|
|
10829
|
+
`authority-bootstrap-handshake-retry-${attempt}`
|
|
10830
|
+
)
|
|
10831
|
+
);
|
|
10832
|
+
}
|
|
10833
|
+
scheduleAuthorityBootstrapHandshakeRetry(reason) {
|
|
10834
|
+
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
10835
|
+
return false;
|
|
10836
|
+
}
|
|
10837
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
10838
|
+
return false;
|
|
10839
|
+
}
|
|
10840
|
+
if (this.authorityBootstrapHandshakeInFlight) {
|
|
10841
|
+
return false;
|
|
10842
|
+
}
|
|
10843
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10844
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10845
|
+
}
|
|
10846
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
10847
|
+
return false;
|
|
10848
|
+
}
|
|
10849
|
+
const retryGeneration = this.authorityBootstrapHandshakeRetryGeneration;
|
|
10850
|
+
const retryReason = this.authorityBootstrapHandshakeRetryReason ?? "authority_bootstrap_handshake_retry";
|
|
10851
|
+
const attempt = this.authorityBootstrapHandshakeRetryIndex + 1;
|
|
10852
|
+
const baseDelayMs = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS[Math.min(
|
|
10853
|
+
this.authorityBootstrapHandshakeRetryIndex,
|
|
10854
|
+
AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length - 1
|
|
10855
|
+
)] ?? AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.at(-1);
|
|
10856
|
+
const delayMs = this.buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(
|
|
10857
|
+
baseDelayMs,
|
|
10858
|
+
attempt
|
|
10859
|
+
);
|
|
10860
|
+
this.authorityBootstrapHandshakeRetryIndex += 1;
|
|
10861
|
+
this.authorityBootstrapHandshakeRetryTimer = setTimeout(() => {
|
|
10862
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
10863
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished() || this.authorityBootstrapHandshakeInFlight || retryGeneration !== this.authorityBootstrapHandshakeRetryGeneration) {
|
|
10864
|
+
return;
|
|
10865
|
+
}
|
|
10866
|
+
this.requestAuthorityBootstrapHandshake({
|
|
10867
|
+
__reason: retryReason,
|
|
10868
|
+
__authorityBootstrapRetry: true,
|
|
10869
|
+
__authorityBootstrapRetryAttempt: attempt
|
|
10870
|
+
});
|
|
10871
|
+
}, delayMs);
|
|
10872
|
+
return true;
|
|
10873
|
+
}
|
|
10874
|
+
restartAuthorityBootstrapHandshakeRetryChain(reason) {
|
|
10875
|
+
this.invalidateAuthorityBootstrapHandshakeRetryState(reason);
|
|
10876
|
+
return this.scheduleAuthorityBootstrapHandshakeRetry(reason);
|
|
10877
|
+
}
|
|
10878
|
+
restartAuthorityBootstrapRecovery(reason) {
|
|
10879
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
10880
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
10881
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
10882
|
+
}
|
|
10883
|
+
return false;
|
|
10884
|
+
}
|
|
10885
|
+
this.authorityBootstrapRecoveryActive = true;
|
|
10886
|
+
this.invalidateAuthorityBootstrapHandshake();
|
|
10887
|
+
this.invalidateBootstrapFullSyncRetryState(reason);
|
|
10888
|
+
return this.restartAuthorityBootstrapHandshakeRetryChain(reason);
|
|
10889
|
+
}
|
|
10508
10890
|
requestAuthorityBootstrapHandshake(ctx) {
|
|
10509
10891
|
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
10510
10892
|
return false;
|
|
@@ -10711,12 +11093,16 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10711
11093
|
return;
|
|
10712
11094
|
}
|
|
10713
11095
|
const deputyTaskName = `Inquire ${map.intentName} via ${map.serviceName} (${map.taskName} v${map.taskVersion})`;
|
|
10714
|
-
const
|
|
11096
|
+
const shouldUseAuthorityBootstrapTimeout = map.serviceName === "CadenzaDB" && isMetaIntentName(map.intentName);
|
|
11097
|
+
const effectiveTimeout = shouldUseAuthorityBootstrapTimeout ? Math.max(map.timeout ?? 0, AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS) : map.timeout;
|
|
11098
|
+
const authorityBootstrapIntentSpec = map.serviceName === "CadenzaDB" ? getAuthorityBootstrapIntentSpec(map.intentName) : null;
|
|
11099
|
+
const authorityBootstrapTaskName = authorityBootstrapIntentSpec?.authorityTaskName ?? map.taskName;
|
|
11100
|
+
const deputyTask = authorityBootstrapIntentSpec ? CadenzaService.createMetaTask(
|
|
10715
11101
|
deputyTaskName,
|
|
10716
11102
|
async (ctx) => this.invokeAuthorityBootstrapRoutine(
|
|
10717
|
-
|
|
11103
|
+
authorityBootstrapTaskName,
|
|
10718
11104
|
ctx,
|
|
10719
|
-
|
|
11105
|
+
effectiveTimeout ?? AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS
|
|
10720
11106
|
),
|
|
10721
11107
|
"Routes reserved authority bootstrap inquiries directly through the post-handshake authority control-plane channel.",
|
|
10722
11108
|
{
|
|
@@ -10726,14 +11112,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10726
11112
|
) : isMetaIntentName(map.intentName) ? CadenzaService.createMetaDeputyTask(map.taskName, map.serviceName, {
|
|
10727
11113
|
register: false,
|
|
10728
11114
|
isHidden: true,
|
|
10729
|
-
timeout:
|
|
11115
|
+
timeout: effectiveTimeout,
|
|
10730
11116
|
retryCount: 1,
|
|
10731
11117
|
retryDelay: 50,
|
|
10732
11118
|
retryDelayFactor: 1.2
|
|
10733
11119
|
}) : CadenzaService.createDeputyTask(map.taskName, map.serviceName, {
|
|
10734
11120
|
register: false,
|
|
10735
11121
|
isHidden: true,
|
|
10736
|
-
timeout:
|
|
11122
|
+
timeout: effectiveTimeout,
|
|
10737
11123
|
retryCount: 1,
|
|
10738
11124
|
retryDelay: 50,
|
|
10739
11125
|
retryDelayFactor: 1.2
|
|
@@ -10747,7 +11133,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10747
11133
|
key,
|
|
10748
11134
|
intentName: map.intentName,
|
|
10749
11135
|
serviceName: map.serviceName,
|
|
10750
|
-
remoteTaskName:
|
|
11136
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
10751
11137
|
remoteTaskVersion: map.taskVersion,
|
|
10752
11138
|
localTaskName: deputyTask.name || deputyTaskName,
|
|
10753
11139
|
localTask: deputyTask
|
|
@@ -10759,7 +11145,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10759
11145
|
localServiceName: this.serviceName,
|
|
10760
11146
|
intentName: map.intentName,
|
|
10761
11147
|
remoteServiceName: map.serviceName,
|
|
10762
|
-
remoteTaskName:
|
|
11148
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
10763
11149
|
remoteTaskVersion: map.taskVersion
|
|
10764
11150
|
});
|
|
10765
11151
|
}
|
|
@@ -11459,6 +11845,50 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
11459
11845
|
);
|
|
11460
11846
|
});
|
|
11461
11847
|
}
|
|
11848
|
+
hasPendingRouteableInstanceForSelection(serviceName, ctx, role, targetServiceInstanceId) {
|
|
11849
|
+
return (this.instances.get(serviceName) ?? []).some((instance) => {
|
|
11850
|
+
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
11851
|
+
return false;
|
|
11852
|
+
}
|
|
11853
|
+
if (!instance.isActive || instance.isNonResponsive || instance.isBlocked) {
|
|
11854
|
+
return false;
|
|
11855
|
+
}
|
|
11856
|
+
if (instance.isFrontend) {
|
|
11857
|
+
return false;
|
|
11858
|
+
}
|
|
11859
|
+
const transport = this.selectTransportForInstance(instance, ctx, role);
|
|
11860
|
+
if (!transport) {
|
|
11861
|
+
return false;
|
|
11862
|
+
}
|
|
11863
|
+
return !this.hasTransportClientReady(instance, transport);
|
|
11864
|
+
});
|
|
11865
|
+
}
|
|
11866
|
+
maybeSchedulePendingRouteSelectionRetry(ctx, serviceName) {
|
|
11867
|
+
const signalName = String(
|
|
11868
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
11869
|
+
).trim();
|
|
11870
|
+
if (!signalName) {
|
|
11871
|
+
return false;
|
|
11872
|
+
}
|
|
11873
|
+
const attempt = Math.max(
|
|
11874
|
+
0,
|
|
11875
|
+
Number(ctx.__pendingRouteSelectionAttempt ?? 0) || 0
|
|
11876
|
+
);
|
|
11877
|
+
const delayMs = PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS[attempt];
|
|
11878
|
+
if (delayMs === void 0) {
|
|
11879
|
+
return false;
|
|
11880
|
+
}
|
|
11881
|
+
CadenzaService.schedule(
|
|
11882
|
+
signalName,
|
|
11883
|
+
{
|
|
11884
|
+
...ctx,
|
|
11885
|
+
__pendingRouteSelectionAttempt: attempt + 1,
|
|
11886
|
+
__pendingRouteSelectionServiceName: serviceName
|
|
11887
|
+
},
|
|
11888
|
+
delayMs
|
|
11889
|
+
);
|
|
11890
|
+
return true;
|
|
11891
|
+
}
|
|
11462
11892
|
refreshRoutingCooldownsForService(serviceName) {
|
|
11463
11893
|
if (!serviceName) {
|
|
11464
11894
|
return;
|
|
@@ -12278,8 +12708,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
12278
12708
|
this.refreshRoutingCooldownsForService(serviceName);
|
|
12279
12709
|
}
|
|
12280
12710
|
clearTransportReadyFromContext(ctx) {
|
|
12281
|
-
const serviceName =
|
|
12282
|
-
const explicitRouteKey = String(ctx.routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
12711
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
12712
|
+
const explicitRouteKey = String(ctx.routeKey ?? ctx.__routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
12283
12713
|
const serviceTransportId = String(
|
|
12284
12714
|
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
12285
12715
|
).trim();
|
|
@@ -13874,6 +14304,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
13874
14304
|
this.bootstrapFullSyncRetryGeneration = 0;
|
|
13875
14305
|
this.bootstrapFullSyncSatisfied = false;
|
|
13876
14306
|
this.bootstrapFullSyncRetryReason = null;
|
|
14307
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
14308
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
14309
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
14310
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
13877
14311
|
this.knownGlobalSignalMaps.clear();
|
|
13878
14312
|
this.authorityBootstrapRoute = {
|
|
13879
14313
|
origin: null,
|
|
@@ -17067,163 +17501,6 @@ var SocketController = class _SocketController {
|
|
|
17067
17501
|
}
|
|
17068
17502
|
};
|
|
17069
17503
|
|
|
17070
|
-
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
17071
|
-
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
17072
|
-
function readString(value) {
|
|
17073
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
17074
|
-
}
|
|
17075
|
-
function readRecord(value) {
|
|
17076
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
17077
|
-
}
|
|
17078
|
-
function normalizeRoutineExecutionTraceFields(data) {
|
|
17079
|
-
if (!data) {
|
|
17080
|
-
return null;
|
|
17081
|
-
}
|
|
17082
|
-
const normalizedData = { ...data };
|
|
17083
|
-
const traceId = readString(
|
|
17084
|
-
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
17085
|
-
);
|
|
17086
|
-
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
17087
|
-
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
17088
|
-
const serviceName = readString(
|
|
17089
|
-
normalizedData.service_name ?? normalizedData.serviceName
|
|
17090
|
-
);
|
|
17091
|
-
const serviceInstanceId = readString(
|
|
17092
|
-
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
17093
|
-
);
|
|
17094
|
-
if (traceId) {
|
|
17095
|
-
normalizedData.execution_trace_id = traceId;
|
|
17096
|
-
}
|
|
17097
|
-
if (metaContext) {
|
|
17098
|
-
normalizedData.meta_context = metaContext;
|
|
17099
|
-
}
|
|
17100
|
-
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
17101
|
-
normalizedData.is_meta = isMeta;
|
|
17102
|
-
}
|
|
17103
|
-
if (serviceName) {
|
|
17104
|
-
normalizedData.service_name = serviceName;
|
|
17105
|
-
}
|
|
17106
|
-
if (serviceInstanceId) {
|
|
17107
|
-
normalizedData.service_instance_id = serviceInstanceId;
|
|
17108
|
-
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
17109
|
-
normalizedData.service_instance_id = null;
|
|
17110
|
-
}
|
|
17111
|
-
delete normalizedData.executionTraceId;
|
|
17112
|
-
delete normalizedData.traceId;
|
|
17113
|
-
delete normalizedData.metaContext;
|
|
17114
|
-
delete normalizedData.isMeta;
|
|
17115
|
-
delete normalizedData.serviceName;
|
|
17116
|
-
delete normalizedData.serviceInstanceId;
|
|
17117
|
-
return normalizedData;
|
|
17118
|
-
}
|
|
17119
|
-
function stripExecutionTraceServiceInstanceFields(data) {
|
|
17120
|
-
if (!data) {
|
|
17121
|
-
return null;
|
|
17122
|
-
}
|
|
17123
|
-
const normalizedData = { ...data };
|
|
17124
|
-
delete normalizedData.serviceInstanceId;
|
|
17125
|
-
delete normalizedData.service_instance_id;
|
|
17126
|
-
return normalizedData;
|
|
17127
|
-
}
|
|
17128
|
-
function normalizeEnsureData(entityType, data) {
|
|
17129
|
-
switch (entityType) {
|
|
17130
|
-
case "execution_trace":
|
|
17131
|
-
return stripExecutionTraceServiceInstanceFields(data);
|
|
17132
|
-
case "routine_execution":
|
|
17133
|
-
return normalizeRoutineExecutionTraceFields(data);
|
|
17134
|
-
default:
|
|
17135
|
-
return data;
|
|
17136
|
-
}
|
|
17137
|
-
}
|
|
17138
|
-
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
17139
|
-
const normalizedEntityId = readString(entityId);
|
|
17140
|
-
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
17141
|
-
}
|
|
17142
|
-
function resolveEnsureEntityId(entityType, data) {
|
|
17143
|
-
switch (entityType) {
|
|
17144
|
-
default:
|
|
17145
|
-
return readString(data.uuid);
|
|
17146
|
-
}
|
|
17147
|
-
}
|
|
17148
|
-
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
17149
|
-
return readString(
|
|
17150
|
-
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
17151
|
-
);
|
|
17152
|
-
}
|
|
17153
|
-
function dedupeDependencies(values) {
|
|
17154
|
-
return Array.from(
|
|
17155
|
-
new Set(values.filter((value) => typeof value === "string"))
|
|
17156
|
-
);
|
|
17157
|
-
}
|
|
17158
|
-
function resolveTraceIdFromData(data) {
|
|
17159
|
-
if (!data) {
|
|
17160
|
-
return null;
|
|
17161
|
-
}
|
|
17162
|
-
return readString(
|
|
17163
|
-
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
17164
|
-
);
|
|
17165
|
-
}
|
|
17166
|
-
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
17167
|
-
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
17168
|
-
if (!normalizedData) {
|
|
17169
|
-
return null;
|
|
17170
|
-
}
|
|
17171
|
-
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
17172
|
-
if (!entityId) {
|
|
17173
|
-
return null;
|
|
17174
|
-
}
|
|
17175
|
-
return {
|
|
17176
|
-
kind: "ensure",
|
|
17177
|
-
entityType,
|
|
17178
|
-
entityId,
|
|
17179
|
-
data: normalizedData,
|
|
17180
|
-
deps: dedupeDependencies(deps)
|
|
17181
|
-
};
|
|
17182
|
-
}
|
|
17183
|
-
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
17184
|
-
const normalizedData = readRecord(data);
|
|
17185
|
-
const normalizedFilter = readRecord(filter);
|
|
17186
|
-
if (!normalizedData || !normalizedFilter) {
|
|
17187
|
-
return null;
|
|
17188
|
-
}
|
|
17189
|
-
const entityId = resolveUpdateEntityId(
|
|
17190
|
-
entityType,
|
|
17191
|
-
normalizedData,
|
|
17192
|
-
normalizedFilter
|
|
17193
|
-
);
|
|
17194
|
-
if (!entityId) {
|
|
17195
|
-
return null;
|
|
17196
|
-
}
|
|
17197
|
-
return {
|
|
17198
|
-
kind: "update",
|
|
17199
|
-
entityType,
|
|
17200
|
-
entityId,
|
|
17201
|
-
data: normalizedData,
|
|
17202
|
-
filter: normalizedFilter,
|
|
17203
|
-
deps: dedupeDependencies(deps)
|
|
17204
|
-
};
|
|
17205
|
-
}
|
|
17206
|
-
function createExecutionPersistenceBundle(input) {
|
|
17207
|
-
const ensures = (input.ensures ?? []).filter(
|
|
17208
|
-
(event) => Boolean(event)
|
|
17209
|
-
);
|
|
17210
|
-
const updates = (input.updates ?? []).filter(
|
|
17211
|
-
(event) => Boolean(event)
|
|
17212
|
-
);
|
|
17213
|
-
if (ensures.length === 0 && updates.length === 0) {
|
|
17214
|
-
return null;
|
|
17215
|
-
}
|
|
17216
|
-
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));
|
|
17217
|
-
if (!traceId) {
|
|
17218
|
-
return null;
|
|
17219
|
-
}
|
|
17220
|
-
return {
|
|
17221
|
-
traceId,
|
|
17222
|
-
ensures,
|
|
17223
|
-
updates
|
|
17224
|
-
};
|
|
17225
|
-
}
|
|
17226
|
-
|
|
17227
17504
|
// src/signals/SignalController.ts
|
|
17228
17505
|
import { v4 as uuid6 } from "uuid";
|
|
17229
17506
|
function resolveExecutionObservabilityServiceInstanceId() {
|
|
@@ -17376,7 +17653,7 @@ var SignalController = class _SignalController {
|
|
|
17376
17653
|
intent: traceContext.__metadata?.__intent ?? traceContext.__intent ?? null,
|
|
17377
17654
|
context: {
|
|
17378
17655
|
id: uuid6(),
|
|
17379
|
-
context:
|
|
17656
|
+
context: sanitizedTraceContext
|
|
17380
17657
|
},
|
|
17381
17658
|
is_meta: signalEmission.isMeta,
|
|
17382
17659
|
service_name: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -17968,6 +18245,18 @@ import {
|
|
|
17968
18245
|
} from "@cadenza.io/core";
|
|
17969
18246
|
import { v4 as uuid7 } from "uuid";
|
|
17970
18247
|
var ACTOR_TASK_METADATA2 = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
18248
|
+
var ROUTING_CRITICAL_META_INTENTS2 = /* @__PURE__ */ new Set([
|
|
18249
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
18250
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
18251
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
18252
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
18253
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
18254
|
+
]);
|
|
18255
|
+
var ROUTING_CRITICAL_META_SIGNALS2 = /* @__PURE__ */ new Set([
|
|
18256
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
18257
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
18258
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
18259
|
+
]);
|
|
17971
18260
|
function getActorTaskRuntimeMetadata2(taskFunction) {
|
|
17972
18261
|
if (typeof taskFunction !== "function") {
|
|
17973
18262
|
return void 0;
|
|
@@ -18059,7 +18348,7 @@ function buildIntentRegistryData(intent) {
|
|
|
18059
18348
|
};
|
|
18060
18349
|
}
|
|
18061
18350
|
function isLocalOnlySyncIntent(intentName) {
|
|
18062
|
-
return intentName === META_ACTOR_SESSION_STATE_PERSIST_INTENT2;
|
|
18351
|
+
return intentName === META_ACTOR_SESSION_STATE_PERSIST_INTENT2 || intentName.startsWith("meta-") || intentName.startsWith("global.meta-");
|
|
18063
18352
|
}
|
|
18064
18353
|
function getJoinedContextValue(ctx, key) {
|
|
18065
18354
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
@@ -18099,6 +18388,32 @@ function buildMinimalSyncSignalContext(ctx, extra = {}) {
|
|
|
18099
18388
|
}
|
|
18100
18389
|
return nextContext;
|
|
18101
18390
|
}
|
|
18391
|
+
function buildMinimalSyncShardContext(ctx, extra = {}) {
|
|
18392
|
+
return {
|
|
18393
|
+
...buildMinimalSyncSignalContext(ctx, extra),
|
|
18394
|
+
tasks: void 0,
|
|
18395
|
+
signals: void 0,
|
|
18396
|
+
intents: void 0,
|
|
18397
|
+
actors: void 0,
|
|
18398
|
+
routines: void 0,
|
|
18399
|
+
serviceInstances: void 0,
|
|
18400
|
+
service_instance_rows: void 0,
|
|
18401
|
+
service_instance_transport_rows: void 0,
|
|
18402
|
+
serviceManifests: void 0,
|
|
18403
|
+
manifests: void 0,
|
|
18404
|
+
signalToTaskMaps: void 0,
|
|
18405
|
+
signal_to_task_maps: void 0,
|
|
18406
|
+
intentToTaskMaps: void 0,
|
|
18407
|
+
intent_to_task_maps: void 0,
|
|
18408
|
+
actorTaskMaps: void 0,
|
|
18409
|
+
actor_task_maps: void 0,
|
|
18410
|
+
directionalTaskMaps: void 0,
|
|
18411
|
+
directional_task_maps: void 0,
|
|
18412
|
+
taskToRoutineMaps: void 0,
|
|
18413
|
+
task_to_routine_maps: void 0,
|
|
18414
|
+
task: void 0
|
|
18415
|
+
};
|
|
18416
|
+
}
|
|
18102
18417
|
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
18103
18418
|
const pickQueryData = (source, allowedKeys) => {
|
|
18104
18419
|
const next = {};
|
|
@@ -18136,7 +18451,40 @@ var DEFAULT_SYNC_CYCLE_RUNTIME_STATE = {
|
|
|
18136
18451
|
activeSyncCycleStartedAt: 0,
|
|
18137
18452
|
phase: "idle"
|
|
18138
18453
|
};
|
|
18139
|
-
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY =
|
|
18454
|
+
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY = 2;
|
|
18455
|
+
function stripSyncResolverPayload(ctx) {
|
|
18456
|
+
const nextContext = {
|
|
18457
|
+
...ctx
|
|
18458
|
+
};
|
|
18459
|
+
const bulkyStructuralKeys = [
|
|
18460
|
+
"tasks",
|
|
18461
|
+
"helpers",
|
|
18462
|
+
"globals",
|
|
18463
|
+
"signals",
|
|
18464
|
+
"intents",
|
|
18465
|
+
"actors",
|
|
18466
|
+
"routines",
|
|
18467
|
+
"serviceInstances",
|
|
18468
|
+
"serviceInstanceTransports",
|
|
18469
|
+
"serviceManifests",
|
|
18470
|
+
"signalToTaskMaps",
|
|
18471
|
+
"intentToTaskMaps",
|
|
18472
|
+
"actorTaskMaps",
|
|
18473
|
+
"directionalTaskMaps",
|
|
18474
|
+
"taskToRoutineMaps",
|
|
18475
|
+
"registeredGlobalSignals",
|
|
18476
|
+
"registeredGlobalIntents",
|
|
18477
|
+
"registeredActors",
|
|
18478
|
+
"registeredRoutines"
|
|
18479
|
+
];
|
|
18480
|
+
delete nextContext.__resolverOriginalContext;
|
|
18481
|
+
delete nextContext.__resolverQueryData;
|
|
18482
|
+
delete nextContext.joinedContexts;
|
|
18483
|
+
for (const key of bulkyStructuralKeys) {
|
|
18484
|
+
delete nextContext[key];
|
|
18485
|
+
}
|
|
18486
|
+
return nextContext;
|
|
18487
|
+
}
|
|
18140
18488
|
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
18141
18489
|
if (!graph) {
|
|
18142
18490
|
return void 0;
|
|
@@ -18148,28 +18496,14 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
|
18148
18496
|
return graph.completionTask;
|
|
18149
18497
|
}
|
|
18150
18498
|
function buildSyncExecutionEnvelope(ctx, queryData) {
|
|
18151
|
-
const originalContext =
|
|
18499
|
+
const originalContext = stripSyncResolverPayload(ctx);
|
|
18152
18500
|
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();
|
|
18153
|
-
const rootDbOperationFields = {};
|
|
18154
|
-
for (const key of [
|
|
18155
|
-
"data",
|
|
18156
|
-
"batch",
|
|
18157
|
-
"transaction",
|
|
18158
|
-
"onConflict",
|
|
18159
|
-
"filter",
|
|
18160
|
-
"fields"
|
|
18161
|
-
]) {
|
|
18162
|
-
if (Object.prototype.hasOwnProperty.call(queryData, key)) {
|
|
18163
|
-
rootDbOperationFields[key] = queryData[key];
|
|
18164
|
-
}
|
|
18165
|
-
}
|
|
18166
18501
|
const nextContext = {
|
|
18167
18502
|
__syncing: ctx.__syncing === true || ctx.__metadata?.__syncing === true || false,
|
|
18168
18503
|
__syncSourceServiceName: syncSourceServiceName,
|
|
18169
18504
|
__preferredTransportProtocol: "rest",
|
|
18170
18505
|
__resolverOriginalContext: originalContext,
|
|
18171
18506
|
__resolverQueryData: queryData,
|
|
18172
|
-
...rootDbOperationFields,
|
|
18173
18507
|
queryData
|
|
18174
18508
|
};
|
|
18175
18509
|
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
@@ -18188,6 +18522,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
18188
18522
|
Number(options.concurrency),
|
|
18189
18523
|
REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY
|
|
18190
18524
|
) : REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY,
|
|
18525
|
+
timeout: Number(options.timeout) > 0 ? Number(options.timeout) : 6e4,
|
|
18191
18526
|
register: false,
|
|
18192
18527
|
isHidden: true
|
|
18193
18528
|
});
|
|
@@ -18227,13 +18562,15 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
18227
18562
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
18228
18563
|
`Finalize graph sync insert for ${tableName}`,
|
|
18229
18564
|
(ctx) => {
|
|
18230
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ?
|
|
18565
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? stripSyncResolverPayload(
|
|
18566
|
+
ctx.__resolverOriginalContext
|
|
18567
|
+
) : {};
|
|
18231
18568
|
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
18232
|
-
const normalizedContext = {
|
|
18569
|
+
const normalizedContext = stripSyncResolverPayload({
|
|
18233
18570
|
...originalContext,
|
|
18234
18571
|
...ctx,
|
|
18235
18572
|
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : originalQueryData
|
|
18236
|
-
};
|
|
18573
|
+
});
|
|
18237
18574
|
if (originalContext.__syncing === true && !didSyncInsertSucceed(normalizedContext)) {
|
|
18238
18575
|
CadenzaService.debounce("meta.sync_requested", {}, 1e3);
|
|
18239
18576
|
}
|
|
@@ -18307,22 +18644,103 @@ function isBootstrapLocalOnlySignal(signalName) {
|
|
|
18307
18644
|
function hasNonZeroPending(summary) {
|
|
18308
18645
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
18309
18646
|
}
|
|
18647
|
+
function shouldSkipIdleBootstrapSyncTrigger(input) {
|
|
18648
|
+
if (input?.__forceSyncCycle === true) {
|
|
18649
|
+
return false;
|
|
18650
|
+
}
|
|
18651
|
+
const triggerSignal = typeof input?.__signal === "string" ? input.__signal.trim() : "";
|
|
18652
|
+
const reason = typeof input?.__reason === "string" ? input.__reason.trim() : "";
|
|
18653
|
+
if (!triggerSignal) {
|
|
18654
|
+
return input?.__bootstrapFullSync === true || reason.length > 0;
|
|
18655
|
+
}
|
|
18656
|
+
return triggerSignal === "meta.sync_controller.sync_tick" || triggerSignal === "meta.sync_requested";
|
|
18657
|
+
}
|
|
18310
18658
|
function isRegistrableRoutine(routine) {
|
|
18311
18659
|
return routine?.name !== "RestServer";
|
|
18312
18660
|
}
|
|
18313
18661
|
function scheduleSyncPassEvaluation(delayMs = SYNC_PASS_SETTLE_DELAY_MS) {
|
|
18314
18662
|
CadenzaService.debounce(SYNC_PASS_EVALUATION_SIGNAL, {}, delayMs);
|
|
18315
18663
|
}
|
|
18664
|
+
function isRoutingCriticalMetaSignalName(signalName) {
|
|
18665
|
+
return ROUTING_CRITICAL_META_SIGNALS2.has(canonicalizeSignalName2(signalName));
|
|
18666
|
+
}
|
|
18667
|
+
function isRoutingCriticalMetaIntentName(intentName) {
|
|
18668
|
+
return ROUTING_CRITICAL_META_INTENTS2.has(String(intentName ?? "").trim());
|
|
18669
|
+
}
|
|
18670
|
+
function isRoutingCapabilityBootstrapSignalName(signalName) {
|
|
18671
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18672
|
+
if (!canonicalSignalName) {
|
|
18673
|
+
return false;
|
|
18674
|
+
}
|
|
18675
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
18676
|
+
if (!signalParts.isGlobal) {
|
|
18677
|
+
return false;
|
|
18678
|
+
}
|
|
18679
|
+
if (signalParts.isMeta) {
|
|
18680
|
+
return isRoutingCriticalMetaSignalName(canonicalSignalName);
|
|
18681
|
+
}
|
|
18682
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
18683
|
+
}
|
|
18684
|
+
function isRouteableBusinessBootstrapSignalName(signalName) {
|
|
18685
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18686
|
+
if (!canonicalSignalName) {
|
|
18687
|
+
return false;
|
|
18688
|
+
}
|
|
18689
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
18690
|
+
if (!signalParts.isGlobal || signalParts.isMeta) {
|
|
18691
|
+
return false;
|
|
18692
|
+
}
|
|
18693
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
18694
|
+
}
|
|
18695
|
+
function isRouteableBusinessBootstrapIntentName(intentName) {
|
|
18696
|
+
const normalizedIntentName = String(intentName ?? "").trim();
|
|
18697
|
+
return normalizedIntentName.length > 0 && !isLocalOnlySyncIntent(normalizedIntentName) && !isMetaIntentName(normalizedIntentName);
|
|
18698
|
+
}
|
|
18699
|
+
function isRoutingCapabilityBootstrapTask(task) {
|
|
18700
|
+
if (!task || !task.register || task.isHidden || task.isDeputy) {
|
|
18701
|
+
return false;
|
|
18702
|
+
}
|
|
18703
|
+
const isMetaTask = task.isMeta === true || task.isSubMeta === true;
|
|
18704
|
+
for (const signalName of task.observedSignals) {
|
|
18705
|
+
if (isMetaTask ? isRoutingCriticalMetaSignalName(signalName) : isRouteableBusinessBootstrapSignalName(signalName)) {
|
|
18706
|
+
return true;
|
|
18707
|
+
}
|
|
18708
|
+
}
|
|
18709
|
+
for (const intentName of task.handlesIntents) {
|
|
18710
|
+
if (isMetaTask ? isRoutingCriticalMetaIntentName(intentName) : isRouteableBusinessBootstrapIntentName(intentName)) {
|
|
18711
|
+
return true;
|
|
18712
|
+
}
|
|
18713
|
+
}
|
|
18714
|
+
return false;
|
|
18715
|
+
}
|
|
18716
|
+
function shouldDirectSyncSignalTaskMapForBootstrap(task, signalName) {
|
|
18717
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
18718
|
+
if (!task || !canonicalSignalName || task.isHidden || !task.register || !task.registered) {
|
|
18719
|
+
return false;
|
|
18720
|
+
}
|
|
18721
|
+
if (!decomposeSignalName(canonicalSignalName).isGlobal) {
|
|
18722
|
+
return false;
|
|
18723
|
+
}
|
|
18724
|
+
if (!isRegistrableBootstrapTask(task)) {
|
|
18725
|
+
return false;
|
|
18726
|
+
}
|
|
18727
|
+
return isRoutingCapabilityBootstrapSignalName(canonicalSignalName);
|
|
18728
|
+
}
|
|
18729
|
+
function isRegistrableBootstrapTask(task) {
|
|
18730
|
+
return isRoutingCapabilityBootstrapTask(task);
|
|
18731
|
+
}
|
|
18316
18732
|
function getRegistrableTasks() {
|
|
18317
18733
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
18318
|
-
|
|
18734
|
+
isRegistrableBootstrapTask
|
|
18319
18735
|
);
|
|
18320
18736
|
}
|
|
18321
18737
|
function getBootstrapBlockingTasks() {
|
|
18322
|
-
return getRegistrableTasks()
|
|
18738
|
+
return getRegistrableTasks();
|
|
18323
18739
|
}
|
|
18324
18740
|
function getRegistrableRoutines() {
|
|
18325
|
-
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
18741
|
+
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
18742
|
+
isRegistrableRoutine
|
|
18743
|
+
);
|
|
18326
18744
|
}
|
|
18327
18745
|
function getRegistrableSignalObservers() {
|
|
18328
18746
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
@@ -18332,19 +18750,23 @@ function getRegistrableSignalObservers() {
|
|
|
18332
18750
|
const canonicalObservers = /* @__PURE__ */ new Map();
|
|
18333
18751
|
for (const [rawSignalName, observer] of signalObservers.entries()) {
|
|
18334
18752
|
const signalName = canonicalizeSignalName2(rawSignalName);
|
|
18335
|
-
|
|
18753
|
+
const isRoutingCriticalMetaSignal2 = signalName.length > 0 && isRoutingCriticalMetaSignalName(signalName);
|
|
18754
|
+
if (!signalName || isBootstrapLocalOnlySignal(signalName) && !isRoutingCriticalMetaSignal2) {
|
|
18755
|
+
continue;
|
|
18756
|
+
}
|
|
18757
|
+
if (!decomposeSignalName(signalName).isGlobal) {
|
|
18336
18758
|
continue;
|
|
18337
18759
|
}
|
|
18338
18760
|
const observerTasks = Array.isArray(observer?.tasks) ? observer.tasks : observer?.tasks instanceof Set ? Array.from(observer.tasks) : [];
|
|
18339
|
-
if (observerTasks.length > 0 && !observerTasks.some(
|
|
18340
|
-
(task) => task?.register && !task.isHidden && !task.isDeputy
|
|
18341
|
-
)) {
|
|
18761
|
+
if (observerTasks.length > 0 && !observerTasks.some((task) => isRegistrableBootstrapTask(task))) {
|
|
18342
18762
|
continue;
|
|
18343
18763
|
}
|
|
18764
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
18344
18765
|
const existing = canonicalObservers.get(signalName);
|
|
18345
18766
|
canonicalObservers.set(signalName, {
|
|
18346
18767
|
signalName,
|
|
18347
|
-
registered: existing?.registered === true || observer?.registered === true
|
|
18768
|
+
registered: existing?.registered === true || observer?.registered === true,
|
|
18769
|
+
metadata: existing?.metadata ?? metadata
|
|
18348
18770
|
});
|
|
18349
18771
|
}
|
|
18350
18772
|
return Array.from(canonicalObservers.values());
|
|
@@ -18355,7 +18777,10 @@ function isLocallyHandledIntentName(intentName) {
|
|
|
18355
18777
|
return false;
|
|
18356
18778
|
}
|
|
18357
18779
|
for (const task of observer.tasks) {
|
|
18358
|
-
if (
|
|
18780
|
+
if (!task) {
|
|
18781
|
+
continue;
|
|
18782
|
+
}
|
|
18783
|
+
if (isRegistrableBootstrapTask(task)) {
|
|
18359
18784
|
return true;
|
|
18360
18785
|
}
|
|
18361
18786
|
}
|
|
@@ -18386,8 +18811,12 @@ function buildActorRegistrationKey(actor, serviceName) {
|
|
|
18386
18811
|
return `${name}|${data.version}|${serviceName}`;
|
|
18387
18812
|
}
|
|
18388
18813
|
function isBootstrapRegistrableActor(actor) {
|
|
18389
|
-
const
|
|
18390
|
-
|
|
18814
|
+
const actorData = buildActorRegistrationData(actor);
|
|
18815
|
+
const actorName = String(actorData.name ?? "").trim();
|
|
18816
|
+
if (!actorName || isBootstrapLocalOnlyActorName(actorName)) {
|
|
18817
|
+
return false;
|
|
18818
|
+
}
|
|
18819
|
+
return false;
|
|
18391
18820
|
}
|
|
18392
18821
|
function buildSignalTaskMapRegistrationKey(input) {
|
|
18393
18822
|
return `${canonicalizeSignalName2(input.signalName)}|${input.serviceName}|${input.taskName}|${input.taskVersion ?? 1}`;
|
|
@@ -18554,6 +18983,7 @@ function resolveSignalNameFromSyncContext(ctx) {
|
|
|
18554
18983
|
var GraphSyncController = class _GraphSyncController {
|
|
18555
18984
|
constructor() {
|
|
18556
18985
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
18986
|
+
this.requestedActorRegistrations = /* @__PURE__ */ new Set();
|
|
18557
18987
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
18558
18988
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
18559
18989
|
this.authoritativeSignalTaskMaps = /* @__PURE__ */ new Set();
|
|
@@ -18882,9 +19312,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18882
19312
|
for (const routine of routines) {
|
|
18883
19313
|
if (!isRegistrableRoutine(routine)) continue;
|
|
18884
19314
|
if (routine.registered) continue;
|
|
19315
|
+
if (routine.registrationRequested === true) continue;
|
|
19316
|
+
routine.registrationRequested = true;
|
|
18885
19317
|
this.routinesSynced = false;
|
|
18886
|
-
yield {
|
|
18887
|
-
__syncing: ctx.__syncing,
|
|
19318
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
18888
19319
|
data: {
|
|
18889
19320
|
name: routine.name,
|
|
18890
19321
|
version: routine.version,
|
|
@@ -18893,7 +19324,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18893
19324
|
is_meta: routine.isMeta
|
|
18894
19325
|
},
|
|
18895
19326
|
__routineName: routine.name
|
|
18896
|
-
};
|
|
19327
|
+
});
|
|
18897
19328
|
}
|
|
18898
19329
|
}.bind(this)
|
|
18899
19330
|
);
|
|
@@ -18911,15 +19342,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18911
19342
|
{ concurrency: 30 }
|
|
18912
19343
|
);
|
|
18913
19344
|
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
19345
|
+
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
18914
19346
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19347
|
+
if (routine) {
|
|
19348
|
+
routine.registrationRequested = false;
|
|
19349
|
+
}
|
|
18915
19350
|
return;
|
|
18916
19351
|
}
|
|
18917
19352
|
scheduleSyncPassEvaluation();
|
|
18918
|
-
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
18919
19353
|
if (!routine) {
|
|
18920
19354
|
return true;
|
|
18921
19355
|
}
|
|
18922
19356
|
routine.registered = true;
|
|
19357
|
+
routine.registrationRequested = false;
|
|
18923
19358
|
return true;
|
|
18924
19359
|
}).then(gatherRoutineRegistrationTask);
|
|
18925
19360
|
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
@@ -18946,8 +19381,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18946
19381
|
if (!nextTask?.registered) {
|
|
18947
19382
|
continue;
|
|
18948
19383
|
}
|
|
18949
|
-
yield {
|
|
18950
|
-
__syncing: ctx.__syncing,
|
|
19384
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
18951
19385
|
data: {
|
|
18952
19386
|
task_name: nextTask.name,
|
|
18953
19387
|
task_version: nextTask.version,
|
|
@@ -18957,7 +19391,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
18957
19391
|
},
|
|
18958
19392
|
__routineName: routine.name,
|
|
18959
19393
|
__taskName: nextTask.name
|
|
18960
|
-
};
|
|
19394
|
+
});
|
|
18961
19395
|
}
|
|
18962
19396
|
}
|
|
18963
19397
|
}
|
|
@@ -19011,7 +19445,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19011
19445
|
signalName: canonicalizeSignalName2(signal.signal),
|
|
19012
19446
|
data: signal.data
|
|
19013
19447
|
})).filter((signal) => {
|
|
19014
|
-
|
|
19448
|
+
const isRoutingCriticalMetaSignal2 = isRoutingCriticalMetaSignalName(signal.signalName);
|
|
19449
|
+
if (!signal.signalName || signal.data?.registered || isBootstrapLocalOnlySignal(signal.signalName) && !isRoutingCriticalMetaSignal2 || signal.data?.metadata?.is_meta === true && !isRoutingCriticalMetaSignal2) {
|
|
19015
19450
|
return false;
|
|
19016
19451
|
}
|
|
19017
19452
|
if (seenSignals.has(signal.signalName)) {
|
|
@@ -19021,10 +19456,20 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19021
19456
|
return true;
|
|
19022
19457
|
}).map((signal) => signal.signalName);
|
|
19023
19458
|
for (const signal of filteredSignals) {
|
|
19459
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19460
|
+
if (!signalObservers?.has(signal)) {
|
|
19461
|
+
CadenzaService.signalBroker.addSignal(signal);
|
|
19462
|
+
}
|
|
19463
|
+
const observer = signalObservers?.get(signal);
|
|
19464
|
+
if (observer?.registrationRequested === true) {
|
|
19465
|
+
continue;
|
|
19466
|
+
}
|
|
19467
|
+
if (observer) {
|
|
19468
|
+
observer.registrationRequested = true;
|
|
19469
|
+
}
|
|
19024
19470
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
19025
19471
|
this.signalsSynced = false;
|
|
19026
|
-
yield {
|
|
19027
|
-
__syncing: ctx.__syncing,
|
|
19472
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19028
19473
|
data: {
|
|
19029
19474
|
name: signal,
|
|
19030
19475
|
is_global: isGlobal,
|
|
@@ -19033,7 +19478,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19033
19478
|
is_meta: isMeta
|
|
19034
19479
|
},
|
|
19035
19480
|
__signal: signal
|
|
19036
|
-
};
|
|
19481
|
+
});
|
|
19037
19482
|
}
|
|
19038
19483
|
}.bind(this)
|
|
19039
19484
|
);
|
|
@@ -19055,21 +19500,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19055
19500
|
(ctx, emit2) => {
|
|
19056
19501
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
19057
19502
|
const signalName = resolveSignalNameFromSyncContext(ctx);
|
|
19503
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19504
|
+
const observer = signalName ? signalObservers?.get(signalName) : void 0;
|
|
19058
19505
|
if (!insertSucceeded) {
|
|
19506
|
+
if (observer) {
|
|
19507
|
+
observer.registrationRequested = false;
|
|
19508
|
+
}
|
|
19059
19509
|
return;
|
|
19060
19510
|
}
|
|
19061
19511
|
scheduleSyncPassEvaluation();
|
|
19062
19512
|
if (!signalName) {
|
|
19063
19513
|
return false;
|
|
19064
19514
|
}
|
|
19065
|
-
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
19066
19515
|
if (!signalObservers?.has(signalName)) {
|
|
19067
19516
|
CadenzaService.signalBroker.addSignal(signalName);
|
|
19068
19517
|
}
|
|
19069
|
-
const
|
|
19070
|
-
if (
|
|
19071
|
-
|
|
19072
|
-
|
|
19518
|
+
const resolvedObserver = signalObservers?.get(signalName);
|
|
19519
|
+
if (resolvedObserver) {
|
|
19520
|
+
resolvedObserver.registered = true;
|
|
19521
|
+
resolvedObserver.registrationRequested = false;
|
|
19073
19522
|
}
|
|
19074
19523
|
emit2(
|
|
19075
19524
|
"meta.sync_controller.signal_registered",
|
|
@@ -19149,8 +19598,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19149
19598
|
return;
|
|
19150
19599
|
}
|
|
19151
19600
|
for (const task of tasks) {
|
|
19152
|
-
if (
|
|
19601
|
+
if (!task) {
|
|
19602
|
+
continue;
|
|
19603
|
+
}
|
|
19604
|
+
if (!isRegistrableBootstrapTask(task)) continue;
|
|
19153
19605
|
if (task.registered) continue;
|
|
19606
|
+
if (task.registrationRequested === true) continue;
|
|
19607
|
+
task.registrationRequested = true;
|
|
19154
19608
|
const { __functionString, __getTagCallback } = task.export();
|
|
19155
19609
|
this.tasksSynced = false;
|
|
19156
19610
|
const taskRegistrationData = sanitizePersistedTaskSourceFields(task, {
|
|
@@ -19185,11 +19639,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19185
19639
|
},
|
|
19186
19640
|
intents: Array.from(task.handlesIntents)
|
|
19187
19641
|
});
|
|
19188
|
-
yield {
|
|
19189
|
-
__syncing: ctx.__syncing,
|
|
19642
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19190
19643
|
data: taskRegistrationData,
|
|
19191
19644
|
__taskName: task.name
|
|
19192
|
-
};
|
|
19645
|
+
});
|
|
19193
19646
|
}
|
|
19194
19647
|
}.bind(this)
|
|
19195
19648
|
);
|
|
@@ -19210,9 +19663,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19210
19663
|
"Record registration",
|
|
19211
19664
|
(ctx, emit2) => {
|
|
19212
19665
|
const task = resolveLocalTaskFromSyncContext(ctx);
|
|
19213
|
-
const serviceName2 = resolveSyncServiceName(task);
|
|
19214
19666
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
19215
19667
|
if (!insertSucceeded) {
|
|
19668
|
+
if (task) {
|
|
19669
|
+
task.registrationRequested = false;
|
|
19670
|
+
}
|
|
19216
19671
|
return;
|
|
19217
19672
|
}
|
|
19218
19673
|
scheduleSyncPassEvaluation();
|
|
@@ -19254,11 +19709,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19254
19709
|
if (this.registeredActors.has(registrationKey)) {
|
|
19255
19710
|
continue;
|
|
19256
19711
|
}
|
|
19712
|
+
if (this.requestedActorRegistrations.has(registrationKey)) {
|
|
19713
|
+
continue;
|
|
19714
|
+
}
|
|
19715
|
+
this.requestedActorRegistrations.add(registrationKey);
|
|
19257
19716
|
this.actorsSynced = false;
|
|
19258
|
-
yield {
|
|
19717
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19259
19718
|
data,
|
|
19260
19719
|
__actorRegistrationKey: registrationKey
|
|
19261
|
-
};
|
|
19720
|
+
});
|
|
19262
19721
|
}
|
|
19263
19722
|
}.bind(this)
|
|
19264
19723
|
);
|
|
@@ -19278,11 +19737,18 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19278
19737
|
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
19279
19738
|
"Record actor registration",
|
|
19280
19739
|
(ctx) => {
|
|
19740
|
+
const registrationKey = typeof ctx.__actorRegistrationKey === "string" ? ctx.__actorRegistrationKey : "";
|
|
19281
19741
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19742
|
+
if (registrationKey) {
|
|
19743
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
19744
|
+
}
|
|
19282
19745
|
return;
|
|
19283
19746
|
}
|
|
19284
19747
|
scheduleSyncPassEvaluation();
|
|
19285
|
-
|
|
19748
|
+
if (registrationKey) {
|
|
19749
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
19750
|
+
this.registeredActors.add(registrationKey);
|
|
19751
|
+
}
|
|
19286
19752
|
return true;
|
|
19287
19753
|
}
|
|
19288
19754
|
).then(gatherActorRegistrationTask);
|
|
@@ -19301,17 +19767,95 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19301
19767
|
}
|
|
19302
19768
|
);
|
|
19303
19769
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
19304
|
-
"
|
|
19305
|
-
()
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19309
|
-
|
|
19770
|
+
"Register routing-critical signal task maps to DB",
|
|
19771
|
+
function* (ctx) {
|
|
19772
|
+
const task = ctx.task;
|
|
19773
|
+
if (!task) {
|
|
19774
|
+
return;
|
|
19775
|
+
}
|
|
19776
|
+
const serviceName2 = resolveSyncServiceName(task);
|
|
19777
|
+
if (!serviceName2) {
|
|
19778
|
+
return;
|
|
19779
|
+
}
|
|
19780
|
+
for (const signal of task.observedSignals) {
|
|
19781
|
+
const signalName = canonicalizeSignalName2(signal);
|
|
19782
|
+
if (!shouldDirectSyncSignalTaskMapForBootstrap(task, signalName)) {
|
|
19783
|
+
continue;
|
|
19784
|
+
}
|
|
19785
|
+
if (task.registeredSignals.has(signalName)) {
|
|
19786
|
+
continue;
|
|
19787
|
+
}
|
|
19788
|
+
const registrationKey = buildSignalTaskMapRegistrationKey({
|
|
19789
|
+
signalName,
|
|
19790
|
+
serviceName: serviceName2,
|
|
19791
|
+
taskName: task.name,
|
|
19792
|
+
taskVersion: task.version
|
|
19793
|
+
});
|
|
19794
|
+
if (this.authoritativeSignalTaskMaps.has(registrationKey)) {
|
|
19795
|
+
continue;
|
|
19796
|
+
}
|
|
19797
|
+
if (!CadenzaService.signalBroker.signalObservers?.get(signalName)?.registered) {
|
|
19798
|
+
continue;
|
|
19799
|
+
}
|
|
19800
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19801
|
+
data: {
|
|
19802
|
+
signal_name: signalName,
|
|
19803
|
+
is_global: true,
|
|
19804
|
+
task_name: task.name,
|
|
19805
|
+
task_version: task.version,
|
|
19806
|
+
service_name: serviceName2
|
|
19807
|
+
},
|
|
19808
|
+
__taskName: task.name,
|
|
19809
|
+
__signalName: signalName
|
|
19810
|
+
});
|
|
19811
|
+
}
|
|
19812
|
+
}.bind(this),
|
|
19813
|
+
"Routing-critical meta signal-task maps are persisted during bootstrap so authority can route required control-plane signals before deferred manifest replay completes.",
|
|
19310
19814
|
{
|
|
19311
19815
|
register: false,
|
|
19312
19816
|
isHidden: true
|
|
19313
19817
|
}
|
|
19314
19818
|
);
|
|
19819
|
+
const signalTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
19820
|
+
this.isCadenzaDBReady,
|
|
19821
|
+
"signal_to_task_map",
|
|
19822
|
+
{
|
|
19823
|
+
onConflict: {
|
|
19824
|
+
target: [
|
|
19825
|
+
"signal_name",
|
|
19826
|
+
"is_global",
|
|
19827
|
+
"task_name",
|
|
19828
|
+
"task_version",
|
|
19829
|
+
"service_name"
|
|
19830
|
+
],
|
|
19831
|
+
action: {
|
|
19832
|
+
do: "nothing"
|
|
19833
|
+
}
|
|
19834
|
+
}
|
|
19835
|
+
},
|
|
19836
|
+
{ concurrency: 30 }
|
|
19837
|
+
);
|
|
19838
|
+
const recordSignalTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
19839
|
+
"Record signal task map registration",
|
|
19840
|
+
(ctx) => {
|
|
19841
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
19842
|
+
return;
|
|
19843
|
+
}
|
|
19844
|
+
scheduleSyncPassEvaluation();
|
|
19845
|
+
const task = CadenzaService.get(ctx.__taskName);
|
|
19846
|
+
const signalName = typeof ctx.__signalName === "string" ? canonicalizeSignalName2(ctx.__signalName) : "";
|
|
19847
|
+
if (!task || !signalName) {
|
|
19848
|
+
return true;
|
|
19849
|
+
}
|
|
19850
|
+
task.registeredSignals.add(signalName);
|
|
19851
|
+
return true;
|
|
19852
|
+
}
|
|
19853
|
+
);
|
|
19854
|
+
wireSyncTaskGraph(
|
|
19855
|
+
this.registerSignalToTaskMapTask,
|
|
19856
|
+
signalTaskMapRegistrationGraph,
|
|
19857
|
+
recordSignalTaskMapRegistrationTask
|
|
19858
|
+
);
|
|
19315
19859
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
19316
19860
|
"Split intents for registration",
|
|
19317
19861
|
function* (ctx) {
|
|
@@ -19327,25 +19871,31 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19327
19871
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
19328
19872
|
continue;
|
|
19329
19873
|
}
|
|
19874
|
+
if (intent.registrationRequested === true) {
|
|
19875
|
+
continue;
|
|
19876
|
+
}
|
|
19877
|
+
intent.registrationRequested = true;
|
|
19330
19878
|
this.intentsSynced = false;
|
|
19331
|
-
yield {
|
|
19332
|
-
__syncing: ctx.__syncing,
|
|
19879
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19333
19880
|
data: intentData,
|
|
19334
19881
|
__intentName: intentData.name
|
|
19335
|
-
};
|
|
19882
|
+
});
|
|
19336
19883
|
}
|
|
19337
19884
|
}.bind(this)
|
|
19338
19885
|
);
|
|
19339
19886
|
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
19340
19887
|
"Record intent definition registration",
|
|
19341
19888
|
(ctx, emit2) => {
|
|
19889
|
+
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
19890
|
+
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
19342
19891
|
if (!didSyncInsertSucceed(ctx)) {
|
|
19892
|
+
if (intentDefinition) {
|
|
19893
|
+
intentDefinition.registrationRequested = false;
|
|
19894
|
+
}
|
|
19343
19895
|
return;
|
|
19344
19896
|
}
|
|
19345
19897
|
scheduleSyncPassEvaluation();
|
|
19346
|
-
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
19347
19898
|
this.registeredIntentDefinitions.add(intentName);
|
|
19348
|
-
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
19349
19899
|
if (intentDefinition) {
|
|
19350
19900
|
intentDefinition.registered = true;
|
|
19351
19901
|
intentDefinition.registrationRequested = false;
|
|
@@ -19605,6 +20155,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19605
20155
|
"Register task map to DB",
|
|
19606
20156
|
function* (ctx) {
|
|
19607
20157
|
const task = ctx.task;
|
|
20158
|
+
if (!task) {
|
|
20159
|
+
return;
|
|
20160
|
+
}
|
|
19608
20161
|
if (task.hidden || !task.register || task.isDeputy || !task.registered) {
|
|
19609
20162
|
return;
|
|
19610
20163
|
}
|
|
@@ -19613,6 +20166,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19613
20166
|
return;
|
|
19614
20167
|
}
|
|
19615
20168
|
for (const t of task.nextTasks) {
|
|
20169
|
+
if (!t) {
|
|
20170
|
+
continue;
|
|
20171
|
+
}
|
|
19616
20172
|
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
19617
20173
|
continue;
|
|
19618
20174
|
}
|
|
@@ -19620,7 +20176,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19620
20176
|
if (!serviceName2) {
|
|
19621
20177
|
continue;
|
|
19622
20178
|
}
|
|
19623
|
-
yield {
|
|
20179
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
19624
20180
|
data: {
|
|
19625
20181
|
task_name: t.name,
|
|
19626
20182
|
task_version: t.version,
|
|
@@ -19631,7 +20187,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
19631
20187
|
},
|
|
19632
20188
|
__taskName: task.name,
|
|
19633
20189
|
__nextTaskName: t.name
|
|
19634
|
-
};
|
|
20190
|
+
});
|
|
19635
20191
|
}
|
|
19636
20192
|
}
|
|
19637
20193
|
);
|
|
@@ -20219,19 +20775,6 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20219
20775
|
if (!ServiceRegistry.instance.hasLocalInstanceRegistered()) {
|
|
20220
20776
|
return false;
|
|
20221
20777
|
}
|
|
20222
|
-
if (ctx.__bootstrapFullSync === true) {
|
|
20223
|
-
if (shouldTraceSyncPhase(serviceName2)) {
|
|
20224
|
-
console.log(
|
|
20225
|
-
"[CADENZA_SYNC_PHASE_TRACE] sync_cycle_ignored_bootstrap_full_sync",
|
|
20226
|
-
{
|
|
20227
|
-
serviceName: serviceName2,
|
|
20228
|
-
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
20229
|
-
attempt: typeof ctx.__bootstrapFullSyncAttempt === "number" ? ctx.__bootstrapFullSyncAttempt : void 0
|
|
20230
|
-
}
|
|
20231
|
-
);
|
|
20232
|
-
}
|
|
20233
|
-
return false;
|
|
20234
|
-
}
|
|
20235
20778
|
if (state.activeSyncCycleId) {
|
|
20236
20779
|
const activeCycleAgeMs = now - state.activeSyncCycleStartedAt;
|
|
20237
20780
|
if (activeCycleAgeMs < BOOTSTRAP_SYNC_STALE_CYCLE_MS) {
|
|
@@ -20258,6 +20801,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20258
20801
|
});
|
|
20259
20802
|
}
|
|
20260
20803
|
}
|
|
20804
|
+
const primitivePendingSummary = buildPrimitivePendingSummary();
|
|
20805
|
+
const mapPendingSummary = buildMapPendingSummary();
|
|
20806
|
+
const hasPendingWork = hasNonZeroPending(primitivePendingSummary) || hasNonZeroPending(mapPendingSummary);
|
|
20807
|
+
if (!hasPendingWork && shouldSkipIdleBootstrapSyncTrigger(ctx)) {
|
|
20808
|
+
if (shouldTraceSyncPhase(serviceName2)) {
|
|
20809
|
+
console.log("[CADENZA_SYNC_PHASE_TRACE] sync_cycle_skipped_idle", {
|
|
20810
|
+
serviceName: serviceName2,
|
|
20811
|
+
triggerSignal: typeof ctx.__signal === "string" ? ctx.__signal : void 0,
|
|
20812
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0
|
|
20813
|
+
});
|
|
20814
|
+
}
|
|
20815
|
+
return false;
|
|
20816
|
+
}
|
|
20261
20817
|
const syncCycleId = `${now}-${uuid7()}`;
|
|
20262
20818
|
setRuntimeState({
|
|
20263
20819
|
activeSyncCycleId: syncCycleId,
|
|
@@ -20366,22 +20922,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20366
20922
|
const getSignalsForSyncTask = CadenzaService.createMetaTask(
|
|
20367
20923
|
"Get signals for sync",
|
|
20368
20924
|
(ctx) => {
|
|
20369
|
-
const
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
20925
|
+
const canonicalSignals = /* @__PURE__ */ new Map();
|
|
20926
|
+
for (const observer of getRegistrableSignalObservers()) {
|
|
20927
|
+
const signalName = canonicalizeSignalName2(observer.signalName);
|
|
20928
|
+
if (!signalName || signalName.includes(":")) {
|
|
20929
|
+
continue;
|
|
20930
|
+
}
|
|
20931
|
+
canonicalSignals.set(signalName, {
|
|
20932
|
+
signal: signalName,
|
|
20933
|
+
data: {
|
|
20934
|
+
registered: observer.registered ?? false,
|
|
20935
|
+
metadata: observer.metadata ?? null
|
|
20936
|
+
}
|
|
20937
|
+
});
|
|
20938
|
+
}
|
|
20939
|
+
for (const emittedSignal of CadenzaService.signalBroker.emittedSignalsRegistry) {
|
|
20940
|
+
const signalName = canonicalizeSignalName2(emittedSignal);
|
|
20941
|
+
if (!signalName || signalName.includes(":")) {
|
|
20942
|
+
continue;
|
|
20943
|
+
}
|
|
20944
|
+
if (canonicalSignals.has(signalName)) {
|
|
20945
|
+
continue;
|
|
20380
20946
|
}
|
|
20381
|
-
|
|
20947
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
20948
|
+
if (metadata?.is_meta === true || isBootstrapLocalOnlySignal(signalName)) {
|
|
20949
|
+
continue;
|
|
20950
|
+
}
|
|
20951
|
+
canonicalSignals.set(signalName, {
|
|
20952
|
+
signal: signalName,
|
|
20953
|
+
data: {
|
|
20954
|
+
registered: CadenzaService.signalBroker.signalObservers.get(signalName)?.registered ?? false,
|
|
20955
|
+
metadata
|
|
20956
|
+
}
|
|
20957
|
+
});
|
|
20958
|
+
}
|
|
20382
20959
|
return {
|
|
20383
20960
|
...ctx,
|
|
20384
|
-
signals:
|
|
20961
|
+
signals: Array.from(canonicalSignals.values())
|
|
20385
20962
|
};
|
|
20386
20963
|
},
|
|
20387
20964
|
"Collects local signals for the primitive sync phase.",
|
|
@@ -20418,9 +20995,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20418
20995
|
"Get all actors for sync",
|
|
20419
20996
|
(ctx) => ({
|
|
20420
20997
|
...ctx,
|
|
20421
|
-
actors:
|
|
20998
|
+
actors: []
|
|
20422
20999
|
}),
|
|
20423
|
-
"
|
|
21000
|
+
"Actor definitions are staged through service-manifest publication rather than the bootstrap primitive sync phase.",
|
|
20424
21001
|
{
|
|
20425
21002
|
register: false,
|
|
20426
21003
|
isHidden: true
|
|
@@ -20452,7 +21029,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20452
21029
|
"Iterate tasks for directional task map sync",
|
|
20453
21030
|
function* (ctx) {
|
|
20454
21031
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20455
|
-
yield
|
|
21032
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20456
21033
|
}
|
|
20457
21034
|
},
|
|
20458
21035
|
"Iterates local tasks for directional task-map sync.",
|
|
@@ -20471,7 +21048,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20471
21048
|
"Iterate tasks for signal task map sync",
|
|
20472
21049
|
function* (ctx) {
|
|
20473
21050
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20474
|
-
yield
|
|
21051
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20475
21052
|
}
|
|
20476
21053
|
},
|
|
20477
21054
|
"Iterates local tasks for signal-to-task map sync.",
|
|
@@ -20485,12 +21062,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20485
21062
|
gatherSignalTaskMapRegistrationTask
|
|
20486
21063
|
);
|
|
20487
21064
|
iterateTasksForSignalTaskMapSyncTask.then(this.registerSignalToTaskMapTask);
|
|
20488
|
-
|
|
21065
|
+
recordSignalTaskMapRegistrationTask.then(gatherSignalTaskMapRegistrationTask);
|
|
20489
21066
|
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
20490
21067
|
"Iterate tasks for intent task map sync",
|
|
20491
21068
|
function* (ctx) {
|
|
20492
21069
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20493
|
-
yield
|
|
21070
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20494
21071
|
}
|
|
20495
21072
|
},
|
|
20496
21073
|
"Iterates local tasks for intent-to-task map sync.",
|
|
@@ -20509,7 +21086,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
20509
21086
|
"Iterate tasks for actor task map sync",
|
|
20510
21087
|
function* (ctx) {
|
|
20511
21088
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
20512
|
-
yield
|
|
21089
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
20513
21090
|
}
|
|
20514
21091
|
},
|
|
20515
21092
|
"Iterates local tasks for actor-to-task map sync.",
|
|
@@ -20642,7 +21219,7 @@ function sanitizePersistedTaskSourceFields2(task, data) {
|
|
|
20642
21219
|
};
|
|
20643
21220
|
}
|
|
20644
21221
|
function shouldSkipDirectTaskMetadata(task) {
|
|
20645
|
-
return !task || !task.register || task.isHidden || task.isDeputy;
|
|
21222
|
+
return !task || !task.register || task.isHidden || task.isDeputy || task.isMeta || task.isSubMeta;
|
|
20646
21223
|
}
|
|
20647
21224
|
function isManagedRouteRecoveryTaskError(errorMessage2) {
|
|
20648
21225
|
if (typeof errorMessage2 !== "string") {
|
|
@@ -20656,7 +21233,10 @@ function isLocallyHandledIntentName2(intentName) {
|
|
|
20656
21233
|
return false;
|
|
20657
21234
|
}
|
|
20658
21235
|
for (const task of observer.tasks) {
|
|
20659
|
-
if (
|
|
21236
|
+
if (!task) {
|
|
21237
|
+
continue;
|
|
21238
|
+
}
|
|
21239
|
+
if (task.register && !task.isHidden && !task.isDeputy && !task.isMeta && !task.isSubMeta) {
|
|
20660
21240
|
return true;
|
|
20661
21241
|
}
|
|
20662
21242
|
}
|
|
@@ -20895,7 +21475,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
20895
21475
|
return false;
|
|
20896
21476
|
}
|
|
20897
21477
|
const helper = resolveHelperFromMetadataContext(ctx);
|
|
20898
|
-
if (!helper) {
|
|
21478
|
+
if (!helper || helper.isMeta) {
|
|
20899
21479
|
return false;
|
|
20900
21480
|
}
|
|
20901
21481
|
return buildDatabaseTriggerContext({
|
|
@@ -20910,7 +21490,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
20910
21490
|
return false;
|
|
20911
21491
|
}
|
|
20912
21492
|
const globalDefinition = resolveGlobalFromMetadataContext(ctx);
|
|
20913
|
-
if (!globalDefinition) {
|
|
21493
|
+
if (!globalDefinition || globalDefinition.isMeta) {
|
|
20914
21494
|
return false;
|
|
20915
21495
|
}
|
|
20916
21496
|
return buildDatabaseTriggerContext({
|
|
@@ -21012,6 +21592,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21012
21592
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21013
21593
|
return false;
|
|
21014
21594
|
}
|
|
21595
|
+
if (ctx.data?.isMeta === true) {
|
|
21596
|
+
return false;
|
|
21597
|
+
}
|
|
21015
21598
|
return buildDatabaseTriggerContext({
|
|
21016
21599
|
...ctx.data,
|
|
21017
21600
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
@@ -21021,6 +21604,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21021
21604
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21022
21605
|
return false;
|
|
21023
21606
|
}
|
|
21607
|
+
if (ctx.data?.isMeta === true) {
|
|
21608
|
+
return false;
|
|
21609
|
+
}
|
|
21024
21610
|
return buildDatabaseTriggerContext(
|
|
21025
21611
|
ctx.data ?? void 0,
|
|
21026
21612
|
{
|
|
@@ -21689,6 +22275,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21689
22275
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21690
22276
|
return false;
|
|
21691
22277
|
}
|
|
22278
|
+
if (ctx.data?.is_meta === true) {
|
|
22279
|
+
return false;
|
|
22280
|
+
}
|
|
21692
22281
|
if (shouldSkipDirectActorMetadata(ctx?.data?.name)) {
|
|
21693
22282
|
return false;
|
|
21694
22283
|
}
|
|
@@ -21701,6 +22290,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
21701
22290
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
21702
22291
|
return false;
|
|
21703
22292
|
}
|
|
22293
|
+
if (ctx.data?.is_meta === true) {
|
|
22294
|
+
return false;
|
|
22295
|
+
}
|
|
21704
22296
|
if (shouldSkipDirectActorMetadata(ctx?.data?.actor_name)) {
|
|
21705
22297
|
return false;
|
|
21706
22298
|
}
|
|
@@ -22146,6 +22738,8 @@ function resetBrowserRuntimeActorHandles() {
|
|
|
22146
22738
|
|
|
22147
22739
|
// src/Cadenza.ts
|
|
22148
22740
|
var POSTGRES_SETUP_DEBUG_ENABLED2 = process.env.CADENZA_POSTGRES_SETUP_DEBUG === "1" || process.env.CADENZA_POSTGRES_SETUP_DEBUG === "true";
|
|
22741
|
+
var DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 15e3;
|
|
22742
|
+
var LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 6e4;
|
|
22149
22743
|
function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE__ */ new Set()) {
|
|
22150
22744
|
if (depth < 0 || value === null || value === void 0) {
|
|
22151
22745
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
@@ -22207,6 +22801,10 @@ var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
|
22207
22801
|
"business_structural",
|
|
22208
22802
|
"local_meta_structural"
|
|
22209
22803
|
];
|
|
22804
|
+
var ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS = 250;
|
|
22805
|
+
var BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 1500;
|
|
22806
|
+
var LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 15e3;
|
|
22807
|
+
var MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS = 1e3;
|
|
22210
22808
|
function getServiceManifestPublicationLayerRank(layer) {
|
|
22211
22809
|
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
22212
22810
|
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
@@ -22340,43 +22938,250 @@ var CadenzaService = class {
|
|
|
22340
22938
|
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
22341
22939
|
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
22342
22940
|
}
|
|
22941
|
+
static clampServiceManifestPublicationLayer(targetLayer) {
|
|
22942
|
+
const maximumLayer = this.isLocalAuthorityService() ? "routing_capability" : "local_meta_structural";
|
|
22943
|
+
return getServiceManifestPublicationLayerRank(targetLayer) > getServiceManifestPublicationLayerRank(maximumLayer) ? maximumLayer : targetLayer;
|
|
22944
|
+
}
|
|
22343
22945
|
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
22344
22946
|
this.serviceManifestPublicationPendingReason = reason;
|
|
22947
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22345
22948
|
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
22346
|
-
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(
|
|
22949
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? normalizedTargetLayer : currentTargetLayer;
|
|
22950
|
+
}
|
|
22951
|
+
static getServiceManifestPublicationGate(publicationLayer) {
|
|
22952
|
+
if (!this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
22953
|
+
return {
|
|
22954
|
+
ready: false,
|
|
22955
|
+
delayMs: ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS
|
|
22956
|
+
};
|
|
22957
|
+
}
|
|
22958
|
+
if (publicationLayer === "routing_capability") {
|
|
22959
|
+
return {
|
|
22960
|
+
ready: true,
|
|
22961
|
+
delayMs: 0
|
|
22962
|
+
};
|
|
22963
|
+
}
|
|
22964
|
+
if (!this.bootstrapSyncCompleted || this.bootstrapSyncCompletedAt <= 0) {
|
|
22965
|
+
return {
|
|
22966
|
+
ready: false,
|
|
22967
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
22968
|
+
};
|
|
22969
|
+
}
|
|
22970
|
+
const now = Date.now();
|
|
22971
|
+
if (publicationLayer === "business_structural") {
|
|
22972
|
+
const allowedAt2 = this.bootstrapSyncCompletedAt + BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
22973
|
+
return {
|
|
22974
|
+
ready: now >= allowedAt2,
|
|
22975
|
+
delayMs: Math.max(1, allowedAt2 - now)
|
|
22976
|
+
};
|
|
22977
|
+
}
|
|
22978
|
+
const businessPublishedAt = this.serviceManifestPublishedAt.business_structural ?? 0;
|
|
22979
|
+
if (!this.lastPublishedServiceManifestHashes.business_structural || businessPublishedAt <= 0) {
|
|
22980
|
+
return {
|
|
22981
|
+
ready: false,
|
|
22982
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
22983
|
+
};
|
|
22984
|
+
}
|
|
22985
|
+
const allowedAt = businessPublishedAt + LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
22986
|
+
return {
|
|
22987
|
+
ready: now >= allowedAt,
|
|
22988
|
+
delayMs: Math.max(1, allowedAt - now)
|
|
22989
|
+
};
|
|
22347
22990
|
}
|
|
22348
22991
|
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
22349
22992
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22350
22993
|
return;
|
|
22351
22994
|
}
|
|
22995
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22352
22996
|
const signalName = "meta.service_manifest.publish_requested";
|
|
22353
22997
|
const payload = {
|
|
22354
22998
|
__reason: reason,
|
|
22355
22999
|
__serviceName: this.serviceRegistry.serviceName,
|
|
22356
23000
|
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
22357
|
-
__publicationLayer:
|
|
23001
|
+
__publicationLayer: normalizedTargetLayer
|
|
22358
23002
|
};
|
|
22359
23003
|
if (immediate) {
|
|
22360
|
-
this.
|
|
23004
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
23005
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
23006
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
23007
|
+
}
|
|
23008
|
+
void this.publishServiceManifestIfNeeded(reason, normalizedTargetLayer);
|
|
22361
23009
|
return;
|
|
22362
23010
|
}
|
|
22363
23011
|
this.debounce(signalName, payload, 100);
|
|
22364
23012
|
}
|
|
22365
|
-
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
23013
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural", options) {
|
|
22366
23014
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22367
23015
|
return;
|
|
22368
23016
|
}
|
|
23017
|
+
this.serviceManifestPublicationRetryReason = reason;
|
|
23018
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
23019
|
+
const currentRetryLayer = this.serviceManifestPublicationRetryLayer ?? "routing_capability";
|
|
23020
|
+
this.serviceManifestPublicationRetryLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentRetryLayer) ? normalizedTargetLayer : currentRetryLayer;
|
|
23021
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
23022
|
+
return;
|
|
23023
|
+
}
|
|
23024
|
+
const retryReason = this.serviceManifestPublicationRetryReason ?? reason;
|
|
23025
|
+
const retryTargetLayer = this.serviceManifestPublicationRetryLayer ?? targetLayer;
|
|
23026
|
+
const shouldIncrementRetryCount = options?.incrementRetryCount !== false;
|
|
23027
|
+
const delayMs = options?.delayMs ?? Math.min(
|
|
23028
|
+
1e4,
|
|
23029
|
+
1e3 * Math.max(1, 2 ** this.serviceManifestPublicationRetryCount)
|
|
23030
|
+
);
|
|
23031
|
+
if (shouldIncrementRetryCount) {
|
|
23032
|
+
this.serviceManifestPublicationRetryCount += 1;
|
|
23033
|
+
}
|
|
23034
|
+
this.serviceManifestPublicationRetryTimer = setTimeout(() => {
|
|
23035
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
23036
|
+
const pendingReason = this.serviceManifestPublicationRetryReason ?? retryReason;
|
|
23037
|
+
const pendingLayer = this.serviceManifestPublicationRetryLayer ?? retryTargetLayer;
|
|
23038
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
23039
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
23040
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
23041
|
+
}, delayMs);
|
|
23042
|
+
}
|
|
23043
|
+
static shouldPublishBusinessManifestForTaskContext(ctx) {
|
|
23044
|
+
const task = ctx?.taskInstance ?? (typeof ctx?.data?.name === "string" ? this.get(ctx.data.name) : void 0);
|
|
23045
|
+
if (task) {
|
|
23046
|
+
if (this.isRoutingCriticalManifestTask(task)) {
|
|
23047
|
+
return true;
|
|
23048
|
+
}
|
|
23049
|
+
return task.register === true && task.isMeta !== true && task.isSubMeta !== true && task.isHidden !== true && task.isEphemeral !== true;
|
|
23050
|
+
}
|
|
23051
|
+
if (this.hasRoutingCriticalManifestBindingInContext(ctx)) {
|
|
23052
|
+
return true;
|
|
23053
|
+
}
|
|
23054
|
+
return ctx?.data?.isMeta !== true && ctx?.data?.isSubMeta !== true && ctx?.data?.isHidden !== true && ctx?.data?.isEphemeral !== true && ctx?.__isSubMeta !== true;
|
|
23055
|
+
}
|
|
23056
|
+
static isRoutingCriticalManifestSignalName(signalName) {
|
|
23057
|
+
const normalizedSignalName = String(signalName ?? "").trim();
|
|
23058
|
+
if (!normalizedSignalName) {
|
|
23059
|
+
return false;
|
|
23060
|
+
}
|
|
23061
|
+
return normalizedSignalName === EXECUTION_PERSISTENCE_BUNDLE_SIGNAL || isAuthorityBootstrapSignal(normalizedSignalName);
|
|
23062
|
+
}
|
|
23063
|
+
static isRoutingCriticalManifestIntentName(intentName) {
|
|
23064
|
+
return isAuthorityBootstrapIntent(intentName);
|
|
23065
|
+
}
|
|
23066
|
+
static isRoutingCriticalManifestTask(task) {
|
|
23067
|
+
for (const signalName of task.observedSignals ?? []) {
|
|
23068
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
23069
|
+
return true;
|
|
23070
|
+
}
|
|
23071
|
+
}
|
|
23072
|
+
for (const intentName of task.handlesIntents ?? []) {
|
|
23073
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
23074
|
+
return true;
|
|
23075
|
+
}
|
|
23076
|
+
}
|
|
23077
|
+
return false;
|
|
23078
|
+
}
|
|
23079
|
+
static hasRoutingCriticalManifestBindingInContext(ctx) {
|
|
23080
|
+
const signalCandidates = [
|
|
23081
|
+
ctx?.signalName,
|
|
23082
|
+
ctx?.data?.signalName,
|
|
23083
|
+
ctx?.data?.signal_name
|
|
23084
|
+
];
|
|
23085
|
+
for (const signalName of signalCandidates) {
|
|
23086
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
23087
|
+
return true;
|
|
23088
|
+
}
|
|
23089
|
+
}
|
|
23090
|
+
const intentCandidates = [
|
|
23091
|
+
ctx?.intentName,
|
|
23092
|
+
ctx?.data?.intentName,
|
|
23093
|
+
ctx?.data?.intent_name
|
|
23094
|
+
];
|
|
23095
|
+
for (const intentName of intentCandidates) {
|
|
23096
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
23097
|
+
return true;
|
|
23098
|
+
}
|
|
23099
|
+
}
|
|
23100
|
+
return false;
|
|
23101
|
+
}
|
|
23102
|
+
static shouldPublishBusinessManifestForHelperContext(ctx) {
|
|
23103
|
+
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 : "";
|
|
23104
|
+
const helper = helperName ? Cadenza.getHelper(helperName) : void 0;
|
|
23105
|
+
if (helper) {
|
|
23106
|
+
return helper.isMeta !== true;
|
|
23107
|
+
}
|
|
23108
|
+
return ctx?.data?.isMeta !== true;
|
|
23109
|
+
}
|
|
23110
|
+
static shouldPublishBusinessManifestForGlobalContext(ctx) {
|
|
23111
|
+
const globalName = typeof ctx?.data?.name === "string" ? ctx.data.name : typeof ctx?.data?.globalName === "string" ? ctx.data.globalName : "";
|
|
23112
|
+
const globalDefinition = globalName ? Cadenza.getGlobal(globalName) : void 0;
|
|
23113
|
+
if (globalDefinition) {
|
|
23114
|
+
return globalDefinition.isMeta !== true;
|
|
23115
|
+
}
|
|
23116
|
+
return ctx?.data?.isMeta !== true;
|
|
23117
|
+
}
|
|
23118
|
+
static shouldPublishBusinessManifestForRoutineContext(ctx) {
|
|
23119
|
+
const routineName = typeof ctx?.data?.name === "string" ? ctx.data.name : "";
|
|
23120
|
+
const routine = routineName ? this.getRoutine(routineName) : void 0;
|
|
23121
|
+
if (routine) {
|
|
23122
|
+
return routine.isMeta !== true;
|
|
23123
|
+
}
|
|
23124
|
+
return ctx?.data?.isMeta !== true;
|
|
23125
|
+
}
|
|
23126
|
+
static shouldRequestServiceManifestPublicationForSignal(ctx) {
|
|
23127
|
+
const signalName = typeof ctx?.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal.trim() : "";
|
|
23128
|
+
switch (signalName) {
|
|
23129
|
+
case "meta.task.created":
|
|
23130
|
+
case "meta.task.destroyed":
|
|
23131
|
+
case "meta.task.relationship_added":
|
|
23132
|
+
case "meta.task.relationship_removed":
|
|
23133
|
+
case "meta.task.intent_associated":
|
|
23134
|
+
case "meta.task.helper_associated":
|
|
23135
|
+
case "meta.task.global_associated":
|
|
23136
|
+
case "meta.task.observed_signal":
|
|
23137
|
+
case "meta.task.attached_signal":
|
|
23138
|
+
case "meta.task.detached_signal":
|
|
23139
|
+
return this.shouldPublishBusinessManifestForTaskContext(ctx);
|
|
23140
|
+
case "meta.helper.created":
|
|
23141
|
+
case "meta.helper.updated":
|
|
23142
|
+
case "meta.helper.helper_associated":
|
|
23143
|
+
case "meta.helper.global_associated":
|
|
23144
|
+
return this.shouldPublishBusinessManifestForHelperContext(ctx);
|
|
23145
|
+
case "meta.global.created":
|
|
23146
|
+
case "meta.global.updated":
|
|
23147
|
+
return this.shouldPublishBusinessManifestForGlobalContext(ctx);
|
|
23148
|
+
case "meta.actor.created":
|
|
23149
|
+
case "meta.actor.task_associated":
|
|
23150
|
+
return ctx?.data?.is_meta !== true && ctx?.__isSubMeta !== true;
|
|
23151
|
+
case "global.meta.graph_metadata.routine_created":
|
|
23152
|
+
case "global.meta.graph_metadata.routine_updated":
|
|
23153
|
+
return this.shouldPublishBusinessManifestForRoutineContext(ctx);
|
|
23154
|
+
default:
|
|
23155
|
+
return false;
|
|
23156
|
+
}
|
|
23157
|
+
}
|
|
23158
|
+
static maybeRequestInitialServiceManifestPublication(reason, targetLayer = "business_structural") {
|
|
23159
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId || !this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
23160
|
+
return false;
|
|
23161
|
+
}
|
|
23162
|
+
this.initialServiceManifestPublicationRequested = true;
|
|
23163
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
23164
|
+
return true;
|
|
23165
|
+
}
|
|
23166
|
+
static scheduleInitialServiceManifestPublicationFallback(reason, targetLayer = "business_structural") {
|
|
23167
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
23168
|
+
return;
|
|
23169
|
+
}
|
|
22369
23170
|
setTimeout(() => {
|
|
22370
|
-
this.
|
|
23171
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
23172
|
+
return;
|
|
23173
|
+
}
|
|
23174
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
22371
23175
|
}, 1e3);
|
|
22372
23176
|
}
|
|
22373
23177
|
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
22374
|
-
if (!this.
|
|
23178
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
22375
23179
|
return false;
|
|
22376
23180
|
}
|
|
22377
23181
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
23182
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
22378
23183
|
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
22379
|
-
|
|
23184
|
+
normalizedTargetLayer
|
|
22380
23185
|
);
|
|
22381
23186
|
if (this.serviceManifestPublicationInFlight) {
|
|
22382
23187
|
this.mergeServiceManifestPublicationRequest(
|
|
@@ -22409,13 +23214,23 @@ var CadenzaService = class {
|
|
|
22409
23214
|
const hasPendingFollowupLayer = publicationPlan.some(
|
|
22410
23215
|
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
22411
23216
|
);
|
|
23217
|
+
const publicationGate = this.getServiceManifestPublicationGate(publicationLayer);
|
|
23218
|
+
if (!publicationGate.ready) {
|
|
23219
|
+
this.scheduleServiceManifestPublicationRetry(publishReason, publishTargetLayer, {
|
|
23220
|
+
delayMs: publicationGate.delayMs,
|
|
23221
|
+
incrementRetryCount: false
|
|
23222
|
+
});
|
|
23223
|
+
return false;
|
|
23224
|
+
}
|
|
22412
23225
|
this.serviceManifestPublicationInFlight = true;
|
|
22413
23226
|
try {
|
|
22414
|
-
this.
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
-
|
|
23227
|
+
if (!this.isLocalAuthorityService()) {
|
|
23228
|
+
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
23229
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
23230
|
+
snapshot
|
|
23231
|
+
);
|
|
23232
|
+
}
|
|
23233
|
+
if (this.shouldRequireAuthorityBootstrapHandshakeForManifestPublication() && !this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
22419
23234
|
this.scheduleServiceManifestPublicationRetry(
|
|
22420
23235
|
publishReason,
|
|
22421
23236
|
publishTargetLayer
|
|
@@ -22423,11 +23238,13 @@ var CadenzaService = class {
|
|
|
22423
23238
|
return false;
|
|
22424
23239
|
}
|
|
22425
23240
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
22426
|
-
timeout:
|
|
23241
|
+
timeout: this.isLocalAuthorityService() ? LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS : DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS,
|
|
22427
23242
|
requireComplete: true
|
|
22428
23243
|
});
|
|
22429
23244
|
this.serviceManifestRevision = snapshot.revision;
|
|
22430
23245
|
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
23246
|
+
this.serviceManifestPublishedAt[publicationLayer] = Date.now();
|
|
23247
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
22431
23248
|
if (hasPendingFollowupLayer) {
|
|
22432
23249
|
this.mergeServiceManifestPublicationRequest(
|
|
22433
23250
|
publishReason,
|
|
@@ -22463,14 +23280,7 @@ var CadenzaService = class {
|
|
|
22463
23280
|
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
22464
23281
|
this.serviceManifestPublicationPendingReason = null;
|
|
22465
23282
|
this.serviceManifestPublicationPendingLayer = null;
|
|
22466
|
-
this.
|
|
22467
|
-
"meta.service_manifest.publish_requested",
|
|
22468
|
-
{
|
|
22469
|
-
__reason: pendingReason,
|
|
22470
|
-
__publicationLayer: pendingLayer
|
|
22471
|
-
},
|
|
22472
|
-
100
|
|
22473
|
-
);
|
|
23283
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
22474
23284
|
}
|
|
22475
23285
|
}
|
|
22476
23286
|
}
|
|
@@ -22484,7 +23294,7 @@ var CadenzaService = class {
|
|
|
22484
23294
|
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
22485
23295
|
this.normalizeServiceManifestPublicationLayer(
|
|
22486
23296
|
ctx.__publicationLayer,
|
|
22487
|
-
"
|
|
23297
|
+
"local_meta_structural"
|
|
22488
23298
|
)
|
|
22489
23299
|
),
|
|
22490
23300
|
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
@@ -22496,14 +23306,17 @@ var CadenzaService = class {
|
|
|
22496
23306
|
this.createMetaTask(
|
|
22497
23307
|
"Request manifest publication after structural change",
|
|
22498
23308
|
(ctx) => {
|
|
23309
|
+
if (!this.shouldRequestServiceManifestPublicationForSignal(ctx)) {
|
|
23310
|
+
return false;
|
|
23311
|
+
}
|
|
22499
23312
|
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";
|
|
22500
|
-
const targetLayer =
|
|
23313
|
+
const targetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
22501
23314
|
ctx.__publicationLayer,
|
|
22502
|
-
"
|
|
23315
|
+
"local_meta_structural"
|
|
22503
23316
|
);
|
|
22504
23317
|
this.requestServiceManifestPublication(
|
|
22505
23318
|
reason,
|
|
22506
|
-
|
|
23319
|
+
false,
|
|
22507
23320
|
targetLayer
|
|
22508
23321
|
);
|
|
22509
23322
|
return true;
|
|
@@ -22514,7 +23327,6 @@ var CadenzaService = class {
|
|
|
22514
23327
|
isHidden: true
|
|
22515
23328
|
}
|
|
22516
23329
|
).doOn(
|
|
22517
|
-
"meta.service_registry.instance_inserted",
|
|
22518
23330
|
"meta.task.created",
|
|
22519
23331
|
"meta.task.destroyed",
|
|
22520
23332
|
"meta.task.relationship_added",
|
|
@@ -22533,14 +23345,21 @@ var CadenzaService = class {
|
|
|
22533
23345
|
"meta.helper.global_associated",
|
|
22534
23346
|
"meta.actor.created",
|
|
22535
23347
|
"meta.actor.task_associated",
|
|
22536
|
-
"meta.fetch.handshake_complete",
|
|
22537
23348
|
"meta.service_registry.registered_global_signals",
|
|
22538
23349
|
"meta.service_registry.registered_global_intents",
|
|
22539
|
-
"meta.service_registry.initial_sync_complete",
|
|
22540
23350
|
"global.meta.graph_metadata.routine_created",
|
|
22541
23351
|
"global.meta.graph_metadata.routine_updated"
|
|
22542
23352
|
);
|
|
22543
23353
|
}
|
|
23354
|
+
static isLocalAuthorityService() {
|
|
23355
|
+
return this.serviceRegistry.serviceName === "CadenzaDB";
|
|
23356
|
+
}
|
|
23357
|
+
static canPublishServiceManifestToAuthority() {
|
|
23358
|
+
return this.serviceRegistry.connectsToCadenzaDB || this.isLocalAuthorityService();
|
|
23359
|
+
}
|
|
23360
|
+
static shouldRequireAuthorityBootstrapHandshakeForManifestPublication() {
|
|
23361
|
+
return !this.isLocalAuthorityService();
|
|
23362
|
+
}
|
|
22544
23363
|
static buildLegacyLocalCadenzaDBTaskName(tableName, operation) {
|
|
22545
23364
|
const operationPrefix = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
22546
23365
|
const helperSuffix = camelCase2(String(tableName ?? "").trim());
|
|
@@ -22707,6 +23526,7 @@ var CadenzaService = class {
|
|
|
22707
23526
|
}
|
|
22708
23527
|
static markBootstrapSyncCompleted() {
|
|
22709
23528
|
this.bootstrapSyncCompleted = true;
|
|
23529
|
+
this.bootstrapSyncCompletedAt = Date.now();
|
|
22710
23530
|
}
|
|
22711
23531
|
/**
|
|
22712
23532
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -23537,6 +24357,7 @@ var CadenzaService = class {
|
|
|
23537
24357
|
this.validateServiceName(serviceName);
|
|
23538
24358
|
const serviceId = options.customServiceId ?? uuid8();
|
|
23539
24359
|
this.bootstrapSyncCompleted = false;
|
|
24360
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
23540
24361
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
23541
24362
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
23542
24363
|
this.serviceRegistry.serviceName = serviceName;
|
|
@@ -23772,6 +24593,7 @@ var CadenzaService = class {
|
|
|
23772
24593
|
__declaredTransports: declaredTransports
|
|
23773
24594
|
};
|
|
23774
24595
|
let bootstrapServiceCreationRequested = false;
|
|
24596
|
+
const emitLocalServiceCreationImmediately = !options.cadenzaDB?.connect;
|
|
23775
24597
|
if (options.cadenzaDB?.connect) {
|
|
23776
24598
|
this.createMetaTask(
|
|
23777
24599
|
"Create service",
|
|
@@ -23794,7 +24616,6 @@ var CadenzaService = class {
|
|
|
23794
24616
|
}
|
|
23795
24617
|
).doOn("meta.fetch.handshake_complete");
|
|
23796
24618
|
} else {
|
|
23797
|
-
this.emit("meta.create_service_requested", initContext);
|
|
23798
24619
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
23799
24620
|
emit2(
|
|
23800
24621
|
"meta.service_registry.gathered_sync_transmission_reconcile_requested",
|
|
@@ -23806,6 +24627,20 @@ var CadenzaService = class {
|
|
|
23806
24627
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
23807
24628
|
}
|
|
23808
24629
|
let serviceSetupCompletedHandled = false;
|
|
24630
|
+
this.createMetaTask("Handle local service definition insertion", (ctx) => {
|
|
24631
|
+
const insertedServiceName = String(
|
|
24632
|
+
ctx?.__serviceName ?? ctx?.serviceName ?? ctx?.service_name ?? ctx?.data?.name ?? ""
|
|
24633
|
+
).trim();
|
|
24634
|
+
if (!insertedServiceName || insertedServiceName !== serviceName) {
|
|
24635
|
+
return false;
|
|
24636
|
+
}
|
|
24637
|
+
this.localServiceManifestDefinitionInserted = true;
|
|
24638
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
24639
|
+
"service_setup_completed",
|
|
24640
|
+
"local_meta_structural"
|
|
24641
|
+
);
|
|
24642
|
+
return true;
|
|
24643
|
+
}).doOn("meta.service_registry.service_inserted");
|
|
23809
24644
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
23810
24645
|
if (serviceSetupCompletedHandled) {
|
|
23811
24646
|
return false;
|
|
@@ -23826,13 +24661,18 @@ var CadenzaService = class {
|
|
|
23826
24661
|
return false;
|
|
23827
24662
|
}
|
|
23828
24663
|
serviceSetupCompletedHandled = true;
|
|
24664
|
+
this.localServiceManifestInstanceInserted = true;
|
|
23829
24665
|
if (options.cadenzaDB?.connect) {
|
|
23830
24666
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
23831
|
-
void this.publishServiceManifestIfNeeded(
|
|
23832
|
-
"service_setup_completed",
|
|
23833
|
-
"business_structural"
|
|
23834
|
-
);
|
|
23835
24667
|
}
|
|
24668
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
24669
|
+
"service_setup_completed",
|
|
24670
|
+
"local_meta_structural"
|
|
24671
|
+
);
|
|
24672
|
+
this.scheduleInitialServiceManifestPublicationFallback(
|
|
24673
|
+
"service_setup_completed",
|
|
24674
|
+
"local_meta_structural"
|
|
24675
|
+
);
|
|
23836
24676
|
if (isFrontend) {
|
|
23837
24677
|
registerActorSessionPersistenceTasks();
|
|
23838
24678
|
this.ensureFrontendSyncLoop();
|
|
@@ -23840,6 +24680,9 @@ var CadenzaService = class {
|
|
|
23840
24680
|
this.log("Service created.");
|
|
23841
24681
|
return true;
|
|
23842
24682
|
}).doOn("meta.service_registry.instance_inserted");
|
|
24683
|
+
if (emitLocalServiceCreationImmediately) {
|
|
24684
|
+
this.emit("meta.create_service_requested", initContext);
|
|
24685
|
+
}
|
|
23843
24686
|
if (!options.cadenzaDB?.connect) {
|
|
23844
24687
|
Cadenza.schedule(
|
|
23845
24688
|
"meta.service_registry.instance_registration_requested",
|
|
@@ -24304,6 +25147,30 @@ var CadenzaService = class {
|
|
|
24304
25147
|
this.bootstrap();
|
|
24305
25148
|
return Cadenza.createTask(name, func, description, options);
|
|
24306
25149
|
}
|
|
25150
|
+
static createHelper(name, func, description = "") {
|
|
25151
|
+
this.bootstrap();
|
|
25152
|
+
return Cadenza.createHelper(name, func, description);
|
|
25153
|
+
}
|
|
25154
|
+
static createMetaHelper(name, func, description = "") {
|
|
25155
|
+
this.bootstrap();
|
|
25156
|
+
return Cadenza.createMetaHelper(name, func, description);
|
|
25157
|
+
}
|
|
25158
|
+
static createHelperFromDefinition(definition) {
|
|
25159
|
+
this.bootstrap();
|
|
25160
|
+
return Cadenza.createHelperFromDefinition(definition);
|
|
25161
|
+
}
|
|
25162
|
+
static createGlobal(name, value, description = "") {
|
|
25163
|
+
this.bootstrap();
|
|
25164
|
+
return Cadenza.createGlobal(name, value, description);
|
|
25165
|
+
}
|
|
25166
|
+
static createMetaGlobal(name, value, description = "") {
|
|
25167
|
+
this.bootstrap();
|
|
25168
|
+
return Cadenza.createMetaGlobal(name, value, description);
|
|
25169
|
+
}
|
|
25170
|
+
static createGlobalFromDefinition(definition) {
|
|
25171
|
+
this.bootstrap();
|
|
25172
|
+
return Cadenza.createGlobalFromDefinition(definition);
|
|
25173
|
+
}
|
|
24307
25174
|
/**
|
|
24308
25175
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
24309
25176
|
* This is used for creating tasks that lives on the meta layer.
|
|
@@ -24640,6 +25507,7 @@ var CadenzaService = class {
|
|
|
24640
25507
|
this.isBootstrapped = false;
|
|
24641
25508
|
this.serviceCreated = false;
|
|
24642
25509
|
this.bootstrapSyncCompleted = false;
|
|
25510
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
24643
25511
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
24644
25512
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
24645
25513
|
this.defaultDatabaseServiceName = null;
|
|
@@ -24648,15 +25516,27 @@ var CadenzaService = class {
|
|
|
24648
25516
|
this.frontendSyncScheduled = false;
|
|
24649
25517
|
this.serviceManifestRevision = 0;
|
|
24650
25518
|
this.lastPublishedServiceManifestHashes = {};
|
|
25519
|
+
this.serviceManifestPublishedAt = {};
|
|
24651
25520
|
this.serviceManifestPublicationInFlight = false;
|
|
24652
25521
|
this.serviceManifestPublicationPendingReason = null;
|
|
24653
25522
|
this.serviceManifestPublicationPendingLayer = null;
|
|
25523
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
25524
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
25525
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
25526
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
25527
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
25528
|
+
}
|
|
25529
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
25530
|
+
this.localServiceManifestDefinitionInserted = false;
|
|
25531
|
+
this.localServiceManifestInstanceInserted = false;
|
|
25532
|
+
this.initialServiceManifestPublicationRequested = false;
|
|
24654
25533
|
resetBrowserRuntimeActorHandles();
|
|
24655
25534
|
}
|
|
24656
25535
|
};
|
|
24657
25536
|
CadenzaService.isBootstrapped = false;
|
|
24658
25537
|
CadenzaService.serviceCreated = false;
|
|
24659
25538
|
CadenzaService.bootstrapSyncCompleted = false;
|
|
25539
|
+
CadenzaService.bootstrapSyncCompletedAt = 0;
|
|
24660
25540
|
CadenzaService.bootstrapSignalRegistrationsCompleted = false;
|
|
24661
25541
|
CadenzaService.bootstrapIntentRegistrationsCompleted = false;
|
|
24662
25542
|
CadenzaService.defaultDatabaseServiceName = null;
|
|
@@ -24665,9 +25545,17 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
24665
25545
|
CadenzaService.frontendSyncScheduled = false;
|
|
24666
25546
|
CadenzaService.serviceManifestRevision = 0;
|
|
24667
25547
|
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
25548
|
+
CadenzaService.serviceManifestPublishedAt = {};
|
|
24668
25549
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
24669
25550
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
24670
25551
|
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
25552
|
+
CadenzaService.serviceManifestPublicationRetryReason = null;
|
|
25553
|
+
CadenzaService.serviceManifestPublicationRetryLayer = null;
|
|
25554
|
+
CadenzaService.serviceManifestPublicationRetryTimer = null;
|
|
25555
|
+
CadenzaService.serviceManifestPublicationRetryCount = 0;
|
|
25556
|
+
CadenzaService.localServiceManifestDefinitionInserted = false;
|
|
25557
|
+
CadenzaService.localServiceManifestInstanceInserted = false;
|
|
25558
|
+
CadenzaService.initialServiceManifestPublicationRequested = false;
|
|
24671
25559
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
24672
25560
|
CadenzaService.shutdownInFlight = false;
|
|
24673
25561
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -24675,6 +25563,8 @@ CadenzaService.shutdownHandlerCleanup = [];
|
|
|
24675
25563
|
// src/index.ts
|
|
24676
25564
|
import {
|
|
24677
25565
|
Actor as Actor2,
|
|
25566
|
+
GlobalDefinition as GlobalDefinition2,
|
|
25567
|
+
HelperDefinition as HelperDefinition2,
|
|
24678
25568
|
DebounceTask as DebounceTask2,
|
|
24679
25569
|
EphemeralTask as EphemeralTask2,
|
|
24680
25570
|
GraphRoutine as GraphRoutine2,
|
|
@@ -24975,6 +25865,18 @@ var createTask = CadenzaService.createTask.bind(
|
|
|
24975
25865
|
var createMetaTask = CadenzaService.createMetaTask.bind(
|
|
24976
25866
|
CadenzaService
|
|
24977
25867
|
);
|
|
25868
|
+
var createHelper = CadenzaService.createHelper.bind(
|
|
25869
|
+
CadenzaService
|
|
25870
|
+
);
|
|
25871
|
+
var createMetaHelper = CadenzaService.createMetaHelper.bind(
|
|
25872
|
+
CadenzaService
|
|
25873
|
+
);
|
|
25874
|
+
var createGlobal = CadenzaService.createGlobal.bind(
|
|
25875
|
+
CadenzaService
|
|
25876
|
+
);
|
|
25877
|
+
var createMetaGlobal = CadenzaService.createMetaGlobal.bind(
|
|
25878
|
+
CadenzaService
|
|
25879
|
+
);
|
|
24978
25880
|
var createActor = CadenzaService.createActor.bind(
|
|
24979
25881
|
CadenzaService
|
|
24980
25882
|
);
|
|
@@ -25009,8 +25911,10 @@ export {
|
|
|
25009
25911
|
DeputyTask,
|
|
25010
25912
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
25011
25913
|
EphemeralTask2 as EphemeralTask,
|
|
25914
|
+
GlobalDefinition2 as GlobalDefinition,
|
|
25012
25915
|
GraphMetadataController,
|
|
25013
25916
|
GraphRoutine2 as GraphRoutine,
|
|
25917
|
+
HelperDefinition2 as HelperDefinition,
|
|
25014
25918
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
25015
25919
|
RUNTIME_VALIDATION_INTENTS,
|
|
25016
25920
|
RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -25030,6 +25934,10 @@ export {
|
|
|
25030
25934
|
createCadenzaService,
|
|
25031
25935
|
createDatabaseService,
|
|
25032
25936
|
createExecutionPersistenceBundle,
|
|
25937
|
+
createGlobal,
|
|
25938
|
+
createHelper,
|
|
25939
|
+
createMetaGlobal,
|
|
25940
|
+
createMetaHelper,
|
|
25033
25941
|
createMetaTask,
|
|
25034
25942
|
createSSRInquiryBridge,
|
|
25035
25943
|
createTask,
|