@cadenza.io/service 2.17.23 → 2.17.25
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 +473 -181
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +473 -181
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +476 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +476 -181
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -737,6 +737,72 @@ var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
737
737
|
"Collect distributed readiness",
|
|
738
738
|
"Get status"
|
|
739
739
|
]);
|
|
740
|
+
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
741
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
742
|
+
const getJoinedValue = (key) => {
|
|
743
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
744
|
+
const joinedContext = joinedContexts[index];
|
|
745
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
746
|
+
return joinedContext[key];
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return void 0;
|
|
750
|
+
};
|
|
751
|
+
const registrationData = Object.prototype.hasOwnProperty.call(ctx, "__registrationData") && ctx.__registrationData !== void 0 ? ctx.__registrationData : getJoinedValue("__registrationData");
|
|
752
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
753
|
+
const nextQueryData = {
|
|
754
|
+
...existingQueryData,
|
|
755
|
+
...queryData
|
|
756
|
+
};
|
|
757
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
758
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
759
|
+
if (!("data" in nextQueryData) && (resolvedData !== void 0 || registrationData !== void 0)) {
|
|
760
|
+
nextQueryData.data = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
761
|
+
}
|
|
762
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
763
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
764
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
765
|
+
) : resolvedBatch;
|
|
766
|
+
}
|
|
767
|
+
return nextQueryData;
|
|
768
|
+
}
|
|
769
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
770
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
771
|
+
tableName,
|
|
772
|
+
queryData,
|
|
773
|
+
options
|
|
774
|
+
);
|
|
775
|
+
return CadenzaService.createUniqueMetaTask(
|
|
776
|
+
`Resolve service registry insert for ${tableName}`,
|
|
777
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
778
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
779
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
780
|
+
CadenzaService.log(
|
|
781
|
+
"Service registry insert resolver missing service payload.",
|
|
782
|
+
{
|
|
783
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
784
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
785
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
786
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
787
|
+
},
|
|
788
|
+
"warning"
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
792
|
+
return targetTask.taskFunction(
|
|
793
|
+
{
|
|
794
|
+
...ctx,
|
|
795
|
+
queryData: nextQueryData
|
|
796
|
+
},
|
|
797
|
+
emit,
|
|
798
|
+
inquire,
|
|
799
|
+
progressCallback
|
|
800
|
+
);
|
|
801
|
+
},
|
|
802
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
803
|
+
options
|
|
804
|
+
);
|
|
805
|
+
}
|
|
740
806
|
function readPositiveIntegerEnv(name, fallback) {
|
|
741
807
|
if (typeof process === "undefined") {
|
|
742
808
|
return fallback;
|
|
@@ -1947,7 +2013,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2013
|
},
|
|
1948
2014
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1949
2015
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1950
|
-
this.insertServiceTask =
|
|
2016
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1951
2017
|
"service",
|
|
1952
2018
|
{
|
|
1953
2019
|
onConflict: {
|
|
@@ -1998,7 +2064,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1998
2064
|
retryDelayFactor: 1.3
|
|
1999
2065
|
}
|
|
2000
2066
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
2001
|
-
this.insertServiceInstanceTask =
|
|
2067
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
2002
2068
|
"service_instance",
|
|
2003
2069
|
{},
|
|
2004
2070
|
{
|
|
@@ -2056,7 +2122,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2056
2122
|
retryCount: 5,
|
|
2057
2123
|
retryDelay: 1e3
|
|
2058
2124
|
}
|
|
2059
|
-
).
|
|
2125
|
+
).then(
|
|
2060
2126
|
CadenzaService.createMetaTask(
|
|
2061
2127
|
"Setup service",
|
|
2062
2128
|
(ctx) => {
|
|
@@ -2083,8 +2149,17 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2083
2149
|
this.useSocket = __useSocket;
|
|
2084
2150
|
this.retryCount = __retryCount;
|
|
2085
2151
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2086
|
-
|
|
2087
|
-
|
|
2152
|
+
return {
|
|
2153
|
+
...ctx,
|
|
2154
|
+
serviceInstance: normalizedLocalInstance,
|
|
2155
|
+
data: {
|
|
2156
|
+
...ctx.data ?? {},
|
|
2157
|
+
uuid: normalizedLocalInstance.uuid,
|
|
2158
|
+
service_name: normalizedLocalInstance.serviceName
|
|
2159
|
+
},
|
|
2160
|
+
__serviceName: normalizedLocalInstance.serviceName,
|
|
2161
|
+
__serviceInstanceId: normalizedLocalInstance.uuid
|
|
2162
|
+
};
|
|
2088
2163
|
},
|
|
2089
2164
|
"Sets service instance id after insertion"
|
|
2090
2165
|
).emits("meta.service_registry.instance_inserted").then(
|
|
@@ -2098,6 +2173,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2098
2173
|
data: {
|
|
2099
2174
|
...transport,
|
|
2100
2175
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2176
|
+
},
|
|
2177
|
+
__registrationData: {
|
|
2178
|
+
...transport,
|
|
2179
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2101
2180
|
}
|
|
2102
2181
|
};
|
|
2103
2182
|
emit(
|
|
@@ -2111,7 +2190,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2111
2190
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2112
2191
|
)
|
|
2113
2192
|
);
|
|
2114
|
-
|
|
2193
|
+
CadenzaService.createMetaTask(
|
|
2194
|
+
"Prepare service instance registration",
|
|
2195
|
+
(ctx) => {
|
|
2196
|
+
const serviceName = String(
|
|
2197
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2198
|
+
).trim();
|
|
2199
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2200
|
+
CadenzaService.schedule(
|
|
2201
|
+
"meta.service_registry.instance_registration_requested",
|
|
2202
|
+
{ ...ctx },
|
|
2203
|
+
250
|
|
2204
|
+
);
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
return ctx;
|
|
2208
|
+
},
|
|
2209
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2210
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2211
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2115
2212
|
"service_instance_transport",
|
|
2116
2213
|
{
|
|
2117
2214
|
onConflict: {
|
|
@@ -2176,7 +2273,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2176
2273
|
retryCount: 5,
|
|
2177
2274
|
retryDelay: 1e3
|
|
2178
2275
|
}
|
|
2179
|
-
).
|
|
2276
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2277
|
+
CadenzaService.createMetaTask(
|
|
2278
|
+
"Prepare service transport registration",
|
|
2279
|
+
(ctx) => {
|
|
2280
|
+
const serviceName = String(
|
|
2281
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2282
|
+
).trim();
|
|
2283
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2284
|
+
CadenzaService.schedule(
|
|
2285
|
+
"meta.service_registry.transport_registration_requested",
|
|
2286
|
+
{ ...ctx },
|
|
2287
|
+
250
|
|
2288
|
+
);
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
return ctx;
|
|
2292
|
+
},
|
|
2293
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2294
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2180
2295
|
CadenzaService.createMetaTask(
|
|
2181
2296
|
"Handle service creation",
|
|
2182
2297
|
(ctx) => {
|
|
@@ -3446,6 +3561,16 @@ var RestController = class _RestController {
|
|
|
3446
3561
|
is_blocked: false,
|
|
3447
3562
|
health: {}
|
|
3448
3563
|
},
|
|
3564
|
+
__registrationData: {
|
|
3565
|
+
uuid: ctx.__serviceInstanceId,
|
|
3566
|
+
process_pid: 1,
|
|
3567
|
+
service_name: ctx.__serviceName,
|
|
3568
|
+
is_frontend: true,
|
|
3569
|
+
is_active: true,
|
|
3570
|
+
is_non_responsive: false,
|
|
3571
|
+
is_blocked: false,
|
|
3572
|
+
health: {}
|
|
3573
|
+
},
|
|
3449
3574
|
__transportData: [],
|
|
3450
3575
|
...ctx
|
|
3451
3576
|
});
|
|
@@ -3745,6 +3870,9 @@ var RestController = class _RestController {
|
|
|
3745
3870
|
is_blocked: false,
|
|
3746
3871
|
health: {}
|
|
3747
3872
|
};
|
|
3873
|
+
ctx.__registrationData = {
|
|
3874
|
+
...ctx.data
|
|
3875
|
+
};
|
|
3748
3876
|
ctx.__transportData = transportData;
|
|
3749
3877
|
delete ctx.__app;
|
|
3750
3878
|
CadenzaService.emit(
|
|
@@ -8153,12 +8281,6 @@ var import_uuid5 = require("uuid");
|
|
|
8153
8281
|
|
|
8154
8282
|
// src/graph/controllers/GraphSyncController.ts
|
|
8155
8283
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8156
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
8157
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
8158
|
-
);
|
|
8159
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
8160
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
8161
|
-
);
|
|
8162
8284
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8163
8285
|
if (typeof taskFunction !== "function") {
|
|
8164
8286
|
return void 0;
|
|
@@ -8235,38 +8357,71 @@ function buildIntentRegistryData(intent) {
|
|
|
8235
8357
|
isMeta: isMetaIntentName(name)
|
|
8236
8358
|
};
|
|
8237
8359
|
}
|
|
8360
|
+
function getJoinedContextValue(ctx, key) {
|
|
8361
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
8362
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
8363
|
+
const joinedContext = joinedContexts[index];
|
|
8364
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
8365
|
+
return joinedContext[key];
|
|
8366
|
+
}
|
|
8367
|
+
}
|
|
8368
|
+
return void 0;
|
|
8369
|
+
}
|
|
8370
|
+
function didSyncInsertSucceed(ctx) {
|
|
8371
|
+
return !ctx.errored && ctx.__success !== false;
|
|
8372
|
+
}
|
|
8373
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
8374
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
8375
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
8376
|
+
const nextQueryData = {
|
|
8377
|
+
...existingQueryData,
|
|
8378
|
+
...queryData
|
|
8379
|
+
};
|
|
8380
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
8381
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
8382
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
8383
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
8384
|
+
}
|
|
8385
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
8386
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
8387
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
8388
|
+
) : resolvedBatch;
|
|
8389
|
+
}
|
|
8390
|
+
return nextQueryData;
|
|
8391
|
+
}
|
|
8238
8392
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8239
8393
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
}
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8394
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8395
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
8396
|
+
return void 0;
|
|
8397
|
+
}
|
|
8398
|
+
return CadenzaService.createUniqueMetaTask(
|
|
8399
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
8400
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
8401
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
8402
|
+
if (!targetTask) {
|
|
8403
|
+
return false;
|
|
8404
|
+
}
|
|
8405
|
+
return targetTask.taskFunction(
|
|
8406
|
+
{
|
|
8252
8407
|
...ctx,
|
|
8253
|
-
queryData:
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8408
|
+
queryData: buildSyncInsertQueryData(
|
|
8409
|
+
ctx,
|
|
8410
|
+
queryData
|
|
8411
|
+
)
|
|
8412
|
+
},
|
|
8413
|
+
emit,
|
|
8414
|
+
inquire,
|
|
8415
|
+
progressCallback
|
|
8416
|
+
);
|
|
8417
|
+
},
|
|
8418
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8419
|
+
{
|
|
8420
|
+
...options,
|
|
8421
|
+
register: false,
|
|
8422
|
+
isHidden: true
|
|
8266
8423
|
}
|
|
8267
|
-
|
|
8268
|
-
}
|
|
8269
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8424
|
+
);
|
|
8270
8425
|
}
|
|
8271
8426
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
8272
8427
|
"intent_registry",
|
|
@@ -8285,11 +8440,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8285
8440
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
8286
8441
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
8287
8442
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
8288
|
-
this.
|
|
8443
|
+
this.tasksSynced = false;
|
|
8444
|
+
this.signalsSynced = false;
|
|
8445
|
+
this.intentsSynced = false;
|
|
8446
|
+
this.routinesSynced = false;
|
|
8289
8447
|
this.isCadenzaDBReady = false;
|
|
8290
8448
|
this.initialized = false;
|
|
8291
8449
|
this.initRetryScheduled = false;
|
|
8292
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
8293
8450
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
8294
8451
|
}
|
|
8295
8452
|
static get instance() {
|
|
@@ -8364,21 +8521,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8364
8521
|
},
|
|
8365
8522
|
{ concurrency: 30 }
|
|
8366
8523
|
);
|
|
8524
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
8525
|
+
this.isCadenzaDBReady,
|
|
8526
|
+
"intent_registry",
|
|
8527
|
+
{
|
|
8528
|
+
onConflict: {
|
|
8529
|
+
target: ["name"],
|
|
8530
|
+
action: {
|
|
8531
|
+
do: "nothing"
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
},
|
|
8535
|
+
{ concurrency: 30 }
|
|
8536
|
+
);
|
|
8367
8537
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
8368
8538
|
"Split routines for registration",
|
|
8369
|
-
|
|
8539
|
+
(ctx, emit) => {
|
|
8370
8540
|
const { routines } = ctx;
|
|
8371
|
-
if (!routines) return;
|
|
8541
|
+
if (!routines) return false;
|
|
8372
8542
|
const serviceName2 = resolveSyncServiceName();
|
|
8373
8543
|
if (!serviceName2) {
|
|
8374
|
-
return;
|
|
8544
|
+
return false;
|
|
8375
8545
|
}
|
|
8376
8546
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8377
8547
|
delayMs: 2e3
|
|
8378
8548
|
});
|
|
8549
|
+
let emittedCount = 0;
|
|
8379
8550
|
for (const routine of routines) {
|
|
8380
8551
|
if (routine.registered) continue;
|
|
8381
|
-
|
|
8552
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
8553
|
+
__syncing: ctx.__syncing,
|
|
8382
8554
|
data: {
|
|
8383
8555
|
name: routine.name,
|
|
8384
8556
|
version: routine.version,
|
|
@@ -8387,10 +8559,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8387
8559
|
isMeta: routine.isMeta
|
|
8388
8560
|
},
|
|
8389
8561
|
__routineName: routine.name
|
|
8390
|
-
};
|
|
8562
|
+
});
|
|
8563
|
+
emittedCount += 1;
|
|
8391
8564
|
}
|
|
8565
|
+
return emittedCount > 0;
|
|
8392
8566
|
}
|
|
8393
|
-
)
|
|
8567
|
+
);
|
|
8568
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
8394
8569
|
resolveSyncInsertTask(
|
|
8395
8570
|
this.isCadenzaDBReady,
|
|
8396
8571
|
"routine",
|
|
@@ -8405,39 +8580,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8405
8580
|
{ concurrency: 30 }
|
|
8406
8581
|
)?.then(
|
|
8407
8582
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
8408
|
-
if (!ctx.__syncing) {
|
|
8583
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8409
8584
|
return;
|
|
8410
8585
|
}
|
|
8411
8586
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8412
8587
|
delayMs: 3e3
|
|
8413
8588
|
});
|
|
8414
8589
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
8590
|
+
CadenzaService.debounce(
|
|
8591
|
+
"meta.sync_controller.routine_registration_settled",
|
|
8592
|
+
{ __syncing: true },
|
|
8593
|
+
300
|
|
8594
|
+
);
|
|
8415
8595
|
return true;
|
|
8416
|
-
})
|
|
8417
|
-
CadenzaService.createUniqueMetaTask(
|
|
8418
|
-
"Gather routine registration",
|
|
8419
|
-
() => true
|
|
8420
|
-
).emits("meta.sync_controller.synced_routines")
|
|
8421
|
-
)
|
|
8596
|
+
})
|
|
8422
8597
|
)
|
|
8423
8598
|
);
|
|
8599
|
+
CadenzaService.createUniqueMetaTask(
|
|
8600
|
+
"Gather routine registration",
|
|
8601
|
+
() => {
|
|
8602
|
+
this.routinesSynced = true;
|
|
8603
|
+
return true;
|
|
8604
|
+
}
|
|
8605
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
8424
8606
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
8425
8607
|
"Split tasks in routines",
|
|
8426
|
-
|
|
8608
|
+
(ctx, emit) => {
|
|
8427
8609
|
const { routines } = ctx;
|
|
8428
|
-
if (!routines) return;
|
|
8610
|
+
if (!routines) return false;
|
|
8429
8611
|
const serviceName2 = resolveSyncServiceName();
|
|
8430
8612
|
if (!serviceName2) {
|
|
8431
|
-
return;
|
|
8613
|
+
return false;
|
|
8432
8614
|
}
|
|
8433
8615
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8434
8616
|
delayMs: 3e3
|
|
8435
8617
|
});
|
|
8618
|
+
let emittedCount = 0;
|
|
8436
8619
|
for (const routine of routines) {
|
|
8437
8620
|
if (!routine.registered) continue;
|
|
8438
8621
|
for (const task of routine.tasks) {
|
|
8439
8622
|
if (!task) {
|
|
8440
|
-
console.log("task is null", routine, task);
|
|
8441
8623
|
continue;
|
|
8442
8624
|
}
|
|
8443
8625
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -8447,7 +8629,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8447
8629
|
if (!nextTask?.registered) {
|
|
8448
8630
|
continue;
|
|
8449
8631
|
}
|
|
8450
|
-
|
|
8632
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
8633
|
+
__syncing: ctx.__syncing,
|
|
8451
8634
|
data: {
|
|
8452
8635
|
taskName: nextTask.name,
|
|
8453
8636
|
taskVersion: nextTask.version,
|
|
@@ -8457,12 +8640,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8457
8640
|
},
|
|
8458
8641
|
__routineName: routine.name,
|
|
8459
8642
|
__taskName: nextTask.name
|
|
8460
|
-
};
|
|
8643
|
+
});
|
|
8644
|
+
emittedCount += 1;
|
|
8461
8645
|
}
|
|
8462
8646
|
}
|
|
8463
8647
|
}
|
|
8648
|
+
return emittedCount > 0;
|
|
8464
8649
|
}
|
|
8465
|
-
)
|
|
8650
|
+
);
|
|
8651
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
8466
8652
|
resolveSyncInsertTask(
|
|
8467
8653
|
this.isCadenzaDBReady,
|
|
8468
8654
|
"task_to_routine_map",
|
|
@@ -8483,7 +8669,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8483
8669
|
{ concurrency: 30 }
|
|
8484
8670
|
)?.then(
|
|
8485
8671
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
8486
|
-
if (!ctx.__syncing) {
|
|
8672
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8487
8673
|
return;
|
|
8488
8674
|
}
|
|
8489
8675
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8497,18 +8683,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8497
8683
|
);
|
|
8498
8684
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
8499
8685
|
"Split signals for registration",
|
|
8500
|
-
|
|
8686
|
+
(ctx, emit) => {
|
|
8501
8687
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8502
8688
|
delayMs: 3e3
|
|
8503
8689
|
});
|
|
8504
8690
|
const { signals } = ctx;
|
|
8505
|
-
if (!signals) return;
|
|
8691
|
+
if (!signals) return false;
|
|
8506
8692
|
const filteredSignals = signals.filter(
|
|
8507
8693
|
(signal) => !signal.data.registered
|
|
8508
8694
|
).map((signal) => signal.signal);
|
|
8509
8695
|
for (const signal of filteredSignals) {
|
|
8510
8696
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
8511
|
-
|
|
8697
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
8698
|
+
__syncing: ctx.__syncing,
|
|
8512
8699
|
data: {
|
|
8513
8700
|
name: signal,
|
|
8514
8701
|
isGlobal,
|
|
@@ -8517,10 +8704,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8517
8704
|
isMeta
|
|
8518
8705
|
},
|
|
8519
8706
|
__signal: signal
|
|
8520
|
-
};
|
|
8707
|
+
});
|
|
8521
8708
|
}
|
|
8709
|
+
return filteredSignals.length > 0;
|
|
8522
8710
|
}
|
|
8523
|
-
)
|
|
8711
|
+
);
|
|
8712
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
8524
8713
|
resolveSyncInsertTask(
|
|
8525
8714
|
this.isCadenzaDBReady,
|
|
8526
8715
|
"signal_registry",
|
|
@@ -8535,37 +8724,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8535
8724
|
{ concurrency: 30 }
|
|
8536
8725
|
)?.then(
|
|
8537
8726
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
8538
|
-
if (!ctx.__syncing) {
|
|
8727
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8539
8728
|
return;
|
|
8540
8729
|
}
|
|
8541
8730
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8542
8731
|
delayMs: 3e3
|
|
8543
8732
|
});
|
|
8733
|
+
CadenzaService.debounce(
|
|
8734
|
+
"meta.sync_controller.signal_registration_settled",
|
|
8735
|
+
{ __syncing: true },
|
|
8736
|
+
300
|
|
8737
|
+
);
|
|
8544
8738
|
return { signalName: ctx.__signal };
|
|
8545
|
-
}).then(
|
|
8546
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
8547
|
-
CadenzaService.createUniqueMetaTask(
|
|
8548
|
-
"Gather signal registration",
|
|
8549
|
-
() => true
|
|
8550
|
-
).emits("meta.sync_controller.synced_signals")
|
|
8551
|
-
)
|
|
8739
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
8552
8740
|
)
|
|
8553
8741
|
);
|
|
8742
|
+
CadenzaService.createUniqueMetaTask(
|
|
8743
|
+
"Gather signal registration",
|
|
8744
|
+
() => {
|
|
8745
|
+
this.signalsSynced = true;
|
|
8746
|
+
return true;
|
|
8747
|
+
}
|
|
8748
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
8554
8749
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
8555
8750
|
"Split tasks for registration",
|
|
8556
|
-
|
|
8751
|
+
(ctx, emit) => {
|
|
8557
8752
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8558
8753
|
delayMs: 3e3
|
|
8559
8754
|
});
|
|
8560
8755
|
const tasks = ctx.tasks;
|
|
8561
8756
|
const serviceName2 = resolveSyncServiceName();
|
|
8562
8757
|
if (!serviceName2) {
|
|
8563
|
-
return;
|
|
8758
|
+
return false;
|
|
8564
8759
|
}
|
|
8760
|
+
let emittedCount = 0;
|
|
8565
8761
|
for (const task of tasks) {
|
|
8566
8762
|
if (task.registered) continue;
|
|
8567
8763
|
const { __functionString, __getTagCallback } = task.export();
|
|
8568
|
-
|
|
8764
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
8765
|
+
__syncing: ctx.__syncing,
|
|
8569
8766
|
data: {
|
|
8570
8767
|
name: task.name,
|
|
8571
8768
|
version: task.version,
|
|
@@ -8583,9 +8780,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8583
8780
|
isMeta: task.isMeta,
|
|
8584
8781
|
isSubMeta: task.isSubMeta,
|
|
8585
8782
|
isHidden: task.isHidden,
|
|
8586
|
-
// inputSchema: task.inputSchema,
|
|
8587
8783
|
validateInputContext: task.validateInputContext,
|
|
8588
|
-
// outputSchema: task.outputSchema,
|
|
8589
8784
|
validateOutputContext: task.validateOutputContext,
|
|
8590
8785
|
retryCount: task.retryCount,
|
|
8591
8786
|
retryDelay: task.retryDelay,
|
|
@@ -8600,10 +8795,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8600
8795
|
}
|
|
8601
8796
|
},
|
|
8602
8797
|
__taskName: task.name
|
|
8603
|
-
};
|
|
8798
|
+
});
|
|
8799
|
+
emittedCount += 1;
|
|
8604
8800
|
}
|
|
8801
|
+
return emittedCount > 0;
|
|
8605
8802
|
}
|
|
8606
|
-
)
|
|
8803
|
+
);
|
|
8804
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
8607
8805
|
resolveSyncInsertTask(
|
|
8608
8806
|
this.isCadenzaDBReady,
|
|
8609
8807
|
"task",
|
|
@@ -8618,7 +8816,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8618
8816
|
{ concurrency: 30 }
|
|
8619
8817
|
)?.then(
|
|
8620
8818
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
8621
|
-
if (!ctx.__syncing) {
|
|
8819
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8622
8820
|
return;
|
|
8623
8821
|
}
|
|
8624
8822
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8629,15 +8827,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8629
8827
|
...ctx,
|
|
8630
8828
|
task: CadenzaService.get(ctx.__taskName)
|
|
8631
8829
|
});
|
|
8830
|
+
CadenzaService.debounce(
|
|
8831
|
+
"meta.sync_controller.task_registration_settled",
|
|
8832
|
+
{ __syncing: true },
|
|
8833
|
+
300
|
|
8834
|
+
);
|
|
8632
8835
|
return true;
|
|
8633
|
-
})
|
|
8634
|
-
CadenzaService.createUniqueMetaTask(
|
|
8635
|
-
"Gather task registration",
|
|
8636
|
-
() => true
|
|
8637
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
8638
|
-
)
|
|
8836
|
+
})
|
|
8639
8837
|
)
|
|
8640
8838
|
);
|
|
8839
|
+
CadenzaService.createUniqueMetaTask(
|
|
8840
|
+
"Gather task registration",
|
|
8841
|
+
() => {
|
|
8842
|
+
this.tasksSynced = true;
|
|
8843
|
+
return true;
|
|
8844
|
+
}
|
|
8845
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
8641
8846
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
8642
8847
|
"Split actors for registration",
|
|
8643
8848
|
function* (ctx) {
|
|
@@ -8682,22 +8887,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8682
8887
|
{ concurrency: 30 }
|
|
8683
8888
|
)?.then(
|
|
8684
8889
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
8685
|
-
if (!ctx.__syncing) {
|
|
8890
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8686
8891
|
return;
|
|
8687
8892
|
}
|
|
8688
8893
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8689
8894
|
delayMs: 3e3
|
|
8690
8895
|
});
|
|
8691
8896
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
8897
|
+
CadenzaService.debounce(
|
|
8898
|
+
"meta.sync_controller.actor_registration_settled",
|
|
8899
|
+
{ __syncing: true },
|
|
8900
|
+
300
|
|
8901
|
+
);
|
|
8692
8902
|
return true;
|
|
8693
|
-
})
|
|
8694
|
-
CadenzaService.createUniqueMetaTask(
|
|
8695
|
-
"Gather actor registration",
|
|
8696
|
-
() => true
|
|
8697
|
-
).emits("meta.sync_controller.synced_actors")
|
|
8698
|
-
)
|
|
8903
|
+
})
|
|
8699
8904
|
)
|
|
8700
8905
|
);
|
|
8906
|
+
CadenzaService.createUniqueMetaTask(
|
|
8907
|
+
"Gather actor registration",
|
|
8908
|
+
() => true
|
|
8909
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
8701
8910
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
8702
8911
|
"Split actor task maps",
|
|
8703
8912
|
function* (ctx) {
|
|
@@ -8752,7 +8961,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8752
8961
|
{ concurrency: 30 }
|
|
8753
8962
|
)?.then(
|
|
8754
8963
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
8755
|
-
if (!ctx.__syncing) {
|
|
8964
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8756
8965
|
return;
|
|
8757
8966
|
}
|
|
8758
8967
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8765,7 +8974,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8765
8974
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
8766
8975
|
"Record signal registration",
|
|
8767
8976
|
(ctx) => {
|
|
8768
|
-
if (!ctx.__syncing) {
|
|
8977
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8769
8978
|
return;
|
|
8770
8979
|
}
|
|
8771
8980
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8776,13 +8985,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8776
8985
|
);
|
|
8777
8986
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
8778
8987
|
"Split observed signals of task",
|
|
8779
|
-
|
|
8988
|
+
(ctx, emit) => {
|
|
8780
8989
|
const task = ctx.task;
|
|
8781
|
-
if (task.hidden || !task.register) return;
|
|
8990
|
+
if (task.hidden || !task.register) return false;
|
|
8782
8991
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8783
8992
|
if (!serviceName2) {
|
|
8784
|
-
return;
|
|
8993
|
+
return false;
|
|
8785
8994
|
}
|
|
8995
|
+
let emittedCount = 0;
|
|
8786
8996
|
for (const signal of task.observedSignals) {
|
|
8787
8997
|
const _signal = signal.split(":")[0];
|
|
8788
8998
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -8790,7 +9000,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8790
9000
|
continue;
|
|
8791
9001
|
}
|
|
8792
9002
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
8793
|
-
|
|
9003
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
9004
|
+
__syncing: ctx.__syncing,
|
|
8794
9005
|
data: {
|
|
8795
9006
|
signalName: _signal,
|
|
8796
9007
|
isGlobal,
|
|
@@ -8800,10 +9011,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8800
9011
|
},
|
|
8801
9012
|
__taskName: task.name,
|
|
8802
9013
|
__signal: signal
|
|
8803
|
-
};
|
|
9014
|
+
});
|
|
9015
|
+
emittedCount += 1;
|
|
8804
9016
|
}
|
|
9017
|
+
return emittedCount > 0;
|
|
8805
9018
|
}
|
|
8806
|
-
)
|
|
9019
|
+
);
|
|
9020
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
8807
9021
|
resolveSyncInsertTask(
|
|
8808
9022
|
this.isCadenzaDBReady,
|
|
8809
9023
|
"signal_to_task_map",
|
|
@@ -8825,29 +9039,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8825
9039
|
);
|
|
8826
9040
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
8827
9041
|
"Split intents for registration",
|
|
8828
|
-
function
|
|
9042
|
+
function(ctx, emit) {
|
|
8829
9043
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8830
9044
|
delayMs: 3e3
|
|
8831
9045
|
});
|
|
8832
9046
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
8833
|
-
|
|
8834
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
8835
|
-
const authorityIntentNames = intentNames.filter(
|
|
8836
|
-
(intentName) => intentName === "meta-service-registry-full-sync" || intentName.includes("service_instance") || intentName.includes("service_instance_transport") || intentName.includes("intent_to_task_map") || intentName.includes("signal_to_task_map")
|
|
8837
|
-
);
|
|
8838
|
-
CadenzaService.log(
|
|
8839
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
8840
|
-
{
|
|
8841
|
-
totalIntents: intentNames.length,
|
|
8842
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
8843
|
-
"meta-service-registry-full-sync"
|
|
8844
|
-
),
|
|
8845
|
-
authorityIntentNames
|
|
8846
|
-
},
|
|
8847
|
-
"info"
|
|
8848
|
-
);
|
|
8849
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
8850
|
-
}
|
|
9047
|
+
let emittedCount = 0;
|
|
8851
9048
|
for (const intent of intents) {
|
|
8852
9049
|
const intentData = buildIntentRegistryData(intent);
|
|
8853
9050
|
if (!intentData) {
|
|
@@ -8856,35 +9053,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8856
9053
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
8857
9054
|
continue;
|
|
8858
9055
|
}
|
|
8859
|
-
|
|
9056
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
9057
|
+
__syncing: ctx.__syncing,
|
|
8860
9058
|
data: intentData,
|
|
8861
9059
|
__intentName: intentData.name
|
|
8862
|
-
};
|
|
9060
|
+
});
|
|
9061
|
+
emittedCount += 1;
|
|
8863
9062
|
}
|
|
9063
|
+
return emittedCount > 0;
|
|
8864
9064
|
}.bind(this)
|
|
8865
|
-
)
|
|
9065
|
+
);
|
|
9066
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
8866
9067
|
insertIntentRegistryTask?.then(
|
|
8867
9068
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
8868
|
-
if (!ctx.__syncing) {
|
|
9069
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8869
9070
|
return;
|
|
8870
9071
|
}
|
|
8871
9072
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8872
9073
|
delayMs: 3e3
|
|
8873
9074
|
});
|
|
8874
9075
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9076
|
+
CadenzaService.debounce(
|
|
9077
|
+
"meta.sync_controller.intent_registration_settled",
|
|
9078
|
+
{ __syncing: true },
|
|
9079
|
+
300
|
|
9080
|
+
);
|
|
8875
9081
|
return true;
|
|
8876
|
-
})
|
|
8877
|
-
CadenzaService.createUniqueMetaTask(
|
|
8878
|
-
"Gather intent registration",
|
|
8879
|
-
() => true
|
|
8880
|
-
).emits("meta.sync_controller.synced_intents")
|
|
8881
|
-
)
|
|
9082
|
+
})
|
|
8882
9083
|
)
|
|
8883
9084
|
);
|
|
9085
|
+
CadenzaService.createUniqueMetaTask(
|
|
9086
|
+
"Gather intent registration",
|
|
9087
|
+
() => {
|
|
9088
|
+
this.intentsSynced = true;
|
|
9089
|
+
return true;
|
|
9090
|
+
}
|
|
9091
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
8884
9092
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
8885
9093
|
"Record intent registration",
|
|
8886
9094
|
(ctx) => {
|
|
8887
|
-
if (!ctx.__syncing) {
|
|
9095
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8888
9096
|
return;
|
|
8889
9097
|
}
|
|
8890
9098
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8897,37 +9105,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8897
9105
|
);
|
|
8898
9106
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
8899
9107
|
"Split intents of task",
|
|
8900
|
-
function
|
|
9108
|
+
function(ctx, emit) {
|
|
8901
9109
|
const task = ctx.task;
|
|
8902
|
-
if (task.hidden || !task.register) return;
|
|
9110
|
+
if (task.hidden || !task.register) return false;
|
|
8903
9111
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8904
9112
|
if (!serviceName2) {
|
|
8905
|
-
return;
|
|
9113
|
+
return false;
|
|
8906
9114
|
}
|
|
8907
9115
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
8908
9116
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
8909
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
8910
|
-
"Query service_instance",
|
|
8911
|
-
"Query service_instance_transport",
|
|
8912
|
-
"Query intent_to_task_map",
|
|
8913
|
-
"Query signal_to_task_map"
|
|
8914
|
-
].includes(task.name)) {
|
|
8915
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
8916
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
8917
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
8918
|
-
CadenzaService.log(
|
|
8919
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
8920
|
-
{
|
|
8921
|
-
taskName: task.name,
|
|
8922
|
-
taskVersion: task.version,
|
|
8923
|
-
isMeta: task.isMeta,
|
|
8924
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
8925
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
8926
|
-
},
|
|
8927
|
-
"info"
|
|
8928
|
-
);
|
|
8929
|
-
}
|
|
8930
|
-
}
|
|
8931
9117
|
for (const intent of task.handlesIntents) {
|
|
8932
9118
|
if (task.__registeredIntents.has(intent)) continue;
|
|
8933
9119
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -8949,7 +9135,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8949
9135
|
if (!intentDefinition) {
|
|
8950
9136
|
continue;
|
|
8951
9137
|
}
|
|
8952
|
-
|
|
9138
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
9139
|
+
__syncing: ctx.__syncing,
|
|
8953
9140
|
data: {
|
|
8954
9141
|
intentName: intent,
|
|
8955
9142
|
taskName: task.name,
|
|
@@ -8965,10 +9152,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8965
9152
|
taskVersion: task.version,
|
|
8966
9153
|
serviceName: serviceName2
|
|
8967
9154
|
}
|
|
8968
|
-
};
|
|
9155
|
+
});
|
|
8969
9156
|
}
|
|
9157
|
+
return true;
|
|
8970
9158
|
}.bind(this)
|
|
8971
|
-
)
|
|
9159
|
+
);
|
|
9160
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
8972
9161
|
CadenzaService.createMetaTask(
|
|
8973
9162
|
"Prepare intent definition for intent-to-task map",
|
|
8974
9163
|
(ctx) => {
|
|
@@ -8981,7 +9170,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8981
9170
|
};
|
|
8982
9171
|
}
|
|
8983
9172
|
).then(
|
|
8984
|
-
|
|
9173
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
8985
9174
|
CadenzaService.createMetaTask(
|
|
8986
9175
|
"Restore intent-to-task map payload",
|
|
8987
9176
|
(ctx) => {
|
|
@@ -9029,7 +9218,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9029
9218
|
return;
|
|
9030
9219
|
}
|
|
9031
9220
|
for (const t of task.nextTasks) {
|
|
9032
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
9221
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
9033
9222
|
continue;
|
|
9034
9223
|
}
|
|
9035
9224
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -9072,7 +9261,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9072
9261
|
{ concurrency: 30 }
|
|
9073
9262
|
)?.then(
|
|
9074
9263
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
9075
|
-
if (!ctx.__syncing) {
|
|
9264
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9076
9265
|
return;
|
|
9077
9266
|
}
|
|
9078
9267
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9133,7 +9322,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9133
9322
|
CadenzaService.createMetaTask(
|
|
9134
9323
|
"Record deputy relationship registration",
|
|
9135
9324
|
(ctx) => {
|
|
9136
|
-
if (!ctx.__syncing) {
|
|
9325
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9137
9326
|
return;
|
|
9138
9327
|
}
|
|
9139
9328
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9148,29 +9337,89 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9148
9337
|
"meta.sync_controller.sync_tick",
|
|
9149
9338
|
"meta.service_registry.initial_sync_complete"
|
|
9150
9339
|
).then(this.splitSignalsTask);
|
|
9151
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9340
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9341
|
+
"meta.sync_controller.sync_tick",
|
|
9342
|
+
"meta.sync_controller.synced_signals"
|
|
9343
|
+
).then(this.splitTasksForRegistration);
|
|
9152
9344
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
9153
9345
|
return {
|
|
9154
9346
|
...ctx,
|
|
9155
9347
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
9156
9348
|
};
|
|
9157
|
-
}).doOn(
|
|
9158
|
-
|
|
9349
|
+
}).doOn(
|
|
9350
|
+
"meta.sync_controller.sync_tick",
|
|
9351
|
+
"meta.service_registry.initial_sync_complete"
|
|
9352
|
+
).then(this.splitIntentsTask);
|
|
9353
|
+
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9354
|
+
"meta.sync_controller.sync_tick",
|
|
9355
|
+
"meta.service_registry.initial_sync_complete"
|
|
9356
|
+
).then(this.splitRoutinesTask);
|
|
9159
9357
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
9160
9358
|
return {
|
|
9161
9359
|
...ctx,
|
|
9162
9360
|
actors: CadenzaService.getAllActors()
|
|
9163
9361
|
};
|
|
9164
|
-
}).doOn(
|
|
9165
|
-
|
|
9362
|
+
}).doOn(
|
|
9363
|
+
"meta.sync_controller.sync_tick",
|
|
9364
|
+
"meta.service_registry.initial_sync_complete"
|
|
9365
|
+
).then(this.splitActorsForRegistration);
|
|
9366
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
9367
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9368
|
+
if (!task) {
|
|
9369
|
+
return false;
|
|
9370
|
+
}
|
|
9371
|
+
return {
|
|
9372
|
+
...ctx,
|
|
9373
|
+
task
|
|
9374
|
+
};
|
|
9375
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9166
9376
|
this.registerTaskMapTask,
|
|
9167
9377
|
this.registerDeputyRelationshipTask
|
|
9168
9378
|
);
|
|
9169
9379
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9170
|
-
"meta.sync_controller.synced_tasks",
|
|
9171
9380
|
"meta.sync_controller.synced_signals"
|
|
9172
|
-
).then(
|
|
9173
|
-
|
|
9381
|
+
).then(
|
|
9382
|
+
CadenzaService.createMetaTask(
|
|
9383
|
+
"Ensure signal and task sync ready",
|
|
9384
|
+
(ctx) => {
|
|
9385
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9386
|
+
return false;
|
|
9387
|
+
}
|
|
9388
|
+
return ctx;
|
|
9389
|
+
}
|
|
9390
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9391
|
+
);
|
|
9392
|
+
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
9393
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9394
|
+
if (!task) {
|
|
9395
|
+
return false;
|
|
9396
|
+
}
|
|
9397
|
+
return {
|
|
9398
|
+
...ctx,
|
|
9399
|
+
task
|
|
9400
|
+
};
|
|
9401
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9402
|
+
CadenzaService.createMetaTask(
|
|
9403
|
+
"Ensure signal and task sync ready from task registration",
|
|
9404
|
+
(ctx) => {
|
|
9405
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9406
|
+
return false;
|
|
9407
|
+
}
|
|
9408
|
+
return ctx;
|
|
9409
|
+
}
|
|
9410
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9411
|
+
);
|
|
9412
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
9413
|
+
CadenzaService.createMetaTask(
|
|
9414
|
+
"Ensure intent and task sync ready",
|
|
9415
|
+
(ctx) => {
|
|
9416
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9417
|
+
return false;
|
|
9418
|
+
}
|
|
9419
|
+
return ctx;
|
|
9420
|
+
}
|
|
9421
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9422
|
+
);
|
|
9174
9423
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
9175
9424
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9176
9425
|
if (!task) {
|
|
@@ -9180,12 +9429,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9180
9429
|
...ctx,
|
|
9181
9430
|
task
|
|
9182
9431
|
};
|
|
9183
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9184
|
-
|
|
9432
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9433
|
+
CadenzaService.createMetaTask(
|
|
9434
|
+
"Ensure intent and task sync ready from task registration",
|
|
9435
|
+
(ctx) => {
|
|
9436
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9437
|
+
return false;
|
|
9438
|
+
}
|
|
9439
|
+
return ctx;
|
|
9440
|
+
}
|
|
9441
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9442
|
+
);
|
|
9443
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
9444
|
+
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
9445
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9446
|
+
if (!task) {
|
|
9447
|
+
return false;
|
|
9448
|
+
}
|
|
9449
|
+
return {
|
|
9450
|
+
...ctx,
|
|
9451
|
+
task
|
|
9452
|
+
};
|
|
9453
|
+
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
9185
9454
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9186
|
-
"meta.sync_controller.
|
|
9187
|
-
"meta.sync_controller.
|
|
9188
|
-
).then(
|
|
9455
|
+
"meta.sync_controller.synced_routines",
|
|
9456
|
+
"meta.sync_controller.task_registered"
|
|
9457
|
+
).then(
|
|
9458
|
+
CadenzaService.createMetaTask(
|
|
9459
|
+
"Ensure routine and task sync ready",
|
|
9460
|
+
(ctx) => {
|
|
9461
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
9462
|
+
return false;
|
|
9463
|
+
}
|
|
9464
|
+
return ctx;
|
|
9465
|
+
}
|
|
9466
|
+
).then(this.splitTasksInRoutines)
|
|
9467
|
+
);
|
|
9189
9468
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
9190
9469
|
emit("global.meta.sync_controller.synced", {
|
|
9191
9470
|
data: {
|
|
@@ -10313,6 +10592,12 @@ var CadenzaService = class {
|
|
|
10313
10592
|
displayName: options.displayName ?? "",
|
|
10314
10593
|
isMeta: options.isMeta
|
|
10315
10594
|
},
|
|
10595
|
+
__registrationData: {
|
|
10596
|
+
name: serviceName,
|
|
10597
|
+
description,
|
|
10598
|
+
displayName: options.displayName ?? "",
|
|
10599
|
+
isMeta: options.isMeta
|
|
10600
|
+
},
|
|
10316
10601
|
__serviceName: serviceName,
|
|
10317
10602
|
__serviceInstanceId: serviceId,
|
|
10318
10603
|
__port: options.port,
|
|
@@ -10365,6 +10650,16 @@ var CadenzaService = class {
|
|
|
10365
10650
|
is_blocked: false,
|
|
10366
10651
|
health: {}
|
|
10367
10652
|
},
|
|
10653
|
+
__registrationData: {
|
|
10654
|
+
uuid: serviceId,
|
|
10655
|
+
process_pid: 1,
|
|
10656
|
+
service_name: serviceName,
|
|
10657
|
+
is_frontend: true,
|
|
10658
|
+
is_active: true,
|
|
10659
|
+
is_non_responsive: false,
|
|
10660
|
+
is_blocked: false,
|
|
10661
|
+
health: {}
|
|
10662
|
+
},
|
|
10368
10663
|
__transportData: [],
|
|
10369
10664
|
__serviceName: serviceName,
|
|
10370
10665
|
__serviceInstanceId: serviceId,
|