@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.mjs
CHANGED
|
@@ -686,6 +686,116 @@ 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 normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResult) {
|
|
719
|
+
if (!rawResult || typeof rawResult !== "object") {
|
|
720
|
+
return rawResult;
|
|
721
|
+
}
|
|
722
|
+
const result = { ...rawResult };
|
|
723
|
+
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
724
|
+
const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
725
|
+
if (resolvedData !== void 0 && result.data === void 0) {
|
|
726
|
+
result.data = resolvedData;
|
|
727
|
+
}
|
|
728
|
+
if (resolvedData !== void 0 && (normalizedQueryData.data === void 0 || normalizedQueryData.data === null)) {
|
|
729
|
+
normalizedQueryData.data = resolvedData;
|
|
730
|
+
}
|
|
731
|
+
result.queryData = normalizedQueryData;
|
|
732
|
+
if (tableName === "service") {
|
|
733
|
+
const resolvedServiceName = String(
|
|
734
|
+
result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ctx.__serviceName ?? ""
|
|
735
|
+
).trim();
|
|
736
|
+
if (resolvedServiceName) {
|
|
737
|
+
result.__serviceName = resolvedServiceName;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
741
|
+
const resolvedUuid = String(
|
|
742
|
+
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
743
|
+
).trim();
|
|
744
|
+
if (resolvedUuid) {
|
|
745
|
+
result.uuid = resolvedUuid;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return result;
|
|
749
|
+
}
|
|
750
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
751
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
752
|
+
tableName,
|
|
753
|
+
queryData,
|
|
754
|
+
options
|
|
755
|
+
);
|
|
756
|
+
return CadenzaService.createUniqueMetaTask(
|
|
757
|
+
`Resolve service registry insert for ${tableName}`,
|
|
758
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
759
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
760
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
761
|
+
CadenzaService.log(
|
|
762
|
+
"Service registry insert resolver missing service payload.",
|
|
763
|
+
{
|
|
764
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
765
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
766
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
767
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
768
|
+
},
|
|
769
|
+
"warning"
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
773
|
+
const delegationContext = ensureDelegationContextMetadata({
|
|
774
|
+
...ctx,
|
|
775
|
+
queryData: nextQueryData
|
|
776
|
+
});
|
|
777
|
+
delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
|
|
778
|
+
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
779
|
+
return Promise.resolve(
|
|
780
|
+
targetTask.taskFunction(
|
|
781
|
+
delegationContext,
|
|
782
|
+
emit,
|
|
783
|
+
inquire,
|
|
784
|
+
progressCallback
|
|
785
|
+
)
|
|
786
|
+
).then(
|
|
787
|
+
(result) => normalizeServiceRegistryInsertResult(
|
|
788
|
+
tableName,
|
|
789
|
+
ctx,
|
|
790
|
+
nextQueryData,
|
|
791
|
+
result
|
|
792
|
+
)
|
|
793
|
+
);
|
|
794
|
+
},
|
|
795
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
796
|
+
options
|
|
797
|
+
);
|
|
798
|
+
}
|
|
689
799
|
function readPositiveIntegerEnv(name, fallback) {
|
|
690
800
|
if (typeof process === "undefined") {
|
|
691
801
|
return fallback;
|
|
@@ -1896,7 +2006,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1896
2006
|
},
|
|
1897
2007
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1898
2008
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1899
|
-
this.insertServiceTask =
|
|
2009
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1900
2010
|
"service",
|
|
1901
2011
|
{
|
|
1902
2012
|
onConflict: {
|
|
@@ -1947,7 +2057,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2057
|
retryDelayFactor: 1.3
|
|
1948
2058
|
}
|
|
1949
2059
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
1950
|
-
this.insertServiceInstanceTask =
|
|
2060
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
1951
2061
|
"service_instance",
|
|
1952
2062
|
{},
|
|
1953
2063
|
{
|
|
@@ -2005,7 +2115,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2005
2115
|
retryCount: 5,
|
|
2006
2116
|
retryDelay: 1e3
|
|
2007
2117
|
}
|
|
2008
|
-
).
|
|
2118
|
+
).then(
|
|
2009
2119
|
CadenzaService.createMetaTask(
|
|
2010
2120
|
"Setup service",
|
|
2011
2121
|
(ctx) => {
|
|
@@ -2032,7 +2142,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2032
2142
|
this.useSocket = __useSocket;
|
|
2033
2143
|
this.retryCount = __retryCount;
|
|
2034
2144
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2035
|
-
console.log("SETUP SERVICE", this.serviceInstanceId);
|
|
2036
2145
|
return {
|
|
2037
2146
|
...ctx,
|
|
2038
2147
|
serviceInstance: normalizedLocalInstance,
|
|
@@ -2057,6 +2166,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2057
2166
|
data: {
|
|
2058
2167
|
...transport,
|
|
2059
2168
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2169
|
+
},
|
|
2170
|
+
__registrationData: {
|
|
2171
|
+
...transport,
|
|
2172
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2060
2173
|
}
|
|
2061
2174
|
};
|
|
2062
2175
|
emit(
|
|
@@ -2070,7 +2183,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2070
2183
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2071
2184
|
)
|
|
2072
2185
|
);
|
|
2073
|
-
|
|
2186
|
+
CadenzaService.createMetaTask(
|
|
2187
|
+
"Prepare service instance registration",
|
|
2188
|
+
(ctx) => {
|
|
2189
|
+
const serviceName = String(
|
|
2190
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2191
|
+
).trim();
|
|
2192
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2193
|
+
CadenzaService.schedule(
|
|
2194
|
+
"meta.service_registry.instance_registration_requested",
|
|
2195
|
+
{ ...ctx },
|
|
2196
|
+
250
|
|
2197
|
+
);
|
|
2198
|
+
return false;
|
|
2199
|
+
}
|
|
2200
|
+
return ctx;
|
|
2201
|
+
},
|
|
2202
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2203
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2204
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2074
2205
|
"service_instance_transport",
|
|
2075
2206
|
{
|
|
2076
2207
|
onConflict: {
|
|
@@ -2135,7 +2266,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2135
2266
|
retryCount: 5,
|
|
2136
2267
|
retryDelay: 1e3
|
|
2137
2268
|
}
|
|
2138
|
-
).
|
|
2269
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2270
|
+
CadenzaService.createMetaTask(
|
|
2271
|
+
"Prepare service transport registration",
|
|
2272
|
+
(ctx) => {
|
|
2273
|
+
const serviceName = String(
|
|
2274
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2275
|
+
).trim();
|
|
2276
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2277
|
+
CadenzaService.schedule(
|
|
2278
|
+
"meta.service_registry.transport_registration_requested",
|
|
2279
|
+
{ ...ctx },
|
|
2280
|
+
250
|
|
2281
|
+
);
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
return ctx;
|
|
2285
|
+
},
|
|
2286
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2287
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2139
2288
|
CadenzaService.createMetaTask(
|
|
2140
2289
|
"Handle service creation",
|
|
2141
2290
|
(ctx) => {
|
|
@@ -3405,6 +3554,16 @@ var RestController = class _RestController {
|
|
|
3405
3554
|
is_blocked: false,
|
|
3406
3555
|
health: {}
|
|
3407
3556
|
},
|
|
3557
|
+
__registrationData: {
|
|
3558
|
+
uuid: ctx.__serviceInstanceId,
|
|
3559
|
+
process_pid: 1,
|
|
3560
|
+
service_name: ctx.__serviceName,
|
|
3561
|
+
is_frontend: true,
|
|
3562
|
+
is_active: true,
|
|
3563
|
+
is_non_responsive: false,
|
|
3564
|
+
is_blocked: false,
|
|
3565
|
+
health: {}
|
|
3566
|
+
},
|
|
3408
3567
|
__transportData: [],
|
|
3409
3568
|
...ctx
|
|
3410
3569
|
});
|
|
@@ -3704,6 +3863,9 @@ var RestController = class _RestController {
|
|
|
3704
3863
|
is_blocked: false,
|
|
3705
3864
|
health: {}
|
|
3706
3865
|
};
|
|
3866
|
+
ctx.__registrationData = {
|
|
3867
|
+
...ctx.data
|
|
3868
|
+
};
|
|
3707
3869
|
ctx.__transportData = transportData;
|
|
3708
3870
|
delete ctx.__app;
|
|
3709
3871
|
CadenzaService.emit(
|
|
@@ -8112,12 +8274,6 @@ import { v4 as uuid5 } from "uuid";
|
|
|
8112
8274
|
|
|
8113
8275
|
// src/graph/controllers/GraphSyncController.ts
|
|
8114
8276
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8115
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
8116
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
8117
|
-
);
|
|
8118
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
8119
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
8120
|
-
);
|
|
8121
8277
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8122
8278
|
if (typeof taskFunction !== "function") {
|
|
8123
8279
|
return void 0;
|
|
@@ -8194,38 +8350,86 @@ function buildIntentRegistryData(intent) {
|
|
|
8194
8350
|
isMeta: isMetaIntentName(name)
|
|
8195
8351
|
};
|
|
8196
8352
|
}
|
|
8353
|
+
function getJoinedContextValue(ctx, key) {
|
|
8354
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
8355
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
8356
|
+
const joinedContext = joinedContexts[index];
|
|
8357
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
8358
|
+
return joinedContext[key];
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
return void 0;
|
|
8362
|
+
}
|
|
8363
|
+
function didSyncInsertSucceed(ctx) {
|
|
8364
|
+
if (ctx.errored || ctx.__success === false) {
|
|
8365
|
+
return false;
|
|
8366
|
+
}
|
|
8367
|
+
const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
|
|
8368
|
+
if (!inquiryMeta) {
|
|
8369
|
+
return true;
|
|
8370
|
+
}
|
|
8371
|
+
const eligibleResponders = Number(inquiryMeta.eligibleResponders);
|
|
8372
|
+
if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
|
|
8373
|
+
return false;
|
|
8374
|
+
}
|
|
8375
|
+
const responded = Number(inquiryMeta.responded);
|
|
8376
|
+
if (Number.isFinite(responded) && responded === 0) {
|
|
8377
|
+
return false;
|
|
8378
|
+
}
|
|
8379
|
+
return true;
|
|
8380
|
+
}
|
|
8381
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
8382
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
8383
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
8384
|
+
const nextQueryData = {
|
|
8385
|
+
...existingQueryData,
|
|
8386
|
+
...queryData
|
|
8387
|
+
};
|
|
8388
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
8389
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
8390
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
8391
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
8392
|
+
}
|
|
8393
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
8394
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
8395
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
8396
|
+
) : resolvedBatch;
|
|
8397
|
+
}
|
|
8398
|
+
return nextQueryData;
|
|
8399
|
+
}
|
|
8197
8400
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8198
8401
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
}
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8402
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8403
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
8404
|
+
return void 0;
|
|
8405
|
+
}
|
|
8406
|
+
return CadenzaService.createUniqueMetaTask(
|
|
8407
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
8408
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
8409
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
8410
|
+
if (!targetTask) {
|
|
8411
|
+
return false;
|
|
8412
|
+
}
|
|
8413
|
+
return targetTask.taskFunction(
|
|
8414
|
+
{
|
|
8211
8415
|
...ctx,
|
|
8212
|
-
queryData:
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8416
|
+
queryData: buildSyncInsertQueryData(
|
|
8417
|
+
ctx,
|
|
8418
|
+
queryData
|
|
8419
|
+
)
|
|
8420
|
+
},
|
|
8421
|
+
emit,
|
|
8422
|
+
inquire,
|
|
8423
|
+
progressCallback
|
|
8424
|
+
);
|
|
8425
|
+
},
|
|
8426
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8427
|
+
{
|
|
8428
|
+
...options,
|
|
8429
|
+
register: false,
|
|
8430
|
+
isHidden: true
|
|
8225
8431
|
}
|
|
8226
|
-
|
|
8227
|
-
}
|
|
8228
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
8432
|
+
);
|
|
8229
8433
|
}
|
|
8230
8434
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
8231
8435
|
"intent_registry",
|
|
@@ -8244,11 +8448,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8244
8448
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
8245
8449
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
8246
8450
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
8247
|
-
this.
|
|
8451
|
+
this.tasksSynced = false;
|
|
8452
|
+
this.signalsSynced = false;
|
|
8453
|
+
this.intentsSynced = false;
|
|
8454
|
+
this.routinesSynced = false;
|
|
8248
8455
|
this.isCadenzaDBReady = false;
|
|
8249
8456
|
this.initialized = false;
|
|
8250
8457
|
this.initRetryScheduled = false;
|
|
8251
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
8252
8458
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
8253
8459
|
}
|
|
8254
8460
|
static get instance() {
|
|
@@ -8323,21 +8529,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8323
8529
|
},
|
|
8324
8530
|
{ concurrency: 30 }
|
|
8325
8531
|
);
|
|
8532
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
8533
|
+
this.isCadenzaDBReady,
|
|
8534
|
+
"intent_registry",
|
|
8535
|
+
{
|
|
8536
|
+
onConflict: {
|
|
8537
|
+
target: ["name"],
|
|
8538
|
+
action: {
|
|
8539
|
+
do: "nothing"
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
},
|
|
8543
|
+
{ concurrency: 30 }
|
|
8544
|
+
);
|
|
8326
8545
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
8327
8546
|
"Split routines for registration",
|
|
8328
|
-
|
|
8547
|
+
(ctx, emit) => {
|
|
8329
8548
|
const { routines } = ctx;
|
|
8330
|
-
if (!routines) return;
|
|
8549
|
+
if (!routines) return false;
|
|
8331
8550
|
const serviceName2 = resolveSyncServiceName();
|
|
8332
8551
|
if (!serviceName2) {
|
|
8333
|
-
return;
|
|
8552
|
+
return false;
|
|
8334
8553
|
}
|
|
8335
8554
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8336
8555
|
delayMs: 2e3
|
|
8337
8556
|
});
|
|
8557
|
+
let emittedCount = 0;
|
|
8338
8558
|
for (const routine of routines) {
|
|
8339
8559
|
if (routine.registered) continue;
|
|
8340
|
-
|
|
8560
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
8561
|
+
__syncing: ctx.__syncing,
|
|
8341
8562
|
data: {
|
|
8342
8563
|
name: routine.name,
|
|
8343
8564
|
version: routine.version,
|
|
@@ -8346,10 +8567,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8346
8567
|
isMeta: routine.isMeta
|
|
8347
8568
|
},
|
|
8348
8569
|
__routineName: routine.name
|
|
8349
|
-
};
|
|
8570
|
+
});
|
|
8571
|
+
emittedCount += 1;
|
|
8350
8572
|
}
|
|
8573
|
+
return emittedCount > 0;
|
|
8351
8574
|
}
|
|
8352
|
-
)
|
|
8575
|
+
);
|
|
8576
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
8353
8577
|
resolveSyncInsertTask(
|
|
8354
8578
|
this.isCadenzaDBReady,
|
|
8355
8579
|
"routine",
|
|
@@ -8364,39 +8588,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8364
8588
|
{ concurrency: 30 }
|
|
8365
8589
|
)?.then(
|
|
8366
8590
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
8367
|
-
if (!ctx.__syncing) {
|
|
8591
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8368
8592
|
return;
|
|
8369
8593
|
}
|
|
8370
8594
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8371
8595
|
delayMs: 3e3
|
|
8372
8596
|
});
|
|
8373
8597
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
8598
|
+
CadenzaService.debounce(
|
|
8599
|
+
"meta.sync_controller.routine_registration_settled",
|
|
8600
|
+
{ __syncing: true },
|
|
8601
|
+
300
|
|
8602
|
+
);
|
|
8374
8603
|
return true;
|
|
8375
|
-
})
|
|
8376
|
-
CadenzaService.createUniqueMetaTask(
|
|
8377
|
-
"Gather routine registration",
|
|
8378
|
-
() => true
|
|
8379
|
-
).emits("meta.sync_controller.synced_routines")
|
|
8380
|
-
)
|
|
8604
|
+
})
|
|
8381
8605
|
)
|
|
8382
8606
|
);
|
|
8607
|
+
CadenzaService.createUniqueMetaTask(
|
|
8608
|
+
"Gather routine registration",
|
|
8609
|
+
() => {
|
|
8610
|
+
this.routinesSynced = true;
|
|
8611
|
+
return true;
|
|
8612
|
+
}
|
|
8613
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
8383
8614
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
8384
8615
|
"Split tasks in routines",
|
|
8385
|
-
|
|
8616
|
+
(ctx, emit) => {
|
|
8386
8617
|
const { routines } = ctx;
|
|
8387
|
-
if (!routines) return;
|
|
8618
|
+
if (!routines) return false;
|
|
8388
8619
|
const serviceName2 = resolveSyncServiceName();
|
|
8389
8620
|
if (!serviceName2) {
|
|
8390
|
-
return;
|
|
8621
|
+
return false;
|
|
8391
8622
|
}
|
|
8392
8623
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8393
8624
|
delayMs: 3e3
|
|
8394
8625
|
});
|
|
8626
|
+
let emittedCount = 0;
|
|
8395
8627
|
for (const routine of routines) {
|
|
8396
8628
|
if (!routine.registered) continue;
|
|
8397
8629
|
for (const task of routine.tasks) {
|
|
8398
8630
|
if (!task) {
|
|
8399
|
-
console.log("task is null", routine, task);
|
|
8400
8631
|
continue;
|
|
8401
8632
|
}
|
|
8402
8633
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -8406,7 +8637,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8406
8637
|
if (!nextTask?.registered) {
|
|
8407
8638
|
continue;
|
|
8408
8639
|
}
|
|
8409
|
-
|
|
8640
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
8641
|
+
__syncing: ctx.__syncing,
|
|
8410
8642
|
data: {
|
|
8411
8643
|
taskName: nextTask.name,
|
|
8412
8644
|
taskVersion: nextTask.version,
|
|
@@ -8416,12 +8648,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8416
8648
|
},
|
|
8417
8649
|
__routineName: routine.name,
|
|
8418
8650
|
__taskName: nextTask.name
|
|
8419
|
-
};
|
|
8651
|
+
});
|
|
8652
|
+
emittedCount += 1;
|
|
8420
8653
|
}
|
|
8421
8654
|
}
|
|
8422
8655
|
}
|
|
8656
|
+
return emittedCount > 0;
|
|
8423
8657
|
}
|
|
8424
|
-
)
|
|
8658
|
+
);
|
|
8659
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
8425
8660
|
resolveSyncInsertTask(
|
|
8426
8661
|
this.isCadenzaDBReady,
|
|
8427
8662
|
"task_to_routine_map",
|
|
@@ -8442,7 +8677,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8442
8677
|
{ concurrency: 30 }
|
|
8443
8678
|
)?.then(
|
|
8444
8679
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
8445
|
-
if (!ctx.__syncing) {
|
|
8680
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8446
8681
|
return;
|
|
8447
8682
|
}
|
|
8448
8683
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8456,18 +8691,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8456
8691
|
);
|
|
8457
8692
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
8458
8693
|
"Split signals for registration",
|
|
8459
|
-
|
|
8694
|
+
(ctx, emit) => {
|
|
8460
8695
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8461
8696
|
delayMs: 3e3
|
|
8462
8697
|
});
|
|
8463
8698
|
const { signals } = ctx;
|
|
8464
|
-
if (!signals) return;
|
|
8699
|
+
if (!signals) return false;
|
|
8465
8700
|
const filteredSignals = signals.filter(
|
|
8466
8701
|
(signal) => !signal.data.registered
|
|
8467
8702
|
).map((signal) => signal.signal);
|
|
8468
8703
|
for (const signal of filteredSignals) {
|
|
8469
8704
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
8470
|
-
|
|
8705
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
8706
|
+
__syncing: ctx.__syncing,
|
|
8471
8707
|
data: {
|
|
8472
8708
|
name: signal,
|
|
8473
8709
|
isGlobal,
|
|
@@ -8476,10 +8712,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8476
8712
|
isMeta
|
|
8477
8713
|
},
|
|
8478
8714
|
__signal: signal
|
|
8479
|
-
};
|
|
8715
|
+
});
|
|
8480
8716
|
}
|
|
8717
|
+
return filteredSignals.length > 0;
|
|
8481
8718
|
}
|
|
8482
|
-
)
|
|
8719
|
+
);
|
|
8720
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
8483
8721
|
resolveSyncInsertTask(
|
|
8484
8722
|
this.isCadenzaDBReady,
|
|
8485
8723
|
"signal_registry",
|
|
@@ -8494,37 +8732,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8494
8732
|
{ concurrency: 30 }
|
|
8495
8733
|
)?.then(
|
|
8496
8734
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
8497
|
-
if (!ctx.__syncing) {
|
|
8735
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8498
8736
|
return;
|
|
8499
8737
|
}
|
|
8500
8738
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8501
8739
|
delayMs: 3e3
|
|
8502
8740
|
});
|
|
8741
|
+
CadenzaService.debounce(
|
|
8742
|
+
"meta.sync_controller.signal_registration_settled",
|
|
8743
|
+
{ __syncing: true },
|
|
8744
|
+
300
|
|
8745
|
+
);
|
|
8503
8746
|
return { signalName: ctx.__signal };
|
|
8504
|
-
}).then(
|
|
8505
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
8506
|
-
CadenzaService.createUniqueMetaTask(
|
|
8507
|
-
"Gather signal registration",
|
|
8508
|
-
() => true
|
|
8509
|
-
).emits("meta.sync_controller.synced_signals")
|
|
8510
|
-
)
|
|
8747
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
8511
8748
|
)
|
|
8512
8749
|
);
|
|
8750
|
+
CadenzaService.createUniqueMetaTask(
|
|
8751
|
+
"Gather signal registration",
|
|
8752
|
+
() => {
|
|
8753
|
+
this.signalsSynced = true;
|
|
8754
|
+
return true;
|
|
8755
|
+
}
|
|
8756
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
8513
8757
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
8514
8758
|
"Split tasks for registration",
|
|
8515
|
-
|
|
8759
|
+
(ctx, emit) => {
|
|
8516
8760
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8517
8761
|
delayMs: 3e3
|
|
8518
8762
|
});
|
|
8519
8763
|
const tasks = ctx.tasks;
|
|
8520
8764
|
const serviceName2 = resolveSyncServiceName();
|
|
8521
8765
|
if (!serviceName2) {
|
|
8522
|
-
return;
|
|
8766
|
+
return false;
|
|
8523
8767
|
}
|
|
8768
|
+
let emittedCount = 0;
|
|
8524
8769
|
for (const task of tasks) {
|
|
8525
8770
|
if (task.registered) continue;
|
|
8526
8771
|
const { __functionString, __getTagCallback } = task.export();
|
|
8527
|
-
|
|
8772
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
8773
|
+
__syncing: ctx.__syncing,
|
|
8528
8774
|
data: {
|
|
8529
8775
|
name: task.name,
|
|
8530
8776
|
version: task.version,
|
|
@@ -8542,9 +8788,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8542
8788
|
isMeta: task.isMeta,
|
|
8543
8789
|
isSubMeta: task.isSubMeta,
|
|
8544
8790
|
isHidden: task.isHidden,
|
|
8545
|
-
// inputSchema: task.inputSchema,
|
|
8546
8791
|
validateInputContext: task.validateInputContext,
|
|
8547
|
-
// outputSchema: task.outputSchema,
|
|
8548
8792
|
validateOutputContext: task.validateOutputContext,
|
|
8549
8793
|
retryCount: task.retryCount,
|
|
8550
8794
|
retryDelay: task.retryDelay,
|
|
@@ -8559,10 +8803,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8559
8803
|
}
|
|
8560
8804
|
},
|
|
8561
8805
|
__taskName: task.name
|
|
8562
|
-
};
|
|
8806
|
+
});
|
|
8807
|
+
emittedCount += 1;
|
|
8563
8808
|
}
|
|
8809
|
+
return emittedCount > 0;
|
|
8564
8810
|
}
|
|
8565
|
-
)
|
|
8811
|
+
);
|
|
8812
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
8566
8813
|
resolveSyncInsertTask(
|
|
8567
8814
|
this.isCadenzaDBReady,
|
|
8568
8815
|
"task",
|
|
@@ -8577,7 +8824,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8577
8824
|
{ concurrency: 30 }
|
|
8578
8825
|
)?.then(
|
|
8579
8826
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
8580
|
-
if (!ctx.__syncing) {
|
|
8827
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8581
8828
|
return;
|
|
8582
8829
|
}
|
|
8583
8830
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8588,15 +8835,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8588
8835
|
...ctx,
|
|
8589
8836
|
task: CadenzaService.get(ctx.__taskName)
|
|
8590
8837
|
});
|
|
8838
|
+
CadenzaService.debounce(
|
|
8839
|
+
"meta.sync_controller.task_registration_settled",
|
|
8840
|
+
{ __syncing: true },
|
|
8841
|
+
300
|
|
8842
|
+
);
|
|
8591
8843
|
return true;
|
|
8592
|
-
})
|
|
8593
|
-
CadenzaService.createUniqueMetaTask(
|
|
8594
|
-
"Gather task registration",
|
|
8595
|
-
() => true
|
|
8596
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
8597
|
-
)
|
|
8844
|
+
})
|
|
8598
8845
|
)
|
|
8599
8846
|
);
|
|
8847
|
+
CadenzaService.createUniqueMetaTask(
|
|
8848
|
+
"Gather task registration",
|
|
8849
|
+
() => {
|
|
8850
|
+
this.tasksSynced = true;
|
|
8851
|
+
return true;
|
|
8852
|
+
}
|
|
8853
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
8600
8854
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
8601
8855
|
"Split actors for registration",
|
|
8602
8856
|
function* (ctx) {
|
|
@@ -8641,22 +8895,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8641
8895
|
{ concurrency: 30 }
|
|
8642
8896
|
)?.then(
|
|
8643
8897
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
8644
|
-
if (!ctx.__syncing) {
|
|
8898
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8645
8899
|
return;
|
|
8646
8900
|
}
|
|
8647
8901
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8648
8902
|
delayMs: 3e3
|
|
8649
8903
|
});
|
|
8650
8904
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
8905
|
+
CadenzaService.debounce(
|
|
8906
|
+
"meta.sync_controller.actor_registration_settled",
|
|
8907
|
+
{ __syncing: true },
|
|
8908
|
+
300
|
|
8909
|
+
);
|
|
8651
8910
|
return true;
|
|
8652
|
-
})
|
|
8653
|
-
CadenzaService.createUniqueMetaTask(
|
|
8654
|
-
"Gather actor registration",
|
|
8655
|
-
() => true
|
|
8656
|
-
).emits("meta.sync_controller.synced_actors")
|
|
8657
|
-
)
|
|
8911
|
+
})
|
|
8658
8912
|
)
|
|
8659
8913
|
);
|
|
8914
|
+
CadenzaService.createUniqueMetaTask(
|
|
8915
|
+
"Gather actor registration",
|
|
8916
|
+
() => true
|
|
8917
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
8660
8918
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
8661
8919
|
"Split actor task maps",
|
|
8662
8920
|
function* (ctx) {
|
|
@@ -8711,7 +8969,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8711
8969
|
{ concurrency: 30 }
|
|
8712
8970
|
)?.then(
|
|
8713
8971
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
8714
|
-
if (!ctx.__syncing) {
|
|
8972
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8715
8973
|
return;
|
|
8716
8974
|
}
|
|
8717
8975
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8724,7 +8982,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8724
8982
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
8725
8983
|
"Record signal registration",
|
|
8726
8984
|
(ctx) => {
|
|
8727
|
-
if (!ctx.__syncing) {
|
|
8985
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8728
8986
|
return;
|
|
8729
8987
|
}
|
|
8730
8988
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8735,13 +8993,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8735
8993
|
);
|
|
8736
8994
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
8737
8995
|
"Split observed signals of task",
|
|
8738
|
-
|
|
8996
|
+
(ctx, emit) => {
|
|
8739
8997
|
const task = ctx.task;
|
|
8740
|
-
if (task.hidden || !task.register) return;
|
|
8998
|
+
if (task.hidden || !task.register) return false;
|
|
8741
8999
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8742
9000
|
if (!serviceName2) {
|
|
8743
|
-
return;
|
|
9001
|
+
return false;
|
|
8744
9002
|
}
|
|
9003
|
+
let emittedCount = 0;
|
|
8745
9004
|
for (const signal of task.observedSignals) {
|
|
8746
9005
|
const _signal = signal.split(":")[0];
|
|
8747
9006
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -8749,7 +9008,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8749
9008
|
continue;
|
|
8750
9009
|
}
|
|
8751
9010
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
8752
|
-
|
|
9011
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
9012
|
+
__syncing: ctx.__syncing,
|
|
8753
9013
|
data: {
|
|
8754
9014
|
signalName: _signal,
|
|
8755
9015
|
isGlobal,
|
|
@@ -8759,10 +9019,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8759
9019
|
},
|
|
8760
9020
|
__taskName: task.name,
|
|
8761
9021
|
__signal: signal
|
|
8762
|
-
};
|
|
9022
|
+
});
|
|
9023
|
+
emittedCount += 1;
|
|
8763
9024
|
}
|
|
9025
|
+
return emittedCount > 0;
|
|
8764
9026
|
}
|
|
8765
|
-
)
|
|
9027
|
+
);
|
|
9028
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
8766
9029
|
resolveSyncInsertTask(
|
|
8767
9030
|
this.isCadenzaDBReady,
|
|
8768
9031
|
"signal_to_task_map",
|
|
@@ -8784,29 +9047,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8784
9047
|
);
|
|
8785
9048
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
8786
9049
|
"Split intents for registration",
|
|
8787
|
-
function
|
|
9050
|
+
function(ctx, emit) {
|
|
8788
9051
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8789
9052
|
delayMs: 3e3
|
|
8790
9053
|
});
|
|
8791
9054
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
8792
|
-
|
|
8793
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
8794
|
-
const authorityIntentNames = intentNames.filter(
|
|
8795
|
-
(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")
|
|
8796
|
-
);
|
|
8797
|
-
CadenzaService.log(
|
|
8798
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
8799
|
-
{
|
|
8800
|
-
totalIntents: intentNames.length,
|
|
8801
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
8802
|
-
"meta-service-registry-full-sync"
|
|
8803
|
-
),
|
|
8804
|
-
authorityIntentNames
|
|
8805
|
-
},
|
|
8806
|
-
"info"
|
|
8807
|
-
);
|
|
8808
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
8809
|
-
}
|
|
9055
|
+
let emittedCount = 0;
|
|
8810
9056
|
for (const intent of intents) {
|
|
8811
9057
|
const intentData = buildIntentRegistryData(intent);
|
|
8812
9058
|
if (!intentData) {
|
|
@@ -8815,35 +9061,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8815
9061
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
8816
9062
|
continue;
|
|
8817
9063
|
}
|
|
8818
|
-
|
|
9064
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
9065
|
+
__syncing: ctx.__syncing,
|
|
8819
9066
|
data: intentData,
|
|
8820
9067
|
__intentName: intentData.name
|
|
8821
|
-
};
|
|
9068
|
+
});
|
|
9069
|
+
emittedCount += 1;
|
|
8822
9070
|
}
|
|
9071
|
+
return emittedCount > 0;
|
|
8823
9072
|
}.bind(this)
|
|
8824
|
-
)
|
|
9073
|
+
);
|
|
9074
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
8825
9075
|
insertIntentRegistryTask?.then(
|
|
8826
9076
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
8827
|
-
if (!ctx.__syncing) {
|
|
9077
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8828
9078
|
return;
|
|
8829
9079
|
}
|
|
8830
9080
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
8831
9081
|
delayMs: 3e3
|
|
8832
9082
|
});
|
|
8833
9083
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9084
|
+
CadenzaService.debounce(
|
|
9085
|
+
"meta.sync_controller.intent_registration_settled",
|
|
9086
|
+
{ __syncing: true },
|
|
9087
|
+
300
|
|
9088
|
+
);
|
|
8834
9089
|
return true;
|
|
8835
|
-
})
|
|
8836
|
-
CadenzaService.createUniqueMetaTask(
|
|
8837
|
-
"Gather intent registration",
|
|
8838
|
-
() => true
|
|
8839
|
-
).emits("meta.sync_controller.synced_intents")
|
|
8840
|
-
)
|
|
9090
|
+
})
|
|
8841
9091
|
)
|
|
8842
9092
|
);
|
|
9093
|
+
CadenzaService.createUniqueMetaTask(
|
|
9094
|
+
"Gather intent registration",
|
|
9095
|
+
() => {
|
|
9096
|
+
this.intentsSynced = true;
|
|
9097
|
+
return true;
|
|
9098
|
+
}
|
|
9099
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
8843
9100
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
8844
9101
|
"Record intent registration",
|
|
8845
9102
|
(ctx) => {
|
|
8846
|
-
if (!ctx.__syncing) {
|
|
9103
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
8847
9104
|
return;
|
|
8848
9105
|
}
|
|
8849
9106
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -8856,37 +9113,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8856
9113
|
);
|
|
8857
9114
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
8858
9115
|
"Split intents of task",
|
|
8859
|
-
function
|
|
9116
|
+
function(ctx, emit) {
|
|
8860
9117
|
const task = ctx.task;
|
|
8861
|
-
if (task.hidden || !task.register) return;
|
|
9118
|
+
if (task.hidden || !task.register) return false;
|
|
8862
9119
|
const serviceName2 = resolveSyncServiceName(task);
|
|
8863
9120
|
if (!serviceName2) {
|
|
8864
|
-
return;
|
|
9121
|
+
return false;
|
|
8865
9122
|
}
|
|
8866
9123
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
8867
9124
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
8868
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
8869
|
-
"Query service_instance",
|
|
8870
|
-
"Query service_instance_transport",
|
|
8871
|
-
"Query intent_to_task_map",
|
|
8872
|
-
"Query signal_to_task_map"
|
|
8873
|
-
].includes(task.name)) {
|
|
8874
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
8875
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
8876
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
8877
|
-
CadenzaService.log(
|
|
8878
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
8879
|
-
{
|
|
8880
|
-
taskName: task.name,
|
|
8881
|
-
taskVersion: task.version,
|
|
8882
|
-
isMeta: task.isMeta,
|
|
8883
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
8884
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
8885
|
-
},
|
|
8886
|
-
"info"
|
|
8887
|
-
);
|
|
8888
|
-
}
|
|
8889
|
-
}
|
|
8890
9125
|
for (const intent of task.handlesIntents) {
|
|
8891
9126
|
if (task.__registeredIntents.has(intent)) continue;
|
|
8892
9127
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -8908,7 +9143,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8908
9143
|
if (!intentDefinition) {
|
|
8909
9144
|
continue;
|
|
8910
9145
|
}
|
|
8911
|
-
|
|
9146
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
9147
|
+
__syncing: ctx.__syncing,
|
|
8912
9148
|
data: {
|
|
8913
9149
|
intentName: intent,
|
|
8914
9150
|
taskName: task.name,
|
|
@@ -8924,10 +9160,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8924
9160
|
taskVersion: task.version,
|
|
8925
9161
|
serviceName: serviceName2
|
|
8926
9162
|
}
|
|
8927
|
-
};
|
|
9163
|
+
});
|
|
8928
9164
|
}
|
|
9165
|
+
return true;
|
|
8929
9166
|
}.bind(this)
|
|
8930
|
-
)
|
|
9167
|
+
);
|
|
9168
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
8931
9169
|
CadenzaService.createMetaTask(
|
|
8932
9170
|
"Prepare intent definition for intent-to-task map",
|
|
8933
9171
|
(ctx) => {
|
|
@@ -8940,7 +9178,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8940
9178
|
};
|
|
8941
9179
|
}
|
|
8942
9180
|
).then(
|
|
8943
|
-
|
|
9181
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
8944
9182
|
CadenzaService.createMetaTask(
|
|
8945
9183
|
"Restore intent-to-task map payload",
|
|
8946
9184
|
(ctx) => {
|
|
@@ -8988,7 +9226,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8988
9226
|
return;
|
|
8989
9227
|
}
|
|
8990
9228
|
for (const t of task.nextTasks) {
|
|
8991
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
9229
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
8992
9230
|
continue;
|
|
8993
9231
|
}
|
|
8994
9232
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -9031,7 +9269,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9031
9269
|
{ concurrency: 30 }
|
|
9032
9270
|
)?.then(
|
|
9033
9271
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
9034
|
-
if (!ctx.__syncing) {
|
|
9272
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9035
9273
|
return;
|
|
9036
9274
|
}
|
|
9037
9275
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9092,7 +9330,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9092
9330
|
CadenzaService.createMetaTask(
|
|
9093
9331
|
"Record deputy relationship registration",
|
|
9094
9332
|
(ctx) => {
|
|
9095
|
-
if (!ctx.__syncing) {
|
|
9333
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
9096
9334
|
return;
|
|
9097
9335
|
}
|
|
9098
9336
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -9107,19 +9345,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9107
9345
|
"meta.sync_controller.sync_tick",
|
|
9108
9346
|
"meta.service_registry.initial_sync_complete"
|
|
9109
9347
|
).then(this.splitSignalsTask);
|
|
9110
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9348
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
9349
|
+
"meta.sync_controller.sync_tick",
|
|
9350
|
+
"meta.sync_controller.synced_signals"
|
|
9351
|
+
).then(this.splitTasksForRegistration);
|
|
9111
9352
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
9112
9353
|
return {
|
|
9113
9354
|
...ctx,
|
|
9114
9355
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
9115
9356
|
};
|
|
9116
9357
|
}).doOn(
|
|
9117
|
-
"meta.sync_controller.
|
|
9118
|
-
"meta.
|
|
9358
|
+
"meta.sync_controller.sync_tick",
|
|
9359
|
+
"meta.service_registry.initial_sync_complete"
|
|
9119
9360
|
).then(this.splitIntentsTask);
|
|
9120
9361
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9121
|
-
"meta.sync_controller.
|
|
9122
|
-
"meta.
|
|
9362
|
+
"meta.sync_controller.sync_tick",
|
|
9363
|
+
"meta.service_registry.initial_sync_complete"
|
|
9123
9364
|
).then(this.splitRoutinesTask);
|
|
9124
9365
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
9125
9366
|
return {
|
|
@@ -9127,16 +9368,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9127
9368
|
actors: CadenzaService.getAllActors()
|
|
9128
9369
|
};
|
|
9129
9370
|
}).doOn(
|
|
9130
|
-
"meta.sync_controller.
|
|
9131
|
-
"meta.
|
|
9371
|
+
"meta.sync_controller.sync_tick",
|
|
9372
|
+
"meta.service_registry.initial_sync_complete"
|
|
9132
9373
|
).then(this.splitActorsForRegistration);
|
|
9133
|
-
CadenzaService.
|
|
9374
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
9375
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9376
|
+
if (!task) {
|
|
9377
|
+
return false;
|
|
9378
|
+
}
|
|
9379
|
+
return {
|
|
9380
|
+
...ctx,
|
|
9381
|
+
task
|
|
9382
|
+
};
|
|
9383
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9134
9384
|
this.registerTaskMapTask,
|
|
9135
9385
|
this.registerDeputyRelationshipTask
|
|
9136
9386
|
);
|
|
9137
9387
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
9138
9388
|
"meta.sync_controller.synced_signals"
|
|
9139
|
-
).then(
|
|
9389
|
+
).then(
|
|
9390
|
+
CadenzaService.createMetaTask(
|
|
9391
|
+
"Ensure signal and task sync ready",
|
|
9392
|
+
(ctx) => {
|
|
9393
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9394
|
+
return false;
|
|
9395
|
+
}
|
|
9396
|
+
return ctx;
|
|
9397
|
+
}
|
|
9398
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9399
|
+
);
|
|
9140
9400
|
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
9141
9401
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9142
9402
|
if (!task) {
|
|
@@ -9146,8 +9406,28 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9146
9406
|
...ctx,
|
|
9147
9407
|
task
|
|
9148
9408
|
};
|
|
9149
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9150
|
-
|
|
9409
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9410
|
+
CadenzaService.createMetaTask(
|
|
9411
|
+
"Ensure signal and task sync ready from task registration",
|
|
9412
|
+
(ctx) => {
|
|
9413
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
9414
|
+
return false;
|
|
9415
|
+
}
|
|
9416
|
+
return ctx;
|
|
9417
|
+
}
|
|
9418
|
+
).then(this.registerSignalToTaskMapTask)
|
|
9419
|
+
);
|
|
9420
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
9421
|
+
CadenzaService.createMetaTask(
|
|
9422
|
+
"Ensure intent and task sync ready",
|
|
9423
|
+
(ctx) => {
|
|
9424
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9425
|
+
return false;
|
|
9426
|
+
}
|
|
9427
|
+
return ctx;
|
|
9428
|
+
}
|
|
9429
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9430
|
+
);
|
|
9151
9431
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
9152
9432
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
9153
9433
|
if (!task) {
|
|
@@ -9157,7 +9437,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9157
9437
|
...ctx,
|
|
9158
9438
|
task
|
|
9159
9439
|
};
|
|
9160
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
9440
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
9441
|
+
CadenzaService.createMetaTask(
|
|
9442
|
+
"Ensure intent and task sync ready from task registration",
|
|
9443
|
+
(ctx) => {
|
|
9444
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
9445
|
+
return false;
|
|
9446
|
+
}
|
|
9447
|
+
return ctx;
|
|
9448
|
+
}
|
|
9449
|
+
).then(this.registerIntentToTaskMapTask)
|
|
9450
|
+
);
|
|
9161
9451
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
9162
9452
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
9163
9453
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
@@ -9170,9 +9460,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9170
9460
|
};
|
|
9171
9461
|
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
9172
9462
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
9173
|
-
"meta.sync_controller.
|
|
9174
|
-
"meta.sync_controller.
|
|
9175
|
-
).then(
|
|
9463
|
+
"meta.sync_controller.synced_routines",
|
|
9464
|
+
"meta.sync_controller.task_registered"
|
|
9465
|
+
).then(
|
|
9466
|
+
CadenzaService.createMetaTask(
|
|
9467
|
+
"Ensure routine and task sync ready",
|
|
9468
|
+
(ctx) => {
|
|
9469
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
9470
|
+
return false;
|
|
9471
|
+
}
|
|
9472
|
+
return ctx;
|
|
9473
|
+
}
|
|
9474
|
+
).then(this.splitTasksInRoutines)
|
|
9475
|
+
);
|
|
9176
9476
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
9177
9477
|
emit("global.meta.sync_controller.synced", {
|
|
9178
9478
|
data: {
|
|
@@ -9200,6 +9500,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9200
9500
|
{ __syncing: true },
|
|
9201
9501
|
18e4
|
|
9202
9502
|
);
|
|
9503
|
+
CadenzaService.schedule(
|
|
9504
|
+
"meta.sync_controller.sync_tick",
|
|
9505
|
+
{ __syncing: true },
|
|
9506
|
+
250
|
|
9507
|
+
);
|
|
9203
9508
|
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
9204
9509
|
}
|
|
9205
9510
|
}
|
|
@@ -9600,20 +9905,28 @@ var CadenzaService = class {
|
|
|
9600
9905
|
return false;
|
|
9601
9906
|
});
|
|
9602
9907
|
if (responders.length === 0) {
|
|
9908
|
+
const inquiryMeta = {
|
|
9909
|
+
inquiry,
|
|
9910
|
+
isMetaInquiry,
|
|
9911
|
+
totalResponders: allResponders.length,
|
|
9912
|
+
eligibleResponders: 0,
|
|
9913
|
+
filteredOutResponders: allResponders.length,
|
|
9914
|
+
responded: 0,
|
|
9915
|
+
failed: 0,
|
|
9916
|
+
timedOut: 0,
|
|
9917
|
+
pending: 0,
|
|
9918
|
+
durationMs: 0,
|
|
9919
|
+
responders: []
|
|
9920
|
+
};
|
|
9921
|
+
if (options.requireComplete) {
|
|
9922
|
+
throw {
|
|
9923
|
+
__inquiryMeta: inquiryMeta,
|
|
9924
|
+
__error: `Inquiry '${inquiry}' had no eligible responders`,
|
|
9925
|
+
errored: true
|
|
9926
|
+
};
|
|
9927
|
+
}
|
|
9603
9928
|
return {
|
|
9604
|
-
__inquiryMeta:
|
|
9605
|
-
inquiry,
|
|
9606
|
-
isMetaInquiry,
|
|
9607
|
-
totalResponders: allResponders.length,
|
|
9608
|
-
eligibleResponders: 0,
|
|
9609
|
-
filteredOutResponders: allResponders.length,
|
|
9610
|
-
responded: 0,
|
|
9611
|
-
failed: 0,
|
|
9612
|
-
timedOut: 0,
|
|
9613
|
-
pending: 0,
|
|
9614
|
-
durationMs: 0,
|
|
9615
|
-
responders: []
|
|
9616
|
-
}
|
|
9929
|
+
__inquiryMeta: inquiryMeta
|
|
9617
9930
|
};
|
|
9618
9931
|
}
|
|
9619
9932
|
responders.sort(this.compareInquiryResponders.bind(this));
|
|
@@ -10300,6 +10613,12 @@ var CadenzaService = class {
|
|
|
10300
10613
|
displayName: options.displayName ?? "",
|
|
10301
10614
|
isMeta: options.isMeta
|
|
10302
10615
|
},
|
|
10616
|
+
__registrationData: {
|
|
10617
|
+
name: serviceName,
|
|
10618
|
+
description,
|
|
10619
|
+
displayName: options.displayName ?? "",
|
|
10620
|
+
isMeta: options.isMeta
|
|
10621
|
+
},
|
|
10303
10622
|
__serviceName: serviceName,
|
|
10304
10623
|
__serviceInstanceId: serviceId,
|
|
10305
10624
|
__port: options.port,
|
|
@@ -10352,6 +10671,16 @@ var CadenzaService = class {
|
|
|
10352
10671
|
is_blocked: false,
|
|
10353
10672
|
health: {}
|
|
10354
10673
|
},
|
|
10674
|
+
__registrationData: {
|
|
10675
|
+
uuid: serviceId,
|
|
10676
|
+
process_pid: 1,
|
|
10677
|
+
service_name: serviceName,
|
|
10678
|
+
is_frontend: true,
|
|
10679
|
+
is_active: true,
|
|
10680
|
+
is_non_responsive: false,
|
|
10681
|
+
is_blocked: false,
|
|
10682
|
+
health: {}
|
|
10683
|
+
},
|
|
10355
10684
|
__transportData: [],
|
|
10356
10685
|
__serviceName: serviceName,
|
|
10357
10686
|
__serviceInstanceId: serviceId,
|