@cadenza.io/service 2.17.24 → 2.17.26
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 +521 -195
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +521 -195
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +524 -195
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +524 -195
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -737,6 +737,116 @@ 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 normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResult) {
|
|
770
|
+
if (!rawResult || typeof rawResult !== "object") {
|
|
771
|
+
return rawResult;
|
|
772
|
+
}
|
|
773
|
+
const result = { ...rawResult };
|
|
774
|
+
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
775
|
+
const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
776
|
+
if (resolvedData !== void 0 && result.data === void 0) {
|
|
777
|
+
result.data = resolvedData;
|
|
778
|
+
}
|
|
779
|
+
if (resolvedData !== void 0 && (normalizedQueryData.data === void 0 || normalizedQueryData.data === null)) {
|
|
780
|
+
normalizedQueryData.data = resolvedData;
|
|
781
|
+
}
|
|
782
|
+
result.queryData = normalizedQueryData;
|
|
783
|
+
if (tableName === "service") {
|
|
784
|
+
const resolvedServiceName = String(
|
|
785
|
+
result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ctx.__serviceName ?? ""
|
|
786
|
+
).trim();
|
|
787
|
+
if (resolvedServiceName) {
|
|
788
|
+
result.__serviceName = resolvedServiceName;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
792
|
+
const resolvedUuid = String(
|
|
793
|
+
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
794
|
+
).trim();
|
|
795
|
+
if (resolvedUuid) {
|
|
796
|
+
result.uuid = resolvedUuid;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return result;
|
|
800
|
+
}
|
|
801
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
802
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
803
|
+
tableName,
|
|
804
|
+
queryData,
|
|
805
|
+
options
|
|
806
|
+
);
|
|
807
|
+
return CadenzaService.createUniqueMetaTask(
|
|
808
|
+
`Resolve service registry insert for ${tableName}`,
|
|
809
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
810
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
811
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
812
|
+
CadenzaService.log(
|
|
813
|
+
"Service registry insert resolver missing service payload.",
|
|
814
|
+
{
|
|
815
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
816
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
817
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
818
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
819
|
+
},
|
|
820
|
+
"warning"
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
824
|
+
const delegationContext = ensureDelegationContextMetadata({
|
|
825
|
+
...ctx,
|
|
826
|
+
queryData: nextQueryData
|
|
827
|
+
});
|
|
828
|
+
delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
|
|
829
|
+
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
830
|
+
return Promise.resolve(
|
|
831
|
+
targetTask.taskFunction(
|
|
832
|
+
delegationContext,
|
|
833
|
+
emit,
|
|
834
|
+
inquire,
|
|
835
|
+
progressCallback
|
|
836
|
+
)
|
|
837
|
+
).then(
|
|
838
|
+
(result) => normalizeServiceRegistryInsertResult(
|
|
839
|
+
tableName,
|
|
840
|
+
ctx,
|
|
841
|
+
nextQueryData,
|
|
842
|
+
result
|
|
843
|
+
)
|
|
844
|
+
);
|
|
845
|
+
},
|
|
846
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
847
|
+
options
|
|
848
|
+
);
|
|
849
|
+
}
|
|
740
850
|
function readPositiveIntegerEnv(name, fallback) {
|
|
741
851
|
if (typeof process === "undefined") {
|
|
742
852
|
return fallback;
|
|
@@ -1947,7 +2057,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2057
|
},
|
|
1948
2058
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1949
2059
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1950
|
-
this.insertServiceTask =
|
|
2060
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1951
2061
|
"service",
|
|
1952
2062
|
{
|
|
1953
2063
|
onConflict: {
|
|
@@ -1998,7 +2108,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1998
2108
|
retryDelayFactor: 1.3
|
|
1999
2109
|
}
|
|
2000
2110
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
2001
|
-
this.insertServiceInstanceTask =
|
|
2111
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
2002
2112
|
"service_instance",
|
|
2003
2113
|
{},
|
|
2004
2114
|
{
|
|
@@ -2056,7 +2166,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2056
2166
|
retryCount: 5,
|
|
2057
2167
|
retryDelay: 1e3
|
|
2058
2168
|
}
|
|
2059
|
-
).
|
|
2169
|
+
).then(
|
|
2060
2170
|
CadenzaService.createMetaTask(
|
|
2061
2171
|
"Setup service",
|
|
2062
2172
|
(ctx) => {
|
|
@@ -2083,7 +2193,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2083
2193
|
this.useSocket = __useSocket;
|
|
2084
2194
|
this.retryCount = __retryCount;
|
|
2085
2195
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2086
|
-
console.log("SETUP SERVICE", this.serviceInstanceId);
|
|
2087
2196
|
return {
|
|
2088
2197
|
...ctx,
|
|
2089
2198
|
serviceInstance: normalizedLocalInstance,
|
|
@@ -2108,6 +2217,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2108
2217
|
data: {
|
|
2109
2218
|
...transport,
|
|
2110
2219
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2220
|
+
},
|
|
2221
|
+
__registrationData: {
|
|
2222
|
+
...transport,
|
|
2223
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2111
2224
|
}
|
|
2112
2225
|
};
|
|
2113
2226
|
emit(
|
|
@@ -2121,7 +2234,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2121
2234
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2122
2235
|
)
|
|
2123
2236
|
);
|
|
2124
|
-
|
|
2237
|
+
CadenzaService.createMetaTask(
|
|
2238
|
+
"Prepare service instance registration",
|
|
2239
|
+
(ctx) => {
|
|
2240
|
+
const serviceName = String(
|
|
2241
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2242
|
+
).trim();
|
|
2243
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2244
|
+
CadenzaService.schedule(
|
|
2245
|
+
"meta.service_registry.instance_registration_requested",
|
|
2246
|
+
{ ...ctx },
|
|
2247
|
+
250
|
|
2248
|
+
);
|
|
2249
|
+
return false;
|
|
2250
|
+
}
|
|
2251
|
+
return ctx;
|
|
2252
|
+
},
|
|
2253
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2254
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2255
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2125
2256
|
"service_instance_transport",
|
|
2126
2257
|
{
|
|
2127
2258
|
onConflict: {
|
|
@@ -2186,7 +2317,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2186
2317
|
retryCount: 5,
|
|
2187
2318
|
retryDelay: 1e3
|
|
2188
2319
|
}
|
|
2189
|
-
).
|
|
2320
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2321
|
+
CadenzaService.createMetaTask(
|
|
2322
|
+
"Prepare service transport registration",
|
|
2323
|
+
(ctx) => {
|
|
2324
|
+
const serviceName = String(
|
|
2325
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2326
|
+
).trim();
|
|
2327
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2328
|
+
CadenzaService.schedule(
|
|
2329
|
+
"meta.service_registry.transport_registration_requested",
|
|
2330
|
+
{ ...ctx },
|
|
2331
|
+
250
|
|
2332
|
+
);
|
|
2333
|
+
return false;
|
|
2334
|
+
}
|
|
2335
|
+
return ctx;
|
|
2336
|
+
},
|
|
2337
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2338
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2190
2339
|
CadenzaService.createMetaTask(
|
|
2191
2340
|
"Handle service creation",
|
|
2192
2341
|
(ctx) => {
|
|
@@ -3456,6 +3605,16 @@ var RestController = class _RestController {
|
|
|
3456
3605
|
is_blocked: false,
|
|
3457
3606
|
health: {}
|
|
3458
3607
|
},
|
|
3608
|
+
__registrationData: {
|
|
3609
|
+
uuid: ctx.__serviceInstanceId,
|
|
3610
|
+
process_pid: 1,
|
|
3611
|
+
service_name: ctx.__serviceName,
|
|
3612
|
+
is_frontend: true,
|
|
3613
|
+
is_active: true,
|
|
3614
|
+
is_non_responsive: false,
|
|
3615
|
+
is_blocked: false,
|
|
3616
|
+
health: {}
|
|
3617
|
+
},
|
|
3459
3618
|
__transportData: [],
|
|
3460
3619
|
...ctx
|
|
3461
3620
|
});
|
|
@@ -3755,6 +3914,9 @@ var RestController = class _RestController {
|
|
|
3755
3914
|
is_blocked: false,
|
|
3756
3915
|
health: {}
|
|
3757
3916
|
};
|
|
3917
|
+
ctx.__registrationData = {
|
|
3918
|
+
...ctx.data
|
|
3919
|
+
};
|
|
3758
3920
|
ctx.__transportData = transportData;
|
|
3759
3921
|
delete ctx.__app;
|
|
3760
3922
|
CadenzaService.emit(
|
|
@@ -8163,12 +8325,6 @@ var import_uuid5 = require("uuid");
|
|
|
8163
8325
|
|
|
8164
8326
|
// src/graph/controllers/GraphSyncController.ts
|
|
8165
8327
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8166
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
8167
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
8168
|
-
);
|
|
8169
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
8170
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
8171
|
-
);
|
|
8172
8328
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8173
8329
|
if (typeof taskFunction !== "function") {
|
|
8174
8330
|
return void 0;
|
|
@@ -8245,38 +8401,86 @@ function buildIntentRegistryData(intent) {
|
|
|
8245
8401
|
isMeta: isMetaIntentName(name)
|
|
8246
8402
|
};
|
|
8247
8403
|
}
|
|
8404
|
+
function getJoinedContextValue(ctx, key) {
|
|
8405
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
8406
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
8407
|
+
const joinedContext = joinedContexts[index];
|
|
8408
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
8409
|
+
return joinedContext[key];
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8412
|
+
return void 0;
|
|
8413
|
+
}
|
|
8414
|
+
function didSyncInsertSucceed(ctx) {
|
|
8415
|
+
if (ctx.errored || ctx.__success === false) {
|
|
8416
|
+
return false;
|
|
8417
|
+
}
|
|
8418
|
+
const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
|
|
8419
|
+
if (!inquiryMeta) {
|
|
8420
|
+
return true;
|
|
8421
|
+
}
|
|
8422
|
+
const eligibleResponders = Number(inquiryMeta.eligibleResponders);
|
|
8423
|
+
if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
|
|
8424
|
+
return false;
|
|
8425
|
+
}
|
|
8426
|
+
const responded = Number(inquiryMeta.responded);
|
|
8427
|
+
if (Number.isFinite(responded) && responded === 0) {
|
|
8428
|
+
return false;
|
|
8429
|
+
}
|
|
8430
|
+
return true;
|
|
8431
|
+
}
|
|
8432
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
8433
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
8434
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
8435
|
+
const nextQueryData = {
|
|
8436
|
+
...existingQueryData,
|
|
8437
|
+
...queryData
|
|
8438
|
+
};
|
|
8439
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
8440
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
8441
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
8442
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
8443
|
+
}
|
|
8444
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
8445
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
8446
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
8447
|
+
) : resolvedBatch;
|
|
8448
|
+
}
|
|
8449
|
+
return nextQueryData;
|
|
8450
|
+
}
|
|
8248
8451
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8249
8452
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
}
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8453
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8454
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
8455
|
+
return void 0;
|
|
8456
|
+
}
|
|
8457
|
+
return CadenzaService.createUniqueMetaTask(
|
|
8458
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
8459
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
8460
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
8461
|
+
if (!targetTask) {
|
|
8462
|
+
return false;
|
|
8463
|
+
}
|
|
8464
|
+
return targetTask.taskFunction(
|
|
8465
|
+
{
|
|
8262
8466
|
...ctx,
|
|
8263
|
-
queryData:
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8467
|
+
queryData: buildSyncInsertQueryData(
|
|
8468
|
+
ctx,
|
|
8469
|
+
queryData
|
|
8470
|
+
)
|
|
8471
|
+
},
|
|
8472
|
+
emit,
|
|
8473
|
+
inquire,
|
|
8474
|
+
progressCallback
|
|
8475
|
+
);
|
|
8476
|
+
},
|
|
8477
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8478
|
+
{
|
|
8479
|
+
...options,
|
|
8480
|
+
register: false,
|
|
8481
|
+
isHidden: true
|
|
8276
8482
|
}
|
|
8277
|
-
|
|
8278
|
-
}
|
|
8279
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8483
|
+
);
|
|
8280
8484
|
}
|
|
8281
8485
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
8282
8486
|
"intent_registry",
|
|
@@ -8295,11 +8499,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8295
8499
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
8296
8500
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
8297
8501
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
8298
|
-
this.
|
|
8502
|
+
this.tasksSynced = false;
|
|
8503
|
+
this.signalsSynced = false;
|
|
8504
|
+
this.intentsSynced = false;
|
|
8505
|
+
this.routinesSynced = false;
|
|
8299
8506
|
this.isCadenzaDBReady = false;
|
|
8300
8507
|
this.initialized = false;
|
|
8301
8508
|
this.initRetryScheduled = false;
|
|
8302
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
8303
8509
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
8304
8510
|
}
|
|
8305
8511
|
static get instance() {
|
|
@@ -8374,21 +8580,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8374
8580
|
},
|
|
8375
8581
|
{ concurrency: 30 }
|
|
8376
8582
|
);
|
|
8583
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
8584
|
+
this.isCadenzaDBReady,
|
|
8585
|
+
"intent_registry",
|
|
8586
|
+
{
|
|
8587
|
+
onConflict: {
|
|
8588
|
+
target: ["name"],
|
|
8589
|
+
action: {
|
|
8590
|
+
do: "nothing"
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
},
|
|
8594
|
+
{ concurrency: 30 }
|
|
8595
|
+
);
|
|
8377
8596
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
8378
8597
|
"Split routines for registration",
|
|
8379
|
-
|
|
8598
|
+
(ctx, emit) => {
|
|
8380
8599
|
const { routines } = ctx;
|
|
8381
|
-
if (!routines) return;
|
|
8600
|
+
if (!routines) return false;
|
|
8382
8601
|
const serviceName2 = resolveSyncServiceName();
|
|
8383
8602
|
if (!serviceName2) {
|
|
8384
|
-
return;
|
|
8603
|
+
return false;
|
|
8385
8604
|
}
|
|
8386
8605
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8387
8606
|
delayMs: 2e3
|
|
8388
8607
|
});
|
|
8608
|
+
let emittedCount = 0;
|
|
8389
8609
|
for (const routine of routines) {
|
|
8390
8610
|
if (routine.registered) continue;
|
|
8391
|
-
|
|
8611
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
8612
|
+
__syncing: ctx.__syncing,
|
|
8392
8613
|
data: {
|
|
8393
8614
|
name: routine.name,
|
|
8394
8615
|
version: routine.version,
|
|
@@ -8397,10 +8618,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8397
8618
|
isMeta: routine.isMeta
|
|
8398
8619
|
},
|
|
8399
8620
|
__routineName: routine.name
|
|
8400
|
-
};
|
|
8621
|
+
});
|
|
8622
|
+
emittedCount += 1;
|
|
8401
8623
|
}
|
|
8624
|
+
return emittedCount > 0;
|
|
8402
8625
|
}
|
|
8403
|
-
)
|
|
8626
|
+
);
|
|
8627
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
8404
8628
|
resolveSyncInsertTask(
|
|
8405
8629
|
this.isCadenzaDBReady,
|
|
8406
8630
|
"routine",
|
|
@@ -8415,39 +8639,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8415
8639
|
{ concurrency: 30 }
|
|
8416
8640
|
)?.then(
|
|
8417
8641
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
8418
|
-
if (!ctx.__syncing) {
|
|
8642
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8419
8643
|
return;
|
|
8420
8644
|
}
|
|
8421
8645
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8422
8646
|
delayMs: 3e3
|
|
8423
8647
|
});
|
|
8424
8648
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
8649
|
+
CadenzaService.debounce(
|
|
8650
|
+
"meta.sync_controller.routine_registration_settled",
|
|
8651
|
+
{ __syncing: true },
|
|
8652
|
+
300
|
|
8653
|
+
);
|
|
8425
8654
|
return true;
|
|
8426
|
-
})
|
|
8427
|
-
CadenzaService.createUniqueMetaTask(
|
|
8428
|
-
"Gather routine registration",
|
|
8429
|
-
() => true
|
|
8430
|
-
).emits("meta.sync_controller.synced_routines")
|
|
8431
|
-
)
|
|
8655
|
+
})
|
|
8432
8656
|
)
|
|
8433
8657
|
);
|
|
8658
|
+
CadenzaService.createUniqueMetaTask(
|
|
8659
|
+
"Gather routine registration",
|
|
8660
|
+
() => {
|
|
8661
|
+
this.routinesSynced = true;
|
|
8662
|
+
return true;
|
|
8663
|
+
}
|
|
8664
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
8434
8665
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
8435
8666
|
"Split tasks in routines",
|
|
8436
|
-
|
|
8667
|
+
(ctx, emit) => {
|
|
8437
8668
|
const { routines } = ctx;
|
|
8438
|
-
if (!routines) return;
|
|
8669
|
+
if (!routines) return false;
|
|
8439
8670
|
const serviceName2 = resolveSyncServiceName();
|
|
8440
8671
|
if (!serviceName2) {
|
|
8441
|
-
return;
|
|
8672
|
+
return false;
|
|
8442
8673
|
}
|
|
8443
8674
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8444
8675
|
delayMs: 3e3
|
|
8445
8676
|
});
|
|
8677
|
+
let emittedCount = 0;
|
|
8446
8678
|
for (const routine of routines) {
|
|
8447
8679
|
if (!routine.registered) continue;
|
|
8448
8680
|
for (const task of routine.tasks) {
|
|
8449
8681
|
if (!task) {
|
|
8450
|
-
console.log("task is null", routine, task);
|
|
8451
8682
|
continue;
|
|
8452
8683
|
}
|
|
8453
8684
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -8457,7 +8688,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8457
8688
|
if (!nextTask?.registered) {
|
|
8458
8689
|
continue;
|
|
8459
8690
|
}
|
|
8460
|
-
|
|
8691
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
8692
|
+
__syncing: ctx.__syncing,
|
|
8461
8693
|
data: {
|
|
8462
8694
|
taskName: nextTask.name,
|
|
8463
8695
|
taskVersion: nextTask.version,
|
|
@@ -8467,12 +8699,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8467
8699
|
},
|
|
8468
8700
|
__routineName: routine.name,
|
|
8469
8701
|
__taskName: nextTask.name
|
|
8470
|
-
};
|
|
8702
|
+
});
|
|
8703
|
+
emittedCount += 1;
|
|
8471
8704
|
}
|
|
8472
8705
|
}
|
|
8473
8706
|
}
|
|
8707
|
+
return emittedCount > 0;
|
|
8474
8708
|
}
|
|
8475
|
-
)
|
|
8709
|
+
);
|
|
8710
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
8476
8711
|
resolveSyncInsertTask(
|
|
8477
8712
|
this.isCadenzaDBReady,
|
|
8478
8713
|
"task_to_routine_map",
|
|
@@ -8493,7 +8728,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8493
8728
|
{ concurrency: 30 }
|
|
8494
8729
|
)?.then(
|
|
8495
8730
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
8496
|
-
if (!ctx.__syncing) {
|
|
8731
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8497
8732
|
return;
|
|
8498
8733
|
}
|
|
8499
8734
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8507,18 +8742,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8507
8742
|
);
|
|
8508
8743
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
8509
8744
|
"Split signals for registration",
|
|
8510
|
-
|
|
8745
|
+
(ctx, emit) => {
|
|
8511
8746
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8512
8747
|
delayMs: 3e3
|
|
8513
8748
|
});
|
|
8514
8749
|
const { signals } = ctx;
|
|
8515
|
-
if (!signals) return;
|
|
8750
|
+
if (!signals) return false;
|
|
8516
8751
|
const filteredSignals = signals.filter(
|
|
8517
8752
|
(signal) => !signal.data.registered
|
|
8518
8753
|
).map((signal) => signal.signal);
|
|
8519
8754
|
for (const signal of filteredSignals) {
|
|
8520
8755
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
8521
|
-
|
|
8756
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
8757
|
+
__syncing: ctx.__syncing,
|
|
8522
8758
|
data: {
|
|
8523
8759
|
name: signal,
|
|
8524
8760
|
isGlobal,
|
|
@@ -8527,10 +8763,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8527
8763
|
isMeta
|
|
8528
8764
|
},
|
|
8529
8765
|
__signal: signal
|
|
8530
|
-
};
|
|
8766
|
+
});
|
|
8531
8767
|
}
|
|
8768
|
+
return filteredSignals.length > 0;
|
|
8532
8769
|
}
|
|
8533
|
-
)
|
|
8770
|
+
);
|
|
8771
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
8534
8772
|
resolveSyncInsertTask(
|
|
8535
8773
|
this.isCadenzaDBReady,
|
|
8536
8774
|
"signal_registry",
|
|
@@ -8545,37 +8783,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8545
8783
|
{ concurrency: 30 }
|
|
8546
8784
|
)?.then(
|
|
8547
8785
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
8548
|
-
if (!ctx.__syncing) {
|
|
8786
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8549
8787
|
return;
|
|
8550
8788
|
}
|
|
8551
8789
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8552
8790
|
delayMs: 3e3
|
|
8553
8791
|
});
|
|
8792
|
+
CadenzaService.debounce(
|
|
8793
|
+
"meta.sync_controller.signal_registration_settled",
|
|
8794
|
+
{ __syncing: true },
|
|
8795
|
+
300
|
|
8796
|
+
);
|
|
8554
8797
|
return { signalName: ctx.__signal };
|
|
8555
|
-
}).then(
|
|
8556
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
8557
|
-
CadenzaService.createUniqueMetaTask(
|
|
8558
|
-
"Gather signal registration",
|
|
8559
|
-
() => true
|
|
8560
|
-
).emits("meta.sync_controller.synced_signals")
|
|
8561
|
-
)
|
|
8798
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
8562
8799
|
)
|
|
8563
8800
|
);
|
|
8801
|
+
CadenzaService.createUniqueMetaTask(
|
|
8802
|
+
"Gather signal registration",
|
|
8803
|
+
() => {
|
|
8804
|
+
this.signalsSynced = true;
|
|
8805
|
+
return true;
|
|
8806
|
+
}
|
|
8807
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
8564
8808
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
8565
8809
|
"Split tasks for registration",
|
|
8566
|
-
|
|
8810
|
+
(ctx, emit) => {
|
|
8567
8811
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8568
8812
|
delayMs: 3e3
|
|
8569
8813
|
});
|
|
8570
8814
|
const tasks = ctx.tasks;
|
|
8571
8815
|
const serviceName2 = resolveSyncServiceName();
|
|
8572
8816
|
if (!serviceName2) {
|
|
8573
|
-
return;
|
|
8817
|
+
return false;
|
|
8574
8818
|
}
|
|
8819
|
+
let emittedCount = 0;
|
|
8575
8820
|
for (const task of tasks) {
|
|
8576
8821
|
if (task.registered) continue;
|
|
8577
8822
|
const { __functionString, __getTagCallback } = task.export();
|
|
8578
|
-
|
|
8823
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
8824
|
+
__syncing: ctx.__syncing,
|
|
8579
8825
|
data: {
|
|
8580
8826
|
name: task.name,
|
|
8581
8827
|
version: task.version,
|
|
@@ -8593,9 +8839,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8593
8839
|
isMeta: task.isMeta,
|
|
8594
8840
|
isSubMeta: task.isSubMeta,
|
|
8595
8841
|
isHidden: task.isHidden,
|
|
8596
|
-
// inputSchema: task.inputSchema,
|
|
8597
8842
|
validateInputContext: task.validateInputContext,
|
|
8598
|
-
// outputSchema: task.outputSchema,
|
|
8599
8843
|
validateOutputContext: task.validateOutputContext,
|
|
8600
8844
|
retryCount: task.retryCount,
|
|
8601
8845
|
retryDelay: task.retryDelay,
|
|
@@ -8610,10 +8854,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8610
8854
|
}
|
|
8611
8855
|
},
|
|
8612
8856
|
__taskName: task.name
|
|
8613
|
-
};
|
|
8857
|
+
});
|
|
8858
|
+
emittedCount += 1;
|
|
8614
8859
|
}
|
|
8860
|
+
return emittedCount > 0;
|
|
8615
8861
|
}
|
|
8616
|
-
)
|
|
8862
|
+
);
|
|
8863
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
8617
8864
|
resolveSyncInsertTask(
|
|
8618
8865
|
this.isCadenzaDBReady,
|
|
8619
8866
|
"task",
|
|
@@ -8628,7 +8875,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8628
8875
|
{ concurrency: 30 }
|
|
8629
8876
|
)?.then(
|
|
8630
8877
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
8631
|
-
if (!ctx.__syncing) {
|
|
8878
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8632
8879
|
return;
|
|
8633
8880
|
}
|
|
8634
8881
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8639,15 +8886,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8639
8886
|
...ctx,
|
|
8640
8887
|
task: CadenzaService.get(ctx.__taskName)
|
|
8641
8888
|
});
|
|
8889
|
+
CadenzaService.debounce(
|
|
8890
|
+
"meta.sync_controller.task_registration_settled",
|
|
8891
|
+
{ __syncing: true },
|
|
8892
|
+
300
|
|
8893
|
+
);
|
|
8642
8894
|
return true;
|
|
8643
|
-
})
|
|
8644
|
-
CadenzaService.createUniqueMetaTask(
|
|
8645
|
-
"Gather task registration",
|
|
8646
|
-
() => true
|
|
8647
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
8648
|
-
)
|
|
8895
|
+
})
|
|
8649
8896
|
)
|
|
8650
8897
|
);
|
|
8898
|
+
CadenzaService.createUniqueMetaTask(
|
|
8899
|
+
"Gather task registration",
|
|
8900
|
+
() => {
|
|
8901
|
+
this.tasksSynced = true;
|
|
8902
|
+
return true;
|
|
8903
|
+
}
|
|
8904
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
8651
8905
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
8652
8906
|
"Split actors for registration",
|
|
8653
8907
|
function* (ctx) {
|
|
@@ -8692,22 +8946,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8692
8946
|
{ concurrency: 30 }
|
|
8693
8947
|
)?.then(
|
|
8694
8948
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
8695
|
-
if (!ctx.__syncing) {
|
|
8949
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8696
8950
|
return;
|
|
8697
8951
|
}
|
|
8698
8952
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8699
8953
|
delayMs: 3e3
|
|
8700
8954
|
});
|
|
8701
8955
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
8956
|
+
CadenzaService.debounce(
|
|
8957
|
+
"meta.sync_controller.actor_registration_settled",
|
|
8958
|
+
{ __syncing: true },
|
|
8959
|
+
300
|
|
8960
|
+
);
|
|
8702
8961
|
return true;
|
|
8703
|
-
})
|
|
8704
|
-
CadenzaService.createUniqueMetaTask(
|
|
8705
|
-
"Gather actor registration",
|
|
8706
|
-
() => true
|
|
8707
|
-
).emits("meta.sync_controller.synced_actors")
|
|
8708
|
-
)
|
|
8962
|
+
})
|
|
8709
8963
|
)
|
|
8710
8964
|
);
|
|
8965
|
+
CadenzaService.createUniqueMetaTask(
|
|
8966
|
+
"Gather actor registration",
|
|
8967
|
+
() => true
|
|
8968
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
8711
8969
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
8712
8970
|
"Split actor task maps",
|
|
8713
8971
|
function* (ctx) {
|
|
@@ -8762,7 +9020,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8762
9020
|
{ concurrency: 30 }
|
|
8763
9021
|
)?.then(
|
|
8764
9022
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
8765
|
-
if (!ctx.__syncing) {
|
|
9023
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8766
9024
|
return;
|
|
8767
9025
|
}
|
|
8768
9026
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8775,7 +9033,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8775
9033
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
8776
9034
|
"Record signal registration",
|
|
8777
9035
|
(ctx) => {
|
|
8778
|
-
if (!ctx.__syncing) {
|
|
9036
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8779
9037
|
return;
|
|
8780
9038
|
}
|
|
8781
9039
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8786,13 +9044,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8786
9044
|
);
|
|
8787
9045
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
8788
9046
|
"Split observed signals of task",
|
|
8789
|
-
|
|
9047
|
+
(ctx, emit) => {
|
|
8790
9048
|
const task = ctx.task;
|
|
8791
|
-
if (task.hidden || !task.register) return;
|
|
9049
|
+
if (task.hidden || !task.register) return false;
|
|
8792
9050
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8793
9051
|
if (!serviceName2) {
|
|
8794
|
-
return;
|
|
9052
|
+
return false;
|
|
8795
9053
|
}
|
|
9054
|
+
let emittedCount = 0;
|
|
8796
9055
|
for (const signal of task.observedSignals) {
|
|
8797
9056
|
const _signal = signal.split(":")[0];
|
|
8798
9057
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -8800,7 +9059,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8800
9059
|
continue;
|
|
8801
9060
|
}
|
|
8802
9061
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
8803
|
-
|
|
9062
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
9063
|
+
__syncing: ctx.__syncing,
|
|
8804
9064
|
data: {
|
|
8805
9065
|
signalName: _signal,
|
|
8806
9066
|
isGlobal,
|
|
@@ -8810,10 +9070,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8810
9070
|
},
|
|
8811
9071
|
__taskName: task.name,
|
|
8812
9072
|
__signal: signal
|
|
8813
|
-
};
|
|
9073
|
+
});
|
|
9074
|
+
emittedCount += 1;
|
|
8814
9075
|
}
|
|
9076
|
+
return emittedCount > 0;
|
|
8815
9077
|
}
|
|
8816
|
-
)
|
|
9078
|
+
);
|
|
9079
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
8817
9080
|
resolveSyncInsertTask(
|
|
8818
9081
|
this.isCadenzaDBReady,
|
|
8819
9082
|
"signal_to_task_map",
|
|
@@ -8835,29 +9098,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8835
9098
|
);
|
|
8836
9099
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
8837
9100
|
"Split intents for registration",
|
|
8838
|
-
function
|
|
9101
|
+
function(ctx, emit) {
|
|
8839
9102
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8840
9103
|
delayMs: 3e3
|
|
8841
9104
|
});
|
|
8842
9105
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
8843
|
-
|
|
8844
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
8845
|
-
const authorityIntentNames = intentNames.filter(
|
|
8846
|
-
(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")
|
|
8847
|
-
);
|
|
8848
|
-
CadenzaService.log(
|
|
8849
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
8850
|
-
{
|
|
8851
|
-
totalIntents: intentNames.length,
|
|
8852
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
8853
|
-
"meta-service-registry-full-sync"
|
|
8854
|
-
),
|
|
8855
|
-
authorityIntentNames
|
|
8856
|
-
},
|
|
8857
|
-
"info"
|
|
8858
|
-
);
|
|
8859
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
8860
|
-
}
|
|
9106
|
+
let emittedCount = 0;
|
|
8861
9107
|
for (const intent of intents) {
|
|
8862
9108
|
const intentData = buildIntentRegistryData(intent);
|
|
8863
9109
|
if (!intentData) {
|
|
@@ -8866,35 +9112,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8866
9112
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
8867
9113
|
continue;
|
|
8868
9114
|
}
|
|
8869
|
-
|
|
9115
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
9116
|
+
__syncing: ctx.__syncing,
|
|
8870
9117
|
data: intentData,
|
|
8871
9118
|
__intentName: intentData.name
|
|
8872
|
-
};
|
|
9119
|
+
});
|
|
9120
|
+
emittedCount += 1;
|
|
8873
9121
|
}
|
|
9122
|
+
return emittedCount > 0;
|
|
8874
9123
|
}.bind(this)
|
|
8875
|
-
)
|
|
9124
|
+
);
|
|
9125
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
8876
9126
|
insertIntentRegistryTask?.then(
|
|
8877
9127
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
8878
|
-
if (!ctx.__syncing) {
|
|
9128
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8879
9129
|
return;
|
|
8880
9130
|
}
|
|
8881
9131
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8882
9132
|
delayMs: 3e3
|
|
8883
9133
|
});
|
|
8884
9134
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9135
|
+
CadenzaService.debounce(
|
|
9136
|
+
"meta.sync_controller.intent_registration_settled",
|
|
9137
|
+
{ __syncing: true },
|
|
9138
|
+
300
|
|
9139
|
+
);
|
|
8885
9140
|
return true;
|
|
8886
|
-
})
|
|
8887
|
-
CadenzaService.createUniqueMetaTask(
|
|
8888
|
-
"Gather intent registration",
|
|
8889
|
-
() => true
|
|
8890
|
-
).emits("meta.sync_controller.synced_intents")
|
|
8891
|
-
)
|
|
9141
|
+
})
|
|
8892
9142
|
)
|
|
8893
9143
|
);
|
|
9144
|
+
CadenzaService.createUniqueMetaTask(
|
|
9145
|
+
"Gather intent registration",
|
|
9146
|
+
() => {
|
|
9147
|
+
this.intentsSynced = true;
|
|
9148
|
+
return true;
|
|
9149
|
+
}
|
|
9150
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
8894
9151
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
8895
9152
|
"Record intent registration",
|
|
8896
9153
|
(ctx) => {
|
|
8897
|
-
if (!ctx.__syncing) {
|
|
9154
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8898
9155
|
return;
|
|
8899
9156
|
}
|
|
8900
9157
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8907,37 +9164,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8907
9164
|
);
|
|
8908
9165
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
8909
9166
|
"Split intents of task",
|
|
8910
|
-
function
|
|
9167
|
+
function(ctx, emit) {
|
|
8911
9168
|
const task = ctx.task;
|
|
8912
|
-
if (task.hidden || !task.register) return;
|
|
9169
|
+
if (task.hidden || !task.register) return false;
|
|
8913
9170
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8914
9171
|
if (!serviceName2) {
|
|
8915
|
-
return;
|
|
9172
|
+
return false;
|
|
8916
9173
|
}
|
|
8917
9174
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
8918
9175
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
8919
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
8920
|
-
"Query service_instance",
|
|
8921
|
-
"Query service_instance_transport",
|
|
8922
|
-
"Query intent_to_task_map",
|
|
8923
|
-
"Query signal_to_task_map"
|
|
8924
|
-
].includes(task.name)) {
|
|
8925
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
8926
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
8927
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
8928
|
-
CadenzaService.log(
|
|
8929
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
8930
|
-
{
|
|
8931
|
-
taskName: task.name,
|
|
8932
|
-
taskVersion: task.version,
|
|
8933
|
-
isMeta: task.isMeta,
|
|
8934
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
8935
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
8936
|
-
},
|
|
8937
|
-
"info"
|
|
8938
|
-
);
|
|
8939
|
-
}
|
|
8940
|
-
}
|
|
8941
9176
|
for (const intent of task.handlesIntents) {
|
|
8942
9177
|
if (task.__registeredIntents.has(intent)) continue;
|
|
8943
9178
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -8959,7 +9194,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8959
9194
|
if (!intentDefinition) {
|
|
8960
9195
|
continue;
|
|
8961
9196
|
}
|
|
8962
|
-
|
|
9197
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
9198
|
+
__syncing: ctx.__syncing,
|
|
8963
9199
|
data: {
|
|
8964
9200
|
intentName: intent,
|
|
8965
9201
|
taskName: task.name,
|
|
@@ -8975,10 +9211,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8975
9211
|
taskVersion: task.version,
|
|
8976
9212
|
serviceName: serviceName2
|
|
8977
9213
|
}
|
|
8978
|
-
};
|
|
9214
|
+
});
|
|
8979
9215
|
}
|
|
9216
|
+
return true;
|
|
8980
9217
|
}.bind(this)
|
|
8981
|
-
)
|
|
9218
|
+
);
|
|
9219
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
8982
9220
|
CadenzaService.createMetaTask(
|
|
8983
9221
|
"Prepare intent definition for intent-to-task map",
|
|
8984
9222
|
(ctx) => {
|
|
@@ -8991,7 +9229,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8991
9229
|
};
|
|
8992
9230
|
}
|
|
8993
9231
|
).then(
|
|
8994
|
-
|
|
9232
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
8995
9233
|
CadenzaService.createMetaTask(
|
|
8996
9234
|
"Restore intent-to-task map payload",
|
|
8997
9235
|
(ctx) => {
|
|
@@ -9039,7 +9277,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9039
9277
|
return;
|
|
9040
9278
|
}
|
|
9041
9279
|
for (const t of task.nextTasks) {
|
|
9042
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
9280
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
9043
9281
|
continue;
|
|
9044
9282
|
}
|
|
9045
9283
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -9082,7 +9320,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9082
9320
|
{ concurrency: 30 }
|
|
9083
9321
|
)?.then(
|
|
9084
9322
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
9085
|
-
if (!ctx.__syncing) {
|
|
9323
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9086
9324
|
return;
|
|
9087
9325
|
}
|
|
9088
9326
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9143,7 +9381,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9143
9381
|
CadenzaService.createMetaTask(
|
|
9144
9382
|
"Record deputy relationship registration",
|
|
9145
9383
|
(ctx) => {
|
|
9146
|
-
if (!ctx.__syncing) {
|
|
9384
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9147
9385
|
return;
|
|
9148
9386
|
}
|
|
9149
9387
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9158,19 +9396,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9158
9396
|
"meta.sync_controller.sync_tick",
|
|
9159
9397
|
"meta.service_registry.initial_sync_complete"
|
|
9160
9398
|
).then(this.splitSignalsTask);
|
|
9161
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9399
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9400
|
+
"meta.sync_controller.sync_tick",
|
|
9401
|
+
"meta.sync_controller.synced_signals"
|
|
9402
|
+
).then(this.splitTasksForRegistration);
|
|
9162
9403
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
9163
9404
|
return {
|
|
9164
9405
|
...ctx,
|
|
9165
9406
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
9166
9407
|
};
|
|
9167
9408
|
}).doOn(
|
|
9168
|
-
"meta.sync_controller.
|
|
9169
|
-
"meta.
|
|
9409
|
+
"meta.sync_controller.sync_tick",
|
|
9410
|
+
"meta.service_registry.initial_sync_complete"
|
|
9170
9411
|
).then(this.splitIntentsTask);
|
|
9171
9412
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9172
|
-
"meta.sync_controller.
|
|
9173
|
-
"meta.
|
|
9413
|
+
"meta.sync_controller.sync_tick",
|
|
9414
|
+
"meta.service_registry.initial_sync_complete"
|
|
9174
9415
|
).then(this.splitRoutinesTask);
|
|
9175
9416
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
9176
9417
|
return {
|
|
@@ -9178,16 +9419,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9178
9419
|
actors: CadenzaService.getAllActors()
|
|
9179
9420
|
};
|
|
9180
9421
|
}).doOn(
|
|
9181
|
-
"meta.sync_controller.
|
|
9182
|
-
"meta.
|
|
9422
|
+
"meta.sync_controller.sync_tick",
|
|
9423
|
+
"meta.service_registry.initial_sync_complete"
|
|
9183
9424
|
).then(this.splitActorsForRegistration);
|
|
9184
|
-
CadenzaService.
|
|
9425
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
9426
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9427
|
+
if (!task) {
|
|
9428
|
+
return false;
|
|
9429
|
+
}
|
|
9430
|
+
return {
|
|
9431
|
+
...ctx,
|
|
9432
|
+
task
|
|
9433
|
+
};
|
|
9434
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9185
9435
|
this.registerTaskMapTask,
|
|
9186
9436
|
this.registerDeputyRelationshipTask
|
|
9187
9437
|
);
|
|
9188
9438
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9189
9439
|
"meta.sync_controller.synced_signals"
|
|
9190
|
-
).then(
|
|
9440
|
+
).then(
|
|
9441
|
+
CadenzaService.createMetaTask(
|
|
9442
|
+
"Ensure signal and task sync ready",
|
|
9443
|
+
(ctx) => {
|
|
9444
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9445
|
+
return false;
|
|
9446
|
+
}
|
|
9447
|
+
return ctx;
|
|
9448
|
+
}
|
|
9449
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9450
|
+
);
|
|
9191
9451
|
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
9192
9452
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9193
9453
|
if (!task) {
|
|
@@ -9197,8 +9457,28 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9197
9457
|
...ctx,
|
|
9198
9458
|
task
|
|
9199
9459
|
};
|
|
9200
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9201
|
-
|
|
9460
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9461
|
+
CadenzaService.createMetaTask(
|
|
9462
|
+
"Ensure signal and task sync ready from task registration",
|
|
9463
|
+
(ctx) => {
|
|
9464
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9465
|
+
return false;
|
|
9466
|
+
}
|
|
9467
|
+
return ctx;
|
|
9468
|
+
}
|
|
9469
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9470
|
+
);
|
|
9471
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
9472
|
+
CadenzaService.createMetaTask(
|
|
9473
|
+
"Ensure intent and task sync ready",
|
|
9474
|
+
(ctx) => {
|
|
9475
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9476
|
+
return false;
|
|
9477
|
+
}
|
|
9478
|
+
return ctx;
|
|
9479
|
+
}
|
|
9480
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9481
|
+
);
|
|
9202
9482
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
9203
9483
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9204
9484
|
if (!task) {
|
|
@@ -9208,7 +9488,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9208
9488
|
...ctx,
|
|
9209
9489
|
task
|
|
9210
9490
|
};
|
|
9211
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9491
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9492
|
+
CadenzaService.createMetaTask(
|
|
9493
|
+
"Ensure intent and task sync ready from task registration",
|
|
9494
|
+
(ctx) => {
|
|
9495
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9496
|
+
return false;
|
|
9497
|
+
}
|
|
9498
|
+
return ctx;
|
|
9499
|
+
}
|
|
9500
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9501
|
+
);
|
|
9212
9502
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
9213
9503
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
9214
9504
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
@@ -9221,9 +9511,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9221
9511
|
};
|
|
9222
9512
|
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
9223
9513
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9224
|
-
"meta.sync_controller.
|
|
9225
|
-
"meta.sync_controller.
|
|
9226
|
-
).then(
|
|
9514
|
+
"meta.sync_controller.synced_routines",
|
|
9515
|
+
"meta.sync_controller.task_registered"
|
|
9516
|
+
).then(
|
|
9517
|
+
CadenzaService.createMetaTask(
|
|
9518
|
+
"Ensure routine and task sync ready",
|
|
9519
|
+
(ctx) => {
|
|
9520
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
9521
|
+
return false;
|
|
9522
|
+
}
|
|
9523
|
+
return ctx;
|
|
9524
|
+
}
|
|
9525
|
+
).then(this.splitTasksInRoutines)
|
|
9526
|
+
);
|
|
9227
9527
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
9228
9528
|
emit("global.meta.sync_controller.synced", {
|
|
9229
9529
|
data: {
|
|
@@ -9251,6 +9551,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9251
9551
|
{ __syncing: true },
|
|
9252
9552
|
18e4
|
|
9253
9553
|
);
|
|
9554
|
+
CadenzaService.schedule(
|
|
9555
|
+
"meta.sync_controller.sync_tick",
|
|
9556
|
+
{ __syncing: true },
|
|
9557
|
+
250
|
|
9558
|
+
);
|
|
9254
9559
|
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
9255
9560
|
}
|
|
9256
9561
|
}
|
|
@@ -9651,20 +9956,28 @@ var CadenzaService = class {
|
|
|
9651
9956
|
return false;
|
|
9652
9957
|
});
|
|
9653
9958
|
if (responders.length === 0) {
|
|
9959
|
+
const inquiryMeta = {
|
|
9960
|
+
inquiry,
|
|
9961
|
+
isMetaInquiry,
|
|
9962
|
+
totalResponders: allResponders.length,
|
|
9963
|
+
eligibleResponders: 0,
|
|
9964
|
+
filteredOutResponders: allResponders.length,
|
|
9965
|
+
responded: 0,
|
|
9966
|
+
failed: 0,
|
|
9967
|
+
timedOut: 0,
|
|
9968
|
+
pending: 0,
|
|
9969
|
+
durationMs: 0,
|
|
9970
|
+
responders: []
|
|
9971
|
+
};
|
|
9972
|
+
if (options.requireComplete) {
|
|
9973
|
+
throw {
|
|
9974
|
+
__inquiryMeta: inquiryMeta,
|
|
9975
|
+
__error: `Inquiry '${inquiry}' had no eligible responders`,
|
|
9976
|
+
errored: true
|
|
9977
|
+
};
|
|
9978
|
+
}
|
|
9654
9979
|
return {
|
|
9655
|
-
__inquiryMeta:
|
|
9656
|
-
inquiry,
|
|
9657
|
-
isMetaInquiry,
|
|
9658
|
-
totalResponders: allResponders.length,
|
|
9659
|
-
eligibleResponders: 0,
|
|
9660
|
-
filteredOutResponders: allResponders.length,
|
|
9661
|
-
responded: 0,
|
|
9662
|
-
failed: 0,
|
|
9663
|
-
timedOut: 0,
|
|
9664
|
-
pending: 0,
|
|
9665
|
-
durationMs: 0,
|
|
9666
|
-
responders: []
|
|
9667
|
-
}
|
|
9980
|
+
__inquiryMeta: inquiryMeta
|
|
9668
9981
|
};
|
|
9669
9982
|
}
|
|
9670
9983
|
responders.sort(this.compareInquiryResponders.bind(this));
|
|
@@ -10351,6 +10664,12 @@ var CadenzaService = class {
|
|
|
10351
10664
|
displayName: options.displayName ?? "",
|
|
10352
10665
|
isMeta: options.isMeta
|
|
10353
10666
|
},
|
|
10667
|
+
__registrationData: {
|
|
10668
|
+
name: serviceName,
|
|
10669
|
+
description,
|
|
10670
|
+
displayName: options.displayName ?? "",
|
|
10671
|
+
isMeta: options.isMeta
|
|
10672
|
+
},
|
|
10354
10673
|
__serviceName: serviceName,
|
|
10355
10674
|
__serviceInstanceId: serviceId,
|
|
10356
10675
|
__port: options.port,
|
|
@@ -10403,6 +10722,16 @@ var CadenzaService = class {
|
|
|
10403
10722
|
is_blocked: false,
|
|
10404
10723
|
health: {}
|
|
10405
10724
|
},
|
|
10725
|
+
__registrationData: {
|
|
10726
|
+
uuid: serviceId,
|
|
10727
|
+
process_pid: 1,
|
|
10728
|
+
service_name: serviceName,
|
|
10729
|
+
is_frontend: true,
|
|
10730
|
+
is_active: true,
|
|
10731
|
+
is_non_responsive: false,
|
|
10732
|
+
is_blocked: false,
|
|
10733
|
+
health: {}
|
|
10734
|
+
},
|
|
10406
10735
|
__transportData: [],
|
|
10407
10736
|
__serviceName: serviceName,
|
|
10408
10737
|
__serviceInstanceId: serviceId,
|