tubeless 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/cli-pipeline-command.d.ts +7 -2
- package/dist/cli/cli-pipeline-command.js +24 -3
- package/dist/cli/cli-pipeline-command.js.map +1 -1
- package/dist/core/child-execution.js +5 -3
- package/dist/core/child-execution.js.map +1 -1
- package/dist/core/child-progress.js +2 -0
- package/dist/core/child-progress.js.map +1 -1
- package/dist/core/pipeline-cache.d.ts +68 -0
- package/dist/core/pipeline-cache.js +157 -0
- package/dist/core/pipeline-cache.js.map +1 -0
- package/dist/core/pipeline-compiler.js +4 -2
- package/dist/core/pipeline-compiler.js.map +1 -1
- package/dist/core/pipeline-definition-identity.d.ts +3 -1
- package/dist/core/pipeline-definition-identity.js +38 -5
- package/dist/core/pipeline-definition-identity.js.map +1 -1
- package/dist/core/pipeline-definition-validation.d.ts +7 -2
- package/dist/core/pipeline-definition-validation.js +22 -2
- package/dist/core/pipeline-definition-validation.js.map +1 -1
- package/dist/core/pipeline-definition.d.ts +6 -0
- package/dist/core/pipeline-definition.js.map +1 -1
- package/dist/core/pipeline-execute.js +5 -0
- package/dist/core/pipeline-execute.js.map +1 -1
- package/dist/core/pipeline-graph.d.ts +2 -1
- package/dist/core/pipeline-graph.js +10 -4
- package/dist/core/pipeline-graph.js.map +1 -1
- package/dist/core/pipeline-mermaid.js +7 -1
- package/dist/core/pipeline-mermaid.js.map +1 -1
- package/dist/core/pipeline-plan.js +4 -0
- package/dist/core/pipeline-plan.js.map +1 -1
- package/dist/core/pipeline-query.d.ts +11 -0
- package/dist/core/pipeline-query.js +10 -0
- package/dist/core/pipeline-query.js.map +1 -0
- package/dist/core/pipeline-run-state.d.ts +2 -2
- package/dist/core/pipeline-run-state.js.map +1 -1
- package/dist/core/pipeline-step-executor.d.ts +2 -0
- package/dist/core/pipeline-step-executor.js +24 -9
- package/dist/core/pipeline-step-executor.js.map +1 -1
- package/dist/core/pipeline-step-metadata.d.ts +1 -0
- package/dist/core/pipeline-step-metadata.js +1 -0
- package/dist/core/pipeline-step-metadata.js.map +1 -1
- package/dist/core/pipeline-steps.d.ts +17 -3
- package/dist/core/pipeline-steps.js +11 -3
- package/dist/core/pipeline-steps.js.map +1 -1
- package/dist/core/pipeline-types.d.ts +20 -7
- package/dist/core/pipeline-types.js.map +1 -1
- package/dist/core/pipeline-validation.js +1 -1
- package/dist/core/pipeline-validation.js.map +1 -1
- package/dist/core/pipeline.d.ts +4 -0
- package/dist/core/pipeline.js +7 -1
- package/dist/core/pipeline.js.map +1 -1
- package/dist/node/node.d.ts +1 -0
- package/dist/node/node.js +1 -0
- package/dist/node/node.js.map +1 -1
- package/dist/reporter/interactive-reporter.js +3 -4
- package/dist/reporter/interactive-reporter.js.map +1 -1
- package/dist/reporter/reporter.d.ts +1 -0
- package/dist/reporter/reporter.js +4 -2
- package/dist/reporter/reporter.js.map +1 -1
- package/dist/run-store/cache-artifact.d.ts +7 -0
- package/dist/run-store/cache-artifact.js +22 -0
- package/dist/run-store/cache-artifact.js.map +1 -0
- package/dist/run-store/definition-diff.js +20 -8
- package/dist/run-store/definition-diff.js.map +1 -1
- package/dist/run-store/run-projection.js +2 -2
- package/dist/run-store/run-projection.js.map +1 -1
- package/dist/run-store/run-store.d.ts +2 -2
- package/dist/run-store/run-store.js.map +1 -1
- package/dist/studio/run-store-ui-artifacts.d.ts +5 -0
- package/dist/studio/run-store-ui-artifacts.js +18 -0
- package/dist/studio/run-store-ui-artifacts.js.map +1 -0
- package/dist/studio/run-store-ui-client-browser.js +2 -2
- package/dist/studio/run-store-ui-client-transport.d.ts +3 -1
- package/dist/studio/run-store-ui-client-transport.js +74 -32
- package/dist/studio/run-store-ui-client-transport.js.map +1 -1
- package/dist/studio/run-store-ui-client.d.ts +12 -5
- package/dist/studio/run-store-ui-client.js +176 -57
- package/dist/studio/run-store-ui-client.js.map +1 -1
- package/dist/studio/run-store-ui-data-controller.d.ts +2 -1
- package/dist/studio/run-store-ui-data-controller.js +31 -9
- package/dist/studio/run-store-ui-data-controller.js.map +1 -1
- package/dist/studio/run-store-ui-debugging.d.ts +13 -0
- package/dist/studio/run-store-ui-debugging.js +48 -0
- package/dist/studio/run-store-ui-debugging.js.map +1 -0
- package/dist/studio/run-store-ui-definitions.js +2 -1
- package/dist/studio/run-store-ui-definitions.js.map +1 -1
- package/dist/studio/run-store-ui-hosting.d.ts +18 -0
- package/dist/studio/run-store-ui-hosting.js +88 -0
- package/dist/studio/run-store-ui-hosting.js.map +1 -0
- package/dist/studio/run-store-ui-http.d.ts +1 -1
- package/dist/studio/run-store-ui-http.js +2 -2
- package/dist/studio/run-store-ui-http.js.map +1 -1
- package/dist/studio/run-store-ui-metadata.d.ts +13 -0
- package/dist/studio/run-store-ui-metadata.js +32 -0
- package/dist/studio/run-store-ui-metadata.js.map +1 -0
- package/dist/studio/run-store-ui-page.d.ts +2 -0
- package/dist/studio/run-store-ui-page.js +52 -3
- package/dist/studio/run-store-ui-page.js.map +1 -1
- package/dist/studio/run-store-ui.d.ts +2 -0
- package/dist/studio/run-store-ui.js +45 -9
- package/dist/studio/run-store-ui.js.map +1 -1
- package/dist/tracing/artifact-metadata.d.ts +1 -0
- package/dist/tracing/artifact-metadata.js +2 -2
- package/dist/tracing/artifact-metadata.js.map +1 -1
- package/dist/tracing/graph-metadata.d.ts +12 -0
- package/dist/tracing/graph-metadata.js +55 -0
- package/dist/tracing/graph-metadata.js.map +1 -0
- package/dist/tracing/tracing-internal.js +2 -2
- package/dist/tracing/tracing-internal.js.map +1 -1
- package/dist/tracing/tracing-schema.d.ts +58 -31
- package/dist/tracing/tracing-schema.js +26 -8
- package/dist/tracing/tracing-schema.js.map +1 -1
- package/dist/utilities/cache-duration.d.ts +2 -0
- package/dist/utilities/cache-duration.js +39 -0
- package/dist/utilities/cache-duration.js.map +1 -0
- package/dist/utilities/cache-key.d.ts +2 -0
- package/dist/utilities/cache-key.js +63 -0
- package/dist/utilities/cache-key.js.map +1 -0
- package/dist/utilities/cache-storage.d.ts +6 -0
- package/dist/utilities/cache-storage.js +83 -0
- package/dist/utilities/cache-storage.js.map +1 -0
- package/dist/utilities/canonical-json.d.ts +2 -0
- package/dist/utilities/canonical-json.js +12 -0
- package/dist/utilities/canonical-json.js.map +1 -0
- package/dist/workbench/workbench-commands.js +43 -3
- package/dist/workbench/workbench-commands.js.map +1 -1
- package/dist/workbench/workbench-history.js +2 -1
- package/dist/workbench/workbench-history.js.map +1 -1
- package/dist/workbench/workbench-ui.js +18 -7
- package/dist/workbench/workbench-ui.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/agent-guide.md +31 -2
- package/docs/api-reference.md +98 -85
- package/docs/api-report.json +19 -6
- package/docs/artifacts.md +6 -2
- package/docs/cli.md +25 -0
- package/docs/concepts.md +10 -0
- package/docs/declarative-pipelines.md +4 -0
- package/docs/graph-metadata.md +108 -0
- package/docs/llms.txt +4 -0
- package/docs/recipes.md +15 -0
- package/docs/step-output-cache.md +242 -0
- package/docs/studio.md +171 -19
- package/examples/graph-metadata.ts +32 -0
- package/examples/project/tubeless.project.ts +5 -0
- package/examples/step-output-cache.ts +30 -0
- package/package.json +2 -2
- package/skills/tubeless/SKILL.md +16 -0
|
@@ -1 +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,CA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,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,+CAA+C,EAC/C,YAAY,EACZ,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,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACzC,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 if (\n definition.name !== undefined &&\n (typeof definition.name !== \"string\" || definition.name.trim().length === 0)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_PIPELINE_NAME_BLANK\",\n \"definition\",\n \"definition\",\n \"Pipeline display name must not be blank\"\n )\n );\n }\n\n if (\n definition.description !== undefined &&\n (typeof definition.description !== \"string\" || definition.description.trim().length === 0)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_PIPELINE_DESCRIPTION_BLANK\",\n \"definition\",\n \"definition\",\n \"Pipeline description must not be blank\"\n )\n );\n }\n\n if (\n definition.implementationVersion !== undefined &&\n (typeof definition.implementationVersion !== \"string\" ||\n definition.implementationVersion.trim().length === 0 ||\n definition.implementationVersion.length > 256)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_IMPLEMENTATION_VERSION_INVALID\",\n \"definition\",\n \"definition\",\n \"Implementation version must be a nonblank string of at most 256 characters\"\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: the tuple contains only steps with the inferred options type.\n const orderedSteps = topologicalSort(steps as readonly AnyStep<TOptions>[]);\n // SAFETY: explicit targets are a subset of TSteps; implicit targets come from its graph.\n const declaredTargets = (definition.targets ??\n orderedSteps?.slice(-1) ??\n []) 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 if (errors.length === 0 && !orderedSteps) {\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"]}
|
|
1
|
+
{"version":3,"file":"pipeline-definition-validation.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC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zC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1F,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,+CAA+C,EAC/C,YAAY,EACZ,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,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CACT,kBAAkB,CAChB,sCAAsC,EACtC,YAAY,EACZ,YAAY,EACZ,YAAY,UAAU,CAAC,EAAE,yBAAyB,CACnD,CACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n compileStepCache,\n validatePipelineCache,\n type CompiledStepCache,\n} from \"./pipeline-cache.js\";\nimport { 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 {\n PIPELINE_FINALIZE_STEP_ID,\n STEP_OPTIONS_SCHEMA,\n STEP_NESTED_PIPELINE,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type { PipelineError, StandardSchemaV1 } from \"./pipeline-types.js\";\n\n/** Validate author declarations and retain cache plans so graph construction never recompiles them. */\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>) {\n type TOptions = StepsOptions<TSteps>;\n const steps = definition.steps;\n const errors: PipelineError[] = [];\n const compiledCaches = new Map<AnyStep, CompiledStepCache<TOptions>>();\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 if (\n definition.name !== undefined &&\n (typeof definition.name !== \"string\" || definition.name.trim().length === 0)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_PIPELINE_NAME_BLANK\",\n \"definition\",\n \"definition\",\n \"Pipeline display name must not be blank\"\n )\n );\n }\n\n if (\n definition.description !== undefined &&\n (typeof definition.description !== \"string\" || definition.description.trim().length === 0)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_PIPELINE_DESCRIPTION_BLANK\",\n \"definition\",\n \"definition\",\n \"Pipeline description must not be blank\"\n )\n );\n }\n\n if (\n definition.implementationVersion !== undefined &&\n (typeof definition.implementationVersion !== \"string\" ||\n definition.implementationVersion.trim().length === 0 ||\n definition.implementationVersion.length > 256)\n ) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_IMPLEMENTATION_VERSION_INVALID\",\n \"definition\",\n \"definition\",\n \"Implementation version must be a nonblank string of at most 256 characters\"\n )\n );\n }\n try {\n validatePipelineCache(definition.cache);\n } catch (error) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_CACHE_INVALID\",\n \"definition\",\n \"definition\",\n error instanceof Error ? error.message : String(error)\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 try {\n const configuredCache = step.cache;\n if (configuredCache && (step[STEP_NESTED_PIPELINE] || step[STEP_REMOTE]))\n throw new Error(\"Only ordinary steps can opt into caching\");\n const cache = compileStepCache(\n configuredCache,\n definition.cache,\n definition.implementationVersion\n );\n if (cache) compiledCaches.set(step, cache);\n } catch (error) {\n errors.push(\n pipelineDiagnostic(\n \"TUBELESS_DEFINITION_STEP_CACHE_INVALID\",\n \"definition\",\n \"definition\",\n `Pipeline ${definition.id} step ${step.id}: ${error instanceof Error ? error.message : String(error)}`,\n { stepId: step.id }\n )\n );\n }\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: the tuple contains only steps with the inferred options type.\n const orderedSteps = topologicalSort(steps as readonly AnyStep<TOptions>[]);\n // SAFETY: explicit targets are a subset of TSteps; implicit targets come from its graph.\n const declaredTargets = (definition.targets ??\n orderedSteps?.slice(-1) ??\n []) 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 if (errors.length === 0 && !orderedSteps) {\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, compiledCaches };\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PipelineMetadata } from "../tracing/graph-metadata.js";
|
|
2
|
+
import type { PipelineCacheOptions } from "./pipeline-cache.js";
|
|
1
3
|
import type { AnyStep, Step, StepOutput } from "./pipeline-steps.js";
|
|
2
4
|
import type { InferSchemaInput, PipelineExecutionContext, StandardSchemaV1 } from "./pipeline-types.js";
|
|
3
5
|
/**
|
|
@@ -37,9 +39,13 @@ export type PipelineDefinition<TSteps extends readonly AnyStep[], TResult = Defa
|
|
|
37
39
|
name?: string;
|
|
38
40
|
/** Human-readable purpose shown by command and discovery surfaces. */
|
|
39
41
|
description?: string;
|
|
42
|
+
/** Inert, bounded JSON metadata, snapshotted during compilation. */
|
|
43
|
+
metadata?: PipelineMetadata;
|
|
40
44
|
/** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */
|
|
41
45
|
implementationVersion?: string;
|
|
42
46
|
steps: TSteps;
|
|
47
|
+
/** Defaults for explicitly cacheable steps. */
|
|
48
|
+
cache?: PipelineCacheOptions;
|
|
43
49
|
/** Selectable public goals; omitted exposes the last step in execution order.
|
|
44
50
|
* This declaration never filters a run. Use `[]` to expose no goals.
|
|
45
51
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-definition.js","sourceRoot":"","sources":["../../src/core/pipeline-definition.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnyStep, Step, StepOutput } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaInput,\n PipelineExecutionContext,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\n/**\n * Recovers the options type from the steps themselves rather than taking it as its own\n * generic parameter. A `TOptions` parameter constrained by `TSteps extends\n * readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a\n * `definePipeline(...)` call site and silently widens `TOptions` to its bare\n * `object` constraint (context.options would lose every pipeline-specific\n * field). Structuring it as \"derive TOptions from TSteps\" instead of \"constrain TSteps by\n * TOptions\" avoids the cycle, so callers never write out any of these type parameters.\n */\nexport type StepsOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;\n\nexport type StepsInputOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut>\n ? TInputOptions\n : StepsOptions<TSteps>;\n\n/** Preserve whether the step factory supplied a runtime options schema. */\nexport type StepsOptionsSchema<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, object, unknown, infer TSchema>\n ? TSchema\n : StandardSchemaV1 | undefined;\n\nexport type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number][\"id\"];\n\nexport type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number][\"id\"];\n\n// Step types retain output and ID types, but erase their dependency graph.\n// Any declared step may therefore be last in the runtime topological order.\ntype DefaultStepOutput<TSteps extends readonly AnyStep[]> = TSteps extends readonly []\n ? undefined\n : StepOutput<TSteps[number]>;\n\nexport type DefaultPipelineResult<TSteps extends readonly AnyStep[]> =\n | DefaultStepOutput<TSteps>\n | undefined;\n\nexport type DefaultPipelineTargets<TSteps extends readonly AnyStep[]> = readonly TSteps[number][];\n\ntype PipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype PipelineFinalizer<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> = (\n outputs: Partial<PipelineOutputs<TSteps>>,\n context: PipelineExecutionContext<StepsOptions<TSteps>>\n) =>\n | (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult)\n | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;\n\ntype PipelineFinalizerSource<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> =\n | PipelineFinalizer<TSteps, TResult, TResultSchema>\n | (TSteps[number] &\n Step<\n string,\n TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult,\n StepsOptions<TSteps>,\n StepsInputOptions<TSteps>,\n unknown\n >);\n\n/**\n * Declarative configuration for compiling a typed pipeline.\n *\n * A pipeline may omit finalize when its final step in execution order supplies the result.\n * Set finalize to a declared step to require and return its precisely typed output.\n * The default emits undefined if that step published no output. If its output cannot\n * satisfy an explicit result type or schema input, a compatible finalizer is required.\n */\nexport type PipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n id: string;\n /** Optional display name; stable identity remains `id`. */\n name?: string;\n /** Human-readable purpose shown by command and discovery surfaces. */\n description?: string;\n /** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */\n implementationVersion?: string;\n steps: TSteps;\n /** Selectable public goals; omitted exposes the last step in execution order.\n * This declaration never filters a run. Use `[]` to expose no goals.\n */\n targets?: TTargets;\n /** Optional Standard Schema for the finalized result. */\n resultSchema?: TResultSchema;\n} & (TResultSchema extends StandardSchemaV1\n ? [DefaultStepOutput<TSteps>] extends [InferSchemaInput<TResultSchema>]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : [DefaultPipelineResult<TSteps>] extends [TResult]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> });\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline-definition.js","sourceRoot":"","sources":["../../src/core/pipeline-definition.ts"],"names":[],"mappings":"","sourcesContent":["import type { PipelineMetadata } from \"../tracing/graph-metadata.js\";\nimport type { PipelineCacheOptions } from \"./pipeline-cache.js\";\nimport type { AnyStep, Step, StepOutput } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaInput,\n PipelineExecutionContext,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\n/**\n * Recovers the options type from the steps themselves rather than taking it as its own\n * generic parameter. A `TOptions` parameter constrained by `TSteps extends\n * readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a\n * `definePipeline(...)` call site and silently widens `TOptions` to its bare\n * `object` constraint (context.options would lose every pipeline-specific\n * field). Structuring it as \"derive TOptions from TSteps\" instead of \"constrain TSteps by\n * TOptions\" avoids the cycle, so callers never write out any of these type parameters.\n */\nexport type StepsOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;\n\nexport type StepsInputOptions<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut>\n ? TInputOptions\n : StepsOptions<TSteps>;\n\n/** Preserve whether the step factory supplied a runtime options schema. */\nexport type StepsOptionsSchema<TSteps extends readonly AnyStep[]> =\n TSteps[number] extends Step<string, unknown, object, object, unknown, infer TSchema>\n ? TSchema\n : StandardSchemaV1 | undefined;\n\nexport type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number][\"id\"];\n\nexport type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number][\"id\"];\n\n// Step types retain output and ID types, but erase their dependency graph.\n// Any declared step may therefore be last in the runtime topological order.\ntype DefaultStepOutput<TSteps extends readonly AnyStep[]> = TSteps extends readonly []\n ? undefined\n : StepOutput<TSteps[number]>;\n\nexport type DefaultPipelineResult<TSteps extends readonly AnyStep[]> =\n | DefaultStepOutput<TSteps>\n | undefined;\n\nexport type DefaultPipelineTargets<TSteps extends readonly AnyStep[]> = readonly TSteps[number][];\n\ntype PipelineOutputs<TSteps extends readonly AnyStep[]> = {\n [S in TSteps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype PipelineFinalizer<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> = (\n outputs: Partial<PipelineOutputs<TSteps>>,\n context: PipelineExecutionContext<StepsOptions<TSteps>>\n) =>\n | (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult)\n | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;\n\ntype PipelineFinalizerSource<\n TSteps extends readonly AnyStep[],\n TResult,\n TResultSchema extends StandardSchemaV1 | undefined,\n> =\n | PipelineFinalizer<TSteps, TResult, TResultSchema>\n | (TSteps[number] &\n Step<\n string,\n TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult,\n StepsOptions<TSteps>,\n StepsInputOptions<TSteps>,\n unknown\n >);\n\n/**\n * Declarative configuration for compiling a typed pipeline.\n *\n * A pipeline may omit finalize when its final step in execution order supplies the result.\n * Set finalize to a declared step to require and return its precisely typed output.\n * The default emits undefined if that step published no output. If its output cannot\n * satisfy an explicit result type or schema input, a compatible finalizer is required.\n */\nexport type PipelineDefinition<\n TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> = {\n id: string;\n /** Optional display name; stable identity remains `id`. */\n name?: string;\n /** Human-readable purpose shown by command and discovery surfaces. */\n description?: string;\n /** Inert, bounded JSON metadata, snapshotted during compilation. */\n metadata?: PipelineMetadata;\n /** Author- or build-supplied version of handlers, mappings, schemas, and finalizer (1–256 characters). */\n implementationVersion?: string;\n steps: TSteps;\n /** Defaults for explicitly cacheable steps. */\n cache?: PipelineCacheOptions;\n /** Selectable public goals; omitted exposes the last step in execution order.\n * This declaration never filters a run. Use `[]` to expose no goals.\n */\n targets?: TTargets;\n /** Optional Standard Schema for the finalized result. */\n resultSchema?: TResultSchema;\n} & (TResultSchema extends StandardSchemaV1\n ? [DefaultStepOutput<TSteps>] extends [InferSchemaInput<TResultSchema>]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : [DefaultPipelineResult<TSteps>] extends [TResult]\n ? { finalize?: PipelineFinalizerSource<TSteps, TResult, TResultSchema> }\n : { finalize: PipelineFinalizerSource<TSteps, TResult, TResultSchema> });\n"]}
|
|
@@ -67,6 +67,7 @@ export async function executePlannedRun(input) {
|
|
|
67
67
|
dryRun,
|
|
68
68
|
log: lifecycle.logger(),
|
|
69
69
|
options: pipelineOptions,
|
|
70
|
+
cachePolicy: controls.cache,
|
|
70
71
|
runId,
|
|
71
72
|
trace: lifecycle.traceContext,
|
|
72
73
|
};
|
|
@@ -212,6 +213,10 @@ export async function executePlannedRun(input) {
|
|
|
212
213
|
try {
|
|
213
214
|
const output = await executeStepAttempt({
|
|
214
215
|
attemptId: attempt.attemptId,
|
|
216
|
+
pipelineId: compiled.id,
|
|
217
|
+
onCacheHit: () => {
|
|
218
|
+
attempt.outputSource = "cache";
|
|
219
|
+
},
|
|
215
220
|
context: executionContext,
|
|
216
221
|
dryRun,
|
|
217
222
|
inputs: stepInputs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-execute.js","sourceRoot":"","sources":["../../src/core/pipeline-execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAA4B,MAAM,yBAAyB,CAAC;AAErF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACnG,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAIvC,SAAS,cAAc,CAAC,OAAwB;IAC9C,oBAAoB,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAKrC,KAOD;IAOC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAC,EAA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AAoB,EAAiB,EAAE,CAChF,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEvD,MAAM,UAAU,sBAAsB;IACpC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAO,GAA6B,EAAE;IAC3E,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAC1C,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,OAAO;QACV,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,WAAW;QAC/C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,IAAI,aAAa;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import { abortableSleep, throwIfAborted as throwIfSignalAborted } from \"../utilities/abort.js\";\nimport { createPipelineLifecycleObserver } from \"./lifecycle.js\";\nimport { createRunId } from \"./pipeline-ids.js\";\nimport type { CompiledPipeline } from \"./pipeline-compiler.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport { decideStepDisposition } from \"./pipeline-disposition.js\";\nimport { schedulePipelineSteps } from \"./pipeline-scheduler.js\";\nimport { compiledStepGraph } from \"./pipeline-graph.js\";\nimport { planStepById, stepToPlanStep } from \"./pipeline-plan.js\";\nimport { PipelineRunState, type PipelineStepAttempt } from \"./pipeline-run-state.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { PIPELINE_FINALIZE_STEP_ID } from \"./pipeline-step-metadata.js\";\nimport {\n evaluateStepSkip,\n executeStepAttempt,\n validateStepOutput,\n} from \"./pipeline-step-executor.js\";\nimport type {\n InferSchemaOutput,\n PipelineContext,\n PipelineError,\n PipelineExecutionContext,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\nimport { PipelineBoundaryValidationError, validateStandardSchema } from \"./pipeline-validation.js\";\nimport {\n finalizationError,\n stepExecutionError,\n toPipelineError,\n} from \"./pipeline-execution-error.js\";\n\ntype PipelineRunIdentity = { correlationId?: string; parentRunId?: string; runId: string };\n\nfunction throwIfAborted(runtime: PipelineRuntime): void {\n throwIfSignalAborted(runtime.signal, \"Pipeline run\");\n}\n\nexport async function executePlannedRun<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(input: {\n compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;\n controls: PipelineRunControls;\n domainOptions: object;\n plan: PipelinePlan;\n runtime: PipelineRuntime;\n overrides?: ReadonlyMap<AnyStep, unknown>;\n}): Promise<\n PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>\n> {\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TOptions = StepsOptions<TSteps>;\n const { compiled, controls, runtime } = input;\n const startedAtMs = runtime.now();\n const runId = createRunId(compiled.id);\n const correlationId = runtime.correlationId;\n const identity: PipelineRunIdentity = { runId };\n if (correlationId !== undefined) identity.correlationId = correlationId;\n if (runtime.parentRunId) identity.parentRunId = runtime.parentRunId;\n const dryRun = controls.dryRun === true;\n const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, {\n ...identity,\n itemKey: runtime.tracing?.itemKey,\n iteration: runtime.tracing?.iteration,\n });\n const state = new PipelineRunState<TPipelineResult>(\n compiled.id,\n dryRun,\n startedAtMs,\n identity,\n runtime.now,\n lifecycle\n );\n state.start(input.plan, compiled.targetIds);\n\n if (!input.plan.ok) {\n state.recordRunErrors(input.plan.errors);\n return state.finish();\n }\n\n const maxConcurrency = controls.maxConcurrency ?? 1;\n\n // SAFETY: `domainOptions` is the user-supplied options object; if a schema\n // is present it is re-validated below before assignment to `pipelineOptions`.\n let pipelineOptions = input.domainOptions as TOptions;\n if (compiled.optionsSchema) {\n try {\n const validated = await validateStandardSchema(\n compiled.optionsSchema,\n input.domainOptions,\n `Pipeline ${compiled.id} options`\n );\n if (typeof validated !== \"object\" || validated === null || Array.isArray(validated)) {\n throw new PipelineBoundaryValidationError(\n `Pipeline ${compiled.id} options schema returned a non-object value`,\n [{ message: \"Expected the validated options value to be an object\" }]\n );\n }\n // SAFETY: the schema validated the value against `TOptions` and the\n // object-shape check above passed, so the value is a `TOptions`.\n pipelineOptions = validated as TOptions;\n } catch (error) {\n state.recordRunErrors([\n toPipelineError(error, {\n code: \"TUBELESS_OPTIONS_VALIDATION_FAILED\",\n kind: \"validation\",\n phase: \"execution\",\n }),\n ]);\n return state.finish();\n }\n }\n\n for (const step of input.plan.steps) state.planStep(step);\n\n const executionContext: PipelineExecutionContext<TOptions> = {\n ...runtime,\n dryRun,\n log: lifecycle.logger(),\n options: pipelineOptions,\n runId,\n trace: lifecycle.traceContext,\n };\n\n const plannedSteps = planStepById(input.plan);\n const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));\n // `input.plan.steps` is already topologically ordered. Rehydrate from the original step\n // objects so callers still get the typed handlers rather than plan metadata.\n // SAFETY: every planned step id originates from `compiled.orderedSteps`, so the\n // map lookup always finds the matching `AnyStep<TOptions>`.\n const orderedSteps = input.plan.steps.map((step) => stepsById.get(step.id) as AnyStep<TOptions>);\n const plannedStepFor = (step: AnyStep<TOptions>): PipelinePlanStep =>\n plannedSteps.get(step.id) ??\n stepToPlanStep(step, true, undefined, undefined, compiledStepGraph(compiled, step));\n\n let stopError: PipelineError | undefined;\n let externalCancellationError: PipelineError | undefined;\n\n const recordUnstartedStep = (step: AnyStep<TOptions>, error: PipelineError): void => {\n const plannedStep = plannedStepFor(step);\n // Only the external signal can override a selected step's planned skip.\n if (plannedStep.skipReason && (!plannedStep.selected || error !== externalCancellationError)) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, { reason: plannedStep.skipReason, dependencyId });\n } else if (error.kind === \"cancellation\") {\n state.cancelStep(plannedStep, { ...error, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: `Not run because fail-fast stopped after ${error.stepId} failed.`,\n dependencyId: error.stepId,\n });\n }\n };\n\n const recordExternalCancellation = (stepId: string): PipelineError | undefined => {\n if (externalCancellationError) return externalCancellationError;\n try {\n throwIfAborted(runtime);\n return undefined;\n } catch (error) {\n externalCancellationError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([externalCancellationError]);\n return externalCancellationError;\n }\n };\n\n const cancelBeforeStepStart = (step: AnyStep<TOptions>): boolean => {\n const pipelineError = recordExternalCancellation(step.id);\n if (!pipelineError) return false;\n stopError ??= pipelineError;\n recordUnstartedStep(step, pipelineError);\n return true;\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n attempt: PipelineStepAttempt\n ): void => {\n const pipelineError = stepExecutionError(error, runtime, plannedStep.id);\n state.failStep(plannedStep, attempt, pipelineError);\n if (!controls.continueOnError) stopError ??= pipelineError;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n reason: string,\n value: unknown\n ): Promise<void> => {\n let attempt: PipelineStepAttempt | undefined;\n let published = value;\n if (step.outputSchema) {\n attempt = state.beginAttempt(plannedStep);\n try {\n published = await validateStepOutput(\n step,\n value,\n `Pipeline ${compiled.id} step ${step.id} output`\n );\n } catch (error) {\n return recordStepExecutionFailure(error, plannedStep, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n };\n\n const executeOneStep = async (step: AnyStep<TOptions>): Promise<void> => {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step)) return;\n\n if (plannedStep.selected && input.overrides?.has(step)) {\n const attempt = state.beginAttempt(plannedStep, runtime.now(), \"override\");\n try {\n const output = await validateStepOutput(\n step,\n input.overrides.get(step),\n `Pipeline ${compiled.id} step ${step.id} override output`\n );\n throwIfAborted(runtime);\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n return;\n }\n\n const graph = compiledStepGraph(compiled, step);\n const disposition = decideStepDisposition({\n dryRun,\n graph,\n planned: plannedStep,\n reportsByStepId: state.reportsByStepId,\n step,\n });\n if (disposition.kind === \"skip\") {\n state.skipStep(plannedStep, disposition);\n return;\n }\n\n const inputEntries: Array<[string, unknown]> = [];\n for (const dep of graph.dependsOn) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n for (const dep of graph.optionalDependsOn) {\n if (state.outputs.has(dep.id)) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n }\n const stepInputs = Object.fromEntries(inputEntries);\n\n if (typeof step.skip === \"function\") {\n let skipDecision;\n try {\n skipDecision = await evaluateStepSkip(step, stepInputs, {\n ...executionContext,\n log: lifecycle.logger(step.id),\n });\n } catch (error) {\n const attempt = state.beginAttempt(plannedStep);\n recordStepExecutionFailure(error, plannedStep, attempt);\n return;\n }\n if (cancelBeforeStepStart(step)) return;\n if (skipDecision) {\n await recordPolicySkip(plannedStep, step, skipDecision.reason, skipDecision.value);\n return;\n }\n }\n\n const attempt = state.beginAttempt(plannedStep);\n try {\n const output = await executeStepAttempt({\n attemptId: attempt.attemptId,\n context: executionContext,\n dryRun,\n inputs: stepInputs,\n log: lifecycle.logger(step.id, attempt.attemptId),\n onArtifact: (record, preview) =>\n lifecycle.recordArtifact(step.id, attempt.attemptId, record, preview),\n onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),\n onReportAttempt: (number, attributes) =>\n lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),\n outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,\n step,\n });\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n };\n\n const unstarted = await schedulePipelineSteps({\n orderedSteps,\n stepGraph: compiled.stepGraph,\n maxConcurrency,\n executeOneStep,\n shouldStop: () => stopError !== undefined || runtime.signal?.aborted === true,\n });\n if (unstarted.length > 0 && runtime.signal?.aborted) {\n // An external abort takes precedence for work that never started, even\n // when an earlier failure stopped dispatch. Keep every active step's outcome.\n // Only reuse diagnostics created from this signal, never a step-local AbortError.\n stopError = recordExternalCancellation(unstarted[0]!.id)!;\n }\n for (const step of unstarted) recordUnstartedStep(step, stopError!);\n\n if (state.errors.length === 0 || controls.continueOnError) {\n const finalizeStartedAt = runtime.now();\n state.beginFinalization();\n try {\n throwIfAborted(runtime);\n // SAFETY: `state.outputs` maps step ids to their produced values, which is\n // exactly the shape the finalizer's outputs parameter describes.\n const finalOutputs = Object.fromEntries(state.outputs) as Parameters<\n CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]\n >[0];\n const finalizedValue = await compiled.finalize(finalOutputs, {\n ...executionContext,\n log: lifecycle.logger(PIPELINE_FINALIZE_STEP_ID),\n });\n // SAFETY: with a result schema the value is validated against\n // `TPipelineResult`; without one the finalizer's declared return type\n // is `TPipelineResult`, so the cast only restores that type.\n const value = compiled.resultSchema\n ? ((await validateStandardSchema(\n compiled.resultSchema,\n finalizedValue,\n `Pipeline ${compiled.id} final result`\n )) as TPipelineResult)\n : (finalizedValue as TPipelineResult);\n state.completeFinalization(value, runtime.now() - finalizeStartedAt);\n } catch (error) {\n const pipelineError = finalizationError(error, runtime);\n state.failFinalization(pipelineError, runtime.now() - finalizeStartedAt);\n }\n }\n\n return state.finish();\n}\n\nconst fallbackNow = (): number => Date.now();\n\nconst fallbackSleep = (durationMs: number, signal?: AbortSignal): Promise<void> =>\n abortableSleep(durationMs, signal, \"Pipeline sleep\");\n\nexport function defaultPipelineContext(): PipelineContext {\n return { cwd: process.cwd(), log: console, now: fallbackNow, sleep: fallbackSleep };\n}\n\nexport function resolvePipelineRuntime(context: Partial<PipelineContext> = {}): PipelineRuntime {\n const defaults = defaultPipelineContext();\n return {\n ...defaults,\n ...context,\n cwd: context.cwd ?? defaults.cwd,\n log: context.log ?? defaults.log,\n now: context.now ?? defaults.now ?? fallbackNow,\n sleep: context.sleep ?? defaults.sleep ?? fallbackSleep,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline-execute.js","sourceRoot":"","sources":["../../src/core/pipeline-execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAA4B,MAAM,yBAAyB,CAAC;AAErF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACnG,OAAO,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,IAAI,aAAa;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import { abortableSleep, throwIfAborted as throwIfSignalAborted } from \"../utilities/abort.js\";\nimport { createPipelineLifecycleObserver } from \"./lifecycle.js\";\nimport { createRunId } from \"./pipeline-ids.js\";\nimport type { CompiledPipeline } from \"./pipeline-compiler.js\";\nimport type { StepsOptions } from \"./pipeline-definition.js\";\nimport { decideStepDisposition } from \"./pipeline-disposition.js\";\nimport { schedulePipelineSteps } from \"./pipeline-scheduler.js\";\nimport { compiledStepGraph } from \"./pipeline-graph.js\";\nimport { planStepById, stepToPlanStep } from \"./pipeline-plan.js\";\nimport { PipelineRunState, type PipelineStepAttempt } from \"./pipeline-run-state.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { PIPELINE_FINALIZE_STEP_ID } from \"./pipeline-step-metadata.js\";\nimport {\n evaluateStepSkip,\n executeStepAttempt,\n validateStepOutput,\n} from \"./pipeline-step-executor.js\";\nimport type {\n InferSchemaOutput,\n PipelineContext,\n PipelineError,\n PipelineExecutionContext,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\nimport { PipelineBoundaryValidationError, validateStandardSchema } from \"./pipeline-validation.js\";\nimport {\n finalizationError,\n stepExecutionError,\n toPipelineError,\n} from \"./pipeline-execution-error.js\";\n\ntype PipelineRunIdentity = { correlationId?: string; parentRunId?: string; runId: string };\n\nfunction throwIfAborted(runtime: PipelineRuntime): void {\n throwIfSignalAborted(runtime.signal, \"Pipeline run\");\n}\n\nexport async function executePlannedRun<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(input: {\n compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;\n controls: PipelineRunControls;\n domainOptions: object;\n plan: PipelinePlan;\n runtime: PipelineRuntime;\n overrides?: ReadonlyMap<AnyStep, unknown>;\n}): Promise<\n PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>\n> {\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TOptions = StepsOptions<TSteps>;\n const { compiled, controls, runtime } = input;\n const startedAtMs = runtime.now();\n const runId = createRunId(compiled.id);\n const correlationId = runtime.correlationId;\n const identity: PipelineRunIdentity = { runId };\n if (correlationId !== undefined) identity.correlationId = correlationId;\n if (runtime.parentRunId) identity.parentRunId = runtime.parentRunId;\n const dryRun = controls.dryRun === true;\n const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, {\n ...identity,\n itemKey: runtime.tracing?.itemKey,\n iteration: runtime.tracing?.iteration,\n });\n const state = new PipelineRunState<TPipelineResult>(\n compiled.id,\n dryRun,\n startedAtMs,\n identity,\n runtime.now,\n lifecycle\n );\n state.start(input.plan, compiled.targetIds);\n\n if (!input.plan.ok) {\n state.recordRunErrors(input.plan.errors);\n return state.finish();\n }\n\n const maxConcurrency = controls.maxConcurrency ?? 1;\n\n // SAFETY: `domainOptions` is the user-supplied options object; if a schema\n // is present it is re-validated below before assignment to `pipelineOptions`.\n let pipelineOptions = input.domainOptions as TOptions;\n if (compiled.optionsSchema) {\n try {\n const validated = await validateStandardSchema(\n compiled.optionsSchema,\n input.domainOptions,\n `Pipeline ${compiled.id} options`\n );\n if (typeof validated !== \"object\" || validated === null || Array.isArray(validated)) {\n throw new PipelineBoundaryValidationError(\n `Pipeline ${compiled.id} options schema returned a non-object value`,\n [{ message: \"Expected the validated options value to be an object\" }]\n );\n }\n // SAFETY: the schema validated the value against `TOptions` and the\n // object-shape check above passed, so the value is a `TOptions`.\n pipelineOptions = validated as TOptions;\n } catch (error) {\n state.recordRunErrors([\n toPipelineError(error, {\n code: \"TUBELESS_OPTIONS_VALIDATION_FAILED\",\n kind: \"validation\",\n phase: \"execution\",\n }),\n ]);\n return state.finish();\n }\n }\n\n for (const step of input.plan.steps) state.planStep(step);\n\n const executionContext: PipelineExecutionContext<TOptions> = {\n ...runtime,\n dryRun,\n log: lifecycle.logger(),\n options: pipelineOptions,\n cachePolicy: controls.cache,\n runId,\n trace: lifecycle.traceContext,\n };\n\n const plannedSteps = planStepById(input.plan);\n const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));\n // `input.plan.steps` is already topologically ordered. Rehydrate from the original step\n // objects so callers still get the typed handlers rather than plan metadata.\n // SAFETY: every planned step id originates from `compiled.orderedSteps`, so the\n // map lookup always finds the matching `AnyStep<TOptions>`.\n const orderedSteps = input.plan.steps.map((step) => stepsById.get(step.id) as AnyStep<TOptions>);\n const plannedStepFor = (step: AnyStep<TOptions>): PipelinePlanStep =>\n plannedSteps.get(step.id) ??\n stepToPlanStep(step, true, undefined, undefined, compiledStepGraph(compiled, step));\n\n let stopError: PipelineError | undefined;\n let externalCancellationError: PipelineError | undefined;\n\n const recordUnstartedStep = (step: AnyStep<TOptions>, error: PipelineError): void => {\n const plannedStep = plannedStepFor(step);\n // Only the external signal can override a selected step's planned skip.\n if (plannedStep.skipReason && (!plannedStep.selected || error !== externalCancellationError)) {\n const dependencyId =\n plannedStep.skipReason === \"unmet-dependency\"\n ? plannedStep.dependencies.find((id) => plannedSteps.get(id)?.skipReason !== undefined)\n : undefined;\n state.skipStep(plannedStep, { reason: plannedStep.skipReason, dependencyId });\n } else if (error.kind === \"cancellation\") {\n state.cancelStep(plannedStep, { ...error, stepId: step.id }, false);\n } else {\n state.skipStep(plannedStep, {\n reason: \"fail-fast\",\n message: `Not run because fail-fast stopped after ${error.stepId} failed.`,\n dependencyId: error.stepId,\n });\n }\n };\n\n const recordExternalCancellation = (stepId: string): PipelineError | undefined => {\n if (externalCancellationError) return externalCancellationError;\n try {\n throwIfAborted(runtime);\n return undefined;\n } catch (error) {\n externalCancellationError = toPipelineError(error, {\n code: \"TUBELESS_RUN_CANCELLED\",\n kind: \"cancellation\",\n phase: \"execution\",\n stepId,\n });\n state.recordRunErrors([externalCancellationError]);\n return externalCancellationError;\n }\n };\n\n const cancelBeforeStepStart = (step: AnyStep<TOptions>): boolean => {\n const pipelineError = recordExternalCancellation(step.id);\n if (!pipelineError) return false;\n stopError ??= pipelineError;\n recordUnstartedStep(step, pipelineError);\n return true;\n };\n\n const recordStepExecutionFailure = (\n error: unknown,\n plannedStep: PipelinePlanStep,\n attempt: PipelineStepAttempt\n ): void => {\n const pipelineError = stepExecutionError(error, runtime, plannedStep.id);\n state.failStep(plannedStep, attempt, pipelineError);\n if (!controls.continueOnError) stopError ??= pipelineError;\n };\n\n const recordPolicySkip = async (\n plannedStep: PipelinePlanStep,\n step: AnyStep<TOptions>,\n reason: string,\n value: unknown\n ): Promise<void> => {\n let attempt: PipelineStepAttempt | undefined;\n let published = value;\n if (step.outputSchema) {\n attempt = state.beginAttempt(plannedStep);\n try {\n published = await validateStepOutput(\n step,\n value,\n `Pipeline ${compiled.id} step ${step.id} output`\n );\n } catch (error) {\n return recordStepExecutionFailure(error, plannedStep, attempt);\n }\n }\n state.skipStep(plannedStep, {\n attempt,\n message: reason,\n output: { value: published },\n reason: \"policy\",\n });\n };\n\n const executeOneStep = async (step: AnyStep<TOptions>): Promise<void> => {\n const plannedStep = plannedStepFor(step);\n if (cancelBeforeStepStart(step)) return;\n\n if (plannedStep.selected && input.overrides?.has(step)) {\n const attempt = state.beginAttempt(plannedStep, runtime.now(), \"override\");\n try {\n const output = await validateStepOutput(\n step,\n input.overrides.get(step),\n `Pipeline ${compiled.id} step ${step.id} override output`\n );\n throwIfAborted(runtime);\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n return;\n }\n\n const graph = compiledStepGraph(compiled, step);\n const disposition = decideStepDisposition({\n dryRun,\n graph,\n planned: plannedStep,\n reportsByStepId: state.reportsByStepId,\n step,\n });\n if (disposition.kind === \"skip\") {\n state.skipStep(plannedStep, disposition);\n return;\n }\n\n const inputEntries: Array<[string, unknown]> = [];\n for (const dep of graph.dependsOn) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n for (const dep of graph.optionalDependsOn) {\n if (state.outputs.has(dep.id)) inputEntries.push([dep.id, state.outputs.get(dep.id)]);\n }\n const stepInputs = Object.fromEntries(inputEntries);\n\n if (typeof step.skip === \"function\") {\n let skipDecision;\n try {\n skipDecision = await evaluateStepSkip(step, stepInputs, {\n ...executionContext,\n log: lifecycle.logger(step.id),\n });\n } catch (error) {\n const attempt = state.beginAttempt(plannedStep);\n recordStepExecutionFailure(error, plannedStep, attempt);\n return;\n }\n if (cancelBeforeStepStart(step)) return;\n if (skipDecision) {\n await recordPolicySkip(plannedStep, step, skipDecision.reason, skipDecision.value);\n return;\n }\n }\n\n const attempt = state.beginAttempt(plannedStep);\n try {\n const output = await executeStepAttempt({\n attemptId: attempt.attemptId,\n pipelineId: compiled.id,\n onCacheHit: () => {\n attempt.outputSource = \"cache\";\n },\n context: executionContext,\n dryRun,\n inputs: stepInputs,\n log: lifecycle.logger(step.id, attempt.attemptId),\n onArtifact: (record, preview) =>\n lifecycle.recordArtifact(step.id, attempt.attemptId, record, preview),\n onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),\n onReportAttempt: (number, attributes) =>\n lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),\n outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,\n step,\n });\n state.completeStep(plannedStep, attempt, output);\n } catch (error) {\n recordStepExecutionFailure(error, plannedStep, attempt);\n }\n };\n\n const unstarted = await schedulePipelineSteps({\n orderedSteps,\n stepGraph: compiled.stepGraph,\n maxConcurrency,\n executeOneStep,\n shouldStop: () => stopError !== undefined || runtime.signal?.aborted === true,\n });\n if (unstarted.length > 0 && runtime.signal?.aborted) {\n // An external abort takes precedence for work that never started, even\n // when an earlier failure stopped dispatch. Keep every active step's outcome.\n // Only reuse diagnostics created from this signal, never a step-local AbortError.\n stopError = recordExternalCancellation(unstarted[0]!.id)!;\n }\n for (const step of unstarted) recordUnstartedStep(step, stopError!);\n\n if (state.errors.length === 0 || controls.continueOnError) {\n const finalizeStartedAt = runtime.now();\n state.beginFinalization();\n try {\n throwIfAborted(runtime);\n // SAFETY: `state.outputs` maps step ids to their produced values, which is\n // exactly the shape the finalizer's outputs parameter describes.\n const finalOutputs = Object.fromEntries(state.outputs) as Parameters<\n CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]\n >[0];\n const finalizedValue = await compiled.finalize(finalOutputs, {\n ...executionContext,\n log: lifecycle.logger(PIPELINE_FINALIZE_STEP_ID),\n });\n // SAFETY: with a result schema the value is validated against\n // `TPipelineResult`; without one the finalizer's declared return type\n // is `TPipelineResult`, so the cast only restores that type.\n const value = compiled.resultSchema\n ? ((await validateStandardSchema(\n compiled.resultSchema,\n finalizedValue,\n `Pipeline ${compiled.id} final result`\n )) as TPipelineResult)\n : (finalizedValue as TPipelineResult);\n state.completeFinalization(value, runtime.now() - finalizeStartedAt);\n } catch (error) {\n const pipelineError = finalizationError(error, runtime);\n state.failFinalization(pipelineError, runtime.now() - finalizeStartedAt);\n }\n }\n\n return state.finish();\n}\n\nconst fallbackNow = (): number => Date.now();\n\nconst fallbackSleep = (durationMs: number, signal?: AbortSignal): Promise<void> =>\n abortableSleep(durationMs, signal, \"Pipeline sleep\");\n\nexport function defaultPipelineContext(): PipelineContext {\n return { cwd: process.cwd(), log: console, now: fallbackNow, sleep: fallbackSleep };\n}\n\nexport function resolvePipelineRuntime(context: Partial<PipelineContext> = {}): PipelineRuntime {\n const defaults = defaultPipelineContext();\n return {\n ...defaults,\n ...context,\n cwd: context.cwd ?? defaults.cwd,\n log: context.log ?? defaults.log,\n now: context.now ?? defaults.now ?? fallbackNow,\n sleep: context.sleep ?? defaults.sleep ?? fallbackSleep,\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CompiledStepCache } from "./pipeline-cache.js";
|
|
1
2
|
import type { AnyStep } from "./pipeline-steps.js";
|
|
2
3
|
export interface CompiledStepGraph<TOptions extends object = object> {
|
|
3
4
|
readonly dependsOn: readonly AnyStep<TOptions>[];
|
|
@@ -20,4 +21,4 @@ export interface CompiledPipelineGraph<TOptions extends object> {
|
|
|
20
21
|
readonly orderedSteps: readonly CompiledStep<TOptions>[];
|
|
21
22
|
readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;
|
|
22
23
|
}
|
|
23
|
-
export declare function compilePipelineGraph<TOptions extends object>(steps: readonly AnyStep<TOptions>[]): CompiledPipelineGraph<TOptions>;
|
|
24
|
+
export declare function compilePipelineGraph<TOptions extends object>(steps: readonly AnyStep<TOptions>[], compiledCaches?: ReadonlyMap<AnyStep, CompiledStepCache<TOptions>>): CompiledPipelineGraph<TOptions>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { snapshotPipelineMetadata } from "../tracing/graph-metadata.js";
|
|
2
|
+
import { STEP_CACHE, STEP_NESTED_PIPELINE, STEP_OPTIONS_SCHEMA, STEP_REMOTE, } from "./pipeline-step-metadata.js";
|
|
2
3
|
export function liveStepGraph(step) {
|
|
3
4
|
return {
|
|
4
5
|
dependsOn: step.dependsOn ?? [],
|
|
@@ -6,12 +7,13 @@ export function liveStepGraph(step) {
|
|
|
6
7
|
skipAfterFailureOf: step.skipAfterFailureOf ?? [],
|
|
7
8
|
};
|
|
8
9
|
}
|
|
9
|
-
function compileStep(step) {
|
|
10
|
+
function compileStep(step, cache) {
|
|
10
11
|
const nestedPipeline = step[STEP_NESTED_PIPELINE];
|
|
11
12
|
const remote = step[STEP_REMOTE];
|
|
12
13
|
const optionsSchema = step[STEP_OPTIONS_SCHEMA];
|
|
13
14
|
const name = step.name;
|
|
14
15
|
const description = step.description;
|
|
16
|
+
const metadata = snapshotPipelineMetadata(step.metadata);
|
|
15
17
|
const dryRun = step.dryRun;
|
|
16
18
|
const outputSchema = step.outputSchema;
|
|
17
19
|
const skip = step.skip;
|
|
@@ -31,6 +33,8 @@ function compileStep(step) {
|
|
|
31
33
|
Object.assign(compiled, { [STEP_REMOTE]: Object.freeze({ ...remote }) });
|
|
32
34
|
if (optionsSchema !== undefined)
|
|
33
35
|
Object.assign(compiled, { [STEP_OPTIONS_SCHEMA]: optionsSchema });
|
|
36
|
+
if (metadata !== undefined)
|
|
37
|
+
Object.assign(compiled, { metadata });
|
|
34
38
|
if (name !== undefined)
|
|
35
39
|
Object.assign(compiled, { name });
|
|
36
40
|
if (description !== undefined)
|
|
@@ -40,6 +44,8 @@ function compileStep(step) {
|
|
|
40
44
|
dryRun: typeof dryRun === "function" ? dryRun.bind(step) : dryRun,
|
|
41
45
|
});
|
|
42
46
|
}
|
|
47
|
+
if (cache)
|
|
48
|
+
Object.assign(compiled, { [STEP_CACHE]: cache });
|
|
43
49
|
if (outputSchema !== undefined)
|
|
44
50
|
Object.assign(compiled, { outputSchema });
|
|
45
51
|
if (skip !== undefined)
|
|
@@ -122,9 +128,9 @@ export function topologicalSort(steps) {
|
|
|
122
128
|
// SAFETY: every id in `orderedIds` came from the same `steps` array.
|
|
123
129
|
return orderedIds.map((id) => stepsById.get(id));
|
|
124
130
|
}
|
|
125
|
-
export function compilePipelineGraph(steps) {
|
|
131
|
+
export function compilePipelineGraph(steps, compiledCaches = new Map()) {
|
|
126
132
|
const orderedAuthorSteps = topologicalSort(steps);
|
|
127
|
-
const compiledByAuthorStep = new Map(orderedAuthorSteps.map((step) => [step, compileStep(step)]));
|
|
133
|
+
const compiledByAuthorStep = new Map(orderedAuthorSteps.map((step) => [step, compileStep(step, compiledCaches.get(step))]));
|
|
128
134
|
const orderedSteps = orderedAuthorSteps.map((step) => compiledByAuthorStep.get(step));
|
|
129
135
|
const stepGraph = new Map(orderedAuthorSteps.map((step) => {
|
|
130
136
|
const compiled = compiledByAuthorStep.get(step);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-graph.js","sourceRoot":"","sources":["../../src/core/pipeline-graph.ts"],"names":[],"mappings":"AAC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CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAChE,qEAAqE;IACrE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAsB,CAAC,CAAC;AACxE,CAAC;AAQD,MAAM,UAAU,oBAAoB,CAClC,KAAmC;IAEnC,MAAM,kBAAkB,GAAG,eAAe,CAAC,KAAK,CAAE,CAAC;IACnD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAClC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;IACF,MAAM,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QACjD,OAAO,CAAC,QAAQ,EAAE,yBAAyB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC;IACF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\n\nexport interface CompiledStepGraph<TOptions extends object = object> {\n readonly dependsOn: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf: readonly AnyStep<TOptions>[];\n}\n\nexport type CompiledStep<TOptions extends object = object> = Omit<\n AnyStep<TOptions>,\n \"dependsOn\" | \"optionalDependsOn\" | \"skipAfterFailureOf\"\n>;\n\nexport function liveStepGraph<TOptions extends object>(\n step: AnyStep<TOptions>\n): CompiledStepGraph<TOptions> {\n return {\n dependsOn: step.dependsOn ?? [],\n optionalDependsOn: step.optionalDependsOn ?? [],\n skipAfterFailureOf: step.skipAfterFailureOf ?? [],\n };\n}\n\nfunction compileStep<TOptions extends object>(step: AnyStep<TOptions>): CompiledStep<TOptions> {\n const nestedPipeline = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n const optionsSchema = step[STEP_OPTIONS_SCHEMA];\n const name = step.name;\n const description = step.description;\n const dryRun = step.dryRun;\n const outputSchema = step.outputSchema;\n const skip = step.skip;\n const compiled = {\n id: step.id,\n run: step.run.bind(step),\n };\n if (nestedPipeline !== undefined) {\n Object.assign(compiled, {\n [STEP_NESTED_PIPELINE]: Object.freeze({\n ...nestedPipeline,\n stepIds: Object.freeze([...nestedPipeline.stepIds]),\n }),\n });\n }\n if (remote !== undefined)\n Object.assign(compiled, { [STEP_REMOTE]: Object.freeze({ ...remote }) });\n if (optionsSchema !== undefined)\n Object.assign(compiled, { [STEP_OPTIONS_SCHEMA]: optionsSchema });\n if (name !== undefined) Object.assign(compiled, { name });\n if (description !== undefined) Object.assign(compiled, { description });\n if (dryRun !== undefined) {\n Object.assign(compiled, {\n dryRun: typeof dryRun === \"function\" ? dryRun.bind(step) : dryRun,\n });\n }\n if (outputSchema !== undefined) Object.assign(compiled, { outputSchema });\n if (skip !== undefined) Object.assign(compiled, { skip: skip.bind(step) });\n return Object.freeze(compiled);\n}\n\nfunction snapshotCompiledStepGraph<TOptions extends object>(\n step: AnyStep<TOptions>,\n compiledByAuthorStep: ReadonlyMap<AnyStep<TOptions>, CompiledStep<TOptions>>\n): CompiledStepGraph<TOptions> {\n const compileDependencies = (\n dependencies: readonly AnyStep<TOptions>[] | undefined\n ): readonly CompiledStep<TOptions>[] =>\n Object.freeze(\n (dependencies ?? []).map((dependency) => {\n const compiled = compiledByAuthorStep.get(dependency);\n if (compiled === undefined) {\n throw new Error(`Compiled pipeline graph is missing dependency ${dependency.id}`);\n }\n return compiled;\n })\n );\n return Object.freeze({\n dependsOn: compileDependencies(step.dependsOn),\n optionalDependsOn: compileDependencies(step.optionalDependsOn),\n skipAfterFailureOf: compileDependencies(step.skipAfterFailureOf),\n });\n}\n\nexport function compiledStepGraph<TOptions extends object>(\n compiled: Pick<{ stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph> }, \"stepGraph\">,\n step: AnyStep<TOptions>\n): CompiledStepGraph<TOptions> {\n const graph = compiled.stepGraph.get(step);\n if (graph === undefined) {\n throw new Error(`Compiled pipeline graph is missing step ${step.id}`);\n }\n // SAFETY: compile stores each descriptor as the map key.\n return graph as CompiledStepGraph<TOptions>;\n}\n\n/** Returns every distinct edge into a step, regardless of dependency policy. */\nexport function stepEdges<TOptions extends object>(\n step: AnyStep<TOptions>,\n graph: CompiledStepGraph<TOptions> = liveStepGraph(step)\n): readonly AnyStep<TOptions>[] {\n return [\n ...new Set([...graph.dependsOn, ...graph.optionalDependsOn, ...graph.skipAfterFailureOf]),\n ];\n}\n\n/** Required data and failure-gate closure for dependency-aware targets. */\nexport function targetClosure<TOptions extends object>(\n targets: readonly AnyStep<TOptions>[]\n): Set<AnyStep<TOptions>> {\n const selected = new Set<AnyStep<TOptions>>();\n const include = (step: AnyStep<TOptions>): void => {\n if (selected.has(step)) return;\n selected.add(step);\n for (const prerequisite of [...(step.dependsOn ?? []), ...(step.skipAfterFailureOf ?? [])]) {\n include(prerequisite);\n }\n };\n for (const target of targets) include(target);\n return selected;\n}\n\n/** Orders steps so every dependency runs before its dependents. */\nexport function topologicalSort<TOptions extends object>(\n steps: readonly AnyStep<TOptions>[]\n): readonly AnyStep<TOptions>[] | null {\n const indexById = new Map(steps.map((step, index) => [step.id, index]));\n const remainingInDegree = new Map(steps.map((step) => [step.id, stepEdges(step).length]));\n const dependentsOf = new Map<string, string[]>();\n for (const step of steps) {\n for (const dep of stepEdges(step)) {\n const dependents = dependentsOf.get(dep.id) ?? [];\n dependents.push(step.id);\n dependentsOf.set(dep.id, dependents);\n }\n }\n\n const ready = steps.filter((step) => remainingInDegree.get(step.id) === 0).map((step) => step.id);\n const orderedIds: string[] = [];\n while (ready.length > 0) {\n ready.sort((left, right) => (indexById.get(left) ?? 0) - (indexById.get(right) ?? 0));\n const nextId = ready.shift();\n if (nextId === undefined) break;\n orderedIds.push(nextId);\n for (const dependentId of dependentsOf.get(nextId) ?? []) {\n const remaining = (remainingInDegree.get(dependentId) ?? 0) - 1;\n remainingInDegree.set(dependentId, remaining);\n if (remaining === 0) ready.push(dependentId);\n }\n }\n\n if (orderedIds.length !== steps.length) return null;\n const stepsById = new Map(steps.map((step) => [step.id, step]));\n // SAFETY: every id in `orderedIds` came from the same `steps` array.\n return orderedIds.map((id) => stepsById.get(id) as AnyStep<TOptions>);\n}\n\nexport interface CompiledPipelineGraph<TOptions extends object> {\n readonly compiledByAuthorStep: ReadonlyMap<AnyStep<TOptions>, CompiledStep<TOptions>>;\n readonly orderedSteps: readonly CompiledStep<TOptions>[];\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n}\n\nexport function compilePipelineGraph<TOptions extends object>(\n steps: readonly AnyStep<TOptions>[]\n): CompiledPipelineGraph<TOptions> {\n const orderedAuthorSteps = topologicalSort(steps)!;\n const compiledByAuthorStep = new Map<AnyStep<TOptions>, CompiledStep<TOptions>>(\n orderedAuthorSteps.map((step) => [step, compileStep(step)])\n );\n const orderedSteps = orderedAuthorSteps.map((step) => compiledByAuthorStep.get(step)!);\n const stepGraph = new Map<AnyStep, CompiledStepGraph>(\n orderedAuthorSteps.map((step) => {\n const compiled = compiledByAuthorStep.get(step)!;\n return [compiled, snapshotCompiledStepGraph(step, compiledByAuthorStep)];\n })\n );\n return { compiledByAuthorStep, orderedSteps, stepGraph };\n}\n"]}
|
|
1
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GAAG,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QACjD,OAAO,CAAC,QAAQ,EAAE,yBAAyB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC;IACF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { snapshotPipelineMetadata } from \"../tracing/graph-metadata.js\";\nimport type { CompiledStepCache } from \"./pipeline-cache.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_CACHE,\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\n\nexport interface CompiledStepGraph<TOptions extends object = object> {\n readonly dependsOn: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf: readonly AnyStep<TOptions>[];\n}\n\nexport type CompiledStep<TOptions extends object = object> = Omit<\n AnyStep<TOptions>,\n \"dependsOn\" | \"optionalDependsOn\" | \"skipAfterFailureOf\"\n>;\n\nexport function liveStepGraph<TOptions extends object>(\n step: AnyStep<TOptions>\n): CompiledStepGraph<TOptions> {\n return {\n dependsOn: step.dependsOn ?? [],\n optionalDependsOn: step.optionalDependsOn ?? [],\n skipAfterFailureOf: step.skipAfterFailureOf ?? [],\n };\n}\n\nfunction compileStep<TOptions extends object>(\n step: AnyStep<TOptions>,\n cache: CompiledStepCache<TOptions> | undefined\n): CompiledStep<TOptions> {\n const nestedPipeline = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n const optionsSchema = step[STEP_OPTIONS_SCHEMA];\n const name = step.name;\n const description = step.description;\n const metadata = snapshotPipelineMetadata(step.metadata);\n const dryRun = step.dryRun;\n const outputSchema = step.outputSchema;\n const skip = step.skip;\n const compiled = {\n id: step.id,\n run: step.run.bind(step),\n };\n if (nestedPipeline !== undefined) {\n Object.assign(compiled, {\n [STEP_NESTED_PIPELINE]: Object.freeze({\n ...nestedPipeline,\n stepIds: Object.freeze([...nestedPipeline.stepIds]),\n }),\n });\n }\n if (remote !== undefined)\n Object.assign(compiled, { [STEP_REMOTE]: Object.freeze({ ...remote }) });\n if (optionsSchema !== undefined)\n Object.assign(compiled, { [STEP_OPTIONS_SCHEMA]: optionsSchema });\n if (metadata !== undefined) Object.assign(compiled, { metadata });\n if (name !== undefined) Object.assign(compiled, { name });\n if (description !== undefined) Object.assign(compiled, { description });\n if (dryRun !== undefined) {\n Object.assign(compiled, {\n dryRun: typeof dryRun === \"function\" ? dryRun.bind(step) : dryRun,\n });\n }\n if (cache) Object.assign(compiled, { [STEP_CACHE]: cache });\n if (outputSchema !== undefined) Object.assign(compiled, { outputSchema });\n if (skip !== undefined) Object.assign(compiled, { skip: skip.bind(step) });\n return Object.freeze(compiled);\n}\n\nfunction snapshotCompiledStepGraph<TOptions extends object>(\n step: AnyStep<TOptions>,\n compiledByAuthorStep: ReadonlyMap<AnyStep<TOptions>, CompiledStep<TOptions>>\n): CompiledStepGraph<TOptions> {\n const compileDependencies = (\n dependencies: readonly AnyStep<TOptions>[] | undefined\n ): readonly CompiledStep<TOptions>[] =>\n Object.freeze(\n (dependencies ?? []).map((dependency) => {\n const compiled = compiledByAuthorStep.get(dependency);\n if (compiled === undefined) {\n throw new Error(`Compiled pipeline graph is missing dependency ${dependency.id}`);\n }\n return compiled;\n })\n );\n return Object.freeze({\n dependsOn: compileDependencies(step.dependsOn),\n optionalDependsOn: compileDependencies(step.optionalDependsOn),\n skipAfterFailureOf: compileDependencies(step.skipAfterFailureOf),\n });\n}\n\nexport function compiledStepGraph<TOptions extends object>(\n compiled: Pick<{ stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph> }, \"stepGraph\">,\n step: AnyStep<TOptions>\n): CompiledStepGraph<TOptions> {\n const graph = compiled.stepGraph.get(step);\n if (graph === undefined) {\n throw new Error(`Compiled pipeline graph is missing step ${step.id}`);\n }\n // SAFETY: compile stores each descriptor as the map key.\n return graph as CompiledStepGraph<TOptions>;\n}\n\n/** Returns every distinct edge into a step, regardless of dependency policy. */\nexport function stepEdges<TOptions extends object>(\n step: AnyStep<TOptions>,\n graph: CompiledStepGraph<TOptions> = liveStepGraph(step)\n): readonly AnyStep<TOptions>[] {\n return [\n ...new Set([...graph.dependsOn, ...graph.optionalDependsOn, ...graph.skipAfterFailureOf]),\n ];\n}\n\n/** Required data and failure-gate closure for dependency-aware targets. */\nexport function targetClosure<TOptions extends object>(\n targets: readonly AnyStep<TOptions>[]\n): Set<AnyStep<TOptions>> {\n const selected = new Set<AnyStep<TOptions>>();\n const include = (step: AnyStep<TOptions>): void => {\n if (selected.has(step)) return;\n selected.add(step);\n for (const prerequisite of [...(step.dependsOn ?? []), ...(step.skipAfterFailureOf ?? [])]) {\n include(prerequisite);\n }\n };\n for (const target of targets) include(target);\n return selected;\n}\n\n/** Orders steps so every dependency runs before its dependents. */\nexport function topologicalSort<TOptions extends object>(\n steps: readonly AnyStep<TOptions>[]\n): readonly AnyStep<TOptions>[] | null {\n const indexById = new Map(steps.map((step, index) => [step.id, index]));\n const remainingInDegree = new Map(steps.map((step) => [step.id, stepEdges(step).length]));\n const dependentsOf = new Map<string, string[]>();\n for (const step of steps) {\n for (const dep of stepEdges(step)) {\n const dependents = dependentsOf.get(dep.id) ?? [];\n dependents.push(step.id);\n dependentsOf.set(dep.id, dependents);\n }\n }\n\n const ready = steps.filter((step) => remainingInDegree.get(step.id) === 0).map((step) => step.id);\n const orderedIds: string[] = [];\n while (ready.length > 0) {\n ready.sort((left, right) => (indexById.get(left) ?? 0) - (indexById.get(right) ?? 0));\n const nextId = ready.shift();\n if (nextId === undefined) break;\n orderedIds.push(nextId);\n for (const dependentId of dependentsOf.get(nextId) ?? []) {\n const remaining = (remainingInDegree.get(dependentId) ?? 0) - 1;\n remainingInDegree.set(dependentId, remaining);\n if (remaining === 0) ready.push(dependentId);\n }\n }\n\n if (orderedIds.length !== steps.length) return null;\n const stepsById = new Map(steps.map((step) => [step.id, step]));\n // SAFETY: every id in `orderedIds` came from the same `steps` array.\n return orderedIds.map((id) => stepsById.get(id) as AnyStep<TOptions>);\n}\n\nexport interface CompiledPipelineGraph<TOptions extends object> {\n readonly compiledByAuthorStep: ReadonlyMap<AnyStep<TOptions>, CompiledStep<TOptions>>;\n readonly orderedSteps: readonly CompiledStep<TOptions>[];\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n}\n\nexport function compilePipelineGraph<TOptions extends object>(\n steps: readonly AnyStep<TOptions>[],\n compiledCaches: ReadonlyMap<AnyStep, CompiledStepCache<TOptions>> = new Map()\n): CompiledPipelineGraph<TOptions> {\n const orderedAuthorSteps = topologicalSort(steps)!;\n const compiledByAuthorStep = new Map<AnyStep<TOptions>, CompiledStep<TOptions>>(\n orderedAuthorSteps.map((step) => [step, compileStep(step, compiledCaches.get(step))])\n );\n const orderedSteps = orderedAuthorSteps.map((step) => compiledByAuthorStep.get(step)!);\n const stepGraph = new Map<AnyStep, CompiledStepGraph>(\n orderedAuthorSteps.map((step) => {\n const compiled = compiledByAuthorStep.get(step)!;\n return [compiled, snapshotCompiledStepGraph(step, compiledByAuthorStep)];\n })\n );\n return { compiledByAuthorStep, orderedSteps, stepGraph };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { matchesStepQuery } from "./pipeline-query.js";
|
|
1
2
|
import { liveStepGraph, stepEdges } from "./pipeline-graph.js";
|
|
2
3
|
import { STEP_NESTED_PIPELINE } from "./pipeline-step-metadata.js";
|
|
3
4
|
import { PIPELINE_MERMAID_DIRECTIONS } from "./pipeline-types.js";
|
|
@@ -12,6 +13,7 @@ function escapeMermaidLabel(value) {
|
|
|
12
13
|
.replace(/>/g, "#62;");
|
|
13
14
|
}
|
|
14
15
|
export function renderPipelineMermaid(steps, options, stepGraph) {
|
|
16
|
+
steps = steps.filter((step) => matchesStepQuery(step.metadata, options.query ?? {}));
|
|
15
17
|
const direction = options.direction ?? "TD";
|
|
16
18
|
if (!PIPELINE_MERMAID_DIRECTIONS.includes(direction)) {
|
|
17
19
|
throw new Error(`Invalid Mermaid flowchart direction: ${direction}`);
|
|
@@ -21,9 +23,11 @@ export function renderPipelineMermaid(steps, options, stepGraph) {
|
|
|
21
23
|
for (const step of steps) {
|
|
22
24
|
const nodeId = nodeIdByStep.get(step);
|
|
23
25
|
const displayName = step.name ?? step.id;
|
|
24
|
-
|
|
26
|
+
let label = options.includeDescriptions && step.description
|
|
25
27
|
? `${displayName} — ${step.description}`
|
|
26
28
|
: displayName;
|
|
29
|
+
if (options.includeMetadata && step.metadata)
|
|
30
|
+
label += ` — ${JSON.stringify(step.metadata)}`;
|
|
27
31
|
const nested = step[STEP_NESTED_PIPELINE];
|
|
28
32
|
const iteration = nested?.mode === "iterate" ? ` (at most ${nested.maxIterations} iterations)` : "";
|
|
29
33
|
lines.push(` ${nodeId}["${escapeMermaidLabel(label + iteration)}"]`);
|
|
@@ -37,6 +41,8 @@ export function renderPipelineMermaid(steps, options, stepGraph) {
|
|
|
37
41
|
const failureGates = new Set(graph.skipAfterFailureOf);
|
|
38
42
|
for (const dependency of stepEdges(step, graph)) {
|
|
39
43
|
const sourceId = nodeIdByStep.get(dependency);
|
|
44
|
+
if (sourceId === undefined)
|
|
45
|
+
continue;
|
|
40
46
|
if (required.has(dependency)) {
|
|
41
47
|
edgeLines.push(` ${sourceId} --> ${targetId}`);
|
|
42
48
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-mermaid.js","sourceRoot":"","sources":["../../src/core/pipeline-mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAA0B,MAAM,qBAAqB,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAA+B,MAAM,qBAAqB,CAAC;AAE/F,SAAS,kBA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AS,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;YAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC9C,IAAI,QAAQ,KAAK,SAAS;gBAAE,SAAS;YACrC,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7B,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,QAAQ,QAAQ,EAAE,CAAC,CAAC;gBAChD,SAAS;YACX,CAAC;YACD,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7D,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,yCAAyC,QAAQ,EAAE,CAAC,CAAC;gBACjF,SAAS;YACX,CAAC;YACD,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7B,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,0BAA0B,QAAQ,EAAE,CAAC,CAAC;gBAClE,SAAS;YACX,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC","sourcesContent":["import { matchesStepQuery } from \"./pipeline-query.js\";\nimport { liveStepGraph, stepEdges, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_NESTED_PIPELINE } from \"./pipeline-step-metadata.js\";\nimport { PIPELINE_MERMAID_DIRECTIONS, type PipelineMermaidOptions } from \"./pipeline-types.js\";\n\nfunction escapeMermaidLabel(value: string): string {\n return value\n .replace(/\\r\\n?|\\n/g, \" \")\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f]/g, \" \")\n .replace(/#/g, \"#35;\")\n .replace(/&/g, \"#38;\")\n .replace(/\"/g, \"#quot;\")\n .replace(/</g, \"#60;\")\n .replace(/>/g, \"#62;\");\n}\n\nexport function renderPipelineMermaid<TOptions extends object>(\n steps: readonly AnyStep<TOptions>[],\n options: PipelineMermaidOptions,\n stepGraph?: ReadonlyMap<AnyStep, CompiledStepGraph>\n): string {\n steps = steps.filter((step) => matchesStepQuery(step.metadata, options.query ?? {}));\n const direction = options.direction ?? \"TD\";\n if (!PIPELINE_MERMAID_DIRECTIONS.includes(direction)) {\n throw new Error(`Invalid Mermaid flowchart direction: ${direction}`);\n }\n const nodeIdByStep = new Map(steps.map((step, index) => [step, `step${index}`]));\n const lines = [`flowchart ${direction}`];\n\n for (const step of steps) {\n const nodeId = nodeIdByStep.get(step)!;\n const displayName = step.name ?? step.id;\n let label =\n options.includeDescriptions && step.description\n ? `${displayName} — ${step.description}`\n : displayName;\n if (options.includeMetadata && step.metadata) label += ` — ${JSON.stringify(step.metadata)}`;\n const nested = step[STEP_NESTED_PIPELINE];\n const iteration =\n nested?.mode === \"iterate\" ? ` (at most ${nested.maxIterations} iterations)` : \"\";\n lines.push(` ${nodeId}[\"${escapeMermaidLabel(label + iteration)}\"]`);\n }\n\n const edgeLines: string[] = [];\n for (const step of steps) {\n const graph = stepGraph?.get(step) ?? liveStepGraph(step);\n const targetId = nodeIdByStep.get(step)!;\n const required = new Set(graph.dependsOn);\n const optional = new Set(graph.optionalDependsOn);\n const failureGates = new Set(graph.skipAfterFailureOf);\n\n for (const dependency of stepEdges(step, graph)) {\n const sourceId = nodeIdByStep.get(dependency);\n if (sourceId === undefined) continue;\n if (required.has(dependency)) {\n edgeLines.push(` ${sourceId} --> ${targetId}`);\n continue;\n }\n if (optional.has(dependency) && failureGates.has(dependency)) {\n edgeLines.push(` ${sourceId} -. optional input + failure gate .-> ${targetId}`);\n continue;\n }\n if (optional.has(dependency)) {\n edgeLines.push(` ${sourceId} -. optional input .-> ${targetId}`);\n continue;\n }\n edgeLines.push(` ${sourceId} -. failure gate .-> ${targetId}`);\n }\n }\n\n if (edgeLines.length > 0) lines.push(\"\", ...edgeLines);\n return `${lines.join(\"\\n\")}\\n`;\n}\n"]}
|
|
@@ -8,6 +8,7 @@ export function stepToPlanStep(step, selected, skipReason, selectionReasons, gra
|
|
|
8
8
|
const planStep = {
|
|
9
9
|
dependencies: graph.dependsOn.map((dep) => dep.id),
|
|
10
10
|
description: step.description,
|
|
11
|
+
...(step.metadata === undefined ? {} : { metadata: step.metadata }),
|
|
11
12
|
dryRun: step.dryRun === "skip" ? "skip" : step.dryRun !== undefined ? "custom" : "run",
|
|
12
13
|
id: step.id,
|
|
13
14
|
name: step.name,
|
|
@@ -86,6 +87,9 @@ export function buildPipelinePlan(compiled, controls) {
|
|
|
86
87
|
const declaredTargetIds = new Set(compiled.declaredTargets.map((target) => target.id));
|
|
87
88
|
const requestedStepIds = controls.stepIds ?? [];
|
|
88
89
|
const requestedTargets = controls.targets ?? [];
|
|
90
|
+
if (controls.cache !== undefined && !["use", "recompute", "bypass"].includes(controls.cache)) {
|
|
91
|
+
errors.push(pipelineDiagnostic("TUBELESS_RUN_CACHE_INVALID", "planning", "validation", "cache must be use, recompute, or bypass"));
|
|
92
|
+
}
|
|
89
93
|
const maxConcurrency = controls.maxConcurrency ?? 1;
|
|
90
94
|
if (!Number.isInteger(maxConcurrency) || maxConcurrency < 1) {
|
|
91
95
|
errors.push(pipelineDiagnostic("TUBELESS_RUN_CONCURRENCY_INVALID", "planning", "validation", "maxConcurrency must be a positive finite integer"));
|