@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.mjs
CHANGED
|
@@ -21,6 +21,30 @@ var LOCAL_ROUTINE_PERSISTENCE_KEYS = [
|
|
|
21
21
|
"__routineCreatedAt",
|
|
22
22
|
"__routineIsMeta"
|
|
23
23
|
];
|
|
24
|
+
var BULKY_EXECUTION_PERSISTENCE_KEYS = [
|
|
25
|
+
"rows",
|
|
26
|
+
"joinedContexts",
|
|
27
|
+
"serviceInstances",
|
|
28
|
+
"serviceInstanceLeases",
|
|
29
|
+
"serviceInstanceTransports",
|
|
30
|
+
"serviceManifests",
|
|
31
|
+
"tasks",
|
|
32
|
+
"helpers",
|
|
33
|
+
"globals",
|
|
34
|
+
"signals",
|
|
35
|
+
"intents",
|
|
36
|
+
"actors",
|
|
37
|
+
"routines",
|
|
38
|
+
"directionalTaskMaps",
|
|
39
|
+
"actorTaskMaps",
|
|
40
|
+
"taskToRoutineMaps",
|
|
41
|
+
"taskToHelperMaps",
|
|
42
|
+
"helperToHelperMaps",
|
|
43
|
+
"taskToGlobalMaps",
|
|
44
|
+
"helperToGlobalMaps",
|
|
45
|
+
"signalToTaskMaps",
|
|
46
|
+
"intentToTaskMaps"
|
|
47
|
+
];
|
|
24
48
|
function readHintValue(source, key) {
|
|
25
49
|
if (!source || typeof source !== "object") {
|
|
26
50
|
return void 0;
|
|
@@ -47,8 +71,80 @@ function stripLocalRoutinePersistenceHints(input) {
|
|
|
47
71
|
}
|
|
48
72
|
return context;
|
|
49
73
|
}
|
|
74
|
+
function summarizeQueryData(queryData) {
|
|
75
|
+
if (!queryData || typeof queryData !== "object") {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
const summary = {};
|
|
79
|
+
if (queryData.data && typeof queryData.data === "object") {
|
|
80
|
+
summary.dataKeys = Object.keys(queryData.data).sort();
|
|
81
|
+
}
|
|
82
|
+
if (queryData.filter && typeof queryData.filter === "object") {
|
|
83
|
+
summary.filterKeys = Object.keys(queryData.filter).sort();
|
|
84
|
+
}
|
|
85
|
+
if (queryData.onConflict && typeof queryData.onConflict === "object") {
|
|
86
|
+
const onConflict = queryData.onConflict;
|
|
87
|
+
summary.onConflictTarget = Array.isArray(onConflict.target) ? [...onConflict.target] : onConflict.target ?? null;
|
|
88
|
+
}
|
|
89
|
+
return Object.keys(summary).length > 0 ? summary : void 0;
|
|
90
|
+
}
|
|
91
|
+
function sanitizeExecutionPersistenceContext(input) {
|
|
92
|
+
const context = stripLocalRoutinePersistenceHints(input);
|
|
93
|
+
for (const key of BULKY_EXECUTION_PERSISTENCE_KEYS) {
|
|
94
|
+
const value = context[key];
|
|
95
|
+
if (value === void 0) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const countKey = `${key}Count`;
|
|
99
|
+
if (context[countKey] === void 0) {
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
context[countKey] = value.length;
|
|
102
|
+
} else if (value && typeof value === "object") {
|
|
103
|
+
context[countKey] = Object.keys(value).length;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
delete context[key];
|
|
107
|
+
}
|
|
108
|
+
if (context.queryData && typeof context.queryData === "object") {
|
|
109
|
+
const queryDataSummary = summarizeQueryData(context.queryData);
|
|
110
|
+
if (queryDataSummary) {
|
|
111
|
+
context.queryData = queryDataSummary;
|
|
112
|
+
} else {
|
|
113
|
+
delete context.queryData;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return context;
|
|
117
|
+
}
|
|
118
|
+
function sanitizeExecutionPersistenceResultPayload(input) {
|
|
119
|
+
const payload = input && typeof input === "object" ? { ...input } : {};
|
|
120
|
+
const resultContext = payload.resultContext && typeof payload.resultContext === "object" ? sanitizeExecutionPersistenceContext(
|
|
121
|
+
payload.resultContext
|
|
122
|
+
) : payload.resultContext;
|
|
123
|
+
const metaResultContext = payload.metaResultContext && typeof payload.metaResultContext === "object" ? sanitizeExecutionPersistenceContext(
|
|
124
|
+
payload.metaResultContext
|
|
125
|
+
) : payload.metaResultContext;
|
|
126
|
+
const snakeResultContext = payload.result_context && typeof payload.result_context === "object" ? sanitizeExecutionPersistenceContext(
|
|
127
|
+
payload.result_context
|
|
128
|
+
) : payload.result_context;
|
|
129
|
+
const snakeMetaResultContext = payload.meta_result_context && typeof payload.meta_result_context === "object" ? sanitizeExecutionPersistenceContext(
|
|
130
|
+
payload.meta_result_context
|
|
131
|
+
) : payload.meta_result_context;
|
|
132
|
+
if (resultContext !== void 0) {
|
|
133
|
+
payload.resultContext = resultContext;
|
|
134
|
+
}
|
|
135
|
+
if (metaResultContext !== void 0) {
|
|
136
|
+
payload.metaResultContext = metaResultContext;
|
|
137
|
+
}
|
|
138
|
+
if (snakeResultContext !== void 0) {
|
|
139
|
+
payload.result_context = snakeResultContext;
|
|
140
|
+
}
|
|
141
|
+
if (snakeMetaResultContext !== void 0) {
|
|
142
|
+
payload.meta_result_context = snakeMetaResultContext;
|
|
143
|
+
}
|
|
144
|
+
return payload;
|
|
145
|
+
}
|
|
50
146
|
function splitRoutinePersistenceContext(input) {
|
|
51
|
-
const sanitized =
|
|
147
|
+
const sanitized = sanitizeExecutionPersistenceContext(input);
|
|
52
148
|
return {
|
|
53
149
|
context: Object.fromEntries(
|
|
54
150
|
Object.entries(sanitized).filter(([key]) => !key.startsWith("__"))
|
|
@@ -79,14 +175,55 @@ var ROOT_METADATA_PASSTHROUGH_KEYS = [
|
|
|
79
175
|
"__inquirySourceRoutineExecutionId"
|
|
80
176
|
];
|
|
81
177
|
var DELEGATION_REQUEST_SNAPSHOT_KEY = "__delegationRequestContext";
|
|
178
|
+
var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
179
|
+
"__remoteRoutineName",
|
|
180
|
+
"__serviceName",
|
|
181
|
+
"__timeout",
|
|
182
|
+
"__localTaskName",
|
|
183
|
+
"__localTaskVersion",
|
|
184
|
+
"__localServiceName",
|
|
185
|
+
"__localRoutineExecId",
|
|
186
|
+
"__previousTaskExecutionId",
|
|
187
|
+
"__fetchId",
|
|
188
|
+
"fetchId",
|
|
189
|
+
"__routeKey",
|
|
190
|
+
"routeKey",
|
|
191
|
+
"__instance",
|
|
192
|
+
"__transportId",
|
|
193
|
+
"__transportOrigin",
|
|
194
|
+
"__transportProtocols",
|
|
195
|
+
"__transportProtocol",
|
|
196
|
+
"__retries",
|
|
197
|
+
"__triedInstances",
|
|
198
|
+
"__delegationRequestContext",
|
|
199
|
+
"__metadata",
|
|
200
|
+
"serviceName",
|
|
201
|
+
"serviceInstanceId",
|
|
202
|
+
"serviceTransportId",
|
|
203
|
+
"serviceOrigin",
|
|
204
|
+
"transportProtocols",
|
|
205
|
+
"transportProtocol"
|
|
206
|
+
];
|
|
207
|
+
function isPlainObject(value) {
|
|
208
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
const prototype = Object.getPrototypeOf(value);
|
|
212
|
+
return prototype === Object.prototype || prototype === null;
|
|
213
|
+
}
|
|
82
214
|
function cloneDelegationValue(value) {
|
|
215
|
+
if (value instanceof Date) {
|
|
216
|
+
return new Date(value.getTime());
|
|
217
|
+
}
|
|
83
218
|
if (Array.isArray(value)) {
|
|
84
|
-
return value.map(
|
|
85
|
-
(item) => item && typeof item === "object" ? { ...item } : item
|
|
86
|
-
);
|
|
219
|
+
return value.map((item) => cloneDelegationValue(item));
|
|
87
220
|
}
|
|
88
|
-
if (value
|
|
89
|
-
|
|
221
|
+
if (isPlainObject(value)) {
|
|
222
|
+
const clone = {};
|
|
223
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
224
|
+
clone[key] = cloneDelegationValue(nestedValue);
|
|
225
|
+
}
|
|
226
|
+
return clone;
|
|
90
227
|
}
|
|
91
228
|
return value;
|
|
92
229
|
}
|
|
@@ -122,9 +259,9 @@ function attachDelegationRequestSnapshot(input) {
|
|
|
122
259
|
function restoreDelegationRequestSnapshot(input) {
|
|
123
260
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
124
261
|
const mutableContext = context;
|
|
125
|
-
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
262
|
+
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY] ?? (mutableContext.__metadata && typeof mutableContext.__metadata === "object" ? mutableContext.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] : void 0);
|
|
126
263
|
const snapshot = snapshotCandidate && typeof snapshotCandidate === "object" ? snapshotCandidate : null;
|
|
127
|
-
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true;
|
|
264
|
+
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;
|
|
128
265
|
if (!snapshot || !looksLikeDelegationResult) {
|
|
129
266
|
return context;
|
|
130
267
|
}
|
|
@@ -145,6 +282,26 @@ function stripDelegationRequestSnapshot(input) {
|
|
|
145
282
|
delete context[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
146
283
|
return context;
|
|
147
284
|
}
|
|
285
|
+
function buildDelegationFailureContext(signalName, input, error) {
|
|
286
|
+
const source = input && typeof input === "object" ? { ...input } : {};
|
|
287
|
+
const slimContext = {};
|
|
288
|
+
for (const key of DELEGATION_FAILURE_CONTEXT_KEYS) {
|
|
289
|
+
if (source[key] !== void 0) {
|
|
290
|
+
slimContext[key] = cloneDelegationValue(source[key]);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] === void 0 && source.__metadata && typeof source.__metadata === "object" && source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] !== void 0) {
|
|
294
|
+
slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] = cloneDelegationValue(
|
|
295
|
+
source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY]
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
__signalName: signalName,
|
|
300
|
+
__error: error instanceof Error ? error.message : String(error ?? "Unknown error"),
|
|
301
|
+
errored: true,
|
|
302
|
+
...slimContext
|
|
303
|
+
};
|
|
304
|
+
}
|
|
148
305
|
function stripTransportSelectionRoutingContext(input) {
|
|
149
306
|
const context = stripLocalRoutinePersistenceHints(
|
|
150
307
|
input && typeof input === "object" ? { ...input } : {}
|
|
@@ -176,6 +333,90 @@ function ensureDelegationContextMetadata(input) {
|
|
|
176
333
|
|
|
177
334
|
// src/graph/definition/DeputyTask.ts
|
|
178
335
|
var SERVICE_REGISTRY_TRACE_SERVICE = (process.env.CADENZA_SERVICE_REGISTRY_TRACE_SERVICE ?? "").trim();
|
|
336
|
+
function deputyTaskExecutor(context, emit2, inquire, _tools, progressCallback) {
|
|
337
|
+
const task = this;
|
|
338
|
+
return new Promise((resolve, reject) => {
|
|
339
|
+
if (context.__metadata.__blockRemoteExecution) {
|
|
340
|
+
reject(new Error("Blocked remote execution"));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (context.__metadata.__skipRemoteExecution) {
|
|
344
|
+
resolve(context);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const processId = uuid2();
|
|
348
|
+
context.__metadata.__deputyExecId = processId;
|
|
349
|
+
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
350
|
+
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
351
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
352
|
+
localTaskName: context.__localTaskName ?? null,
|
|
353
|
+
remoteRoutineName: context.__remoteRoutineName ?? null,
|
|
354
|
+
targetServiceName: context.__serviceName ?? null,
|
|
355
|
+
deputyExecId: processId,
|
|
356
|
+
dataKeys: context.data && typeof context.data === "object" ? Object.keys(context.data) : [],
|
|
357
|
+
queryDataKeys: context.queryData && typeof context.queryData === "object" ? Object.keys(context.queryData) : [],
|
|
358
|
+
queryDataDataKeys: context.queryData?.data && typeof context.queryData.data === "object" ? Object.keys(context.queryData.data) : []
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
emit2("meta.deputy.delegation_requested", {
|
|
362
|
+
...context
|
|
363
|
+
});
|
|
364
|
+
CadenzaService.createEphemeralMetaTask(
|
|
365
|
+
`On progress deputy ${task.remoteRoutineName}`,
|
|
366
|
+
(ctx) => {
|
|
367
|
+
if (typeof progressCallback === "function" && ctx.progress) {
|
|
368
|
+
progressCallback(ctx.progress * ctx.weight);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
`Ephemeral task for deputy process ${processId}`,
|
|
372
|
+
{
|
|
373
|
+
once: false,
|
|
374
|
+
destroyCondition: (ctx) => ctx.progress === 1 || ctx.progress === void 0,
|
|
375
|
+
register: false
|
|
376
|
+
}
|
|
377
|
+
).doOn(
|
|
378
|
+
`meta.socket_client.delegation_progress:${processId}`,
|
|
379
|
+
`meta.socket_client.delegated:${processId}`,
|
|
380
|
+
`meta.fetch.delegated:${processId}`,
|
|
381
|
+
`meta.service_registry.load_balance_failed:${processId}`
|
|
382
|
+
);
|
|
383
|
+
CadenzaService.createEphemeralMetaTask(
|
|
384
|
+
`Resolve deputy ${task.remoteRoutineName}`,
|
|
385
|
+
(responseCtx) => {
|
|
386
|
+
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
387
|
+
...context,
|
|
388
|
+
...responseCtx
|
|
389
|
+
} : responseCtx;
|
|
390
|
+
if (responseCtx?.errored) {
|
|
391
|
+
reject(new Error(responseCtx.__error));
|
|
392
|
+
} else {
|
|
393
|
+
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
394
|
+
console.log(
|
|
395
|
+
"[CADENZA_SERVICE_REGISTRY_TRACE] deputy_insert_service_instance_resolved",
|
|
396
|
+
{
|
|
397
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
398
|
+
targetServiceName: context.__serviceName ?? null,
|
|
399
|
+
resolverRequestId: context.__resolverRequestId ?? null,
|
|
400
|
+
serviceInstanceId: mergedResponseCtx && typeof mergedResponseCtx === "object" ? mergedResponseCtx.__serviceInstanceId ?? mergedResponseCtx.uuid ?? mergedResponseCtx.data?.uuid ?? null : null,
|
|
401
|
+
hasResolverQueryData: mergedResponseCtx && typeof mergedResponseCtx === "object" && mergedResponseCtx.__resolverQueryData !== void 0
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
406
|
+
delete mergedResponseCtx.__isDeputy;
|
|
407
|
+
}
|
|
408
|
+
resolve(mergedResponseCtx);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
`Ephemeral resolver for deputy process ${processId}`,
|
|
412
|
+
{ register: false }
|
|
413
|
+
).doOn(
|
|
414
|
+
`meta.socket_client.delegated:${processId}`,
|
|
415
|
+
`meta.fetch.delegated:${processId}`,
|
|
416
|
+
`meta.service_registry.load_balance_failed:${processId}`
|
|
417
|
+
);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
179
420
|
var DeputyTask = class extends Task {
|
|
180
421
|
/**
|
|
181
422
|
* Constructs a new instance of the class with the specified parameters.
|
|
@@ -203,87 +444,9 @@ var DeputyTask = class extends Task {
|
|
|
203
444
|
* @return {void} This constructor does not return a value.
|
|
204
445
|
*/
|
|
205
446
|
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) {
|
|
206
|
-
const taskFunction = (context, emit2, inquire, progressCallback) => {
|
|
207
|
-
return new Promise((resolve, reject) => {
|
|
208
|
-
if (context.__metadata.__blockRemoteExecution) {
|
|
209
|
-
reject(new Error("Blocked remote execution"));
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (context.__metadata.__skipRemoteExecution) {
|
|
213
|
-
resolve(context);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const processId = uuid2();
|
|
217
|
-
context.__metadata.__deputyExecId = processId;
|
|
218
|
-
if ((process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true") && context.__remoteRoutineName === "Insert service_instance") {
|
|
219
|
-
console.log("[CADENZA_INSTANCE_DEBUG] deputy_delegation_requested", {
|
|
220
|
-
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
221
|
-
localTaskName: context.__localTaskName ?? null,
|
|
222
|
-
remoteRoutineName: context.__remoteRoutineName ?? null,
|
|
223
|
-
targetServiceName: context.__serviceName ?? null,
|
|
224
|
-
deputyExecId: processId,
|
|
225
|
-
dataKeys: context.data && typeof context.data === "object" ? Object.keys(context.data) : [],
|
|
226
|
-
queryDataKeys: context.queryData && typeof context.queryData === "object" ? Object.keys(context.queryData) : [],
|
|
227
|
-
queryDataDataKeys: context.queryData?.data && typeof context.queryData.data === "object" ? Object.keys(context.queryData.data) : []
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
emit2("meta.deputy.delegation_requested", {
|
|
231
|
-
...context
|
|
232
|
-
});
|
|
233
|
-
CadenzaService.createEphemeralMetaTask(
|
|
234
|
-
`On progress deputy ${this.remoteRoutineName}`,
|
|
235
|
-
(ctx) => {
|
|
236
|
-
if (ctx.progress) progressCallback(ctx.progress * ctx.weight);
|
|
237
|
-
},
|
|
238
|
-
`Ephemeral task for deputy process ${processId}`,
|
|
239
|
-
{
|
|
240
|
-
once: false,
|
|
241
|
-
destroyCondition: (ctx) => ctx.progress === 1 || ctx.progress === void 0,
|
|
242
|
-
register: false
|
|
243
|
-
}
|
|
244
|
-
).doOn(
|
|
245
|
-
`meta.socket_client.delegation_progress:${processId}`,
|
|
246
|
-
`meta.socket_client.delegated:${processId}`,
|
|
247
|
-
`meta.fetch.delegated:${processId}`,
|
|
248
|
-
`meta.service_registry.load_balance_failed:${processId}`
|
|
249
|
-
);
|
|
250
|
-
CadenzaService.createEphemeralMetaTask(
|
|
251
|
-
`Resolve deputy ${this.remoteRoutineName}`,
|
|
252
|
-
(responseCtx) => {
|
|
253
|
-
const mergedResponseCtx = responseCtx && typeof responseCtx === "object" ? {
|
|
254
|
-
...context,
|
|
255
|
-
...responseCtx
|
|
256
|
-
} : responseCtx;
|
|
257
|
-
if (responseCtx?.errored) {
|
|
258
|
-
reject(new Error(responseCtx.__error));
|
|
259
|
-
} else {
|
|
260
|
-
if (SERVICE_REGISTRY_TRACE_SERVICE.length > 0 && CadenzaService.serviceRegistry.serviceName === SERVICE_REGISTRY_TRACE_SERVICE && context.__remoteRoutineName === "Insert service_instance") {
|
|
261
|
-
console.log("[CADENZA_SERVICE_REGISTRY_TRACE] deputy_insert_service_instance_resolved", {
|
|
262
|
-
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
263
|
-
targetServiceName: context.__serviceName ?? null,
|
|
264
|
-
resolverRequestId: context.__resolverRequestId ?? null,
|
|
265
|
-
serviceInstanceId: mergedResponseCtx && typeof mergedResponseCtx === "object" ? mergedResponseCtx.__serviceInstanceId ?? mergedResponseCtx.uuid ?? mergedResponseCtx.data?.uuid ?? null : null,
|
|
266
|
-
hasResolverQueryData: mergedResponseCtx && typeof mergedResponseCtx === "object" && mergedResponseCtx.__resolverQueryData !== void 0
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
if (mergedResponseCtx && typeof mergedResponseCtx === "object") {
|
|
270
|
-
delete mergedResponseCtx.__isDeputy;
|
|
271
|
-
}
|
|
272
|
-
resolve(mergedResponseCtx);
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
`Ephemeral resolver for deputy process ${processId}`,
|
|
276
|
-
{ register: false }
|
|
277
|
-
).doOn(
|
|
278
|
-
`meta.socket_client.delegated:${processId}`,
|
|
279
|
-
`meta.fetch.delegated:${processId}`,
|
|
280
|
-
`meta.service_registry.load_balance_failed:${processId}`
|
|
281
|
-
);
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
447
|
super(
|
|
285
448
|
name,
|
|
286
|
-
|
|
449
|
+
deputyTaskExecutor,
|
|
287
450
|
description,
|
|
288
451
|
concurrency,
|
|
289
452
|
timeout,
|
|
@@ -315,6 +478,11 @@ var DeputyTask = class extends Task {
|
|
|
315
478
|
communicationType: "delegation"
|
|
316
479
|
});
|
|
317
480
|
}
|
|
481
|
+
clone() {
|
|
482
|
+
throw new Error(
|
|
483
|
+
`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.`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
318
486
|
/**
|
|
319
487
|
* Executes the specified task function within the provided execution context.
|
|
320
488
|
*
|
|
@@ -358,12 +526,32 @@ var DeputyTask = class extends Task {
|
|
|
358
526
|
})
|
|
359
527
|
)
|
|
360
528
|
);
|
|
361
|
-
|
|
529
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
530
|
+
this,
|
|
531
|
+
deputyContext,
|
|
532
|
+
emit2,
|
|
533
|
+
inquire,
|
|
534
|
+
progressCallback
|
|
535
|
+
) : {
|
|
536
|
+
helpers: {},
|
|
537
|
+
globals: {}
|
|
538
|
+
};
|
|
539
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
540
|
+
};
|
|
541
|
+
return this.taskFunction(
|
|
542
|
+
deputyContext,
|
|
543
|
+
emit2,
|
|
544
|
+
inquire,
|
|
545
|
+
resolvedTools,
|
|
546
|
+
resolvedProgressCallback
|
|
547
|
+
);
|
|
362
548
|
}
|
|
363
549
|
};
|
|
364
550
|
|
|
365
551
|
// src/graph/definition/DatabaseTask.ts
|
|
366
552
|
var ACTOR_SESSION_TRACE_ENABLED = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
553
|
+
var actorSessionEmptyDelegationLogCount = 0;
|
|
554
|
+
var ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT = 40;
|
|
367
555
|
var INSTANCE_TRACE_ENABLED = process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true";
|
|
368
556
|
var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
369
557
|
"Insert execution_trace",
|
|
@@ -425,6 +613,11 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
425
613
|
);
|
|
426
614
|
this.queryData = queryData;
|
|
427
615
|
}
|
|
616
|
+
clone() {
|
|
617
|
+
throw new Error(
|
|
618
|
+
`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.`
|
|
619
|
+
);
|
|
620
|
+
}
|
|
428
621
|
/**
|
|
429
622
|
* Executes the specified task within the given context.
|
|
430
623
|
*
|
|
@@ -465,15 +658,16 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
465
658
|
}
|
|
466
659
|
delete ctx.__metadata;
|
|
467
660
|
const isResolverExecution = typeof ctx.__resolverRequestId === "string" && ctx.__resolverRequestId.length > 0;
|
|
468
|
-
const
|
|
661
|
+
const resolverQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : null;
|
|
662
|
+
const dynamicQueryData = resolverQueryData ?? (ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {});
|
|
469
663
|
delete ctx.queryData;
|
|
470
664
|
const nextQueryData = {
|
|
471
665
|
...this.queryData,
|
|
472
|
-
data: {
|
|
473
|
-
...ctx.data
|
|
474
|
-
},
|
|
475
666
|
...dynamicQueryData
|
|
476
667
|
};
|
|
668
|
+
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
669
|
+
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
670
|
+
}
|
|
477
671
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
478
672
|
stripDelegationRequestSnapshot(
|
|
479
673
|
hoistDelegationMetadataFields({
|
|
@@ -533,7 +727,41 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
533
727
|
rootKeys: Object.keys(rawContext)
|
|
534
728
|
});
|
|
535
729
|
}
|
|
536
|
-
|
|
730
|
+
if (this.remoteRoutineName === "Insert actor_session_state" && deputyContext.data === void 0 && deputyContext.queryData === void 0 && actorSessionEmptyDelegationLogCount < ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT) {
|
|
731
|
+
actorSessionEmptyDelegationLogCount += 1;
|
|
732
|
+
console.warn("[CADENZA_ACTOR_SESSION_EMPTY_DELEGATION]", {
|
|
733
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
734
|
+
localTaskName: this.name,
|
|
735
|
+
remoteRoutineName: this.remoteRoutineName,
|
|
736
|
+
hadSnapshotBeforeRestore: initialFullContext.__delegationRequestContext !== void 0 || initialFullContext.__metadata?.__delegationRequestContext !== void 0,
|
|
737
|
+
restoredRootKeys: Object.keys(rawContext),
|
|
738
|
+
deputyRootKeys: Object.keys(deputyContext),
|
|
739
|
+
signalName: rawContext.__signalName ?? rawContext.__metadata?.__signalName ?? null,
|
|
740
|
+
inquiryName: rawContext.__inquiryName ?? rawContext.__metadata?.__inquiryName ?? null,
|
|
741
|
+
sourceServiceName: rawContext.__localServiceName ?? rawContext.__metadata?.__localServiceName ?? null,
|
|
742
|
+
sourceRoutineName: rawContext.__routineName ?? rawContext.__metadata?.__routineName ?? null,
|
|
743
|
+
sourceTaskName: rawContext.__localTaskName ?? rawContext.__metadata?.__localTaskName ?? null
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
747
|
+
this,
|
|
748
|
+
deputyContext,
|
|
749
|
+
emit2,
|
|
750
|
+
inquire,
|
|
751
|
+
progressCallback
|
|
752
|
+
) : {
|
|
753
|
+
helpers: {},
|
|
754
|
+
globals: {}
|
|
755
|
+
};
|
|
756
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
757
|
+
};
|
|
758
|
+
return this.taskFunction(
|
|
759
|
+
deputyContext,
|
|
760
|
+
emit2,
|
|
761
|
+
inquire,
|
|
762
|
+
resolvedTools,
|
|
763
|
+
resolvedProgressCallback
|
|
764
|
+
);
|
|
537
765
|
}
|
|
538
766
|
};
|
|
539
767
|
|
|
@@ -572,14 +800,14 @@ var META_INTENT_PREFIX = "meta-";
|
|
|
572
800
|
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
573
801
|
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
574
802
|
var META_READINESS_INTENT = "meta-readiness";
|
|
575
|
-
function
|
|
803
|
+
function isPlainObject2(value) {
|
|
576
804
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
577
805
|
}
|
|
578
806
|
function deepMergeDeterministic(left, right) {
|
|
579
807
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
580
808
|
return [...left, ...right];
|
|
581
809
|
}
|
|
582
|
-
if (
|
|
810
|
+
if (isPlainObject2(left) && isPlainObject2(right)) {
|
|
583
811
|
const merged = { ...left };
|
|
584
812
|
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
585
813
|
for (const key of keys) {
|
|
@@ -823,6 +1051,10 @@ function normalizeServiceInstanceDescriptor(value) {
|
|
|
823
1051
|
return null;
|
|
824
1052
|
}
|
|
825
1053
|
const transports = normalizeTransportArray(raw.transports, uuid9);
|
|
1054
|
+
const leaseStatusRaw = normalizeString2(raw.leaseStatus ?? raw.lease_status);
|
|
1055
|
+
const leaseStatus = leaseStatusRaw === "active" || leaseStatusRaw === "non_responsive" || leaseStatusRaw === "inactive" || leaseStatusRaw === "deleted" ? leaseStatusRaw : void 0;
|
|
1056
|
+
const isActive = leaseStatus === "active" ? true : leaseStatus === "non_responsive" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : Boolean(raw.isActive ?? raw.is_active ?? true);
|
|
1057
|
+
const isNonResponsive = leaseStatus === "non_responsive" ? true : leaseStatus === "active" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : Boolean(raw.isNonResponsive ?? raw.is_non_responsive ?? false);
|
|
826
1058
|
return {
|
|
827
1059
|
uuid: uuid9,
|
|
828
1060
|
serviceName,
|
|
@@ -833,10 +1065,16 @@ function normalizeServiceInstanceDescriptor(value) {
|
|
|
833
1065
|
)
|
|
834
1066
|
),
|
|
835
1067
|
isPrimary: Boolean(raw.isPrimary ?? raw.is_primary ?? false),
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1068
|
+
leaseStatus,
|
|
1069
|
+
leaseExpiresAt: typeof raw.leaseExpiresAt === "string" ? raw.leaseExpiresAt : typeof raw.lease_expires_at === "string" ? raw.lease_expires_at : void 0,
|
|
1070
|
+
lastLeaseRenewedAt: typeof raw.lastLeaseRenewedAt === "string" ? raw.lastLeaseRenewedAt : typeof raw.last_lease_renewed_at === "string" ? raw.last_lease_renewed_at : void 0,
|
|
1071
|
+
isReady: typeof raw.isReady === "boolean" ? raw.isReady : typeof raw.is_ready === "boolean" ? raw.is_ready : void 0,
|
|
1072
|
+
readinessReason: typeof raw.readinessReason === "string" ? raw.readinessReason : typeof raw.readiness_reason === "string" ? raw.readiness_reason : null,
|
|
1073
|
+
lastReadyAt: typeof raw.lastReadyAt === "string" ? raw.lastReadyAt : typeof raw.last_ready_at === "string" ? raw.last_ready_at : null,
|
|
1074
|
+
lastObservedTransportAt: typeof raw.lastObservedTransportAt === "string" ? raw.lastObservedTransportAt : typeof raw.last_observed_transport_at === "string" ? raw.last_observed_transport_at : null,
|
|
1075
|
+
shutdownRequestedAt: typeof raw.shutdownRequestedAt === "string" ? raw.shutdownRequestedAt : typeof raw.shutdown_requested_at === "string" ? raw.shutdown_requested_at : null,
|
|
1076
|
+
isActive,
|
|
1077
|
+
isNonResponsive,
|
|
840
1078
|
isBlocked: Boolean(raw.isBlocked ?? raw.is_blocked ?? false),
|
|
841
1079
|
runtimeState: raw.runtimeState === "healthy" || raw.runtimeState === "degraded" || raw.runtimeState === "overloaded" || raw.runtimeState === "unavailable" ? raw.runtimeState : void 0,
|
|
842
1080
|
acceptingWork: typeof raw.acceptingWork === "boolean" ? raw.acceptingWork : void 0,
|
|
@@ -1289,6 +1527,61 @@ function resolveHealthMetric(input, keys) {
|
|
|
1289
1527
|
}
|
|
1290
1528
|
return void 0;
|
|
1291
1529
|
}
|
|
1530
|
+
function sanitizeRuntimeMetricsHealthDetail(value) {
|
|
1531
|
+
if (!value || typeof value !== "object") {
|
|
1532
|
+
return void 0;
|
|
1533
|
+
}
|
|
1534
|
+
const input = value;
|
|
1535
|
+
const sampledAt = typeof input.sampledAt === "string" && input.sampledAt.trim().length > 0 ? input.sampledAt : void 0;
|
|
1536
|
+
const cpuUsage = normalizeOptionalMetric(input.cpuUsage ?? input.cpu ?? input.cpuLoad);
|
|
1537
|
+
const memoryUsage = normalizeOptionalMetric(
|
|
1538
|
+
input.memoryUsage ?? input.memory ?? input.memoryPressure
|
|
1539
|
+
);
|
|
1540
|
+
const eventLoopLag = normalizeOptionalMetric(
|
|
1541
|
+
input.eventLoopLag ?? input.eventLoopLagMs
|
|
1542
|
+
);
|
|
1543
|
+
const rssBytes = normalizeOptionalMetric(input.rssBytes);
|
|
1544
|
+
const heapUsedBytes = normalizeOptionalMetric(input.heapUsedBytes);
|
|
1545
|
+
const heapTotalBytes = normalizeOptionalMetric(input.heapTotalBytes);
|
|
1546
|
+
const memoryLimitBytes = normalizeOptionalMetric(input.memoryLimitBytes);
|
|
1547
|
+
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) {
|
|
1548
|
+
return void 0;
|
|
1549
|
+
}
|
|
1550
|
+
return {
|
|
1551
|
+
...sampledAt !== void 0 ? { sampledAt } : {},
|
|
1552
|
+
...cpuUsage !== void 0 ? { cpuUsage } : {},
|
|
1553
|
+
...memoryUsage !== void 0 ? { memoryUsage } : {},
|
|
1554
|
+
...eventLoopLag !== void 0 ? { eventLoopLag } : {},
|
|
1555
|
+
...rssBytes !== void 0 ? { rssBytes } : {},
|
|
1556
|
+
...heapUsedBytes !== void 0 ? { heapUsedBytes } : {},
|
|
1557
|
+
...heapTotalBytes !== void 0 ? { heapTotalBytes } : {},
|
|
1558
|
+
...memoryLimitBytes !== void 0 ? { memoryLimitBytes } : {}
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
function sanitizeAuthorityRuntimeStatusHealth(health, options) {
|
|
1562
|
+
const input = health && typeof health === "object" ? health : {};
|
|
1563
|
+
const cpuUsage = options?.cpuUsage !== void 0 ? options.cpuUsage : normalizeOptionalMetric(input.cpuUsage ?? input.cpu ?? input.cpuLoad);
|
|
1564
|
+
const memoryUsage = options?.memoryUsage !== void 0 ? options.memoryUsage : normalizeOptionalMetric(
|
|
1565
|
+
input.memoryUsage ?? input.memory ?? input.memoryPressure
|
|
1566
|
+
);
|
|
1567
|
+
const eventLoopLag = options?.eventLoopLag !== void 0 ? options.eventLoopLag : normalizeOptionalMetric(input.eventLoopLag ?? input.eventLoopLagMs);
|
|
1568
|
+
const runtimeMetrics = sanitizeRuntimeMetricsHealthDetail(input.runtimeMetrics);
|
|
1569
|
+
const runtimeStatus = options?.state || options?.reportedAt || typeof options?.acceptingWork === "boolean" ? {
|
|
1570
|
+
...options?.state ? { state: options.state } : {},
|
|
1571
|
+
...typeof options?.acceptingWork === "boolean" ? { acceptingWork: options.acceptingWork } : {},
|
|
1572
|
+
...options?.reportedAt ? { reportedAt: options.reportedAt } : {}
|
|
1573
|
+
} : void 0;
|
|
1574
|
+
if (cpuUsage === void 0 && memoryUsage === void 0 && eventLoopLag === void 0 && !runtimeMetrics && !runtimeStatus) {
|
|
1575
|
+
return void 0;
|
|
1576
|
+
}
|
|
1577
|
+
return {
|
|
1578
|
+
...cpuUsage !== void 0 ? { cpuUsage } : {},
|
|
1579
|
+
...memoryUsage !== void 0 ? { memoryUsage } : {},
|
|
1580
|
+
...eventLoopLag !== void 0 ? { eventLoopLag } : {},
|
|
1581
|
+
...runtimeMetrics ? { runtimeMetrics } : {},
|
|
1582
|
+
...runtimeStatus ? { runtimeStatus } : {}
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1292
1585
|
function normalizeAuthorityRuntimeStatusReport(input) {
|
|
1293
1586
|
if (!input || typeof input !== "object") {
|
|
1294
1587
|
return null;
|
|
@@ -1317,6 +1610,17 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1317
1610
|
(protocol) => protocol === "rest" || protocol === "socket"
|
|
1318
1611
|
) : [];
|
|
1319
1612
|
const transportProtocols = transportProtocolList.length > 0 ? Array.from(new Set(transportProtocolList)) : void 0;
|
|
1613
|
+
const acceptingWork = Boolean(input.acceptingWork ?? input.accepting_work);
|
|
1614
|
+
const cpuUsage = resolveHealthMetric(input, ["cpuUsage", "cpu", "cpuLoad"]);
|
|
1615
|
+
const memoryUsage = resolveHealthMetric(input, [
|
|
1616
|
+
"memoryUsage",
|
|
1617
|
+
"memory",
|
|
1618
|
+
"memoryPressure"
|
|
1619
|
+
]);
|
|
1620
|
+
const eventLoopLag = resolveHealthMetric(input, [
|
|
1621
|
+
"eventLoopLag",
|
|
1622
|
+
"eventLoopLagMs"
|
|
1623
|
+
]);
|
|
1320
1624
|
return {
|
|
1321
1625
|
serviceName,
|
|
1322
1626
|
serviceInstanceId,
|
|
@@ -1327,7 +1631,7 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1327
1631
|
isFrontend: typeof input.isFrontend === "boolean" ? input.isFrontend : typeof input.is_frontend === "boolean" ? input.is_frontend : void 0,
|
|
1328
1632
|
reportedAt,
|
|
1329
1633
|
state,
|
|
1330
|
-
acceptingWork
|
|
1634
|
+
acceptingWork,
|
|
1331
1635
|
numberOfRunningGraphs: Math.max(
|
|
1332
1636
|
0,
|
|
1333
1637
|
Math.trunc(
|
|
@@ -1336,22 +1640,22 @@ function normalizeAuthorityRuntimeStatusReport(input) {
|
|
|
1336
1640
|
) || 0
|
|
1337
1641
|
)
|
|
1338
1642
|
),
|
|
1339
|
-
cpuUsage
|
|
1340
|
-
memoryUsage
|
|
1341
|
-
|
|
1342
|
-
"memory",
|
|
1343
|
-
"memoryPressure"
|
|
1344
|
-
]),
|
|
1345
|
-
eventLoopLag: resolveHealthMetric(input, [
|
|
1346
|
-
"eventLoopLag",
|
|
1347
|
-
"eventLoopLagMs"
|
|
1348
|
-
]),
|
|
1643
|
+
cpuUsage,
|
|
1644
|
+
memoryUsage,
|
|
1645
|
+
eventLoopLag,
|
|
1349
1646
|
isActive: Boolean(input.isActive ?? input.is_active ?? true),
|
|
1350
1647
|
isNonResponsive: Boolean(
|
|
1351
1648
|
input.isNonResponsive ?? input.is_non_responsive ?? false
|
|
1352
1649
|
),
|
|
1353
1650
|
isBlocked: Boolean(input.isBlocked ?? input.is_blocked ?? false),
|
|
1354
|
-
health: input.health
|
|
1651
|
+
health: sanitizeAuthorityRuntimeStatusHealth(input.health, {
|
|
1652
|
+
state,
|
|
1653
|
+
acceptingWork,
|
|
1654
|
+
reportedAt,
|
|
1655
|
+
cpuUsage,
|
|
1656
|
+
memoryUsage,
|
|
1657
|
+
eventLoopLag
|
|
1658
|
+
})
|
|
1355
1659
|
};
|
|
1356
1660
|
}
|
|
1357
1661
|
function buildAuthorityRuntimeStatusSignature(report) {
|
|
@@ -1364,18 +1668,53 @@ function buildAuthorityRuntimeStatusSignature(report) {
|
|
|
1364
1668
|
transportProtocols: report.transportProtocols ?? [],
|
|
1365
1669
|
state: report.state,
|
|
1366
1670
|
acceptingWork: report.acceptingWork,
|
|
1367
|
-
numberOfRunningGraphs: report.numberOfRunningGraphs,
|
|
1368
|
-
cpuUsage: report.cpuUsage ?? null,
|
|
1369
|
-
memoryUsage: report.memoryUsage ?? null,
|
|
1370
|
-
eventLoopLag: report.eventLoopLag ?? null,
|
|
1371
1671
|
isActive: report.isActive,
|
|
1372
1672
|
isNonResponsive: report.isNonResponsive,
|
|
1373
1673
|
isBlocked: report.isBlocked,
|
|
1374
|
-
isFrontend: report.isFrontend ?? null
|
|
1375
|
-
health: report.health ?? {}
|
|
1674
|
+
isFrontend: report.isFrontend ?? null
|
|
1376
1675
|
});
|
|
1377
1676
|
}
|
|
1378
1677
|
|
|
1678
|
+
// src/registry/runtimeJitter.ts
|
|
1679
|
+
function normalizeKey(key) {
|
|
1680
|
+
return key.trim() || "default";
|
|
1681
|
+
}
|
|
1682
|
+
function hashKeyToUnitInterval(key) {
|
|
1683
|
+
const normalizedKey = normalizeKey(key);
|
|
1684
|
+
let hash = 2166136261;
|
|
1685
|
+
for (let index = 0; index < normalizedKey.length; index += 1) {
|
|
1686
|
+
hash ^= normalizedKey.charCodeAt(index);
|
|
1687
|
+
hash = Math.imul(hash, 16777619);
|
|
1688
|
+
}
|
|
1689
|
+
return (hash >>> 0) / 4294967295;
|
|
1690
|
+
}
|
|
1691
|
+
function normalizeJitterRatio(value) {
|
|
1692
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
1693
|
+
return 0;
|
|
1694
|
+
}
|
|
1695
|
+
return Math.min(value, 1);
|
|
1696
|
+
}
|
|
1697
|
+
function buildDeterministicJitterOffsetMs(baseMs, ratio, key) {
|
|
1698
|
+
if (!Number.isFinite(baseMs) || baseMs <= 0) {
|
|
1699
|
+
return 0;
|
|
1700
|
+
}
|
|
1701
|
+
const normalizedRatio = normalizeJitterRatio(ratio);
|
|
1702
|
+
if (normalizedRatio <= 0) {
|
|
1703
|
+
return 0;
|
|
1704
|
+
}
|
|
1705
|
+
const maxOffsetMs = Math.round(baseMs * normalizedRatio);
|
|
1706
|
+
if (maxOffsetMs <= 0) {
|
|
1707
|
+
return 0;
|
|
1708
|
+
}
|
|
1709
|
+
return Math.round(hashKeyToUnitInterval(key) * maxOffsetMs);
|
|
1710
|
+
}
|
|
1711
|
+
function buildDeterministicJitteredDelayMs(baseMs, ratio, key) {
|
|
1712
|
+
return Math.max(
|
|
1713
|
+
0,
|
|
1714
|
+
Math.round(baseMs) + buildDeterministicJitterOffsetMs(baseMs, ratio, key)
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1379
1718
|
// src/registry/serviceManifestContract.ts
|
|
1380
1719
|
var AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT = "meta-service-registry-authority-service-manifest-report";
|
|
1381
1720
|
var AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL = "global.meta.cadenza_db.service_manifest_updated";
|
|
@@ -1401,16 +1740,23 @@ function normalizeServiceManifestSnapshot(input) {
|
|
|
1401
1740
|
revision,
|
|
1402
1741
|
manifestHash,
|
|
1403
1742
|
publishedAt,
|
|
1743
|
+
publicationLayer: record.publicationLayer === "routing_capability" || record.publicationLayer === "business_structural" || record.publicationLayer === "local_meta_structural" ? record.publicationLayer : "business_structural",
|
|
1404
1744
|
tasks: normalizeArray(record.tasks),
|
|
1405
1745
|
signals: normalizeArray(record.signals),
|
|
1406
1746
|
intents: normalizeArray(record.intents),
|
|
1407
1747
|
actors: normalizeArray(record.actors),
|
|
1408
1748
|
routines: normalizeArray(record.routines),
|
|
1749
|
+
helpers: normalizeArray(record.helpers),
|
|
1750
|
+
globals: normalizeArray(record.globals),
|
|
1409
1751
|
directionalTaskMaps: normalizeArray(record.directionalTaskMaps),
|
|
1410
1752
|
signalToTaskMaps: normalizeArray(record.signalToTaskMaps),
|
|
1411
1753
|
intentToTaskMaps: normalizeArray(record.intentToTaskMaps),
|
|
1412
1754
|
actorTaskMaps: normalizeArray(record.actorTaskMaps),
|
|
1413
|
-
taskToRoutineMaps: normalizeArray(record.taskToRoutineMaps)
|
|
1755
|
+
taskToRoutineMaps: normalizeArray(record.taskToRoutineMaps),
|
|
1756
|
+
taskToHelperMaps: normalizeArray(record.taskToHelperMaps),
|
|
1757
|
+
helperToHelperMaps: normalizeArray(record.helperToHelperMaps),
|
|
1758
|
+
taskToGlobalMaps: normalizeArray(record.taskToGlobalMaps),
|
|
1759
|
+
helperToGlobalMaps: normalizeArray(record.helperToGlobalMaps)
|
|
1414
1760
|
};
|
|
1415
1761
|
}
|
|
1416
1762
|
function selectLatestServiceManifestSnapshots(snapshots) {
|
|
@@ -1530,6 +1876,7 @@ function decomposeSignalName(signalName) {
|
|
|
1530
1876
|
}
|
|
1531
1877
|
|
|
1532
1878
|
// src/registry/serviceManifest.ts
|
|
1879
|
+
import CoreCadenza from "@cadenza.io/core";
|
|
1533
1880
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
1534
1881
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
1535
1882
|
if (typeof taskFunction !== "function") {
|
|
@@ -1673,15 +2020,90 @@ function buildRoutineDefinition(routine, serviceName) {
|
|
|
1673
2020
|
is_meta: routine.isMeta === true
|
|
1674
2021
|
};
|
|
1675
2022
|
}
|
|
2023
|
+
function buildHelperDefinition(helper, serviceName) {
|
|
2024
|
+
return {
|
|
2025
|
+
name: helper.name,
|
|
2026
|
+
version: helper.version,
|
|
2027
|
+
description: helper.description,
|
|
2028
|
+
service_name: serviceName,
|
|
2029
|
+
is_meta: helper.isMeta === true,
|
|
2030
|
+
handler_source: helper.helperFunction.toString(),
|
|
2031
|
+
language: "js"
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
function buildGlobalDefinition(globalDefinition, serviceName) {
|
|
2035
|
+
return {
|
|
2036
|
+
name: globalDefinition.name,
|
|
2037
|
+
version: globalDefinition.version,
|
|
2038
|
+
description: globalDefinition.description,
|
|
2039
|
+
service_name: serviceName,
|
|
2040
|
+
is_meta: globalDefinition.isMeta === true,
|
|
2041
|
+
value: sanitizeManifestValue(globalDefinition.value)
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
1676
2044
|
function shouldExportTask(task) {
|
|
1677
|
-
return !task.isDeputy && !task.isEphemeral;
|
|
2045
|
+
return task.register !== false && task.isHidden !== true && !task.isDeputy && !task.isEphemeral;
|
|
1678
2046
|
}
|
|
1679
2047
|
function shouldExportRoutine(routine) {
|
|
1680
2048
|
return Boolean(String(routine?.name ?? "").trim());
|
|
1681
2049
|
}
|
|
2050
|
+
function buildTaskKey(task) {
|
|
2051
|
+
return `${task.service_name}|${task.name}|${task.version}`;
|
|
2052
|
+
}
|
|
2053
|
+
function buildActorKey(actor) {
|
|
2054
|
+
return `${actor.service_name}|${actor.name}|${actor.version}`;
|
|
2055
|
+
}
|
|
2056
|
+
function buildRoutineKey(routine) {
|
|
2057
|
+
return `${routine.service_name}|${routine.name}|${routine.version}`;
|
|
2058
|
+
}
|
|
2059
|
+
function buildHelperKey(helper) {
|
|
2060
|
+
return `${helper.service_name}|${helper.name}|${helper.version}`;
|
|
2061
|
+
}
|
|
2062
|
+
function buildGlobalKey(globalDefinition) {
|
|
2063
|
+
return `${globalDefinition.service_name}|${globalDefinition.name}|${globalDefinition.version}`;
|
|
2064
|
+
}
|
|
2065
|
+
function listManifestTasks() {
|
|
2066
|
+
const registryTasks = Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
2067
|
+
(task) => Boolean(task)
|
|
2068
|
+
);
|
|
2069
|
+
const cachedTasks = Array.from(
|
|
2070
|
+
CoreCadenza.taskCache?.values?.() ?? []
|
|
2071
|
+
).filter((task) => Boolean(task));
|
|
2072
|
+
return Array.from(
|
|
2073
|
+
new Map(
|
|
2074
|
+
[...registryTasks, ...cachedTasks].map((task) => [task.name, task])
|
|
2075
|
+
).values()
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2078
|
+
function listManifestHelpers() {
|
|
2079
|
+
const toolRuntime = CadenzaService;
|
|
2080
|
+
return (toolRuntime.getAllHelpers?.() ?? []).filter(
|
|
2081
|
+
(helper) => Boolean(helper && !helper.destroyed)
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
2084
|
+
function listManifestGlobals() {
|
|
2085
|
+
const toolRuntime = CadenzaService;
|
|
2086
|
+
return (toolRuntime.getAllGlobals?.() ?? []).filter(
|
|
2087
|
+
(globalDefinition) => Boolean(globalDefinition && !globalDefinition.destroyed)
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2090
|
+
function isRoutingCriticalMetaSignal(_signal) {
|
|
2091
|
+
return false;
|
|
2092
|
+
}
|
|
2093
|
+
function isRoutingCriticalMetaIntent(_intent) {
|
|
2094
|
+
return false;
|
|
2095
|
+
}
|
|
1682
2096
|
function buildServiceManifestSnapshot(params) {
|
|
1683
|
-
const {
|
|
1684
|
-
|
|
2097
|
+
const {
|
|
2098
|
+
serviceName,
|
|
2099
|
+
serviceInstanceId,
|
|
2100
|
+
revision,
|
|
2101
|
+
publishedAt,
|
|
2102
|
+
publicationLayer = "business_structural"
|
|
2103
|
+
} = params;
|
|
2104
|
+
const tasks = listManifestTasks().filter(shouldExportTask);
|
|
2105
|
+
const helpers = listManifestHelpers();
|
|
2106
|
+
const globals = listManifestGlobals();
|
|
1685
2107
|
const routines = Array.from(CadenzaService.registry.routines.values()).filter((routine) => Boolean(routine)).filter(shouldExportRoutine);
|
|
1686
2108
|
const actors = CadenzaService.getAllActors();
|
|
1687
2109
|
const taskDefinitions = tasks.map((task) => buildTaskDefinition(task, serviceName)).sort(
|
|
@@ -1693,6 +2115,10 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1693
2115
|
const directionalTaskMaps = /* @__PURE__ */ new Map();
|
|
1694
2116
|
const actorTaskMaps = /* @__PURE__ */ new Map();
|
|
1695
2117
|
const taskToRoutineMaps = /* @__PURE__ */ new Map();
|
|
2118
|
+
const helperTaskMaps = /* @__PURE__ */ new Map();
|
|
2119
|
+
const helperHelperMaps = /* @__PURE__ */ new Map();
|
|
2120
|
+
const taskGlobalMaps = /* @__PURE__ */ new Map();
|
|
2121
|
+
const helperGlobalMaps = /* @__PURE__ */ new Map();
|
|
1696
2122
|
const registerSignal = (signalName) => {
|
|
1697
2123
|
const normalizedSignalName = canonicalizeSignalName(signalName);
|
|
1698
2124
|
if (!normalizedSignalName || signalDefinitions.has(normalizedSignalName)) {
|
|
@@ -1776,6 +2202,37 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1776
2202
|
is_meta: actorTaskMetadata.actorKind === "meta" || task.isMeta === true
|
|
1777
2203
|
});
|
|
1778
2204
|
}
|
|
2205
|
+
const taskTools = task;
|
|
2206
|
+
for (const [alias, helperName] of taskTools.helperAliases?.entries?.() ?? []) {
|
|
2207
|
+
const helper = CadenzaService.getHelper?.(helperName);
|
|
2208
|
+
if (!helper) {
|
|
2209
|
+
continue;
|
|
2210
|
+
}
|
|
2211
|
+
const key = `${task.name}|${task.version}|${alias}|${helper.name}|${helper.version}|${serviceName}`;
|
|
2212
|
+
helperTaskMaps.set(key, {
|
|
2213
|
+
task_name: task.name,
|
|
2214
|
+
task_version: task.version,
|
|
2215
|
+
service_name: serviceName,
|
|
2216
|
+
alias,
|
|
2217
|
+
helper_name: helper.name,
|
|
2218
|
+
helper_version: helper.version
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
for (const [alias, globalName] of taskTools.globalAliases?.entries?.() ?? []) {
|
|
2222
|
+
const globalDefinition = CadenzaService.getGlobal?.(globalName);
|
|
2223
|
+
if (!globalDefinition) {
|
|
2224
|
+
continue;
|
|
2225
|
+
}
|
|
2226
|
+
const key = `${task.name}|${task.version}|${alias}|${globalDefinition.name}|${globalDefinition.version}|${serviceName}`;
|
|
2227
|
+
taskGlobalMaps.set(key, {
|
|
2228
|
+
task_name: task.name,
|
|
2229
|
+
task_version: task.version,
|
|
2230
|
+
service_name: serviceName,
|
|
2231
|
+
alias,
|
|
2232
|
+
global_name: globalDefinition.name,
|
|
2233
|
+
global_version: globalDefinition.version
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
1779
2236
|
}
|
|
1780
2237
|
const intentDefinitions = Array.from(CadenzaService.inquiryBroker.intents.values()).map((intent) => {
|
|
1781
2238
|
const intentRecord = intent;
|
|
@@ -1807,6 +2264,44 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1807
2264
|
).sort(
|
|
1808
2265
|
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
1809
2266
|
);
|
|
2267
|
+
const helperDefinitions = helpers.map((helper) => buildHelperDefinition(helper, serviceName)).sort(
|
|
2268
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2269
|
+
);
|
|
2270
|
+
const globalDefinitions = globals.map((globalDefinition) => buildGlobalDefinition(globalDefinition, serviceName)).sort(
|
|
2271
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2272
|
+
);
|
|
2273
|
+
for (const helper of helpers) {
|
|
2274
|
+
for (const [alias, dependencyHelperName] of helper.helperAliases.entries()) {
|
|
2275
|
+
const dependencyHelper = CadenzaService.getHelper?.(dependencyHelperName);
|
|
2276
|
+
if (!dependencyHelper) {
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
const key = `${helper.name}|${helper.version}|${alias}|${dependencyHelper.name}|${dependencyHelper.version}|${serviceName}`;
|
|
2280
|
+
helperHelperMaps.set(key, {
|
|
2281
|
+
helper_name: helper.name,
|
|
2282
|
+
helper_version: helper.version,
|
|
2283
|
+
service_name: serviceName,
|
|
2284
|
+
alias,
|
|
2285
|
+
dependency_helper_name: dependencyHelper.name,
|
|
2286
|
+
dependency_helper_version: dependencyHelper.version
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
for (const [alias, globalName] of helper.globalAliases.entries()) {
|
|
2290
|
+
const globalDefinition = CadenzaService.getGlobal?.(globalName);
|
|
2291
|
+
if (!globalDefinition) {
|
|
2292
|
+
continue;
|
|
2293
|
+
}
|
|
2294
|
+
const key = `${helper.name}|${helper.version}|${alias}|${globalDefinition.name}|${globalDefinition.version}|${serviceName}`;
|
|
2295
|
+
helperGlobalMaps.set(key, {
|
|
2296
|
+
helper_name: helper.name,
|
|
2297
|
+
helper_version: helper.version,
|
|
2298
|
+
service_name: serviceName,
|
|
2299
|
+
alias,
|
|
2300
|
+
global_name: globalDefinition.name,
|
|
2301
|
+
global_version: globalDefinition.version
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
1810
2305
|
for (const routine of routines) {
|
|
1811
2306
|
for (const task of routine.tasks) {
|
|
1812
2307
|
if (!task) {
|
|
@@ -1829,59 +2324,524 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1829
2324
|
}
|
|
1830
2325
|
}
|
|
1831
2326
|
}
|
|
1832
|
-
const
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
)
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
)
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
(
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2327
|
+
const taskDefinitionsByKey = new Map(
|
|
2328
|
+
taskDefinitions.map((task) => [buildTaskKey(task), task])
|
|
2329
|
+
);
|
|
2330
|
+
const signalDefinitionsByName = new Map(
|
|
2331
|
+
Array.from(signalDefinitions.values()).map((signal) => [signal.name, signal])
|
|
2332
|
+
);
|
|
2333
|
+
const intentDefinitionsByName = new Map(
|
|
2334
|
+
intentDefinitions.map((intent) => [intent.name, intent])
|
|
2335
|
+
);
|
|
2336
|
+
const actorDefinitionsByKey = new Map(
|
|
2337
|
+
actorDefinitions.map((actor) => [buildActorKey(actor), actor])
|
|
2338
|
+
);
|
|
2339
|
+
const routineDefinitionsByKey = new Map(
|
|
2340
|
+
routineDefinitions.map((routine) => [buildRoutineKey(routine), routine])
|
|
2341
|
+
);
|
|
2342
|
+
const helperDefinitionsByKey = new Map(
|
|
2343
|
+
helperDefinitions.map((helper) => [buildHelperKey(helper), helper])
|
|
2344
|
+
);
|
|
2345
|
+
const globalDefinitionsByKey = new Map(
|
|
2346
|
+
globalDefinitions.map((globalDefinition) => [
|
|
2347
|
+
buildGlobalKey(globalDefinition),
|
|
2348
|
+
globalDefinition
|
|
2349
|
+
])
|
|
2350
|
+
);
|
|
2351
|
+
const routingTaskKeys = /* @__PURE__ */ new Set();
|
|
2352
|
+
const routingSignalNames = /* @__PURE__ */ new Set();
|
|
2353
|
+
const routingIntentNames = /* @__PURE__ */ new Set();
|
|
2354
|
+
const publishedSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => {
|
|
2355
|
+
const signal = signalDefinitionsByName.get(map.signal_name);
|
|
2356
|
+
return signal?.is_meta !== true || (signal ? isRoutingCriticalMetaSignal(signal) : false);
|
|
2357
|
+
}).sort(
|
|
2358
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2359
|
+
`${right.signal_name}:${right.task_name}`
|
|
2360
|
+
)
|
|
2361
|
+
);
|
|
2362
|
+
const publishedIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => {
|
|
2363
|
+
const intent = intentDefinitionsByName.get(map.intent_name);
|
|
2364
|
+
return intent?.is_meta !== true || (intent ? isRoutingCriticalMetaIntent(intent) : false);
|
|
2365
|
+
}).sort(
|
|
2366
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2367
|
+
`${right.intent_name}:${right.task_name}`
|
|
2368
|
+
)
|
|
2369
|
+
);
|
|
2370
|
+
const localMetaSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => !publishedSignalTaskMaps.includes(map)).sort(
|
|
2371
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2372
|
+
`${right.signal_name}:${right.task_name}`
|
|
2373
|
+
)
|
|
2374
|
+
);
|
|
2375
|
+
const localMetaIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => !publishedIntentTaskMaps.includes(map)).sort(
|
|
2376
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2377
|
+
`${right.intent_name}:${right.task_name}`
|
|
2378
|
+
)
|
|
2379
|
+
);
|
|
2380
|
+
for (const map of publishedSignalTaskMaps) {
|
|
2381
|
+
routingTaskKeys.add(
|
|
2382
|
+
buildTaskKey({
|
|
2383
|
+
service_name: map.service_name,
|
|
2384
|
+
name: map.task_name,
|
|
2385
|
+
version: map.task_version
|
|
2386
|
+
})
|
|
2387
|
+
);
|
|
2388
|
+
routingSignalNames.add(map.signal_name);
|
|
2389
|
+
}
|
|
2390
|
+
for (const map of publishedIntentTaskMaps) {
|
|
2391
|
+
routingTaskKeys.add(
|
|
2392
|
+
buildTaskKey({
|
|
2393
|
+
service_name: map.service_name,
|
|
2394
|
+
name: map.task_name,
|
|
2395
|
+
version: map.task_version
|
|
2396
|
+
})
|
|
2397
|
+
);
|
|
2398
|
+
routingIntentNames.add(map.intent_name);
|
|
2399
|
+
}
|
|
2400
|
+
const routingTasks = Array.from(routingTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter((task) => task !== null).sort(
|
|
2401
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2402
|
+
);
|
|
2403
|
+
const routingSignals = Array.from(routingSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter((signal) => signal !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2404
|
+
const routingIntents = Array.from(routingIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter((intent) => intent !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2405
|
+
const businessTasks = taskDefinitions.filter((task) => task.is_meta !== true && task.is_sub_meta !== true).sort(
|
|
2406
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2407
|
+
);
|
|
2408
|
+
const businessSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2409
|
+
const businessIntents = intentDefinitions.filter((intent) => intent.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2410
|
+
const businessActors = actorDefinitions.filter((actor) => actor.is_meta !== true).sort(
|
|
2411
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2412
|
+
);
|
|
2413
|
+
const businessRoutines = routineDefinitions.filter((routine) => routine.is_meta !== true).sort(
|
|
2414
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2415
|
+
);
|
|
2416
|
+
const businessDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => {
|
|
2417
|
+
const predecessor = taskDefinitionsByKey.get(
|
|
2418
|
+
buildTaskKey({
|
|
2419
|
+
service_name: map.predecessor_service_name,
|
|
2420
|
+
name: map.predecessor_task_name,
|
|
2421
|
+
version: map.predecessor_task_version
|
|
2422
|
+
})
|
|
2423
|
+
);
|
|
2424
|
+
const task = taskDefinitionsByKey.get(
|
|
2425
|
+
buildTaskKey({
|
|
2426
|
+
service_name: map.service_name,
|
|
2427
|
+
name: map.task_name,
|
|
2428
|
+
version: map.task_version
|
|
2429
|
+
})
|
|
2430
|
+
);
|
|
2431
|
+
return predecessor?.is_meta !== true && predecessor?.is_sub_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2432
|
+
}).sort(
|
|
2433
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2434
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2435
|
+
)
|
|
2436
|
+
);
|
|
2437
|
+
const businessActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => {
|
|
2438
|
+
const actor = actorDefinitionsByKey.get(
|
|
2439
|
+
buildActorKey({
|
|
2440
|
+
service_name: map.service_name,
|
|
2441
|
+
name: map.actor_name,
|
|
2442
|
+
version: map.actor_version
|
|
2443
|
+
})
|
|
2444
|
+
);
|
|
2445
|
+
const task = taskDefinitionsByKey.get(
|
|
2446
|
+
buildTaskKey({
|
|
2447
|
+
service_name: map.service_name,
|
|
2448
|
+
name: map.task_name,
|
|
2449
|
+
version: map.task_version
|
|
2450
|
+
})
|
|
2451
|
+
);
|
|
2452
|
+
return actor?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2453
|
+
}).sort(
|
|
2454
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2455
|
+
`${right.actor_name}:${right.task_name}`
|
|
2456
|
+
)
|
|
2457
|
+
);
|
|
2458
|
+
const businessTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => {
|
|
2459
|
+
const routine = routineDefinitionsByKey.get(
|
|
2460
|
+
buildRoutineKey({
|
|
2461
|
+
service_name: map.service_name,
|
|
2462
|
+
name: map.routine_name,
|
|
2463
|
+
version: map.routine_version
|
|
2464
|
+
})
|
|
2465
|
+
);
|
|
2466
|
+
const task = taskDefinitionsByKey.get(
|
|
2467
|
+
buildTaskKey({
|
|
2468
|
+
service_name: map.service_name,
|
|
2469
|
+
name: map.task_name,
|
|
2470
|
+
version: map.task_version
|
|
2471
|
+
})
|
|
2472
|
+
);
|
|
2473
|
+
return routine?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2474
|
+
}).sort(
|
|
2475
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2476
|
+
`${right.routine_name}:${right.task_name}`
|
|
2477
|
+
)
|
|
2478
|
+
);
|
|
2479
|
+
const localMetaTasks = taskDefinitions.filter((task) => task.is_meta === true || task.is_sub_meta === true).sort(
|
|
2480
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2481
|
+
);
|
|
2482
|
+
const localMetaSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2483
|
+
const localMetaIntents = intentDefinitions.filter((intent) => intent.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2484
|
+
const localMetaActors = actorDefinitions.filter((actor) => actor.is_meta === true).sort(
|
|
2485
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2486
|
+
);
|
|
2487
|
+
const localMetaRoutines = routineDefinitions.filter((routine) => routine.is_meta === true).sort(
|
|
2488
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2489
|
+
);
|
|
2490
|
+
const localMetaDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => !businessDirectionalTaskMaps.includes(map)).sort(
|
|
2491
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2492
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2493
|
+
)
|
|
2494
|
+
);
|
|
2495
|
+
const localMetaActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => !businessActorTaskMaps.includes(map)).sort(
|
|
2496
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2497
|
+
`${right.actor_name}:${right.task_name}`
|
|
2498
|
+
)
|
|
2499
|
+
);
|
|
2500
|
+
const localMetaTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => !businessTaskToRoutineMaps.includes(map)).sort(
|
|
2501
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2502
|
+
`${right.routine_name}:${right.task_name}`
|
|
2503
|
+
)
|
|
2504
|
+
);
|
|
2505
|
+
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
2506
|
+
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
2507
|
+
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
2508
|
+
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
2509
|
+
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
2510
|
+
for (const map of localMetaSignalTaskMaps) {
|
|
2511
|
+
businessLocalMetaSignalNames.add(map.signal_name);
|
|
2512
|
+
businessLocalMetaTaskKeys.add(
|
|
2513
|
+
buildTaskKey({
|
|
2514
|
+
service_name: map.service_name,
|
|
2515
|
+
name: map.task_name,
|
|
2516
|
+
version: map.task_version
|
|
2517
|
+
})
|
|
2518
|
+
);
|
|
2519
|
+
}
|
|
2520
|
+
for (const map of localMetaIntentTaskMaps) {
|
|
2521
|
+
businessLocalMetaIntentNames.add(map.intent_name);
|
|
2522
|
+
businessLocalMetaTaskKeys.add(
|
|
2523
|
+
buildTaskKey({
|
|
2524
|
+
service_name: map.service_name,
|
|
2525
|
+
name: map.task_name,
|
|
2526
|
+
version: map.task_version
|
|
2527
|
+
})
|
|
2528
|
+
);
|
|
2529
|
+
}
|
|
2530
|
+
for (const map of localMetaActorTaskMaps) {
|
|
2531
|
+
businessLocalMetaActorKeys.add(
|
|
2532
|
+
buildActorKey({
|
|
2533
|
+
service_name: map.service_name,
|
|
2534
|
+
name: map.actor_name,
|
|
2535
|
+
version: map.actor_version
|
|
2536
|
+
})
|
|
2537
|
+
);
|
|
2538
|
+
businessLocalMetaTaskKeys.add(
|
|
2539
|
+
buildTaskKey({
|
|
2540
|
+
service_name: map.service_name,
|
|
2541
|
+
name: map.task_name,
|
|
2542
|
+
version: map.task_version
|
|
2543
|
+
})
|
|
2544
|
+
);
|
|
2545
|
+
}
|
|
2546
|
+
for (const map of localMetaTaskToRoutineMaps) {
|
|
2547
|
+
businessLocalMetaRoutineKeys.add(
|
|
2548
|
+
buildRoutineKey({
|
|
2549
|
+
service_name: map.service_name,
|
|
2550
|
+
name: map.routine_name,
|
|
2551
|
+
version: map.routine_version
|
|
2552
|
+
})
|
|
2553
|
+
);
|
|
2554
|
+
businessLocalMetaTaskKeys.add(
|
|
2555
|
+
buildTaskKey({
|
|
2556
|
+
service_name: map.service_name,
|
|
2557
|
+
name: map.task_name,
|
|
2558
|
+
version: map.task_version
|
|
2559
|
+
})
|
|
2560
|
+
);
|
|
2561
|
+
}
|
|
2562
|
+
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
2563
|
+
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
2564
|
+
).sort(
|
|
2565
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2566
|
+
);
|
|
2567
|
+
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
2568
|
+
(signal) => signal !== null && signal.is_meta === true
|
|
2569
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2570
|
+
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
2571
|
+
(intent) => intent !== null && intent.is_meta === true
|
|
2572
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2573
|
+
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
2574
|
+
(actor) => actor !== null && actor.is_meta === true
|
|
2575
|
+
).sort(
|
|
2576
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2577
|
+
);
|
|
2578
|
+
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
2579
|
+
(routine) => routine !== null && routine.is_meta === true
|
|
2580
|
+
).sort(
|
|
2581
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2582
|
+
);
|
|
2583
|
+
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
2584
|
+
new Map(
|
|
2585
|
+
[...routingTasks, ...businessTasks, ...businessLocalMetaTasks].map((task) => [
|
|
2586
|
+
buildTaskKey(task),
|
|
2587
|
+
task
|
|
2588
|
+
])
|
|
2589
|
+
).values()
|
|
2590
|
+
).sort(
|
|
2591
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2592
|
+
) : Array.from(
|
|
2593
|
+
new Map(
|
|
2594
|
+
[...routingTasks, ...businessTasks, ...localMetaTasks].map((task) => [
|
|
2595
|
+
buildTaskKey(task),
|
|
2596
|
+
task
|
|
2597
|
+
])
|
|
2598
|
+
).values()
|
|
2599
|
+
).sort(
|
|
2600
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2601
|
+
);
|
|
2602
|
+
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
2603
|
+
new Map(
|
|
2604
|
+
[...routingSignals, ...businessSignals, ...businessLocalMetaSignals].map(
|
|
2605
|
+
(signal) => [signal.name, signal]
|
|
2606
|
+
)
|
|
2607
|
+
).values()
|
|
2608
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2609
|
+
new Map(
|
|
2610
|
+
[...routingSignals, ...businessSignals, ...localMetaSignals].map((signal) => [
|
|
2611
|
+
signal.name,
|
|
2612
|
+
signal
|
|
2613
|
+
])
|
|
2614
|
+
).values()
|
|
2615
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2616
|
+
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
2617
|
+
new Map(
|
|
2618
|
+
[...routingIntents, ...businessIntents, ...businessLocalMetaIntents].map(
|
|
2619
|
+
(intent) => [intent.name, intent]
|
|
2620
|
+
)
|
|
2621
|
+
).values()
|
|
2622
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2623
|
+
new Map(
|
|
2624
|
+
[...routingIntents, ...businessIntents, ...localMetaIntents].map((intent) => [
|
|
2625
|
+
intent.name,
|
|
2626
|
+
intent
|
|
2627
|
+
])
|
|
2628
|
+
).values()
|
|
2629
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2630
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2631
|
+
new Map(
|
|
2632
|
+
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
2633
|
+
buildActorKey(actor),
|
|
2634
|
+
actor
|
|
2635
|
+
])
|
|
2636
|
+
).values()
|
|
2637
|
+
).sort(
|
|
2638
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2639
|
+
) : Array.from(
|
|
2640
|
+
new Map(
|
|
2641
|
+
[...businessActors, ...localMetaActors].map((actor) => [
|
|
2642
|
+
buildActorKey(actor),
|
|
2643
|
+
actor
|
|
2644
|
+
])
|
|
2645
|
+
).values()
|
|
2646
|
+
).sort(
|
|
2647
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2648
|
+
);
|
|
2649
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2650
|
+
new Map(
|
|
2651
|
+
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
2652
|
+
buildRoutineKey(routine),
|
|
2653
|
+
routine
|
|
2654
|
+
])
|
|
2655
|
+
).values()
|
|
2656
|
+
).sort(
|
|
2657
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2658
|
+
) : Array.from(
|
|
2659
|
+
new Map(
|
|
2660
|
+
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
2661
|
+
buildRoutineKey(routine),
|
|
2662
|
+
routine
|
|
2663
|
+
])
|
|
2664
|
+
).values()
|
|
2665
|
+
).sort(
|
|
2666
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2667
|
+
);
|
|
2668
|
+
const businessHelpers = helperDefinitions.filter((helper) => helper.is_meta !== true).sort(
|
|
2669
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2670
|
+
);
|
|
2671
|
+
const localMetaHelpers = helperDefinitions.filter((helper) => helper.is_meta === true).sort(
|
|
2672
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2673
|
+
);
|
|
2674
|
+
const businessGlobals = globalDefinitions.filter((globalDefinition) => globalDefinition.is_meta !== true).sort(
|
|
2675
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2676
|
+
);
|
|
2677
|
+
const localMetaGlobals = globalDefinitions.filter((globalDefinition) => globalDefinition.is_meta === true).sort(
|
|
2678
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2679
|
+
);
|
|
2680
|
+
const businessTaskToHelperMaps = Array.from(helperTaskMaps.values()).filter((map) => {
|
|
2681
|
+
const task = taskDefinitionsByKey.get(
|
|
2682
|
+
buildTaskKey({
|
|
2683
|
+
service_name: map.service_name,
|
|
2684
|
+
name: map.task_name,
|
|
2685
|
+
version: map.task_version
|
|
2686
|
+
})
|
|
2687
|
+
);
|
|
2688
|
+
const helper = helperDefinitionsByKey.get(
|
|
2689
|
+
buildHelperKey({
|
|
2690
|
+
service_name: map.service_name,
|
|
2691
|
+
name: map.helper_name,
|
|
2692
|
+
version: map.helper_version
|
|
2693
|
+
})
|
|
2694
|
+
);
|
|
2695
|
+
return task?.is_meta !== true && task?.is_sub_meta !== true && helper?.is_meta !== true;
|
|
2696
|
+
}).sort(
|
|
2697
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2698
|
+
);
|
|
2699
|
+
const localMetaTaskToHelperMaps = Array.from(helperTaskMaps.values()).filter((map) => !businessTaskToHelperMaps.includes(map)).sort(
|
|
2700
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2701
|
+
);
|
|
2702
|
+
const businessHelperToHelperMaps = Array.from(helperHelperMaps.values()).filter((map) => {
|
|
2703
|
+
const helper = helperDefinitionsByKey.get(
|
|
2704
|
+
buildHelperKey({
|
|
2705
|
+
service_name: map.service_name,
|
|
2706
|
+
name: map.helper_name,
|
|
2707
|
+
version: map.helper_version
|
|
2708
|
+
})
|
|
2709
|
+
);
|
|
2710
|
+
const dependencyHelper = helperDefinitionsByKey.get(
|
|
2711
|
+
buildHelperKey({
|
|
2712
|
+
service_name: map.service_name,
|
|
2713
|
+
name: map.dependency_helper_name,
|
|
2714
|
+
version: map.dependency_helper_version
|
|
2715
|
+
})
|
|
2716
|
+
);
|
|
2717
|
+
return helper?.is_meta !== true && dependencyHelper?.is_meta !== true;
|
|
2718
|
+
}).sort(
|
|
2719
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2720
|
+
);
|
|
2721
|
+
const localMetaHelperToHelperMaps = Array.from(helperHelperMaps.values()).filter((map) => !businessHelperToHelperMaps.includes(map)).sort(
|
|
2722
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2723
|
+
);
|
|
2724
|
+
const businessTaskToGlobalMaps = Array.from(taskGlobalMaps.values()).filter((map) => {
|
|
2725
|
+
const task = taskDefinitionsByKey.get(
|
|
2726
|
+
buildTaskKey({
|
|
2727
|
+
service_name: map.service_name,
|
|
2728
|
+
name: map.task_name,
|
|
2729
|
+
version: map.task_version
|
|
2730
|
+
})
|
|
2731
|
+
);
|
|
2732
|
+
const globalDefinition = globalDefinitionsByKey.get(
|
|
2733
|
+
buildGlobalKey({
|
|
2734
|
+
service_name: map.service_name,
|
|
2735
|
+
name: map.global_name,
|
|
2736
|
+
version: map.global_version
|
|
2737
|
+
})
|
|
2738
|
+
);
|
|
2739
|
+
return task?.is_meta !== true && task?.is_sub_meta !== true && globalDefinition?.is_meta !== true;
|
|
2740
|
+
}).sort(
|
|
2741
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2742
|
+
);
|
|
2743
|
+
const localMetaTaskToGlobalMaps = Array.from(taskGlobalMaps.values()).filter((map) => !businessTaskToGlobalMaps.includes(map)).sort(
|
|
2744
|
+
(left, right) => `${left.task_name}:${left.alias}`.localeCompare(`${right.task_name}:${right.alias}`)
|
|
2745
|
+
);
|
|
2746
|
+
const businessHelperToGlobalMaps = Array.from(helperGlobalMaps.values()).filter((map) => {
|
|
2747
|
+
const helper = helperDefinitionsByKey.get(
|
|
2748
|
+
buildHelperKey({
|
|
2749
|
+
service_name: map.service_name,
|
|
2750
|
+
name: map.helper_name,
|
|
2751
|
+
version: map.helper_version
|
|
2752
|
+
})
|
|
2753
|
+
);
|
|
2754
|
+
const globalDefinition = globalDefinitionsByKey.get(
|
|
2755
|
+
buildGlobalKey({
|
|
2756
|
+
service_name: map.service_name,
|
|
2757
|
+
name: map.global_name,
|
|
2758
|
+
version: map.global_version
|
|
2759
|
+
})
|
|
2760
|
+
);
|
|
2761
|
+
return helper?.is_meta !== true && globalDefinition?.is_meta !== true;
|
|
2762
|
+
}).sort(
|
|
2763
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2764
|
+
);
|
|
2765
|
+
const localMetaHelperToGlobalMaps = Array.from(helperGlobalMaps.values()).filter((map) => !businessHelperToGlobalMaps.includes(map)).sort(
|
|
2766
|
+
(left, right) => `${left.helper_name}:${left.alias}`.localeCompare(`${right.helper_name}:${right.alias}`)
|
|
2767
|
+
);
|
|
2768
|
+
const cumulativeHelpers = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelpers : [...businessHelpers, ...localMetaHelpers];
|
|
2769
|
+
const cumulativeGlobals = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessGlobals : [...businessGlobals, ...localMetaGlobals];
|
|
2770
|
+
const cumulativeTaskToHelperMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToHelperMaps : [...businessTaskToHelperMaps, ...localMetaTaskToHelperMaps];
|
|
2771
|
+
const cumulativeHelperToHelperMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelperToHelperMaps : [...businessHelperToHelperMaps, ...localMetaHelperToHelperMaps];
|
|
2772
|
+
const cumulativeTaskToGlobalMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToGlobalMaps : [...businessTaskToGlobalMaps, ...localMetaTaskToGlobalMaps];
|
|
2773
|
+
const cumulativeHelperToGlobalMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessHelperToGlobalMaps : [...businessHelperToGlobalMaps, ...localMetaHelperToGlobalMaps];
|
|
2774
|
+
const cumulativeDirectionalTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessDirectionalTaskMaps : Array.from(
|
|
2775
|
+
new Map(
|
|
2776
|
+
[...businessDirectionalTaskMaps, ...localMetaDirectionalTaskMaps].map(
|
|
2777
|
+
(map) => [
|
|
2778
|
+
`${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
2779
|
+
map
|
|
2780
|
+
]
|
|
2781
|
+
)
|
|
2782
|
+
).values()
|
|
2783
|
+
);
|
|
2784
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2785
|
+
new Map(
|
|
2786
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2787
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2788
|
+
map
|
|
2789
|
+
])
|
|
2790
|
+
).values()
|
|
2791
|
+
) : Array.from(
|
|
2792
|
+
new Map(
|
|
2793
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2794
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2795
|
+
map
|
|
2796
|
+
])
|
|
2797
|
+
).values()
|
|
2798
|
+
);
|
|
2799
|
+
const cumulativeTaskToRoutineMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToRoutineMaps : Array.from(
|
|
2800
|
+
new Map(
|
|
2801
|
+
[...businessTaskToRoutineMaps, ...localMetaTaskToRoutineMaps].map((map) => [
|
|
2802
|
+
`${map.service_name}|${map.task_name}|${map.task_version}|${map.routine_name}|${map.routine_version}`,
|
|
2803
|
+
map
|
|
2804
|
+
])
|
|
2805
|
+
).values()
|
|
2806
|
+
);
|
|
2807
|
+
const manifestBody = {
|
|
2808
|
+
serviceName,
|
|
2809
|
+
serviceInstanceId,
|
|
2810
|
+
publicationLayer,
|
|
2811
|
+
tasks: cumulativeTasks,
|
|
2812
|
+
signals: cumulativeSignals,
|
|
2813
|
+
intents: cumulativeIntents,
|
|
2814
|
+
actors: cumulativeActors,
|
|
2815
|
+
routines: cumulativeRoutines,
|
|
2816
|
+
helpers: cumulativeHelpers,
|
|
2817
|
+
globals: cumulativeGlobals,
|
|
2818
|
+
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
2819
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps],
|
|
2820
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps],
|
|
2821
|
+
actorTaskMaps: cumulativeActorTaskMaps,
|
|
2822
|
+
taskToRoutineMaps: cumulativeTaskToRoutineMaps,
|
|
2823
|
+
taskToHelperMaps: cumulativeTaskToHelperMaps,
|
|
2824
|
+
helperToHelperMaps: cumulativeHelperToHelperMaps,
|
|
2825
|
+
taskToGlobalMaps: cumulativeTaskToGlobalMaps,
|
|
2826
|
+
helperToGlobalMaps: cumulativeHelperToGlobalMaps
|
|
2827
|
+
};
|
|
2828
|
+
return {
|
|
2829
|
+
...manifestBody,
|
|
2830
|
+
revision,
|
|
2831
|
+
manifestHash: hashManifest(manifestBody),
|
|
2832
|
+
publishedAt
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
function explodeServiceManifestSnapshots(snapshots) {
|
|
2836
|
+
const dedupe = (items, keyOf, sortOf) => Array.from(
|
|
2837
|
+
new Map(items.map((item) => [keyOf(item), item])).values()
|
|
2838
|
+
).sort(sortOf);
|
|
2839
|
+
const tasks = dedupe(
|
|
2840
|
+
snapshots.flatMap((snapshot) => snapshot.tasks),
|
|
2841
|
+
(task) => `${task.service_name}|${task.name}|${task.version}`,
|
|
2842
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2843
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2844
|
+
)
|
|
1885
2845
|
);
|
|
1886
2846
|
const signals = dedupe(
|
|
1887
2847
|
snapshots.flatMap((snapshot) => snapshot.signals),
|
|
@@ -1907,6 +2867,20 @@ function explodeServiceManifestSnapshots(snapshots) {
|
|
|
1907
2867
|
`${right.service_name}|${right.name}|${right.version}`
|
|
1908
2868
|
)
|
|
1909
2869
|
);
|
|
2870
|
+
const helpers = dedupe(
|
|
2871
|
+
snapshots.flatMap((snapshot) => snapshot.helpers),
|
|
2872
|
+
(helper) => `${helper.service_name}|${helper.name}|${helper.version}`,
|
|
2873
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2874
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2875
|
+
)
|
|
2876
|
+
);
|
|
2877
|
+
const globals = dedupe(
|
|
2878
|
+
snapshots.flatMap((snapshot) => snapshot.globals),
|
|
2879
|
+
(globalDefinition) => `${globalDefinition.service_name}|${globalDefinition.name}|${globalDefinition.version}`,
|
|
2880
|
+
(left, right) => `${left.service_name}|${left.name}|${left.version}`.localeCompare(
|
|
2881
|
+
`${right.service_name}|${right.name}|${right.version}`
|
|
2882
|
+
)
|
|
2883
|
+
);
|
|
1910
2884
|
const directionalTaskMaps = dedupe(
|
|
1911
2885
|
snapshots.flatMap((snapshot) => snapshot.directionalTaskMaps),
|
|
1912
2886
|
(map) => `${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
@@ -1942,17 +2916,51 @@ function explodeServiceManifestSnapshots(snapshots) {
|
|
|
1942
2916
|
`${right.routine_name}|${right.routine_version}|${right.service_name}|${right.task_name}|${right.task_version}`
|
|
1943
2917
|
)
|
|
1944
2918
|
);
|
|
2919
|
+
const taskToHelperMaps = dedupe(
|
|
2920
|
+
snapshots.flatMap((snapshot) => snapshot.taskToHelperMaps),
|
|
2921
|
+
(map) => `${map.service_name}|${map.task_name}|${map.task_version}|${map.alias}|${map.helper_name}|${map.helper_version}`,
|
|
2922
|
+
(left, right) => `${left.service_name}|${left.task_name}|${left.alias}|${left.helper_name}`.localeCompare(
|
|
2923
|
+
`${right.service_name}|${right.task_name}|${right.alias}|${right.helper_name}`
|
|
2924
|
+
)
|
|
2925
|
+
);
|
|
2926
|
+
const helperToHelperMaps = dedupe(
|
|
2927
|
+
snapshots.flatMap((snapshot) => snapshot.helperToHelperMaps),
|
|
2928
|
+
(map) => `${map.service_name}|${map.helper_name}|${map.helper_version}|${map.alias}|${map.dependency_helper_name}|${map.dependency_helper_version}`,
|
|
2929
|
+
(left, right) => `${left.service_name}|${left.helper_name}|${left.alias}|${left.dependency_helper_name}`.localeCompare(
|
|
2930
|
+
`${right.service_name}|${right.helper_name}|${right.alias}|${right.dependency_helper_name}`
|
|
2931
|
+
)
|
|
2932
|
+
);
|
|
2933
|
+
const taskToGlobalMaps = dedupe(
|
|
2934
|
+
snapshots.flatMap((snapshot) => snapshot.taskToGlobalMaps),
|
|
2935
|
+
(map) => `${map.service_name}|${map.task_name}|${map.task_version}|${map.alias}|${map.global_name}|${map.global_version}`,
|
|
2936
|
+
(left, right) => `${left.service_name}|${left.task_name}|${left.alias}|${left.global_name}`.localeCompare(
|
|
2937
|
+
`${right.service_name}|${right.task_name}|${right.alias}|${right.global_name}`
|
|
2938
|
+
)
|
|
2939
|
+
);
|
|
2940
|
+
const helperToGlobalMaps = dedupe(
|
|
2941
|
+
snapshots.flatMap((snapshot) => snapshot.helperToGlobalMaps),
|
|
2942
|
+
(map) => `${map.service_name}|${map.helper_name}|${map.helper_version}|${map.alias}|${map.global_name}|${map.global_version}`,
|
|
2943
|
+
(left, right) => `${left.service_name}|${left.helper_name}|${left.alias}|${left.global_name}`.localeCompare(
|
|
2944
|
+
`${right.service_name}|${right.helper_name}|${right.alias}|${right.global_name}`
|
|
2945
|
+
)
|
|
2946
|
+
);
|
|
1945
2947
|
return {
|
|
1946
2948
|
tasks,
|
|
1947
2949
|
signals,
|
|
1948
2950
|
intents,
|
|
1949
2951
|
actors,
|
|
1950
2952
|
routines,
|
|
2953
|
+
helpers,
|
|
2954
|
+
globals,
|
|
1951
2955
|
directionalTaskMaps,
|
|
1952
2956
|
signalToTaskMaps,
|
|
1953
2957
|
intentToTaskMaps,
|
|
1954
2958
|
actorTaskMaps,
|
|
1955
|
-
taskToRoutineMaps
|
|
2959
|
+
taskToRoutineMaps,
|
|
2960
|
+
taskToHelperMaps,
|
|
2961
|
+
helperToHelperMaps,
|
|
2962
|
+
taskToGlobalMaps,
|
|
2963
|
+
helperToGlobalMaps
|
|
1956
2964
|
};
|
|
1957
2965
|
}
|
|
1958
2966
|
|
|
@@ -2001,7 +3009,53 @@ var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRAC
|
|
|
2001
3009
|
function shouldTraceServiceRegistry(serviceName) {
|
|
2002
3010
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
2003
3011
|
}
|
|
2004
|
-
function
|
|
3012
|
+
function normalizeLeaseStatus(value) {
|
|
3013
|
+
const status = String(value ?? "").trim();
|
|
3014
|
+
if (status === "active" || status === "non_responsive" || status === "inactive" || status === "deleted") {
|
|
3015
|
+
return status;
|
|
3016
|
+
}
|
|
3017
|
+
return null;
|
|
3018
|
+
}
|
|
3019
|
+
function overlayServiceInstancesWithLeases(serviceInstances, serviceInstanceLeases) {
|
|
3020
|
+
if (serviceInstanceLeases.length === 0) {
|
|
3021
|
+
return serviceInstances;
|
|
3022
|
+
}
|
|
3023
|
+
const leasesByInstanceId = /* @__PURE__ */ new Map();
|
|
3024
|
+
for (const row of serviceInstanceLeases) {
|
|
3025
|
+
const serviceInstanceId = String(
|
|
3026
|
+
row.service_instance_id ?? row.serviceInstanceId ?? ""
|
|
3027
|
+
).trim();
|
|
3028
|
+
if (!serviceInstanceId) {
|
|
3029
|
+
continue;
|
|
3030
|
+
}
|
|
3031
|
+
leasesByInstanceId.set(serviceInstanceId, row);
|
|
3032
|
+
}
|
|
3033
|
+
return serviceInstances.map((row) => {
|
|
3034
|
+
const serviceInstanceId = String(row.uuid ?? "").trim();
|
|
3035
|
+
const lease = serviceInstanceId ? leasesByInstanceId.get(serviceInstanceId) : void 0;
|
|
3036
|
+
if (!lease) {
|
|
3037
|
+
return row;
|
|
3038
|
+
}
|
|
3039
|
+
const leaseStatus = normalizeLeaseStatus(
|
|
3040
|
+
lease.status ?? lease.lease_status ?? lease.leaseStatus
|
|
3041
|
+
);
|
|
3042
|
+
return {
|
|
3043
|
+
...row,
|
|
3044
|
+
lease_status: leaseStatus ?? void 0,
|
|
3045
|
+
is_ready: typeof lease.is_ready === "boolean" ? lease.is_ready : typeof lease.isReady === "boolean" ? lease.isReady : void 0,
|
|
3046
|
+
readiness_reason: typeof lease.readiness_reason === "string" ? lease.readiness_reason : typeof lease.readinessReason === "string" ? lease.readinessReason : null,
|
|
3047
|
+
lease_expires_at: typeof lease.lease_expires_at === "string" ? lease.lease_expires_at : typeof lease.leaseExpiresAt === "string" ? lease.leaseExpiresAt : null,
|
|
3048
|
+
last_lease_renewed_at: typeof lease.last_lease_renewed_at === "string" ? lease.last_lease_renewed_at : typeof lease.lastLeaseRenewedAt === "string" ? lease.lastLeaseRenewedAt : null,
|
|
3049
|
+
last_ready_at: typeof lease.last_ready_at === "string" ? lease.last_ready_at : typeof lease.lastReadyAt === "string" ? lease.lastReadyAt : null,
|
|
3050
|
+
last_observed_transport_at: typeof lease.last_observed_transport_at === "string" ? lease.last_observed_transport_at : typeof lease.lastObservedTransportAt === "string" ? lease.lastObservedTransportAt : null,
|
|
3051
|
+
shutdown_requested_at: typeof lease.shutdown_requested_at === "string" ? lease.shutdown_requested_at : typeof lease.shutdownRequestedAt === "string" ? lease.shutdownRequestedAt : null,
|
|
3052
|
+
is_active: leaseStatus === "active" ? true : leaseStatus === "non_responsive" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : row.is_active,
|
|
3053
|
+
is_non_responsive: leaseStatus === "non_responsive" ? true : leaseStatus === "active" || leaseStatus === "inactive" || leaseStatus === "deleted" ? false : row.is_non_responsive,
|
|
3054
|
+
deleted: leaseStatus === "deleted" ? true : Boolean(row.deleted ?? false)
|
|
3055
|
+
};
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
function buildServiceRegistryInsertQueryData(tableName, ctx, queryData) {
|
|
2005
3059
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
2006
3060
|
const getJoinedValue = (key) => {
|
|
2007
3061
|
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
@@ -2019,7 +3073,8 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
|
2019
3073
|
if (!Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
2020
3074
|
delete nextQueryData.onConflict;
|
|
2021
3075
|
}
|
|
2022
|
-
const
|
|
3076
|
+
const preferRegistrationData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
3077
|
+
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");
|
|
2023
3078
|
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
2024
3079
|
const nextData = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
2025
3080
|
if (nextData !== void 0) {
|
|
@@ -2046,8 +3101,151 @@ function sanitizeServiceRegistryInsertExecutionContext(ctx) {
|
|
|
2046
3101
|
delete sanitized.returnedValue;
|
|
2047
3102
|
delete sanitized.queryData;
|
|
2048
3103
|
delete sanitized.onConflict;
|
|
3104
|
+
delete sanitized.task;
|
|
3105
|
+
delete sanitized.routine;
|
|
3106
|
+
delete sanitized.httpServer;
|
|
3107
|
+
delete sanitized.service;
|
|
3108
|
+
delete sanitized.serviceInstance;
|
|
3109
|
+
delete sanitized.joinedContexts;
|
|
3110
|
+
delete sanitized.__declaredTransports;
|
|
3111
|
+
delete sanitized.__resolverOriginalContext;
|
|
3112
|
+
delete sanitized.__resolverQueryData;
|
|
2049
3113
|
return sanitized;
|
|
2050
3114
|
}
|
|
3115
|
+
function sanitizeAuthorityBootstrapDelegationContext(ctx) {
|
|
3116
|
+
const sanitized = stripDelegationRequestSnapshot({
|
|
3117
|
+
...ctx
|
|
3118
|
+
});
|
|
3119
|
+
delete sanitized.__resolverOriginalContext;
|
|
3120
|
+
delete sanitized.__resolverQueryData;
|
|
3121
|
+
delete sanitized.joinedContexts;
|
|
3122
|
+
delete sanitized.httpServer;
|
|
3123
|
+
delete sanitized.service;
|
|
3124
|
+
delete sanitized.serviceInstance;
|
|
3125
|
+
delete sanitized.task;
|
|
3126
|
+
delete sanitized.routine;
|
|
3127
|
+
delete sanitized.__declaredTransports;
|
|
3128
|
+
const queryData = sanitized.queryData && typeof sanitized.queryData === "object" ? { ...sanitized.queryData } : null;
|
|
3129
|
+
if (queryData) {
|
|
3130
|
+
delete queryData.joinedContexts;
|
|
3131
|
+
sanitized.queryData = queryData;
|
|
3132
|
+
}
|
|
3133
|
+
return sanitized;
|
|
3134
|
+
}
|
|
3135
|
+
var BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS = [
|
|
3136
|
+
"data",
|
|
3137
|
+
"batch",
|
|
3138
|
+
"transaction",
|
|
3139
|
+
"onConflict",
|
|
3140
|
+
"filter",
|
|
3141
|
+
"fields",
|
|
3142
|
+
"joins",
|
|
3143
|
+
"sort",
|
|
3144
|
+
"limit",
|
|
3145
|
+
"offset",
|
|
3146
|
+
"queryMode",
|
|
3147
|
+
"aggregates",
|
|
3148
|
+
"groupBy"
|
|
3149
|
+
];
|
|
3150
|
+
function isBootstrapDbOperationRoutineName(value) {
|
|
3151
|
+
return /^(Insert|Update|Query|Delete)\s+/.test(String(value ?? "").trim());
|
|
3152
|
+
}
|
|
3153
|
+
function compactAuthorityBootstrapRequestBody(ctx) {
|
|
3154
|
+
if (!isBootstrapDbOperationRoutineName(ctx.__remoteRoutineName)) {
|
|
3155
|
+
return ctx;
|
|
3156
|
+
}
|
|
3157
|
+
const queryData = ctx.queryData && typeof ctx.queryData === "object" ? { ...ctx.queryData } : null;
|
|
3158
|
+
if (!queryData) {
|
|
3159
|
+
return ctx;
|
|
3160
|
+
}
|
|
3161
|
+
const compacted = {
|
|
3162
|
+
...ctx,
|
|
3163
|
+
queryData
|
|
3164
|
+
};
|
|
3165
|
+
for (const key of BOOTSTRAP_DB_OPERATION_CONTEXT_KEYS) {
|
|
3166
|
+
if (Object.prototype.hasOwnProperty.call(queryData, key)) {
|
|
3167
|
+
delete compacted[key];
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
return compacted;
|
|
3171
|
+
}
|
|
3172
|
+
function cloneServiceRegistryContextValue(value) {
|
|
3173
|
+
if (value instanceof Date) {
|
|
3174
|
+
return new Date(value.getTime());
|
|
3175
|
+
}
|
|
3176
|
+
if (Array.isArray(value)) {
|
|
3177
|
+
return value.map(
|
|
3178
|
+
(entry) => cloneServiceRegistryContextValue(entry)
|
|
3179
|
+
);
|
|
3180
|
+
}
|
|
3181
|
+
if (value && typeof value === "object") {
|
|
3182
|
+
const clone = {};
|
|
3183
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3184
|
+
clone[key] = cloneServiceRegistryContextValue(nestedValue);
|
|
3185
|
+
}
|
|
3186
|
+
return clone;
|
|
3187
|
+
}
|
|
3188
|
+
return value;
|
|
3189
|
+
}
|
|
3190
|
+
function buildServiceRegistryResolverOriginalContext(tableName, ctx, queryData) {
|
|
3191
|
+
const originalContext = {};
|
|
3192
|
+
for (const key of [
|
|
3193
|
+
"__serviceName",
|
|
3194
|
+
"serviceName",
|
|
3195
|
+
"__serviceInstanceId",
|
|
3196
|
+
"serviceInstanceId",
|
|
3197
|
+
"__registrationData",
|
|
3198
|
+
"__reason",
|
|
3199
|
+
"__syncing",
|
|
3200
|
+
"__syncSourceServiceName",
|
|
3201
|
+
"__preferredTransportProtocol",
|
|
3202
|
+
"__networkMode",
|
|
3203
|
+
"__securityProfile",
|
|
3204
|
+
"__loadBalance",
|
|
3205
|
+
"__cadenzaDBConnect",
|
|
3206
|
+
"__isFrontend",
|
|
3207
|
+
"__isDatabase",
|
|
3208
|
+
"__retryCount",
|
|
3209
|
+
"__retries",
|
|
3210
|
+
"__triedInstances"
|
|
3211
|
+
]) {
|
|
3212
|
+
if (ctx[key] !== void 0) {
|
|
3213
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
if (queryData.data !== void 0) {
|
|
3217
|
+
originalContext.data = cloneServiceRegistryContextValue(queryData.data);
|
|
3218
|
+
}
|
|
3219
|
+
if (queryData.batch !== void 0) {
|
|
3220
|
+
originalContext.batch = cloneServiceRegistryContextValue(queryData.batch);
|
|
3221
|
+
}
|
|
3222
|
+
if (Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
3223
|
+
originalContext.queryData = {
|
|
3224
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
3225
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0,
|
|
3226
|
+
onConflict: cloneServiceRegistryContextValue(queryData.onConflict)
|
|
3227
|
+
};
|
|
3228
|
+
} else if (queryData.data !== void 0 || queryData.batch !== void 0) {
|
|
3229
|
+
originalContext.queryData = {
|
|
3230
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
3231
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0
|
|
3232
|
+
};
|
|
3233
|
+
}
|
|
3234
|
+
if (tableName === "service_instance") {
|
|
3235
|
+
for (const key of [
|
|
3236
|
+
"__transportData",
|
|
3237
|
+
"transportData",
|
|
3238
|
+
"__useSocket",
|
|
3239
|
+
"__retryCount",
|
|
3240
|
+
"__isFrontend"
|
|
3241
|
+
]) {
|
|
3242
|
+
if (ctx[key] !== void 0) {
|
|
3243
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
return originalContext;
|
|
3248
|
+
}
|
|
2051
3249
|
function clearTransientRoutingErrorState(context) {
|
|
2052
3250
|
delete context.errored;
|
|
2053
3251
|
delete context.failed;
|
|
@@ -2103,7 +3301,8 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2103
3301
|
delete result.__resolverOriginalContext;
|
|
2104
3302
|
delete result.__resolverQueryData;
|
|
2105
3303
|
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
2106
|
-
const
|
|
3304
|
+
const preferRequestedData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
3305
|
+
const resolvedData = preferRequestedData ? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData ?? result.data : result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
2107
3306
|
if (resolvedData !== void 0 && result.data === void 0) {
|
|
2108
3307
|
result.data = resolvedData;
|
|
2109
3308
|
}
|
|
@@ -2133,6 +3332,7 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2133
3332
|
).trim();
|
|
2134
3333
|
if (resolvedServiceName) {
|
|
2135
3334
|
result.__serviceName = resolvedServiceName;
|
|
3335
|
+
result.serviceName = resolvedServiceName;
|
|
2136
3336
|
}
|
|
2137
3337
|
}
|
|
2138
3338
|
const resolvedLocalServiceInstanceId = String(
|
|
@@ -2141,6 +3341,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2141
3341
|
if (resolvedLocalServiceInstanceId) {
|
|
2142
3342
|
result.__serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
2143
3343
|
}
|
|
3344
|
+
if (tableName === "service_instance") {
|
|
3345
|
+
const resolvedServiceName = String(
|
|
3346
|
+
ctx.__serviceName ?? resolveServiceNameFromContext(ctx) ?? resolvedData?.service_name ?? resolvedData?.serviceName ?? ""
|
|
3347
|
+
).trim();
|
|
3348
|
+
if (resolvedServiceName) {
|
|
3349
|
+
result.__serviceName = resolvedServiceName;
|
|
3350
|
+
result.serviceName = resolvedServiceName;
|
|
3351
|
+
}
|
|
3352
|
+
if (resolvedLocalServiceInstanceId) {
|
|
3353
|
+
result.serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
2144
3356
|
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
2145
3357
|
const resolvedUuid = String(
|
|
2146
3358
|
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
@@ -2240,9 +3452,15 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2240
3452
|
ctx
|
|
2241
3453
|
);
|
|
2242
3454
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
3455
|
+
tableName,
|
|
2243
3456
|
sanitizedContext,
|
|
2244
3457
|
queryData
|
|
2245
3458
|
);
|
|
3459
|
+
const resolverOriginalContext = buildServiceRegistryResolverOriginalContext(
|
|
3460
|
+
tableName,
|
|
3461
|
+
sanitizedContext,
|
|
3462
|
+
nextQueryData
|
|
3463
|
+
);
|
|
2246
3464
|
const delegationContext = ensureDelegationContextMetadata({
|
|
2247
3465
|
...sanitizedContext,
|
|
2248
3466
|
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
@@ -2255,9 +3473,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2255
3473
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
2256
3474
|
const nextContext = {
|
|
2257
3475
|
...delegationContext,
|
|
2258
|
-
__resolverOriginalContext:
|
|
2259
|
-
...sanitizedContext
|
|
2260
|
-
},
|
|
3476
|
+
__resolverOriginalContext: resolverOriginalContext,
|
|
2261
3477
|
__resolverQueryData: nextQueryData
|
|
2262
3478
|
};
|
|
2263
3479
|
if (tableName === "service_instance_transport" && shouldTraceServiceRegistry(
|
|
@@ -2309,6 +3525,92 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2309
3525
|
`Resolve service registry insert for ${tableName}`,
|
|
2310
3526
|
(ctx, emit2) => new Promise((resolve) => {
|
|
2311
3527
|
const resolverRequestId = uuid3();
|
|
3528
|
+
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
3529
|
+
const bootstrapAuthorityInsertSpec = !localInsertTask && CadenzaService.serviceRegistry.connectsToCadenzaDB ? getAuthorityBootstrapInsertIntentSpecForTable(tableName) : null;
|
|
3530
|
+
const resolvedTargetServiceName = resolveServiceNameFromContext(ctx);
|
|
3531
|
+
const selfBootstrapRetrySignal = CadenzaService.serviceRegistry.serviceName === "CadenzaDB" && resolvedTargetServiceName === "CadenzaDB" && !localInsertTask ? getSelfBootstrapRegistrationRetrySignal(tableName) : null;
|
|
3532
|
+
if (selfBootstrapRetrySignal) {
|
|
3533
|
+
CadenzaService.schedule(
|
|
3534
|
+
selfBootstrapRetrySignal,
|
|
3535
|
+
{
|
|
3536
|
+
...ctx
|
|
3537
|
+
},
|
|
3538
|
+
250
|
|
3539
|
+
);
|
|
3540
|
+
resolve(false);
|
|
3541
|
+
return;
|
|
3542
|
+
}
|
|
3543
|
+
if (bootstrapAuthorityInsertSpec) {
|
|
3544
|
+
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
3545
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
3546
|
+
tableName,
|
|
3547
|
+
sanitizedContext,
|
|
3548
|
+
queryData
|
|
3549
|
+
);
|
|
3550
|
+
const inquiryContext = ensureDelegationContextMetadata({
|
|
3551
|
+
...sanitizedContext,
|
|
3552
|
+
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
3553
|
+
batch: nextQueryData.batch !== void 0 ? nextQueryData.batch : sanitizedContext.batch,
|
|
3554
|
+
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
3555
|
+
transaction: nextQueryData.transaction !== void 0 ? nextQueryData.transaction : sanitizedContext.transaction,
|
|
3556
|
+
queryData: nextQueryData
|
|
3557
|
+
});
|
|
3558
|
+
inquiryContext.__metadata = {
|
|
3559
|
+
...inquiryContext.__metadata ?? {},
|
|
3560
|
+
__skipRemoteExecution: inquiryContext.__metadata?.__skipRemoteExecution ?? inquiryContext.__skipRemoteExecution ?? false,
|
|
3561
|
+
__blockRemoteExecution: inquiryContext.__metadata?.__blockRemoteExecution ?? inquiryContext.__blockRemoteExecution ?? false
|
|
3562
|
+
};
|
|
3563
|
+
CadenzaService.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
3564
|
+
bootstrapAuthorityInsertSpec.intentName,
|
|
3565
|
+
inquiryContext
|
|
3566
|
+
);
|
|
3567
|
+
void CadenzaService.inquire(
|
|
3568
|
+
bootstrapAuthorityInsertSpec.intentName,
|
|
3569
|
+
inquiryContext,
|
|
3570
|
+
{
|
|
3571
|
+
requireComplete: true,
|
|
3572
|
+
timeout: bootstrapAuthorityInsertSpec.defaultTimeoutMs
|
|
3573
|
+
}
|
|
3574
|
+
).then(
|
|
3575
|
+
(result) => resolve(
|
|
3576
|
+
resolveBootstrapAuthorityInsertResult(
|
|
3577
|
+
tableName,
|
|
3578
|
+
sanitizedContext,
|
|
3579
|
+
nextQueryData,
|
|
3580
|
+
result,
|
|
3581
|
+
emit2
|
|
3582
|
+
)
|
|
3583
|
+
)
|
|
3584
|
+
).catch(
|
|
3585
|
+
(error) => resolve(
|
|
3586
|
+
resolveBootstrapAuthorityInsertResult(
|
|
3587
|
+
tableName,
|
|
3588
|
+
sanitizedContext,
|
|
3589
|
+
nextQueryData,
|
|
3590
|
+
error,
|
|
3591
|
+
emit2
|
|
3592
|
+
)
|
|
3593
|
+
)
|
|
3594
|
+
);
|
|
3595
|
+
return;
|
|
3596
|
+
}
|
|
3597
|
+
const executionSignal = localInsertTask ? localExecutionRequestedSignal : remoteExecutionRequestedSignal;
|
|
3598
|
+
if ((tableName === "service_instance" || tableName === "service") && (process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true")) {
|
|
3599
|
+
console.log("[CADENZA_INSTANCE_DEBUG] resolve_service_registry_insert", {
|
|
3600
|
+
tableName,
|
|
3601
|
+
executionSignal,
|
|
3602
|
+
hasLocalInsertTask: !!localInsertTask,
|
|
3603
|
+
serviceName: ctx.__serviceName ?? ctx.data?.service_name ?? null,
|
|
3604
|
+
serviceInstanceId: ctx.__serviceInstanceId ?? ctx.data?.uuid ?? null,
|
|
3605
|
+
hasData: !!ctx.data,
|
|
3606
|
+
dataKeys: ctx.data && typeof ctx.data === "object" ? Object.keys(ctx.data) : [],
|
|
3607
|
+
registrationKeys: ctx.__registrationData && typeof ctx.__registrationData === "object" ? Object.keys(ctx.__registrationData) : []
|
|
3608
|
+
});
|
|
3609
|
+
}
|
|
3610
|
+
if (localInsertTask && !wiredLocalTaskNames.has(localInsertTask.name)) {
|
|
3611
|
+
wireExecutionTarget(localInsertTask, prepareLocalExecutionTask);
|
|
3612
|
+
wiredLocalTaskNames.add(localInsertTask.name);
|
|
3613
|
+
}
|
|
2312
3614
|
CadenzaService.createEphemeralMetaTask(
|
|
2313
3615
|
`Resolve service registry insert execution for ${tableName} (${resolverRequestId})`,
|
|
2314
3616
|
(resultCtx) => {
|
|
@@ -2408,94 +3710,11 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2408
3710
|
},
|
|
2409
3711
|
`Resolves signal-driven ${tableName} service-registry insert execution.`,
|
|
2410
3712
|
{
|
|
2411
|
-
register: false
|
|
3713
|
+
register: false,
|
|
3714
|
+
once: false,
|
|
3715
|
+
destroyCondition: (result) => result !== false
|
|
2412
3716
|
}
|
|
2413
3717
|
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
2414
|
-
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
2415
|
-
const bootstrapAuthorityInsertSpec = !localInsertTask && CadenzaService.serviceRegistry.connectsToCadenzaDB ? getAuthorityBootstrapInsertIntentSpecForTable(tableName) : null;
|
|
2416
|
-
const resolvedTargetServiceName = resolveServiceNameFromContext(ctx);
|
|
2417
|
-
const selfBootstrapRetrySignal = CadenzaService.serviceRegistry.serviceName === "CadenzaDB" && resolvedTargetServiceName === "CadenzaDB" && !localInsertTask ? getSelfBootstrapRegistrationRetrySignal(tableName) : null;
|
|
2418
|
-
if (selfBootstrapRetrySignal) {
|
|
2419
|
-
CadenzaService.schedule(
|
|
2420
|
-
selfBootstrapRetrySignal,
|
|
2421
|
-
{
|
|
2422
|
-
...ctx
|
|
2423
|
-
},
|
|
2424
|
-
250
|
|
2425
|
-
);
|
|
2426
|
-
resolve(false);
|
|
2427
|
-
return;
|
|
2428
|
-
}
|
|
2429
|
-
if (bootstrapAuthorityInsertSpec) {
|
|
2430
|
-
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
2431
|
-
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
2432
|
-
sanitizedContext,
|
|
2433
|
-
queryData
|
|
2434
|
-
);
|
|
2435
|
-
const inquiryContext = ensureDelegationContextMetadata({
|
|
2436
|
-
...sanitizedContext,
|
|
2437
|
-
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
2438
|
-
batch: nextQueryData.batch !== void 0 ? nextQueryData.batch : sanitizedContext.batch,
|
|
2439
|
-
onConflict: Object.prototype.hasOwnProperty.call(nextQueryData, "onConflict") ? nextQueryData.onConflict : void 0,
|
|
2440
|
-
transaction: nextQueryData.transaction !== void 0 ? nextQueryData.transaction : sanitizedContext.transaction,
|
|
2441
|
-
queryData: nextQueryData
|
|
2442
|
-
});
|
|
2443
|
-
inquiryContext.__metadata = {
|
|
2444
|
-
...inquiryContext.__metadata ?? {},
|
|
2445
|
-
__skipRemoteExecution: inquiryContext.__metadata?.__skipRemoteExecution ?? inquiryContext.__skipRemoteExecution ?? false,
|
|
2446
|
-
__blockRemoteExecution: inquiryContext.__metadata?.__blockRemoteExecution ?? inquiryContext.__blockRemoteExecution ?? false
|
|
2447
|
-
};
|
|
2448
|
-
CadenzaService.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
2449
|
-
bootstrapAuthorityInsertSpec.intentName,
|
|
2450
|
-
inquiryContext
|
|
2451
|
-
);
|
|
2452
|
-
void CadenzaService.inquire(
|
|
2453
|
-
bootstrapAuthorityInsertSpec.intentName,
|
|
2454
|
-
inquiryContext,
|
|
2455
|
-
{
|
|
2456
|
-
requireComplete: true,
|
|
2457
|
-
timeout: bootstrapAuthorityInsertSpec.defaultTimeoutMs
|
|
2458
|
-
}
|
|
2459
|
-
).then(
|
|
2460
|
-
(result) => resolve(
|
|
2461
|
-
resolveBootstrapAuthorityInsertResult(
|
|
2462
|
-
tableName,
|
|
2463
|
-
sanitizedContext,
|
|
2464
|
-
nextQueryData,
|
|
2465
|
-
result,
|
|
2466
|
-
emit2
|
|
2467
|
-
)
|
|
2468
|
-
)
|
|
2469
|
-
).catch(
|
|
2470
|
-
(error) => resolve(
|
|
2471
|
-
resolveBootstrapAuthorityInsertResult(
|
|
2472
|
-
tableName,
|
|
2473
|
-
sanitizedContext,
|
|
2474
|
-
nextQueryData,
|
|
2475
|
-
error,
|
|
2476
|
-
emit2
|
|
2477
|
-
)
|
|
2478
|
-
)
|
|
2479
|
-
);
|
|
2480
|
-
return;
|
|
2481
|
-
}
|
|
2482
|
-
const executionSignal = localInsertTask ? localExecutionRequestedSignal : remoteExecutionRequestedSignal;
|
|
2483
|
-
if ((tableName === "service_instance" || tableName === "service") && (process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true")) {
|
|
2484
|
-
console.log("[CADENZA_INSTANCE_DEBUG] resolve_service_registry_insert", {
|
|
2485
|
-
tableName,
|
|
2486
|
-
executionSignal,
|
|
2487
|
-
hasLocalInsertTask: !!localInsertTask,
|
|
2488
|
-
serviceName: ctx.__serviceName ?? ctx.data?.service_name ?? null,
|
|
2489
|
-
serviceInstanceId: ctx.__serviceInstanceId ?? ctx.data?.uuid ?? null,
|
|
2490
|
-
hasData: !!ctx.data,
|
|
2491
|
-
dataKeys: ctx.data && typeof ctx.data === "object" ? Object.keys(ctx.data) : [],
|
|
2492
|
-
registrationKeys: ctx.__registrationData && typeof ctx.__registrationData === "object" ? Object.keys(ctx.__registrationData) : []
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
if (localInsertTask && !wiredLocalTaskNames.has(localInsertTask.name)) {
|
|
2496
|
-
wireExecutionTarget(localInsertTask, prepareLocalExecutionTask);
|
|
2497
|
-
wiredLocalTaskNames.add(localInsertTask.name);
|
|
2498
|
-
}
|
|
2499
3718
|
emit2(executionSignal, {
|
|
2500
3719
|
...ctx,
|
|
2501
3720
|
__resolverRequestId: resolverRequestId
|
|
@@ -2520,6 +3739,17 @@ function readPositiveIntegerEnv(name, fallback) {
|
|
|
2520
3739
|
}
|
|
2521
3740
|
return normalized;
|
|
2522
3741
|
}
|
|
3742
|
+
function readNonNegativeFloatEnv(name, fallback) {
|
|
3743
|
+
if (typeof process === "undefined") {
|
|
3744
|
+
return fallback;
|
|
3745
|
+
}
|
|
3746
|
+
const raw = process.env?.[name];
|
|
3747
|
+
const parsed = Number(raw);
|
|
3748
|
+
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
3749
|
+
return fallback;
|
|
3750
|
+
}
|
|
3751
|
+
return parsed;
|
|
3752
|
+
}
|
|
2523
3753
|
var ServiceRegistry = class _ServiceRegistry {
|
|
2524
3754
|
/**
|
|
2525
3755
|
* Initializes a private constructor for managing service instances, remote signals,
|
|
@@ -2569,6 +3799,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2569
3799
|
"CADENZA_RUNTIME_STATUS_REST_REFRESH_MS",
|
|
2570
3800
|
this.runtimeMetricsSampleIntervalMs
|
|
2571
3801
|
);
|
|
3802
|
+
this.runtimeStatusLoopJitterRatio = normalizeJitterRatio(
|
|
3803
|
+
readNonNegativeFloatEnv("CADENZA_RUNTIME_STATUS_JITTER_RATIO", 0.2)
|
|
3804
|
+
);
|
|
2572
3805
|
this.runtimeStatusMissThreshold = readPositiveIntegerEnv(
|
|
2573
3806
|
"CADENZA_RUNTIME_STATUS_MISSED_HEARTBEATS",
|
|
2574
3807
|
3
|
|
@@ -2617,6 +3850,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2617
3850
|
"CADENZA_RUNTIME_STATUS_OVERLOADED_GRAPH_THRESHOLD",
|
|
2618
3851
|
20
|
|
2619
3852
|
);
|
|
3853
|
+
this.bootstrapFullSyncRetryJitterRatio = normalizeJitterRatio(
|
|
3854
|
+
readNonNegativeFloatEnv(
|
|
3855
|
+
"CADENZA_BOOTSTRAP_FULL_SYNC_RETRY_JITTER_RATIO",
|
|
3856
|
+
0.2
|
|
3857
|
+
)
|
|
3858
|
+
);
|
|
3859
|
+
this.serviceCommunicationRetryJitterRatio = normalizeJitterRatio(
|
|
3860
|
+
readNonNegativeFloatEnv(
|
|
3861
|
+
"CADENZA_SERVICE_COMMUNICATION_RETRY_JITTER_RATIO",
|
|
3862
|
+
0.2
|
|
3863
|
+
)
|
|
3864
|
+
);
|
|
2620
3865
|
this.serviceName = null;
|
|
2621
3866
|
this.serviceInstanceId = null;
|
|
2622
3867
|
this.numberOfRunningGraphs = 0;
|
|
@@ -2863,6 +4108,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2863
4108
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
2864
4109
|
);
|
|
2865
4110
|
if (uuid9 === this.serviceInstanceId) return;
|
|
4111
|
+
if (serviceName === this.serviceName) {
|
|
4112
|
+
return false;
|
|
4113
|
+
}
|
|
2866
4114
|
if (deleted) {
|
|
2867
4115
|
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid9);
|
|
2868
4116
|
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid9) ?? -1;
|
|
@@ -2949,9 +4197,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2949
4197
|
emit2
|
|
2950
4198
|
);
|
|
2951
4199
|
}
|
|
2952
|
-
if (this.serviceName === serviceName) {
|
|
2953
|
-
return false;
|
|
2954
|
-
}
|
|
2955
4200
|
if (trackedInstance?.isFrontend) {
|
|
2956
4201
|
return true;
|
|
2957
4202
|
}
|
|
@@ -3005,6 +4250,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3005
4250
|
if (!ownerInstance) {
|
|
3006
4251
|
return false;
|
|
3007
4252
|
}
|
|
4253
|
+
if (ownerInstance.serviceName === this.serviceName && ownerInstance.uuid !== this.serviceInstanceId) {
|
|
4254
|
+
return false;
|
|
4255
|
+
}
|
|
3008
4256
|
if (transport.deleted) {
|
|
3009
4257
|
this.clearTransportFailureState(ownerInstance.uuid, transport.uuid);
|
|
3010
4258
|
const transportKey = this.buildTransportRouteKey(
|
|
@@ -3592,6 +4840,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3592
4840
|
const tasks = this.readArrayPayload(inquiryResult, [
|
|
3593
4841
|
"tasks"
|
|
3594
4842
|
]);
|
|
4843
|
+
const helpers = this.readArrayPayload(inquiryResult, [
|
|
4844
|
+
"helpers"
|
|
4845
|
+
]);
|
|
4846
|
+
const globals = this.readArrayPayload(inquiryResult, [
|
|
4847
|
+
"globals"
|
|
4848
|
+
]);
|
|
3595
4849
|
const signals = this.readArrayPayload(inquiryResult, [
|
|
3596
4850
|
"signals"
|
|
3597
4851
|
]);
|
|
@@ -3616,6 +4870,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3616
4870
|
inquiryResult,
|
|
3617
4871
|
["taskToRoutineMaps", "task_to_routine_maps"]
|
|
3618
4872
|
);
|
|
4873
|
+
const taskToHelperMaps = this.readArrayPayload(
|
|
4874
|
+
inquiryResult,
|
|
4875
|
+
["taskToHelperMaps", "task_to_helper_maps"]
|
|
4876
|
+
);
|
|
4877
|
+
const helperToHelperMaps = this.readArrayPayload(
|
|
4878
|
+
inquiryResult,
|
|
4879
|
+
["helperToHelperMaps", "helper_to_helper_maps"]
|
|
4880
|
+
);
|
|
4881
|
+
const taskToGlobalMaps = this.readArrayPayload(
|
|
4882
|
+
inquiryResult,
|
|
4883
|
+
["taskToGlobalMaps", "task_to_global_maps"]
|
|
4884
|
+
);
|
|
4885
|
+
const helperToGlobalMaps = this.readArrayPayload(
|
|
4886
|
+
inquiryResult,
|
|
4887
|
+
["helperToGlobalMaps", "helper_to_global_maps"]
|
|
4888
|
+
);
|
|
3619
4889
|
const serviceInstances = this.normalizeServiceInstancesFromSync(
|
|
3620
4890
|
inquiryResult
|
|
3621
4891
|
);
|
|
@@ -3649,6 +4919,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3649
4919
|
serviceInstanceTransports: serviceInstanceTransports.length,
|
|
3650
4920
|
serviceManifests: serviceManifests.length,
|
|
3651
4921
|
tasks: tasks.length,
|
|
4922
|
+
helpers: helpers.length,
|
|
4923
|
+
globals: globals.length,
|
|
3652
4924
|
signals: signals.length,
|
|
3653
4925
|
intents: intents.length,
|
|
3654
4926
|
actors: actors.length,
|
|
@@ -3674,6 +4946,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3674
4946
|
serviceInstanceTransports,
|
|
3675
4947
|
serviceManifests,
|
|
3676
4948
|
tasks,
|
|
4949
|
+
helpers,
|
|
4950
|
+
globals,
|
|
3677
4951
|
signals,
|
|
3678
4952
|
intents,
|
|
3679
4953
|
actors,
|
|
@@ -3681,6 +4955,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3681
4955
|
directionalTaskMaps,
|
|
3682
4956
|
actorTaskMaps,
|
|
3683
4957
|
taskToRoutineMaps,
|
|
4958
|
+
taskToHelperMaps,
|
|
4959
|
+
helperToHelperMaps,
|
|
4960
|
+
taskToGlobalMaps,
|
|
4961
|
+
helperToGlobalMaps,
|
|
3684
4962
|
__inquiryMeta: inquiryResult.__inquiryMeta
|
|
3685
4963
|
};
|
|
3686
4964
|
},
|
|
@@ -4300,29 +5578,51 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
4300
5578
|
this.runtimeStatusHeartbeatStarted = true;
|
|
4301
5579
|
if (!this.runtimeMetricsSamplingStarted) {
|
|
4302
5580
|
this.runtimeMetricsSamplingStarted = true;
|
|
5581
|
+
CadenzaService.emit(META_RUNTIME_METRICS_SAMPLE_TICK_SIGNAL, {});
|
|
4303
5582
|
CadenzaService.interval(
|
|
4304
5583
|
META_RUNTIME_METRICS_SAMPLE_TICK_SIGNAL,
|
|
4305
5584
|
{},
|
|
4306
5585
|
this.runtimeMetricsSampleIntervalMs,
|
|
4307
|
-
|
|
5586
|
+
false,
|
|
5587
|
+
this.buildJitteredIntervalStartDate(
|
|
5588
|
+
this.runtimeMetricsSampleIntervalMs,
|
|
5589
|
+
"runtime-metrics-sample"
|
|
5590
|
+
)
|
|
4308
5591
|
);
|
|
4309
5592
|
}
|
|
5593
|
+
CadenzaService.emit(META_RUNTIME_STATUS_HEARTBEAT_TICK_SIGNAL, {
|
|
5594
|
+
reason: "heartbeat"
|
|
5595
|
+
});
|
|
4310
5596
|
CadenzaService.interval(
|
|
4311
5597
|
META_RUNTIME_STATUS_HEARTBEAT_TICK_SIGNAL,
|
|
4312
5598
|
{ reason: "heartbeat" },
|
|
4313
5599
|
this.runtimeStatusHeartbeatIntervalMs,
|
|
4314
|
-
|
|
5600
|
+
false,
|
|
5601
|
+
this.buildJitteredIntervalStartDate(
|
|
5602
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5603
|
+
"runtime-status-heartbeat"
|
|
5604
|
+
)
|
|
4315
5605
|
);
|
|
4316
5606
|
CadenzaService.interval(
|
|
4317
5607
|
META_RUNTIME_STATUS_MONITOR_TICK_SIGNAL,
|
|
4318
5608
|
{},
|
|
4319
|
-
this.runtimeStatusHeartbeatIntervalMs
|
|
5609
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5610
|
+
false,
|
|
5611
|
+
this.buildJitteredIntervalStartDate(
|
|
5612
|
+
this.runtimeStatusHeartbeatIntervalMs,
|
|
5613
|
+
"runtime-status-monitor"
|
|
5614
|
+
)
|
|
4320
5615
|
);
|
|
5616
|
+
CadenzaService.emit(META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL, {});
|
|
4321
5617
|
CadenzaService.interval(
|
|
4322
5618
|
META_RUNTIME_STATUS_REST_REFRESH_TICK_SIGNAL,
|
|
4323
5619
|
{},
|
|
4324
5620
|
this.runtimeStatusRestRefreshIntervalMs,
|
|
4325
|
-
|
|
5621
|
+
false,
|
|
5622
|
+
this.buildJitteredIntervalStartDate(
|
|
5623
|
+
this.runtimeStatusRestRefreshIntervalMs,
|
|
5624
|
+
"runtime-status-rest-refresh"
|
|
5625
|
+
)
|
|
4326
5626
|
);
|
|
4327
5627
|
return true;
|
|
4328
5628
|
},
|
|
@@ -5327,11 +6627,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5327
6627
|
}
|
|
5328
6628
|
collectBootstrapFullSyncPayload(ctx) {
|
|
5329
6629
|
const serviceInstances = [];
|
|
6630
|
+
const serviceInstanceLeases = [];
|
|
5330
6631
|
const serviceInstanceTransports = [];
|
|
5331
6632
|
const manifestSnapshots = [];
|
|
5332
6633
|
const signalToTaskMaps = [];
|
|
5333
6634
|
const intentToTaskMaps = [];
|
|
5334
6635
|
const tasks = [];
|
|
6636
|
+
const helpers = [];
|
|
6637
|
+
const globals = [];
|
|
5335
6638
|
const signals = [];
|
|
5336
6639
|
const intents = [];
|
|
5337
6640
|
const actors = [];
|
|
@@ -5339,11 +6642,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5339
6642
|
const directionalTaskMaps = [];
|
|
5340
6643
|
const actorTaskMaps = [];
|
|
5341
6644
|
const taskToRoutineMaps = [];
|
|
6645
|
+
const taskToHelperMaps = [];
|
|
6646
|
+
const helperToHelperMaps = [];
|
|
6647
|
+
const taskToGlobalMaps = [];
|
|
6648
|
+
const helperToGlobalMaps = [];
|
|
5342
6649
|
const seenServiceInstances = /* @__PURE__ */ new Set();
|
|
6650
|
+
const seenServiceInstanceLeases = /* @__PURE__ */ new Set();
|
|
5343
6651
|
const seenServiceInstanceTransports = /* @__PURE__ */ new Set();
|
|
5344
6652
|
const seenSignalMaps = /* @__PURE__ */ new Set();
|
|
5345
6653
|
const seenIntentMaps = /* @__PURE__ */ new Set();
|
|
5346
6654
|
const seenTasks = /* @__PURE__ */ new Set();
|
|
6655
|
+
const seenHelpers = /* @__PURE__ */ new Set();
|
|
6656
|
+
const seenGlobals = /* @__PURE__ */ new Set();
|
|
5347
6657
|
const seenSignals = /* @__PURE__ */ new Set();
|
|
5348
6658
|
const seenIntents = /* @__PURE__ */ new Set();
|
|
5349
6659
|
const seenActors = /* @__PURE__ */ new Set();
|
|
@@ -5351,6 +6661,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5351
6661
|
const seenDirectionalTaskMaps = /* @__PURE__ */ new Set();
|
|
5352
6662
|
const seenActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5353
6663
|
const seenTaskToRoutineMaps = /* @__PURE__ */ new Set();
|
|
6664
|
+
const seenTaskToHelperMaps = /* @__PURE__ */ new Set();
|
|
6665
|
+
const seenHelperToHelperMaps = /* @__PURE__ */ new Set();
|
|
6666
|
+
const seenTaskToGlobalMaps = /* @__PURE__ */ new Set();
|
|
6667
|
+
const seenHelperToGlobalMaps = /* @__PURE__ */ new Set();
|
|
5354
6668
|
const contexts = Array.isArray(ctx.joinedContexts) ? [ctx, ...ctx.joinedContexts] : [ctx];
|
|
5355
6669
|
const pushUnique = (rows, target, seen, keyResolver) => {
|
|
5356
6670
|
for (const row of rows) {
|
|
@@ -5381,6 +6695,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5381
6695
|
"serviceInstance",
|
|
5382
6696
|
"service_instance"
|
|
5383
6697
|
]);
|
|
6698
|
+
const serviceInstanceLeaseRows = readDirectArrayPayload(candidate, [
|
|
6699
|
+
"serviceInstanceLeases",
|
|
6700
|
+
"service_instance_leases",
|
|
6701
|
+
"serviceInstanceLease",
|
|
6702
|
+
"service_instance_lease"
|
|
6703
|
+
]);
|
|
5384
6704
|
const serviceInstanceTransportRows = readDirectArrayPayload(candidate, [
|
|
5385
6705
|
"serviceInstanceTransports",
|
|
5386
6706
|
"service_instance_transports",
|
|
@@ -5411,6 +6731,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5411
6731
|
seenServiceInstances,
|
|
5412
6732
|
(row) => String(row.uuid ?? "").trim()
|
|
5413
6733
|
);
|
|
6734
|
+
pushUnique(
|
|
6735
|
+
serviceInstanceLeaseRows,
|
|
6736
|
+
serviceInstanceLeases,
|
|
6737
|
+
seenServiceInstanceLeases,
|
|
6738
|
+
(row) => String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
6739
|
+
);
|
|
5414
6740
|
pushUnique(
|
|
5415
6741
|
serviceInstanceTransportRows,
|
|
5416
6742
|
serviceInstanceTransports,
|
|
@@ -5431,6 +6757,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5431
6757
|
seenSignalMaps,
|
|
5432
6758
|
(row) => `${String(row.service_name ?? row.serviceName ?? "").trim()}|${String(
|
|
5433
6759
|
row.signal_name ?? row.signalName ?? ""
|
|
6760
|
+
).trim()}|${String(row.task_name ?? row.taskName ?? "").trim()}|${String(
|
|
6761
|
+
row.task_version ?? row.taskVersion ?? 1
|
|
5434
6762
|
).trim()}`
|
|
5435
6763
|
);
|
|
5436
6764
|
pushUnique(
|
|
@@ -5465,10 +6793,23 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5465
6793
|
seenSignalMaps,
|
|
5466
6794
|
(entry) => `${String(entry.service_name ?? entry.serviceName ?? "").trim()}|${String(
|
|
5467
6795
|
entry.signal_name ?? entry.signalName ?? ""
|
|
6796
|
+
).trim()}|${String(entry.task_name ?? entry.taskName ?? "").trim()}|${String(
|
|
6797
|
+
entry.task_version ?? entry.taskVersion ?? 1
|
|
5468
6798
|
).trim()}`
|
|
5469
6799
|
);
|
|
5470
6800
|
continue;
|
|
5471
6801
|
}
|
|
6802
|
+
if (row.status !== void 0 && (row.service_instance_id !== void 0 || row.serviceInstanceId !== void 0)) {
|
|
6803
|
+
pushUnique(
|
|
6804
|
+
[row],
|
|
6805
|
+
serviceInstanceLeases,
|
|
6806
|
+
seenServiceInstanceLeases,
|
|
6807
|
+
(entry) => String(
|
|
6808
|
+
entry.service_instance_id ?? entry.serviceInstanceId ?? ""
|
|
6809
|
+
).trim()
|
|
6810
|
+
);
|
|
6811
|
+
continue;
|
|
6812
|
+
}
|
|
5472
6813
|
if (row.service_instance_id !== void 0 || row.serviceInstanceId !== void 0) {
|
|
5473
6814
|
pushUnique(
|
|
5474
6815
|
[row],
|
|
@@ -5497,9 +6838,40 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5497
6838
|
}
|
|
5498
6839
|
}
|
|
5499
6840
|
}
|
|
5500
|
-
const
|
|
5501
|
-
|
|
5502
|
-
|
|
6841
|
+
const mergedServiceInstances = overlayServiceInstancesWithLeases(
|
|
6842
|
+
serviceInstances,
|
|
6843
|
+
serviceInstanceLeases
|
|
6844
|
+
);
|
|
6845
|
+
const activeServiceInstanceIds = new Set(
|
|
6846
|
+
mergedServiceInstances.filter((row) => row.is_active === true || row.isActive === true).map((row) => String(row.uuid ?? "").trim()).filter((uuid9) => uuid9.length > 0)
|
|
6847
|
+
);
|
|
6848
|
+
const filteredServiceInstances = activeServiceInstanceIds.size > 0 ? mergedServiceInstances.filter(
|
|
6849
|
+
(row) => activeServiceInstanceIds.has(String(row.uuid ?? "").trim())
|
|
6850
|
+
) : mergedServiceInstances;
|
|
6851
|
+
const filteredServiceInstanceTransports = activeServiceInstanceIds.size > 0 ? serviceInstanceTransports.filter(
|
|
6852
|
+
(row) => activeServiceInstanceIds.has(
|
|
6853
|
+
String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
6854
|
+
)
|
|
6855
|
+
) : serviceInstanceTransports;
|
|
6856
|
+
const filteredManifestSnapshots = activeServiceInstanceIds.size > 0 ? manifestSnapshots.filter(
|
|
6857
|
+
(snapshot) => activeServiceInstanceIds.has(snapshot.serviceInstanceId)
|
|
6858
|
+
) : manifestSnapshots;
|
|
6859
|
+
const activeServiceNames = new Set(
|
|
6860
|
+
filteredServiceInstances.map((row) => String(row.service_name ?? row.serviceName ?? "").trim()).filter((serviceName) => serviceName.length > 0)
|
|
6861
|
+
);
|
|
6862
|
+
const filteredSignalToTaskMaps = activeServiceNames.size > 0 ? signalToTaskMaps.filter(
|
|
6863
|
+
(row) => activeServiceNames.has(
|
|
6864
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6865
|
+
)
|
|
6866
|
+
) : signalToTaskMaps;
|
|
6867
|
+
const filteredIntentToTaskMaps = activeServiceNames.size > 0 ? intentToTaskMaps.filter(
|
|
6868
|
+
(row) => activeServiceNames.has(
|
|
6869
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6870
|
+
)
|
|
6871
|
+
) : intentToTaskMaps;
|
|
6872
|
+
const hasExplicitSignalRoutingRows = filteredSignalToTaskMaps.length > 0;
|
|
6873
|
+
const hasExplicitIntentRoutingRows = filteredIntentToTaskMaps.length > 0;
|
|
6874
|
+
const latestManifestSnapshots = selectLatestServiceManifestSnapshots(filteredManifestSnapshots);
|
|
5503
6875
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
5504
6876
|
latestManifestSnapshots
|
|
5505
6877
|
);
|
|
@@ -5519,6 +6891,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5519
6891
|
row.version ?? 1
|
|
5520
6892
|
).trim()}`
|
|
5521
6893
|
);
|
|
6894
|
+
pushUnique(
|
|
6895
|
+
explodedManifest.helpers,
|
|
6896
|
+
helpers,
|
|
6897
|
+
seenHelpers,
|
|
6898
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.name ?? "").trim()}|${String(
|
|
6899
|
+
row.version ?? 1
|
|
6900
|
+
).trim()}`
|
|
6901
|
+
);
|
|
6902
|
+
pushUnique(
|
|
6903
|
+
explodedManifest.globals,
|
|
6904
|
+
globals,
|
|
6905
|
+
seenGlobals,
|
|
6906
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.name ?? "").trim()}|${String(
|
|
6907
|
+
row.version ?? 1
|
|
6908
|
+
).trim()}`
|
|
6909
|
+
);
|
|
5522
6910
|
pushUnique(
|
|
5523
6911
|
explodedManifest.signals,
|
|
5524
6912
|
signals,
|
|
@@ -5579,10 +6967,54 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5579
6967
|
row.task_version ?? 1
|
|
5580
6968
|
).trim()}`
|
|
5581
6969
|
);
|
|
6970
|
+
pushUnique(
|
|
6971
|
+
explodedManifest.taskToHelperMaps,
|
|
6972
|
+
taskToHelperMaps,
|
|
6973
|
+
seenTaskToHelperMaps,
|
|
6974
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
6975
|
+
row.task_version ?? 1
|
|
6976
|
+
).trim()}|${String(row.alias ?? "").trim()}|${String(
|
|
6977
|
+
row.helper_name ?? ""
|
|
6978
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}`
|
|
6979
|
+
);
|
|
6980
|
+
pushUnique(
|
|
6981
|
+
explodedManifest.helperToHelperMaps,
|
|
6982
|
+
helperToHelperMaps,
|
|
6983
|
+
seenHelperToHelperMaps,
|
|
6984
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(
|
|
6985
|
+
row.helper_name ?? ""
|
|
6986
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}|${String(
|
|
6987
|
+
row.alias ?? ""
|
|
6988
|
+
).trim()}|${String(row.dependency_helper_name ?? "").trim()}|${String(
|
|
6989
|
+
row.dependency_helper_version ?? 1
|
|
6990
|
+
).trim()}`
|
|
6991
|
+
);
|
|
6992
|
+
pushUnique(
|
|
6993
|
+
explodedManifest.taskToGlobalMaps,
|
|
6994
|
+
taskToGlobalMaps,
|
|
6995
|
+
seenTaskToGlobalMaps,
|
|
6996
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
6997
|
+
row.task_version ?? 1
|
|
6998
|
+
).trim()}|${String(row.alias ?? "").trim()}|${String(
|
|
6999
|
+
row.global_name ?? ""
|
|
7000
|
+
).trim()}|${String(row.global_version ?? 1).trim()}`
|
|
7001
|
+
);
|
|
7002
|
+
pushUnique(
|
|
7003
|
+
explodedManifest.helperToGlobalMaps,
|
|
7004
|
+
helperToGlobalMaps,
|
|
7005
|
+
seenHelperToGlobalMaps,
|
|
7006
|
+
(row) => `${String(row.service_name ?? "").trim()}|${String(
|
|
7007
|
+
row.helper_name ?? ""
|
|
7008
|
+
).trim()}|${String(row.helper_version ?? 1).trim()}|${String(
|
|
7009
|
+
row.alias ?? ""
|
|
7010
|
+
).trim()}|${String(row.global_name ?? "").trim()}|${String(
|
|
7011
|
+
row.global_version ?? 1
|
|
7012
|
+
).trim()}`
|
|
7013
|
+
);
|
|
5582
7014
|
if (!hasExplicitSignalRoutingRows) {
|
|
5583
7015
|
pushUnique(
|
|
5584
7016
|
explodedManifest.signalToTaskMaps,
|
|
5585
|
-
|
|
7017
|
+
filteredSignalToTaskMaps,
|
|
5586
7018
|
seenSignalMaps,
|
|
5587
7019
|
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
5588
7020
|
row.service_name ?? ""
|
|
@@ -5594,7 +7026,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5594
7026
|
if (!hasExplicitIntentRoutingRows) {
|
|
5595
7027
|
pushUnique(
|
|
5596
7028
|
explodedManifest.intentToTaskMaps,
|
|
5597
|
-
|
|
7029
|
+
filteredIntentToTaskMaps,
|
|
5598
7030
|
seenIntentMaps,
|
|
5599
7031
|
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
5600
7032
|
row.service_name ?? ""
|
|
@@ -5604,10 +7036,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5604
7036
|
);
|
|
5605
7037
|
}
|
|
5606
7038
|
return {
|
|
5607
|
-
serviceInstances,
|
|
5608
|
-
|
|
7039
|
+
serviceInstances: filteredServiceInstances,
|
|
7040
|
+
serviceInstanceLeases,
|
|
7041
|
+
serviceInstanceTransports: filteredServiceInstanceTransports,
|
|
5609
7042
|
serviceManifests,
|
|
5610
7043
|
tasks,
|
|
7044
|
+
helpers,
|
|
7045
|
+
globals,
|
|
5611
7046
|
signals,
|
|
5612
7047
|
intents,
|
|
5613
7048
|
actors,
|
|
@@ -5615,8 +7050,12 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5615
7050
|
directionalTaskMaps,
|
|
5616
7051
|
actorTaskMaps,
|
|
5617
7052
|
taskToRoutineMaps,
|
|
5618
|
-
|
|
5619
|
-
|
|
7053
|
+
taskToHelperMaps,
|
|
7054
|
+
helperToHelperMaps,
|
|
7055
|
+
taskToGlobalMaps,
|
|
7056
|
+
helperToGlobalMaps,
|
|
7057
|
+
signalToTaskMaps: filteredSignalToTaskMaps,
|
|
7058
|
+
intentToTaskMaps: filteredIntentToTaskMaps
|
|
5620
7059
|
};
|
|
5621
7060
|
}
|
|
5622
7061
|
buildRemoteIntentDeputyKey(map) {
|
|
@@ -6045,29 +7484,32 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6045
7484
|
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
6046
7485
|
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
6047
7486
|
try {
|
|
6048
|
-
const
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
__transportOrigin: target.origin,
|
|
6058
|
-
__transportProtocol: "rest",
|
|
6059
|
-
__transportProtocols: ["rest"],
|
|
6060
|
-
__routeKey: target.routeKey,
|
|
6061
|
-
routeKey: target.routeKey,
|
|
6062
|
-
__fetchId: target.fetchId,
|
|
6063
|
-
fetchId: target.fetchId,
|
|
6064
|
-
__metadata: {
|
|
6065
|
-
...context.__metadata && typeof context.__metadata === "object" ? context.__metadata : {},
|
|
7487
|
+
const sanitizedContext = sanitizeAuthorityBootstrapDelegationContext(context);
|
|
7488
|
+
const requestBody = compactAuthorityBootstrapRequestBody(
|
|
7489
|
+
stripDelegationRequestSnapshot(
|
|
7490
|
+
ensureDelegationContextMetadata(
|
|
7491
|
+
attachDelegationRequestSnapshot({
|
|
7492
|
+
...sanitizedContext,
|
|
7493
|
+
__remoteRoutineName: remoteRoutineName,
|
|
7494
|
+
__serviceName: "CadenzaDB",
|
|
7495
|
+
__localServiceName: this.serviceName,
|
|
6066
7496
|
__timeout: timeoutMs,
|
|
6067
7497
|
__syncing: true,
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
7498
|
+
__transportOrigin: target.origin,
|
|
7499
|
+
__transportProtocol: "rest",
|
|
7500
|
+
__transportProtocols: ["rest"],
|
|
7501
|
+
__routeKey: target.routeKey,
|
|
7502
|
+
routeKey: target.routeKey,
|
|
7503
|
+
__fetchId: target.fetchId,
|
|
7504
|
+
fetchId: target.fetchId,
|
|
7505
|
+
__metadata: {
|
|
7506
|
+
...sanitizedContext.__metadata && typeof sanitizedContext.__metadata === "object" ? sanitizedContext.__metadata : {},
|
|
7507
|
+
__timeout: timeoutMs,
|
|
7508
|
+
__syncing: true,
|
|
7509
|
+
__authorityBootstrapChannel: true
|
|
7510
|
+
}
|
|
7511
|
+
})
|
|
7512
|
+
)
|
|
6071
7513
|
)
|
|
6072
7514
|
);
|
|
6073
7515
|
const response = await globalThis.fetch(`${target.origin}/delegation`, {
|
|
@@ -6080,22 +7522,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6080
7522
|
});
|
|
6081
7523
|
if ("ok" in response && response.ok === false) {
|
|
6082
7524
|
return {
|
|
6083
|
-
...
|
|
7525
|
+
...sanitizedContext,
|
|
6084
7526
|
__error: `Bootstrap authority delegation failed with HTTP ${response.status}`,
|
|
6085
7527
|
errored: true
|
|
6086
7528
|
};
|
|
6087
7529
|
}
|
|
6088
7530
|
const payload = typeof response.json === "function" ? await response.json() : response;
|
|
6089
7531
|
return payload && typeof payload === "object" ? {
|
|
6090
|
-
...
|
|
7532
|
+
...sanitizedContext,
|
|
6091
7533
|
...payload
|
|
6092
7534
|
} : {
|
|
6093
|
-
...
|
|
7535
|
+
...sanitizedContext,
|
|
6094
7536
|
returnedValue: payload
|
|
6095
7537
|
};
|
|
6096
7538
|
} catch (error) {
|
|
6097
7539
|
return {
|
|
6098
|
-
...context,
|
|
7540
|
+
...sanitizeAuthorityBootstrapDelegationContext(context),
|
|
6099
7541
|
__error: error instanceof Error ? error.message : String(error),
|
|
6100
7542
|
errored: true
|
|
6101
7543
|
};
|
|
@@ -6222,12 +7664,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6222
7664
|
};
|
|
6223
7665
|
const [
|
|
6224
7666
|
serviceInstances,
|
|
7667
|
+
serviceInstanceLeases,
|
|
6225
7668
|
serviceInstanceTransports,
|
|
6226
7669
|
serviceManifests,
|
|
6227
7670
|
signalToTaskMaps,
|
|
6228
7671
|
intentToTaskMaps
|
|
6229
7672
|
] = await Promise.all([
|
|
6230
7673
|
DatabaseController.instance.queryAuthorityTableRows("service_instance"),
|
|
7674
|
+
queryOptionalAuthorityRoutingRows("service_instance_lease"),
|
|
6231
7675
|
DatabaseController.instance.queryAuthorityTableRows(
|
|
6232
7676
|
"service_instance_transport"
|
|
6233
7677
|
),
|
|
@@ -6240,6 +7684,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6240
7684
|
__syncing: true,
|
|
6241
7685
|
...this.collectBootstrapFullSyncPayload({
|
|
6242
7686
|
serviceInstances,
|
|
7687
|
+
serviceInstanceLeases,
|
|
6243
7688
|
serviceInstanceTransports,
|
|
6244
7689
|
serviceManifests,
|
|
6245
7690
|
signalToTaskMaps,
|
|
@@ -6272,9 +7717,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6272
7717
|
return false;
|
|
6273
7718
|
}
|
|
6274
7719
|
const scheduleRetry = (reason, error) => {
|
|
6275
|
-
const
|
|
7720
|
+
const baseDelayMs = SERVICE_COMMUNICATION_PERSIST_RETRY_DELAYS_MS[descriptor.retryAttempt];
|
|
6276
7721
|
const nextAttempt = descriptor.retryAttempt + 1;
|
|
6277
|
-
if (
|
|
7722
|
+
if (baseDelayMs !== void 0) {
|
|
7723
|
+
const delayMs = buildDeterministicJitteredDelayMs(
|
|
7724
|
+
baseDelayMs,
|
|
7725
|
+
this.serviceCommunicationRetryJitterRatio,
|
|
7726
|
+
`${descriptor.serviceInstanceId}:${descriptor.communicationType}:${descriptor.retryAttempt}`
|
|
7727
|
+
);
|
|
6278
7728
|
CadenzaService.schedule(
|
|
6279
7729
|
retrySignal,
|
|
6280
7730
|
buildServiceCommunicationRetryContext({
|
|
@@ -6422,6 +7872,31 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6422
7872
|
})
|
|
6423
7873
|
);
|
|
6424
7874
|
}
|
|
7875
|
+
buildDeterministicInstanceJitterKey(scope) {
|
|
7876
|
+
const serviceName = String(this.serviceName ?? "").trim() || "unknown-service";
|
|
7877
|
+
const serviceInstanceId = String(this.serviceInstanceId ?? "").trim() || "pending-instance";
|
|
7878
|
+
return `${serviceName}:${serviceInstanceId}:${scope}`;
|
|
7879
|
+
}
|
|
7880
|
+
buildJitteredIntervalStartDate(intervalMs, scope) {
|
|
7881
|
+
const jitterOffsetMs = buildDeterministicJitterOffsetMs(
|
|
7882
|
+
intervalMs,
|
|
7883
|
+
this.runtimeStatusLoopJitterRatio,
|
|
7884
|
+
this.buildDeterministicInstanceJitterKey(scope)
|
|
7885
|
+
);
|
|
7886
|
+
if (jitterOffsetMs <= 0) {
|
|
7887
|
+
return void 0;
|
|
7888
|
+
}
|
|
7889
|
+
return new Date(Date.now() + intervalMs + jitterOffsetMs);
|
|
7890
|
+
}
|
|
7891
|
+
buildJitteredBootstrapRetryDelayMs(baseDelayMs, attempt) {
|
|
7892
|
+
return buildDeterministicJitteredDelayMs(
|
|
7893
|
+
baseDelayMs,
|
|
7894
|
+
this.bootstrapFullSyncRetryJitterRatio,
|
|
7895
|
+
this.buildDeterministicInstanceJitterKey(
|
|
7896
|
+
`bootstrap-full-sync-retry-${attempt}`
|
|
7897
|
+
)
|
|
7898
|
+
);
|
|
7899
|
+
}
|
|
6425
7900
|
ensureAuthorityBootstrapSignalTransmissions() {
|
|
6426
7901
|
if (this.serviceName !== "CadenzaDB") {
|
|
6427
7902
|
return false;
|
|
@@ -6499,8 +7974,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6499
7974
|
}
|
|
6500
7975
|
const retryGeneration = this.bootstrapFullSyncRetryGeneration;
|
|
6501
7976
|
const retryReason = this.bootstrapFullSyncRetryReason ?? "service_registry_bootstrap_retry";
|
|
6502
|
-
const delayMs = EARLY_FULL_SYNC_DELAYS_MS[this.bootstrapFullSyncRetryIndex];
|
|
6503
7977
|
const attempt = this.bootstrapFullSyncRetryIndex + 1;
|
|
7978
|
+
const delayMs = this.buildJitteredBootstrapRetryDelayMs(
|
|
7979
|
+
EARLY_FULL_SYNC_DELAYS_MS[this.bootstrapFullSyncRetryIndex],
|
|
7980
|
+
attempt
|
|
7981
|
+
);
|
|
6504
7982
|
this.bootstrapFullSyncRetryIndex += 1;
|
|
6505
7983
|
this.bootstrapFullSyncRetryTimer = setTimeout(() => {
|
|
6506
7984
|
this.bootstrapFullSyncRetryTimer = null;
|
|
@@ -8403,6 +9881,18 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8403
9881
|
isNonResponsive,
|
|
8404
9882
|
isBlocked
|
|
8405
9883
|
);
|
|
9884
|
+
const cpuUsage = this.readRuntimeStatusMetric(ctx, "cpuUsage", "cpu", "cpuLoad");
|
|
9885
|
+
const memoryUsage = this.readRuntimeStatusMetric(
|
|
9886
|
+
ctx,
|
|
9887
|
+
"memoryUsage",
|
|
9888
|
+
"memory",
|
|
9889
|
+
"memoryPressure"
|
|
9890
|
+
);
|
|
9891
|
+
const eventLoopLag = this.readRuntimeStatusMetric(
|
|
9892
|
+
ctx,
|
|
9893
|
+
"eventLoopLag",
|
|
9894
|
+
"eventLoopLagMs"
|
|
9895
|
+
);
|
|
8406
9896
|
return {
|
|
8407
9897
|
serviceName,
|
|
8408
9898
|
serviceInstanceId,
|
|
@@ -8415,22 +9905,20 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8415
9905
|
state: ctx.state === "healthy" || ctx.state === "degraded" || ctx.state === "overloaded" || ctx.state === "unavailable" ? ctx.state : resolved.state,
|
|
8416
9906
|
acceptingWork: typeof ctx.acceptingWork === "boolean" ? ctx.acceptingWork : resolved.acceptingWork,
|
|
8417
9907
|
numberOfRunningGraphs,
|
|
8418
|
-
cpuUsage
|
|
8419
|
-
memoryUsage
|
|
8420
|
-
|
|
8421
|
-
"memoryUsage",
|
|
8422
|
-
"memory",
|
|
8423
|
-
"memoryPressure"
|
|
8424
|
-
),
|
|
8425
|
-
eventLoopLag: this.readRuntimeStatusMetric(
|
|
8426
|
-
ctx,
|
|
8427
|
-
"eventLoopLag",
|
|
8428
|
-
"eventLoopLagMs"
|
|
8429
|
-
),
|
|
9908
|
+
cpuUsage,
|
|
9909
|
+
memoryUsage,
|
|
9910
|
+
eventLoopLag,
|
|
8430
9911
|
isActive,
|
|
8431
9912
|
isNonResponsive,
|
|
8432
9913
|
isBlocked,
|
|
8433
|
-
health: ctx.health ?? ctx.__health
|
|
9914
|
+
health: sanitizeAuthorityRuntimeStatusHealth(ctx.health ?? ctx.__health, {
|
|
9915
|
+
state: ctx.state === "healthy" || ctx.state === "degraded" || ctx.state === "overloaded" || ctx.state === "unavailable" ? ctx.state : resolved.state,
|
|
9916
|
+
acceptingWork: typeof ctx.acceptingWork === "boolean" ? ctx.acceptingWork : resolved.acceptingWork,
|
|
9917
|
+
reportedAt: ctx.reportedAt ?? (typeof ctx.__reportedAt === "string" ? ctx.__reportedAt : void 0) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
9918
|
+
cpuUsage,
|
|
9919
|
+
memoryUsage,
|
|
9920
|
+
eventLoopLag
|
|
9921
|
+
})
|
|
8434
9922
|
};
|
|
8435
9923
|
}
|
|
8436
9924
|
applyRuntimeStatusReport(report) {
|
|
@@ -8471,12 +9959,14 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8471
9959
|
instance.isFrontend = report.isFrontend;
|
|
8472
9960
|
}
|
|
8473
9961
|
instance.numberOfRunningGraphs = report.numberOfRunningGraphs;
|
|
8474
|
-
const
|
|
9962
|
+
const runtimeStatusHealth = sanitizeAuthorityRuntimeStatusHealth(report.health, {
|
|
9963
|
+
state: report.state,
|
|
9964
|
+
acceptingWork: report.acceptingWork,
|
|
9965
|
+
reportedAt: report.reportedAt,
|
|
8475
9966
|
cpuUsage: report.cpuUsage ?? null,
|
|
8476
9967
|
memoryUsage: report.memoryUsage ?? null,
|
|
8477
|
-
eventLoopLag: report.eventLoopLag ?? null
|
|
8478
|
-
|
|
8479
|
-
};
|
|
9968
|
+
eventLoopLag: report.eventLoopLag ?? null
|
|
9969
|
+
});
|
|
8480
9970
|
instance.isActive = report.isActive;
|
|
8481
9971
|
instance.isNonResponsive = report.isNonResponsive;
|
|
8482
9972
|
instance.isBlocked = report.isBlocked;
|
|
@@ -8485,13 +9975,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8485
9975
|
instance.reportedAt = report.reportedAt;
|
|
8486
9976
|
instance.health = {
|
|
8487
9977
|
...instance.health ?? {},
|
|
8488
|
-
...
|
|
8489
|
-
...runtimeMetricsHealth,
|
|
8490
|
-
runtimeStatus: {
|
|
8491
|
-
state: report.state,
|
|
8492
|
-
acceptingWork: report.acceptingWork,
|
|
8493
|
-
reportedAt: report.reportedAt
|
|
8494
|
-
}
|
|
9978
|
+
...runtimeStatusHealth ?? {}
|
|
8495
9979
|
};
|
|
8496
9980
|
this.lastHeartbeatAtByInstance.set(report.serviceInstanceId, Date.now());
|
|
8497
9981
|
this.missedHeartbeatsByInstance.set(report.serviceInstanceId, 0);
|
|
@@ -8663,15 +10147,20 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8663
10147
|
isActive: snapshot.isActive,
|
|
8664
10148
|
isNonResponsive: snapshot.isNonResponsive,
|
|
8665
10149
|
isBlocked: snapshot.isBlocked,
|
|
8666
|
-
health:
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
10150
|
+
health: sanitizeAuthorityRuntimeStatusHealth(
|
|
10151
|
+
{
|
|
10152
|
+
...localInstance.health ?? {},
|
|
10153
|
+
...this.buildRuntimeMetricsHealthPayload(runtimeMetricsSnapshot) ?? {}
|
|
10154
|
+
},
|
|
10155
|
+
{
|
|
8670
10156
|
state: snapshot.state,
|
|
8671
10157
|
acceptingWork: snapshot.acceptingWork,
|
|
8672
|
-
reportedAt
|
|
10158
|
+
reportedAt,
|
|
10159
|
+
cpuUsage: runtimeMetricsSnapshot?.cpuUsage ?? null,
|
|
10160
|
+
memoryUsage: runtimeMetricsSnapshot?.memoryUsage ?? null,
|
|
10161
|
+
eventLoopLag: runtimeMetricsSnapshot?.eventLoopLag ?? null
|
|
8673
10162
|
}
|
|
8674
|
-
|
|
10163
|
+
)
|
|
8675
10164
|
};
|
|
8676
10165
|
this.applyRuntimeStatusReport(report);
|
|
8677
10166
|
return detailLevel === "full" ? report : this.stripRuntimeStatusReportForPeer(report);
|
|
@@ -9025,6 +10514,32 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9025
10514
|
if (!instancePersisted) {
|
|
9026
10515
|
return false;
|
|
9027
10516
|
}
|
|
10517
|
+
await this.delegateAuthorityLifecycleUpdate(
|
|
10518
|
+
"Update service_instance_lease",
|
|
10519
|
+
{
|
|
10520
|
+
reason,
|
|
10521
|
+
graceful: true,
|
|
10522
|
+
data: {
|
|
10523
|
+
status: "inactive",
|
|
10524
|
+
is_ready: false,
|
|
10525
|
+
readiness_reason: "graceful_shutdown",
|
|
10526
|
+
lease_expires_at: reportedAt,
|
|
10527
|
+
last_lease_renewed_at: reportedAt,
|
|
10528
|
+
last_ready_at: null,
|
|
10529
|
+
last_observed_transport_at: reportedAt,
|
|
10530
|
+
shutdown_requested_at: reportedAt,
|
|
10531
|
+
deleted: false,
|
|
10532
|
+
modified: reportedAt
|
|
10533
|
+
},
|
|
10534
|
+
queryData: {
|
|
10535
|
+
filter: {
|
|
10536
|
+
service_instance_id: localInstance.uuid
|
|
10537
|
+
}
|
|
10538
|
+
},
|
|
10539
|
+
__serviceInstanceId: localInstance.uuid
|
|
10540
|
+
},
|
|
10541
|
+
Math.max(1e3, timeoutMs)
|
|
10542
|
+
);
|
|
9028
10543
|
for (const transport of localInstance.transports) {
|
|
9029
10544
|
if (!isPersistedUuid(transport.uuid)) {
|
|
9030
10545
|
continue;
|
|
@@ -9176,6 +10691,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9176
10691
|
};
|
|
9177
10692
|
}
|
|
9178
10693
|
reset() {
|
|
10694
|
+
this.clearBootstrapFullSyncRetryTimer();
|
|
9179
10695
|
this.instances.clear();
|
|
9180
10696
|
this.deputies.clear();
|
|
9181
10697
|
this.remoteSignals.clear();
|
|
@@ -9199,6 +10715,23 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9199
10715
|
this.lastRuntimeStatusSnapshot = null;
|
|
9200
10716
|
this.isFrontend = false;
|
|
9201
10717
|
this.localInstanceSeed = null;
|
|
10718
|
+
this.bootstrapFullSyncRetryIndex = 0;
|
|
10719
|
+
this.bootstrapFullSyncRetryGeneration = 0;
|
|
10720
|
+
this.bootstrapFullSyncSatisfied = false;
|
|
10721
|
+
this.bootstrapFullSyncRetryReason = null;
|
|
10722
|
+
this.knownGlobalSignalMaps.clear();
|
|
10723
|
+
this.authorityBootstrapRoute = {
|
|
10724
|
+
origin: null,
|
|
10725
|
+
role: "internal",
|
|
10726
|
+
routeKey: null,
|
|
10727
|
+
fetchId: null,
|
|
10728
|
+
serviceInstanceId: null,
|
|
10729
|
+
serviceTransportId: null,
|
|
10730
|
+
handshakeEstablished: false
|
|
10731
|
+
};
|
|
10732
|
+
this.authorityBootstrapHandshakeInFlight = false;
|
|
10733
|
+
this.authorityFullSyncResponderTask = null;
|
|
10734
|
+
this.authorityServiceCommunicationPersistenceTask = null;
|
|
9202
10735
|
}
|
|
9203
10736
|
};
|
|
9204
10737
|
|
|
@@ -9307,7 +10840,25 @@ var SignalTransmissionTask = class extends Task2 {
|
|
|
9307
10840
|
...ctx
|
|
9308
10841
|
})
|
|
9309
10842
|
);
|
|
9310
|
-
|
|
10843
|
+
const resolvedTools = typeof CadenzaService.resolveToolsForOwner === "function" ? CadenzaService.resolveToolsForOwner(
|
|
10844
|
+
this,
|
|
10845
|
+
deputyContext,
|
|
10846
|
+
emit2,
|
|
10847
|
+
inquire,
|
|
10848
|
+
progressCallback
|
|
10849
|
+
) : {
|
|
10850
|
+
helpers: {},
|
|
10851
|
+
globals: {}
|
|
10852
|
+
};
|
|
10853
|
+
const resolvedProgressCallback = typeof progressCallback === "function" ? progressCallback : () => {
|
|
10854
|
+
};
|
|
10855
|
+
return this.taskFunction(
|
|
10856
|
+
deputyContext,
|
|
10857
|
+
emit2,
|
|
10858
|
+
inquire,
|
|
10859
|
+
resolvedTools,
|
|
10860
|
+
resolvedProgressCallback
|
|
10861
|
+
);
|
|
9311
10862
|
}
|
|
9312
10863
|
};
|
|
9313
10864
|
|
|
@@ -11113,8 +12664,8 @@ var SocketController = class _SocketController {
|
|
|
11113
12664
|
}
|
|
11114
12665
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(delegateCtx);
|
|
11115
12666
|
const normalizedDelegateCtx = ensureDelegationContextMetadata(
|
|
11116
|
-
|
|
11117
|
-
|
|
12667
|
+
restoreDelegationRequestSnapshot(
|
|
12668
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
11118
12669
|
)
|
|
11119
12670
|
);
|
|
11120
12671
|
delete normalizedDelegateCtx.__isSubMeta;
|
|
@@ -11187,13 +12738,11 @@ var SocketController = class _SocketController {
|
|
|
11187
12738
|
return resolvedResultContext;
|
|
11188
12739
|
} catch (error) {
|
|
11189
12740
|
const message = error instanceof Error ? error.message : String(error);
|
|
11190
|
-
const failedContext =
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
...normalizedDelegateCtx.__metadata
|
|
11196
|
-
};
|
|
12741
|
+
const failedContext = buildDelegationFailureContext(
|
|
12742
|
+
"meta.socket_client.delegate_failed",
|
|
12743
|
+
normalizedDelegateCtx,
|
|
12744
|
+
error
|
|
12745
|
+
);
|
|
11197
12746
|
if (deputyExecId) {
|
|
11198
12747
|
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
11199
12748
|
...failedContext,
|
|
@@ -11880,7 +13429,7 @@ var SignalController = class _SignalController {
|
|
|
11880
13429
|
}
|
|
11881
13430
|
const traceContext = { ...ctx };
|
|
11882
13431
|
delete traceContext.__traceCreatedBySignalBroker;
|
|
11883
|
-
const sanitizedTraceContext =
|
|
13432
|
+
const sanitizedTraceContext = sanitizeExecutionPersistenceContext(traceContext);
|
|
11884
13433
|
const routineMetadata = resolveRoutinePersistenceMetadata(traceContext);
|
|
11885
13434
|
const { context: routineContext, metaContext: routineMetaContext } = splitRoutinePersistenceContext(traceContext);
|
|
11886
13435
|
const traceCreatedBySignalBroker = ctx.__traceCreatedBySignalBroker === true || signalEmission.__traceCreatedBySignalBroker === true;
|
|
@@ -12202,6 +13751,51 @@ import { META_ACTOR_SESSION_STATE_PERSIST_INTENT } from "@cadenza.io/core";
|
|
|
12202
13751
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
12203
13752
|
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
12204
13753
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
13754
|
+
function findNestedContextValue(ctx, key) {
|
|
13755
|
+
if (!ctx || typeof ctx !== "object") {
|
|
13756
|
+
return void 0;
|
|
13757
|
+
}
|
|
13758
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key) || ctx[key] !== void 0) {
|
|
13759
|
+
return ctx[key];
|
|
13760
|
+
}
|
|
13761
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
13762
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
13763
|
+
const nested = joinedContexts[index];
|
|
13764
|
+
if (!nested || typeof nested !== "object") {
|
|
13765
|
+
continue;
|
|
13766
|
+
}
|
|
13767
|
+
const nestedValue = findNestedContextValue(nested, key);
|
|
13768
|
+
if (nestedValue !== void 0) {
|
|
13769
|
+
return nestedValue;
|
|
13770
|
+
}
|
|
13771
|
+
}
|
|
13772
|
+
return void 0;
|
|
13773
|
+
}
|
|
13774
|
+
function resolveActorSessionStateRow(ctx) {
|
|
13775
|
+
const singular = findNestedContextValue(ctx, "actorSessionState");
|
|
13776
|
+
if (singular && typeof singular === "object" && !Array.isArray(singular)) {
|
|
13777
|
+
return singular;
|
|
13778
|
+
}
|
|
13779
|
+
const plural = findNestedContextValue(ctx, "actorSessionStates");
|
|
13780
|
+
if (Array.isArray(plural)) {
|
|
13781
|
+
const first = plural.find(
|
|
13782
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
13783
|
+
);
|
|
13784
|
+
if (first) {
|
|
13785
|
+
return first;
|
|
13786
|
+
}
|
|
13787
|
+
}
|
|
13788
|
+
const rows = findNestedContextValue(ctx, "rows");
|
|
13789
|
+
if (Array.isArray(rows)) {
|
|
13790
|
+
const first = rows.find(
|
|
13791
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
13792
|
+
);
|
|
13793
|
+
if (first) {
|
|
13794
|
+
return first;
|
|
13795
|
+
}
|
|
13796
|
+
}
|
|
13797
|
+
return null;
|
|
13798
|
+
}
|
|
12205
13799
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
12206
13800
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
12207
13801
|
}
|
|
@@ -12274,7 +13868,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12274
13868
|
)
|
|
12275
13869
|
);
|
|
12276
13870
|
}
|
|
12277
|
-
const row =
|
|
13871
|
+
const row = resolveActorSessionStateRow(ctx);
|
|
12278
13872
|
if (!row) {
|
|
12279
13873
|
return {
|
|
12280
13874
|
__success: true,
|
|
@@ -12519,6 +14113,16 @@ function buildActorRegistrationData(actor) {
|
|
|
12519
14113
|
version: 1
|
|
12520
14114
|
};
|
|
12521
14115
|
}
|
|
14116
|
+
function sanitizePersistedTaskSourceFields(task, data) {
|
|
14117
|
+
if (!task.isMeta && !task.isDeputy) {
|
|
14118
|
+
return data;
|
|
14119
|
+
}
|
|
14120
|
+
return {
|
|
14121
|
+
...data,
|
|
14122
|
+
function_string: "",
|
|
14123
|
+
tag_id_getter: null
|
|
14124
|
+
};
|
|
14125
|
+
}
|
|
12522
14126
|
function resolveSyncServiceName(task) {
|
|
12523
14127
|
const ownerServiceName = typeof task?.ownerServiceName === "string" ? task.ownerServiceName.trim() : "";
|
|
12524
14128
|
const taskServiceName = typeof task?.serviceName === "string" ? task.serviceName.trim() : "";
|
|
@@ -12681,16 +14285,20 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
12681
14285
|
ctx,
|
|
12682
14286
|
queryData
|
|
12683
14287
|
);
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
14288
|
+
const hasEmptyObjectData = originalQueryData.data && typeof originalQueryData.data === "object" && !Array.isArray(originalQueryData.data) && Object.keys(originalQueryData.data).length === 0;
|
|
14289
|
+
const hasMissingData = originalQueryData.data === void 0;
|
|
14290
|
+
if ((tableName === "task" || tableName === "signal_registry" || tableName === "directional_task_graph_map") && (hasEmptyObjectData || hasMissingData)) {
|
|
14291
|
+
console.warn("[CADENZA_SYNC_EMPTY_INSERT]", {
|
|
14292
|
+
tableName,
|
|
14293
|
+
hasMissingData,
|
|
14294
|
+
hasEmptyObjectData,
|
|
14295
|
+
taskName: typeof ctx.__taskName === "string" ? ctx.__taskName : void 0,
|
|
14296
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
14297
|
+
syncSourceServiceName: typeof ctx.__syncSourceServiceName === "string" ? ctx.__syncSourceServiceName : void 0,
|
|
14298
|
+
queryData: originalQueryData,
|
|
14299
|
+
ctx,
|
|
14300
|
+
joinedContexts: Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : []
|
|
14301
|
+
});
|
|
12694
14302
|
}
|
|
12695
14303
|
return buildSyncExecutionEnvelope(
|
|
12696
14304
|
ctx,
|
|
@@ -12781,7 +14389,7 @@ function isBootstrapLocalOnlyActorName(actorName) {
|
|
|
12781
14389
|
return BOOTSTRAP_LOCAL_ONLY_ACTOR_NAMES.has(actorName);
|
|
12782
14390
|
}
|
|
12783
14391
|
function isBootstrapLocalOnlySignal(signalName) {
|
|
12784
|
-
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);
|
|
14392
|
+
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);
|
|
12785
14393
|
}
|
|
12786
14394
|
function hasNonZeroPending(summary) {
|
|
12787
14395
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
@@ -13009,6 +14617,12 @@ function resolveLocalRoutineFromSyncContext(ctx) {
|
|
|
13009
14617
|
);
|
|
13010
14618
|
return routineName ? CadenzaService.getRoutine(routineName) : void 0;
|
|
13011
14619
|
}
|
|
14620
|
+
function shouldTrackDirectionalTaskMapForBootstrap(predecessorTask, nextTask) {
|
|
14621
|
+
if (!predecessorTask || !nextTask) {
|
|
14622
|
+
return false;
|
|
14623
|
+
}
|
|
14624
|
+
return predecessorTask.isMeta !== true && predecessorTask.isSubMeta !== true && nextTask.isMeta !== true && nextTask.isSubMeta !== true;
|
|
14625
|
+
}
|
|
13012
14626
|
function resolveSignalNameFromSyncContext(ctx) {
|
|
13013
14627
|
const candidateSignalNames = [
|
|
13014
14628
|
ctx.signalName,
|
|
@@ -13626,40 +15240,41 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
13626
15240
|
if (task.registered) continue;
|
|
13627
15241
|
const { __functionString, __getTagCallback } = task.export();
|
|
13628
15242
|
this.tasksSynced = false;
|
|
15243
|
+
const taskRegistrationData = sanitizePersistedTaskSourceFields(task, {
|
|
15244
|
+
name: task.name,
|
|
15245
|
+
version: task.version,
|
|
15246
|
+
description: task.description,
|
|
15247
|
+
function_string: __functionString,
|
|
15248
|
+
tag_id_getter: __getTagCallback,
|
|
15249
|
+
layer_index: task.layerIndex,
|
|
15250
|
+
concurrency: task.concurrency,
|
|
15251
|
+
timeout: task.timeout,
|
|
15252
|
+
is_unique: task.isUnique,
|
|
15253
|
+
is_signal: task.isSignal,
|
|
15254
|
+
is_throttled: task.isThrottled,
|
|
15255
|
+
is_debounce: task.isDebounce,
|
|
15256
|
+
is_ephemeral: task.isEphemeral,
|
|
15257
|
+
is_meta: task.isMeta,
|
|
15258
|
+
is_sub_meta: task.isSubMeta,
|
|
15259
|
+
is_hidden: task.isHidden,
|
|
15260
|
+
validate_input_context: task.validateInputContext,
|
|
15261
|
+
validate_output_context: task.validateOutputContext,
|
|
15262
|
+
retry_count: task.retryCount,
|
|
15263
|
+
retry_delay: task.retryDelay,
|
|
15264
|
+
retry_delay_max: task.retryDelayMax,
|
|
15265
|
+
retry_delay_factor: task.retryDelayFactor,
|
|
15266
|
+
service_name: serviceName2,
|
|
15267
|
+
signals: {
|
|
15268
|
+
emits: Array.from(task.emitsSignals),
|
|
15269
|
+
signalsToEmitAfter: Array.from(task.signalsToEmitAfter),
|
|
15270
|
+
signalsToEmitOnFail: Array.from(task.signalsToEmitOnFail),
|
|
15271
|
+
observed: Array.from(task.observedSignals)
|
|
15272
|
+
},
|
|
15273
|
+
intents: Array.from(task.handlesIntents)
|
|
15274
|
+
});
|
|
13629
15275
|
yield {
|
|
13630
15276
|
__syncing: ctx.__syncing,
|
|
13631
|
-
data:
|
|
13632
|
-
name: task.name,
|
|
13633
|
-
version: task.version,
|
|
13634
|
-
description: task.description,
|
|
13635
|
-
function_string: __functionString,
|
|
13636
|
-
tag_id_getter: __getTagCallback,
|
|
13637
|
-
layer_index: task.layerIndex,
|
|
13638
|
-
concurrency: task.concurrency,
|
|
13639
|
-
timeout: task.timeout,
|
|
13640
|
-
is_unique: task.isUnique,
|
|
13641
|
-
is_signal: task.isSignal,
|
|
13642
|
-
is_throttled: task.isThrottled,
|
|
13643
|
-
is_debounce: task.isDebounce,
|
|
13644
|
-
is_ephemeral: task.isEphemeral,
|
|
13645
|
-
is_meta: task.isMeta,
|
|
13646
|
-
is_sub_meta: task.isSubMeta,
|
|
13647
|
-
is_hidden: task.isHidden,
|
|
13648
|
-
validate_input_context: task.validateInputContext,
|
|
13649
|
-
validate_output_context: task.validateOutputContext,
|
|
13650
|
-
retry_count: task.retryCount,
|
|
13651
|
-
retry_delay: task.retryDelay,
|
|
13652
|
-
retry_delay_max: task.retryDelayMax,
|
|
13653
|
-
retry_delay_factor: task.retryDelayFactor,
|
|
13654
|
-
service_name: serviceName2,
|
|
13655
|
-
signals: {
|
|
13656
|
-
emits: Array.from(task.emitsSignals),
|
|
13657
|
-
signalsToEmitAfter: Array.from(task.signalsToEmitAfter),
|
|
13658
|
-
signalsToEmitOnFail: Array.from(task.signalsToEmitOnFail),
|
|
13659
|
-
observed: Array.from(task.observedSignals)
|
|
13660
|
-
},
|
|
13661
|
-
intents: Array.from(task.handlesIntents)
|
|
13662
|
-
},
|
|
15277
|
+
data: taskRegistrationData,
|
|
13663
15278
|
__taskName: task.name
|
|
13664
15279
|
};
|
|
13665
15280
|
}
|
|
@@ -14085,7 +15700,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14085
15700
|
return;
|
|
14086
15701
|
}
|
|
14087
15702
|
for (const t of task.nextTasks) {
|
|
14088
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
15703
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
14089
15704
|
continue;
|
|
14090
15705
|
}
|
|
14091
15706
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -14153,7 +15768,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14153
15768
|
return false;
|
|
14154
15769
|
}
|
|
14155
15770
|
for (const nextTask of task.nextTasks) {
|
|
14156
|
-
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered) {
|
|
15771
|
+
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, nextTask)) {
|
|
14157
15772
|
continue;
|
|
14158
15773
|
}
|
|
14159
15774
|
if (resolveSyncServiceName(nextTask)) {
|
|
@@ -14818,13 +16433,50 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14818
16433
|
startActorPrimitiveSyncTask,
|
|
14819
16434
|
startRoutinePrimitiveSyncTask
|
|
14820
16435
|
);
|
|
14821
|
-
const getAllTasksForSyncTask = CadenzaService.
|
|
16436
|
+
const getAllTasksForSyncTask = CadenzaService.createMetaTask(
|
|
16437
|
+
"Get all tasks for sync",
|
|
16438
|
+
(ctx) => ({
|
|
16439
|
+
...ctx,
|
|
16440
|
+
tasks: Array.from(CadenzaService.registry.tasks.values())
|
|
16441
|
+
}),
|
|
16442
|
+
"Collects local tasks for the primitive sync phase.",
|
|
16443
|
+
{
|
|
16444
|
+
register: false,
|
|
16445
|
+
isHidden: true
|
|
16446
|
+
}
|
|
16447
|
+
);
|
|
14822
16448
|
startTaskPrimitiveSyncTask.then(
|
|
14823
16449
|
getAllTasksForSyncTask,
|
|
14824
16450
|
gatherTaskRegistrationTask
|
|
14825
16451
|
);
|
|
14826
16452
|
getAllTasksForSyncTask.then(this.splitTasksForRegistration);
|
|
14827
|
-
const getSignalsForSyncTask = CadenzaService.
|
|
16453
|
+
const getSignalsForSyncTask = CadenzaService.createMetaTask(
|
|
16454
|
+
"Get signals for sync",
|
|
16455
|
+
(ctx) => {
|
|
16456
|
+
const uniqueSignals = Array.from(
|
|
16457
|
+
/* @__PURE__ */ new Set([
|
|
16458
|
+
...CadenzaService.signalBroker.signalObservers.keys(),
|
|
16459
|
+
...CadenzaService.signalBroker.emittedSignalsRegistry
|
|
16460
|
+
])
|
|
16461
|
+
).filter((signal) => !signal.includes(":"));
|
|
16462
|
+
const processedSignals = uniqueSignals.map((signal) => ({
|
|
16463
|
+
signal,
|
|
16464
|
+
data: {
|
|
16465
|
+
registered: CadenzaService.signalBroker.signalObservers.get(signal)?.registered ?? false,
|
|
16466
|
+
metadata: CadenzaService.signalBroker.getSignalMetadata(signal) ?? null
|
|
16467
|
+
}
|
|
16468
|
+
}));
|
|
16469
|
+
return {
|
|
16470
|
+
...ctx,
|
|
16471
|
+
signals: processedSignals
|
|
16472
|
+
};
|
|
16473
|
+
},
|
|
16474
|
+
"Collects local signals for the primitive sync phase.",
|
|
16475
|
+
{
|
|
16476
|
+
register: false,
|
|
16477
|
+
isHidden: true
|
|
16478
|
+
}
|
|
16479
|
+
);
|
|
14828
16480
|
startSignalPrimitiveSyncTask.then(
|
|
14829
16481
|
getSignalsForSyncTask,
|
|
14830
16482
|
gatherSignalRegistrationTask
|
|
@@ -14866,40 +16518,110 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14866
16518
|
gatherActorRegistrationTask
|
|
14867
16519
|
);
|
|
14868
16520
|
getAllActorsForSyncTask.then(this.splitActorsForRegistration);
|
|
14869
|
-
const getAllRoutinesForSyncTask = CadenzaService.
|
|
16521
|
+
const getAllRoutinesForSyncTask = CadenzaService.createMetaTask(
|
|
16522
|
+
"Get all routines for sync",
|
|
16523
|
+
(ctx) => ({
|
|
16524
|
+
...ctx,
|
|
16525
|
+
routines: Array.from(CadenzaService.registry.routines.values())
|
|
16526
|
+
}),
|
|
16527
|
+
"Collects local routines for the primitive sync phase.",
|
|
16528
|
+
{
|
|
16529
|
+
register: false,
|
|
16530
|
+
isHidden: true
|
|
16531
|
+
}
|
|
16532
|
+
);
|
|
14870
16533
|
startRoutinePrimitiveSyncTask.then(
|
|
14871
16534
|
getAllRoutinesForSyncTask,
|
|
14872
16535
|
gatherRoutineRegistrationTask
|
|
14873
16536
|
);
|
|
14874
16537
|
getAllRoutinesForSyncTask.then(this.splitRoutinesTask);
|
|
14875
|
-
const iterateTasksForDirectionalTaskMapSyncTask = CadenzaService.
|
|
16538
|
+
const iterateTasksForDirectionalTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16539
|
+
"Iterate tasks for directional task map sync",
|
|
16540
|
+
function* (ctx) {
|
|
16541
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16542
|
+
yield { ...ctx, task };
|
|
16543
|
+
}
|
|
16544
|
+
},
|
|
16545
|
+
"Iterates local tasks for directional task-map sync.",
|
|
16546
|
+
{
|
|
16547
|
+
register: false,
|
|
16548
|
+
isHidden: true
|
|
16549
|
+
}
|
|
16550
|
+
);
|
|
14876
16551
|
startDirectionalTaskMapSyncTask.then(
|
|
14877
16552
|
iterateTasksForDirectionalTaskMapSyncTask,
|
|
14878
16553
|
gatherDirectionalTaskMapRegistrationTask
|
|
14879
16554
|
);
|
|
14880
16555
|
iterateTasksForDirectionalTaskMapSyncTask.then(this.registerTaskMapTask);
|
|
14881
16556
|
recordTaskMapRegistrationTask.then(gatherDirectionalTaskMapRegistrationTask);
|
|
14882
|
-
const iterateTasksForSignalTaskMapSyncTask = CadenzaService.
|
|
16557
|
+
const iterateTasksForSignalTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16558
|
+
"Iterate tasks for signal task map sync",
|
|
16559
|
+
function* (ctx) {
|
|
16560
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16561
|
+
yield { ...ctx, task };
|
|
16562
|
+
}
|
|
16563
|
+
},
|
|
16564
|
+
"Iterates local tasks for signal-to-task map sync.",
|
|
16565
|
+
{
|
|
16566
|
+
register: false,
|
|
16567
|
+
isHidden: true
|
|
16568
|
+
}
|
|
16569
|
+
);
|
|
14883
16570
|
startSignalTaskMapSyncTask.then(
|
|
14884
16571
|
iterateTasksForSignalTaskMapSyncTask,
|
|
14885
16572
|
gatherSignalTaskMapRegistrationTask
|
|
14886
16573
|
);
|
|
14887
16574
|
iterateTasksForSignalTaskMapSyncTask.then(this.registerSignalToTaskMapTask);
|
|
14888
16575
|
this.registerSignalToTaskMapTask.then(gatherSignalTaskMapRegistrationTask);
|
|
14889
|
-
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.
|
|
16576
|
+
const iterateTasksForIntentTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16577
|
+
"Iterate tasks for intent task map sync",
|
|
16578
|
+
function* (ctx) {
|
|
16579
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16580
|
+
yield { ...ctx, task };
|
|
16581
|
+
}
|
|
16582
|
+
},
|
|
16583
|
+
"Iterates local tasks for intent-to-task map sync.",
|
|
16584
|
+
{
|
|
16585
|
+
register: false,
|
|
16586
|
+
isHidden: true
|
|
16587
|
+
}
|
|
16588
|
+
);
|
|
14890
16589
|
startIntentTaskMapSyncTask.then(
|
|
14891
16590
|
iterateTasksForIntentTaskMapSyncTask,
|
|
14892
16591
|
gatherIntentTaskMapRegistrationTask
|
|
14893
16592
|
);
|
|
14894
16593
|
iterateTasksForIntentTaskMapSyncTask.then(this.registerIntentToTaskMapTask);
|
|
14895
16594
|
this.registerIntentToTaskMapTask.then(gatherIntentTaskMapRegistrationTask);
|
|
14896
|
-
const iterateTasksForActorTaskMapSyncTask = CadenzaService.
|
|
16595
|
+
const iterateTasksForActorTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16596
|
+
"Iterate tasks for actor task map sync",
|
|
16597
|
+
function* (ctx) {
|
|
16598
|
+
for (const task of CadenzaService.registry.tasks.values()) {
|
|
16599
|
+
yield { ...ctx, task };
|
|
16600
|
+
}
|
|
16601
|
+
},
|
|
16602
|
+
"Iterates local tasks for actor-to-task map sync.",
|
|
16603
|
+
{
|
|
16604
|
+
register: false,
|
|
16605
|
+
isHidden: true
|
|
16606
|
+
}
|
|
16607
|
+
);
|
|
14897
16608
|
startActorTaskMapSyncTask.then(
|
|
14898
16609
|
iterateTasksForActorTaskMapSyncTask,
|
|
14899
16610
|
gatherActorTaskMapRegistrationTask
|
|
14900
16611
|
);
|
|
14901
16612
|
iterateTasksForActorTaskMapSyncTask.then(this.registerActorTaskMapTask);
|
|
14902
|
-
const getAllRoutinesForTaskMapSyncTask = CadenzaService.
|
|
16613
|
+
const getAllRoutinesForTaskMapSyncTask = CadenzaService.createMetaTask(
|
|
16614
|
+
"Get all routines for task map sync",
|
|
16615
|
+
(ctx) => ({
|
|
16616
|
+
...ctx,
|
|
16617
|
+
routines: Array.from(CadenzaService.registry.routines.values())
|
|
16618
|
+
}),
|
|
16619
|
+
"Collects local routines for routine-to-task map sync.",
|
|
16620
|
+
{
|
|
16621
|
+
register: false,
|
|
16622
|
+
isHidden: true
|
|
16623
|
+
}
|
|
16624
|
+
);
|
|
14903
16625
|
startRoutineTaskMapSyncTask.then(
|
|
14904
16626
|
getAllRoutinesForTaskMapSyncTask,
|
|
14905
16627
|
gatherRoutineTaskMapRegistrationTask
|
|
@@ -14975,11 +16697,37 @@ function resolveTaskByName(name) {
|
|
|
14975
16697
|
const taskName = String(name ?? "");
|
|
14976
16698
|
return taskName ? CadenzaService.get(taskName) : void 0;
|
|
14977
16699
|
}
|
|
16700
|
+
function resolveHelperFromMetadataContext(ctx) {
|
|
16701
|
+
const toolRuntime = CadenzaService;
|
|
16702
|
+
const helperName = String(
|
|
16703
|
+
ctx?.helperName ?? ctx?.data?.helperName ?? ctx?.data?.helper_name ?? ctx?.filter?.helperName ?? ctx?.filter?.helper_name ?? ""
|
|
16704
|
+
);
|
|
16705
|
+
return helperName ? toolRuntime.getHelper?.(helperName) : void 0;
|
|
16706
|
+
}
|
|
16707
|
+
function resolveGlobalFromMetadataContext(ctx) {
|
|
16708
|
+
const toolRuntime = CadenzaService;
|
|
16709
|
+
const globalName = String(
|
|
16710
|
+
ctx?.globalName ?? ctx?.data?.globalName ?? ctx?.data?.global_name ?? ctx?.filter?.globalName ?? ctx?.filter?.global_name ?? ""
|
|
16711
|
+
);
|
|
16712
|
+
return globalName ? toolRuntime.getGlobal?.(globalName) : void 0;
|
|
16713
|
+
}
|
|
14978
16714
|
function resolvePredecessorTaskFromMetadataContext(ctx) {
|
|
14979
16715
|
return resolveTaskByName(
|
|
14980
16716
|
ctx?.predecessorTaskName ?? ctx?.data?.predecessorTaskName ?? ctx?.data?.predecessor_task_name ?? ctx?.filter?.predecessorTaskName ?? ctx?.filter?.predecessor_task_name
|
|
14981
16717
|
);
|
|
14982
16718
|
}
|
|
16719
|
+
function sanitizePersistedTaskSourceFields2(task, data) {
|
|
16720
|
+
if (!task?.isMeta && !task?.isDeputy) {
|
|
16721
|
+
return data;
|
|
16722
|
+
}
|
|
16723
|
+
return {
|
|
16724
|
+
...data,
|
|
16725
|
+
functionString: "",
|
|
16726
|
+
function_string: "",
|
|
16727
|
+
tagIdGetter: null,
|
|
16728
|
+
tag_id_getter: null
|
|
16729
|
+
};
|
|
16730
|
+
}
|
|
14983
16731
|
function shouldSkipDirectTaskMetadata(task) {
|
|
14984
16732
|
return !task || !task.register || task.isHidden || task.isDeputy;
|
|
14985
16733
|
}
|
|
@@ -15057,6 +16805,9 @@ function shouldPersistBusinessInquiryCompletion(ctx) {
|
|
|
15057
16805
|
const inquiryName = String(ctx?.data?.metadata?.inquiryMeta?.inquiry ?? "");
|
|
15058
16806
|
return inquiryName.length > 0 && !isMetaIntentName(inquiryName);
|
|
15059
16807
|
}
|
|
16808
|
+
function shouldPersistExecutionTrace(ctx) {
|
|
16809
|
+
return ctx?.data?.isMeta !== true && ctx?.data?.is_meta !== true;
|
|
16810
|
+
}
|
|
15060
16811
|
function shouldPersistRoutineExecution(ctx) {
|
|
15061
16812
|
if (ctx?.data?.isMeta === true || ctx?.data?.is_meta === true) {
|
|
15062
16813
|
return false;
|
|
@@ -15120,10 +16871,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15120
16871
|
task.registrationRequested = true;
|
|
15121
16872
|
}
|
|
15122
16873
|
return buildDatabaseTriggerContext(
|
|
15123
|
-
{
|
|
16874
|
+
sanitizePersistedTaskSourceFields2(task, {
|
|
15124
16875
|
...ctx.data,
|
|
15125
16876
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
15126
|
-
},
|
|
16877
|
+
}),
|
|
15127
16878
|
void 0,
|
|
15128
16879
|
{ onConflict },
|
|
15129
16880
|
{ onConflict }
|
|
@@ -15226,6 +16977,88 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15226
16977
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
15227
16978
|
});
|
|
15228
16979
|
}).doOn("meta.task.intent_associated").emits("global.meta.graph_metadata.task_intent_associated");
|
|
16980
|
+
const buildHelperMetadataContext = (ctx) => {
|
|
16981
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
16982
|
+
return false;
|
|
16983
|
+
}
|
|
16984
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
16985
|
+
if (!helper) {
|
|
16986
|
+
return false;
|
|
16987
|
+
}
|
|
16988
|
+
return buildDatabaseTriggerContext({
|
|
16989
|
+
...ctx.data,
|
|
16990
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
16991
|
+
});
|
|
16992
|
+
};
|
|
16993
|
+
createLocalGraphMetadataTask("Handle helper creation", buildHelperMetadataContext).doOn("meta.helper.created").emits("global.meta.graph_metadata.helper_created");
|
|
16994
|
+
createLocalGraphMetadataTask("Handle helper update", buildHelperMetadataContext).doOn("meta.helper.updated").emits("global.meta.graph_metadata.helper_updated");
|
|
16995
|
+
const buildGlobalMetadataContext = (ctx) => {
|
|
16996
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
16997
|
+
return false;
|
|
16998
|
+
}
|
|
16999
|
+
const globalDefinition = resolveGlobalFromMetadataContext(ctx);
|
|
17000
|
+
if (!globalDefinition) {
|
|
17001
|
+
return false;
|
|
17002
|
+
}
|
|
17003
|
+
return buildDatabaseTriggerContext({
|
|
17004
|
+
...ctx.data,
|
|
17005
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17006
|
+
});
|
|
17007
|
+
};
|
|
17008
|
+
createLocalGraphMetadataTask("Handle global creation", buildGlobalMetadataContext).doOn("meta.global.created").emits("global.meta.graph_metadata.global_created");
|
|
17009
|
+
createLocalGraphMetadataTask("Handle global update", buildGlobalMetadataContext).doOn("meta.global.updated").emits("global.meta.graph_metadata.global_updated");
|
|
17010
|
+
createLocalGraphMetadataTask("Handle task helper association", (ctx) => {
|
|
17011
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17012
|
+
return false;
|
|
17013
|
+
}
|
|
17014
|
+
const task = resolveTaskFromMetadataContext(ctx);
|
|
17015
|
+
if (shouldSkipDirectTaskMetadata(task)) {
|
|
17016
|
+
return false;
|
|
17017
|
+
}
|
|
17018
|
+
return buildDatabaseTriggerContext({
|
|
17019
|
+
...ctx.data,
|
|
17020
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17021
|
+
});
|
|
17022
|
+
}).doOn("meta.task.helper_associated").emits("global.meta.graph_metadata.task_helper_associated");
|
|
17023
|
+
createLocalGraphMetadataTask("Handle helper helper association", (ctx) => {
|
|
17024
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17025
|
+
return false;
|
|
17026
|
+
}
|
|
17027
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
17028
|
+
if (!helper) {
|
|
17029
|
+
return false;
|
|
17030
|
+
}
|
|
17031
|
+
return buildDatabaseTriggerContext({
|
|
17032
|
+
...ctx.data,
|
|
17033
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17034
|
+
});
|
|
17035
|
+
}).doOn("meta.helper.helper_associated").emits("global.meta.graph_metadata.helper_helper_associated");
|
|
17036
|
+
createLocalGraphMetadataTask("Handle task global association", (ctx) => {
|
|
17037
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17038
|
+
return false;
|
|
17039
|
+
}
|
|
17040
|
+
const task = resolveTaskFromMetadataContext(ctx);
|
|
17041
|
+
if (shouldSkipDirectTaskMetadata(task)) {
|
|
17042
|
+
return false;
|
|
17043
|
+
}
|
|
17044
|
+
return buildDatabaseTriggerContext({
|
|
17045
|
+
...ctx.data,
|
|
17046
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17047
|
+
});
|
|
17048
|
+
}).doOn("meta.task.global_associated").emits("global.meta.graph_metadata.task_global_associated");
|
|
17049
|
+
createLocalGraphMetadataTask("Handle helper global association", (ctx) => {
|
|
17050
|
+
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
17051
|
+
return false;
|
|
17052
|
+
}
|
|
17053
|
+
const helper = resolveHelperFromMetadataContext(ctx);
|
|
17054
|
+
if (!helper) {
|
|
17055
|
+
return false;
|
|
17056
|
+
}
|
|
17057
|
+
return buildDatabaseTriggerContext({
|
|
17058
|
+
...ctx.data,
|
|
17059
|
+
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
17060
|
+
});
|
|
17061
|
+
}).doOn("meta.helper.global_associated").emits("global.meta.graph_metadata.helper_global_associated");
|
|
15229
17062
|
createLocalGraphMetadataTask("Handle task unsubscribing signal", (ctx) => {
|
|
15230
17063
|
if (!shouldEmitDirectPrimitiveMetadata()) {
|
|
15231
17064
|
return false;
|
|
@@ -15293,6 +17126,9 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15293
17126
|
});
|
|
15294
17127
|
}).doOn("meta.routine.task_added").emits("global.meta.graph_metadata.task_added_to_routine");
|
|
15295
17128
|
createLocalGraphMetadataTask("Handle new trace", (ctx) => {
|
|
17129
|
+
if (!shouldPersistExecutionTrace(ctx)) {
|
|
17130
|
+
return false;
|
|
17131
|
+
}
|
|
15296
17132
|
return buildDatabaseTriggerContext({
|
|
15297
17133
|
...ctx.data,
|
|
15298
17134
|
service_name: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -15306,10 +17142,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15306
17142
|
return false;
|
|
15307
17143
|
}
|
|
15308
17144
|
const routineData = ctx.data ?? {};
|
|
15309
|
-
const sanitizedRoutineContext =
|
|
17145
|
+
const sanitizedRoutineContext = sanitizeExecutionPersistenceContext(
|
|
15310
17146
|
routineData.context ?? {}
|
|
15311
17147
|
);
|
|
15312
|
-
const sanitizedRoutineMetaContext =
|
|
17148
|
+
const sanitizedRoutineMetaContext = sanitizeExecutionPersistenceContext(
|
|
15313
17149
|
routineData.metaContext ?? {}
|
|
15314
17150
|
);
|
|
15315
17151
|
const routineExecutionRow = {
|
|
@@ -15444,12 +17280,13 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15444
17280
|
createLocalGraphMetadataTask(
|
|
15445
17281
|
"Handle routine execution ended",
|
|
15446
17282
|
(ctx) => {
|
|
17283
|
+
const sanitizedData = sanitizeExecutionPersistenceResultPayload({
|
|
17284
|
+
...ctx.data,
|
|
17285
|
+
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
17286
|
+
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
17287
|
+
});
|
|
15447
17288
|
return buildDatabaseTriggerContext(
|
|
15448
|
-
|
|
15449
|
-
...ctx.data,
|
|
15450
|
-
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
15451
|
-
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
15452
|
-
},
|
|
17289
|
+
sanitizedData,
|
|
15453
17290
|
ctx.filter ?? void 0
|
|
15454
17291
|
);
|
|
15455
17292
|
},
|
|
@@ -15463,10 +17300,10 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15463
17300
|
return false;
|
|
15464
17301
|
}
|
|
15465
17302
|
const taskExecutionData = ctx.data ?? {};
|
|
15466
|
-
const sanitizedTaskContext =
|
|
17303
|
+
const sanitizedTaskContext = sanitizeExecutionPersistenceContext(
|
|
15467
17304
|
taskExecutionData.context ?? {}
|
|
15468
17305
|
);
|
|
15469
|
-
const sanitizedTaskMetaContext =
|
|
17306
|
+
const sanitizedTaskMetaContext = sanitizeExecutionPersistenceContext(
|
|
15470
17307
|
taskExecutionData.metaContext ?? {}
|
|
15471
17308
|
);
|
|
15472
17309
|
const routineMetadata = resolveRoutinePersistenceMetadata(
|
|
@@ -15699,12 +17536,13 @@ var GraphMetadataController = class _GraphMetadataController {
|
|
|
15699
17536
|
if (!shouldPersistTaskExecutionMetadata(ctx)) {
|
|
15700
17537
|
return false;
|
|
15701
17538
|
}
|
|
17539
|
+
const sanitizedData = sanitizeExecutionPersistenceResultPayload({
|
|
17540
|
+
...ctx.data,
|
|
17541
|
+
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
17542
|
+
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
17543
|
+
});
|
|
15702
17544
|
return buildDatabaseTriggerContext(
|
|
15703
|
-
|
|
15704
|
-
...ctx.data,
|
|
15705
|
-
serviceName: CadenzaService.serviceRegistry.serviceName,
|
|
15706
|
-
serviceInstanceId: resolveExecutionObservabilityServiceInstanceId2()
|
|
15707
|
-
},
|
|
17545
|
+
sanitizedData,
|
|
15708
17546
|
ctx.filter ?? void 0
|
|
15709
17547
|
);
|
|
15710
17548
|
},
|
|
@@ -16451,6 +18289,15 @@ var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
|
16451
18289
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
16452
18290
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
16453
18291
|
var DEFAULT_DATABASE_PROXY_TASK_TIMEOUT_MS = 12e4;
|
|
18292
|
+
var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
18293
|
+
"routing_capability",
|
|
18294
|
+
"business_structural",
|
|
18295
|
+
"local_meta_structural"
|
|
18296
|
+
];
|
|
18297
|
+
function getServiceManifestPublicationLayerRank(layer) {
|
|
18298
|
+
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
18299
|
+
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
18300
|
+
}
|
|
16454
18301
|
var CadenzaService = class {
|
|
16455
18302
|
static unregisterGracefulShutdownHandlers() {
|
|
16456
18303
|
for (const cleanup of this.shutdownHandlerCleanup) {
|
|
@@ -16577,7 +18424,15 @@ var CadenzaService = class {
|
|
|
16577
18424
|
this.replayRegisteredTaskSignalObservations();
|
|
16578
18425
|
this.replayRegisteredTaskIntentAssociations();
|
|
16579
18426
|
}
|
|
16580
|
-
static
|
|
18427
|
+
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
18428
|
+
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
18429
|
+
}
|
|
18430
|
+
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
18431
|
+
this.serviceManifestPublicationPendingReason = reason;
|
|
18432
|
+
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
18433
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(targetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? targetLayer : currentTargetLayer;
|
|
18434
|
+
}
|
|
18435
|
+
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
16581
18436
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16582
18437
|
return;
|
|
16583
18438
|
}
|
|
@@ -16585,7 +18440,8 @@ var CadenzaService = class {
|
|
|
16585
18440
|
const payload = {
|
|
16586
18441
|
__reason: reason,
|
|
16587
18442
|
__serviceName: this.serviceRegistry.serviceName,
|
|
16588
|
-
__serviceInstanceId: this.serviceRegistry.serviceInstanceId
|
|
18443
|
+
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
18444
|
+
__publicationLayer: targetLayer
|
|
16589
18445
|
};
|
|
16590
18446
|
if (immediate) {
|
|
16591
18447
|
this.emit(signalName, payload);
|
|
@@ -16593,32 +18449,53 @@ var CadenzaService = class {
|
|
|
16593
18449
|
}
|
|
16594
18450
|
this.debounce(signalName, payload, 100);
|
|
16595
18451
|
}
|
|
16596
|
-
static scheduleServiceManifestPublicationRetry(reason) {
|
|
18452
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
16597
18453
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16598
18454
|
return;
|
|
16599
18455
|
}
|
|
16600
18456
|
setTimeout(() => {
|
|
16601
|
-
this.requestServiceManifestPublication(reason, false);
|
|
18457
|
+
this.requestServiceManifestPublication(reason, false, targetLayer);
|
|
16602
18458
|
}, 1e3);
|
|
16603
18459
|
}
|
|
16604
|
-
static async publishServiceManifestIfNeeded(reason) {
|
|
18460
|
+
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
16605
18461
|
if (!this.serviceRegistry.connectsToCadenzaDB || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16606
18462
|
return false;
|
|
16607
18463
|
}
|
|
16608
18464
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
18465
|
+
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
18466
|
+
targetLayer
|
|
18467
|
+
);
|
|
16609
18468
|
if (this.serviceManifestPublicationInFlight) {
|
|
16610
|
-
this.
|
|
18469
|
+
this.mergeServiceManifestPublicationRequest(
|
|
18470
|
+
publishReason,
|
|
18471
|
+
publishTargetLayer
|
|
18472
|
+
);
|
|
16611
18473
|
return false;
|
|
16612
18474
|
}
|
|
16613
|
-
const
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
18475
|
+
const publicationPlan = SERVICE_MANIFEST_PUBLICATION_ORDER.filter(
|
|
18476
|
+
(layer) => getServiceManifestPublicationLayerRank(layer) <= getServiceManifestPublicationLayerRank(publishTargetLayer)
|
|
18477
|
+
).map((layer) => {
|
|
18478
|
+
const snapshot2 = buildServiceManifestSnapshot({
|
|
18479
|
+
serviceName: this.serviceRegistry.serviceName,
|
|
18480
|
+
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
18481
|
+
revision: this.serviceManifestRevision + 1,
|
|
18482
|
+
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18483
|
+
publicationLayer: layer
|
|
18484
|
+
});
|
|
18485
|
+
return {
|
|
18486
|
+
layer,
|
|
18487
|
+
snapshot: snapshot2,
|
|
18488
|
+
changed: this.lastPublishedServiceManifestHashes[layer] !== snapshot2.manifestHash
|
|
18489
|
+
};
|
|
16618
18490
|
});
|
|
16619
|
-
|
|
18491
|
+
const nextPublication = publicationPlan.find((entry) => entry.changed);
|
|
18492
|
+
if (!nextPublication) {
|
|
16620
18493
|
return false;
|
|
16621
18494
|
}
|
|
18495
|
+
const { layer: publicationLayer, snapshot } = nextPublication;
|
|
18496
|
+
const hasPendingFollowupLayer = publicationPlan.some(
|
|
18497
|
+
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
18498
|
+
);
|
|
16622
18499
|
this.serviceManifestPublicationInFlight = true;
|
|
16623
18500
|
try {
|
|
16624
18501
|
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
@@ -16626,7 +18503,10 @@ var CadenzaService = class {
|
|
|
16626
18503
|
snapshot
|
|
16627
18504
|
);
|
|
16628
18505
|
if (!this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
16629
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
18506
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
18507
|
+
publishReason,
|
|
18508
|
+
publishTargetLayer
|
|
18509
|
+
);
|
|
16630
18510
|
return false;
|
|
16631
18511
|
}
|
|
16632
18512
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
@@ -16634,32 +18514,48 @@ var CadenzaService = class {
|
|
|
16634
18514
|
requireComplete: true
|
|
16635
18515
|
});
|
|
16636
18516
|
this.serviceManifestRevision = snapshot.revision;
|
|
16637
|
-
this.
|
|
18517
|
+
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
18518
|
+
if (hasPendingFollowupLayer) {
|
|
18519
|
+
this.mergeServiceManifestPublicationRequest(
|
|
18520
|
+
publishReason,
|
|
18521
|
+
publishTargetLayer
|
|
18522
|
+
);
|
|
18523
|
+
}
|
|
16638
18524
|
return {
|
|
16639
18525
|
serviceManifest: snapshot,
|
|
16640
|
-
published: true
|
|
18526
|
+
published: true,
|
|
18527
|
+
publicationLayer
|
|
16641
18528
|
};
|
|
16642
18529
|
} catch (error) {
|
|
16643
18530
|
this.log("Service manifest publication failed. Scheduling retry.", {
|
|
16644
18531
|
serviceName: this.serviceRegistry.serviceName,
|
|
16645
18532
|
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
16646
18533
|
reason: publishReason,
|
|
18534
|
+
publicationLayer,
|
|
16647
18535
|
error: resolveInquiryFailureError(
|
|
16648
18536
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
16649
18537
|
error
|
|
16650
18538
|
),
|
|
16651
18539
|
inquiryMeta: error && typeof error === "object" && "__inquiryMeta" in error ? error.__inquiryMeta : null
|
|
16652
18540
|
});
|
|
16653
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
18541
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
18542
|
+
publishReason,
|
|
18543
|
+
publishTargetLayer
|
|
18544
|
+
);
|
|
16654
18545
|
return false;
|
|
16655
18546
|
} finally {
|
|
16656
18547
|
this.serviceManifestPublicationInFlight = false;
|
|
16657
|
-
if (this.serviceManifestPublicationPendingReason) {
|
|
18548
|
+
if (this.serviceManifestPublicationPendingReason && this.serviceManifestPublicationPendingLayer) {
|
|
16658
18549
|
const pendingReason = this.serviceManifestPublicationPendingReason;
|
|
18550
|
+
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
16659
18551
|
this.serviceManifestPublicationPendingReason = null;
|
|
18552
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
16660
18553
|
this.debounce(
|
|
16661
18554
|
"meta.service_manifest.publish_requested",
|
|
16662
|
-
{
|
|
18555
|
+
{
|
|
18556
|
+
__reason: pendingReason,
|
|
18557
|
+
__publicationLayer: pendingLayer
|
|
18558
|
+
},
|
|
16663
18559
|
100
|
|
16664
18560
|
);
|
|
16665
18561
|
}
|
|
@@ -16672,9 +18568,13 @@ var CadenzaService = class {
|
|
|
16672
18568
|
this.createMetaTask(
|
|
16673
18569
|
"Publish service manifest",
|
|
16674
18570
|
async (ctx) => this.publishServiceManifestIfNeeded(
|
|
16675
|
-
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish"
|
|
18571
|
+
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
18572
|
+
this.normalizeServiceManifestPublicationLayer(
|
|
18573
|
+
ctx.__publicationLayer,
|
|
18574
|
+
"business_structural"
|
|
18575
|
+
)
|
|
16676
18576
|
),
|
|
16677
|
-
"Publishes
|
|
18577
|
+
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
16678
18578
|
{
|
|
16679
18579
|
register: false,
|
|
16680
18580
|
isHidden: true
|
|
@@ -16684,13 +18584,18 @@ var CadenzaService = class {
|
|
|
16684
18584
|
"Request manifest publication after structural change",
|
|
16685
18585
|
(ctx) => {
|
|
16686
18586
|
const reason = typeof ctx.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal : typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason : "manifest_structural_update";
|
|
18587
|
+
const targetLayer = reason === "meta.service_registry.instance_inserted" ? "business_structural" : this.normalizeServiceManifestPublicationLayer(
|
|
18588
|
+
ctx.__publicationLayer,
|
|
18589
|
+
"business_structural"
|
|
18590
|
+
);
|
|
16687
18591
|
this.requestServiceManifestPublication(
|
|
16688
18592
|
reason,
|
|
16689
|
-
reason === "meta.service_registry.instance_inserted"
|
|
18593
|
+
reason === "meta.service_registry.instance_inserted",
|
|
18594
|
+
targetLayer
|
|
16690
18595
|
);
|
|
16691
18596
|
return true;
|
|
16692
18597
|
},
|
|
16693
|
-
"Requests
|
|
18598
|
+
"Requests staged manifest publication when a static service primitive changes.",
|
|
16694
18599
|
{
|
|
16695
18600
|
register: false,
|
|
16696
18601
|
isHidden: true
|
|
@@ -16702,9 +18607,17 @@ var CadenzaService = class {
|
|
|
16702
18607
|
"meta.task.relationship_added",
|
|
16703
18608
|
"meta.task.relationship_removed",
|
|
16704
18609
|
"meta.task.intent_associated",
|
|
18610
|
+
"meta.task.helper_associated",
|
|
18611
|
+
"meta.task.global_associated",
|
|
16705
18612
|
"meta.task.observed_signal",
|
|
16706
18613
|
"meta.task.attached_signal",
|
|
16707
18614
|
"meta.task.detached_signal",
|
|
18615
|
+
"meta.helper.created",
|
|
18616
|
+
"meta.helper.updated",
|
|
18617
|
+
"meta.global.created",
|
|
18618
|
+
"meta.global.updated",
|
|
18619
|
+
"meta.helper.helper_associated",
|
|
18620
|
+
"meta.helper.global_associated",
|
|
16708
18621
|
"meta.actor.created",
|
|
16709
18622
|
"meta.actor.task_associated",
|
|
16710
18623
|
"meta.fetch.handshake_complete",
|
|
@@ -17945,10 +19858,28 @@ var CadenzaService = class {
|
|
|
17945
19858
|
__isFrontend: isFrontend,
|
|
17946
19859
|
__declaredTransports: declaredTransports
|
|
17947
19860
|
};
|
|
19861
|
+
let bootstrapServiceCreationRequested = false;
|
|
17948
19862
|
if (options.cadenzaDB?.connect) {
|
|
17949
|
-
this.
|
|
17950
|
-
|
|
17951
|
-
|
|
19863
|
+
this.createMetaTask(
|
|
19864
|
+
"Create service",
|
|
19865
|
+
async (context, emit2) => {
|
|
19866
|
+
const handshakeServiceName = String(context?.serviceName ?? "").trim();
|
|
19867
|
+
if (handshakeServiceName !== "CadenzaDB") {
|
|
19868
|
+
return false;
|
|
19869
|
+
}
|
|
19870
|
+
if (bootstrapServiceCreationRequested) {
|
|
19871
|
+
return false;
|
|
19872
|
+
}
|
|
19873
|
+
bootstrapServiceCreationRequested = true;
|
|
19874
|
+
emit2("meta.create_service_requested", initContext);
|
|
19875
|
+
return true;
|
|
19876
|
+
},
|
|
19877
|
+
"Requests local service creation only once after the initial authority bootstrap handshake completes.",
|
|
19878
|
+
{
|
|
19879
|
+
register: false,
|
|
19880
|
+
isHidden: true
|
|
19881
|
+
}
|
|
19882
|
+
).doOn("meta.fetch.handshake_complete");
|
|
17952
19883
|
} else {
|
|
17953
19884
|
this.emit("meta.create_service_requested", initContext);
|
|
17954
19885
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
@@ -17961,10 +19892,33 @@ var CadenzaService = class {
|
|
|
17961
19892
|
);
|
|
17962
19893
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
17963
19894
|
}
|
|
19895
|
+
let serviceSetupCompletedHandled = false;
|
|
17964
19896
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
19897
|
+
if (serviceSetupCompletedHandled) {
|
|
19898
|
+
return false;
|
|
19899
|
+
}
|
|
19900
|
+
const insertedServiceInstanceId = String(
|
|
19901
|
+
ctx?.serviceInstanceId ?? ctx?.service_instance_id ?? ctx?.serviceInstance?.uuid ?? ctx?.serviceInstance?.serviceInstanceId ?? ""
|
|
19902
|
+
).trim();
|
|
19903
|
+
const insertedServiceName = String(
|
|
19904
|
+
ctx?.serviceName ?? ctx?.service_name ?? ctx?.serviceInstance?.serviceName ?? ctx?.serviceInstance?.service_name ?? ""
|
|
19905
|
+
).trim();
|
|
19906
|
+
if (!insertedServiceInstanceId && !insertedServiceName) {
|
|
19907
|
+
return false;
|
|
19908
|
+
}
|
|
19909
|
+
if (insertedServiceInstanceId && insertedServiceInstanceId !== serviceId) {
|
|
19910
|
+
return false;
|
|
19911
|
+
}
|
|
19912
|
+
if (!insertedServiceInstanceId && insertedServiceName && insertedServiceName !== serviceName) {
|
|
19913
|
+
return false;
|
|
19914
|
+
}
|
|
19915
|
+
serviceSetupCompletedHandled = true;
|
|
17965
19916
|
if (options.cadenzaDB?.connect) {
|
|
17966
19917
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
17967
|
-
void this.publishServiceManifestIfNeeded(
|
|
19918
|
+
void this.publishServiceManifestIfNeeded(
|
|
19919
|
+
"service_setup_completed",
|
|
19920
|
+
"business_structural"
|
|
19921
|
+
);
|
|
17968
19922
|
}
|
|
17969
19923
|
if (isFrontend) {
|
|
17970
19924
|
registerActorSessionPersistenceTasks();
|
|
@@ -18019,7 +19973,11 @@ var CadenzaService = class {
|
|
|
18019
19973
|
);
|
|
18020
19974
|
}
|
|
18021
19975
|
this.serviceCreated = true;
|
|
18022
|
-
this.requestServiceManifestPublication(
|
|
19976
|
+
this.requestServiceManifestPublication(
|
|
19977
|
+
"service_created",
|
|
19978
|
+
true,
|
|
19979
|
+
"routing_capability"
|
|
19980
|
+
);
|
|
18023
19981
|
}
|
|
18024
19982
|
/**
|
|
18025
19983
|
* Creates a Cadenza metadata service with the specified name, description, and options.
|
|
@@ -18775,6 +20733,11 @@ var CadenzaService = class {
|
|
|
18775
20733
|
this.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
18776
20734
|
this.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18777
20735
|
this.frontendSyncScheduled = false;
|
|
20736
|
+
this.serviceManifestRevision = 0;
|
|
20737
|
+
this.lastPublishedServiceManifestHashes = {};
|
|
20738
|
+
this.serviceManifestPublicationInFlight = false;
|
|
20739
|
+
this.serviceManifestPublicationPendingReason = null;
|
|
20740
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
18778
20741
|
resetBrowserRuntimeActorHandles();
|
|
18779
20742
|
}
|
|
18780
20743
|
};
|
|
@@ -18788,9 +20751,10 @@ CadenzaService.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
|
18788
20751
|
CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18789
20752
|
CadenzaService.frontendSyncScheduled = false;
|
|
18790
20753
|
CadenzaService.serviceManifestRevision = 0;
|
|
18791
|
-
CadenzaService.
|
|
20754
|
+
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
18792
20755
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
18793
20756
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
20757
|
+
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
18794
20758
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
18795
20759
|
CadenzaService.shutdownInFlight = false;
|
|
18796
20760
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -18824,6 +20788,17 @@ function normalizeArrayResponse(value, keys) {
|
|
|
18824
20788
|
if (Array.isArray(value?.data)) {
|
|
18825
20789
|
return value.data;
|
|
18826
20790
|
}
|
|
20791
|
+
const joinedContexts = Array.isArray(value?.joinedContexts) ? value.joinedContexts : [];
|
|
20792
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
20793
|
+
const nested = joinedContexts[index];
|
|
20794
|
+
if (!nested || typeof nested !== "object") {
|
|
20795
|
+
continue;
|
|
20796
|
+
}
|
|
20797
|
+
const rows = normalizeArrayResponse(nested, keys);
|
|
20798
|
+
if (rows.length > 0) {
|
|
20799
|
+
return rows;
|
|
20800
|
+
}
|
|
20801
|
+
}
|
|
18827
20802
|
return [];
|
|
18828
20803
|
}
|
|
18829
20804
|
function buildQueryResponseKeys(tableName) {
|