@cadenza.io/service 2.17.24 → 2.17.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +521 -195
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +521 -195
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +524 -195
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +524 -195
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -686,6 +686,116 @@ var INTERNAL_RUNTIME_STATUS_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
686
686
|
"Collect distributed readiness",
|
|
687
687
|
"Get status"
|
|
688
688
|
]);
|
|
689
|
+
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
690
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
691
|
+
const getJoinedValue = (key) => {
|
|
692
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
693
|
+
const joinedContext = joinedContexts[index];
|
|
694
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
695
|
+
return joinedContext[key];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return void 0;
|
|
699
|
+
};
|
|
700
|
+
const registrationData = Object.prototype.hasOwnProperty.call(ctx, "__registrationData") && ctx.__registrationData !== void 0 ? ctx.__registrationData : getJoinedValue("__registrationData");
|
|
701
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
|
|
702
|
+
const nextQueryData = {
|
|
703
|
+
...existingQueryData,
|
|
704
|
+
...queryData
|
|
705
|
+
};
|
|
706
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
707
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
708
|
+
if (!("data" in nextQueryData) && (resolvedData !== void 0 || registrationData !== void 0)) {
|
|
709
|
+
nextQueryData.data = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
710
|
+
}
|
|
711
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
712
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
713
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
714
|
+
) : resolvedBatch;
|
|
715
|
+
}
|
|
716
|
+
return nextQueryData;
|
|
717
|
+
}
|
|
718
|
+
function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResult) {
|
|
719
|
+
if (!rawResult || typeof rawResult !== "object") {
|
|
720
|
+
return rawResult;
|
|
721
|
+
}
|
|
722
|
+
const result = { ...rawResult };
|
|
723
|
+
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
724
|
+
const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
725
|
+
if (resolvedData !== void 0 && result.data === void 0) {
|
|
726
|
+
result.data = resolvedData;
|
|
727
|
+
}
|
|
728
|
+
if (resolvedData !== void 0 && (normalizedQueryData.data === void 0 || normalizedQueryData.data === null)) {
|
|
729
|
+
normalizedQueryData.data = resolvedData;
|
|
730
|
+
}
|
|
731
|
+
result.queryData = normalizedQueryData;
|
|
732
|
+
if (tableName === "service") {
|
|
733
|
+
const resolvedServiceName = String(
|
|
734
|
+
result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ctx.__serviceName ?? ""
|
|
735
|
+
).trim();
|
|
736
|
+
if (resolvedServiceName) {
|
|
737
|
+
result.__serviceName = resolvedServiceName;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
741
|
+
const resolvedUuid = String(
|
|
742
|
+
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
743
|
+
).trim();
|
|
744
|
+
if (resolvedUuid) {
|
|
745
|
+
result.uuid = resolvedUuid;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return result;
|
|
749
|
+
}
|
|
750
|
+
function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
|
|
751
|
+
const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
|
|
752
|
+
tableName,
|
|
753
|
+
queryData,
|
|
754
|
+
options
|
|
755
|
+
);
|
|
756
|
+
return CadenzaService.createUniqueMetaTask(
|
|
757
|
+
`Resolve service registry insert for ${tableName}`,
|
|
758
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
759
|
+
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
760
|
+
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
761
|
+
CadenzaService.log(
|
|
762
|
+
"Service registry insert resolver missing service payload.",
|
|
763
|
+
{
|
|
764
|
+
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
765
|
+
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
766
|
+
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
767
|
+
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
768
|
+
},
|
|
769
|
+
"warning"
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
773
|
+
const delegationContext = ensureDelegationContextMetadata({
|
|
774
|
+
...ctx,
|
|
775
|
+
queryData: nextQueryData
|
|
776
|
+
});
|
|
777
|
+
delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
|
|
778
|
+
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
779
|
+
return Promise.resolve(
|
|
780
|
+
targetTask.taskFunction(
|
|
781
|
+
delegationContext,
|
|
782
|
+
emit,
|
|
783
|
+
inquire,
|
|
784
|
+
progressCallback
|
|
785
|
+
)
|
|
786
|
+
).then(
|
|
787
|
+
(result) => normalizeServiceRegistryInsertResult(
|
|
788
|
+
tableName,
|
|
789
|
+
ctx,
|
|
790
|
+
nextQueryData,
|
|
791
|
+
result
|
|
792
|
+
)
|
|
793
|
+
);
|
|
794
|
+
},
|
|
795
|
+
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
796
|
+
options
|
|
797
|
+
);
|
|
798
|
+
}
|
|
689
799
|
function readPositiveIntegerEnv(name, fallback) {
|
|
690
800
|
if (typeof process === "undefined") {
|
|
691
801
|
return fallback;
|
|
@@ -1896,7 +2006,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1896
2006
|
},
|
|
1897
2007
|
"Collects distributed transport diagnostics using inquiry responders."
|
|
1898
2008
|
).doOn("meta.service_registry.transport_diagnostics_requested").emits("meta.service_registry.transport_diagnostics_collected").emitsOnFail("meta.service_registry.transport_diagnostics_failed");
|
|
1899
|
-
this.insertServiceTask =
|
|
2009
|
+
this.insertServiceTask = resolveServiceRegistryInsertTask(
|
|
1900
2010
|
"service",
|
|
1901
2011
|
{
|
|
1902
2012
|
onConflict: {
|
|
@@ -1947,7 +2057,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1947
2057
|
retryDelayFactor: 1.3
|
|
1948
2058
|
}
|
|
1949
2059
|
).emits("meta.service_registry.service_inserted").emitsOnFail("meta.service_registry.service_insertion_failed");
|
|
1950
|
-
this.insertServiceInstanceTask =
|
|
2060
|
+
this.insertServiceInstanceTask = resolveServiceRegistryInsertTask(
|
|
1951
2061
|
"service_instance",
|
|
1952
2062
|
{},
|
|
1953
2063
|
{
|
|
@@ -2005,7 +2115,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2005
2115
|
retryCount: 5,
|
|
2006
2116
|
retryDelay: 1e3
|
|
2007
2117
|
}
|
|
2008
|
-
).
|
|
2118
|
+
).then(
|
|
2009
2119
|
CadenzaService.createMetaTask(
|
|
2010
2120
|
"Setup service",
|
|
2011
2121
|
(ctx) => {
|
|
@@ -2032,7 +2142,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2032
2142
|
this.useSocket = __useSocket;
|
|
2033
2143
|
this.retryCount = __retryCount;
|
|
2034
2144
|
this.isFrontend = typeof __isFrontend === "boolean" ? __isFrontend : !!normalizedLocalInstance.isFrontend;
|
|
2035
|
-
console.log("SETUP SERVICE", this.serviceInstanceId);
|
|
2036
2145
|
return {
|
|
2037
2146
|
...ctx,
|
|
2038
2147
|
serviceInstance: normalizedLocalInstance,
|
|
@@ -2057,6 +2166,10 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2057
2166
|
data: {
|
|
2058
2167
|
...transport,
|
|
2059
2168
|
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2169
|
+
},
|
|
2170
|
+
__registrationData: {
|
|
2171
|
+
...transport,
|
|
2172
|
+
service_instance_id: transport.service_instance_id ?? ctx.__serviceInstanceId
|
|
2060
2173
|
}
|
|
2061
2174
|
};
|
|
2062
2175
|
emit(
|
|
@@ -2070,7 +2183,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2070
2183
|
).attachSignal("meta.service_registry.transport_registration_requested")
|
|
2071
2184
|
)
|
|
2072
2185
|
);
|
|
2073
|
-
|
|
2186
|
+
CadenzaService.createMetaTask(
|
|
2187
|
+
"Prepare service instance registration",
|
|
2188
|
+
(ctx) => {
|
|
2189
|
+
const serviceName = String(
|
|
2190
|
+
ctx.data?.service_name ?? ctx.__serviceName ?? this.serviceName ?? ""
|
|
2191
|
+
).trim();
|
|
2192
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance")) {
|
|
2193
|
+
CadenzaService.schedule(
|
|
2194
|
+
"meta.service_registry.instance_registration_requested",
|
|
2195
|
+
{ ...ctx },
|
|
2196
|
+
250
|
|
2197
|
+
);
|
|
2198
|
+
return false;
|
|
2199
|
+
}
|
|
2200
|
+
return ctx;
|
|
2201
|
+
},
|
|
2202
|
+
"Waits for the exact local CadenzaDB service instance insert task during self-bootstrap."
|
|
2203
|
+
).doOn("meta.service_registry.instance_registration_requested").then(this.insertServiceInstanceTask);
|
|
2204
|
+
this.insertServiceTransportTask = resolveServiceRegistryInsertTask(
|
|
2074
2205
|
"service_instance_transport",
|
|
2075
2206
|
{
|
|
2076
2207
|
onConflict: {
|
|
@@ -2135,7 +2266,25 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2135
2266
|
retryCount: 5,
|
|
2136
2267
|
retryDelay: 1e3
|
|
2137
2268
|
}
|
|
2138
|
-
).
|
|
2269
|
+
).emits("meta.service_registry.transport_registered").emitsOnFail("meta.service_registry.transport_registration_failed");
|
|
2270
|
+
CadenzaService.createMetaTask(
|
|
2271
|
+
"Prepare service transport registration",
|
|
2272
|
+
(ctx) => {
|
|
2273
|
+
const serviceName = String(
|
|
2274
|
+
ctx.__serviceName ?? this.serviceName ?? ""
|
|
2275
|
+
).trim();
|
|
2276
|
+
if (serviceName === "CadenzaDB" && !CadenzaService.getLocalCadenzaDBInsertTask("service_instance_transport")) {
|
|
2277
|
+
CadenzaService.schedule(
|
|
2278
|
+
"meta.service_registry.transport_registration_requested",
|
|
2279
|
+
{ ...ctx },
|
|
2280
|
+
250
|
|
2281
|
+
);
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
return ctx;
|
|
2285
|
+
},
|
|
2286
|
+
"Waits for the exact local CadenzaDB service transport insert task during self-bootstrap."
|
|
2287
|
+
).doOn("meta.service_registry.transport_registration_requested").then(this.insertServiceTransportTask);
|
|
2139
2288
|
CadenzaService.createMetaTask(
|
|
2140
2289
|
"Handle service creation",
|
|
2141
2290
|
(ctx) => {
|
|
@@ -3349,6 +3498,16 @@ var RestController = class _RestController {
|
|
|
3349
3498
|
is_blocked: false,
|
|
3350
3499
|
health: {}
|
|
3351
3500
|
},
|
|
3501
|
+
__registrationData: {
|
|
3502
|
+
uuid: ctx.__serviceInstanceId,
|
|
3503
|
+
process_pid: 1,
|
|
3504
|
+
service_name: ctx.__serviceName,
|
|
3505
|
+
is_frontend: true,
|
|
3506
|
+
is_active: true,
|
|
3507
|
+
is_non_responsive: false,
|
|
3508
|
+
is_blocked: false,
|
|
3509
|
+
health: {}
|
|
3510
|
+
},
|
|
3352
3511
|
__transportData: [],
|
|
3353
3512
|
...ctx
|
|
3354
3513
|
});
|
|
@@ -5673,12 +5832,6 @@ import { v4 as uuid4 } from "uuid";
|
|
|
5673
5832
|
|
|
5674
5833
|
// src/graph/controllers/GraphSyncController.ts
|
|
5675
5834
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5676
|
-
var LOCAL_SYNC_QUERY_DATA = /* @__PURE__ */ Symbol.for(
|
|
5677
|
-
"@cadenza.io/service/local-sync-query-data"
|
|
5678
|
-
);
|
|
5679
|
-
var LOCAL_SYNC_ORIGINAL_TASK_FUNCTION = /* @__PURE__ */ Symbol.for(
|
|
5680
|
-
"@cadenza.io/service/local-sync-original-task-function"
|
|
5681
|
-
);
|
|
5682
5835
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5683
5836
|
if (typeof taskFunction !== "function") {
|
|
5684
5837
|
return void 0;
|
|
@@ -5755,38 +5908,86 @@ function buildIntentRegistryData(intent) {
|
|
|
5755
5908
|
isMeta: isMetaIntentName(name)
|
|
5756
5909
|
};
|
|
5757
5910
|
}
|
|
5911
|
+
function getJoinedContextValue(ctx, key) {
|
|
5912
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
5913
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
5914
|
+
const joinedContext = joinedContexts[index];
|
|
5915
|
+
if (joinedContext && typeof joinedContext === "object" && (Object.prototype.hasOwnProperty.call(joinedContext, key) || joinedContext[key] !== void 0)) {
|
|
5916
|
+
return joinedContext[key];
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
return void 0;
|
|
5920
|
+
}
|
|
5921
|
+
function didSyncInsertSucceed(ctx) {
|
|
5922
|
+
if (ctx.errored || ctx.__success === false) {
|
|
5923
|
+
return false;
|
|
5924
|
+
}
|
|
5925
|
+
const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
|
|
5926
|
+
if (!inquiryMeta) {
|
|
5927
|
+
return true;
|
|
5928
|
+
}
|
|
5929
|
+
const eligibleResponders = Number(inquiryMeta.eligibleResponders);
|
|
5930
|
+
if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
|
|
5931
|
+
return false;
|
|
5932
|
+
}
|
|
5933
|
+
const responded = Number(inquiryMeta.responded);
|
|
5934
|
+
if (Number.isFinite(responded) && responded === 0) {
|
|
5935
|
+
return false;
|
|
5936
|
+
}
|
|
5937
|
+
return true;
|
|
5938
|
+
}
|
|
5939
|
+
function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
5940
|
+
const joinedQueryData = getJoinedContextValue(ctx, "queryData");
|
|
5941
|
+
const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
|
|
5942
|
+
const nextQueryData = {
|
|
5943
|
+
...existingQueryData,
|
|
5944
|
+
...queryData
|
|
5945
|
+
};
|
|
5946
|
+
const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
|
|
5947
|
+
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
|
|
5948
|
+
if (!("data" in nextQueryData) && resolvedData !== void 0) {
|
|
5949
|
+
nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
|
|
5950
|
+
}
|
|
5951
|
+
if (!("batch" in nextQueryData) && resolvedBatch !== void 0) {
|
|
5952
|
+
nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
|
|
5953
|
+
(row) => row && typeof row === "object" ? { ...row } : row
|
|
5954
|
+
) : resolvedBatch;
|
|
5955
|
+
}
|
|
5956
|
+
return nextQueryData;
|
|
5957
|
+
}
|
|
5758
5958
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
5759
5959
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
}
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5960
|
+
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5961
|
+
if (!localInsertTask && !remoteInsertTask) {
|
|
5962
|
+
return void 0;
|
|
5963
|
+
}
|
|
5964
|
+
return CadenzaService.createUniqueMetaTask(
|
|
5965
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
5966
|
+
(ctx, emit, inquire, progressCallback) => {
|
|
5967
|
+
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
5968
|
+
if (!targetTask) {
|
|
5969
|
+
return false;
|
|
5970
|
+
}
|
|
5971
|
+
return targetTask.taskFunction(
|
|
5972
|
+
{
|
|
5772
5973
|
...ctx,
|
|
5773
|
-
queryData:
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5974
|
+
queryData: buildSyncInsertQueryData(
|
|
5975
|
+
ctx,
|
|
5976
|
+
queryData
|
|
5977
|
+
)
|
|
5978
|
+
},
|
|
5979
|
+
emit,
|
|
5980
|
+
inquire,
|
|
5981
|
+
progressCallback
|
|
5982
|
+
);
|
|
5983
|
+
},
|
|
5984
|
+
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
5985
|
+
{
|
|
5986
|
+
...options,
|
|
5987
|
+
register: false,
|
|
5988
|
+
isHidden: true
|
|
5786
5989
|
}
|
|
5787
|
-
|
|
5788
|
-
}
|
|
5789
|
-
return isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
5990
|
+
);
|
|
5790
5991
|
}
|
|
5791
5992
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
5792
5993
|
"intent_registry",
|
|
@@ -5805,11 +6006,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5805
6006
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
5806
6007
|
this.registeredActorTaskMaps = /* @__PURE__ */ new Set();
|
|
5807
6008
|
this.registeredIntentDefinitions = /* @__PURE__ */ new Set();
|
|
5808
|
-
this.
|
|
6009
|
+
this.tasksSynced = false;
|
|
6010
|
+
this.signalsSynced = false;
|
|
6011
|
+
this.intentsSynced = false;
|
|
6012
|
+
this.routinesSynced = false;
|
|
5809
6013
|
this.isCadenzaDBReady = false;
|
|
5810
6014
|
this.initialized = false;
|
|
5811
6015
|
this.initRetryScheduled = false;
|
|
5812
|
-
this.loggedCadenzaDBIntentSweep = false;
|
|
5813
6016
|
this.lastMissingLocalCadenzaDBInsertTablesKey = "";
|
|
5814
6017
|
}
|
|
5815
6018
|
static get instance() {
|
|
@@ -5884,21 +6087,36 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5884
6087
|
},
|
|
5885
6088
|
{ concurrency: 30 }
|
|
5886
6089
|
);
|
|
6090
|
+
const ensureIntentRegistryBeforeIntentMapTask = resolveSyncInsertTask(
|
|
6091
|
+
this.isCadenzaDBReady,
|
|
6092
|
+
"intent_registry",
|
|
6093
|
+
{
|
|
6094
|
+
onConflict: {
|
|
6095
|
+
target: ["name"],
|
|
6096
|
+
action: {
|
|
6097
|
+
do: "nothing"
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
},
|
|
6101
|
+
{ concurrency: 30 }
|
|
6102
|
+
);
|
|
5887
6103
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
5888
6104
|
"Split routines for registration",
|
|
5889
|
-
|
|
6105
|
+
(ctx, emit) => {
|
|
5890
6106
|
const { routines } = ctx;
|
|
5891
|
-
if (!routines) return;
|
|
6107
|
+
if (!routines) return false;
|
|
5892
6108
|
const serviceName2 = resolveSyncServiceName();
|
|
5893
6109
|
if (!serviceName2) {
|
|
5894
|
-
return;
|
|
6110
|
+
return false;
|
|
5895
6111
|
}
|
|
5896
6112
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5897
6113
|
delayMs: 2e3
|
|
5898
6114
|
});
|
|
6115
|
+
let emittedCount = 0;
|
|
5899
6116
|
for (const routine of routines) {
|
|
5900
6117
|
if (routine.registered) continue;
|
|
5901
|
-
|
|
6118
|
+
emit("meta.sync_controller.routine_registration_split", {
|
|
6119
|
+
__syncing: ctx.__syncing,
|
|
5902
6120
|
data: {
|
|
5903
6121
|
name: routine.name,
|
|
5904
6122
|
version: routine.version,
|
|
@@ -5907,10 +6125,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5907
6125
|
isMeta: routine.isMeta
|
|
5908
6126
|
},
|
|
5909
6127
|
__routineName: routine.name
|
|
5910
|
-
};
|
|
6128
|
+
});
|
|
6129
|
+
emittedCount += 1;
|
|
5911
6130
|
}
|
|
6131
|
+
return emittedCount > 0;
|
|
5912
6132
|
}
|
|
5913
|
-
)
|
|
6133
|
+
);
|
|
6134
|
+
CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
|
|
5914
6135
|
resolveSyncInsertTask(
|
|
5915
6136
|
this.isCadenzaDBReady,
|
|
5916
6137
|
"routine",
|
|
@@ -5925,39 +6146,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5925
6146
|
{ concurrency: 30 }
|
|
5926
6147
|
)?.then(
|
|
5927
6148
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
5928
|
-
if (!ctx.__syncing) {
|
|
6149
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
5929
6150
|
return;
|
|
5930
6151
|
}
|
|
5931
6152
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5932
6153
|
delayMs: 3e3
|
|
5933
6154
|
});
|
|
5934
6155
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6156
|
+
CadenzaService.debounce(
|
|
6157
|
+
"meta.sync_controller.routine_registration_settled",
|
|
6158
|
+
{ __syncing: true },
|
|
6159
|
+
300
|
|
6160
|
+
);
|
|
5935
6161
|
return true;
|
|
5936
|
-
})
|
|
5937
|
-
CadenzaService.createUniqueMetaTask(
|
|
5938
|
-
"Gather routine registration",
|
|
5939
|
-
() => true
|
|
5940
|
-
).emits("meta.sync_controller.synced_routines")
|
|
5941
|
-
)
|
|
6162
|
+
})
|
|
5942
6163
|
)
|
|
5943
6164
|
);
|
|
6165
|
+
CadenzaService.createUniqueMetaTask(
|
|
6166
|
+
"Gather routine registration",
|
|
6167
|
+
() => {
|
|
6168
|
+
this.routinesSynced = true;
|
|
6169
|
+
return true;
|
|
6170
|
+
}
|
|
6171
|
+
).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
|
|
5944
6172
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
5945
6173
|
"Split tasks in routines",
|
|
5946
|
-
|
|
6174
|
+
(ctx, emit) => {
|
|
5947
6175
|
const { routines } = ctx;
|
|
5948
|
-
if (!routines) return;
|
|
6176
|
+
if (!routines) return false;
|
|
5949
6177
|
const serviceName2 = resolveSyncServiceName();
|
|
5950
6178
|
if (!serviceName2) {
|
|
5951
|
-
return;
|
|
6179
|
+
return false;
|
|
5952
6180
|
}
|
|
5953
6181
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
5954
6182
|
delayMs: 3e3
|
|
5955
6183
|
});
|
|
6184
|
+
let emittedCount = 0;
|
|
5956
6185
|
for (const routine of routines) {
|
|
5957
6186
|
if (!routine.registered) continue;
|
|
5958
6187
|
for (const task of routine.tasks) {
|
|
5959
6188
|
if (!task) {
|
|
5960
|
-
console.log("task is null", routine, task);
|
|
5961
6189
|
continue;
|
|
5962
6190
|
}
|
|
5963
6191
|
if (routine.registeredTasks.has(task.name)) continue;
|
|
@@ -5967,7 +6195,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5967
6195
|
if (!nextTask?.registered) {
|
|
5968
6196
|
continue;
|
|
5969
6197
|
}
|
|
5970
|
-
|
|
6198
|
+
emit("meta.sync_controller.routine_task_map_split", {
|
|
6199
|
+
__syncing: ctx.__syncing,
|
|
5971
6200
|
data: {
|
|
5972
6201
|
taskName: nextTask.name,
|
|
5973
6202
|
taskVersion: nextTask.version,
|
|
@@ -5977,12 +6206,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
5977
6206
|
},
|
|
5978
6207
|
__routineName: routine.name,
|
|
5979
6208
|
__taskName: nextTask.name
|
|
5980
|
-
};
|
|
6209
|
+
});
|
|
6210
|
+
emittedCount += 1;
|
|
5981
6211
|
}
|
|
5982
6212
|
}
|
|
5983
6213
|
}
|
|
6214
|
+
return emittedCount > 0;
|
|
5984
6215
|
}
|
|
5985
|
-
)
|
|
6216
|
+
);
|
|
6217
|
+
CadenzaService.createMetaTask("Process split routine task map", (ctx) => ctx).doOn("meta.sync_controller.routine_task_map_split").then(
|
|
5986
6218
|
resolveSyncInsertTask(
|
|
5987
6219
|
this.isCadenzaDBReady,
|
|
5988
6220
|
"task_to_routine_map",
|
|
@@ -6003,7 +6235,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6003
6235
|
{ concurrency: 30 }
|
|
6004
6236
|
)?.then(
|
|
6005
6237
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
6006
|
-
if (!ctx.__syncing) {
|
|
6238
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6007
6239
|
return;
|
|
6008
6240
|
}
|
|
6009
6241
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6017,18 +6249,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6017
6249
|
);
|
|
6018
6250
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
6019
6251
|
"Split signals for registration",
|
|
6020
|
-
|
|
6252
|
+
(ctx, emit) => {
|
|
6021
6253
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6022
6254
|
delayMs: 3e3
|
|
6023
6255
|
});
|
|
6024
6256
|
const { signals } = ctx;
|
|
6025
|
-
if (!signals) return;
|
|
6257
|
+
if (!signals) return false;
|
|
6026
6258
|
const filteredSignals = signals.filter(
|
|
6027
6259
|
(signal) => !signal.data.registered
|
|
6028
6260
|
).map((signal) => signal.signal);
|
|
6029
6261
|
for (const signal of filteredSignals) {
|
|
6030
6262
|
const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
|
|
6031
|
-
|
|
6263
|
+
emit("meta.sync_controller.signal_registration_split", {
|
|
6264
|
+
__syncing: ctx.__syncing,
|
|
6032
6265
|
data: {
|
|
6033
6266
|
name: signal,
|
|
6034
6267
|
isGlobal,
|
|
@@ -6037,10 +6270,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6037
6270
|
isMeta
|
|
6038
6271
|
},
|
|
6039
6272
|
__signal: signal
|
|
6040
|
-
};
|
|
6273
|
+
});
|
|
6041
6274
|
}
|
|
6275
|
+
return filteredSignals.length > 0;
|
|
6042
6276
|
}
|
|
6043
|
-
)
|
|
6277
|
+
);
|
|
6278
|
+
CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
|
|
6044
6279
|
resolveSyncInsertTask(
|
|
6045
6280
|
this.isCadenzaDBReady,
|
|
6046
6281
|
"signal_registry",
|
|
@@ -6055,37 +6290,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6055
6290
|
{ concurrency: 30 }
|
|
6056
6291
|
)?.then(
|
|
6057
6292
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
6058
|
-
if (!ctx.__syncing) {
|
|
6293
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6059
6294
|
return;
|
|
6060
6295
|
}
|
|
6061
6296
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6062
6297
|
delayMs: 3e3
|
|
6063
6298
|
});
|
|
6299
|
+
CadenzaService.debounce(
|
|
6300
|
+
"meta.sync_controller.signal_registration_settled",
|
|
6301
|
+
{ __syncing: true },
|
|
6302
|
+
300
|
|
6303
|
+
);
|
|
6064
6304
|
return { signalName: ctx.__signal };
|
|
6065
|
-
}).then(
|
|
6066
|
-
CadenzaService.signalBroker.registerSignalTask,
|
|
6067
|
-
CadenzaService.createUniqueMetaTask(
|
|
6068
|
-
"Gather signal registration",
|
|
6069
|
-
() => true
|
|
6070
|
-
).emits("meta.sync_controller.synced_signals")
|
|
6071
|
-
)
|
|
6305
|
+
}).then(CadenzaService.signalBroker.registerSignalTask)
|
|
6072
6306
|
)
|
|
6073
6307
|
);
|
|
6308
|
+
CadenzaService.createUniqueMetaTask(
|
|
6309
|
+
"Gather signal registration",
|
|
6310
|
+
() => {
|
|
6311
|
+
this.signalsSynced = true;
|
|
6312
|
+
return true;
|
|
6313
|
+
}
|
|
6314
|
+
).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
|
|
6074
6315
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
6075
6316
|
"Split tasks for registration",
|
|
6076
|
-
|
|
6317
|
+
(ctx, emit) => {
|
|
6077
6318
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6078
6319
|
delayMs: 3e3
|
|
6079
6320
|
});
|
|
6080
6321
|
const tasks = ctx.tasks;
|
|
6081
6322
|
const serviceName2 = resolveSyncServiceName();
|
|
6082
6323
|
if (!serviceName2) {
|
|
6083
|
-
return;
|
|
6324
|
+
return false;
|
|
6084
6325
|
}
|
|
6326
|
+
let emittedCount = 0;
|
|
6085
6327
|
for (const task of tasks) {
|
|
6086
6328
|
if (task.registered) continue;
|
|
6087
6329
|
const { __functionString, __getTagCallback } = task.export();
|
|
6088
|
-
|
|
6330
|
+
emit("meta.sync_controller.task_registration_split", {
|
|
6331
|
+
__syncing: ctx.__syncing,
|
|
6089
6332
|
data: {
|
|
6090
6333
|
name: task.name,
|
|
6091
6334
|
version: task.version,
|
|
@@ -6103,9 +6346,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6103
6346
|
isMeta: task.isMeta,
|
|
6104
6347
|
isSubMeta: task.isSubMeta,
|
|
6105
6348
|
isHidden: task.isHidden,
|
|
6106
|
-
// inputSchema: task.inputSchema,
|
|
6107
6349
|
validateInputContext: task.validateInputContext,
|
|
6108
|
-
// outputSchema: task.outputSchema,
|
|
6109
6350
|
validateOutputContext: task.validateOutputContext,
|
|
6110
6351
|
retryCount: task.retryCount,
|
|
6111
6352
|
retryDelay: task.retryDelay,
|
|
@@ -6120,10 +6361,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6120
6361
|
}
|
|
6121
6362
|
},
|
|
6122
6363
|
__taskName: task.name
|
|
6123
|
-
};
|
|
6364
|
+
});
|
|
6365
|
+
emittedCount += 1;
|
|
6124
6366
|
}
|
|
6367
|
+
return emittedCount > 0;
|
|
6125
6368
|
}
|
|
6126
|
-
)
|
|
6369
|
+
);
|
|
6370
|
+
CadenzaService.createMetaTask("Process split task registration", (ctx) => ctx).doOn("meta.sync_controller.task_registration_split").then(
|
|
6127
6371
|
resolveSyncInsertTask(
|
|
6128
6372
|
this.isCadenzaDBReady,
|
|
6129
6373
|
"task",
|
|
@@ -6138,7 +6382,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6138
6382
|
{ concurrency: 30 }
|
|
6139
6383
|
)?.then(
|
|
6140
6384
|
CadenzaService.createMetaTask("Record registration", (ctx, emit) => {
|
|
6141
|
-
if (!ctx.__syncing) {
|
|
6385
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6142
6386
|
return;
|
|
6143
6387
|
}
|
|
6144
6388
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6149,15 +6393,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6149
6393
|
...ctx,
|
|
6150
6394
|
task: CadenzaService.get(ctx.__taskName)
|
|
6151
6395
|
});
|
|
6396
|
+
CadenzaService.debounce(
|
|
6397
|
+
"meta.sync_controller.task_registration_settled",
|
|
6398
|
+
{ __syncing: true },
|
|
6399
|
+
300
|
|
6400
|
+
);
|
|
6152
6401
|
return true;
|
|
6153
|
-
})
|
|
6154
|
-
CadenzaService.createUniqueMetaTask(
|
|
6155
|
-
"Gather task registration",
|
|
6156
|
-
() => true
|
|
6157
|
-
).emits("meta.sync_controller.synced_tasks")
|
|
6158
|
-
)
|
|
6402
|
+
})
|
|
6159
6403
|
)
|
|
6160
6404
|
);
|
|
6405
|
+
CadenzaService.createUniqueMetaTask(
|
|
6406
|
+
"Gather task registration",
|
|
6407
|
+
() => {
|
|
6408
|
+
this.tasksSynced = true;
|
|
6409
|
+
return true;
|
|
6410
|
+
}
|
|
6411
|
+
).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
|
|
6161
6412
|
this.splitActorsForRegistration = CadenzaService.createMetaTask(
|
|
6162
6413
|
"Split actors for registration",
|
|
6163
6414
|
function* (ctx) {
|
|
@@ -6202,22 +6453,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6202
6453
|
{ concurrency: 30 }
|
|
6203
6454
|
)?.then(
|
|
6204
6455
|
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
6205
|
-
if (!ctx.__syncing) {
|
|
6456
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6206
6457
|
return;
|
|
6207
6458
|
}
|
|
6208
6459
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6209
6460
|
delayMs: 3e3
|
|
6210
6461
|
});
|
|
6211
6462
|
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
6463
|
+
CadenzaService.debounce(
|
|
6464
|
+
"meta.sync_controller.actor_registration_settled",
|
|
6465
|
+
{ __syncing: true },
|
|
6466
|
+
300
|
|
6467
|
+
);
|
|
6212
6468
|
return true;
|
|
6213
|
-
})
|
|
6214
|
-
CadenzaService.createUniqueMetaTask(
|
|
6215
|
-
"Gather actor registration",
|
|
6216
|
-
() => true
|
|
6217
|
-
).emits("meta.sync_controller.synced_actors")
|
|
6218
|
-
)
|
|
6469
|
+
})
|
|
6219
6470
|
)
|
|
6220
6471
|
);
|
|
6472
|
+
CadenzaService.createUniqueMetaTask(
|
|
6473
|
+
"Gather actor registration",
|
|
6474
|
+
() => true
|
|
6475
|
+
).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
|
|
6221
6476
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
6222
6477
|
"Split actor task maps",
|
|
6223
6478
|
function* (ctx) {
|
|
@@ -6272,7 +6527,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6272
6527
|
{ concurrency: 30 }
|
|
6273
6528
|
)?.then(
|
|
6274
6529
|
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
6275
|
-
if (!ctx.__syncing) {
|
|
6530
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6276
6531
|
return;
|
|
6277
6532
|
}
|
|
6278
6533
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6285,7 +6540,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6285
6540
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
6286
6541
|
"Record signal registration",
|
|
6287
6542
|
(ctx) => {
|
|
6288
|
-
if (!ctx.__syncing) {
|
|
6543
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6289
6544
|
return;
|
|
6290
6545
|
}
|
|
6291
6546
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6296,13 +6551,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6296
6551
|
);
|
|
6297
6552
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
6298
6553
|
"Split observed signals of task",
|
|
6299
|
-
|
|
6554
|
+
(ctx, emit) => {
|
|
6300
6555
|
const task = ctx.task;
|
|
6301
|
-
if (task.hidden || !task.register) return;
|
|
6556
|
+
if (task.hidden || !task.register) return false;
|
|
6302
6557
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6303
6558
|
if (!serviceName2) {
|
|
6304
|
-
return;
|
|
6559
|
+
return false;
|
|
6305
6560
|
}
|
|
6561
|
+
let emittedCount = 0;
|
|
6306
6562
|
for (const signal of task.observedSignals) {
|
|
6307
6563
|
const _signal = signal.split(":")[0];
|
|
6308
6564
|
if (task.registeredSignals.has(signal)) continue;
|
|
@@ -6310,7 +6566,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6310
6566
|
continue;
|
|
6311
6567
|
}
|
|
6312
6568
|
const { isGlobal } = decomposeSignalName(_signal);
|
|
6313
|
-
|
|
6569
|
+
emit("meta.sync_controller.signal_task_map_split", {
|
|
6570
|
+
__syncing: ctx.__syncing,
|
|
6314
6571
|
data: {
|
|
6315
6572
|
signalName: _signal,
|
|
6316
6573
|
isGlobal,
|
|
@@ -6320,10 +6577,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6320
6577
|
},
|
|
6321
6578
|
__taskName: task.name,
|
|
6322
6579
|
__signal: signal
|
|
6323
|
-
};
|
|
6580
|
+
});
|
|
6581
|
+
emittedCount += 1;
|
|
6324
6582
|
}
|
|
6583
|
+
return emittedCount > 0;
|
|
6325
6584
|
}
|
|
6326
|
-
)
|
|
6585
|
+
);
|
|
6586
|
+
CadenzaService.createMetaTask("Process split signal-to-task map", (ctx) => ctx).doOn("meta.sync_controller.signal_task_map_split").then(
|
|
6327
6587
|
resolveSyncInsertTask(
|
|
6328
6588
|
this.isCadenzaDBReady,
|
|
6329
6589
|
"signal_to_task_map",
|
|
@@ -6345,29 +6605,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6345
6605
|
);
|
|
6346
6606
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
6347
6607
|
"Split intents for registration",
|
|
6348
|
-
function
|
|
6608
|
+
function(ctx, emit) {
|
|
6349
6609
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6350
6610
|
delayMs: 3e3
|
|
6351
6611
|
});
|
|
6352
6612
|
const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
|
|
6353
|
-
|
|
6354
|
-
const intentNames = intents.map((intent) => String(intent?.name ?? "").trim()).filter(Boolean);
|
|
6355
|
-
const authorityIntentNames = intentNames.filter(
|
|
6356
|
-
(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")
|
|
6357
|
-
);
|
|
6358
|
-
CadenzaService.log(
|
|
6359
|
-
"CadenzaDB intent sweep diagnostics.",
|
|
6360
|
-
{
|
|
6361
|
-
totalIntents: intentNames.length,
|
|
6362
|
-
hasMetaServiceRegistryFullSync: intentNames.includes(
|
|
6363
|
-
"meta-service-registry-full-sync"
|
|
6364
|
-
),
|
|
6365
|
-
authorityIntentNames
|
|
6366
|
-
},
|
|
6367
|
-
"info"
|
|
6368
|
-
);
|
|
6369
|
-
this.loggedCadenzaDBIntentSweep = true;
|
|
6370
|
-
}
|
|
6613
|
+
let emittedCount = 0;
|
|
6371
6614
|
for (const intent of intents) {
|
|
6372
6615
|
const intentData = buildIntentRegistryData(intent);
|
|
6373
6616
|
if (!intentData) {
|
|
@@ -6376,35 +6619,46 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6376
6619
|
if (this.registeredIntentDefinitions.has(intentData.name)) {
|
|
6377
6620
|
continue;
|
|
6378
6621
|
}
|
|
6379
|
-
|
|
6622
|
+
emit("meta.sync_controller.intent_registration_split", {
|
|
6623
|
+
__syncing: ctx.__syncing,
|
|
6380
6624
|
data: intentData,
|
|
6381
6625
|
__intentName: intentData.name
|
|
6382
|
-
};
|
|
6626
|
+
});
|
|
6627
|
+
emittedCount += 1;
|
|
6383
6628
|
}
|
|
6629
|
+
return emittedCount > 0;
|
|
6384
6630
|
}.bind(this)
|
|
6385
|
-
)
|
|
6631
|
+
);
|
|
6632
|
+
CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
|
|
6386
6633
|
insertIntentRegistryTask?.then(
|
|
6387
6634
|
CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
|
|
6388
|
-
if (!ctx.__syncing) {
|
|
6635
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6389
6636
|
return;
|
|
6390
6637
|
}
|
|
6391
6638
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6392
6639
|
delayMs: 3e3
|
|
6393
6640
|
});
|
|
6394
6641
|
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
6642
|
+
CadenzaService.debounce(
|
|
6643
|
+
"meta.sync_controller.intent_registration_settled",
|
|
6644
|
+
{ __syncing: true },
|
|
6645
|
+
300
|
|
6646
|
+
);
|
|
6395
6647
|
return true;
|
|
6396
|
-
})
|
|
6397
|
-
CadenzaService.createUniqueMetaTask(
|
|
6398
|
-
"Gather intent registration",
|
|
6399
|
-
() => true
|
|
6400
|
-
).emits("meta.sync_controller.synced_intents")
|
|
6401
|
-
)
|
|
6648
|
+
})
|
|
6402
6649
|
)
|
|
6403
6650
|
);
|
|
6651
|
+
CadenzaService.createUniqueMetaTask(
|
|
6652
|
+
"Gather intent registration",
|
|
6653
|
+
() => {
|
|
6654
|
+
this.intentsSynced = true;
|
|
6655
|
+
return true;
|
|
6656
|
+
}
|
|
6657
|
+
).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
|
|
6404
6658
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
6405
6659
|
"Record intent registration",
|
|
6406
6660
|
(ctx) => {
|
|
6407
|
-
if (!ctx.__syncing) {
|
|
6661
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6408
6662
|
return;
|
|
6409
6663
|
}
|
|
6410
6664
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6417,37 +6671,15 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6417
6671
|
);
|
|
6418
6672
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
6419
6673
|
"Split intents of task",
|
|
6420
|
-
function
|
|
6674
|
+
function(ctx, emit) {
|
|
6421
6675
|
const task = ctx.task;
|
|
6422
|
-
if (task.hidden || !task.register) return;
|
|
6676
|
+
if (task.hidden || !task.register) return false;
|
|
6423
6677
|
const serviceName2 = resolveSyncServiceName(task);
|
|
6424
6678
|
if (!serviceName2) {
|
|
6425
|
-
return;
|
|
6679
|
+
return false;
|
|
6426
6680
|
}
|
|
6427
6681
|
task.__registeredIntents = task.__registeredIntents ?? /* @__PURE__ */ new Set();
|
|
6428
6682
|
task.__invalidMetaIntentWarnings = task.__invalidMetaIntentWarnings ?? /* @__PURE__ */ new Set();
|
|
6429
|
-
if (serviceName2 === "CadenzaDB" && [
|
|
6430
|
-
"Query service_instance",
|
|
6431
|
-
"Query service_instance_transport",
|
|
6432
|
-
"Query intent_to_task_map",
|
|
6433
|
-
"Query signal_to_task_map"
|
|
6434
|
-
].includes(task.name)) {
|
|
6435
|
-
const authorityTaskKey = `${task.name}:${task.version}`;
|
|
6436
|
-
if (!this.loggedAuthorityTaskIntentDiagnostics.has(authorityTaskKey)) {
|
|
6437
|
-
this.loggedAuthorityTaskIntentDiagnostics.add(authorityTaskKey);
|
|
6438
|
-
CadenzaService.log(
|
|
6439
|
-
"CadenzaDB authority task intent diagnostics.",
|
|
6440
|
-
{
|
|
6441
|
-
taskName: task.name,
|
|
6442
|
-
taskVersion: task.version,
|
|
6443
|
-
isMeta: task.isMeta,
|
|
6444
|
-
handlesIntents: Array.from(task.handlesIntents ?? []),
|
|
6445
|
-
registeredIntents: Array.from(task.__registeredIntents ?? [])
|
|
6446
|
-
},
|
|
6447
|
-
"info"
|
|
6448
|
-
);
|
|
6449
|
-
}
|
|
6450
|
-
}
|
|
6451
6683
|
for (const intent of task.handlesIntents) {
|
|
6452
6684
|
if (task.__registeredIntents.has(intent)) continue;
|
|
6453
6685
|
if (isMetaIntentName(intent) && !task.isMeta) {
|
|
@@ -6469,7 +6701,8 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6469
6701
|
if (!intentDefinition) {
|
|
6470
6702
|
continue;
|
|
6471
6703
|
}
|
|
6472
|
-
|
|
6704
|
+
emit("meta.sync_controller.intent_task_map_split", {
|
|
6705
|
+
__syncing: ctx.__syncing,
|
|
6473
6706
|
data: {
|
|
6474
6707
|
intentName: intent,
|
|
6475
6708
|
taskName: task.name,
|
|
@@ -6485,10 +6718,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6485
6718
|
taskVersion: task.version,
|
|
6486
6719
|
serviceName: serviceName2
|
|
6487
6720
|
}
|
|
6488
|
-
};
|
|
6721
|
+
});
|
|
6489
6722
|
}
|
|
6723
|
+
return true;
|
|
6490
6724
|
}.bind(this)
|
|
6491
|
-
)
|
|
6725
|
+
);
|
|
6726
|
+
CadenzaService.createMetaTask("Process split intent-to-task map", (ctx) => ctx).doOn("meta.sync_controller.intent_task_map_split").then(
|
|
6492
6727
|
CadenzaService.createMetaTask(
|
|
6493
6728
|
"Prepare intent definition for intent-to-task map",
|
|
6494
6729
|
(ctx) => {
|
|
@@ -6501,7 +6736,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6501
6736
|
};
|
|
6502
6737
|
}
|
|
6503
6738
|
).then(
|
|
6504
|
-
|
|
6739
|
+
ensureIntentRegistryBeforeIntentMapTask?.then(
|
|
6505
6740
|
CadenzaService.createMetaTask(
|
|
6506
6741
|
"Restore intent-to-task map payload",
|
|
6507
6742
|
(ctx) => {
|
|
@@ -6549,7 +6784,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6549
6784
|
return;
|
|
6550
6785
|
}
|
|
6551
6786
|
for (const t of task.nextTasks) {
|
|
6552
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register) {
|
|
6787
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
6553
6788
|
continue;
|
|
6554
6789
|
}
|
|
6555
6790
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -6592,7 +6827,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6592
6827
|
{ concurrency: 30 }
|
|
6593
6828
|
)?.then(
|
|
6594
6829
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
6595
|
-
if (!ctx.__syncing) {
|
|
6830
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6596
6831
|
return;
|
|
6597
6832
|
}
|
|
6598
6833
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6653,7 +6888,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6653
6888
|
CadenzaService.createMetaTask(
|
|
6654
6889
|
"Record deputy relationship registration",
|
|
6655
6890
|
(ctx) => {
|
|
6656
|
-
if (!ctx.__syncing) {
|
|
6891
|
+
if (!ctx.__syncing || !didSyncInsertSucceed(ctx)) {
|
|
6657
6892
|
return;
|
|
6658
6893
|
}
|
|
6659
6894
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
@@ -6668,19 +6903,22 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6668
6903
|
"meta.sync_controller.sync_tick",
|
|
6669
6904
|
"meta.service_registry.initial_sync_complete"
|
|
6670
6905
|
).then(this.splitSignalsTask);
|
|
6671
|
-
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6906
|
+
CadenzaService.registry.getAllTasks.clone().doOn(
|
|
6907
|
+
"meta.sync_controller.sync_tick",
|
|
6908
|
+
"meta.sync_controller.synced_signals"
|
|
6909
|
+
).then(this.splitTasksForRegistration);
|
|
6672
6910
|
CadenzaService.createMetaTask("Get all intents", (ctx) => {
|
|
6673
6911
|
return {
|
|
6674
6912
|
...ctx,
|
|
6675
6913
|
intents: Array.from(CadenzaService.inquiryBroker.intents.values())
|
|
6676
6914
|
};
|
|
6677
6915
|
}).doOn(
|
|
6678
|
-
"meta.sync_controller.
|
|
6679
|
-
"meta.
|
|
6916
|
+
"meta.sync_controller.sync_tick",
|
|
6917
|
+
"meta.service_registry.initial_sync_complete"
|
|
6680
6918
|
).then(this.splitIntentsTask);
|
|
6681
6919
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6682
|
-
"meta.sync_controller.
|
|
6683
|
-
"meta.
|
|
6920
|
+
"meta.sync_controller.sync_tick",
|
|
6921
|
+
"meta.service_registry.initial_sync_complete"
|
|
6684
6922
|
).then(this.splitRoutinesTask);
|
|
6685
6923
|
CadenzaService.createMetaTask("Get all actors", (ctx) => {
|
|
6686
6924
|
return {
|
|
@@ -6688,16 +6926,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6688
6926
|
actors: CadenzaService.getAllActors()
|
|
6689
6927
|
};
|
|
6690
6928
|
}).doOn(
|
|
6691
|
-
"meta.sync_controller.
|
|
6692
|
-
"meta.
|
|
6929
|
+
"meta.sync_controller.sync_tick",
|
|
6930
|
+
"meta.service_registry.initial_sync_complete"
|
|
6693
6931
|
).then(this.splitActorsForRegistration);
|
|
6694
|
-
CadenzaService.
|
|
6932
|
+
CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
|
|
6933
|
+
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6934
|
+
if (!task) {
|
|
6935
|
+
return false;
|
|
6936
|
+
}
|
|
6937
|
+
return {
|
|
6938
|
+
...ctx,
|
|
6939
|
+
task
|
|
6940
|
+
};
|
|
6941
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6695
6942
|
this.registerTaskMapTask,
|
|
6696
6943
|
this.registerDeputyRelationshipTask
|
|
6697
6944
|
);
|
|
6698
6945
|
CadenzaService.registry.doForEachTask.clone().doOn(
|
|
6699
6946
|
"meta.sync_controller.synced_signals"
|
|
6700
|
-
).then(
|
|
6947
|
+
).then(
|
|
6948
|
+
CadenzaService.createMetaTask(
|
|
6949
|
+
"Ensure signal and task sync ready",
|
|
6950
|
+
(ctx) => {
|
|
6951
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6952
|
+
return false;
|
|
6953
|
+
}
|
|
6954
|
+
return ctx;
|
|
6955
|
+
}
|
|
6956
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6957
|
+
);
|
|
6701
6958
|
CadenzaService.createMetaTask("Get registered task for signal sync", (ctx) => {
|
|
6702
6959
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6703
6960
|
if (!task) {
|
|
@@ -6707,8 +6964,28 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6707
6964
|
...ctx,
|
|
6708
6965
|
task
|
|
6709
6966
|
};
|
|
6710
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6711
|
-
|
|
6967
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6968
|
+
CadenzaService.createMetaTask(
|
|
6969
|
+
"Ensure signal and task sync ready from task registration",
|
|
6970
|
+
(ctx) => {
|
|
6971
|
+
if (!this.tasksSynced || !this.signalsSynced) {
|
|
6972
|
+
return false;
|
|
6973
|
+
}
|
|
6974
|
+
return ctx;
|
|
6975
|
+
}
|
|
6976
|
+
).then(this.registerSignalToTaskMapTask)
|
|
6977
|
+
);
|
|
6978
|
+
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_intents").then(
|
|
6979
|
+
CadenzaService.createMetaTask(
|
|
6980
|
+
"Ensure intent and task sync ready",
|
|
6981
|
+
(ctx) => {
|
|
6982
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
6983
|
+
return false;
|
|
6984
|
+
}
|
|
6985
|
+
return ctx;
|
|
6986
|
+
}
|
|
6987
|
+
).then(this.registerIntentToTaskMapTask)
|
|
6988
|
+
);
|
|
6712
6989
|
CadenzaService.createMetaTask("Get registered task for intent sync", (ctx) => {
|
|
6713
6990
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
6714
6991
|
if (!task) {
|
|
@@ -6718,7 +6995,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6718
6995
|
...ctx,
|
|
6719
6996
|
task
|
|
6720
6997
|
};
|
|
6721
|
-
}).doOn("meta.sync_controller.task_registered").then(
|
|
6998
|
+
}).doOn("meta.sync_controller.task_registered").then(
|
|
6999
|
+
CadenzaService.createMetaTask(
|
|
7000
|
+
"Ensure intent and task sync ready from task registration",
|
|
7001
|
+
(ctx) => {
|
|
7002
|
+
if (!this.tasksSynced || !this.intentsSynced) {
|
|
7003
|
+
return false;
|
|
7004
|
+
}
|
|
7005
|
+
return ctx;
|
|
7006
|
+
}
|
|
7007
|
+
).then(this.registerIntentToTaskMapTask)
|
|
7008
|
+
);
|
|
6722
7009
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_actors").then(this.registerActorTaskMapTask);
|
|
6723
7010
|
CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
|
|
6724
7011
|
const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
|
|
@@ -6731,9 +7018,19 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6731
7018
|
};
|
|
6732
7019
|
}).doOn("meta.sync_controller.task_registered").then(this.registerActorTaskMapTask);
|
|
6733
7020
|
CadenzaService.registry.getAllRoutines.clone().doOn(
|
|
6734
|
-
"meta.sync_controller.
|
|
6735
|
-
"meta.sync_controller.
|
|
6736
|
-
).then(
|
|
7021
|
+
"meta.sync_controller.synced_routines",
|
|
7022
|
+
"meta.sync_controller.task_registered"
|
|
7023
|
+
).then(
|
|
7024
|
+
CadenzaService.createMetaTask(
|
|
7025
|
+
"Ensure routine and task sync ready",
|
|
7026
|
+
(ctx) => {
|
|
7027
|
+
if (!this.tasksSynced || !this.routinesSynced) {
|
|
7028
|
+
return false;
|
|
7029
|
+
}
|
|
7030
|
+
return ctx;
|
|
7031
|
+
}
|
|
7032
|
+
).then(this.splitTasksInRoutines)
|
|
7033
|
+
);
|
|
6737
7034
|
CadenzaService.createMetaTask("Finish sync", (ctx, emit) => {
|
|
6738
7035
|
emit("global.meta.sync_controller.synced", {
|
|
6739
7036
|
data: {
|
|
@@ -6761,6 +7058,11 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6761
7058
|
{ __syncing: true },
|
|
6762
7059
|
18e4
|
|
6763
7060
|
);
|
|
7061
|
+
CadenzaService.schedule(
|
|
7062
|
+
"meta.sync_controller.sync_tick",
|
|
7063
|
+
{ __syncing: true },
|
|
7064
|
+
250
|
|
7065
|
+
);
|
|
6764
7066
|
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
6765
7067
|
}
|
|
6766
7068
|
}
|
|
@@ -7161,20 +7463,28 @@ var CadenzaService = class {
|
|
|
7161
7463
|
return false;
|
|
7162
7464
|
});
|
|
7163
7465
|
if (responders.length === 0) {
|
|
7466
|
+
const inquiryMeta = {
|
|
7467
|
+
inquiry,
|
|
7468
|
+
isMetaInquiry,
|
|
7469
|
+
totalResponders: allResponders.length,
|
|
7470
|
+
eligibleResponders: 0,
|
|
7471
|
+
filteredOutResponders: allResponders.length,
|
|
7472
|
+
responded: 0,
|
|
7473
|
+
failed: 0,
|
|
7474
|
+
timedOut: 0,
|
|
7475
|
+
pending: 0,
|
|
7476
|
+
durationMs: 0,
|
|
7477
|
+
responders: []
|
|
7478
|
+
};
|
|
7479
|
+
if (options.requireComplete) {
|
|
7480
|
+
throw {
|
|
7481
|
+
__inquiryMeta: inquiryMeta,
|
|
7482
|
+
__error: `Inquiry '${inquiry}' had no eligible responders`,
|
|
7483
|
+
errored: true
|
|
7484
|
+
};
|
|
7485
|
+
}
|
|
7164
7486
|
return {
|
|
7165
|
-
__inquiryMeta:
|
|
7166
|
-
inquiry,
|
|
7167
|
-
isMetaInquiry,
|
|
7168
|
-
totalResponders: allResponders.length,
|
|
7169
|
-
eligibleResponders: 0,
|
|
7170
|
-
filteredOutResponders: allResponders.length,
|
|
7171
|
-
responded: 0,
|
|
7172
|
-
failed: 0,
|
|
7173
|
-
timedOut: 0,
|
|
7174
|
-
pending: 0,
|
|
7175
|
-
durationMs: 0,
|
|
7176
|
-
responders: []
|
|
7177
|
-
}
|
|
7487
|
+
__inquiryMeta: inquiryMeta
|
|
7178
7488
|
};
|
|
7179
7489
|
}
|
|
7180
7490
|
responders.sort(this.compareInquiryResponders.bind(this));
|
|
@@ -7861,6 +8171,12 @@ var CadenzaService = class {
|
|
|
7861
8171
|
displayName: options.displayName ?? "",
|
|
7862
8172
|
isMeta: options.isMeta
|
|
7863
8173
|
},
|
|
8174
|
+
__registrationData: {
|
|
8175
|
+
name: serviceName,
|
|
8176
|
+
description,
|
|
8177
|
+
displayName: options.displayName ?? "",
|
|
8178
|
+
isMeta: options.isMeta
|
|
8179
|
+
},
|
|
7864
8180
|
__serviceName: serviceName,
|
|
7865
8181
|
__serviceInstanceId: serviceId,
|
|
7866
8182
|
__port: options.port,
|
|
@@ -7913,6 +8229,16 @@ var CadenzaService = class {
|
|
|
7913
8229
|
is_blocked: false,
|
|
7914
8230
|
health: {}
|
|
7915
8231
|
},
|
|
8232
|
+
__registrationData: {
|
|
8233
|
+
uuid: serviceId,
|
|
8234
|
+
process_pid: 1,
|
|
8235
|
+
service_name: serviceName,
|
|
8236
|
+
is_frontend: true,
|
|
8237
|
+
is_active: true,
|
|
8238
|
+
is_non_responsive: false,
|
|
8239
|
+
is_blocked: false,
|
|
8240
|
+
health: {}
|
|
8241
|
+
},
|
|
7916
8242
|
__transportData: [],
|
|
7917
8243
|
__serviceName: serviceName,
|
|
7918
8244
|
__serviceInstanceId: serviceId,
|