@cadenza.io/service 2.17.45 → 2.17.47

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/index.mjs CHANGED
@@ -8780,6 +8780,7 @@ var AUTHORITY_QUERY_RESULT_KEYS = {
8780
8780
  signal_registry: "signalRegistrys",
8781
8781
  intent_registry: "intentRegistrys"
8782
8782
  };
8783
+ var EARLY_SYNC_REQUEST_DELAYS_MS = [2e3, 1e4, 3e4];
8783
8784
  function resolveSyncQueryRows(ctx, tableName) {
8784
8785
  const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
8785
8786
  const rows = ctx?.[resultKey];
@@ -9230,6 +9231,24 @@ var GraphSyncController = class _GraphSyncController {
9230
9231
  if (registerTaskTask) {
9231
9232
  this.splitTasksForRegistration.then(registerTaskTask);
9232
9233
  }
9234
+ CadenzaService.createMetaTask(
9235
+ "Prepare created task for immediate sync",
9236
+ (ctx) => {
9237
+ const task = ctx.taskInstance ?? (ctx.data?.name ? CadenzaService.get(String(ctx.data.name)) : void 0);
9238
+ if (!task || task.hidden || !task.register || task.registered) {
9239
+ return false;
9240
+ }
9241
+ return {
9242
+ __syncing: true,
9243
+ tasks: [task]
9244
+ };
9245
+ },
9246
+ "Schedules newly created tasks into the graph sync registration flow without waiting for the next periodic tick.",
9247
+ {
9248
+ register: false,
9249
+ isHidden: true
9250
+ }
9251
+ ).doOn("meta.task.created").then(this.splitTasksForRegistration);
9233
9252
  CadenzaService.createUniqueMetaTask(
9234
9253
  "Gather task registration",
9235
9254
  () => {
@@ -10018,11 +10037,13 @@ var GraphSyncController = class _GraphSyncController {
10018
10037
  ).doOn(...authoritativeRegistrationTriggers).then(authoritativeIntentReconciliationGraph);
10019
10038
  CadenzaService.signalBroker.getSignalsTask.clone().doOn(
10020
10039
  "meta.sync_controller.sync_tick",
10021
- "meta.service_registry.initial_sync_complete"
10040
+ "meta.service_registry.initial_sync_complete",
10041
+ "meta.sync_requested"
10022
10042
  ).then(this.splitSignalsTask);
10023
10043
  CadenzaService.registry.getAllTasks.clone().doOn(
10024
10044
  "meta.sync_controller.sync_tick",
10025
- "meta.sync_controller.synced_signals"
10045
+ "meta.sync_controller.synced_signals",
10046
+ "meta.sync_requested"
10026
10047
  ).then(this.splitTasksForRegistration);
10027
10048
  CadenzaService.createMetaTask("Get all intents", (ctx) => {
10028
10049
  return {
@@ -10031,11 +10052,13 @@ var GraphSyncController = class _GraphSyncController {
10031
10052
  };
10032
10053
  }).doOn(
10033
10054
  "meta.sync_controller.sync_tick",
10034
- "meta.service_registry.initial_sync_complete"
10055
+ "meta.service_registry.initial_sync_complete",
10056
+ "meta.sync_requested"
10035
10057
  ).then(this.splitIntentsTask);
10036
10058
  CadenzaService.registry.getAllRoutines.clone().doOn(
10037
10059
  "meta.sync_controller.sync_tick",
10038
- "meta.service_registry.initial_sync_complete"
10060
+ "meta.service_registry.initial_sync_complete",
10061
+ "meta.sync_requested"
10039
10062
  ).then(this.splitRoutinesTask);
10040
10063
  CadenzaService.createMetaTask("Get all actors", (ctx) => {
10041
10064
  return {
@@ -10044,7 +10067,8 @@ var GraphSyncController = class _GraphSyncController {
10044
10067
  };
10045
10068
  }).doOn(
10046
10069
  "meta.sync_controller.sync_tick",
10047
- "meta.service_registry.initial_sync_complete"
10070
+ "meta.service_registry.initial_sync_complete",
10071
+ "meta.sync_requested"
10048
10072
  ).then(this.splitActorsForRegistration);
10049
10073
  CadenzaService.createMetaTask("Get registered task for task graph sync", (ctx) => {
10050
10074
  const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
@@ -10061,7 +10085,8 @@ var GraphSyncController = class _GraphSyncController {
10061
10085
  );
10062
10086
  CadenzaService.registry.doForEachTask.clone().doOn(
10063
10087
  "meta.sync_controller.synced_signals",
10064
- "meta.sync_controller.synced_tasks"
10088
+ "meta.sync_controller.synced_tasks",
10089
+ "meta.sync_requested"
10065
10090
  ).then(
10066
10091
  CadenzaService.createMetaTask(
10067
10092
  "Ensure signal and task sync ready",
@@ -10095,7 +10120,8 @@ var GraphSyncController = class _GraphSyncController {
10095
10120
  );
10096
10121
  CadenzaService.registry.doForEachTask.clone().doOn(
10097
10122
  "meta.sync_controller.synced_intents",
10098
- "meta.sync_controller.synced_tasks"
10123
+ "meta.sync_controller.synced_tasks",
10124
+ "meta.sync_requested"
10099
10125
  ).then(
10100
10126
  CadenzaService.createMetaTask(
10101
10127
  "Ensure intent and task sync ready",
@@ -10129,7 +10155,8 @@ var GraphSyncController = class _GraphSyncController {
10129
10155
  );
10130
10156
  CadenzaService.registry.doForEachTask.clone().doOn(
10131
10157
  "meta.sync_controller.synced_actors",
10132
- "meta.sync_controller.synced_tasks"
10158
+ "meta.sync_controller.synced_tasks",
10159
+ "meta.sync_requested"
10133
10160
  ).then(this.registerActorTaskMapTask);
10134
10161
  CadenzaService.createMetaTask("Get registered task for actor sync", (ctx) => {
10135
10162
  const task = ctx.task ?? (ctx.__taskName ? CadenzaService.get(ctx.__taskName) : void 0);
@@ -10154,7 +10181,7 @@ var GraphSyncController = class _GraphSyncController {
10154
10181
  CadenzaService.registry.getAllRoutines.clone().doOn(
10155
10182
  "meta.sync_controller.synced_routines",
10156
10183
  "meta.sync_controller.synced_tasks",
10157
- "meta.sync_controller.task_registered"
10184
+ "meta.sync_requested"
10158
10185
  ).then(
10159
10186
  CadenzaService.createMetaTask(
10160
10187
  "Ensure routine and task sync ready",
@@ -10198,7 +10225,9 @@ var GraphSyncController = class _GraphSyncController {
10198
10225
  { __syncing: true },
10199
10226
  250
10200
10227
  );
10201
- CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
10228
+ for (const delayMs of EARLY_SYNC_REQUEST_DELAYS_MS) {
10229
+ CadenzaService.schedule("meta.sync_requested", { __syncing: true }, delayMs);
10230
+ }
10202
10231
  }
10203
10232
  }
10204
10233
  };