@cadenza.io/service 2.17.24 → 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 +436 -182
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +436 -182
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +439 -182
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +439 -182
- 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,7 +2149,6 @@ 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
|
-
console.log("SETUP SERVICE", this.serviceInstanceId);
|
|
2087
2152
|
return {
|
|
2088
2153
|
...ctx,
|
|
2089
2154
|
serviceInstance: normalizedLocalInstance,
|
|
@@ -2108,6 +2173,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2108
2173
|
data: {
|
|
2109
2174
|
...transport,
|
|
2110
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
|
|
2111
2180
|
}
|
|
2112
2181
|
};
|
|
2113
2182
|
emit(
|
|
@@ -2121,7 +2190,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2121
2190
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2122
2191
|
)
|
|
2123
2192
|
);
|
|
2124
|
-
|
|
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(
|
|
2125
2212
|
"service_instance_transport",
|
|
2126
2213
|
{
|
|
2127
2214
|
onConflict: {
|
|
@@ -2186,7 +2273,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2186
2273
|
retryCount: 5,
|
|
2187
2274
|
retryDelay: 1e3
|
|
2188
2275
|
}
|
|
2189
|
-
).
|
|
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);
|
|
2190
2295
|
CadenzaService.createMetaTask(
|
|
2191
2296
|
"Handle service creation",
|
|
2192
2297
|
(ctx) => {
|
|
@@ -3400,6 +3505,16 @@ var RestController = class _RestController {
|
|
|
3400
3505
|
is_blocked: false,
|
|
3401
3506
|
health: {}
|
|
3402
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
|
+
},
|
|
3403
3518
|
__transportData: [],
|
|
3404
3519
|
...ctx
|
|
3405
3520
|
});
|
|
@@ -5724,12 +5839,6 @@ var import_uuid4 = require("uuid");
|
|
|
5724
5839
|
|
|
5725
5840
|
// src/graph/controllers/GraphSyncController.ts
|
|
5726
5841
|
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
5842
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5734
5843
|
if (typeof taskFunction !== "function") {
|
|
5735
5844
|
return void 0;
|
|
@@ -5806,38 +5915,71 @@ function buildIntentRegistryData(intent) {
|
|
|
5806
5915
|
isMeta: isMetaIntentName(name)
|
|
5807
5916
|
};
|
|
5808
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
|
+
}
|
|
5809
5950
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
5810
5951
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
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
|
+
{
|
|
5823
5965
|
...ctx,
|
|
5824
|
-
queryData:
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
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
|
|
5837
5981
|
}
|
|
5838
|
-
|
|
5839
|
-
}
|
|
5840
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5982
|
+
);
|
|
5841
5983
|
}
|
|
5842
5984
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
5843
5985
|
"intent_registry",
|
|
@@ -5856,11 +5998,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5856
5998
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
5857
5999
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5858
6000
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
5859
|
-
this.
|
|
6001
|
+
this.tasksSynced = false;
|
|
6002
|
+
this.signalsSynced = false;
|
|
6003
|
+
this.intentsSynced = false;
|
|
6004
|
+
this.routinesSynced = false;
|
|
5860
6005
|
this.isCadenzaDBReady = false;
|
|
5861
6006
|
this.initialized = false;
|
|
5862
6007
|
this.initRetryScheduled = false;
|
|
5863
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
5864
6008
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
5865
6009
|
}
|
|
5866
6010
|
static get instance() {
|
|
@@ -5935,21 +6079,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5935
6079
|
},
|
|
5936
6080
|
{ concurrency: 30 }
|
|
5937
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
|
+
);
|
|
5938
6095
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
5939
6096
|
"Split routines for registration",
|
|
5940
|
-
|
|
6097
|
+
(ctx, emit) => {
|
|
5941
6098
|
const { routines } = ctx;
|
|
5942
|
-
if (!routines) return;
|
|
6099
|
+
if (!routines) return false;
|
|
5943
6100
|
const serviceName2 = resolveSyncServiceName();
|
|
5944
6101
|
if (!serviceName2) {
|
|
5945
|
-
return;
|
|
6102
|
+
return false;
|
|
5946
6103
|
}
|
|
5947
6104
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5948
6105
|
delayMs: 2e3
|
|
5949
6106
|
});
|
|
6107
|
+
let emittedCount = 0;
|
|
5950
6108
|
for (const routine of routines) {
|
|
5951
6109
|
if (routine.registered) continue;
|
|
5952
|
-
|
|
6110
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
6111
|
+
__syncing: ctx.__syncing,
|
|
5953
6112
|
data: {
|
|
5954
6113
|
name: routine.name,
|
|
5955
6114
|
version: routine.version,
|
|
@@ -5958,10 +6117,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5958
6117
|
isMeta: routine.isMeta
|
|
5959
6118
|
},
|
|
5960
6119
|
__routineName: routine.name
|
|
5961
|
-
};
|
|
6120
|
+
});
|
|
6121
|
+
emittedCount += 1;
|
|
5962
6122
|
}
|
|
6123
|
+
return emittedCount > 0;
|
|
5963
6124
|
}
|
|
5964
|
-
)
|
|
6125
|
+
);
|
|
6126
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
5965
6127
|
resolveSyncInsertTask(
|
|
5966
6128
|
this.isCadenzaDBReady,
|
|
5967
6129
|
"routine",
|
|
@@ -5976,39 +6138,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5976
6138
|
{ concurrency: 30 }
|
|
5977
6139
|
)?.then(
|
|
5978
6140
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
5979
|
-
if (!ctx.__syncing) {
|
|
6141
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5980
6142
|
return;
|
|
5981
6143
|
}
|
|
5982
6144
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5983
6145
|
delayMs: 3e3
|
|
5984
6146
|
});
|
|
5985
6147
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6148
|
+
CadenzaService.debounce(
|
|
6149
|
+
"meta.sync_controller.routine_registration_settled",
|
|
6150
|
+
{ __syncing: true },
|
|
6151
|
+
300
|
|
6152
|
+
);
|
|
5986
6153
|
return true;
|
|
5987
|
-
})
|
|
5988
|
-
CadenzaService.createUniqueMetaTask(
|
|
5989
|
-
"Gather routine registration",
|
|
5990
|
-
() => true
|
|
5991
|
-
).emits("meta.sync_controller.synced_routines")
|
|
5992
|
-
)
|
|
6154
|
+
})
|
|
5993
6155
|
)
|
|
5994
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");
|
|
5995
6164
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
5996
6165
|
"Split tasks in routines",
|
|
5997
|
-
|
|
6166
|
+
(ctx, emit) => {
|
|
5998
6167
|
const { routines } = ctx;
|
|
5999
|
-
if (!routines) return;
|
|
6168
|
+
if (!routines) return false;
|
|
6000
6169
|
const serviceName2 = resolveSyncServiceName();
|
|
6001
6170
|
if (!serviceName2) {
|
|
6002
|
-
return;
|
|
6171
|
+
return false;
|
|
6003
6172
|
}
|
|
6004
6173
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6005
6174
|
delayMs: 3e3
|
|
6006
6175
|
});
|
|
6176
|
+
let emittedCount = 0;
|
|
6007
6177
|
for (const routine of routines) {
|
|
6008
6178
|
if (!routine.registered) continue;
|
|
6009
6179
|
for (const task of routine.tasks) {
|
|
6010
6180
|
if (!task) {
|
|
6011
|
-
console.log("task is null", routine, task);
|
|
6012
6181
|
continue;
|
|
6013
6182
|
}
|
|
6014
6183
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -6018,7 +6187,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6018
6187
|
if (!nextTask?.registered) {
|
|
6019
6188
|
continue;
|
|
6020
6189
|
}
|
|
6021
|
-
|
|
6190
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
6191
|
+
__syncing: ctx.__syncing,
|
|
6022
6192
|
data: {
|
|
6023
6193
|
taskName: nextTask.name,
|
|
6024
6194
|
taskVersion: nextTask.version,
|
|
@@ -6028,12 +6198,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6028
6198
|
},
|
|
6029
6199
|
__routineName: routine.name,
|
|
6030
6200
|
__taskName: nextTask.name
|
|
6031
|
-
};
|
|
6201
|
+
});
|
|
6202
|
+
emittedCount += 1;
|
|
6032
6203
|
}
|
|
6033
6204
|
}
|
|
6034
6205
|
}
|
|
6206
|
+
return emittedCount > 0;
|
|
6035
6207
|
}
|
|
6036
|
-
)
|
|
6208
|
+
);
|
|
6209
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
6037
6210
|
resolveSyncInsertTask(
|
|
6038
6211
|
this.isCadenzaDBReady,
|
|
6039
6212
|
"task_to_routine_map",
|
|
@@ -6054,7 +6227,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6054
6227
|
{ concurrency: 30 }
|
|
6055
6228
|
)?.then(
|
|
6056
6229
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
6057
|
-
if (!ctx.__syncing) {
|
|
6230
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6058
6231
|
return;
|
|
6059
6232
|
}
|
|
6060
6233
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6068,18 +6241,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6068
6241
|
);
|
|
6069
6242
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
6070
6243
|
"Split signals for registration",
|
|
6071
|
-
|
|
6244
|
+
(ctx, emit) => {
|
|
6072
6245
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6073
6246
|
delayMs: 3e3
|
|
6074
6247
|
});
|
|
6075
6248
|
const { signals } = ctx;
|
|
6076
|
-
if (!signals) return;
|
|
6249
|
+
if (!signals) return false;
|
|
6077
6250
|
const filteredSignals = signals.filter(
|
|
6078
6251
|
(signal) => !signal.data.registered
|
|
6079
6252
|
).map((signal) => signal.signal);
|
|
6080
6253
|
for (const signal of filteredSignals) {
|
|
6081
6254
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
6082
|
-
|
|
6255
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
6256
|
+
__syncing: ctx.__syncing,
|
|
6083
6257
|
data: {
|
|
6084
6258
|
name: signal,
|
|
6085
6259
|
isGlobal,
|
|
@@ -6088,10 +6262,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6088
6262
|
isMeta
|
|
6089
6263
|
},
|
|
6090
6264
|
__signal: signal
|
|
6091
|
-
};
|
|
6265
|
+
});
|
|
6092
6266
|
}
|
|
6267
|
+
return filteredSignals.length > 0;
|
|
6093
6268
|
}
|
|
6094
|
-
)
|
|
6269
|
+
);
|
|
6270
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
6095
6271
|
resolveSyncInsertTask(
|
|
6096
6272
|
this.isCadenzaDBReady,
|
|
6097
6273
|
"signal_registry",
|
|
@@ -6106,37 +6282,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6106
6282
|
{ concurrency: 30 }
|
|
6107
6283
|
)?.then(
|
|
6108
6284
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
6109
|
-
if (!ctx.__syncing) {
|
|
6285
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6110
6286
|
return;
|
|
6111
6287
|
}
|
|
6112
6288
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6113
6289
|
delayMs: 3e3
|
|
6114
6290
|
});
|
|
6291
|
+
CadenzaService.debounce(
|
|
6292
|
+
"meta.sync_controller.signal_registration_settled",
|
|
6293
|
+
{ __syncing: true },
|
|
6294
|
+
300
|
|
6295
|
+
);
|
|
6115
6296
|
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
|
-
)
|
|
6297
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
6123
6298
|
)
|
|
6124
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");
|
|
6125
6307
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
6126
6308
|
"Split tasks for registration",
|
|
6127
|
-
|
|
6309
|
+
(ctx, emit) => {
|
|
6128
6310
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6129
6311
|
delayMs: 3e3
|
|
6130
6312
|
});
|
|
6131
6313
|
const tasks = ctx.tasks;
|
|
6132
6314
|
const serviceName2 = resolveSyncServiceName();
|
|
6133
6315
|
if (!serviceName2) {
|
|
6134
|
-
return;
|
|
6316
|
+
return false;
|
|
6135
6317
|
}
|
|
6318
|
+
let emittedCount = 0;
|
|
6136
6319
|
for (const task of tasks) {
|
|
6137
6320
|
if (task.registered) continue;
|
|
6138
6321
|
const { __functionString, __getTagCallback } = task.export();
|
|
6139
|
-
|
|
6322
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
6323
|
+
__syncing: ctx.__syncing,
|
|
6140
6324
|
data: {
|
|
6141
6325
|
name: task.name,
|
|
6142
6326
|
version: task.version,
|
|
@@ -6154,9 +6338,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6154
6338
|
isMeta: task.isMeta,
|
|
6155
6339
|
isSubMeta: task.isSubMeta,
|
|
6156
6340
|
isHidden: task.isHidden,
|
|
6157
|
-
// inputSchema: task.inputSchema,
|
|
6158
6341
|
validateInputContext: task.validateInputContext,
|
|
6159
|
-
// outputSchema: task.outputSchema,
|
|
6160
6342
|
validateOutputContext: task.validateOutputContext,
|
|
6161
6343
|
retryCount: task.retryCount,
|
|
6162
6344
|
retryDelay: task.retryDelay,
|
|
@@ -6171,10 +6353,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6171
6353
|
}
|
|
6172
6354
|
},
|
|
6173
6355
|
__taskName: task.name
|
|
6174
|
-
};
|
|
6356
|
+
});
|
|
6357
|
+
emittedCount += 1;
|
|
6175
6358
|
}
|
|
6359
|
+
return emittedCount > 0;
|
|
6176
6360
|
}
|
|
6177
|
-
)
|
|
6361
|
+
);
|
|
6362
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
6178
6363
|
resolveSyncInsertTask(
|
|
6179
6364
|
this.isCadenzaDBReady,
|
|
6180
6365
|
"task",
|
|
@@ -6189,7 +6374,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6189
6374
|
{ concurrency: 30 }
|
|
6190
6375
|
)?.then(
|
|
6191
6376
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
6192
|
-
if (!ctx.__syncing) {
|
|
6377
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6193
6378
|
return;
|
|
6194
6379
|
}
|
|
6195
6380
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6200,15 +6385,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6200
6385
|
...ctx,
|
|
6201
6386
|
task: CadenzaService.get(ctx.__taskName)
|
|
6202
6387
|
});
|
|
6388
|
+
CadenzaService.debounce(
|
|
6389
|
+
"meta.sync_controller.task_registration_settled",
|
|
6390
|
+
{ __syncing: true },
|
|
6391
|
+
300
|
|
6392
|
+
);
|
|
6203
6393
|
return true;
|
|
6204
|
-
})
|
|
6205
|
-
CadenzaService.createUniqueMetaTask(
|
|
6206
|
-
"Gather task registration",
|
|
6207
|
-
() => true
|
|
6208
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
6209
|
-
)
|
|
6394
|
+
})
|
|
6210
6395
|
)
|
|
6211
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");
|
|
6212
6404
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
6213
6405
|
"Split actors for registration",
|
|
6214
6406
|
function* (ctx) {
|
|
@@ -6253,22 +6445,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6253
6445
|
{ concurrency: 30 }
|
|
6254
6446
|
)?.then(
|
|
6255
6447
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
6256
|
-
if (!ctx.__syncing) {
|
|
6448
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6257
6449
|
return;
|
|
6258
6450
|
}
|
|
6259
6451
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6260
6452
|
delayMs: 3e3
|
|
6261
6453
|
});
|
|
6262
6454
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
6455
|
+
CadenzaService.debounce(
|
|
6456
|
+
"meta.sync_controller.actor_registration_settled",
|
|
6457
|
+
{ __syncing: true },
|
|
6458
|
+
300
|
|
6459
|
+
);
|
|
6263
6460
|
return true;
|
|
6264
|
-
})
|
|
6265
|
-
CadenzaService.createUniqueMetaTask(
|
|
6266
|
-
"Gather actor registration",
|
|
6267
|
-
() => true
|
|
6268
|
-
).emits("meta.sync_controller.synced_actors")
|
|
6269
|
-
)
|
|
6461
|
+
})
|
|
6270
6462
|
)
|
|
6271
6463
|
);
|
|
6464
|
+
CadenzaService.createUniqueMetaTask(
|
|
6465
|
+
"Gather actor registration",
|
|
6466
|
+
() => true
|
|
6467
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
6272
6468
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
6273
6469
|
"Split actor task maps",
|
|
6274
6470
|
function* (ctx) {
|
|
@@ -6323,7 +6519,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6323
6519
|
{ concurrency: 30 }
|
|
6324
6520
|
)?.then(
|
|
6325
6521
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
6326
|
-
if (!ctx.__syncing) {
|
|
6522
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6327
6523
|
return;
|
|
6328
6524
|
}
|
|
6329
6525
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6336,7 +6532,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6336
6532
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
6337
6533
|
"Record signal registration",
|
|
6338
6534
|
(ctx) => {
|
|
6339
|
-
if (!ctx.__syncing) {
|
|
6535
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6340
6536
|
return;
|
|
6341
6537
|
}
|
|
6342
6538
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6347,13 +6543,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6347
6543
|
);
|
|
6348
6544
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
6349
6545
|
"Split observed signals of task",
|
|
6350
|
-
|
|
6546
|
+
(ctx, emit) => {
|
|
6351
6547
|
const task = ctx.task;
|
|
6352
|
-
if (task.hidden || !task.register) return;
|
|
6548
|
+
if (task.hidden || !task.register) return false;
|
|
6353
6549
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6354
6550
|
if (!serviceName2) {
|
|
6355
|
-
return;
|
|
6551
|
+
return false;
|
|
6356
6552
|
}
|
|
6553
|
+
let emittedCount = 0;
|
|
6357
6554
|
for (const signal of task.observedSignals) {
|
|
6358
6555
|
const _signal = signal.split(":")[0];
|
|
6359
6556
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -6361,7 +6558,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6361
6558
|
continue;
|
|
6362
6559
|
}
|
|
6363
6560
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
6364
|
-
|
|
6561
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
6562
|
+
__syncing: ctx.__syncing,
|
|
6365
6563
|
data: {
|
|
6366
6564
|
signalName: _signal,
|
|
6367
6565
|
isGlobal,
|
|
@@ -6371,10 +6569,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6371
6569
|
},
|
|
6372
6570
|
__taskName: task.name,
|
|
6373
6571
|
__signal: signal
|
|
6374
|
-
};
|
|
6572
|
+
});
|
|
6573
|
+
emittedCount += 1;
|
|
6375
6574
|
}
|
|
6575
|
+
return emittedCount > 0;
|
|
6376
6576
|
}
|
|
6377
|
-
)
|
|
6577
|
+
);
|
|
6578
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
6378
6579
|
resolveSyncInsertTask(
|
|
6379
6580
|
this.isCadenzaDBReady,
|
|
6380
6581
|
"signal_to_task_map",
|
|
@@ -6396,29 +6597,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6396
6597
|
);
|
|
6397
6598
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
6398
6599
|
"Split intents for registration",
|
|
6399
|
-
function
|
|
6600
|
+
function(ctx, emit) {
|
|
6400
6601
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6401
6602
|
delayMs: 3e3
|
|
6402
6603
|
});
|
|
6403
6604
|
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
|
-
}
|
|
6605
|
+
let emittedCount = 0;
|
|
6422
6606
|
for (const intent of intents) {
|
|
6423
6607
|
const intentData = buildIntentRegistryData(intent);
|
|
6424
6608
|
if (!intentData) {
|
|
@@ -6427,35 +6611,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6427
6611
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
6428
6612
|
continue;
|
|
6429
6613
|
}
|
|
6430
|
-
|
|
6614
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
6615
|
+
__syncing: ctx.__syncing,
|
|
6431
6616
|
data: intentData,
|
|
6432
6617
|
__intentName: intentData.name
|
|
6433
|
-
};
|
|
6618
|
+
});
|
|
6619
|
+
emittedCount += 1;
|
|
6434
6620
|
}
|
|
6621
|
+
return emittedCount > 0;
|
|
6435
6622
|
}.bind(this)
|
|
6436
|
-
)
|
|
6623
|
+
);
|
|
6624
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
6437
6625
|
insertIntentRegistryTask?.then(
|
|
6438
6626
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
6439
|
-
if (!ctx.__syncing) {
|
|
6627
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6440
6628
|
return;
|
|
6441
6629
|
}
|
|
6442
6630
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6443
6631
|
delayMs: 3e3
|
|
6444
6632
|
});
|
|
6445
6633
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
6634
|
+
CadenzaService.debounce(
|
|
6635
|
+
"meta.sync_controller.intent_registration_settled",
|
|
6636
|
+
{ __syncing: true },
|
|
6637
|
+
300
|
|
6638
|
+
);
|
|
6446
6639
|
return true;
|
|
6447
|
-
})
|
|
6448
|
-
CadenzaService.createUniqueMetaTask(
|
|
6449
|
-
"Gather intent registration",
|
|
6450
|
-
() => true
|
|
6451
|
-
).emits("meta.sync_controller.synced_intents")
|
|
6452
|
-
)
|
|
6640
|
+
})
|
|
6453
6641
|
)
|
|
6454
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");
|
|
6455
6650
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
6456
6651
|
"Record intent registration",
|
|
6457
6652
|
(ctx) => {
|
|
6458
|
-
if (!ctx.__syncing) {
|
|
6653
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6459
6654
|
return;
|
|
6460
6655
|
}
|
|
6461
6656
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6468,37 +6663,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6468
6663
|
);
|
|
6469
6664
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
6470
6665
|
"Split intents of task",
|
|
6471
|
-
function
|
|
6666
|
+
function(ctx, emit) {
|
|
6472
6667
|
const task = ctx.task;
|
|
6473
|
-
if (task.hidden || !task.register) return;
|
|
6668
|
+
if (task.hidden || !task.register) return false;
|
|
6474
6669
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6475
6670
|
if (!serviceName2) {
|
|
6476
|
-
return;
|
|
6671
|
+
return false;
|
|
6477
6672
|
}
|
|
6478
6673
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
6479
6674
|
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
6675
|
for (const intent of task.handlesIntents) {
|
|
6503
6676
|
if (task.__registeredIntents.has(intent)) continue;
|
|
6504
6677
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -6520,7 +6693,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6520
6693
|
if (!intentDefinition) {
|
|
6521
6694
|
continue;
|
|
6522
6695
|
}
|
|
6523
|
-
|
|
6696
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
6697
|
+
__syncing: ctx.__syncing,
|
|
6524
6698
|
data: {
|
|
6525
6699
|
intentName: intent,
|
|
6526
6700
|
taskName: task.name,
|
|
@@ -6536,10 +6710,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6536
6710
|
taskVersion: task.version,
|
|
6537
6711
|
serviceName: serviceName2
|
|
6538
6712
|
}
|
|
6539
|
-
};
|
|
6713
|
+
});
|
|
6540
6714
|
}
|
|
6715
|
+
return true;
|
|
6541
6716
|
}.bind(this)
|
|
6542
|
-
)
|
|
6717
|
+
);
|
|
6718
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
6543
6719
|
CadenzaService.createMetaTask(
|
|
6544
6720
|
"Prepare intent definition for intent-to-task map",
|
|
6545
6721
|
(ctx) => {
|
|
@@ -6552,7 +6728,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6552
6728
|
};
|
|
6553
6729
|
}
|
|
6554
6730
|
).then(
|
|
6555
|
-
|
|
6731
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
6556
6732
|
CadenzaService.createMetaTask(
|
|
6557
6733
|
"Restore intent-to-task map payload",
|
|
6558
6734
|
(ctx) => {
|
|
@@ -6600,7 +6776,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6600
6776
|
return;
|
|
6601
6777
|
}
|
|
6602
6778
|
for (const t of task.nextTasks) {
|
|
6603
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
6779
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
6604
6780
|
continue;
|
|
6605
6781
|
}
|
|
6606
6782
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -6643,7 +6819,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6643
6819
|
{ concurrency: 30 }
|
|
6644
6820
|
)?.then(
|
|
6645
6821
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
6646
|
-
if (!ctx.__syncing) {
|
|
6822
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6647
6823
|
return;
|
|
6648
6824
|
}
|
|
6649
6825
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6704,7 +6880,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6704
6880
|
CadenzaService.createMetaTask(
|
|
6705
6881
|
"Record deputy relationship registration",
|
|
6706
6882
|
(ctx) => {
|
|
6707
|
-
if (!ctx.__syncing) {
|
|
6883
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6708
6884
|
return;
|
|
6709
6885
|
}
|
|
6710
6886
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6719,19 +6895,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6719
6895
|
"meta.sync_controller.sync_tick",
|
|
6720
6896
|
"meta.service_registry.initial_sync_complete"
|
|
6721
6897
|
).then(this.splitSignalsTask);
|
|
6722
|
-
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);
|
|
6723
6902
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
6724
6903
|
return {
|
|
6725
6904
|
...ctx,
|
|
6726
6905
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
6727
6906
|
};
|
|
6728
6907
|
}).doOn(
|
|
6729
|
-
"meta.sync_controller.
|
|
6730
|
-
"meta.
|
|
6908
|
+
"meta.sync_controller.sync_tick",
|
|
6909
|
+
"meta.service_registry.initial_sync_complete"
|
|
6731
6910
|
).then(this.splitIntentsTask);
|
|
6732
6911
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6733
|
-
"meta.sync_controller.
|
|
6734
|
-
"meta.
|
|
6912
|
+
"meta.sync_controller.sync_tick",
|
|
6913
|
+
"meta.service_registry.initial_sync_complete"
|
|
6735
6914
|
).then(this.splitRoutinesTask);
|
|
6736
6915
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
6737
6916
|
return {
|
|
@@ -6739,16 +6918,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6739
6918
|
actors: CadenzaService.getAllActors()
|
|
6740
6919
|
};
|
|
6741
6920
|
}).doOn(
|
|
6742
|
-
"meta.sync_controller.
|
|
6743
|
-
"meta.
|
|
6921
|
+
"meta.sync_controller.sync_tick",
|
|
6922
|
+
"meta.service_registry.initial_sync_complete"
|
|
6744
6923
|
).then(this.splitActorsForRegistration);
|
|
6745
|
-
CadenzaService.
|
|
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(
|
|
6746
6934
|
this.registerTaskMapTask,
|
|
6747
6935
|
this.registerDeputyRelationshipTask
|
|
6748
6936
|
);
|
|
6749
6937
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
6750
6938
|
"meta.sync_controller.synced_signals"
|
|
6751
|
-
).then(
|
|
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
|
+
);
|
|
6752
6950
|
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
6753
6951
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6754
6952
|
if (!task) {
|
|
@@ -6758,8 +6956,28 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6758
6956
|
...ctx,
|
|
6759
6957
|
task
|
|
6760
6958
|
};
|
|
6761
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6762
|
-
|
|
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
|
+
);
|
|
6763
6981
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
6764
6982
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6765
6983
|
if (!task) {
|
|
@@ -6769,7 +6987,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6769
6987
|
...ctx,
|
|
6770
6988
|
task
|
|
6771
6989
|
};
|
|
6772
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
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
|
+
);
|
|
6773
7001
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
6774
7002
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
6775
7003
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
@@ -6782,9 +7010,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6782
7010
|
};
|
|
6783
7011
|
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
6784
7012
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6785
|
-
"meta.sync_controller.
|
|
6786
|
-
"meta.sync_controller.
|
|
6787
|
-
).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
|
+
);
|
|
6788
7026
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
6789
7027
|
emit("global.meta.sync_controller.synced", {
|
|
6790
7028
|
data: {
|
|
@@ -7912,6 +8150,12 @@ var CadenzaService = class {
|
|
|
7912
8150
|
displayName: options.displayName ?? "",
|
|
7913
8151
|
isMeta: options.isMeta
|
|
7914
8152
|
},
|
|
8153
|
+
__registrationData: {
|
|
8154
|
+
name: serviceName,
|
|
8155
|
+
description,
|
|
8156
|
+
displayName: options.displayName ?? "",
|
|
8157
|
+
isMeta: options.isMeta
|
|
8158
|
+
},
|
|
7915
8159
|
__serviceName: serviceName,
|
|
7916
8160
|
__serviceInstanceId: serviceId,
|
|
7917
8161
|
__port: options.port,
|
|
@@ -7964,6 +8208,16 @@ var CadenzaService = class {
|
|
|
7964
8208
|
is_blocked: false,
|
|
7965
8209
|
health: {}
|
|
7966
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
|
+
},
|
|
7967
8221
|
__transportData: [],
|
|
7968
8222
|
__serviceName: serviceName,
|
|
7969
8223
|
__serviceInstanceId: serviceId,
|