@cadenza.io/core 3.7.0 → 3.9.0

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
@@ -219,10 +219,25 @@ var SignalBroker = class _SignalBroker {
219
219
  }
220
220
  executeListener(signal, context) {
221
221
  const obs = this.signalObservers.get(signal);
222
+ if (!obs || obs.tasks.size === 0) {
223
+ return false;
224
+ }
222
225
  const isMeta = signal.startsWith("meta");
223
- const runner = isMeta ? this.metaRunner : this.runner;
224
- if (obs && obs.tasks.size && runner) {
225
- obs.fn(runner, Array.from(obs.tasks), context);
226
+ if (!isMeta) {
227
+ const tasks = [];
228
+ const metaTasks = [];
229
+ obs.tasks.forEach(
230
+ (task) => task.isMeta ? metaTasks.push(task) : tasks.push(task)
231
+ );
232
+ if (tasks.length && this.runner) {
233
+ obs.fn(this.runner, tasks, context);
234
+ }
235
+ if (metaTasks.length && this.metaRunner) {
236
+ obs.fn(this.metaRunner, metaTasks, context);
237
+ }
238
+ return true;
239
+ } else if (this.metaRunner) {
240
+ obs.fn(this.metaRunner, Array.from(obs.tasks), context);
226
241
  return true;
227
242
  }
228
243
  return false;
@@ -801,6 +816,23 @@ var GraphNode = class _GraphNode extends SignalEmitter {
801
816
  }
802
817
  });
803
818
  });
819
+ if (context.__previousTaskExecutionId) {
820
+ this.emitMetricsWithMetadata(
821
+ "meta.node.detected_previous_task_execution",
822
+ {
823
+ data: {
824
+ taskExecutionId: this.id,
825
+ previousTaskExecutionId: context.__previousTaskExecutionId
826
+ },
827
+ filter: {
828
+ taskName: this.task.name,
829
+ taskVersion: this.task.version
830
+ },
831
+ ...context
832
+ }
833
+ );
834
+ context.__previousTaskExecutionId = null;
835
+ }
804
836
  if (context.__signalEmission?.consumed === false && (!this.isMeta() || this.debug)) {
805
837
  this.emitMetricsWithMetadata("meta.node.consumed_signal", {
806
838
  data: {
@@ -946,7 +978,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
946
978
  const result = this.task.execute(
947
979
  this.context,
948
980
  this.emitWithMetadata.bind(this),
949
- this.onProgress.bind(this)
981
+ this.onProgress.bind(this),
982
+ { nodeId: this.id, routineExecId: this.routineExecId }
950
983
  );
951
984
  if (result?.errored || result?.failed) {
952
985
  return this.retry(result);
@@ -978,9 +1011,6 @@ var GraphNode = class _GraphNode extends SignalEmitter {
978
1011
  };
979
1012
  }
980
1013
  this.emit(signal, data);
981
- if (!this.task.emitsSignals.has(signal)) {
982
- this.task.attachSignal(signal);
983
- }
984
1014
  }
985
1015
  emitMetricsWithMetadata(signal, data) {
986
1016
  if (!this.task?.isHidden) {
@@ -998,9 +1028,6 @@ var GraphNode = class _GraphNode extends SignalEmitter {
998
1028
  };
999
1029
  }
1000
1030
  this.emitMetrics(signal, data);
1001
- if (!this.task.emitsSignals.has(signal)) {
1002
- this.task.attachSignal(signal);
1003
- }
1004
1031
  }
1005
1032
  onProgress(progress) {
1006
1033
  progress = Math.min(Math.max(0, progress), 1);
@@ -1808,11 +1835,12 @@ var Task = class extends SignalEmitter {
1808
1835
  * @param context - The GraphContext to validate and execute.
1809
1836
  * @param emit
1810
1837
  * @param progressCallback - Callback for progress updates.
1838
+ * @param nodeData
1811
1839
  * @returns TaskResult from the taskFunction or error object on validation failure.
1812
1840
  * @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
1813
1841
  * @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
1814
1842
  */
1815
- execute(context, emit, progressCallback) {
1843
+ execute(context, emit, progressCallback, nodeData) {
1816
1844
  return this.taskFunction(
1817
1845
  this.isMeta ? context.getClonedFullContext() : context.getClonedContext(),
1818
1846
  emit,
@@ -2630,8 +2658,8 @@ var EphemeralTask = class extends Task {
2630
2658
  this.once = once;
2631
2659
  this.condition = condition;
2632
2660
  }
2633
- execute(context, emit, progressCallback) {
2634
- const result = super.execute(context, emit, progressCallback);
2661
+ execute(context, emit, progressCallback, nodeData) {
2662
+ const result = super.execute(context, emit, progressCallback, nodeData);
2635
2663
  if (this.once || this.condition(result)) {
2636
2664
  this.destroy();
2637
2665
  }