@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/browser/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
|
)
|
|
@@ -1857,6 +1960,163 @@ function getAuthorityBootstrapInsertIntentSpecForTable(tableName) {
|
|
|
1857
1960
|
return getAuthorityBootstrapIntentSpec(intentName);
|
|
1858
1961
|
}
|
|
1859
1962
|
|
|
1963
|
+
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
1964
|
+
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
1965
|
+
function readString(value) {
|
|
1966
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
1967
|
+
}
|
|
1968
|
+
function readRecord(value) {
|
|
1969
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
1970
|
+
}
|
|
1971
|
+
function normalizeRoutineExecutionTraceFields(data) {
|
|
1972
|
+
if (!data) {
|
|
1973
|
+
return null;
|
|
1974
|
+
}
|
|
1975
|
+
const normalizedData = { ...data };
|
|
1976
|
+
const traceId = readString(
|
|
1977
|
+
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
1978
|
+
);
|
|
1979
|
+
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
1980
|
+
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
1981
|
+
const serviceName = readString(
|
|
1982
|
+
normalizedData.service_name ?? normalizedData.serviceName
|
|
1983
|
+
);
|
|
1984
|
+
const serviceInstanceId = readString(
|
|
1985
|
+
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
1986
|
+
);
|
|
1987
|
+
if (traceId) {
|
|
1988
|
+
normalizedData.execution_trace_id = traceId;
|
|
1989
|
+
}
|
|
1990
|
+
if (metaContext) {
|
|
1991
|
+
normalizedData.meta_context = metaContext;
|
|
1992
|
+
}
|
|
1993
|
+
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
1994
|
+
normalizedData.is_meta = isMeta;
|
|
1995
|
+
}
|
|
1996
|
+
if (serviceName) {
|
|
1997
|
+
normalizedData.service_name = serviceName;
|
|
1998
|
+
}
|
|
1999
|
+
if (serviceInstanceId) {
|
|
2000
|
+
normalizedData.service_instance_id = serviceInstanceId;
|
|
2001
|
+
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
2002
|
+
normalizedData.service_instance_id = null;
|
|
2003
|
+
}
|
|
2004
|
+
delete normalizedData.executionTraceId;
|
|
2005
|
+
delete normalizedData.traceId;
|
|
2006
|
+
delete normalizedData.metaContext;
|
|
2007
|
+
delete normalizedData.isMeta;
|
|
2008
|
+
delete normalizedData.serviceName;
|
|
2009
|
+
delete normalizedData.serviceInstanceId;
|
|
2010
|
+
return normalizedData;
|
|
2011
|
+
}
|
|
2012
|
+
function stripExecutionTraceServiceInstanceFields(data) {
|
|
2013
|
+
if (!data) {
|
|
2014
|
+
return null;
|
|
2015
|
+
}
|
|
2016
|
+
const normalizedData = { ...data };
|
|
2017
|
+
delete normalizedData.serviceInstanceId;
|
|
2018
|
+
delete normalizedData.service_instance_id;
|
|
2019
|
+
return normalizedData;
|
|
2020
|
+
}
|
|
2021
|
+
function normalizeEnsureData(entityType, data) {
|
|
2022
|
+
switch (entityType) {
|
|
2023
|
+
case "execution_trace":
|
|
2024
|
+
return stripExecutionTraceServiceInstanceFields(data);
|
|
2025
|
+
case "routine_execution":
|
|
2026
|
+
return normalizeRoutineExecutionTraceFields(data);
|
|
2027
|
+
default:
|
|
2028
|
+
return data;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
2032
|
+
const normalizedEntityId = readString(entityId);
|
|
2033
|
+
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
2034
|
+
}
|
|
2035
|
+
function resolveEnsureEntityId(entityType, data) {
|
|
2036
|
+
switch (entityType) {
|
|
2037
|
+
default:
|
|
2038
|
+
return readString(data.uuid);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
2042
|
+
return readString(
|
|
2043
|
+
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
function dedupeDependencies(values) {
|
|
2047
|
+
return Array.from(
|
|
2048
|
+
new Set(values.filter((value) => typeof value === "string"))
|
|
2049
|
+
);
|
|
2050
|
+
}
|
|
2051
|
+
function resolveTraceIdFromData(data) {
|
|
2052
|
+
if (!data) {
|
|
2053
|
+
return null;
|
|
2054
|
+
}
|
|
2055
|
+
return readString(
|
|
2056
|
+
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
2060
|
+
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
2061
|
+
if (!normalizedData) {
|
|
2062
|
+
return null;
|
|
2063
|
+
}
|
|
2064
|
+
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
2065
|
+
if (!entityId) {
|
|
2066
|
+
return null;
|
|
2067
|
+
}
|
|
2068
|
+
return {
|
|
2069
|
+
kind: "ensure",
|
|
2070
|
+
entityType,
|
|
2071
|
+
entityId,
|
|
2072
|
+
data: normalizedData,
|
|
2073
|
+
deps: dedupeDependencies(deps)
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
2077
|
+
const normalizedData = readRecord(data);
|
|
2078
|
+
const normalizedFilter = readRecord(filter);
|
|
2079
|
+
if (!normalizedData || !normalizedFilter) {
|
|
2080
|
+
return null;
|
|
2081
|
+
}
|
|
2082
|
+
const entityId = resolveUpdateEntityId(
|
|
2083
|
+
entityType,
|
|
2084
|
+
normalizedData,
|
|
2085
|
+
normalizedFilter
|
|
2086
|
+
);
|
|
2087
|
+
if (!entityId) {
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2090
|
+
return {
|
|
2091
|
+
kind: "update",
|
|
2092
|
+
entityType,
|
|
2093
|
+
entityId,
|
|
2094
|
+
data: normalizedData,
|
|
2095
|
+
filter: normalizedFilter,
|
|
2096
|
+
deps: dedupeDependencies(deps)
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
function createExecutionPersistenceBundle(input) {
|
|
2100
|
+
const ensures = (input.ensures ?? []).filter(
|
|
2101
|
+
(event) => Boolean(event)
|
|
2102
|
+
);
|
|
2103
|
+
const updates = (input.updates ?? []).filter(
|
|
2104
|
+
(event) => Boolean(event)
|
|
2105
|
+
);
|
|
2106
|
+
if (ensures.length === 0 && updates.length === 0) {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
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));
|
|
2110
|
+
if (!traceId) {
|
|
2111
|
+
return null;
|
|
2112
|
+
}
|
|
2113
|
+
return {
|
|
2114
|
+
traceId,
|
|
2115
|
+
ensures,
|
|
2116
|
+
updates
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
|
|
1860
2120
|
// src/utils/tools.ts
|
|
1861
2121
|
function formatTimestamp(timestamp) {
|
|
1862
2122
|
return new Date(timestamp).toISOString();
|
|
@@ -2087,12 +2347,24 @@ function listManifestGlobals() {
|
|
|
2087
2347
|
(globalDefinition) => Boolean(globalDefinition && !globalDefinition.destroyed)
|
|
2088
2348
|
);
|
|
2089
2349
|
}
|
|
2090
|
-
function isRoutingCriticalMetaSignal(
|
|
2091
|
-
return
|
|
2350
|
+
function isRoutingCriticalMetaSignal(signal) {
|
|
2351
|
+
return ROUTING_CRITICAL_META_SIGNALS.has(signal.name);
|
|
2092
2352
|
}
|
|
2093
|
-
function isRoutingCriticalMetaIntent(
|
|
2094
|
-
return
|
|
2353
|
+
function isRoutingCriticalMetaIntent(intent) {
|
|
2354
|
+
return ROUTING_CRITICAL_META_INTENTS.has(intent.name);
|
|
2095
2355
|
}
|
|
2356
|
+
var ROUTING_CRITICAL_META_INTENTS = /* @__PURE__ */ new Set([
|
|
2357
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
2358
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
2359
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
2360
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
2361
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
2362
|
+
]);
|
|
2363
|
+
var ROUTING_CRITICAL_META_SIGNALS = /* @__PURE__ */ new Set([
|
|
2364
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
2365
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
2366
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
2367
|
+
]);
|
|
2096
2368
|
function buildServiceManifestSnapshot(params) {
|
|
2097
2369
|
const {
|
|
2098
2370
|
serviceName,
|
|
@@ -2502,87 +2774,9 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2502
2774
|
`${right.routine_name}:${right.task_name}`
|
|
2503
2775
|
)
|
|
2504
2776
|
);
|
|
2505
|
-
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
2506
|
-
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
2507
|
-
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
2508
|
-
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
2509
|
-
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
2510
|
-
for (const map of localMetaSignalTaskMaps) {
|
|
2511
|
-
businessLocalMetaSignalNames.add(map.signal_name);
|
|
2512
|
-
businessLocalMetaTaskKeys.add(
|
|
2513
|
-
buildTaskKey({
|
|
2514
|
-
service_name: map.service_name,
|
|
2515
|
-
name: map.task_name,
|
|
2516
|
-
version: map.task_version
|
|
2517
|
-
})
|
|
2518
|
-
);
|
|
2519
|
-
}
|
|
2520
|
-
for (const map of localMetaIntentTaskMaps) {
|
|
2521
|
-
businessLocalMetaIntentNames.add(map.intent_name);
|
|
2522
|
-
businessLocalMetaTaskKeys.add(
|
|
2523
|
-
buildTaskKey({
|
|
2524
|
-
service_name: map.service_name,
|
|
2525
|
-
name: map.task_name,
|
|
2526
|
-
version: map.task_version
|
|
2527
|
-
})
|
|
2528
|
-
);
|
|
2529
|
-
}
|
|
2530
|
-
for (const map of localMetaActorTaskMaps) {
|
|
2531
|
-
businessLocalMetaActorKeys.add(
|
|
2532
|
-
buildActorKey({
|
|
2533
|
-
service_name: map.service_name,
|
|
2534
|
-
name: map.actor_name,
|
|
2535
|
-
version: map.actor_version
|
|
2536
|
-
})
|
|
2537
|
-
);
|
|
2538
|
-
businessLocalMetaTaskKeys.add(
|
|
2539
|
-
buildTaskKey({
|
|
2540
|
-
service_name: map.service_name,
|
|
2541
|
-
name: map.task_name,
|
|
2542
|
-
version: map.task_version
|
|
2543
|
-
})
|
|
2544
|
-
);
|
|
2545
|
-
}
|
|
2546
|
-
for (const map of localMetaTaskToRoutineMaps) {
|
|
2547
|
-
businessLocalMetaRoutineKeys.add(
|
|
2548
|
-
buildRoutineKey({
|
|
2549
|
-
service_name: map.service_name,
|
|
2550
|
-
name: map.routine_name,
|
|
2551
|
-
version: map.routine_version
|
|
2552
|
-
})
|
|
2553
|
-
);
|
|
2554
|
-
businessLocalMetaTaskKeys.add(
|
|
2555
|
-
buildTaskKey({
|
|
2556
|
-
service_name: map.service_name,
|
|
2557
|
-
name: map.task_name,
|
|
2558
|
-
version: map.task_version
|
|
2559
|
-
})
|
|
2560
|
-
);
|
|
2561
|
-
}
|
|
2562
|
-
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
2563
|
-
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
2564
|
-
).sort(
|
|
2565
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2566
|
-
);
|
|
2567
|
-
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
2568
|
-
(signal) => signal !== null && signal.is_meta === true
|
|
2569
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2570
|
-
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
2571
|
-
(intent) => intent !== null && intent.is_meta === true
|
|
2572
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2573
|
-
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
2574
|
-
(actor) => actor !== null && actor.is_meta === true
|
|
2575
|
-
).sort(
|
|
2576
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2577
|
-
);
|
|
2578
|
-
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
2579
|
-
(routine) => routine !== null && routine.is_meta === true
|
|
2580
|
-
).sort(
|
|
2581
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2582
|
-
);
|
|
2583
2777
|
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
2584
2778
|
new Map(
|
|
2585
|
-
[...routingTasks, ...businessTasks
|
|
2779
|
+
[...routingTasks, ...businessTasks].map((task) => [
|
|
2586
2780
|
buildTaskKey(task),
|
|
2587
2781
|
task
|
|
2588
2782
|
])
|
|
@@ -2601,7 +2795,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2601
2795
|
);
|
|
2602
2796
|
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
2603
2797
|
new Map(
|
|
2604
|
-
[...routingSignals, ...businessSignals
|
|
2798
|
+
[...routingSignals, ...businessSignals].map(
|
|
2605
2799
|
(signal) => [signal.name, signal]
|
|
2606
2800
|
)
|
|
2607
2801
|
).values()
|
|
@@ -2615,7 +2809,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2615
2809
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2616
2810
|
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
2617
2811
|
new Map(
|
|
2618
|
-
[...routingIntents, ...businessIntents
|
|
2812
|
+
[...routingIntents, ...businessIntents].map(
|
|
2619
2813
|
(intent) => [intent.name, intent]
|
|
2620
2814
|
)
|
|
2621
2815
|
).values()
|
|
@@ -2627,16 +2821,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2627
2821
|
])
|
|
2628
2822
|
).values()
|
|
2629
2823
|
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2630
|
-
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2631
|
-
new Map(
|
|
2632
|
-
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
2633
|
-
buildActorKey(actor),
|
|
2634
|
-
actor
|
|
2635
|
-
])
|
|
2636
|
-
).values()
|
|
2637
|
-
).sort(
|
|
2638
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2639
|
-
) : Array.from(
|
|
2824
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActors : Array.from(
|
|
2640
2825
|
new Map(
|
|
2641
2826
|
[...businessActors, ...localMetaActors].map((actor) => [
|
|
2642
2827
|
buildActorKey(actor),
|
|
@@ -2646,16 +2831,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2646
2831
|
).sort(
|
|
2647
2832
|
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2648
2833
|
);
|
|
2649
|
-
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2650
|
-
new Map(
|
|
2651
|
-
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
2652
|
-
buildRoutineKey(routine),
|
|
2653
|
-
routine
|
|
2654
|
-
])
|
|
2655
|
-
).values()
|
|
2656
|
-
).sort(
|
|
2657
|
-
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2658
|
-
) : Array.from(
|
|
2834
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessRoutines : Array.from(
|
|
2659
2835
|
new Map(
|
|
2660
2836
|
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
2661
2837
|
buildRoutineKey(routine),
|
|
@@ -2781,14 +2957,7 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2781
2957
|
)
|
|
2782
2958
|
).values()
|
|
2783
2959
|
);
|
|
2784
|
-
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2785
|
-
new Map(
|
|
2786
|
-
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2787
|
-
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2788
|
-
map
|
|
2789
|
-
])
|
|
2790
|
-
).values()
|
|
2791
|
-
) : Array.from(
|
|
2960
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessActorTaskMaps : Array.from(
|
|
2792
2961
|
new Map(
|
|
2793
2962
|
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2794
2963
|
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
@@ -2816,8 +2985,8 @@ function buildServiceManifestSnapshot(params) {
|
|
|
2816
2985
|
helpers: cumulativeHelpers,
|
|
2817
2986
|
globals: cumulativeGlobals,
|
|
2818
2987
|
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
2819
|
-
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] :
|
|
2820
|
-
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] :
|
|
2988
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : publishedSignalTaskMaps,
|
|
2989
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : publishedIntentTaskMaps,
|
|
2821
2990
|
actorTaskMaps: cumulativeActorTaskMaps,
|
|
2822
2991
|
taskToRoutineMaps: cumulativeTaskToRoutineMaps,
|
|
2823
2992
|
taskToHelperMaps: cumulativeTaskToHelperMaps,
|
|
@@ -2981,6 +3150,13 @@ var META_SERVICE_INSTANCE_SHUTDOWN_TRANSPORT_DEACTIVATION_SIGNAL = "meta.service
|
|
|
2981
3150
|
var META_AUTHORITY_BOOTSTRAP_HANDSHAKE_REQUESTED_SIGNAL = "meta.service_registry.authority_bootstrap_handshake_requested";
|
|
2982
3151
|
var META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL = "meta.service_registry.runtime_status.rest_refresh_tick";
|
|
2983
3152
|
var AUTHORITY_BOOTSTRAP_HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
3153
|
+
var AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS = [
|
|
3154
|
+
1e3,
|
|
3155
|
+
3e3,
|
|
3156
|
+
7e3,
|
|
3157
|
+
15e3
|
|
3158
|
+
];
|
|
3159
|
+
var AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS = 6e4;
|
|
2984
3160
|
var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
2985
3161
|
100,
|
|
2986
3162
|
1500,
|
|
@@ -2990,25 +3166,41 @@ var EARLY_FULL_SYNC_DELAYS_MS = [
|
|
|
2990
3166
|
45e3,
|
|
2991
3167
|
7e4
|
|
2992
3168
|
];
|
|
3169
|
+
var PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS = [
|
|
3170
|
+
50,
|
|
3171
|
+
125,
|
|
3172
|
+
250,
|
|
3173
|
+
500
|
|
3174
|
+
];
|
|
2993
3175
|
var MIN_BOOTSTRAP_FULL_SYNC_ATTEMPTS = 4;
|
|
2994
|
-
var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
2995
|
-
"Track local routine start",
|
|
2996
|
-
"Track local routine end",
|
|
2997
|
-
"Start runtime status sharing intervals",
|
|
2998
|
-
"Broadcast runtime status",
|
|
2999
|
-
"Flush local runtime status to authority",
|
|
3000
|
-
"Monitor dependee heartbeat freshness",
|
|
3001
|
-
"Refresh REST dependee runtime status",
|
|
3002
|
-
"Resolve runtime status fallback inquiry",
|
|
3003
|
-
"Respond runtime status inquiry",
|
|
3004
|
-
"Respond readiness inquiry",
|
|
3005
|
-
"Collect distributed readiness",
|
|
3006
|
-
"Get status"
|
|
3007
|
-
]);
|
|
3008
3176
|
var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRACE_SERVICE ?? "").trim();
|
|
3009
3177
|
function shouldTraceServiceRegistry(serviceName) {
|
|
3010
3178
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
3011
3179
|
}
|
|
3180
|
+
function getFetchFailureText(ctx) {
|
|
3181
|
+
return String(ctx?.__error ?? ctx?.error ?? ctx?.message ?? "").trim();
|
|
3182
|
+
}
|
|
3183
|
+
function isTerminalFetchTransportFailure(ctx) {
|
|
3184
|
+
const errorText = getFetchFailureText(ctx);
|
|
3185
|
+
if (!errorText) {
|
|
3186
|
+
return false;
|
|
3187
|
+
}
|
|
3188
|
+
return errorText.includes("ENOTFOUND") || errorText.includes("ECONNREFUSED") || errorText.includes("EHOSTUNREACH");
|
|
3189
|
+
}
|
|
3190
|
+
function isRecoverableFetchTransportFailure(ctx, options = {}) {
|
|
3191
|
+
const errorText = getFetchFailureText(ctx);
|
|
3192
|
+
if (!errorText) {
|
|
3193
|
+
return false;
|
|
3194
|
+
}
|
|
3195
|
+
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");
|
|
3196
|
+
}
|
|
3197
|
+
function isHardFetchHandshakeFailure(ctx) {
|
|
3198
|
+
const errorText = getFetchFailureText(ctx);
|
|
3199
|
+
if (!errorText) {
|
|
3200
|
+
return false;
|
|
3201
|
+
}
|
|
3202
|
+
return isTerminalFetchTransportFailure(ctx) || isRecoverableFetchTransportFailure(ctx);
|
|
3203
|
+
}
|
|
3012
3204
|
function normalizeLeaseStatus(value) {
|
|
3013
3205
|
const status = String(value ?? "").trim();
|
|
3014
3206
|
if (status === "active" || status === "non_responsive" || status === "inactive" || status === "deleted") {
|
|
@@ -3154,18 +3346,28 @@ function compactAuthorityBootstrapRequestBody(ctx) {
|
|
|
3154
3346
|
if (!isBootstrapDbOperationRoutineName(ctx.__remoteRoutineName)) {
|
|
3155
3347
|
return ctx;
|
|
3156
3348
|
}
|
|
3157
|
-
const
|
|
3158
|
-
|
|
3159
|
-
|
|
3349
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? { ...ctx.queryData } : {};
|
|
3350
|
+
const compactQueryData = {};
|
|
3351
|
+
for (const key of BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS) {
|
|
3352
|
+
if (Object.prototype.hasOwnProperty.call(existingQueryData, key)) {
|
|
3353
|
+
compactQueryData[key] = existingQueryData[key];
|
|
3354
|
+
continue;
|
|
3355
|
+
}
|
|
3356
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key)) {
|
|
3357
|
+
compactQueryData[key] = ctx[key];
|
|
3358
|
+
}
|
|
3160
3359
|
}
|
|
3161
3360
|
const compacted = {
|
|
3162
|
-
|
|
3163
|
-
|
|
3361
|
+
__remoteRoutineName: ctx.__remoteRoutineName,
|
|
3362
|
+
__serviceName: ctx.__serviceName,
|
|
3363
|
+
__localServiceName: ctx.__localServiceName,
|
|
3364
|
+
__timeout: ctx.__timeout,
|
|
3365
|
+
__syncing: true,
|
|
3366
|
+
__authorityBootstrapChannel: true,
|
|
3367
|
+
queryData: compactQueryData
|
|
3164
3368
|
};
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
delete compacted[key];
|
|
3168
|
-
}
|
|
3369
|
+
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
3370
|
+
compacted.__reason = ctx.__reason;
|
|
3169
3371
|
}
|
|
3170
3372
|
return compacted;
|
|
3171
3373
|
}
|
|
@@ -3885,6 +4087,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3885
4087
|
handshakeEstablished: false
|
|
3886
4088
|
};
|
|
3887
4089
|
this.authorityBootstrapHandshakeInFlight = false;
|
|
4090
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
4091
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
4092
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
4093
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
4094
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
3888
4095
|
this.authorityFullSyncResponderTask = null;
|
|
3889
4096
|
this.authorityServiceCommunicationPersistenceTask = null;
|
|
3890
4097
|
this.localLifecycleFlushActor = CadenzaService.createActor(
|
|
@@ -4420,7 +4627,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4420
4627
|
return false;
|
|
4421
4628
|
}
|
|
4422
4629
|
this.clearTransportReadyFromContext(ctx);
|
|
4423
|
-
const
|
|
4630
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
4631
|
+
const serviceInstanceId = String(
|
|
4632
|
+
ctx.serviceInstanceId ?? ctx.__instance ?? ctx.filter?.uuid ?? ""
|
|
4633
|
+
).trim();
|
|
4634
|
+
const serviceTransportId = String(
|
|
4635
|
+
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
4636
|
+
).trim();
|
|
4424
4637
|
if (serviceName === "CadenzaDB" && this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
4425
4638
|
const currentAuthorityInstanceId = String(
|
|
4426
4639
|
this.authorityBootstrapRoute.serviceInstanceId ?? ""
|
|
@@ -4436,6 +4649,26 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4436
4649
|
return true;
|
|
4437
4650
|
}
|
|
4438
4651
|
}
|
|
4652
|
+
const signalName = String(
|
|
4653
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
4654
|
+
).trim();
|
|
4655
|
+
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
4656
|
+
const hardFetchHandshakeFailure = isFetchHandshakeFailure && isHardFetchHandshakeFailure(ctx);
|
|
4657
|
+
const recoverableFetchHandshakeFailure = isFetchHandshakeFailure && isRecoverableFetchTransportFailure(ctx, {
|
|
4658
|
+
includeConnectionRefused: true
|
|
4659
|
+
});
|
|
4660
|
+
const isFetchDelegateFailure = signalName === "meta.fetch.delegate_failed" || signalName.startsWith("meta.fetch.delegate_failed:");
|
|
4661
|
+
const hardFetchDelegateFailure = isFetchDelegateFailure && isHardFetchHandshakeFailure(ctx);
|
|
4662
|
+
const recoverableFetchDelegateFailure = isFetchDelegateFailure && isRecoverableFetchTransportFailure(ctx);
|
|
4663
|
+
if (isFetchDelegateFailure && !hardFetchDelegateFailure) {
|
|
4664
|
+
return false;
|
|
4665
|
+
}
|
|
4666
|
+
if (serviceName === "CadenzaDB" && (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure)) {
|
|
4667
|
+
return false;
|
|
4668
|
+
}
|
|
4669
|
+
if (serviceName === "CadenzaDB" && this.authorityBootstrapRecoveryActive) {
|
|
4670
|
+
return false;
|
|
4671
|
+
}
|
|
4439
4672
|
const serviceInstances = this.instances.get(serviceName);
|
|
4440
4673
|
const instances = serviceInstances?.filter((instance) => {
|
|
4441
4674
|
if (serviceInstanceId && instance.uuid === serviceInstanceId) {
|
|
@@ -4459,6 +4692,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4459
4692
|
"warning",
|
|
4460
4693
|
serviceName
|
|
4461
4694
|
);
|
|
4695
|
+
if (serviceName === "CadenzaDB") {
|
|
4696
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
4697
|
+
}
|
|
4462
4698
|
for (const instance of instances ?? []) {
|
|
4463
4699
|
if (instance.serviceName === this.serviceName && instance.uuid === this.serviceInstanceId) {
|
|
4464
4700
|
continue;
|
|
@@ -4467,13 +4703,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4467
4703
|
if (affectedTransport && this.hasAnyReadyClientProtocolForTransport(instance, affectedTransport)) {
|
|
4468
4704
|
continue;
|
|
4469
4705
|
}
|
|
4470
|
-
|
|
4471
|
-
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
4472
|
-
).trim();
|
|
4473
|
-
const isFetchHandshakeFailure = signalName === "meta.fetch.handshake_failed" || signalName.startsWith("meta.fetch.handshake_failed:");
|
|
4474
|
-
if (isFetchHandshakeFailure && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
4706
|
+
if ((isFetchHandshakeFailure && (!hardFetchHandshakeFailure || recoverableFetchHandshakeFailure) || isFetchDelegateFailure && (!hardFetchDelegateFailure || recoverableFetchDelegateFailure)) && affectedTransport && this.isCurrentRouteContext(ctx) && this.scheduleDependeeClientRecovery(instance, affectedTransport, {
|
|
4475
4707
|
...ctx,
|
|
4476
|
-
__reason: "fetch_handshake_failed_retry"
|
|
4708
|
+
__reason: isFetchDelegateFailure ? "fetch_delegate_failed_retry" : "fetch_handshake_failed_retry"
|
|
4477
4709
|
})) {
|
|
4478
4710
|
continue;
|
|
4479
4711
|
}
|
|
@@ -4484,10 +4716,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4484
4716
|
});
|
|
4485
4717
|
continue;
|
|
4486
4718
|
}
|
|
4719
|
+
if (isFetchHandshakeFailure && recoverableFetchHandshakeFailure || isFetchDelegateFailure && recoverableFetchDelegateFailure) {
|
|
4720
|
+
continue;
|
|
4721
|
+
}
|
|
4487
4722
|
this.applyInstanceLifecycleState(instance, {
|
|
4488
4723
|
isActive: false,
|
|
4489
4724
|
isNonResponsive: true
|
|
4490
4725
|
});
|
|
4726
|
+
const transportsToClear = affectedTransport ? [affectedTransport] : (instance.transports ?? []).filter((transport) => !transport.deleted);
|
|
4727
|
+
for (const transport of transportsToClear) {
|
|
4728
|
+
this.clearTransportFailureState(instance.uuid, transport.uuid);
|
|
4729
|
+
this.clearTransportClientState(instance, transport);
|
|
4730
|
+
this.clearRemoteRouteRecordIfCurrent(
|
|
4731
|
+
instance.serviceName,
|
|
4732
|
+
instance.uuid,
|
|
4733
|
+
transport
|
|
4734
|
+
);
|
|
4735
|
+
this.emitTransportHandleShutdowns(
|
|
4736
|
+
emit2,
|
|
4737
|
+
this.buildTransportRouteKey(instance.serviceName, transport),
|
|
4738
|
+
transport
|
|
4739
|
+
);
|
|
4740
|
+
}
|
|
4741
|
+
emit2("meta.service_registry.service_not_responding", {
|
|
4742
|
+
...ctx,
|
|
4743
|
+
serviceName: instance.serviceName,
|
|
4744
|
+
serviceInstanceId: instance.uuid,
|
|
4745
|
+
serviceTransportId: affectedTransport?.uuid ?? serviceTransportId ?? void 0,
|
|
4746
|
+
routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.routeKey ?? ctx.__routeKey,
|
|
4747
|
+
__routeKey: affectedTransport ? this.buildTransportRouteKey(instance.serviceName, affectedTransport) : ctx.__routeKey ?? ctx.routeKey
|
|
4748
|
+
});
|
|
4491
4749
|
emit2("global.meta.service_registry.service_not_responding", {
|
|
4492
4750
|
data: {
|
|
4493
4751
|
isActive: false,
|
|
@@ -4516,6 +4774,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4516
4774
|
).doOn(
|
|
4517
4775
|
"meta.fetch.handshake_failed",
|
|
4518
4776
|
"meta.fetch.handshake_failed.*",
|
|
4777
|
+
"meta.fetch.delegate_failed",
|
|
4778
|
+
"meta.fetch.delegate_failed.*",
|
|
4519
4779
|
"meta.socket_client.disconnected",
|
|
4520
4780
|
"meta.socket_client.disconnected.*",
|
|
4521
4781
|
"meta.service_registry.runtime_status_unreachable"
|
|
@@ -4701,12 +4961,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4701
4961
|
return false;
|
|
4702
4962
|
}
|
|
4703
4963
|
}
|
|
4704
|
-
this.
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
__reason: "cadenza_db_unreachable"
|
|
4709
|
-
});
|
|
4964
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
4965
|
+
return false;
|
|
4966
|
+
}
|
|
4967
|
+
this.restartAuthorityBootstrapRecovery("cadenza_db_unreachable");
|
|
4710
4968
|
return true;
|
|
4711
4969
|
},
|
|
4712
4970
|
"Clears bootstrap full-sync retry satisfaction when the authority becomes unreachable."
|
|
@@ -4726,7 +4984,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4726
4984
|
return false;
|
|
4727
4985
|
}
|
|
4728
4986
|
this.ensureBootstrapAuthorityControlPlane(ctx, emit2);
|
|
4729
|
-
return this.
|
|
4987
|
+
return this.scheduleNextBootstrapFullSyncRetry(
|
|
4730
4988
|
"cadenza_db_fetch_handshake"
|
|
4731
4989
|
);
|
|
4732
4990
|
},
|
|
@@ -5093,12 +5351,24 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5093
5351
|
preferredRole,
|
|
5094
5352
|
preferredProtocol
|
|
5095
5353
|
);
|
|
5354
|
+
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
5355
|
+
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
5356
|
+
}
|
|
5357
|
+
const hasPendingRouteableInstance = Boolean(__serviceName) && __serviceName !== "CadenzaDB" && this.hasPendingRouteableInstanceForSelection(
|
|
5358
|
+
__serviceName,
|
|
5359
|
+
context,
|
|
5360
|
+
preferredRole,
|
|
5361
|
+
targetServiceInstanceId
|
|
5362
|
+
);
|
|
5096
5363
|
const activeRoutingCooldown = __serviceName && !targetServiceInstanceId ? this.getActiveRoutingCooldown(
|
|
5097
5364
|
__serviceName,
|
|
5098
5365
|
preferredRole,
|
|
5099
5366
|
preferredProtocol
|
|
5100
5367
|
) : null;
|
|
5101
5368
|
if (activeRoutingCooldown) {
|
|
5369
|
+
if (hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
5370
|
+
return false;
|
|
5371
|
+
}
|
|
5102
5372
|
context.errored = true;
|
|
5103
5373
|
context.__error = `No routeable ${preferredRole} transport available for ${__serviceName}. Waiting for authority route updates before retrying.`;
|
|
5104
5374
|
emit2(
|
|
@@ -5140,9 +5410,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5140
5410
|
}
|
|
5141
5411
|
let retries = __retries ?? 0;
|
|
5142
5412
|
let triedInstances = __triedInstances ?? [];
|
|
5143
|
-
if (this.shouldDemandEstablishRemoteClients(context)) {
|
|
5144
|
-
this.ensureDependeeClientsForService(__serviceName, emit2, context);
|
|
5145
|
-
}
|
|
5146
5413
|
const filteredInstances = this.instances.get(__serviceName)?.filter((instance) => {
|
|
5147
5414
|
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
5148
5415
|
return false;
|
|
@@ -5161,6 +5428,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5161
5428
|
)
|
|
5162
5429
|
);
|
|
5163
5430
|
}) ?? [];
|
|
5431
|
+
if (filteredInstances.length === 0 && __serviceName && hasPendingRouteableInstance && this.maybeSchedulePendingRouteSelectionRetry(context, __serviceName)) {
|
|
5432
|
+
return false;
|
|
5433
|
+
}
|
|
5164
5434
|
const instances = this.collapseInstancesByRouteOrigin(
|
|
5165
5435
|
filteredInstances,
|
|
5166
5436
|
context,
|
|
@@ -5504,10 +5774,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5504
5774
|
CadenzaService.createMetaTask(
|
|
5505
5775
|
"Track local routine start",
|
|
5506
5776
|
(ctx, emit2) => {
|
|
5507
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
5508
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
5509
|
-
return false;
|
|
5510
|
-
}
|
|
5511
5777
|
const routineId = String(
|
|
5512
5778
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
5513
5779
|
);
|
|
@@ -5538,10 +5804,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5538
5804
|
CadenzaService.createMetaTask(
|
|
5539
5805
|
"Track local routine end",
|
|
5540
5806
|
(ctx, emit2) => {
|
|
5541
|
-
const sourceTaskName = String(ctx.__signalEmission?.taskName ?? "");
|
|
5542
|
-
if (INTERNAL_RUNTIME_STATUS_TASK_NAMES.has(sourceTaskName)) {
|
|
5543
|
-
return false;
|
|
5544
|
-
}
|
|
5545
5807
|
const routineId = String(
|
|
5546
5808
|
ctx.filter?.uuid ?? ctx.__routineExecId ?? ""
|
|
5547
5809
|
);
|
|
@@ -6175,6 +6437,19 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6175
6437
|
}
|
|
6176
6438
|
return false;
|
|
6177
6439
|
}
|
|
6440
|
+
if (this.serviceName && normalizedLocalInstance.serviceName !== this.serviceName || this.serviceInstanceId && normalizedLocalInstance.uuid !== this.serviceInstanceId) {
|
|
6441
|
+
if (shouldTraceServiceRegistry(
|
|
6442
|
+
resolveServiceNameFromContext(ctx) || this.serviceName
|
|
6443
|
+
)) {
|
|
6444
|
+
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service_ignored_non_local_instance", {
|
|
6445
|
+
localServiceName: this.serviceName,
|
|
6446
|
+
localServiceInstanceId: this.serviceInstanceId,
|
|
6447
|
+
resolvedServiceName: normalizedLocalInstance.serviceName,
|
|
6448
|
+
resolvedServiceInstanceId: normalizedLocalInstance.uuid
|
|
6449
|
+
});
|
|
6450
|
+
}
|
|
6451
|
+
return false;
|
|
6452
|
+
}
|
|
6178
6453
|
if (shouldTraceServiceRegistry(normalizedLocalInstance.serviceName)) {
|
|
6179
6454
|
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] setup_service", {
|
|
6180
6455
|
localServiceName: this.serviceName,
|
|
@@ -6390,7 +6665,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6390
6665
|
security_profile: "excluded",
|
|
6391
6666
|
auth_strategy: "excluded",
|
|
6392
6667
|
deleted: "false"
|
|
6393
|
-
}
|
|
6668
|
+
},
|
|
6669
|
+
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"
|
|
6394
6670
|
}
|
|
6395
6671
|
}
|
|
6396
6672
|
},
|
|
@@ -7322,6 +7598,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7322
7598
|
serviceTransportId: String(ctx.serviceTransportId ?? "").trim() || null,
|
|
7323
7599
|
handshakeEstablished: true
|
|
7324
7600
|
};
|
|
7601
|
+
this.markAuthorityBootstrapHandshakeSatisfied();
|
|
7325
7602
|
return true;
|
|
7326
7603
|
}
|
|
7327
7604
|
getAuthorityBootstrapRestTarget() {
|
|
@@ -7350,6 +7627,92 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7350
7627
|
handshakeEstablished: false
|
|
7351
7628
|
};
|
|
7352
7629
|
}
|
|
7630
|
+
clearAuthorityBootstrapHandshakeRetryTimer() {
|
|
7631
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
7632
|
+
clearTimeout(this.authorityBootstrapHandshakeRetryTimer);
|
|
7633
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
7634
|
+
}
|
|
7635
|
+
}
|
|
7636
|
+
invalidateAuthorityBootstrapHandshakeRetryState(reason) {
|
|
7637
|
+
this.authorityBootstrapHandshakeRetryGeneration += 1;
|
|
7638
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
7639
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
7640
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
7641
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
markAuthorityBootstrapHandshakeSatisfied() {
|
|
7645
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
7646
|
+
this.authorityBootstrapHandshakeRetryIndex = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length;
|
|
7647
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
7648
|
+
this.authorityBootstrapRecoveryActive = false;
|
|
7649
|
+
}
|
|
7650
|
+
buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(baseDelayMs, attempt) {
|
|
7651
|
+
return buildDeterministicJitteredDelayMs(
|
|
7652
|
+
baseDelayMs,
|
|
7653
|
+
this.bootstrapFullSyncRetryJitterRatio,
|
|
7654
|
+
this.buildDeterministicInstanceJitterKey(
|
|
7655
|
+
`authority-bootstrap-handshake-retry-${attempt}`
|
|
7656
|
+
)
|
|
7657
|
+
);
|
|
7658
|
+
}
|
|
7659
|
+
scheduleAuthorityBootstrapHandshakeRetry(reason) {
|
|
7660
|
+
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
7661
|
+
return false;
|
|
7662
|
+
}
|
|
7663
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
7664
|
+
return false;
|
|
7665
|
+
}
|
|
7666
|
+
if (this.authorityBootstrapHandshakeInFlight) {
|
|
7667
|
+
return false;
|
|
7668
|
+
}
|
|
7669
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
7670
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
7671
|
+
}
|
|
7672
|
+
if (this.authorityBootstrapHandshakeRetryTimer) {
|
|
7673
|
+
return false;
|
|
7674
|
+
}
|
|
7675
|
+
const retryGeneration = this.authorityBootstrapHandshakeRetryGeneration;
|
|
7676
|
+
const retryReason = this.authorityBootstrapHandshakeRetryReason ?? "authority_bootstrap_handshake_retry";
|
|
7677
|
+
const attempt = this.authorityBootstrapHandshakeRetryIndex + 1;
|
|
7678
|
+
const baseDelayMs = AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS[Math.min(
|
|
7679
|
+
this.authorityBootstrapHandshakeRetryIndex,
|
|
7680
|
+
AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.length - 1
|
|
7681
|
+
)] ?? AUTHORITY_BOOTSTRAP_HANDSHAKE_RETRY_DELAYS_MS.at(-1);
|
|
7682
|
+
const delayMs = this.buildJitteredAuthorityBootstrapHandshakeRetryDelayMs(
|
|
7683
|
+
baseDelayMs,
|
|
7684
|
+
attempt
|
|
7685
|
+
);
|
|
7686
|
+
this.authorityBootstrapHandshakeRetryIndex += 1;
|
|
7687
|
+
this.authorityBootstrapHandshakeRetryTimer = setTimeout(() => {
|
|
7688
|
+
this.authorityBootstrapHandshakeRetryTimer = null;
|
|
7689
|
+
if (this.hasAuthorityBootstrapHandshakeEstablished() || this.authorityBootstrapHandshakeInFlight || retryGeneration !== this.authorityBootstrapHandshakeRetryGeneration) {
|
|
7690
|
+
return;
|
|
7691
|
+
}
|
|
7692
|
+
this.requestAuthorityBootstrapHandshake({
|
|
7693
|
+
__reason: retryReason,
|
|
7694
|
+
__authorityBootstrapRetry: true,
|
|
7695
|
+
__authorityBootstrapRetryAttempt: attempt
|
|
7696
|
+
});
|
|
7697
|
+
}, delayMs);
|
|
7698
|
+
return true;
|
|
7699
|
+
}
|
|
7700
|
+
restartAuthorityBootstrapHandshakeRetryChain(reason) {
|
|
7701
|
+
this.invalidateAuthorityBootstrapHandshakeRetryState(reason);
|
|
7702
|
+
return this.scheduleAuthorityBootstrapHandshakeRetry(reason);
|
|
7703
|
+
}
|
|
7704
|
+
restartAuthorityBootstrapRecovery(reason) {
|
|
7705
|
+
if (this.authorityBootstrapRecoveryActive) {
|
|
7706
|
+
if (typeof reason === "string" && reason.trim()) {
|
|
7707
|
+
this.authorityBootstrapHandshakeRetryReason = reason.trim();
|
|
7708
|
+
}
|
|
7709
|
+
return false;
|
|
7710
|
+
}
|
|
7711
|
+
this.authorityBootstrapRecoveryActive = true;
|
|
7712
|
+
this.invalidateAuthorityBootstrapHandshake();
|
|
7713
|
+
this.invalidateBootstrapFullSyncRetryState(reason);
|
|
7714
|
+
return this.restartAuthorityBootstrapHandshakeRetryChain(reason);
|
|
7715
|
+
}
|
|
7353
7716
|
requestAuthorityBootstrapHandshake(ctx) {
|
|
7354
7717
|
if (!this.connectsToCadenzaDB || !this.serviceName || this.serviceName === "CadenzaDB") {
|
|
7355
7718
|
return false;
|
|
@@ -7556,12 +7919,16 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7556
7919
|
return;
|
|
7557
7920
|
}
|
|
7558
7921
|
const deputyTaskName = `Inquire ${map.intentName} via ${map.serviceName} (${map.taskName} v${map.taskVersion})`;
|
|
7559
|
-
const
|
|
7922
|
+
const shouldUseAuthorityBootstrapTimeout = map.serviceName === "CadenzaDB" && isMetaIntentName(map.intentName);
|
|
7923
|
+
const effectiveTimeout = shouldUseAuthorityBootstrapTimeout ? Math.max(map.timeout ?? 0, AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS) : map.timeout;
|
|
7924
|
+
const authorityBootstrapIntentSpec = map.serviceName === "CadenzaDB" ? getAuthorityBootstrapIntentSpec(map.intentName) : null;
|
|
7925
|
+
const authorityBootstrapTaskName = authorityBootstrapIntentSpec?.authorityTaskName ?? map.taskName;
|
|
7926
|
+
const deputyTask = authorityBootstrapIntentSpec ? CadenzaService.createMetaTask(
|
|
7560
7927
|
deputyTaskName,
|
|
7561
7928
|
async (ctx) => this.invokeAuthorityBootstrapRoutine(
|
|
7562
|
-
|
|
7929
|
+
authorityBootstrapTaskName,
|
|
7563
7930
|
ctx,
|
|
7564
|
-
|
|
7931
|
+
effectiveTimeout ?? AUTHORITY_BOOTSTRAP_ROUTINE_TIMEOUT_MS
|
|
7565
7932
|
),
|
|
7566
7933
|
"Routes reserved authority bootstrap inquiries directly through the post-handshake authority control-plane channel.",
|
|
7567
7934
|
{
|
|
@@ -7571,14 +7938,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7571
7938
|
) : isMetaIntentName(map.intentName) ? CadenzaService.createMetaDeputyTask(map.taskName, map.serviceName, {
|
|
7572
7939
|
register: false,
|
|
7573
7940
|
isHidden: true,
|
|
7574
|
-
timeout:
|
|
7941
|
+
timeout: effectiveTimeout,
|
|
7575
7942
|
retryCount: 1,
|
|
7576
7943
|
retryDelay: 50,
|
|
7577
7944
|
retryDelayFactor: 1.2
|
|
7578
7945
|
}) : CadenzaService.createDeputyTask(map.taskName, map.serviceName, {
|
|
7579
7946
|
register: false,
|
|
7580
7947
|
isHidden: true,
|
|
7581
|
-
timeout:
|
|
7948
|
+
timeout: effectiveTimeout,
|
|
7582
7949
|
retryCount: 1,
|
|
7583
7950
|
retryDelay: 50,
|
|
7584
7951
|
retryDelayFactor: 1.2
|
|
@@ -7592,7 +7959,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7592
7959
|
key,
|
|
7593
7960
|
intentName: map.intentName,
|
|
7594
7961
|
serviceName: map.serviceName,
|
|
7595
|
-
remoteTaskName:
|
|
7962
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
7596
7963
|
remoteTaskVersion: map.taskVersion,
|
|
7597
7964
|
localTaskName: deputyTask.name || deputyTaskName,
|
|
7598
7965
|
localTask: deputyTask
|
|
@@ -7604,7 +7971,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
7604
7971
|
localServiceName: this.serviceName,
|
|
7605
7972
|
intentName: map.intentName,
|
|
7606
7973
|
remoteServiceName: map.serviceName,
|
|
7607
|
-
remoteTaskName:
|
|
7974
|
+
remoteTaskName: authorityBootstrapTaskName,
|
|
7608
7975
|
remoteTaskVersion: map.taskVersion
|
|
7609
7976
|
});
|
|
7610
7977
|
}
|
|
@@ -8304,6 +8671,50 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8304
8671
|
);
|
|
8305
8672
|
});
|
|
8306
8673
|
}
|
|
8674
|
+
hasPendingRouteableInstanceForSelection(serviceName, ctx, role, targetServiceInstanceId) {
|
|
8675
|
+
return (this.instances.get(serviceName) ?? []).some((instance) => {
|
|
8676
|
+
if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
|
|
8677
|
+
return false;
|
|
8678
|
+
}
|
|
8679
|
+
if (!instance.isActive || instance.isNonResponsive || instance.isBlocked) {
|
|
8680
|
+
return false;
|
|
8681
|
+
}
|
|
8682
|
+
if (instance.isFrontend) {
|
|
8683
|
+
return false;
|
|
8684
|
+
}
|
|
8685
|
+
const transport = this.selectTransportForInstance(instance, ctx, role);
|
|
8686
|
+
if (!transport) {
|
|
8687
|
+
return false;
|
|
8688
|
+
}
|
|
8689
|
+
return !this.hasTransportClientReady(instance, transport);
|
|
8690
|
+
});
|
|
8691
|
+
}
|
|
8692
|
+
maybeSchedulePendingRouteSelectionRetry(ctx, serviceName) {
|
|
8693
|
+
const signalName = String(
|
|
8694
|
+
ctx.__signalName ?? ctx.__signalEmission?.fullSignalName ?? ""
|
|
8695
|
+
).trim();
|
|
8696
|
+
if (!signalName) {
|
|
8697
|
+
return false;
|
|
8698
|
+
}
|
|
8699
|
+
const attempt = Math.max(
|
|
8700
|
+
0,
|
|
8701
|
+
Number(ctx.__pendingRouteSelectionAttempt ?? 0) || 0
|
|
8702
|
+
);
|
|
8703
|
+
const delayMs = PENDING_ROUTE_SELECTION_RETRY_DELAYS_MS[attempt];
|
|
8704
|
+
if (delayMs === void 0) {
|
|
8705
|
+
return false;
|
|
8706
|
+
}
|
|
8707
|
+
CadenzaService.schedule(
|
|
8708
|
+
signalName,
|
|
8709
|
+
{
|
|
8710
|
+
...ctx,
|
|
8711
|
+
__pendingRouteSelectionAttempt: attempt + 1,
|
|
8712
|
+
__pendingRouteSelectionServiceName: serviceName
|
|
8713
|
+
},
|
|
8714
|
+
delayMs
|
|
8715
|
+
);
|
|
8716
|
+
return true;
|
|
8717
|
+
}
|
|
8307
8718
|
refreshRoutingCooldownsForService(serviceName) {
|
|
8308
8719
|
if (!serviceName) {
|
|
8309
8720
|
return;
|
|
@@ -9123,8 +9534,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9123
9534
|
this.refreshRoutingCooldownsForService(serviceName);
|
|
9124
9535
|
}
|
|
9125
9536
|
clearTransportReadyFromContext(ctx) {
|
|
9126
|
-
const serviceName =
|
|
9127
|
-
const explicitRouteKey = String(ctx.routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
9537
|
+
const serviceName = resolveServiceNameFromContext(ctx);
|
|
9538
|
+
const explicitRouteKey = String(ctx.routeKey ?? ctx.__routeKey ?? "").trim() || parseTransportHandleKey(ctx.fetchId ?? ctx.__fetchId)?.routeKey || "";
|
|
9128
9539
|
const serviceTransportId = String(
|
|
9129
9540
|
ctx.serviceTransportId ?? ctx.__transportId ?? ""
|
|
9130
9541
|
).trim();
|
|
@@ -10719,6 +11130,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
10719
11130
|
this.bootstrapFullSyncRetryGeneration = 0;
|
|
10720
11131
|
this.bootstrapFullSyncSatisfied = false;
|
|
10721
11132
|
this.bootstrapFullSyncRetryReason = null;
|
|
11133
|
+
this.clearAuthorityBootstrapHandshakeRetryTimer();
|
|
11134
|
+
this.authorityBootstrapHandshakeRetryIndex = 0;
|
|
11135
|
+
this.authorityBootstrapHandshakeRetryGeneration = 0;
|
|
11136
|
+
this.authorityBootstrapHandshakeRetryReason = null;
|
|
10722
11137
|
this.knownGlobalSignalMaps.clear();
|
|
10723
11138
|
this.authorityBootstrapRoute = {
|
|
10724
11139
|
origin: null,
|
|
@@ -13154,163 +13569,6 @@ var SocketController = class _SocketController {
|
|
|
13154
13569
|
}
|
|
13155
13570
|
};
|
|
13156
13571
|
|
|
13157
|
-
// src/execution/ExecutionPersistenceCoordinator.ts
|
|
13158
|
-
var EXECUTION_PERSISTENCE_BUNDLE_SIGNAL = "global.meta.execution_persistence.bundle_requested";
|
|
13159
|
-
function readString(value) {
|
|
13160
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
13161
|
-
}
|
|
13162
|
-
function readRecord(value) {
|
|
13163
|
-
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : null;
|
|
13164
|
-
}
|
|
13165
|
-
function normalizeRoutineExecutionTraceFields(data) {
|
|
13166
|
-
if (!data) {
|
|
13167
|
-
return null;
|
|
13168
|
-
}
|
|
13169
|
-
const normalizedData = { ...data };
|
|
13170
|
-
const traceId = readString(
|
|
13171
|
-
normalizedData.execution_trace_id ?? normalizedData.executionTraceId
|
|
13172
|
-
);
|
|
13173
|
-
const metaContext = readRecord(normalizedData.meta_context) ?? readRecord(normalizedData.metaContext);
|
|
13174
|
-
const isMeta = normalizedData.is_meta === true || normalizedData.isMeta === true;
|
|
13175
|
-
const serviceName = readString(
|
|
13176
|
-
normalizedData.service_name ?? normalizedData.serviceName
|
|
13177
|
-
);
|
|
13178
|
-
const serviceInstanceId = readString(
|
|
13179
|
-
normalizedData.service_instance_id ?? normalizedData.serviceInstanceId
|
|
13180
|
-
);
|
|
13181
|
-
if (traceId) {
|
|
13182
|
-
normalizedData.execution_trace_id = traceId;
|
|
13183
|
-
}
|
|
13184
|
-
if (metaContext) {
|
|
13185
|
-
normalizedData.meta_context = metaContext;
|
|
13186
|
-
}
|
|
13187
|
-
if (normalizedData.is_meta !== void 0 || normalizedData.isMeta !== void 0) {
|
|
13188
|
-
normalizedData.is_meta = isMeta;
|
|
13189
|
-
}
|
|
13190
|
-
if (serviceName) {
|
|
13191
|
-
normalizedData.service_name = serviceName;
|
|
13192
|
-
}
|
|
13193
|
-
if (serviceInstanceId) {
|
|
13194
|
-
normalizedData.service_instance_id = serviceInstanceId;
|
|
13195
|
-
} else if (normalizedData.serviceInstanceId === null || normalizedData.service_instance_id === null) {
|
|
13196
|
-
normalizedData.service_instance_id = null;
|
|
13197
|
-
}
|
|
13198
|
-
delete normalizedData.executionTraceId;
|
|
13199
|
-
delete normalizedData.traceId;
|
|
13200
|
-
delete normalizedData.metaContext;
|
|
13201
|
-
delete normalizedData.isMeta;
|
|
13202
|
-
delete normalizedData.serviceName;
|
|
13203
|
-
delete normalizedData.serviceInstanceId;
|
|
13204
|
-
return normalizedData;
|
|
13205
|
-
}
|
|
13206
|
-
function stripExecutionTraceServiceInstanceFields(data) {
|
|
13207
|
-
if (!data) {
|
|
13208
|
-
return null;
|
|
13209
|
-
}
|
|
13210
|
-
const normalizedData = { ...data };
|
|
13211
|
-
delete normalizedData.serviceInstanceId;
|
|
13212
|
-
delete normalizedData.service_instance_id;
|
|
13213
|
-
return normalizedData;
|
|
13214
|
-
}
|
|
13215
|
-
function normalizeEnsureData(entityType, data) {
|
|
13216
|
-
switch (entityType) {
|
|
13217
|
-
case "execution_trace":
|
|
13218
|
-
return stripExecutionTraceServiceInstanceFields(data);
|
|
13219
|
-
case "routine_execution":
|
|
13220
|
-
return normalizeRoutineExecutionTraceFields(data);
|
|
13221
|
-
default:
|
|
13222
|
-
return data;
|
|
13223
|
-
}
|
|
13224
|
-
}
|
|
13225
|
-
function buildExecutionPersistenceDependency(entityType, entityId) {
|
|
13226
|
-
const normalizedEntityId = readString(entityId);
|
|
13227
|
-
return normalizedEntityId ? `${entityType}:${normalizedEntityId}` : null;
|
|
13228
|
-
}
|
|
13229
|
-
function resolveEnsureEntityId(entityType, data) {
|
|
13230
|
-
switch (entityType) {
|
|
13231
|
-
default:
|
|
13232
|
-
return readString(data.uuid);
|
|
13233
|
-
}
|
|
13234
|
-
}
|
|
13235
|
-
function resolveUpdateEntityId(_entityType, data, filter) {
|
|
13236
|
-
return readString(
|
|
13237
|
-
filter.uuid ?? filter.taskExecutionId ?? filter.task_execution_id ?? data.uuid ?? data.taskExecutionId ?? data.task_execution_id
|
|
13238
|
-
);
|
|
13239
|
-
}
|
|
13240
|
-
function dedupeDependencies(values) {
|
|
13241
|
-
return Array.from(
|
|
13242
|
-
new Set(values.filter((value) => typeof value === "string"))
|
|
13243
|
-
);
|
|
13244
|
-
}
|
|
13245
|
-
function resolveTraceIdFromData(data) {
|
|
13246
|
-
if (!data) {
|
|
13247
|
-
return null;
|
|
13248
|
-
}
|
|
13249
|
-
return readString(
|
|
13250
|
-
data.traceId ?? data.executionTraceId ?? data.execution_trace_id ?? data.metaContext?.__executionTraceId ?? data.metaContext?.__metadata?.__executionTraceId ?? data.meta_context?.__executionTraceId ?? data.meta_context?.__metadata?.__executionTraceId
|
|
13251
|
-
);
|
|
13252
|
-
}
|
|
13253
|
-
function buildExecutionPersistenceEnsureEvent(entityType, data, deps = []) {
|
|
13254
|
-
const normalizedData = normalizeEnsureData(entityType, readRecord(data));
|
|
13255
|
-
if (!normalizedData) {
|
|
13256
|
-
return null;
|
|
13257
|
-
}
|
|
13258
|
-
const entityId = resolveEnsureEntityId(entityType, normalizedData);
|
|
13259
|
-
if (!entityId) {
|
|
13260
|
-
return null;
|
|
13261
|
-
}
|
|
13262
|
-
return {
|
|
13263
|
-
kind: "ensure",
|
|
13264
|
-
entityType,
|
|
13265
|
-
entityId,
|
|
13266
|
-
data: normalizedData,
|
|
13267
|
-
deps: dedupeDependencies(deps)
|
|
13268
|
-
};
|
|
13269
|
-
}
|
|
13270
|
-
function buildExecutionPersistenceUpdateEvent(entityType, data, filter, deps = []) {
|
|
13271
|
-
const normalizedData = readRecord(data);
|
|
13272
|
-
const normalizedFilter = readRecord(filter);
|
|
13273
|
-
if (!normalizedData || !normalizedFilter) {
|
|
13274
|
-
return null;
|
|
13275
|
-
}
|
|
13276
|
-
const entityId = resolveUpdateEntityId(
|
|
13277
|
-
entityType,
|
|
13278
|
-
normalizedData,
|
|
13279
|
-
normalizedFilter
|
|
13280
|
-
);
|
|
13281
|
-
if (!entityId) {
|
|
13282
|
-
return null;
|
|
13283
|
-
}
|
|
13284
|
-
return {
|
|
13285
|
-
kind: "update",
|
|
13286
|
-
entityType,
|
|
13287
|
-
entityId,
|
|
13288
|
-
data: normalizedData,
|
|
13289
|
-
filter: normalizedFilter,
|
|
13290
|
-
deps: dedupeDependencies(deps)
|
|
13291
|
-
};
|
|
13292
|
-
}
|
|
13293
|
-
function createExecutionPersistenceBundle(input) {
|
|
13294
|
-
const ensures = (input.ensures ?? []).filter(
|
|
13295
|
-
(event) => Boolean(event)
|
|
13296
|
-
);
|
|
13297
|
-
const updates = (input.updates ?? []).filter(
|
|
13298
|
-
(event) => Boolean(event)
|
|
13299
|
-
);
|
|
13300
|
-
if (ensures.length === 0 && updates.length === 0) {
|
|
13301
|
-
return null;
|
|
13302
|
-
}
|
|
13303
|
-
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));
|
|
13304
|
-
if (!traceId) {
|
|
13305
|
-
return null;
|
|
13306
|
-
}
|
|
13307
|
-
return {
|
|
13308
|
-
traceId,
|
|
13309
|
-
ensures,
|
|
13310
|
-
updates
|
|
13311
|
-
};
|
|
13312
|
-
}
|
|
13313
|
-
|
|
13314
13572
|
// src/signals/SignalController.ts
|
|
13315
13573
|
import { v4 as uuid5 } from "uuid";
|
|
13316
13574
|
function resolveExecutionObservabilityServiceInstanceId() {
|
|
@@ -13463,7 +13721,7 @@ var SignalController = class _SignalController {
|
|
|
13463
13721
|
intent: traceContext.__metadata?.__intent ?? traceContext.__intent ?? null,
|
|
13464
13722
|
context: {
|
|
13465
13723
|
id: uuid5(),
|
|
13466
|
-
context:
|
|
13724
|
+
context: sanitizedTraceContext
|
|
13467
13725
|
},
|
|
13468
13726
|
is_meta: signalEmission.isMeta,
|
|
13469
13727
|
service_name: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -14055,6 +14313,18 @@ import {
|
|
|
14055
14313
|
} from "@cadenza.io/core";
|
|
14056
14314
|
import { v4 as uuid6 } from "uuid";
|
|
14057
14315
|
var ACTOR_TASK_METADATA2 = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
14316
|
+
var ROUTING_CRITICAL_META_INTENTS2 = /* @__PURE__ */ new Set([
|
|
14317
|
+
AUTHORITY_BOOTSTRAP_FULL_SYNC_INTENT,
|
|
14318
|
+
AUTHORITY_SERVICE_INSTANCE_REGISTER_INTENT,
|
|
14319
|
+
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_INTENT,
|
|
14320
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
14321
|
+
AUTHORITY_RUNTIME_STATUS_REPORT_INTENT
|
|
14322
|
+
]);
|
|
14323
|
+
var ROUTING_CRITICAL_META_SIGNALS2 = /* @__PURE__ */ new Set([
|
|
14324
|
+
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
14325
|
+
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
14326
|
+
...AUTHORITY_BOOTSTRAP_SIGNAL_NAMES
|
|
14327
|
+
]);
|
|
14058
14328
|
function getActorTaskRuntimeMetadata2(taskFunction) {
|
|
14059
14329
|
if (typeof taskFunction !== "function") {
|
|
14060
14330
|
return void 0;
|
|
@@ -14146,7 +14416,7 @@ function buildIntentRegistryData(intent) {
|
|
|
14146
14416
|
};
|
|
14147
14417
|
}
|
|
14148
14418
|
function isLocalOnlySyncIntent(intentName) {
|
|
14149
|
-
return intentName === META_ACTOR_SESSION_STATE_PERSIST_INTENT2;
|
|
14419
|
+
return intentName === META_ACTOR_SESSION_STATE_PERSIST_INTENT2 || intentName.startsWith("meta-") || intentName.startsWith("global.meta-");
|
|
14150
14420
|
}
|
|
14151
14421
|
function getJoinedContextValue(ctx, key) {
|
|
14152
14422
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
@@ -14186,6 +14456,32 @@ function buildMinimalSyncSignalContext(ctx, extra = {}) {
|
|
|
14186
14456
|
}
|
|
14187
14457
|
return nextContext;
|
|
14188
14458
|
}
|
|
14459
|
+
function buildMinimalSyncShardContext(ctx, extra = {}) {
|
|
14460
|
+
return {
|
|
14461
|
+
...buildMinimalSyncSignalContext(ctx, extra),
|
|
14462
|
+
tasks: void 0,
|
|
14463
|
+
signals: void 0,
|
|
14464
|
+
intents: void 0,
|
|
14465
|
+
actors: void 0,
|
|
14466
|
+
routines: void 0,
|
|
14467
|
+
serviceInstances: void 0,
|
|
14468
|
+
service_instance_rows: void 0,
|
|
14469
|
+
service_instance_transport_rows: void 0,
|
|
14470
|
+
serviceManifests: void 0,
|
|
14471
|
+
manifests: void 0,
|
|
14472
|
+
signalToTaskMaps: void 0,
|
|
14473
|
+
signal_to_task_maps: void 0,
|
|
14474
|
+
intentToTaskMaps: void 0,
|
|
14475
|
+
intent_to_task_maps: void 0,
|
|
14476
|
+
actorTaskMaps: void 0,
|
|
14477
|
+
actor_task_maps: void 0,
|
|
14478
|
+
directionalTaskMaps: void 0,
|
|
14479
|
+
directional_task_maps: void 0,
|
|
14480
|
+
taskToRoutineMaps: void 0,
|
|
14481
|
+
task_to_routine_maps: void 0,
|
|
14482
|
+
task: void 0
|
|
14483
|
+
};
|
|
14484
|
+
}
|
|
14189
14485
|
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
14190
14486
|
const pickQueryData = (source, allowedKeys) => {
|
|
14191
14487
|
const next = {};
|
|
@@ -14223,7 +14519,40 @@ var DEFAULT_SYNC_CYCLE_RUNTIME_STATE = {
|
|
|
14223
14519
|
activeSyncCycleStartedAt: 0,
|
|
14224
14520
|
phase: "idle"
|
|
14225
14521
|
};
|
|
14226
|
-
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY =
|
|
14522
|
+
var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY = 2;
|
|
14523
|
+
function stripSyncResolverPayload(ctx) {
|
|
14524
|
+
const nextContext = {
|
|
14525
|
+
...ctx
|
|
14526
|
+
};
|
|
14527
|
+
const bulkyStructuralKeys = [
|
|
14528
|
+
"tasks",
|
|
14529
|
+
"helpers",
|
|
14530
|
+
"globals",
|
|
14531
|
+
"signals",
|
|
14532
|
+
"intents",
|
|
14533
|
+
"actors",
|
|
14534
|
+
"routines",
|
|
14535
|
+
"serviceInstances",
|
|
14536
|
+
"serviceInstanceTransports",
|
|
14537
|
+
"serviceManifests",
|
|
14538
|
+
"signalToTaskMaps",
|
|
14539
|
+
"intentToTaskMaps",
|
|
14540
|
+
"actorTaskMaps",
|
|
14541
|
+
"directionalTaskMaps",
|
|
14542
|
+
"taskToRoutineMaps",
|
|
14543
|
+
"registeredGlobalSignals",
|
|
14544
|
+
"registeredGlobalIntents",
|
|
14545
|
+
"registeredActors",
|
|
14546
|
+
"registeredRoutines"
|
|
14547
|
+
];
|
|
14548
|
+
delete nextContext.__resolverOriginalContext;
|
|
14549
|
+
delete nextContext.__resolverQueryData;
|
|
14550
|
+
delete nextContext.joinedContexts;
|
|
14551
|
+
for (const key of bulkyStructuralKeys) {
|
|
14552
|
+
delete nextContext[key];
|
|
14553
|
+
}
|
|
14554
|
+
return nextContext;
|
|
14555
|
+
}
|
|
14227
14556
|
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
14228
14557
|
if (!graph) {
|
|
14229
14558
|
return void 0;
|
|
@@ -14235,28 +14564,14 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
|
14235
14564
|
return graph.completionTask;
|
|
14236
14565
|
}
|
|
14237
14566
|
function buildSyncExecutionEnvelope(ctx, queryData) {
|
|
14238
|
-
const originalContext =
|
|
14567
|
+
const originalContext = stripSyncResolverPayload(ctx);
|
|
14239
14568
|
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();
|
|
14240
|
-
const rootDbOperationFields = {};
|
|
14241
|
-
for (const key of [
|
|
14242
|
-
"data",
|
|
14243
|
-
"batch",
|
|
14244
|
-
"transaction",
|
|
14245
|
-
"onConflict",
|
|
14246
|
-
"filter",
|
|
14247
|
-
"fields"
|
|
14248
|
-
]) {
|
|
14249
|
-
if (Object.prototype.hasOwnProperty.call(queryData, key)) {
|
|
14250
|
-
rootDbOperationFields[key] = queryData[key];
|
|
14251
|
-
}
|
|
14252
|
-
}
|
|
14253
14569
|
const nextContext = {
|
|
14254
14570
|
__syncing: ctx.__syncing === true || ctx.__metadata?.__syncing === true || false,
|
|
14255
14571
|
__syncSourceServiceName: syncSourceServiceName,
|
|
14256
14572
|
__preferredTransportProtocol: "rest",
|
|
14257
14573
|
__resolverOriginalContext: originalContext,
|
|
14258
14574
|
__resolverQueryData: queryData,
|
|
14259
|
-
...rootDbOperationFields,
|
|
14260
14575
|
queryData
|
|
14261
14576
|
};
|
|
14262
14577
|
if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
|
|
@@ -14275,6 +14590,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
14275
14590
|
Number(options.concurrency),
|
|
14276
14591
|
REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY
|
|
14277
14592
|
) : REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY,
|
|
14593
|
+
timeout: Number(options.timeout) > 0 ? Number(options.timeout) : 6e4,
|
|
14278
14594
|
register: false,
|
|
14279
14595
|
isHidden: true
|
|
14280
14596
|
});
|
|
@@ -14314,13 +14630,15 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
14314
14630
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
14315
14631
|
`Finalize graph sync insert for ${tableName}`,
|
|
14316
14632
|
(ctx) => {
|
|
14317
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ?
|
|
14633
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? stripSyncResolverPayload(
|
|
14634
|
+
ctx.__resolverOriginalContext
|
|
14635
|
+
) : {};
|
|
14318
14636
|
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
14319
|
-
const normalizedContext = {
|
|
14637
|
+
const normalizedContext = stripSyncResolverPayload({
|
|
14320
14638
|
...originalContext,
|
|
14321
14639
|
...ctx,
|
|
14322
14640
|
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : originalQueryData
|
|
14323
|
-
};
|
|
14641
|
+
});
|
|
14324
14642
|
if (originalContext.__syncing === true && !didSyncInsertSucceed(normalizedContext)) {
|
|
14325
14643
|
CadenzaService.debounce("meta.sync_requested", {}, 1e3);
|
|
14326
14644
|
}
|
|
@@ -14394,22 +14712,103 @@ function isBootstrapLocalOnlySignal(signalName) {
|
|
|
14394
14712
|
function hasNonZeroPending(summary) {
|
|
14395
14713
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
14396
14714
|
}
|
|
14715
|
+
function shouldSkipIdleBootstrapSyncTrigger(input) {
|
|
14716
|
+
if (input?.__forceSyncCycle === true) {
|
|
14717
|
+
return false;
|
|
14718
|
+
}
|
|
14719
|
+
const triggerSignal = typeof input?.__signal === "string" ? input.__signal.trim() : "";
|
|
14720
|
+
const reason = typeof input?.__reason === "string" ? input.__reason.trim() : "";
|
|
14721
|
+
if (!triggerSignal) {
|
|
14722
|
+
return input?.__bootstrapFullSync === true || reason.length > 0;
|
|
14723
|
+
}
|
|
14724
|
+
return triggerSignal === "meta.sync_controller.sync_tick" || triggerSignal === "meta.sync_requested";
|
|
14725
|
+
}
|
|
14397
14726
|
function isRegistrableRoutine(routine) {
|
|
14398
14727
|
return routine?.name !== "RestServer";
|
|
14399
14728
|
}
|
|
14400
14729
|
function scheduleSyncPassEvaluation(delayMs = SYNC_PASS_SETTLE_DELAY_MS) {
|
|
14401
14730
|
CadenzaService.debounce(SYNC_PASS_EVALUATION_SIGNAL, {}, delayMs);
|
|
14402
14731
|
}
|
|
14732
|
+
function isRoutingCriticalMetaSignalName(signalName) {
|
|
14733
|
+
return ROUTING_CRITICAL_META_SIGNALS2.has(canonicalizeSignalName2(signalName));
|
|
14734
|
+
}
|
|
14735
|
+
function isRoutingCriticalMetaIntentName(intentName) {
|
|
14736
|
+
return ROUTING_CRITICAL_META_INTENTS2.has(String(intentName ?? "").trim());
|
|
14737
|
+
}
|
|
14738
|
+
function isRoutingCapabilityBootstrapSignalName(signalName) {
|
|
14739
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
14740
|
+
if (!canonicalSignalName) {
|
|
14741
|
+
return false;
|
|
14742
|
+
}
|
|
14743
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
14744
|
+
if (!signalParts.isGlobal) {
|
|
14745
|
+
return false;
|
|
14746
|
+
}
|
|
14747
|
+
if (signalParts.isMeta) {
|
|
14748
|
+
return isRoutingCriticalMetaSignalName(canonicalSignalName);
|
|
14749
|
+
}
|
|
14750
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
14751
|
+
}
|
|
14752
|
+
function isRouteableBusinessBootstrapSignalName(signalName) {
|
|
14753
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
14754
|
+
if (!canonicalSignalName) {
|
|
14755
|
+
return false;
|
|
14756
|
+
}
|
|
14757
|
+
const signalParts = decomposeSignalName(canonicalSignalName);
|
|
14758
|
+
if (!signalParts.isGlobal || signalParts.isMeta) {
|
|
14759
|
+
return false;
|
|
14760
|
+
}
|
|
14761
|
+
return !isBootstrapLocalOnlySignal(canonicalSignalName);
|
|
14762
|
+
}
|
|
14763
|
+
function isRouteableBusinessBootstrapIntentName(intentName) {
|
|
14764
|
+
const normalizedIntentName = String(intentName ?? "").trim();
|
|
14765
|
+
return normalizedIntentName.length > 0 && !isLocalOnlySyncIntent(normalizedIntentName) && !isMetaIntentName(normalizedIntentName);
|
|
14766
|
+
}
|
|
14767
|
+
function isRoutingCapabilityBootstrapTask(task) {
|
|
14768
|
+
if (!task || !task.register || task.isHidden || task.isDeputy) {
|
|
14769
|
+
return false;
|
|
14770
|
+
}
|
|
14771
|
+
const isMetaTask = task.isMeta === true || task.isSubMeta === true;
|
|
14772
|
+
for (const signalName of task.observedSignals) {
|
|
14773
|
+
if (isMetaTask ? isRoutingCriticalMetaSignalName(signalName) : isRouteableBusinessBootstrapSignalName(signalName)) {
|
|
14774
|
+
return true;
|
|
14775
|
+
}
|
|
14776
|
+
}
|
|
14777
|
+
for (const intentName of task.handlesIntents) {
|
|
14778
|
+
if (isMetaTask ? isRoutingCriticalMetaIntentName(intentName) : isRouteableBusinessBootstrapIntentName(intentName)) {
|
|
14779
|
+
return true;
|
|
14780
|
+
}
|
|
14781
|
+
}
|
|
14782
|
+
return false;
|
|
14783
|
+
}
|
|
14784
|
+
function shouldDirectSyncSignalTaskMapForBootstrap(task, signalName) {
|
|
14785
|
+
const canonicalSignalName = canonicalizeSignalName2(signalName);
|
|
14786
|
+
if (!task || !canonicalSignalName || task.isHidden || !task.register || !task.registered) {
|
|
14787
|
+
return false;
|
|
14788
|
+
}
|
|
14789
|
+
if (!decomposeSignalName(canonicalSignalName).isGlobal) {
|
|
14790
|
+
return false;
|
|
14791
|
+
}
|
|
14792
|
+
if (!isRegistrableBootstrapTask(task)) {
|
|
14793
|
+
return false;
|
|
14794
|
+
}
|
|
14795
|
+
return isRoutingCapabilityBootstrapSignalName(canonicalSignalName);
|
|
14796
|
+
}
|
|
14797
|
+
function isRegistrableBootstrapTask(task) {
|
|
14798
|
+
return isRoutingCapabilityBootstrapTask(task);
|
|
14799
|
+
}
|
|
14403
14800
|
function getRegistrableTasks() {
|
|
14404
14801
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
14405
|
-
|
|
14802
|
+
isRegistrableBootstrapTask
|
|
14406
14803
|
);
|
|
14407
14804
|
}
|
|
14408
14805
|
function getBootstrapBlockingTasks() {
|
|
14409
|
-
return getRegistrableTasks()
|
|
14806
|
+
return getRegistrableTasks();
|
|
14410
14807
|
}
|
|
14411
14808
|
function getRegistrableRoutines() {
|
|
14412
|
-
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
14809
|
+
return Array.from(CadenzaService.registry.routines.values()).filter(
|
|
14810
|
+
isRegistrableRoutine
|
|
14811
|
+
);
|
|
14413
14812
|
}
|
|
14414
14813
|
function getRegistrableSignalObservers() {
|
|
14415
14814
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
@@ -14419,19 +14818,23 @@ function getRegistrableSignalObservers() {
|
|
|
14419
14818
|
const canonicalObservers = /* @__PURE__ */ new Map();
|
|
14420
14819
|
for (const [rawSignalName, observer] of signalObservers.entries()) {
|
|
14421
14820
|
const signalName = canonicalizeSignalName2(rawSignalName);
|
|
14422
|
-
|
|
14821
|
+
const isRoutingCriticalMetaSignal2 = signalName.length > 0 && isRoutingCriticalMetaSignalName(signalName);
|
|
14822
|
+
if (!signalName || isBootstrapLocalOnlySignal(signalName) && !isRoutingCriticalMetaSignal2) {
|
|
14823
|
+
continue;
|
|
14824
|
+
}
|
|
14825
|
+
if (!decomposeSignalName(signalName).isGlobal) {
|
|
14423
14826
|
continue;
|
|
14424
14827
|
}
|
|
14425
14828
|
const observerTasks = Array.isArray(observer?.tasks) ? observer.tasks : observer?.tasks instanceof Set ? Array.from(observer.tasks) : [];
|
|
14426
|
-
if (observerTasks.length > 0 && !observerTasks.some(
|
|
14427
|
-
(task) => task?.register && !task.isHidden && !task.isDeputy
|
|
14428
|
-
)) {
|
|
14829
|
+
if (observerTasks.length > 0 && !observerTasks.some((task) => isRegistrableBootstrapTask(task))) {
|
|
14429
14830
|
continue;
|
|
14430
14831
|
}
|
|
14832
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
14431
14833
|
const existing = canonicalObservers.get(signalName);
|
|
14432
14834
|
canonicalObservers.set(signalName, {
|
|
14433
14835
|
signalName,
|
|
14434
|
-
registered: existing?.registered === true || observer?.registered === true
|
|
14836
|
+
registered: existing?.registered === true || observer?.registered === true,
|
|
14837
|
+
metadata: existing?.metadata ?? metadata
|
|
14435
14838
|
});
|
|
14436
14839
|
}
|
|
14437
14840
|
return Array.from(canonicalObservers.values());
|
|
@@ -14442,7 +14845,10 @@ function isLocallyHandledIntentName(intentName) {
|
|
|
14442
14845
|
return false;
|
|
14443
14846
|
}
|
|
14444
14847
|
for (const task of observer.tasks) {
|
|
14445
|
-
if (
|
|
14848
|
+
if (!task) {
|
|
14849
|
+
continue;
|
|
14850
|
+
}
|
|
14851
|
+
if (isRegistrableBootstrapTask(task)) {
|
|
14446
14852
|
return true;
|
|
14447
14853
|
}
|
|
14448
14854
|
}
|
|
@@ -14473,8 +14879,12 @@ function buildActorRegistrationKey(actor, serviceName) {
|
|
|
14473
14879
|
return `${name}|${data.version}|${serviceName}`;
|
|
14474
14880
|
}
|
|
14475
14881
|
function isBootstrapRegistrableActor(actor) {
|
|
14476
|
-
const
|
|
14477
|
-
|
|
14882
|
+
const actorData = buildActorRegistrationData(actor);
|
|
14883
|
+
const actorName = String(actorData.name ?? "").trim();
|
|
14884
|
+
if (!actorName || isBootstrapLocalOnlyActorName(actorName)) {
|
|
14885
|
+
return false;
|
|
14886
|
+
}
|
|
14887
|
+
return false;
|
|
14478
14888
|
}
|
|
14479
14889
|
function buildSignalTaskMapRegistrationKey(input) {
|
|
14480
14890
|
return `${canonicalizeSignalName2(input.signalName)}|${input.serviceName}|${input.taskName}|${input.taskVersion ?? 1}`;
|
|
@@ -14641,6 +15051,7 @@ function resolveSignalNameFromSyncContext(ctx) {
|
|
|
14641
15051
|
var GraphSyncController = class _GraphSyncController {
|
|
14642
15052
|
constructor() {
|
|
14643
15053
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
15054
|
+
this.requestedActorRegistrations = /* @__PURE__ */ new Set();
|
|
14644
15055
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
14645
15056
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
14646
15057
|
this.authoritativeSignalTaskMaps = /* @__PURE__ */ new Set();
|
|
@@ -14969,9 +15380,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14969
15380
|
for (const routine of routines) {
|
|
14970
15381
|
if (!isRegistrableRoutine(routine)) continue;
|
|
14971
15382
|
if (routine.registered) continue;
|
|
15383
|
+
if (routine.registrationRequested === true) continue;
|
|
15384
|
+
routine.registrationRequested = true;
|
|
14972
15385
|
this.routinesSynced = false;
|
|
14973
|
-
yield {
|
|
14974
|
-
__syncing: ctx.__syncing,
|
|
15386
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
14975
15387
|
data: {
|
|
14976
15388
|
name: routine.name,
|
|
14977
15389
|
version: routine.version,
|
|
@@ -14980,7 +15392,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14980
15392
|
is_meta: routine.isMeta
|
|
14981
15393
|
},
|
|
14982
15394
|
__routineName: routine.name
|
|
14983
|
-
};
|
|
15395
|
+
});
|
|
14984
15396
|
}
|
|
14985
15397
|
}.bind(this)
|
|
14986
15398
|
);
|
|
@@ -14998,15 +15410,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14998
15410
|
{ concurrency: 30 }
|
|
14999
15411
|
);
|
|
15000
15412
|
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
15413
|
+
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
15001
15414
|
if (!didSyncInsertSucceed(ctx)) {
|
|
15415
|
+
if (routine) {
|
|
15416
|
+
routine.registrationRequested = false;
|
|
15417
|
+
}
|
|
15002
15418
|
return;
|
|
15003
15419
|
}
|
|
15004
15420
|
scheduleSyncPassEvaluation();
|
|
15005
|
-
const routine = resolveLocalRoutineFromSyncContext(ctx);
|
|
15006
15421
|
if (!routine) {
|
|
15007
15422
|
return true;
|
|
15008
15423
|
}
|
|
15009
15424
|
routine.registered = true;
|
|
15425
|
+
routine.registrationRequested = false;
|
|
15010
15426
|
return true;
|
|
15011
15427
|
}).then(gatherRoutineRegistrationTask);
|
|
15012
15428
|
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
@@ -15033,8 +15449,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15033
15449
|
if (!nextTask?.registered) {
|
|
15034
15450
|
continue;
|
|
15035
15451
|
}
|
|
15036
|
-
yield {
|
|
15037
|
-
__syncing: ctx.__syncing,
|
|
15452
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15038
15453
|
data: {
|
|
15039
15454
|
task_name: nextTask.name,
|
|
15040
15455
|
task_version: nextTask.version,
|
|
@@ -15044,7 +15459,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15044
15459
|
},
|
|
15045
15460
|
__routineName: routine.name,
|
|
15046
15461
|
__taskName: nextTask.name
|
|
15047
|
-
};
|
|
15462
|
+
});
|
|
15048
15463
|
}
|
|
15049
15464
|
}
|
|
15050
15465
|
}
|
|
@@ -15098,7 +15513,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15098
15513
|
signalName: canonicalizeSignalName2(signal.signal),
|
|
15099
15514
|
data: signal.data
|
|
15100
15515
|
})).filter((signal) => {
|
|
15101
|
-
|
|
15516
|
+
const isRoutingCriticalMetaSignal2 = isRoutingCriticalMetaSignalName(signal.signalName);
|
|
15517
|
+
if (!signal.signalName || signal.data?.registered || isBootstrapLocalOnlySignal(signal.signalName) && !isRoutingCriticalMetaSignal2 || signal.data?.metadata?.is_meta === true && !isRoutingCriticalMetaSignal2) {
|
|
15102
15518
|
return false;
|
|
15103
15519
|
}
|
|
15104
15520
|
if (seenSignals.has(signal.signalName)) {
|
|
@@ -15108,10 +15524,20 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15108
15524
|
return true;
|
|
15109
15525
|
}).map((signal) => signal.signalName);
|
|
15110
15526
|
for (const signal of filteredSignals) {
|
|
15527
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
15528
|
+
if (!signalObservers?.has(signal)) {
|
|
15529
|
+
CadenzaService.signalBroker.addSignal(signal);
|
|
15530
|
+
}
|
|
15531
|
+
const observer = signalObservers?.get(signal);
|
|
15532
|
+
if (observer?.registrationRequested === true) {
|
|
15533
|
+
continue;
|
|
15534
|
+
}
|
|
15535
|
+
if (observer) {
|
|
15536
|
+
observer.registrationRequested = true;
|
|
15537
|
+
}
|
|
15111
15538
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
15112
15539
|
this.signalsSynced = false;
|
|
15113
|
-
yield {
|
|
15114
|
-
__syncing: ctx.__syncing,
|
|
15540
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15115
15541
|
data: {
|
|
15116
15542
|
name: signal,
|
|
15117
15543
|
is_global: isGlobal,
|
|
@@ -15120,7 +15546,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15120
15546
|
is_meta: isMeta
|
|
15121
15547
|
},
|
|
15122
15548
|
__signal: signal
|
|
15123
|
-
};
|
|
15549
|
+
});
|
|
15124
15550
|
}
|
|
15125
15551
|
}.bind(this)
|
|
15126
15552
|
);
|
|
@@ -15142,21 +15568,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15142
15568
|
(ctx, emit2) => {
|
|
15143
15569
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
15144
15570
|
const signalName = resolveSignalNameFromSyncContext(ctx);
|
|
15571
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
15572
|
+
const observer = signalName ? signalObservers?.get(signalName) : void 0;
|
|
15145
15573
|
if (!insertSucceeded) {
|
|
15574
|
+
if (observer) {
|
|
15575
|
+
observer.registrationRequested = false;
|
|
15576
|
+
}
|
|
15146
15577
|
return;
|
|
15147
15578
|
}
|
|
15148
15579
|
scheduleSyncPassEvaluation();
|
|
15149
15580
|
if (!signalName) {
|
|
15150
15581
|
return false;
|
|
15151
15582
|
}
|
|
15152
|
-
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
15153
15583
|
if (!signalObservers?.has(signalName)) {
|
|
15154
15584
|
CadenzaService.signalBroker.addSignal(signalName);
|
|
15155
15585
|
}
|
|
15156
|
-
const
|
|
15157
|
-
if (
|
|
15158
|
-
|
|
15159
|
-
|
|
15586
|
+
const resolvedObserver = signalObservers?.get(signalName);
|
|
15587
|
+
if (resolvedObserver) {
|
|
15588
|
+
resolvedObserver.registered = true;
|
|
15589
|
+
resolvedObserver.registrationRequested = false;
|
|
15160
15590
|
}
|
|
15161
15591
|
emit2(
|
|
15162
15592
|
"meta.sync_controller.signal_registered",
|
|
@@ -15236,8 +15666,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15236
15666
|
return;
|
|
15237
15667
|
}
|
|
15238
15668
|
for (const task of tasks) {
|
|
15239
|
-
if (
|
|
15669
|
+
if (!task) {
|
|
15670
|
+
continue;
|
|
15671
|
+
}
|
|
15672
|
+
if (!isRegistrableBootstrapTask(task)) continue;
|
|
15240
15673
|
if (task.registered) continue;
|
|
15674
|
+
if (task.registrationRequested === true) continue;
|
|
15675
|
+
task.registrationRequested = true;
|
|
15241
15676
|
const { __functionString, __getTagCallback } = task.export();
|
|
15242
15677
|
this.tasksSynced = false;
|
|
15243
15678
|
const taskRegistrationData = sanitizePersistedTaskSourceFields(task, {
|
|
@@ -15272,11 +15707,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15272
15707
|
},
|
|
15273
15708
|
intents: Array.from(task.handlesIntents)
|
|
15274
15709
|
});
|
|
15275
|
-
yield {
|
|
15276
|
-
__syncing: ctx.__syncing,
|
|
15710
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15277
15711
|
data: taskRegistrationData,
|
|
15278
15712
|
__taskName: task.name
|
|
15279
|
-
};
|
|
15713
|
+
});
|
|
15280
15714
|
}
|
|
15281
15715
|
}.bind(this)
|
|
15282
15716
|
);
|
|
@@ -15297,9 +15731,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15297
15731
|
"Record registration",
|
|
15298
15732
|
(ctx, emit2) => {
|
|
15299
15733
|
const task = resolveLocalTaskFromSyncContext(ctx);
|
|
15300
|
-
const serviceName2 = resolveSyncServiceName(task);
|
|
15301
15734
|
const insertSucceeded = didSyncInsertSucceed(ctx);
|
|
15302
15735
|
if (!insertSucceeded) {
|
|
15736
|
+
if (task) {
|
|
15737
|
+
task.registrationRequested = false;
|
|
15738
|
+
}
|
|
15303
15739
|
return;
|
|
15304
15740
|
}
|
|
15305
15741
|
scheduleSyncPassEvaluation();
|
|
@@ -15341,11 +15777,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15341
15777
|
if (this.registeredActors.has(registrationKey)) {
|
|
15342
15778
|
continue;
|
|
15343
15779
|
}
|
|
15780
|
+
if (this.requestedActorRegistrations.has(registrationKey)) {
|
|
15781
|
+
continue;
|
|
15782
|
+
}
|
|
15783
|
+
this.requestedActorRegistrations.add(registrationKey);
|
|
15344
15784
|
this.actorsSynced = false;
|
|
15345
|
-
yield {
|
|
15785
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15346
15786
|
data,
|
|
15347
15787
|
__actorRegistrationKey: registrationKey
|
|
15348
|
-
};
|
|
15788
|
+
});
|
|
15349
15789
|
}
|
|
15350
15790
|
}.bind(this)
|
|
15351
15791
|
);
|
|
@@ -15365,11 +15805,18 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15365
15805
|
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
15366
15806
|
"Record actor registration",
|
|
15367
15807
|
(ctx) => {
|
|
15808
|
+
const registrationKey = typeof ctx.__actorRegistrationKey === "string" ? ctx.__actorRegistrationKey : "";
|
|
15368
15809
|
if (!didSyncInsertSucceed(ctx)) {
|
|
15810
|
+
if (registrationKey) {
|
|
15811
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
15812
|
+
}
|
|
15369
15813
|
return;
|
|
15370
15814
|
}
|
|
15371
15815
|
scheduleSyncPassEvaluation();
|
|
15372
|
-
|
|
15816
|
+
if (registrationKey) {
|
|
15817
|
+
this.requestedActorRegistrations.delete(registrationKey);
|
|
15818
|
+
this.registeredActors.add(registrationKey);
|
|
15819
|
+
}
|
|
15373
15820
|
return true;
|
|
15374
15821
|
}
|
|
15375
15822
|
).then(gatherActorRegistrationTask);
|
|
@@ -15388,17 +15835,95 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15388
15835
|
}
|
|
15389
15836
|
);
|
|
15390
15837
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
15391
|
-
"
|
|
15392
|
-
()
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
|
|
15838
|
+
"Register routing-critical signal task maps to DB",
|
|
15839
|
+
function* (ctx) {
|
|
15840
|
+
const task = ctx.task;
|
|
15841
|
+
if (!task) {
|
|
15842
|
+
return;
|
|
15843
|
+
}
|
|
15844
|
+
const serviceName2 = resolveSyncServiceName(task);
|
|
15845
|
+
if (!serviceName2) {
|
|
15846
|
+
return;
|
|
15847
|
+
}
|
|
15848
|
+
for (const signal of task.observedSignals) {
|
|
15849
|
+
const signalName = canonicalizeSignalName2(signal);
|
|
15850
|
+
if (!shouldDirectSyncSignalTaskMapForBootstrap(task, signalName)) {
|
|
15851
|
+
continue;
|
|
15852
|
+
}
|
|
15853
|
+
if (task.registeredSignals.has(signalName)) {
|
|
15854
|
+
continue;
|
|
15855
|
+
}
|
|
15856
|
+
const registrationKey = buildSignalTaskMapRegistrationKey({
|
|
15857
|
+
signalName,
|
|
15858
|
+
serviceName: serviceName2,
|
|
15859
|
+
taskName: task.name,
|
|
15860
|
+
taskVersion: task.version
|
|
15861
|
+
});
|
|
15862
|
+
if (this.authoritativeSignalTaskMaps.has(registrationKey)) {
|
|
15863
|
+
continue;
|
|
15864
|
+
}
|
|
15865
|
+
if (!CadenzaService.signalBroker.signalObservers?.get(signalName)?.registered) {
|
|
15866
|
+
continue;
|
|
15867
|
+
}
|
|
15868
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15869
|
+
data: {
|
|
15870
|
+
signal_name: signalName,
|
|
15871
|
+
is_global: true,
|
|
15872
|
+
task_name: task.name,
|
|
15873
|
+
task_version: task.version,
|
|
15874
|
+
service_name: serviceName2
|
|
15875
|
+
},
|
|
15876
|
+
__taskName: task.name,
|
|
15877
|
+
__signalName: signalName
|
|
15878
|
+
});
|
|
15879
|
+
}
|
|
15880
|
+
}.bind(this),
|
|
15881
|
+
"Routing-critical meta signal-task maps are persisted during bootstrap so authority can route required control-plane signals before deferred manifest replay completes.",
|
|
15397
15882
|
{
|
|
15398
15883
|
register: false,
|
|
15399
15884
|
isHidden: true
|
|
15400
15885
|
}
|
|
15401
15886
|
);
|
|
15887
|
+
const signalTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
15888
|
+
this.isCadenzaDBReady,
|
|
15889
|
+
"signal_to_task_map",
|
|
15890
|
+
{
|
|
15891
|
+
onConflict: {
|
|
15892
|
+
target: [
|
|
15893
|
+
"signal_name",
|
|
15894
|
+
"is_global",
|
|
15895
|
+
"task_name",
|
|
15896
|
+
"task_version",
|
|
15897
|
+
"service_name"
|
|
15898
|
+
],
|
|
15899
|
+
action: {
|
|
15900
|
+
do: "nothing"
|
|
15901
|
+
}
|
|
15902
|
+
}
|
|
15903
|
+
},
|
|
15904
|
+
{ concurrency: 30 }
|
|
15905
|
+
);
|
|
15906
|
+
const recordSignalTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
15907
|
+
"Record signal task map registration",
|
|
15908
|
+
(ctx) => {
|
|
15909
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
15910
|
+
return;
|
|
15911
|
+
}
|
|
15912
|
+
scheduleSyncPassEvaluation();
|
|
15913
|
+
const task = CadenzaService.get(ctx.__taskName);
|
|
15914
|
+
const signalName = typeof ctx.__signalName === "string" ? canonicalizeSignalName2(ctx.__signalName) : "";
|
|
15915
|
+
if (!task || !signalName) {
|
|
15916
|
+
return true;
|
|
15917
|
+
}
|
|
15918
|
+
task.registeredSignals.add(signalName);
|
|
15919
|
+
return true;
|
|
15920
|
+
}
|
|
15921
|
+
);
|
|
15922
|
+
wireSyncTaskGraph(
|
|
15923
|
+
this.registerSignalToTaskMapTask,
|
|
15924
|
+
signalTaskMapRegistrationGraph,
|
|
15925
|
+
recordSignalTaskMapRegistrationTask
|
|
15926
|
+
);
|
|
15402
15927
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
15403
15928
|
"Split intents for registration",
|
|
15404
15929
|
function* (ctx) {
|
|
@@ -15414,25 +15939,31 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15414
15939
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
15415
15940
|
continue;
|
|
15416
15941
|
}
|
|
15942
|
+
if (intent.registrationRequested === true) {
|
|
15943
|
+
continue;
|
|
15944
|
+
}
|
|
15945
|
+
intent.registrationRequested = true;
|
|
15417
15946
|
this.intentsSynced = false;
|
|
15418
|
-
yield {
|
|
15419
|
-
__syncing: ctx.__syncing,
|
|
15947
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15420
15948
|
data: intentData,
|
|
15421
15949
|
__intentName: intentData.name
|
|
15422
|
-
};
|
|
15950
|
+
});
|
|
15423
15951
|
}
|
|
15424
15952
|
}.bind(this)
|
|
15425
15953
|
);
|
|
15426
15954
|
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
15427
15955
|
"Record intent definition registration",
|
|
15428
15956
|
(ctx, emit2) => {
|
|
15957
|
+
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
15958
|
+
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
15429
15959
|
if (!didSyncInsertSucceed(ctx)) {
|
|
15960
|
+
if (intentDefinition) {
|
|
15961
|
+
intentDefinition.registrationRequested = false;
|
|
15962
|
+
}
|
|
15430
15963
|
return;
|
|
15431
15964
|
}
|
|
15432
15965
|
scheduleSyncPassEvaluation();
|
|
15433
|
-
const intentName = typeof ctx.__intentName === "string" ? ctx.__intentName : "";
|
|
15434
15966
|
this.registeredIntentDefinitions.add(intentName);
|
|
15435
|
-
const intentDefinition = intentName ? CadenzaService.inquiryBroker.intents.get(intentName) ?? null : null;
|
|
15436
15967
|
if (intentDefinition) {
|
|
15437
15968
|
intentDefinition.registered = true;
|
|
15438
15969
|
intentDefinition.registrationRequested = false;
|
|
@@ -15692,6 +16223,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15692
16223
|
"Register task map to DB",
|
|
15693
16224
|
function* (ctx) {
|
|
15694
16225
|
const task = ctx.task;
|
|
16226
|
+
if (!task) {
|
|
16227
|
+
return;
|
|
16228
|
+
}
|
|
15695
16229
|
if (task.hidden || !task.register || task.isDeputy || !task.registered) {
|
|
15696
16230
|
return;
|
|
15697
16231
|
}
|
|
@@ -15700,6 +16234,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15700
16234
|
return;
|
|
15701
16235
|
}
|
|
15702
16236
|
for (const t of task.nextTasks) {
|
|
16237
|
+
if (!t) {
|
|
16238
|
+
continue;
|
|
16239
|
+
}
|
|
15703
16240
|
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
15704
16241
|
continue;
|
|
15705
16242
|
}
|
|
@@ -15707,7 +16244,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15707
16244
|
if (!serviceName2) {
|
|
15708
16245
|
continue;
|
|
15709
16246
|
}
|
|
15710
|
-
yield {
|
|
16247
|
+
yield buildMinimalSyncShardContext(ctx, {
|
|
15711
16248
|
data: {
|
|
15712
16249
|
task_name: t.name,
|
|
15713
16250
|
task_version: t.version,
|
|
@@ -15718,7 +16255,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
15718
16255
|
},
|
|
15719
16256
|
__taskName: task.name,
|
|
15720
16257
|
__nextTaskName: t.name
|
|
15721
|
-
};
|
|
16258
|
+
});
|
|
15722
16259
|
}
|
|
15723
16260
|
}
|
|
15724
16261
|
);
|
|
@@ -16306,19 +16843,6 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16306
16843
|
if (!ServiceRegistry.instance.hasLocalInstanceRegistered()) {
|
|
16307
16844
|
return false;
|
|
16308
16845
|
}
|
|
16309
|
-
if (ctx.__bootstrapFullSync === true) {
|
|
16310
|
-
if (shouldTraceSyncPhase(serviceName2)) {
|
|
16311
|
-
console.log(
|
|
16312
|
-
"[CADENZA_SYNC_PHASE_TRACE] sync_cycle_ignored_bootstrap_full_sync",
|
|
16313
|
-
{
|
|
16314
|
-
serviceName: serviceName2,
|
|
16315
|
-
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
16316
|
-
attempt: typeof ctx.__bootstrapFullSyncAttempt === "number" ? ctx.__bootstrapFullSyncAttempt : void 0
|
|
16317
|
-
}
|
|
16318
|
-
);
|
|
16319
|
-
}
|
|
16320
|
-
return false;
|
|
16321
|
-
}
|
|
16322
16846
|
if (state.activeSyncCycleId) {
|
|
16323
16847
|
const activeCycleAgeMs = now - state.activeSyncCycleStartedAt;
|
|
16324
16848
|
if (activeCycleAgeMs < BOOTSTRAP_SYNC_STALE_CYCLE_MS) {
|
|
@@ -16345,6 +16869,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16345
16869
|
});
|
|
16346
16870
|
}
|
|
16347
16871
|
}
|
|
16872
|
+
const primitivePendingSummary = buildPrimitivePendingSummary();
|
|
16873
|
+
const mapPendingSummary = buildMapPendingSummary();
|
|
16874
|
+
const hasPendingWork = hasNonZeroPending(primitivePendingSummary) || hasNonZeroPending(mapPendingSummary);
|
|
16875
|
+
if (!hasPendingWork && shouldSkipIdleBootstrapSyncTrigger(ctx)) {
|
|
16876
|
+
if (shouldTraceSyncPhase(serviceName2)) {
|
|
16877
|
+
console.log("[CADENZA_SYNC_PHASE_TRACE] sync_cycle_skipped_idle", {
|
|
16878
|
+
serviceName: serviceName2,
|
|
16879
|
+
triggerSignal: typeof ctx.__signal === "string" ? ctx.__signal : void 0,
|
|
16880
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0
|
|
16881
|
+
});
|
|
16882
|
+
}
|
|
16883
|
+
return false;
|
|
16884
|
+
}
|
|
16348
16885
|
const syncCycleId = `${now}-${uuid6()}`;
|
|
16349
16886
|
setRuntimeState({
|
|
16350
16887
|
activeSyncCycleId: syncCycleId,
|
|
@@ -16453,22 +16990,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16453
16990
|
const getSignalsForSyncTask = CadenzaService.createMetaTask(
|
|
16454
16991
|
"Get signals for sync",
|
|
16455
16992
|
(ctx) => {
|
|
16456
|
-
const
|
|
16457
|
-
|
|
16458
|
-
|
|
16459
|
-
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
|
|
16993
|
+
const canonicalSignals = /* @__PURE__ */ new Map();
|
|
16994
|
+
for (const observer of getRegistrableSignalObservers()) {
|
|
16995
|
+
const signalName = canonicalizeSignalName2(observer.signalName);
|
|
16996
|
+
if (!signalName || signalName.includes(":")) {
|
|
16997
|
+
continue;
|
|
16998
|
+
}
|
|
16999
|
+
canonicalSignals.set(signalName, {
|
|
17000
|
+
signal: signalName,
|
|
17001
|
+
data: {
|
|
17002
|
+
registered: observer.registered ?? false,
|
|
17003
|
+
metadata: observer.metadata ?? null
|
|
17004
|
+
}
|
|
17005
|
+
});
|
|
17006
|
+
}
|
|
17007
|
+
for (const emittedSignal of CadenzaService.signalBroker.emittedSignalsRegistry) {
|
|
17008
|
+
const signalName = canonicalizeSignalName2(emittedSignal);
|
|
17009
|
+
if (!signalName || signalName.includes(":")) {
|
|
17010
|
+
continue;
|
|
17011
|
+
}
|
|
17012
|
+
if (canonicalSignals.has(signalName)) {
|
|
17013
|
+
continue;
|
|
16467
17014
|
}
|
|
16468
|
-
|
|
17015
|
+
const metadata = CadenzaService.signalBroker.getSignalMetadata(signalName) ?? null;
|
|
17016
|
+
if (metadata?.is_meta === true || isBootstrapLocalOnlySignal(signalName)) {
|
|
17017
|
+
continue;
|
|
17018
|
+
}
|
|
17019
|
+
canonicalSignals.set(signalName, {
|
|
17020
|
+
signal: signalName,
|
|
17021
|
+
data: {
|
|
17022
|
+
registered: CadenzaService.signalBroker.signalObservers.get(signalName)?.registered ?? false,
|
|
17023
|
+
metadata
|
|
17024
|
+
}
|
|
17025
|
+
});
|
|
17026
|
+
}
|
|
16469
17027
|
return {
|
|
16470
17028
|
...ctx,
|
|
16471
|
-
signals:
|
|
17029
|
+
signals: Array.from(canonicalSignals.values())
|
|
16472
17030
|
};
|
|
16473
17031
|
},
|
|
16474
17032
|
"Collects local signals for the primitive sync phase.",
|
|
@@ -16505,9 +17063,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16505
17063
|
"Get all actors for sync",
|
|
16506
17064
|
(ctx) => ({
|
|
16507
17065
|
...ctx,
|
|
16508
|
-
actors:
|
|
17066
|
+
actors: []
|
|
16509
17067
|
}),
|
|
16510
|
-
"
|
|
17068
|
+
"Actor definitions are staged through service-manifest publication rather than the bootstrap primitive sync phase.",
|
|
16511
17069
|
{
|
|
16512
17070
|
register: false,
|
|
16513
17071
|
isHidden: true
|
|
@@ -16539,7 +17097,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16539
17097
|
"Iterate tasks for directional task map sync",
|
|
16540
17098
|
function* (ctx) {
|
|
16541
17099
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16542
|
-
yield
|
|
17100
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
16543
17101
|
}
|
|
16544
17102
|
},
|
|
16545
17103
|
"Iterates local tasks for directional task-map sync.",
|
|
@@ -16558,7 +17116,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16558
17116
|
"Iterate tasks for signal task map sync",
|
|
16559
17117
|
function* (ctx) {
|
|
16560
17118
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16561
|
-
yield
|
|
17119
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
16562
17120
|
}
|
|
16563
17121
|
},
|
|
16564
17122
|
"Iterates local tasks for signal-to-task map sync.",
|
|
@@ -16572,12 +17130,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16572
17130
|
gatherSignalTaskMapRegistrationTask
|
|
16573
17131
|
);
|
|
16574
17132
|
iterateTasksForSignalTaskMapSyncTask.then(this.registerSignalToTaskMapTask);
|
|
16575
|
-
|
|
17133
|
+
recordSignalTaskMapRegistrationTask.then(gatherSignalTaskMapRegistrationTask);
|
|
16576
17134
|
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16577
17135
|
"Iterate tasks for intent task map sync",
|
|
16578
17136
|
function* (ctx) {
|
|
16579
17137
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16580
|
-
yield
|
|
17138
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
16581
17139
|
}
|
|
16582
17140
|
},
|
|
16583
17141
|
"Iterates local tasks for intent-to-task map sync.",
|
|
@@ -16596,7 +17154,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
16596
17154
|
"Iterate tasks for actor task map sync",
|
|
16597
17155
|
function* (ctx) {
|
|
16598
17156
|
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16599
|
-
yield
|
|
17157
|
+
yield buildMinimalSyncShardContext(ctx, { task });
|
|
16600
17158
|
}
|
|
16601
17159
|
},
|
|
16602
17160
|
"Iterates local tasks for actor-to-task map sync.",
|
|
@@ -16729,7 +17287,7 @@ function sanitizePersistedTaskSourceFields2(task, data) {
|
|
|
16729
17287
|
};
|
|
16730
17288
|
}
|
|
16731
17289
|
function shouldSkipDirectTaskMetadata(task) {
|
|
16732
|
-
return !task || !task.register || task.isHidden || task.isDeputy;
|
|
17290
|
+
return !task || !task.register || task.isHidden || task.isDeputy || task.isMeta || task.isSubMeta;
|
|
16733
17291
|
}
|
|
16734
17292
|
function isManagedRouteRecoveryTaskError(errorMessage) {
|
|
16735
17293
|
if (typeof errorMessage !== "string") {
|
|
@@ -16743,7 +17301,10 @@ function isLocallyHandledIntentName2(intentName) {
|
|
|
16743
17301
|
return false;
|
|
16744
17302
|
}
|
|
16745
17303
|
for (const task of observer.tasks) {
|
|
16746
|
-
if (
|
|
17304
|
+
if (!task) {
|
|
17305
|
+
continue;
|
|
17306
|
+
}
|
|
17307
|
+
if (task.register && !task.isHidden && !task.isDeputy && !task.isMeta && !task.isSubMeta) {
|
|
16747
17308
|
return true;
|
|
16748
17309
|
}
|
|
16749
17310
|
}
|
|
@@ -16982,7 +17543,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
16982
17543
|
return false;
|
|
16983
17544
|
}
|
|
16984
17545
|
const helper = resolveHelperFromMetadataContext(ctx);
|
|
16985
|
-
if (!helper) {
|
|
17546
|
+
if (!helper || helper.isMeta) {
|
|
16986
17547
|
return false;
|
|
16987
17548
|
}
|
|
16988
17549
|
return buildDatabaseTriggerContext({
|
|
@@ -16997,7 +17558,7 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
16997
17558
|
return false;
|
|
16998
17559
|
}
|
|
16999
17560
|
const globalDefinition = resolveGlobalFromMetadataContext(ctx);
|
|
17000
|
-
if (!globalDefinition) {
|
|
17561
|
+
if (!globalDefinition || globalDefinition.isMeta) {
|
|
17001
17562
|
return false;
|
|
17002
17563
|
}
|
|
17003
17564
|
return buildDatabaseTriggerContext({
|
|
@@ -17099,6 +17660,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
17099
17660
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17100
17661
|
return false;
|
|
17101
17662
|
}
|
|
17663
|
+
if (ctx.data?.isMeta === true) {
|
|
17664
|
+
return false;
|
|
17665
|
+
}
|
|
17102
17666
|
return buildDatabaseTriggerContext({
|
|
17103
17667
|
...ctx.data,
|
|
17104
17668
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
@@ -17108,6 +17672,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
17108
17672
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17109
17673
|
return false;
|
|
17110
17674
|
}
|
|
17675
|
+
if (ctx.data?.isMeta === true) {
|
|
17676
|
+
return false;
|
|
17677
|
+
}
|
|
17111
17678
|
return buildDatabaseTriggerContext(
|
|
17112
17679
|
ctx.data ?? void 0,
|
|
17113
17680
|
{
|
|
@@ -17776,6 +18343,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
17776
18343
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17777
18344
|
return false;
|
|
17778
18345
|
}
|
|
18346
|
+
if (ctx.data?.is_meta === true) {
|
|
18347
|
+
return false;
|
|
18348
|
+
}
|
|
17779
18349
|
if (shouldSkipDirectActorMetadata(ctx?.data?.name)) {
|
|
17780
18350
|
return false;
|
|
17781
18351
|
}
|
|
@@ -17788,6 +18358,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
17788
18358
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17789
18359
|
return false;
|
|
17790
18360
|
}
|
|
18361
|
+
if (ctx.data?.is_meta === true) {
|
|
18362
|
+
return false;
|
|
18363
|
+
}
|
|
17791
18364
|
if (shouldSkipDirectActorMetadata(ctx?.data?.actor_name)) {
|
|
17792
18365
|
return false;
|
|
17793
18366
|
}
|
|
@@ -18233,6 +18806,8 @@ function resetBrowserRuntimeActorHandles() {
|
|
|
18233
18806
|
|
|
18234
18807
|
// src/Cadenza.ts
|
|
18235
18808
|
var POSTGRES_SETUP_DEBUG_ENABLED = process.env.CADENZA_POSTGRES_SETUP_DEBUG === "1" || process.env.CADENZA_POSTGRES_SETUP_DEBUG === "true";
|
|
18809
|
+
var DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 15e3;
|
|
18810
|
+
var LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS = 6e4;
|
|
18236
18811
|
function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE__ */ new Set()) {
|
|
18237
18812
|
if (depth < 0 || value === null || value === void 0) {
|
|
18238
18813
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
@@ -18294,6 +18869,10 @@ var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
|
18294
18869
|
"business_structural",
|
|
18295
18870
|
"local_meta_structural"
|
|
18296
18871
|
];
|
|
18872
|
+
var ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS = 250;
|
|
18873
|
+
var BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 1500;
|
|
18874
|
+
var LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS = 15e3;
|
|
18875
|
+
var MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS = 1e3;
|
|
18297
18876
|
function getServiceManifestPublicationLayerRank(layer) {
|
|
18298
18877
|
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
18299
18878
|
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
@@ -18427,43 +19006,250 @@ var CadenzaService = class {
|
|
|
18427
19006
|
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
18428
19007
|
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
18429
19008
|
}
|
|
19009
|
+
static clampServiceManifestPublicationLayer(targetLayer) {
|
|
19010
|
+
const maximumLayer = this.isLocalAuthorityService() ? "routing_capability" : "local_meta_structural";
|
|
19011
|
+
return getServiceManifestPublicationLayerRank(targetLayer) > getServiceManifestPublicationLayerRank(maximumLayer) ? maximumLayer : targetLayer;
|
|
19012
|
+
}
|
|
18430
19013
|
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
18431
19014
|
this.serviceManifestPublicationPendingReason = reason;
|
|
19015
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
18432
19016
|
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
18433
|
-
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(
|
|
19017
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? normalizedTargetLayer : currentTargetLayer;
|
|
19018
|
+
}
|
|
19019
|
+
static getServiceManifestPublicationGate(publicationLayer) {
|
|
19020
|
+
if (!this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
19021
|
+
return {
|
|
19022
|
+
ready: false,
|
|
19023
|
+
delayMs: ROUTING_CAPABILITY_PUBLICATION_RETRY_DELAY_MS
|
|
19024
|
+
};
|
|
19025
|
+
}
|
|
19026
|
+
if (publicationLayer === "routing_capability") {
|
|
19027
|
+
return {
|
|
19028
|
+
ready: true,
|
|
19029
|
+
delayMs: 0
|
|
19030
|
+
};
|
|
19031
|
+
}
|
|
19032
|
+
if (!this.bootstrapSyncCompleted || this.bootstrapSyncCompletedAt <= 0) {
|
|
19033
|
+
return {
|
|
19034
|
+
ready: false,
|
|
19035
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
19036
|
+
};
|
|
19037
|
+
}
|
|
19038
|
+
const now = Date.now();
|
|
19039
|
+
if (publicationLayer === "business_structural") {
|
|
19040
|
+
const allowedAt2 = this.bootstrapSyncCompletedAt + BUSINESS_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
19041
|
+
return {
|
|
19042
|
+
ready: now >= allowedAt2,
|
|
19043
|
+
delayMs: Math.max(1, allowedAt2 - now)
|
|
19044
|
+
};
|
|
19045
|
+
}
|
|
19046
|
+
const businessPublishedAt = this.serviceManifestPublishedAt.business_structural ?? 0;
|
|
19047
|
+
if (!this.lastPublishedServiceManifestHashes.business_structural || businessPublishedAt <= 0) {
|
|
19048
|
+
return {
|
|
19049
|
+
ready: false,
|
|
19050
|
+
delayMs: MANIFEST_PUBLICATION_PREREQUISITE_RETRY_DELAY_MS
|
|
19051
|
+
};
|
|
19052
|
+
}
|
|
19053
|
+
const allowedAt = businessPublishedAt + LOCAL_META_STRUCTURAL_PUBLICATION_CALM_DELAY_MS;
|
|
19054
|
+
return {
|
|
19055
|
+
ready: now >= allowedAt,
|
|
19056
|
+
delayMs: Math.max(1, allowedAt - now)
|
|
19057
|
+
};
|
|
18434
19058
|
}
|
|
18435
19059
|
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
18436
19060
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
18437
19061
|
return;
|
|
18438
19062
|
}
|
|
19063
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
18439
19064
|
const signalName = "meta.service_manifest.publish_requested";
|
|
18440
19065
|
const payload = {
|
|
18441
19066
|
__reason: reason,
|
|
18442
19067
|
__serviceName: this.serviceRegistry.serviceName,
|
|
18443
19068
|
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
18444
|
-
__publicationLayer:
|
|
19069
|
+
__publicationLayer: normalizedTargetLayer
|
|
18445
19070
|
};
|
|
18446
19071
|
if (immediate) {
|
|
18447
|
-
this.
|
|
19072
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
19073
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
19074
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
19075
|
+
}
|
|
19076
|
+
void this.publishServiceManifestIfNeeded(reason, normalizedTargetLayer);
|
|
18448
19077
|
return;
|
|
18449
19078
|
}
|
|
18450
19079
|
this.debounce(signalName, payload, 100);
|
|
18451
19080
|
}
|
|
18452
|
-
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
19081
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural", options) {
|
|
18453
19082
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
18454
19083
|
return;
|
|
18455
19084
|
}
|
|
19085
|
+
this.serviceManifestPublicationRetryReason = reason;
|
|
19086
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
19087
|
+
const currentRetryLayer = this.serviceManifestPublicationRetryLayer ?? "routing_capability";
|
|
19088
|
+
this.serviceManifestPublicationRetryLayer = getServiceManifestPublicationLayerRank(normalizedTargetLayer) >= getServiceManifestPublicationLayerRank(currentRetryLayer) ? normalizedTargetLayer : currentRetryLayer;
|
|
19089
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
19090
|
+
return;
|
|
19091
|
+
}
|
|
19092
|
+
const retryReason = this.serviceManifestPublicationRetryReason ?? reason;
|
|
19093
|
+
const retryTargetLayer = this.serviceManifestPublicationRetryLayer ?? targetLayer;
|
|
19094
|
+
const shouldIncrementRetryCount = options?.incrementRetryCount !== false;
|
|
19095
|
+
const delayMs = options?.delayMs ?? Math.min(
|
|
19096
|
+
1e4,
|
|
19097
|
+
1e3 * Math.max(1, 2 ** this.serviceManifestPublicationRetryCount)
|
|
19098
|
+
);
|
|
19099
|
+
if (shouldIncrementRetryCount) {
|
|
19100
|
+
this.serviceManifestPublicationRetryCount += 1;
|
|
19101
|
+
}
|
|
19102
|
+
this.serviceManifestPublicationRetryTimer = setTimeout(() => {
|
|
19103
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
19104
|
+
const pendingReason = this.serviceManifestPublicationRetryReason ?? retryReason;
|
|
19105
|
+
const pendingLayer = this.serviceManifestPublicationRetryLayer ?? retryTargetLayer;
|
|
19106
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
19107
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
19108
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
19109
|
+
}, delayMs);
|
|
19110
|
+
}
|
|
19111
|
+
static shouldPublishBusinessManifestForTaskContext(ctx) {
|
|
19112
|
+
const task = ctx?.taskInstance ?? (typeof ctx?.data?.name === "string" ? this.get(ctx.data.name) : void 0);
|
|
19113
|
+
if (task) {
|
|
19114
|
+
if (this.isRoutingCriticalManifestTask(task)) {
|
|
19115
|
+
return true;
|
|
19116
|
+
}
|
|
19117
|
+
return task.register === true && task.isMeta !== true && task.isSubMeta !== true && task.isHidden !== true && task.isEphemeral !== true;
|
|
19118
|
+
}
|
|
19119
|
+
if (this.hasRoutingCriticalManifestBindingInContext(ctx)) {
|
|
19120
|
+
return true;
|
|
19121
|
+
}
|
|
19122
|
+
return ctx?.data?.isMeta !== true && ctx?.data?.isSubMeta !== true && ctx?.data?.isHidden !== true && ctx?.data?.isEphemeral !== true && ctx?.__isSubMeta !== true;
|
|
19123
|
+
}
|
|
19124
|
+
static isRoutingCriticalManifestSignalName(signalName) {
|
|
19125
|
+
const normalizedSignalName = String(signalName ?? "").trim();
|
|
19126
|
+
if (!normalizedSignalName) {
|
|
19127
|
+
return false;
|
|
19128
|
+
}
|
|
19129
|
+
return normalizedSignalName === EXECUTION_PERSISTENCE_BUNDLE_SIGNAL || isAuthorityBootstrapSignal(normalizedSignalName);
|
|
19130
|
+
}
|
|
19131
|
+
static isRoutingCriticalManifestIntentName(intentName) {
|
|
19132
|
+
return isAuthorityBootstrapIntent(intentName);
|
|
19133
|
+
}
|
|
19134
|
+
static isRoutingCriticalManifestTask(task) {
|
|
19135
|
+
for (const signalName of task.observedSignals ?? []) {
|
|
19136
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
19137
|
+
return true;
|
|
19138
|
+
}
|
|
19139
|
+
}
|
|
19140
|
+
for (const intentName of task.handlesIntents ?? []) {
|
|
19141
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
19142
|
+
return true;
|
|
19143
|
+
}
|
|
19144
|
+
}
|
|
19145
|
+
return false;
|
|
19146
|
+
}
|
|
19147
|
+
static hasRoutingCriticalManifestBindingInContext(ctx) {
|
|
19148
|
+
const signalCandidates = [
|
|
19149
|
+
ctx?.signalName,
|
|
19150
|
+
ctx?.data?.signalName,
|
|
19151
|
+
ctx?.data?.signal_name
|
|
19152
|
+
];
|
|
19153
|
+
for (const signalName of signalCandidates) {
|
|
19154
|
+
if (this.isRoutingCriticalManifestSignalName(signalName)) {
|
|
19155
|
+
return true;
|
|
19156
|
+
}
|
|
19157
|
+
}
|
|
19158
|
+
const intentCandidates = [
|
|
19159
|
+
ctx?.intentName,
|
|
19160
|
+
ctx?.data?.intentName,
|
|
19161
|
+
ctx?.data?.intent_name
|
|
19162
|
+
];
|
|
19163
|
+
for (const intentName of intentCandidates) {
|
|
19164
|
+
if (this.isRoutingCriticalManifestIntentName(intentName)) {
|
|
19165
|
+
return true;
|
|
19166
|
+
}
|
|
19167
|
+
}
|
|
19168
|
+
return false;
|
|
19169
|
+
}
|
|
19170
|
+
static shouldPublishBusinessManifestForHelperContext(ctx) {
|
|
19171
|
+
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 : "";
|
|
19172
|
+
const helper = helperName ? Cadenza.getHelper(helperName) : void 0;
|
|
19173
|
+
if (helper) {
|
|
19174
|
+
return helper.isMeta !== true;
|
|
19175
|
+
}
|
|
19176
|
+
return ctx?.data?.isMeta !== true;
|
|
19177
|
+
}
|
|
19178
|
+
static shouldPublishBusinessManifestForGlobalContext(ctx) {
|
|
19179
|
+
const globalName = typeof ctx?.data?.name === "string" ? ctx.data.name : typeof ctx?.data?.globalName === "string" ? ctx.data.globalName : "";
|
|
19180
|
+
const globalDefinition = globalName ? Cadenza.getGlobal(globalName) : void 0;
|
|
19181
|
+
if (globalDefinition) {
|
|
19182
|
+
return globalDefinition.isMeta !== true;
|
|
19183
|
+
}
|
|
19184
|
+
return ctx?.data?.isMeta !== true;
|
|
19185
|
+
}
|
|
19186
|
+
static shouldPublishBusinessManifestForRoutineContext(ctx) {
|
|
19187
|
+
const routineName = typeof ctx?.data?.name === "string" ? ctx.data.name : "";
|
|
19188
|
+
const routine = routineName ? this.getRoutine(routineName) : void 0;
|
|
19189
|
+
if (routine) {
|
|
19190
|
+
return routine.isMeta !== true;
|
|
19191
|
+
}
|
|
19192
|
+
return ctx?.data?.isMeta !== true;
|
|
19193
|
+
}
|
|
19194
|
+
static shouldRequestServiceManifestPublicationForSignal(ctx) {
|
|
19195
|
+
const signalName = typeof ctx?.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal.trim() : "";
|
|
19196
|
+
switch (signalName) {
|
|
19197
|
+
case "meta.task.created":
|
|
19198
|
+
case "meta.task.destroyed":
|
|
19199
|
+
case "meta.task.relationship_added":
|
|
19200
|
+
case "meta.task.relationship_removed":
|
|
19201
|
+
case "meta.task.intent_associated":
|
|
19202
|
+
case "meta.task.helper_associated":
|
|
19203
|
+
case "meta.task.global_associated":
|
|
19204
|
+
case "meta.task.observed_signal":
|
|
19205
|
+
case "meta.task.attached_signal":
|
|
19206
|
+
case "meta.task.detached_signal":
|
|
19207
|
+
return this.shouldPublishBusinessManifestForTaskContext(ctx);
|
|
19208
|
+
case "meta.helper.created":
|
|
19209
|
+
case "meta.helper.updated":
|
|
19210
|
+
case "meta.helper.helper_associated":
|
|
19211
|
+
case "meta.helper.global_associated":
|
|
19212
|
+
return this.shouldPublishBusinessManifestForHelperContext(ctx);
|
|
19213
|
+
case "meta.global.created":
|
|
19214
|
+
case "meta.global.updated":
|
|
19215
|
+
return this.shouldPublishBusinessManifestForGlobalContext(ctx);
|
|
19216
|
+
case "meta.actor.created":
|
|
19217
|
+
case "meta.actor.task_associated":
|
|
19218
|
+
return ctx?.data?.is_meta !== true && ctx?.__isSubMeta !== true;
|
|
19219
|
+
case "global.meta.graph_metadata.routine_created":
|
|
19220
|
+
case "global.meta.graph_metadata.routine_updated":
|
|
19221
|
+
return this.shouldPublishBusinessManifestForRoutineContext(ctx);
|
|
19222
|
+
default:
|
|
19223
|
+
return false;
|
|
19224
|
+
}
|
|
19225
|
+
}
|
|
19226
|
+
static maybeRequestInitialServiceManifestPublication(reason, targetLayer = "business_structural") {
|
|
19227
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId || !this.localServiceManifestDefinitionInserted || !this.localServiceManifestInstanceInserted) {
|
|
19228
|
+
return false;
|
|
19229
|
+
}
|
|
19230
|
+
this.initialServiceManifestPublicationRequested = true;
|
|
19231
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
19232
|
+
return true;
|
|
19233
|
+
}
|
|
19234
|
+
static scheduleInitialServiceManifestPublicationFallback(reason, targetLayer = "business_structural") {
|
|
19235
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
19236
|
+
return;
|
|
19237
|
+
}
|
|
18456
19238
|
setTimeout(() => {
|
|
18457
|
-
this.
|
|
19239
|
+
if (this.initialServiceManifestPublicationRequested || !this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
19240
|
+
return;
|
|
19241
|
+
}
|
|
19242
|
+
this.requestServiceManifestPublication(reason, true, targetLayer);
|
|
18458
19243
|
}, 1e3);
|
|
18459
19244
|
}
|
|
18460
19245
|
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
18461
|
-
if (!this.
|
|
19246
|
+
if (!this.canPublishServiceManifestToAuthority() || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
18462
19247
|
return false;
|
|
18463
19248
|
}
|
|
18464
19249
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
19250
|
+
const normalizedTargetLayer = this.clampServiceManifestPublicationLayer(targetLayer);
|
|
18465
19251
|
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
18466
|
-
|
|
19252
|
+
normalizedTargetLayer
|
|
18467
19253
|
);
|
|
18468
19254
|
if (this.serviceManifestPublicationInFlight) {
|
|
18469
19255
|
this.mergeServiceManifestPublicationRequest(
|
|
@@ -18496,13 +19282,23 @@ var CadenzaService = class {
|
|
|
18496
19282
|
const hasPendingFollowupLayer = publicationPlan.some(
|
|
18497
19283
|
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
18498
19284
|
);
|
|
19285
|
+
const publicationGate = this.getServiceManifestPublicationGate(publicationLayer);
|
|
19286
|
+
if (!publicationGate.ready) {
|
|
19287
|
+
this.scheduleServiceManifestPublicationRetry(publishReason, publishTargetLayer, {
|
|
19288
|
+
delayMs: publicationGate.delayMs,
|
|
19289
|
+
incrementRetryCount: false
|
|
19290
|
+
});
|
|
19291
|
+
return false;
|
|
19292
|
+
}
|
|
18499
19293
|
this.serviceManifestPublicationInFlight = true;
|
|
18500
19294
|
try {
|
|
18501
|
-
this.
|
|
18502
|
-
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
19295
|
+
if (!this.isLocalAuthorityService()) {
|
|
19296
|
+
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
19297
|
+
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
19298
|
+
snapshot
|
|
19299
|
+
);
|
|
19300
|
+
}
|
|
19301
|
+
if (this.shouldRequireAuthorityBootstrapHandshakeForManifestPublication() && !this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
18506
19302
|
this.scheduleServiceManifestPublicationRetry(
|
|
18507
19303
|
publishReason,
|
|
18508
19304
|
publishTargetLayer
|
|
@@ -18510,11 +19306,13 @@ var CadenzaService = class {
|
|
|
18510
19306
|
return false;
|
|
18511
19307
|
}
|
|
18512
19308
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
18513
|
-
timeout:
|
|
19309
|
+
timeout: this.isLocalAuthorityService() ? LOCAL_AUTHORITY_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS : DEFAULT_SERVICE_MANIFEST_PUBLICATION_TIMEOUT_MS,
|
|
18514
19310
|
requireComplete: true
|
|
18515
19311
|
});
|
|
18516
19312
|
this.serviceManifestRevision = snapshot.revision;
|
|
18517
19313
|
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
19314
|
+
this.serviceManifestPublishedAt[publicationLayer] = Date.now();
|
|
19315
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
18518
19316
|
if (hasPendingFollowupLayer) {
|
|
18519
19317
|
this.mergeServiceManifestPublicationRequest(
|
|
18520
19318
|
publishReason,
|
|
@@ -18550,14 +19348,7 @@ var CadenzaService = class {
|
|
|
18550
19348
|
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
18551
19349
|
this.serviceManifestPublicationPendingReason = null;
|
|
18552
19350
|
this.serviceManifestPublicationPendingLayer = null;
|
|
18553
|
-
this.
|
|
18554
|
-
"meta.service_manifest.publish_requested",
|
|
18555
|
-
{
|
|
18556
|
-
__reason: pendingReason,
|
|
18557
|
-
__publicationLayer: pendingLayer
|
|
18558
|
-
},
|
|
18559
|
-
100
|
|
18560
|
-
);
|
|
19351
|
+
void this.publishServiceManifestIfNeeded(pendingReason, pendingLayer);
|
|
18561
19352
|
}
|
|
18562
19353
|
}
|
|
18563
19354
|
}
|
|
@@ -18571,7 +19362,7 @@ var CadenzaService = class {
|
|
|
18571
19362
|
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
18572
19363
|
this.normalizeServiceManifestPublicationLayer(
|
|
18573
19364
|
ctx.__publicationLayer,
|
|
18574
|
-
"
|
|
19365
|
+
"local_meta_structural"
|
|
18575
19366
|
)
|
|
18576
19367
|
),
|
|
18577
19368
|
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
@@ -18583,14 +19374,17 @@ var CadenzaService = class {
|
|
|
18583
19374
|
this.createMetaTask(
|
|
18584
19375
|
"Request manifest publication after structural change",
|
|
18585
19376
|
(ctx) => {
|
|
19377
|
+
if (!this.shouldRequestServiceManifestPublicationForSignal(ctx)) {
|
|
19378
|
+
return false;
|
|
19379
|
+
}
|
|
18586
19380
|
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";
|
|
18587
|
-
const targetLayer =
|
|
19381
|
+
const targetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
18588
19382
|
ctx.__publicationLayer,
|
|
18589
|
-
"
|
|
19383
|
+
"local_meta_structural"
|
|
18590
19384
|
);
|
|
18591
19385
|
this.requestServiceManifestPublication(
|
|
18592
19386
|
reason,
|
|
18593
|
-
|
|
19387
|
+
false,
|
|
18594
19388
|
targetLayer
|
|
18595
19389
|
);
|
|
18596
19390
|
return true;
|
|
@@ -18601,7 +19395,6 @@ var CadenzaService = class {
|
|
|
18601
19395
|
isHidden: true
|
|
18602
19396
|
}
|
|
18603
19397
|
).doOn(
|
|
18604
|
-
"meta.service_registry.instance_inserted",
|
|
18605
19398
|
"meta.task.created",
|
|
18606
19399
|
"meta.task.destroyed",
|
|
18607
19400
|
"meta.task.relationship_added",
|
|
@@ -18620,14 +19413,21 @@ var CadenzaService = class {
|
|
|
18620
19413
|
"meta.helper.global_associated",
|
|
18621
19414
|
"meta.actor.created",
|
|
18622
19415
|
"meta.actor.task_associated",
|
|
18623
|
-
"meta.fetch.handshake_complete",
|
|
18624
19416
|
"meta.service_registry.registered_global_signals",
|
|
18625
19417
|
"meta.service_registry.registered_global_intents",
|
|
18626
|
-
"meta.service_registry.initial_sync_complete",
|
|
18627
19418
|
"global.meta.graph_metadata.routine_created",
|
|
18628
19419
|
"global.meta.graph_metadata.routine_updated"
|
|
18629
19420
|
);
|
|
18630
19421
|
}
|
|
19422
|
+
static isLocalAuthorityService() {
|
|
19423
|
+
return this.serviceRegistry.serviceName === "CadenzaDB";
|
|
19424
|
+
}
|
|
19425
|
+
static canPublishServiceManifestToAuthority() {
|
|
19426
|
+
return this.serviceRegistry.connectsToCadenzaDB || this.isLocalAuthorityService();
|
|
19427
|
+
}
|
|
19428
|
+
static shouldRequireAuthorityBootstrapHandshakeForManifestPublication() {
|
|
19429
|
+
return !this.isLocalAuthorityService();
|
|
19430
|
+
}
|
|
18631
19431
|
static buildLegacyLocalCadenzaDBTaskName(tableName, operation) {
|
|
18632
19432
|
const operationPrefix = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
18633
19433
|
const helperSuffix = camelCase(String(tableName ?? "").trim());
|
|
@@ -18794,6 +19594,7 @@ var CadenzaService = class {
|
|
|
18794
19594
|
}
|
|
18795
19595
|
static markBootstrapSyncCompleted() {
|
|
18796
19596
|
this.bootstrapSyncCompleted = true;
|
|
19597
|
+
this.bootstrapSyncCompletedAt = Date.now();
|
|
18797
19598
|
}
|
|
18798
19599
|
/**
|
|
18799
19600
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -19624,6 +20425,7 @@ var CadenzaService = class {
|
|
|
19624
20425
|
this.validateServiceName(serviceName);
|
|
19625
20426
|
const serviceId = options.customServiceId ?? uuid7();
|
|
19626
20427
|
this.bootstrapSyncCompleted = false;
|
|
20428
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
19627
20429
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
19628
20430
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
19629
20431
|
this.serviceRegistry.serviceName = serviceName;
|
|
@@ -19859,6 +20661,7 @@ var CadenzaService = class {
|
|
|
19859
20661
|
__declaredTransports: declaredTransports
|
|
19860
20662
|
};
|
|
19861
20663
|
let bootstrapServiceCreationRequested = false;
|
|
20664
|
+
const emitLocalServiceCreationImmediately = !options.cadenzaDB?.connect;
|
|
19862
20665
|
if (options.cadenzaDB?.connect) {
|
|
19863
20666
|
this.createMetaTask(
|
|
19864
20667
|
"Create service",
|
|
@@ -19881,7 +20684,6 @@ var CadenzaService = class {
|
|
|
19881
20684
|
}
|
|
19882
20685
|
).doOn("meta.fetch.handshake_complete");
|
|
19883
20686
|
} else {
|
|
19884
|
-
this.emit("meta.create_service_requested", initContext);
|
|
19885
20687
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
19886
20688
|
emit2(
|
|
19887
20689
|
"meta.service_registry.gathered_sync_transmission_reconcile_requested",
|
|
@@ -19893,6 +20695,20 @@ var CadenzaService = class {
|
|
|
19893
20695
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
19894
20696
|
}
|
|
19895
20697
|
let serviceSetupCompletedHandled = false;
|
|
20698
|
+
this.createMetaTask("Handle local service definition insertion", (ctx) => {
|
|
20699
|
+
const insertedServiceName = String(
|
|
20700
|
+
ctx?.__serviceName ?? ctx?.serviceName ?? ctx?.service_name ?? ctx?.data?.name ?? ""
|
|
20701
|
+
).trim();
|
|
20702
|
+
if (!insertedServiceName || insertedServiceName !== serviceName) {
|
|
20703
|
+
return false;
|
|
20704
|
+
}
|
|
20705
|
+
this.localServiceManifestDefinitionInserted = true;
|
|
20706
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
20707
|
+
"service_setup_completed",
|
|
20708
|
+
"local_meta_structural"
|
|
20709
|
+
);
|
|
20710
|
+
return true;
|
|
20711
|
+
}).doOn("meta.service_registry.service_inserted");
|
|
19896
20712
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
19897
20713
|
if (serviceSetupCompletedHandled) {
|
|
19898
20714
|
return false;
|
|
@@ -19913,13 +20729,18 @@ var CadenzaService = class {
|
|
|
19913
20729
|
return false;
|
|
19914
20730
|
}
|
|
19915
20731
|
serviceSetupCompletedHandled = true;
|
|
20732
|
+
this.localServiceManifestInstanceInserted = true;
|
|
19916
20733
|
if (options.cadenzaDB?.connect) {
|
|
19917
20734
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
19918
|
-
void this.publishServiceManifestIfNeeded(
|
|
19919
|
-
"service_setup_completed",
|
|
19920
|
-
"business_structural"
|
|
19921
|
-
);
|
|
19922
20735
|
}
|
|
20736
|
+
this.maybeRequestInitialServiceManifestPublication(
|
|
20737
|
+
"service_setup_completed",
|
|
20738
|
+
"local_meta_structural"
|
|
20739
|
+
);
|
|
20740
|
+
this.scheduleInitialServiceManifestPublicationFallback(
|
|
20741
|
+
"service_setup_completed",
|
|
20742
|
+
"local_meta_structural"
|
|
20743
|
+
);
|
|
19923
20744
|
if (isFrontend) {
|
|
19924
20745
|
registerActorSessionPersistenceTasks();
|
|
19925
20746
|
this.ensureFrontendSyncLoop();
|
|
@@ -19927,6 +20748,9 @@ var CadenzaService = class {
|
|
|
19927
20748
|
this.log("Service created.");
|
|
19928
20749
|
return true;
|
|
19929
20750
|
}).doOn("meta.service_registry.instance_inserted");
|
|
20751
|
+
if (emitLocalServiceCreationImmediately) {
|
|
20752
|
+
this.emit("meta.create_service_requested", initContext);
|
|
20753
|
+
}
|
|
19930
20754
|
if (!options.cadenzaDB?.connect) {
|
|
19931
20755
|
Cadenza.schedule(
|
|
19932
20756
|
"meta.service_registry.instance_registration_requested",
|
|
@@ -20391,6 +21215,30 @@ var CadenzaService = class {
|
|
|
20391
21215
|
this.bootstrap();
|
|
20392
21216
|
return Cadenza.createTask(name, func, description, options);
|
|
20393
21217
|
}
|
|
21218
|
+
static createHelper(name, func, description = "") {
|
|
21219
|
+
this.bootstrap();
|
|
21220
|
+
return Cadenza.createHelper(name, func, description);
|
|
21221
|
+
}
|
|
21222
|
+
static createMetaHelper(name, func, description = "") {
|
|
21223
|
+
this.bootstrap();
|
|
21224
|
+
return Cadenza.createMetaHelper(name, func, description);
|
|
21225
|
+
}
|
|
21226
|
+
static createHelperFromDefinition(definition) {
|
|
21227
|
+
this.bootstrap();
|
|
21228
|
+
return Cadenza.createHelperFromDefinition(definition);
|
|
21229
|
+
}
|
|
21230
|
+
static createGlobal(name, value, description = "") {
|
|
21231
|
+
this.bootstrap();
|
|
21232
|
+
return Cadenza.createGlobal(name, value, description);
|
|
21233
|
+
}
|
|
21234
|
+
static createMetaGlobal(name, value, description = "") {
|
|
21235
|
+
this.bootstrap();
|
|
21236
|
+
return Cadenza.createMetaGlobal(name, value, description);
|
|
21237
|
+
}
|
|
21238
|
+
static createGlobalFromDefinition(definition) {
|
|
21239
|
+
this.bootstrap();
|
|
21240
|
+
return Cadenza.createGlobalFromDefinition(definition);
|
|
21241
|
+
}
|
|
20394
21242
|
/**
|
|
20395
21243
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
20396
21244
|
* This is used for creating tasks that lives on the meta layer.
|
|
@@ -20727,6 +21575,7 @@ var CadenzaService = class {
|
|
|
20727
21575
|
this.isBootstrapped = false;
|
|
20728
21576
|
this.serviceCreated = false;
|
|
20729
21577
|
this.bootstrapSyncCompleted = false;
|
|
21578
|
+
this.bootstrapSyncCompletedAt = 0;
|
|
20730
21579
|
this.bootstrapSignalRegistrationsCompleted = false;
|
|
20731
21580
|
this.bootstrapIntentRegistrationsCompleted = false;
|
|
20732
21581
|
this.defaultDatabaseServiceName = null;
|
|
@@ -20735,15 +21584,27 @@ var CadenzaService = class {
|
|
|
20735
21584
|
this.frontendSyncScheduled = false;
|
|
20736
21585
|
this.serviceManifestRevision = 0;
|
|
20737
21586
|
this.lastPublishedServiceManifestHashes = {};
|
|
21587
|
+
this.serviceManifestPublishedAt = {};
|
|
20738
21588
|
this.serviceManifestPublicationInFlight = false;
|
|
20739
21589
|
this.serviceManifestPublicationPendingReason = null;
|
|
20740
21590
|
this.serviceManifestPublicationPendingLayer = null;
|
|
21591
|
+
this.serviceManifestPublicationRetryReason = null;
|
|
21592
|
+
this.serviceManifestPublicationRetryLayer = null;
|
|
21593
|
+
if (this.serviceManifestPublicationRetryTimer) {
|
|
21594
|
+
clearTimeout(this.serviceManifestPublicationRetryTimer);
|
|
21595
|
+
this.serviceManifestPublicationRetryTimer = null;
|
|
21596
|
+
}
|
|
21597
|
+
this.serviceManifestPublicationRetryCount = 0;
|
|
21598
|
+
this.localServiceManifestDefinitionInserted = false;
|
|
21599
|
+
this.localServiceManifestInstanceInserted = false;
|
|
21600
|
+
this.initialServiceManifestPublicationRequested = false;
|
|
20741
21601
|
resetBrowserRuntimeActorHandles();
|
|
20742
21602
|
}
|
|
20743
21603
|
};
|
|
20744
21604
|
CadenzaService.isBootstrapped = false;
|
|
20745
21605
|
CadenzaService.serviceCreated = false;
|
|
20746
21606
|
CadenzaService.bootstrapSyncCompleted = false;
|
|
21607
|
+
CadenzaService.bootstrapSyncCompletedAt = 0;
|
|
20747
21608
|
CadenzaService.bootstrapSignalRegistrationsCompleted = false;
|
|
20748
21609
|
CadenzaService.bootstrapIntentRegistrationsCompleted = false;
|
|
20749
21610
|
CadenzaService.defaultDatabaseServiceName = null;
|
|
@@ -20752,9 +21613,17 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
20752
21613
|
CadenzaService.frontendSyncScheduled = false;
|
|
20753
21614
|
CadenzaService.serviceManifestRevision = 0;
|
|
20754
21615
|
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
21616
|
+
CadenzaService.serviceManifestPublishedAt = {};
|
|
20755
21617
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
20756
21618
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
20757
21619
|
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
21620
|
+
CadenzaService.serviceManifestPublicationRetryReason = null;
|
|
21621
|
+
CadenzaService.serviceManifestPublicationRetryLayer = null;
|
|
21622
|
+
CadenzaService.serviceManifestPublicationRetryTimer = null;
|
|
21623
|
+
CadenzaService.serviceManifestPublicationRetryCount = 0;
|
|
21624
|
+
CadenzaService.localServiceManifestDefinitionInserted = false;
|
|
21625
|
+
CadenzaService.localServiceManifestInstanceInserted = false;
|
|
21626
|
+
CadenzaService.initialServiceManifestPublicationRequested = false;
|
|
20758
21627
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
20759
21628
|
CadenzaService.shutdownInFlight = false;
|
|
20760
21629
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -20762,6 +21631,8 @@ CadenzaService.shutdownHandlerCleanup = [];
|
|
|
20762
21631
|
// src/index.ts
|
|
20763
21632
|
import {
|
|
20764
21633
|
Actor as Actor2,
|
|
21634
|
+
GlobalDefinition as GlobalDefinition2,
|
|
21635
|
+
HelperDefinition as HelperDefinition2,
|
|
20765
21636
|
DebounceTask as DebounceTask2,
|
|
20766
21637
|
EphemeralTask as EphemeralTask2,
|
|
20767
21638
|
GraphRoutine as GraphRoutine2,
|
|
@@ -21062,6 +21933,18 @@ var createTask = CadenzaService.createTask.bind(
|
|
|
21062
21933
|
var createMetaTask = CadenzaService.createMetaTask.bind(
|
|
21063
21934
|
CadenzaService
|
|
21064
21935
|
);
|
|
21936
|
+
var createHelper = CadenzaService.createHelper.bind(
|
|
21937
|
+
CadenzaService
|
|
21938
|
+
);
|
|
21939
|
+
var createMetaHelper = CadenzaService.createMetaHelper.bind(
|
|
21940
|
+
CadenzaService
|
|
21941
|
+
);
|
|
21942
|
+
var createGlobal = CadenzaService.createGlobal.bind(
|
|
21943
|
+
CadenzaService
|
|
21944
|
+
);
|
|
21945
|
+
var createMetaGlobal = CadenzaService.createMetaGlobal.bind(
|
|
21946
|
+
CadenzaService
|
|
21947
|
+
);
|
|
21065
21948
|
var createActor = CadenzaService.createActor.bind(
|
|
21066
21949
|
CadenzaService
|
|
21067
21950
|
);
|
|
@@ -21096,8 +21979,10 @@ export {
|
|
|
21096
21979
|
DeputyTask,
|
|
21097
21980
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
21098
21981
|
EphemeralTask2 as EphemeralTask,
|
|
21982
|
+
GlobalDefinition2 as GlobalDefinition,
|
|
21099
21983
|
GraphMetadataController,
|
|
21100
21984
|
GraphRoutine2 as GraphRoutine,
|
|
21985
|
+
HelperDefinition2 as HelperDefinition,
|
|
21101
21986
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
21102
21987
|
RUNTIME_VALIDATION_INTENTS,
|
|
21103
21988
|
RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -21117,6 +22002,10 @@ export {
|
|
|
21117
22002
|
createCadenzaService,
|
|
21118
22003
|
createDatabaseService,
|
|
21119
22004
|
createExecutionPersistenceBundle,
|
|
22005
|
+
createGlobal,
|
|
22006
|
+
createHelper,
|
|
22007
|
+
createMetaGlobal,
|
|
22008
|
+
createMetaHelper,
|
|
21120
22009
|
createMetaTask,
|
|
21121
22010
|
createSSRInquiryBridge,
|
|
21122
22011
|
createTask,
|