@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.mjs
CHANGED
|
@@ -686,6 +686,72 @@ var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
686
686
|
"Collect distributed readiness",
|
|
687
687
|
"Get status"
|
|
688
688
|
]);
|
|
689
|
+
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
690
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
691
|
+
const getJoinedValue = (key) => {
|
|
692
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
693
|
+
const joinedContext = joinedContexts[index];
|
|
694
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
695
|
+
return joinedContext[key];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return void 0;
|
|
699
|
+
};
|
|
700
|
+
const registrationData = Object.prototype.hasOwnProperty.call(ctx, "__registrationData") && ctx.__registrationData !== void 0 ? ctx.__registrationData : getJoinedValue("__registrationData");
|
|
701
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
702
|
+
const nextQueryData = {
|
|
703
|
+
...existingQueryData,
|
|
704
|
+
...queryData
|
|
705
|
+
};
|
|
706
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
707
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
708
|
+
if (!("data" in nextQueryData) && (resolvedData !== void 0 || registrationData !== void 0)) {
|
|
709
|
+
nextQueryData.data = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
710
|
+
}
|
|
711
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
712
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
713
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
714
|
+
) : resolvedBatch;
|
|
715
|
+
}
|
|
716
|
+
return nextQueryData;
|
|
717
|
+
}
|
|
718
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
719
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
720
|
+
tableName,
|
|
721
|
+
queryData,
|
|
722
|
+
options
|
|
723
|
+
);
|
|
724
|
+
return CadenzaService.createUniqueMetaTask(
|
|
725
|
+
`Resolve service registry insert for ${tableName}`,
|
|
726
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
727
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
728
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
729
|
+
CadenzaService.log(
|
|
730
|
+
"Service registry insert resolver missing service payload.",
|
|
731
|
+
{
|
|
732
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
733
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
734
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
735
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
736
|
+
},
|
|
737
|
+
"warning"
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
741
|
+
return targetTask.taskFunction(
|
|
742
|
+
{
|
|
743
|
+
...ctx,
|
|
744
|
+
queryData: nextQueryData
|
|
745
|
+
},
|
|
746
|
+
emit,
|
|
747
|
+
inquire,
|
|
748
|
+
progressCallback
|
|
749
|
+
);
|
|
750
|
+
},
|
|
751
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
752
|
+
options
|
|
753
|
+
);
|
|
754
|
+
}
|
|
689
755
|
function readPositiveIntegerEnv(name, fallback) {
|
|
690
756
|
if (typeof process === "undefined") {
|
|
691
757
|
return fallback;
|
|
@@ -1896,7 +1962,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1896
1962
|
},
|
|
1897
1963
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1898
1964
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1899
|
-
this.insertServiceTask =
|
|
1965
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1900
1966
|
"service",
|
|
1901
1967
|
{
|
|
1902
1968
|
onConflict: {
|
|
@@ -1947,7 +2013,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2013
|
retryDelayFactor: 1.3
|
|
1948
2014
|
}
|
|
1949
2015
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
1950
|
-
this.insertServiceInstanceTask =
|
|
2016
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
1951
2017
|
"service_instance",
|
|
1952
2018
|
{},
|
|
1953
2019
|
{
|
|
@@ -2005,7 +2071,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2005
2071
|
retryCount: 5,
|
|
2006
2072
|
retryDelay: 1e3
|
|
2007
2073
|
}
|
|
2008
|
-
).
|
|
2074
|
+
).then(
|
|
2009
2075
|
CadenzaService.createMetaTask(
|
|
2010
2076
|
"Setup service",
|
|
2011
2077
|
(ctx) => {
|
|
@@ -2032,8 +2098,17 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2032
2098
|
this.useSocket = __useSocket;
|
|
2033
2099
|
this.retryCount = __retryCount;
|
|
2034
2100
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2035
|
-
|
|
2036
|
-
|
|
2101
|
+
return {
|
|
2102
|
+
...ctx,
|
|
2103
|
+
serviceInstance: normalizedLocalInstance,
|
|
2104
|
+
data: {
|
|
2105
|
+
...ctx.data ?? {},
|
|
2106
|
+
uuid: normalizedLocalInstance.uuid,
|
|
2107
|
+
service_name: normalizedLocalInstance.serviceName
|
|
2108
|
+
},
|
|
2109
|
+
__serviceName: normalizedLocalInstance.serviceName,
|
|
2110
|
+
__serviceInstanceId: normalizedLocalInstance.uuid
|
|
2111
|
+
};
|
|
2037
2112
|
},
|
|
2038
2113
|
"Sets service instance id after insertion"
|
|
2039
2114
|
).emits("meta.service_registry.instance_inserted").then(
|
|
@@ -2047,6 +2122,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2047
2122
|
data: {
|
|
2048
2123
|
...transport,
|
|
2049
2124
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2125
|
+
},
|
|
2126
|
+
__registrationData: {
|
|
2127
|
+
...transport,
|
|
2128
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2050
2129
|
}
|
|
2051
2130
|
};
|
|
2052
2131
|
emit(
|
|
@@ -2060,7 +2139,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2060
2139
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2061
2140
|
)
|
|
2062
2141
|
);
|
|
2063
|
-
|
|
2142
|
+
CadenzaService.createMetaTask(
|
|
2143
|
+
"Prepare service instance registration",
|
|
2144
|
+
(ctx) => {
|
|
2145
|
+
const serviceName = String(
|
|
2146
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2147
|
+
).trim();
|
|
2148
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2149
|
+
CadenzaService.schedule(
|
|
2150
|
+
"meta.service_registry.instance_registration_requested",
|
|
2151
|
+
{ ...ctx },
|
|
2152
|
+
250
|
|
2153
|
+
);
|
|
2154
|
+
return false;
|
|
2155
|
+
}
|
|
2156
|
+
return ctx;
|
|
2157
|
+
},
|
|
2158
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2159
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2160
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2064
2161
|
"service_instance_transport",
|
|
2065
2162
|
{
|
|
2066
2163
|
onConflict: {
|
|
@@ -2125,7 +2222,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2125
2222
|
retryCount: 5,
|
|
2126
2223
|
retryDelay: 1e3
|
|
2127
2224
|
}
|
|
2128
|
-
).
|
|
2225
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2226
|
+
CadenzaService.createMetaTask(
|
|
2227
|
+
"Prepare service transport registration",
|
|
2228
|
+
(ctx) => {
|
|
2229
|
+
const serviceName = String(
|
|
2230
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2231
|
+
).trim();
|
|
2232
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2233
|
+
CadenzaService.schedule(
|
|
2234
|
+
"meta.service_registry.transport_registration_requested",
|
|
2235
|
+
{ ...ctx },
|
|
2236
|
+
250
|
|
2237
|
+
);
|
|
2238
|
+
return false;
|
|
2239
|
+
}
|
|
2240
|
+
return ctx;
|
|
2241
|
+
},
|
|
2242
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2243
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2129
2244
|
CadenzaService.createMetaTask(
|
|
2130
2245
|
"Handle service creation",
|
|
2131
2246
|
(ctx) => {
|
|
@@ -3339,6 +3454,16 @@ var RestController = class _RestController {
|
|
|
3339
3454
|
is_blocked: false,
|
|
3340
3455
|
health: {}
|
|
3341
3456
|
},
|
|
3457
|
+
__registrationData: {
|
|
3458
|
+
uuid: ctx.__serviceInstanceId,
|
|
3459
|
+
process_pid: 1,
|
|
3460
|
+
service_name: ctx.__serviceName,
|
|
3461
|
+
is_frontend: true,
|
|
3462
|
+
is_active: true,
|
|
3463
|
+
is_non_responsive: false,
|
|
3464
|
+
is_blocked: false,
|
|
3465
|
+
health: {}
|
|
3466
|
+
},
|
|
3342
3467
|
__transportData: [],
|
|
3343
3468
|
...ctx
|
|
3344
3469
|
});
|
|
@@ -5663,12 +5788,6 @@ import { v4 as uuid4 } from "uuid";
|
|
|
5663
5788
|
|
|
5664
5789
|
// src/graph/controllers/GraphSyncController.ts
|
|
5665
5790
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5666
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
5667
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
5668
|
-
);
|
|
5669
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
5670
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
5671
|
-
);
|
|
5672
5791
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5673
5792
|
if (typeof taskFunction !== "function") {
|
|
5674
5793
|
return void 0;
|
|
@@ -5745,38 +5864,71 @@ function buildIntentRegistryData(intent) {
|
|
|
5745
5864
|
isMeta: isMetaIntentName(name)
|
|
5746
5865
|
};
|
|
5747
5866
|
}
|
|
5867
|
+
function getJoinedContextValue(ctx, key) {
|
|
5868
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
5869
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
5870
|
+
const joinedContext = joinedContexts[index];
|
|
5871
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
5872
|
+
return joinedContext[key];
|
|
5873
|
+
}
|
|
5874
|
+
}
|
|
5875
|
+
return void 0;
|
|
5876
|
+
}
|
|
5877
|
+
function didSyncInsertSucceed(ctx) {
|
|
5878
|
+
return !ctx.errored && ctx.__success !== false;
|
|
5879
|
+
}
|
|
5880
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
5881
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
5882
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
5883
|
+
const nextQueryData = {
|
|
5884
|
+
...existingQueryData,
|
|
5885
|
+
...queryData
|
|
5886
|
+
};
|
|
5887
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
5888
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
5889
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
5890
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
5891
|
+
}
|
|
5892
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
5893
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
5894
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
5895
|
+
) : resolvedBatch;
|
|
5896
|
+
}
|
|
5897
|
+
return nextQueryData;
|
|
5898
|
+
}
|
|
5748
5899
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
5749
5900
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
}
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5901
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5902
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
5903
|
+
return void 0;
|
|
5904
|
+
}
|
|
5905
|
+
return CadenzaService.createUniqueMetaTask(
|
|
5906
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
5907
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
5908
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
5909
|
+
if (!targetTask) {
|
|
5910
|
+
return false;
|
|
5911
|
+
}
|
|
5912
|
+
return targetTask.taskFunction(
|
|
5913
|
+
{
|
|
5762
5914
|
...ctx,
|
|
5763
|
-
queryData:
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5915
|
+
queryData: buildSyncInsertQueryData(
|
|
5916
|
+
ctx,
|
|
5917
|
+
queryData
|
|
5918
|
+
)
|
|
5919
|
+
},
|
|
5920
|
+
emit,
|
|
5921
|
+
inquire,
|
|
5922
|
+
progressCallback
|
|
5923
|
+
);
|
|
5924
|
+
},
|
|
5925
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
5926
|
+
{
|
|
5927
|
+
...options,
|
|
5928
|
+
register: false,
|
|
5929
|
+
isHidden: true
|
|
5776
5930
|
}
|
|
5777
|
-
|
|
5778
|
-
}
|
|
5779
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5931
|
+
);
|
|
5780
5932
|
}
|
|
5781
5933
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
5782
5934
|
"intent_registry",
|
|
@@ -5795,11 +5947,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5795
5947
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
5796
5948
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5797
5949
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
5798
|
-
this.
|
|
5950
|
+
this.tasksSynced = false;
|
|
5951
|
+
this.signalsSynced = false;
|
|
5952
|
+
this.intentsSynced = false;
|
|
5953
|
+
this.routinesSynced = false;
|
|
5799
5954
|
this.isCadenzaDBReady = false;
|
|
5800
5955
|
this.initialized = false;
|
|
5801
5956
|
this.initRetryScheduled = false;
|
|
5802
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
5803
5957
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
5804
5958
|
}
|
|
5805
5959
|
static get instance() {
|
|
@@ -5874,21 +6028,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5874
6028
|
},
|
|
5875
6029
|
{ concurrency: 30 }
|
|
5876
6030
|
);
|
|
6031
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
6032
|
+
this.isCadenzaDBReady,
|
|
6033
|
+
"intent_registry",
|
|
6034
|
+
{
|
|
6035
|
+
onConflict: {
|
|
6036
|
+
target: ["name"],
|
|
6037
|
+
action: {
|
|
6038
|
+
do: "nothing"
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
},
|
|
6042
|
+
{ concurrency: 30 }
|
|
6043
|
+
);
|
|
5877
6044
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
5878
6045
|
"Split routines for registration",
|
|
5879
|
-
|
|
6046
|
+
(ctx, emit) => {
|
|
5880
6047
|
const { routines } = ctx;
|
|
5881
|
-
if (!routines) return;
|
|
6048
|
+
if (!routines) return false;
|
|
5882
6049
|
const serviceName2 = resolveSyncServiceName();
|
|
5883
6050
|
if (!serviceName2) {
|
|
5884
|
-
return;
|
|
6051
|
+
return false;
|
|
5885
6052
|
}
|
|
5886
6053
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5887
6054
|
delayMs: 2e3
|
|
5888
6055
|
});
|
|
6056
|
+
let emittedCount = 0;
|
|
5889
6057
|
for (const routine of routines) {
|
|
5890
6058
|
if (routine.registered) continue;
|
|
5891
|
-
|
|
6059
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
6060
|
+
__syncing: ctx.__syncing,
|
|
5892
6061
|
data: {
|
|
5893
6062
|
name: routine.name,
|
|
5894
6063
|
version: routine.version,
|
|
@@ -5897,10 +6066,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5897
6066
|
isMeta: routine.isMeta
|
|
5898
6067
|
},
|
|
5899
6068
|
__routineName: routine.name
|
|
5900
|
-
};
|
|
6069
|
+
});
|
|
6070
|
+
emittedCount += 1;
|
|
5901
6071
|
}
|
|
6072
|
+
return emittedCount > 0;
|
|
5902
6073
|
}
|
|
5903
|
-
)
|
|
6074
|
+
);
|
|
6075
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
5904
6076
|
resolveSyncInsertTask(
|
|
5905
6077
|
this.isCadenzaDBReady,
|
|
5906
6078
|
"routine",
|
|
@@ -5915,39 +6087,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5915
6087
|
{ concurrency: 30 }
|
|
5916
6088
|
)?.then(
|
|
5917
6089
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
5918
|
-
if (!ctx.__syncing) {
|
|
6090
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5919
6091
|
return;
|
|
5920
6092
|
}
|
|
5921
6093
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5922
6094
|
delayMs: 3e3
|
|
5923
6095
|
});
|
|
5924
6096
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6097
|
+
CadenzaService.debounce(
|
|
6098
|
+
"meta.sync_controller.routine_registration_settled",
|
|
6099
|
+
{ __syncing: true },
|
|
6100
|
+
300
|
|
6101
|
+
);
|
|
5925
6102
|
return true;
|
|
5926
|
-
})
|
|
5927
|
-
CadenzaService.createUniqueMetaTask(
|
|
5928
|
-
"Gather routine registration",
|
|
5929
|
-
() => true
|
|
5930
|
-
).emits("meta.sync_controller.synced_routines")
|
|
5931
|
-
)
|
|
6103
|
+
})
|
|
5932
6104
|
)
|
|
5933
6105
|
);
|
|
6106
|
+
CadenzaService.createUniqueMetaTask(
|
|
6107
|
+
"Gather routine registration",
|
|
6108
|
+
() => {
|
|
6109
|
+
this.routinesSynced = true;
|
|
6110
|
+
return true;
|
|
6111
|
+
}
|
|
6112
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
5934
6113
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
5935
6114
|
"Split tasks in routines",
|
|
5936
|
-
|
|
6115
|
+
(ctx, emit) => {
|
|
5937
6116
|
const { routines } = ctx;
|
|
5938
|
-
if (!routines) return;
|
|
6117
|
+
if (!routines) return false;
|
|
5939
6118
|
const serviceName2 = resolveSyncServiceName();
|
|
5940
6119
|
if (!serviceName2) {
|
|
5941
|
-
return;
|
|
6120
|
+
return false;
|
|
5942
6121
|
}
|
|
5943
6122
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5944
6123
|
delayMs: 3e3
|
|
5945
6124
|
});
|
|
6125
|
+
let emittedCount = 0;
|
|
5946
6126
|
for (const routine of routines) {
|
|
5947
6127
|
if (!routine.registered) continue;
|
|
5948
6128
|
for (const task of routine.tasks) {
|
|
5949
6129
|
if (!task) {
|
|
5950
|
-
console.log("task is null", routine, task);
|
|
5951
6130
|
continue;
|
|
5952
6131
|
}
|
|
5953
6132
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -5957,7 +6136,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5957
6136
|
if (!nextTask?.registered) {
|
|
5958
6137
|
continue;
|
|
5959
6138
|
}
|
|
5960
|
-
|
|
6139
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
6140
|
+
__syncing: ctx.__syncing,
|
|
5961
6141
|
data: {
|
|
5962
6142
|
taskName: nextTask.name,
|
|
5963
6143
|
taskVersion: nextTask.version,
|
|
@@ -5967,12 +6147,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5967
6147
|
},
|
|
5968
6148
|
__routineName: routine.name,
|
|
5969
6149
|
__taskName: nextTask.name
|
|
5970
|
-
};
|
|
6150
|
+
});
|
|
6151
|
+
emittedCount += 1;
|
|
5971
6152
|
}
|
|
5972
6153
|
}
|
|
5973
6154
|
}
|
|
6155
|
+
return emittedCount > 0;
|
|
5974
6156
|
}
|
|
5975
|
-
)
|
|
6157
|
+
);
|
|
6158
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
5976
6159
|
resolveSyncInsertTask(
|
|
5977
6160
|
this.isCadenzaDBReady,
|
|
5978
6161
|
"task_to_routine_map",
|
|
@@ -5993,7 +6176,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5993
6176
|
{ concurrency: 30 }
|
|
5994
6177
|
)?.then(
|
|
5995
6178
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
5996
|
-
if (!ctx.__syncing) {
|
|
6179
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5997
6180
|
return;
|
|
5998
6181
|
}
|
|
5999
6182
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6007,18 +6190,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6007
6190
|
);
|
|
6008
6191
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
6009
6192
|
"Split signals for registration",
|
|
6010
|
-
|
|
6193
|
+
(ctx, emit) => {
|
|
6011
6194
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6012
6195
|
delayMs: 3e3
|
|
6013
6196
|
});
|
|
6014
6197
|
const { signals } = ctx;
|
|
6015
|
-
if (!signals) return;
|
|
6198
|
+
if (!signals) return false;
|
|
6016
6199
|
const filteredSignals = signals.filter(
|
|
6017
6200
|
(signal) => !signal.data.registered
|
|
6018
6201
|
).map((signal) => signal.signal);
|
|
6019
6202
|
for (const signal of filteredSignals) {
|
|
6020
6203
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
6021
|
-
|
|
6204
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
6205
|
+
__syncing: ctx.__syncing,
|
|
6022
6206
|
data: {
|
|
6023
6207
|
name: signal,
|
|
6024
6208
|
isGlobal,
|
|
@@ -6027,10 +6211,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6027
6211
|
isMeta
|
|
6028
6212
|
},
|
|
6029
6213
|
__signal: signal
|
|
6030
|
-
};
|
|
6214
|
+
});
|
|
6031
6215
|
}
|
|
6216
|
+
return filteredSignals.length > 0;
|
|
6032
6217
|
}
|
|
6033
|
-
)
|
|
6218
|
+
);
|
|
6219
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
6034
6220
|
resolveSyncInsertTask(
|
|
6035
6221
|
this.isCadenzaDBReady,
|
|
6036
6222
|
"signal_registry",
|
|
@@ -6045,37 +6231,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6045
6231
|
{ concurrency: 30 }
|
|
6046
6232
|
)?.then(
|
|
6047
6233
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
6048
|
-
if (!ctx.__syncing) {
|
|
6234
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6049
6235
|
return;
|
|
6050
6236
|
}
|
|
6051
6237
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6052
6238
|
delayMs: 3e3
|
|
6053
6239
|
});
|
|
6240
|
+
CadenzaService.debounce(
|
|
6241
|
+
"meta.sync_controller.signal_registration_settled",
|
|
6242
|
+
{ __syncing: true },
|
|
6243
|
+
300
|
|
6244
|
+
);
|
|
6054
6245
|
return { signalName: ctx.__signal };
|
|
6055
|
-
}).then(
|
|
6056
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
6057
|
-
CadenzaService.createUniqueMetaTask(
|
|
6058
|
-
"Gather signal registration",
|
|
6059
|
-
() => true
|
|
6060
|
-
).emits("meta.sync_controller.synced_signals")
|
|
6061
|
-
)
|
|
6246
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
6062
6247
|
)
|
|
6063
6248
|
);
|
|
6249
|
+
CadenzaService.createUniqueMetaTask(
|
|
6250
|
+
"Gather signal registration",
|
|
6251
|
+
() => {
|
|
6252
|
+
this.signalsSynced = true;
|
|
6253
|
+
return true;
|
|
6254
|
+
}
|
|
6255
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
6064
6256
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
6065
6257
|
"Split tasks for registration",
|
|
6066
|
-
|
|
6258
|
+
(ctx, emit) => {
|
|
6067
6259
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6068
6260
|
delayMs: 3e3
|
|
6069
6261
|
});
|
|
6070
6262
|
const tasks = ctx.tasks;
|
|
6071
6263
|
const serviceName2 = resolveSyncServiceName();
|
|
6072
6264
|
if (!serviceName2) {
|
|
6073
|
-
return;
|
|
6265
|
+
return false;
|
|
6074
6266
|
}
|
|
6267
|
+
let emittedCount = 0;
|
|
6075
6268
|
for (const task of tasks) {
|
|
6076
6269
|
if (task.registered) continue;
|
|
6077
6270
|
const { __functionString, __getTagCallback } = task.export();
|
|
6078
|
-
|
|
6271
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
6272
|
+
__syncing: ctx.__syncing,
|
|
6079
6273
|
data: {
|
|
6080
6274
|
name: task.name,
|
|
6081
6275
|
version: task.version,
|
|
@@ -6093,9 +6287,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6093
6287
|
isMeta: task.isMeta,
|
|
6094
6288
|
isSubMeta: task.isSubMeta,
|
|
6095
6289
|
isHidden: task.isHidden,
|
|
6096
|
-
// inputSchema: task.inputSchema,
|
|
6097
6290
|
validateInputContext: task.validateInputContext,
|
|
6098
|
-
// outputSchema: task.outputSchema,
|
|
6099
6291
|
validateOutputContext: task.validateOutputContext,
|
|
6100
6292
|
retryCount: task.retryCount,
|
|
6101
6293
|
retryDelay: task.retryDelay,
|
|
@@ -6110,10 +6302,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6110
6302
|
}
|
|
6111
6303
|
},
|
|
6112
6304
|
__taskName: task.name
|
|
6113
|
-
};
|
|
6305
|
+
});
|
|
6306
|
+
emittedCount += 1;
|
|
6114
6307
|
}
|
|
6308
|
+
return emittedCount > 0;
|
|
6115
6309
|
}
|
|
6116
|
-
)
|
|
6310
|
+
);
|
|
6311
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
6117
6312
|
resolveSyncInsertTask(
|
|
6118
6313
|
this.isCadenzaDBReady,
|
|
6119
6314
|
"task",
|
|
@@ -6128,7 +6323,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6128
6323
|
{ concurrency: 30 }
|
|
6129
6324
|
)?.then(
|
|
6130
6325
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
6131
|
-
if (!ctx.__syncing) {
|
|
6326
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6132
6327
|
return;
|
|
6133
6328
|
}
|
|
6134
6329
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6139,15 +6334,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6139
6334
|
...ctx,
|
|
6140
6335
|
task: CadenzaService.get(ctx.__taskName)
|
|
6141
6336
|
});
|
|
6337
|
+
CadenzaService.debounce(
|
|
6338
|
+
"meta.sync_controller.task_registration_settled",
|
|
6339
|
+
{ __syncing: true },
|
|
6340
|
+
300
|
|
6341
|
+
);
|
|
6142
6342
|
return true;
|
|
6143
|
-
})
|
|
6144
|
-
CadenzaService.createUniqueMetaTask(
|
|
6145
|
-
"Gather task registration",
|
|
6146
|
-
() => true
|
|
6147
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
6148
|
-
)
|
|
6343
|
+
})
|
|
6149
6344
|
)
|
|
6150
6345
|
);
|
|
6346
|
+
CadenzaService.createUniqueMetaTask(
|
|
6347
|
+
"Gather task registration",
|
|
6348
|
+
() => {
|
|
6349
|
+
this.tasksSynced = true;
|
|
6350
|
+
return true;
|
|
6351
|
+
}
|
|
6352
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
6151
6353
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
6152
6354
|
"Split actors for registration",
|
|
6153
6355
|
function* (ctx) {
|
|
@@ -6192,22 +6394,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6192
6394
|
{ concurrency: 30 }
|
|
6193
6395
|
)?.then(
|
|
6194
6396
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
6195
|
-
if (!ctx.__syncing) {
|
|
6397
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6196
6398
|
return;
|
|
6197
6399
|
}
|
|
6198
6400
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6199
6401
|
delayMs: 3e3
|
|
6200
6402
|
});
|
|
6201
6403
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
6404
|
+
CadenzaService.debounce(
|
|
6405
|
+
"meta.sync_controller.actor_registration_settled",
|
|
6406
|
+
{ __syncing: true },
|
|
6407
|
+
300
|
|
6408
|
+
);
|
|
6202
6409
|
return true;
|
|
6203
|
-
})
|
|
6204
|
-
CadenzaService.createUniqueMetaTask(
|
|
6205
|
-
"Gather actor registration",
|
|
6206
|
-
() => true
|
|
6207
|
-
).emits("meta.sync_controller.synced_actors")
|
|
6208
|
-
)
|
|
6410
|
+
})
|
|
6209
6411
|
)
|
|
6210
6412
|
);
|
|
6413
|
+
CadenzaService.createUniqueMetaTask(
|
|
6414
|
+
"Gather actor registration",
|
|
6415
|
+
() => true
|
|
6416
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
6211
6417
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
6212
6418
|
"Split actor task maps",
|
|
6213
6419
|
function* (ctx) {
|
|
@@ -6262,7 +6468,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6262
6468
|
{ concurrency: 30 }
|
|
6263
6469
|
)?.then(
|
|
6264
6470
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
6265
|
-
if (!ctx.__syncing) {
|
|
6471
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6266
6472
|
return;
|
|
6267
6473
|
}
|
|
6268
6474
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6275,7 +6481,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6275
6481
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
6276
6482
|
"Record signal registration",
|
|
6277
6483
|
(ctx) => {
|
|
6278
|
-
if (!ctx.__syncing) {
|
|
6484
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6279
6485
|
return;
|
|
6280
6486
|
}
|
|
6281
6487
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6286,13 +6492,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6286
6492
|
);
|
|
6287
6493
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
6288
6494
|
"Split observed signals of task",
|
|
6289
|
-
|
|
6495
|
+
(ctx, emit) => {
|
|
6290
6496
|
const task = ctx.task;
|
|
6291
|
-
if (task.hidden || !task.register) return;
|
|
6497
|
+
if (task.hidden || !task.register) return false;
|
|
6292
6498
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6293
6499
|
if (!serviceName2) {
|
|
6294
|
-
return;
|
|
6500
|
+
return false;
|
|
6295
6501
|
}
|
|
6502
|
+
let emittedCount = 0;
|
|
6296
6503
|
for (const signal of task.observedSignals) {
|
|
6297
6504
|
const _signal = signal.split(":")[0];
|
|
6298
6505
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -6300,7 +6507,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6300
6507
|
continue;
|
|
6301
6508
|
}
|
|
6302
6509
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
6303
|
-
|
|
6510
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
6511
|
+
__syncing: ctx.__syncing,
|
|
6304
6512
|
data: {
|
|
6305
6513
|
signalName: _signal,
|
|
6306
6514
|
isGlobal,
|
|
@@ -6310,10 +6518,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6310
6518
|
},
|
|
6311
6519
|
__taskName: task.name,
|
|
6312
6520
|
__signal: signal
|
|
6313
|
-
};
|
|
6521
|
+
});
|
|
6522
|
+
emittedCount += 1;
|
|
6314
6523
|
}
|
|
6524
|
+
return emittedCount > 0;
|
|
6315
6525
|
}
|
|
6316
|
-
)
|
|
6526
|
+
);
|
|
6527
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
6317
6528
|
resolveSyncInsertTask(
|
|
6318
6529
|
this.isCadenzaDBReady,
|
|
6319
6530
|
"signal_to_task_map",
|
|
@@ -6335,29 +6546,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6335
6546
|
);
|
|
6336
6547
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
6337
6548
|
"Split intents for registration",
|
|
6338
|
-
function
|
|
6549
|
+
function(ctx, emit) {
|
|
6339
6550
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6340
6551
|
delayMs: 3e3
|
|
6341
6552
|
});
|
|
6342
6553
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
6343
|
-
|
|
6344
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
6345
|
-
const authorityIntentNames = intentNames.filter(
|
|
6346
|
-
(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")
|
|
6347
|
-
);
|
|
6348
|
-
CadenzaService.log(
|
|
6349
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
6350
|
-
{
|
|
6351
|
-
totalIntents: intentNames.length,
|
|
6352
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
6353
|
-
"meta-service-registry-full-sync"
|
|
6354
|
-
),
|
|
6355
|
-
authorityIntentNames
|
|
6356
|
-
},
|
|
6357
|
-
"info"
|
|
6358
|
-
);
|
|
6359
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
6360
|
-
}
|
|
6554
|
+
let emittedCount = 0;
|
|
6361
6555
|
for (const intent of intents) {
|
|
6362
6556
|
const intentData = buildIntentRegistryData(intent);
|
|
6363
6557
|
if (!intentData) {
|
|
@@ -6366,35 +6560,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6366
6560
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
6367
6561
|
continue;
|
|
6368
6562
|
}
|
|
6369
|
-
|
|
6563
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
6564
|
+
__syncing: ctx.__syncing,
|
|
6370
6565
|
data: intentData,
|
|
6371
6566
|
__intentName: intentData.name
|
|
6372
|
-
};
|
|
6567
|
+
});
|
|
6568
|
+
emittedCount += 1;
|
|
6373
6569
|
}
|
|
6570
|
+
return emittedCount > 0;
|
|
6374
6571
|
}.bind(this)
|
|
6375
|
-
)
|
|
6572
|
+
);
|
|
6573
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
6376
6574
|
insertIntentRegistryTask?.then(
|
|
6377
6575
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
6378
|
-
if (!ctx.__syncing) {
|
|
6576
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6379
6577
|
return;
|
|
6380
6578
|
}
|
|
6381
6579
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6382
6580
|
delayMs: 3e3
|
|
6383
6581
|
});
|
|
6384
6582
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
6583
|
+
CadenzaService.debounce(
|
|
6584
|
+
"meta.sync_controller.intent_registration_settled",
|
|
6585
|
+
{ __syncing: true },
|
|
6586
|
+
300
|
|
6587
|
+
);
|
|
6385
6588
|
return true;
|
|
6386
|
-
})
|
|
6387
|
-
CadenzaService.createUniqueMetaTask(
|
|
6388
|
-
"Gather intent registration",
|
|
6389
|
-
() => true
|
|
6390
|
-
).emits("meta.sync_controller.synced_intents")
|
|
6391
|
-
)
|
|
6589
|
+
})
|
|
6392
6590
|
)
|
|
6393
6591
|
);
|
|
6592
|
+
CadenzaService.createUniqueMetaTask(
|
|
6593
|
+
"Gather intent registration",
|
|
6594
|
+
() => {
|
|
6595
|
+
this.intentsSynced = true;
|
|
6596
|
+
return true;
|
|
6597
|
+
}
|
|
6598
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
6394
6599
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
6395
6600
|
"Record intent registration",
|
|
6396
6601
|
(ctx) => {
|
|
6397
|
-
if (!ctx.__syncing) {
|
|
6602
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6398
6603
|
return;
|
|
6399
6604
|
}
|
|
6400
6605
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6407,37 +6612,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6407
6612
|
);
|
|
6408
6613
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
6409
6614
|
"Split intents of task",
|
|
6410
|
-
function
|
|
6615
|
+
function(ctx, emit) {
|
|
6411
6616
|
const task = ctx.task;
|
|
6412
|
-
if (task.hidden || !task.register) return;
|
|
6617
|
+
if (task.hidden || !task.register) return false;
|
|
6413
6618
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6414
6619
|
if (!serviceName2) {
|
|
6415
|
-
return;
|
|
6620
|
+
return false;
|
|
6416
6621
|
}
|
|
6417
6622
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
6418
6623
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
6419
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
6420
|
-
"Query service_instance",
|
|
6421
|
-
"Query service_instance_transport",
|
|
6422
|
-
"Query intent_to_task_map",
|
|
6423
|
-
"Query signal_to_task_map"
|
|
6424
|
-
].includes(task.name)) {
|
|
6425
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
6426
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
6427
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
6428
|
-
CadenzaService.log(
|
|
6429
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
6430
|
-
{
|
|
6431
|
-
taskName: task.name,
|
|
6432
|
-
taskVersion: task.version,
|
|
6433
|
-
isMeta: task.isMeta,
|
|
6434
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
6435
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
6436
|
-
},
|
|
6437
|
-
"info"
|
|
6438
|
-
);
|
|
6439
|
-
}
|
|
6440
|
-
}
|
|
6441
6624
|
for (const intent of task.handlesIntents) {
|
|
6442
6625
|
if (task.__registeredIntents.has(intent)) continue;
|
|
6443
6626
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -6459,7 +6642,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6459
6642
|
if (!intentDefinition) {
|
|
6460
6643
|
continue;
|
|
6461
6644
|
}
|
|
6462
|
-
|
|
6645
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
6646
|
+
__syncing: ctx.__syncing,
|
|
6463
6647
|
data: {
|
|
6464
6648
|
intentName: intent,
|
|
6465
6649
|
taskName: task.name,
|
|
@@ -6475,10 +6659,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6475
6659
|
taskVersion: task.version,
|
|
6476
6660
|
serviceName: serviceName2
|
|
6477
6661
|
}
|
|
6478
|
-
};
|
|
6662
|
+
});
|
|
6479
6663
|
}
|
|
6664
|
+
return true;
|
|
6480
6665
|
}.bind(this)
|
|
6481
|
-
)
|
|
6666
|
+
);
|
|
6667
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
6482
6668
|
CadenzaService.createMetaTask(
|
|
6483
6669
|
"Prepare intent definition for intent-to-task map",
|
|
6484
6670
|
(ctx) => {
|
|
@@ -6491,7 +6677,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6491
6677
|
};
|
|
6492
6678
|
}
|
|
6493
6679
|
).then(
|
|
6494
|
-
|
|
6680
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
6495
6681
|
CadenzaService.createMetaTask(
|
|
6496
6682
|
"Restore intent-to-task map payload",
|
|
6497
6683
|
(ctx) => {
|
|
@@ -6539,7 +6725,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6539
6725
|
return;
|
|
6540
6726
|
}
|
|
6541
6727
|
for (const t of task.nextTasks) {
|
|
6542
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
6728
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
6543
6729
|
continue;
|
|
6544
6730
|
}
|
|
6545
6731
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -6582,7 +6768,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6582
6768
|
{ concurrency: 30 }
|
|
6583
6769
|
)?.then(
|
|
6584
6770
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
6585
|
-
if (!ctx.__syncing) {
|
|
6771
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6586
6772
|
return;
|
|
6587
6773
|
}
|
|
6588
6774
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6643,7 +6829,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6643
6829
|
CadenzaService.createMetaTask(
|
|
6644
6830
|
"Record deputy relationship registration",
|
|
6645
6831
|
(ctx) => {
|
|
6646
|
-
if (!ctx.__syncing) {
|
|
6832
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6647
6833
|
return;
|
|
6648
6834
|
}
|
|
6649
6835
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6658,29 +6844,89 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6658
6844
|
"meta.sync_controller.sync_tick",
|
|
6659
6845
|
"meta.service_registry.initial_sync_complete"
|
|
6660
6846
|
).then(this.splitSignalsTask);
|
|
6661
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6847
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6848
|
+
"meta.sync_controller.sync_tick",
|
|
6849
|
+
"meta.sync_controller.synced_signals"
|
|
6850
|
+
).then(this.splitTasksForRegistration);
|
|
6662
6851
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
6663
6852
|
return {
|
|
6664
6853
|
...ctx,
|
|
6665
6854
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
6666
6855
|
};
|
|
6667
|
-
}).doOn(
|
|
6668
|
-
|
|
6856
|
+
}).doOn(
|
|
6857
|
+
"meta.sync_controller.sync_tick",
|
|
6858
|
+
"meta.service_registry.initial_sync_complete"
|
|
6859
|
+
).then(this.splitIntentsTask);
|
|
6860
|
+
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6861
|
+
"meta.sync_controller.sync_tick",
|
|
6862
|
+
"meta.service_registry.initial_sync_complete"
|
|
6863
|
+
).then(this.splitRoutinesTask);
|
|
6669
6864
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
6670
6865
|
return {
|
|
6671
6866
|
...ctx,
|
|
6672
6867
|
actors: CadenzaService.getAllActors()
|
|
6673
6868
|
};
|
|
6674
|
-
}).doOn(
|
|
6675
|
-
|
|
6869
|
+
}).doOn(
|
|
6870
|
+
"meta.sync_controller.sync_tick",
|
|
6871
|
+
"meta.service_registry.initial_sync_complete"
|
|
6872
|
+
).then(this.splitActorsForRegistration);
|
|
6873
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
6874
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6875
|
+
if (!task) {
|
|
6876
|
+
return false;
|
|
6877
|
+
}
|
|
6878
|
+
return {
|
|
6879
|
+
...ctx,
|
|
6880
|
+
task
|
|
6881
|
+
};
|
|
6882
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6676
6883
|
this.registerTaskMapTask,
|
|
6677
6884
|
this.registerDeputyRelationshipTask
|
|
6678
6885
|
);
|
|
6679
6886
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
6680
|
-
"meta.sync_controller.synced_tasks",
|
|
6681
6887
|
"meta.sync_controller.synced_signals"
|
|
6682
|
-
).then(
|
|
6683
|
-
|
|
6888
|
+
).then(
|
|
6889
|
+
CadenzaService.createMetaTask(
|
|
6890
|
+
"Ensure signal and task sync ready",
|
|
6891
|
+
(ctx) => {
|
|
6892
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6893
|
+
return false;
|
|
6894
|
+
}
|
|
6895
|
+
return ctx;
|
|
6896
|
+
}
|
|
6897
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6898
|
+
);
|
|
6899
|
+
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
6900
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6901
|
+
if (!task) {
|
|
6902
|
+
return false;
|
|
6903
|
+
}
|
|
6904
|
+
return {
|
|
6905
|
+
...ctx,
|
|
6906
|
+
task
|
|
6907
|
+
};
|
|
6908
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6909
|
+
CadenzaService.createMetaTask(
|
|
6910
|
+
"Ensure signal and task sync ready from task registration",
|
|
6911
|
+
(ctx) => {
|
|
6912
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6913
|
+
return false;
|
|
6914
|
+
}
|
|
6915
|
+
return ctx;
|
|
6916
|
+
}
|
|
6917
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6918
|
+
);
|
|
6919
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
6920
|
+
CadenzaService.createMetaTask(
|
|
6921
|
+
"Ensure intent and task sync ready",
|
|
6922
|
+
(ctx) => {
|
|
6923
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
6924
|
+
return false;
|
|
6925
|
+
}
|
|
6926
|
+
return ctx;
|
|
6927
|
+
}
|
|
6928
|
+
).then(this.registerIntentToTaskMapTask)
|
|
6929
|
+
);
|
|
6684
6930
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
6685
6931
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6686
6932
|
if (!task) {
|
|
@@ -6690,12 +6936,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6690
6936
|
...ctx,
|
|
6691
6937
|
task
|
|
6692
6938
|
};
|
|
6693
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6694
|
-
|
|
6939
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6940
|
+
CadenzaService.createMetaTask(
|
|
6941
|
+
"Ensure intent and task sync ready from task registration",
|
|
6942
|
+
(ctx) => {
|
|
6943
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
6944
|
+
return false;
|
|
6945
|
+
}
|
|
6946
|
+
return ctx;
|
|
6947
|
+
}
|
|
6948
|
+
).then(this.registerIntentToTaskMapTask)
|
|
6949
|
+
);
|
|
6950
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
6951
|
+
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
6952
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6953
|
+
if (!task) {
|
|
6954
|
+
return false;
|
|
6955
|
+
}
|
|
6956
|
+
return {
|
|
6957
|
+
...ctx,
|
|
6958
|
+
task
|
|
6959
|
+
};
|
|
6960
|
+
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
6695
6961
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6696
|
-
"meta.sync_controller.
|
|
6697
|
-
"meta.sync_controller.
|
|
6698
|
-
).then(
|
|
6962
|
+
"meta.sync_controller.synced_routines",
|
|
6963
|
+
"meta.sync_controller.task_registered"
|
|
6964
|
+
).then(
|
|
6965
|
+
CadenzaService.createMetaTask(
|
|
6966
|
+
"Ensure routine and task sync ready",
|
|
6967
|
+
(ctx) => {
|
|
6968
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
6969
|
+
return false;
|
|
6970
|
+
}
|
|
6971
|
+
return ctx;
|
|
6972
|
+
}
|
|
6973
|
+
).then(this.splitTasksInRoutines)
|
|
6974
|
+
);
|
|
6699
6975
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
6700
6976
|
emit("global.meta.sync_controller.synced", {
|
|
6701
6977
|
data: {
|
|
@@ -7823,6 +8099,12 @@ var CadenzaService = class {
|
|
|
7823
8099
|
displayName: options.displayName ?? "",
|
|
7824
8100
|
isMeta: options.isMeta
|
|
7825
8101
|
},
|
|
8102
|
+
__registrationData: {
|
|
8103
|
+
name: serviceName,
|
|
8104
|
+
description,
|
|
8105
|
+
displayName: options.displayName ?? "",
|
|
8106
|
+
isMeta: options.isMeta
|
|
8107
|
+
},
|
|
7826
8108
|
__serviceName: serviceName,
|
|
7827
8109
|
__serviceInstanceId: serviceId,
|
|
7828
8110
|
__port: options.port,
|
|
@@ -7875,6 +8157,16 @@ var CadenzaService = class {
|
|
|
7875
8157
|
is_blocked: false,
|
|
7876
8158
|
health: {}
|
|
7877
8159
|
},
|
|
8160
|
+
__registrationData: {
|
|
8161
|
+
uuid: serviceId,
|
|
8162
|
+
process_pid: 1,
|
|
8163
|
+
service_name: serviceName,
|
|
8164
|
+
is_frontend: true,
|
|
8165
|
+
is_active: true,
|
|
8166
|
+
is_non_responsive: false,
|
|
8167
|
+
is_blocked: false,
|
|
8168
|
+
health: {}
|
|
8169
|
+
},
|
|
7878
8170
|
__transportData: [],
|
|
7879
8171
|
__serviceName: serviceName,
|
|
7880
8172
|
__serviceInstanceId: serviceId,
|