tubeless 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +52 -52
  2. package/dist/cli/cli-types.d.ts +1 -1
  3. package/dist/cli/cli-types.js.map +1 -1
  4. package/dist/cli/cli.d.ts +2 -4
  5. package/dist/cli/cli.js +1 -3
  6. package/dist/cli/cli.js.map +1 -1
  7. package/dist/core/child-execution.js +2 -4
  8. package/dist/core/child-execution.js.map +1 -1
  9. package/dist/core/lifecycle.d.ts +1 -1
  10. package/dist/core/lifecycle.js.map +1 -1
  11. package/dist/core/pipeline-compiler.d.ts +17 -0
  12. package/dist/core/pipeline-compiler.js +44 -0
  13. package/dist/core/pipeline-compiler.js.map +1 -0
  14. package/dist/core/pipeline-definition-validation.d.ts +4 -0
  15. package/dist/core/pipeline-definition-validation.js +101 -0
  16. package/dist/core/pipeline-definition-validation.js.map +1 -0
  17. package/dist/core/pipeline-definition.d.ts +28 -0
  18. package/dist/core/pipeline-definition.js +2 -0
  19. package/dist/core/pipeline-definition.js.map +1 -0
  20. package/dist/core/pipeline-disposition.d.ts +26 -0
  21. package/dist/core/pipeline-disposition.js +44 -0
  22. package/dist/core/pipeline-disposition.js.map +1 -0
  23. package/dist/core/pipeline-errors.d.ts +8 -0
  24. package/dist/core/pipeline-errors.js +20 -0
  25. package/dist/core/pipeline-errors.js.map +1 -0
  26. package/dist/core/pipeline-execute.d.ts +1 -1
  27. package/dist/core/pipeline-execute.js +5 -2
  28. package/dist/core/pipeline-execute.js.map +1 -1
  29. package/dist/core/pipeline-finalizer.d.ts +18 -0
  30. package/dist/core/pipeline-finalizer.js +37 -0
  31. package/dist/core/pipeline-finalizer.js.map +1 -0
  32. package/dist/core/pipeline-graph.d.ts +23 -0
  33. package/dist/core/pipeline-graph.js +135 -0
  34. package/dist/core/pipeline-graph.js.map +1 -0
  35. package/dist/core/pipeline-identity.d.ts +5 -0
  36. package/dist/core/pipeline-identity.js +11 -0
  37. package/dist/core/pipeline-identity.js.map +1 -0
  38. package/dist/core/pipeline-mermaid.d.ts +4 -0
  39. package/dist/core/pipeline-mermaid.js +56 -0
  40. package/dist/core/pipeline-mermaid.js.map +1 -0
  41. package/dist/core/pipeline-plan.d.ts +5 -94
  42. package/dist/core/pipeline-plan.js +5 -454
  43. package/dist/core/pipeline-plan.js.map +1 -1
  44. package/dist/core/pipeline-step-executor.d.ts +1 -1
  45. package/dist/core/pipeline-step-executor.js.map +1 -1
  46. package/dist/core/pipeline-step-metadata.d.ts +4 -0
  47. package/dist/core/pipeline-step-metadata.js +5 -0
  48. package/dist/core/pipeline-step-metadata.js.map +1 -0
  49. package/dist/core/pipeline-steps.d.ts +1 -1
  50. package/dist/core/pipeline-steps.js +1 -1
  51. package/dist/core/pipeline-steps.js.map +1 -1
  52. package/dist/core/pipeline-types.d.ts +10 -10
  53. package/dist/core/pipeline-types.js +8 -0
  54. package/dist/core/pipeline-types.js.map +1 -1
  55. package/dist/core/pipeline.d.ts +8 -9
  56. package/dist/core/pipeline.js +9 -6
  57. package/dist/core/pipeline.js.map +1 -1
  58. package/dist/node/node.d.ts +0 -3
  59. package/dist/node/node.js +0 -3
  60. package/dist/node/node.js.map +1 -1
  61. package/dist/reporter/reporter-entry.d.ts +1 -2
  62. package/dist/reporter/reporter-entry.js +1 -2
  63. package/dist/reporter/reporter-entry.js.map +1 -1
  64. package/dist/run-store/run-store-codec.d.ts +4 -0
  65. package/dist/run-store/run-store-codec.js +31 -0
  66. package/dist/run-store/run-store-codec.js.map +1 -0
  67. package/dist/run-store/run-store-sqlite.js +9 -55
  68. package/dist/run-store/run-store-sqlite.js.map +1 -1
  69. package/dist/run-store/run-store.d.ts +1 -1
  70. package/dist/run-store/run-store.js.map +1 -1
  71. package/dist/studio/run-store-ui-client-app.d.ts +12 -0
  72. package/dist/studio/run-store-ui-client-app.js +224 -0
  73. package/dist/studio/run-store-ui-client-app.js.map +1 -0
  74. package/dist/studio/run-store-ui-client-browser.d.ts +1 -0
  75. package/dist/studio/run-store-ui-client-browser.js +2 -0
  76. package/dist/studio/run-store-ui-client-commands.d.ts +18 -0
  77. package/dist/studio/run-store-ui-client-commands.js +98 -0
  78. package/dist/studio/run-store-ui-client-commands.js.map +1 -0
  79. package/dist/studio/run-store-ui-client-form.d.ts +2 -0
  80. package/dist/studio/run-store-ui-client-form.js +10 -0
  81. package/dist/studio/run-store-ui-client-form.js.map +1 -1
  82. package/dist/studio/run-store-ui-client-modals.d.ts +20 -0
  83. package/dist/studio/run-store-ui-client-modals.js +154 -0
  84. package/dist/studio/run-store-ui-client-modals.js.map +1 -0
  85. package/dist/studio/run-store-ui-client-model.d.ts +0 -21
  86. package/dist/studio/run-store-ui-client-model.js +2 -24
  87. package/dist/studio/run-store-ui-client-model.js.map +1 -1
  88. package/dist/studio/run-store-ui-client-runs.d.ts +24 -0
  89. package/dist/studio/run-store-ui-client-runs.js +78 -0
  90. package/dist/studio/run-store-ui-client-runs.js.map +1 -0
  91. package/dist/studio/run-store-ui-client-shared.d.ts +22 -0
  92. package/dist/studio/run-store-ui-client-shared.js +63 -0
  93. package/dist/studio/run-store-ui-client-shared.js.map +1 -0
  94. package/dist/studio/run-store-ui-client-transport.js +7 -12
  95. package/dist/studio/run-store-ui-client-transport.js.map +1 -1
  96. package/dist/studio/run-store-ui-client.d.ts +1 -1
  97. package/dist/studio/run-store-ui-client.js +8 -6
  98. package/dist/studio/run-store-ui-client.js.map +1 -1
  99. package/dist/studio/run-store-ui-page.d.ts +2 -2
  100. package/dist/studio/run-store-ui-page.js +7 -71
  101. package/dist/studio/run-store-ui-page.js.map +1 -1
  102. package/dist/studio/run-store-ui.d.ts +1 -1
  103. package/dist/studio/run-store-ui.js +3 -4
  104. package/dist/studio/run-store-ui.js.map +1 -1
  105. package/dist/tracing/tracing-codec.d.ts +4 -5
  106. package/dist/tracing/tracing-codec.js +8 -824
  107. package/dist/tracing/tracing-codec.js.map +1 -1
  108. package/dist/tracing/tracing-contracts.d.ts +31 -0
  109. package/dist/tracing/tracing-contracts.js +2 -0
  110. package/dist/tracing/tracing-contracts.js.map +1 -0
  111. package/dist/tracing/tracing-internal.d.ts +1 -1
  112. package/dist/tracing/tracing-internal.js.map +1 -1
  113. package/dist/tracing/tracing-schema.d.ts +809 -0
  114. package/dist/tracing/tracing-schema.js +429 -0
  115. package/dist/tracing/tracing-schema.js.map +1 -0
  116. package/dist/tracing/tracing.d.ts +2 -193
  117. package/dist/tracing/tracing.js.map +1 -1
  118. package/dist/tracing/wire-schema.d.ts +50 -0
  119. package/dist/tracing/wire-schema.js +193 -0
  120. package/dist/tracing/wire-schema.js.map +1 -0
  121. package/dist/workbench/pipeline-module.js +4 -4
  122. package/dist/workbench/pipeline-module.js.map +1 -1
  123. package/dist/workbench/workbench-entry.d.ts +2 -0
  124. package/dist/workbench/workbench-entry.js +3 -0
  125. package/dist/workbench/workbench-entry.js.map +1 -0
  126. package/dist/workbench/workbench-ui.js +13 -37
  127. package/dist/workbench/workbench-ui.js.map +1 -1
  128. package/docs/README.md +4 -3
  129. package/docs/agent-guide.md +25 -44
  130. package/docs/api-reference.md +14 -194
  131. package/docs/api-report.json +13 -231
  132. package/docs/child-pipeline-composition.md +0 -3
  133. package/docs/cli.md +5 -5
  134. package/docs/comparison.md +2 -1
  135. package/docs/concepts.md +16 -25
  136. package/docs/getting-started.md +6 -5
  137. package/docs/llms.txt +2 -5
  138. package/docs/recipes.md +25 -31
  139. package/docs/studio.md +6 -44
  140. package/examples/catalog/scripts/enrich.ts +1 -1
  141. package/examples/catalog/scripts/import.ts +1 -1
  142. package/examples/catalog/scripts/publish.ts +1 -1
  143. package/examples/catalog/tubeless.project.ts +2 -1
  144. package/examples/cli-job.ts +1 -1
  145. package/examples/live-tui.ts +1 -1
  146. package/examples/peloton.ts +1 -1
  147. package/examples/tracing.ts +96 -5
  148. package/package.json +8 -56
  149. package/skills/tubeless/SKILL.md +4 -2
  150. package/dist/node/env.d.ts +0 -1
  151. package/dist/node/env.js +0 -8
  152. package/dist/node/env.js.map +0 -1
  153. package/dist/node/file-utils.d.ts +0 -3
  154. package/dist/node/file-utils.js +0 -17
  155. package/dist/node/file-utils.js.map +0 -1
  156. package/dist/node/paths.d.ts +0 -8
  157. package/dist/node/paths.js +0 -19
  158. package/dist/node/paths.js.map +0 -1
  159. package/dist/reporter/prompt-select.d.ts +0 -80
  160. package/dist/reporter/prompt-select.js +0 -197
  161. package/dist/reporter/prompt-select.js.map +0 -1
  162. package/dist/studio/run-store-ui-client-controller.d.ts +0 -9
  163. package/dist/studio/run-store-ui-client-controller.js +0 -479
  164. package/dist/studio/run-store-ui-client-controller.js.map +0 -1
  165. package/dist/studio/run-store-ui-client-source.d.ts +0 -1
  166. package/dist/studio/run-store-ui-client-source.js +0 -1
  167. package/dist/studio/run-store-ui-client-views.d.ts +0 -24
  168. package/dist/studio/run-store-ui-client-views.js +0 -676
  169. package/dist/studio/run-store-ui-client-views.js.map +0 -1
  170. package/dist/tracing/tracing-json.d.ts +0 -11
  171. package/dist/tracing/tracing-json.js +0 -8
  172. package/dist/tracing/tracing-json.js.map +0 -1
  173. package/dist/tracing/tracing-otel.d.ts +0 -35
  174. package/dist/tracing/tracing-otel.js +0 -76
  175. package/dist/tracing/tracing-otel.js.map +0 -1
  176. package/dist/workbench/workbench-studio.d.ts +0 -29
  177. package/dist/workbench/workbench-studio.js +0 -61
  178. package/dist/workbench/workbench-studio.js.map +0 -1
  179. package/examples/catalog/tubeless.studio.ts +0 -20
  180. package/examples/local-observability.ts +0 -105
  181. package/examples/rendering.ts +0 -34
@@ -0,0 +1,44 @@
1
+ import { validatePipelineDefinition } from "./pipeline-definition-validation.js";
2
+ import { PipelineDefinitionError } from "./pipeline-errors.js";
3
+ import { requiredFinalizerMetadata } from "./pipeline-finalizer.js";
4
+ import { compilePipelineGraph } from "./pipeline-graph.js";
5
+ import { STEP_OPTIONS_SCHEMA } from "./pipeline-step-metadata.js";
6
+ export function compilePipeline(definition) {
7
+ const errors = validatePipelineDefinition(definition);
8
+ if (errors.length > 0) {
9
+ throw new PipelineDefinitionError(definition.id, errors);
10
+ }
11
+ // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores
12
+ // the `TOptions` generic that the tuple erased, without changing the values.
13
+ const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(definition.steps);
14
+ const finalizerMetadata = requiredFinalizerMetadata(definition.finalize);
15
+ const requiredFinalizerSteps = finalizerMetadata?.steps;
16
+ // SAFETY: targets are a subset of `TSteps[number]`, each an `AnyStep<TOptions>`.
17
+ const declaredTargets = (definition.targets ?? []);
18
+ const compiledTargets = declaredTargets.map((target) => compiledByAuthorStep.get(target));
19
+ const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) => compiledByAuthorStep.get(step));
20
+ const compiledFinalize = finalizerMetadata
21
+ ? finalizerMetadata.compile(compiledRequiredFinalizerSteps.map((step) => step.id))
22
+ : (outputs, context) => definition.finalize(outputs, context);
23
+ return Object.freeze({
24
+ declaredTargets: Object.freeze(compiledTargets),
25
+ // Invoke ordinary finalizers on the author's definition so method-style
26
+ // implementations keep `this`. Required finalizers compile the same input
27
+ // and context contract with stable required ids.
28
+ // SAFETY: both branches preserve `definition.finalize`'s call signature.
29
+ finalize: compiledFinalize,
30
+ id: definition.id,
31
+ optionsSchema: definition.steps.length === 0
32
+ ? undefined
33
+ : compiledByAuthorStep.get(definition.steps[0])?.[STEP_OPTIONS_SCHEMA],
34
+ orderedSteps: Object.freeze([...orderedSteps]),
35
+ stepGraph,
36
+ requiredFinalizerSteps: compiledRequiredFinalizerSteps
37
+ ? Object.freeze(compiledRequiredFinalizerSteps)
38
+ : undefined,
39
+ resultSchema: definition.resultSchema,
40
+ stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step).id)),
41
+ targetIds: Object.freeze(compiledTargets.map((step) => step.id)),
42
+ });
43
+ }
44
+ //# sourceMappingURL=pipeline-compiler.js.map
@@ -0,0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sourcesContent":["import 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 { 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 declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\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 // SAFETY: targets are a subset of `TSteps[number]`, each an `AnyStep<TOptions>`.\n const declaredTargets = (definition.targets ?? []) as readonly AnyStep<TOptions>[];\n const compiledTargets = declaredTargets.map((target) => compiledByAuthorStep.get(target)!);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : (\n outputs: Parameters<typeof definition.finalize>[0],\n context: Parameters<typeof definition.finalize>[1]\n ) => definition.finalize(outputs, context);\n return Object.freeze({\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: both branches preserve `definition.finalize`'s call signature.\n finalize: compiledFinalize as typeof definition.finalize,\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"]}
@@ -0,0 +1,4 @@
1
+ import type { PipelineDefinition } from "./pipeline-definition.js";
2
+ import type { AnyStep } from "./pipeline-steps.js";
3
+ import type { PipelineError, StandardSchemaV1 } from "./pipeline-types.js";
4
+ export declare function validatePipelineDefinition<TSteps extends readonly AnyStep[], TResult, TTargets extends readonly TSteps[number][], TResultSchema extends StandardSchemaV1 | undefined>(definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>): PipelineError[];
@@ -0,0 +1,101 @@
1
+ import { duplicateValues } from "../utilities/collections.js";
2
+ import { requiredFinalizerMetadata } from "./pipeline-finalizer.js";
3
+ import { stepEdges, targetClosure, topologicalSort } from "./pipeline-graph.js";
4
+ import { pipelineDiagnostic } from "./pipeline-errors.js";
5
+ import { PIPELINE_FINALIZE_STEP_ID, STEP_OPTIONS_SCHEMA } from "./pipeline-step-metadata.js";
6
+ export function validatePipelineDefinition(definition) {
7
+ const steps = definition.steps;
8
+ const errors = [];
9
+ if (definition.id.trim().length === 0) {
10
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_PIPELINE_ID_BLANK", "definition", "definition", "Pipeline id must not be blank"));
11
+ }
12
+ const stepIds = steps.map((step) => step.id);
13
+ const duplicateStepIds = duplicateValues(stepIds);
14
+ if (duplicateStepIds.length > 0) {
15
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_STEP_IDS_DUPLICATE", "definition", "definition", `Pipeline ${definition.id} has duplicate step ids: ${duplicateStepIds.join(", ")}`));
16
+ }
17
+ const optionsSchemas = new Set(steps.map((step) => step[STEP_OPTIONS_SCHEMA]));
18
+ if (optionsSchemas.size > 1 && [...optionsSchemas].some(Boolean)) {
19
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_OPTIONS_SCHEMA_CONFLICT", "definition", "definition", `Pipeline ${definition.id} mixes steps from different options-schema scopes`));
20
+ }
21
+ for (const step of steps) {
22
+ if (step.id.trim().length === 0) {
23
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_STEP_ID_BLANK", "definition", "definition", `Pipeline ${definition.id} has a step with a blank id`, { stepId: step.id }));
24
+ }
25
+ if (step.id === PIPELINE_FINALIZE_STEP_ID) {
26
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_STEP_ID_RESERVED", "definition", "definition", `Pipeline ${definition.id} uses reserved step id ${PIPELINE_FINALIZE_STEP_ID}`, { stepId: step.id }));
27
+ }
28
+ if (step.name !== undefined && step.name.trim().length === 0) {
29
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_STEP_NAME_BLANK", "definition", "definition", `Pipeline ${definition.id} step ${step.id} has a blank display name`, { stepId: step.id }));
30
+ }
31
+ const dependencyGroups = [
32
+ ["dependsOn", step.dependsOn ?? []],
33
+ ["optionalDependsOn", step.optionalDependsOn ?? []],
34
+ ["skipAfterFailureOf", step.skipAfterFailureOf ?? []],
35
+ ];
36
+ for (const [field, dependencies] of dependencyGroups) {
37
+ const duplicates = duplicateValues(dependencies.map((dependency) => dependency.id));
38
+ if (duplicates.length > 0) {
39
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_DEPENDENCY_DUPLICATE", "definition", "definition", `Pipeline ${definition.id} step ${step.id} repeats ${field}: ${duplicates.join(", ")}`, { stepId: step.id }));
40
+ }
41
+ if (dependencies.includes(step)) {
42
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_DEPENDENCY_SELF_REFERENCE", "definition", "definition", `Pipeline ${definition.id} step ${step.id} cannot reference itself in ${field}`, { stepId: step.id }));
43
+ }
44
+ }
45
+ const required = new Set(step.dependsOn ?? []);
46
+ const contradictory = (step.optionalDependsOn ?? []).filter((dependency) => required.has(dependency));
47
+ if (contradictory.length > 0) {
48
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_DEPENDENCY_CONTRADICTORY", "definition", "definition", `Pipeline ${definition.id} step ${step.id} declares dependencies as both required and optional: ${contradictory.map(({ id }) => id).join(", ")}`, { stepId: step.id }));
49
+ }
50
+ }
51
+ // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores
52
+ // the `TOptions` generic that the tuple erased, without changing the values.
53
+ const knownSteps = new Set(steps);
54
+ // SAFETY: targets are a subset of `TSteps[number]`, each an `AnyStep<TOptions>`.
55
+ const declaredTargets = (definition.targets ?? []);
56
+ const duplicateTargetIds = duplicateValues(declaredTargets.map((target) => target.id));
57
+ if (duplicateTargetIds.length > 0) {
58
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_TARGETS_DUPLICATE", "definition", "definition", `Pipeline ${definition.id} declares duplicate targets: ${duplicateTargetIds.join(", ")}`));
59
+ }
60
+ const missingTargets = declaredTargets.filter((target) => !knownSteps.has(target));
61
+ if (missingTargets.length > 0) {
62
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_TARGET_NOT_IN_STEPS", "definition", "definition", `Pipeline ${definition.id} declares target step(s) not included in its steps list: ${missingTargets.map(({ id }) => id).join(", ")}`));
63
+ }
64
+ const missingReferences = [];
65
+ // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores the
66
+ // `TOptions` generic that the tuple erased, without changing the values.
67
+ for (const step of steps) {
68
+ for (const dependency of stepEdges(step)) {
69
+ if (!knownSteps.has(dependency)) {
70
+ missingReferences.push(`${step.id} -> ${dependency.id}`);
71
+ }
72
+ }
73
+ }
74
+ if (missingReferences.length > 0) {
75
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_DEPENDENCY_NOT_IN_STEPS", "definition", "definition", `Pipeline ${definition.id} references step(s) not included in its steps list: ${missingReferences.join(", ")}`));
76
+ }
77
+ const requiredFinalizerSteps = requiredFinalizerMetadata(definition.finalize)?.steps;
78
+ const missingFinalizerSteps = (requiredFinalizerSteps ?? []).filter((step) => !knownSteps.has(step));
79
+ if (missingFinalizerSteps.length > 0) {
80
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_FINALIZER_STEP_NOT_IN_STEPS", "definition", "definition", `Pipeline ${definition.id} requires finalizer output from step(s) not included in its steps list: ${missingFinalizerSteps.map(({ id }) => id).join(", ")}`));
81
+ }
82
+ if (requiredFinalizerSteps &&
83
+ missingTargets.length === 0 &&
84
+ missingReferences.length === 0 &&
85
+ missingFinalizerSteps.length === 0) {
86
+ for (const target of declaredTargets) {
87
+ const selected = targetClosure([target]);
88
+ const missingRequiredSteps = requiredFinalizerSteps.filter((step) => !selected.has(step));
89
+ if (missingRequiredSteps.length > 0) {
90
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_TARGET_FINALIZER_MISMATCH", "definition", "definition", `Pipeline ${definition.id} target ${target.id} cannot satisfy required finalizer output(s): ${missingRequiredSteps.map(({ id }) => id).join(", ")}`, { stepId: target.id }));
91
+ }
92
+ }
93
+ }
94
+ // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores the
95
+ // `TOptions` generic that the tuple erased, without changing the values.
96
+ if (errors.length === 0 && !topologicalSort(steps)) {
97
+ errors.push(pipelineDiagnostic("TUBELESS_DEFINITION_DEPENDENCY_CYCLE", "definition", "definition", `Pipeline ${definition.id} has a dependency cycle`));
98
+ }
99
+ return errors;
100
+ }
101
+ //# sourceMappingURL=pipeline-definition-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-definition-validation.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAG7F,MAAM,UAAU,0BAA0B,CAKxC,UAAwE;IAExE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,IAAI,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,uCAAuC,EACvC,YAAY,EACZ,YAAY,EACZ,+BAA+B,CAChC,CACF,CAAC;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,YAAY,EACZ,YAAY,UAAU,CAAC,EAAE,WAAW,MAAM,CAAC,EAAE,iDAAiD,oBAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACnJ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CACtB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,gFAAgF;IAChF,yEAAyE;IACzE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,KAAqC,CAAC,EAAE,CAAC;QACnF,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,sCAAsC,EACtC,YAAY,EACZ,YAAY,EACZ,YAAY,UAAU,CAAC,EAAE,yBAAyB,CACnD,CACF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { duplicateValues } from \"../utilities/collections.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { stepEdges, targetClosure, topologicalSort } from \"./pipeline-graph.js\";\nimport { pipelineDiagnostic } from \"./pipeline-errors.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { PIPELINE_FINALIZE_STEP_ID, STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineError, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport function validatePipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>): PipelineError[] {\n type TOptions = StepsOptions<TSteps>;\n const steps = definition.steps;\n const errors: PipelineError[] = [];\n if (definition.id.trim().length === 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_PIPELINE_ID_BLANK\",\n \"definition\",\n \"definition\",\n \"Pipeline id must not be blank\"\n )\n );\n }\n\n const stepIds = steps.map((step) => step.id);\n const duplicateStepIds = duplicateValues(stepIds);\n if (duplicateStepIds.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_STEP_IDS_DUPLICATE\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} has duplicate step ids: ${duplicateStepIds.join(\", \")}`\n )\n );\n }\n const optionsSchemas = new Set(steps.map((step) => step[STEP_OPTIONS_SCHEMA]));\n if (optionsSchemas.size > 1 && [...optionsSchemas].some(Boolean)) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_OPTIONS_SCHEMA_CONFLICT\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} mixes steps from different options-schema scopes`\n )\n );\n }\n for (const step of steps) {\n if (step.id.trim().length === 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_STEP_ID_BLANK\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} has a step with a blank id`,\n { stepId: step.id }\n )\n );\n }\n if (step.id === PIPELINE_FINALIZE_STEP_ID) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_STEP_ID_RESERVED\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} uses reserved step id ${PIPELINE_FINALIZE_STEP_ID}`,\n { stepId: step.id }\n )\n );\n }\n if (step.name !== undefined && step.name.trim().length === 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_STEP_NAME_BLANK\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} step ${step.id} has a blank display name`,\n { stepId: step.id }\n )\n );\n }\n const dependencyGroups = [\n [\"dependsOn\", step.dependsOn ?? []],\n [\"optionalDependsOn\", step.optionalDependsOn ?? []],\n [\"skipAfterFailureOf\", step.skipAfterFailureOf ?? []],\n ] as const;\n for (const [field, dependencies] of dependencyGroups) {\n const duplicates = duplicateValues(dependencies.map((dependency) => dependency.id));\n if (duplicates.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_DEPENDENCY_DUPLICATE\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} step ${step.id} repeats ${field}: ${duplicates.join(\", \")}`,\n { stepId: step.id }\n )\n );\n }\n if (dependencies.includes(step)) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_DEPENDENCY_SELF_REFERENCE\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} step ${step.id} cannot reference itself in ${field}`,\n { stepId: step.id }\n )\n );\n }\n }\n\n const required = new Set(step.dependsOn ?? []);\n const contradictory = (step.optionalDependsOn ?? []).filter((dependency) =>\n required.has(dependency)\n );\n if (contradictory.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_DEPENDENCY_CONTRADICTORY\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} step ${step.id} declares dependencies as both required and optional: ${contradictory.map(({ id }) => id).join(\", \")}`,\n { stepId: step.id }\n )\n );\n }\n }\n\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 knownSteps = new Set<AnyStep<TOptions>>(steps as readonly AnyStep<TOptions>[]);\n // SAFETY: targets are a subset of `TSteps[number]`, each an `AnyStep<TOptions>`.\n const declaredTargets = (definition.targets ?? []) as readonly AnyStep<TOptions>[];\n const duplicateTargetIds = duplicateValues(declaredTargets.map((target) => target.id));\n if (duplicateTargetIds.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_TARGETS_DUPLICATE\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} declares duplicate targets: ${duplicateTargetIds.join(\", \")}`\n )\n );\n }\n const missingTargets = declaredTargets.filter((target) => !knownSteps.has(target));\n if (missingTargets.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_TARGET_NOT_IN_STEPS\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} declares target step(s) not included in its steps list: ${missingTargets.map(({ id }) => id).join(\", \")}`\n )\n );\n }\n const missingReferences: string[] = [];\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores the\n // `TOptions` generic that the tuple erased, without changing the values.\n for (const step of steps as readonly AnyStep<TOptions>[]) {\n for (const dependency of stepEdges(step)) {\n if (!knownSteps.has(dependency)) {\n missingReferences.push(`${step.id} -> ${dependency.id}`);\n }\n }\n }\n if (missingReferences.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_DEPENDENCY_NOT_IN_STEPS\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} references step(s) not included in its steps list: ${missingReferences.join(\", \")}`\n )\n );\n }\n\n const requiredFinalizerSteps = requiredFinalizerMetadata<TOptions>(definition.finalize)?.steps;\n const missingFinalizerSteps = (requiredFinalizerSteps ?? []).filter(\n (step) => !knownSteps.has(step)\n );\n if (missingFinalizerSteps.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_FINALIZER_STEP_NOT_IN_STEPS\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} requires finalizer output from step(s) not included in its steps list: ${missingFinalizerSteps.map(({ id }) => id).join(\", \")}`\n )\n );\n }\n\n if (\n requiredFinalizerSteps &&\n missingTargets.length === 0 &&\n missingReferences.length === 0 &&\n missingFinalizerSteps.length === 0\n ) {\n for (const target of declaredTargets) {\n const selected = targetClosure([target]);\n const missingRequiredSteps = requiredFinalizerSteps.filter((step) => !selected.has(step));\n if (missingRequiredSteps.length > 0) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_TARGET_FINALIZER_MISMATCH\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} target ${target.id} cannot satisfy required finalizer output(s): ${missingRequiredSteps.map(({ id }) => id).join(\", \")}`,\n { stepId: target.id }\n )\n );\n }\n }\n }\n\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores the\n // `TOptions` generic that the tuple erased, without changing the values.\n if (errors.length === 0 && !topologicalSort(steps as readonly AnyStep<TOptions>[])) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_DEPENDENCY_CYCLE\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} has a dependency cycle`\n )\n );\n }\n return errors;\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { AnyStep, Step, StepOutput } from "./pipeline-steps.js";
2
+ import type { InferSchemaInput, PipelineExecutionContext, StandardSchemaV1 } from "./pipeline-types.js";
3
+ /**
4
+ * Recovers the options type from the steps themselves rather than taking it as its own
5
+ * generic parameter. A `TOptions` parameter constrained by `TSteps extends
6
+ * readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a
7
+ * `definePipeline(...)` call site and silently widens `TOptions` to its bare
8
+ * `object` constraint (context.options would lose every pipeline-specific
9
+ * field). Structuring it as "derive TOptions from TSteps" instead of "constrain TSteps by
10
+ * TOptions" avoids the cycle, so callers never write out any of these type parameters.
11
+ */
12
+ export type StepsOptions<TSteps extends readonly AnyStep[]> = TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;
13
+ export type StepsInputOptions<TSteps extends readonly AnyStep[]> = TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut> ? TInputOptions : StepsOptions<TSteps>;
14
+ export type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number]["id"];
15
+ export type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number]["id"];
16
+ type PipelineOutputs<TSteps extends readonly AnyStep[]> = {
17
+ [S in TSteps[number] as S["id"]]: StepOutput<S>;
18
+ };
19
+ export interface PipelineDefinition<TSteps extends readonly AnyStep[], TResult, TTargets extends readonly TSteps[number][] = readonly [], TResultSchema extends StandardSchemaV1 | undefined = undefined> {
20
+ id: string;
21
+ steps: TSteps;
22
+ /** Public downstream goals that callers may select with `targets`. */
23
+ targets?: TTargets;
24
+ /** Optional Standard Schema for the finalized result. */
25
+ resultSchema?: TResultSchema;
26
+ finalize(outputs: Partial<PipelineOutputs<TSteps>>, context: PipelineExecutionContext<StepsOptions<TSteps>>): (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult) | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;
27
+ }
28
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pipeline-definition.js.map
@@ -0,0 +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\nexport type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number][\"id\"];\n\nexport type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number][\"id\"];\n\ntype PipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\nexport interface PipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n id: string;\n steps: TSteps;\n /** Public downstream goals that callers may select with `targets`. */\n targets?: TTargets;\n /** Optional Standard Schema for the finalized result. */\n resultSchema?: TResultSchema;\n finalize(\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"]}
@@ -0,0 +1,26 @@
1
+ import type { CompiledStepGraph } from "./pipeline-graph.js";
2
+ import type { AnyStep } from "./pipeline-steps.js";
3
+ import type { PipelinePlanStep, PipelineStepReport, PipelineStepSkipReason } from "./pipeline-types.js";
4
+ type StepDispositionInput<TOptions extends object> = {
5
+ dryRun: boolean;
6
+ graph: CompiledStepGraph<TOptions>;
7
+ planned: PipelinePlanStep;
8
+ reportsByStepId: ReadonlyMap<string, PipelineStepReport>;
9
+ step: AnyStep<TOptions>;
10
+ };
11
+ type StepDisposition = {
12
+ kind: "run";
13
+ } | {
14
+ kind: "skip";
15
+ reason: PipelineStepSkipReason;
16
+ dependencyId?: string;
17
+ message?: string;
18
+ };
19
+ /**
20
+ * Single skip ladder for plan and live execution.
21
+ * Policy skips stay outside: they run only after a step is scheduled.
22
+ * Remainder copies plan `skipReason` for structural skips and marks planned-run
23
+ * steps fail-fast or cancelled, so this ladder has no abort/fail-fast mode.
24
+ */
25
+ export declare function decideStepDisposition<TOptions extends object>(input: StepDispositionInput<TOptions>): StepDisposition;
26
+ export {};
@@ -0,0 +1,44 @@
1
+ /** Required dependencies are met when completed, or intentionally policy-skipped. */
2
+ function isRequiredDependencyMet(report) {
3
+ if (!report)
4
+ return false;
5
+ if (report.status === "completed")
6
+ return true;
7
+ return report.status === "skipped" && report.reason === "policy";
8
+ }
9
+ /**
10
+ * Single skip ladder for plan and live execution.
11
+ * Policy skips stay outside: they run only after a step is scheduled.
12
+ * Remainder copies plan `skipReason` for structural skips and marks planned-run
13
+ * steps fail-fast or cancelled, so this ladder has no abort/fail-fast mode.
14
+ */
15
+ export function decideStepDisposition(input) {
16
+ const { dryRun, graph, planned, reportsByStepId, step } = input;
17
+ if (!planned.selected) {
18
+ return { kind: "skip", reason: "filtered" };
19
+ }
20
+ const unsuccessfulAncestor = graph.skipAfterFailureOf.find((dep) => {
21
+ const status = reportsByStepId.get(dep.id)?.status;
22
+ return status === "failed" || status === "cancelled";
23
+ });
24
+ if (unsuccessfulAncestor) {
25
+ return {
26
+ kind: "skip",
27
+ reason: "failed-dependency",
28
+ dependencyId: unsuccessfulAncestor.id,
29
+ };
30
+ }
31
+ const unmetDependency = graph.dependsOn.find((dep) => !isRequiredDependencyMet(reportsByStepId.get(dep.id)));
32
+ if (unmetDependency) {
33
+ return {
34
+ kind: "skip",
35
+ reason: "unmet-dependency",
36
+ dependencyId: unmetDependency.id,
37
+ };
38
+ }
39
+ if (dryRun && step.dryRun === "skip") {
40
+ return { kind: "skip", reason: "dry-run" };
41
+ }
42
+ return { kind: "run" };
43
+ }
44
+ //# sourceMappingURL=pipeline-disposition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-disposition.js","sourceRoot":"","sources":["../../src/core/pipeline-disposition.ts"],"names":[],"mappings":"AAQA,qFAAqF;AACrF,SAAS,uBAAuB,CAAC,MAAsC;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC;AACnE,CAAC;AAmBD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAqC;IAErC,MAAM,EAAE,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\"./pipeline-steps.js\";\nimport type {\n PipelinePlanStep,\n PipelineStepReport,\n PipelineStepSkipReason,\n} from \"./pipeline-types.js\";\n\n/** Required dependencies are met when completed, or intentionally policy-skipped. */\nfunction isRequiredDependencyMet(report: PipelineStepReport | undefined): boolean {\n if (!report) return false;\n if (report.status === \"completed\") return true;\n return report.status === \"skipped\" && report.reason === \"policy\";\n}\n\ntype StepDispositionInput<TOptions extends object> = {\n dryRun: boolean;\n graph: CompiledStepGraph<TOptions>;\n planned: PipelinePlanStep;\n reportsByStepId: ReadonlyMap<string, PipelineStepReport>;\n step: AnyStep<TOptions>;\n};\n\ntype StepDisposition =\n | { kind: \"run\" }\n | {\n kind: \"skip\";\n reason: PipelineStepSkipReason;\n dependencyId?: string;\n message?: string;\n };\n\n/**\n * Single skip ladder for plan and live execution.\n * Policy skips stay outside: they run only after a step is scheduled.\n * Remainder copies plan `skipReason` for structural skips and marks planned-run\n * steps fail-fast or cancelled, so this ladder has no abort/fail-fast mode.\n */\nexport function decideStepDisposition<TOptions extends object>(\n input: StepDispositionInput<TOptions>\n): StepDisposition {\n const { dryRun, graph, planned, reportsByStepId, step } = input;\n\n if (!planned.selected) {\n return { kind: \"skip\", reason: \"filtered\" };\n }\n\n const unsuccessfulAncestor = graph.skipAfterFailureOf.find((dep) => {\n const status = reportsByStepId.get(dep.id)?.status;\n return status === \"failed\" || status === \"cancelled\";\n });\n if (unsuccessfulAncestor) {\n return {\n kind: \"skip\",\n reason: \"failed-dependency\",\n dependencyId: unsuccessfulAncestor.id,\n };\n }\n\n const unmetDependency = graph.dependsOn.find(\n (dep) => !isRequiredDependencyMet(reportsByStepId.get(dep.id))\n );\n if (unmetDependency) {\n return {\n kind: \"skip\",\n reason: \"unmet-dependency\",\n dependencyId: unmetDependency.id,\n };\n }\n\n if (dryRun && step.dryRun === \"skip\") {\n return { kind: \"skip\", reason: \"dry-run\" };\n }\n\n return { kind: \"run\" };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { PipelineError, PipelineErrorCode, PipelineErrorKind, PipelineErrorPhase } from "./pipeline-types.js";
2
+ export declare function pipelineDiagnostic(code: PipelineErrorCode, phase: PipelineErrorPhase, kind: PipelineErrorKind, message: string, fields?: Pick<PipelineError, "stepId">): PipelineError;
3
+ /** Programmer error raised immediately when a pipeline graph is invalid. */
4
+ export declare class PipelineDefinitionError extends Error {
5
+ readonly pipelineId: string;
6
+ readonly errors: readonly PipelineError[];
7
+ constructor(pipelineId: string, errors: readonly PipelineError[]);
8
+ }
@@ -0,0 +1,20 @@
1
+ import { brandTubelessError } from "../utilities/tubeless-error.js";
2
+ import { formatPipelineError } from "./pipeline-diagnostics.js";
3
+ export function pipelineDiagnostic(code, phase, kind, message, fields = {}) {
4
+ return { code, kind, message, phase, ...fields };
5
+ }
6
+ /** Programmer error raised immediately when a pipeline graph is invalid. */
7
+ export class PipelineDefinitionError extends Error {
8
+ pipelineId;
9
+ errors;
10
+ constructor(pipelineId, errors) {
11
+ super(errors.length > 0
12
+ ? `Invalid pipeline ${pipelineId}: ${errors.map((error) => formatPipelineError(error)).join("; ")}`
13
+ : `Invalid pipeline ${pipelineId}`);
14
+ this.pipelineId = pipelineId;
15
+ this.errors = errors;
16
+ this.name = "PipelineDefinitionError";
17
+ brandTubelessError(this, "pipeline-definition");
18
+ }
19
+ }
20
+ //# sourceMappingURL=pipeline-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-errors.js","sourceRoot":"","sources":["../../src/core/pipeline-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQhE,MAAM,UAAU,kBAAkB,CAChC,IAAuB,EACvB,KAAyB,EACzB,IAAuB,EACvB,OAAe,EACf,MAAM,GAAkC,EAAE;IAE1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,4EAA4E;AAC5E,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAErC,UAAU;IACV,MAAM;IAFjB,YACW,UAAkB,EAClB,MAAgC;QAEzC,KAAK,CACH,MAAM,CAAC,MAAM,GAAG,CAAC;YACf,CAAC,CAAC,oBAAoB,UAAU,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACnG,CAAC,CAAC,oBAAoB,UAAU,EAAE,CACrC,CAAC;0BAPO,UAAU;sBACV,MAAM;QAOf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,kBAAkB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { brandTubelessError } from \"../utilities/tubeless-error.js\";\nimport { formatPipelineError } from \"./pipeline-diagnostics.js\";\nimport type {\n PipelineError,\n PipelineErrorCode,\n PipelineErrorKind,\n PipelineErrorPhase,\n} from \"./pipeline-types.js\";\n\nexport function pipelineDiagnostic(\n code: PipelineErrorCode,\n phase: PipelineErrorPhase,\n kind: PipelineErrorKind,\n message: string,\n fields: Pick<PipelineError, \"stepId\"> = {}\n): PipelineError {\n return { code, kind, message, phase, ...fields };\n}\n\n/** Programmer error raised immediately when a pipeline graph is invalid. */\nexport class PipelineDefinitionError extends Error {\n constructor(\n readonly pipelineId: string,\n readonly errors: readonly PipelineError[]\n ) {\n super(\n errors.length > 0\n ? `Invalid pipeline ${pipelineId}: ${errors.map((error) => formatPipelineError(error)).join(\"; \")}`\n : `Invalid pipeline ${pipelineId}`\n );\n this.name = \"PipelineDefinitionError\";\n brandTubelessError(this, \"pipeline-definition\");\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type CompiledPipeline } from "./pipeline-plan.js";
1
+ import type { CompiledPipeline } from "./pipeline-compiler.js";
2
2
  import type { AnyStep } from "./pipeline-steps.js";
3
3
  import type { InferSchemaOutput, PipelineContext, PipelinePlan, PipelineRun, PipelineRunControls, PipelineRuntime, StandardSchemaV1 } from "./pipeline-types.js";
4
4
  /** Observe an execution ID from an internal host without allowing it to be overridden. */
@@ -4,8 +4,11 @@ import { brandTubelessError } from "../utilities/tubeless-error.js";
4
4
  import { createPipelineLifecycleObserver } from "./lifecycle.js";
5
5
  import { formatPipelineError } from "./pipeline-diagnostics.js";
6
6
  import { createRunId } from "./pipeline-ids.js";
7
- import { PIPELINE_FINALIZE_STEP_ID, compiledStepGraph, decideStepDisposition, planStepById, stepToPlanStep, } from "./pipeline-plan.js";
7
+ import { decideStepDisposition } from "./pipeline-disposition.js";
8
+ import { compiledStepGraph } from "./pipeline-graph.js";
9
+ import { planStepById, stepToPlanStep } from "./pipeline-plan.js";
8
10
  import { PipelineRunState, isCancellationOnly, } from "./pipeline-run-state.js";
11
+ import { PIPELINE_FINALIZE_STEP_ID } from "./pipeline-step-metadata.js";
9
12
  import { evaluateStepSkip, executeStepAttempt, validateStepOutput, } from "./pipeline-step-executor.js";
10
13
  import { PipelineBoundaryValidationError, validateStandardSchema } from "./pipeline-validation.js";
11
14
  import { createPipelineTraceEmitter } from "../tracing/tracing-internal.js";
@@ -178,7 +181,7 @@ export async function executePlannedRun(input) {
178
181
  catch {
179
182
  // Ignore observation failures; execution identity remains package-owned.
180
183
  }
181
- const correlationId = runtime.correlationId ?? runtime.runId;
184
+ const correlationId = runtime.correlationId;
182
185
  const identity = { runId };
183
186
  if (correlationId !== undefined)
184
187
  identity.correlationId = correlationId;
@@ -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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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 {\n PIPELINE_FINALIZE_STEP_ID,\n compiledStepGraph,\n decideStepDisposition,\n planStepById,\n stepToPlanStep,\n type CompiledPipeline,\n} from \"./pipeline-plan.js\";\nimport type { StepsOptions } 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 {\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_RUN_ID_OBSERVER = Symbol.for(\"tubeless.pipeline.runIdObserver\");\n\ninterface ObservedPipelineRuntime {\n [PIPELINE_RUN_ID_OBSERVER]?: (runId: string) => void;\n}\n\n/** Observe an execution ID from an internal host without allowing it to be overridden. */\nexport function observePipelineRunId<TContext extends object>(\n context: TContext,\n observer: (runId: string) => void\n): TContext {\n // SAFETY: the internal observer is intentionally hidden from the returned\n // public type and can observe, but never choose, the generated run ID.\n return { ...context, [PIPELINE_RUN_ID_OBSERVER]: observer };\n}\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\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 try {\n // SAFETY: only internal hosts attach this observation callback. A callback\n // failure must not change whether the pipeline execution itself can start.\n (runtime as PipelineRuntime & ObservedPipelineRuntime)[PIPELINE_RUN_ID_OBSERVER]?.(runId);\n } catch {\n // Ignore observation failures; execution identity remains package-owned.\n }\n const correlationId = runtime.correlationId ?? runtime.runId;\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 // 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 if (correlationId !== undefined) executionContext.correlationId = correlationId;\n if (runtime.parentRunId) executionContext.parentRunId = runtime.parentRunId;\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 const recordRemainingStates = (\n fromIndex: number,\n failedStepId?: string,\n cancellationError?: PipelineError\n ): void => {\n for (let index = fromIndex; index < orderedSteps.length; index++) {\n const step = orderedSteps[index]!;\n const plannedStep = plannedStepFor(step);\n if (plannedStep.skipReason) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, {\n reason: plannedStep.skipReason,\n dependencyId,\n });\n } else if (cancellationError) {\n state.cancelStep(plannedStep, { ...cancellationError, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: failedStepId\n ? `Not run because fail-fast stopped after ${failedStepId} failed.`\n : \"Not run because the pipeline was aborted before this step started.\",\n dependencyId: failedStepId,\n });\n }\n }\n };\n\n const cancelBeforeStepStart = (stepId: string, stepIndex: number): boolean => {\n try {\n throwIfAborted(runtime);\n return false;\n } catch (error) {\n const pipelineError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([pipelineError]);\n recordRemainingStates(stepIndex, undefined, pipelineError);\n return true;\n }\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n stepIndex: number,\n attempt: PipelineStepAttempt\n ): boolean => {\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) return false;\n recordRemainingStates(stepIndex + 1, plannedStep.id, cancelled ? pipelineError : undefined);\n return true;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n stepIndex: number,\n reason: string,\n value: unknown\n ): Promise<boolean> => {\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, stepIndex, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n return false;\n };\n\n for (const [stepIndex, step] of orderedSteps.entries()) {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step.id, stepIndex)) break;\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 continue;\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 if (recordStepExecutionFailure(error, plannedStep, stepIndex, attempt)) break;\n continue;\n }\n if (cancelBeforeStepStart(step.id, stepIndex)) break;\n if (skipDecision) {\n if (\n await recordPolicySkip(\n plannedStep,\n step,\n stepIndex,\n skipDecision.reason,\n skipDecision.value\n )\n ) {\n break;\n }\n continue;\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 if (recordStepExecutionFailure(error, plannedStep, stepIndex, attempt)) break;\n }\n }\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,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AA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tF,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 { 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_RUN_ID_OBSERVER = Symbol.for(\"tubeless.pipeline.runIdObserver\");\n\ninterface ObservedPipelineRuntime {\n [PIPELINE_RUN_ID_OBSERVER]?: (runId: string) => void;\n}\n\n/** Observe an execution ID from an internal host without allowing it to be overridden. */\nexport function observePipelineRunId<TContext extends object>(\n context: TContext,\n observer: (runId: string) => void\n): TContext {\n // SAFETY: the internal observer is intentionally hidden from the returned\n // public type and can observe, but never choose, the generated run ID.\n return { ...context, [PIPELINE_RUN_ID_OBSERVER]: observer };\n}\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\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 try {\n // SAFETY: only internal hosts attach this observation callback. A callback\n // failure must not change whether the pipeline execution itself can start.\n (runtime as PipelineRuntime & ObservedPipelineRuntime)[PIPELINE_RUN_ID_OBSERVER]?.(runId);\n } catch {\n // Ignore observation failures; execution identity remains package-owned.\n }\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 // 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 if (correlationId !== undefined) executionContext.correlationId = correlationId;\n if (runtime.parentRunId) executionContext.parentRunId = runtime.parentRunId;\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 const recordRemainingStates = (\n fromIndex: number,\n failedStepId?: string,\n cancellationError?: PipelineError\n ): void => {\n for (let index = fromIndex; index < orderedSteps.length; index++) {\n const step = orderedSteps[index]!;\n const plannedStep = plannedStepFor(step);\n if (plannedStep.skipReason) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, {\n reason: plannedStep.skipReason,\n dependencyId,\n });\n } else if (cancellationError) {\n state.cancelStep(plannedStep, { ...cancellationError, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: failedStepId\n ? `Not run because fail-fast stopped after ${failedStepId} failed.`\n : \"Not run because the pipeline was aborted before this step started.\",\n dependencyId: failedStepId,\n });\n }\n }\n };\n\n const cancelBeforeStepStart = (stepId: string, stepIndex: number): boolean => {\n try {\n throwIfAborted(runtime);\n return false;\n } catch (error) {\n const pipelineError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([pipelineError]);\n recordRemainingStates(stepIndex, undefined, pipelineError);\n return true;\n }\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n stepIndex: number,\n attempt: PipelineStepAttempt\n ): boolean => {\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) return false;\n recordRemainingStates(stepIndex + 1, plannedStep.id, cancelled ? pipelineError : undefined);\n return true;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n stepIndex: number,\n reason: string,\n value: unknown\n ): Promise<boolean> => {\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, stepIndex, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n return false;\n };\n\n for (const [stepIndex, step] of orderedSteps.entries()) {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step.id, stepIndex)) break;\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 continue;\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 if (recordStepExecutionFailure(error, plannedStep, stepIndex, attempt)) break;\n continue;\n }\n if (cancelBeforeStepStart(step.id, stepIndex)) break;\n if (skipDecision) {\n if (\n await recordPolicySkip(\n plannedStep,\n step,\n stepIndex,\n skipDecision.reason,\n skipDecision.value\n )\n ) {\n break;\n }\n continue;\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 if (recordStepExecutionFailure(error, plannedStep, stepIndex, attempt)) break;\n }\n }\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"]}