@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.mjs
CHANGED
|
@@ -686,6 +686,72 @@ var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
686
686
|
"Collect distributed readiness",
|
|
687
687
|
"Get status"
|
|
688
688
|
]);
|
|
689
|
+
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
690
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
691
|
+
const getJoinedValue = (key) => {
|
|
692
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
693
|
+
const joinedContext = joinedContexts[index];
|
|
694
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
695
|
+
return joinedContext[key];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return void 0;
|
|
699
|
+
};
|
|
700
|
+
const registrationData = Object.prototype.hasOwnProperty.call(ctx, "__registrationData") && ctx.__registrationData !== void 0 ? ctx.__registrationData : getJoinedValue("__registrationData");
|
|
701
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
702
|
+
const nextQueryData = {
|
|
703
|
+
...existingQueryData,
|
|
704
|
+
...queryData
|
|
705
|
+
};
|
|
706
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
707
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
708
|
+
if (!("data" in nextQueryData) && (resolvedData !== void 0 || registrationData !== void 0)) {
|
|
709
|
+
nextQueryData.data = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
710
|
+
}
|
|
711
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
712
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
713
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
714
|
+
) : resolvedBatch;
|
|
715
|
+
}
|
|
716
|
+
return nextQueryData;
|
|
717
|
+
}
|
|
718
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
719
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
720
|
+
tableName,
|
|
721
|
+
queryData,
|
|
722
|
+
options
|
|
723
|
+
);
|
|
724
|
+
return CadenzaService.createUniqueMetaTask(
|
|
725
|
+
`Resolve service registry insert for ${tableName}`,
|
|
726
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
727
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
728
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
729
|
+
CadenzaService.log(
|
|
730
|
+
"Service registry insert resolver missing service payload.",
|
|
731
|
+
{
|
|
732
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
733
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
734
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
735
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
736
|
+
},
|
|
737
|
+
"warning"
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
741
|
+
return targetTask.taskFunction(
|
|
742
|
+
{
|
|
743
|
+
...ctx,
|
|
744
|
+
queryData: nextQueryData
|
|
745
|
+
},
|
|
746
|
+
emit,
|
|
747
|
+
inquire,
|
|
748
|
+
progressCallback
|
|
749
|
+
);
|
|
750
|
+
},
|
|
751
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
752
|
+
options
|
|
753
|
+
);
|
|
754
|
+
}
|
|
689
755
|
function readPositiveIntegerEnv(name, fallback) {
|
|
690
756
|
if (typeof process === "undefined") {
|
|
691
757
|
return fallback;
|
|
@@ -1896,7 +1962,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1896
1962
|
},
|
|
1897
1963
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1898
1964
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1899
|
-
this.insertServiceTask =
|
|
1965
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1900
1966
|
"service",
|
|
1901
1967
|
{
|
|
1902
1968
|
onConflict: {
|
|
@@ -1947,7 +2013,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2013
|
retryDelayFactor: 1.3
|
|
1948
2014
|
}
|
|
1949
2015
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
1950
|
-
this.insertServiceInstanceTask =
|
|
2016
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
1951
2017
|
"service_instance",
|
|
1952
2018
|
{},
|
|
1953
2019
|
{
|
|
@@ -2005,7 +2071,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2005
2071
|
retryCount: 5,
|
|
2006
2072
|
retryDelay: 1e3
|
|
2007
2073
|
}
|
|
2008
|
-
).
|
|
2074
|
+
).then(
|
|
2009
2075
|
CadenzaService.createMetaTask(
|
|
2010
2076
|
"Setup service",
|
|
2011
2077
|
(ctx) => {
|
|
@@ -2032,8 +2098,17 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2032
2098
|
this.useSocket = __useSocket;
|
|
2033
2099
|
this.retryCount = __retryCount;
|
|
2034
2100
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2035
|
-
|
|
2036
|
-
|
|
2101
|
+
return {
|
|
2102
|
+
...ctx,
|
|
2103
|
+
serviceInstance: normalizedLocalInstance,
|
|
2104
|
+
data: {
|
|
2105
|
+
...ctx.data ?? {},
|
|
2106
|
+
uuid: normalizedLocalInstance.uuid,
|
|
2107
|
+
service_name: normalizedLocalInstance.serviceName
|
|
2108
|
+
},
|
|
2109
|
+
__serviceName: normalizedLocalInstance.serviceName,
|
|
2110
|
+
__serviceInstanceId: normalizedLocalInstance.uuid
|
|
2111
|
+
};
|
|
2037
2112
|
},
|
|
2038
2113
|
"Sets service instance id after insertion"
|
|
2039
2114
|
).emits("meta.service_registry.instance_inserted").then(
|
|
@@ -2047,6 +2122,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2047
2122
|
data: {
|
|
2048
2123
|
...transport,
|
|
2049
2124
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2125
|
+
},
|
|
2126
|
+
__registrationData: {
|
|
2127
|
+
...transport,
|
|
2128
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2050
2129
|
}
|
|
2051
2130
|
};
|
|
2052
2131
|
emit(
|
|
@@ -2060,7 +2139,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2060
2139
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2061
2140
|
)
|
|
2062
2141
|
);
|
|
2063
|
-
|
|
2142
|
+
CadenzaService.createMetaTask(
|
|
2143
|
+
"Prepare service instance registration",
|
|
2144
|
+
(ctx) => {
|
|
2145
|
+
const serviceName = String(
|
|
2146
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2147
|
+
).trim();
|
|
2148
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2149
|
+
CadenzaService.schedule(
|
|
2150
|
+
"meta.service_registry.instance_registration_requested",
|
|
2151
|
+
{ ...ctx },
|
|
2152
|
+
250
|
|
2153
|
+
);
|
|
2154
|
+
return false;
|
|
2155
|
+
}
|
|
2156
|
+
return ctx;
|
|
2157
|
+
},
|
|
2158
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2159
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2160
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2064
2161
|
"service_instance_transport",
|
|
2065
2162
|
{
|
|
2066
2163
|
onConflict: {
|
|
@@ -2125,7 +2222,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2125
2222
|
retryCount: 5,
|
|
2126
2223
|
retryDelay: 1e3
|
|
2127
2224
|
}
|
|
2128
|
-
).
|
|
2225
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2226
|
+
CadenzaService.createMetaTask(
|
|
2227
|
+
"Prepare service transport registration",
|
|
2228
|
+
(ctx) => {
|
|
2229
|
+
const serviceName = String(
|
|
2230
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2231
|
+
).trim();
|
|
2232
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2233
|
+
CadenzaService.schedule(
|
|
2234
|
+
"meta.service_registry.transport_registration_requested",
|
|
2235
|
+
{ ...ctx },
|
|
2236
|
+
250
|
|
2237
|
+
);
|
|
2238
|
+
return false;
|
|
2239
|
+
}
|
|
2240
|
+
return ctx;
|
|
2241
|
+
},
|
|
2242
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2243
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2129
2244
|
CadenzaService.createMetaTask(
|
|
2130
2245
|
"Handle service creation",
|
|
2131
2246
|
(ctx) => {
|
|
@@ -3395,6 +3510,16 @@ var RestController = class _RestController {
|
|
|
3395
3510
|
is_blocked: false,
|
|
3396
3511
|
health: {}
|
|
3397
3512
|
},
|
|
3513
|
+
__registrationData: {
|
|
3514
|
+
uuid: ctx.__serviceInstanceId,
|
|
3515
|
+
process_pid: 1,
|
|
3516
|
+
service_name: ctx.__serviceName,
|
|
3517
|
+
is_frontend: true,
|
|
3518
|
+
is_active: true,
|
|
3519
|
+
is_non_responsive: false,
|
|
3520
|
+
is_blocked: false,
|
|
3521
|
+
health: {}
|
|
3522
|
+
},
|
|
3398
3523
|
__transportData: [],
|
|
3399
3524
|
...ctx
|
|
3400
3525
|
});
|
|
@@ -3694,6 +3819,9 @@ var RestController = class _RestController {
|
|
|
3694
3819
|
is_blocked: false,
|
|
3695
3820
|
health: {}
|
|
3696
3821
|
};
|
|
3822
|
+
ctx.__registrationData = {
|
|
3823
|
+
...ctx.data
|
|
3824
|
+
};
|
|
3697
3825
|
ctx.__transportData = transportData;
|
|
3698
3826
|
delete ctx.__app;
|
|
3699
3827
|
CadenzaService.emit(
|
|
@@ -8102,12 +8230,6 @@ import { v4 as uuid5 } from "uuid";
|
|
|
8102
8230
|
|
|
8103
8231
|
// src/graph/controllers/GraphSyncController.ts
|
|
8104
8232
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8105
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
8106
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
8107
|
-
);
|
|
8108
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
8109
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
8110
|
-
);
|
|
8111
8233
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8112
8234
|
if (typeof taskFunction !== "function") {
|
|
8113
8235
|
return void 0;
|
|
@@ -8184,38 +8306,71 @@ function buildIntentRegistryData(intent) {
|
|
|
8184
8306
|
isMeta: isMetaIntentName(name)
|
|
8185
8307
|
};
|
|
8186
8308
|
}
|
|
8309
|
+
function getJoinedContextValue(ctx, key) {
|
|
8310
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
8311
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
8312
|
+
const joinedContext = joinedContexts[index];
|
|
8313
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
8314
|
+
return joinedContext[key];
|
|
8315
|
+
}
|
|
8316
|
+
}
|
|
8317
|
+
return void 0;
|
|
8318
|
+
}
|
|
8319
|
+
function didSyncInsertSucceed(ctx) {
|
|
8320
|
+
return !ctx.errored && ctx.__success !== false;
|
|
8321
|
+
}
|
|
8322
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
8323
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
8324
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
8325
|
+
const nextQueryData = {
|
|
8326
|
+
...existingQueryData,
|
|
8327
|
+
...queryData
|
|
8328
|
+
};
|
|
8329
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
8330
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
8331
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
8332
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
8333
|
+
}
|
|
8334
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
8335
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
8336
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
8337
|
+
) : resolvedBatch;
|
|
8338
|
+
}
|
|
8339
|
+
return nextQueryData;
|
|
8340
|
+
}
|
|
8187
8341
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8188
8342
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
}
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8343
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8344
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
8345
|
+
return void 0;
|
|
8346
|
+
}
|
|
8347
|
+
return CadenzaService.createUniqueMetaTask(
|
|
8348
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
8349
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
8350
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
8351
|
+
if (!targetTask) {
|
|
8352
|
+
return false;
|
|
8353
|
+
}
|
|
8354
|
+
return targetTask.taskFunction(
|
|
8355
|
+
{
|
|
8201
8356
|
...ctx,
|
|
8202
|
-
queryData:
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8357
|
+
queryData: buildSyncInsertQueryData(
|
|
8358
|
+
ctx,
|
|
8359
|
+
queryData
|
|
8360
|
+
)
|
|
8361
|
+
},
|
|
8362
|
+
emit,
|
|
8363
|
+
inquire,
|
|
8364
|
+
progressCallback
|
|
8365
|
+
);
|
|
8366
|
+
},
|
|
8367
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8368
|
+
{
|
|
8369
|
+
...options,
|
|
8370
|
+
register: false,
|
|
8371
|
+
isHidden: true
|
|
8215
8372
|
}
|
|
8216
|
-
|
|
8217
|
-
}
|
|
8218
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8373
|
+
);
|
|
8219
8374
|
}
|
|
8220
8375
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
8221
8376
|
"intent_registry",
|
|
@@ -8234,11 +8389,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8234
8389
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
8235
8390
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
8236
8391
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
8237
|
-
this.
|
|
8392
|
+
this.tasksSynced = false;
|
|
8393
|
+
this.signalsSynced = false;
|
|
8394
|
+
this.intentsSynced = false;
|
|
8395
|
+
this.routinesSynced = false;
|
|
8238
8396
|
this.isCadenzaDBReady = false;
|
|
8239
8397
|
this.initialized = false;
|
|
8240
8398
|
this.initRetryScheduled = false;
|
|
8241
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
8242
8399
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
8243
8400
|
}
|
|
8244
8401
|
static get instance() {
|
|
@@ -8313,21 +8470,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8313
8470
|
},
|
|
8314
8471
|
{ concurrency: 30 }
|
|
8315
8472
|
);
|
|
8473
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
8474
|
+
this.isCadenzaDBReady,
|
|
8475
|
+
"intent_registry",
|
|
8476
|
+
{
|
|
8477
|
+
onConflict: {
|
|
8478
|
+
target: ["name"],
|
|
8479
|
+
action: {
|
|
8480
|
+
do: "nothing"
|
|
8481
|
+
}
|
|
8482
|
+
}
|
|
8483
|
+
},
|
|
8484
|
+
{ concurrency: 30 }
|
|
8485
|
+
);
|
|
8316
8486
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
8317
8487
|
"Split routines for registration",
|
|
8318
|
-
|
|
8488
|
+
(ctx, emit) => {
|
|
8319
8489
|
const { routines } = ctx;
|
|
8320
|
-
if (!routines) return;
|
|
8490
|
+
if (!routines) return false;
|
|
8321
8491
|
const serviceName2 = resolveSyncServiceName();
|
|
8322
8492
|
if (!serviceName2) {
|
|
8323
|
-
return;
|
|
8493
|
+
return false;
|
|
8324
8494
|
}
|
|
8325
8495
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8326
8496
|
delayMs: 2e3
|
|
8327
8497
|
});
|
|
8498
|
+
let emittedCount = 0;
|
|
8328
8499
|
for (const routine of routines) {
|
|
8329
8500
|
if (routine.registered) continue;
|
|
8330
|
-
|
|
8501
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
8502
|
+
__syncing: ctx.__syncing,
|
|
8331
8503
|
data: {
|
|
8332
8504
|
name: routine.name,
|
|
8333
8505
|
version: routine.version,
|
|
@@ -8336,10 +8508,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8336
8508
|
isMeta: routine.isMeta
|
|
8337
8509
|
},
|
|
8338
8510
|
__routineName: routine.name
|
|
8339
|
-
};
|
|
8511
|
+
});
|
|
8512
|
+
emittedCount += 1;
|
|
8340
8513
|
}
|
|
8514
|
+
return emittedCount > 0;
|
|
8341
8515
|
}
|
|
8342
|
-
)
|
|
8516
|
+
);
|
|
8517
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
8343
8518
|
resolveSyncInsertTask(
|
|
8344
8519
|
this.isCadenzaDBReady,
|
|
8345
8520
|
"routine",
|
|
@@ -8354,39 +8529,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8354
8529
|
{ concurrency: 30 }
|
|
8355
8530
|
)?.then(
|
|
8356
8531
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
8357
|
-
if (!ctx.__syncing) {
|
|
8532
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8358
8533
|
return;
|
|
8359
8534
|
}
|
|
8360
8535
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8361
8536
|
delayMs: 3e3
|
|
8362
8537
|
});
|
|
8363
8538
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
8539
|
+
CadenzaService.debounce(
|
|
8540
|
+
"meta.sync_controller.routine_registration_settled",
|
|
8541
|
+
{ __syncing: true },
|
|
8542
|
+
300
|
|
8543
|
+
);
|
|
8364
8544
|
return true;
|
|
8365
|
-
})
|
|
8366
|
-
CadenzaService.createUniqueMetaTask(
|
|
8367
|
-
"Gather routine registration",
|
|
8368
|
-
() => true
|
|
8369
|
-
).emits("meta.sync_controller.synced_routines")
|
|
8370
|
-
)
|
|
8545
|
+
})
|
|
8371
8546
|
)
|
|
8372
8547
|
);
|
|
8548
|
+
CadenzaService.createUniqueMetaTask(
|
|
8549
|
+
"Gather routine registration",
|
|
8550
|
+
() => {
|
|
8551
|
+
this.routinesSynced = true;
|
|
8552
|
+
return true;
|
|
8553
|
+
}
|
|
8554
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
8373
8555
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
8374
8556
|
"Split tasks in routines",
|
|
8375
|
-
|
|
8557
|
+
(ctx, emit) => {
|
|
8376
8558
|
const { routines } = ctx;
|
|
8377
|
-
if (!routines) return;
|
|
8559
|
+
if (!routines) return false;
|
|
8378
8560
|
const serviceName2 = resolveSyncServiceName();
|
|
8379
8561
|
if (!serviceName2) {
|
|
8380
|
-
return;
|
|
8562
|
+
return false;
|
|
8381
8563
|
}
|
|
8382
8564
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8383
8565
|
delayMs: 3e3
|
|
8384
8566
|
});
|
|
8567
|
+
let emittedCount = 0;
|
|
8385
8568
|
for (const routine of routines) {
|
|
8386
8569
|
if (!routine.registered) continue;
|
|
8387
8570
|
for (const task of routine.tasks) {
|
|
8388
8571
|
if (!task) {
|
|
8389
|
-
console.log("task is null", routine, task);
|
|
8390
8572
|
continue;
|
|
8391
8573
|
}
|
|
8392
8574
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -8396,7 +8578,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8396
8578
|
if (!nextTask?.registered) {
|
|
8397
8579
|
continue;
|
|
8398
8580
|
}
|
|
8399
|
-
|
|
8581
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
8582
|
+
__syncing: ctx.__syncing,
|
|
8400
8583
|
data: {
|
|
8401
8584
|
taskName: nextTask.name,
|
|
8402
8585
|
taskVersion: nextTask.version,
|
|
@@ -8406,12 +8589,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8406
8589
|
},
|
|
8407
8590
|
__routineName: routine.name,
|
|
8408
8591
|
__taskName: nextTask.name
|
|
8409
|
-
};
|
|
8592
|
+
});
|
|
8593
|
+
emittedCount += 1;
|
|
8410
8594
|
}
|
|
8411
8595
|
}
|
|
8412
8596
|
}
|
|
8597
|
+
return emittedCount > 0;
|
|
8413
8598
|
}
|
|
8414
|
-
)
|
|
8599
|
+
);
|
|
8600
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
8415
8601
|
resolveSyncInsertTask(
|
|
8416
8602
|
this.isCadenzaDBReady,
|
|
8417
8603
|
"task_to_routine_map",
|
|
@@ -8432,7 +8618,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8432
8618
|
{ concurrency: 30 }
|
|
8433
8619
|
)?.then(
|
|
8434
8620
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
8435
|
-
if (!ctx.__syncing) {
|
|
8621
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8436
8622
|
return;
|
|
8437
8623
|
}
|
|
8438
8624
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8446,18 +8632,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8446
8632
|
);
|
|
8447
8633
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
8448
8634
|
"Split signals for registration",
|
|
8449
|
-
|
|
8635
|
+
(ctx, emit) => {
|
|
8450
8636
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8451
8637
|
delayMs: 3e3
|
|
8452
8638
|
});
|
|
8453
8639
|
const { signals } = ctx;
|
|
8454
|
-
if (!signals) return;
|
|
8640
|
+
if (!signals) return false;
|
|
8455
8641
|
const filteredSignals = signals.filter(
|
|
8456
8642
|
(signal) => !signal.data.registered
|
|
8457
8643
|
).map((signal) => signal.signal);
|
|
8458
8644
|
for (const signal of filteredSignals) {
|
|
8459
8645
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
8460
|
-
|
|
8646
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
8647
|
+
__syncing: ctx.__syncing,
|
|
8461
8648
|
data: {
|
|
8462
8649
|
name: signal,
|
|
8463
8650
|
isGlobal,
|
|
@@ -8466,10 +8653,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8466
8653
|
isMeta
|
|
8467
8654
|
},
|
|
8468
8655
|
__signal: signal
|
|
8469
|
-
};
|
|
8656
|
+
});
|
|
8470
8657
|
}
|
|
8658
|
+
return filteredSignals.length > 0;
|
|
8471
8659
|
}
|
|
8472
|
-
)
|
|
8660
|
+
);
|
|
8661
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
8473
8662
|
resolveSyncInsertTask(
|
|
8474
8663
|
this.isCadenzaDBReady,
|
|
8475
8664
|
"signal_registry",
|
|
@@ -8484,37 +8673,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8484
8673
|
{ concurrency: 30 }
|
|
8485
8674
|
)?.then(
|
|
8486
8675
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
8487
|
-
if (!ctx.__syncing) {
|
|
8676
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8488
8677
|
return;
|
|
8489
8678
|
}
|
|
8490
8679
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8491
8680
|
delayMs: 3e3
|
|
8492
8681
|
});
|
|
8682
|
+
CadenzaService.debounce(
|
|
8683
|
+
"meta.sync_controller.signal_registration_settled",
|
|
8684
|
+
{ __syncing: true },
|
|
8685
|
+
300
|
|
8686
|
+
);
|
|
8493
8687
|
return { signalName: ctx.__signal };
|
|
8494
|
-
}).then(
|
|
8495
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
8496
|
-
CadenzaService.createUniqueMetaTask(
|
|
8497
|
-
"Gather signal registration",
|
|
8498
|
-
() => true
|
|
8499
|
-
).emits("meta.sync_controller.synced_signals")
|
|
8500
|
-
)
|
|
8688
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
8501
8689
|
)
|
|
8502
8690
|
);
|
|
8691
|
+
CadenzaService.createUniqueMetaTask(
|
|
8692
|
+
"Gather signal registration",
|
|
8693
|
+
() => {
|
|
8694
|
+
this.signalsSynced = true;
|
|
8695
|
+
return true;
|
|
8696
|
+
}
|
|
8697
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
8503
8698
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
8504
8699
|
"Split tasks for registration",
|
|
8505
|
-
|
|
8700
|
+
(ctx, emit) => {
|
|
8506
8701
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8507
8702
|
delayMs: 3e3
|
|
8508
8703
|
});
|
|
8509
8704
|
const tasks = ctx.tasks;
|
|
8510
8705
|
const serviceName2 = resolveSyncServiceName();
|
|
8511
8706
|
if (!serviceName2) {
|
|
8512
|
-
return;
|
|
8707
|
+
return false;
|
|
8513
8708
|
}
|
|
8709
|
+
let emittedCount = 0;
|
|
8514
8710
|
for (const task of tasks) {
|
|
8515
8711
|
if (task.registered) continue;
|
|
8516
8712
|
const { __functionString, __getTagCallback } = task.export();
|
|
8517
|
-
|
|
8713
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
8714
|
+
__syncing: ctx.__syncing,
|
|
8518
8715
|
data: {
|
|
8519
8716
|
name: task.name,
|
|
8520
8717
|
version: task.version,
|
|
@@ -8532,9 +8729,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8532
8729
|
isMeta: task.isMeta,
|
|
8533
8730
|
isSubMeta: task.isSubMeta,
|
|
8534
8731
|
isHidden: task.isHidden,
|
|
8535
|
-
// inputSchema: task.inputSchema,
|
|
8536
8732
|
validateInputContext: task.validateInputContext,
|
|
8537
|
-
// outputSchema: task.outputSchema,
|
|
8538
8733
|
validateOutputContext: task.validateOutputContext,
|
|
8539
8734
|
retryCount: task.retryCount,
|
|
8540
8735
|
retryDelay: task.retryDelay,
|
|
@@ -8549,10 +8744,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8549
8744
|
}
|
|
8550
8745
|
},
|
|
8551
8746
|
__taskName: task.name
|
|
8552
|
-
};
|
|
8747
|
+
});
|
|
8748
|
+
emittedCount += 1;
|
|
8553
8749
|
}
|
|
8750
|
+
return emittedCount > 0;
|
|
8554
8751
|
}
|
|
8555
|
-
)
|
|
8752
|
+
);
|
|
8753
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
8556
8754
|
resolveSyncInsertTask(
|
|
8557
8755
|
this.isCadenzaDBReady,
|
|
8558
8756
|
"task",
|
|
@@ -8567,7 +8765,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8567
8765
|
{ concurrency: 30 }
|
|
8568
8766
|
)?.then(
|
|
8569
8767
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
8570
|
-
if (!ctx.__syncing) {
|
|
8768
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8571
8769
|
return;
|
|
8572
8770
|
}
|
|
8573
8771
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8578,15 +8776,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8578
8776
|
...ctx,
|
|
8579
8777
|
task: CadenzaService.get(ctx.__taskName)
|
|
8580
8778
|
});
|
|
8779
|
+
CadenzaService.debounce(
|
|
8780
|
+
"meta.sync_controller.task_registration_settled",
|
|
8781
|
+
{ __syncing: true },
|
|
8782
|
+
300
|
|
8783
|
+
);
|
|
8581
8784
|
return true;
|
|
8582
|
-
})
|
|
8583
|
-
CadenzaService.createUniqueMetaTask(
|
|
8584
|
-
"Gather task registration",
|
|
8585
|
-
() => true
|
|
8586
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
8587
|
-
)
|
|
8785
|
+
})
|
|
8588
8786
|
)
|
|
8589
8787
|
);
|
|
8788
|
+
CadenzaService.createUniqueMetaTask(
|
|
8789
|
+
"Gather task registration",
|
|
8790
|
+
() => {
|
|
8791
|
+
this.tasksSynced = true;
|
|
8792
|
+
return true;
|
|
8793
|
+
}
|
|
8794
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
8590
8795
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
8591
8796
|
"Split actors for registration",
|
|
8592
8797
|
function* (ctx) {
|
|
@@ -8631,22 +8836,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8631
8836
|
{ concurrency: 30 }
|
|
8632
8837
|
)?.then(
|
|
8633
8838
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
8634
|
-
if (!ctx.__syncing) {
|
|
8839
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8635
8840
|
return;
|
|
8636
8841
|
}
|
|
8637
8842
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8638
8843
|
delayMs: 3e3
|
|
8639
8844
|
});
|
|
8640
8845
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
8846
|
+
CadenzaService.debounce(
|
|
8847
|
+
"meta.sync_controller.actor_registration_settled",
|
|
8848
|
+
{ __syncing: true },
|
|
8849
|
+
300
|
|
8850
|
+
);
|
|
8641
8851
|
return true;
|
|
8642
|
-
})
|
|
8643
|
-
CadenzaService.createUniqueMetaTask(
|
|
8644
|
-
"Gather actor registration",
|
|
8645
|
-
() => true
|
|
8646
|
-
).emits("meta.sync_controller.synced_actors")
|
|
8647
|
-
)
|
|
8852
|
+
})
|
|
8648
8853
|
)
|
|
8649
8854
|
);
|
|
8855
|
+
CadenzaService.createUniqueMetaTask(
|
|
8856
|
+
"Gather actor registration",
|
|
8857
|
+
() => true
|
|
8858
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
8650
8859
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
8651
8860
|
"Split actor task maps",
|
|
8652
8861
|
function* (ctx) {
|
|
@@ -8701,7 +8910,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8701
8910
|
{ concurrency: 30 }
|
|
8702
8911
|
)?.then(
|
|
8703
8912
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
8704
|
-
if (!ctx.__syncing) {
|
|
8913
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8705
8914
|
return;
|
|
8706
8915
|
}
|
|
8707
8916
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8714,7 +8923,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8714
8923
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
8715
8924
|
"Record signal registration",
|
|
8716
8925
|
(ctx) => {
|
|
8717
|
-
if (!ctx.__syncing) {
|
|
8926
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8718
8927
|
return;
|
|
8719
8928
|
}
|
|
8720
8929
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8725,13 +8934,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8725
8934
|
);
|
|
8726
8935
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
8727
8936
|
"Split observed signals of task",
|
|
8728
|
-
|
|
8937
|
+
(ctx, emit) => {
|
|
8729
8938
|
const task = ctx.task;
|
|
8730
|
-
if (task.hidden || !task.register) return;
|
|
8939
|
+
if (task.hidden || !task.register) return false;
|
|
8731
8940
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8732
8941
|
if (!serviceName2) {
|
|
8733
|
-
return;
|
|
8942
|
+
return false;
|
|
8734
8943
|
}
|
|
8944
|
+
let emittedCount = 0;
|
|
8735
8945
|
for (const signal of task.observedSignals) {
|
|
8736
8946
|
const _signal = signal.split(":")[0];
|
|
8737
8947
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -8739,7 +8949,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8739
8949
|
continue;
|
|
8740
8950
|
}
|
|
8741
8951
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
8742
|
-
|
|
8952
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
8953
|
+
__syncing: ctx.__syncing,
|
|
8743
8954
|
data: {
|
|
8744
8955
|
signalName: _signal,
|
|
8745
8956
|
isGlobal,
|
|
@@ -8749,10 +8960,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8749
8960
|
},
|
|
8750
8961
|
__taskName: task.name,
|
|
8751
8962
|
__signal: signal
|
|
8752
|
-
};
|
|
8963
|
+
});
|
|
8964
|
+
emittedCount += 1;
|
|
8753
8965
|
}
|
|
8966
|
+
return emittedCount > 0;
|
|
8754
8967
|
}
|
|
8755
|
-
)
|
|
8968
|
+
);
|
|
8969
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
8756
8970
|
resolveSyncInsertTask(
|
|
8757
8971
|
this.isCadenzaDBReady,
|
|
8758
8972
|
"signal_to_task_map",
|
|
@@ -8774,29 +8988,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8774
8988
|
);
|
|
8775
8989
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
8776
8990
|
"Split intents for registration",
|
|
8777
|
-
function
|
|
8991
|
+
function(ctx, emit) {
|
|
8778
8992
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8779
8993
|
delayMs: 3e3
|
|
8780
8994
|
});
|
|
8781
8995
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
8782
|
-
|
|
8783
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
8784
|
-
const authorityIntentNames = intentNames.filter(
|
|
8785
|
-
(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")
|
|
8786
|
-
);
|
|
8787
|
-
CadenzaService.log(
|
|
8788
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
8789
|
-
{
|
|
8790
|
-
totalIntents: intentNames.length,
|
|
8791
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
8792
|
-
"meta-service-registry-full-sync"
|
|
8793
|
-
),
|
|
8794
|
-
authorityIntentNames
|
|
8795
|
-
},
|
|
8796
|
-
"info"
|
|
8797
|
-
);
|
|
8798
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
8799
|
-
}
|
|
8996
|
+
let emittedCount = 0;
|
|
8800
8997
|
for (const intent of intents) {
|
|
8801
8998
|
const intentData = buildIntentRegistryData(intent);
|
|
8802
8999
|
if (!intentData) {
|
|
@@ -8805,35 +9002,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8805
9002
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
8806
9003
|
continue;
|
|
8807
9004
|
}
|
|
8808
|
-
|
|
9005
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
9006
|
+
__syncing: ctx.__syncing,
|
|
8809
9007
|
data: intentData,
|
|
8810
9008
|
__intentName: intentData.name
|
|
8811
|
-
};
|
|
9009
|
+
});
|
|
9010
|
+
emittedCount += 1;
|
|
8812
9011
|
}
|
|
9012
|
+
return emittedCount > 0;
|
|
8813
9013
|
}.bind(this)
|
|
8814
|
-
)
|
|
9014
|
+
);
|
|
9015
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
8815
9016
|
insertIntentRegistryTask?.then(
|
|
8816
9017
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
8817
|
-
if (!ctx.__syncing) {
|
|
9018
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8818
9019
|
return;
|
|
8819
9020
|
}
|
|
8820
9021
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8821
9022
|
delayMs: 3e3
|
|
8822
9023
|
});
|
|
8823
9024
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9025
|
+
CadenzaService.debounce(
|
|
9026
|
+
"meta.sync_controller.intent_registration_settled",
|
|
9027
|
+
{ __syncing: true },
|
|
9028
|
+
300
|
|
9029
|
+
);
|
|
8824
9030
|
return true;
|
|
8825
|
-
})
|
|
8826
|
-
CadenzaService.createUniqueMetaTask(
|
|
8827
|
-
"Gather intent registration",
|
|
8828
|
-
() => true
|
|
8829
|
-
).emits("meta.sync_controller.synced_intents")
|
|
8830
|
-
)
|
|
9031
|
+
})
|
|
8831
9032
|
)
|
|
8832
9033
|
);
|
|
9034
|
+
CadenzaService.createUniqueMetaTask(
|
|
9035
|
+
"Gather intent registration",
|
|
9036
|
+
() => {
|
|
9037
|
+
this.intentsSynced = true;
|
|
9038
|
+
return true;
|
|
9039
|
+
}
|
|
9040
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
8833
9041
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
8834
9042
|
"Record intent registration",
|
|
8835
9043
|
(ctx) => {
|
|
8836
|
-
if (!ctx.__syncing) {
|
|
9044
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8837
9045
|
return;
|
|
8838
9046
|
}
|
|
8839
9047
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8846,37 +9054,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8846
9054
|
);
|
|
8847
9055
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
8848
9056
|
"Split intents of task",
|
|
8849
|
-
function
|
|
9057
|
+
function(ctx, emit) {
|
|
8850
9058
|
const task = ctx.task;
|
|
8851
|
-
if (task.hidden || !task.register) return;
|
|
9059
|
+
if (task.hidden || !task.register) return false;
|
|
8852
9060
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8853
9061
|
if (!serviceName2) {
|
|
8854
|
-
return;
|
|
9062
|
+
return false;
|
|
8855
9063
|
}
|
|
8856
9064
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
8857
9065
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
8858
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
8859
|
-
"Query service_instance",
|
|
8860
|
-
"Query service_instance_transport",
|
|
8861
|
-
"Query intent_to_task_map",
|
|
8862
|
-
"Query signal_to_task_map"
|
|
8863
|
-
].includes(task.name)) {
|
|
8864
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
8865
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
8866
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
8867
|
-
CadenzaService.log(
|
|
8868
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
8869
|
-
{
|
|
8870
|
-
taskName: task.name,
|
|
8871
|
-
taskVersion: task.version,
|
|
8872
|
-
isMeta: task.isMeta,
|
|
8873
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
8874
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
8875
|
-
},
|
|
8876
|
-
"info"
|
|
8877
|
-
);
|
|
8878
|
-
}
|
|
8879
|
-
}
|
|
8880
9066
|
for (const intent of task.handlesIntents) {
|
|
8881
9067
|
if (task.__registeredIntents.has(intent)) continue;
|
|
8882
9068
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -8898,7 +9084,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8898
9084
|
if (!intentDefinition) {
|
|
8899
9085
|
continue;
|
|
8900
9086
|
}
|
|
8901
|
-
|
|
9087
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
9088
|
+
__syncing: ctx.__syncing,
|
|
8902
9089
|
data: {
|
|
8903
9090
|
intentName: intent,
|
|
8904
9091
|
taskName: task.name,
|
|
@@ -8914,10 +9101,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8914
9101
|
taskVersion: task.version,
|
|
8915
9102
|
serviceName: serviceName2
|
|
8916
9103
|
}
|
|
8917
|
-
};
|
|
9104
|
+
});
|
|
8918
9105
|
}
|
|
9106
|
+
return true;
|
|
8919
9107
|
}.bind(this)
|
|
8920
|
-
)
|
|
9108
|
+
);
|
|
9109
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
8921
9110
|
CadenzaService.createMetaTask(
|
|
8922
9111
|
"Prepare intent definition for intent-to-task map",
|
|
8923
9112
|
(ctx) => {
|
|
@@ -8930,7 +9119,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8930
9119
|
};
|
|
8931
9120
|
}
|
|
8932
9121
|
).then(
|
|
8933
|
-
|
|
9122
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
8934
9123
|
CadenzaService.createMetaTask(
|
|
8935
9124
|
"Restore intent-to-task map payload",
|
|
8936
9125
|
(ctx) => {
|
|
@@ -8978,7 +9167,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8978
9167
|
return;
|
|
8979
9168
|
}
|
|
8980
9169
|
for (const t of task.nextTasks) {
|
|
8981
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
9170
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
8982
9171
|
continue;
|
|
8983
9172
|
}
|
|
8984
9173
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -9021,7 +9210,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9021
9210
|
{ concurrency: 30 }
|
|
9022
9211
|
)?.then(
|
|
9023
9212
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
9024
|
-
if (!ctx.__syncing) {
|
|
9213
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9025
9214
|
return;
|
|
9026
9215
|
}
|
|
9027
9216
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9082,7 +9271,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9082
9271
|
CadenzaService.createMetaTask(
|
|
9083
9272
|
"Record deputy relationship registration",
|
|
9084
9273
|
(ctx) => {
|
|
9085
|
-
if (!ctx.__syncing) {
|
|
9274
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9086
9275
|
return;
|
|
9087
9276
|
}
|
|
9088
9277
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9097,29 +9286,89 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9097
9286
|
"meta.sync_controller.sync_tick",
|
|
9098
9287
|
"meta.service_registry.initial_sync_complete"
|
|
9099
9288
|
).then(this.splitSignalsTask);
|
|
9100
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9289
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9290
|
+
"meta.sync_controller.sync_tick",
|
|
9291
|
+
"meta.sync_controller.synced_signals"
|
|
9292
|
+
).then(this.splitTasksForRegistration);
|
|
9101
9293
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
9102
9294
|
return {
|
|
9103
9295
|
...ctx,
|
|
9104
9296
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
9105
9297
|
};
|
|
9106
|
-
}).doOn(
|
|
9107
|
-
|
|
9298
|
+
}).doOn(
|
|
9299
|
+
"meta.sync_controller.sync_tick",
|
|
9300
|
+
"meta.service_registry.initial_sync_complete"
|
|
9301
|
+
).then(this.splitIntentsTask);
|
|
9302
|
+
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9303
|
+
"meta.sync_controller.sync_tick",
|
|
9304
|
+
"meta.service_registry.initial_sync_complete"
|
|
9305
|
+
).then(this.splitRoutinesTask);
|
|
9108
9306
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
9109
9307
|
return {
|
|
9110
9308
|
...ctx,
|
|
9111
9309
|
actors: CadenzaService.getAllActors()
|
|
9112
9310
|
};
|
|
9113
|
-
}).doOn(
|
|
9114
|
-
|
|
9311
|
+
}).doOn(
|
|
9312
|
+
"meta.sync_controller.sync_tick",
|
|
9313
|
+
"meta.service_registry.initial_sync_complete"
|
|
9314
|
+
).then(this.splitActorsForRegistration);
|
|
9315
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
9316
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9317
|
+
if (!task) {
|
|
9318
|
+
return false;
|
|
9319
|
+
}
|
|
9320
|
+
return {
|
|
9321
|
+
...ctx,
|
|
9322
|
+
task
|
|
9323
|
+
};
|
|
9324
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9115
9325
|
this.registerTaskMapTask,
|
|
9116
9326
|
this.registerDeputyRelationshipTask
|
|
9117
9327
|
);
|
|
9118
9328
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9119
|
-
"meta.sync_controller.synced_tasks",
|
|
9120
9329
|
"meta.sync_controller.synced_signals"
|
|
9121
|
-
).then(
|
|
9122
|
-
|
|
9330
|
+
).then(
|
|
9331
|
+
CadenzaService.createMetaTask(
|
|
9332
|
+
"Ensure signal and task sync ready",
|
|
9333
|
+
(ctx) => {
|
|
9334
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9335
|
+
return false;
|
|
9336
|
+
}
|
|
9337
|
+
return ctx;
|
|
9338
|
+
}
|
|
9339
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9340
|
+
);
|
|
9341
|
+
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
9342
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9343
|
+
if (!task) {
|
|
9344
|
+
return false;
|
|
9345
|
+
}
|
|
9346
|
+
return {
|
|
9347
|
+
...ctx,
|
|
9348
|
+
task
|
|
9349
|
+
};
|
|
9350
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9351
|
+
CadenzaService.createMetaTask(
|
|
9352
|
+
"Ensure signal and task sync ready from task registration",
|
|
9353
|
+
(ctx) => {
|
|
9354
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9355
|
+
return false;
|
|
9356
|
+
}
|
|
9357
|
+
return ctx;
|
|
9358
|
+
}
|
|
9359
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9360
|
+
);
|
|
9361
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
9362
|
+
CadenzaService.createMetaTask(
|
|
9363
|
+
"Ensure intent and task sync ready",
|
|
9364
|
+
(ctx) => {
|
|
9365
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9366
|
+
return false;
|
|
9367
|
+
}
|
|
9368
|
+
return ctx;
|
|
9369
|
+
}
|
|
9370
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9371
|
+
);
|
|
9123
9372
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
9124
9373
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9125
9374
|
if (!task) {
|
|
@@ -9129,12 +9378,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9129
9378
|
...ctx,
|
|
9130
9379
|
task
|
|
9131
9380
|
};
|
|
9132
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9133
|
-
|
|
9381
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9382
|
+
CadenzaService.createMetaTask(
|
|
9383
|
+
"Ensure intent and task sync ready from task registration",
|
|
9384
|
+
(ctx) => {
|
|
9385
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9386
|
+
return false;
|
|
9387
|
+
}
|
|
9388
|
+
return ctx;
|
|
9389
|
+
}
|
|
9390
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9391
|
+
);
|
|
9392
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
9393
|
+
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
9394
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9395
|
+
if (!task) {
|
|
9396
|
+
return false;
|
|
9397
|
+
}
|
|
9398
|
+
return {
|
|
9399
|
+
...ctx,
|
|
9400
|
+
task
|
|
9401
|
+
};
|
|
9402
|
+
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
9134
9403
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9135
|
-
"meta.sync_controller.
|
|
9136
|
-
"meta.sync_controller.
|
|
9137
|
-
).then(
|
|
9404
|
+
"meta.sync_controller.synced_routines",
|
|
9405
|
+
"meta.sync_controller.task_registered"
|
|
9406
|
+
).then(
|
|
9407
|
+
CadenzaService.createMetaTask(
|
|
9408
|
+
"Ensure routine and task sync ready",
|
|
9409
|
+
(ctx) => {
|
|
9410
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
9411
|
+
return false;
|
|
9412
|
+
}
|
|
9413
|
+
return ctx;
|
|
9414
|
+
}
|
|
9415
|
+
).then(this.splitTasksInRoutines)
|
|
9416
|
+
);
|
|
9138
9417
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
9139
9418
|
emit("global.meta.sync_controller.synced", {
|
|
9140
9419
|
data: {
|
|
@@ -10262,6 +10541,12 @@ var CadenzaService = class {
|
|
|
10262
10541
|
displayName: options.displayName ?? "",
|
|
10263
10542
|
isMeta: options.isMeta
|
|
10264
10543
|
},
|
|
10544
|
+
__registrationData: {
|
|
10545
|
+
name: serviceName,
|
|
10546
|
+
description,
|
|
10547
|
+
displayName: options.displayName ?? "",
|
|
10548
|
+
isMeta: options.isMeta
|
|
10549
|
+
},
|
|
10265
10550
|
__serviceName: serviceName,
|
|
10266
10551
|
__serviceInstanceId: serviceId,
|
|
10267
10552
|
__port: options.port,
|
|
@@ -10314,6 +10599,16 @@ var CadenzaService = class {
|
|
|
10314
10599
|
is_blocked: false,
|
|
10315
10600
|
health: {}
|
|
10316
10601
|
},
|
|
10602
|
+
__registrationData: {
|
|
10603
|
+
uuid: serviceId,
|
|
10604
|
+
process_pid: 1,
|
|
10605
|
+
service_name: serviceName,
|
|
10606
|
+
is_frontend: true,
|
|
10607
|
+
is_active: true,
|
|
10608
|
+
is_non_responsive: false,
|
|
10609
|
+
is_blocked: false,
|
|
10610
|
+
health: {}
|
|
10611
|
+
},
|
|
10317
10612
|
__transportData: [],
|
|
10318
10613
|
__serviceName: serviceName,
|
|
10319
10614
|
__serviceInstanceId: serviceId,
|