@cadenza.io/service 2.17.52 → 2.17.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +477 -421
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +477 -421
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +477 -421
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -421
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -385,16 +385,16 @@ function normalizeServiceTransportConfig(value) {
|
|
|
385
385
|
}
|
|
386
386
|
function normalizeServiceTransportDescriptor(value) {
|
|
387
387
|
const raw = value ?? {};
|
|
388
|
-
const
|
|
388
|
+
const uuid7 = normalizeString(raw.uuid);
|
|
389
389
|
const serviceInstanceId = normalizeString(
|
|
390
390
|
raw.serviceInstanceId ?? raw.service_instance_id
|
|
391
391
|
);
|
|
392
392
|
const config = normalizeServiceTransportConfig(raw);
|
|
393
|
-
if (!
|
|
393
|
+
if (!uuid7 || !serviceInstanceId || !config) {
|
|
394
394
|
return null;
|
|
395
395
|
}
|
|
396
396
|
return {
|
|
397
|
-
uuid:
|
|
397
|
+
uuid: uuid7,
|
|
398
398
|
serviceInstanceId,
|
|
399
399
|
role: config.role,
|
|
400
400
|
origin: config.origin,
|
|
@@ -456,14 +456,14 @@ function normalizeTransportArray(value, serviceInstanceId) {
|
|
|
456
456
|
}
|
|
457
457
|
function normalizeServiceInstanceDescriptor(value) {
|
|
458
458
|
const raw = value ?? {};
|
|
459
|
-
const
|
|
459
|
+
const uuid7 = normalizeString2(raw.uuid);
|
|
460
460
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
461
|
-
if (!
|
|
461
|
+
if (!uuid7 || !serviceName) {
|
|
462
462
|
return null;
|
|
463
463
|
}
|
|
464
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
464
|
+
const transports = normalizeTransportArray(raw.transports, uuid7);
|
|
465
465
|
return {
|
|
466
|
-
uuid:
|
|
466
|
+
uuid: uuid7,
|
|
467
467
|
serviceName,
|
|
468
468
|
numberOfRunningGraphs: Math.max(
|
|
469
469
|
0,
|
|
@@ -1104,15 +1104,15 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1104
1104
|
if (!serviceInstance) {
|
|
1105
1105
|
return false;
|
|
1106
1106
|
}
|
|
1107
|
-
const
|
|
1107
|
+
const uuid7 = serviceInstance.uuid;
|
|
1108
1108
|
const serviceName = serviceInstance.serviceName;
|
|
1109
1109
|
const deleted = Boolean(
|
|
1110
1110
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
1111
1111
|
);
|
|
1112
|
-
if (
|
|
1112
|
+
if (uuid7 === this.serviceInstanceId) return;
|
|
1113
1113
|
if (deleted) {
|
|
1114
|
-
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid ===
|
|
1115
|
-
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid ===
|
|
1114
|
+
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid7);
|
|
1115
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid7) ?? -1;
|
|
1116
1116
|
if (indexToDelete >= 0 && existingInstance) {
|
|
1117
1117
|
this.instances.get(serviceName)?.splice(indexToDelete, 1);
|
|
1118
1118
|
for (const transport of existingInstance.transports) {
|
|
@@ -1124,13 +1124,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1124
1124
|
if (this.instances.get(serviceName)?.length === 0) {
|
|
1125
1125
|
this.instances.delete(serviceName);
|
|
1126
1126
|
}
|
|
1127
|
-
this.unregisterDependee(
|
|
1127
|
+
this.unregisterDependee(uuid7, serviceName);
|
|
1128
1128
|
return;
|
|
1129
1129
|
}
|
|
1130
1130
|
if (!this.instances.has(serviceName))
|
|
1131
1131
|
this.instances.set(serviceName, []);
|
|
1132
1132
|
const instances = this.instances.get(serviceName);
|
|
1133
|
-
const existing = instances.find((i) => i.uuid ===
|
|
1133
|
+
const existing = instances.find((i) => i.uuid === uuid7);
|
|
1134
1134
|
if (existing) {
|
|
1135
1135
|
Object.assign(existing, {
|
|
1136
1136
|
...serviceInstance,
|
|
@@ -1140,7 +1140,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1140
1140
|
} else {
|
|
1141
1141
|
instances.push(serviceInstance);
|
|
1142
1142
|
}
|
|
1143
|
-
const trackedInstance = existing ?? instances.find((instance) => instance.uuid ===
|
|
1143
|
+
const trackedInstance = existing ?? instances.find((instance) => instance.uuid === uuid7);
|
|
1144
1144
|
if (trackedInstance) {
|
|
1145
1145
|
const snapshot = this.resolveRuntimeStatusSnapshot(
|
|
1146
1146
|
trackedInstance.numberOfRunningGraphs ?? 0,
|
|
@@ -1153,7 +1153,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1153
1153
|
trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1154
1154
|
}
|
|
1155
1155
|
if (!serviceInstance.isBootstrapPlaceholder) {
|
|
1156
|
-
this.reconcileBootstrapPlaceholderInstance(serviceName,
|
|
1156
|
+
this.reconcileBootstrapPlaceholderInstance(serviceName, uuid7, emit);
|
|
1157
1157
|
}
|
|
1158
1158
|
if (this.serviceName === serviceName) {
|
|
1159
1159
|
return false;
|
|
@@ -1182,7 +1182,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1182
1182
|
if (!clientCreated) {
|
|
1183
1183
|
emit("meta.service_registry.dependee_registered", {
|
|
1184
1184
|
serviceName,
|
|
1185
|
-
serviceInstanceId:
|
|
1185
|
+
serviceInstanceId: uuid7,
|
|
1186
1186
|
serviceTransportId: trackedTransport.uuid,
|
|
1187
1187
|
serviceOrigin: trackedTransport.origin,
|
|
1188
1188
|
transportProtocols: trackedTransport.protocols,
|
|
@@ -1196,7 +1196,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1196
1196
|
} else {
|
|
1197
1197
|
emit("meta.service_registry.routeable_transport_missing", {
|
|
1198
1198
|
serviceName,
|
|
1199
|
-
serviceInstanceId:
|
|
1199
|
+
serviceInstanceId: uuid7,
|
|
1200
1200
|
requiredRole: this.getRoutingTransportRole(),
|
|
1201
1201
|
isFrontend: this.isFrontend
|
|
1202
1202
|
});
|
|
@@ -6060,13 +6060,12 @@ var DatabaseController = class _DatabaseController {
|
|
|
6060
6060
|
};
|
|
6061
6061
|
|
|
6062
6062
|
// src/Cadenza.ts
|
|
6063
|
-
import { v4 as
|
|
6063
|
+
import { v4 as uuid5 } from "uuid";
|
|
6064
6064
|
|
|
6065
6065
|
// src/graph/controllers/GraphSyncController.ts
|
|
6066
6066
|
import {
|
|
6067
6067
|
META_ACTOR_SESSION_STATE_PERSIST_INTENT as META_ACTOR_SESSION_STATE_PERSIST_INTENT2
|
|
6068
6068
|
} from "@cadenza.io/core";
|
|
6069
|
-
import { v4 as uuid5 } from "uuid";
|
|
6070
6069
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
6071
6070
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
6072
6071
|
if (typeof taskFunction !== "function") {
|
|
@@ -6194,6 +6193,64 @@ function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
|
6194
6193
|
}
|
|
6195
6194
|
return nextQueryData;
|
|
6196
6195
|
}
|
|
6196
|
+
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
6197
|
+
if (!graph) {
|
|
6198
|
+
return void 0;
|
|
6199
|
+
}
|
|
6200
|
+
predecessorTask.then(graph.entryTask);
|
|
6201
|
+
if (completionTasks.length > 0) {
|
|
6202
|
+
graph.completionTask.then(...completionTasks);
|
|
6203
|
+
}
|
|
6204
|
+
return graph.completionTask;
|
|
6205
|
+
}
|
|
6206
|
+
function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
|
|
6207
|
+
if (!task) {
|
|
6208
|
+
return void 0;
|
|
6209
|
+
}
|
|
6210
|
+
const expectedPrefix = `${operation}-pg-`;
|
|
6211
|
+
const expectedSuffix = `-${tableName}`;
|
|
6212
|
+
const handledIntents = Array.from(task.handlesIntents ?? []);
|
|
6213
|
+
const directMatch = handledIntents.find(
|
|
6214
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
|
|
6215
|
+
);
|
|
6216
|
+
if (directMatch) {
|
|
6217
|
+
return directMatch;
|
|
6218
|
+
}
|
|
6219
|
+
return handledIntents.find(
|
|
6220
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
|
|
6221
|
+
);
|
|
6222
|
+
}
|
|
6223
|
+
function createLocalDatabaseInquiryTask(localTask, operation, tableName, options = {}) {
|
|
6224
|
+
const intentName = resolveLocalDatabaseTaskIntent(localTask, operation, tableName);
|
|
6225
|
+
return CadenzaService.createMetaTask(
|
|
6226
|
+
`Execute local graph sync ${operation} for ${tableName}`,
|
|
6227
|
+
async (ctx, _emit, inquire) => {
|
|
6228
|
+
if (!intentName) {
|
|
6229
|
+
return {
|
|
6230
|
+
...ctx,
|
|
6231
|
+
errored: true,
|
|
6232
|
+
__success: false,
|
|
6233
|
+
__error: `No local ${operation} intent found for ${tableName}`
|
|
6234
|
+
};
|
|
6235
|
+
}
|
|
6236
|
+
const inquiryContext = {
|
|
6237
|
+
...ctx,
|
|
6238
|
+
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
|
|
6239
|
+
};
|
|
6240
|
+
const result = await inquire(intentName, inquiryContext, {});
|
|
6241
|
+
return {
|
|
6242
|
+
...ctx,
|
|
6243
|
+
...result
|
|
6244
|
+
};
|
|
6245
|
+
},
|
|
6246
|
+
`Executes the local ${tableName} ${operation} operation through the generated database intent.`,
|
|
6247
|
+
{
|
|
6248
|
+
...options,
|
|
6249
|
+
register: false,
|
|
6250
|
+
isHidden: true
|
|
6251
|
+
}
|
|
6252
|
+
);
|
|
6253
|
+
}
|
|
6197
6254
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6198
6255
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
6199
6256
|
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
@@ -6201,7 +6258,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6201
6258
|
if (!localInsertTask && !remoteInsertTask) {
|
|
6202
6259
|
return void 0;
|
|
6203
6260
|
}
|
|
6204
|
-
const targetTask = localInsertTask
|
|
6261
|
+
const targetTask = localInsertTask ? createLocalDatabaseInquiryTask(localInsertTask, "insert", tableName, options) : remoteInsertTask;
|
|
6205
6262
|
if (debugTable) {
|
|
6206
6263
|
logSyncDebug("insert_task_resolved", {
|
|
6207
6264
|
tableName,
|
|
@@ -6212,21 +6269,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6212
6269
|
options
|
|
6213
6270
|
});
|
|
6214
6271
|
}
|
|
6215
|
-
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
6216
|
-
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
6217
|
-
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
6218
|
-
const pendingResolverContexts = /* @__PURE__ */ new Map();
|
|
6219
6272
|
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
6220
6273
|
`Prepare graph sync insert for ${tableName}`,
|
|
6221
6274
|
(ctx) => {
|
|
6222
6275
|
const originalContext = { ...ctx };
|
|
6223
|
-
const originalQueryData = buildSyncInsertQueryData(
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
originalQueryData
|
|
6228
|
-
});
|
|
6229
|
-
}
|
|
6276
|
+
const originalQueryData = buildSyncInsertQueryData(
|
|
6277
|
+
ctx,
|
|
6278
|
+
queryData
|
|
6279
|
+
);
|
|
6230
6280
|
return {
|
|
6231
6281
|
...ctx,
|
|
6232
6282
|
__resolverOriginalContext: originalContext,
|
|
@@ -6239,7 +6289,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6239
6289
|
register: false,
|
|
6240
6290
|
isHidden: true
|
|
6241
6291
|
}
|
|
6242
|
-
)
|
|
6292
|
+
);
|
|
6243
6293
|
if (debugTable) {
|
|
6244
6294
|
prepareExecutionTask.then(
|
|
6245
6295
|
CadenzaService.createMetaTask(
|
|
@@ -6273,15 +6323,9 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6273
6323
|
}
|
|
6274
6324
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
6275
6325
|
`Finalize graph sync insert for ${tableName}`,
|
|
6276
|
-
(ctx
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
}
|
|
6280
|
-
const pendingResolverContext = pendingResolverContexts.get(
|
|
6281
|
-
ctx.__resolverRequestId
|
|
6282
|
-
);
|
|
6283
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : pendingResolverContext?.originalContext ? { ...pendingResolverContext.originalContext } : {};
|
|
6284
|
-
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : pendingResolverContext?.originalQueryData;
|
|
6326
|
+
(ctx) => {
|
|
6327
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : {};
|
|
6328
|
+
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
6285
6329
|
const normalizedContext = {
|
|
6286
6330
|
...originalContext,
|
|
6287
6331
|
...ctx,
|
|
@@ -6306,8 +6350,6 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6306
6350
|
});
|
|
6307
6351
|
}
|
|
6308
6352
|
}
|
|
6309
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
6310
|
-
emit(executionResolvedSignal, normalizedContext);
|
|
6311
6353
|
return normalizedContext;
|
|
6312
6354
|
},
|
|
6313
6355
|
`Finalizes ${tableName} graph-sync insert execution after the authority task finishes.`,
|
|
@@ -6316,95 +6358,12 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6316
6358
|
isHidden: true
|
|
6317
6359
|
}
|
|
6318
6360
|
);
|
|
6319
|
-
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
6320
6361
|
prepareExecutionTask.then(targetTask);
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
if (shouldDebugTaskSyncPayload(ctx) || shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
6327
|
-
logSyncDebug("insert_failed", {
|
|
6328
|
-
tableName,
|
|
6329
|
-
targetTaskName: targetTask.name,
|
|
6330
|
-
payload: buildTaskSyncDebugPayload({
|
|
6331
|
-
...ctx,
|
|
6332
|
-
__taskName: ctx.__taskName
|
|
6333
|
-
})
|
|
6334
|
-
});
|
|
6335
|
-
}
|
|
6336
|
-
} else {
|
|
6337
|
-
logSyncDebug("insert_failed", {
|
|
6338
|
-
tableName,
|
|
6339
|
-
targetTaskName: targetTask.name,
|
|
6340
|
-
ctx
|
|
6341
|
-
});
|
|
6342
|
-
}
|
|
6343
|
-
if (typeof ctx.__resolverRequestId === "string") {
|
|
6344
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
6345
|
-
}
|
|
6346
|
-
return false;
|
|
6347
|
-
},
|
|
6348
|
-
`Logs failed ${tableName} sync insert executions.`,
|
|
6349
|
-
{
|
|
6350
|
-
register: false,
|
|
6351
|
-
isHidden: true
|
|
6352
|
-
}
|
|
6353
|
-
).doOn(executionFailedSignal);
|
|
6354
|
-
}
|
|
6355
|
-
return CadenzaService.createMetaTask(
|
|
6356
|
-
`Resolve graph sync insert for ${tableName}`,
|
|
6357
|
-
(ctx, emit) => new Promise((resolve) => {
|
|
6358
|
-
const resolverRequestId = uuid5();
|
|
6359
|
-
const resolvedContext = {
|
|
6360
|
-
...ctx,
|
|
6361
|
-
__resolverRequestId: resolverRequestId
|
|
6362
|
-
};
|
|
6363
|
-
if (debugTable) {
|
|
6364
|
-
if (tableName === "task") {
|
|
6365
|
-
if (shouldDebugTaskSyncPayload(resolvedContext)) {
|
|
6366
|
-
logSyncDebug("insert_resolver_request", {
|
|
6367
|
-
tableName,
|
|
6368
|
-
targetTaskName: targetTask.name,
|
|
6369
|
-
payload: buildTaskSyncDebugPayload(resolvedContext)
|
|
6370
|
-
});
|
|
6371
|
-
}
|
|
6372
|
-
} else {
|
|
6373
|
-
logSyncDebug("insert_resolver_request", {
|
|
6374
|
-
tableName,
|
|
6375
|
-
targetTaskName: targetTask.name,
|
|
6376
|
-
ctx: resolvedContext
|
|
6377
|
-
});
|
|
6378
|
-
}
|
|
6379
|
-
}
|
|
6380
|
-
CadenzaService.createEphemeralMetaTask(
|
|
6381
|
-
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
6382
|
-
(resultCtx) => {
|
|
6383
|
-
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
6384
|
-
return false;
|
|
6385
|
-
}
|
|
6386
|
-
const normalizedResult = {
|
|
6387
|
-
...resultCtx
|
|
6388
|
-
};
|
|
6389
|
-
delete normalizedResult.__resolverRequestId;
|
|
6390
|
-
pendingResolverContexts.delete(resolverRequestId);
|
|
6391
|
-
resolve(normalizedResult);
|
|
6392
|
-
return normalizedResult;
|
|
6393
|
-
},
|
|
6394
|
-
`Waits for ${tableName} graph-sync insert execution.`,
|
|
6395
|
-
{
|
|
6396
|
-
register: false
|
|
6397
|
-
}
|
|
6398
|
-
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
6399
|
-
emit(executionRequestedSignal, resolvedContext);
|
|
6400
|
-
}),
|
|
6401
|
-
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
6402
|
-
{
|
|
6403
|
-
...options,
|
|
6404
|
-
register: false,
|
|
6405
|
-
isHidden: true
|
|
6406
|
-
}
|
|
6407
|
-
);
|
|
6362
|
+
targetTask.then(finalizeExecutionTask);
|
|
6363
|
+
return {
|
|
6364
|
+
entryTask: prepareExecutionTask,
|
|
6365
|
+
completionTask: finalizeExecutionTask
|
|
6366
|
+
};
|
|
6408
6367
|
}
|
|
6409
6368
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
6410
6369
|
"intent_registry",
|
|
@@ -6565,8 +6524,8 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
6565
6524
|
if (!localQueryTask && !remoteQueryTask) {
|
|
6566
6525
|
return void 0;
|
|
6567
6526
|
}
|
|
6568
|
-
const targetTask = localQueryTask
|
|
6569
|
-
|
|
6527
|
+
const targetTask = localQueryTask ? createLocalDatabaseInquiryTask(localQueryTask, "query", tableName, options) : remoteQueryTask;
|
|
6528
|
+
const prepareQueryTask = CadenzaService.createMetaTask(
|
|
6570
6529
|
`Prepare graph sync query for ${tableName}`,
|
|
6571
6530
|
(ctx) => ({
|
|
6572
6531
|
...ctx,
|
|
@@ -6580,7 +6539,22 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
6580
6539
|
register: false,
|
|
6581
6540
|
isHidden: true
|
|
6582
6541
|
}
|
|
6583
|
-
)
|
|
6542
|
+
);
|
|
6543
|
+
const finalizeQueryTask = CadenzaService.createMetaTask(
|
|
6544
|
+
`Finalize graph sync query for ${tableName}`,
|
|
6545
|
+
(ctx) => ctx,
|
|
6546
|
+
`Finalizes ${tableName} graph-sync query payloads after authority lookup.`,
|
|
6547
|
+
{
|
|
6548
|
+
register: false,
|
|
6549
|
+
isHidden: true
|
|
6550
|
+
}
|
|
6551
|
+
);
|
|
6552
|
+
prepareQueryTask.then(targetTask);
|
|
6553
|
+
targetTask.then(finalizeQueryTask);
|
|
6554
|
+
return {
|
|
6555
|
+
entryTask: prepareQueryTask,
|
|
6556
|
+
completionTask: finalizeQueryTask
|
|
6557
|
+
};
|
|
6584
6558
|
}
|
|
6585
6559
|
function getRegistrableTasks() {
|
|
6586
6560
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
@@ -6707,25 +6681,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6707
6681
|
},
|
|
6708
6682
|
{ concurrency: 30 }
|
|
6709
6683
|
);
|
|
6710
|
-
const
|
|
6684
|
+
const authoritativeTaskQueryGraph = resolveSyncQueryTask(
|
|
6711
6685
|
this.isCadenzaDBReady,
|
|
6712
6686
|
"task",
|
|
6713
6687
|
{},
|
|
6714
6688
|
{ concurrency: 10 }
|
|
6715
6689
|
);
|
|
6716
|
-
const
|
|
6690
|
+
const authoritativeRoutineQueryGraph = resolveSyncQueryTask(
|
|
6717
6691
|
this.isCadenzaDBReady,
|
|
6718
6692
|
"routine",
|
|
6719
6693
|
{},
|
|
6720
6694
|
{ concurrency: 10 }
|
|
6721
6695
|
);
|
|
6722
|
-
const
|
|
6696
|
+
const authoritativeSignalQueryGraph = resolveSyncQueryTask(
|
|
6723
6697
|
this.isCadenzaDBReady,
|
|
6724
6698
|
"signal_registry",
|
|
6725
6699
|
{},
|
|
6726
6700
|
{ concurrency: 10 }
|
|
6727
6701
|
);
|
|
6728
|
-
const
|
|
6702
|
+
const authoritativeIntentQueryGraph = resolveSyncQueryTask(
|
|
6729
6703
|
this.isCadenzaDBReady,
|
|
6730
6704
|
"intent_registry",
|
|
6731
6705
|
{},
|
|
@@ -6896,32 +6870,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6896
6870
|
}
|
|
6897
6871
|
}.bind(this)
|
|
6898
6872
|
);
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
{
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
do: "nothing"
|
|
6908
|
-
}
|
|
6909
|
-
}
|
|
6910
|
-
},
|
|
6911
|
-
{ concurrency: 30 }
|
|
6912
|
-
)?.then(
|
|
6913
|
-
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
6914
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
6915
|
-
return;
|
|
6873
|
+
const routineRegistrationGraph = resolveSyncInsertTask(
|
|
6874
|
+
this.isCadenzaDBReady,
|
|
6875
|
+
"routine",
|
|
6876
|
+
{
|
|
6877
|
+
onConflict: {
|
|
6878
|
+
target: ["name", "version", "service_name"],
|
|
6879
|
+
action: {
|
|
6880
|
+
do: "nothing"
|
|
6916
6881
|
}
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6921
|
-
return true;
|
|
6922
|
-
}).then(gatherRoutineRegistrationTask)
|
|
6923
|
-
)
|
|
6882
|
+
}
|
|
6883
|
+
},
|
|
6884
|
+
{ concurrency: 30 }
|
|
6924
6885
|
);
|
|
6886
|
+
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
6887
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
6888
|
+
return;
|
|
6889
|
+
}
|
|
6890
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6891
|
+
delayMs: 3e3
|
|
6892
|
+
});
|
|
6893
|
+
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6894
|
+
return true;
|
|
6895
|
+
}).then(gatherRoutineRegistrationTask);
|
|
6896
|
+
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
6925
6897
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
6926
6898
|
"Split tasks in routines",
|
|
6927
6899
|
function* (ctx) {
|
|
@@ -6974,7 +6946,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6974
6946
|
}
|
|
6975
6947
|
}
|
|
6976
6948
|
);
|
|
6977
|
-
const
|
|
6949
|
+
const registerTaskToRoutineMapGraph = resolveSyncInsertTask(
|
|
6978
6950
|
this.isCadenzaDBReady,
|
|
6979
6951
|
"task_to_routine_map",
|
|
6980
6952
|
{
|
|
@@ -6992,8 +6964,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6992
6964
|
}
|
|
6993
6965
|
},
|
|
6994
6966
|
{ concurrency: 30 }
|
|
6995
|
-
)
|
|
6996
|
-
|
|
6967
|
+
);
|
|
6968
|
+
const registerTaskToRoutineMapTask = CadenzaService.createMetaTask(
|
|
6969
|
+
"Register routine task",
|
|
6970
|
+
(ctx) => {
|
|
6997
6971
|
if (!didSyncInsertSucceed(ctx)) {
|
|
6998
6972
|
return;
|
|
6999
6973
|
}
|
|
@@ -7003,11 +6977,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7003
6977
|
CadenzaService.getRoutine(ctx.__routineName).registeredTasks.add(
|
|
7004
6978
|
ctx.__taskName
|
|
7005
6979
|
);
|
|
7006
|
-
}
|
|
6980
|
+
}
|
|
6981
|
+
);
|
|
6982
|
+
wireSyncTaskGraph(
|
|
6983
|
+
this.splitTasksInRoutines,
|
|
6984
|
+
registerTaskToRoutineMapGraph,
|
|
6985
|
+
registerTaskToRoutineMapTask
|
|
7007
6986
|
);
|
|
7008
|
-
if (registerTaskToRoutineMapTask) {
|
|
7009
|
-
this.splitTasksInRoutines.then(registerTaskToRoutineMapTask);
|
|
7010
|
-
}
|
|
7011
6987
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
7012
6988
|
"Split signals for registration",
|
|
7013
6989
|
function* (ctx) {
|
|
@@ -7036,30 +7012,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7036
7012
|
}
|
|
7037
7013
|
}.bind(this)
|
|
7038
7014
|
);
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
{
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
do: "nothing"
|
|
7048
|
-
}
|
|
7049
|
-
}
|
|
7050
|
-
},
|
|
7051
|
-
{ concurrency: 30 }
|
|
7052
|
-
)?.then(
|
|
7053
|
-
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
7054
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7055
|
-
return;
|
|
7015
|
+
const signalRegistrationGraph = resolveSyncInsertTask(
|
|
7016
|
+
this.isCadenzaDBReady,
|
|
7017
|
+
"signal_registry",
|
|
7018
|
+
{
|
|
7019
|
+
onConflict: {
|
|
7020
|
+
target: ["name"],
|
|
7021
|
+
action: {
|
|
7022
|
+
do: "nothing"
|
|
7056
7023
|
}
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7024
|
+
}
|
|
7025
|
+
},
|
|
7026
|
+
{ concurrency: 30 }
|
|
7027
|
+
);
|
|
7028
|
+
const processSignalRegistrationTask = CadenzaService.createMetaTask(
|
|
7029
|
+
"Process signal registration",
|
|
7030
|
+
(ctx) => {
|
|
7031
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7032
|
+
return;
|
|
7033
|
+
}
|
|
7034
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7035
|
+
delayMs: 3e3
|
|
7036
|
+
});
|
|
7037
|
+
return { signalName: ctx.__signal };
|
|
7038
|
+
}
|
|
7039
|
+
).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask);
|
|
7040
|
+
wireSyncTaskGraph(
|
|
7041
|
+
this.splitSignalsTask,
|
|
7042
|
+
signalRegistrationGraph,
|
|
7043
|
+
processSignalRegistrationTask
|
|
7063
7044
|
);
|
|
7064
7045
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
7065
7046
|
"Split tasks for registration",
|
|
@@ -7128,7 +7109,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7128
7109
|
}
|
|
7129
7110
|
}.bind(this)
|
|
7130
7111
|
);
|
|
7131
|
-
const
|
|
7112
|
+
const registerTaskGraph = resolveSyncInsertTask(
|
|
7132
7113
|
this.isCadenzaDBReady,
|
|
7133
7114
|
"task",
|
|
7134
7115
|
{
|
|
@@ -7140,8 +7121,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7140
7121
|
}
|
|
7141
7122
|
},
|
|
7142
7123
|
{ concurrency: 30 }
|
|
7143
|
-
)
|
|
7144
|
-
|
|
7124
|
+
);
|
|
7125
|
+
const registerTaskTask = CadenzaService.createMetaTask(
|
|
7126
|
+
"Record registration",
|
|
7127
|
+
(ctx, emit) => {
|
|
7145
7128
|
if (shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
7146
7129
|
logSyncDebug("task_registration_result", {
|
|
7147
7130
|
taskName: ctx.__taskName,
|
|
@@ -7161,11 +7144,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7161
7144
|
task: CadenzaService.get(ctx.__taskName)
|
|
7162
7145
|
});
|
|
7163
7146
|
return true;
|
|
7164
|
-
}
|
|
7165
|
-
);
|
|
7166
|
-
|
|
7167
|
-
this.splitTasksForRegistration.then(registerTaskTask);
|
|
7168
|
-
}
|
|
7147
|
+
}
|
|
7148
|
+
).then(gatherTaskRegistrationTask);
|
|
7149
|
+
wireSyncTaskGraph(this.splitTasksForRegistration, registerTaskGraph, registerTaskTask);
|
|
7169
7150
|
CadenzaService.createMetaTask(
|
|
7170
7151
|
"Prepare created task for immediate sync",
|
|
7171
7152
|
(ctx) => {
|
|
@@ -7224,31 +7205,37 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7224
7205
|
};
|
|
7225
7206
|
}
|
|
7226
7207
|
}.bind(this)
|
|
7227
|
-
)
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
}
|
|
7237
|
-
}
|
|
7238
|
-
},
|
|
7239
|
-
{ concurrency: 30 }
|
|
7240
|
-
)?.then(
|
|
7241
|
-
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
7242
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7243
|
-
return;
|
|
7208
|
+
);
|
|
7209
|
+
const actorRegistrationGraph = resolveSyncInsertTask(
|
|
7210
|
+
this.isCadenzaDBReady,
|
|
7211
|
+
"actor",
|
|
7212
|
+
{
|
|
7213
|
+
onConflict: {
|
|
7214
|
+
target: ["name", "service_name", "version"],
|
|
7215
|
+
action: {
|
|
7216
|
+
do: "nothing"
|
|
7244
7217
|
}
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
)
|
|
7218
|
+
}
|
|
7219
|
+
},
|
|
7220
|
+
{ concurrency: 30 }
|
|
7221
|
+
);
|
|
7222
|
+
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
7223
|
+
"Record actor registration",
|
|
7224
|
+
(ctx) => {
|
|
7225
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7226
|
+
return;
|
|
7227
|
+
}
|
|
7228
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7229
|
+
delayMs: 3e3
|
|
7230
|
+
});
|
|
7231
|
+
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
7232
|
+
return true;
|
|
7233
|
+
}
|
|
7234
|
+
).then(gatherActorRegistrationTask);
|
|
7235
|
+
wireSyncTaskGraph(
|
|
7236
|
+
this.splitActorsForRegistration,
|
|
7237
|
+
actorRegistrationGraph,
|
|
7238
|
+
recordActorRegistrationTask
|
|
7252
7239
|
);
|
|
7253
7240
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
7254
7241
|
"Split actor task maps",
|
|
@@ -7286,36 +7273,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7286
7273
|
__actorTaskMapRegistrationKey: registrationKey
|
|
7287
7274
|
};
|
|
7288
7275
|
}.bind(this)
|
|
7289
|
-
)
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
}
|
|
7305
|
-
}
|
|
7306
|
-
},
|
|
7307
|
-
{ concurrency: 30 }
|
|
7308
|
-
)?.then(
|
|
7309
|
-
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
7310
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7311
|
-
return;
|
|
7276
|
+
);
|
|
7277
|
+
const actorTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
7278
|
+
this.isCadenzaDBReady,
|
|
7279
|
+
"actor_task_map",
|
|
7280
|
+
{
|
|
7281
|
+
onConflict: {
|
|
7282
|
+
target: [
|
|
7283
|
+
"actor_name",
|
|
7284
|
+
"actor_version",
|
|
7285
|
+
"task_name",
|
|
7286
|
+
"task_version",
|
|
7287
|
+
"service_name"
|
|
7288
|
+
],
|
|
7289
|
+
action: {
|
|
7290
|
+
do: "nothing"
|
|
7312
7291
|
}
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7292
|
+
}
|
|
7293
|
+
},
|
|
7294
|
+
{ concurrency: 30 }
|
|
7295
|
+
);
|
|
7296
|
+
const recordActorTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
7297
|
+
"Record actor task map registration",
|
|
7298
|
+
(ctx) => {
|
|
7299
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7300
|
+
return;
|
|
7301
|
+
}
|
|
7302
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7303
|
+
delayMs: 3e3
|
|
7304
|
+
});
|
|
7305
|
+
this.registeredActorTaskMaps.add(ctx.__actorTaskMapRegistrationKey);
|
|
7306
|
+
}
|
|
7307
|
+
);
|
|
7308
|
+
wireSyncTaskGraph(
|
|
7309
|
+
this.registerActorTaskMapTask,
|
|
7310
|
+
actorTaskMapRegistrationGraph,
|
|
7311
|
+
recordActorTaskMapRegistrationTask
|
|
7319
7312
|
);
|
|
7320
7313
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
7321
7314
|
"Record signal registration",
|
|
@@ -7374,25 +7367,32 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7374
7367
|
return emittedCount > 0;
|
|
7375
7368
|
}
|
|
7376
7369
|
);
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7370
|
+
const processSplitSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
7371
|
+
"Process split signal-to-task map",
|
|
7372
|
+
(ctx) => ctx
|
|
7373
|
+
).doOn("meta.sync_controller.signal_task_map_split");
|
|
7374
|
+
const signalToTaskMapGraph = resolveSyncInsertTask(
|
|
7375
|
+
this.isCadenzaDBReady,
|
|
7376
|
+
"signal_to_task_map",
|
|
7377
|
+
{
|
|
7378
|
+
onConflict: {
|
|
7379
|
+
target: [
|
|
7380
|
+
"task_name",
|
|
7381
|
+
"task_version",
|
|
7382
|
+
"service_name",
|
|
7383
|
+
"signal_name"
|
|
7384
|
+
],
|
|
7385
|
+
action: {
|
|
7386
|
+
do: "nothing"
|
|
7392
7387
|
}
|
|
7393
|
-
}
|
|
7394
|
-
|
|
7395
|
-
|
|
7388
|
+
}
|
|
7389
|
+
},
|
|
7390
|
+
{ concurrency: 30 }
|
|
7391
|
+
);
|
|
7392
|
+
wireSyncTaskGraph(
|
|
7393
|
+
processSplitSignalToTaskMapTask,
|
|
7394
|
+
signalToTaskMapGraph,
|
|
7395
|
+
registerSignalTask
|
|
7396
7396
|
);
|
|
7397
7397
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
7398
7398
|
"Split intents for registration",
|
|
@@ -7418,19 +7418,23 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7418
7418
|
}
|
|
7419
7419
|
}.bind(this)
|
|
7420
7420
|
);
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7421
|
+
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
7422
|
+
"Record intent definition registration",
|
|
7423
|
+
(ctx) => {
|
|
7424
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7425
|
+
return;
|
|
7426
|
+
}
|
|
7427
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7428
|
+
delayMs: 3e3
|
|
7429
|
+
});
|
|
7430
|
+
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
7431
|
+
return true;
|
|
7432
|
+
}
|
|
7433
|
+
).then(gatherIntentRegistrationTask);
|
|
7434
|
+
wireSyncTaskGraph(
|
|
7435
|
+
this.splitIntentsTask,
|
|
7436
|
+
insertIntentRegistryTask,
|
|
7437
|
+
recordIntentDefinitionRegistrationTask
|
|
7434
7438
|
);
|
|
7435
7439
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
7436
7440
|
"Record intent registration",
|
|
@@ -7512,67 +7516,82 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7512
7516
|
return true;
|
|
7513
7517
|
}.bind(this)
|
|
7514
7518
|
);
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7519
|
+
const processSplitIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
7520
|
+
"Process split intent-to-task map",
|
|
7521
|
+
(ctx) => ctx
|
|
7522
|
+
).doOn("meta.sync_controller.intent_task_map_split");
|
|
7523
|
+
const prepareIntentDefinitionForIntentMapTask = CadenzaService.createMetaTask(
|
|
7524
|
+
"Prepare intent definition for intent-to-task map",
|
|
7525
|
+
(ctx) => {
|
|
7526
|
+
if (!ctx.__intentDefinition || !ctx.__intentMapData) {
|
|
7527
|
+
return false;
|
|
7528
|
+
}
|
|
7529
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
7530
|
+
logSyncDebug("intent_definition_prepare", {
|
|
7531
|
+
taskName: ctx.__taskName,
|
|
7532
|
+
intentName: ctx.__intent,
|
|
7533
|
+
intentDefinition: ctx.__intentDefinition
|
|
7534
|
+
});
|
|
7535
|
+
}
|
|
7536
|
+
return {
|
|
7537
|
+
...ctx,
|
|
7538
|
+
data: ctx.__intentDefinition
|
|
7539
|
+
};
|
|
7540
|
+
}
|
|
7541
|
+
);
|
|
7542
|
+
const restoreIntentToTaskMapPayloadTask = CadenzaService.createMetaTask(
|
|
7543
|
+
"Restore intent-to-task map payload",
|
|
7544
|
+
(ctx) => {
|
|
7545
|
+
if (!ctx.__intentMapData) {
|
|
7546
|
+
return false;
|
|
7547
|
+
}
|
|
7548
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
7549
|
+
logSyncDebug("intent_map_payload_restore", {
|
|
7550
|
+
taskName: ctx.__taskName,
|
|
7551
|
+
intentName: ctx.__intent,
|
|
7552
|
+
intentMapData: ctx.__intentMapData
|
|
7553
|
+
});
|
|
7554
|
+
}
|
|
7555
|
+
return {
|
|
7556
|
+
...ctx,
|
|
7557
|
+
data: ctx.__intentMapData
|
|
7558
|
+
};
|
|
7559
|
+
}
|
|
7560
|
+
);
|
|
7561
|
+
const intentToTaskMapGraph = resolveSyncInsertTask(
|
|
7562
|
+
this.isCadenzaDBReady,
|
|
7563
|
+
"intent_to_task_map",
|
|
7564
|
+
{
|
|
7565
|
+
onConflict: {
|
|
7566
|
+
target: [
|
|
7567
|
+
"intent_name",
|
|
7568
|
+
"task_name",
|
|
7569
|
+
"task_version",
|
|
7570
|
+
"service_name"
|
|
7571
|
+
],
|
|
7572
|
+
action: {
|
|
7573
|
+
do: "nothing"
|
|
7528
7574
|
}
|
|
7529
|
-
return {
|
|
7530
|
-
...ctx,
|
|
7531
|
-
data: ctx.__intentDefinition
|
|
7532
|
-
};
|
|
7533
7575
|
}
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
}
|
|
7554
|
-
).then(
|
|
7555
|
-
resolveSyncInsertTask(
|
|
7556
|
-
this.isCadenzaDBReady,
|
|
7557
|
-
"intent_to_task_map",
|
|
7558
|
-
{
|
|
7559
|
-
onConflict: {
|
|
7560
|
-
target: [
|
|
7561
|
-
"intent_name",
|
|
7562
|
-
"task_name",
|
|
7563
|
-
"task_version",
|
|
7564
|
-
"service_name"
|
|
7565
|
-
],
|
|
7566
|
-
action: {
|
|
7567
|
-
do: "nothing"
|
|
7568
|
-
}
|
|
7569
|
-
}
|
|
7570
|
-
},
|
|
7571
|
-
{ concurrency: 30 }
|
|
7572
|
-
)?.then(registerIntentTask)
|
|
7573
|
-
)
|
|
7574
|
-
)
|
|
7575
|
-
)
|
|
7576
|
+
},
|
|
7577
|
+
{ concurrency: 30 }
|
|
7578
|
+
);
|
|
7579
|
+
processSplitIntentToTaskMapTask.then(prepareIntentDefinitionForIntentMapTask);
|
|
7580
|
+
if (ensureIntentRegistryBeforeIntentMapTask) {
|
|
7581
|
+
wireSyncTaskGraph(
|
|
7582
|
+
prepareIntentDefinitionForIntentMapTask,
|
|
7583
|
+
ensureIntentRegistryBeforeIntentMapTask,
|
|
7584
|
+
restoreIntentToTaskMapPayloadTask
|
|
7585
|
+
);
|
|
7586
|
+
} else {
|
|
7587
|
+
prepareIntentDefinitionForIntentMapTask.then(
|
|
7588
|
+
restoreIntentToTaskMapPayloadTask
|
|
7589
|
+
);
|
|
7590
|
+
}
|
|
7591
|
+
wireSyncTaskGraph(
|
|
7592
|
+
restoreIntentToTaskMapPayloadTask,
|
|
7593
|
+
intentToTaskMapGraph,
|
|
7594
|
+
registerIntentTask
|
|
7576
7595
|
);
|
|
7577
7596
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
7578
7597
|
"Register task map to DB",
|
|
@@ -7608,39 +7627,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7608
7627
|
};
|
|
7609
7628
|
}
|
|
7610
7629
|
}
|
|
7611
|
-
)
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
}
|
|
7628
|
-
}
|
|
7629
|
-
},
|
|
7630
|
-
{ concurrency: 30 }
|
|
7631
|
-
)?.then(
|
|
7632
|
-
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
7633
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7634
|
-
return;
|
|
7630
|
+
);
|
|
7631
|
+
const taskMapRegistrationGraph = resolveSyncInsertTask(
|
|
7632
|
+
this.isCadenzaDBReady,
|
|
7633
|
+
"directional_task_graph_map",
|
|
7634
|
+
{
|
|
7635
|
+
onConflict: {
|
|
7636
|
+
target: [
|
|
7637
|
+
"task_name",
|
|
7638
|
+
"predecessor_task_name",
|
|
7639
|
+
"task_version",
|
|
7640
|
+
"predecessor_task_version",
|
|
7641
|
+
"service_name",
|
|
7642
|
+
"predecessor_service_name"
|
|
7643
|
+
],
|
|
7644
|
+
action: {
|
|
7645
|
+
do: "nothing"
|
|
7635
7646
|
}
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7647
|
+
}
|
|
7648
|
+
},
|
|
7649
|
+
{ concurrency: 30 }
|
|
7650
|
+
);
|
|
7651
|
+
const recordTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
7652
|
+
"Record task map registration",
|
|
7653
|
+
(ctx) => {
|
|
7654
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7655
|
+
return;
|
|
7656
|
+
}
|
|
7657
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7658
|
+
delayMs: 3e3
|
|
7659
|
+
});
|
|
7660
|
+
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
7661
|
+
ctx.__nextTaskName
|
|
7662
|
+
);
|
|
7663
|
+
}
|
|
7664
|
+
);
|
|
7665
|
+
wireSyncTaskGraph(
|
|
7666
|
+
this.registerTaskMapTask,
|
|
7667
|
+
taskMapRegistrationGraph,
|
|
7668
|
+
recordTaskMapRegistrationTask
|
|
7644
7669
|
);
|
|
7645
7670
|
this.registerDeputyRelationshipTask = CadenzaService.createMetaTask(
|
|
7646
7671
|
"Register deputy relationship",
|
|
@@ -7667,40 +7692,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7667
7692
|
};
|
|
7668
7693
|
}
|
|
7669
7694
|
}
|
|
7670
|
-
)
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
}
|
|
7687
|
-
}
|
|
7688
|
-
},
|
|
7689
|
-
{ concurrency: 30 }
|
|
7690
|
-
)?.then(
|
|
7691
|
-
CadenzaService.createMetaTask(
|
|
7692
|
-
"Record deputy relationship registration",
|
|
7693
|
-
(ctx) => {
|
|
7694
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7695
|
-
return;
|
|
7696
|
-
}
|
|
7697
|
-
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7698
|
-
delayMs: 3e3
|
|
7699
|
-
});
|
|
7700
|
-
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
7695
|
+
);
|
|
7696
|
+
const deputyRelationshipRegistrationGraph = resolveSyncInsertTask(
|
|
7697
|
+
this.isCadenzaDBReady,
|
|
7698
|
+
"directional_task_graph_map",
|
|
7699
|
+
{
|
|
7700
|
+
onConflict: {
|
|
7701
|
+
target: [
|
|
7702
|
+
"task_name",
|
|
7703
|
+
"predecessor_task_name",
|
|
7704
|
+
"task_version",
|
|
7705
|
+
"predecessor_task_version",
|
|
7706
|
+
"service_name",
|
|
7707
|
+
"predecessor_service_name"
|
|
7708
|
+
],
|
|
7709
|
+
action: {
|
|
7710
|
+
do: "nothing"
|
|
7701
7711
|
}
|
|
7702
|
-
|
|
7703
|
-
|
|
7712
|
+
}
|
|
7713
|
+
},
|
|
7714
|
+
{ concurrency: 30 }
|
|
7715
|
+
);
|
|
7716
|
+
const recordDeputyRelationshipRegistrationTask = CadenzaService.createMetaTask(
|
|
7717
|
+
"Record deputy relationship registration",
|
|
7718
|
+
(ctx) => {
|
|
7719
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7720
|
+
return;
|
|
7721
|
+
}
|
|
7722
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7723
|
+
delayMs: 3e3
|
|
7724
|
+
});
|
|
7725
|
+
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
7726
|
+
}
|
|
7727
|
+
);
|
|
7728
|
+
wireSyncTaskGraph(
|
|
7729
|
+
this.registerDeputyRelationshipTask,
|
|
7730
|
+
deputyRelationshipRegistrationGraph,
|
|
7731
|
+
recordDeputyRelationshipRegistrationTask
|
|
7704
7732
|
);
|
|
7705
7733
|
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7706
7734
|
"Reconcile task registration from authority",
|
|
@@ -7832,7 +7860,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7832
7860
|
isHidden: true
|
|
7833
7861
|
}
|
|
7834
7862
|
);
|
|
7835
|
-
const
|
|
7863
|
+
const skipAuthoritativeTaskReconciliationTask = CadenzaService.createMetaTask(
|
|
7836
7864
|
"Skip authoritative task reconciliation",
|
|
7837
7865
|
() => false,
|
|
7838
7866
|
"Skips task reconciliation when no authority query task is available.",
|
|
@@ -7841,7 +7869,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7841
7869
|
isHidden: true
|
|
7842
7870
|
}
|
|
7843
7871
|
);
|
|
7844
|
-
const
|
|
7872
|
+
const skipAuthoritativeRoutineReconciliationTask = CadenzaService.createMetaTask(
|
|
7845
7873
|
"Skip authoritative routine reconciliation",
|
|
7846
7874
|
() => false,
|
|
7847
7875
|
"Skips routine reconciliation when no authority query task is available.",
|
|
@@ -7850,7 +7878,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7850
7878
|
isHidden: true
|
|
7851
7879
|
}
|
|
7852
7880
|
);
|
|
7853
|
-
const
|
|
7881
|
+
const skipAuthoritativeSignalReconciliationTask = CadenzaService.createMetaTask(
|
|
7854
7882
|
"Skip authoritative signal reconciliation",
|
|
7855
7883
|
() => false,
|
|
7856
7884
|
"Skips signal reconciliation when no authority query task is available.",
|
|
@@ -7859,7 +7887,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7859
7887
|
isHidden: true
|
|
7860
7888
|
}
|
|
7861
7889
|
);
|
|
7862
|
-
const
|
|
7890
|
+
const skipAuthoritativeIntentReconciliationTask = CadenzaService.createMetaTask(
|
|
7863
7891
|
"Skip authoritative intent reconciliation",
|
|
7864
7892
|
() => false,
|
|
7865
7893
|
"Skips intent reconciliation when no authority query task is available.",
|
|
@@ -7868,6 +7896,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7868
7896
|
isHidden: true
|
|
7869
7897
|
}
|
|
7870
7898
|
);
|
|
7899
|
+
if (authoritativeTaskQueryGraph) {
|
|
7900
|
+
authoritativeTaskQueryGraph.completionTask.then(
|
|
7901
|
+
reconcileTaskRegistrationFromAuthorityTask
|
|
7902
|
+
);
|
|
7903
|
+
}
|
|
7904
|
+
if (authoritativeRoutineQueryGraph) {
|
|
7905
|
+
authoritativeRoutineQueryGraph.completionTask.then(
|
|
7906
|
+
reconcileRoutineRegistrationFromAuthorityTask
|
|
7907
|
+
);
|
|
7908
|
+
}
|
|
7909
|
+
if (authoritativeSignalQueryGraph) {
|
|
7910
|
+
authoritativeSignalQueryGraph.completionTask.then(
|
|
7911
|
+
reconcileSignalRegistrationFromAuthorityTask
|
|
7912
|
+
);
|
|
7913
|
+
}
|
|
7914
|
+
if (authoritativeIntentQueryGraph) {
|
|
7915
|
+
authoritativeIntentQueryGraph.completionTask.then(
|
|
7916
|
+
reconcileIntentRegistrationFromAuthorityTask
|
|
7917
|
+
);
|
|
7918
|
+
}
|
|
7871
7919
|
const authoritativeRegistrationTriggers = [
|
|
7872
7920
|
"meta.service_registry.initial_sync_complete",
|
|
7873
7921
|
"meta.sync_requested",
|
|
@@ -7900,7 +7948,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7900
7948
|
register: false,
|
|
7901
7949
|
isHidden: true
|
|
7902
7950
|
}
|
|
7903
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
7951
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
7952
|
+
authoritativeTaskQueryGraph?.entryTask ?? skipAuthoritativeTaskReconciliationTask
|
|
7953
|
+
);
|
|
7904
7954
|
CadenzaService.createMetaTask(
|
|
7905
7955
|
"Prepare authoritative routine registration query",
|
|
7906
7956
|
(ctx) => {
|
|
@@ -7927,7 +7977,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7927
7977
|
register: false,
|
|
7928
7978
|
isHidden: true
|
|
7929
7979
|
}
|
|
7930
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
7980
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
7981
|
+
authoritativeRoutineQueryGraph?.entryTask ?? skipAuthoritativeRoutineReconciliationTask
|
|
7982
|
+
);
|
|
7931
7983
|
CadenzaService.createMetaTask(
|
|
7932
7984
|
"Prepare authoritative signal registration query",
|
|
7933
7985
|
(ctx) => {
|
|
@@ -7946,7 +7998,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7946
7998
|
register: false,
|
|
7947
7999
|
isHidden: true
|
|
7948
8000
|
}
|
|
7949
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8001
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8002
|
+
authoritativeSignalQueryGraph?.entryTask ?? skipAuthoritativeSignalReconciliationTask
|
|
8003
|
+
);
|
|
7950
8004
|
CadenzaService.createMetaTask(
|
|
7951
8005
|
"Prepare authoritative intent registration query",
|
|
7952
8006
|
(ctx) => {
|
|
@@ -7965,7 +8019,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7965
8019
|
register: false,
|
|
7966
8020
|
isHidden: true
|
|
7967
8021
|
}
|
|
7968
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8022
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8023
|
+
authoritativeIntentQueryGraph?.entryTask ?? skipAuthoritativeIntentReconciliationTask
|
|
8024
|
+
);
|
|
7969
8025
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
7970
8026
|
"meta.sync_controller.sync_tick",
|
|
7971
8027
|
"meta.service_registry.initial_sync_complete",
|
|
@@ -8400,7 +8456,7 @@ var CadenzaService = class {
|
|
|
8400
8456
|
).map((transport) => ({
|
|
8401
8457
|
...transport,
|
|
8402
8458
|
protocols: transport.protocols && transport.protocols.length > 0 ? transport.protocols : useSocket ? ["rest", "socket"] : ["rest"],
|
|
8403
|
-
uuid:
|
|
8459
|
+
uuid: uuid5()
|
|
8404
8460
|
}));
|
|
8405
8461
|
}
|
|
8406
8462
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -8652,7 +8708,7 @@ var CadenzaService = class {
|
|
|
8652
8708
|
}
|
|
8653
8709
|
for (const responder of responders) {
|
|
8654
8710
|
const { task, descriptor } = responder;
|
|
8655
|
-
const inquiryId =
|
|
8711
|
+
const inquiryId = uuid5();
|
|
8656
8712
|
startTimeByTask.set(task, Date.now());
|
|
8657
8713
|
const resolverTask = this.createEphemeralMetaTask(
|
|
8658
8714
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -9160,7 +9216,7 @@ var CadenzaService = class {
|
|
|
9160
9216
|
this.bootstrap();
|
|
9161
9217
|
this.validateName(serviceName);
|
|
9162
9218
|
this.validateServiceName(serviceName);
|
|
9163
|
-
const serviceId = options.customServiceId ??
|
|
9219
|
+
const serviceId = options.customServiceId ?? uuid5();
|
|
9164
9220
|
this.serviceRegistry.serviceName = serviceName;
|
|
9165
9221
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
9166
9222
|
this.setHydrationResults(options.hydration);
|
|
@@ -10011,7 +10067,7 @@ import {
|
|
|
10011
10067
|
} from "@cadenza.io/core";
|
|
10012
10068
|
|
|
10013
10069
|
// src/ssr/createSSRInquiryBridge.ts
|
|
10014
|
-
import { v4 as
|
|
10070
|
+
import { v4 as uuid6 } from "uuid";
|
|
10015
10071
|
function ensureFetch() {
|
|
10016
10072
|
if (typeof globalThis.fetch !== "function") {
|
|
10017
10073
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -10100,7 +10156,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
10100
10156
|
__remoteRoutineName: remoteRoutineName,
|
|
10101
10157
|
__metadata: {
|
|
10102
10158
|
...context.__metadata ?? {},
|
|
10103
|
-
__deputyExecId:
|
|
10159
|
+
__deputyExecId: uuid6()
|
|
10104
10160
|
}
|
|
10105
10161
|
}),
|
|
10106
10162
|
signal
|