@cadenza.io/core 3.8.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);
@@ -1802,11 +1835,12 @@ var Task = class extends SignalEmitter {
1802
1835
  * @param context - The GraphContext to validate and execute.
1803
1836
  * @param emit
1804
1837
  * @param progressCallback - Callback for progress updates.
1838
+ * @param nodeData
1805
1839
  * @returns TaskResult from the taskFunction or error object on validation failure.
1806
1840
  * @edge If validateInputContext is true, validates context; on failure, emits 'meta.task.validationFailed' with detailed errors.
1807
1841
  * @edge If validateOutputContext is true, validates output; on failure, emits 'meta.task.outputValidationFailed' with detailed errors.
1808
1842
  */
1809
- execute(context, emit, progressCallback) {
1843
+ execute(context, emit, progressCallback, nodeData) {
1810
1844
  return this.taskFunction(
1811
1845
  this.isMeta ? context.getClonedFullContext() : context.getClonedContext(),
1812
1846
  emit,
@@ -2624,8 +2658,8 @@ var EphemeralTask = class extends Task {
2624
2658
  this.once = once;
2625
2659
  this.condition = condition;
2626
2660
  }
2627
- execute(context, emit, progressCallback) {
2628
- const result = super.execute(context, emit, progressCallback);
2661
+ execute(context, emit, progressCallback, nodeData) {
2662
+ const result = super.execute(context, emit, progressCallback, nodeData);
2629
2663
  if (this.once || this.condition(result)) {
2630
2664
  this.destroy();
2631
2665
  }