tubeless 0.2.10 → 0.2.11

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.
@@ -12,43 +12,51 @@ function emitHook(runtime, emit) {
12
12
  }
13
13
  }
14
14
  }
15
+ function snapshotRun(result) {
16
+ if (!result.finalized)
17
+ return structuredClone(result);
18
+ // Domain results may contain functions or class instances. Only lifecycle
19
+ // metadata belongs to Tubeless; preserve the domain value's identity.
20
+ const { value, ...metadata } = result;
21
+ return { ...structuredClone(metadata), value };
22
+ }
15
23
  export function createPipelineLifecycleObserver(pipelineId, runtime, trace) {
16
24
  return {
17
25
  pipelineStart(plan, targetIds) {
18
- emitHook(runtime, (hooks) => hooks.onPipelineStart?.(plan));
26
+ emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));
19
27
  trace?.pipelineStart(plan, targetIds);
20
28
  },
21
29
  stepStatus(event, traceStatus = true) {
22
- emitHook(runtime, (hooks) => hooks.onStepStatus?.(event));
30
+ emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));
23
31
  switch (event.status) {
24
32
  case "planned":
25
- emitHook(runtime, (hooks) => hooks.onStepPlan?.(event));
33
+ emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));
26
34
  break;
27
35
  case "running":
28
36
  if (event.progress) {
29
37
  const progress = event.progress;
30
- emitHook(runtime, (hooks) => hooks.onStepProgress?.({ ...event, progress }));
38
+ emitHook(runtime, (hooks) => hooks.onStepProgress?.(structuredClone({ ...event, progress })));
31
39
  }
32
40
  else {
33
41
  emitHook(runtime, (hooks) => hooks.onStepStart?.({
34
42
  attemptId: event.attemptId,
35
43
  pipelineId: event.pipelineId,
36
44
  status: "running",
37
- step: event.step,
45
+ step: structuredClone(event.step),
38
46
  }));
39
47
  }
40
48
  break;
41
49
  case "cancelled":
42
- emitHook(runtime, (hooks) => hooks.onStepCancel?.(event));
50
+ emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));
43
51
  break;
44
52
  case "failed":
45
- emitHook(runtime, (hooks) => hooks.onStepFail?.(event));
53
+ emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));
46
54
  break;
47
55
  case "skipped":
48
- emitHook(runtime, (hooks) => hooks.onStepSkip?.(event));
56
+ emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));
49
57
  break;
50
58
  case "completed":
51
- emitHook(runtime, (hooks) => hooks.onStepComplete?.(event));
59
+ emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));
52
60
  break;
53
61
  }
54
62
  if (traceStatus)
@@ -65,11 +73,11 @@ export function createPipelineLifecycleObserver(pipelineId, runtime, trace) {
65
73
  trace?.finalizeComplete(durationMs);
66
74
  },
67
75
  finalizeError(error, durationMs) {
68
- emitHook(runtime, (hooks) => hooks.onFinalizeError?.({ durationMs, error, pipelineId }));
76
+ emitHook(runtime, (hooks) => hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId }));
69
77
  trace?.finalizeError(error, durationMs);
70
78
  },
71
79
  pipelineComplete(result) {
72
- emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(result));
80
+ emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));
73
81
  trace?.pipelineComplete(result);
74
82
  },
75
83
  flush: () => trace?.flush() ?? Promise.resolve(),
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AA8BxC,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OA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7C,UAAkB,EAClB,SAA4B,EAC5B,IAAkB,EAClB,OAAwB,EACxB,MAA4B;IAE5B,MAAM,QAAQ,GAAyB,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/D,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS;QAAE,QAAQ,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;IACtF,IAAI,MAAM,CAAC,WAAW;QAAE,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAClE,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO;QAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;IACzE,MAAM,SAAS,GAAG,+BAA+B,CAC/C,UAAU,EACV,OAAO,EACP,0BAA0B,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAC5F,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type {\n PipelineError,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport {\n createPipelineTraceEmitter,\n type PipelineTraceEmitter,\n} from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n log(\n level: \"error\" | \"log\" | \"warn\",\n message: unknown,\n params?: readonly unknown[],\n stepId?: string,\n attemptId?: string\n ): void;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n trace: PipelineTraceEmitter | undefined\n): PipelineLifecycleObserver {\n return {\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(plan));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(event));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(event));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) => hooks.onStepProgress?.({ ...event, progress }));\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n pipelineId: event.pipelineId,\n status: \"running\",\n step: event.step,\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(event));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(event));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(event));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(event));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n log: (level, message, params, stepId, attemptId) =>\n trace?.log(level, message, params, stepId, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) => hooks.onFinalizeError?.({ durationMs, error, pipelineId }));\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(result));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n const lifecycle = createPipelineLifecycleObserver(\n pipelineId,\n runtime,\n createPipelineTraceEmitter(pipelineId, runtime.tracing, runtime.log, identity, runtime.now)\n );\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AA8BxC,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC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,GAAG,CAAC,CAC5F,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type {\n PipelineError,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport {\n createPipelineTraceEmitter,\n type PipelineTraceEmitter,\n} from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n log(\n level: \"error\" | \"log\" | \"warn\",\n message: unknown,\n params?: readonly unknown[],\n stepId?: string,\n attemptId?: string\n ): void;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nfunction snapshotRun(result: PipelineRun<unknown>): PipelineRun<unknown> {\n if (!result.finalized) return structuredClone(result);\n // Domain results may contain functions or class instances. Only lifecycle\n // metadata belongs to Tubeless; preserve the domain value's identity.\n const { value, ...metadata } = result;\n return { ...structuredClone(metadata), value };\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n trace: PipelineTraceEmitter | undefined\n): PipelineLifecycleObserver {\n return {\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) =>\n hooks.onStepProgress?.(structuredClone({ ...event, progress }))\n );\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n pipelineId: event.pipelineId,\n status: \"running\",\n step: structuredClone(event.step),\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n log: (level, message, params, stepId, attemptId) =>\n trace?.log(level, message, params, stepId, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) =>\n hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId })\n );\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n const lifecycle = createPipelineLifecycleObserver(\n pipelineId,\n runtime,\n createPipelineTraceEmitter(pipelineId, runtime.tracing, runtime.log, identity, runtime.now)\n );\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
@@ -5,7 +5,7 @@ import type { PipelineDefinitionSnapshot, StandardSchemaV1 } from "./pipeline-ty
5
5
  export interface CompiledPipeline<TSteps extends readonly AnyStep[] = readonly AnyStep[], TResult = unknown, TTargets extends readonly TSteps[number][] = readonly [], TResultSchema extends StandardSchemaV1 | undefined = undefined> {
6
6
  readonly definition: PipelineDefinitionSnapshot;
7
7
  readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];
8
- readonly finalize: NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>["finalize"]>;
8
+ readonly finalize: Extract<NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>["finalize"]>, (...args: never[]) => unknown>;
9
9
  readonly id: string;
10
10
  readonly optionsSchema: StandardSchemaV1 | undefined;
11
11
  readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];
@@ -22,7 +22,7 @@ export function compilePipeline(definition) {
22
22
  const authoredFinalize = definition.finalize;
23
23
  const compiledFinalize = finalizerMetadata
24
24
  ? finalizerMetadata.compile(compiledRequiredFinalizerSteps.map((step) => step.id))
25
- : authoredFinalize
25
+ : typeof authoredFinalize === "function"
26
26
  ? (outputs, context) => authoredFinalize.call(definition, outputs, context)
27
27
  : (outputs) => lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)
28
28
  ? outputs[lastStepId]
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAwBlE,MAAM,UAAU,eAAe,CAM7B,UAAwE;IAExE,MAAM,MAAM,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,oBAAoB,CAC5E,UAAU,CAAC,KAAqC,CACjD,CAAC;IACF,MAAM,iBAAiB,GAAG,yBAAyB,CAAW,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnF,MAAM,sBAAsB,GAAG,iBAAiB,EAAE,KAAK,CAAC;IACxD,MAAM,eAAe,GAAG,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AAS;QACtD,qBAAqB,EAAE,UAAU,CAAC,qBAAqB;KACxD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,UAAU,EAAE,QAAQ;QACpB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;QAC/C,wEAAwE;QACxE,0EAA0E;QAC1E,iDAAiD;QACjD,8EAA8E;QAC9E,0EAA0E;QAC1E,QAAQ,EAAE,gBAA6B;QACvC,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,aAAa,EACX,UAAU,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YAC3B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC;QAC3E,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QAC9C,SAAS;QACT,sBAAsB,EAAE,8BAA8B;YACpD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,8BAA8B,CAAC;YAC/C,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { compileDefinitionSnapshot } from \"./pipeline-definition-identity.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { validatePipelineDefinition } from \"./pipeline-definition-validation.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { compilePipelineGraph, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionSnapshot, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport interface CompiledPipeline<\n TSteps extends readonly AnyStep[] = readonly AnyStep[],\n TResult = unknown,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n readonly definition: PipelineDefinitionSnapshot;\n readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: NonNullable<\n PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]\n >;\n readonly id: string;\n readonly optionsSchema: StandardSchemaV1 | undefined;\n readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n readonly resultSchema: TResultSchema | undefined;\n readonly stepIds: readonly string[];\n readonly targetIds: readonly string[];\n}\n\nexport function compilePipeline<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>\n): CompiledPipeline<TSteps, TResult, TTargets, TResultSchema> {\n const errors = validatePipelineDefinition(definition);\n if (errors.length > 0) {\n throw new PipelineDefinitionError(definition.id, errors);\n }\n type TOptions = StepsOptions<TSteps>;\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores\n // the `TOptions` generic that the tuple erased, without changing the values.\n const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(\n definition.steps as readonly AnyStep<TOptions>[]\n );\n const finalizerMetadata = requiredFinalizerMetadata<TOptions>(definition.finalize);\n const requiredFinalizerSteps = finalizerMetadata?.steps;\n const compiledTargets = definition.targets\n ? definition.targets.map((target) => compiledByAuthorStep.get(target)!)\n : orderedSteps.slice(-1);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const lastStepId = orderedSteps.at(-1)?.id;\n const authoredFinalize = definition.finalize;\n type Finalizer = CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : authoredFinalize\n ? (outputs: Parameters<Finalizer>[0], context: Parameters<Finalizer>[1]) =>\n authoredFinalize.call(definition, outputs, context)\n : (outputs: Record<string, unknown>) =>\n lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)\n ? outputs[lastStepId]\n : undefined;\n const snapshot = compileDefinitionSnapshot({\n orderedSteps,\n stepGraph,\n targetIds: compiledTargets.map((step) => step.id),\n requiredFinalizerSteps: compiledRequiredFinalizerSteps,\n resultValidated: definition.resultSchema !== undefined,\n implementationVersion: definition.implementationVersion,\n });\n return Object.freeze({\n definition: snapshot,\n declaredTargets: Object.freeze(compiledTargets),\n // Invoke ordinary finalizers on the author's definition so method-style\n // implementations keep `this`. Required finalizers compile the same input\n // and context contract with stable required ids.\n // SAFETY: supplied finalizers preserve their signature; definePipeline checks\n // that an omitted finalizer can use the last step's output as its result.\n finalize: compiledFinalize as Finalizer,\n id: definition.id,\n optionsSchema:\n definition.steps.length === 0\n ? undefined\n : compiledByAuthorStep.get(definition.steps[0]!)?.[STEP_OPTIONS_SCHEMA],\n orderedSteps: Object.freeze([...orderedSteps]),\n stepGraph,\n requiredFinalizerSteps: compiledRequiredFinalizerSteps\n ? Object.freeze(compiledRequiredFinalizerSteps)\n : undefined,\n resultSchema: definition.resultSchema,\n stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step)!.id)),\n targetIds: Object.freeze(compiledTargets.map((step) => step.id)),\n });\n}\n"]}
1
+ {"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAyBlE,MAAM,UAAU,eAAe,CAM7B,UAAwE;IAExE,MAAM,MAAM,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,oBAAoB,CAC5E,UAAU,CAAC,KAAqC,CACjD,CAAC;IACF,MAAM,iBAAiB,GAAG,yBAAyB,CAAW,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnF,MAAM,sBAAsB,GAAG,iBAAiB,EAAE,KAAK,CAAC;IACxD,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO;QACxC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QACvE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,8BAA8B,GAAG,sB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ACjD,8EAA8E;QAC9E,0EAA0E;QAC1E,QAAQ,EAAE,gBAA6B;QACvC,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,aAAa,EACX,UAAU,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YAC3B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC;QAC3E,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QAC9C,SAAS;QACT,sBAAsB,EAAE,8BAA8B;YACpD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,8BAA8B,CAAC;YAC/C,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { compileDefinitionSnapshot } from \"./pipeline-definition-identity.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { validatePipelineDefinition } from \"./pipeline-definition-validation.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { compilePipelineGraph, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionSnapshot, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport interface CompiledPipeline<\n TSteps extends readonly AnyStep[] = readonly AnyStep[],\n TResult = unknown,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n readonly definition: PipelineDefinitionSnapshot;\n readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: Extract<\n NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]>,\n (...args: never[]) => unknown\n >;\n readonly id: string;\n readonly optionsSchema: StandardSchemaV1 | undefined;\n readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n readonly resultSchema: TResultSchema | undefined;\n readonly stepIds: readonly string[];\n readonly targetIds: readonly string[];\n}\n\nexport function compilePipeline<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>\n): CompiledPipeline<TSteps, TResult, TTargets, TResultSchema> {\n const errors = validatePipelineDefinition(definition);\n if (errors.length > 0) {\n throw new PipelineDefinitionError(definition.id, errors);\n }\n type TOptions = StepsOptions<TSteps>;\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores\n // the `TOptions` generic that the tuple erased, without changing the values.\n const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(\n definition.steps as readonly AnyStep<TOptions>[]\n );\n const finalizerMetadata = requiredFinalizerMetadata<TOptions>(definition.finalize);\n const requiredFinalizerSteps = finalizerMetadata?.steps;\n const compiledTargets = definition.targets\n ? definition.targets.map((target) => compiledByAuthorStep.get(target)!)\n : orderedSteps.slice(-1);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const lastStepId = orderedSteps.at(-1)?.id;\n const authoredFinalize = definition.finalize;\n type Finalizer = CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : typeof authoredFinalize === \"function\"\n ? (outputs: Parameters<Finalizer>[0], context: Parameters<Finalizer>[1]) =>\n authoredFinalize.call(definition, outputs, context)\n : (outputs: Record<string, unknown>) =>\n lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)\n ? outputs[lastStepId]\n : undefined;\n const snapshot = compileDefinitionSnapshot({\n orderedSteps,\n stepGraph,\n targetIds: compiledTargets.map((step) => step.id),\n requiredFinalizerSteps: compiledRequiredFinalizerSteps,\n resultValidated: definition.resultSchema !== undefined,\n implementationVersion: definition.implementationVersion,\n });\n return Object.freeze({\n definition: snapshot,\n declaredTargets: Object.freeze(compiledTargets),\n // Invoke ordinary finalizers on the author's definition so method-style\n // implementations keep `this`. Required finalizers compile the same input\n // and context contract with stable required ids.\n // SAFETY: supplied finalizers preserve their signature; definePipeline checks\n // that an omitted finalizer can use the last step's output as its result.\n finalize: compiledFinalize as Finalizer,\n id: definition.id,\n optionsSchema:\n definition.steps.length === 0\n ? undefined\n : compiledByAuthorStep.get(definition.steps[0]!)?.[STEP_OPTIONS_SCHEMA],\n orderedSteps: Object.freeze([...orderedSteps]),\n stepGraph,\n requiredFinalizerSteps: compiledRequiredFinalizerSteps\n ? Object.freeze(compiledRequiredFinalizerSteps)\n : undefined,\n resultSchema: definition.resultSchema,\n stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step)!.id)),\n targetIds: Object.freeze(compiledTargets.map((step) => step.id)),\n });\n}\n"]}
@@ -22,10 +22,12 @@ type PipelineOutputs<TSteps extends readonly AnyStep[]> = {
22
22
  [S in TSteps[number] as S["id"]]: StepOutput<S>;
23
23
  };
24
24
  type PipelineFinalizer<TSteps extends readonly AnyStep[], TResult, TResultSchema extends StandardSchemaV1 | undefined> = (outputs: Partial<PipelineOutputs<TSteps>>, context: PipelineExecutionContext<StepsOptions<TSteps>>) => (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult) | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;
25
+ type PipelineFinalizerSource<TSteps extends readonly AnyStep[], TResult, TResultSchema extends StandardSchemaV1 | undefined> = PipelineFinalizer<TSteps, TResult, TResultSchema> | (TSteps[number] & Step<string, TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult, StepsOptions<TSteps>, StepsInputOptions<TSteps>, unknown>);
25
26
  /**
26
27
  * Declarative configuration for compiling a typed pipeline.
27
28
  *
28
29
  * A pipeline may omit finalize when its final step in execution order supplies the result.
30
+ * Set finalize to a declared step to require and return its precisely typed output.
29
31
  * The default emits undefined if that step published no output. If its output cannot
30
32
  * satisfy an explicit result type or schema input, a compatible finalizer is required.
31
33
  */
@@ -38,17 +40,19 @@ export type PipelineDefinition<TSteps extends readonly AnyStep[], TResult = Defa
38
40
  /** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */
39
41
  implementationVersion?: string;
40
42
  steps: TSteps;
41
- /** Public goals; defaults to the last step in execution order. Use `[]` to expose none. */
43
+ /** Selectable public goals; omitted exposes the last step in execution order.
44
+ * This declaration never filters a run. Use `[]` to expose no goals.
45
+ */
42
46
  targets?: TTargets;
43
47
  /** Optional Standard Schema for the finalized result. */
44
48
  resultSchema?: TResultSchema;
45
49
  } & (TResultSchema extends StandardSchemaV1 ? [DefaultStepOutput<TSteps>] extends [InferSchemaInput<TResultSchema>] ? {
46
- finalize?: PipelineFinalizer<TSteps, TResult, TResultSchema>;
50
+ finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema>;
47
51
  } : {
48
- finalize: PipelineFinalizer<TSteps, TResult, TResultSchema>;
52
+ finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema>;
49
53
  } : [DefaultPipelineResult<TSteps>] extends [TResult] ? {
50
- finalize?: PipelineFinalizer<TSteps, TResult, TResultSchema>;
54
+ finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema>;
51
55
  } : {
52
- finalize: PipelineFinalizer<TSteps, TResult, TResultSchema>;
56
+ finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema>;
53
57
  });
54
58
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-definition.js","sourceRoot":"","sources":["../../src/core/pipeline-definition.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnyStep, Step, StepOutput } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaInput,\n PipelineExecutionContext,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\n/**\n * Recovers the options type from the steps themselves rather than taking it as its own\n * generic parameter. A `TOptions` parameter constrained by `TSteps extends\n * readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a\n * `definePipeline(...)` call site and silently widens `TOptions` to its bare\n * `object` constraint (context.options would lose every pipeline-specific\n * field). Structuring it as \"derive TOptions from TSteps\" instead of \"constrain TSteps by\n * TOptions\" avoids the cycle, so callers never write out any of these type parameters.\n */\nexport type StepsOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;\n\nexport type StepsInputOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut>\n ? TInputOptions\n : StepsOptions<TSteps>;\n\n/** Preserve whether the step factory supplied a runtime options schema. */\nexport type StepsOptionsSchema<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, object, unknown, infer TSchema>\n ? TSchema\n : StandardSchemaV1 | undefined;\n\nexport type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number][\"id\"];\n\nexport type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number][\"id\"];\n\n// Step types retain output and ID types, but erase their dependency graph.\n// Any declared step may therefore be last in the runtime topological order.\ntype DefaultStepOutput<TSteps extends readonly AnyStep[]> = TSteps extends readonly []\n ? undefined\n : StepOutput<TSteps[number]>;\n\nexport type DefaultPipelineResult<TSteps extends readonly AnyStep[]> =\n | DefaultStepOutput<TSteps>\n | undefined;\n\nexport type DefaultPipelineTargets<TSteps extends readonly AnyStep[]> = readonly TSteps[number][];\n\ntype PipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype PipelineFinalizer<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> = (\n outputs: Partial<PipelineOutputs<TSteps>>,\n context: PipelineExecutionContext<StepsOptions<TSteps>>\n) =>\n | (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult)\n | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;\n\n/**\n * Declarative configuration for compiling a typed pipeline.\n *\n * A pipeline may omit finalize when its final step in execution order supplies the result.\n * The default emits undefined if that step published no output. If its output cannot\n * satisfy an explicit result type or schema input, a compatible finalizer is required.\n */\nexport type PipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n id: string;\n /** Optional display name; stable identity remains `id`. */\n name?: string;\n /** Human-readable purpose shown by command and discovery surfaces. */\n description?: string;\n /** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */\n implementationVersion?: string;\n steps: TSteps;\n /** Public goals; defaults to the last step in execution order. Use `[]` to expose none. */\n targets?: TTargets;\n /** Optional Standard Schema for the finalized result. */\n resultSchema?: TResultSchema;\n} & (TResultSchema extends StandardSchemaV1\n ? [DefaultStepOutput<TSteps>] extends [InferSchemaInput<TResultSchema>]\n ? { finalize?: PipelineFinalizer<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizer<TSteps, TResult, TResultSchema> }\n : [DefaultPipelineResult<TSteps>] extends [TResult]\n ? { finalize?: PipelineFinalizer<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizer<TSteps, TResult, TResultSchema> });\n"]}
1
+ {"version":3,"file":"pipeline-definition.js","sourceRoot":"","sources":["../../src/core/pipeline-definition.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnyStep, Step, StepOutput } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaInput,\n PipelineExecutionContext,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\n/**\n * Recovers the options type from the steps themselves rather than taking it as its own\n * generic parameter. A `TOptions` parameter constrained by `TSteps extends\n * readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a\n * `definePipeline(...)` call site and silently widens `TOptions` to its bare\n * `object` constraint (context.options would lose every pipeline-specific\n * field). Structuring it as \"derive TOptions from TSteps\" instead of \"constrain TSteps by\n * TOptions\" avoids the cycle, so callers never write out any of these type parameters.\n */\nexport type StepsOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;\n\nexport type StepsInputOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut>\n ? TInputOptions\n : StepsOptions<TSteps>;\n\n/** Preserve whether the step factory supplied a runtime options schema. */\nexport type StepsOptionsSchema<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, object, unknown, infer TSchema>\n ? TSchema\n : StandardSchemaV1 | undefined;\n\nexport type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number][\"id\"];\n\nexport type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number][\"id\"];\n\n// Step types retain output and ID types, but erase their dependency graph.\n// Any declared step may therefore be last in the runtime topological order.\ntype DefaultStepOutput<TSteps extends readonly AnyStep[]> = TSteps extends readonly []\n ? undefined\n : StepOutput<TSteps[number]>;\n\nexport type DefaultPipelineResult<TSteps extends readonly AnyStep[]> =\n | DefaultStepOutput<TSteps>\n | undefined;\n\nexport type DefaultPipelineTargets<TSteps extends readonly AnyStep[]> = readonly TSteps[number][];\n\ntype PipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype PipelineFinalizer<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> = (\n outputs: Partial<PipelineOutputs<TSteps>>,\n context: PipelineExecutionContext<StepsOptions<TSteps>>\n) =>\n | (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult)\n | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;\n\ntype PipelineFinalizerSource<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> =\n | PipelineFinalizer<TSteps, TResult, TResultSchema>\n | (TSteps[number] &\n Step<\n string,\n TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult,\n StepsOptions<TSteps>,\n StepsInputOptions<TSteps>,\n unknown\n >);\n\n/**\n * Declarative configuration for compiling a typed pipeline.\n *\n * A pipeline may omit finalize when its final step in execution order supplies the result.\n * Set finalize to a declared step to require and return its precisely typed output.\n * The default emits undefined if that step published no output. If its output cannot\n * satisfy an explicit result type or schema input, a compatible finalizer is required.\n */\nexport type PipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n id: string;\n /** Optional display name; stable identity remains `id`. */\n name?: string;\n /** Human-readable purpose shown by command and discovery surfaces. */\n description?: string;\n /** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */\n implementationVersion?: string;\n steps: TSteps;\n /** Selectable public goals; omitted exposes the last step in execution order.\n * This declaration never filters a run. Use `[]` to expose no goals.\n */\n targets?: TTargets;\n /** Optional Standard Schema for the finalized result. */\n resultSchema?: TResultSchema;\n} & (TResultSchema extends StandardSchemaV1\n ? [DefaultStepOutput<TSteps>] extends [InferSchemaInput<TResultSchema>]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : [DefaultPipelineResult<TSteps>] extends [TResult]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> });\n"]}
@@ -205,17 +205,6 @@ export async function executePlannedRun(input) {
205
205
  return state.finish();
206
206
  }
207
207
  const maxConcurrency = controls.maxConcurrency ?? 1;
208
- if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) {
209
- state.recordRunErrors([
210
- {
211
- code: "TUBELESS_RUN_CONCURRENCY_INVALID",
212
- kind: "validation",
213
- phase: "execution",
214
- message: "maxConcurrency must be a positive finite integer",
215
- },
216
- ]);
217
- return state.finish();
218
- }
219
208
  // SAFETY: `domainOptions` is the user-supplied options object; if a schema
220
209
  // is present it is re-validated below before assignment to `pipelineOptions`.
221
210
  let pipelineOptions = input.domainOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-execute.js","sourceRoot":"","sources":["../../src/core/pipeline-execute.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,IAAI,oBAAoB,GACvC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,WAAW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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 if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) {\n state.recordRunErrors([\n {\n code: \"TUBELESS_RUN_CONCURRENCY_INVALID\",\n kind: \"validation\",\n phase: \"execution\",\n message: \"maxConcurrency must be a positive finite integer\",\n },\n ]);\n return state.finish();\n }\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,EACL,cAAc,EACd,YAAY,EACZ,cAAc,IAAI,oBAAoB,GACvC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,+B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AAC,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"]}
@@ -8,7 +8,7 @@ export interface RequiredFinalizerMetadata<TOptions extends object> {
8
8
  type RequiredPipelineOutputs<TSteps extends readonly AnyStep[]> = {
9
9
  [S in TSteps[number] as S["id"]]-?: StepOutput<S>;
10
10
  };
11
- export declare function requiredFinalizerMetadata<TOptions extends object>(finalize: object | undefined): RequiredFinalizerMetadata<TOptions> | undefined;
11
+ export declare function requiredFinalizerMetadata<TOptions extends object>(finalize: AnyStep<TOptions> | ((...args: never[]) => unknown) | undefined): RequiredFinalizerMetadata<TOptions> | undefined;
12
12
  /**
13
13
  * Build a finalizer that only runs when every listed step published an output.
14
14
  * Presence is checked by output slot, so a successfully published `undefined`
@@ -1,5 +1,9 @@
1
1
  const REQUIRED_FINALIZER_OUTPUTS = Symbol("tubeless.requiredFinalizerOutputs");
2
2
  export function requiredFinalizerMetadata(finalize) {
3
+ if (finalize && typeof finalize !== "function") {
4
+ const id = finalize.id;
5
+ return requiredFinalizerMetadata(requireOutputs([finalize], (outputs) => outputs[id]));
6
+ }
3
7
  // SAFETY: `requireOutputs` stamps internal compilation metadata onto the
4
8
  // finalizer; the intersection only exposes that optional property.
5
9
  return finalize?.[REQUIRED_FINALIZER_OUTPUTS];
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-finalizer.js","sourceRoot":"","sources":["../../src/core/pipeline-finalizer.ts"],"names":[],"mappings":"AAIA,MAAM,0BAA0B,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AAW9F,MAAM,UAAU,yBAAyB,CACvC,QAA4B;IAE5B,yEAAyE;IACzE,mEAAmE;IACnE,OACE,QACD,EAAE,CAAC,0BAA0B,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,aAA6B,EAC7B,QAG+B;IAK/B,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,CACb,eAAkC,EAClC,OAAyD,EACzD,OAA+D,EAC/D,EAAE;QACF,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,CAC3C,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CACnE,CAAC;QACF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,sCAAsC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrF,CAAC;QACD,4EAA4E;QAC5E,6EAA6E;QAC7E,OAAO,QAAQ,CAAC,OAA6D,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC,CAAC;IACF,MAAM,iBAAiB,GAAG,CACxB,OAAyD,EACzD,OAA+D,EAC/D,EAAE,CACF,MAAM,CACJ,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAC1C,OAAO,EACP,OAAO,CACR,CAAC;IACJ,MAAM,QAAQ,GAA4D,MAAM,CAAC,MAAM,CAAC;QACtF,OAAO,EAAE,CAAC,eAAkC,EAAE,EAAE;YAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;YACrD,OAAO,CACL,OAAyD,EACzD,OAA+D,EAC/D,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC;KAC/C,CAAC,CAAC;IACH,MAAM,CAAC,cAAc,CAAC,iBAAiB,EAAE,0BAA0B,EAAE;QACnE,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { AnyStep, StepOutput } from \"./pipeline-steps.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport type { PipelineExecutionContext } from \"./pipeline-types.js\";\n\nconst REQUIRED_FINALIZER_OUTPUTS: unique symbol = Symbol(\"tubeless.requiredFinalizerOutputs\");\n\nexport interface RequiredFinalizerMetadata<TOptions extends object> {\n readonly steps: readonly AnyStep<TOptions>[];\n compile(requiredStepIds: readonly string[]): (...args: never[]) => unknown;\n}\n\ntype RequiredPipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]-?: StepOutput<S>;\n};\n\nexport function requiredFinalizerMetadata<TOptions extends object>(\n finalize: object | undefined\n): RequiredFinalizerMetadata<TOptions> | undefined {\n // SAFETY: `requireOutputs` stamps internal compilation metadata onto the\n // finalizer; the intersection only exposes that optional property.\n return (\n finalize as { [REQUIRED_FINALIZER_OUTPUTS]?: RequiredFinalizerMetadata<TOptions> } | undefined\n )?.[REQUIRED_FINALIZER_OUTPUTS];\n}\n\n/**\n * Build a finalizer that only runs when every listed step published an output.\n * Presence is checked by output slot, so a successfully published `undefined`\n * remains distinct from a structural skip or failure.\n */\nexport function requireOutputs<const TRequiredSteps extends readonly AnyStep[], TResult>(\n requiredSteps: TRequiredSteps,\n finalize: (\n outputs: RequiredPipelineOutputs<TRequiredSteps>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => TResult | Promise<TResult>\n): (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n) => TResult | Promise<TResult> {\n const uniqueRequiredSteps = [...new Set(requiredSteps)];\n const invoke = (\n requiredStepIds: readonly string[],\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => {\n const missingStepIds = requiredStepIds.filter(\n (stepId) => !Object.prototype.hasOwnProperty.call(outputs, stepId)\n );\n if (missingStepIds.length > 0) {\n throw new Error(`Required pipeline outputs missing: ${missingStepIds.join(\", \")}`);\n }\n // SAFETY: every required step id was verified present above, so the partial\n // outputs contain all required keys and are a complete required-outputs map.\n return finalize(outputs as unknown as RequiredPipelineOutputs<TRequiredSteps>, context);\n };\n const requiredFinalizer = (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) =>\n invoke(\n uniqueRequiredSteps.map((step) => step.id),\n outputs,\n context\n );\n const metadata: RequiredFinalizerMetadata<StepsOptions<TRequiredSteps>> = Object.freeze({\n compile: (requiredStepIds: readonly string[]) => {\n const snapshot = Object.freeze([...requiredStepIds]);\n return (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => invoke(snapshot, outputs, context);\n },\n steps: Object.freeze([...uniqueRequiredSteps]),\n });\n Object.defineProperty(requiredFinalizer, REQUIRED_FINALIZER_OUTPUTS, {\n value: metadata,\n });\n return requiredFinalizer;\n}\n"]}
1
+ {"version":3,"file":"pipeline-finalizer.js","sour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AM,CACJ,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAC1C,OAAO,EACP,OAAO,CACR,CAAC;IACJ,MAAM,QAAQ,GAA4D,MAAM,CAAC,MAAM,CAAC;QACtF,OAAO,EAAE,CAAC,eAAkC,EAAE,EAAE;YAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;YACrD,OAAO,CACL,OAAyD,EACzD,OAA+D,EAC/D,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC;KAC/C,CAAC,CAAC;IACH,MAAM,CAAC,cAAc,CAAC,iBAAiB,EAAE,0BAA0B,EAAE;QACnE,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { AnyStep, StepOutput } from \"./pipeline-steps.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport type { PipelineExecutionContext } from \"./pipeline-types.js\";\n\nconst REQUIRED_FINALIZER_OUTPUTS: unique symbol = Symbol(\"tubeless.requiredFinalizerOutputs\");\n\nexport interface RequiredFinalizerMetadata<TOptions extends object> {\n readonly steps: readonly AnyStep<TOptions>[];\n compile(requiredStepIds: readonly string[]): (...args: never[]) => unknown;\n}\n\ntype RequiredPipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]-?: StepOutput<S>;\n};\n\nexport function requiredFinalizerMetadata<TOptions extends object>(\n finalize: AnyStep<TOptions> | ((...args: never[]) => unknown) | undefined\n): RequiredFinalizerMetadata<TOptions> | undefined {\n if (finalize && typeof finalize !== \"function\") {\n const id = finalize.id;\n return requiredFinalizerMetadata<TOptions>(\n requireOutputs([finalize], (outputs) => outputs[id])\n );\n }\n // SAFETY: `requireOutputs` stamps internal compilation metadata onto the\n // finalizer; the intersection only exposes that optional property.\n return (\n finalize as { [REQUIRED_FINALIZER_OUTPUTS]?: RequiredFinalizerMetadata<TOptions> } | undefined\n )?.[REQUIRED_FINALIZER_OUTPUTS];\n}\n\n/**\n * Build a finalizer that only runs when every listed step published an output.\n * Presence is checked by output slot, so a successfully published `undefined`\n * remains distinct from a structural skip or failure.\n */\nexport function requireOutputs<const TRequiredSteps extends readonly AnyStep[], TResult>(\n requiredSteps: TRequiredSteps,\n finalize: (\n outputs: RequiredPipelineOutputs<TRequiredSteps>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => TResult | Promise<TResult>\n): (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n) => TResult | Promise<TResult> {\n const uniqueRequiredSteps = [...new Set(requiredSteps)];\n const invoke = (\n requiredStepIds: readonly string[],\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => {\n const missingStepIds = requiredStepIds.filter(\n (stepId) => !Object.prototype.hasOwnProperty.call(outputs, stepId)\n );\n if (missingStepIds.length > 0) {\n throw new Error(`Required pipeline outputs missing: ${missingStepIds.join(\", \")}`);\n }\n // SAFETY: every required step id was verified present above, so the partial\n // outputs contain all required keys and are a complete required-outputs map.\n return finalize(outputs as unknown as RequiredPipelineOutputs<TRequiredSteps>, context);\n };\n const requiredFinalizer = (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) =>\n invoke(\n uniqueRequiredSteps.map((step) => step.id),\n outputs,\n context\n );\n const metadata: RequiredFinalizerMetadata<StepsOptions<TRequiredSteps>> = Object.freeze({\n compile: (requiredStepIds: readonly string[]) => {\n const snapshot = Object.freeze([...requiredStepIds]);\n return (\n outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>,\n context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>\n ) => invoke(snapshot, outputs, context);\n },\n steps: Object.freeze([...uniqueRequiredSteps]),\n });\n Object.defineProperty(requiredFinalizer, REQUIRED_FINALIZER_OUTPUTS, {\n value: metadata,\n });\n return requiredFinalizer;\n}\n"]}
@@ -86,6 +86,10 @@ export function buildPipelinePlan(compiled, controls) {
86
86
  const declaredTargetIds = new Set(compiled.declaredTargets.map((target) => target.id));
87
87
  const requestedStepIds = controls.stepIds ?? [];
88
88
  const requestedTargets = controls.targets ?? [];
89
+ const maxConcurrency = controls.maxConcurrency ?? 1;
90
+ if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) {
91
+ errors.push(pipelineDiagnostic("TUBELESS_RUN_CONCURRENCY_INVALID", "planning", "validation", "maxConcurrency must be a positive finite integer"));
92
+ }
89
93
  if (controls.stepIds !== undefined && controls.targets !== undefined) {
90
94
  errors.push(pipelineDiagnostic("TUBELESS_PLANNING_SELECTION_CONFLICT", "planning", "selection", `Pipeline ${compiled.id} cannot combine exact stepIds filtering with dependency-aware targets`));
91
95
  }