@cadenza.io/service 2.17.48 → 2.17.50

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.
@@ -6250,6 +6250,17 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6250
6250
  CadenzaService.createMetaTask(
6251
6251
  `Log prepared graph sync insert execution for ${tableName}`,
6252
6252
  (ctx) => {
6253
+ if (tableName === "task") {
6254
+ if (!shouldDebugTaskSyncPayload(ctx)) {
6255
+ return ctx;
6256
+ }
6257
+ logSyncDebug("insert_prepare", {
6258
+ tableName,
6259
+ targetTaskName: targetTask.name,
6260
+ payload: buildTaskSyncDebugPayload(ctx)
6261
+ });
6262
+ return ctx;
6263
+ }
6253
6264
  logSyncDebug("insert_prepare", {
6254
6265
  tableName,
6255
6266
  targetTaskName: targetTask.name,
@@ -6282,12 +6293,23 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6282
6293
  queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : originalQueryData
6283
6294
  };
6284
6295
  if (debugTable) {
6285
- logSyncDebug("insert_finalize", {
6286
- tableName,
6287
- targetTaskName: targetTask.name,
6288
- success: didSyncInsertSucceed(normalizedContext),
6289
- ctx: normalizedContext
6290
- });
6296
+ if (tableName === "task") {
6297
+ if (shouldDebugTaskSyncPayload(normalizedContext)) {
6298
+ logSyncDebug("insert_finalize", {
6299
+ tableName,
6300
+ targetTaskName: targetTask.name,
6301
+ success: didSyncInsertSucceed(normalizedContext),
6302
+ payload: buildTaskSyncDebugPayload(normalizedContext)
6303
+ });
6304
+ }
6305
+ } else {
6306
+ logSyncDebug("insert_finalize", {
6307
+ tableName,
6308
+ targetTaskName: targetTask.name,
6309
+ success: didSyncInsertSucceed(normalizedContext),
6310
+ ctx: normalizedContext
6311
+ });
6312
+ }
6291
6313
  }
6292
6314
  pendingResolverContexts.delete(ctx.__resolverRequestId);
6293
6315
  emit(executionResolvedSignal, normalizedContext);
@@ -6305,11 +6327,21 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6305
6327
  CadenzaService.createMetaTask(
6306
6328
  `Log failed graph sync insert execution for ${tableName}`,
6307
6329
  (ctx) => {
6308
- logSyncDebug("insert_failed", {
6309
- tableName,
6310
- targetTaskName: targetTask.name,
6311
- ctx
6312
- });
6330
+ if (tableName === "task") {
6331
+ if (shouldDebugTaskSyncPayload(ctx)) {
6332
+ logSyncDebug("insert_failed", {
6333
+ tableName,
6334
+ targetTaskName: targetTask.name,
6335
+ payload: buildTaskSyncDebugPayload(ctx)
6336
+ });
6337
+ }
6338
+ } else {
6339
+ logSyncDebug("insert_failed", {
6340
+ tableName,
6341
+ targetTaskName: targetTask.name,
6342
+ ctx
6343
+ });
6344
+ }
6313
6345
  if (typeof ctx.__resolverRequestId === "string") {
6314
6346
  pendingResolverContexts.delete(ctx.__resolverRequestId);
6315
6347
  }
@@ -6475,6 +6507,37 @@ function summarizeSyncDebugValue(value, depth = 0) {
6475
6507
  function logSyncDebug(event, payload) {
6476
6508
  console.log(`${SYNC_DEBUG_PREFIX} ${event}`, summarizeSyncDebugValue(payload));
6477
6509
  }
6510
+ function buildTaskSyncDebugPayload(ctx) {
6511
+ const data = ctx.data && typeof ctx.data === "object" ? ctx.data : {};
6512
+ const queryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {};
6513
+ const queryDataData = queryData.data && typeof queryData.data === "object" ? queryData.data : {};
6514
+ const taskPayload = Object.keys(queryDataData).length > 0 ? queryDataData : data;
6515
+ const functionString = typeof taskPayload.functionString === "string" ? taskPayload.functionString : typeof taskPayload.function_string === "string" ? taskPayload.function_string : void 0;
6516
+ const tagIdGetter = typeof taskPayload.tagIdGetter === "string" ? taskPayload.tagIdGetter : typeof taskPayload.tag_id_getter === "string" ? taskPayload.tag_id_getter : void 0;
6517
+ const signals = taskPayload.signals && typeof taskPayload.signals === "object" ? taskPayload.signals : {};
6518
+ const intents = taskPayload.intents && typeof taskPayload.intents === "object" ? taskPayload.intents : {};
6519
+ return {
6520
+ taskName: taskPayload.name ?? taskPayload.taskName ?? taskPayload.task_name ?? ctx.__taskName ?? null,
6521
+ serviceName: taskPayload.service_name ?? taskPayload.serviceName ?? ctx.__syncServiceName ?? null,
6522
+ functionStringLength: functionString?.length ?? null,
6523
+ tagIdGetterLength: tagIdGetter?.length ?? null,
6524
+ isMeta: taskPayload.isMeta ?? taskPayload.is_meta ?? null,
6525
+ isSubMeta: taskPayload.isSubMeta ?? taskPayload.is_sub_meta ?? null,
6526
+ isHidden: taskPayload.isHidden ?? taskPayload.is_hidden ?? null,
6527
+ signalsEmitsCount: Array.isArray(signals.emits) ? signals.emits.length : null,
6528
+ signalsObservedCount: Array.isArray(signals.observed) ? signals.observed.length : null,
6529
+ intentHandlesCount: Array.isArray(intents.handles) ? intents.handles.length : null,
6530
+ intentInquiresCount: Array.isArray(intents.inquires) ? intents.inquires.length : null,
6531
+ rowCount: ctx.rowCount ?? null,
6532
+ errored: ctx.errored ?? false,
6533
+ success: ctx.__success ?? null,
6534
+ error: ctx.__error ?? null
6535
+ };
6536
+ }
6537
+ function shouldDebugTaskSyncPayload(ctx) {
6538
+ const payload = buildTaskSyncDebugPayload(ctx);
6539
+ return shouldDebugSyncTaskName(payload.taskName);
6540
+ }
6478
6541
  function resolveSyncQueryRows(ctx, tableName) {
6479
6542
  const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
6480
6543
  const rows = ctx?.[resultKey];
@@ -6503,6 +6566,31 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
6503
6566
  }
6504
6567
  ).then(targetTask);
6505
6568
  }
6569
+ function getRegistrableTasks() {
6570
+ return Array.from(CadenzaService.registry.tasks.values()).filter(
6571
+ (task) => task.register && !task.isHidden
6572
+ );
6573
+ }
6574
+ function getRegistrableRoutines() {
6575
+ return Array.from(CadenzaService.registry.routines.values());
6576
+ }
6577
+ function getRegistrableSignalObservers() {
6578
+ const signalObservers = CadenzaService.signalBroker.signalObservers;
6579
+ return signalObservers ? Array.from(signalObservers.values()) : [];
6580
+ }
6581
+ function getRegistrableIntentNames() {
6582
+ return Array.from(CadenzaService.inquiryBroker.intents.values()).map((intent) => buildIntentRegistryData(intent)).filter(
6583
+ (intentDefinition) => intentDefinition !== null
6584
+ ).map((intentDefinition) => String(intentDefinition.name));
6585
+ }
6586
+ function buildActorRegistrationKey(actor, serviceName) {
6587
+ const data = buildActorRegistrationData(actor);
6588
+ const name = typeof data.name === "string" && data.name.trim().length > 0 ? data.name.trim() : "";
6589
+ if (!name) {
6590
+ return null;
6591
+ }
6592
+ return `${name}|${data.version}|${serviceName}`;
6593
+ }
6506
6594
  var GraphSyncController = class _GraphSyncController {
6507
6595
  constructor() {
6508
6596
  this.registeredActors = /* @__PURE__ */ new Set();
@@ -6627,22 +6715,158 @@ var GraphSyncController = class _GraphSyncController {
6627
6715
  {},
6628
6716
  { concurrency: 10 }
6629
6717
  );
6718
+ const finalizeTaskSync = (emit, ctx) => {
6719
+ const pendingTasks = getRegistrableTasks().filter((task) => !task.registered);
6720
+ if (pendingTasks.length > 0) {
6721
+ this.tasksSynced = false;
6722
+ return false;
6723
+ }
6724
+ const shouldEmit = !this.tasksSynced;
6725
+ this.tasksSynced = true;
6726
+ if (shouldEmit) {
6727
+ emit("meta.sync_controller.synced_tasks", {
6728
+ __syncing: true,
6729
+ ...ctx
6730
+ });
6731
+ }
6732
+ return true;
6733
+ };
6734
+ const finalizeRoutineSync = (emit, ctx) => {
6735
+ const pendingRoutines = getRegistrableRoutines().filter(
6736
+ (routine) => !routine.registered
6737
+ );
6738
+ if (pendingRoutines.length > 0) {
6739
+ this.routinesSynced = false;
6740
+ return false;
6741
+ }
6742
+ const shouldEmit = !this.routinesSynced;
6743
+ this.routinesSynced = true;
6744
+ if (shouldEmit) {
6745
+ emit("meta.sync_controller.synced_routines", {
6746
+ __syncing: true,
6747
+ ...ctx
6748
+ });
6749
+ }
6750
+ return true;
6751
+ };
6752
+ const finalizeSignalSync = (emit, ctx) => {
6753
+ const pendingSignals = getRegistrableSignalObservers().filter(
6754
+ (observer) => observer?.registered !== true
6755
+ );
6756
+ if (pendingSignals.length > 0) {
6757
+ this.signalsSynced = false;
6758
+ return false;
6759
+ }
6760
+ const shouldEmit = !this.signalsSynced;
6761
+ this.signalsSynced = true;
6762
+ if (shouldEmit) {
6763
+ emit("meta.sync_controller.synced_signals", {
6764
+ __syncing: true,
6765
+ ...ctx
6766
+ });
6767
+ }
6768
+ return true;
6769
+ };
6770
+ const finalizeIntentSync = (emit, ctx) => {
6771
+ const pendingIntentNames = getRegistrableIntentNames().filter(
6772
+ (intentName) => !this.registeredIntentDefinitions.has(intentName)
6773
+ );
6774
+ if (pendingIntentNames.length > 0) {
6775
+ this.intentsSynced = false;
6776
+ return false;
6777
+ }
6778
+ const shouldEmit = !this.intentsSynced;
6779
+ this.intentsSynced = true;
6780
+ if (shouldEmit) {
6781
+ emit("meta.sync_controller.synced_intents", {
6782
+ __syncing: true,
6783
+ ...ctx
6784
+ });
6785
+ }
6786
+ return true;
6787
+ };
6788
+ const finalizeActorSync = (emit, ctx) => {
6789
+ const syncServiceName = resolveSyncServiceName();
6790
+ if (!syncServiceName) {
6791
+ this.actorsSynced = false;
6792
+ return false;
6793
+ }
6794
+ const pendingActorKeys = CadenzaService.getAllActors().map((actor) => buildActorRegistrationKey(actor, syncServiceName)).filter((registrationKey) => Boolean(registrationKey)).filter((registrationKey) => !this.registeredActors.has(registrationKey));
6795
+ if (pendingActorKeys.length > 0) {
6796
+ this.actorsSynced = false;
6797
+ return false;
6798
+ }
6799
+ const shouldEmit = !this.actorsSynced;
6800
+ this.actorsSynced = true;
6801
+ if (shouldEmit) {
6802
+ emit("meta.sync_controller.synced_actors", {
6803
+ __syncing: true,
6804
+ ...ctx
6805
+ });
6806
+ }
6807
+ return true;
6808
+ };
6809
+ const gatherTaskRegistrationTask = CadenzaService.createUniqueMetaTask(
6810
+ "Gather task registration",
6811
+ (ctx, emit) => finalizeTaskSync(emit, ctx),
6812
+ "Completes task registration when all registrable tasks are marked registered.",
6813
+ {
6814
+ register: false,
6815
+ isHidden: true
6816
+ }
6817
+ );
6818
+ const gatherRoutineRegistrationTask = CadenzaService.createUniqueMetaTask(
6819
+ "Gather routine registration",
6820
+ (ctx, emit) => finalizeRoutineSync(emit, ctx),
6821
+ "Completes routine registration when all registrable routines are marked registered.",
6822
+ {
6823
+ register: false,
6824
+ isHidden: true
6825
+ }
6826
+ );
6827
+ const gatherSignalRegistrationTask = CadenzaService.createUniqueMetaTask(
6828
+ "Gather signal registration",
6829
+ (ctx, emit) => finalizeSignalSync(emit, ctx),
6830
+ "Completes signal registration when all signal observers are marked registered.",
6831
+ {
6832
+ register: false,
6833
+ isHidden: true
6834
+ }
6835
+ );
6836
+ const gatherIntentRegistrationTask = CadenzaService.createUniqueMetaTask(
6837
+ "Gather intent registration",
6838
+ (ctx, emit) => finalizeIntentSync(emit, ctx),
6839
+ "Completes intent registration when all registrable intents are marked registered.",
6840
+ {
6841
+ register: false,
6842
+ isHidden: true
6843
+ }
6844
+ );
6845
+ const gatherActorRegistrationTask = CadenzaService.createUniqueMetaTask(
6846
+ "Gather actor registration",
6847
+ (ctx, emit) => finalizeActorSync(emit, ctx),
6848
+ "Completes actor registration when all registrable actors are marked registered.",
6849
+ {
6850
+ register: false,
6851
+ isHidden: true
6852
+ }
6853
+ );
6630
6854
  this.splitRoutinesTask = CadenzaService.createMetaTask(
6631
6855
  "Split routines for registration",
6632
- (ctx, emit) => {
6856
+ function* (ctx) {
6633
6857
  const { routines } = ctx;
6634
- if (!routines) return false;
6858
+ if (!routines) return;
6635
6859
  const serviceName2 = resolveSyncServiceName();
6636
6860
  if (!serviceName2) {
6637
- return false;
6861
+ return;
6638
6862
  }
6639
6863
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
6640
6864
  delayMs: 2e3
6641
6865
  });
6642
- let emittedCount = 0;
6643
6866
  for (const routine of routines) {
6644
6867
  if (routine.registered) continue;
6645
- emit("meta.sync_controller.routine_registration_split", {
6868
+ this.routinesSynced = false;
6869
+ yield {
6646
6870
  __syncing: ctx.__syncing,
6647
6871
  data: {
6648
6872
  name: routine.name,
@@ -6652,13 +6876,11 @@ var GraphSyncController = class _GraphSyncController {
6652
6876
  isMeta: routine.isMeta
6653
6877
  },
6654
6878
  __routineName: routine.name
6655
- });
6656
- emittedCount += 1;
6879
+ };
6657
6880
  }
6658
- return emittedCount > 0;
6659
- }
6881
+ }.bind(this)
6660
6882
  );
6661
- CadenzaService.createMetaTask("Process split routine registration", (ctx) => ctx).doOn("meta.sync_controller.routine_registration_split").then(
6883
+ this.splitRoutinesTask.then(
6662
6884
  resolveSyncInsertTask(
6663
6885
  this.isCadenzaDBReady,
6664
6886
  "routine",
@@ -6680,22 +6902,10 @@ var GraphSyncController = class _GraphSyncController {
6680
6902
  delayMs: 3e3
6681
6903
  });
6682
6904
  CadenzaService.getRoutine(ctx.__routineName).registered = true;
6683
- CadenzaService.debounce(
6684
- "meta.sync_controller.routine_registration_settled",
6685
- { __syncing: true },
6686
- 300
6687
- );
6688
6905
  return true;
6689
- })
6906
+ }).then(gatherRoutineRegistrationTask)
6690
6907
  )
6691
6908
  );
6692
- CadenzaService.createUniqueMetaTask(
6693
- "Gather routine registration",
6694
- () => {
6695
- this.routinesSynced = true;
6696
- return true;
6697
- }
6698
- ).doOn("meta.sync_controller.routine_registration_settled").emits("meta.sync_controller.synced_routines");
6699
6909
  this.splitTasksInRoutines = CadenzaService.createMetaTask(
6700
6910
  "Split tasks in routines",
6701
6911
  function* (ctx) {
@@ -6784,18 +6994,19 @@ var GraphSyncController = class _GraphSyncController {
6784
6994
  }
6785
6995
  this.splitSignalsTask = CadenzaService.createMetaTask(
6786
6996
  "Split signals for registration",
6787
- (ctx, emit) => {
6997
+ function* (ctx) {
6788
6998
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
6789
6999
  delayMs: 3e3
6790
7000
  });
6791
7001
  const { signals } = ctx;
6792
- if (!signals) return false;
7002
+ if (!signals) return;
6793
7003
  const filteredSignals = signals.filter(
6794
7004
  (signal) => !signal.data.registered
6795
7005
  ).map((signal) => signal.signal);
6796
7006
  for (const signal of filteredSignals) {
6797
7007
  const { isMeta, isGlobal, domain, action } = decomposeSignalName(signal);
6798
- emit("meta.sync_controller.signal_registration_split", {
7008
+ this.signalsSynced = false;
7009
+ yield {
6799
7010
  __syncing: ctx.__syncing,
6800
7011
  data: {
6801
7012
  name: signal,
@@ -6805,12 +7016,11 @@ var GraphSyncController = class _GraphSyncController {
6805
7016
  isMeta
6806
7017
  },
6807
7018
  __signal: signal
6808
- });
7019
+ };
6809
7020
  }
6810
- return filteredSignals.length > 0;
6811
- }
7021
+ }.bind(this)
6812
7022
  );
6813
- CadenzaService.createMetaTask("Process split signal registration", (ctx) => ctx).doOn("meta.sync_controller.signal_registration_split").then(
7023
+ this.splitSignalsTask.then(
6814
7024
  resolveSyncInsertTask(
6815
7025
  this.isCadenzaDBReady,
6816
7026
  "signal_registry",
@@ -6831,22 +7041,10 @@ var GraphSyncController = class _GraphSyncController {
6831
7041
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
6832
7042
  delayMs: 3e3
6833
7043
  });
6834
- CadenzaService.debounce(
6835
- "meta.sync_controller.signal_registration_settled",
6836
- { __syncing: true },
6837
- 300
6838
- );
6839
7044
  return { signalName: ctx.__signal };
6840
- }).then(CadenzaService.signalBroker.registerSignalTask)
7045
+ }).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask)
6841
7046
  )
6842
7047
  );
6843
- CadenzaService.createUniqueMetaTask(
6844
- "Gather signal registration",
6845
- () => {
6846
- this.signalsSynced = true;
6847
- return true;
6848
- }
6849
- ).doOn("meta.sync_controller.signal_registration_settled").emits("meta.sync_controller.synced_signals");
6850
7048
  this.splitTasksForRegistration = CadenzaService.createMetaTask(
6851
7049
  "Split tasks for registration",
6852
7050
  function* (ctx) {
@@ -6861,6 +7059,7 @@ var GraphSyncController = class _GraphSyncController {
6861
7059
  for (const task of tasks) {
6862
7060
  if (task.registered) continue;
6863
7061
  const { __functionString, __getTagCallback } = task.export();
7062
+ this.tasksSynced = false;
6864
7063
  if (shouldDebugSyncTaskName(task.name)) {
6865
7064
  logSyncDebug("task_registration_split", {
6866
7065
  taskName: task.name,
@@ -6869,6 +7068,8 @@ var GraphSyncController = class _GraphSyncController {
6869
7068
  register: task.register,
6870
7069
  registered: task.registered,
6871
7070
  hidden: task.hidden,
7071
+ exportFunctionLength: __functionString?.length ?? null,
7072
+ exportTagGetterLength: __getTagCallback?.length ?? null,
6872
7073
  observedSignals: Array.from(task.observedSignals),
6873
7074
  handledIntents: Array.from(task.handlesIntents)
6874
7075
  });
@@ -6909,7 +7110,7 @@ var GraphSyncController = class _GraphSyncController {
6909
7110
  __taskName: task.name
6910
7111
  };
6911
7112
  }
6912
- }
7113
+ }.bind(this)
6913
7114
  );
6914
7115
  const registerTaskTask = resolveSyncInsertTask(
6915
7116
  this.isCadenzaDBReady,
@@ -6943,13 +7144,8 @@ var GraphSyncController = class _GraphSyncController {
6943
7144
  ...ctx,
6944
7145
  task: CadenzaService.get(ctx.__taskName)
6945
7146
  });
6946
- CadenzaService.debounce(
6947
- "meta.sync_controller.task_registration_settled",
6948
- { __syncing: true },
6949
- 300
6950
- );
6951
7147
  return true;
6952
- })
7148
+ }).then(gatherTaskRegistrationTask)
6953
7149
  );
6954
7150
  if (registerTaskTask) {
6955
7151
  this.splitTasksForRegistration.then(registerTaskTask);
@@ -6982,13 +7178,6 @@ var GraphSyncController = class _GraphSyncController {
6982
7178
  isHidden: true
6983
7179
  }
6984
7180
  ).doOn("meta.task.created").then(this.splitTasksForRegistration);
6985
- CadenzaService.createUniqueMetaTask(
6986
- "Gather task registration",
6987
- () => {
6988
- this.tasksSynced = true;
6989
- return true;
6990
- }
6991
- ).doOn("meta.sync_controller.task_registration_settled").emits("meta.sync_controller.synced_tasks");
6992
7181
  this.splitActorsForRegistration = CadenzaService.createMetaTask(
6993
7182
  "Split actors for registration",
6994
7183
  function* (ctx) {
@@ -7012,6 +7201,7 @@ var GraphSyncController = class _GraphSyncController {
7012
7201
  if (this.registeredActors.has(registrationKey)) {
7013
7202
  continue;
7014
7203
  }
7204
+ this.actorsSynced = false;
7015
7205
  yield {
7016
7206
  data,
7017
7207
  __actorRegistrationKey: registrationKey
@@ -7040,22 +7230,10 @@ var GraphSyncController = class _GraphSyncController {
7040
7230
  delayMs: 3e3
7041
7231
  });
7042
7232
  this.registeredActors.add(ctx.__actorRegistrationKey);
7043
- CadenzaService.debounce(
7044
- "meta.sync_controller.actor_registration_settled",
7045
- { __syncing: true },
7046
- 300
7047
- );
7048
7233
  return true;
7049
- })
7234
+ }).then(gatherActorRegistrationTask)
7050
7235
  )
7051
7236
  );
7052
- CadenzaService.createUniqueMetaTask(
7053
- "Gather actor registration",
7054
- () => {
7055
- this.actorsSynced = true;
7056
- return true;
7057
- }
7058
- ).doOn("meta.sync_controller.actor_registration_settled").emits("meta.sync_controller.synced_actors");
7059
7237
  this.registerActorTaskMapTask = CadenzaService.createMetaTask(
7060
7238
  "Split actor task maps",
7061
7239
  function* (ctx) {
@@ -7202,12 +7380,11 @@ var GraphSyncController = class _GraphSyncController {
7202
7380
  );
7203
7381
  this.splitIntentsTask = CadenzaService.createMetaTask(
7204
7382
  "Split intents for registration",
7205
- function(ctx, emit) {
7383
+ function* (ctx) {
7206
7384
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
7207
7385
  delayMs: 3e3
7208
7386
  });
7209
7387
  const intents = Array.isArray(ctx.intents) ? ctx.intents : Array.from(CadenzaService.inquiryBroker.intents.values());
7210
- let emittedCount = 0;
7211
7388
  for (const intent of intents) {
7212
7389
  const intentData = buildIntentRegistryData(intent);
7213
7390
  if (!intentData) {
@@ -7216,17 +7393,16 @@ var GraphSyncController = class _GraphSyncController {
7216
7393
  if (this.registeredIntentDefinitions.has(intentData.name)) {
7217
7394
  continue;
7218
7395
  }
7219
- emit("meta.sync_controller.intent_registration_split", {
7396
+ this.intentsSynced = false;
7397
+ yield {
7220
7398
  __syncing: ctx.__syncing,
7221
7399
  data: intentData,
7222
7400
  __intentName: intentData.name
7223
- });
7224
- emittedCount += 1;
7401
+ };
7225
7402
  }
7226
- return emittedCount > 0;
7227
7403
  }.bind(this)
7228
7404
  );
7229
- CadenzaService.createMetaTask("Process split intent registration", (ctx) => ctx).doOn("meta.sync_controller.intent_registration_split").then(
7405
+ this.splitIntentsTask.then(
7230
7406
  insertIntentRegistryTask?.then(
7231
7407
  CadenzaService.createMetaTask("Record intent definition registration", (ctx) => {
7232
7408
  if (!didSyncInsertSucceed(ctx)) {
@@ -7236,22 +7412,10 @@ var GraphSyncController = class _GraphSyncController {
7236
7412
  delayMs: 3e3
7237
7413
  });
7238
7414
  this.registeredIntentDefinitions.add(ctx.__intentName);
7239
- CadenzaService.debounce(
7240
- "meta.sync_controller.intent_registration_settled",
7241
- { __syncing: true },
7242
- 300
7243
- );
7244
7415
  return true;
7245
- })
7416
+ }).then(gatherIntentRegistrationTask)
7246
7417
  )
7247
7418
  );
7248
- CadenzaService.createUniqueMetaTask(
7249
- "Gather intent registration",
7250
- () => {
7251
- this.intentsSynced = true;
7252
- return true;
7253
- }
7254
- ).doOn("meta.sync_controller.intent_registration_settled").emits("meta.sync_controller.synced_intents");
7255
7419
  const registerIntentTask = CadenzaService.createMetaTask(
7256
7420
  "Record intent registration",
7257
7421
  (ctx) => {
@@ -7545,15 +7709,11 @@ var GraphSyncController = class _GraphSyncController {
7545
7709
  __authoritativeReconciliation: true
7546
7710
  });
7547
7711
  }
7548
- if (authoritativeTasks.length > 0) {
7549
- CadenzaService.debounce(
7550
- "meta.sync_controller.task_registration_settled",
7551
- {
7552
- __syncing: true,
7553
- __authoritativeReconciliation: true
7554
- },
7555
- 300
7556
- );
7712
+ if (authoritativeTasks.length > 0 || changed) {
7713
+ finalizeTaskSync(emit, {
7714
+ ...ctx,
7715
+ __authoritativeReconciliation: true
7716
+ });
7557
7717
  }
7558
7718
  return changed;
7559
7719
  },
@@ -7565,7 +7725,7 @@ var GraphSyncController = class _GraphSyncController {
7565
7725
  );
7566
7726
  const reconcileRoutineRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
7567
7727
  "Reconcile routine registration from authority",
7568
- (ctx) => {
7728
+ (ctx, emit) => {
7569
7729
  const authoritativeRoutines = resolveSyncQueryRows(ctx, "routine");
7570
7730
  let changed = false;
7571
7731
  for (const row of authoritativeRoutines) {
@@ -7580,15 +7740,11 @@ var GraphSyncController = class _GraphSyncController {
7580
7740
  routine.registered = true;
7581
7741
  changed = true;
7582
7742
  }
7583
- if (authoritativeRoutines.length > 0) {
7584
- CadenzaService.debounce(
7585
- "meta.sync_controller.routine_registration_settled",
7586
- {
7587
- __syncing: true,
7588
- __authoritativeReconciliation: true
7589
- },
7590
- 300
7591
- );
7743
+ if (authoritativeRoutines.length > 0 || changed) {
7744
+ finalizeRoutineSync(emit, {
7745
+ ...ctx,
7746
+ __authoritativeReconciliation: true
7747
+ });
7592
7748
  }
7593
7749
  return changed;
7594
7750
  },
@@ -7600,7 +7756,7 @@ var GraphSyncController = class _GraphSyncController {
7600
7756
  );
7601
7757
  const reconcileSignalRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
7602
7758
  "Reconcile signal registration from authority",
7603
- (ctx) => {
7759
+ (ctx, emit) => {
7604
7760
  const authoritativeSignals = resolveSyncQueryRows(ctx, "signal_registry");
7605
7761
  const signalObservers = CadenzaService.signalBroker.signalObservers;
7606
7762
  let changed = false;
@@ -7616,15 +7772,11 @@ var GraphSyncController = class _GraphSyncController {
7616
7772
  observer.registered = true;
7617
7773
  changed = true;
7618
7774
  }
7619
- if (authoritativeSignals.length > 0) {
7620
- CadenzaService.debounce(
7621
- "meta.sync_controller.signal_registration_settled",
7622
- {
7623
- __syncing: true,
7624
- __authoritativeReconciliation: true
7625
- },
7626
- 300
7627
- );
7775
+ if (authoritativeSignals.length > 0 || changed) {
7776
+ finalizeSignalSync(emit, {
7777
+ ...ctx,
7778
+ __authoritativeReconciliation: true
7779
+ });
7628
7780
  }
7629
7781
  return changed;
7630
7782
  },
@@ -7636,7 +7788,7 @@ var GraphSyncController = class _GraphSyncController {
7636
7788
  );
7637
7789
  const reconcileIntentRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
7638
7790
  "Reconcile intent registration from authority",
7639
- (ctx) => {
7791
+ (ctx, emit) => {
7640
7792
  const authoritativeIntents = resolveSyncQueryRows(ctx, "intent_registry");
7641
7793
  let changed = false;
7642
7794
  for (const row of authoritativeIntents) {
@@ -7650,15 +7802,11 @@ var GraphSyncController = class _GraphSyncController {
7650
7802
  this.registeredIntentDefinitions.add(intentName);
7651
7803
  changed = true;
7652
7804
  }
7653
- if (authoritativeIntents.length > 0) {
7654
- CadenzaService.debounce(
7655
- "meta.sync_controller.intent_registration_settled",
7656
- {
7657
- __syncing: true,
7658
- __authoritativeReconciliation: true
7659
- },
7660
- 300
7661
- );
7805
+ if (authoritativeIntents.length > 0 || changed) {
7806
+ finalizeIntentSync(emit, {
7807
+ ...ctx,
7808
+ __authoritativeReconciliation: true
7809
+ });
7662
7810
  }
7663
7811
  return changed;
7664
7812
  },