@cadenza.io/service 2.17.23 → 2.17.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +473 -181
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +473 -181
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +476 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +476 -181
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -737,6 +737,72 @@ var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
737
737
|
"Collect distributed readiness",
|
|
738
738
|
"Get status"
|
|
739
739
|
]);
|
|
740
|
+
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
741
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
742
|
+
const getJoinedValue = (key) => {
|
|
743
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
744
|
+
const joinedContext = joinedContexts[index];
|
|
745
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
746
|
+
return joinedContext[key];
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return void 0;
|
|
750
|
+
};
|
|
751
|
+
const registrationData = Object.prototype.hasOwnProperty.call(ctx, "__registrationData") && ctx.__registrationData !== void 0 ? ctx.__registrationData : getJoinedValue("__registrationData");
|
|
752
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
753
|
+
const nextQueryData = {
|
|
754
|
+
...existingQueryData,
|
|
755
|
+
...queryData
|
|
756
|
+
};
|
|
757
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
758
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
759
|
+
if (!("data" in nextQueryData) && (resolvedData !== void 0 || registrationData !== void 0)) {
|
|
760
|
+
nextQueryData.data = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
761
|
+
}
|
|
762
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
763
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
764
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
765
|
+
) : resolvedBatch;
|
|
766
|
+
}
|
|
767
|
+
return nextQueryData;
|
|
768
|
+
}
|
|
769
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
770
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
771
|
+
tableName,
|
|
772
|
+
queryData,
|
|
773
|
+
options
|
|
774
|
+
);
|
|
775
|
+
return CadenzaService.createUniqueMetaTask(
|
|
776
|
+
`Resolve service registry insert for ${tableName}`,
|
|
777
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
778
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
779
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
780
|
+
CadenzaService.log(
|
|
781
|
+
"Service registry insert resolver missing service payload.",
|
|
782
|
+
{
|
|
783
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
784
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
785
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
786
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
787
|
+
},
|
|
788
|
+
"warning"
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
792
|
+
return targetTask.taskFunction(
|
|
793
|
+
{
|
|
794
|
+
...ctx,
|
|
795
|
+
queryData: nextQueryData
|
|
796
|
+
},
|
|
797
|
+
emit,
|
|
798
|
+
inquire,
|
|
799
|
+
progressCallback
|
|
800
|
+
);
|
|
801
|
+
},
|
|
802
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
803
|
+
options
|
|
804
|
+
);
|
|
805
|
+
}
|
|
740
806
|
function readPositiveIntegerEnv(name, fallback) {
|
|
741
807
|
if (typeof process === "undefined") {
|
|
742
808
|
return fallback;
|
|
@@ -1947,7 +2013,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2013
|
},
|
|
1948
2014
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1949
2015
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1950
|
-
this.insertServiceTask =
|
|
2016
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1951
2017
|
"service",
|
|
1952
2018
|
{
|
|
1953
2019
|
onConflict: {
|
|
@@ -1998,7 +2064,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1998
2064
|
retryDelayFactor: 1.3
|
|
1999
2065
|
}
|
|
2000
2066
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
2001
|
-
this.insertServiceInstanceTask =
|
|
2067
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
2002
2068
|
"service_instance",
|
|
2003
2069
|
{},
|
|
2004
2070
|
{
|
|
@@ -2056,7 +2122,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2056
2122
|
retryCount: 5,
|
|
2057
2123
|
retryDelay: 1e3
|
|
2058
2124
|
}
|
|
2059
|
-
).
|
|
2125
|
+
).then(
|
|
2060
2126
|
CadenzaService.createMetaTask(
|
|
2061
2127
|
"Setup service",
|
|
2062
2128
|
(ctx) => {
|
|
@@ -2083,8 +2149,17 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2083
2149
|
this.useSocket = __useSocket;
|
|
2084
2150
|
this.retryCount = __retryCount;
|
|
2085
2151
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2086
|
-
|
|
2087
|
-
|
|
2152
|
+
return {
|
|
2153
|
+
...ctx,
|
|
2154
|
+
serviceInstance: normalizedLocalInstance,
|
|
2155
|
+
data: {
|
|
2156
|
+
...ctx.data ?? {},
|
|
2157
|
+
uuid: normalizedLocalInstance.uuid,
|
|
2158
|
+
service_name: normalizedLocalInstance.serviceName
|
|
2159
|
+
},
|
|
2160
|
+
__serviceName: normalizedLocalInstance.serviceName,
|
|
2161
|
+
__serviceInstanceId: normalizedLocalInstance.uuid
|
|
2162
|
+
};
|
|
2088
2163
|
},
|
|
2089
2164
|
"Sets service instance id after insertion"
|
|
2090
2165
|
).emits("meta.service_registry.instance_inserted").then(
|
|
@@ -2098,6 +2173,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2098
2173
|
data: {
|
|
2099
2174
|
...transport,
|
|
2100
2175
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2176
|
+
},
|
|
2177
|
+
__registrationData: {
|
|
2178
|
+
...transport,
|
|
2179
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2101
2180
|
}
|
|
2102
2181
|
};
|
|
2103
2182
|
emit(
|
|
@@ -2111,7 +2190,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2111
2190
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2112
2191
|
)
|
|
2113
2192
|
);
|
|
2114
|
-
|
|
2193
|
+
CadenzaService.createMetaTask(
|
|
2194
|
+
"Prepare service instance registration",
|
|
2195
|
+
(ctx) => {
|
|
2196
|
+
const serviceName = String(
|
|
2197
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2198
|
+
).trim();
|
|
2199
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2200
|
+
CadenzaService.schedule(
|
|
2201
|
+
"meta.service_registry.instance_registration_requested",
|
|
2202
|
+
{ ...ctx },
|
|
2203
|
+
250
|
|
2204
|
+
);
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
return ctx;
|
|
2208
|
+
},
|
|
2209
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2210
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2211
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2115
2212
|
"service_instance_transport",
|
|
2116
2213
|
{
|
|
2117
2214
|
onConflict: {
|
|
@@ -2176,7 +2273,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2176
2273
|
retryCount: 5,
|
|
2177
2274
|
retryDelay: 1e3
|
|
2178
2275
|
}
|
|
2179
|
-
).
|
|
2276
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2277
|
+
CadenzaService.createMetaTask(
|
|
2278
|
+
"Prepare service transport registration",
|
|
2279
|
+
(ctx) => {
|
|
2280
|
+
const serviceName = String(
|
|
2281
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2282
|
+
).trim();
|
|
2283
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2284
|
+
CadenzaService.schedule(
|
|
2285
|
+
"meta.service_registry.transport_registration_requested",
|
|
2286
|
+
{ ...ctx },
|
|
2287
|
+
250
|
|
2288
|
+
);
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
return ctx;
|
|
2292
|
+
},
|
|
2293
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2294
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2180
2295
|
CadenzaService.createMetaTask(
|
|
2181
2296
|
"Handle service creation",
|
|
2182
2297
|
(ctx) => {
|
|
@@ -3390,6 +3505,16 @@ var RestController = class _RestController {
|
|
|
3390
3505
|
is_blocked: false,
|
|
3391
3506
|
health: {}
|
|
3392
3507
|
},
|
|
3508
|
+
__registrationData: {
|
|
3509
|
+
uuid: ctx.__serviceInstanceId,
|
|
3510
|
+
process_pid: 1,
|
|
3511
|
+
service_name: ctx.__serviceName,
|
|
3512
|
+
is_frontend: true,
|
|
3513
|
+
is_active: true,
|
|
3514
|
+
is_non_responsive: false,
|
|
3515
|
+
is_blocked: false,
|
|
3516
|
+
health: {}
|
|
3517
|
+
},
|
|
3393
3518
|
__transportData: [],
|
|
3394
3519
|
...ctx
|
|
3395
3520
|
});
|
|
@@ -5714,12 +5839,6 @@ var import_uuid4 = require("uuid");
|
|
|
5714
5839
|
|
|
5715
5840
|
// src/graph/controllers/GraphSyncController.ts
|
|
5716
5841
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5717
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
5718
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
5719
|
-
);
|
|
5720
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
5721
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
5722
|
-
);
|
|
5723
5842
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5724
5843
|
if (typeof taskFunction !== "function") {
|
|
5725
5844
|
return void 0;
|
|
@@ -5796,38 +5915,71 @@ function buildIntentRegistryData(intent) {
|
|
|
5796
5915
|
isMeta: isMetaIntentName(name)
|
|
5797
5916
|
};
|
|
5798
5917
|
}
|
|
5918
|
+
function getJoinedContextValue(ctx, key) {
|
|
5919
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
5920
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
5921
|
+
const joinedContext = joinedContexts[index];
|
|
5922
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
5923
|
+
return joinedContext[key];
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
return void 0;
|
|
5927
|
+
}
|
|
5928
|
+
function didSyncInsertSucceed(ctx) {
|
|
5929
|
+
return !ctx.errored && ctx.__success !== false;
|
|
5930
|
+
}
|
|
5931
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
5932
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
5933
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
5934
|
+
const nextQueryData = {
|
|
5935
|
+
...existingQueryData,
|
|
5936
|
+
...queryData
|
|
5937
|
+
};
|
|
5938
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
5939
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
5940
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
5941
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
5942
|
+
}
|
|
5943
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
5944
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
5945
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
5946
|
+
) : resolvedBatch;
|
|
5947
|
+
}
|
|
5948
|
+
return nextQueryData;
|
|
5949
|
+
}
|
|
5799
5950
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
5800
5951
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
}
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5952
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5953
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
5954
|
+
return void 0;
|
|
5955
|
+
}
|
|
5956
|
+
return CadenzaService.createUniqueMetaTask(
|
|
5957
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
5958
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
5959
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
5960
|
+
if (!targetTask) {
|
|
5961
|
+
return false;
|
|
5962
|
+
}
|
|
5963
|
+
return targetTask.taskFunction(
|
|
5964
|
+
{
|
|
5813
5965
|
...ctx,
|
|
5814
|
-
queryData:
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5966
|
+
queryData: buildSyncInsertQueryData(
|
|
5967
|
+
ctx,
|
|
5968
|
+
queryData
|
|
5969
|
+
)
|
|
5970
|
+
},
|
|
5971
|
+
emit,
|
|
5972
|
+
inquire,
|
|
5973
|
+
progressCallback
|
|
5974
|
+
);
|
|
5975
|
+
},
|
|
5976
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
5977
|
+
{
|
|
5978
|
+
...options,
|
|
5979
|
+
register: false,
|
|
5980
|
+
isHidden: true
|
|
5827
5981
|
}
|
|
5828
|
-
|
|
5829
|
-
}
|
|
5830
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5982
|
+
);
|
|
5831
5983
|
}
|
|
5832
5984
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
5833
5985
|
"intent_registry",
|
|
@@ -5846,11 +5998,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5846
5998
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
5847
5999
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5848
6000
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
5849
|
-
this.
|
|
6001
|
+
this.tasksSynced = false;
|
|
6002
|
+
this.signalsSynced = false;
|
|
6003
|
+
this.intentsSynced = false;
|
|
6004
|
+
this.routinesSynced = false;
|
|
5850
6005
|
this.isCadenzaDBReady = false;
|
|
5851
6006
|
this.initialized = false;
|
|
5852
6007
|
this.initRetryScheduled = false;
|
|
5853
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
5854
6008
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
5855
6009
|
}
|
|
5856
6010
|
static get instance() {
|
|
@@ -5925,21 +6079,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5925
6079
|
},
|
|
5926
6080
|
{ concurrency: 30 }
|
|
5927
6081
|
);
|
|
6082
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
6083
|
+
this.isCadenzaDBReady,
|
|
6084
|
+
"intent_registry",
|
|
6085
|
+
{
|
|
6086
|
+
onConflict: {
|
|
6087
|
+
target: ["name"],
|
|
6088
|
+
action: {
|
|
6089
|
+
do: "nothing"
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
},
|
|
6093
|
+
{ concurrency: 30 }
|
|
6094
|
+
);
|
|
5928
6095
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
5929
6096
|
"Split routines for registration",
|
|
5930
|
-
|
|
6097
|
+
(ctx, emit) => {
|
|
5931
6098
|
const { routines } = ctx;
|
|
5932
|
-
if (!routines) return;
|
|
6099
|
+
if (!routines) return false;
|
|
5933
6100
|
const serviceName2 = resolveSyncServiceName();
|
|
5934
6101
|
if (!serviceName2) {
|
|
5935
|
-
return;
|
|
6102
|
+
return false;
|
|
5936
6103
|
}
|
|
5937
6104
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5938
6105
|
delayMs: 2e3
|
|
5939
6106
|
});
|
|
6107
|
+
let emittedCount = 0;
|
|
5940
6108
|
for (const routine of routines) {
|
|
5941
6109
|
if (routine.registered) continue;
|
|
5942
|
-
|
|
6110
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
6111
|
+
__syncing: ctx.__syncing,
|
|
5943
6112
|
data: {
|
|
5944
6113
|
name: routine.name,
|
|
5945
6114
|
version: routine.version,
|
|
@@ -5948,10 +6117,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5948
6117
|
isMeta: routine.isMeta
|
|
5949
6118
|
},
|
|
5950
6119
|
__routineName: routine.name
|
|
5951
|
-
};
|
|
6120
|
+
});
|
|
6121
|
+
emittedCount += 1;
|
|
5952
6122
|
}
|
|
6123
|
+
return emittedCount > 0;
|
|
5953
6124
|
}
|
|
5954
|
-
)
|
|
6125
|
+
);
|
|
6126
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
5955
6127
|
resolveSyncInsertTask(
|
|
5956
6128
|
this.isCadenzaDBReady,
|
|
5957
6129
|
"routine",
|
|
@@ -5966,39 +6138,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5966
6138
|
{ concurrency: 30 }
|
|
5967
6139
|
)?.then(
|
|
5968
6140
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
5969
|
-
if (!ctx.__syncing) {
|
|
6141
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5970
6142
|
return;
|
|
5971
6143
|
}
|
|
5972
6144
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5973
6145
|
delayMs: 3e3
|
|
5974
6146
|
});
|
|
5975
6147
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6148
|
+
CadenzaService.debounce(
|
|
6149
|
+
"meta.sync_controller.routine_registration_settled",
|
|
6150
|
+
{ __syncing: true },
|
|
6151
|
+
300
|
|
6152
|
+
);
|
|
5976
6153
|
return true;
|
|
5977
|
-
})
|
|
5978
|
-
CadenzaService.createUniqueMetaTask(
|
|
5979
|
-
"Gather routine registration",
|
|
5980
|
-
() => true
|
|
5981
|
-
).emits("meta.sync_controller.synced_routines")
|
|
5982
|
-
)
|
|
6154
|
+
})
|
|
5983
6155
|
)
|
|
5984
6156
|
);
|
|
6157
|
+
CadenzaService.createUniqueMetaTask(
|
|
6158
|
+
"Gather routine registration",
|
|
6159
|
+
() => {
|
|
6160
|
+
this.routinesSynced = true;
|
|
6161
|
+
return true;
|
|
6162
|
+
}
|
|
6163
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
5985
6164
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
5986
6165
|
"Split tasks in routines",
|
|
5987
|
-
|
|
6166
|
+
(ctx, emit) => {
|
|
5988
6167
|
const { routines } = ctx;
|
|
5989
|
-
if (!routines) return;
|
|
6168
|
+
if (!routines) return false;
|
|
5990
6169
|
const serviceName2 = resolveSyncServiceName();
|
|
5991
6170
|
if (!serviceName2) {
|
|
5992
|
-
return;
|
|
6171
|
+
return false;
|
|
5993
6172
|
}
|
|
5994
6173
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5995
6174
|
delayMs: 3e3
|
|
5996
6175
|
});
|
|
6176
|
+
let emittedCount = 0;
|
|
5997
6177
|
for (const routine of routines) {
|
|
5998
6178
|
if (!routine.registered) continue;
|
|
5999
6179
|
for (const task of routine.tasks) {
|
|
6000
6180
|
if (!task) {
|
|
6001
|
-
console.log("task is null", routine, task);
|
|
6002
6181
|
continue;
|
|
6003
6182
|
}
|
|
6004
6183
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -6008,7 +6187,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6008
6187
|
if (!nextTask?.registered) {
|
|
6009
6188
|
continue;
|
|
6010
6189
|
}
|
|
6011
|
-
|
|
6190
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
6191
|
+
__syncing: ctx.__syncing,
|
|
6012
6192
|
data: {
|
|
6013
6193
|
taskName: nextTask.name,
|
|
6014
6194
|
taskVersion: nextTask.version,
|
|
@@ -6018,12 +6198,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6018
6198
|
},
|
|
6019
6199
|
__routineName: routine.name,
|
|
6020
6200
|
__taskName: nextTask.name
|
|
6021
|
-
};
|
|
6201
|
+
});
|
|
6202
|
+
emittedCount += 1;
|
|
6022
6203
|
}
|
|
6023
6204
|
}
|
|
6024
6205
|
}
|
|
6206
|
+
return emittedCount > 0;
|
|
6025
6207
|
}
|
|
6026
|
-
)
|
|
6208
|
+
);
|
|
6209
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
6027
6210
|
resolveSyncInsertTask(
|
|
6028
6211
|
this.isCadenzaDBReady,
|
|
6029
6212
|
"task_to_routine_map",
|
|
@@ -6044,7 +6227,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6044
6227
|
{ concurrency: 30 }
|
|
6045
6228
|
)?.then(
|
|
6046
6229
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
6047
|
-
if (!ctx.__syncing) {
|
|
6230
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6048
6231
|
return;
|
|
6049
6232
|
}
|
|
6050
6233
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6058,18 +6241,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6058
6241
|
);
|
|
6059
6242
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
6060
6243
|
"Split signals for registration",
|
|
6061
|
-
|
|
6244
|
+
(ctx, emit) => {
|
|
6062
6245
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6063
6246
|
delayMs: 3e3
|
|
6064
6247
|
});
|
|
6065
6248
|
const { signals } = ctx;
|
|
6066
|
-
if (!signals) return;
|
|
6249
|
+
if (!signals) return false;
|
|
6067
6250
|
const filteredSignals = signals.filter(
|
|
6068
6251
|
(signal) => !signal.data.registered
|
|
6069
6252
|
).map((signal) => signal.signal);
|
|
6070
6253
|
for (const signal of filteredSignals) {
|
|
6071
6254
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
6072
|
-
|
|
6255
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
6256
|
+
__syncing: ctx.__syncing,
|
|
6073
6257
|
data: {
|
|
6074
6258
|
name: signal,
|
|
6075
6259
|
isGlobal,
|
|
@@ -6078,10 +6262,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6078
6262
|
isMeta
|
|
6079
6263
|
},
|
|
6080
6264
|
__signal: signal
|
|
6081
|
-
};
|
|
6265
|
+
});
|
|
6082
6266
|
}
|
|
6267
|
+
return filteredSignals.length > 0;
|
|
6083
6268
|
}
|
|
6084
|
-
)
|
|
6269
|
+
);
|
|
6270
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
6085
6271
|
resolveSyncInsertTask(
|
|
6086
6272
|
this.isCadenzaDBReady,
|
|
6087
6273
|
"signal_registry",
|
|
@@ -6096,37 +6282,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6096
6282
|
{ concurrency: 30 }
|
|
6097
6283
|
)?.then(
|
|
6098
6284
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
6099
|
-
if (!ctx.__syncing) {
|
|
6285
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6100
6286
|
return;
|
|
6101
6287
|
}
|
|
6102
6288
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6103
6289
|
delayMs: 3e3
|
|
6104
6290
|
});
|
|
6291
|
+
CadenzaService.debounce(
|
|
6292
|
+
"meta.sync_controller.signal_registration_settled",
|
|
6293
|
+
{ __syncing: true },
|
|
6294
|
+
300
|
|
6295
|
+
);
|
|
6105
6296
|
return { signalName: ctx.__signal };
|
|
6106
|
-
}).then(
|
|
6107
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
6108
|
-
CadenzaService.createUniqueMetaTask(
|
|
6109
|
-
"Gather signal registration",
|
|
6110
|
-
() => true
|
|
6111
|
-
).emits("meta.sync_controller.synced_signals")
|
|
6112
|
-
)
|
|
6297
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
6113
6298
|
)
|
|
6114
6299
|
);
|
|
6300
|
+
CadenzaService.createUniqueMetaTask(
|
|
6301
|
+
"Gather signal registration",
|
|
6302
|
+
() => {
|
|
6303
|
+
this.signalsSynced = true;
|
|
6304
|
+
return true;
|
|
6305
|
+
}
|
|
6306
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
6115
6307
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
6116
6308
|
"Split tasks for registration",
|
|
6117
|
-
|
|
6309
|
+
(ctx, emit) => {
|
|
6118
6310
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6119
6311
|
delayMs: 3e3
|
|
6120
6312
|
});
|
|
6121
6313
|
const tasks = ctx.tasks;
|
|
6122
6314
|
const serviceName2 = resolveSyncServiceName();
|
|
6123
6315
|
if (!serviceName2) {
|
|
6124
|
-
return;
|
|
6316
|
+
return false;
|
|
6125
6317
|
}
|
|
6318
|
+
let emittedCount = 0;
|
|
6126
6319
|
for (const task of tasks) {
|
|
6127
6320
|
if (task.registered) continue;
|
|
6128
6321
|
const { __functionString, __getTagCallback } = task.export();
|
|
6129
|
-
|
|
6322
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
6323
|
+
__syncing: ctx.__syncing,
|
|
6130
6324
|
data: {
|
|
6131
6325
|
name: task.name,
|
|
6132
6326
|
version: task.version,
|
|
@@ -6144,9 +6338,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6144
6338
|
isMeta: task.isMeta,
|
|
6145
6339
|
isSubMeta: task.isSubMeta,
|
|
6146
6340
|
isHidden: task.isHidden,
|
|
6147
|
-
// inputSchema: task.inputSchema,
|
|
6148
6341
|
validateInputContext: task.validateInputContext,
|
|
6149
|
-
// outputSchema: task.outputSchema,
|
|
6150
6342
|
validateOutputContext: task.validateOutputContext,
|
|
6151
6343
|
retryCount: task.retryCount,
|
|
6152
6344
|
retryDelay: task.retryDelay,
|
|
@@ -6161,10 +6353,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6161
6353
|
}
|
|
6162
6354
|
},
|
|
6163
6355
|
__taskName: task.name
|
|
6164
|
-
};
|
|
6356
|
+
});
|
|
6357
|
+
emittedCount += 1;
|
|
6165
6358
|
}
|
|
6359
|
+
return emittedCount > 0;
|
|
6166
6360
|
}
|
|
6167
|
-
)
|
|
6361
|
+
);
|
|
6362
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
6168
6363
|
resolveSyncInsertTask(
|
|
6169
6364
|
this.isCadenzaDBReady,
|
|
6170
6365
|
"task",
|
|
@@ -6179,7 +6374,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6179
6374
|
{ concurrency: 30 }
|
|
6180
6375
|
)?.then(
|
|
6181
6376
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
6182
|
-
if (!ctx.__syncing) {
|
|
6377
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6183
6378
|
return;
|
|
6184
6379
|
}
|
|
6185
6380
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6190,15 +6385,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6190
6385
|
...ctx,
|
|
6191
6386
|
task: CadenzaService.get(ctx.__taskName)
|
|
6192
6387
|
});
|
|
6388
|
+
CadenzaService.debounce(
|
|
6389
|
+
"meta.sync_controller.task_registration_settled",
|
|
6390
|
+
{ __syncing: true },
|
|
6391
|
+
300
|
|
6392
|
+
);
|
|
6193
6393
|
return true;
|
|
6194
|
-
})
|
|
6195
|
-
CadenzaService.createUniqueMetaTask(
|
|
6196
|
-
"Gather task registration",
|
|
6197
|
-
() => true
|
|
6198
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
6199
|
-
)
|
|
6394
|
+
})
|
|
6200
6395
|
)
|
|
6201
6396
|
);
|
|
6397
|
+
CadenzaService.createUniqueMetaTask(
|
|
6398
|
+
"Gather task registration",
|
|
6399
|
+
() => {
|
|
6400
|
+
this.tasksSynced = true;
|
|
6401
|
+
return true;
|
|
6402
|
+
}
|
|
6403
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
6202
6404
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
6203
6405
|
"Split actors for registration",
|
|
6204
6406
|
function* (ctx) {
|
|
@@ -6243,22 +6445,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6243
6445
|
{ concurrency: 30 }
|
|
6244
6446
|
)?.then(
|
|
6245
6447
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
6246
|
-
if (!ctx.__syncing) {
|
|
6448
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6247
6449
|
return;
|
|
6248
6450
|
}
|
|
6249
6451
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6250
6452
|
delayMs: 3e3
|
|
6251
6453
|
});
|
|
6252
6454
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
6455
|
+
CadenzaService.debounce(
|
|
6456
|
+
"meta.sync_controller.actor_registration_settled",
|
|
6457
|
+
{ __syncing: true },
|
|
6458
|
+
300
|
|
6459
|
+
);
|
|
6253
6460
|
return true;
|
|
6254
|
-
})
|
|
6255
|
-
CadenzaService.createUniqueMetaTask(
|
|
6256
|
-
"Gather actor registration",
|
|
6257
|
-
() => true
|
|
6258
|
-
).emits("meta.sync_controller.synced_actors")
|
|
6259
|
-
)
|
|
6461
|
+
})
|
|
6260
6462
|
)
|
|
6261
6463
|
);
|
|
6464
|
+
CadenzaService.createUniqueMetaTask(
|
|
6465
|
+
"Gather actor registration",
|
|
6466
|
+
() => true
|
|
6467
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
6262
6468
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
6263
6469
|
"Split actor task maps",
|
|
6264
6470
|
function* (ctx) {
|
|
@@ -6313,7 +6519,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6313
6519
|
{ concurrency: 30 }
|
|
6314
6520
|
)?.then(
|
|
6315
6521
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
6316
|
-
if (!ctx.__syncing) {
|
|
6522
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6317
6523
|
return;
|
|
6318
6524
|
}
|
|
6319
6525
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6326,7 +6532,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6326
6532
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
6327
6533
|
"Record signal registration",
|
|
6328
6534
|
(ctx) => {
|
|
6329
|
-
if (!ctx.__syncing) {
|
|
6535
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6330
6536
|
return;
|
|
6331
6537
|
}
|
|
6332
6538
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6337,13 +6543,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6337
6543
|
);
|
|
6338
6544
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
6339
6545
|
"Split observed signals of task",
|
|
6340
|
-
|
|
6546
|
+
(ctx, emit) => {
|
|
6341
6547
|
const task = ctx.task;
|
|
6342
|
-
if (task.hidden || !task.register) return;
|
|
6548
|
+
if (task.hidden || !task.register) return false;
|
|
6343
6549
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6344
6550
|
if (!serviceName2) {
|
|
6345
|
-
return;
|
|
6551
|
+
return false;
|
|
6346
6552
|
}
|
|
6553
|
+
let emittedCount = 0;
|
|
6347
6554
|
for (const signal of task.observedSignals) {
|
|
6348
6555
|
const _signal = signal.split(":")[0];
|
|
6349
6556
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -6351,7 +6558,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6351
6558
|
continue;
|
|
6352
6559
|
}
|
|
6353
6560
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
6354
|
-
|
|
6561
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
6562
|
+
__syncing: ctx.__syncing,
|
|
6355
6563
|
data: {
|
|
6356
6564
|
signalName: _signal,
|
|
6357
6565
|
isGlobal,
|
|
@@ -6361,10 +6569,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6361
6569
|
},
|
|
6362
6570
|
__taskName: task.name,
|
|
6363
6571
|
__signal: signal
|
|
6364
|
-
};
|
|
6572
|
+
});
|
|
6573
|
+
emittedCount += 1;
|
|
6365
6574
|
}
|
|
6575
|
+
return emittedCount > 0;
|
|
6366
6576
|
}
|
|
6367
|
-
)
|
|
6577
|
+
);
|
|
6578
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
6368
6579
|
resolveSyncInsertTask(
|
|
6369
6580
|
this.isCadenzaDBReady,
|
|
6370
6581
|
"signal_to_task_map",
|
|
@@ -6386,29 +6597,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6386
6597
|
);
|
|
6387
6598
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
6388
6599
|
"Split intents for registration",
|
|
6389
|
-
function
|
|
6600
|
+
function(ctx, emit) {
|
|
6390
6601
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6391
6602
|
delayMs: 3e3
|
|
6392
6603
|
});
|
|
6393
6604
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
6394
|
-
|
|
6395
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
6396
|
-
const authorityIntentNames = intentNames.filter(
|
|
6397
|
-
(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")
|
|
6398
|
-
);
|
|
6399
|
-
CadenzaService.log(
|
|
6400
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
6401
|
-
{
|
|
6402
|
-
totalIntents: intentNames.length,
|
|
6403
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
6404
|
-
"meta-service-registry-full-sync"
|
|
6405
|
-
),
|
|
6406
|
-
authorityIntentNames
|
|
6407
|
-
},
|
|
6408
|
-
"info"
|
|
6409
|
-
);
|
|
6410
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
6411
|
-
}
|
|
6605
|
+
let emittedCount = 0;
|
|
6412
6606
|
for (const intent of intents) {
|
|
6413
6607
|
const intentData = buildIntentRegistryData(intent);
|
|
6414
6608
|
if (!intentData) {
|
|
@@ -6417,35 +6611,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6417
6611
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
6418
6612
|
continue;
|
|
6419
6613
|
}
|
|
6420
|
-
|
|
6614
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
6615
|
+
__syncing: ctx.__syncing,
|
|
6421
6616
|
data: intentData,
|
|
6422
6617
|
__intentName: intentData.name
|
|
6423
|
-
};
|
|
6618
|
+
});
|
|
6619
|
+
emittedCount += 1;
|
|
6424
6620
|
}
|
|
6621
|
+
return emittedCount > 0;
|
|
6425
6622
|
}.bind(this)
|
|
6426
|
-
)
|
|
6623
|
+
);
|
|
6624
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
6427
6625
|
insertIntentRegistryTask?.then(
|
|
6428
6626
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
6429
|
-
if (!ctx.__syncing) {
|
|
6627
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6430
6628
|
return;
|
|
6431
6629
|
}
|
|
6432
6630
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6433
6631
|
delayMs: 3e3
|
|
6434
6632
|
});
|
|
6435
6633
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
6634
|
+
CadenzaService.debounce(
|
|
6635
|
+
"meta.sync_controller.intent_registration_settled",
|
|
6636
|
+
{ __syncing: true },
|
|
6637
|
+
300
|
|
6638
|
+
);
|
|
6436
6639
|
return true;
|
|
6437
|
-
})
|
|
6438
|
-
CadenzaService.createUniqueMetaTask(
|
|
6439
|
-
"Gather intent registration",
|
|
6440
|
-
() => true
|
|
6441
|
-
).emits("meta.sync_controller.synced_intents")
|
|
6442
|
-
)
|
|
6640
|
+
})
|
|
6443
6641
|
)
|
|
6444
6642
|
);
|
|
6643
|
+
CadenzaService.createUniqueMetaTask(
|
|
6644
|
+
"Gather intent registration",
|
|
6645
|
+
() => {
|
|
6646
|
+
this.intentsSynced = true;
|
|
6647
|
+
return true;
|
|
6648
|
+
}
|
|
6649
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
6445
6650
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
6446
6651
|
"Record intent registration",
|
|
6447
6652
|
(ctx) => {
|
|
6448
|
-
if (!ctx.__syncing) {
|
|
6653
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6449
6654
|
return;
|
|
6450
6655
|
}
|
|
6451
6656
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6458,37 +6663,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6458
6663
|
);
|
|
6459
6664
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
6460
6665
|
"Split intents of task",
|
|
6461
|
-
function
|
|
6666
|
+
function(ctx, emit) {
|
|
6462
6667
|
const task = ctx.task;
|
|
6463
|
-
if (task.hidden || !task.register) return;
|
|
6668
|
+
if (task.hidden || !task.register) return false;
|
|
6464
6669
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6465
6670
|
if (!serviceName2) {
|
|
6466
|
-
return;
|
|
6671
|
+
return false;
|
|
6467
6672
|
}
|
|
6468
6673
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
6469
6674
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
6470
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
6471
|
-
"Query service_instance",
|
|
6472
|
-
"Query service_instance_transport",
|
|
6473
|
-
"Query intent_to_task_map",
|
|
6474
|
-
"Query signal_to_task_map"
|
|
6475
|
-
].includes(task.name)) {
|
|
6476
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
6477
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
6478
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
6479
|
-
CadenzaService.log(
|
|
6480
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
6481
|
-
{
|
|
6482
|
-
taskName: task.name,
|
|
6483
|
-
taskVersion: task.version,
|
|
6484
|
-
isMeta: task.isMeta,
|
|
6485
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
6486
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
6487
|
-
},
|
|
6488
|
-
"info"
|
|
6489
|
-
);
|
|
6490
|
-
}
|
|
6491
|
-
}
|
|
6492
6675
|
for (const intent of task.handlesIntents) {
|
|
6493
6676
|
if (task.__registeredIntents.has(intent)) continue;
|
|
6494
6677
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -6510,7 +6693,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6510
6693
|
if (!intentDefinition) {
|
|
6511
6694
|
continue;
|
|
6512
6695
|
}
|
|
6513
|
-
|
|
6696
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
6697
|
+
__syncing: ctx.__syncing,
|
|
6514
6698
|
data: {
|
|
6515
6699
|
intentName: intent,
|
|
6516
6700
|
taskName: task.name,
|
|
@@ -6526,10 +6710,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6526
6710
|
taskVersion: task.version,
|
|
6527
6711
|
serviceName: serviceName2
|
|
6528
6712
|
}
|
|
6529
|
-
};
|
|
6713
|
+
});
|
|
6530
6714
|
}
|
|
6715
|
+
return true;
|
|
6531
6716
|
}.bind(this)
|
|
6532
|
-
)
|
|
6717
|
+
);
|
|
6718
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
6533
6719
|
CadenzaService.createMetaTask(
|
|
6534
6720
|
"Prepare intent definition for intent-to-task map",
|
|
6535
6721
|
(ctx) => {
|
|
@@ -6542,7 +6728,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6542
6728
|
};
|
|
6543
6729
|
}
|
|
6544
6730
|
).then(
|
|
6545
|
-
|
|
6731
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
6546
6732
|
CadenzaService.createMetaTask(
|
|
6547
6733
|
"Restore intent-to-task map payload",
|
|
6548
6734
|
(ctx) => {
|
|
@@ -6590,7 +6776,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6590
6776
|
return;
|
|
6591
6777
|
}
|
|
6592
6778
|
for (const t of task.nextTasks) {
|
|
6593
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
6779
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
6594
6780
|
continue;
|
|
6595
6781
|
}
|
|
6596
6782
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -6633,7 +6819,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6633
6819
|
{ concurrency: 30 }
|
|
6634
6820
|
)?.then(
|
|
6635
6821
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
6636
|
-
if (!ctx.__syncing) {
|
|
6822
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6637
6823
|
return;
|
|
6638
6824
|
}
|
|
6639
6825
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6694,7 +6880,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6694
6880
|
CadenzaService.createMetaTask(
|
|
6695
6881
|
"Record deputy relationship registration",
|
|
6696
6882
|
(ctx) => {
|
|
6697
|
-
if (!ctx.__syncing) {
|
|
6883
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6698
6884
|
return;
|
|
6699
6885
|
}
|
|
6700
6886
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6709,29 +6895,89 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6709
6895
|
"meta.sync_controller.sync_tick",
|
|
6710
6896
|
"meta.service_registry.initial_sync_complete"
|
|
6711
6897
|
).then(this.splitSignalsTask);
|
|
6712
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6898
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6899
|
+
"meta.sync_controller.sync_tick",
|
|
6900
|
+
"meta.sync_controller.synced_signals"
|
|
6901
|
+
).then(this.splitTasksForRegistration);
|
|
6713
6902
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
6714
6903
|
return {
|
|
6715
6904
|
...ctx,
|
|
6716
6905
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
6717
6906
|
};
|
|
6718
|
-
}).doOn(
|
|
6719
|
-
|
|
6907
|
+
}).doOn(
|
|
6908
|
+
"meta.sync_controller.sync_tick",
|
|
6909
|
+
"meta.service_registry.initial_sync_complete"
|
|
6910
|
+
).then(this.splitIntentsTask);
|
|
6911
|
+
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6912
|
+
"meta.sync_controller.sync_tick",
|
|
6913
|
+
"meta.service_registry.initial_sync_complete"
|
|
6914
|
+
).then(this.splitRoutinesTask);
|
|
6720
6915
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
6721
6916
|
return {
|
|
6722
6917
|
...ctx,
|
|
6723
6918
|
actors: CadenzaService.getAllActors()
|
|
6724
6919
|
};
|
|
6725
|
-
}).doOn(
|
|
6726
|
-
|
|
6920
|
+
}).doOn(
|
|
6921
|
+
"meta.sync_controller.sync_tick",
|
|
6922
|
+
"meta.service_registry.initial_sync_complete"
|
|
6923
|
+
).then(this.splitActorsForRegistration);
|
|
6924
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
6925
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6926
|
+
if (!task) {
|
|
6927
|
+
return false;
|
|
6928
|
+
}
|
|
6929
|
+
return {
|
|
6930
|
+
...ctx,
|
|
6931
|
+
task
|
|
6932
|
+
};
|
|
6933
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6727
6934
|
this.registerTaskMapTask,
|
|
6728
6935
|
this.registerDeputyRelationshipTask
|
|
6729
6936
|
);
|
|
6730
6937
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
6731
|
-
"meta.sync_controller.synced_tasks",
|
|
6732
6938
|
"meta.sync_controller.synced_signals"
|
|
6733
|
-
).then(
|
|
6734
|
-
|
|
6939
|
+
).then(
|
|
6940
|
+
CadenzaService.createMetaTask(
|
|
6941
|
+
"Ensure signal and task sync ready",
|
|
6942
|
+
(ctx) => {
|
|
6943
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6944
|
+
return false;
|
|
6945
|
+
}
|
|
6946
|
+
return ctx;
|
|
6947
|
+
}
|
|
6948
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6949
|
+
);
|
|
6950
|
+
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
6951
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6952
|
+
if (!task) {
|
|
6953
|
+
return false;
|
|
6954
|
+
}
|
|
6955
|
+
return {
|
|
6956
|
+
...ctx,
|
|
6957
|
+
task
|
|
6958
|
+
};
|
|
6959
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6960
|
+
CadenzaService.createMetaTask(
|
|
6961
|
+
"Ensure signal and task sync ready from task registration",
|
|
6962
|
+
(ctx) => {
|
|
6963
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6964
|
+
return false;
|
|
6965
|
+
}
|
|
6966
|
+
return ctx;
|
|
6967
|
+
}
|
|
6968
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6969
|
+
);
|
|
6970
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
6971
|
+
CadenzaService.createMetaTask(
|
|
6972
|
+
"Ensure intent and task sync ready",
|
|
6973
|
+
(ctx) => {
|
|
6974
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
6975
|
+
return false;
|
|
6976
|
+
}
|
|
6977
|
+
return ctx;
|
|
6978
|
+
}
|
|
6979
|
+
).then(this.registerIntentToTaskMapTask)
|
|
6980
|
+
);
|
|
6735
6981
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
6736
6982
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6737
6983
|
if (!task) {
|
|
@@ -6741,12 +6987,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6741
6987
|
...ctx,
|
|
6742
6988
|
task
|
|
6743
6989
|
};
|
|
6744
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6745
|
-
|
|
6990
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6991
|
+
CadenzaService.createMetaTask(
|
|
6992
|
+
"Ensure intent and task sync ready from task registration",
|
|
6993
|
+
(ctx) => {
|
|
6994
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
6995
|
+
return false;
|
|
6996
|
+
}
|
|
6997
|
+
return ctx;
|
|
6998
|
+
}
|
|
6999
|
+
).then(this.registerIntentToTaskMapTask)
|
|
7000
|
+
);
|
|
7001
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
7002
|
+
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
7003
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
7004
|
+
if (!task) {
|
|
7005
|
+
return false;
|
|
7006
|
+
}
|
|
7007
|
+
return {
|
|
7008
|
+
...ctx,
|
|
7009
|
+
task
|
|
7010
|
+
};
|
|
7011
|
+
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
6746
7012
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6747
|
-
"meta.sync_controller.
|
|
6748
|
-
"meta.sync_controller.
|
|
6749
|
-
).then(
|
|
7013
|
+
"meta.sync_controller.synced_routines",
|
|
7014
|
+
"meta.sync_controller.task_registered"
|
|
7015
|
+
).then(
|
|
7016
|
+
CadenzaService.createMetaTask(
|
|
7017
|
+
"Ensure routine and task sync ready",
|
|
7018
|
+
(ctx) => {
|
|
7019
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
7020
|
+
return false;
|
|
7021
|
+
}
|
|
7022
|
+
return ctx;
|
|
7023
|
+
}
|
|
7024
|
+
).then(this.splitTasksInRoutines)
|
|
7025
|
+
);
|
|
6750
7026
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
6751
7027
|
emit("global.meta.sync_controller.synced", {
|
|
6752
7028
|
data: {
|
|
@@ -7874,6 +8150,12 @@ var CadenzaService = class {
|
|
|
7874
8150
|
displayName: options.displayName ?? "",
|
|
7875
8151
|
isMeta: options.isMeta
|
|
7876
8152
|
},
|
|
8153
|
+
__registrationData: {
|
|
8154
|
+
name: serviceName,
|
|
8155
|
+
description,
|
|
8156
|
+
displayName: options.displayName ?? "",
|
|
8157
|
+
isMeta: options.isMeta
|
|
8158
|
+
},
|
|
7877
8159
|
__serviceName: serviceName,
|
|
7878
8160
|
__serviceInstanceId: serviceId,
|
|
7879
8161
|
__port: options.port,
|
|
@@ -7926,6 +8208,16 @@ var CadenzaService = class {
|
|
|
7926
8208
|
is_blocked: false,
|
|
7927
8209
|
health: {}
|
|
7928
8210
|
},
|
|
8211
|
+
__registrationData: {
|
|
8212
|
+
uuid: serviceId,
|
|
8213
|
+
process_pid: 1,
|
|
8214
|
+
service_name: serviceName,
|
|
8215
|
+
is_frontend: true,
|
|
8216
|
+
is_active: true,
|
|
8217
|
+
is_non_responsive: false,
|
|
8218
|
+
is_blocked: false,
|
|
8219
|
+
health: {}
|
|
8220
|
+
},
|
|
7929
8221
|
__transportData: [],
|
|
7930
8222
|
__serviceName: serviceName,
|
|
7931
8223
|
__serviceInstanceId: serviceId,
|