@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/browser/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) => {
|
|
@@ -3400,6 +3549,16 @@ var RestController = class _RestController {
|
|
|
3400
3549
|
is_blocked: false,
|
|
3401
3550
|
health: {}
|
|
3402
3551
|
},
|
|
3552
|
+
__registrationData: {
|
|
3553
|
+
uuid: ctx.__serviceInstanceId,
|
|
3554
|
+
process_pid: 1,
|
|
3555
|
+
service_name: ctx.__serviceName,
|
|
3556
|
+
is_frontend: true,
|
|
3557
|
+
is_active: true,
|
|
3558
|
+
is_non_responsive: false,
|
|
3559
|
+
is_blocked: false,
|
|
3560
|
+
health: {}
|
|
3561
|
+
},
|
|
3403
3562
|
__transportData: [],
|
|
3404
3563
|
...ctx
|
|
3405
3564
|
});
|
|
@@ -5724,12 +5883,6 @@ var import_uuid4 = require("uuid");
|
|
|
5724
5883
|
|
|
5725
5884
|
// src/graph/controllers/GraphSyncController.ts
|
|
5726
5885
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5727
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
5728
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
5729
|
-
);
|
|
5730
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
5731
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
5732
|
-
);
|
|
5733
5886
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5734
5887
|
if (typeof taskFunction !== "function") {
|
|
5735
5888
|
return void 0;
|
|
@@ -5806,38 +5959,86 @@ function buildIntentRegistryData(intent) {
|
|
|
5806
5959
|
isMeta: isMetaIntentName(name)
|
|
5807
5960
|
};
|
|
5808
5961
|
}
|
|
5962
|
+
function getJoinedContextValue(ctx, key) {
|
|
5963
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
5964
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
5965
|
+
const joinedContext = joinedContexts[index];
|
|
5966
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
5967
|
+
return joinedContext[key];
|
|
5968
|
+
}
|
|
5969
|
+
}
|
|
5970
|
+
return void 0;
|
|
5971
|
+
}
|
|
5972
|
+
function didSyncInsertSucceed(ctx) {
|
|
5973
|
+
if (ctx.errored || ctx.__success === false) {
|
|
5974
|
+
return false;
|
|
5975
|
+
}
|
|
5976
|
+
const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
|
|
5977
|
+
if (!inquiryMeta) {
|
|
5978
|
+
return true;
|
|
5979
|
+
}
|
|
5980
|
+
const eligibleResponders = Number(inquiryMeta.eligibleResponders);
|
|
5981
|
+
if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
|
|
5982
|
+
return false;
|
|
5983
|
+
}
|
|
5984
|
+
const responded = Number(inquiryMeta.responded);
|
|
5985
|
+
if (Number.isFinite(responded) && responded === 0) {
|
|
5986
|
+
return false;
|
|
5987
|
+
}
|
|
5988
|
+
return true;
|
|
5989
|
+
}
|
|
5990
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
5991
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
5992
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
5993
|
+
const nextQueryData = {
|
|
5994
|
+
...existingQueryData,
|
|
5995
|
+
...queryData
|
|
5996
|
+
};
|
|
5997
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
5998
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
5999
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
6000
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
6001
|
+
}
|
|
6002
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
6003
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
6004
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
6005
|
+
) : resolvedBatch;
|
|
6006
|
+
}
|
|
6007
|
+
return nextQueryData;
|
|
6008
|
+
}
|
|
5809
6009
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
5810
6010
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
6011
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
6012
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
6013
|
+
return void 0;
|
|
6014
|
+
}
|
|
6015
|
+
return CadenzaService.createUniqueMetaTask(
|
|
6016
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
6017
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
6018
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
6019
|
+
if (!targetTask) {
|
|
6020
|
+
return false;
|
|
6021
|
+
}
|
|
6022
|
+
return targetTask.taskFunction(
|
|
6023
|
+
{
|
|
5823
6024
|
...ctx,
|
|
5824
|
-
queryData:
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
6025
|
+
queryData: buildSyncInsertQueryData(
|
|
6026
|
+
ctx,
|
|
6027
|
+
queryData
|
|
6028
|
+
)
|
|
6029
|
+
},
|
|
6030
|
+
emit,
|
|
6031
|
+
inquire,
|
|
6032
|
+
progressCallback
|
|
6033
|
+
);
|
|
6034
|
+
},
|
|
6035
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
6036
|
+
{
|
|
6037
|
+
...options,
|
|
6038
|
+
register: false,
|
|
6039
|
+
isHidden: true
|
|
5837
6040
|
}
|
|
5838
|
-
|
|
5839
|
-
}
|
|
5840
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
6041
|
+
);
|
|
5841
6042
|
}
|
|
5842
6043
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
5843
6044
|
"intent_registry",
|
|
@@ -5856,11 +6057,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5856
6057
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
5857
6058
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5858
6059
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
5859
|
-
this.
|
|
6060
|
+
this.tasksSynced = false;
|
|
6061
|
+
this.signalsSynced = false;
|
|
6062
|
+
this.intentsSynced = false;
|
|
6063
|
+
this.routinesSynced = false;
|
|
5860
6064
|
this.isCadenzaDBReady = false;
|
|
5861
6065
|
this.initialized = false;
|
|
5862
6066
|
this.initRetryScheduled = false;
|
|
5863
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
5864
6067
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
5865
6068
|
}
|
|
5866
6069
|
static get instance() {
|
|
@@ -5935,21 +6138,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5935
6138
|
},
|
|
5936
6139
|
{ concurrency: 30 }
|
|
5937
6140
|
);
|
|
6141
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
6142
|
+
this.isCadenzaDBReady,
|
|
6143
|
+
"intent_registry",
|
|
6144
|
+
{
|
|
6145
|
+
onConflict: {
|
|
6146
|
+
target: ["name"],
|
|
6147
|
+
action: {
|
|
6148
|
+
do: "nothing"
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
6151
|
+
},
|
|
6152
|
+
{ concurrency: 30 }
|
|
6153
|
+
);
|
|
5938
6154
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
5939
6155
|
"Split routines for registration",
|
|
5940
|
-
|
|
6156
|
+
(ctx, emit) => {
|
|
5941
6157
|
const { routines } = ctx;
|
|
5942
|
-
if (!routines) return;
|
|
6158
|
+
if (!routines) return false;
|
|
5943
6159
|
const serviceName2 = resolveSyncServiceName();
|
|
5944
6160
|
if (!serviceName2) {
|
|
5945
|
-
return;
|
|
6161
|
+
return false;
|
|
5946
6162
|
}
|
|
5947
6163
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5948
6164
|
delayMs: 2e3
|
|
5949
6165
|
});
|
|
6166
|
+
let emittedCount = 0;
|
|
5950
6167
|
for (const routine of routines) {
|
|
5951
6168
|
if (routine.registered) continue;
|
|
5952
|
-
|
|
6169
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
6170
|
+
__syncing: ctx.__syncing,
|
|
5953
6171
|
data: {
|
|
5954
6172
|
name: routine.name,
|
|
5955
6173
|
version: routine.version,
|
|
@@ -5958,10 +6176,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5958
6176
|
isMeta: routine.isMeta
|
|
5959
6177
|
},
|
|
5960
6178
|
__routineName: routine.name
|
|
5961
|
-
};
|
|
6179
|
+
});
|
|
6180
|
+
emittedCount += 1;
|
|
5962
6181
|
}
|
|
6182
|
+
return emittedCount > 0;
|
|
5963
6183
|
}
|
|
5964
|
-
)
|
|
6184
|
+
);
|
|
6185
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
5965
6186
|
resolveSyncInsertTask(
|
|
5966
6187
|
this.isCadenzaDBReady,
|
|
5967
6188
|
"routine",
|
|
@@ -5976,39 +6197,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5976
6197
|
{ concurrency: 30 }
|
|
5977
6198
|
)?.then(
|
|
5978
6199
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
5979
|
-
if (!ctx.__syncing) {
|
|
6200
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5980
6201
|
return;
|
|
5981
6202
|
}
|
|
5982
6203
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5983
6204
|
delayMs: 3e3
|
|
5984
6205
|
});
|
|
5985
6206
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6207
|
+
CadenzaService.debounce(
|
|
6208
|
+
"meta.sync_controller.routine_registration_settled",
|
|
6209
|
+
{ __syncing: true },
|
|
6210
|
+
300
|
|
6211
|
+
);
|
|
5986
6212
|
return true;
|
|
5987
|
-
})
|
|
5988
|
-
CadenzaService.createUniqueMetaTask(
|
|
5989
|
-
"Gather routine registration",
|
|
5990
|
-
() => true
|
|
5991
|
-
).emits("meta.sync_controller.synced_routines")
|
|
5992
|
-
)
|
|
6213
|
+
})
|
|
5993
6214
|
)
|
|
5994
6215
|
);
|
|
6216
|
+
CadenzaService.createUniqueMetaTask(
|
|
6217
|
+
"Gather routine registration",
|
|
6218
|
+
() => {
|
|
6219
|
+
this.routinesSynced = true;
|
|
6220
|
+
return true;
|
|
6221
|
+
}
|
|
6222
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
5995
6223
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
5996
6224
|
"Split tasks in routines",
|
|
5997
|
-
|
|
6225
|
+
(ctx, emit) => {
|
|
5998
6226
|
const { routines } = ctx;
|
|
5999
|
-
if (!routines) return;
|
|
6227
|
+
if (!routines) return false;
|
|
6000
6228
|
const serviceName2 = resolveSyncServiceName();
|
|
6001
6229
|
if (!serviceName2) {
|
|
6002
|
-
return;
|
|
6230
|
+
return false;
|
|
6003
6231
|
}
|
|
6004
6232
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6005
6233
|
delayMs: 3e3
|
|
6006
6234
|
});
|
|
6235
|
+
let emittedCount = 0;
|
|
6007
6236
|
for (const routine of routines) {
|
|
6008
6237
|
if (!routine.registered) continue;
|
|
6009
6238
|
for (const task of routine.tasks) {
|
|
6010
6239
|
if (!task) {
|
|
6011
|
-
console.log("task is null", routine, task);
|
|
6012
6240
|
continue;
|
|
6013
6241
|
}
|
|
6014
6242
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -6018,7 +6246,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6018
6246
|
if (!nextTask?.registered) {
|
|
6019
6247
|
continue;
|
|
6020
6248
|
}
|
|
6021
|
-
|
|
6249
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
6250
|
+
__syncing: ctx.__syncing,
|
|
6022
6251
|
data: {
|
|
6023
6252
|
taskName: nextTask.name,
|
|
6024
6253
|
taskVersion: nextTask.version,
|
|
@@ -6028,12 +6257,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6028
6257
|
},
|
|
6029
6258
|
__routineName: routine.name,
|
|
6030
6259
|
__taskName: nextTask.name
|
|
6031
|
-
};
|
|
6260
|
+
});
|
|
6261
|
+
emittedCount += 1;
|
|
6032
6262
|
}
|
|
6033
6263
|
}
|
|
6034
6264
|
}
|
|
6265
|
+
return emittedCount > 0;
|
|
6035
6266
|
}
|
|
6036
|
-
)
|
|
6267
|
+
);
|
|
6268
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
6037
6269
|
resolveSyncInsertTask(
|
|
6038
6270
|
this.isCadenzaDBReady,
|
|
6039
6271
|
"task_to_routine_map",
|
|
@@ -6054,7 +6286,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6054
6286
|
{ concurrency: 30 }
|
|
6055
6287
|
)?.then(
|
|
6056
6288
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
6057
|
-
if (!ctx.__syncing) {
|
|
6289
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6058
6290
|
return;
|
|
6059
6291
|
}
|
|
6060
6292
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6068,18 +6300,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6068
6300
|
);
|
|
6069
6301
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
6070
6302
|
"Split signals for registration",
|
|
6071
|
-
|
|
6303
|
+
(ctx, emit) => {
|
|
6072
6304
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6073
6305
|
delayMs: 3e3
|
|
6074
6306
|
});
|
|
6075
6307
|
const { signals } = ctx;
|
|
6076
|
-
if (!signals) return;
|
|
6308
|
+
if (!signals) return false;
|
|
6077
6309
|
const filteredSignals = signals.filter(
|
|
6078
6310
|
(signal) => !signal.data.registered
|
|
6079
6311
|
).map((signal) => signal.signal);
|
|
6080
6312
|
for (const signal of filteredSignals) {
|
|
6081
6313
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
6082
|
-
|
|
6314
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
6315
|
+
__syncing: ctx.__syncing,
|
|
6083
6316
|
data: {
|
|
6084
6317
|
name: signal,
|
|
6085
6318
|
isGlobal,
|
|
@@ -6088,10 +6321,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6088
6321
|
isMeta
|
|
6089
6322
|
},
|
|
6090
6323
|
__signal: signal
|
|
6091
|
-
};
|
|
6324
|
+
});
|
|
6092
6325
|
}
|
|
6326
|
+
return filteredSignals.length > 0;
|
|
6093
6327
|
}
|
|
6094
|
-
)
|
|
6328
|
+
);
|
|
6329
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
6095
6330
|
resolveSyncInsertTask(
|
|
6096
6331
|
this.isCadenzaDBReady,
|
|
6097
6332
|
"signal_registry",
|
|
@@ -6106,37 +6341,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6106
6341
|
{ concurrency: 30 }
|
|
6107
6342
|
)?.then(
|
|
6108
6343
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
6109
|
-
if (!ctx.__syncing) {
|
|
6344
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6110
6345
|
return;
|
|
6111
6346
|
}
|
|
6112
6347
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6113
6348
|
delayMs: 3e3
|
|
6114
6349
|
});
|
|
6350
|
+
CadenzaService.debounce(
|
|
6351
|
+
"meta.sync_controller.signal_registration_settled",
|
|
6352
|
+
{ __syncing: true },
|
|
6353
|
+
300
|
|
6354
|
+
);
|
|
6115
6355
|
return { signalName: ctx.__signal };
|
|
6116
|
-
}).then(
|
|
6117
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
6118
|
-
CadenzaService.createUniqueMetaTask(
|
|
6119
|
-
"Gather signal registration",
|
|
6120
|
-
() => true
|
|
6121
|
-
).emits("meta.sync_controller.synced_signals")
|
|
6122
|
-
)
|
|
6356
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
6123
6357
|
)
|
|
6124
6358
|
);
|
|
6359
|
+
CadenzaService.createUniqueMetaTask(
|
|
6360
|
+
"Gather signal registration",
|
|
6361
|
+
() => {
|
|
6362
|
+
this.signalsSynced = true;
|
|
6363
|
+
return true;
|
|
6364
|
+
}
|
|
6365
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
6125
6366
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
6126
6367
|
"Split tasks for registration",
|
|
6127
|
-
|
|
6368
|
+
(ctx, emit) => {
|
|
6128
6369
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6129
6370
|
delayMs: 3e3
|
|
6130
6371
|
});
|
|
6131
6372
|
const tasks = ctx.tasks;
|
|
6132
6373
|
const serviceName2 = resolveSyncServiceName();
|
|
6133
6374
|
if (!serviceName2) {
|
|
6134
|
-
return;
|
|
6375
|
+
return false;
|
|
6135
6376
|
}
|
|
6377
|
+
let emittedCount = 0;
|
|
6136
6378
|
for (const task of tasks) {
|
|
6137
6379
|
if (task.registered) continue;
|
|
6138
6380
|
const { __functionString, __getTagCallback } = task.export();
|
|
6139
|
-
|
|
6381
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
6382
|
+
__syncing: ctx.__syncing,
|
|
6140
6383
|
data: {
|
|
6141
6384
|
name: task.name,
|
|
6142
6385
|
version: task.version,
|
|
@@ -6154,9 +6397,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6154
6397
|
isMeta: task.isMeta,
|
|
6155
6398
|
isSubMeta: task.isSubMeta,
|
|
6156
6399
|
isHidden: task.isHidden,
|
|
6157
|
-
// inputSchema: task.inputSchema,
|
|
6158
6400
|
validateInputContext: task.validateInputContext,
|
|
6159
|
-
// outputSchema: task.outputSchema,
|
|
6160
6401
|
validateOutputContext: task.validateOutputContext,
|
|
6161
6402
|
retryCount: task.retryCount,
|
|
6162
6403
|
retryDelay: task.retryDelay,
|
|
@@ -6171,10 +6412,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6171
6412
|
}
|
|
6172
6413
|
},
|
|
6173
6414
|
__taskName: task.name
|
|
6174
|
-
};
|
|
6415
|
+
});
|
|
6416
|
+
emittedCount += 1;
|
|
6175
6417
|
}
|
|
6418
|
+
return emittedCount > 0;
|
|
6176
6419
|
}
|
|
6177
|
-
)
|
|
6420
|
+
);
|
|
6421
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
6178
6422
|
resolveSyncInsertTask(
|
|
6179
6423
|
this.isCadenzaDBReady,
|
|
6180
6424
|
"task",
|
|
@@ -6189,7 +6433,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6189
6433
|
{ concurrency: 30 }
|
|
6190
6434
|
)?.then(
|
|
6191
6435
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
6192
|
-
if (!ctx.__syncing) {
|
|
6436
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6193
6437
|
return;
|
|
6194
6438
|
}
|
|
6195
6439
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6200,15 +6444,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6200
6444
|
...ctx,
|
|
6201
6445
|
task: CadenzaService.get(ctx.__taskName)
|
|
6202
6446
|
});
|
|
6447
|
+
CadenzaService.debounce(
|
|
6448
|
+
"meta.sync_controller.task_registration_settled",
|
|
6449
|
+
{ __syncing: true },
|
|
6450
|
+
300
|
|
6451
|
+
);
|
|
6203
6452
|
return true;
|
|
6204
|
-
})
|
|
6205
|
-
CadenzaService.createUniqueMetaTask(
|
|
6206
|
-
"Gather task registration",
|
|
6207
|
-
() => true
|
|
6208
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
6209
|
-
)
|
|
6453
|
+
})
|
|
6210
6454
|
)
|
|
6211
6455
|
);
|
|
6456
|
+
CadenzaService.createUniqueMetaTask(
|
|
6457
|
+
"Gather task registration",
|
|
6458
|
+
() => {
|
|
6459
|
+
this.tasksSynced = true;
|
|
6460
|
+
return true;
|
|
6461
|
+
}
|
|
6462
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
6212
6463
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
6213
6464
|
"Split actors for registration",
|
|
6214
6465
|
function* (ctx) {
|
|
@@ -6253,22 +6504,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6253
6504
|
{ concurrency: 30 }
|
|
6254
6505
|
)?.then(
|
|
6255
6506
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
6256
|
-
if (!ctx.__syncing) {
|
|
6507
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6257
6508
|
return;
|
|
6258
6509
|
}
|
|
6259
6510
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6260
6511
|
delayMs: 3e3
|
|
6261
6512
|
});
|
|
6262
6513
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
6514
|
+
CadenzaService.debounce(
|
|
6515
|
+
"meta.sync_controller.actor_registration_settled",
|
|
6516
|
+
{ __syncing: true },
|
|
6517
|
+
300
|
|
6518
|
+
);
|
|
6263
6519
|
return true;
|
|
6264
|
-
})
|
|
6265
|
-
CadenzaService.createUniqueMetaTask(
|
|
6266
|
-
"Gather actor registration",
|
|
6267
|
-
() => true
|
|
6268
|
-
).emits("meta.sync_controller.synced_actors")
|
|
6269
|
-
)
|
|
6520
|
+
})
|
|
6270
6521
|
)
|
|
6271
6522
|
);
|
|
6523
|
+
CadenzaService.createUniqueMetaTask(
|
|
6524
|
+
"Gather actor registration",
|
|
6525
|
+
() => true
|
|
6526
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
6272
6527
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
6273
6528
|
"Split actor task maps",
|
|
6274
6529
|
function* (ctx) {
|
|
@@ -6323,7 +6578,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6323
6578
|
{ concurrency: 30 }
|
|
6324
6579
|
)?.then(
|
|
6325
6580
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
6326
|
-
if (!ctx.__syncing) {
|
|
6581
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6327
6582
|
return;
|
|
6328
6583
|
}
|
|
6329
6584
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6336,7 +6591,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6336
6591
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
6337
6592
|
"Record signal registration",
|
|
6338
6593
|
(ctx) => {
|
|
6339
|
-
if (!ctx.__syncing) {
|
|
6594
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6340
6595
|
return;
|
|
6341
6596
|
}
|
|
6342
6597
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6347,13 +6602,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6347
6602
|
);
|
|
6348
6603
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
6349
6604
|
"Split observed signals of task",
|
|
6350
|
-
|
|
6605
|
+
(ctx, emit) => {
|
|
6351
6606
|
const task = ctx.task;
|
|
6352
|
-
if (task.hidden || !task.register) return;
|
|
6607
|
+
if (task.hidden || !task.register) return false;
|
|
6353
6608
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6354
6609
|
if (!serviceName2) {
|
|
6355
|
-
return;
|
|
6610
|
+
return false;
|
|
6356
6611
|
}
|
|
6612
|
+
let emittedCount = 0;
|
|
6357
6613
|
for (const signal of task.observedSignals) {
|
|
6358
6614
|
const _signal = signal.split(":")[0];
|
|
6359
6615
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -6361,7 +6617,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6361
6617
|
continue;
|
|
6362
6618
|
}
|
|
6363
6619
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
6364
|
-
|
|
6620
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
6621
|
+
__syncing: ctx.__syncing,
|
|
6365
6622
|
data: {
|
|
6366
6623
|
signalName: _signal,
|
|
6367
6624
|
isGlobal,
|
|
@@ -6371,10 +6628,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6371
6628
|
},
|
|
6372
6629
|
__taskName: task.name,
|
|
6373
6630
|
__signal: signal
|
|
6374
|
-
};
|
|
6631
|
+
});
|
|
6632
|
+
emittedCount += 1;
|
|
6375
6633
|
}
|
|
6634
|
+
return emittedCount > 0;
|
|
6376
6635
|
}
|
|
6377
|
-
)
|
|
6636
|
+
);
|
|
6637
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
6378
6638
|
resolveSyncInsertTask(
|
|
6379
6639
|
this.isCadenzaDBReady,
|
|
6380
6640
|
"signal_to_task_map",
|
|
@@ -6396,29 +6656,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6396
6656
|
);
|
|
6397
6657
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
6398
6658
|
"Split intents for registration",
|
|
6399
|
-
function
|
|
6659
|
+
function(ctx, emit) {
|
|
6400
6660
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6401
6661
|
delayMs: 3e3
|
|
6402
6662
|
});
|
|
6403
6663
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
6404
|
-
|
|
6405
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
6406
|
-
const authorityIntentNames = intentNames.filter(
|
|
6407
|
-
(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")
|
|
6408
|
-
);
|
|
6409
|
-
CadenzaService.log(
|
|
6410
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
6411
|
-
{
|
|
6412
|
-
totalIntents: intentNames.length,
|
|
6413
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
6414
|
-
"meta-service-registry-full-sync"
|
|
6415
|
-
),
|
|
6416
|
-
authorityIntentNames
|
|
6417
|
-
},
|
|
6418
|
-
"info"
|
|
6419
|
-
);
|
|
6420
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
6421
|
-
}
|
|
6664
|
+
let emittedCount = 0;
|
|
6422
6665
|
for (const intent of intents) {
|
|
6423
6666
|
const intentData = buildIntentRegistryData(intent);
|
|
6424
6667
|
if (!intentData) {
|
|
@@ -6427,35 +6670,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6427
6670
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
6428
6671
|
continue;
|
|
6429
6672
|
}
|
|
6430
|
-
|
|
6673
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
6674
|
+
__syncing: ctx.__syncing,
|
|
6431
6675
|
data: intentData,
|
|
6432
6676
|
__intentName: intentData.name
|
|
6433
|
-
};
|
|
6677
|
+
});
|
|
6678
|
+
emittedCount += 1;
|
|
6434
6679
|
}
|
|
6680
|
+
return emittedCount > 0;
|
|
6435
6681
|
}.bind(this)
|
|
6436
|
-
)
|
|
6682
|
+
);
|
|
6683
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
6437
6684
|
insertIntentRegistryTask?.then(
|
|
6438
6685
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
6439
|
-
if (!ctx.__syncing) {
|
|
6686
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6440
6687
|
return;
|
|
6441
6688
|
}
|
|
6442
6689
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6443
6690
|
delayMs: 3e3
|
|
6444
6691
|
});
|
|
6445
6692
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
6693
|
+
CadenzaService.debounce(
|
|
6694
|
+
"meta.sync_controller.intent_registration_settled",
|
|
6695
|
+
{ __syncing: true },
|
|
6696
|
+
300
|
|
6697
|
+
);
|
|
6446
6698
|
return true;
|
|
6447
|
-
})
|
|
6448
|
-
CadenzaService.createUniqueMetaTask(
|
|
6449
|
-
"Gather intent registration",
|
|
6450
|
-
() => true
|
|
6451
|
-
).emits("meta.sync_controller.synced_intents")
|
|
6452
|
-
)
|
|
6699
|
+
})
|
|
6453
6700
|
)
|
|
6454
6701
|
);
|
|
6702
|
+
CadenzaService.createUniqueMetaTask(
|
|
6703
|
+
"Gather intent registration",
|
|
6704
|
+
() => {
|
|
6705
|
+
this.intentsSynced = true;
|
|
6706
|
+
return true;
|
|
6707
|
+
}
|
|
6708
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
6455
6709
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
6456
6710
|
"Record intent registration",
|
|
6457
6711
|
(ctx) => {
|
|
6458
|
-
if (!ctx.__syncing) {
|
|
6712
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6459
6713
|
return;
|
|
6460
6714
|
}
|
|
6461
6715
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6468,37 +6722,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6468
6722
|
);
|
|
6469
6723
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
6470
6724
|
"Split intents of task",
|
|
6471
|
-
function
|
|
6725
|
+
function(ctx, emit) {
|
|
6472
6726
|
const task = ctx.task;
|
|
6473
|
-
if (task.hidden || !task.register) return;
|
|
6727
|
+
if (task.hidden || !task.register) return false;
|
|
6474
6728
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6475
6729
|
if (!serviceName2) {
|
|
6476
|
-
return;
|
|
6730
|
+
return false;
|
|
6477
6731
|
}
|
|
6478
6732
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
6479
6733
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
6480
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
6481
|
-
"Query service_instance",
|
|
6482
|
-
"Query service_instance_transport",
|
|
6483
|
-
"Query intent_to_task_map",
|
|
6484
|
-
"Query signal_to_task_map"
|
|
6485
|
-
].includes(task.name)) {
|
|
6486
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
6487
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
6488
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
6489
|
-
CadenzaService.log(
|
|
6490
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
6491
|
-
{
|
|
6492
|
-
taskName: task.name,
|
|
6493
|
-
taskVersion: task.version,
|
|
6494
|
-
isMeta: task.isMeta,
|
|
6495
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
6496
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
6497
|
-
},
|
|
6498
|
-
"info"
|
|
6499
|
-
);
|
|
6500
|
-
}
|
|
6501
|
-
}
|
|
6502
6734
|
for (const intent of task.handlesIntents) {
|
|
6503
6735
|
if (task.__registeredIntents.has(intent)) continue;
|
|
6504
6736
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -6520,7 +6752,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6520
6752
|
if (!intentDefinition) {
|
|
6521
6753
|
continue;
|
|
6522
6754
|
}
|
|
6523
|
-
|
|
6755
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
6756
|
+
__syncing: ctx.__syncing,
|
|
6524
6757
|
data: {
|
|
6525
6758
|
intentName: intent,
|
|
6526
6759
|
taskName: task.name,
|
|
@@ -6536,10 +6769,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6536
6769
|
taskVersion: task.version,
|
|
6537
6770
|
serviceName: serviceName2
|
|
6538
6771
|
}
|
|
6539
|
-
};
|
|
6772
|
+
});
|
|
6540
6773
|
}
|
|
6774
|
+
return true;
|
|
6541
6775
|
}.bind(this)
|
|
6542
|
-
)
|
|
6776
|
+
);
|
|
6777
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
6543
6778
|
CadenzaService.createMetaTask(
|
|
6544
6779
|
"Prepare intent definition for intent-to-task map",
|
|
6545
6780
|
(ctx) => {
|
|
@@ -6552,7 +6787,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6552
6787
|
};
|
|
6553
6788
|
}
|
|
6554
6789
|
).then(
|
|
6555
|
-
|
|
6790
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
6556
6791
|
CadenzaService.createMetaTask(
|
|
6557
6792
|
"Restore intent-to-task map payload",
|
|
6558
6793
|
(ctx) => {
|
|
@@ -6600,7 +6835,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6600
6835
|
return;
|
|
6601
6836
|
}
|
|
6602
6837
|
for (const t of task.nextTasks) {
|
|
6603
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
6838
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
6604
6839
|
continue;
|
|
6605
6840
|
}
|
|
6606
6841
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -6643,7 +6878,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6643
6878
|
{ concurrency: 30 }
|
|
6644
6879
|
)?.then(
|
|
6645
6880
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
6646
|
-
if (!ctx.__syncing) {
|
|
6881
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6647
6882
|
return;
|
|
6648
6883
|
}
|
|
6649
6884
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6704,7 +6939,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6704
6939
|
CadenzaService.createMetaTask(
|
|
6705
6940
|
"Record deputy relationship registration",
|
|
6706
6941
|
(ctx) => {
|
|
6707
|
-
if (!ctx.__syncing) {
|
|
6942
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6708
6943
|
return;
|
|
6709
6944
|
}
|
|
6710
6945
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6719,19 +6954,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6719
6954
|
"meta.sync_controller.sync_tick",
|
|
6720
6955
|
"meta.service_registry.initial_sync_complete"
|
|
6721
6956
|
).then(this.splitSignalsTask);
|
|
6722
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6957
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6958
|
+
"meta.sync_controller.sync_tick",
|
|
6959
|
+
"meta.sync_controller.synced_signals"
|
|
6960
|
+
).then(this.splitTasksForRegistration);
|
|
6723
6961
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
6724
6962
|
return {
|
|
6725
6963
|
...ctx,
|
|
6726
6964
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
6727
6965
|
};
|
|
6728
6966
|
}).doOn(
|
|
6729
|
-
"meta.sync_controller.
|
|
6730
|
-
"meta.
|
|
6967
|
+
"meta.sync_controller.sync_tick",
|
|
6968
|
+
"meta.service_registry.initial_sync_complete"
|
|
6731
6969
|
).then(this.splitIntentsTask);
|
|
6732
6970
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6733
|
-
"meta.sync_controller.
|
|
6734
|
-
"meta.
|
|
6971
|
+
"meta.sync_controller.sync_tick",
|
|
6972
|
+
"meta.service_registry.initial_sync_complete"
|
|
6735
6973
|
).then(this.splitRoutinesTask);
|
|
6736
6974
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
6737
6975
|
return {
|
|
@@ -6739,16 +6977,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6739
6977
|
actors: CadenzaService.getAllActors()
|
|
6740
6978
|
};
|
|
6741
6979
|
}).doOn(
|
|
6742
|
-
"meta.sync_controller.
|
|
6743
|
-
"meta.
|
|
6980
|
+
"meta.sync_controller.sync_tick",
|
|
6981
|
+
"meta.service_registry.initial_sync_complete"
|
|
6744
6982
|
).then(this.splitActorsForRegistration);
|
|
6745
|
-
CadenzaService.
|
|
6983
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
6984
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6985
|
+
if (!task) {
|
|
6986
|
+
return false;
|
|
6987
|
+
}
|
|
6988
|
+
return {
|
|
6989
|
+
...ctx,
|
|
6990
|
+
task
|
|
6991
|
+
};
|
|
6992
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6746
6993
|
this.registerTaskMapTask,
|
|
6747
6994
|
this.registerDeputyRelationshipTask
|
|
6748
6995
|
);
|
|
6749
6996
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
6750
6997
|
"meta.sync_controller.synced_signals"
|
|
6751
|
-
).then(
|
|
6998
|
+
).then(
|
|
6999
|
+
CadenzaService.createMetaTask(
|
|
7000
|
+
"Ensure signal and task sync ready",
|
|
7001
|
+
(ctx) => {
|
|
7002
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
7003
|
+
return false;
|
|
7004
|
+
}
|
|
7005
|
+
return ctx;
|
|
7006
|
+
}
|
|
7007
|
+
).then(this.registerSignalToTaskMapTask)
|
|
7008
|
+
);
|
|
6752
7009
|
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
6753
7010
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6754
7011
|
if (!task) {
|
|
@@ -6758,8 +7015,28 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6758
7015
|
...ctx,
|
|
6759
7016
|
task
|
|
6760
7017
|
};
|
|
6761
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6762
|
-
|
|
7018
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
7019
|
+
CadenzaService.createMetaTask(
|
|
7020
|
+
"Ensure signal and task sync ready from task registration",
|
|
7021
|
+
(ctx) => {
|
|
7022
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
7023
|
+
return false;
|
|
7024
|
+
}
|
|
7025
|
+
return ctx;
|
|
7026
|
+
}
|
|
7027
|
+
).then(this.registerSignalToTaskMapTask)
|
|
7028
|
+
);
|
|
7029
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
7030
|
+
CadenzaService.createMetaTask(
|
|
7031
|
+
"Ensure intent and task sync ready",
|
|
7032
|
+
(ctx) => {
|
|
7033
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
7034
|
+
return false;
|
|
7035
|
+
}
|
|
7036
|
+
return ctx;
|
|
7037
|
+
}
|
|
7038
|
+
).then(this.registerIntentToTaskMapTask)
|
|
7039
|
+
);
|
|
6763
7040
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
6764
7041
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6765
7042
|
if (!task) {
|
|
@@ -6769,7 +7046,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6769
7046
|
...ctx,
|
|
6770
7047
|
task
|
|
6771
7048
|
};
|
|
6772
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
7049
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
7050
|
+
CadenzaService.createMetaTask(
|
|
7051
|
+
"Ensure intent and task sync ready from task registration",
|
|
7052
|
+
(ctx) => {
|
|
7053
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
7054
|
+
return false;
|
|
7055
|
+
}
|
|
7056
|
+
return ctx;
|
|
7057
|
+
}
|
|
7058
|
+
).then(this.registerIntentToTaskMapTask)
|
|
7059
|
+
);
|
|
6773
7060
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
6774
7061
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
6775
7062
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
@@ -6782,9 +7069,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6782
7069
|
};
|
|
6783
7070
|
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
6784
7071
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6785
|
-
"meta.sync_controller.
|
|
6786
|
-
"meta.sync_controller.
|
|
6787
|
-
).then(
|
|
7072
|
+
"meta.sync_controller.synced_routines",
|
|
7073
|
+
"meta.sync_controller.task_registered"
|
|
7074
|
+
).then(
|
|
7075
|
+
CadenzaService.createMetaTask(
|
|
7076
|
+
"Ensure routine and task sync ready",
|
|
7077
|
+
(ctx) => {
|
|
7078
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
7079
|
+
return false;
|
|
7080
|
+
}
|
|
7081
|
+
return ctx;
|
|
7082
|
+
}
|
|
7083
|
+
).then(this.splitTasksInRoutines)
|
|
7084
|
+
);
|
|
6788
7085
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
6789
7086
|
emit("global.meta.sync_controller.synced", {
|
|
6790
7087
|
data: {
|
|
@@ -6812,6 +7109,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6812
7109
|
{ __syncing: true },
|
|
6813
7110
|
18e4
|
|
6814
7111
|
);
|
|
7112
|
+
CadenzaService.schedule(
|
|
7113
|
+
"meta.sync_controller.sync_tick",
|
|
7114
|
+
{ __syncing: true },
|
|
7115
|
+
250
|
|
7116
|
+
);
|
|
6815
7117
|
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
6816
7118
|
}
|
|
6817
7119
|
}
|
|
@@ -7212,20 +7514,28 @@ var CadenzaService = class {
|
|
|
7212
7514
|
return false;
|
|
7213
7515
|
});
|
|
7214
7516
|
if (responders.length === 0) {
|
|
7517
|
+
const inquiryMeta = {
|
|
7518
|
+
inquiry,
|
|
7519
|
+
isMetaInquiry,
|
|
7520
|
+
totalResponders: allResponders.length,
|
|
7521
|
+
eligibleResponders: 0,
|
|
7522
|
+
filteredOutResponders: allResponders.length,
|
|
7523
|
+
responded: 0,
|
|
7524
|
+
failed: 0,
|
|
7525
|
+
timedOut: 0,
|
|
7526
|
+
pending: 0,
|
|
7527
|
+
durationMs: 0,
|
|
7528
|
+
responders: []
|
|
7529
|
+
};
|
|
7530
|
+
if (options.requireComplete) {
|
|
7531
|
+
throw {
|
|
7532
|
+
__inquiryMeta: inquiryMeta,
|
|
7533
|
+
__error: `Inquiry '${inquiry}' had no eligible responders`,
|
|
7534
|
+
errored: true
|
|
7535
|
+
};
|
|
7536
|
+
}
|
|
7215
7537
|
return {
|
|
7216
|
-
__inquiryMeta:
|
|
7217
|
-
inquiry,
|
|
7218
|
-
isMetaInquiry,
|
|
7219
|
-
totalResponders: allResponders.length,
|
|
7220
|
-
eligibleResponders: 0,
|
|
7221
|
-
filteredOutResponders: allResponders.length,
|
|
7222
|
-
responded: 0,
|
|
7223
|
-
failed: 0,
|
|
7224
|
-
timedOut: 0,
|
|
7225
|
-
pending: 0,
|
|
7226
|
-
durationMs: 0,
|
|
7227
|
-
responders: []
|
|
7228
|
-
}
|
|
7538
|
+
__inquiryMeta: inquiryMeta
|
|
7229
7539
|
};
|
|
7230
7540
|
}
|
|
7231
7541
|
responders.sort(this.compareInquiryResponders.bind(this));
|
|
@@ -7912,6 +8222,12 @@ var CadenzaService = class {
|
|
|
7912
8222
|
displayName: options.displayName ?? "",
|
|
7913
8223
|
isMeta: options.isMeta
|
|
7914
8224
|
},
|
|
8225
|
+
__registrationData: {
|
|
8226
|
+
name: serviceName,
|
|
8227
|
+
description,
|
|
8228
|
+
displayName: options.displayName ?? "",
|
|
8229
|
+
isMeta: options.isMeta
|
|
8230
|
+
},
|
|
7915
8231
|
__serviceName: serviceName,
|
|
7916
8232
|
__serviceInstanceId: serviceId,
|
|
7917
8233
|
__port: options.port,
|
|
@@ -7964,6 +8280,16 @@ var CadenzaService = class {
|
|
|
7964
8280
|
is_blocked: false,
|
|
7965
8281
|
health: {}
|
|
7966
8282
|
},
|
|
8283
|
+
__registrationData: {
|
|
8284
|
+
uuid: serviceId,
|
|
8285
|
+
process_pid: 1,
|
|
8286
|
+
service_name: serviceName,
|
|
8287
|
+
is_frontend: true,
|
|
8288
|
+
is_active: true,
|
|
8289
|
+
is_non_responsive: false,
|
|
8290
|
+
is_blocked: false,
|
|
8291
|
+
health: {}
|
|
8292
|
+
},
|
|
7967
8293
|
__transportData: [],
|
|
7968
8294
|
__serviceName: serviceName,
|
|
7969
8295
|
__serviceInstanceId: serviceId,
|