tubeless 0.2.11 → 0.2.13

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.
Files changed (196) hide show
  1. package/dist/core/child-execution.d.ts +1 -24
  2. package/dist/core/child-execution.js +11 -13
  3. package/dist/core/child-execution.js.map +1 -1
  4. package/dist/core/child-progress.js +7 -2
  5. package/dist/core/child-progress.js.map +1 -1
  6. package/dist/core/iteration.d.ts +27 -0
  7. package/dist/core/iteration.js +111 -0
  8. package/dist/core/iteration.js.map +1 -0
  9. package/dist/core/lifecycle.d.ts +7 -5
  10. package/dist/core/lifecycle.js +36 -4
  11. package/dist/core/lifecycle.js.map +1 -1
  12. package/dist/core/pipeline-artifacts.d.ts +11 -0
  13. package/dist/core/pipeline-artifacts.js +2 -0
  14. package/dist/core/pipeline-artifacts.js.map +1 -0
  15. package/dist/core/pipeline-compiler.d.ts +1 -0
  16. package/dist/core/pipeline-compiler.js +1 -0
  17. package/dist/core/pipeline-compiler.js.map +1 -1
  18. package/dist/core/pipeline-definition-identity.d.ts +2 -2
  19. package/dist/core/pipeline-definition-identity.js +28 -5
  20. package/dist/core/pipeline-definition-identity.js.map +1 -1
  21. package/dist/core/pipeline-execute.d.ts +1 -6
  22. package/dist/core/pipeline-execute.js +28 -215
  23. package/dist/core/pipeline-execute.js.map +1 -1
  24. package/dist/core/pipeline-execution-error.d.ts +35 -0
  25. package/dist/core/pipeline-execution-error.js +195 -0
  26. package/dist/core/pipeline-execution-error.js.map +1 -0
  27. package/dist/core/pipeline-identity.d.ts +1 -0
  28. package/dist/core/pipeline-identity.js +1 -0
  29. package/dist/core/pipeline-identity.js.map +1 -1
  30. package/dist/core/pipeline-mermaid.js +4 -1
  31. package/dist/core/pipeline-mermaid.js.map +1 -1
  32. package/dist/core/pipeline-run-state.d.ts +4 -4
  33. package/dist/core/pipeline-run-state.js +10 -16
  34. package/dist/core/pipeline-run-state.js.map +1 -1
  35. package/dist/core/pipeline-step-executor.d.ts +2 -0
  36. package/dist/core/pipeline-step-executor.js +11 -3
  37. package/dist/core/pipeline-step-executor.js.map +1 -1
  38. package/dist/core/pipeline-steps.d.ts +24 -1
  39. package/dist/core/pipeline-steps.js +62 -0
  40. package/dist/core/pipeline-steps.js.map +1 -1
  41. package/dist/core/pipeline-types.d.ts +28 -3
  42. package/dist/core/pipeline-types.js.map +1 -1
  43. package/dist/core/pipeline.d.ts +4 -1
  44. package/dist/core/pipeline.js +22 -4
  45. package/dist/core/pipeline.js.map +1 -1
  46. package/dist/project/project-compiler.d.ts +3 -31
  47. package/dist/project/project-compiler.js +11 -180
  48. package/dist/project/project-compiler.js.map +1 -1
  49. package/dist/project/project-registry.d.ts +44 -0
  50. package/dist/project/project-registry.js +107 -0
  51. package/dist/project/project-registry.js.map +1 -0
  52. package/dist/project/project-step-graph.d.ts +9 -0
  53. package/dist/project/project-step-graph.js +99 -0
  54. package/dist/project/project-step-graph.js.map +1 -0
  55. package/dist/render/render.js +1 -1
  56. package/dist/render/render.js.map +1 -1
  57. package/dist/reporter/interactive-reporter.js +6 -3
  58. package/dist/reporter/interactive-reporter.js.map +1 -1
  59. package/dist/reporter/live-ticker-frame.d.ts +21 -0
  60. package/dist/reporter/live-ticker-frame.js +196 -0
  61. package/dist/reporter/live-ticker-frame.js.map +1 -0
  62. package/dist/reporter/live-ticker-protocol.d.ts +41 -0
  63. package/dist/reporter/live-ticker-protocol.js +59 -0
  64. package/dist/reporter/live-ticker-protocol.js.map +1 -0
  65. package/dist/reporter/live-ticker-worker.js +11 -25
  66. package/dist/reporter/live-ticker-worker.js.map +1 -1
  67. package/dist/reporter/live-ticker.d.ts +0 -15
  68. package/dist/reporter/live-ticker.js +11 -216
  69. package/dist/reporter/live-ticker.js.map +1 -1
  70. package/dist/reporter/reporter.js +7 -6
  71. package/dist/reporter/reporter.js.map +1 -1
  72. package/dist/run-store/definition-projection.d.ts +8 -0
  73. package/dist/run-store/definition-projection.js +89 -0
  74. package/dist/run-store/definition-projection.js.map +1 -0
  75. package/dist/run-store/run-projection.d.ts +15 -0
  76. package/dist/run-store/run-projection.js +203 -0
  77. package/dist/run-store/run-projection.js.map +1 -0
  78. package/dist/run-store/run-store-codec.d.ts +2 -0
  79. package/dist/run-store/run-store-codec.js +11 -0
  80. package/dist/run-store/run-store-codec.js.map +1 -1
  81. package/dist/run-store/run-store-event-decoder.js +3 -0
  82. package/dist/run-store/run-store-event-decoder.js.map +1 -1
  83. package/dist/run-store/run-store-reader.d.ts +7 -0
  84. package/dist/run-store/run-store-reader.js +31 -0
  85. package/dist/run-store/run-store-reader.js.map +1 -0
  86. package/dist/run-store/run-store-sqlite.js +23 -7
  87. package/dist/run-store/run-store-sqlite.js.map +1 -1
  88. package/dist/run-store/run-store.d.ts +16 -4
  89. package/dist/run-store/run-store.js +14 -263
  90. package/dist/run-store/run-store.js.map +1 -1
  91. package/dist/studio/run-store-ui-api.d.ts +13 -0
  92. package/dist/studio/run-store-ui-api.js +163 -0
  93. package/dist/studio/run-store-ui-api.js.map +1 -0
  94. package/dist/studio/run-store-ui-client-browser.js +2 -2
  95. package/dist/studio/run-store-ui-client-transport.js +28 -3
  96. package/dist/studio/run-store-ui-client-transport.js.map +1 -1
  97. package/dist/studio/run-store-ui-client.d.ts +2 -1
  98. package/dist/studio/run-store-ui-client.js +15 -9
  99. package/dist/studio/run-store-ui-client.js.map +1 -1
  100. package/dist/studio/run-store-ui-http.d.ts +11 -0
  101. package/dist/studio/run-store-ui-http.js +52 -0
  102. package/dist/studio/run-store-ui-http.js.map +1 -1
  103. package/dist/studio/run-store-ui-state.d.ts +1 -1
  104. package/dist/studio/run-store-ui-state.js +10 -28
  105. package/dist/studio/run-store-ui-state.js.map +1 -1
  106. package/dist/studio/run-store-ui.d.ts +5 -11
  107. package/dist/studio/run-store-ui.js +5 -203
  108. package/dist/studio/run-store-ui.js.map +1 -1
  109. package/dist/testing/testing.d.ts +18 -2
  110. package/dist/testing/testing.js +35 -2
  111. package/dist/testing/testing.js.map +1 -1
  112. package/dist/tracing/artifact-metadata.d.ts +28 -0
  113. package/dist/tracing/artifact-metadata.js +105 -0
  114. package/dist/tracing/artifact-metadata.js.map +1 -0
  115. package/dist/tracing/tracing-codec.d.ts +1 -1
  116. package/dist/tracing/tracing-codec.js +1 -1
  117. package/dist/tracing/tracing-codec.js.map +1 -1
  118. package/dist/tracing/tracing-constants.d.ts +1 -1
  119. package/dist/tracing/tracing-constants.js +1 -1
  120. package/dist/tracing/tracing-constants.js.map +1 -1
  121. package/dist/tracing/tracing-contracts.d.ts +3 -1
  122. package/dist/tracing/tracing-contracts.js.map +1 -1
  123. package/dist/tracing/tracing-internal.d.ts +2 -0
  124. package/dist/tracing/tracing-internal.js +36 -13
  125. package/dist/tracing/tracing-internal.js.map +1 -1
  126. package/dist/tracing/tracing-schema.d.ts +330 -49
  127. package/dist/tracing/tracing-schema.js +102 -10
  128. package/dist/tracing/tracing-schema.js.map +1 -1
  129. package/dist/workbench/workbench-command-execution.d.ts +6 -0
  130. package/dist/workbench/workbench-command-execution.js +48 -0
  131. package/dist/workbench/workbench-command-execution.js.map +1 -0
  132. package/dist/workbench/workbench-history.js +11 -18
  133. package/dist/workbench/workbench-history.js.map +1 -1
  134. package/dist/workbench/workbench-launch-session.d.ts +2 -2
  135. package/dist/workbench/workbench-launch-session.js.map +1 -1
  136. package/dist/workbench/workbench-run.d.ts +0 -4
  137. package/dist/workbench/workbench-run.js +3 -47
  138. package/dist/workbench/workbench-run.js.map +1 -1
  139. package/dist/workbench/workbench-studio-launcher.d.ts +27 -0
  140. package/dist/workbench/workbench-studio-launcher.js +95 -0
  141. package/dist/workbench/workbench-studio-launcher.js.map +1 -0
  142. package/dist/workbench/workbench-ui.js +10 -83
  143. package/dist/workbench/workbench-ui.js.map +1 -1
  144. package/docs/README.md +13 -7
  145. package/docs/agent-guide.md +75 -6
  146. package/docs/airflow.md +187 -0
  147. package/docs/api-reference.md +87 -76
  148. package/docs/api-report.json +17 -6
  149. package/docs/artifacts.md +173 -0
  150. package/docs/child-pipeline-composition.md +87 -8
  151. package/docs/comparison.md +20 -0
  152. package/docs/concepts.md +79 -2
  153. package/docs/dagster.md +161 -0
  154. package/docs/inngest.md +163 -0
  155. package/docs/llms.txt +30 -1
  156. package/docs/recipes.md +82 -32
  157. package/docs/remote-step-composition.md +6 -0
  158. package/docs/step-functions.md +190 -0
  159. package/docs/studio.md +31 -12
  160. package/docs/temporal.md +183 -0
  161. package/examples/airflow/contract.ts +46 -0
  162. package/examples/airflow/hosted.ts +70 -0
  163. package/examples/airflow/remote.ts +175 -0
  164. package/examples/airflow/tubeless_example.py +49 -0
  165. package/examples/airflow/worker.ts +24 -0
  166. package/examples/artifact-lineage.ts +70 -0
  167. package/examples/dagster/definitions.py +59 -0
  168. package/examples/dagster/hosted.ts +78 -0
  169. package/examples/dagster/pipeline.ts +62 -0
  170. package/examples/dagster/test_definitions.py +47 -0
  171. package/examples/dagster/tsconfig.build.json +10 -0
  172. package/examples/dagster/worker.ts +22 -0
  173. package/examples/inherited-inputs.ts +28 -0
  174. package/examples/inngest/client.ts +4 -0
  175. package/examples/inngest/functions.ts +65 -0
  176. package/examples/inngest/pipeline.ts +41 -0
  177. package/examples/inngest/send.ts +11 -0
  178. package/examples/inngest/server.ts +17 -0
  179. package/examples/inngest/tsconfig.build.json +10 -0
  180. package/examples/iteration.ts +52 -0
  181. package/examples/parameterized-steps.ts +96 -0
  182. package/examples/project/tubeless.project.ts +50 -0
  183. package/examples/step-functions/handler.ts +110 -0
  184. package/examples/step-functions/input.json +1 -0
  185. package/examples/step-functions/pipeline.ts +41 -0
  186. package/examples/step-functions/state-machine.asl.json +41 -0
  187. package/examples/step-functions/template.json +42 -0
  188. package/examples/step-output-overrides.ts +41 -0
  189. package/examples/temporal/activities.ts +94 -0
  190. package/examples/temporal/client.ts +19 -0
  191. package/examples/temporal/pipeline.ts +41 -0
  192. package/examples/temporal/tsconfig.build.json +10 -0
  193. package/examples/temporal/worker.ts +21 -0
  194. package/examples/temporal/workflows.ts +16 -0
  195. package/package.json +13 -4
  196. package/skills/tubeless/SKILL.md +37 -4
@@ -1,166 +1,15 @@
1
- import { abortableSleep, isAbortError, throwIfAborted as throwIfSignalAborted, } from "../utilities/abort.js";
2
- import { PipelineChildError } from "./child-execution.js";
3
- import { brandTubelessError } from "../utilities/tubeless-error.js";
1
+ import { abortableSleep, throwIfAborted as throwIfSignalAborted } from "../utilities/abort.js";
4
2
  import { createPipelineLifecycleObserver } from "./lifecycle.js";
5
- import { formatPipelineError } from "./pipeline-diagnostics.js";
6
3
  import { createRunId } from "./pipeline-ids.js";
7
4
  import { decideStepDisposition } from "./pipeline-disposition.js";
8
5
  import { schedulePipelineSteps } from "./pipeline-scheduler.js";
9
6
  import { compiledStepGraph } from "./pipeline-graph.js";
10
7
  import { planStepById, stepToPlanStep } from "./pipeline-plan.js";
11
- import { PipelineRunState, isCancellationOnly, } from "./pipeline-run-state.js";
8
+ import { PipelineRunState } from "./pipeline-run-state.js";
12
9
  import { PIPELINE_FINALIZE_STEP_ID } from "./pipeline-step-metadata.js";
13
10
  import { evaluateStepSkip, executeStepAttempt, validateStepOutput, } from "./pipeline-step-executor.js";
14
11
  import { PipelineBoundaryValidationError, validateStandardSchema } from "./pipeline-validation.js";
15
- import { createPipelineTraceEmitter } from "../tracing/tracing-internal.js";
16
- const PIPELINE_LOGGER_BASE = Symbol("pipelineLoggerBase");
17
- function basePipelineLogger(log) {
18
- // SAFETY: `TracedPipelineLogger` only adds the optional symbol-keyed base
19
- // property; reading it off any `PipelineLogger` is safe because the property
20
- // is absent unless a tracing wrapper installed it.
21
- return log[PIPELINE_LOGGER_BASE] ?? log;
22
- }
23
- const originalPipelineErrors = new WeakMap();
24
- function defaultExecutionErrorMessage(result) {
25
- const firstError = result.errors[0];
26
- const disposition = isCancellationOnly(result.errors) ? "cancelled" : "failed";
27
- return firstError
28
- ? `Pipeline ${result.pipelineId} ${disposition}: ${formatPipelineError(firstError)}`
29
- : `Pipeline ${result.pipelineId} ${disposition}`;
30
- }
31
- function firstOriginalPipelineError(errors) {
32
- for (const error of errors) {
33
- if (originalPipelineErrors.has(error))
34
- return originalPipelineErrors.get(error);
35
- }
36
- return undefined;
37
- }
38
- /** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */
39
- export class PipelineExecutionError extends Error {
40
- result;
41
- constructor(result, message = defaultExecutionErrorMessage(result)) {
42
- const cause = firstOriginalPipelineError(result.errors);
43
- super(message, cause === undefined ? undefined : { cause });
44
- this.result = result;
45
- this.name = "PipelineExecutionError";
46
- brandTubelessError(this, "pipeline-execution");
47
- }
48
- }
49
- const MAX_PIPELINE_CAUSE_DEPTH = 8;
50
- function readErrorField(value, field) {
51
- try {
52
- // SAFETY: any object may be probed for an optional string-keyed field; a
53
- // getter that throws is caught below, so the cast only enables the lookup.
54
- return value[field];
55
- }
56
- catch {
57
- return undefined;
58
- }
59
- }
60
- function safeErrorMessage(value) {
61
- try {
62
- return String(value);
63
- }
64
- catch {
65
- return "Unknown thrown value";
66
- }
67
- }
68
- function normalizePipelineCause(value, seen, depth = 0) {
69
- if (depth >= MAX_PIPELINE_CAUSE_DEPTH) {
70
- return { message: "Cause chain truncated" };
71
- }
72
- if (typeof value !== "object" || value === null) {
73
- return { message: safeErrorMessage(value) };
74
- }
75
- if (seen.has(value)) {
76
- return { message: "Circular cause" };
77
- }
78
- seen.add(value);
79
- const message = readErrorField(value, "message");
80
- const name = readErrorField(value, "name");
81
- const sourceCode = readErrorField(value, "code");
82
- const nested = readErrorField(value, "cause");
83
- const cause = {
84
- message: typeof message === "string" ? message : safeErrorMessage(value),
85
- };
86
- if (typeof name === "string")
87
- cause.name = name;
88
- if (typeof sourceCode === "string")
89
- cause.sourceCode = sourceCode;
90
- if (nested !== undefined)
91
- cause.cause = normalizePipelineCause(nested, seen, depth + 1);
92
- return cause;
93
- }
94
- // Fan-out snapshots bound every string as well as cause depth and item count.
95
- function fanOutCause(error) {
96
- const cause = normalizePipelineCause(error, new WeakSet());
97
- let current = cause;
98
- while (current) {
99
- current.message = current.message.slice(0, 1024);
100
- if (current.name)
101
- current.name = current.name.slice(0, 1024);
102
- if (current.sourceCode)
103
- current.sourceCode = current.sourceCode.slice(0, 1024);
104
- current = current.cause;
105
- }
106
- return cause;
107
- }
108
- function normalizedNestedCause(error) {
109
- if (typeof error !== "object" || error === null)
110
- return undefined;
111
- const cause = readErrorField(error, "cause");
112
- if (cause === undefined)
113
- return undefined;
114
- const seen = new WeakSet();
115
- seen.add(error);
116
- return normalizePipelineCause(cause, seen);
117
- }
118
- function toPipelineError(error, classification) {
119
- const sourceCode = typeof error === "object" && error !== null ? readErrorField(error, "code") : undefined;
120
- const cause = normalizedNestedCause(error);
121
- const pipelineError = {
122
- ...classification,
123
- message: error instanceof Error ? error.message : safeErrorMessage(error),
124
- };
125
- if (error instanceof Error && error.stack)
126
- pipelineError.stack = error.stack;
127
- if (typeof sourceCode === "string")
128
- pipelineError.sourceCode = sourceCode;
129
- if (cause)
130
- pipelineError.cause = cause;
131
- if (error instanceof PipelineBoundaryValidationError)
132
- pipelineError.issues = error.issues;
133
- if (error instanceof PipelineChildError && error.fanOut) {
134
- const { failures, failureCount, schedulerError } = error.fanOut;
135
- pipelineError.fanOut = {
136
- failures: failures.map(({ error: itemError, key, index, cancelled }) => ({
137
- index,
138
- key: key.slice(0, 1024),
139
- keyTruncated: key.length > 1024,
140
- cancelled,
141
- error: fanOutCause(itemError),
142
- })),
143
- failureCount,
144
- omittedFailureCount: failureCount - failures.length,
145
- };
146
- if (schedulerError !== undefined)
147
- pipelineError.fanOut.schedulerError = fanOutCause(schedulerError);
148
- }
149
- originalPipelineErrors.set(pipelineError, error);
150
- return pipelineError;
151
- }
152
- export function isPipelineCancellation(error, runtime) {
153
- if (isAbortError(error))
154
- return true;
155
- if (runtime.signal?.aborted === true && error === runtime.signal.reason)
156
- return true;
157
- if (error instanceof PipelineChildError)
158
- return error.cancelled;
159
- return error instanceof PipelineExecutionError && isCancelledResult(error.result);
160
- }
161
- function isCancelledResult(result) {
162
- return result.status === "cancelled";
163
- }
12
+ import { finalizationError, stepExecutionError, toPipelineError, } from "./pipeline-execution-error.js";
164
13
  function throwIfAborted(runtime) {
165
14
  throwIfSignalAborted(runtime.signal, "Pipeline run");
166
15
  }
@@ -175,29 +24,11 @@ export async function executePlannedRun(input) {
175
24
  if (runtime.parentRunId)
176
25
  identity.parentRunId = runtime.parentRunId;
177
26
  const dryRun = controls.dryRun === true;
178
- const trace = createPipelineTraceEmitter(compiled.id, runtime.tracing, basePipelineLogger(runtime.log), { ...identity, itemKey: runtime.tracing?.itemKey }, runtime.now);
179
- const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, trace);
180
- const tracedLogger = (stepId, attemptId) => {
181
- if (!trace)
182
- return runtime.log;
183
- const base = basePipelineLogger(runtime.log);
184
- const log = {
185
- error: (message, ...params) => {
186
- lifecycle.log("error", message, params, stepId, attemptId);
187
- base.error(message, ...params);
188
- },
189
- log: (message, ...params) => {
190
- lifecycle.log("log", message, params, stepId, attemptId);
191
- base.log(message, ...params);
192
- },
193
- warn: (message, ...params) => {
194
- lifecycle.log("warn", message, params, stepId, attemptId);
195
- base.warn(message, ...params);
196
- },
197
- };
198
- log[PIPELINE_LOGGER_BASE] = base;
199
- return log;
200
- };
27
+ const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, {
28
+ ...identity,
29
+ itemKey: runtime.tracing?.itemKey,
30
+ iteration: runtime.tracing?.iteration,
31
+ });
201
32
  const state = new PipelineRunState(compiled.id, dryRun, startedAtMs, identity, runtime.now, lifecycle);
202
33
  state.start(input.plan, compiled.targetIds);
203
34
  if (!input.plan.ok) {
@@ -234,10 +65,10 @@ export async function executePlannedRun(input) {
234
65
  const executionContext = {
235
66
  ...runtime,
236
67
  dryRun,
237
- log: tracedLogger(),
68
+ log: lifecycle.logger(),
238
69
  options: pipelineOptions,
239
70
  runId,
240
- trace: trace?.context,
71
+ trace: lifecycle.traceContext,
241
72
  };
242
73
  const plannedSteps = planStepById(input.plan);
243
74
  const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));
@@ -297,27 +128,7 @@ export async function executePlannedRun(input) {
297
128
  return true;
298
129
  };
299
130
  const recordStepExecutionFailure = (error, plannedStep, attempt) => {
300
- const cancelled = isPipelineCancellation(error, runtime);
301
- const childFailure = error instanceof PipelineExecutionError || error instanceof PipelineChildError;
302
- const validationFailure = error instanceof PipelineBoundaryValidationError;
303
- const pipelineError = toPipelineError(error, {
304
- code: cancelled
305
- ? "TUBELESS_RUN_CANCELLED"
306
- : validationFailure
307
- ? "TUBELESS_STEP_OUTPUT_VALIDATION_FAILED"
308
- : childFailure
309
- ? "TUBELESS_CHILD_FAILED"
310
- : "TUBELESS_STEP_FAILED",
311
- kind: cancelled
312
- ? "cancellation"
313
- : validationFailure
314
- ? "validation"
315
- : childFailure
316
- ? "child"
317
- : "step",
318
- phase: "execution",
319
- stepId: plannedStep.id,
320
- });
131
+ const pipelineError = stepExecutionError(error, runtime, plannedStep.id);
321
132
  state.failStep(plannedStep, attempt, pipelineError);
322
133
  if (!controls.continueOnError)
323
134
  stopError ??= pipelineError;
@@ -345,6 +156,18 @@ export async function executePlannedRun(input) {
345
156
  const plannedStep = plannedStepFor(step);
346
157
  if (cancelBeforeStepStart(step))
347
158
  return;
159
+ if (plannedStep.selected && input.overrides?.has(step)) {
160
+ const attempt = state.beginAttempt(plannedStep, runtime.now(), "override");
161
+ try {
162
+ const output = await validateStepOutput(step, input.overrides.get(step), `Pipeline ${compiled.id} step ${step.id} override output`);
163
+ throwIfAborted(runtime);
164
+ state.completeStep(plannedStep, attempt, output);
165
+ }
166
+ catch (error) {
167
+ recordStepExecutionFailure(error, plannedStep, attempt);
168
+ }
169
+ return;
170
+ }
348
171
  const graph = compiledStepGraph(compiled, step);
349
172
  const disposition = decideStepDisposition({
350
173
  dryRun,
@@ -370,7 +193,7 @@ export async function executePlannedRun(input) {
370
193
  try {
371
194
  skipDecision = await evaluateStepSkip(step, stepInputs, {
372
195
  ...executionContext,
373
- log: tracedLogger(step.id),
196
+ log: lifecycle.logger(step.id),
374
197
  });
375
198
  }
376
199
  catch (error) {
@@ -392,7 +215,8 @@ export async function executePlannedRun(input) {
392
215
  context: executionContext,
393
216
  dryRun,
394
217
  inputs: stepInputs,
395
- log: tracedLogger(step.id, attempt.attemptId),
218
+ log: lifecycle.logger(step.id, attempt.attemptId),
219
+ onArtifact: (record, preview) => lifecycle.recordArtifact(step.id, attempt.attemptId, record, preview),
396
220
  onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),
397
221
  onReportAttempt: (number, attributes) => lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),
398
222
  outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,
@@ -429,7 +253,7 @@ export async function executePlannedRun(input) {
429
253
  const finalOutputs = Object.fromEntries(state.outputs);
430
254
  const finalizedValue = await compiled.finalize(finalOutputs, {
431
255
  ...executionContext,
432
- log: tracedLogger(PIPELINE_FINALIZE_STEP_ID),
256
+ log: lifecycle.logger(PIPELINE_FINALIZE_STEP_ID),
433
257
  });
434
258
  // SAFETY: with a result schema the value is validated against
435
259
  // `TPipelineResult`; without one the finalizer's declared return type
@@ -440,18 +264,7 @@ export async function executePlannedRun(input) {
440
264
  state.completeFinalization(value, runtime.now() - finalizeStartedAt);
441
265
  }
442
266
  catch (error) {
443
- const cancelled = isPipelineCancellation(error, runtime);
444
- const validationFailure = error instanceof PipelineBoundaryValidationError;
445
- const pipelineError = toPipelineError(error, {
446
- code: cancelled
447
- ? "TUBELESS_FINALIZATION_CANCELLED"
448
- : validationFailure
449
- ? "TUBELESS_FINAL_RESULT_VALIDATION_FAILED"
450
- : "TUBELESS_FINALIZATION_FAILED",
451
- kind: cancelled ? "cancellation" : validationFailure ? "validation" : "finalization",
452
- phase: "finalization",
453
- stepId: PIPELINE_FINALIZE_STEP_ID,
454
- });
267
+ const pipelineError = finalizationError(error, runtime);
455
268
  state.failFinalization(pipelineError, runtime.now() - finalizeStarted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C;IACH,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,WAAW,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAE7C,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,MAAoB,EAAiB,EAAE,CAChF,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEvD,MAAM,UAAU,sBAAsB;IACpC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAO,GAA6B,EAAE;IAC3E,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAC1C,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,OAAO;QACV,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,WAAW;QAC/C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,IAAI,aAAa;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import {\n abortableSleep,\n isAbortError,\n throwIfAborted as throwIfSignalAborted,\n} from \"../utilities/abort.js\";\nimport { PipelineChildError } from \"./child-execution.js\";\nimport { brandTubelessError } from \"../utilities/tubeless-error.js\";\nimport { createPipelineLifecycleObserver } from \"./lifecycle.js\";\nimport { formatPipelineError } from \"./pipeline-diagnostics.js\";\nimport { createRunId } from \"./pipeline-ids.js\";\nimport type { CompiledPipeline } from \"./pipeline-compiler.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport { decideStepDisposition } from \"./pipeline-disposition.js\";\nimport { schedulePipelineSteps } from \"./pipeline-scheduler.js\";\nimport { compiledStepGraph } from \"./pipeline-graph.js\";\nimport { planStepById, stepToPlanStep } from \"./pipeline-plan.js\";\nimport {\n PipelineRunState,\n isCancellationOnly,\n type PipelineStepAttempt,\n} from \"./pipeline-run-state.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { PIPELINE_FINALIZE_STEP_ID } from \"./pipeline-step-metadata.js\";\nimport {\n evaluateStepSkip,\n executeStepAttempt,\n validateStepOutput,\n} from \"./pipeline-step-executor.js\";\nimport type {\n InferSchemaOutput,\n PipelineContext,\n PipelineError,\n PipelineErrorCause,\n PipelineExecutionContext,\n PipelineLogger,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\nimport { PipelineBoundaryValidationError, validateStandardSchema } from \"./pipeline-validation.js\";\nimport { createPipelineTraceEmitter } from \"../tracing/tracing-internal.js\";\n\nconst PIPELINE_LOGGER_BASE = Symbol(\"pipelineLoggerBase\");\n\ntype TracedPipelineLogger = PipelineLogger & { [PIPELINE_LOGGER_BASE]?: PipelineLogger };\n\nfunction basePipelineLogger(log: PipelineLogger): PipelineLogger {\n // SAFETY: `TracedPipelineLogger` only adds the optional symbol-keyed base\n // property; reading it off any `PipelineLogger` is safe because the property\n // is absent unless a tracing wrapper installed it.\n return (log as TracedPipelineLogger)[PIPELINE_LOGGER_BASE] ?? log;\n}\n\nconst originalPipelineErrors = new WeakMap<PipelineError, unknown>();\n\nfunction defaultExecutionErrorMessage(result: PipelineRun<unknown>): string {\n const firstError = result.errors[0];\n const disposition = isCancellationOnly(result.errors) ? \"cancelled\" : \"failed\";\n return firstError\n ? `Pipeline ${result.pipelineId} ${disposition}: ${formatPipelineError(firstError)}`\n : `Pipeline ${result.pipelineId} ${disposition}`;\n}\n\nfunction firstOriginalPipelineError(errors: readonly PipelineError[]): unknown {\n for (const error of errors) {\n if (originalPipelineErrors.has(error)) return originalPipelineErrors.get(error);\n }\n return undefined;\n}\n\n/** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */\nexport class PipelineExecutionError extends Error {\n constructor(\n readonly result: PipelineRun<unknown>,\n message = defaultExecutionErrorMessage(result)\n ) {\n const cause = firstOriginalPipelineError(result.errors);\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"PipelineExecutionError\";\n brandTubelessError(this, \"pipeline-execution\");\n }\n}\n\nconst MAX_PIPELINE_CAUSE_DEPTH = 8;\n\nfunction readErrorField(value: object, field: \"cause\" | \"code\" | \"message\" | \"name\"): unknown {\n try {\n // SAFETY: any object may be probed for an optional string-keyed field; a\n // getter that throws is caught below, so the cast only enables the lookup.\n return (value as Record<string, unknown>)[field];\n } catch {\n return undefined;\n }\n}\n\nfunction safeErrorMessage(value: unknown): string {\n try {\n return String(value);\n } catch {\n return \"Unknown thrown value\";\n }\n}\n\nfunction normalizePipelineCause(\n value: unknown,\n seen: WeakSet<object>,\n depth = 0\n): PipelineErrorCause {\n if (depth >= MAX_PIPELINE_CAUSE_DEPTH) {\n return { message: \"Cause chain truncated\" };\n }\n if (typeof value !== \"object\" || value === null) {\n return { message: safeErrorMessage(value) };\n }\n if (seen.has(value)) {\n return { message: \"Circular cause\" };\n }\n seen.add(value);\n\n const message = readErrorField(value, \"message\");\n const name = readErrorField(value, \"name\");\n const sourceCode = readErrorField(value, \"code\");\n const nested = readErrorField(value, \"cause\");\n const cause: PipelineErrorCause = {\n message: typeof message === \"string\" ? message : safeErrorMessage(value),\n };\n if (typeof name === \"string\") cause.name = name;\n if (typeof sourceCode === \"string\") cause.sourceCode = sourceCode;\n if (nested !== undefined) cause.cause = normalizePipelineCause(nested, seen, depth + 1);\n return cause;\n}\n\n// Fan-out snapshots bound every string as well as cause depth and item count.\nfunction fanOutCause(error: unknown): PipelineErrorCause {\n const cause = normalizePipelineCause(error, new WeakSet<object>());\n let current: PipelineErrorCause | undefined = cause;\n while (current) {\n current.message = current.message.slice(0, 1024);\n if (current.name) current.name = current.name.slice(0, 1024);\n if (current.sourceCode) current.sourceCode = current.sourceCode.slice(0, 1024);\n current = current.cause;\n }\n return cause;\n}\n\nfunction normalizedNestedCause(error: unknown): PipelineErrorCause | undefined {\n if (typeof error !== \"object\" || error === null) return undefined;\n const cause = readErrorField(error, \"cause\");\n if (cause === undefined) return undefined;\n const seen = new WeakSet<object>();\n seen.add(error);\n return normalizePipelineCause(cause, seen);\n}\n\nfunction toPipelineError(\n error: unknown,\n classification: Omit<PipelineError, \"cause\" | \"message\" | \"sourceCode\" | \"stack\">\n): PipelineError {\n const sourceCode =\n typeof error === \"object\" && error !== null ? readErrorField(error, \"code\") : undefined;\n const cause = normalizedNestedCause(error);\n const pipelineError: PipelineError = {\n ...classification,\n message: error instanceof Error ? error.message : safeErrorMessage(error),\n };\n if (error instanceof Error && error.stack) pipelineError.stack = error.stack;\n if (typeof sourceCode === \"string\") pipelineError.sourceCode = sourceCode;\n if (cause) pipelineError.cause = cause;\n if (error instanceof PipelineBoundaryValidationError) pipelineError.issues = error.issues;\n if (error instanceof PipelineChildError && error.fanOut) {\n const { failures, failureCount, schedulerError } = error.fanOut;\n pipelineError.fanOut = {\n failures: failures.map(({ error: itemError, key, index, cancelled }) => ({\n index,\n key: key.slice(0, 1024),\n keyTruncated: key.length > 1024,\n cancelled,\n error: fanOutCause(itemError),\n })),\n failureCount,\n omittedFailureCount: failureCount - failures.length,\n };\n if (schedulerError !== undefined)\n pipelineError.fanOut.schedulerError = fanOutCause(schedulerError);\n }\n originalPipelineErrors.set(pipelineError, error);\n return pipelineError;\n}\n\nexport function isPipelineCancellation(error: unknown, runtime: PipelineRuntime): boolean {\n if (isAbortError(error)) return true;\n if (runtime.signal?.aborted === true && error === runtime.signal.reason) return true;\n if (error instanceof PipelineChildError) return error.cancelled;\n return error instanceof PipelineExecutionError && isCancelledResult(error.result);\n}\n\nfunction isCancelledResult(result: PipelineRun<unknown>): boolean {\n return result.status === \"cancelled\";\n}\n\ntype PipelineRunIdentity = { correlationId?: string; parentRunId?: string; runId: string };\n\nfunction throwIfAborted(runtime: PipelineRuntime): void {\n throwIfSignalAborted(runtime.signal, \"Pipeline run\");\n}\n\nexport async function executePlannedRun<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(input: {\n compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;\n controls: PipelineRunControls;\n domainOptions: object;\n plan: PipelinePlan;\n runtime: PipelineRuntime;\n}): Promise<\n PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>\n> {\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TOptions = StepsOptions<TSteps>;\n const { compiled, controls, runtime } = input;\n const startedAtMs = runtime.now();\n const runId = createRunId(compiled.id);\n const correlationId = runtime.correlationId;\n const identity: PipelineRunIdentity = { runId };\n if (correlationId !== undefined) identity.correlationId = correlationId;\n if (runtime.parentRunId) identity.parentRunId = runtime.parentRunId;\n const dryRun = controls.dryRun === true;\n const trace = createPipelineTraceEmitter(\n compiled.id,\n runtime.tracing,\n basePipelineLogger(runtime.log),\n { ...identity, itemKey: runtime.tracing?.itemKey },\n runtime.now\n );\n const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, trace);\n const tracedLogger = (stepId?: string, attemptId?: string): PipelineLogger => {\n if (!trace) return runtime.log;\n const base = basePipelineLogger(runtime.log);\n const log: TracedPipelineLogger = {\n error: (message, ...params) => {\n lifecycle.log(\"error\", message, params, stepId, attemptId);\n base.error(message, ...params);\n },\n log: (message, ...params) => {\n lifecycle.log(\"log\", message, params, stepId, attemptId);\n base.log(message, ...params);\n },\n warn: (message, ...params) => {\n lifecycle.log(\"warn\", message, params, stepId, attemptId);\n base.warn(message, ...params);\n },\n };\n log[PIPELINE_LOGGER_BASE] = base;\n return log;\n };\n const state = new PipelineRunState<TPipelineResult>(\n compiled.id,\n dryRun,\n startedAtMs,\n identity,\n runtime.now,\n lifecycle\n );\n state.start(input.plan, compiled.targetIds);\n\n if (!input.plan.ok) {\n state.recordRunErrors(input.plan.errors);\n return state.finish();\n }\n\n const maxConcurrency = controls.maxConcurrency ?? 1;\n\n // SAFETY: `domainOptions` is the user-supplied options object; if a schema\n // is present it is re-validated below before assignment to `pipelineOptions`.\n let pipelineOptions = input.domainOptions as TOptions;\n if (compiled.optionsSchema) {\n try {\n const validated = await validateStandardSchema(\n compiled.optionsSchema,\n input.domainOptions,\n `Pipeline ${compiled.id} options`\n );\n if (typeof validated !== \"object\" || validated === null || Array.isArray(validated)) {\n throw new PipelineBoundaryValidationError(\n `Pipeline ${compiled.id} options schema returned a non-object value`,\n [{ message: \"Expected the validated options value to be an object\" }]\n );\n }\n // SAFETY: the schema validated the value against `TOptions` and the\n // object-shape check above passed, so the value is a `TOptions`.\n pipelineOptions = validated as TOptions;\n } catch (error) {\n state.recordRunErrors([\n toPipelineError(error, {\n code: \"TUBELESS_OPTIONS_VALIDATION_FAILED\",\n kind: \"validation\",\n phase: \"execution\",\n }),\n ]);\n return state.finish();\n }\n }\n\n for (const step of input.plan.steps) state.planStep(step);\n\n const executionContext: PipelineExecutionContext<TOptions> = {\n ...runtime,\n dryRun,\n log: tracedLogger(),\n options: pipelineOptions,\n runId,\n trace: trace?.context,\n };\n\n const plannedSteps = planStepById(input.plan);\n const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));\n // `input.plan.steps` is already topologically ordered. Rehydrate from the original step\n // objects so callers still get the typed handlers rather than plan metadata.\n // SAFETY: every planned step id originates from `compiled.orderedSteps`, so the\n // map lookup always finds the matching `AnyStep<TOptions>`.\n const orderedSteps = input.plan.steps.map((step) => stepsById.get(step.id) as AnyStep<TOptions>);\n const plannedStepFor = (step: AnyStep<TOptions>): PipelinePlanStep =>\n plannedSteps.get(step.id) ??\n stepToPlanStep(step, true, undefined, undefined, compiledStepGraph(compiled, step));\n\n let stopError: PipelineError | undefined;\n let externalCancellationError: PipelineError | undefined;\n\n const recordUnstartedStep = (step: AnyStep<TOptions>, error: PipelineError): void => {\n const plannedStep = plannedStepFor(step);\n // Only the external signal can override a selected step's planned skip.\n if (plannedStep.skipReason && (!plannedStep.selected || error !== externalCancellationError)) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, { reason: plannedStep.skipReason, dependencyId });\n } else if (error.kind === \"cancellation\") {\n state.cancelStep(plannedStep, { ...error, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: `Not run because fail-fast stopped after ${error.stepId} failed.`,\n dependencyId: error.stepId,\n });\n }\n };\n\n const recordExternalCancellation = (stepId: string): PipelineError | undefined => {\n if (externalCancellationError) return externalCancellationError;\n try {\n throwIfAborted(runtime);\n return undefined;\n } catch (error) {\n externalCancellationError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([externalCancellationError]);\n return externalCancellationError;\n }\n };\n\n const cancelBeforeStepStart = (step: AnyStep<TOptions>): boolean => {\n const pipelineError = recordExternalCancellation(step.id);\n if (!pipelineError) return false;\n stopError ??= pipelineError;\n recordUnstartedStep(step, pipelineError);\n return true;\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n attempt: PipelineStepAttempt\n ): void => {\n const cancelled = isPipelineCancellation(error, runtime);\n const childFailure =\n error instanceof PipelineExecutionError || error instanceof PipelineChildError;\n const validationFailure = error instanceof PipelineBoundaryValidationError;\n const pipelineError = toPipelineError(error, {\n code: cancelled\n ? \"TUBELESS_RUN_CANCELLED\"\n : validationFailure\n ? \"TUBELESS_STEP_OUTPUT_VALIDATION_FAILED\"\n : childFailure\n ? \"TUBELESS_CHILD_FAILED\"\n : \"TUBELESS_STEP_FAILED\",\n kind: cancelled\n ? \"cancellation\"\n : validationFailure\n ? \"validation\"\n : childFailure\n ? \"child\"\n : \"step\",\n phase: \"execution\",\n stepId: plannedStep.id,\n });\n state.failStep(plannedStep, attempt, pipelineError);\n if (!controls.continueOnError) stopError ??= pipelineError;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n reason: string,\n value: unknown\n ): Promise<void> => {\n let attempt: PipelineStepAttempt | undefined;\n let published = value;\n if (step.outputSchema) {\n attempt = state.beginAttempt(plannedStep);\n try {\n published = await validateStepOutput(\n step,\n value,\n `Pipeline ${compiled.id} step ${step.id} output`\n );\n } catch (error) {\n return recordStepExecutionFailure(error, plannedStep, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n };\n\n const executeOneStep = async (step: AnyStep<TOptions>): Promise<void> => {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step)) return;\n\n const graph = compiledStepGraph(compiled, step);\n const disposition = decideStepDisposition({\n dryRun,\n graph,\n planned: plannedStep,\n reportsByStepId: state.reportsByStepId,\n step,\n });\n if (disposition.kind === \"skip\") {\n state.skipStep(plannedStep, disposition);\n return;\n }\n\n const inputEntries: Array<[string, unknown]> = [];\n for (const dep of graph.dependsOn) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n for (const dep of graph.optionalDependsOn) {\n if (state.outputs.has(dep.id)) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n }\n const stepInputs = Object.fromEntries(inputEntries);\n\n if (typeof step.skip === \"function\") {\n let skipDecision;\n try {\n skipDecision = await evaluateStepSkip(step, stepInputs, {\n ...executionContext,\n log: tracedLogger(step.id),\n });\n } catch (error) {\n const attempt = state.beginAttempt(plannedStep);\n recordStepExecutionFailure(error, plannedStep, attempt);\n return;\n }\n if (cancelBeforeStepStart(step)) return;\n if (skipDecision) {\n await recordPolicySkip(plannedStep, step, skipDecision.reason, skipDecision.value);\n return;\n }\n }\n\n const attempt = state.beginAttempt(plannedStep);\n try {\n const output = await executeStepAttempt({\n attemptId: attempt.attemptId,\n context: executionContext,\n dryRun,\n inputs: stepInputs,\n log: tracedLogger(step.id, attempt.attemptId),\n onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),\n onReportAttempt: (number, attributes) =>\n lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),\n outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,\n step,\n });\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n };\n\n const unstarted = await schedulePipelineSteps({\n orderedSteps,\n stepGraph: compiled.stepGraph,\n maxConcurrency,\n executeOneStep,\n shouldStop: () => stopError !== undefined || runtime.signal?.aborted === true,\n });\n if (unstarted.length > 0 && runtime.signal?.aborted) {\n // An external abort takes precedence for work that never started, even\n // when an earlier failure stopped dispatch. Keep every active step's outcome.\n // Only reuse diagnostics created from this signal, never a step-local AbortError.\n stopError = recordExternalCancellation(unstarted[0]!.id)!;\n }\n for (const step of unstarted) recordUnstartedStep(step, stopError!);\n\n if (state.errors.length === 0 || controls.continueOnError) {\n const finalizeStartedAt = runtime.now();\n state.beginFinalization();\n try {\n throwIfAborted(runtime);\n // SAFETY: `state.outputs` maps step ids to their produced values, which is\n // exactly the shape the finalizer's outputs parameter describes.\n const finalOutputs = Object.fromEntries(state.outputs) as Parameters<\n CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]\n >[0];\n const finalizedValue = await compiled.finalize(finalOutputs, {\n ...executionContext,\n log: tracedLogger(PIPELINE_FINALIZE_STEP_ID),\n });\n // SAFETY: with a result schema the value is validated against\n // `TPipelineResult`; without one the finalizer's declared return type\n // is `TPipelineResult`, so the cast only restores that type.\n const value = compiled.resultSchema\n ? ((await validateStandardSchema(\n compiled.resultSchema,\n finalizedValue,\n `Pipeline ${compiled.id} final result`\n )) as TPipelineResult)\n : (finalizedValue as TPipelineResult);\n state.completeFinalization(value, runtime.now() - finalizeStartedAt);\n } catch (error) {\n const cancelled = isPipelineCancellation(error, runtime);\n const validationFailure = error instanceof PipelineBoundaryValidationError;\n const pipelineError = toPipelineError(error, {\n code: cancelled\n ? \"TUBELESS_FINALIZATION_CANCELLED\"\n : validationFailure\n ? \"TUBELESS_FINAL_RESULT_VALIDATION_FAILED\"\n : \"TUBELESS_FINALIZATION_FAILED\",\n kind: cancelled ? \"cancellation\" : validationFailure ? \"validation\" : \"finalization\",\n phase: \"finalization\",\n stepId: PIPELINE_FINALIZE_STEP_ID,\n });\n state.failFinalization(pipelineError, runtime.now() - finalizeStartedAt);\n }\n }\n\n return state.finish();\n}\n\nconst fallbackNow = (): number => Date.now();\n\nconst fallbackSleep = (durationMs: number, signal?: AbortSignal): Promise<void> =>\n abortableSleep(durationMs, signal, \"Pipeline sleep\");\n\nexport function defaultPipelineContext(): PipelineContext {\n return { cwd: process.cwd(), log: console, now: fallbackNow, sleep: fallbackSleep };\n}\n\nexport function resolvePipelineRuntime(context: Partial<PipelineContext> = {}): PipelineRuntime {\n const defaults = defaultPipelineContext();\n return {\n ...defaults,\n ...context,\n cwd: context.cwd ?? defaults.cwd,\n log: context.log ?? defaults.log,\n now: context.now ?? defaults.now ?? fallbackNow,\n sleep: context.sleep ?? defaults.sleep ?? fallbackSleep,\n };\n}\n"]}
1
+ {"version":3,"file":"pipeline-execute.js","sourceRoot":"","sources":["../../src/core/pipeline-execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,qBAAq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AG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,WAAW;QAC/C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,IAAI,aAAa;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import { abortableSleep, throwIfAborted as throwIfSignalAborted } from \"../utilities/abort.js\";\nimport { createPipelineLifecycleObserver } from \"./lifecycle.js\";\nimport { createRunId } from \"./pipeline-ids.js\";\nimport type { CompiledPipeline } from \"./pipeline-compiler.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport { decideStepDisposition } from \"./pipeline-disposition.js\";\nimport { schedulePipelineSteps } from \"./pipeline-scheduler.js\";\nimport { compiledStepGraph } from \"./pipeline-graph.js\";\nimport { planStepById, stepToPlanStep } from \"./pipeline-plan.js\";\nimport { PipelineRunState, type PipelineStepAttempt } from \"./pipeline-run-state.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { PIPELINE_FINALIZE_STEP_ID } from \"./pipeline-step-metadata.js\";\nimport {\n evaluateStepSkip,\n executeStepAttempt,\n validateStepOutput,\n} from \"./pipeline-step-executor.js\";\nimport type {\n InferSchemaOutput,\n PipelineContext,\n PipelineError,\n PipelineExecutionContext,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\nimport { PipelineBoundaryValidationError, validateStandardSchema } from \"./pipeline-validation.js\";\nimport {\n finalizationError,\n stepExecutionError,\n toPipelineError,\n} from \"./pipeline-execution-error.js\";\n\ntype PipelineRunIdentity = { correlationId?: string; parentRunId?: string; runId: string };\n\nfunction throwIfAborted(runtime: PipelineRuntime): void {\n throwIfSignalAborted(runtime.signal, \"Pipeline run\");\n}\n\nexport async function executePlannedRun<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(input: {\n compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;\n controls: PipelineRunControls;\n domainOptions: object;\n plan: PipelinePlan;\n runtime: PipelineRuntime;\n overrides?: ReadonlyMap<AnyStep, unknown>;\n}): Promise<\n PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>\n> {\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TOptions = StepsOptions<TSteps>;\n const { compiled, controls, runtime } = input;\n const startedAtMs = runtime.now();\n const runId = createRunId(compiled.id);\n const correlationId = runtime.correlationId;\n const identity: PipelineRunIdentity = { runId };\n if (correlationId !== undefined) identity.correlationId = correlationId;\n if (runtime.parentRunId) identity.parentRunId = runtime.parentRunId;\n const dryRun = controls.dryRun === true;\n const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, {\n ...identity,\n itemKey: runtime.tracing?.itemKey,\n iteration: runtime.tracing?.iteration,\n });\n const state = new PipelineRunState<TPipelineResult>(\n compiled.id,\n dryRun,\n startedAtMs,\n identity,\n runtime.now,\n lifecycle\n );\n state.start(input.plan, compiled.targetIds);\n\n if (!input.plan.ok) {\n state.recordRunErrors(input.plan.errors);\n return state.finish();\n }\n\n const maxConcurrency = controls.maxConcurrency ?? 1;\n\n // SAFETY: `domainOptions` is the user-supplied options object; if a schema\n // is present it is re-validated below before assignment to `pipelineOptions`.\n let pipelineOptions = input.domainOptions as TOptions;\n if (compiled.optionsSchema) {\n try {\n const validated = await validateStandardSchema(\n compiled.optionsSchema,\n input.domainOptions,\n `Pipeline ${compiled.id} options`\n );\n if (typeof validated !== \"object\" || validated === null || Array.isArray(validated)) {\n throw new PipelineBoundaryValidationError(\n `Pipeline ${compiled.id} options schema returned a non-object value`,\n [{ message: \"Expected the validated options value to be an object\" }]\n );\n }\n // SAFETY: the schema validated the value against `TOptions` and the\n // object-shape check above passed, so the value is a `TOptions`.\n pipelineOptions = validated as TOptions;\n } catch (error) {\n state.recordRunErrors([\n toPipelineError(error, {\n code: \"TUBELESS_OPTIONS_VALIDATION_FAILED\",\n kind: \"validation\",\n phase: \"execution\",\n }),\n ]);\n return state.finish();\n }\n }\n\n for (const step of input.plan.steps) state.planStep(step);\n\n const executionContext: PipelineExecutionContext<TOptions> = {\n ...runtime,\n dryRun,\n log: lifecycle.logger(),\n options: pipelineOptions,\n runId,\n trace: lifecycle.traceContext,\n };\n\n const plannedSteps = planStepById(input.plan);\n const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));\n // `input.plan.steps` is already topologically ordered. Rehydrate from the original step\n // objects so callers still get the typed handlers rather than plan metadata.\n // SAFETY: every planned step id originates from `compiled.orderedSteps`, so the\n // map lookup always finds the matching `AnyStep<TOptions>`.\n const orderedSteps = input.plan.steps.map((step) => stepsById.get(step.id) as AnyStep<TOptions>);\n const plannedStepFor = (step: AnyStep<TOptions>): PipelinePlanStep =>\n plannedSteps.get(step.id) ??\n stepToPlanStep(step, true, undefined, undefined, compiledStepGraph(compiled, step));\n\n let stopError: PipelineError | undefined;\n let externalCancellationError: PipelineError | undefined;\n\n const recordUnstartedStep = (step: AnyStep<TOptions>, error: PipelineError): void => {\n const plannedStep = plannedStepFor(step);\n // Only the external signal can override a selected step's planned skip.\n if (plannedStep.skipReason && (!plannedStep.selected || error !== externalCancellationError)) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, { reason: plannedStep.skipReason, dependencyId });\n } else if (error.kind === \"cancellation\") {\n state.cancelStep(plannedStep, { ...error, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: `Not run because fail-fast stopped after ${error.stepId} failed.`,\n dependencyId: error.stepId,\n });\n }\n };\n\n const recordExternalCancellation = (stepId: string): PipelineError | undefined => {\n if (externalCancellationError) return externalCancellationError;\n try {\n throwIfAborted(runtime);\n return undefined;\n } catch (error) {\n externalCancellationError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([externalCancellationError]);\n return externalCancellationError;\n }\n };\n\n const cancelBeforeStepStart = (step: AnyStep<TOptions>): boolean => {\n const pipelineError = recordExternalCancellation(step.id);\n if (!pipelineError) return false;\n stopError ??= pipelineError;\n recordUnstartedStep(step, pipelineError);\n return true;\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n attempt: PipelineStepAttempt\n ): void => {\n const pipelineError = stepExecutionError(error, runtime, plannedStep.id);\n state.failStep(plannedStep, attempt, pipelineError);\n if (!controls.continueOnError) stopError ??= pipelineError;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n reason: string,\n value: unknown\n ): Promise<void> => {\n let attempt: PipelineStepAttempt | undefined;\n let published = value;\n if (step.outputSchema) {\n attempt = state.beginAttempt(plannedStep);\n try {\n published = await validateStepOutput(\n step,\n value,\n `Pipeline ${compiled.id} step ${step.id} output`\n );\n } catch (error) {\n return recordStepExecutionFailure(error, plannedStep, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n };\n\n const executeOneStep = async (step: AnyStep<TOptions>): Promise<void> => {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step)) return;\n\n if (plannedStep.selected && input.overrides?.has(step)) {\n const attempt = state.beginAttempt(plannedStep, runtime.now(), \"override\");\n try {\n const output = await validateStepOutput(\n step,\n input.overrides.get(step),\n `Pipeline ${compiled.id} step ${step.id} override output`\n );\n throwIfAborted(runtime);\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n return;\n }\n\n const graph = compiledStepGraph(compiled, step);\n const disposition = decideStepDisposition({\n dryRun,\n graph,\n planned: plannedStep,\n reportsByStepId: state.reportsByStepId,\n step,\n });\n if (disposition.kind === \"skip\") {\n state.skipStep(plannedStep, disposition);\n return;\n }\n\n const inputEntries: Array<[string, unknown]> = [];\n for (const dep of graph.dependsOn) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n for (const dep of graph.optionalDependsOn) {\n if (state.outputs.has(dep.id)) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n }\n const stepInputs = Object.fromEntries(inputEntries);\n\n if (typeof step.skip === \"function\") {\n let skipDecision;\n try {\n skipDecision = await evaluateStepSkip(step, stepInputs, {\n ...executionContext,\n log: lifecycle.logger(step.id),\n });\n } catch (error) {\n const attempt = state.beginAttempt(plannedStep);\n recordStepExecutionFailure(error, plannedStep, attempt);\n return;\n }\n if (cancelBeforeStepStart(step)) return;\n if (skipDecision) {\n await recordPolicySkip(plannedStep, step, skipDecision.reason, skipDecision.value);\n return;\n }\n }\n\n const attempt = state.beginAttempt(plannedStep);\n try {\n const output = await executeStepAttempt({\n attemptId: attempt.attemptId,\n context: executionContext,\n dryRun,\n inputs: stepInputs,\n log: lifecycle.logger(step.id, attempt.attemptId),\n onArtifact: (record, preview) =>\n lifecycle.recordArtifact(step.id, attempt.attemptId, record, preview),\n onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),\n onReportAttempt: (number, attributes) =>\n lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),\n outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,\n step,\n });\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n };\n\n const unstarted = await schedulePipelineSteps({\n orderedSteps,\n stepGraph: compiled.stepGraph,\n maxConcurrency,\n executeOneStep,\n shouldStop: () => stopError !== undefined || runtime.signal?.aborted === true,\n });\n if (unstarted.length > 0 && runtime.signal?.aborted) {\n // An external abort takes precedence for work that never started, even\n // when an earlier failure stopped dispatch. Keep every active step's outcome.\n // Only reuse diagnostics created from this signal, never a step-local AbortError.\n stopError = recordExternalCancellation(unstarted[0]!.id)!;\n }\n for (const step of unstarted) recordUnstartedStep(step, stopError!);\n\n if (state.errors.length === 0 || controls.continueOnError) {\n const finalizeStartedAt = runtime.now();\n state.beginFinalization();\n try {\n throwIfAborted(runtime);\n // SAFETY: `state.outputs` maps step ids to their produced values, which is\n // exactly the shape the finalizer's outputs parameter describes.\n const finalOutputs = Object.fromEntries(state.outputs) as Parameters<\n CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]\n >[0];\n const finalizedValue = await compiled.finalize(finalOutputs, {\n ...executionContext,\n log: lifecycle.logger(PIPELINE_FINALIZE_STEP_ID),\n });\n // SAFETY: with a result schema the value is validated against\n // `TPipelineResult`; without one the finalizer's declared return type\n // is `TPipelineResult`, so the cast only restores that type.\n const value = compiled.resultSchema\n ? ((await validateStandardSchema(\n compiled.resultSchema,\n finalizedValue,\n `Pipeline ${compiled.id} final result`\n )) as TPipelineResult)\n : (finalizedValue as TPipelineResult);\n state.completeFinalization(value, runtime.now() - finalizeStartedAt);\n } catch (error) {\n const pipelineError = finalizationError(error, runtime);\n state.failFinalization(pipelineError, runtime.now() - finalizeStartedAt);\n }\n }\n\n return state.finish();\n}\n\nconst fallbackNow = (): number => Date.now();\n\nconst fallbackSleep = (durationMs: number, signal?: AbortSignal): Promise<void> =>\n abortableSleep(durationMs, signal, \"Pipeline sleep\");\n\nexport function defaultPipelineContext(): PipelineContext {\n return { cwd: process.cwd(), log: console, now: fallbackNow, sleep: fallbackSleep };\n}\n\nexport function resolvePipelineRuntime(context: Partial<PipelineContext> = {}): PipelineRuntime {\n const defaults = defaultPipelineContext();\n return {\n ...defaults,\n ...context,\n cwd: context.cwd ?? defaults.cwd,\n log: context.log ?? defaults.log,\n now: context.now ?? defaults.now ?? fallbackNow,\n sleep: context.sleep ?? defaults.sleep ?? fallbackSleep,\n };\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import type { PipelineError, PipelineRun, PipelineRuntime } from "./pipeline-types.js";
2
+ export declare function isCancellationOnly(errors: readonly PipelineError[]): boolean;
3
+ export declare class PipelineChildError extends Error {
4
+ readonly cancelled: boolean;
5
+ readonly fanOut?: {
6
+ failures: readonly {
7
+ error: Error;
8
+ key: string;
9
+ index: number;
10
+ cancelled: boolean;
11
+ }[];
12
+ failureCount: number;
13
+ schedulerError?: Error;
14
+ } | undefined;
15
+ constructor(message: string, cancelled?: boolean, cause?: unknown, fanOut?: {
16
+ failures: readonly {
17
+ error: Error;
18
+ key: string;
19
+ index: number;
20
+ cancelled: boolean;
21
+ }[];
22
+ failureCount: number;
23
+ schedulerError?: Error;
24
+ } | undefined);
25
+ }
26
+ /** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */
27
+ export declare class PipelineExecutionError extends Error {
28
+ readonly result: PipelineRun<unknown>;
29
+ constructor(result: PipelineRun<unknown>, message?: string);
30
+ }
31
+ export declare function toPipelineError(error: unknown, classification: Omit<PipelineError, "cause" | "message" | "sourceCode" | "stack">): PipelineError;
32
+ export declare function isPipelineCancellation(error: unknown, runtime: Pick<PipelineRuntime, "signal">): boolean;
33
+ /** Classify a failed attempt without exposing error subclasses to execution. */
34
+ export declare function stepExecutionError(error: unknown, runtime: Pick<PipelineRuntime, "signal">, stepId: string): PipelineError;
35
+ export declare function finalizationError(error: unknown, runtime: Pick<PipelineRuntime, "signal">): PipelineError;