@usearazzo/runner 1.0.1-alpha.37 → 1.0.1-alpha.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usearazzo/runner",
3
- "version": "1.0.1-alpha.37",
3
+ "version": "1.0.1-alpha.39",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -112,8 +112,8 @@
112
112
  "@swaggerexpert/json-pointer": "^3.0.3",
113
113
  "@swaggerexpert/jsonpath": "^4.1.0",
114
114
  "@swaggerexpert/media-types": "^1.0.3",
115
- "@usearazzo/parser": "1.0.1-alpha.37",
116
- "@usearazzo/resolver": "1.0.1-alpha.37",
115
+ "@usearazzo/parser": "1.0.1-alpha.39",
116
+ "@usearazzo/resolver": "1.0.1-alpha.39",
117
117
  "@xmldom/xmldom": "^0.9.12",
118
118
  "fontoxpath": "^3.34.0",
119
119
  "ramda": "^0.32.0",
@@ -148,5 +148,5 @@
148
148
  "@opentelemetry/sdk-trace-base": "^2.12.0",
149
149
  "swagger-client": "^3.39.0"
150
150
  },
151
- "gitHead": "b725c4fbaa4066e4823e13efadbb0fd399f86e34"
151
+ "gitHead": "538aacec09d68c1f11ab2a384c83e3b633c5dd2c"
152
152
  }
@@ -35,7 +35,7 @@ class ExecutionError extends _ArazzoRunnerError.default {
35
35
  static InvalidWorkflowReference = 'invalid-workflow-reference';
36
36
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
37
37
  static MalformedDependsOn = 'malformed-dependsOn';
38
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
38
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
39
39
  static MalformedSteps = 'malformed-steps';
40
40
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
41
41
  static MissingOperation = 'missing-operation';
@@ -28,7 +28,7 @@ class ExecutionError extends ArazzoRunnerError {
28
28
  static InvalidWorkflowReference = 'invalid-workflow-reference';
29
29
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
30
30
  static MalformedDependsOn = 'malformed-dependsOn';
31
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
31
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
32
32
  static MalformedSteps = 'malformed-steps';
33
33
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
34
34
  static MissingOperation = 'missing-operation';
@@ -16,6 +16,7 @@ var _RuntimeExpressionEvaluator = _interopRequireDefault(require("../expression/
16
16
  var _ArazzoWorkflowExtractor = _interopRequireDefault(require("../extractor/ArazzoWorkflowExtractor.cjs"));
17
17
  var _ArazzoWorkflowNormalizer = _interopRequireDefault(require("../normalizer/ArazzoWorkflowNormalizer.cjs"));
18
18
  var _OutputResolver = _interopRequireDefault(require("../resolver/OutputResolver.cjs"));
19
+ var _WorkflowInputsResolver = _interopRequireDefault(require("../resolver/WorkflowInputsResolver.cjs"));
19
20
  var _WorkflowParameterResolver = _interopRequireDefault(require("../resolver/WorkflowParameterResolver.cjs"));
20
21
  var _WorkflowExecutionState = _interopRequireDefault(require("../state/WorkflowExecutionState.cjs"));
21
22
  var _StepExecutor = require("./StepExecutor.cjs");
@@ -105,11 +106,6 @@ function settledResult(result) {
105
106
  * @internal
106
107
  */
107
108
 
108
- /**
109
- * One completed `dependsOn` run, remembered with the inputs it was actually
110
- * given — see {@link RunScope.dependencyRuns}.
111
- */
112
-
113
109
  /**
114
110
  * One `executeOptions` entry and the canonical URI of the document its name
115
111
  * points at.
@@ -197,6 +193,11 @@ class WorkflowExecutor {
197
193
  #normalizer;
198
194
  #outputResolver = new _OutputResolver.default();
199
195
  #parameterResolver = new _WorkflowParameterResolver.default();
196
+ #inputsResolver = new _WorkflowInputsResolver.default();
197
+ // the inputs each workflow run ran with, defaults filled in, by its result:
198
+ // what a caller records under `$workflows.{id}.inputs`. Beside the result
199
+ // and not on it, since the events a trace is rebuilt from carry no inputs.
200
+ #inputsByResult = new WeakMap();
200
201
  #stepExecutor;
201
202
  #retryRunner;
202
203
  #interpreter = new _StepTransitionInterpreter.default();
@@ -378,12 +379,11 @@ class WorkflowExecutor {
378
379
  // define never starts, and the event can say where the one it runs is.
379
380
  const extracted = this.#extractWorkflow(locator);
380
381
  const location = locator.document.locationOf(extracted);
381
- const invocation = {
382
+ // without its state: the inputs it runs with are known only once the
383
+ // workflow is normalized, which happens inside `workflow:start`.
384
+ const entered = {
382
385
  workflowId,
383
386
  document: locator.document,
384
- state: new _WorkflowExecutionState.default({
385
- inputs
386
- }),
387
387
  callStack: nested,
388
388
  via,
389
389
  frame
@@ -411,7 +411,7 @@ class WorkflowExecutor {
411
411
  location
412
412
  }, startedAt);
413
413
  }
414
- result = await this.#runInvocation(locator, extracted, invocation, scope, startedAt);
414
+ result = await this.#runInvocation(locator, extracted, entered, inputs, scope, startedAt);
415
415
  } catch (error) {
416
416
  this.#settleThrown({
417
417
  type: 'workflow:settled',
@@ -429,6 +429,9 @@ class WorkflowExecutor {
429
429
  ...frame,
430
430
  status: result.status,
431
431
  settledStatus: result.settledStatus,
432
+ ...(result.inputDefaults === undefined ? {} : {
433
+ inputDefaults: result.inputDefaults
434
+ }),
432
435
  outputs: result.outputs
433
436
  }, startedAt + result.durationMs);
434
437
  }
@@ -441,13 +444,23 @@ class WorkflowExecutor {
441
444
  * normalizes the workflow, checks its definition, runs its dependencies
442
445
  * and its steps, and builds its result.
443
446
  */
444
- async #runInvocation(locator, extracted, invocation, scope, startedAt) {
447
+ async #runInvocation(locator, extracted, entered, inputs, scope, startedAt) {
445
448
  const {
446
449
  workflowId,
447
450
  callStack: nested,
448
451
  frame
449
- } = invocation;
452
+ } = entered;
450
453
  const workflow = await this.#resolveWorkflow(locator, extracted, scope, frame);
454
+ // the defaults of the workflow's `inputs` schema, read from the normalized
455
+ // workflow so that one behind a reference is found.
456
+ const resolved = this.#inputsResolver.resolve(workflow.inputs, inputs);
457
+ const invocation = {
458
+ ...entered,
459
+ state: new _WorkflowExecutionState.default({
460
+ inputs: resolved.inputs
461
+ }),
462
+ inputDefaults: resolved.defaults
463
+ };
451
464
 
452
465
  // validated before any prerequisite runs: a malformed `steps` is an
453
466
  // authoring error, and discovering it only after the dependencies have
@@ -756,6 +769,9 @@ class WorkflowExecutor {
756
769
  const settledAt = this.#now();
757
770
  const shared = {
758
771
  workflowId: invocation.workflowId,
772
+ ...(Object.keys(invocation.inputDefaults).length > 0 ? {
773
+ inputDefaults: invocation.inputDefaults
774
+ } : {}),
759
775
  steps,
760
776
  durationMs: settledAt - startedAt,
761
777
  ...(dependencies.length > 0 ? {
@@ -778,6 +794,7 @@ class WorkflowExecutor {
778
794
  status: outcome.status,
779
795
  settledStatus: outcome.status
780
796
  };
797
+ this.#inputsByResult.set(result, invocation.state.inputs);
781
798
  return result;
782
799
  }
783
800
 
@@ -902,17 +919,16 @@ class WorkflowExecutor {
902
919
  * it is named a call cycle, not a dependency one, and charged one unit
903
920
  * for entering the reference itself, matching the "1 for the step itself
904
921
  * plus whatever its sub-run spends" convention a sub-workflow step
905
- * already follows (without it, a reference to a workflow with few or no
906
- * steps of its own would cost nothing to fire). Its inputs are the
922
+ * already follows (without it, a reference to a one-step workflow would
923
+ * cost no more than that step to fire). Its inputs are the
907
924
  * action's `parameters` (`#115`), resolved again on every firing
908
925
  * against the attempt that fired it — `{}` without them. Its outputs are
909
926
  * recorded via `state.setWorkflow`, which *is* "context transfers back",
910
- * together with the inputs it ran with when the action carries
911
- * `parameters`. Without them, the recorded `inputs` are preserved rather
912
- * than overwritten with `{}` when this workflowId was already recorded
913
- * (by an earlier `dependsOn` prerequisite or sub-workflow step sharing
914
- * the id): this call's own lack of a real inputs value must not erase one
915
- * a different, better-informed caller already gave.
927
+ * together with the inputs it ran with, the defaults of its `inputs`
928
+ * schema included. That holds without `parameters` too, where the
929
+ * reference runs on those defaults alone: the recorded inputs and
930
+ * outputs then describe the same run, and an earlier run sharing the id
931
+ * (a `dependsOn` prerequisite, a sub-workflow step) is replaced whole.
916
932
  * - a `stepId` reference must name a step of the current workflow (checked
917
933
  * lazily, at fire time, via the same lookup a `goto` target uses) and
918
934
  * runs as one more attempt at that step, through
@@ -979,7 +995,7 @@ class WorkflowExecutor {
979
995
  // the key run state is recorded under, whichever document owns it.
980
996
  const refId = result.workflowId;
981
997
  state.setWorkflow(refId, {
982
- inputs: action.hasKey('parameters') ? inputs : state.getWorkflow(refId)?.inputs ?? {},
998
+ inputs: this.#inputsByResult.get(result),
983
999
  outputs: result.outputs
984
1000
  });
985
1001
  const successful = !this.#settledFailed(result);
@@ -1104,11 +1120,10 @@ class WorkflowExecutor {
1104
1120
  // precondition holds once met, and a diamond (two dependents sharing one
1105
1121
  // dependency) must not duplicate its live side effects. Every dependent
1106
1122
  // still reports and reads that one run — including the inputs the run
1107
- // was actually given, not whatever this dependent's own
1108
- // `dependencyInputs` entry would have supplied had it run it.
1123
+ // ran with, not whatever this dependent's own `dependencyInputs` entry
1124
+ // would have supplied had it run it.
1109
1125
  const memoized = scope.dependencyRuns.get(qualifiedId);
1110
- const inputs = memoized?.inputs ?? scope.dependencyInputs[dependency.inputsKey] ?? {};
1111
- const result = memoized?.result ?? (await this.#run(dependency.locator, inputs, scope, callStack, 'dependsOn'));
1126
+ const result = memoized ?? (await this.#run(dependency.locator, scope.dependencyInputs[dependency.inputsKey] ?? {}, scope, callStack, 'dependsOn'));
1112
1127
  results.push(result);
1113
1128
  // recorded whether or not it completed: a failed prerequisite still
1114
1129
  // resolved (possibly partial) outputs, and the parent resolves its own
@@ -1119,7 +1134,7 @@ class WorkflowExecutor {
1119
1134
  // never ran. Keyed by the bare id even for a cross-document dependency:
1120
1135
  // `$workflows.{id}` is the only form an expression can read it back by.
1121
1136
  state.setWorkflow(dependency.locator.workflowId, {
1122
- inputs,
1137
+ inputs: this.#inputsByResult.get(result),
1123
1138
  outputs: result.outputs
1124
1139
  });
1125
1140
  if (this.#events.hasObservers) {
@@ -1136,10 +1151,7 @@ class WorkflowExecutor {
1136
1151
  // only a dependency whose chain settled non-`failed` is remembered as
1137
1152
  // satisfied — a failure, transferred or not, must never let a later
1138
1153
  // dependent skip running it.
1139
- scope.dependencyRuns.set(qualifiedId, {
1140
- result,
1141
- inputs
1142
- });
1154
+ scope.dependencyRuns.set(qualifiedId, result);
1143
1155
  }
1144
1156
  return results;
1145
1157
  }
@@ -1268,7 +1280,7 @@ class WorkflowExecutor {
1268
1280
  const result = await this.#run(locator, inputs, scope, callStack, 'step');
1269
1281
  subWorkflows.push(result);
1270
1282
  state.setWorkflow(subWorkflowId, {
1271
- inputs,
1283
+ inputs: this.#inputsByResult.get(result),
1272
1284
  outputs: result.outputs
1273
1285
  });
1274
1286
 
@@ -1525,13 +1537,24 @@ class WorkflowExecutor {
1525
1537
  }
1526
1538
 
1527
1539
  /**
1528
- * The workflow's steps as an array in list order. An absent `steps` is a
1529
- * workflow with no steps — an empty list, a completed no-op run. A present but
1530
- * malformed `steps` (not a list, or holding a non-step entry) is an authoring
1531
- * error and throws rather than being silently treated as empty or partial.
1540
+ * The workflow's steps as an array in list order. `steps` is a REQUIRED field
1541
+ * holding at least one step, and the validator reports an absent or empty one
1542
+ * as an Error, so neither runs as a completed no-op. Those, like a `steps`
1543
+ * that is not a list or holds a non-step entry, are authoring errors and
1544
+ * throw rather than being silently treated as empty or partial.
1545
+ *
1546
+ * Checked when the workflow is entered, before any of its own prerequisites
1547
+ * or steps. A workflow another one only references (a `goto` target, a retry
1548
+ * reference) is therefore rejected when the run reaches it, after the
1549
+ * requests sent on the way there.
1532
1550
  */
1533
1551
  #orderedSteps(workflow, workflowId) {
1534
- if (!workflow.hasKey('steps')) return [];
1552
+ if (!workflow.hasKey('steps')) {
1553
+ throw new _ExecutionError.default(`workflow "${workflowId}" has no "steps"`, {
1554
+ workflowId,
1555
+ reason: _ExecutionError.default.MalformedSteps
1556
+ });
1557
+ }
1535
1558
  const steps = workflow.steps;
1536
1559
  if (!(0, _apidomDatamodel.isArrayElement)(steps)) {
1537
1560
  throw new _ExecutionError.default(`workflow "${workflowId}" has a non-list "steps"`, {
@@ -1539,6 +1562,12 @@ class WorkflowExecutor {
1539
1562
  reason: _ExecutionError.default.MalformedSteps
1540
1563
  });
1541
1564
  }
1565
+ if (steps.isEmpty) {
1566
+ throw new _ExecutionError.default(`workflow "${workflowId}" has an empty "steps"`, {
1567
+ workflowId,
1568
+ reason: _ExecutionError.default.MalformedSteps
1569
+ });
1570
+ }
1542
1571
  return [...steps].map((step, index) => {
1543
1572
  if (!(0, _apidomNsArazzo.isStepElement)(step)) {
1544
1573
  throw new _ExecutionError.default(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
@@ -7,6 +7,7 @@ import RuntimeExpressionEvaluator from "../expression/RuntimeExpressionEvaluator
7
7
  import ArazzoWorkflowExtractor from "../extractor/ArazzoWorkflowExtractor.mjs";
8
8
  import ArazzoWorkflowNormalizer from "../normalizer/ArazzoWorkflowNormalizer.mjs";
9
9
  import OutputResolver from "../resolver/OutputResolver.mjs";
10
+ import WorkflowInputsResolver from "../resolver/WorkflowInputsResolver.mjs";
10
11
  import WorkflowParameterResolver from "../resolver/WorkflowParameterResolver.mjs";
11
12
  import WorkflowExecutionState from "../state/WorkflowExecutionState.mjs";
12
13
  import { STEP_TARGET_FIELDS } from "./StepExecutor.mjs";
@@ -91,11 +92,6 @@ export function settledResult(result) {
91
92
  * @internal
92
93
  */
93
94
 
94
- /**
95
- * One completed `dependsOn` run, remembered with the inputs it was actually
96
- * given — see {@link RunScope.dependencyRuns}.
97
- */
98
-
99
95
  /**
100
96
  * One `executeOptions` entry and the canonical URI of the document its name
101
97
  * points at.
@@ -183,6 +179,11 @@ class WorkflowExecutor {
183
179
  #normalizer;
184
180
  #outputResolver = new OutputResolver();
185
181
  #parameterResolver = new WorkflowParameterResolver();
182
+ #inputsResolver = new WorkflowInputsResolver();
183
+ // the inputs each workflow run ran with, defaults filled in, by its result:
184
+ // what a caller records under `$workflows.{id}.inputs`. Beside the result
185
+ // and not on it, since the events a trace is rebuilt from carry no inputs.
186
+ #inputsByResult = new WeakMap();
186
187
  #stepExecutor;
187
188
  #retryRunner;
188
189
  #interpreter = new StepTransitionInterpreter();
@@ -364,12 +365,11 @@ class WorkflowExecutor {
364
365
  // define never starts, and the event can say where the one it runs is.
365
366
  const extracted = this.#extractWorkflow(locator);
366
367
  const location = locator.document.locationOf(extracted);
367
- const invocation = {
368
+ // without its state: the inputs it runs with are known only once the
369
+ // workflow is normalized, which happens inside `workflow:start`.
370
+ const entered = {
368
371
  workflowId,
369
372
  document: locator.document,
370
- state: new WorkflowExecutionState({
371
- inputs
372
- }),
373
373
  callStack: nested,
374
374
  via,
375
375
  frame
@@ -397,7 +397,7 @@ class WorkflowExecutor {
397
397
  location
398
398
  }, startedAt);
399
399
  }
400
- result = await this.#runInvocation(locator, extracted, invocation, scope, startedAt);
400
+ result = await this.#runInvocation(locator, extracted, entered, inputs, scope, startedAt);
401
401
  } catch (error) {
402
402
  this.#settleThrown({
403
403
  type: 'workflow:settled',
@@ -415,6 +415,9 @@ class WorkflowExecutor {
415
415
  ...frame,
416
416
  status: result.status,
417
417
  settledStatus: result.settledStatus,
418
+ ...(result.inputDefaults === undefined ? {} : {
419
+ inputDefaults: result.inputDefaults
420
+ }),
418
421
  outputs: result.outputs
419
422
  }, startedAt + result.durationMs);
420
423
  }
@@ -427,13 +430,23 @@ class WorkflowExecutor {
427
430
  * normalizes the workflow, checks its definition, runs its dependencies
428
431
  * and its steps, and builds its result.
429
432
  */
430
- async #runInvocation(locator, extracted, invocation, scope, startedAt) {
433
+ async #runInvocation(locator, extracted, entered, inputs, scope, startedAt) {
431
434
  const {
432
435
  workflowId,
433
436
  callStack: nested,
434
437
  frame
435
- } = invocation;
438
+ } = entered;
436
439
  const workflow = await this.#resolveWorkflow(locator, extracted, scope, frame);
440
+ // the defaults of the workflow's `inputs` schema, read from the normalized
441
+ // workflow so that one behind a reference is found.
442
+ const resolved = this.#inputsResolver.resolve(workflow.inputs, inputs);
443
+ const invocation = {
444
+ ...entered,
445
+ state: new WorkflowExecutionState({
446
+ inputs: resolved.inputs
447
+ }),
448
+ inputDefaults: resolved.defaults
449
+ };
437
450
 
438
451
  // validated before any prerequisite runs: a malformed `steps` is an
439
452
  // authoring error, and discovering it only after the dependencies have
@@ -742,6 +755,9 @@ class WorkflowExecutor {
742
755
  const settledAt = this.#now();
743
756
  const shared = {
744
757
  workflowId: invocation.workflowId,
758
+ ...(Object.keys(invocation.inputDefaults).length > 0 ? {
759
+ inputDefaults: invocation.inputDefaults
760
+ } : {}),
745
761
  steps,
746
762
  durationMs: settledAt - startedAt,
747
763
  ...(dependencies.length > 0 ? {
@@ -764,6 +780,7 @@ class WorkflowExecutor {
764
780
  status: outcome.status,
765
781
  settledStatus: outcome.status
766
782
  };
783
+ this.#inputsByResult.set(result, invocation.state.inputs);
767
784
  return result;
768
785
  }
769
786
 
@@ -888,17 +905,16 @@ class WorkflowExecutor {
888
905
  * it is named a call cycle, not a dependency one, and charged one unit
889
906
  * for entering the reference itself, matching the "1 for the step itself
890
907
  * plus whatever its sub-run spends" convention a sub-workflow step
891
- * already follows (without it, a reference to a workflow with few or no
892
- * steps of its own would cost nothing to fire). Its inputs are the
908
+ * already follows (without it, a reference to a one-step workflow would
909
+ * cost no more than that step to fire). Its inputs are the
893
910
  * action's `parameters` (`#115`), resolved again on every firing
894
911
  * against the attempt that fired it — `{}` without them. Its outputs are
895
912
  * recorded via `state.setWorkflow`, which *is* "context transfers back",
896
- * together with the inputs it ran with when the action carries
897
- * `parameters`. Without them, the recorded `inputs` are preserved rather
898
- * than overwritten with `{}` when this workflowId was already recorded
899
- * (by an earlier `dependsOn` prerequisite or sub-workflow step sharing
900
- * the id): this call's own lack of a real inputs value must not erase one
901
- * a different, better-informed caller already gave.
913
+ * together with the inputs it ran with, the defaults of its `inputs`
914
+ * schema included. That holds without `parameters` too, where the
915
+ * reference runs on those defaults alone: the recorded inputs and
916
+ * outputs then describe the same run, and an earlier run sharing the id
917
+ * (a `dependsOn` prerequisite, a sub-workflow step) is replaced whole.
902
918
  * - a `stepId` reference must name a step of the current workflow (checked
903
919
  * lazily, at fire time, via the same lookup a `goto` target uses) and
904
920
  * runs as one more attempt at that step, through
@@ -965,7 +981,7 @@ class WorkflowExecutor {
965
981
  // the key run state is recorded under, whichever document owns it.
966
982
  const refId = result.workflowId;
967
983
  state.setWorkflow(refId, {
968
- inputs: action.hasKey('parameters') ? inputs : state.getWorkflow(refId)?.inputs ?? {},
984
+ inputs: this.#inputsByResult.get(result),
969
985
  outputs: result.outputs
970
986
  });
971
987
  const successful = !this.#settledFailed(result);
@@ -1090,11 +1106,10 @@ class WorkflowExecutor {
1090
1106
  // precondition holds once met, and a diamond (two dependents sharing one
1091
1107
  // dependency) must not duplicate its live side effects. Every dependent
1092
1108
  // still reports and reads that one run — including the inputs the run
1093
- // was actually given, not whatever this dependent's own
1094
- // `dependencyInputs` entry would have supplied had it run it.
1109
+ // ran with, not whatever this dependent's own `dependencyInputs` entry
1110
+ // would have supplied had it run it.
1095
1111
  const memoized = scope.dependencyRuns.get(qualifiedId);
1096
- const inputs = memoized?.inputs ?? scope.dependencyInputs[dependency.inputsKey] ?? {};
1097
- const result = memoized?.result ?? (await this.#run(dependency.locator, inputs, scope, callStack, 'dependsOn'));
1112
+ const result = memoized ?? (await this.#run(dependency.locator, scope.dependencyInputs[dependency.inputsKey] ?? {}, scope, callStack, 'dependsOn'));
1098
1113
  results.push(result);
1099
1114
  // recorded whether or not it completed: a failed prerequisite still
1100
1115
  // resolved (possibly partial) outputs, and the parent resolves its own
@@ -1105,7 +1120,7 @@ class WorkflowExecutor {
1105
1120
  // never ran. Keyed by the bare id even for a cross-document dependency:
1106
1121
  // `$workflows.{id}` is the only form an expression can read it back by.
1107
1122
  state.setWorkflow(dependency.locator.workflowId, {
1108
- inputs,
1123
+ inputs: this.#inputsByResult.get(result),
1109
1124
  outputs: result.outputs
1110
1125
  });
1111
1126
  if (this.#events.hasObservers) {
@@ -1122,10 +1137,7 @@ class WorkflowExecutor {
1122
1137
  // only a dependency whose chain settled non-`failed` is remembered as
1123
1138
  // satisfied — a failure, transferred or not, must never let a later
1124
1139
  // dependent skip running it.
1125
- scope.dependencyRuns.set(qualifiedId, {
1126
- result,
1127
- inputs
1128
- });
1140
+ scope.dependencyRuns.set(qualifiedId, result);
1129
1141
  }
1130
1142
  return results;
1131
1143
  }
@@ -1254,7 +1266,7 @@ class WorkflowExecutor {
1254
1266
  const result = await this.#run(locator, inputs, scope, callStack, 'step');
1255
1267
  subWorkflows.push(result);
1256
1268
  state.setWorkflow(subWorkflowId, {
1257
- inputs,
1269
+ inputs: this.#inputsByResult.get(result),
1258
1270
  outputs: result.outputs
1259
1271
  });
1260
1272
 
@@ -1511,13 +1523,24 @@ class WorkflowExecutor {
1511
1523
  }
1512
1524
 
1513
1525
  /**
1514
- * The workflow's steps as an array in list order. An absent `steps` is a
1515
- * workflow with no steps — an empty list, a completed no-op run. A present but
1516
- * malformed `steps` (not a list, or holding a non-step entry) is an authoring
1517
- * error and throws rather than being silently treated as empty or partial.
1526
+ * The workflow's steps as an array in list order. `steps` is a REQUIRED field
1527
+ * holding at least one step, and the validator reports an absent or empty one
1528
+ * as an Error, so neither runs as a completed no-op. Those, like a `steps`
1529
+ * that is not a list or holds a non-step entry, are authoring errors and
1530
+ * throw rather than being silently treated as empty or partial.
1531
+ *
1532
+ * Checked when the workflow is entered, before any of its own prerequisites
1533
+ * or steps. A workflow another one only references (a `goto` target, a retry
1534
+ * reference) is therefore rejected when the run reaches it, after the
1535
+ * requests sent on the way there.
1518
1536
  */
1519
1537
  #orderedSteps(workflow, workflowId) {
1520
- if (!workflow.hasKey('steps')) return [];
1538
+ if (!workflow.hasKey('steps')) {
1539
+ throw new ExecutionError(`workflow "${workflowId}" has no "steps"`, {
1540
+ workflowId,
1541
+ reason: ExecutionError.MalformedSteps
1542
+ });
1543
+ }
1521
1544
  const steps = workflow.steps;
1522
1545
  if (!isArrayElement(steps)) {
1523
1546
  throw new ExecutionError(`workflow "${workflowId}" has a non-list "steps"`, {
@@ -1525,6 +1548,12 @@ class WorkflowExecutor {
1525
1548
  reason: ExecutionError.MalformedSteps
1526
1549
  });
1527
1550
  }
1551
+ if (steps.isEmpty) {
1552
+ throw new ExecutionError(`workflow "${workflowId}" has an empty "steps"`, {
1553
+ workflowId,
1554
+ reason: ExecutionError.MalformedSteps
1555
+ });
1556
+ }
1528
1557
  return [...steps].map((step, index) => {
1529
1558
  if (!isStepElement(step)) {
1530
1559
  throw new ExecutionError(`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
package/src/index.cjs CHANGED
@@ -359,6 +359,12 @@ Object.defineProperty(exports, "WorkflowExecutor", {
359
359
  return _WorkflowExecutor.default;
360
360
  }
361
361
  });
362
+ Object.defineProperty(exports, "WorkflowInputsResolver", {
363
+ enumerable: true,
364
+ get: function () {
365
+ return _WorkflowInputsResolver.default;
366
+ }
367
+ });
362
368
  Object.defineProperty(exports, "WorkflowParameterResolver", {
363
369
  enumerable: true,
364
370
  get: function () {
@@ -434,6 +440,7 @@ var _ArazzoValueResolver = _interopRequireDefault(require("./resolver/ArazzoValu
434
440
  var _StepParameterResolver = _interopRequireDefault(require("./resolver/StepParameterResolver.cjs"));
435
441
  var _OpenAPIOperationParameterResolver = _interopRequireDefault(require("./resolver/OpenAPIOperationParameterResolver.cjs"));
436
442
  var _WorkflowParameterResolver = _interopRequireDefault(require("./resolver/WorkflowParameterResolver.cjs"));
443
+ var _WorkflowInputsResolver = _interopRequireDefault(require("./resolver/WorkflowInputsResolver.cjs"));
437
444
  var _OutputResolver = _interopRequireDefault(require("./resolver/OutputResolver.cjs"));
438
445
  var _RequestBodyResolver = _interopRequireDefault(require("./resolver/RequestBodyResolver.cjs"));
439
446
  var _ActionResolver = _interopRequireDefault(require("./action/ActionResolver.cjs"));
package/src/index.mjs CHANGED
@@ -50,6 +50,7 @@ export { default as ArazzoValueResolver } from "./resolver/ArazzoValueResolver.m
50
50
  export { default as StepParameterResolver } from "./resolver/StepParameterResolver.mjs";
51
51
  export { default as OpenAPIOperationParameterResolver } from "./resolver/OpenAPIOperationParameterResolver.mjs";
52
52
  export { default as WorkflowParameterResolver } from "./resolver/WorkflowParameterResolver.mjs";
53
+ export { default as WorkflowInputsResolver } from "./resolver/WorkflowInputsResolver.mjs";
53
54
  export { default as OutputResolver } from "./resolver/OutputResolver.mjs";
54
55
  export { default as RequestBodyResolver } from "./resolver/RequestBodyResolver.mjs";
55
56
  /* Actions */