@cadenza.io/service 2.17.48 → 2.17.50
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 +288 -140
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +288 -140
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +288 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +288 -140
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8763,6 +8763,17 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8763
8763
|
CadenzaService.createMetaTask(
|
|
8764
8764
|
`Log prepared graph sync insert execution for ${tableName}`,
|
|
8765
8765
|
(ctx) => {
|
|
8766
|
+
if (tableName === "task") {
|
|
8767
|
+
if (!shouldDebugTaskSyncPayload(ctx)) {
|
|
8768
|
+
return ctx;
|
|
8769
|
+
}
|
|
8770
|
+
logSyncDebug("insert_prepare", {
|
|
8771
|
+
tableName,
|
|
8772
|
+
targetTaskName: targetTask.name,
|
|
8773
|
+
payload: buildTaskSyncDebugPayload(ctx)
|
|
8774
|
+
});
|
|
8775
|
+
return ctx;
|
|
8776
|
+
}
|
|
8766
8777
|
logSyncDebug("insert_prepare", {
|
|
8767
8778
|
tableName,
|
|
8768
8779
|
targetTaskName: targetTask.name,
|
|
@@ -8795,12 +8806,23 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8795
8806
|
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : originalQueryData
|
|
8796
8807
|
};
|
|
8797
8808
|
if (debugTable) {
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8809
|
+
if (tableName === "task") {
|
|
8810
|
+
if (shouldDebugTaskSyncPayload(normalizedContext)) {
|
|
8811
|
+
logSyncDebug("insert_finalize", {
|
|
8812
|
+
tableName,
|
|
8813
|
+
targetTaskName: targetTask.name,
|
|
8814
|
+
success: didSyncInsertSucceed(normalizedContext),
|
|
8815
|
+
payload: buildTaskSyncDebugPayload(normalizedContext)
|
|
8816
|
+
});
|
|
8817
|
+
}
|
|
8818
|
+
} else {
|
|
8819
|
+
logSyncDebug("insert_finalize", {
|
|
8820
|
+
tableName,
|
|
8821
|
+
targetTaskName: targetTask.name,
|
|
8822
|
+
success: didSyncInsertSucceed(normalizedContext),
|
|
8823
|
+
ctx: normalizedContext
|
|
8824
|
+
});
|
|
8825
|
+
}
|
|
8804
8826
|
}
|
|
8805
8827
|
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8806
8828
|
emit(executionResolvedSignal, normalizedContext);
|
|
@@ -8818,11 +8840,21 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8818
8840
|
CadenzaService.createMetaTask(
|
|
8819
8841
|
`Log failed graph sync insert execution for ${tableName}`,
|
|
8820
8842
|
(ctx) => {
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8843
|
+
if (tableName === "task") {
|
|
8844
|
+
if (shouldDebugTaskSyncPayload(ctx)) {
|
|
8845
|
+
logSyncDebug("insert_failed", {
|
|
8846
|
+
tableName,
|
|
8847
|
+
targetTaskName: targetTask.name,
|
|
8848
|
+
payload: buildTaskSyncDebugPayload(ctx)
|
|
8849
|
+
});
|
|
8850
|
+
}
|
|
8851
|
+
} else {
|
|
8852
|
+
logSyncDebug("insert_failed", {
|
|
8853
|
+
tableName,
|
|
8854
|
+
targetTaskName: targetTask.name,
|
|
8855
|
+
ctx
|
|
8856
|
+
});
|
|
8857
|
+
}
|
|
8826
8858
|
if (typeof ctx.__resolverRequestId === "string") {
|
|
8827
8859
|
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8828
8860
|
}
|
|
@@ -8988,6 +9020,37 @@ function summarizeSyncDebugValue(value, depth = 0) {
|
|
|
8988
9020
|
function logSyncDebug(event, payload) {
|
|
8989
9021
|
console.log(`${SYNC_DEBUG_PREFIX} ${event}`, summarizeSyncDebugValue(payload));
|
|
8990
9022
|
}
|
|
9023
|
+
function buildTaskSyncDebugPayload(ctx) {
|
|
9024
|
+
const data = ctx.data && typeof ctx.data === "object" ? ctx.data : {};
|
|
9025
|
+
const queryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
9026
|
+
const queryDataData = queryData.data && typeof queryData.data === "object" ? queryData.data : {};
|
|
9027
|
+
const taskPayload = Object.keys(queryDataData).length > 0 ? queryDataData : data;
|
|
9028
|
+
const functionString = typeof taskPayload.functionString === "string" ? taskPayload.functionString : typeof taskPayload.function_string === "string" ? taskPayload.function_string : void 0;
|
|
9029
|
+
const tagIdGetter = typeof taskPayload.tagIdGetter === "string" ? taskPayload.tagIdGetter : typeof taskPayload.tag_id_getter === "string" ? taskPayload.tag_id_getter : void 0;
|
|
9030
|
+
const signals = taskPayload.signals && typeof taskPayload.signals === "object" ? taskPayload.signals : {};
|
|
9031
|
+
const intents = taskPayload.intents && typeof taskPayload.intents === "object" ? taskPayload.intents : {};
|
|
9032
|
+
return {
|
|
9033
|
+
taskName: taskPayload.name ?? taskPayload.taskName ?? taskPayload.task_name ?? ctx.__taskName ?? null,
|
|
9034
|
+
serviceName: taskPayload.service_name ?? taskPayload.serviceName ?? ctx.__syncServiceName ?? null,
|
|
9035
|
+
functionStringLength: functionString?.length ?? null,
|
|
9036
|
+
tagIdGetterLength: tagIdGetter?.length ?? null,
|
|
9037
|
+
isMeta: taskPayload.isMeta ?? taskPayload.is_meta ?? null,
|
|
9038
|
+
isSubMeta: taskPayload.isSubMeta ?? taskPayload.is_sub_meta ?? null,
|
|
9039
|
+
isHidden: taskPayload.isHidden ?? taskPayload.is_hidden ?? null,
|
|
9040
|
+
signalsEmitsCount: Array.isArray(signals.emits) ? signals.emits.length : null,
|
|
9041
|
+
signalsObservedCount: Array.isArray(signals.observed) ? signals.observed.length : null,
|
|
9042
|
+
intentHandlesCount: Array.isArray(intents.handles) ? intents.handles.length : null,
|
|
9043
|
+
intentInquiresCount: Array.isArray(intents.inquires) ? intents.inquires.length : null,
|
|
9044
|
+
rowCount: ctx.rowCount ?? null,
|
|
9045
|
+
errored: ctx.errored ?? false,
|
|
9046
|
+
success: ctx.__success ?? null,
|
|
9047
|
+
error: ctx.__error ?? null
|
|
9048
|
+
};
|
|
9049
|
+
}
|
|
9050
|
+
function shouldDebugTaskSyncPayload(ctx) {
|
|
9051
|
+
const payload = buildTaskSyncDebugPayload(ctx);
|
|
9052
|
+
return shouldDebugSyncTaskName(payload.taskName);
|
|
9053
|
+
}
|
|
8991
9054
|
function resolveSyncQueryRows(ctx, tableName) {
|
|
8992
9055
|
const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
|
|
8993
9056
|
const rows = ctx?.[resultKey];
|
|
@@ -9016,6 +9079,31 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
9016
9079
|
}
|
|
9017
9080
|
).then(targetTask);
|
|
9018
9081
|
}
|
|
9082
|
+
function getRegistrableTasks() {
|
|
9083
|
+
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
9084
|
+
(task) => task.register && !task.isHidden
|
|
9085
|
+
);
|
|
9086
|
+
}
|
|
9087
|
+
function getRegistrableRoutines() {
|
|
9088
|
+
return Array.from(CadenzaService.registry.routines.values());
|
|
9089
|
+
}
|
|
9090
|
+
function getRegistrableSignalObservers() {
|
|
9091
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
9092
|
+
return signalObservers ? Array.from(signalObservers.values()) : [];
|
|
9093
|
+
}
|
|
9094
|
+
function getRegistrableIntentNames() {
|
|
9095
|
+
return Array.from(CadenzaService.inquiryBroker.intents.values()).map((intent) => buildIntentRegistryData(intent)).filter(
|
|
9096
|
+
(intentDefinition) => intentDefinition !== null
|
|
9097
|
+
).map((intentDefinition) => String(intentDefinition.name));
|
|
9098
|
+
}
|
|
9099
|
+
function buildActorRegistrationKey(actor, serviceName) {
|
|
9100
|
+
const data = buildActorRegistrationData(actor);
|
|
9101
|
+
const name = typeof data.name === "string" && data.name.trim().length > 0 ? data.name.trim() : "";
|
|
9102
|
+
if (!name) {
|
|
9103
|
+
return null;
|
|
9104
|
+
}
|
|
9105
|
+
return `${name}|${data.version}|${serviceName}`;
|
|
9106
|
+
}
|
|
9019
9107
|
var GraphSyncController = class _GraphSyncController {
|
|
9020
9108
|
constructor() {
|
|
9021
9109
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
@@ -9140,22 +9228,158 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9140
9228
|
{},
|
|
9141
9229
|
{ concurrency: 10 }
|
|
9142
9230
|
);
|
|
9231
|
+
const finalizeTaskSync = (emit, ctx) => {
|
|
9232
|
+
const pendingTasks = getRegistrableTasks().filter((task) => !task.registered);
|
|
9233
|
+
if (pendingTasks.length > 0) {
|
|
9234
|
+
this.tasksSynced = false;
|
|
9235
|
+
return false;
|
|
9236
|
+
}
|
|
9237
|
+
const shouldEmit = !this.tasksSynced;
|
|
9238
|
+
this.tasksSynced = true;
|
|
9239
|
+
if (shouldEmit) {
|
|
9240
|
+
emit("meta.sync_controller.synced_tasks", {
|
|
9241
|
+
__syncing: true,
|
|
9242
|
+
...ctx
|
|
9243
|
+
});
|
|
9244
|
+
}
|
|
9245
|
+
return true;
|
|
9246
|
+
};
|
|
9247
|
+
const finalizeRoutineSync = (emit, ctx) => {
|
|
9248
|
+
const pendingRoutines = getRegistrableRoutines().filter(
|
|
9249
|
+
(routine) => !routine.registered
|
|
9250
|
+
);
|
|
9251
|
+
if (pendingRoutines.length > 0) {
|
|
9252
|
+
this.routinesSynced = false;
|
|
9253
|
+
return false;
|
|
9254
|
+
}
|
|
9255
|
+
const shouldEmit = !this.routinesSynced;
|
|
9256
|
+
this.routinesSynced = true;
|
|
9257
|
+
if (shouldEmit) {
|
|
9258
|
+
emit("meta.sync_controller.synced_routines", {
|
|
9259
|
+
__syncing: true,
|
|
9260
|
+
...ctx
|
|
9261
|
+
});
|
|
9262
|
+
}
|
|
9263
|
+
return true;
|
|
9264
|
+
};
|
|
9265
|
+
const finalizeSignalSync = (emit, ctx) => {
|
|
9266
|
+
const pendingSignals = getRegistrableSignalObservers().filter(
|
|
9267
|
+
(observer) => observer?.registered !== true
|
|
9268
|
+
);
|
|
9269
|
+
if (pendingSignals.length > 0) {
|
|
9270
|
+
this.signalsSynced = false;
|
|
9271
|
+
return false;
|
|
9272
|
+
}
|
|
9273
|
+
const shouldEmit = !this.signalsSynced;
|
|
9274
|
+
this.signalsSynced = true;
|
|
9275
|
+
if (shouldEmit) {
|
|
9276
|
+
emit("meta.sync_controller.synced_signals", {
|
|
9277
|
+
__syncing: true,
|
|
9278
|
+
...ctx
|
|
9279
|
+
});
|
|
9280
|
+
}
|
|
9281
|
+
return true;
|
|
9282
|
+
};
|
|
9283
|
+
const finalizeIntentSync = (emit, ctx) => {
|
|
9284
|
+
const pendingIntentNames = getRegistrableIntentNames().filter(
|
|
9285
|
+
(intentName) => !this.registeredIntentDefinitions.has(intentName)
|
|
9286
|
+
);
|
|
9287
|
+
if (pendingIntentNames.length > 0) {
|
|
9288
|
+
this.intentsSynced = false;
|
|
9289
|
+
return false;
|
|
9290
|
+
}
|
|
9291
|
+
const shouldEmit = !this.intentsSynced;
|
|
9292
|
+
this.intentsSynced = true;
|
|
9293
|
+
if (shouldEmit) {
|
|
9294
|
+
emit("meta.sync_controller.synced_intents", {
|
|
9295
|
+
__syncing: true,
|
|
9296
|
+
...ctx
|
|
9297
|
+
});
|
|
9298
|
+
}
|
|
9299
|
+
return true;
|
|
9300
|
+
};
|
|
9301
|
+
const finalizeActorSync = (emit, ctx) => {
|
|
9302
|
+
const syncServiceName = resolveSyncServiceName();
|
|
9303
|
+
if (!syncServiceName) {
|
|
9304
|
+
this.actorsSynced = false;
|
|
9305
|
+
return false;
|
|
9306
|
+
}
|
|
9307
|
+
const pendingActorKeys = CadenzaService.getAllActors().map((actor) => buildActorRegistrationKey(actor, syncServiceName)).filter((registrationKey) => Boolean(registrationKey)).filter((registrationKey) => !this.registeredActors.has(registrationKey));
|
|
9308
|
+
if (pendingActorKeys.length > 0) {
|
|
9309
|
+
this.actorsSynced = false;
|
|
9310
|
+
return false;
|
|
9311
|
+
}
|
|
9312
|
+
const shouldEmit = !this.actorsSynced;
|
|
9313
|
+
this.actorsSynced = true;
|
|
9314
|
+
if (shouldEmit) {
|
|
9315
|
+
emit("meta.sync_controller.synced_actors", {
|
|
9316
|
+
__syncing: true,
|
|
9317
|
+
...ctx
|
|
9318
|
+
});
|
|
9319
|
+
}
|
|
9320
|
+
return true;
|
|
9321
|
+
};
|
|
9322
|
+
const gatherTaskRegistrationTask = CadenzaService.createUniqueMetaTask(
|
|
9323
|
+
"Gather task registration",
|
|
9324
|
+
(ctx, emit) => finalizeTaskSync(emit, ctx),
|
|
9325
|
+
"Completes task registration when all registrable tasks are marked registered.",
|
|
9326
|
+
{
|
|
9327
|
+
register: false,
|
|
9328
|
+
isHidden: true
|
|
9329
|
+
}
|
|
9330
|
+
);
|
|
9331
|
+
const gatherRoutineRegistrationTask = CadenzaService.createUniqueMetaTask(
|
|
9332
|
+
"Gather routine registration",
|
|
9333
|
+
(ctx, emit) => finalizeRoutineSync(emit, ctx),
|
|
9334
|
+
"Completes routine registration when all registrable routines are marked registered.",
|
|
9335
|
+
{
|
|
9336
|
+
register: false,
|
|
9337
|
+
isHidden: true
|
|
9338
|
+
}
|
|
9339
|
+
);
|
|
9340
|
+
const gatherSignalRegistrationTask = CadenzaService.createUniqueMetaTask(
|
|
9341
|
+
"Gather signal registration",
|
|
9342
|
+
(ctx, emit) => finalizeSignalSync(emit, ctx),
|
|
9343
|
+
"Completes signal registration when all signal observers are marked registered.",
|
|
9344
|
+
{
|
|
9345
|
+
register: false,
|
|
9346
|
+
isHidden: true
|
|
9347
|
+
}
|
|
9348
|
+
);
|
|
9349
|
+
const gatherIntentRegistrationTask = CadenzaService.createUniqueMetaTask(
|
|
9350
|
+
"Gather intent registration",
|
|
9351
|
+
(ctx, emit) => finalizeIntentSync(emit, ctx),
|
|
9352
|
+
"Completes intent registration when all registrable intents are marked registered.",
|
|
9353
|
+
{
|
|
9354
|
+
register: false,
|
|
9355
|
+
isHidden: true
|
|
9356
|
+
}
|
|
9357
|
+
);
|
|
9358
|
+
const gatherActorRegistrationTask = CadenzaService.createUniqueMetaTask(
|
|
9359
|
+
"Gather actor registration",
|
|
9360
|
+
(ctx, emit) => finalizeActorSync(emit, ctx),
|
|
9361
|
+
"Completes actor registration when all registrable actors are marked registered.",
|
|
9362
|
+
{
|
|
9363
|
+
register: false,
|
|
9364
|
+
isHidden: true
|
|
9365
|
+
}
|
|
9366
|
+
);
|
|
9143
9367
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
9144
9368
|
"Split routines for registration",
|
|
9145
|
-
(ctx
|
|
9369
|
+
function* (ctx) {
|
|
9146
9370
|
const { routines } = ctx;
|
|
9147
|
-
if (!routines) return
|
|
9371
|
+
if (!routines) return;
|
|
9148
9372
|
const serviceName2 = resolveSyncServiceName();
|
|
9149
9373
|
if (!serviceName2) {
|
|
9150
|
-
return
|
|
9374
|
+
return;
|
|
9151
9375
|
}
|
|
9152
9376
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9153
9377
|
delayMs: 2e3
|
|
9154
9378
|
});
|
|
9155
|
-
let emittedCount = 0;
|
|
9156
9379
|
for (const routine of routines) {
|
|
9157
9380
|
if (routine.registered) continue;
|
|
9158
|
-
|
|
9381
|
+
this.routinesSynced = false;
|
|
9382
|
+
yield {
|
|
9159
9383
|
__syncing: ctx.__syncing,
|
|
9160
9384
|
data: {
|
|
9161
9385
|
name: routine.name,
|
|
@@ -9165,13 +9389,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9165
9389
|
isMeta: routine.isMeta
|
|
9166
9390
|
},
|
|
9167
9391
|
__routineName: routine.name
|
|
9168
|
-
}
|
|
9169
|
-
emittedCount += 1;
|
|
9392
|
+
};
|
|
9170
9393
|
}
|
|
9171
|
-
|
|
9172
|
-
}
|
|
9394
|
+
}.bind(this)
|
|
9173
9395
|
);
|
|
9174
|
-
|
|
9396
|
+
this.splitRoutinesTask.then(
|
|
9175
9397
|
resolveSyncInsertTask(
|
|
9176
9398
|
this.isCadenzaDBReady,
|
|
9177
9399
|
"routine",
|
|
@@ -9193,22 +9415,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9193
9415
|
delayMs: 3e3
|
|
9194
9416
|
});
|
|
9195
9417
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
9196
|
-
CadenzaService.debounce(
|
|
9197
|
-
"meta.sync_controller.routine_registration_settled",
|
|
9198
|
-
{ __syncing: true },
|
|
9199
|
-
300
|
|
9200
|
-
);
|
|
9201
9418
|
return true;
|
|
9202
|
-
})
|
|
9419
|
+
}).then(gatherRoutineRegistrationTask)
|
|
9203
9420
|
)
|
|
9204
9421
|
);
|
|
9205
|
-
CadenzaService.createUniqueMetaTask(
|
|
9206
|
-
"Gather routine registration",
|
|
9207
|
-
() => {
|
|
9208
|
-
this.routinesSynced = true;
|
|
9209
|
-
return true;
|
|
9210
|
-
}
|
|
9211
|
-
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
9212
9422
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
9213
9423
|
"Split tasks in routines",
|
|
9214
9424
|
function* (ctx) {
|
|
@@ -9297,18 +9507,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9297
9507
|
}
|
|
9298
9508
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
9299
9509
|
"Split signals for registration",
|
|
9300
|
-
(ctx
|
|
9510
|
+
function* (ctx) {
|
|
9301
9511
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9302
9512
|
delayMs: 3e3
|
|
9303
9513
|
});
|
|
9304
9514
|
const { signals } = ctx;
|
|
9305
|
-
if (!signals) return
|
|
9515
|
+
if (!signals) return;
|
|
9306
9516
|
const filteredSignals = signals.filter(
|
|
9307
9517
|
(signal) => !signal.data.registered
|
|
9308
9518
|
).map((signal) => signal.signal);
|
|
9309
9519
|
for (const signal of filteredSignals) {
|
|
9310
9520
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
9311
|
-
|
|
9521
|
+
this.signalsSynced = false;
|
|
9522
|
+
yield {
|
|
9312
9523
|
__syncing: ctx.__syncing,
|
|
9313
9524
|
data: {
|
|
9314
9525
|
name: signal,
|
|
@@ -9318,12 +9529,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9318
9529
|
isMeta
|
|
9319
9530
|
},
|
|
9320
9531
|
__signal: signal
|
|
9321
|
-
}
|
|
9532
|
+
};
|
|
9322
9533
|
}
|
|
9323
|
-
|
|
9324
|
-
}
|
|
9534
|
+
}.bind(this)
|
|
9325
9535
|
);
|
|
9326
|
-
|
|
9536
|
+
this.splitSignalsTask.then(
|
|
9327
9537
|
resolveSyncInsertTask(
|
|
9328
9538
|
this.isCadenzaDBReady,
|
|
9329
9539
|
"signal_registry",
|
|
@@ -9344,22 +9554,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9344
9554
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9345
9555
|
delayMs: 3e3
|
|
9346
9556
|
});
|
|
9347
|
-
CadenzaService.debounce(
|
|
9348
|
-
"meta.sync_controller.signal_registration_settled",
|
|
9349
|
-
{ __syncing: true },
|
|
9350
|
-
300
|
|
9351
|
-
);
|
|
9352
9557
|
return { signalName: ctx.__signal };
|
|
9353
|
-
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
9558
|
+
}).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask)
|
|
9354
9559
|
)
|
|
9355
9560
|
);
|
|
9356
|
-
CadenzaService.createUniqueMetaTask(
|
|
9357
|
-
"Gather signal registration",
|
|
9358
|
-
() => {
|
|
9359
|
-
this.signalsSynced = true;
|
|
9360
|
-
return true;
|
|
9361
|
-
}
|
|
9362
|
-
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
9363
9561
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
9364
9562
|
"Split tasks for registration",
|
|
9365
9563
|
function* (ctx) {
|
|
@@ -9374,6 +9572,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9374
9572
|
for (const task of tasks) {
|
|
9375
9573
|
if (task.registered) continue;
|
|
9376
9574
|
const { __functionString, __getTagCallback } = task.export();
|
|
9575
|
+
this.tasksSynced = false;
|
|
9377
9576
|
if (shouldDebugSyncTaskName(task.name)) {
|
|
9378
9577
|
logSyncDebug("task_registration_split", {
|
|
9379
9578
|
taskName: task.name,
|
|
@@ -9382,6 +9581,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9382
9581
|
register: task.register,
|
|
9383
9582
|
registered: task.registered,
|
|
9384
9583
|
hidden: task.hidden,
|
|
9584
|
+
exportFunctionLength: __functionString?.length ?? null,
|
|
9585
|
+
exportTagGetterLength: __getTagCallback?.length ?? null,
|
|
9385
9586
|
observedSignals: Array.from(task.observedSignals),
|
|
9386
9587
|
handledIntents: Array.from(task.handlesIntents)
|
|
9387
9588
|
});
|
|
@@ -9422,7 +9623,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9422
9623
|
__taskName: task.name
|
|
9423
9624
|
};
|
|
9424
9625
|
}
|
|
9425
|
-
}
|
|
9626
|
+
}.bind(this)
|
|
9426
9627
|
);
|
|
9427
9628
|
const registerTaskTask = resolveSyncInsertTask(
|
|
9428
9629
|
this.isCadenzaDBReady,
|
|
@@ -9456,13 +9657,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9456
9657
|
...ctx,
|
|
9457
9658
|
task: CadenzaService.get(ctx.__taskName)
|
|
9458
9659
|
});
|
|
9459
|
-
CadenzaService.debounce(
|
|
9460
|
-
"meta.sync_controller.task_registration_settled",
|
|
9461
|
-
{ __syncing: true },
|
|
9462
|
-
300
|
|
9463
|
-
);
|
|
9464
9660
|
return true;
|
|
9465
|
-
})
|
|
9661
|
+
}).then(gatherTaskRegistrationTask)
|
|
9466
9662
|
);
|
|
9467
9663
|
if (registerTaskTask) {
|
|
9468
9664
|
this.splitTasksForRegistration.then(registerTaskTask);
|
|
@@ -9495,13 +9691,6 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9495
9691
|
isHidden: true
|
|
9496
9692
|
}
|
|
9497
9693
|
).doOn("meta.task.created").then(this.splitTasksForRegistration);
|
|
9498
|
-
CadenzaService.createUniqueMetaTask(
|
|
9499
|
-
"Gather task registration",
|
|
9500
|
-
() => {
|
|
9501
|
-
this.tasksSynced = true;
|
|
9502
|
-
return true;
|
|
9503
|
-
}
|
|
9504
|
-
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
9505
9694
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
9506
9695
|
"Split actors for registration",
|
|
9507
9696
|
function* (ctx) {
|
|
@@ -9525,6 +9714,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9525
9714
|
if (this.registeredActors.has(registrationKey)) {
|
|
9526
9715
|
continue;
|
|
9527
9716
|
}
|
|
9717
|
+
this.actorsSynced = false;
|
|
9528
9718
|
yield {
|
|
9529
9719
|
data,
|
|
9530
9720
|
__actorRegistrationKey: registrationKey
|
|
@@ -9553,22 +9743,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9553
9743
|
delayMs: 3e3
|
|
9554
9744
|
});
|
|
9555
9745
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
9556
|
-
CadenzaService.debounce(
|
|
9557
|
-
"meta.sync_controller.actor_registration_settled",
|
|
9558
|
-
{ __syncing: true },
|
|
9559
|
-
300
|
|
9560
|
-
);
|
|
9561
9746
|
return true;
|
|
9562
|
-
})
|
|
9747
|
+
}).then(gatherActorRegistrationTask)
|
|
9563
9748
|
)
|
|
9564
9749
|
);
|
|
9565
|
-
CadenzaService.createUniqueMetaTask(
|
|
9566
|
-
"Gather actor registration",
|
|
9567
|
-
() => {
|
|
9568
|
-
this.actorsSynced = true;
|
|
9569
|
-
return true;
|
|
9570
|
-
}
|
|
9571
|
-
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
9572
9750
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
9573
9751
|
"Split actor task maps",
|
|
9574
9752
|
function* (ctx) {
|
|
@@ -9715,12 +9893,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9715
9893
|
);
|
|
9716
9894
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
9717
9895
|
"Split intents for registration",
|
|
9718
|
-
function(ctx
|
|
9896
|
+
function* (ctx) {
|
|
9719
9897
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9720
9898
|
delayMs: 3e3
|
|
9721
9899
|
});
|
|
9722
9900
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
9723
|
-
let emittedCount = 0;
|
|
9724
9901
|
for (const intent of intents) {
|
|
9725
9902
|
const intentData = buildIntentRegistryData(intent);
|
|
9726
9903
|
if (!intentData) {
|
|
@@ -9729,17 +9906,16 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9729
9906
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
9730
9907
|
continue;
|
|
9731
9908
|
}
|
|
9732
|
-
|
|
9909
|
+
this.intentsSynced = false;
|
|
9910
|
+
yield {
|
|
9733
9911
|
__syncing: ctx.__syncing,
|
|
9734
9912
|
data: intentData,
|
|
9735
9913
|
__intentName: intentData.name
|
|
9736
|
-
}
|
|
9737
|
-
emittedCount += 1;
|
|
9914
|
+
};
|
|
9738
9915
|
}
|
|
9739
|
-
return emittedCount > 0;
|
|
9740
9916
|
}.bind(this)
|
|
9741
9917
|
);
|
|
9742
|
-
|
|
9918
|
+
this.splitIntentsTask.then(
|
|
9743
9919
|
insertIntentRegistryTask?.then(
|
|
9744
9920
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
9745
9921
|
if (!didSyncInsertSucceed(ctx)) {
|
|
@@ -9749,22 +9925,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9749
9925
|
delayMs: 3e3
|
|
9750
9926
|
});
|
|
9751
9927
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9752
|
-
CadenzaService.debounce(
|
|
9753
|
-
"meta.sync_controller.intent_registration_settled",
|
|
9754
|
-
{ __syncing: true },
|
|
9755
|
-
300
|
|
9756
|
-
);
|
|
9757
9928
|
return true;
|
|
9758
|
-
})
|
|
9929
|
+
}).then(gatherIntentRegistrationTask)
|
|
9759
9930
|
)
|
|
9760
9931
|
);
|
|
9761
|
-
CadenzaService.createUniqueMetaTask(
|
|
9762
|
-
"Gather intent registration",
|
|
9763
|
-
() => {
|
|
9764
|
-
this.intentsSynced = true;
|
|
9765
|
-
return true;
|
|
9766
|
-
}
|
|
9767
|
-
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
9768
9932
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
9769
9933
|
"Record intent registration",
|
|
9770
9934
|
(ctx) => {
|
|
@@ -10058,15 +10222,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10058
10222
|
__authoritativeReconciliation: true
|
|
10059
10223
|
});
|
|
10060
10224
|
}
|
|
10061
|
-
if (authoritativeTasks.length > 0) {
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
__authoritativeReconciliation: true
|
|
10067
|
-
},
|
|
10068
|
-
300
|
|
10069
|
-
);
|
|
10225
|
+
if (authoritativeTasks.length > 0 || changed) {
|
|
10226
|
+
finalizeTaskSync(emit, {
|
|
10227
|
+
...ctx,
|
|
10228
|
+
__authoritativeReconciliation: true
|
|
10229
|
+
});
|
|
10070
10230
|
}
|
|
10071
10231
|
return changed;
|
|
10072
10232
|
},
|
|
@@ -10078,7 +10238,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10078
10238
|
);
|
|
10079
10239
|
const reconcileRoutineRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
10080
10240
|
"Reconcile routine registration from authority",
|
|
10081
|
-
(ctx) => {
|
|
10241
|
+
(ctx, emit) => {
|
|
10082
10242
|
const authoritativeRoutines = resolveSyncQueryRows(ctx, "routine");
|
|
10083
10243
|
let changed = false;
|
|
10084
10244
|
for (const row of authoritativeRoutines) {
|
|
@@ -10093,15 +10253,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10093
10253
|
routine.registered = true;
|
|
10094
10254
|
changed = true;
|
|
10095
10255
|
}
|
|
10096
|
-
if (authoritativeRoutines.length > 0) {
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
__authoritativeReconciliation: true
|
|
10102
|
-
},
|
|
10103
|
-
300
|
|
10104
|
-
);
|
|
10256
|
+
if (authoritativeRoutines.length > 0 || changed) {
|
|
10257
|
+
finalizeRoutineSync(emit, {
|
|
10258
|
+
...ctx,
|
|
10259
|
+
__authoritativeReconciliation: true
|
|
10260
|
+
});
|
|
10105
10261
|
}
|
|
10106
10262
|
return changed;
|
|
10107
10263
|
},
|
|
@@ -10113,7 +10269,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10113
10269
|
);
|
|
10114
10270
|
const reconcileSignalRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
10115
10271
|
"Reconcile signal registration from authority",
|
|
10116
|
-
(ctx) => {
|
|
10272
|
+
(ctx, emit) => {
|
|
10117
10273
|
const authoritativeSignals = resolveSyncQueryRows(ctx, "signal_registry");
|
|
10118
10274
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
10119
10275
|
let changed = false;
|
|
@@ -10129,15 +10285,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10129
10285
|
observer.registered = true;
|
|
10130
10286
|
changed = true;
|
|
10131
10287
|
}
|
|
10132
|
-
if (authoritativeSignals.length > 0) {
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
__authoritativeReconciliation: true
|
|
10138
|
-
},
|
|
10139
|
-
300
|
|
10140
|
-
);
|
|
10288
|
+
if (authoritativeSignals.length > 0 || changed) {
|
|
10289
|
+
finalizeSignalSync(emit, {
|
|
10290
|
+
...ctx,
|
|
10291
|
+
__authoritativeReconciliation: true
|
|
10292
|
+
});
|
|
10141
10293
|
}
|
|
10142
10294
|
return changed;
|
|
10143
10295
|
},
|
|
@@ -10149,7 +10301,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10149
10301
|
);
|
|
10150
10302
|
const reconcileIntentRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
10151
10303
|
"Reconcile intent registration from authority",
|
|
10152
|
-
(ctx) => {
|
|
10304
|
+
(ctx, emit) => {
|
|
10153
10305
|
const authoritativeIntents = resolveSyncQueryRows(ctx, "intent_registry");
|
|
10154
10306
|
let changed = false;
|
|
10155
10307
|
for (const row of authoritativeIntents) {
|
|
@@ -10163,15 +10315,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10163
10315
|
this.registeredIntentDefinitions.add(intentName);
|
|
10164
10316
|
changed = true;
|
|
10165
10317
|
}
|
|
10166
|
-
if (authoritativeIntents.length > 0) {
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
__authoritativeReconciliation: true
|
|
10172
|
-
},
|
|
10173
|
-
300
|
|
10174
|
-
);
|
|
10318
|
+
if (authoritativeIntents.length > 0 || changed) {
|
|
10319
|
+
finalizeIntentSync(emit, {
|
|
10320
|
+
...ctx,
|
|
10321
|
+
__authoritativeReconciliation: true
|
|
10322
|
+
});
|
|
10175
10323
|
}
|
|
10176
10324
|
return changed;
|
|
10177
10325
|
},
|