@cadenza.io/service 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/{Cadenza-D787NzXY.d.mts → Cadenza-Cq1mscQf.d.mts} +205 -2
- package/dist/{Cadenza-D787NzXY.d.ts → Cadenza-Cq1mscQf.d.ts} +205 -2
- package/dist/browser/index.js +2526 -551
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +2425 -450
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +10 -130
- package/dist/index.d.ts +10 -130
- package/dist/index.js +2697 -564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2637 -504
- 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 +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -39,15 +39,15 @@ __export(src_exports, {
|
|
|
39
39
|
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_TASK_NAME: () => AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_TASK_NAME,
|
|
40
40
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT: () => AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
41
41
|
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL: () => AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
42
|
-
Actor: () =>
|
|
42
|
+
Actor: () => import_core7.Actor,
|
|
43
43
|
DatabaseController: () => DatabaseController,
|
|
44
44
|
DatabaseTask: () => DatabaseTask,
|
|
45
|
-
DebounceTask: () =>
|
|
45
|
+
DebounceTask: () => import_core7.DebounceTask,
|
|
46
46
|
DeputyTask: () => DeputyTask,
|
|
47
47
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL: () => EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
48
|
-
EphemeralTask: () =>
|
|
48
|
+
EphemeralTask: () => import_core7.EphemeralTask,
|
|
49
49
|
GraphMetadataController: () => GraphMetadataController,
|
|
50
|
-
GraphRoutine: () =>
|
|
50
|
+
GraphRoutine: () => import_core7.GraphRoutine,
|
|
51
51
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL: () => RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
52
52
|
RUNTIME_VALIDATION_INTENTS: () => RUNTIME_VALIDATION_INTENTS,
|
|
53
53
|
RUNTIME_VALIDATION_SIGNALS: () => RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -56,7 +56,7 @@ __export(src_exports, {
|
|
|
56
56
|
SignalController: () => SignalController,
|
|
57
57
|
SignalTransmissionTask: () => SignalTransmissionTask,
|
|
58
58
|
SocketController: () => SocketController,
|
|
59
|
-
Task: () =>
|
|
59
|
+
Task: () => import_core7.Task,
|
|
60
60
|
buildAuthorityRuntimeStatusSignature: () => buildAuthorityRuntimeStatusSignature,
|
|
61
61
|
buildExecutionPersistenceDependency: () => buildExecutionPersistenceDependency,
|
|
62
62
|
buildExecutionPersistenceEnsureEvent: () => buildExecutionPersistenceEnsureEvent,
|
|
@@ -87,7 +87,7 @@ __export(src_exports, {
|
|
|
87
87
|
module.exports = __toCommonJS(src_exports);
|
|
88
88
|
|
|
89
89
|
// src/Cadenza.ts
|
|
90
|
-
var
|
|
90
|
+
var import_core6 = __toESM(require("@cadenza.io/core"));
|
|
91
91
|
|
|
92
92
|
// src/graph/definition/DeputyTask.ts
|
|
93
93
|
var import_uuid2 = require("uuid");
|
|
@@ -105,6 +105,30 @@ var LOCAL_ROUTINE_PERSISTENCE_KEYS = [
|
|
|
105
105
|
"__routineCreatedAt",
|
|
106
106
|
"__routineIsMeta"
|
|
107
107
|
];
|
|
108
|
+
var BULKY_EXECUTION_PERSISTENCE_KEYS = [
|
|
109
|
+
"rows",
|
|
110
|
+
"joinedContexts",
|
|
111
|
+
"serviceInstances",
|
|
112
|
+
"serviceInstanceLeases",
|
|
113
|
+
"serviceInstanceTransports",
|
|
114
|
+
"serviceManifests",
|
|
115
|
+
"tasks",
|
|
116
|
+
"helpers",
|
|
117
|
+
"globals",
|
|
118
|
+
"signals",
|
|
119
|
+
"intents",
|
|
120
|
+
"actors",
|
|
121
|
+
"routines",
|
|
122
|
+
"directionalTaskMaps",
|
|
123
|
+
"actorTaskMaps",
|
|
124
|
+
"taskToRoutineMaps",
|
|
125
|
+
"taskToHelperMaps",
|
|
126
|
+
"helperToHelperMaps",
|
|
127
|
+
"taskToGlobalMaps",
|
|
128
|
+
"helperToGlobalMaps",
|
|
129
|
+
"signalToTaskMaps",
|
|
130
|
+
"intentToTaskMaps"
|
|
131
|
+
];
|
|
108
132
|
function readHintValue(source, key) {
|
|
109
133
|
if (!source || typeof source !== "object") {
|
|
110
134
|
return void 0;
|
|
@@ -131,8 +155,80 @@ function stripLocalRoutinePersistenceHints(input) {
|
|
|
131
155
|
}
|
|
132
156
|
return context;
|
|
133
157
|
}
|
|
158
|
+
function summarizeQueryData(queryData) {
|
|
159
|
+
if (!queryData || typeof queryData !== "object") {
|
|
160
|
+
return void 0;
|
|
161
|
+
}
|
|
162
|
+
const summary = {};
|
|
163
|
+
if (queryData.data && typeof queryData.data === "object") {
|
|
164
|
+
summary.dataKeys = Object.keys(queryData.data).sort();
|
|
165
|
+
}
|
|
166
|
+
if (queryData.filter && typeof queryData.filter === "object") {
|
|
167
|
+
summary.filterKeys = Object.keys(queryData.filter).sort();
|
|
168
|
+
}
|
|
169
|
+
if (queryData.onConflict && typeof queryData.onConflict === "object") {
|
|
170
|
+
const onConflict = queryData.onConflict;
|
|
171
|
+
summary.onConflictTarget = Array.isArray(onConflict.target) ? [...onConflict.target] : onConflict.target ?? null;
|
|
172
|
+
}
|
|
173
|
+
return Object.keys(summary).length > 0 ? summary : void 0;
|
|
174
|
+
}
|
|
175
|
+
function sanitizeExecutionPersistenceContext(input) {
|
|
176
|
+
const context = stripLocalRoutinePersistenceHints(input);
|
|
177
|
+
for (const key of BULKY_EXECUTION_PERSISTENCE_KEYS) {
|
|
178
|
+
const value = context[key];
|
|
179
|
+
if (value === void 0) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const countKey = `${key}Count`;
|
|
183
|
+
if (context[countKey] === void 0) {
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
context[countKey] = value.length;
|
|
186
|
+
} else if (value && typeof value === "object") {
|
|
187
|
+
context[countKey] = Object.keys(value).length;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
delete context[key];
|
|
191
|
+
}
|
|
192
|
+
if (context.queryData && typeof context.queryData === "object") {
|
|
193
|
+
const queryDataSummary = summarizeQueryData(context.queryData);
|
|
194
|
+
if (queryDataSummary) {
|
|
195
|
+
context.queryData = queryDataSummary;
|
|
196
|
+
} else {
|
|
197
|
+
delete context.queryData;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return context;
|
|
201
|
+
}
|
|
202
|
+
function sanitizeExecutionPersistenceResultPayload(input) {
|
|
203
|
+
const payload = input && typeof input === "object" ? { ...input } : {};
|
|
204
|
+
const resultContext = payload.resultContext && typeof payload.resultContext === "object" ? sanitizeExecutionPersistenceContext(
|
|
205
|
+
payload.resultContext
|
|
206
|
+
) : payload.resultContext;
|
|
207
|
+
const metaResultContext = payload.metaResultContext && typeof payload.metaResultContext === "object" ? sanitizeExecutionPersistenceContext(
|
|
208
|
+
payload.metaResultContext
|
|
209
|
+
) : payload.metaResultContext;
|
|
210
|
+
const snakeResultContext = payload.result_context && typeof payload.result_context === "object" ? sanitizeExecutionPersistenceContext(
|
|
211
|
+
payload.result_context
|
|
212
|
+
) : payload.result_context;
|
|
213
|
+
const snakeMetaResultContext = payload.meta_result_context && typeof payload.meta_result_context === "object" ? sanitizeExecutionPersistenceContext(
|
|
214
|
+
payload.meta_result_context
|
|
215
|
+
) : payload.meta_result_context;
|
|
216
|
+
if (resultContext !== void 0) {
|
|
217
|
+
payload.resultContext = resultContext;
|
|
218
|
+
}
|
|
219
|
+
if (metaResultContext !== void 0) {
|
|
220
|
+
payload.metaResultContext = metaResultContext;
|
|
221
|
+
}
|
|
222
|
+
if (snakeResultContext !== void 0) {
|
|
223
|
+
payload.result_context = snakeResultContext;
|
|
224
|
+
}
|
|
225
|
+
if (snakeMetaResultContext !== void 0) {
|
|
226
|
+
payload.meta_result_context = snakeMetaResultContext;
|
|
227
|
+
}
|
|
228
|
+
return payload;
|
|
229
|
+
}
|
|
134
230
|
function splitRoutinePersistenceContext(input) {
|
|
135
|
-
const sanitized =
|
|
231
|
+
const sanitized = sanitizeExecutionPersistenceContext(input);
|
|
136
232
|
return {
|
|
137
233
|
context: Object.fromEntries(
|
|
138
234
|
Object.entries(sanitized).filter(([key]) => !key.startsWith("__"))
|
|
@@ -163,14 +259,55 @@ var ROOT_METADATA_PASSTHROUGH_KEYS = [
|
|
|
163
259
|
"__inquirySourceRoutineExecutionId"
|
|
164
260
|
];
|
|
165
261
|
var DELEGATION_REQUEST_SNAPSHOT_KEY = "__delegationRequestContext";
|
|
262
|
+
var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
263
|
+
"__remoteRoutineName",
|
|
264
|
+
"__serviceName",
|
|
265
|
+
"__timeout",
|
|
266
|
+
"__localTaskName",
|
|
267
|
+
"__localTaskVersion",
|
|
268
|
+
"__localServiceName",
|
|
269
|
+
"__localRoutineExecId",
|
|
270
|
+
"__previousTaskExecutionId",
|
|
271
|
+
"__fetchId",
|
|
272
|
+
"fetchId",
|
|
273
|
+
"__routeKey",
|
|
274
|
+
"routeKey",
|
|
275
|
+
"__instance",
|
|
276
|
+
"__transportId",
|
|
277
|
+
"__transportOrigin",
|
|
278
|
+
"__transportProtocols",
|
|
279
|
+
"__transportProtocol",
|
|
280
|
+
"__retries",
|
|
281
|
+
"__triedInstances",
|
|
282
|
+
"__delegationRequestContext",
|
|
283
|
+
"__metadata",
|
|
284
|
+
"serviceName",
|
|
285
|
+
"serviceInstanceId",
|
|
286
|
+
"serviceTransportId",
|
|
287
|
+
"serviceOrigin",
|
|
288
|
+
"transportProtocols",
|
|
289
|
+
"transportProtocol"
|
|
290
|
+
];
|
|
291
|
+
function isPlainObject(value) {
|
|
292
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const prototype = Object.getPrototypeOf(value);
|
|
296
|
+
return prototype === Object.prototype || prototype === null;
|
|
297
|
+
}
|
|
166
298
|
function cloneDelegationValue(value) {
|
|
299
|
+
if (value instanceof Date) {
|
|
300
|
+
return new Date(value.getTime());
|
|
301
|
+
}
|
|
167
302
|
if (Array.isArray(value)) {
|
|
168
|
-
return value.map(
|
|
169
|
-
(item) => item && typeof item === "object" ? { ...item } : item
|
|
170
|
-
);
|
|
303
|
+
return value.map((item) => cloneDelegationValue(item));
|
|
171
304
|
}
|
|
172
|
-
if (value
|
|
173
|
-
|
|
305
|
+
if (isPlainObject(value)) {
|
|
306
|
+
const clone = {};
|
|
307
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
308
|
+
clone[key] = cloneDelegationValue(nestedValue);
|
|
309
|
+
}
|
|
310
|
+
return clone;
|
|
174
311
|
}
|
|
175
312
|
return value;
|
|
176
313
|
}
|
|
@@ -206,9 +343,9 @@ function attachDelegationRequestSnapshot(input) {
|
|
|
206
343
|
function restoreDelegationRequestSnapshot(input) {
|
|
207
344
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
208
345
|
const mutableContext = context;
|
|
209
|
-
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
346
|
+
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY] ?? (mutableContext.__metadata && typeof mutableContext.__metadata === "object" ? mutableContext.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] : void 0);
|
|
210
347
|
const snapshot = snapshotCandidate && typeof snapshotCandidate === "object" ? snapshotCandidate : null;
|
|
211
|
-
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true;
|
|
348
|
+
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true || mutableContext.errored === true || mutableContext.failed === true || mutableContext.timedOut === true || mutableContext.__error !== void 0 || mutableContext.error !== void 0 || mutableContext.__inquiryMeta !== void 0;
|
|
212
349
|
if (!snapshot || !looksLikeDelegationResult) {
|
|
213
350
|
return context;
|
|
214
351
|
}
|
|
@@ -229,6 +366,26 @@ function stripDelegationRequestSnapshot(input) {
|
|
|
229
366
|
delete context[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
230
367
|
return context;
|
|
231
368
|
}
|
|
369
|
+
function buildDelegationFailureContext(signalName, input, error) {
|
|
370
|
+
const source = input && typeof input === "object" ? { ...input } : {};
|
|
371
|
+
const slimContext = {};
|
|
372
|
+
for (const key of DELEGATION_FAILURE_CONTEXT_KEYS) {
|
|
373
|
+
if (source[key] !== void 0) {
|
|
374
|
+
slimContext[key] = cloneDelegationValue(source[key]);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] === void 0 && source.__metadata && typeof source.__metadata === "object" && source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] !== void 0) {
|
|
378
|
+
slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] = cloneDelegationValue(
|
|
379
|
+
source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY]
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
__signalName: signalName,
|
|
384
|
+
__error: error instanceof Error ? error.message : String(error ?? "Unknown error"),
|
|
385
|
+
errored: true,
|
|
386
|
+
...slimContext
|
|
387
|
+
};
|
|
388
|
+
}
|
|
232
389
|
function stripTransportSelectionRoutingContext(input) {
|
|
233
390
|
const context = stripLocalRoutinePersistenceHints(
|
|
234
391
|
input && typeof input === "object" ? { ...input } : {}
|
|
@@ -260,6 +417,90 @@ function ensureDelegationContextMetadata(input) {
|
|
|
260
417
|
|
|
261
418
|
// src/graph/definition/DeputyTask.ts
|
|
262
419
|
var SERVICE_REGISTRY_TRACE_SERVICE = (process.env.CADENZA_SERVICE_REGISTRY_TRACE_SERVICE ?? "").trim();
|
|
420
|
+
function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
421
|
+
const task = this;
|
|
422
|
+
return new Promise((resolve, reject) => {
|
|
423
|
+
if (context.__metadata.__blockRemoteExecution) {
|
|
424
|
+
reject(new Error("Blocked remote execution"));
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (context.__metadata.__skipRemoteExecution) {
|
|
428
|
+
resolve(context);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const processId = (0, import_uuid2.v4)();
|
|
432
|
+
context.__metadata.__deputyExecId = processId;
|
|
433
|
+
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
434
|
+
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
435
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
436
|
+
localTaskName: context.__localTaskName ?? null,
|
|
437
|
+
remoteRoutineName: context.__remoteRoutineName ?? null,
|
|
438
|
+
targetServiceName: context.__serviceName ?? null,
|
|
439
|
+
deputyExecId: processId,
|
|
440
|
+
dataKeys: context.data && typeof context.data === "object" ? Object.keys(context.data) : [],
|
|
441
|
+
queryDataKeys: context.queryData && typeof context.queryData === "object" ? Object.keys(context.queryData) : [],
|
|
442
|
+
queryDataDataKeys: context.queryData?.data && typeof context.queryData.data === "object" ? Object.keys(context.queryData.data) : []
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
emit2("meta.deputy.delegation_requested", {
|
|
446
|
+
...context
|
|
447
|
+
});
|
|
448
|
+
CadenzaService.createEphemeralMetaTask(
|
|
449
|
+
`On progress deputy ${task.remoteRoutineName}`,
|
|
450
|
+
(ctx) => {
|
|
451
|
+
if (typeof progressCallback === "function" && ctx.progress) {
|
|
452
|
+
progressCallback(ctx.progress * ctx.weight);
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
`Ephemeral task for deputy process ${processId}`,
|
|
456
|
+
{
|
|
457
|
+
once: false,
|
|
458
|
+
destroyCondition: (ctx) => ctx.progress === 1 || ctx.progress === void 0,
|
|
459
|
+
register: false
|
|
460
|
+
}
|
|
461
|
+
).doOn(
|
|
462
|
+
`meta.socket_client.delegation_progress:${processId}`,
|
|
463
|
+
`meta.socket_client.delegated:${processId}`,
|
|
464
|
+
`meta.fetch.delegated:${processId}`,
|
|
465
|
+
`meta.service_registry.load_balance_failed:${processId}`
|
|
466
|
+
);
|
|
467
|
+
CadenzaService.createEphemeralMetaTask(
|
|
468
|
+
`Resolve deputy ${task.remoteRoutineName}`,
|
|
469
|
+
(responseCtx) => {
|
|
470
|
+
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
471
|
+
...context,
|
|
472
|
+
...responseCtx
|
|
473
|
+
} : responseCtx;
|
|
474
|
+
if (responseCtx?.errored) {
|
|
475
|
+
reject(new Error(responseCtx.__error));
|
|
476
|
+
} else {
|
|
477
|
+
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
478
|
+
console.log(
|
|
479
|
+
"[CADENZA_SERVICE_REGISTRY_TRACE] deputy_insert_service_instance_resolved",
|
|
480
|
+
{
|
|
481
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
482
|
+
targetServiceName: context.__serviceName ?? null,
|
|
483
|
+
resolverRequestId: context.__resolverRequestId ?? null,
|
|
484
|
+
serviceInstanceId: mergedResponseCtx && typeof mergedResponseCtx === "object" ? mergedResponseCtx.__serviceInstanceId ?? mergedResponseCtx.uuid ?? mergedResponseCtx.data?.uuid ?? null : null,
|
|
485
|
+
hasResolverQueryData: mergedResponseCtx && typeof mergedResponseCtx === "object" && mergedResponseCtx.__resolverQueryData !== void 0
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
490
|
+
delete mergedResponseCtx.__isDeputy;
|
|
491
|
+
}
|
|
492
|
+
resolve(mergedResponseCtx);
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
`Ephemeral resolver for deputy process ${processId}`,
|
|
496
|
+
{ register: false }
|
|
497
|
+
).doOn(
|
|
498
|
+
`meta.socket_client.delegated:${processId}`,
|
|
499
|
+
`meta.fetch.delegated:${processId}`,
|
|
500
|
+
`meta.service_registry.load_balance_failed:${processId}`
|
|
501
|
+
);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
263
504
|
var DeputyTask = class extends import_core.Task {
|
|
264
505
|
/**
|
|
265
506
|
* Constructs a new instance of the class with the specified parameters.
|
|
@@ -287,87 +528,9 @@ var DeputyTask = class extends import_core.Task {
|
|
|
287
528
|
* @return {void} This constructor does not return a value.
|
|
288
529
|
*/
|
|
289
530
|
constructor(name, remoteRoutineName, serviceName = void 0, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false, retryCount = 0, retryDelay = 0, retryDelayMax = 0, retryDelayFactor = 1) {
|
|
290
|
-
const taskFunction = (context, emit2, inquire, progressCallback) => {
|
|
291
|
-
return new Promise((resolve, reject) => {
|
|
292
|
-
if (context.__metadata.__blockRemoteExecution) {
|
|
293
|
-
reject(new Error("Blocked remote execution"));
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
if (context.__metadata.__skipRemoteExecution) {
|
|
297
|
-
resolve(context);
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
const processId = (0, import_uuid2.v4)();
|
|
301
|
-
context.__metadata.__deputyExecId = processId;
|
|
302
|
-
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
303
|
-
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
304
|
-
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
305
|
-
localTaskName: context.__localTaskName ?? null,
|
|
306
|
-
remoteRoutineName: context.__remoteRoutineName ?? null,
|
|
307
|
-
targetServiceName: context.__serviceName ?? null,
|
|
308
|
-
deputyExecId: processId,
|
|
309
|
-
dataKeys: context.data && typeof context.data === "object" ? Object.keys(context.data) : [],
|
|
310
|
-
queryDataKeys: context.queryData && typeof context.queryData === "object" ? Object.keys(context.queryData) : [],
|
|
311
|
-
queryDataDataKeys: context.queryData?.data && typeof context.queryData.data === "object" ? Object.keys(context.queryData.data) : []
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
emit2("meta.deputy.delegation_requested", {
|
|
315
|
-
...context
|
|
316
|
-
});
|
|
317
|
-
CadenzaService.createEphemeralMetaTask(
|
|
318
|
-
`On progress deputy ${this.remoteRoutineName}`,
|
|
319
|
-
(ctx) => {
|
|
320
|
-
if (ctx.progress) progressCallback(ctx.progress * ctx.weight);
|
|
321
|
-
},
|
|
322
|
-
`Ephemeral task for deputy process ${processId}`,
|
|
323
|
-
{
|
|
324
|
-
once: false,
|
|
325
|
-
destroyCondition: (ctx) => ctx.progress === 1 || ctx.progress === void 0,
|
|
326
|
-
register: false
|
|
327
|
-
}
|
|
328
|
-
).doOn(
|
|
329
|
-
`meta.socket_client.delegation_progress:${processId}`,
|
|
330
|
-
`meta.socket_client.delegated:${processId}`,
|
|
331
|
-
`meta.fetch.delegated:${processId}`,
|
|
332
|
-
`meta.service_registry.load_balance_failed:${processId}`
|
|
333
|
-
);
|
|
334
|
-
CadenzaService.createEphemeralMetaTask(
|
|
335
|
-
`Resolve deputy ${this.remoteRoutineName}`,
|
|
336
|
-
(responseCtx) => {
|
|
337
|
-
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
338
|
-
...context,
|
|
339
|
-
...responseCtx
|
|
340
|
-
} : responseCtx;
|
|
341
|
-
if (responseCtx?.errored) {
|
|
342
|
-
reject(new Error(responseCtx.__error));
|
|
343
|
-
} else {
|
|
344
|
-
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
345
|
-
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] deputy_insert_service_instance_resolved", {
|
|
346
|
-
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
347
|
-
targetServiceName: context.__serviceName ?? null,
|
|
348
|
-
resolverRequestId: context.__resolverRequestId ?? null,
|
|
349
|
-
serviceInstanceId: mergedResponseCtx && typeof mergedResponseCtx === "object" ? mergedResponseCtx.__serviceInstanceId ?? mergedResponseCtx.uuid ?? mergedResponseCtx.data?.uuid ?? null : null,
|
|
350
|
-
hasResolverQueryData: mergedResponseCtx && typeof mergedResponseCtx === "object" && mergedResponseCtx.__resolverQueryData !== void 0
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
354
|
-
delete mergedResponseCtx.__isDeputy;
|
|
355
|
-
}
|
|
356
|
-
resolve(mergedResponseCtx);
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
`Ephemeral resolver for deputy process ${processId}`,
|
|
360
|
-
{ register: false }
|
|
361
|
-
).doOn(
|
|
362
|
-
`meta.socket_client.delegated:${processId}`,
|
|
363
|
-
`meta.fetch.delegated:${processId}`,
|
|
364
|
-
`meta.service_registry.load_balance_failed:${processId}`
|
|
365
|
-
);
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
531
|
super(
|
|
369
532
|
name,
|
|
370
|
-
|
|
533
|
+
deputyTaskExecutor,
|
|
371
534
|
description,
|
|
372
535
|
concurrency,
|
|
373
536
|
timeout,
|
|
@@ -399,6 +562,11 @@ var DeputyTask = class extends import_core.Task {
|
|
|
399
562
|
communicationType: "delegation"
|
|
400
563
|
});
|
|
401
564
|
}
|
|
565
|
+
clone() {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`DeputyTask '${this.name}' does not support clone(). Create a new named deputy task or use a flow-specific meta task that performs an inquiry instead.`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
402
570
|
/**
|
|
403
571
|
* Executes the specified task function within the provided execution context.
|
|
404
572
|
*
|
|
@@ -442,12 +610,32 @@ var DeputyTask = class extends import_core.Task {
|
|
|
442
610
|
})
|
|
443
611
|
)
|
|
444
612
|
);
|
|
445
|
-
|
|
613
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
614
|
+
this,
|
|
615
|
+
deputyContext,
|
|
616
|
+
emit2,
|
|
617
|
+
inquire,
|
|
618
|
+
progressCallback
|
|
619
|
+
) : {
|
|
620
|
+
helpers: {},
|
|
621
|
+
globals: {}
|
|
622
|
+
};
|
|
623
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
624
|
+
};
|
|
625
|
+
return this.taskFunction(
|
|
626
|
+
deputyContext,
|
|
627
|
+
emit2,
|
|
628
|
+
inquire,
|
|
629
|
+
resolvedTools,
|
|
630
|
+
resolvedProgressCallback
|
|
631
|
+
);
|
|
446
632
|
}
|
|
447
633
|
};
|
|
448
634
|
|
|
449
635
|
// src/graph/definition/DatabaseTask.ts
|
|
450
636
|
var ACTOR_SESSION_TRACE_ENABLED = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
637
|
+
var actorSessionEmptyDelegationLogCount = 0;
|
|
638
|
+
var ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT = 40;
|
|
451
639
|
var INSTANCE_TRACE_ENABLED = process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true";
|
|
452
640
|
var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
453
641
|
"Insert execution_trace",
|
|
@@ -509,6 +697,11 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
509
697
|
);
|
|
510
698
|
this.queryData = queryData;
|
|
511
699
|
}
|
|
700
|
+
clone() {
|
|
701
|
+
throw new Error(
|
|
702
|
+
`DatabaseTask '${this.name}' does not support clone(). Create a new named database task or use a flow-specific meta task that performs the default database inquiry instead.`
|
|
703
|
+
);
|
|
704
|
+
}
|
|
512
705
|
/**
|
|
513
706
|
* Executes the specified task within the given context.
|
|
514
707
|
*
|
|
@@ -549,15 +742,16 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
549
742
|
}
|
|
550
743
|
delete ctx.__metadata;
|
|
551
744
|
const isResolverExecution = typeof ctx.__resolverRequestId === "string" && ctx.__resolverRequestId.length > 0;
|
|
552
|
-
const
|
|
745
|
+
const resolverQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : null;
|
|
746
|
+
const dynamicQueryData = resolverQueryData ?? (ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {});
|
|
553
747
|
delete ctx.queryData;
|
|
554
748
|
const nextQueryData = {
|
|
555
749
|
...this.queryData,
|
|
556
|
-
data: {
|
|
557
|
-
...ctx.data
|
|
558
|
-
},
|
|
559
750
|
...dynamicQueryData
|
|
560
751
|
};
|
|
752
|
+
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
753
|
+
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
754
|
+
}
|
|
561
755
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
562
756
|
stripDelegationRequestSnapshot(
|
|
563
757
|
hoistDelegationMetadataFields({
|
|
@@ -617,7 +811,41 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
617
811
|
rootKeys: Object.keys(rawContext)
|
|
618
812
|
});
|
|
619
813
|
}
|
|
620
|
-
|
|
814
|
+
if (this.remoteRoutineName === "Insert actor_session_state" && deputyContext.data === void 0 && deputyContext.queryData === void 0 && actorSessionEmptyDelegationLogCount < ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT) {
|
|
815
|
+
actorSessionEmptyDelegationLogCount += 1;
|
|
816
|
+
console.warn("[CADENZA_ACTOR_SESSION_EMPTY_DELEGATION]", {
|
|
817
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
818
|
+
localTaskName: this.name,
|
|
819
|
+
remoteRoutineName: this.remoteRoutineName,
|
|
820
|
+
hadSnapshotBeforeRestore: initialFullContext.__delegationRequestContext !== void 0 || initialFullContext.__metadata?.__delegationRequestContext !== void 0,
|
|
821
|
+
restoredRootKeys: Object.keys(rawContext),
|
|
822
|
+
deputyRootKeys: Object.keys(deputyContext),
|
|
823
|
+
signalName: rawContext.__signalName ?? rawContext.__metadata?.__signalName ?? null,
|
|
824
|
+
inquiryName: rawContext.__inquiryName ?? rawContext.__metadata?.__inquiryName ?? null,
|
|
825
|
+
sourceServiceName: rawContext.__localServiceName ?? rawContext.__metadata?.__localServiceName ?? null,
|
|
826
|
+
sourceRoutineName: rawContext.__routineName ?? rawContext.__metadata?.__routineName ?? null,
|
|
827
|
+
sourceTaskName: rawContext.__localTaskName ?? rawContext.__metadata?.__localTaskName ?? null
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
831
|
+
this,
|
|
832
|
+
deputyContext,
|
|
833
|
+
emit2,
|
|
834
|
+
inquire,
|
|
835
|
+
progressCallback
|
|
836
|
+
) : {
|
|
837
|
+
helpers: {},
|
|
838
|
+
globals: {}
|
|
839
|
+
};
|
|
840
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
841
|
+
};
|
|
842
|
+
return this.taskFunction(
|
|
843
|
+
deputyContext,
|
|
844
|
+
emit2,
|
|
845
|
+
inquire,
|
|
846
|
+
resolvedTools,
|
|
847
|
+
resolvedProgressCallback
|
|
848
|
+
);
|
|
621
849
|
}
|
|
622
850
|
};
|
|
623
851
|
|
|
@@ -656,14 +884,14 @@ var META_INTENT_PREFIX = "meta-";
|
|
|
656
884
|
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
657
885
|
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
658
886
|
var META_READINESS_INTENT = "meta-readiness";
|
|
659
|
-
function
|
|
887
|
+
function isPlainObject2(value) {
|
|
660
888
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
661
889
|
}
|
|
662
890
|
function deepMergeDeterministic(left, right) {
|
|
663
891
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
664
892
|
return [...left, ...right];
|
|
665
893
|
}
|
|
666
|
-
if (
|
|
894
|
+
if (isPlainObject2(left) && isPlainObject2(right)) {
|
|
667
895
|
const merged = { ...left };
|
|
668
896
|
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
669
897
|
for (const key of keys) {
|
|
@@ -907,6 +1135,10 @@ function normalizeServiceInstanceDescriptor(value) {
|
|
|
907
1135
|
return null;
|
|
908
1136
|
}
|
|
909
1137
|
const transports = normalizeTransportArray(raw.transports, uuid9);
|
|
1138
|
+
const leaseStatusRaw = normalizeString2(raw.leaseStatus ?? raw.lease_status);
|
|
1139
|
+
const leaseStatus = leaseStatusRaw === "active" || leaseStatusRaw === "non_responsive" || leaseStatusRaw === "inactive" || leaseStatusRaw === "deleted" ? leaseStatusRaw : void 0;
|
|
1140
|
+
const isActive = leaseStatus === "active" ? true : leaseStatus === "non_responsive" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : Boolean(raw.isActive ?? raw.is_active ?? true);
|
|
1141
|
+
const isNonResponsive = leaseStatus === "non_responsive" ? true : leaseStatus === "active" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : Boolean(raw.isNonResponsive ?? raw.is_non_responsive ?? false);
|
|
910
1142
|
return {
|
|
911
1143
|
uuid: uuid9,
|
|
912
1144
|
serviceName,
|
|
@@ -917,10 +1149,16 @@ function normalizeServiceInstanceDescriptor(value) {
|
|
|
917
1149
|
)
|
|
918
1150
|
),
|
|
919
1151
|
isPrimary: Boolean(raw.isPrimary ?? raw.is_primary ?? false),
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1152
|
+
leaseStatus,
|
|
1153
|
+
leaseExpiresAt: typeof raw.leaseExpiresAt === "string" ? raw.leaseExpiresAt : typeof raw.lease_expires_at === "string" ? raw.lease_expires_at : void 0,
|
|
1154
|
+
lastLeaseRenewedAt: typeof raw.lastLeaseRenewedAt === "string" ? raw.lastLeaseRenewedAt : typeof raw.last_lease_renewed_at === "string" ? raw.last_lease_renewed_at : void 0,
|
|
1155
|
+
isReady: typeof raw.isReady === "boolean" ? raw.isReady : typeof raw.is_ready === "boolean" ? raw.is_ready : void 0,
|
|
1156
|
+
readinessReason: typeof raw.readinessReason === "string" ? raw.readinessReason : typeof raw.readiness_reason === "string" ? raw.readiness_reason : null,
|
|
1157
|
+
lastReadyAt: typeof raw.lastReadyAt === "string" ? raw.lastReadyAt : typeof raw.last_ready_at === "string" ? raw.last_ready_at : null,
|
|
1158
|
+
lastObservedTransportAt: typeof raw.lastObservedTransportAt === "string" ? raw.lastObservedTransportAt : typeof raw.last_observed_transport_at === "string" ? raw.last_observed_transport_at : null,
|
|
1159
|
+
shutdownRequestedAt: typeof raw.shutdownRequestedAt === "string" ? raw.shutdownRequestedAt : typeof raw.shutdown_requested_at === "string" ? raw.shutdown_requested_at : null,
|
|
1160
|
+
isActive,
|
|
1161
|
+
isNonResponsive,
|
|
924
1162
|
isBlocked: Boolean(raw.isBlocked ?? raw.is_blocked ?? false),
|
|
925
1163
|
runtimeState: raw.runtimeState === "healthy" || raw.runtimeState === "degraded" || raw.runtimeState === "overloaded" || raw.runtimeState === "unavailable" ? raw.runtimeState : void 0,
|
|
926
1164
|
acceptingWork: typeof raw.acceptingWork === "boolean" ? raw.acceptingWork : void 0,
|
|
@@ -1373,6 +1611,61 @@ function resolveHealthMetric(input, keys) {
|
|
|
1373
1611
|
}
|
|
1374
1612
|
return void 0;
|
|
1375
1613
|
}
|
|
1614
|
+
function sanitizeRuntimeMetricsHealthDetail(value) {
|
|
1615
|
+
if (!value || typeof value !== "object") {
|
|
1616
|
+
return void 0;
|
|
1617
|
+
}
|
|
1618
|
+
const input = value;
|
|
1619
|
+
const sampledAt = typeof input.sampledAt === "string" && input.sampledAt.trim().length > 0 ? input.sampledAt : void 0;
|
|
1620
|
+
const cpuUsage = normalizeOptionalMetric(input.cpuUsage ?? input.cpu ?? input.cpuLoad);
|
|
1621
|
+
const memoryUsage = normalizeOptionalMetric(
|
|
1622
|
+
input.memoryUsage ?? input.memory ?? input.memoryPressure
|
|
1623
|
+
);
|
|
1624
|
+
const eventLoopLag = normalizeOptionalMetric(
|
|
1625
|
+
input.eventLoopLag ?? input.eventLoopLagMs
|
|
1626
|
+
);
|
|
1627
|
+
const rssBytes = normalizeOptionalMetric(input.rssBytes);
|
|
1628
|
+
const heapUsedBytes = normalizeOptionalMetric(input.heapUsedBytes);
|
|
1629
|
+
const heapTotalBytes = normalizeOptionalMetric(input.heapTotalBytes);
|
|
1630
|
+
const memoryLimitBytes = normalizeOptionalMetric(input.memoryLimitBytes);
|
|
1631
|
+
if (sampledAt === void 0 && cpuUsage === void 0 && memoryUsage === void 0 && eventLoopLag === void 0 && rssBytes === void 0 && heapUsedBytes === void 0 && heapTotalBytes === void 0 && memoryLimitBytes === void 0) {
|
|
1632
|
+
return void 0;
|
|
1633
|
+
}
|
|
1634
|
+
return {
|
|
1635
|
+
...sampledAt !== void 0 ? { sampledAt } : {},
|
|
1636
|
+
...cpuUsage !== void 0 ? { cpuUsage } : {},
|
|
1637
|
+
...memoryUsage !== void 0 ? { memoryUsage } : {},
|
|
1638
|
+
...eventLoopLag !== void 0 ? { eventLoopLag } : {},
|
|
1639
|
+
...rssBytes !== void 0 ? { rssBytes } : {},
|
|
1640
|
+
...heapUsedBytes !== void 0 ? { heapUsedBytes } : {},
|
|
1641
|
+
...heapTotalBytes !== void 0 ? { heapTotalBytes } : {},
|
|
1642
|
+
...memoryLimitBytes !== void 0 ? { memoryLimitBytes } : {}
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
function sanitizeAuthorityRuntimeStatusHealth(health, options) {
|
|
1646
|
+
const input = health && typeof health === "object" ? health : {};
|
|
1647
|
+
const cpuUsage = options?.cpuUsage !== void 0 ? options.cpuUsage : normalizeOptionalMetric(input.cpuUsage ?? input.cpu ?? input.cpuLoad);
|
|
1648
|
+
const memoryUsage = options?.memoryUsage !== void 0 ? options.memoryUsage : normalizeOptionalMetric(
|
|
1649
|
+
input.memoryUsage ?? input.memory ?? input.memoryPressure
|
|
1650
|
+
);
|
|
1651
|
+
const eventLoopLag = options?.eventLoopLag !== void 0 ? options.eventLoopLag : normalizeOptionalMetric(input.eventLoopLag ?? input.eventLoopLagMs);
|
|
1652
|
+
const runtimeMetrics = sanitizeRuntimeMetricsHealthDetail(input.runtimeMetrics);
|
|
1653
|
+
const runtimeStatus = options?.state || options?.reportedAt || typeof options?.acceptingWork === "boolean" ? {
|
|
1654
|
+
...options?.state ? { state: options.state } : {},
|
|
1655
|
+
...typeof options?.acceptingWork === "boolean" ? { acceptingWork: options.acceptingWork } : {},
|
|
1656
|
+
...options?.reportedAt ? { reportedAt: options.reportedAt } : {}
|
|
1657
|
+
} : void 0;
|
|
1658
|
+
if (cpuUsage === void 0 && memoryUsage === void 0 && eventLoopLag === void 0 && !runtimeMetrics && !runtimeStatus) {
|
|
1659
|
+
return void 0;
|
|
1660
|
+
}
|
|
1661
|
+
return {
|
|
1662
|
+
...cpuUsage !== void 0 ? { cpuUsage } : {},
|
|
1663
|
+
...memoryUsage !== void 0 ? { memoryUsage } : {},
|
|
1664
|
+
...eventLoopLag !== void 0 ? { eventLoopLag } : {},
|
|
1665
|
+
...runtimeMetrics ? { runtimeMetrics } : {},
|
|
1666
|
+
...runtimeStatus ? { runtimeStatus } : {}
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1376
1669
|
function normalizeAuthorityRuntimeStatusReport(input) {
|
|
1377
1670
|
if (!input || typeof input !== "object") {
|
|
1378
1671
|
return null;
|
|
@@ -1401,6 +1694,17 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1401
1694
|
(protocol) => protocol === "rest" || protocol === "socket"
|
|
1402
1695
|
) : [];
|
|
1403
1696
|
const transportProtocols = transportProtocolList.length > 0 ? Array.from(new Set(transportProtocolList)) : void 0;
|
|
1697
|
+
const acceptingWork = Boolean(input.acceptingWork ?? input.accepting_work);
|
|
1698
|
+
const cpuUsage = resolveHealthMetric(input, ["cpuUsage", "cpu", "cpuLoad"]);
|
|
1699
|
+
const memoryUsage = resolveHealthMetric(input, [
|
|
1700
|
+
"memoryUsage",
|
|
1701
|
+
"memory",
|
|
1702
|
+
"memoryPressure"
|
|
1703
|
+
]);
|
|
1704
|
+
const eventLoopLag = resolveHealthMetric(input, [
|
|
1705
|
+
"eventLoopLag",
|
|
1706
|
+
"eventLoopLagMs"
|
|
1707
|
+
]);
|
|
1404
1708
|
return {
|
|
1405
1709
|
serviceName,
|
|
1406
1710
|
serviceInstanceId,
|
|
@@ -1411,7 +1715,7 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1411
1715
|
isFrontend: typeof input.isFrontend === "boolean" ? input.isFrontend : typeof input.is_frontend === "boolean" ? input.is_frontend : void 0,
|
|
1412
1716
|
reportedAt,
|
|
1413
1717
|
state,
|
|
1414
|
-
acceptingWork
|
|
1718
|
+
acceptingWork,
|
|
1415
1719
|
numberOfRunningGraphs: Math.max(
|
|
1416
1720
|
0,
|
|
1417
1721
|
Math.trunc(
|
|
@@ -1420,22 +1724,22 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1420
1724
|
) || 0
|
|
1421
1725
|
)
|
|
1422
1726
|
),
|
|
1423
|
-
cpuUsage
|
|
1424
|
-
memoryUsage
|
|
1425
|
-
|
|
1426
|
-
"memory",
|
|
1427
|
-
"memoryPressure"
|
|
1428
|
-
]),
|
|
1429
|
-
eventLoopLag: resolveHealthMetric(input, [
|
|
1430
|
-
"eventLoopLag",
|
|
1431
|
-
"eventLoopLagMs"
|
|
1432
|
-
]),
|
|
1727
|
+
cpuUsage,
|
|
1728
|
+
memoryUsage,
|
|
1729
|
+
eventLoopLag,
|
|
1433
1730
|
isActive: Boolean(input.isActive ?? input.is_active ?? true),
|
|
1434
1731
|
isNonResponsive: Boolean(
|
|
1435
1732
|
input.isNonResponsive ?? input.is_non_responsive ?? false
|
|
1436
1733
|
),
|
|
1437
1734
|
isBlocked: Boolean(input.isBlocked ?? input.is_blocked ?? false),
|
|
1438
|
-
health: input.health
|
|
1735
|
+
health: sanitizeAuthorityRuntimeStatusHealth(input.health, {
|
|
1736
|
+
state,
|
|
1737
|
+
acceptingWork,
|
|
1738
|
+
reportedAt,
|
|
1739
|
+
cpuUsage,
|
|
1740
|
+
memoryUsage,
|
|
1741
|
+
eventLoopLag
|
|
1742
|
+
})
|
|
1439
1743
|
};
|
|
1440
1744
|
}
|
|
1441
1745
|
function buildAuthorityRuntimeStatusSignature(report) {
|
|
@@ -1448,18 +1752,53 @@ function buildAuthorityRuntimeStatusSignature(report) {
|
|
|
1448
1752
|
transportProtocols: report.transportProtocols ?? [],
|
|
1449
1753
|
state: report.state,
|
|
1450
1754
|
acceptingWork: report.acceptingWork,
|
|
1451
|
-
numberOfRunningGraphs: report.numberOfRunningGraphs,
|
|
1452
|
-
cpuUsage: report.cpuUsage ?? null,
|
|
1453
|
-
memoryUsage: report.memoryUsage ?? null,
|
|
1454
|
-
eventLoopLag: report.eventLoopLag ?? null,
|
|
1455
1755
|
isActive: report.isActive,
|
|
1456
1756
|
isNonResponsive: report.isNonResponsive,
|
|
1457
1757
|
isBlocked: report.isBlocked,
|
|
1458
|
-
isFrontend: report.isFrontend ?? null
|
|
1459
|
-
health: report.health ?? {}
|
|
1758
|
+
isFrontend: report.isFrontend ?? null
|
|
1460
1759
|
});
|
|
1461
1760
|
}
|
|
1462
1761
|
|
|
1762
|
+
// src/registry/runtimeJitter.ts
|
|
1763
|
+
function normalizeKey(key) {
|
|
1764
|
+
return key.trim() || "default";
|
|
1765
|
+
}
|
|
1766
|
+
function hashKeyToUnitInterval(key) {
|
|
1767
|
+
const normalizedKey = normalizeKey(key);
|
|
1768
|
+
let hash = 2166136261;
|
|
1769
|
+
for (let index = 0; index < normalizedKey.length; index += 1) {
|
|
1770
|
+
hash ^= normalizedKey.charCodeAt(index);
|
|
1771
|
+
hash = Math.imul(hash, 16777619);
|
|
1772
|
+
}
|
|
1773
|
+
return (hash >>> 0) / 4294967295;
|
|
1774
|
+
}
|
|
1775
|
+
function normalizeJitterRatio(value) {
|
|
1776
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
1777
|
+
return 0;
|
|
1778
|
+
}
|
|
1779
|
+
return Math.min(value, 1);
|
|
1780
|
+
}
|
|
1781
|
+
function buildDeterministicJitterOffsetMs(baseMs, ratio, key) {
|
|
1782
|
+
if (!Number.isFinite(baseMs) || baseMs <= 0) {
|
|
1783
|
+
return 0;
|
|
1784
|
+
}
|
|
1785
|
+
const normalizedRatio = normalizeJitterRatio(ratio);
|
|
1786
|
+
if (normalizedRatio <= 0) {
|
|
1787
|
+
return 0;
|
|
1788
|
+
}
|
|
1789
|
+
const maxOffsetMs = Math.round(baseMs * normalizedRatio);
|
|
1790
|
+
if (maxOffsetMs <= 0) {
|
|
1791
|
+
return 0;
|
|
1792
|
+
}
|
|
1793
|
+
return Math.round(hashKeyToUnitInterval(key) * maxOffsetMs);
|
|
1794
|
+
}
|
|
1795
|
+
function buildDeterministicJitteredDelayMs(baseMs, ratio, key) {
|
|
1796
|
+
return Math.max(
|
|
1797
|
+
0,
|
|
1798
|
+
Math.round(baseMs) + buildDeterministicJitterOffsetMs(baseMs, ratio, key)
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1463
1802
|
// src/registry/serviceManifestContract.ts
|
|
1464
1803
|
var AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT = "meta-service-registry-authority-service-manifest-report";
|
|
1465
1804
|
var AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL = "global.meta.cadenza_db.service_manifest_updated";
|
|
@@ -1485,16 +1824,23 @@ function normalizeServiceManifestSnapshot(input) {
|
|
|
1485
1824
|
revision,
|
|
1486
1825
|
manifestHash,
|
|
1487
1826
|
publishedAt,
|
|
1827
|
+
publicationLayer: record.publicationLayer === "routing_capability" || record.publicationLayer === "business_structural" || record.publicationLayer === "local_meta_structural" ? record.publicationLayer : "business_structural",
|
|
1488
1828
|
tasks: normalizeArray(record.tasks),
|
|
1489
1829
|
signals: normalizeArray(record.signals),
|
|
1490
1830
|
intents: normalizeArray(record.intents),
|
|
1491
1831
|
actors: normalizeArray(record.actors),
|
|
1492
1832
|
routines: normalizeArray(record.routines),
|
|
1833
|
+
helpers: normalizeArray(record.helpers),
|
|
1834
|
+
globals: normalizeArray(record.globals),
|
|
1493
1835
|
directionalTaskMaps: normalizeArray(record.directionalTaskMaps),
|
|
1494
1836
|
signalToTaskMaps: normalizeArray(record.signalToTaskMaps),
|
|
1495
1837
|
intentToTaskMaps: normalizeArray(record.intentToTaskMaps),
|
|
1496
1838
|
actorTaskMaps: normalizeArray(record.actorTaskMaps),
|
|
1497
|
-
taskToRoutineMaps: normalizeArray(record.taskToRoutineMaps)
|
|
1839
|
+
taskToRoutineMaps: normalizeArray(record.taskToRoutineMaps),
|
|
1840
|
+
taskToHelperMaps: normalizeArray(record.taskToHelperMaps),
|
|
1841
|
+
helperToHelperMaps: normalizeArray(record.helperToHelperMaps),
|
|
1842
|
+
taskToGlobalMaps: normalizeArray(record.taskToGlobalMaps),
|
|
1843
|
+
helperToGlobalMaps: normalizeArray(record.helperToGlobalMaps)
|
|
1498
1844
|
};
|
|
1499
1845
|
}
|
|
1500
1846
|
function selectLatestServiceManifestSnapshots(snapshots) {
|
|
@@ -1614,6 +1960,7 @@ function decomposeSignalName(signalName) {
|
|
|
1614
1960
|
}
|
|
1615
1961
|
|
|
1616
1962
|
// src/registry/serviceManifest.ts
|
|
1963
|
+
var import_core2 = __toESM(require("@cadenza.io/core"));
|
|
1617
1964
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
1618
1965
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
1619
1966
|
if (typeof taskFunction !== "function") {
|
|
@@ -1757,15 +2104,90 @@ function buildRoutineDefinition(routine, serviceName) {
|
|
|
1757
2104
|
is_meta: routine.isMeta === true
|
|
1758
2105
|
};
|
|
1759
2106
|
}
|
|
2107
|
+
function buildHelperDefinition(helper, serviceName) {
|
|
2108
|
+
return {
|
|
2109
|
+
name: helper.name,
|
|
2110
|
+
version: helper.version,
|
|
2111
|
+
description: helper.description,
|
|
2112
|
+
service_name: serviceName,
|
|
2113
|
+
is_meta: helper.isMeta === true,
|
|
2114
|
+
handler_source: helper.helperFunction.toString(),
|
|
2115
|
+
language: "js"
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
function buildGlobalDefinition(globalDefinition, serviceName) {
|
|
2119
|
+
return {
|
|
2120
|
+
name: globalDefinition.name,
|
|
2121
|
+
version: globalDefinition.version,
|
|
2122
|
+
description: globalDefinition.description,
|
|
2123
|
+
service_name: serviceName,
|
|
2124
|
+
is_meta: globalDefinition.isMeta === true,
|
|
2125
|
+
value: sanitizeManifestValue(globalDefinition.value)
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
1760
2128
|
function shouldExportTask(task) {
|
|
1761
|
-
return !task.isDeputy && !task.isEphemeral;
|
|
2129
|
+
return task.register !== false && task.isHidden !== true && !task.isDeputy && !task.isEphemeral;
|
|
1762
2130
|
}
|
|
1763
2131
|
function shouldExportRoutine(routine) {
|
|
1764
2132
|
return Boolean(String(routine?.name ?? "").trim());
|
|
1765
2133
|
}
|
|
2134
|
+
function buildTaskKey(task) {
|
|
2135
|
+
return `${task.service_name}|${task.name}|${task.version}`;
|
|
2136
|
+
}
|
|
2137
|
+
function buildActorKey(actor) {
|
|
2138
|
+
return `${actor.service_name}|${actor.name}|${actor.version}`;
|
|
2139
|
+
}
|
|
2140
|
+
function buildRoutineKey(routine) {
|
|
2141
|
+
return `${routine.service_name}|${routine.name}|${routine.version}`;
|
|
2142
|
+
}
|
|
2143
|
+
function buildHelperKey(helper) {
|
|
2144
|
+
return `${helper.service_name}|${helper.name}|${helper.version}`;
|
|
2145
|
+
}
|
|
2146
|
+
function buildGlobalKey(globalDefinition) {
|
|
2147
|
+
return `${globalDefinition.service_name}|${globalDefinition.name}|${globalDefinition.version}`;
|
|
2148
|
+
}
|
|
2149
|
+
function listManifestTasks() {
|
|
2150
|
+
const registryTasks = Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
2151
|
+
(task) => Boolean(task)
|
|
2152
|
+
);
|
|
2153
|
+
const cachedTasks = Array.from(
|
|
2154
|
+
import_core2.default.taskCache?.values?.() ?? []
|
|
2155
|
+
).filter((task) => Boolean(task));
|
|
2156
|
+
return Array.from(
|
|
2157
|
+
new Map(
|
|
2158
|
+
[...registryTasks, ...cachedTasks].map((task) => [task.name, task])
|
|
2159
|
+
).values()
|
|
2160
|
+
);
|
|
2161
|
+
}
|
|
2162
|
+
function listManifestHelpers() {
|
|
2163
|
+
const toolRuntime = CadenzaService;
|
|
2164
|
+
return (toolRuntime.getAllHelpers?.() ?? []).filter(
|
|
2165
|
+
(helper) => Boolean(helper && !helper.destroyed)
|
|
2166
|
+
);
|
|
2167
|
+
}
|
|
2168
|
+
function listManifestGlobals() {
|
|
2169
|
+
const toolRuntime = CadenzaService;
|
|
2170
|
+
return (toolRuntime.getAllGlobals?.() ?? []).filter(
|
|
2171
|
+
(globalDefinition) => Boolean(globalDefinition && !globalDefinition.destroyed)
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
function isRoutingCriticalMetaSignal(_signal) {
|
|
2175
|
+
return false;
|
|
2176
|
+
}
|
|
2177
|
+
function isRoutingCriticalMetaIntent(_intent) {
|
|
2178
|
+
return false;
|
|
2179
|
+
}
|
|
1766
2180
|
function buildServiceManifestSnapshot(params) {
|
|
1767
|
-
const {
|
|
1768
|
-
|
|
2181
|
+
const {
|
|
2182
|
+
serviceName,
|
|
2183
|
+
serviceInstanceId,
|
|
2184
|
+
revision,
|
|
2185
|
+
publishedAt,
|
|
2186
|
+
publicationLayer = "business_structural"
|
|
2187
|
+
} = params;
|
|
2188
|
+
const tasks = listManifestTasks().filter(shouldExportTask);
|
|
2189
|
+
const helpers = listManifestHelpers();
|
|
2190
|
+
const globals = listManifestGlobals();
|
|
1769
2191
|
const routines = Array.from(CadenzaService.registry.routines.values()).filter((routine) => Boolean(routine)).filter(shouldExportRoutine);
|
|
1770
2192
|
const actors = CadenzaService.getAllActors();
|
|
1771
2193
|
const taskDefinitions = tasks.map((task) => buildTaskDefinition(task, serviceName)).sort(
|
|
@@ -1777,6 +2199,10 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1777
2199
|
const directionalTaskMaps = /* @__PURE__ */ new Map();
|
|
1778
2200
|
const actorTaskMaps = /* @__PURE__ */ new Map();
|
|
1779
2201
|
const taskToRoutineMaps = /* @__PURE__ */ new Map();
|
|
2202
|
+
const helperTaskMaps = /* @__PURE__ */ new Map();
|
|
2203
|
+
const helperHelperMaps = /* @__PURE__ */ new Map();
|
|
2204
|
+
const taskGlobalMaps = /* @__PURE__ */ new Map();
|
|
2205
|
+
const helperGlobalMaps = /* @__PURE__ */ new Map();
|
|
1780
2206
|
const registerSignal = (signalName) => {
|
|
1781
2207
|
const normalizedSignalName = canonicalizeSignalName(signalName);
|
|
1782
2208
|
if (!normalizedSignalName || signalDefinitions.has(normalizedSignalName)) {
|
|
@@ -1860,6 +2286,37 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1860
2286
|
is_meta: actorTaskMetadata.actorKind === "meta" || task.isMeta === true
|
|
1861
2287
|
});
|
|
1862
2288
|
}
|
|
2289
|
+
const taskTools = task;
|
|
2290
|
+
for (const [alias, helperName] of taskTools.helperAliases?.entries?.() ?? []) {
|
|
2291
|
+
const helper = CadenzaService.getHelper?.(helperName);
|
|
2292
|
+
if (!helper) {
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
const key = `${task.name}|${task.version}|${alias}|${helper.name}|${helper.version}|${serviceName}`;
|
|
2296
|
+
helperTaskMaps.set(key, {
|
|
2297
|
+
task_name: task.name,
|
|
2298
|
+
task_version: task.version,
|
|
2299
|
+
service_name: serviceName,
|
|
2300
|
+
alias,
|
|
2301
|
+
helper_name: helper.name,
|
|
2302
|
+
helper_version: helper.version
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
for (const [alias, globalName] of taskTools.globalAliases?.entries?.() ?? []) {
|
|
2306
|
+
const globalDefinition = CadenzaService.getGlobal?.(globalName);
|
|
2307
|
+
if (!globalDefinition) {
|
|
2308
|
+
continue;
|
|
2309
|
+
}
|
|
2310
|
+
const key = `${task.name}|${task.version}|${alias}|${globalDefinition.name}|${globalDefinition.version}|${serviceName}`;
|
|
2311
|
+
taskGlobalMaps.set(key, {
|
|
2312
|
+
task_name: task.name,
|
|
2313
|
+
task_version: task.version,
|
|
2314
|
+
service_name: serviceName,
|
|
2315
|
+
alias,
|
|
2316
|
+
global_name: globalDefinition.name,
|
|
2317
|
+
global_version: globalDefinition.version
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
1863
2320
|
}
|
|
1864
2321
|
const intentDefinitions = Array.from(CadenzaService.inquiryBroker.intents.values()).map((intent) => {
|
|
1865
2322
|
const intentRecord = intent;
|
|
@@ -1891,6 +2348,44 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1891
2348
|
).sort(
|
|
1892
2349
|
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
1893
2350
|
);
|
|
2351
|
+
const helperDefinitions = helpers.map((helper) => buildHelperDefinition(helper, serviceName)).sort(
|
|
2352
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2353
|
+
);
|
|
2354
|
+
const globalDefinitions = globals.map((globalDefinition) => buildGlobalDefinition(globalDefinition, serviceName)).sort(
|
|
2355
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2356
|
+
);
|
|
2357
|
+
for (const helper of helpers) {
|
|
2358
|
+
for (const [alias, dependencyHelperName] of helper.helperAliases.entries()) {
|
|
2359
|
+
const dependencyHelper = CadenzaService.getHelper?.(dependencyHelperName);
|
|
2360
|
+
if (!dependencyHelper) {
|
|
2361
|
+
continue;
|
|
2362
|
+
}
|
|
2363
|
+
const key = `${helper.name}|${helper.version}|${alias}|${dependencyHelper.name}|${dependencyHelper.version}|${serviceName}`;
|
|
2364
|
+
helperHelperMaps.set(key, {
|
|
2365
|
+
helper_name: helper.name,
|
|
2366
|
+
helper_version: helper.version,
|
|
2367
|
+
service_name: serviceName,
|
|
2368
|
+
alias,
|
|
2369
|
+
dependency_helper_name: dependencyHelper.name,
|
|
2370
|
+
dependency_helper_version: dependencyHelper.version
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
for (const [alias, globalName] of helper.globalAliases.entries()) {
|
|
2374
|
+
const globalDefinition = CadenzaService.getGlobal?.(globalName);
|
|
2375
|
+
if (!globalDefinition) {
|
|
2376
|
+
continue;
|
|
2377
|
+
}
|
|
2378
|
+
const key = `${helper.name}|${helper.version}|${alias}|${globalDefinition.name}|${globalDefinition.version}|${serviceName}`;
|
|
2379
|
+
helperGlobalMaps.set(key, {
|
|
2380
|
+
helper_name: helper.name,
|
|
2381
|
+
helper_version: helper.version,
|
|
2382
|
+
service_name: serviceName,
|
|
2383
|
+
alias,
|
|
2384
|
+
global_name: globalDefinition.name,
|
|
2385
|
+
global_version: globalDefinition.version
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
1894
2389
|
for (const routine of routines) {
|
|
1895
2390
|
for (const task of routine.tasks) {
|
|
1896
2391
|
if (!task) {
|
|
@@ -1913,59 +2408,524 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1913
2408
|
}
|
|
1914
2409
|
}
|
|
1915
2410
|
}
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
)
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
)
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
(
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2411
|
+
const taskDefinitionsByKey = new Map(
|
|
2412
|
+
taskDefinitions.map((task) => [buildTaskKey(task), task])
|
|
2413
|
+
);
|
|
2414
|
+
const signalDefinitionsByName = new Map(
|
|
2415
|
+
Array.from(signalDefinitions.values()).map((signal) => [signal.name, signal])
|
|
2416
|
+
);
|
|
2417
|
+
const intentDefinitionsByName = new Map(
|
|
2418
|
+
intentDefinitions.map((intent) => [intent.name, intent])
|
|
2419
|
+
);
|
|
2420
|
+
const actorDefinitionsByKey = new Map(
|
|
2421
|
+
actorDefinitions.map((actor) => [buildActorKey(actor), actor])
|
|
2422
|
+
);
|
|
2423
|
+
const routineDefinitionsByKey = new Map(
|
|
2424
|
+
routineDefinitions.map((routine) => [buildRoutineKey(routine), routine])
|
|
2425
|
+
);
|
|
2426
|
+
const helperDefinitionsByKey = new Map(
|
|
2427
|
+
helperDefinitions.map((helper) => [buildHelperKey(helper), helper])
|
|
2428
|
+
);
|
|
2429
|
+
const globalDefinitionsByKey = new Map(
|
|
2430
|
+
globalDefinitions.map((globalDefinition) => [
|
|
2431
|
+
buildGlobalKey(globalDefinition),
|
|
2432
|
+
globalDefinition
|
|
2433
|
+
])
|
|
2434
|
+
);
|
|
2435
|
+
const routingTaskKeys = /* @__PURE__ */ new Set();
|
|
2436
|
+
const routingSignalNames = /* @__PURE__ */ new Set();
|
|
2437
|
+
const routingIntentNames = /* @__PURE__ */ new Set();
|
|
2438
|
+
const publishedSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => {
|
|
2439
|
+
const signal = signalDefinitionsByName.get(map.signal_name);
|
|
2440
|
+
return signal?.is_meta !== true || (signal ? isRoutingCriticalMetaSignal(signal) : false);
|
|
2441
|
+
}).sort(
|
|
2442
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2443
|
+
`${right.signal_name}:${right.task_name}`
|
|
2444
|
+
)
|
|
2445
|
+
);
|
|
2446
|
+
const publishedIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => {
|
|
2447
|
+
const intent = intentDefinitionsByName.get(map.intent_name);
|
|
2448
|
+
return intent?.is_meta !== true || (intent ? isRoutingCriticalMetaIntent(intent) : false);
|
|
2449
|
+
}).sort(
|
|
2450
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2451
|
+
`${right.intent_name}:${right.task_name}`
|
|
2452
|
+
)
|
|
2453
|
+
);
|
|
2454
|
+
const localMetaSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => !publishedSignalTaskMaps.includes(map)).sort(
|
|
2455
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2456
|
+
`${right.signal_name}:${right.task_name}`
|
|
2457
|
+
)
|
|
2458
|
+
);
|
|
2459
|
+
const localMetaIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => !publishedIntentTaskMaps.includes(map)).sort(
|
|
2460
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2461
|
+
`${right.intent_name}:${right.task_name}`
|
|
2462
|
+
)
|
|
2463
|
+
);
|
|
2464
|
+
for (const map of publishedSignalTaskMaps) {
|
|
2465
|
+
routingTaskKeys.add(
|
|
2466
|
+
buildTaskKey({
|
|
2467
|
+
service_name: map.service_name,
|
|
2468
|
+
name: map.task_name,
|
|
2469
|
+
version: map.task_version
|
|
2470
|
+
})
|
|
2471
|
+
);
|
|
2472
|
+
routingSignalNames.add(map.signal_name);
|
|
2473
|
+
}
|
|
2474
|
+
for (const map of publishedIntentTaskMaps) {
|
|
2475
|
+
routingTaskKeys.add(
|
|
2476
|
+
buildTaskKey({
|
|
2477
|
+
service_name: map.service_name,
|
|
2478
|
+
name: map.task_name,
|
|
2479
|
+
version: map.task_version
|
|
2480
|
+
})
|
|
2481
|
+
);
|
|
2482
|
+
routingIntentNames.add(map.intent_name);
|
|
2483
|
+
}
|
|
2484
|
+
const routingTasks = Array.from(routingTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter((task) => task !== null).sort(
|
|
2485
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2486
|
+
);
|
|
2487
|
+
const routingSignals = Array.from(routingSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter((signal) => signal !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2488
|
+
const routingIntents = Array.from(routingIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter((intent) => intent !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2489
|
+
const businessTasks = taskDefinitions.filter((task) => task.is_meta !== true && task.is_sub_meta !== true).sort(
|
|
2490
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2491
|
+
);
|
|
2492
|
+
const businessSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2493
|
+
const businessIntents = intentDefinitions.filter((intent) => intent.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2494
|
+
const businessActors = actorDefinitions.filter((actor) => actor.is_meta !== true).sort(
|
|
2495
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2496
|
+
);
|
|
2497
|
+
const businessRoutines = routineDefinitions.filter((routine) => routine.is_meta !== true).sort(
|
|
2498
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2499
|
+
);
|
|
2500
|
+
const businessDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => {
|
|
2501
|
+
const predecessor = taskDefinitionsByKey.get(
|
|
2502
|
+
buildTaskKey({
|
|
2503
|
+
service_name: map.predecessor_service_name,
|
|
2504
|
+
name: map.predecessor_task_name,
|
|
2505
|
+
version: map.predecessor_task_version
|
|
2506
|
+
})
|
|
2507
|
+
);
|
|
2508
|
+
const task = taskDefinitionsByKey.get(
|
|
2509
|
+
buildTaskKey({
|
|
2510
|
+
service_name: map.service_name,
|
|
2511
|
+
name: map.task_name,
|
|
2512
|
+
version: map.task_version
|
|
2513
|
+
})
|
|
2514
|
+
);
|
|
2515
|
+
return predecessor?.is_meta !== true && predecessor?.is_sub_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2516
|
+
}).sort(
|
|
2517
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2518
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2519
|
+
)
|
|
2520
|
+
);
|
|
2521
|
+
const businessActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => {
|
|
2522
|
+
const actor = actorDefinitionsByKey.get(
|
|
2523
|
+
buildActorKey({
|
|
2524
|
+
service_name: map.service_name,
|
|
2525
|
+
name: map.actor_name,
|
|
2526
|
+
version: map.actor_version
|
|
2527
|
+
})
|
|
2528
|
+
);
|
|
2529
|
+
const task = taskDefinitionsByKey.get(
|
|
2530
|
+
buildTaskKey({
|
|
2531
|
+
service_name: map.service_name,
|
|
2532
|
+
name: map.task_name,
|
|
2533
|
+
version: map.task_version
|
|
2534
|
+
})
|
|
2535
|
+
);
|
|
2536
|
+
return actor?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2537
|
+
}).sort(
|
|
2538
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2539
|
+
`${right.actor_name}:${right.task_name}`
|
|
2540
|
+
)
|
|
2541
|
+
);
|
|
2542
|
+
const businessTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => {
|
|
2543
|
+
const routine = routineDefinitionsByKey.get(
|
|
2544
|
+
buildRoutineKey({
|
|
2545
|
+
service_name: map.service_name,
|
|
2546
|
+
name: map.routine_name,
|
|
2547
|
+
version: map.routine_version
|
|
2548
|
+
})
|
|
2549
|
+
);
|
|
2550
|
+
const task = taskDefinitionsByKey.get(
|
|
2551
|
+
buildTaskKey({
|
|
2552
|
+
service_name: map.service_name,
|
|
2553
|
+
name: map.task_name,
|
|
2554
|
+
version: map.task_version
|
|
2555
|
+
})
|
|
2556
|
+
);
|
|
2557
|
+
return routine?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2558
|
+
}).sort(
|
|
2559
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2560
|
+
`${right.routine_name}:${right.task_name}`
|
|
2561
|
+
)
|
|
2562
|
+
);
|
|
2563
|
+
const localMetaTasks = taskDefinitions.filter((task) => task.is_meta === true || task.is_sub_meta === true).sort(
|
|
2564
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2565
|
+
);
|
|
2566
|
+
const localMetaSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2567
|
+
const localMetaIntents = intentDefinitions.filter((intent) => intent.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2568
|
+
const localMetaActors = actorDefinitions.filter((actor) => actor.is_meta === true).sort(
|
|
2569
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2570
|
+
);
|
|
2571
|
+
const localMetaRoutines = routineDefinitions.filter((routine) => routine.is_meta === true).sort(
|
|
2572
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2573
|
+
);
|
|
2574
|
+
const localMetaDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => !businessDirectionalTaskMaps.includes(map)).sort(
|
|
2575
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2576
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2577
|
+
)
|
|
2578
|
+
);
|
|
2579
|
+
const localMetaActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => !businessActorTaskMaps.includes(map)).sort(
|
|
2580
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2581
|
+
`${right.actor_name}:${right.task_name}`
|
|
2582
|
+
)
|
|
2583
|
+
);
|
|
2584
|
+
const localMetaTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => !businessTaskToRoutineMaps.includes(map)).sort(
|
|
2585
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2586
|
+
`${right.routine_name}:${right.task_name}`
|
|
2587
|
+
)
|
|
2588
|
+
);
|
|
2589
|
+
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
2590
|
+
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
2591
|
+
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
2592
|
+
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
2593
|
+
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
2594
|
+
for (const map of localMetaSignalTaskMaps) {
|
|
2595
|
+
businessLocalMetaSignalNames.add(map.signal_name);
|
|
2596
|
+
businessLocalMetaTaskKeys.add(
|
|
2597
|
+
buildTaskKey({
|
|
2598
|
+
service_name: map.service_name,
|
|
2599
|
+
name: map.task_name,
|
|
2600
|
+
version: map.task_version
|
|
2601
|
+
})
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
for (const map of localMetaIntentTaskMaps) {
|
|
2605
|
+
businessLocalMetaIntentNames.add(map.intent_name);
|
|
2606
|
+
businessLocalMetaTaskKeys.add(
|
|
2607
|
+
buildTaskKey({
|
|
2608
|
+
service_name: map.service_name,
|
|
2609
|
+
name: map.task_name,
|
|
2610
|
+
version: map.task_version
|
|
2611
|
+
})
|
|
2612
|
+
);
|
|
2613
|
+
}
|
|
2614
|
+
for (const map of localMetaActorTaskMaps) {
|
|
2615
|
+
businessLocalMetaActorKeys.add(
|
|
2616
|
+
buildActorKey({
|
|
2617
|
+
service_name: map.service_name,
|
|
2618
|
+
name: map.actor_name,
|
|
2619
|
+
version: map.actor_version
|
|
2620
|
+
})
|
|
2621
|
+
);
|
|
2622
|
+
businessLocalMetaTaskKeys.add(
|
|
2623
|
+
buildTaskKey({
|
|
2624
|
+
service_name: map.service_name,
|
|
2625
|
+
name: map.task_name,
|
|
2626
|
+
version: map.task_version
|
|
2627
|
+
})
|
|
2628
|
+
);
|
|
2629
|
+
}
|
|
2630
|
+
for (const map of localMetaTaskToRoutineMaps) {
|
|
2631
|
+
businessLocalMetaRoutineKeys.add(
|
|
2632
|
+
buildRoutineKey({
|
|
2633
|
+
service_name: map.service_name,
|
|
2634
|
+
name: map.routine_name,
|
|
2635
|
+
version: map.routine_version
|
|
2636
|
+
})
|
|
2637
|
+
);
|
|
2638
|
+
businessLocalMetaTaskKeys.add(
|
|
2639
|
+
buildTaskKey({
|
|
2640
|
+
service_name: map.service_name,
|
|
2641
|
+
name: map.task_name,
|
|
2642
|
+
version: map.task_version
|
|
2643
|
+
})
|
|
2644
|
+
);
|
|
2645
|
+
}
|
|
2646
|
+
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
2647
|
+
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
2648
|
+
).sort(
|
|
2649
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2650
|
+
);
|
|
2651
|
+
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
2652
|
+
(signal) => signal !== null && signal.is_meta === true
|
|
2653
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2654
|
+
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
2655
|
+
(intent) => intent !== null && intent.is_meta === true
|
|
2656
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2657
|
+
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
2658
|
+
(actor) => actor !== null && actor.is_meta === true
|
|
2659
|
+
).sort(
|
|
2660
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2661
|
+
);
|
|
2662
|
+
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
2663
|
+
(routine) => routine !== null && routine.is_meta === true
|
|
2664
|
+
).sort(
|
|
2665
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2666
|
+
);
|
|
2667
|
+
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
2668
|
+
new Map(
|
|
2669
|
+
[...routingTasks, ...businessTasks, ...businessLocalMetaTasks].map((task) => [
|
|
2670
|
+
buildTaskKey(task),
|
|
2671
|
+
task
|
|
2672
|
+
])
|
|
2673
|
+
).values()
|
|
2674
|
+
).sort(
|
|
2675
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2676
|
+
) : Array.from(
|
|
2677
|
+
new Map(
|
|
2678
|
+
[...routingTasks, ...businessTasks, ...localMetaTasks].map((task) => [
|
|
2679
|
+
buildTaskKey(task),
|
|
2680
|
+
task
|
|
2681
|
+
])
|
|
2682
|
+
).values()
|
|
2683
|
+
).sort(
|
|
2684
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2685
|
+
);
|
|
2686
|
+
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
2687
|
+
new Map(
|
|
2688
|
+
[...routingSignals, ...businessSignals, ...businessLocalMetaSignals].map(
|
|
2689
|
+
(signal) => [signal.name, signal]
|
|
2690
|
+
)
|
|
2691
|
+
).values()
|
|
2692
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2693
|
+
new Map(
|
|
2694
|
+
[...routingSignals, ...businessSignals, ...localMetaSignals].map((signal) => [
|
|
2695
|
+
signal.name,
|
|
2696
|
+
signal
|
|
2697
|
+
])
|
|
2698
|
+
).values()
|
|
2699
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2700
|
+
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
2701
|
+
new Map(
|
|
2702
|
+
[...routingIntents, ...businessIntents, ...businessLocalMetaIntents].map(
|
|
2703
|
+
(intent) => [intent.name, intent]
|
|
2704
|
+
)
|
|
2705
|
+
).values()
|
|
2706
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2707
|
+
new Map(
|
|
2708
|
+
[...routingIntents, ...businessIntents, ...localMetaIntents].map((intent) => [
|
|
2709
|
+
intent.name,
|
|
2710
|
+
intent
|
|
2711
|
+
])
|
|
2712
|
+
).values()
|
|
2713
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2714
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2715
|
+
new Map(
|
|
2716
|
+
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
2717
|
+
buildActorKey(actor),
|
|
2718
|
+
actor
|
|
2719
|
+
])
|
|
2720
|
+
).values()
|
|
2721
|
+
).sort(
|
|
2722
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2723
|
+
) : Array.from(
|
|
2724
|
+
new Map(
|
|
2725
|
+
[...businessActors, ...localMetaActors].map((actor) => [
|
|
2726
|
+
buildActorKey(actor),
|
|
2727
|
+
actor
|
|
2728
|
+
])
|
|
2729
|
+
).values()
|
|
2730
|
+
).sort(
|
|
2731
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2732
|
+
);
|
|
2733
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2734
|
+
new Map(
|
|
2735
|
+
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
2736
|
+
buildRoutineKey(routine),
|
|
2737
|
+
routine
|
|
2738
|
+
])
|
|
2739
|
+
).values()
|
|
2740
|
+
).sort(
|
|
2741
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2742
|
+
) : Array.from(
|
|
2743
|
+
new Map(
|
|
2744
|
+
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
2745
|
+
buildRoutineKey(routine),
|
|
2746
|
+
routine
|
|
2747
|
+
])
|
|
2748
|
+
).values()
|
|
2749
|
+
).sort(
|
|
2750
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2751
|
+
);
|
|
2752
|
+
const businessHelpers = helperDefinitions.filter((helper) => helper.is_meta !== true).sort(
|
|
2753
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2754
|
+
);
|
|
2755
|
+
const localMetaHelpers = helperDefinitions.filter((helper) => helper.is_meta === true).sort(
|
|
2756
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2757
|
+
);
|
|
2758
|
+
const businessGlobals = globalDefinitions.filter((globalDefinition) => globalDefinition.is_meta !== true).sort(
|
|
2759
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2760
|
+
);
|
|
2761
|
+
const localMetaGlobals = globalDefinitions.filter((globalDefinition) => globalDefinition.is_meta === true).sort(
|
|
2762
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2763
|
+
);
|
|
2764
|
+
const businessTaskToHelperMaps = Array.from(helperTaskMaps.values()).filter((map) => {
|
|
2765
|
+
const task = taskDefinitionsByKey.get(
|
|
2766
|
+
buildTaskKey({
|
|
2767
|
+
service_name: map.service_name,
|
|
2768
|
+
name: map.task_name,
|
|
2769
|
+
version: map.task_version
|
|
2770
|
+
})
|
|
2771
|
+
);
|
|
2772
|
+
const helper = helperDefinitionsByKey.get(
|
|
2773
|
+
buildHelperKey({
|
|
2774
|
+
service_name: map.service_name,
|
|
2775
|
+
name: map.helper_name,
|
|
2776
|
+
version: map.helper_version
|
|
2777
|
+
})
|
|
2778
|
+
);
|
|
2779
|
+
return task?.is_meta !== true && task?.is_sub_meta !== true && helper?.is_meta !== true;
|
|
2780
|
+
}).sort(
|
|
2781
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2782
|
+
);
|
|
2783
|
+
const localMetaTaskToHelperMaps = Array.from(helperTaskMaps.values()).filter((map) => !businessTaskToHelperMaps.includes(map)).sort(
|
|
2784
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2785
|
+
);
|
|
2786
|
+
const businessHelperToHelperMaps = Array.from(helperHelperMaps.values()).filter((map) => {
|
|
2787
|
+
const helper = helperDefinitionsByKey.get(
|
|
2788
|
+
buildHelperKey({
|
|
2789
|
+
service_name: map.service_name,
|
|
2790
|
+
name: map.helper_name,
|
|
2791
|
+
version: map.helper_version
|
|
2792
|
+
})
|
|
2793
|
+
);
|
|
2794
|
+
const dependencyHelper = helperDefinitionsByKey.get(
|
|
2795
|
+
buildHelperKey({
|
|
2796
|
+
service_name: map.service_name,
|
|
2797
|
+
name: map.dependency_helper_name,
|
|
2798
|
+
version: map.dependency_helper_version
|
|
2799
|
+
})
|
|
2800
|
+
);
|
|
2801
|
+
return helper?.is_meta !== true && dependencyHelper?.is_meta !== true;
|
|
2802
|
+
}).sort(
|
|
2803
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2804
|
+
);
|
|
2805
|
+
const localMetaHelperToHelperMaps = Array.from(helperHelperMaps.values()).filter((map) => !businessHelperToHelperMaps.includes(map)).sort(
|
|
2806
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2807
|
+
);
|
|
2808
|
+
const businessTaskToGlobalMaps = Array.from(taskGlobalMaps.values()).filter((map) => {
|
|
2809
|
+
const task = taskDefinitionsByKey.get(
|
|
2810
|
+
buildTaskKey({
|
|
2811
|
+
service_name: map.service_name,
|
|
2812
|
+
name: map.task_name,
|
|
2813
|
+
version: map.task_version
|
|
2814
|
+
})
|
|
2815
|
+
);
|
|
2816
|
+
const globalDefinition = globalDefinitionsByKey.get(
|
|
2817
|
+
buildGlobalKey({
|
|
2818
|
+
service_name: map.service_name,
|
|
2819
|
+
name: map.global_name,
|
|
2820
|
+
version: map.global_version
|
|
2821
|
+
})
|
|
2822
|
+
);
|
|
2823
|
+
return task?.is_meta !== true && task?.is_sub_meta !== true && globalDefinition?.is_meta !== true;
|
|
2824
|
+
}).sort(
|
|
2825
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2826
|
+
);
|
|
2827
|
+
const localMetaTaskToGlobalMaps = Array.from(taskGlobalMaps.values()).filter((map) => !businessTaskToGlobalMaps.includes(map)).sort(
|
|
2828
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2829
|
+
);
|
|
2830
|
+
const businessHelperToGlobalMaps = Array.from(helperGlobalMaps.values()).filter((map) => {
|
|
2831
|
+
const helper = helperDefinitionsByKey.get(
|
|
2832
|
+
buildHelperKey({
|
|
2833
|
+
service_name: map.service_name,
|
|
2834
|
+
name: map.helper_name,
|
|
2835
|
+
version: map.helper_version
|
|
2836
|
+
})
|
|
2837
|
+
);
|
|
2838
|
+
const globalDefinition = globalDefinitionsByKey.get(
|
|
2839
|
+
buildGlobalKey({
|
|
2840
|
+
service_name: map.service_name,
|
|
2841
|
+
name: map.global_name,
|
|
2842
|
+
version: map.global_version
|
|
2843
|
+
})
|
|
2844
|
+
);
|
|
2845
|
+
return helper?.is_meta !== true && globalDefinition?.is_meta !== true;
|
|
2846
|
+
}).sort(
|
|
2847
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2848
|
+
);
|
|
2849
|
+
const localMetaHelperToGlobalMaps = Array.from(helperGlobalMaps.values()).filter((map) => !businessHelperToGlobalMaps.includes(map)).sort(
|
|
2850
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2851
|
+
);
|
|
2852
|
+
const cumulativeHelpers = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelpers : [...businessHelpers, ...localMetaHelpers];
|
|
2853
|
+
const cumulativeGlobals = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessGlobals : [...businessGlobals, ...localMetaGlobals];
|
|
2854
|
+
const cumulativeTaskToHelperMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToHelperMaps : [...businessTaskToHelperMaps, ...localMetaTaskToHelperMaps];
|
|
2855
|
+
const cumulativeHelperToHelperMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelperToHelperMaps : [...businessHelperToHelperMaps, ...localMetaHelperToHelperMaps];
|
|
2856
|
+
const cumulativeTaskToGlobalMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToGlobalMaps : [...businessTaskToGlobalMaps, ...localMetaTaskToGlobalMaps];
|
|
2857
|
+
const cumulativeHelperToGlobalMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelperToGlobalMaps : [...businessHelperToGlobalMaps, ...localMetaHelperToGlobalMaps];
|
|
2858
|
+
const cumulativeDirectionalTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessDirectionalTaskMaps : Array.from(
|
|
2859
|
+
new Map(
|
|
2860
|
+
[...businessDirectionalTaskMaps, ...localMetaDirectionalTaskMaps].map(
|
|
2861
|
+
(map) => [
|
|
2862
|
+
`${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
2863
|
+
map
|
|
2864
|
+
]
|
|
2865
|
+
)
|
|
2866
|
+
).values()
|
|
2867
|
+
);
|
|
2868
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2869
|
+
new Map(
|
|
2870
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2871
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2872
|
+
map
|
|
2873
|
+
])
|
|
2874
|
+
).values()
|
|
2875
|
+
) : Array.from(
|
|
2876
|
+
new Map(
|
|
2877
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2878
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2879
|
+
map
|
|
2880
|
+
])
|
|
2881
|
+
).values()
|
|
2882
|
+
);
|
|
2883
|
+
const cumulativeTaskToRoutineMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToRoutineMaps : Array.from(
|
|
2884
|
+
new Map(
|
|
2885
|
+
[...businessTaskToRoutineMaps, ...localMetaTaskToRoutineMaps].map((map) => [
|
|
2886
|
+
`${map.service_name}|${map.task_name}|${map.task_version}|${map.routine_name}|${map.routine_version}`,
|
|
2887
|
+
map
|
|
2888
|
+
])
|
|
2889
|
+
).values()
|
|
2890
|
+
);
|
|
2891
|
+
const manifestBody = {
|
|
2892
|
+
serviceName,
|
|
2893
|
+
serviceInstanceId,
|
|
2894
|
+
publicationLayer,
|
|
2895
|
+
tasks: cumulativeTasks,
|
|
2896
|
+
signals: cumulativeSignals,
|
|
2897
|
+
intents: cumulativeIntents,
|
|
2898
|
+
actors: cumulativeActors,
|
|
2899
|
+
routines: cumulativeRoutines,
|
|
2900
|
+
helpers: cumulativeHelpers,
|
|
2901
|
+
globals: cumulativeGlobals,
|
|
2902
|
+
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
2903
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps],
|
|
2904
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps],
|
|
2905
|
+
actorTaskMaps: cumulativeActorTaskMaps,
|
|
2906
|
+
taskToRoutineMaps: cumulativeTaskToRoutineMaps,
|
|
2907
|
+
taskToHelperMaps: cumulativeTaskToHelperMaps,
|
|
2908
|
+
helperToHelperMaps: cumulativeHelperToHelperMaps,
|
|
2909
|
+
taskToGlobalMaps: cumulativeTaskToGlobalMaps,
|
|
2910
|
+
helperToGlobalMaps: cumulativeHelperToGlobalMaps
|
|
2911
|
+
};
|
|
2912
|
+
return {
|
|
2913
|
+
...manifestBody,
|
|
2914
|
+
revision,
|
|
2915
|
+
manifestHash: hashManifest(manifestBody),
|
|
2916
|
+
publishedAt
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
function explodeServiceManifestSnapshots(snapshots) {
|
|
2920
|
+
const dedupe = (items, keyOf, sortOf) => Array.from(
|
|
2921
|
+
new Map(items.map((item) => [keyOf(item), item])).values()
|
|
2922
|
+
).sort(sortOf);
|
|
2923
|
+
const tasks = dedupe(
|
|
2924
|
+
snapshots.flatMap((snapshot) => snapshot.tasks),
|
|
2925
|
+
(task) => `${task.service_name}|${task.name}|${task.version}`,
|
|
2926
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2927
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2928
|
+
)
|
|
1969
2929
|
);
|
|
1970
2930
|
const signals = dedupe(
|
|
1971
2931
|
snapshots.flatMap((snapshot) => snapshot.signals),
|
|
@@ -1991,6 +2951,20 @@ function explodeServiceManifestSnapshots(snapshots) {
|
|
|
1991
2951
|
`${right.service_name}|${right.name}|${right.version}`
|
|
1992
2952
|
)
|
|
1993
2953
|
);
|
|
2954
|
+
const helpers = dedupe(
|
|
2955
|
+
snapshots.flatMap((snapshot) => snapshot.helpers),
|
|
2956
|
+
(helper) => `${helper.service_name}|${helper.name}|${helper.version}`,
|
|
2957
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2958
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2959
|
+
)
|
|
2960
|
+
);
|
|
2961
|
+
const globals = dedupe(
|
|
2962
|
+
snapshots.flatMap((snapshot) => snapshot.globals),
|
|
2963
|
+
(globalDefinition) => `${globalDefinition.service_name}|${globalDefinition.name}|${globalDefinition.version}`,
|
|
2964
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2965
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2966
|
+
)
|
|
2967
|
+
);
|
|
1994
2968
|
const directionalTaskMaps = dedupe(
|
|
1995
2969
|
snapshots.flatMap((snapshot) => snapshot.directionalTaskMaps),
|
|
1996
2970
|
(map) => `${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
@@ -2026,17 +3000,51 @@ function explodeServiceManifestSnapshots(snapshots) {
|
|
|
2026
3000
|
`${right.routine_name}|${right.routine_version}|${right.service_name}|${right.task_name}|${right.task_version}`
|
|
2027
3001
|
)
|
|
2028
3002
|
);
|
|
3003
|
+
const taskToHelperMaps = dedupe(
|
|
3004
|
+
snapshots.flatMap((snapshot) => snapshot.taskToHelperMaps),
|
|
3005
|
+
(map) => `${map.service_name}|${map.task_name}|${map.task_version}|${map.alias}|${map.helper_name}|${map.helper_version}`,
|
|
3006
|
+
(left, right) => `${left.service_name}|${left.task_name}|${left.alias}|${left.helper_name}`.localeCompare(
|
|
3007
|
+
`${right.service_name}|${right.task_name}|${right.alias}|${right.helper_name}`
|
|
3008
|
+
)
|
|
3009
|
+
);
|
|
3010
|
+
const helperToHelperMaps = dedupe(
|
|
3011
|
+
snapshots.flatMap((snapshot) => snapshot.helperToHelperMaps),
|
|
3012
|
+
(map) => `${map.service_name}|${map.helper_name}|${map.helper_version}|${map.alias}|${map.dependency_helper_name}|${map.dependency_helper_version}`,
|
|
3013
|
+
(left, right) => `${left.service_name}|${left.helper_name}|${left.alias}|${left.dependency_helper_name}`.localeCompare(
|
|
3014
|
+
`${right.service_name}|${right.helper_name}|${right.alias}|${right.dependency_helper_name}`
|
|
3015
|
+
)
|
|
3016
|
+
);
|
|
3017
|
+
const taskToGlobalMaps = dedupe(
|
|
3018
|
+
snapshots.flatMap((snapshot) => snapshot.taskToGlobalMaps),
|
|
3019
|
+
(map) => `${map.service_name}|${map.task_name}|${map.task_version}|${map.alias}|${map.global_name}|${map.global_version}`,
|
|
3020
|
+
(left, right) => `${left.service_name}|${left.task_name}|${left.alias}|${left.global_name}`.localeCompare(
|
|
3021
|
+
`${right.service_name}|${right.task_name}|${right.alias}|${right.global_name}`
|
|
3022
|
+
)
|
|
3023
|
+
);
|
|
3024
|
+
const helperToGlobalMaps = dedupe(
|
|
3025
|
+
snapshots.flatMap((snapshot) => snapshot.helperToGlobalMaps),
|
|
3026
|
+
(map) => `${map.service_name}|${map.helper_name}|${map.helper_version}|${map.alias}|${map.global_name}|${map.global_version}`,
|
|
3027
|
+
(left, right) => `${left.service_name}|${left.helper_name}|${left.alias}|${left.global_name}`.localeCompare(
|
|
3028
|
+
`${right.service_name}|${right.helper_name}|${right.alias}|${right.global_name}`
|
|
3029
|
+
)
|
|
3030
|
+
);
|
|
2029
3031
|
return {
|
|
2030
3032
|
tasks,
|
|
2031
3033
|
signals,
|
|
2032
3034
|
intents,
|
|
2033
3035
|
actors,
|
|
2034
3036
|
routines,
|
|
3037
|
+
helpers,
|
|
3038
|
+
globals,
|
|
2035
3039
|
directionalTaskMaps,
|
|
2036
3040
|
signalToTaskMaps,
|
|
2037
3041
|
intentToTaskMaps,
|
|
2038
3042
|
actorTaskMaps,
|
|
2039
|
-
taskToRoutineMaps
|
|
3043
|
+
taskToRoutineMaps,
|
|
3044
|
+
taskToHelperMaps,
|
|
3045
|
+
helperToHelperMaps,
|
|
3046
|
+
taskToGlobalMaps,
|
|
3047
|
+
helperToGlobalMaps
|
|
2040
3048
|
};
|
|
2041
3049
|
}
|
|
2042
3050
|
|
|
@@ -2085,7 +3093,53 @@ var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRAC
|
|
|
2085
3093
|
function shouldTraceServiceRegistry(serviceName) {
|
|
2086
3094
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
2087
3095
|
}
|
|
2088
|
-
function
|
|
3096
|
+
function normalizeLeaseStatus(value) {
|
|
3097
|
+
const status = String(value ?? "").trim();
|
|
3098
|
+
if (status === "active" || status === "non_responsive" || status === "inactive" || status === "deleted") {
|
|
3099
|
+
return status;
|
|
3100
|
+
}
|
|
3101
|
+
return null;
|
|
3102
|
+
}
|
|
3103
|
+
function overlayServiceInstancesWithLeases(serviceInstances, serviceInstanceLeases) {
|
|
3104
|
+
if (serviceInstanceLeases.length === 0) {
|
|
3105
|
+
return serviceInstances;
|
|
3106
|
+
}
|
|
3107
|
+
const leasesByInstanceId = /* @__PURE__ */ new Map();
|
|
3108
|
+
for (const row of serviceInstanceLeases) {
|
|
3109
|
+
const serviceInstanceId = String(
|
|
3110
|
+
row.service_instance_id ?? row.serviceInstanceId ?? ""
|
|
3111
|
+
).trim();
|
|
3112
|
+
if (!serviceInstanceId) {
|
|
3113
|
+
continue;
|
|
3114
|
+
}
|
|
3115
|
+
leasesByInstanceId.set(serviceInstanceId, row);
|
|
3116
|
+
}
|
|
3117
|
+
return serviceInstances.map((row) => {
|
|
3118
|
+
const serviceInstanceId = String(row.uuid ?? "").trim();
|
|
3119
|
+
const lease = serviceInstanceId ? leasesByInstanceId.get(serviceInstanceId) : void 0;
|
|
3120
|
+
if (!lease) {
|
|
3121
|
+
return row;
|
|
3122
|
+
}
|
|
3123
|
+
const leaseStatus = normalizeLeaseStatus(
|
|
3124
|
+
lease.status ?? lease.lease_status ?? lease.leaseStatus
|
|
3125
|
+
);
|
|
3126
|
+
return {
|
|
3127
|
+
...row,
|
|
3128
|
+
lease_status: leaseStatus ?? void 0,
|
|
3129
|
+
is_ready: typeof lease.is_ready === "boolean" ? lease.is_ready : typeof lease.isReady === "boolean" ? lease.isReady : void 0,
|
|
3130
|
+
readiness_reason: typeof lease.readiness_reason === "string" ? lease.readiness_reason : typeof lease.readinessReason === "string" ? lease.readinessReason : null,
|
|
3131
|
+
lease_expires_at: typeof lease.lease_expires_at === "string" ? lease.lease_expires_at : typeof lease.leaseExpiresAt === "string" ? lease.leaseExpiresAt : null,
|
|
3132
|
+
last_lease_renewed_at: typeof lease.last_lease_renewed_at === "string" ? lease.last_lease_renewed_at : typeof lease.lastLeaseRenewedAt === "string" ? lease.lastLeaseRenewedAt : null,
|
|
3133
|
+
last_ready_at: typeof lease.last_ready_at === "string" ? lease.last_ready_at : typeof lease.lastReadyAt === "string" ? lease.lastReadyAt : null,
|
|
3134
|
+
last_observed_transport_at: typeof lease.last_observed_transport_at === "string" ? lease.last_observed_transport_at : typeof lease.lastObservedTransportAt === "string" ? lease.lastObservedTransportAt : null,
|
|
3135
|
+
shutdown_requested_at: typeof lease.shutdown_requested_at === "string" ? lease.shutdown_requested_at : typeof lease.shutdownRequestedAt === "string" ? lease.shutdownRequestedAt : null,
|
|
3136
|
+
is_active: leaseStatus === "active" ? true : leaseStatus === "non_responsive" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : row.is_active,
|
|
3137
|
+
is_non_responsive: leaseStatus === "non_responsive" ? true : leaseStatus === "active" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : row.is_non_responsive,
|
|
3138
|
+
deleted: leaseStatus === "deleted" ? true : Boolean(row.deleted ?? false)
|
|
3139
|
+
};
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
function buildServiceRegistryInsertQueryData(tableName, ctx, queryData) {
|
|
2089
3143
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
2090
3144
|
const getJoinedValue = (key) => {
|
|
2091
3145
|
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
@@ -2103,7 +3157,8 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
|
2103
3157
|
if (!Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
2104
3158
|
delete nextQueryData.onConflict;
|
|
2105
3159
|
}
|
|
2106
|
-
const
|
|
3160
|
+
const preferRegistrationData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
3161
|
+
const resolvedData = preferRegistrationData ? registrationData ?? (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data")) : Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
2107
3162
|
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
2108
3163
|
const nextData = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
2109
3164
|
if (nextData !== void 0) {
|
|
@@ -2130,8 +3185,151 @@ function sanitizeServiceRegistryInsertExecutionContext(ctx) {
|
|
|
2130
3185
|
delete sanitized.returnedValue;
|
|
2131
3186
|
delete sanitized.queryData;
|
|
2132
3187
|
delete sanitized.onConflict;
|
|
3188
|
+
delete sanitized.task;
|
|
3189
|
+
delete sanitized.routine;
|
|
3190
|
+
delete sanitized.httpServer;
|
|
3191
|
+
delete sanitized.service;
|
|
3192
|
+
delete sanitized.serviceInstance;
|
|
3193
|
+
delete sanitized.joinedContexts;
|
|
3194
|
+
delete sanitized.__declaredTransports;
|
|
3195
|
+
delete sanitized.__resolverOriginalContext;
|
|
3196
|
+
delete sanitized.__resolverQueryData;
|
|
2133
3197
|
return sanitized;
|
|
2134
3198
|
}
|
|
3199
|
+
function sanitizeAuthorityBootstrapDelegationContext(ctx) {
|
|
3200
|
+
const sanitized = stripDelegationRequestSnapshot({
|
|
3201
|
+
...ctx
|
|
3202
|
+
});
|
|
3203
|
+
delete sanitized.__resolverOriginalContext;
|
|
3204
|
+
delete sanitized.__resolverQueryData;
|
|
3205
|
+
delete sanitized.joinedContexts;
|
|
3206
|
+
delete sanitized.httpServer;
|
|
3207
|
+
delete sanitized.service;
|
|
3208
|
+
delete sanitized.serviceInstance;
|
|
3209
|
+
delete sanitized.task;
|
|
3210
|
+
delete sanitized.routine;
|
|
3211
|
+
delete sanitized.__declaredTransports;
|
|
3212
|
+
const queryData = sanitized.queryData && typeof sanitized.queryData === "object" ? { ...sanitized.queryData } : null;
|
|
3213
|
+
if (queryData) {
|
|
3214
|
+
delete queryData.joinedContexts;
|
|
3215
|
+
sanitized.queryData = queryData;
|
|
3216
|
+
}
|
|
3217
|
+
return sanitized;
|
|
3218
|
+
}
|
|
3219
|
+
var BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS = [
|
|
3220
|
+
"data",
|
|
3221
|
+
"batch",
|
|
3222
|
+
"transaction",
|
|
3223
|
+
"onConflict",
|
|
3224
|
+
"filter",
|
|
3225
|
+
"fields",
|
|
3226
|
+
"joins",
|
|
3227
|
+
"sort",
|
|
3228
|
+
"limit",
|
|
3229
|
+
"offset",
|
|
3230
|
+
"queryMode",
|
|
3231
|
+
"aggregates",
|
|
3232
|
+
"groupBy"
|
|
3233
|
+
];
|
|
3234
|
+
function isBootstrapDbOperationRoutineName(value) {
|
|
3235
|
+
return /^(Insert|Update|Query|Delete)\s+/.test(String(value ?? "").trim());
|
|
3236
|
+
}
|
|
3237
|
+
function compactAuthorityBootstrapRequestBody(ctx) {
|
|
3238
|
+
if (!isBootstrapDbOperationRoutineName(ctx.__remoteRoutineName)) {
|
|
3239
|
+
return ctx;
|
|
3240
|
+
}
|
|
3241
|
+
const queryData = ctx.queryData && typeof ctx.queryData === "object" ? { ...ctx.queryData } : null;
|
|
3242
|
+
if (!queryData) {
|
|
3243
|
+
return ctx;
|
|
3244
|
+
}
|
|
3245
|
+
const compacted = {
|
|
3246
|
+
...ctx,
|
|
3247
|
+
queryData
|
|
3248
|
+
};
|
|
3249
|
+
for (const key of BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS) {
|
|
3250
|
+
if (Object.prototype.hasOwnProperty.call(queryData, key)) {
|
|
3251
|
+
delete compacted[key];
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
return compacted;
|
|
3255
|
+
}
|
|
3256
|
+
function cloneServiceRegistryContextValue(value) {
|
|
3257
|
+
if (value instanceof Date) {
|
|
3258
|
+
return new Date(value.getTime());
|
|
3259
|
+
}
|
|
3260
|
+
if (Array.isArray(value)) {
|
|
3261
|
+
return value.map(
|
|
3262
|
+
(entry) => cloneServiceRegistryContextValue(entry)
|
|
3263
|
+
);
|
|
3264
|
+
}
|
|
3265
|
+
if (value && typeof value === "object") {
|
|
3266
|
+
const clone = {};
|
|
3267
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3268
|
+
clone[key] = cloneServiceRegistryContextValue(nestedValue);
|
|
3269
|
+
}
|
|
3270
|
+
return clone;
|
|
3271
|
+
}
|
|
3272
|
+
return value;
|
|
3273
|
+
}
|
|
3274
|
+
function buildServiceRegistryResolverOriginalContext(tableName, ctx, queryData) {
|
|
3275
|
+
const originalContext = {};
|
|
3276
|
+
for (const key of [
|
|
3277
|
+
"__serviceName",
|
|
3278
|
+
"serviceName",
|
|
3279
|
+
"__serviceInstanceId",
|
|
3280
|
+
"serviceInstanceId",
|
|
3281
|
+
"__registrationData",
|
|
3282
|
+
"__reason",
|
|
3283
|
+
"__syncing",
|
|
3284
|
+
"__syncSourceServiceName",
|
|
3285
|
+
"__preferredTransportProtocol",
|
|
3286
|
+
"__networkMode",
|
|
3287
|
+
"__securityProfile",
|
|
3288
|
+
"__loadBalance",
|
|
3289
|
+
"__cadenzaDBConnect",
|
|
3290
|
+
"__isFrontend",
|
|
3291
|
+
"__isDatabase",
|
|
3292
|
+
"__retryCount",
|
|
3293
|
+
"__retries",
|
|
3294
|
+
"__triedInstances"
|
|
3295
|
+
]) {
|
|
3296
|
+
if (ctx[key] !== void 0) {
|
|
3297
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
if (queryData.data !== void 0) {
|
|
3301
|
+
originalContext.data = cloneServiceRegistryContextValue(queryData.data);
|
|
3302
|
+
}
|
|
3303
|
+
if (queryData.batch !== void 0) {
|
|
3304
|
+
originalContext.batch = cloneServiceRegistryContextValue(queryData.batch);
|
|
3305
|
+
}
|
|
3306
|
+
if (Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
3307
|
+
originalContext.queryData = {
|
|
3308
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
3309
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0,
|
|
3310
|
+
onConflict: cloneServiceRegistryContextValue(queryData.onConflict)
|
|
3311
|
+
};
|
|
3312
|
+
} else if (queryData.data !== void 0 || queryData.batch !== void 0) {
|
|
3313
|
+
originalContext.queryData = {
|
|
3314
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
3315
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0
|
|
3316
|
+
};
|
|
3317
|
+
}
|
|
3318
|
+
if (tableName === "service_instance") {
|
|
3319
|
+
for (const key of [
|
|
3320
|
+
"__transportData",
|
|
3321
|
+
"transportData",
|
|
3322
|
+
"__useSocket",
|
|
3323
|
+
"__retryCount",
|
|
3324
|
+
"__isFrontend"
|
|
3325
|
+
]) {
|
|
3326
|
+
if (ctx[key] !== void 0) {
|
|
3327
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
return originalContext;
|
|
3332
|
+
}
|
|
2135
3333
|
function clearTransientRoutingErrorState(context) {
|
|
2136
3334
|
delete context.errored;
|
|
2137
3335
|
delete context.failed;
|
|
@@ -2187,7 +3385,8 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2187
3385
|
delete result.__resolverOriginalContext;
|
|
2188
3386
|
delete result.__resolverQueryData;
|
|
2189
3387
|
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
2190
|
-
const
|
|
3388
|
+
const preferRequestedData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
3389
|
+
const resolvedData = preferRequestedData ? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData ?? result.data : result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
2191
3390
|
if (resolvedData !== void 0 && result.data === void 0) {
|
|
2192
3391
|
result.data = resolvedData;
|
|
2193
3392
|
}
|
|
@@ -2217,6 +3416,7 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2217
3416
|
).trim();
|
|
2218
3417
|
if (resolvedServiceName) {
|
|
2219
3418
|
result.__serviceName = resolvedServiceName;
|
|
3419
|
+
result.serviceName = resolvedServiceName;
|
|
2220
3420
|
}
|
|
2221
3421
|
}
|
|
2222
3422
|
const resolvedLocalServiceInstanceId = String(
|
|
@@ -2225,6 +3425,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2225
3425
|
if (resolvedLocalServiceInstanceId) {
|
|
2226
3426
|
result.__serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
2227
3427
|
}
|
|
3428
|
+
if (tableName === "service_instance") {
|
|
3429
|
+
const resolvedServiceName = String(
|
|
3430
|
+
ctx.__serviceName ?? resolveServiceNameFromContext(ctx) ?? resolvedData?.service_name ?? resolvedData?.serviceName ?? ""
|
|
3431
|
+
).trim();
|
|
3432
|
+
if (resolvedServiceName) {
|
|
3433
|
+
result.__serviceName = resolvedServiceName;
|
|
3434
|
+
result.serviceName = resolvedServiceName;
|
|
3435
|
+
}
|
|
3436
|
+
if (resolvedLocalServiceInstanceId) {
|
|
3437
|
+
result.serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
2228
3440
|
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
2229
3441
|
const resolvedUuid = String(
|
|
2230
3442
|
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
@@ -2324,9 +3536,15 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2324
3536
|
ctx
|
|
2325
3537
|
);
|
|
2326
3538
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
3539
|
+
tableName,
|
|
2327
3540
|
sanitizedContext,
|
|
2328
3541
|
queryData
|
|
2329
3542
|
);
|
|
3543
|
+
const resolverOriginalContext = buildServiceRegistryResolverOriginalContext(
|
|
3544
|
+
tableName,
|
|
3545
|
+
sanitizedContext,
|
|
3546
|
+
nextQueryData
|
|
3547
|
+
);
|
|
2330
3548
|
const delegationContext = ensureDelegationContextMetadata({
|
|
2331
3549
|
...sanitizedContext,
|
|
2332
3550
|
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
@@ -2339,9 +3557,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2339
3557
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
2340
3558
|
const nextContext = {
|
|
2341
3559
|
...delegationContext,
|
|
2342
|
-
__resolverOriginalContext:
|
|
2343
|
-
...sanitizedContext
|
|
2344
|
-
},
|
|
3560
|
+
__resolverOriginalContext: resolverOriginalContext,
|
|
2345
3561
|
__resolverQueryData: nextQueryData
|
|
2346
3562
|
};
|
|
2347
3563
|
if (tableName === "service_instance_transport" && shouldTraceServiceRegistry(
|
|
@@ -2393,6 +3609,92 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2393
3609
|
`Resolve service registry insert for ${tableName}`,
|
|
2394
3610
|
(ctx, emit2) => new Promise((resolve) => {
|
|
2395
3611
|
const resolverRequestId = (0, import_uuid3.v4)();
|
|
3612
|
+
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
3613
|
+
const bootstrapAuthorityInsertSpec = !localInsertTask && CadenzaService.serviceRegistry.connectsToCadenzaDB ? getAuthorityBootstrapInsertIntentSpecForTable(tableName) : null;
|
|
3614
|
+
const resolvedTargetServiceName = resolveServiceNameFromContext(ctx);
|
|
3615
|
+
const selfBootstrapRetrySignal = CadenzaService.serviceRegistry.serviceName === "CadenzaDB" && resolvedTargetServiceName === "CadenzaDB" && !localInsertTask ? getSelfBootstrapRegistrationRetrySignal(tableName) : null;
|
|
3616
|
+
if (selfBootstrapRetrySignal) {
|
|
3617
|
+
CadenzaService.schedule(
|
|
3618
|
+
selfBootstrapRetrySignal,
|
|
3619
|
+
{
|
|
3620
|
+
...ctx
|
|
3621
|
+
},
|
|
3622
|
+
250
|
|
3623
|
+
);
|
|
3624
|
+
resolve(false);
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
if (bootstrapAuthorityInsertSpec) {
|
|
3628
|
+
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
3629
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
3630
|
+
tableName,
|
|
3631
|
+
sanitizedContext,
|
|
3632
|
+
queryData
|
|
3633
|
+
);
|
|
3634
|
+
const inquiryContext = ensureDelegationContextMetadata({
|
|
3635
|
+
...sanitizedContext,
|
|
3636
|
+
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
3637
|
+
batch: nextQueryData.batch !== void 0 ? nextQueryData.batch : sanitizedContext.batch,
|
|
3638
|
+
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
3639
|
+
transaction: nextQueryData.transaction !== void 0 ? nextQueryData.transaction : sanitizedContext.transaction,
|
|
3640
|
+
queryData: nextQueryData
|
|
3641
|
+
});
|
|
3642
|
+
inquiryContext.__metadata = {
|
|
3643
|
+
...inquiryContext.__metadata ?? {},
|
|
3644
|
+
__skipRemoteExecution: inquiryContext.__metadata?.__skipRemoteExecution ?? inquiryContext.__skipRemoteExecution ?? false,
|
|
3645
|
+
__blockRemoteExecution: inquiryContext.__metadata?.__blockRemoteExecution ?? inquiryContext.__blockRemoteExecution ?? false
|
|
3646
|
+
};
|
|
3647
|
+
CadenzaService.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
3648
|
+
bootstrapAuthorityInsertSpec.intentName,
|
|
3649
|
+
inquiryContext
|
|
3650
|
+
);
|
|
3651
|
+
void CadenzaService.inquire(
|
|
3652
|
+
bootstrapAuthorityInsertSpec.intentName,
|
|
3653
|
+
inquiryContext,
|
|
3654
|
+
{
|
|
3655
|
+
requireComplete: true,
|
|
3656
|
+
timeout: bootstrapAuthorityInsertSpec.defaultTimeoutMs
|
|
3657
|
+
}
|
|
3658
|
+
).then(
|
|
3659
|
+
(result) => resolve(
|
|
3660
|
+
resolveBootstrapAuthorityInsertResult(
|
|
3661
|
+
tableName,
|
|
3662
|
+
sanitizedContext,
|
|
3663
|
+
nextQueryData,
|
|
3664
|
+
result,
|
|
3665
|
+
emit2
|
|
3666
|
+
)
|
|
3667
|
+
)
|
|
3668
|
+
).catch(
|
|
3669
|
+
(error) => resolve(
|
|
3670
|
+
resolveBootstrapAuthorityInsertResult(
|
|
3671
|
+
tableName,
|
|
3672
|
+
sanitizedContext,
|
|
3673
|
+
nextQueryData,
|
|
3674
|
+
error,
|
|
3675
|
+
emit2
|
|
3676
|
+
)
|
|
3677
|
+
)
|
|
3678
|
+
);
|
|
3679
|
+
return;
|
|
3680
|
+
}
|
|
3681
|
+
const executionSignal = localInsertTask ? localExecutionRequestedSignal : remoteExecutionRequestedSignal;
|
|
3682
|
+
if ((tableName === "service_instance" || tableName === "service") && (process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true")) {
|
|
3683
|
+
console.log("[CADENZA_INSTANCE_DEBUG] resolve_service_registry_insert", {
|
|
3684
|
+
tableName,
|
|
3685
|
+
executionSignal,
|
|
3686
|
+
hasLocalInsertTask: !!localInsertTask,
|
|
3687
|
+
serviceName: ctx.__serviceName ?? ctx.data?.service_name ?? null,
|
|
3688
|
+
serviceInstanceId: ctx.__serviceInstanceId ?? ctx.data?.uuid ?? null,
|
|
3689
|
+
hasData: !!ctx.data,
|
|
3690
|
+
dataKeys: ctx.data && typeof ctx.data === "object" ? Object.keys(ctx.data) : [],
|
|
3691
|
+
registrationKeys: ctx.__registrationData && typeof ctx.__registrationData === "object" ? Object.keys(ctx.__registrationData) : []
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
if (localInsertTask && !wiredLocalTaskNames.has(localInsertTask.name)) {
|
|
3695
|
+
wireExecutionTarget(localInsertTask, prepareLocalExecutionTask);
|
|
3696
|
+
wiredLocalTaskNames.add(localInsertTask.name);
|
|
3697
|
+
}
|
|
2396
3698
|
CadenzaService.createEphemeralMetaTask(
|
|
2397
3699
|
`Resolve service registry insert execution for ${tableName} (${resolverRequestId})`,
|
|
2398
3700
|
(resultCtx) => {
|
|
@@ -2451,135 +3753,52 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2451
3753
|
) || CadenzaService.serviceRegistry.serviceName,
|
|
2452
3754
|
uuid: normalizedResult.uuid ?? normalizedResult.data?.uuid ?? null,
|
|
2453
3755
|
errored: normalizedResult.errored === true,
|
|
2454
|
-
error: normalizedResult.__error ?? null,
|
|
2455
|
-
data: normalizedResult.data ?? normalizedResult.queryData?.data ?? null
|
|
2456
|
-
});
|
|
2457
|
-
}
|
|
2458
|
-
if (normalizedResult && typeof normalizedResult === "object" && tableName === "service_instance") {
|
|
2459
|
-
const traceServiceName = resolveServiceNameFromContext(
|
|
2460
|
-
resultCtx.__resolverOriginalContext ?? resultCtx
|
|
2461
|
-
) || CadenzaService.serviceRegistry.serviceName;
|
|
2462
|
-
if (shouldTraceServiceRegistry(traceServiceName)) {
|
|
2463
|
-
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] service_instance_insert_resolved", {
|
|
2464
|
-
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
2465
|
-
serviceName: traceServiceName,
|
|
2466
|
-
serviceInstanceId: normalizedResult.__serviceInstanceId ?? normalizedResult.uuid ?? normalizedResult.data?.uuid ?? null,
|
|
2467
|
-
hasTransportData: Array.isArray(normalizedResult.__transportData) || Array.isArray(normalizedResult.transportData),
|
|
2468
|
-
transportCount: Array.isArray(
|
|
2469
|
-
normalizedResult.__transportData
|
|
2470
|
-
) ? normalizedResult.__transportData.length : Array.isArray(normalizedResult.transportData) ? normalizedResult.transportData.length : 0,
|
|
2471
|
-
errored: normalizedResult.errored === true,
|
|
2472
|
-
error: normalizedResult.__error ?? null
|
|
2473
|
-
});
|
|
2474
|
-
}
|
|
2475
|
-
emit2(
|
|
2476
|
-
META_SERVICE_INSTANCE_INSERT_RESOLVED_SIGNAL,
|
|
2477
|
-
normalizedResult
|
|
2478
|
-
);
|
|
2479
|
-
}
|
|
2480
|
-
if (!normalizedResult || typeof normalizedResult !== "object") {
|
|
2481
|
-
resolve(normalizedResult);
|
|
2482
|
-
return normalizedResult;
|
|
2483
|
-
}
|
|
2484
|
-
const resolvedResult = {
|
|
2485
|
-
...normalizedResult
|
|
2486
|
-
};
|
|
2487
|
-
delete resolvedResult.__resolverRequestId;
|
|
2488
|
-
delete resolvedResult.__resolverOriginalContext;
|
|
2489
|
-
delete resolvedResult.__resolverQueryData;
|
|
2490
|
-
resolve(resolvedResult);
|
|
2491
|
-
return resolvedResult;
|
|
2492
|
-
},
|
|
2493
|
-
`Resolves signal-driven ${tableName} service-registry insert execution.`,
|
|
2494
|
-
{
|
|
2495
|
-
register: false
|
|
2496
|
-
}
|
|
2497
|
-
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
2498
|
-
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
2499
|
-
const bootstrapAuthorityInsertSpec = !localInsertTask && CadenzaService.serviceRegistry.connectsToCadenzaDB ? getAuthorityBootstrapInsertIntentSpecForTable(tableName) : null;
|
|
2500
|
-
const resolvedTargetServiceName = resolveServiceNameFromContext(ctx);
|
|
2501
|
-
const selfBootstrapRetrySignal = CadenzaService.serviceRegistry.serviceName === "CadenzaDB" && resolvedTargetServiceName === "CadenzaDB" && !localInsertTask ? getSelfBootstrapRegistrationRetrySignal(tableName) : null;
|
|
2502
|
-
if (selfBootstrapRetrySignal) {
|
|
2503
|
-
CadenzaService.schedule(
|
|
2504
|
-
selfBootstrapRetrySignal,
|
|
2505
|
-
{
|
|
2506
|
-
...ctx
|
|
2507
|
-
},
|
|
2508
|
-
250
|
|
2509
|
-
);
|
|
2510
|
-
resolve(false);
|
|
2511
|
-
return;
|
|
2512
|
-
}
|
|
2513
|
-
if (bootstrapAuthorityInsertSpec) {
|
|
2514
|
-
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
2515
|
-
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
2516
|
-
sanitizedContext,
|
|
2517
|
-
queryData
|
|
2518
|
-
);
|
|
2519
|
-
const inquiryContext = ensureDelegationContextMetadata({
|
|
2520
|
-
...sanitizedContext,
|
|
2521
|
-
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
2522
|
-
batch: nextQueryData.batch !== void 0 ? nextQueryData.batch : sanitizedContext.batch,
|
|
2523
|
-
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
2524
|
-
transaction: nextQueryData.transaction !== void 0 ? nextQueryData.transaction : sanitizedContext.transaction,
|
|
2525
|
-
queryData: nextQueryData
|
|
2526
|
-
});
|
|
2527
|
-
inquiryContext.__metadata = {
|
|
2528
|
-
...inquiryContext.__metadata ?? {},
|
|
2529
|
-
__skipRemoteExecution: inquiryContext.__metadata?.__skipRemoteExecution ?? inquiryContext.__skipRemoteExecution ?? false,
|
|
2530
|
-
__blockRemoteExecution: inquiryContext.__metadata?.__blockRemoteExecution ?? inquiryContext.__blockRemoteExecution ?? false
|
|
2531
|
-
};
|
|
2532
|
-
CadenzaService.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
2533
|
-
bootstrapAuthorityInsertSpec.intentName,
|
|
2534
|
-
inquiryContext
|
|
2535
|
-
);
|
|
2536
|
-
void CadenzaService.inquire(
|
|
2537
|
-
bootstrapAuthorityInsertSpec.intentName,
|
|
2538
|
-
inquiryContext,
|
|
2539
|
-
{
|
|
2540
|
-
requireComplete: true,
|
|
2541
|
-
timeout: bootstrapAuthorityInsertSpec.defaultTimeoutMs
|
|
3756
|
+
error: normalizedResult.__error ?? null,
|
|
3757
|
+
data: normalizedResult.data ?? normalizedResult.queryData?.data ?? null
|
|
3758
|
+
});
|
|
2542
3759
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
}
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
3760
|
+
if (normalizedResult && typeof normalizedResult === "object" && tableName === "service_instance") {
|
|
3761
|
+
const traceServiceName = resolveServiceNameFromContext(
|
|
3762
|
+
resultCtx.__resolverOriginalContext ?? resultCtx
|
|
3763
|
+
) || CadenzaService.serviceRegistry.serviceName;
|
|
3764
|
+
if (shouldTraceServiceRegistry(traceServiceName)) {
|
|
3765
|
+
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] service_instance_insert_resolved", {
|
|
3766
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
3767
|
+
serviceName: traceServiceName,
|
|
3768
|
+
serviceInstanceId: normalizedResult.__serviceInstanceId ?? normalizedResult.uuid ?? normalizedResult.data?.uuid ?? null,
|
|
3769
|
+
hasTransportData: Array.isArray(normalizedResult.__transportData) || Array.isArray(normalizedResult.transportData),
|
|
3770
|
+
transportCount: Array.isArray(
|
|
3771
|
+
normalizedResult.__transportData
|
|
3772
|
+
) ? normalizedResult.__transportData.length : Array.isArray(normalizedResult.transportData) ? normalizedResult.transportData.length : 0,
|
|
3773
|
+
errored: normalizedResult.errored === true,
|
|
3774
|
+
error: normalizedResult.__error ?? null
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
emit2(
|
|
3778
|
+
META_SERVICE_INSTANCE_INSERT_RESOLVED_SIGNAL,
|
|
3779
|
+
normalizedResult
|
|
3780
|
+
);
|
|
3781
|
+
}
|
|
3782
|
+
if (!normalizedResult || typeof normalizedResult !== "object") {
|
|
3783
|
+
resolve(normalizedResult);
|
|
3784
|
+
return normalizedResult;
|
|
3785
|
+
}
|
|
3786
|
+
const resolvedResult = {
|
|
3787
|
+
...normalizedResult
|
|
3788
|
+
};
|
|
3789
|
+
delete resolvedResult.__resolverRequestId;
|
|
3790
|
+
delete resolvedResult.__resolverOriginalContext;
|
|
3791
|
+
delete resolvedResult.__resolverQueryData;
|
|
3792
|
+
resolve(resolvedResult);
|
|
3793
|
+
return resolvedResult;
|
|
3794
|
+
},
|
|
3795
|
+
`Resolves signal-driven ${tableName} service-registry insert execution.`,
|
|
3796
|
+
{
|
|
3797
|
+
register: false,
|
|
3798
|
+
once: false,
|
|
3799
|
+
destroyCondition: (result) => result !== false
|
|
3800
|
+
}
|
|
3801
|
+
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
2583
3802
|
emit2(executionSignal, {
|
|
2584
3803
|
...ctx,
|
|
2585
3804
|
__resolverRequestId: resolverRequestId
|
|
@@ -2604,6 +3823,17 @@ function readPositiveIntegerEnv(name, fallback) {
|
|
|
2604
3823
|
}
|
|
2605
3824
|
return normalized;
|
|
2606
3825
|
}
|
|
3826
|
+
function readNonNegativeFloatEnv(name, fallback) {
|
|
3827
|
+
if (typeof process === "undefined") {
|
|
3828
|
+
return fallback;
|
|
3829
|
+
}
|
|
3830
|
+
const raw = process.env?.[name];
|
|
3831
|
+
const parsed = Number(raw);
|
|
3832
|
+
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
3833
|
+
return fallback;
|
|
3834
|
+
}
|
|
3835
|
+
return parsed;
|
|
3836
|
+
}
|
|
2607
3837
|
var ServiceRegistry = class _ServiceRegistry {
|
|
2608
3838
|
/**
|
|
2609
3839
|
* Initializes a private constructor for managing service instances, remote signals,
|
|
@@ -2653,6 +3883,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2653
3883
|
"CADENZA_RUNTIME_STATUS_REST_REFRESH_MS",
|
|
2654
3884
|
this.runtimeMetricsSampleIntervalMs
|
|
2655
3885
|
);
|
|
3886
|
+
this.runtimeStatusLoopJitterRatio = normalizeJitterRatio(
|
|
3887
|
+
readNonNegativeFloatEnv("CADENZA_RUNTIME_STATUS_JITTER_RATIO", 0.2)
|
|
3888
|
+
);
|
|
2656
3889
|
this.runtimeStatusMissThreshold = readPositiveIntegerEnv(
|
|
2657
3890
|
"CADENZA_RUNTIME_STATUS_MISSED_HEARTBEATS",
|
|
2658
3891
|
3
|
|
@@ -2701,6 +3934,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2701
3934
|
"CADENZA_RUNTIME_STATUS_OVERLOADED_GRAPH_THRESHOLD",
|
|
2702
3935
|
20
|
|
2703
3936
|
);
|
|
3937
|
+
this.bootstrapFullSyncRetryJitterRatio = normalizeJitterRatio(
|
|
3938
|
+
readNonNegativeFloatEnv(
|
|
3939
|
+
"CADENZA_BOOTSTRAP_FULL_SYNC_RETRY_JITTER_RATIO",
|
|
3940
|
+
0.2
|
|
3941
|
+
)
|
|
3942
|
+
);
|
|
3943
|
+
this.serviceCommunicationRetryJitterRatio = normalizeJitterRatio(
|
|
3944
|
+
readNonNegativeFloatEnv(
|
|
3945
|
+
"CADENZA_SERVICE_COMMUNICATION_RETRY_JITTER_RATIO",
|
|
3946
|
+
0.2
|
|
3947
|
+
)
|
|
3948
|
+
);
|
|
2704
3949
|
this.serviceName = null;
|
|
2705
3950
|
this.serviceInstanceId = null;
|
|
2706
3951
|
this.numberOfRunningGraphs = 0;
|
|
@@ -2947,6 +4192,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2947
4192
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
2948
4193
|
);
|
|
2949
4194
|
if (uuid9 === this.serviceInstanceId) return;
|
|
4195
|
+
if (serviceName === this.serviceName) {
|
|
4196
|
+
return false;
|
|
4197
|
+
}
|
|
2950
4198
|
if (deleted) {
|
|
2951
4199
|
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid9);
|
|
2952
4200
|
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid9) ?? -1;
|
|
@@ -3033,9 +4281,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3033
4281
|
emit2
|
|
3034
4282
|
);
|
|
3035
4283
|
}
|
|
3036
|
-
if (this.serviceName === serviceName) {
|
|
3037
|
-
return false;
|
|
3038
|
-
}
|
|
3039
4284
|
if (trackedInstance?.isFrontend) {
|
|
3040
4285
|
return true;
|
|
3041
4286
|
}
|
|
@@ -3089,6 +4334,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3089
4334
|
if (!ownerInstance) {
|
|
3090
4335
|
return false;
|
|
3091
4336
|
}
|
|
4337
|
+
if (ownerInstance.serviceName === this.serviceName && ownerInstance.uuid !== this.serviceInstanceId) {
|
|
4338
|
+
return false;
|
|
4339
|
+
}
|
|
3092
4340
|
if (transport.deleted) {
|
|
3093
4341
|
this.clearTransportFailureState(ownerInstance.uuid, transport.uuid);
|
|
3094
4342
|
const transportKey = this.buildTransportRouteKey(
|
|
@@ -3676,6 +4924,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3676
4924
|
const tasks = this.readArrayPayload(inquiryResult, [
|
|
3677
4925
|
"tasks"
|
|
3678
4926
|
]);
|
|
4927
|
+
const helpers = this.readArrayPayload(inquiryResult, [
|
|
4928
|
+
"helpers"
|
|
4929
|
+
]);
|
|
4930
|
+
const globals = this.readArrayPayload(inquiryResult, [
|
|
4931
|
+
"globals"
|
|
4932
|
+
]);
|
|
3679
4933
|
const signals = this.readArrayPayload(inquiryResult, [
|
|
3680
4934
|
"signals"
|
|
3681
4935
|
]);
|
|
@@ -3700,6 +4954,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3700
4954
|
inquiryResult,
|
|
3701
4955
|
["taskToRoutineMaps", "task_to_routine_maps"]
|
|
3702
4956
|
);
|
|
4957
|
+
const taskToHelperMaps = this.readArrayPayload(
|
|
4958
|
+
inquiryResult,
|
|
4959
|
+
["taskToHelperMaps", "task_to_helper_maps"]
|
|
4960
|
+
);
|
|
4961
|
+
const helperToHelperMaps = this.readArrayPayload(
|
|
4962
|
+
inquiryResult,
|
|
4963
|
+
["helperToHelperMaps", "helper_to_helper_maps"]
|
|
4964
|
+
);
|
|
4965
|
+
const taskToGlobalMaps = this.readArrayPayload(
|
|
4966
|
+
inquiryResult,
|
|
4967
|
+
["taskToGlobalMaps", "task_to_global_maps"]
|
|
4968
|
+
);
|
|
4969
|
+
const helperToGlobalMaps = this.readArrayPayload(
|
|
4970
|
+
inquiryResult,
|
|
4971
|
+
["helperToGlobalMaps", "helper_to_global_maps"]
|
|
4972
|
+
);
|
|
3703
4973
|
const serviceInstances = this.normalizeServiceInstancesFromSync(
|
|
3704
4974
|
inquiryResult
|
|
3705
4975
|
);
|
|
@@ -3733,6 +5003,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3733
5003
|
serviceInstanceTransports: serviceInstanceTransports.length,
|
|
3734
5004
|
serviceManifests: serviceManifests.length,
|
|
3735
5005
|
tasks: tasks.length,
|
|
5006
|
+
helpers: helpers.length,
|
|
5007
|
+
globals: globals.length,
|
|
3736
5008
|
signals: signals.length,
|
|
3737
5009
|
intents: intents.length,
|
|
3738
5010
|
actors: actors.length,
|
|
@@ -3758,6 +5030,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3758
5030
|
serviceInstanceTransports,
|
|
3759
5031
|
serviceManifests,
|
|
3760
5032
|
tasks,
|
|
5033
|
+
helpers,
|
|
5034
|
+
globals,
|
|
3761
5035
|
signals,
|
|
3762
5036
|
intents,
|
|
3763
5037
|
actors,
|
|
@@ -3765,6 +5039,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3765
5039
|
directionalTaskMaps,
|
|
3766
5040
|
actorTaskMaps,
|
|
3767
5041
|
taskToRoutineMaps,
|
|
5042
|
+
taskToHelperMaps,
|
|
5043
|
+
helperToHelperMaps,
|
|
5044
|
+
taskToGlobalMaps,
|
|
5045
|
+
helperToGlobalMaps,
|
|
3768
5046
|
__inquiryMeta: inquiryResult.__inquiryMeta
|
|
3769
5047
|
};
|
|
3770
5048
|
},
|
|
@@ -4384,29 +5662,51 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4384
5662
|
this.runtimeStatusHeartbeatStarted = true;
|
|
4385
5663
|
if (!this.runtimeMetricsSamplingStarted) {
|
|
4386
5664
|
this.runtimeMetricsSamplingStarted = true;
|
|
5665
|
+
CadenzaService.emit(META_RUNTIME_METRICS_SAMPLE_TICK_SIGNAL, {});
|
|
4387
5666
|
CadenzaService.interval(
|
|
4388
5667
|
META_RUNTIME_METRICS_SAMPLE_TICK_SIGNAL,
|
|
4389
5668
|
{},
|
|
4390
5669
|
this.runtimeMetricsSampleIntervalMs,
|
|
4391
|
-
|
|
5670
|
+
false,
|
|
5671
|
+
this.buildJitteredIntervalStartDate(
|
|
5672
|
+
this.runtimeMetricsSampleIntervalMs,
|
|
5673
|
+
"runtime-metrics-sample"
|
|
5674
|
+
)
|
|
4392
5675
|
);
|
|
4393
5676
|
}
|
|
5677
|
+
CadenzaService.emit(META_RUNTIME_STATUS_HEARTBEAT_TICK_SIGNAL, {
|
|
5678
|
+
reason: "heartbeat"
|
|
5679
|
+
});
|
|
4394
5680
|
CadenzaService.interval(
|
|
4395
5681
|
META_RUNTIME_STATUS_HEARTBEAT_TICK_SIGNAL,
|
|
4396
5682
|
{ reason: "heartbeat" },
|
|
4397
5683
|
this.runtimeStatusHeartbeatIntervalMs,
|
|
4398
|
-
|
|
5684
|
+
false,
|
|
5685
|
+
this.buildJitteredIntervalStartDate(
|
|
5686
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5687
|
+
"runtime-status-heartbeat"
|
|
5688
|
+
)
|
|
4399
5689
|
);
|
|
4400
5690
|
CadenzaService.interval(
|
|
4401
5691
|
META_RUNTIME_STATUS_MONITOR_TICK_SIGNAL,
|
|
4402
5692
|
{},
|
|
4403
|
-
this.runtimeStatusHeartbeatIntervalMs
|
|
5693
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5694
|
+
false,
|
|
5695
|
+
this.buildJitteredIntervalStartDate(
|
|
5696
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5697
|
+
"runtime-status-monitor"
|
|
5698
|
+
)
|
|
4404
5699
|
);
|
|
5700
|
+
CadenzaService.emit(META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL, {});
|
|
4405
5701
|
CadenzaService.interval(
|
|
4406
5702
|
META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL,
|
|
4407
5703
|
{},
|
|
4408
5704
|
this.runtimeStatusRestRefreshIntervalMs,
|
|
4409
|
-
|
|
5705
|
+
false,
|
|
5706
|
+
this.buildJitteredIntervalStartDate(
|
|
5707
|
+
this.runtimeStatusRestRefreshIntervalMs,
|
|
5708
|
+
"runtime-status-rest-refresh"
|
|
5709
|
+
)
|
|
4410
5710
|
);
|
|
4411
5711
|
return true;
|
|
4412
5712
|
},
|
|
@@ -5411,11 +6711,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5411
6711
|
}
|
|
5412
6712
|
collectBootstrapFullSyncPayload(ctx) {
|
|
5413
6713
|
const serviceInstances = [];
|
|
6714
|
+
const serviceInstanceLeases = [];
|
|
5414
6715
|
const serviceInstanceTransports = [];
|
|
5415
6716
|
const manifestSnapshots = [];
|
|
5416
6717
|
const signalToTaskMaps = [];
|
|
5417
6718
|
const intentToTaskMaps = [];
|
|
5418
6719
|
const tasks = [];
|
|
6720
|
+
const helpers = [];
|
|
6721
|
+
const globals = [];
|
|
5419
6722
|
const signals = [];
|
|
5420
6723
|
const intents = [];
|
|
5421
6724
|
const actors = [];
|
|
@@ -5423,11 +6726,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5423
6726
|
const directionalTaskMaps = [];
|
|
5424
6727
|
const actorTaskMaps = [];
|
|
5425
6728
|
const taskToRoutineMaps = [];
|
|
6729
|
+
const taskToHelperMaps = [];
|
|
6730
|
+
const helperToHelperMaps = [];
|
|
6731
|
+
const taskToGlobalMaps = [];
|
|
6732
|
+
const helperToGlobalMaps = [];
|
|
5426
6733
|
const seenServiceInstances = /* @__PURE__ */ new Set();
|
|
6734
|
+
const seenServiceInstanceLeases = /* @__PURE__ */ new Set();
|
|
5427
6735
|
const seenServiceInstanceTransports = /* @__PURE__ */ new Set();
|
|
5428
6736
|
const seenSignalMaps = /* @__PURE__ */ new Set();
|
|
5429
6737
|
const seenIntentMaps = /* @__PURE__ */ new Set();
|
|
5430
6738
|
const seenTasks = /* @__PURE__ */ new Set();
|
|
6739
|
+
const seenHelpers = /* @__PURE__ */ new Set();
|
|
6740
|
+
const seenGlobals = /* @__PURE__ */ new Set();
|
|
5431
6741
|
const seenSignals = /* @__PURE__ */ new Set();
|
|
5432
6742
|
const seenIntents = /* @__PURE__ */ new Set();
|
|
5433
6743
|
const seenActors = /* @__PURE__ */ new Set();
|
|
@@ -5435,6 +6745,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5435
6745
|
const seenDirectionalTaskMaps = /* @__PURE__ */ new Set();
|
|
5436
6746
|
const seenActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5437
6747
|
const seenTaskToRoutineMaps = /* @__PURE__ */ new Set();
|
|
6748
|
+
const seenTaskToHelperMaps = /* @__PURE__ */ new Set();
|
|
6749
|
+
const seenHelperToHelperMaps = /* @__PURE__ */ new Set();
|
|
6750
|
+
const seenTaskToGlobalMaps = /* @__PURE__ */ new Set();
|
|
6751
|
+
const seenHelperToGlobalMaps = /* @__PURE__ */ new Set();
|
|
5438
6752
|
const contexts = Array.isArray(ctx.joinedContexts) ? [ctx, ...ctx.joinedContexts] : [ctx];
|
|
5439
6753
|
const pushUnique = (rows, target, seen, keyResolver) => {
|
|
5440
6754
|
for (const row of rows) {
|
|
@@ -5465,6 +6779,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5465
6779
|
"serviceInstance",
|
|
5466
6780
|
"service_instance"
|
|
5467
6781
|
]);
|
|
6782
|
+
const serviceInstanceLeaseRows = readDirectArrayPayload(candidate, [
|
|
6783
|
+
"serviceInstanceLeases",
|
|
6784
|
+
"service_instance_leases",
|
|
6785
|
+
"serviceInstanceLease",
|
|
6786
|
+
"service_instance_lease"
|
|
6787
|
+
]);
|
|
5468
6788
|
const serviceInstanceTransportRows = readDirectArrayPayload(candidate, [
|
|
5469
6789
|
"serviceInstanceTransports",
|
|
5470
6790
|
"service_instance_transports",
|
|
@@ -5495,6 +6815,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5495
6815
|
seenServiceInstances,
|
|
5496
6816
|
(row) => String(row.uuid ?? "").trim()
|
|
5497
6817
|
);
|
|
6818
|
+
pushUnique(
|
|
6819
|
+
serviceInstanceLeaseRows,
|
|
6820
|
+
serviceInstanceLeases,
|
|
6821
|
+
seenServiceInstanceLeases,
|
|
6822
|
+
(row) => String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
6823
|
+
);
|
|
5498
6824
|
pushUnique(
|
|
5499
6825
|
serviceInstanceTransportRows,
|
|
5500
6826
|
serviceInstanceTransports,
|
|
@@ -5515,6 +6841,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5515
6841
|
seenSignalMaps,
|
|
5516
6842
|
(row) => `${String(row.service_name ?? row.serviceName ?? "").trim()}|${String(
|
|
5517
6843
|
row.signal_name ?? row.signalName ?? ""
|
|
6844
|
+
).trim()}|${String(row.task_name ?? row.taskName ?? "").trim()}|${String(
|
|
6845
|
+
row.task_version ?? row.taskVersion ?? 1
|
|
5518
6846
|
).trim()}`
|
|
5519
6847
|
);
|
|
5520
6848
|
pushUnique(
|
|
@@ -5549,10 +6877,23 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5549
6877
|
seenSignalMaps,
|
|
5550
6878
|
(entry) => `${String(entry.service_name ?? entry.serviceName ?? "").trim()}|${String(
|
|
5551
6879
|
entry.signal_name ?? entry.signalName ?? ""
|
|
6880
|
+
).trim()}|${String(entry.task_name ?? entry.taskName ?? "").trim()}|${String(
|
|
6881
|
+
entry.task_version ?? entry.taskVersion ?? 1
|
|
5552
6882
|
).trim()}`
|
|
5553
6883
|
);
|
|
5554
6884
|
continue;
|
|
5555
6885
|
}
|
|
6886
|
+
if (row.status !== void 0 && (row.service_instance_id !== void 0 || row.serviceInstanceId !== void 0)) {
|
|
6887
|
+
pushUnique(
|
|
6888
|
+
[row],
|
|
6889
|
+
serviceInstanceLeases,
|
|
6890
|
+
seenServiceInstanceLeases,
|
|
6891
|
+
(entry) => String(
|
|
6892
|
+
entry.service_instance_id ?? entry.serviceInstanceId ?? ""
|
|
6893
|
+
).trim()
|
|
6894
|
+
);
|
|
6895
|
+
continue;
|
|
6896
|
+
}
|
|
5556
6897
|
if (row.service_instance_id !== void 0 || row.serviceInstanceId !== void 0) {
|
|
5557
6898
|
pushUnique(
|
|
5558
6899
|
[row],
|
|
@@ -5581,9 +6922,40 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5581
6922
|
}
|
|
5582
6923
|
}
|
|
5583
6924
|
}
|
|
5584
|
-
const
|
|
5585
|
-
|
|
5586
|
-
|
|
6925
|
+
const mergedServiceInstances = overlayServiceInstancesWithLeases(
|
|
6926
|
+
serviceInstances,
|
|
6927
|
+
serviceInstanceLeases
|
|
6928
|
+
);
|
|
6929
|
+
const activeServiceInstanceIds = new Set(
|
|
6930
|
+
mergedServiceInstances.filter((row) => row.is_active === true || row.isActive === true).map((row) => String(row.uuid ?? "").trim()).filter((uuid9) => uuid9.length > 0)
|
|
6931
|
+
);
|
|
6932
|
+
const filteredServiceInstances = activeServiceInstanceIds.size > 0 ? mergedServiceInstances.filter(
|
|
6933
|
+
(row) => activeServiceInstanceIds.has(String(row.uuid ?? "").trim())
|
|
6934
|
+
) : mergedServiceInstances;
|
|
6935
|
+
const filteredServiceInstanceTransports = activeServiceInstanceIds.size > 0 ? serviceInstanceTransports.filter(
|
|
6936
|
+
(row) => activeServiceInstanceIds.has(
|
|
6937
|
+
String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
6938
|
+
)
|
|
6939
|
+
) : serviceInstanceTransports;
|
|
6940
|
+
const filteredManifestSnapshots = activeServiceInstanceIds.size > 0 ? manifestSnapshots.filter(
|
|
6941
|
+
(snapshot) => activeServiceInstanceIds.has(snapshot.serviceInstanceId)
|
|
6942
|
+
) : manifestSnapshots;
|
|
6943
|
+
const activeServiceNames = new Set(
|
|
6944
|
+
filteredServiceInstances.map((row) => String(row.service_name ?? row.serviceName ?? "").trim()).filter((serviceName) => serviceName.length > 0)
|
|
6945
|
+
);
|
|
6946
|
+
const filteredSignalToTaskMaps = activeServiceNames.size > 0 ? signalToTaskMaps.filter(
|
|
6947
|
+
(row) => activeServiceNames.has(
|
|
6948
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6949
|
+
)
|
|
6950
|
+
) : signalToTaskMaps;
|
|
6951
|
+
const filteredIntentToTaskMaps = activeServiceNames.size > 0 ? intentToTaskMaps.filter(
|
|
6952
|
+
(row) => activeServiceNames.has(
|
|
6953
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6954
|
+
)
|
|
6955
|
+
) : intentToTaskMaps;
|
|
6956
|
+
const hasExplicitSignalRoutingRows = filteredSignalToTaskMaps.length > 0;
|
|
6957
|
+
const hasExplicitIntentRoutingRows = filteredIntentToTaskMaps.length > 0;
|
|
6958
|
+
const latestManifestSnapshots = selectLatestServiceManifestSnapshots(filteredManifestSnapshots);
|
|
5587
6959
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
5588
6960
|
latestManifestSnapshots
|
|
5589
6961
|
);
|
|
@@ -5603,6 +6975,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5603
6975
|
row.version ?? 1
|
|
5604
6976
|
).trim()}`
|
|
5605
6977
|
);
|
|
6978
|
+
pushUnique(
|
|
6979
|
+
explodedManifest.helpers,
|
|
6980
|
+
helpers,
|
|
6981
|
+
seenHelpers,
|
|
6982
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.name ?? "").trim()}|${String(
|
|
6983
|
+
row.version ?? 1
|
|
6984
|
+
).trim()}`
|
|
6985
|
+
);
|
|
6986
|
+
pushUnique(
|
|
6987
|
+
explodedManifest.globals,
|
|
6988
|
+
globals,
|
|
6989
|
+
seenGlobals,
|
|
6990
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.name ?? "").trim()}|${String(
|
|
6991
|
+
row.version ?? 1
|
|
6992
|
+
).trim()}`
|
|
6993
|
+
);
|
|
5606
6994
|
pushUnique(
|
|
5607
6995
|
explodedManifest.signals,
|
|
5608
6996
|
signals,
|
|
@@ -5663,10 +7051,54 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5663
7051
|
row.task_version ?? 1
|
|
5664
7052
|
).trim()}`
|
|
5665
7053
|
);
|
|
7054
|
+
pushUnique(
|
|
7055
|
+
explodedManifest.taskToHelperMaps,
|
|
7056
|
+
taskToHelperMaps,
|
|
7057
|
+
seenTaskToHelperMaps,
|
|
7058
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
7059
|
+
row.task_version ?? 1
|
|
7060
|
+
).trim()}|${String(row.alias ?? "").trim()}|${String(
|
|
7061
|
+
row.helper_name ?? ""
|
|
7062
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}`
|
|
7063
|
+
);
|
|
7064
|
+
pushUnique(
|
|
7065
|
+
explodedManifest.helperToHelperMaps,
|
|
7066
|
+
helperToHelperMaps,
|
|
7067
|
+
seenHelperToHelperMaps,
|
|
7068
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(
|
|
7069
|
+
row.helper_name ?? ""
|
|
7070
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}|${String(
|
|
7071
|
+
row.alias ?? ""
|
|
7072
|
+
).trim()}|${String(row.dependency_helper_name ?? "").trim()}|${String(
|
|
7073
|
+
row.dependency_helper_version ?? 1
|
|
7074
|
+
).trim()}`
|
|
7075
|
+
);
|
|
7076
|
+
pushUnique(
|
|
7077
|
+
explodedManifest.taskToGlobalMaps,
|
|
7078
|
+
taskToGlobalMaps,
|
|
7079
|
+
seenTaskToGlobalMaps,
|
|
7080
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
7081
|
+
row.task_version ?? 1
|
|
7082
|
+
).trim()}|${String(row.alias ?? "").trim()}|${String(
|
|
7083
|
+
row.global_name ?? ""
|
|
7084
|
+
).trim()}|${String(row.global_version ?? 1).trim()}`
|
|
7085
|
+
);
|
|
7086
|
+
pushUnique(
|
|
7087
|
+
explodedManifest.helperToGlobalMaps,
|
|
7088
|
+
helperToGlobalMaps,
|
|
7089
|
+
seenHelperToGlobalMaps,
|
|
7090
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(
|
|
7091
|
+
row.helper_name ?? ""
|
|
7092
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}|${String(
|
|
7093
|
+
row.alias ?? ""
|
|
7094
|
+
).trim()}|${String(row.global_name ?? "").trim()}|${String(
|
|
7095
|
+
row.global_version ?? 1
|
|
7096
|
+
).trim()}`
|
|
7097
|
+
);
|
|
5666
7098
|
if (!hasExplicitSignalRoutingRows) {
|
|
5667
7099
|
pushUnique(
|
|
5668
7100
|
explodedManifest.signalToTaskMaps,
|
|
5669
|
-
|
|
7101
|
+
filteredSignalToTaskMaps,
|
|
5670
7102
|
seenSignalMaps,
|
|
5671
7103
|
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
5672
7104
|
row.service_name ?? ""
|
|
@@ -5678,7 +7110,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5678
7110
|
if (!hasExplicitIntentRoutingRows) {
|
|
5679
7111
|
pushUnique(
|
|
5680
7112
|
explodedManifest.intentToTaskMaps,
|
|
5681
|
-
|
|
7113
|
+
filteredIntentToTaskMaps,
|
|
5682
7114
|
seenIntentMaps,
|
|
5683
7115
|
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
5684
7116
|
row.service_name ?? ""
|
|
@@ -5688,10 +7120,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5688
7120
|
);
|
|
5689
7121
|
}
|
|
5690
7122
|
return {
|
|
5691
|
-
serviceInstances,
|
|
5692
|
-
|
|
7123
|
+
serviceInstances: filteredServiceInstances,
|
|
7124
|
+
serviceInstanceLeases,
|
|
7125
|
+
serviceInstanceTransports: filteredServiceInstanceTransports,
|
|
5693
7126
|
serviceManifests,
|
|
5694
7127
|
tasks,
|
|
7128
|
+
helpers,
|
|
7129
|
+
globals,
|
|
5695
7130
|
signals,
|
|
5696
7131
|
intents,
|
|
5697
7132
|
actors,
|
|
@@ -5699,8 +7134,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5699
7134
|
directionalTaskMaps,
|
|
5700
7135
|
actorTaskMaps,
|
|
5701
7136
|
taskToRoutineMaps,
|
|
5702
|
-
|
|
5703
|
-
|
|
7137
|
+
taskToHelperMaps,
|
|
7138
|
+
helperToHelperMaps,
|
|
7139
|
+
taskToGlobalMaps,
|
|
7140
|
+
helperToGlobalMaps,
|
|
7141
|
+
signalToTaskMaps: filteredSignalToTaskMaps,
|
|
7142
|
+
intentToTaskMaps: filteredIntentToTaskMaps
|
|
5704
7143
|
};
|
|
5705
7144
|
}
|
|
5706
7145
|
buildRemoteIntentDeputyKey(map) {
|
|
@@ -6129,29 +7568,32 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6129
7568
|
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
6130
7569
|
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
6131
7570
|
try {
|
|
6132
|
-
const
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
__transportOrigin: target.origin,
|
|
6142
|
-
__transportProtocol: "rest",
|
|
6143
|
-
__transportProtocols: ["rest"],
|
|
6144
|
-
__routeKey: target.routeKey,
|
|
6145
|
-
routeKey: target.routeKey,
|
|
6146
|
-
__fetchId: target.fetchId,
|
|
6147
|
-
fetchId: target.fetchId,
|
|
6148
|
-
__metadata: {
|
|
6149
|
-
...context.__metadata && typeof context.__metadata === "object" ? context.__metadata : {},
|
|
7571
|
+
const sanitizedContext = sanitizeAuthorityBootstrapDelegationContext(context);
|
|
7572
|
+
const requestBody = compactAuthorityBootstrapRequestBody(
|
|
7573
|
+
stripDelegationRequestSnapshot(
|
|
7574
|
+
ensureDelegationContextMetadata(
|
|
7575
|
+
attachDelegationRequestSnapshot({
|
|
7576
|
+
...sanitizedContext,
|
|
7577
|
+
__remoteRoutineName: remoteRoutineName,
|
|
7578
|
+
__serviceName: "CadenzaDB",
|
|
7579
|
+
__localServiceName: this.serviceName,
|
|
6150
7580
|
__timeout: timeoutMs,
|
|
6151
7581
|
__syncing: true,
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
7582
|
+
__transportOrigin: target.origin,
|
|
7583
|
+
__transportProtocol: "rest",
|
|
7584
|
+
__transportProtocols: ["rest"],
|
|
7585
|
+
__routeKey: target.routeKey,
|
|
7586
|
+
routeKey: target.routeKey,
|
|
7587
|
+
__fetchId: target.fetchId,
|
|
7588
|
+
fetchId: target.fetchId,
|
|
7589
|
+
__metadata: {
|
|
7590
|
+
...sanitizedContext.__metadata && typeof sanitizedContext.__metadata === "object" ? sanitizedContext.__metadata : {},
|
|
7591
|
+
__timeout: timeoutMs,
|
|
7592
|
+
__syncing: true,
|
|
7593
|
+
__authorityBootstrapChannel: true
|
|
7594
|
+
}
|
|
7595
|
+
})
|
|
7596
|
+
)
|
|
6155
7597
|
)
|
|
6156
7598
|
);
|
|
6157
7599
|
const response = await globalThis.fetch(`${target.origin}/delegation`, {
|
|
@@ -6164,22 +7606,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6164
7606
|
});
|
|
6165
7607
|
if ("ok" in response && response.ok === false) {
|
|
6166
7608
|
return {
|
|
6167
|
-
...
|
|
7609
|
+
...sanitizedContext,
|
|
6168
7610
|
__error: `Bootstrap authority delegation failed with HTTP ${response.status}`,
|
|
6169
7611
|
errored: true
|
|
6170
7612
|
};
|
|
6171
7613
|
}
|
|
6172
7614
|
const payload = typeof response.json === "function" ? await response.json() : response;
|
|
6173
7615
|
return payload && typeof payload === "object" ? {
|
|
6174
|
-
...
|
|
7616
|
+
...sanitizedContext,
|
|
6175
7617
|
...payload
|
|
6176
7618
|
} : {
|
|
6177
|
-
...
|
|
7619
|
+
...sanitizedContext,
|
|
6178
7620
|
returnedValue: payload
|
|
6179
7621
|
};
|
|
6180
7622
|
} catch (error) {
|
|
6181
7623
|
return {
|
|
6182
|
-
...context,
|
|
7624
|
+
...sanitizeAuthorityBootstrapDelegationContext(context),
|
|
6183
7625
|
__error: error instanceof Error ? error.message : String(error),
|
|
6184
7626
|
errored: true
|
|
6185
7627
|
};
|
|
@@ -6306,12 +7748,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6306
7748
|
};
|
|
6307
7749
|
const [
|
|
6308
7750
|
serviceInstances,
|
|
7751
|
+
serviceInstanceLeases,
|
|
6309
7752
|
serviceInstanceTransports,
|
|
6310
7753
|
serviceManifests,
|
|
6311
7754
|
signalToTaskMaps,
|
|
6312
7755
|
intentToTaskMaps
|
|
6313
7756
|
] = await Promise.all([
|
|
6314
7757
|
DatabaseController.instance.queryAuthorityTableRows("service_instance"),
|
|
7758
|
+
queryOptionalAuthorityRoutingRows("service_instance_lease"),
|
|
6315
7759
|
DatabaseController.instance.queryAuthorityTableRows(
|
|
6316
7760
|
"service_instance_transport"
|
|
6317
7761
|
),
|
|
@@ -6324,6 +7768,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6324
7768
|
__syncing: true,
|
|
6325
7769
|
...this.collectBootstrapFullSyncPayload({
|
|
6326
7770
|
serviceInstances,
|
|
7771
|
+
serviceInstanceLeases,
|
|
6327
7772
|
serviceInstanceTransports,
|
|
6328
7773
|
serviceManifests,
|
|
6329
7774
|
signalToTaskMaps,
|
|
@@ -6356,9 +7801,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6356
7801
|
return false;
|
|
6357
7802
|
}
|
|
6358
7803
|
const scheduleRetry = (reason, error) => {
|
|
6359
|
-
const
|
|
7804
|
+
const baseDelayMs = SERVICE_COMMUNICATION_PERSIST_RETRY_DELAYS_MS[descriptor.retryAttempt];
|
|
6360
7805
|
const nextAttempt = descriptor.retryAttempt + 1;
|
|
6361
|
-
if (
|
|
7806
|
+
if (baseDelayMs !== void 0) {
|
|
7807
|
+
const delayMs = buildDeterministicJitteredDelayMs(
|
|
7808
|
+
baseDelayMs,
|
|
7809
|
+
this.serviceCommunicationRetryJitterRatio,
|
|
7810
|
+
`${descriptor.serviceInstanceId}:${descriptor.communicationType}:${descriptor.retryAttempt}`
|
|
7811
|
+
);
|
|
6362
7812
|
CadenzaService.schedule(
|
|
6363
7813
|
retrySignal,
|
|
6364
7814
|
buildServiceCommunicationRetryContext({
|
|
@@ -6506,6 +7956,31 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6506
7956
|
})
|
|
6507
7957
|
);
|
|
6508
7958
|
}
|
|
7959
|
+
buildDeterministicInstanceJitterKey(scope) {
|
|
7960
|
+
const serviceName = String(this.serviceName ?? "").trim() || "unknown-service";
|
|
7961
|
+
const serviceInstanceId = String(this.serviceInstanceId ?? "").trim() || "pending-instance";
|
|
7962
|
+
return `${serviceName}:${serviceInstanceId}:${scope}`;
|
|
7963
|
+
}
|
|
7964
|
+
buildJitteredIntervalStartDate(intervalMs, scope) {
|
|
7965
|
+
const jitterOffsetMs = buildDeterministicJitterOffsetMs(
|
|
7966
|
+
intervalMs,
|
|
7967
|
+
this.runtimeStatusLoopJitterRatio,
|
|
7968
|
+
this.buildDeterministicInstanceJitterKey(scope)
|
|
7969
|
+
);
|
|
7970
|
+
if (jitterOffsetMs <= 0) {
|
|
7971
|
+
return void 0;
|
|
7972
|
+
}
|
|
7973
|
+
return new Date(Date.now() + intervalMs + jitterOffsetMs);
|
|
7974
|
+
}
|
|
7975
|
+
buildJitteredBootstrapRetryDelayMs(baseDelayMs, attempt) {
|
|
7976
|
+
return buildDeterministicJitteredDelayMs(
|
|
7977
|
+
baseDelayMs,
|
|
7978
|
+
this.bootstrapFullSyncRetryJitterRatio,
|
|
7979
|
+
this.buildDeterministicInstanceJitterKey(
|
|
7980
|
+
`bootstrap-full-sync-retry-${attempt}`
|
|
7981
|
+
)
|
|
7982
|
+
);
|
|
7983
|
+
}
|
|
6509
7984
|
ensureAuthorityBootstrapSignalTransmissions() {
|
|
6510
7985
|
if (this.serviceName !== "CadenzaDB") {
|
|
6511
7986
|
return false;
|
|
@@ -6583,8 +8058,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6583
8058
|
}
|
|
6584
8059
|
const retryGeneration = this.bootstrapFullSyncRetryGeneration;
|
|
6585
8060
|
const retryReason = this.bootstrapFullSyncRetryReason ?? "service_registry_bootstrap_retry";
|
|
6586
|
-
const delayMs = EARLY_FULL_SYNC_DELAYS_MS[this.bootstrapFullSyncRetryIndex];
|
|
6587
8061
|
const attempt = this.bootstrapFullSyncRetryIndex + 1;
|
|
8062
|
+
const delayMs = this.buildJitteredBootstrapRetryDelayMs(
|
|
8063
|
+
EARLY_FULL_SYNC_DELAYS_MS[this.bootstrapFullSyncRetryIndex],
|
|
8064
|
+
attempt
|
|
8065
|
+
);
|
|
6588
8066
|
this.bootstrapFullSyncRetryIndex += 1;
|
|
6589
8067
|
this.bootstrapFullSyncRetryTimer = setTimeout(() => {
|
|
6590
8068
|
this.bootstrapFullSyncRetryTimer = null;
|
|
@@ -8487,6 +9965,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8487
9965
|
isNonResponsive,
|
|
8488
9966
|
isBlocked
|
|
8489
9967
|
);
|
|
9968
|
+
const cpuUsage = this.readRuntimeStatusMetric(ctx, "cpuUsage", "cpu", "cpuLoad");
|
|
9969
|
+
const memoryUsage = this.readRuntimeStatusMetric(
|
|
9970
|
+
ctx,
|
|
9971
|
+
"memoryUsage",
|
|
9972
|
+
"memory",
|
|
9973
|
+
"memoryPressure"
|
|
9974
|
+
);
|
|
9975
|
+
const eventLoopLag = this.readRuntimeStatusMetric(
|
|
9976
|
+
ctx,
|
|
9977
|
+
"eventLoopLag",
|
|
9978
|
+
"eventLoopLagMs"
|
|
9979
|
+
);
|
|
8490
9980
|
return {
|
|
8491
9981
|
serviceName,
|
|
8492
9982
|
serviceInstanceId,
|
|
@@ -8499,22 +9989,20 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8499
9989
|
state: ctx.state === "healthy" || ctx.state === "degraded" || ctx.state === "overloaded" || ctx.state === "unavailable" ? ctx.state : resolved.state,
|
|
8500
9990
|
acceptingWork: typeof ctx.acceptingWork === "boolean" ? ctx.acceptingWork : resolved.acceptingWork,
|
|
8501
9991
|
numberOfRunningGraphs,
|
|
8502
|
-
cpuUsage
|
|
8503
|
-
memoryUsage
|
|
8504
|
-
|
|
8505
|
-
"memoryUsage",
|
|
8506
|
-
"memory",
|
|
8507
|
-
"memoryPressure"
|
|
8508
|
-
),
|
|
8509
|
-
eventLoopLag: this.readRuntimeStatusMetric(
|
|
8510
|
-
ctx,
|
|
8511
|
-
"eventLoopLag",
|
|
8512
|
-
"eventLoopLagMs"
|
|
8513
|
-
),
|
|
9992
|
+
cpuUsage,
|
|
9993
|
+
memoryUsage,
|
|
9994
|
+
eventLoopLag,
|
|
8514
9995
|
isActive,
|
|
8515
9996
|
isNonResponsive,
|
|
8516
9997
|
isBlocked,
|
|
8517
|
-
health: ctx.health ?? ctx.__health
|
|
9998
|
+
health: sanitizeAuthorityRuntimeStatusHealth(ctx.health ?? ctx.__health, {
|
|
9999
|
+
state: ctx.state === "healthy" || ctx.state === "degraded" || ctx.state === "overloaded" || ctx.state === "unavailable" ? ctx.state : resolved.state,
|
|
10000
|
+
acceptingWork: typeof ctx.acceptingWork === "boolean" ? ctx.acceptingWork : resolved.acceptingWork,
|
|
10001
|
+
reportedAt: ctx.reportedAt ?? (typeof ctx.__reportedAt === "string" ? ctx.__reportedAt : void 0) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
10002
|
+
cpuUsage,
|
|
10003
|
+
memoryUsage,
|
|
10004
|
+
eventLoopLag
|
|
10005
|
+
})
|
|
8518
10006
|
};
|
|
8519
10007
|
}
|
|
8520
10008
|
applyRuntimeStatusReport(report) {
|
|
@@ -8555,12 +10043,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8555
10043
|
instance.isFrontend = report.isFrontend;
|
|
8556
10044
|
}
|
|
8557
10045
|
instance.numberOfRunningGraphs = report.numberOfRunningGraphs;
|
|
8558
|
-
const
|
|
10046
|
+
const runtimeStatusHealth = sanitizeAuthorityRuntimeStatusHealth(report.health, {
|
|
10047
|
+
state: report.state,
|
|
10048
|
+
acceptingWork: report.acceptingWork,
|
|
10049
|
+
reportedAt: report.reportedAt,
|
|
8559
10050
|
cpuUsage: report.cpuUsage ?? null,
|
|
8560
10051
|
memoryUsage: report.memoryUsage ?? null,
|
|
8561
|
-
eventLoopLag: report.eventLoopLag ?? null
|
|
8562
|
-
|
|
8563
|
-
};
|
|
10052
|
+
eventLoopLag: report.eventLoopLag ?? null
|
|
10053
|
+
});
|
|
8564
10054
|
instance.isActive = report.isActive;
|
|
8565
10055
|
instance.isNonResponsive = report.isNonResponsive;
|
|
8566
10056
|
instance.isBlocked = report.isBlocked;
|
|
@@ -8569,13 +10059,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8569
10059
|
instance.reportedAt = report.reportedAt;
|
|
8570
10060
|
instance.health = {
|
|
8571
10061
|
...instance.health ?? {},
|
|
8572
|
-
...
|
|
8573
|
-
...runtimeMetricsHealth,
|
|
8574
|
-
runtimeStatus: {
|
|
8575
|
-
state: report.state,
|
|
8576
|
-
acceptingWork: report.acceptingWork,
|
|
8577
|
-
reportedAt: report.reportedAt
|
|
8578
|
-
}
|
|
10062
|
+
...runtimeStatusHealth ?? {}
|
|
8579
10063
|
};
|
|
8580
10064
|
this.lastHeartbeatAtByInstance.set(report.serviceInstanceId, Date.now());
|
|
8581
10065
|
this.missedHeartbeatsByInstance.set(report.serviceInstanceId, 0);
|
|
@@ -8747,15 +10231,20 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8747
10231
|
isActive: snapshot.isActive,
|
|
8748
10232
|
isNonResponsive: snapshot.isNonResponsive,
|
|
8749
10233
|
isBlocked: snapshot.isBlocked,
|
|
8750
|
-
health:
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
10234
|
+
health: sanitizeAuthorityRuntimeStatusHealth(
|
|
10235
|
+
{
|
|
10236
|
+
...localInstance.health ?? {},
|
|
10237
|
+
...this.buildRuntimeMetricsHealthPayload(runtimeMetricsSnapshot) ?? {}
|
|
10238
|
+
},
|
|
10239
|
+
{
|
|
8754
10240
|
state: snapshot.state,
|
|
8755
10241
|
acceptingWork: snapshot.acceptingWork,
|
|
8756
|
-
reportedAt
|
|
10242
|
+
reportedAt,
|
|
10243
|
+
cpuUsage: runtimeMetricsSnapshot?.cpuUsage ?? null,
|
|
10244
|
+
memoryUsage: runtimeMetricsSnapshot?.memoryUsage ?? null,
|
|
10245
|
+
eventLoopLag: runtimeMetricsSnapshot?.eventLoopLag ?? null
|
|
8757
10246
|
}
|
|
8758
|
-
|
|
10247
|
+
)
|
|
8759
10248
|
};
|
|
8760
10249
|
this.applyRuntimeStatusReport(report);
|
|
8761
10250
|
return detailLevel === "full" ? report : this.stripRuntimeStatusReportForPeer(report);
|
|
@@ -9109,6 +10598,32 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9109
10598
|
if (!instancePersisted) {
|
|
9110
10599
|
return false;
|
|
9111
10600
|
}
|
|
10601
|
+
await this.delegateAuthorityLifecycleUpdate(
|
|
10602
|
+
"Update service_instance_lease",
|
|
10603
|
+
{
|
|
10604
|
+
reason,
|
|
10605
|
+
graceful: true,
|
|
10606
|
+
data: {
|
|
10607
|
+
status: "inactive",
|
|
10608
|
+
is_ready: false,
|
|
10609
|
+
readiness_reason: "graceful_shutdown",
|
|
10610
|
+
lease_expires_at: reportedAt,
|
|
10611
|
+
last_lease_renewed_at: reportedAt,
|
|
10612
|
+
last_ready_at: null,
|
|
10613
|
+
last_observed_transport_at: reportedAt,
|
|
10614
|
+
shutdown_requested_at: reportedAt,
|
|
10615
|
+
deleted: false,
|
|
10616
|
+
modified: reportedAt
|
|
10617
|
+
},
|
|
10618
|
+
queryData: {
|
|
10619
|
+
filter: {
|
|
10620
|
+
service_instance_id: localInstance.uuid
|
|
10621
|
+
}
|
|
10622
|
+
},
|
|
10623
|
+
__serviceInstanceId: localInstance.uuid
|
|
10624
|
+
},
|
|
10625
|
+
Math.max(1e3, timeoutMs)
|
|
10626
|
+
);
|
|
9112
10627
|
for (const transport of localInstance.transports) {
|
|
9113
10628
|
if (!isPersistedUuid(transport.uuid)) {
|
|
9114
10629
|
continue;
|
|
@@ -9260,6 +10775,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9260
10775
|
};
|
|
9261
10776
|
}
|
|
9262
10777
|
reset() {
|
|
10778
|
+
this.clearBootstrapFullSyncRetryTimer();
|
|
9263
10779
|
this.instances.clear();
|
|
9264
10780
|
this.deputies.clear();
|
|
9265
10781
|
this.remoteSignals.clear();
|
|
@@ -9283,13 +10799,30 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9283
10799
|
this.lastRuntimeStatusSnapshot = null;
|
|
9284
10800
|
this.isFrontend = false;
|
|
9285
10801
|
this.localInstanceSeed = null;
|
|
10802
|
+
this.bootstrapFullSyncRetryIndex = 0;
|
|
10803
|
+
this.bootstrapFullSyncRetryGeneration = 0;
|
|
10804
|
+
this.bootstrapFullSyncSatisfied = false;
|
|
10805
|
+
this.bootstrapFullSyncRetryReason = null;
|
|
10806
|
+
this.knownGlobalSignalMaps.clear();
|
|
10807
|
+
this.authorityBootstrapRoute = {
|
|
10808
|
+
origin: null,
|
|
10809
|
+
role: "internal",
|
|
10810
|
+
routeKey: null,
|
|
10811
|
+
fetchId: null,
|
|
10812
|
+
serviceInstanceId: null,
|
|
10813
|
+
serviceTransportId: null,
|
|
10814
|
+
handshakeEstablished: false
|
|
10815
|
+
};
|
|
10816
|
+
this.authorityBootstrapHandshakeInFlight = false;
|
|
10817
|
+
this.authorityFullSyncResponderTask = null;
|
|
10818
|
+
this.authorityServiceCommunicationPersistenceTask = null;
|
|
9286
10819
|
}
|
|
9287
10820
|
};
|
|
9288
10821
|
|
|
9289
10822
|
// src/graph/definition/SignalTransmissionTask.ts
|
|
9290
|
-
var
|
|
10823
|
+
var import_core3 = require("@cadenza.io/core");
|
|
9291
10824
|
var import_uuid4 = require("uuid");
|
|
9292
|
-
var SignalTransmissionTask = class extends
|
|
10825
|
+
var SignalTransmissionTask = class extends import_core3.Task {
|
|
9293
10826
|
/**
|
|
9294
10827
|
* Constructs a new instance of the class and initializes it with the provided parameters.
|
|
9295
10828
|
*
|
|
@@ -9391,7 +10924,25 @@ var SignalTransmissionTask = class extends import_core2.Task {
|
|
|
9391
10924
|
...ctx
|
|
9392
10925
|
})
|
|
9393
10926
|
);
|
|
9394
|
-
|
|
10927
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
10928
|
+
this,
|
|
10929
|
+
deputyContext,
|
|
10930
|
+
emit2,
|
|
10931
|
+
inquire,
|
|
10932
|
+
progressCallback
|
|
10933
|
+
) : {
|
|
10934
|
+
helpers: {},
|
|
10935
|
+
globals: {}
|
|
10936
|
+
};
|
|
10937
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
10938
|
+
};
|
|
10939
|
+
return this.taskFunction(
|
|
10940
|
+
deputyContext,
|
|
10941
|
+
emit2,
|
|
10942
|
+
inquire,
|
|
10943
|
+
resolvedTools,
|
|
10944
|
+
resolvedProgressCallback
|
|
10945
|
+
);
|
|
9395
10946
|
}
|
|
9396
10947
|
};
|
|
9397
10948
|
|
|
@@ -11197,8 +12748,8 @@ var SocketController = class _SocketController {
|
|
|
11197
12748
|
}
|
|
11198
12749
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(delegateCtx);
|
|
11199
12750
|
const normalizedDelegateCtx = ensureDelegationContextMetadata(
|
|
11200
|
-
|
|
11201
|
-
|
|
12751
|
+
restoreDelegationRequestSnapshot(
|
|
12752
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
11202
12753
|
)
|
|
11203
12754
|
);
|
|
11204
12755
|
delete normalizedDelegateCtx.__isSubMeta;
|
|
@@ -11271,13 +12822,11 @@ var SocketController = class _SocketController {
|
|
|
11271
12822
|
return resolvedResultContext;
|
|
11272
12823
|
} catch (error) {
|
|
11273
12824
|
const message = error instanceof Error ? error.message : String(error);
|
|
11274
|
-
const failedContext =
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
...normalizedDelegateCtx.__metadata
|
|
11280
|
-
};
|
|
12825
|
+
const failedContext = buildDelegationFailureContext(
|
|
12826
|
+
"meta.socket_client.delegate_failed",
|
|
12827
|
+
normalizedDelegateCtx,
|
|
12828
|
+
error
|
|
12829
|
+
);
|
|
11281
12830
|
if (deputyExecId) {
|
|
11282
12831
|
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
11283
12832
|
...failedContext,
|
|
@@ -11964,7 +13513,7 @@ var SignalController = class _SignalController {
|
|
|
11964
13513
|
}
|
|
11965
13514
|
const traceContext = { ...ctx };
|
|
11966
13515
|
delete traceContext.__traceCreatedBySignalBroker;
|
|
11967
|
-
const sanitizedTraceContext =
|
|
13516
|
+
const sanitizedTraceContext = sanitizeExecutionPersistenceContext(traceContext);
|
|
11968
13517
|
const routineMetadata = resolveRoutinePersistenceMetadata(traceContext);
|
|
11969
13518
|
const { context: routineContext, metaContext: routineMetaContext } = splitRoutinePersistenceContext(traceContext);
|
|
11970
13519
|
const traceCreatedBySignalBroker = ctx.__traceCreatedBySignalBroker === true || signalEmission.__traceCreatedBySignalBroker === true;
|
|
@@ -12282,10 +13831,55 @@ var RuntimeValidationController = class _RuntimeValidationController {
|
|
|
12282
13831
|
};
|
|
12283
13832
|
|
|
12284
13833
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
12285
|
-
var
|
|
13834
|
+
var import_core4 = require("@cadenza.io/core");
|
|
12286
13835
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
12287
13836
|
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
12288
13837
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
13838
|
+
function findNestedContextValue(ctx, key) {
|
|
13839
|
+
if (!ctx || typeof ctx !== "object") {
|
|
13840
|
+
return void 0;
|
|
13841
|
+
}
|
|
13842
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key) || ctx[key] !== void 0) {
|
|
13843
|
+
return ctx[key];
|
|
13844
|
+
}
|
|
13845
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
13846
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
13847
|
+
const nested = joinedContexts[index];
|
|
13848
|
+
if (!nested || typeof nested !== "object") {
|
|
13849
|
+
continue;
|
|
13850
|
+
}
|
|
13851
|
+
const nestedValue = findNestedContextValue(nested, key);
|
|
13852
|
+
if (nestedValue !== void 0) {
|
|
13853
|
+
return nestedValue;
|
|
13854
|
+
}
|
|
13855
|
+
}
|
|
13856
|
+
return void 0;
|
|
13857
|
+
}
|
|
13858
|
+
function resolveActorSessionStateRow(ctx) {
|
|
13859
|
+
const singular = findNestedContextValue(ctx, "actorSessionState");
|
|
13860
|
+
if (singular && typeof singular === "object" && !Array.isArray(singular)) {
|
|
13861
|
+
return singular;
|
|
13862
|
+
}
|
|
13863
|
+
const plural = findNestedContextValue(ctx, "actorSessionStates");
|
|
13864
|
+
if (Array.isArray(plural)) {
|
|
13865
|
+
const first = plural.find(
|
|
13866
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
13867
|
+
);
|
|
13868
|
+
if (first) {
|
|
13869
|
+
return first;
|
|
13870
|
+
}
|
|
13871
|
+
}
|
|
13872
|
+
const rows = findNestedContextValue(ctx, "rows");
|
|
13873
|
+
if (Array.isArray(rows)) {
|
|
13874
|
+
const first = rows.find(
|
|
13875
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
13876
|
+
);
|
|
13877
|
+
if (first) {
|
|
13878
|
+
return first;
|
|
13879
|
+
}
|
|
13880
|
+
}
|
|
13881
|
+
return null;
|
|
13882
|
+
}
|
|
12289
13883
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
12290
13884
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
12291
13885
|
}
|
|
@@ -12358,7 +13952,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12358
13952
|
)
|
|
12359
13953
|
);
|
|
12360
13954
|
}
|
|
12361
|
-
const row =
|
|
13955
|
+
const row = resolveActorSessionStateRow(ctx);
|
|
12362
13956
|
if (!row) {
|
|
12363
13957
|
return {
|
|
12364
13958
|
__success: true,
|
|
@@ -12536,11 +14130,11 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12536
14130
|
},
|
|
12537
14131
|
"Validates and prepares actor_session_state payload for strict write-through persistence.",
|
|
12538
14132
|
localActorSessionTaskOptions
|
|
12539
|
-
).then(insertAndValidateActorSessionStateTask).respondsTo(
|
|
14133
|
+
).then(insertAndValidateActorSessionStateTask).respondsTo(import_core4.META_ACTOR_SESSION_STATE_PERSIST_INTENT);
|
|
12540
14134
|
}
|
|
12541
14135
|
|
|
12542
14136
|
// src/graph/controllers/GraphSyncController.ts
|
|
12543
|
-
var
|
|
14137
|
+
var import_core5 = require("@cadenza.io/core");
|
|
12544
14138
|
var import_uuid6 = require("uuid");
|
|
12545
14139
|
var ACTOR_TASK_METADATA2 = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
12546
14140
|
function getActorTaskRuntimeMetadata2(taskFunction) {
|
|
@@ -12601,6 +14195,16 @@ function buildActorRegistrationData(actor) {
|
|
|
12601
14195
|
version: 1
|
|
12602
14196
|
};
|
|
12603
14197
|
}
|
|
14198
|
+
function sanitizePersistedTaskSourceFields(task, data) {
|
|
14199
|
+
if (!task.isMeta && !task.isDeputy) {
|
|
14200
|
+
return data;
|
|
14201
|
+
}
|
|
14202
|
+
return {
|
|
14203
|
+
...data,
|
|
14204
|
+
function_string: "",
|
|
14205
|
+
tag_id_getter: null
|
|
14206
|
+
};
|
|
14207
|
+
}
|
|
12604
14208
|
function resolveSyncServiceName(task) {
|
|
12605
14209
|
const ownerServiceName = typeof task?.ownerServiceName === "string" ? task.ownerServiceName.trim() : "";
|
|
12606
14210
|
const taskServiceName = typeof task?.serviceName === "string" ? task.serviceName.trim() : "";
|
|
@@ -12624,7 +14228,7 @@ function buildIntentRegistryData(intent) {
|
|
|
12624
14228
|
};
|
|
12625
14229
|
}
|
|
12626
14230
|
function isLocalOnlySyncIntent(intentName) {
|
|
12627
|
-
return intentName ===
|
|
14231
|
+
return intentName === import_core5.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
12628
14232
|
}
|
|
12629
14233
|
function getJoinedContextValue(ctx, key) {
|
|
12630
14234
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
@@ -12763,16 +14367,20 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
12763
14367
|
ctx,
|
|
12764
14368
|
queryData
|
|
12765
14369
|
);
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
14370
|
+
const hasEmptyObjectData = originalQueryData.data && typeof originalQueryData.data === "object" && !Array.isArray(originalQueryData.data) && Object.keys(originalQueryData.data).length === 0;
|
|
14371
|
+
const hasMissingData = originalQueryData.data === void 0;
|
|
14372
|
+
if ((tableName === "task" || tableName === "signal_registry" || tableName === "directional_task_graph_map") && (hasEmptyObjectData || hasMissingData)) {
|
|
14373
|
+
console.warn("[CADENZA_SYNC_EMPTY_INSERT]", {
|
|
14374
|
+
tableName,
|
|
14375
|
+
hasMissingData,
|
|
14376
|
+
hasEmptyObjectData,
|
|
14377
|
+
taskName: typeof ctx.__taskName === "string" ? ctx.__taskName : void 0,
|
|
14378
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
14379
|
+
syncSourceServiceName: typeof ctx.__syncSourceServiceName === "string" ? ctx.__syncSourceServiceName : void 0,
|
|
14380
|
+
queryData: originalQueryData,
|
|
14381
|
+
ctx,
|
|
14382
|
+
joinedContexts: Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : []
|
|
14383
|
+
});
|
|
12776
14384
|
}
|
|
12777
14385
|
return buildSyncExecutionEnvelope(
|
|
12778
14386
|
ctx,
|
|
@@ -12863,7 +14471,7 @@ function isBootstrapLocalOnlyActorName(actorName) {
|
|
|
12863
14471
|
return BOOTSTRAP_LOCAL_ONLY_ACTOR_NAMES.has(actorName);
|
|
12864
14472
|
}
|
|
12865
14473
|
function isBootstrapLocalOnlySignal(signalName) {
|
|
12866
|
-
return signalName.startsWith("meta.") || signalName === "meta.service_registry.insert_execution_requested" || signalName === "meta.service_registry.routeable_transport_missing" || signalName === "meta.signal_broker.added" || signalName === "meta.rest.handshake" || signalName === "meta.rest.delegation_target_not_found" || signalName === "meta.socket.handshake" || signalName === "meta.socket.delegation_target_not_found" || signalName === "meta.fetch.handshake_complete" || signalName === "sub_meta.signal_broker.new_trace" || signalName.startsWith("meta.task.") || signalName.startsWith("meta.sync_controller.") || isLocalServiceReadySignal(signalName);
|
|
14474
|
+
return signalName.startsWith("meta.") || signalName.startsWith("global.meta.") || signalName === "meta.service_registry.insert_execution_requested" || signalName === "meta.service_registry.routeable_transport_missing" || signalName === "meta.signal_broker.added" || signalName === "meta.rest.handshake" || signalName === "meta.rest.delegation_target_not_found" || signalName === "meta.socket.handshake" || signalName === "meta.socket.delegation_target_not_found" || signalName === "meta.fetch.handshake_complete" || signalName === "sub_meta.signal_broker.new_trace" || signalName.startsWith("meta.task.") || signalName.startsWith("meta.sync_controller.") || isLocalServiceReadySignal(signalName);
|
|
12867
14475
|
}
|
|
12868
14476
|
function hasNonZeroPending(summary) {
|
|
12869
14477
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
@@ -13091,6 +14699,12 @@ function resolveLocalRoutineFromSyncContext(ctx) {
|
|
|
13091
14699
|
);
|
|
13092
14700
|
return routineName ? CadenzaService.getRoutine(routineName) : void 0;
|
|
13093
14701
|
}
|
|
14702
|
+
function shouldTrackDirectionalTaskMapForBootstrap(predecessorTask, nextTask) {
|
|
14703
|
+
if (!predecessorTask || !nextTask) {
|
|
14704
|
+
return false;
|
|
14705
|
+
}
|
|
14706
|
+
return predecessorTask.isMeta !== true && predecessorTask.isSubMeta !== true && nextTask.isMeta !== true && nextTask.isSubMeta !== true;
|
|
14707
|
+
}
|
|
13094
14708
|
function resolveSignalNameFromSyncContext(ctx) {
|
|
13095
14709
|
const candidateSignalNames = [
|
|
13096
14710
|
ctx.signalName,
|
|
@@ -13708,40 +15322,41 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
13708
15322
|
if (task.registered) continue;
|
|
13709
15323
|
const { __functionString, __getTagCallback } = task.export();
|
|
13710
15324
|
this.tasksSynced = false;
|
|
15325
|
+
const taskRegistrationData = sanitizePersistedTaskSourceFields(task, {
|
|
15326
|
+
name: task.name,
|
|
15327
|
+
version: task.version,
|
|
15328
|
+
description: task.description,
|
|
15329
|
+
function_string: __functionString,
|
|
15330
|
+
tag_id_getter: __getTagCallback,
|
|
15331
|
+
layer_index: task.layerIndex,
|
|
15332
|
+
concurrency: task.concurrency,
|
|
15333
|
+
timeout: task.timeout,
|
|
15334
|
+
is_unique: task.isUnique,
|
|
15335
|
+
is_signal: task.isSignal,
|
|
15336
|
+
is_throttled: task.isThrottled,
|
|
15337
|
+
is_debounce: task.isDebounce,
|
|
15338
|
+
is_ephemeral: task.isEphemeral,
|
|
15339
|
+
is_meta: task.isMeta,
|
|
15340
|
+
is_sub_meta: task.isSubMeta,
|
|
15341
|
+
is_hidden: task.isHidden,
|
|
15342
|
+
validate_input_context: task.validateInputContext,
|
|
15343
|
+
validate_output_context: task.validateOutputContext,
|
|
15344
|
+
retry_count: task.retryCount,
|
|
15345
|
+
retry_delay: task.retryDelay,
|
|
15346
|
+
retry_delay_max: task.retryDelayMax,
|
|
15347
|
+
retry_delay_factor: task.retryDelayFactor,
|
|
15348
|
+
service_name: serviceName2,
|
|
15349
|
+
signals: {
|
|
15350
|
+
emits: Array.from(task.emitsSignals),
|
|
15351
|
+
signalsToEmitAfter: Array.from(task.signalsToEmitAfter),
|
|
15352
|
+
signalsToEmitOnFail: Array.from(task.signalsToEmitOnFail),
|
|
15353
|
+
observed: Array.from(task.observedSignals)
|
|
15354
|
+
},
|
|
15355
|
+
intents: Array.from(task.handlesIntents)
|
|
15356
|
+
});
|
|
13711
15357
|
yield {
|
|
13712
15358
|
__syncing: ctx.__syncing,
|
|
13713
|
-
data:
|
|
13714
|
-
name: task.name,
|
|
13715
|
-
version: task.version,
|
|
13716
|
-
description: task.description,
|
|
13717
|
-
function_string: __functionString,
|
|
13718
|
-
tag_id_getter: __getTagCallback,
|
|
13719
|
-
layer_index: task.layerIndex,
|
|
13720
|
-
concurrency: task.concurrency,
|
|
13721
|
-
timeout: task.timeout,
|
|
13722
|
-
is_unique: task.isUnique,
|
|
13723
|
-
is_signal: task.isSignal,
|
|
13724
|
-
is_throttled: task.isThrottled,
|
|
13725
|
-
is_debounce: task.isDebounce,
|
|
13726
|
-
is_ephemeral: task.isEphemeral,
|
|
13727
|
-
is_meta: task.isMeta,
|
|
13728
|
-
is_sub_meta: task.isSubMeta,
|
|
13729
|
-
is_hidden: task.isHidden,
|
|
13730
|
-
validate_input_context: task.validateInputContext,
|
|
13731
|
-
validate_output_context: task.validateOutputContext,
|
|
13732
|
-
retry_count: task.retryCount,
|
|
13733
|
-
retry_delay: task.retryDelay,
|
|
13734
|
-
retry_delay_max: task.retryDelayMax,
|
|
13735
|
-
retry_delay_factor: task.retryDelayFactor,
|
|
13736
|
-
service_name: serviceName2,
|
|
13737
|
-
signals: {
|
|
13738
|
-
emits: Array.from(task.emitsSignals),
|
|
13739
|
-
signalsToEmitAfter: Array.from(task.signalsToEmitAfter),
|
|
13740
|
-
signalsToEmitOnFail: Array.from(task.signalsToEmitOnFail),
|
|
13741
|
-
observed: Array.from(task.observedSignals)
|
|
13742
|
-
},
|
|
13743
|
-
intents: Array.from(task.handlesIntents)
|
|
13744
|
-
},
|
|
15359
|
+
data: taskRegistrationData,
|
|
13745
15360
|
__taskName: task.name
|
|
13746
15361
|
};
|
|
13747
15362
|
}
|
|
@@ -14167,7 +15782,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14167
15782
|
return;
|
|
14168
15783
|
}
|
|
14169
15784
|
for (const t of task.nextTasks) {
|
|
14170
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
15785
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
14171
15786
|
continue;
|
|
14172
15787
|
}
|
|
14173
15788
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -14235,7 +15850,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14235
15850
|
return false;
|
|
14236
15851
|
}
|
|
14237
15852
|
for (const nextTask of task.nextTasks) {
|
|
14238
|
-
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered) {
|
|
15853
|
+
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, nextTask)) {
|
|
14239
15854
|
continue;
|
|
14240
15855
|
}
|
|
14241
15856
|
if (resolveSyncServiceName(nextTask)) {
|
|
@@ -14900,13 +16515,50 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14900
16515
|
startActorPrimitiveSyncTask,
|
|
14901
16516
|
startRoutinePrimitiveSyncTask
|
|
14902
16517
|
);
|
|
14903
|
-
const getAllTasksForSyncTask = CadenzaService.
|
|
16518
|
+
const getAllTasksForSyncTask = CadenzaService.createMetaTask(
|
|
16519
|
+
"Get all tasks for sync",
|
|
16520
|
+
(ctx) => ({
|
|
16521
|
+
...ctx,
|
|
16522
|
+
tasks: Array.from(CadenzaService.registry.tasks.values())
|
|
16523
|
+
}),
|
|
16524
|
+
"Collects local tasks for the primitive sync phase.",
|
|
16525
|
+
{
|
|
16526
|
+
register: false,
|
|
16527
|
+
isHidden: true
|
|
16528
|
+
}
|
|
16529
|
+
);
|
|
14904
16530
|
startTaskPrimitiveSyncTask.then(
|
|
14905
16531
|
getAllTasksForSyncTask,
|
|
14906
16532
|
gatherTaskRegistrationTask
|
|
14907
16533
|
);
|
|
14908
16534
|
getAllTasksForSyncTask.then(this.splitTasksForRegistration);
|
|
14909
|
-
const getSignalsForSyncTask = CadenzaService.
|
|
16535
|
+
const getSignalsForSyncTask = CadenzaService.createMetaTask(
|
|
16536
|
+
"Get signals for sync",
|
|
16537
|
+
(ctx) => {
|
|
16538
|
+
const uniqueSignals = Array.from(
|
|
16539
|
+
/* @__PURE__ */ new Set([
|
|
16540
|
+
...CadenzaService.signalBroker.signalObservers.keys(),
|
|
16541
|
+
...CadenzaService.signalBroker.emittedSignalsRegistry
|
|
16542
|
+
])
|
|
16543
|
+
).filter((signal) => !signal.includes(":"));
|
|
16544
|
+
const processedSignals = uniqueSignals.map((signal) => ({
|
|
16545
|
+
signal,
|
|
16546
|
+
data: {
|
|
16547
|
+
registered: CadenzaService.signalBroker.signalObservers.get(signal)?.registered ?? false,
|
|
16548
|
+
metadata: CadenzaService.signalBroker.getSignalMetadata(signal) ?? null
|
|
16549
|
+
}
|
|
16550
|
+
}));
|
|
16551
|
+
return {
|
|
16552
|
+
...ctx,
|
|
16553
|
+
signals: processedSignals
|
|
16554
|
+
};
|
|
16555
|
+
},
|
|
16556
|
+
"Collects local signals for the primitive sync phase.",
|
|
16557
|
+
{
|
|
16558
|
+
register: false,
|
|
16559
|
+
isHidden: true
|
|
16560
|
+
}
|
|
16561
|
+
);
|
|
14910
16562
|
startSignalPrimitiveSyncTask.then(
|
|
14911
16563
|
getSignalsForSyncTask,
|
|
14912
16564
|
gatherSignalRegistrationTask
|
|
@@ -14948,40 +16600,110 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14948
16600
|
gatherActorRegistrationTask
|
|
14949
16601
|
);
|
|
14950
16602
|
getAllActorsForSyncTask.then(this.splitActorsForRegistration);
|
|
14951
|
-
const getAllRoutinesForSyncTask = CadenzaService.
|
|
16603
|
+
const getAllRoutinesForSyncTask = CadenzaService.createMetaTask(
|
|
16604
|
+
"Get all routines for sync",
|
|
16605
|
+
(ctx) => ({
|
|
16606
|
+
...ctx,
|
|
16607
|
+
routines: Array.from(CadenzaService.registry.routines.values())
|
|
16608
|
+
}),
|
|
16609
|
+
"Collects local routines for the primitive sync phase.",
|
|
16610
|
+
{
|
|
16611
|
+
register: false,
|
|
16612
|
+
isHidden: true
|
|
16613
|
+
}
|
|
16614
|
+
);
|
|
14952
16615
|
startRoutinePrimitiveSyncTask.then(
|
|
14953
16616
|
getAllRoutinesForSyncTask,
|
|
14954
16617
|
gatherRoutineRegistrationTask
|
|
14955
16618
|
);
|
|
14956
16619
|
getAllRoutinesForSyncTask.then(this.splitRoutinesTask);
|
|
14957
|
-
const iterateTasksForDirectionalTaskMapSyncTask = CadenzaService.
|
|
16620
|
+
const iterateTasksForDirectionalTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16621
|
+
"Iterate tasks for directional task map sync",
|
|
16622
|
+
function* (ctx) {
|
|
16623
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16624
|
+
yield { ...ctx, task };
|
|
16625
|
+
}
|
|
16626
|
+
},
|
|
16627
|
+
"Iterates local tasks for directional task-map sync.",
|
|
16628
|
+
{
|
|
16629
|
+
register: false,
|
|
16630
|
+
isHidden: true
|
|
16631
|
+
}
|
|
16632
|
+
);
|
|
14958
16633
|
startDirectionalTaskMapSyncTask.then(
|
|
14959
16634
|
iterateTasksForDirectionalTaskMapSyncTask,
|
|
14960
16635
|
gatherDirectionalTaskMapRegistrationTask
|
|
14961
16636
|
);
|
|
14962
16637
|
iterateTasksForDirectionalTaskMapSyncTask.then(this.registerTaskMapTask);
|
|
14963
16638
|
recordTaskMapRegistrationTask.then(gatherDirectionalTaskMapRegistrationTask);
|
|
14964
|
-
const iterateTasksForSignalTaskMapSyncTask = CadenzaService.
|
|
16639
|
+
const iterateTasksForSignalTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16640
|
+
"Iterate tasks for signal task map sync",
|
|
16641
|
+
function* (ctx) {
|
|
16642
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16643
|
+
yield { ...ctx, task };
|
|
16644
|
+
}
|
|
16645
|
+
},
|
|
16646
|
+
"Iterates local tasks for signal-to-task map sync.",
|
|
16647
|
+
{
|
|
16648
|
+
register: false,
|
|
16649
|
+
isHidden: true
|
|
16650
|
+
}
|
|
16651
|
+
);
|
|
14965
16652
|
startSignalTaskMapSyncTask.then(
|
|
14966
16653
|
iterateTasksForSignalTaskMapSyncTask,
|
|
14967
16654
|
gatherSignalTaskMapRegistrationTask
|
|
14968
16655
|
);
|
|
14969
16656
|
iterateTasksForSignalTaskMapSyncTask.then(this.registerSignalToTaskMapTask);
|
|
14970
16657
|
this.registerSignalToTaskMapTask.then(gatherSignalTaskMapRegistrationTask);
|
|
14971
|
-
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.
|
|
16658
|
+
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16659
|
+
"Iterate tasks for intent task map sync",
|
|
16660
|
+
function* (ctx) {
|
|
16661
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16662
|
+
yield { ...ctx, task };
|
|
16663
|
+
}
|
|
16664
|
+
},
|
|
16665
|
+
"Iterates local tasks for intent-to-task map sync.",
|
|
16666
|
+
{
|
|
16667
|
+
register: false,
|
|
16668
|
+
isHidden: true
|
|
16669
|
+
}
|
|
16670
|
+
);
|
|
14972
16671
|
startIntentTaskMapSyncTask.then(
|
|
14973
16672
|
iterateTasksForIntentTaskMapSyncTask,
|
|
14974
16673
|
gatherIntentTaskMapRegistrationTask
|
|
14975
16674
|
);
|
|
14976
16675
|
iterateTasksForIntentTaskMapSyncTask.then(this.registerIntentToTaskMapTask);
|
|
14977
16676
|
this.registerIntentToTaskMapTask.then(gatherIntentTaskMapRegistrationTask);
|
|
14978
|
-
const iterateTasksForActorTaskMapSyncTask = CadenzaService.
|
|
16677
|
+
const iterateTasksForActorTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16678
|
+
"Iterate tasks for actor task map sync",
|
|
16679
|
+
function* (ctx) {
|
|
16680
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16681
|
+
yield { ...ctx, task };
|
|
16682
|
+
}
|
|
16683
|
+
},
|
|
16684
|
+
"Iterates local tasks for actor-to-task map sync.",
|
|
16685
|
+
{
|
|
16686
|
+
register: false,
|
|
16687
|
+
isHidden: true
|
|
16688
|
+
}
|
|
16689
|
+
);
|
|
14979
16690
|
startActorTaskMapSyncTask.then(
|
|
14980
16691
|
iterateTasksForActorTaskMapSyncTask,
|
|
14981
16692
|
gatherActorTaskMapRegistrationTask
|
|
14982
16693
|
);
|
|
14983
16694
|
iterateTasksForActorTaskMapSyncTask.then(this.registerActorTaskMapTask);
|
|
14984
|
-
const getAllRoutinesForTaskMapSyncTask = CadenzaService.
|
|
16695
|
+
const getAllRoutinesForTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16696
|
+
"Get all routines for task map sync",
|
|
16697
|
+
(ctx) => ({
|
|
16698
|
+
...ctx,
|
|
16699
|
+
routines: Array.from(CadenzaService.registry.routines.values())
|
|
16700
|
+
}),
|
|
16701
|
+
"Collects local routines for routine-to-task map sync.",
|
|
16702
|
+
{
|
|
16703
|
+
register: false,
|
|
16704
|
+
isHidden: true
|
|
16705
|
+
}
|
|
16706
|
+
);
|
|
14985
16707
|
startRoutineTaskMapSyncTask.then(
|
|
14986
16708
|
getAllRoutinesForTaskMapSyncTask,
|
|
14987
16709
|
gatherRoutineTaskMapRegistrationTask
|
|
@@ -15057,11 +16779,37 @@ function resolveTaskByName(name) {
|
|
|
15057
16779
|
const taskName = String(name ?? "");
|
|
15058
16780
|
return taskName ? CadenzaService.get(taskName) : void 0;
|
|
15059
16781
|
}
|
|
16782
|
+
function resolveHelperFromMetadataContext(ctx) {
|
|
16783
|
+
const toolRuntime = CadenzaService;
|
|
16784
|
+
const helperName = String(
|
|
16785
|
+
ctx?.helperName ?? ctx?.data?.helperName ?? ctx?.data?.helper_name ?? ctx?.filter?.helperName ?? ctx?.filter?.helper_name ?? ""
|
|
16786
|
+
);
|
|
16787
|
+
return helperName ? toolRuntime.getHelper?.(helperName) : void 0;
|
|
16788
|
+
}
|
|
16789
|
+
function resolveGlobalFromMetadataContext(ctx) {
|
|
16790
|
+
const toolRuntime = CadenzaService;
|
|
16791
|
+
const globalName = String(
|
|
16792
|
+
ctx?.globalName ?? ctx?.data?.globalName ?? ctx?.data?.global_name ?? ctx?.filter?.globalName ?? ctx?.filter?.global_name ?? ""
|
|
16793
|
+
);
|
|
16794
|
+
return globalName ? toolRuntime.getGlobal?.(globalName) : void 0;
|
|
16795
|
+
}
|
|
15060
16796
|
function resolvePredecessorTaskFromMetadataContext(ctx) {
|
|
15061
16797
|
return resolveTaskByName(
|
|
15062
16798
|
ctx?.predecessorTaskName ?? ctx?.data?.predecessorTaskName ?? ctx?.data?.predecessor_task_name ?? ctx?.filter?.predecessorTaskName ?? ctx?.filter?.predecessor_task_name
|
|
15063
16799
|
);
|
|
15064
16800
|
}
|
|
16801
|
+
function sanitizePersistedTaskSourceFields2(task, data) {
|
|
16802
|
+
if (!task?.isMeta && !task?.isDeputy) {
|
|
16803
|
+
return data;
|
|
16804
|
+
}
|
|
16805
|
+
return {
|
|
16806
|
+
...data,
|
|
16807
|
+
functionString: "",
|
|
16808
|
+
function_string: "",
|
|
16809
|
+
tagIdGetter: null,
|
|
16810
|
+
tag_id_getter: null
|
|
16811
|
+
};
|
|
16812
|
+
}
|
|
15065
16813
|
function shouldSkipDirectTaskMetadata(task) {
|
|
15066
16814
|
return !task || !task.register || task.isHidden || task.isDeputy;
|
|
15067
16815
|
}
|
|
@@ -15139,6 +16887,9 @@ function shouldPersistBusinessInquiryCompletion(ctx) {
|
|
|
15139
16887
|
const inquiryName = String(ctx?.data?.metadata?.inquiryMeta?.inquiry ?? "");
|
|
15140
16888
|
return inquiryName.length > 0 && !isMetaIntentName(inquiryName);
|
|
15141
16889
|
}
|
|
16890
|
+
function shouldPersistExecutionTrace(ctx) {
|
|
16891
|
+
return ctx?.data?.isMeta !== true && ctx?.data?.is_meta !== true;
|
|
16892
|
+
}
|
|
15142
16893
|
function shouldPersistRoutineExecution(ctx) {
|
|
15143
16894
|
if (ctx?.data?.isMeta === true || ctx?.data?.is_meta === true) {
|
|
15144
16895
|
return false;
|
|
@@ -15202,10 +16953,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15202
16953
|
task.registrationRequested = true;
|
|
15203
16954
|
}
|
|
15204
16955
|
return buildDatabaseTriggerContext(
|
|
15205
|
-
{
|
|
16956
|
+
sanitizePersistedTaskSourceFields2(task, {
|
|
15206
16957
|
...ctx.data,
|
|
15207
16958
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
15208
|
-
},
|
|
16959
|
+
}),
|
|
15209
16960
|
void 0,
|
|
15210
16961
|
{ onConflict },
|
|
15211
16962
|
{ onConflict }
|
|
@@ -15308,6 +17059,88 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15308
17059
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
15309
17060
|
});
|
|
15310
17061
|
}).doOn("meta.task.intent_associated").emits("global.meta.graph_metadata.task_intent_associated");
|
|
17062
|
+
const buildHelperMetadataContext = (ctx) => {
|
|
17063
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17064
|
+
return false;
|
|
17065
|
+
}
|
|
17066
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
17067
|
+
if (!helper) {
|
|
17068
|
+
return false;
|
|
17069
|
+
}
|
|
17070
|
+
return buildDatabaseTriggerContext({
|
|
17071
|
+
...ctx.data,
|
|
17072
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17073
|
+
});
|
|
17074
|
+
};
|
|
17075
|
+
createLocalGraphMetadataTask("Handle helper creation", buildHelperMetadataContext).doOn("meta.helper.created").emits("global.meta.graph_metadata.helper_created");
|
|
17076
|
+
createLocalGraphMetadataTask("Handle helper update", buildHelperMetadataContext).doOn("meta.helper.updated").emits("global.meta.graph_metadata.helper_updated");
|
|
17077
|
+
const buildGlobalMetadataContext = (ctx) => {
|
|
17078
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17079
|
+
return false;
|
|
17080
|
+
}
|
|
17081
|
+
const globalDefinition = resolveGlobalFromMetadataContext(ctx);
|
|
17082
|
+
if (!globalDefinition) {
|
|
17083
|
+
return false;
|
|
17084
|
+
}
|
|
17085
|
+
return buildDatabaseTriggerContext({
|
|
17086
|
+
...ctx.data,
|
|
17087
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17088
|
+
});
|
|
17089
|
+
};
|
|
17090
|
+
createLocalGraphMetadataTask("Handle global creation", buildGlobalMetadataContext).doOn("meta.global.created").emits("global.meta.graph_metadata.global_created");
|
|
17091
|
+
createLocalGraphMetadataTask("Handle global update", buildGlobalMetadataContext).doOn("meta.global.updated").emits("global.meta.graph_metadata.global_updated");
|
|
17092
|
+
createLocalGraphMetadataTask("Handle task helper association", (ctx) => {
|
|
17093
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17094
|
+
return false;
|
|
17095
|
+
}
|
|
17096
|
+
const task = resolveTaskFromMetadataContext(ctx);
|
|
17097
|
+
if (shouldSkipDirectTaskMetadata(task)) {
|
|
17098
|
+
return false;
|
|
17099
|
+
}
|
|
17100
|
+
return buildDatabaseTriggerContext({
|
|
17101
|
+
...ctx.data,
|
|
17102
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17103
|
+
});
|
|
17104
|
+
}).doOn("meta.task.helper_associated").emits("global.meta.graph_metadata.task_helper_associated");
|
|
17105
|
+
createLocalGraphMetadataTask("Handle helper helper association", (ctx) => {
|
|
17106
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17107
|
+
return false;
|
|
17108
|
+
}
|
|
17109
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
17110
|
+
if (!helper) {
|
|
17111
|
+
return false;
|
|
17112
|
+
}
|
|
17113
|
+
return buildDatabaseTriggerContext({
|
|
17114
|
+
...ctx.data,
|
|
17115
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17116
|
+
});
|
|
17117
|
+
}).doOn("meta.helper.helper_associated").emits("global.meta.graph_metadata.helper_helper_associated");
|
|
17118
|
+
createLocalGraphMetadataTask("Handle task global association", (ctx) => {
|
|
17119
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17120
|
+
return false;
|
|
17121
|
+
}
|
|
17122
|
+
const task = resolveTaskFromMetadataContext(ctx);
|
|
17123
|
+
if (shouldSkipDirectTaskMetadata(task)) {
|
|
17124
|
+
return false;
|
|
17125
|
+
}
|
|
17126
|
+
return buildDatabaseTriggerContext({
|
|
17127
|
+
...ctx.data,
|
|
17128
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17129
|
+
});
|
|
17130
|
+
}).doOn("meta.task.global_associated").emits("global.meta.graph_metadata.task_global_associated");
|
|
17131
|
+
createLocalGraphMetadataTask("Handle helper global association", (ctx) => {
|
|
17132
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17133
|
+
return false;
|
|
17134
|
+
}
|
|
17135
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
17136
|
+
if (!helper) {
|
|
17137
|
+
return false;
|
|
17138
|
+
}
|
|
17139
|
+
return buildDatabaseTriggerContext({
|
|
17140
|
+
...ctx.data,
|
|
17141
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17142
|
+
});
|
|
17143
|
+
}).doOn("meta.helper.global_associated").emits("global.meta.graph_metadata.helper_global_associated");
|
|
15311
17144
|
createLocalGraphMetadataTask("Handle task unsubscribing signal", (ctx) => {
|
|
15312
17145
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
15313
17146
|
return false;
|
|
@@ -15375,6 +17208,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15375
17208
|
});
|
|
15376
17209
|
}).doOn("meta.routine.task_added").emits("global.meta.graph_metadata.task_added_to_routine");
|
|
15377
17210
|
createLocalGraphMetadataTask("Handle new trace", (ctx) => {
|
|
17211
|
+
if (!shouldPersistExecutionTrace(ctx)) {
|
|
17212
|
+
return false;
|
|
17213
|
+
}
|
|
15378
17214
|
return buildDatabaseTriggerContext({
|
|
15379
17215
|
...ctx.data,
|
|
15380
17216
|
service_name: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -15388,10 +17224,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15388
17224
|
return false;
|
|
15389
17225
|
}
|
|
15390
17226
|
const routineData = ctx.data ?? {};
|
|
15391
|
-
const sanitizedRoutineContext =
|
|
17227
|
+
const sanitizedRoutineContext = sanitizeExecutionPersistenceContext(
|
|
15392
17228
|
routineData.context ?? {}
|
|
15393
17229
|
);
|
|
15394
|
-
const sanitizedRoutineMetaContext =
|
|
17230
|
+
const sanitizedRoutineMetaContext = sanitizeExecutionPersistenceContext(
|
|
15395
17231
|
routineData.metaContext ?? {}
|
|
15396
17232
|
);
|
|
15397
17233
|
const routineExecutionRow = {
|
|
@@ -15526,12 +17362,13 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15526
17362
|
createLocalGraphMetadataTask(
|
|
15527
17363
|
"Handle routine execution ended",
|
|
15528
17364
|
(ctx) => {
|
|
17365
|
+
const sanitizedData = sanitizeExecutionPersistenceResultPayload({
|
|
17366
|
+
...ctx.data,
|
|
17367
|
+
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
17368
|
+
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
17369
|
+
});
|
|
15529
17370
|
return buildDatabaseTriggerContext(
|
|
15530
|
-
|
|
15531
|
-
...ctx.data,
|
|
15532
|
-
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
15533
|
-
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
15534
|
-
},
|
|
17371
|
+
sanitizedData,
|
|
15535
17372
|
ctx.filter ?? void 0
|
|
15536
17373
|
);
|
|
15537
17374
|
},
|
|
@@ -15545,10 +17382,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15545
17382
|
return false;
|
|
15546
17383
|
}
|
|
15547
17384
|
const taskExecutionData = ctx.data ?? {};
|
|
15548
|
-
const sanitizedTaskContext =
|
|
17385
|
+
const sanitizedTaskContext = sanitizeExecutionPersistenceContext(
|
|
15549
17386
|
taskExecutionData.context ?? {}
|
|
15550
17387
|
);
|
|
15551
|
-
const sanitizedTaskMetaContext =
|
|
17388
|
+
const sanitizedTaskMetaContext = sanitizeExecutionPersistenceContext(
|
|
15552
17389
|
taskExecutionData.metaContext ?? {}
|
|
15553
17390
|
);
|
|
15554
17391
|
const routineMetadata = resolveRoutinePersistenceMetadata(
|
|
@@ -15781,12 +17618,13 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15781
17618
|
if (!shouldPersistTaskExecutionMetadata(ctx)) {
|
|
15782
17619
|
return false;
|
|
15783
17620
|
}
|
|
17621
|
+
const sanitizedData = sanitizeExecutionPersistenceResultPayload({
|
|
17622
|
+
...ctx.data,
|
|
17623
|
+
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
17624
|
+
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
17625
|
+
});
|
|
15784
17626
|
return buildDatabaseTriggerContext(
|
|
15785
|
-
|
|
15786
|
-
...ctx.data,
|
|
15787
|
-
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
15788
|
-
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
15789
|
-
},
|
|
17627
|
+
sanitizedData,
|
|
15790
17628
|
ctx.filter ?? void 0
|
|
15791
17629
|
);
|
|
15792
17630
|
},
|
|
@@ -16553,6 +18391,15 @@ var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
|
16553
18391
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
16554
18392
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
16555
18393
|
var DEFAULT_DATABASE_PROXY_TASK_TIMEOUT_MS = 12e4;
|
|
18394
|
+
var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
18395
|
+
"routing_capability",
|
|
18396
|
+
"business_structural",
|
|
18397
|
+
"local_meta_structural"
|
|
18398
|
+
];
|
|
18399
|
+
function getServiceManifestPublicationLayerRank(layer) {
|
|
18400
|
+
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
18401
|
+
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
18402
|
+
}
|
|
16556
18403
|
var CadenzaService = class {
|
|
16557
18404
|
static unregisterGracefulShutdownHandlers() {
|
|
16558
18405
|
for (const cleanup of this.shutdownHandlerCleanup) {
|
|
@@ -16679,7 +18526,15 @@ var CadenzaService = class {
|
|
|
16679
18526
|
this.replayRegisteredTaskSignalObservations();
|
|
16680
18527
|
this.replayRegisteredTaskIntentAssociations();
|
|
16681
18528
|
}
|
|
16682
|
-
static
|
|
18529
|
+
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
18530
|
+
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
18531
|
+
}
|
|
18532
|
+
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
18533
|
+
this.serviceManifestPublicationPendingReason = reason;
|
|
18534
|
+
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
18535
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(targetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? targetLayer : currentTargetLayer;
|
|
18536
|
+
}
|
|
18537
|
+
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
16683
18538
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16684
18539
|
return;
|
|
16685
18540
|
}
|
|
@@ -16687,7 +18542,8 @@ var CadenzaService = class {
|
|
|
16687
18542
|
const payload = {
|
|
16688
18543
|
__reason: reason,
|
|
16689
18544
|
__serviceName: this.serviceRegistry.serviceName,
|
|
16690
|
-
__serviceInstanceId: this.serviceRegistry.serviceInstanceId
|
|
18545
|
+
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
18546
|
+
__publicationLayer: targetLayer
|
|
16691
18547
|
};
|
|
16692
18548
|
if (immediate) {
|
|
16693
18549
|
this.emit(signalName, payload);
|
|
@@ -16695,32 +18551,53 @@ var CadenzaService = class {
|
|
|
16695
18551
|
}
|
|
16696
18552
|
this.debounce(signalName, payload, 100);
|
|
16697
18553
|
}
|
|
16698
|
-
static scheduleServiceManifestPublicationRetry(reason) {
|
|
18554
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
16699
18555
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16700
18556
|
return;
|
|
16701
18557
|
}
|
|
16702
18558
|
setTimeout(() => {
|
|
16703
|
-
this.requestServiceManifestPublication(reason, false);
|
|
18559
|
+
this.requestServiceManifestPublication(reason, false, targetLayer);
|
|
16704
18560
|
}, 1e3);
|
|
16705
18561
|
}
|
|
16706
|
-
static async publishServiceManifestIfNeeded(reason) {
|
|
18562
|
+
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
16707
18563
|
if (!this.serviceRegistry.connectsToCadenzaDB || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16708
18564
|
return false;
|
|
16709
18565
|
}
|
|
16710
18566
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
18567
|
+
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
18568
|
+
targetLayer
|
|
18569
|
+
);
|
|
16711
18570
|
if (this.serviceManifestPublicationInFlight) {
|
|
16712
|
-
this.
|
|
18571
|
+
this.mergeServiceManifestPublicationRequest(
|
|
18572
|
+
publishReason,
|
|
18573
|
+
publishTargetLayer
|
|
18574
|
+
);
|
|
16713
18575
|
return false;
|
|
16714
18576
|
}
|
|
16715
|
-
const
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
|
|
18577
|
+
const publicationPlan = SERVICE_MANIFEST_PUBLICATION_ORDER.filter(
|
|
18578
|
+
(layer) => getServiceManifestPublicationLayerRank(layer) <= getServiceManifestPublicationLayerRank(publishTargetLayer)
|
|
18579
|
+
).map((layer) => {
|
|
18580
|
+
const snapshot2 = buildServiceManifestSnapshot({
|
|
18581
|
+
serviceName: this.serviceRegistry.serviceName,
|
|
18582
|
+
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
18583
|
+
revision: this.serviceManifestRevision + 1,
|
|
18584
|
+
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18585
|
+
publicationLayer: layer
|
|
18586
|
+
});
|
|
18587
|
+
return {
|
|
18588
|
+
layer,
|
|
18589
|
+
snapshot: snapshot2,
|
|
18590
|
+
changed: this.lastPublishedServiceManifestHashes[layer] !== snapshot2.manifestHash
|
|
18591
|
+
};
|
|
16720
18592
|
});
|
|
16721
|
-
|
|
18593
|
+
const nextPublication = publicationPlan.find((entry) => entry.changed);
|
|
18594
|
+
if (!nextPublication) {
|
|
16722
18595
|
return false;
|
|
16723
18596
|
}
|
|
18597
|
+
const { layer: publicationLayer, snapshot } = nextPublication;
|
|
18598
|
+
const hasPendingFollowupLayer = publicationPlan.some(
|
|
18599
|
+
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
18600
|
+
);
|
|
16724
18601
|
this.serviceManifestPublicationInFlight = true;
|
|
16725
18602
|
try {
|
|
16726
18603
|
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
@@ -16728,7 +18605,10 @@ var CadenzaService = class {
|
|
|
16728
18605
|
snapshot
|
|
16729
18606
|
);
|
|
16730
18607
|
if (!this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
16731
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
18608
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
18609
|
+
publishReason,
|
|
18610
|
+
publishTargetLayer
|
|
18611
|
+
);
|
|
16732
18612
|
return false;
|
|
16733
18613
|
}
|
|
16734
18614
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
@@ -16736,32 +18616,48 @@ var CadenzaService = class {
|
|
|
16736
18616
|
requireComplete: true
|
|
16737
18617
|
});
|
|
16738
18618
|
this.serviceManifestRevision = snapshot.revision;
|
|
16739
|
-
this.
|
|
18619
|
+
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
18620
|
+
if (hasPendingFollowupLayer) {
|
|
18621
|
+
this.mergeServiceManifestPublicationRequest(
|
|
18622
|
+
publishReason,
|
|
18623
|
+
publishTargetLayer
|
|
18624
|
+
);
|
|
18625
|
+
}
|
|
16740
18626
|
return {
|
|
16741
18627
|
serviceManifest: snapshot,
|
|
16742
|
-
published: true
|
|
18628
|
+
published: true,
|
|
18629
|
+
publicationLayer
|
|
16743
18630
|
};
|
|
16744
18631
|
} catch (error) {
|
|
16745
18632
|
this.log("Service manifest publication failed. Scheduling retry.", {
|
|
16746
18633
|
serviceName: this.serviceRegistry.serviceName,
|
|
16747
18634
|
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
16748
18635
|
reason: publishReason,
|
|
18636
|
+
publicationLayer,
|
|
16749
18637
|
error: resolveInquiryFailureError(
|
|
16750
18638
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
16751
18639
|
error
|
|
16752
18640
|
),
|
|
16753
18641
|
inquiryMeta: error && typeof error === "object" && "__inquiryMeta" in error ? error.__inquiryMeta : null
|
|
16754
18642
|
});
|
|
16755
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
18643
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
18644
|
+
publishReason,
|
|
18645
|
+
publishTargetLayer
|
|
18646
|
+
);
|
|
16756
18647
|
return false;
|
|
16757
18648
|
} finally {
|
|
16758
18649
|
this.serviceManifestPublicationInFlight = false;
|
|
16759
|
-
if (this.serviceManifestPublicationPendingReason) {
|
|
18650
|
+
if (this.serviceManifestPublicationPendingReason && this.serviceManifestPublicationPendingLayer) {
|
|
16760
18651
|
const pendingReason = this.serviceManifestPublicationPendingReason;
|
|
18652
|
+
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
16761
18653
|
this.serviceManifestPublicationPendingReason = null;
|
|
18654
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
16762
18655
|
this.debounce(
|
|
16763
18656
|
"meta.service_manifest.publish_requested",
|
|
16764
|
-
{
|
|
18657
|
+
{
|
|
18658
|
+
__reason: pendingReason,
|
|
18659
|
+
__publicationLayer: pendingLayer
|
|
18660
|
+
},
|
|
16765
18661
|
100
|
|
16766
18662
|
);
|
|
16767
18663
|
}
|
|
@@ -16774,9 +18670,13 @@ var CadenzaService = class {
|
|
|
16774
18670
|
this.createMetaTask(
|
|
16775
18671
|
"Publish service manifest",
|
|
16776
18672
|
async (ctx) => this.publishServiceManifestIfNeeded(
|
|
16777
|
-
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish"
|
|
18673
|
+
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
18674
|
+
this.normalizeServiceManifestPublicationLayer(
|
|
18675
|
+
ctx.__publicationLayer,
|
|
18676
|
+
"business_structural"
|
|
18677
|
+
)
|
|
16778
18678
|
),
|
|
16779
|
-
"Publishes
|
|
18679
|
+
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
16780
18680
|
{
|
|
16781
18681
|
register: false,
|
|
16782
18682
|
isHidden: true
|
|
@@ -16786,13 +18686,18 @@ var CadenzaService = class {
|
|
|
16786
18686
|
"Request manifest publication after structural change",
|
|
16787
18687
|
(ctx) => {
|
|
16788
18688
|
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";
|
|
18689
|
+
const targetLayer = reason === "meta.service_registry.instance_inserted" ? "business_structural" : this.normalizeServiceManifestPublicationLayer(
|
|
18690
|
+
ctx.__publicationLayer,
|
|
18691
|
+
"business_structural"
|
|
18692
|
+
);
|
|
16789
18693
|
this.requestServiceManifestPublication(
|
|
16790
18694
|
reason,
|
|
16791
|
-
reason === "meta.service_registry.instance_inserted"
|
|
18695
|
+
reason === "meta.service_registry.instance_inserted",
|
|
18696
|
+
targetLayer
|
|
16792
18697
|
);
|
|
16793
18698
|
return true;
|
|
16794
18699
|
},
|
|
16795
|
-
"Requests
|
|
18700
|
+
"Requests staged manifest publication when a static service primitive changes.",
|
|
16796
18701
|
{
|
|
16797
18702
|
register: false,
|
|
16798
18703
|
isHidden: true
|
|
@@ -16804,9 +18709,17 @@ var CadenzaService = class {
|
|
|
16804
18709
|
"meta.task.relationship_added",
|
|
16805
18710
|
"meta.task.relationship_removed",
|
|
16806
18711
|
"meta.task.intent_associated",
|
|
18712
|
+
"meta.task.helper_associated",
|
|
18713
|
+
"meta.task.global_associated",
|
|
16807
18714
|
"meta.task.observed_signal",
|
|
16808
18715
|
"meta.task.attached_signal",
|
|
16809
18716
|
"meta.task.detached_signal",
|
|
18717
|
+
"meta.helper.created",
|
|
18718
|
+
"meta.helper.updated",
|
|
18719
|
+
"meta.global.created",
|
|
18720
|
+
"meta.global.updated",
|
|
18721
|
+
"meta.helper.helper_associated",
|
|
18722
|
+
"meta.helper.global_associated",
|
|
16810
18723
|
"meta.actor.created",
|
|
16811
18724
|
"meta.actor.task_associated",
|
|
16812
18725
|
"meta.fetch.handshake_complete",
|
|
@@ -16835,19 +18748,19 @@ var CadenzaService = class {
|
|
|
16835
18748
|
static bootstrap() {
|
|
16836
18749
|
if (this.isBootstrapped) return;
|
|
16837
18750
|
this.isBootstrapped = true;
|
|
16838
|
-
|
|
16839
|
-
|
|
18751
|
+
import_core6.default.bootstrap();
|
|
18752
|
+
import_core6.default.setRuntimeInquiryDelegate(
|
|
16840
18753
|
(inquiry, context, options) => this.inquire(
|
|
16841
18754
|
inquiry,
|
|
16842
18755
|
context,
|
|
16843
18756
|
options ?? {}
|
|
16844
18757
|
)
|
|
16845
18758
|
);
|
|
16846
|
-
this.signalBroker =
|
|
16847
|
-
this.inquiryBroker =
|
|
16848
|
-
this.runner =
|
|
16849
|
-
this.metaRunner =
|
|
16850
|
-
this.registry =
|
|
18759
|
+
this.signalBroker = import_core6.default.signalBroker;
|
|
18760
|
+
this.inquiryBroker = import_core6.default.inquiryBroker;
|
|
18761
|
+
this.runner = import_core6.default.runner;
|
|
18762
|
+
this.metaRunner = import_core6.default.metaRunner;
|
|
18763
|
+
this.registry = import_core6.default.registry;
|
|
16851
18764
|
this.serviceRegistry = ServiceRegistry.instance;
|
|
16852
18765
|
RestController.instance;
|
|
16853
18766
|
SocketController.instance;
|
|
@@ -16881,8 +18794,8 @@ var CadenzaService = class {
|
|
|
16881
18794
|
return;
|
|
16882
18795
|
}
|
|
16883
18796
|
this.frontendSyncScheduled = true;
|
|
16884
|
-
|
|
16885
|
-
|
|
18797
|
+
import_core6.default.interval("meta.sync_requested", { __syncing: false }, 18e4);
|
|
18798
|
+
import_core6.default.schedule("meta.sync_requested", { __syncing: false }, 250);
|
|
16886
18799
|
}
|
|
16887
18800
|
static normalizeDeclaredTransports(transports, serviceId, useSocket) {
|
|
16888
18801
|
return (transports ?? []).map((transport) => normalizeServiceTransportConfig(transport)).filter(
|
|
@@ -16940,7 +18853,7 @@ var CadenzaService = class {
|
|
|
16940
18853
|
* @return {void} Does not return any value.
|
|
16941
18854
|
*/
|
|
16942
18855
|
static validateName(name) {
|
|
16943
|
-
|
|
18856
|
+
import_core6.default.validateName(name);
|
|
16944
18857
|
}
|
|
16945
18858
|
/**
|
|
16946
18859
|
* Gets the current run strategy from the Cadenza configuration.
|
|
@@ -16948,7 +18861,7 @@ var CadenzaService = class {
|
|
|
16948
18861
|
* @return {Function} The run strategy function defined in the Cadenza configuration.
|
|
16949
18862
|
*/
|
|
16950
18863
|
static get runStrategy() {
|
|
16951
|
-
return
|
|
18864
|
+
return import_core6.default.runStrategy;
|
|
16952
18865
|
}
|
|
16953
18866
|
/**
|
|
16954
18867
|
* Sets the mode for the Cadenza application.
|
|
@@ -16957,7 +18870,7 @@ var CadenzaService = class {
|
|
|
16957
18870
|
* @return {void} This method does not return a value.
|
|
16958
18871
|
*/
|
|
16959
18872
|
static setMode(mode) {
|
|
16960
|
-
|
|
18873
|
+
import_core6.default.setMode(mode);
|
|
16961
18874
|
}
|
|
16962
18875
|
static hasCompletedBootstrapSync() {
|
|
16963
18876
|
return !this.serviceCreated || this.bootstrapSyncCompleted;
|
|
@@ -17000,16 +18913,16 @@ var CadenzaService = class {
|
|
|
17000
18913
|
* ```
|
|
17001
18914
|
*/
|
|
17002
18915
|
static emit(signal, data = {}, options = {}) {
|
|
17003
|
-
|
|
18916
|
+
import_core6.default.emit(signal, data, options);
|
|
17004
18917
|
}
|
|
17005
18918
|
static debounce(signal, context = {}, delayMs = 500) {
|
|
17006
|
-
|
|
18919
|
+
import_core6.default.debounce(signal, context, delayMs);
|
|
17007
18920
|
}
|
|
17008
18921
|
static schedule(signal, context, timeoutMs, exactDateTime) {
|
|
17009
|
-
|
|
18922
|
+
import_core6.default.schedule(signal, context, timeoutMs, exactDateTime);
|
|
17010
18923
|
}
|
|
17011
18924
|
static interval(signal, context, intervalMs, leading = false, startDateTime) {
|
|
17012
|
-
|
|
18925
|
+
import_core6.default.interval(signal, context, intervalMs, leading, startDateTime);
|
|
17013
18926
|
}
|
|
17014
18927
|
static defineIntent(intent) {
|
|
17015
18928
|
this.inquiryBroker?.addIntent(intent);
|
|
@@ -17017,35 +18930,35 @@ var CadenzaService = class {
|
|
|
17017
18930
|
}
|
|
17018
18931
|
static getRuntimeValidationPolicy() {
|
|
17019
18932
|
this.bootstrap();
|
|
17020
|
-
return
|
|
18933
|
+
return import_core6.default.getRuntimeValidationPolicy();
|
|
17021
18934
|
}
|
|
17022
18935
|
static setRuntimeValidationPolicy(policy = {}) {
|
|
17023
18936
|
this.bootstrap();
|
|
17024
|
-
return
|
|
18937
|
+
return import_core6.default.setRuntimeValidationPolicy(policy);
|
|
17025
18938
|
}
|
|
17026
18939
|
static replaceRuntimeValidationPolicy(policy = {}) {
|
|
17027
18940
|
this.bootstrap();
|
|
17028
|
-
return
|
|
18941
|
+
return import_core6.default.replaceRuntimeValidationPolicy(policy);
|
|
17029
18942
|
}
|
|
17030
18943
|
static clearRuntimeValidationPolicy() {
|
|
17031
18944
|
this.bootstrap();
|
|
17032
|
-
|
|
18945
|
+
import_core6.default.clearRuntimeValidationPolicy();
|
|
17033
18946
|
}
|
|
17034
18947
|
static getRuntimeValidationScopes() {
|
|
17035
18948
|
this.bootstrap();
|
|
17036
|
-
return
|
|
18949
|
+
return import_core6.default.getRuntimeValidationScopes();
|
|
17037
18950
|
}
|
|
17038
18951
|
static upsertRuntimeValidationScope(scope) {
|
|
17039
18952
|
this.bootstrap();
|
|
17040
|
-
return
|
|
18953
|
+
return import_core6.default.upsertRuntimeValidationScope(scope);
|
|
17041
18954
|
}
|
|
17042
18955
|
static removeRuntimeValidationScope(id) {
|
|
17043
18956
|
this.bootstrap();
|
|
17044
|
-
|
|
18957
|
+
import_core6.default.removeRuntimeValidationScope(id);
|
|
17045
18958
|
}
|
|
17046
18959
|
static clearRuntimeValidationScopes() {
|
|
17047
18960
|
this.bootstrap();
|
|
17048
|
-
|
|
18961
|
+
import_core6.default.clearRuntimeValidationScopes();
|
|
17049
18962
|
}
|
|
17050
18963
|
static getInquiryResponderDescriptor(task) {
|
|
17051
18964
|
return this.serviceRegistry.getInquiryResponderDescriptor(task);
|
|
@@ -17407,7 +19320,7 @@ var CadenzaService = class {
|
|
|
17407
19320
|
});
|
|
17408
19321
|
}
|
|
17409
19322
|
static get(taskName) {
|
|
17410
|
-
return
|
|
19323
|
+
return import_core6.default.get(taskName);
|
|
17411
19324
|
}
|
|
17412
19325
|
static getLocalCadenzaDBTask(tableName, operation) {
|
|
17413
19326
|
const generatedTaskName = this.buildGeneratedLocalCadenzaDBTaskName(
|
|
@@ -17418,7 +19331,7 @@ var CadenzaService = class {
|
|
|
17418
19331
|
tableName,
|
|
17419
19332
|
operation
|
|
17420
19333
|
);
|
|
17421
|
-
return
|
|
19334
|
+
return import_core6.default.get(generatedTaskName) ?? import_core6.default.get(legacyTaskName);
|
|
17422
19335
|
}
|
|
17423
19336
|
static getLocalCadenzaDBInsertTask(tableName) {
|
|
17424
19337
|
return this.getLocalCadenzaDBTask(tableName, "insert");
|
|
@@ -17427,15 +19340,15 @@ var CadenzaService = class {
|
|
|
17427
19340
|
return this.getLocalCadenzaDBTask(tableName, "query");
|
|
17428
19341
|
}
|
|
17429
19342
|
static getActor(actorName) {
|
|
17430
|
-
const cadenzaWithActors =
|
|
19343
|
+
const cadenzaWithActors = import_core6.default;
|
|
17431
19344
|
return cadenzaWithActors.getActor?.(actorName);
|
|
17432
19345
|
}
|
|
17433
19346
|
static getAllActors() {
|
|
17434
|
-
const cadenzaWithActors =
|
|
19347
|
+
const cadenzaWithActors = import_core6.default;
|
|
17435
19348
|
return cadenzaWithActors.getAllActors?.() ?? [];
|
|
17436
19349
|
}
|
|
17437
19350
|
static getRoutine(routineName) {
|
|
17438
|
-
return
|
|
19351
|
+
return import_core6.default.getRoutine(routineName);
|
|
17439
19352
|
}
|
|
17440
19353
|
/**
|
|
17441
19354
|
* Creates a new DeputyTask instance based on the provided routine name, service name, and options.
|
|
@@ -18047,10 +19960,28 @@ var CadenzaService = class {
|
|
|
18047
19960
|
__isFrontend: isFrontend,
|
|
18048
19961
|
__declaredTransports: declaredTransports
|
|
18049
19962
|
};
|
|
19963
|
+
let bootstrapServiceCreationRequested = false;
|
|
18050
19964
|
if (options.cadenzaDB?.connect) {
|
|
18051
|
-
this.
|
|
18052
|
-
|
|
18053
|
-
|
|
19965
|
+
this.createMetaTask(
|
|
19966
|
+
"Create service",
|
|
19967
|
+
async (context, emit2) => {
|
|
19968
|
+
const handshakeServiceName = String(context?.serviceName ?? "").trim();
|
|
19969
|
+
if (handshakeServiceName !== "CadenzaDB") {
|
|
19970
|
+
return false;
|
|
19971
|
+
}
|
|
19972
|
+
if (bootstrapServiceCreationRequested) {
|
|
19973
|
+
return false;
|
|
19974
|
+
}
|
|
19975
|
+
bootstrapServiceCreationRequested = true;
|
|
19976
|
+
emit2("meta.create_service_requested", initContext);
|
|
19977
|
+
return true;
|
|
19978
|
+
},
|
|
19979
|
+
"Requests local service creation only once after the initial authority bootstrap handshake completes.",
|
|
19980
|
+
{
|
|
19981
|
+
register: false,
|
|
19982
|
+
isHidden: true
|
|
19983
|
+
}
|
|
19984
|
+
).doOn("meta.fetch.handshake_complete");
|
|
18054
19985
|
} else {
|
|
18055
19986
|
this.emit("meta.create_service_requested", initContext);
|
|
18056
19987
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
@@ -18063,10 +19994,33 @@ var CadenzaService = class {
|
|
|
18063
19994
|
);
|
|
18064
19995
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
18065
19996
|
}
|
|
19997
|
+
let serviceSetupCompletedHandled = false;
|
|
18066
19998
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
19999
|
+
if (serviceSetupCompletedHandled) {
|
|
20000
|
+
return false;
|
|
20001
|
+
}
|
|
20002
|
+
const insertedServiceInstanceId = String(
|
|
20003
|
+
ctx?.serviceInstanceId ?? ctx?.service_instance_id ?? ctx?.serviceInstance?.uuid ?? ctx?.serviceInstance?.serviceInstanceId ?? ""
|
|
20004
|
+
).trim();
|
|
20005
|
+
const insertedServiceName = String(
|
|
20006
|
+
ctx?.serviceName ?? ctx?.service_name ?? ctx?.serviceInstance?.serviceName ?? ctx?.serviceInstance?.service_name ?? ""
|
|
20007
|
+
).trim();
|
|
20008
|
+
if (!insertedServiceInstanceId && !insertedServiceName) {
|
|
20009
|
+
return false;
|
|
20010
|
+
}
|
|
20011
|
+
if (insertedServiceInstanceId && insertedServiceInstanceId !== serviceId) {
|
|
20012
|
+
return false;
|
|
20013
|
+
}
|
|
20014
|
+
if (!insertedServiceInstanceId && insertedServiceName && insertedServiceName !== serviceName) {
|
|
20015
|
+
return false;
|
|
20016
|
+
}
|
|
20017
|
+
serviceSetupCompletedHandled = true;
|
|
18067
20018
|
if (options.cadenzaDB?.connect) {
|
|
18068
20019
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
18069
|
-
void this.publishServiceManifestIfNeeded(
|
|
20020
|
+
void this.publishServiceManifestIfNeeded(
|
|
20021
|
+
"service_setup_completed",
|
|
20022
|
+
"business_structural"
|
|
20023
|
+
);
|
|
18070
20024
|
}
|
|
18071
20025
|
if (isFrontend) {
|
|
18072
20026
|
registerActorSessionPersistenceTasks();
|
|
@@ -18076,7 +20030,7 @@ var CadenzaService = class {
|
|
|
18076
20030
|
return true;
|
|
18077
20031
|
}).doOn("meta.service_registry.instance_inserted");
|
|
18078
20032
|
if (!options.cadenzaDB?.connect) {
|
|
18079
|
-
|
|
20033
|
+
import_core6.default.schedule(
|
|
18080
20034
|
"meta.service_registry.instance_registration_requested",
|
|
18081
20035
|
{
|
|
18082
20036
|
data: {
|
|
@@ -18121,7 +20075,11 @@ var CadenzaService = class {
|
|
|
18121
20075
|
);
|
|
18122
20076
|
}
|
|
18123
20077
|
this.serviceCreated = true;
|
|
18124
|
-
this.requestServiceManifestPublication(
|
|
20078
|
+
this.requestServiceManifestPublication(
|
|
20079
|
+
"service_created",
|
|
20080
|
+
true,
|
|
20081
|
+
"routing_capability"
|
|
20082
|
+
);
|
|
18125
20083
|
}
|
|
18126
20084
|
/**
|
|
18127
20085
|
* Creates a Cadenza metadata service with the specified name, description, and options.
|
|
@@ -18382,7 +20340,7 @@ var CadenzaService = class {
|
|
|
18382
20340
|
}
|
|
18383
20341
|
static createActor(spec, options = {}) {
|
|
18384
20342
|
this.bootstrap();
|
|
18385
|
-
return
|
|
20343
|
+
return import_core6.default.createActor(
|
|
18386
20344
|
spec,
|
|
18387
20345
|
this.withActorSessionHydration(
|
|
18388
20346
|
spec,
|
|
@@ -18392,7 +20350,7 @@ var CadenzaService = class {
|
|
|
18392
20350
|
}
|
|
18393
20351
|
static createActorFromDefinition(definition, options = {}) {
|
|
18394
20352
|
this.bootstrap();
|
|
18395
|
-
return
|
|
20353
|
+
return import_core6.default.createActorFromDefinition(
|
|
18396
20354
|
definition,
|
|
18397
20355
|
this.withActorSessionHydration(
|
|
18398
20356
|
{
|
|
@@ -18430,7 +20388,7 @@ var CadenzaService = class {
|
|
|
18430
20388
|
...options,
|
|
18431
20389
|
hydrateDurableState: async (actorKey) => {
|
|
18432
20390
|
registerActorSessionPersistenceTasks();
|
|
18433
|
-
const response = await
|
|
20391
|
+
const response = await import_core6.default.inquire(
|
|
18434
20392
|
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
18435
20393
|
{
|
|
18436
20394
|
actor_name: actorName,
|
|
@@ -18533,7 +20491,7 @@ var CadenzaService = class {
|
|
|
18533
20491
|
*/
|
|
18534
20492
|
static createTask(name, func, description, options = {}) {
|
|
18535
20493
|
this.bootstrap();
|
|
18536
|
-
return
|
|
20494
|
+
return import_core6.default.createTask(name, func, description, options);
|
|
18537
20495
|
}
|
|
18538
20496
|
/**
|
|
18539
20497
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
@@ -18549,7 +20507,7 @@ var CadenzaService = class {
|
|
|
18549
20507
|
*/
|
|
18550
20508
|
static createMetaTask(name, func, description, options = {}) {
|
|
18551
20509
|
this.bootstrap();
|
|
18552
|
-
return
|
|
20510
|
+
return import_core6.default.createMetaTask(name, func, description, options);
|
|
18553
20511
|
}
|
|
18554
20512
|
/**
|
|
18555
20513
|
* Creates a unique task by wrapping the provided task function with a uniqueness constraint.
|
|
@@ -18599,7 +20557,7 @@ var CadenzaService = class {
|
|
|
18599
20557
|
*/
|
|
18600
20558
|
static createUniqueTask(name, func, description, options = {}) {
|
|
18601
20559
|
this.bootstrap();
|
|
18602
|
-
return
|
|
20560
|
+
return import_core6.default.createUniqueTask(name, func, description, options);
|
|
18603
20561
|
}
|
|
18604
20562
|
/**
|
|
18605
20563
|
* Creates a unique meta task with the specified name, function, description, and options.
|
|
@@ -18613,7 +20571,7 @@ var CadenzaService = class {
|
|
|
18613
20571
|
*/
|
|
18614
20572
|
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
18615
20573
|
this.bootstrap();
|
|
18616
|
-
return
|
|
20574
|
+
return import_core6.default.createUniqueMetaTask(name, func, description, options);
|
|
18617
20575
|
}
|
|
18618
20576
|
/**
|
|
18619
20577
|
* Creates a throttled task with a concurrency limit of 1, ensuring that only one instance of the task can run at a time for a specific throttle tag.
|
|
@@ -18646,7 +20604,7 @@ var CadenzaService = class {
|
|
|
18646
20604
|
*/
|
|
18647
20605
|
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
18648
20606
|
this.bootstrap();
|
|
18649
|
-
return
|
|
20607
|
+
return import_core6.default.createThrottledTask(
|
|
18650
20608
|
name,
|
|
18651
20609
|
func,
|
|
18652
20610
|
throttledIdGetter,
|
|
@@ -18667,7 +20625,7 @@ var CadenzaService = class {
|
|
|
18667
20625
|
*/
|
|
18668
20626
|
static createThrottledMetaTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
18669
20627
|
this.bootstrap();
|
|
18670
|
-
return
|
|
20628
|
+
return import_core6.default.createThrottledMetaTask(
|
|
18671
20629
|
name,
|
|
18672
20630
|
func,
|
|
18673
20631
|
throttledIdGetter,
|
|
@@ -18710,7 +20668,7 @@ var CadenzaService = class {
|
|
|
18710
20668
|
*/
|
|
18711
20669
|
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
18712
20670
|
this.bootstrap();
|
|
18713
|
-
return
|
|
20671
|
+
return import_core6.default.createDebounceTask(
|
|
18714
20672
|
name,
|
|
18715
20673
|
func,
|
|
18716
20674
|
description,
|
|
@@ -18731,7 +20689,7 @@ var CadenzaService = class {
|
|
|
18731
20689
|
*/
|
|
18732
20690
|
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
18733
20691
|
this.bootstrap();
|
|
18734
|
-
return
|
|
20692
|
+
return import_core6.default.createDebounceMetaTask(
|
|
18735
20693
|
name,
|
|
18736
20694
|
func,
|
|
18737
20695
|
description,
|
|
@@ -18801,7 +20759,7 @@ var CadenzaService = class {
|
|
|
18801
20759
|
*/
|
|
18802
20760
|
static createEphemeralTask(name, func, description, options = {}) {
|
|
18803
20761
|
this.bootstrap();
|
|
18804
|
-
return
|
|
20762
|
+
return import_core6.default.createEphemeralTask(name, func, description, options);
|
|
18805
20763
|
}
|
|
18806
20764
|
/**
|
|
18807
20765
|
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
@@ -18815,7 +20773,7 @@ var CadenzaService = class {
|
|
|
18815
20773
|
*/
|
|
18816
20774
|
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
18817
20775
|
this.bootstrap();
|
|
18818
|
-
return
|
|
20776
|
+
return import_core6.default.createEphemeralMetaTask(name, func, description, options);
|
|
18819
20777
|
}
|
|
18820
20778
|
/**
|
|
18821
20779
|
* Creates a new routine with the specified name, tasks, and an optional description.
|
|
@@ -18847,7 +20805,7 @@ var CadenzaService = class {
|
|
|
18847
20805
|
*/
|
|
18848
20806
|
static createRoutine(name, tasks, description = "") {
|
|
18849
20807
|
this.bootstrap();
|
|
18850
|
-
return
|
|
20808
|
+
return import_core6.default.createRoutine(name, tasks, description);
|
|
18851
20809
|
}
|
|
18852
20810
|
/**
|
|
18853
20811
|
* Creates a meta routine with a given name, tasks, and optional description.
|
|
@@ -18862,10 +20820,10 @@ var CadenzaService = class {
|
|
|
18862
20820
|
*/
|
|
18863
20821
|
static createMetaRoutine(name, tasks, description = "") {
|
|
18864
20822
|
this.bootstrap();
|
|
18865
|
-
return
|
|
20823
|
+
return import_core6.default.createMetaRoutine(name, tasks, description);
|
|
18866
20824
|
}
|
|
18867
20825
|
static reset() {
|
|
18868
|
-
|
|
20826
|
+
import_core6.default.reset();
|
|
18869
20827
|
this.serviceRegistry?.reset();
|
|
18870
20828
|
this.unregisterGracefulShutdownHandlers();
|
|
18871
20829
|
this.isBootstrapped = false;
|
|
@@ -18877,6 +20835,11 @@ var CadenzaService = class {
|
|
|
18877
20835
|
this.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
18878
20836
|
this.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18879
20837
|
this.frontendSyncScheduled = false;
|
|
20838
|
+
this.serviceManifestRevision = 0;
|
|
20839
|
+
this.lastPublishedServiceManifestHashes = {};
|
|
20840
|
+
this.serviceManifestPublicationInFlight = false;
|
|
20841
|
+
this.serviceManifestPublicationPendingReason = null;
|
|
20842
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
18880
20843
|
resetBrowserRuntimeActorHandles();
|
|
18881
20844
|
}
|
|
18882
20845
|
};
|
|
@@ -18890,15 +20853,16 @@ CadenzaService.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
|
18890
20853
|
CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18891
20854
|
CadenzaService.frontendSyncScheduled = false;
|
|
18892
20855
|
CadenzaService.serviceManifestRevision = 0;
|
|
18893
|
-
CadenzaService.
|
|
20856
|
+
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
18894
20857
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
18895
20858
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
20859
|
+
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
18896
20860
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
18897
20861
|
CadenzaService.shutdownInFlight = false;
|
|
18898
20862
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
18899
20863
|
|
|
18900
20864
|
// src/index.ts
|
|
18901
|
-
var
|
|
20865
|
+
var import_core7 = require("@cadenza.io/core");
|
|
18902
20866
|
|
|
18903
20867
|
// src/ssr/createSSRInquiryBridge.ts
|
|
18904
20868
|
var import_uuid8 = require("uuid");
|
|
@@ -18920,6 +20884,17 @@ function normalizeArrayResponse(value, keys) {
|
|
|
18920
20884
|
if (Array.isArray(value?.data)) {
|
|
18921
20885
|
return value.data;
|
|
18922
20886
|
}
|
|
20887
|
+
const joinedContexts = Array.isArray(value?.joinedContexts) ? value.joinedContexts : [];
|
|
20888
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
20889
|
+
const nested = joinedContexts[index];
|
|
20890
|
+
if (!nested || typeof nested !== "object") {
|
|
20891
|
+
continue;
|
|
20892
|
+
}
|
|
20893
|
+
const rows = normalizeArrayResponse(nested, keys);
|
|
20894
|
+
if (rows.length > 0) {
|
|
20895
|
+
return rows;
|
|
20896
|
+
}
|
|
20897
|
+
}
|
|
18923
20898
|
return [];
|
|
18924
20899
|
}
|
|
18925
20900
|
function buildQueryResponseKeys(tableName) {
|