tubeless 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/child-execution.d.ts +0 -23
- package/dist/core/child-execution.js +10 -12
- package/dist/core/child-execution.js.map +1 -1
- package/dist/core/child-progress.js +7 -2
- package/dist/core/child-progress.js.map +1 -1
- package/dist/core/iteration.d.ts +27 -0
- package/dist/core/iteration.js +111 -0
- package/dist/core/iteration.js.map +1 -0
- package/dist/core/lifecycle.d.ts +7 -5
- package/dist/core/lifecycle.js +36 -4
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core/pipeline-artifacts.d.ts +11 -0
- package/dist/core/pipeline-artifacts.js +2 -0
- package/dist/core/pipeline-artifacts.js.map +1 -0
- package/dist/core/pipeline-compiler.d.ts +1 -0
- package/dist/core/pipeline-compiler.js +1 -0
- package/dist/core/pipeline-compiler.js.map +1 -1
- package/dist/core/pipeline-definition-identity.d.ts +2 -2
- package/dist/core/pipeline-definition-identity.js +28 -5
- package/dist/core/pipeline-definition-identity.js.map +1 -1
- package/dist/core/pipeline-execute.d.ts +1 -6
- package/dist/core/pipeline-execute.js +28 -215
- package/dist/core/pipeline-execute.js.map +1 -1
- package/dist/core/pipeline-execution-error.d.ts +35 -0
- package/dist/core/pipeline-execution-error.js +195 -0
- package/dist/core/pipeline-execution-error.js.map +1 -0
- package/dist/core/pipeline-identity.d.ts +1 -0
- package/dist/core/pipeline-identity.js +1 -0
- package/dist/core/pipeline-identity.js.map +1 -1
- package/dist/core/pipeline-mermaid.js +4 -1
- package/dist/core/pipeline-mermaid.js.map +1 -1
- package/dist/core/pipeline-run-state.d.ts +4 -4
- package/dist/core/pipeline-run-state.js +10 -16
- 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 +11 -3
- package/dist/core/pipeline-step-executor.js.map +1 -1
- package/dist/core/pipeline-steps.d.ts +20 -0
- package/dist/core/pipeline-steps.js +62 -0
- package/dist/core/pipeline-steps.js.map +1 -1
- package/dist/core/pipeline-types.d.ts +15 -2
- package/dist/core/pipeline-types.js.map +1 -1
- package/dist/core/pipeline.d.ts +4 -1
- package/dist/core/pipeline.js +18 -3
- package/dist/core/pipeline.js.map +1 -1
- package/dist/project/project-compiler.d.ts +3 -31
- package/dist/project/project-compiler.js +11 -180
- package/dist/project/project-compiler.js.map +1 -1
- package/dist/project/project-registry.d.ts +44 -0
- package/dist/project/project-registry.js +107 -0
- package/dist/project/project-registry.js.map +1 -0
- package/dist/project/project-step-graph.d.ts +9 -0
- package/dist/project/project-step-graph.js +99 -0
- package/dist/project/project-step-graph.js.map +1 -0
- package/dist/render/render.js +1 -1
- package/dist/render/render.js.map +1 -1
- package/dist/reporter/interactive-reporter.js +6 -3
- package/dist/reporter/interactive-reporter.js.map +1 -1
- package/dist/reporter/live-ticker-frame.d.ts +21 -0
- package/dist/reporter/live-ticker-frame.js +196 -0
- package/dist/reporter/live-ticker-frame.js.map +1 -0
- package/dist/reporter/live-ticker-protocol.d.ts +41 -0
- package/dist/reporter/live-ticker-protocol.js +59 -0
- package/dist/reporter/live-ticker-protocol.js.map +1 -0
- package/dist/reporter/live-ticker-worker.js +11 -25
- package/dist/reporter/live-ticker-worker.js.map +1 -1
- package/dist/reporter/live-ticker.d.ts +0 -15
- package/dist/reporter/live-ticker.js +11 -216
- package/dist/reporter/live-ticker.js.map +1 -1
- package/dist/reporter/reporter.js +7 -6
- package/dist/reporter/reporter.js.map +1 -1
- package/dist/run-store/definition-projection.d.ts +8 -0
- package/dist/run-store/definition-projection.js +89 -0
- package/dist/run-store/definition-projection.js.map +1 -0
- package/dist/run-store/run-projection.d.ts +15 -0
- package/dist/run-store/run-projection.js +203 -0
- package/dist/run-store/run-projection.js.map +1 -0
- package/dist/run-store/run-store-codec.d.ts +2 -0
- package/dist/run-store/run-store-codec.js +11 -0
- package/dist/run-store/run-store-codec.js.map +1 -1
- package/dist/run-store/run-store-event-decoder.js +3 -0
- package/dist/run-store/run-store-event-decoder.js.map +1 -1
- package/dist/run-store/run-store-reader.d.ts +7 -0
- package/dist/run-store/run-store-reader.js +31 -0
- package/dist/run-store/run-store-reader.js.map +1 -0
- package/dist/run-store/run-store-sqlite.js +23 -7
- package/dist/run-store/run-store-sqlite.js.map +1 -1
- package/dist/run-store/run-store.d.ts +16 -4
- package/dist/run-store/run-store.js +14 -263
- package/dist/run-store/run-store.js.map +1 -1
- package/dist/studio/run-store-ui-api.d.ts +13 -0
- package/dist/studio/run-store-ui-api.js +163 -0
- package/dist/studio/run-store-ui-api.js.map +1 -0
- package/dist/studio/run-store-ui-client-browser.js +2 -2
- package/dist/studio/run-store-ui-client-transport.js +28 -3
- package/dist/studio/run-store-ui-client-transport.js.map +1 -1
- package/dist/studio/run-store-ui-client.d.ts +2 -1
- package/dist/studio/run-store-ui-client.js +15 -9
- package/dist/studio/run-store-ui-client.js.map +1 -1
- package/dist/studio/run-store-ui-http.d.ts +11 -0
- package/dist/studio/run-store-ui-http.js +52 -0
- package/dist/studio/run-store-ui-http.js.map +1 -1
- package/dist/studio/run-store-ui-state.d.ts +1 -1
- package/dist/studio/run-store-ui-state.js +10 -28
- package/dist/studio/run-store-ui-state.js.map +1 -1
- package/dist/studio/run-store-ui.d.ts +5 -11
- package/dist/studio/run-store-ui.js +5 -203
- package/dist/studio/run-store-ui.js.map +1 -1
- package/dist/testing/testing.d.ts +18 -2
- package/dist/testing/testing.js +35 -2
- package/dist/testing/testing.js.map +1 -1
- package/dist/tracing/artifact-metadata.d.ts +28 -0
- package/dist/tracing/artifact-metadata.js +105 -0
- package/dist/tracing/artifact-metadata.js.map +1 -0
- package/dist/tracing/tracing-codec.d.ts +1 -1
- package/dist/tracing/tracing-codec.js +1 -1
- package/dist/tracing/tracing-codec.js.map +1 -1
- package/dist/tracing/tracing-constants.d.ts +1 -1
- package/dist/tracing/tracing-constants.js +1 -1
- package/dist/tracing/tracing-constants.js.map +1 -1
- package/dist/tracing/tracing-contracts.d.ts +3 -1
- package/dist/tracing/tracing-contracts.js.map +1 -1
- package/dist/tracing/tracing-internal.d.ts +2 -0
- package/dist/tracing/tracing-internal.js +36 -13
- package/dist/tracing/tracing-internal.js.map +1 -1
- package/dist/tracing/tracing-schema.d.ts +330 -49
- package/dist/tracing/tracing-schema.js +102 -10
- package/dist/tracing/tracing-schema.js.map +1 -1
- package/dist/workbench/workbench-command-execution.d.ts +6 -0
- package/dist/workbench/workbench-command-execution.js +48 -0
- package/dist/workbench/workbench-command-execution.js.map +1 -0
- package/dist/workbench/workbench-history.js +11 -18
- package/dist/workbench/workbench-history.js.map +1 -1
- package/dist/workbench/workbench-launch-session.d.ts +2 -2
- package/dist/workbench/workbench-launch-session.js.map +1 -1
- package/dist/workbench/workbench-run.d.ts +0 -4
- package/dist/workbench/workbench-run.js +3 -47
- package/dist/workbench/workbench-run.js.map +1 -1
- package/dist/workbench/workbench-studio-launcher.d.ts +27 -0
- package/dist/workbench/workbench-studio-launcher.js +95 -0
- package/dist/workbench/workbench-studio-launcher.js.map +1 -0
- package/dist/workbench/workbench-ui.js +10 -83
- package/dist/workbench/workbench-ui.js.map +1 -1
- package/docs/README.md +13 -7
- package/docs/agent-guide.md +69 -6
- package/docs/airflow.md +187 -0
- package/docs/api-reference.md +87 -76
- package/docs/api-report.json +17 -6
- package/docs/artifacts.md +173 -0
- package/docs/child-pipeline-composition.md +65 -2
- package/docs/comparison.md +20 -0
- package/docs/concepts.md +70 -2
- package/docs/dagster.md +161 -0
- package/docs/inngest.md +163 -0
- package/docs/llms.txt +30 -1
- package/docs/recipes.md +82 -33
- package/docs/remote-step-composition.md +6 -0
- package/docs/step-functions.md +190 -0
- package/docs/studio.md +31 -12
- package/docs/temporal.md +183 -0
- package/examples/airflow/contract.ts +46 -0
- package/examples/airflow/hosted.ts +70 -0
- package/examples/airflow/remote.ts +175 -0
- package/examples/airflow/tubeless_example.py +49 -0
- package/examples/airflow/worker.ts +24 -0
- package/examples/artifact-lineage.ts +70 -0
- package/examples/dagster/definitions.py +59 -0
- package/examples/dagster/hosted.ts +78 -0
- package/examples/dagster/pipeline.ts +62 -0
- package/examples/dagster/test_definitions.py +47 -0
- package/examples/dagster/tsconfig.build.json +10 -0
- package/examples/dagster/worker.ts +22 -0
- package/examples/inngest/client.ts +4 -0
- package/examples/inngest/functions.ts +65 -0
- package/examples/inngest/pipeline.ts +41 -0
- package/examples/inngest/send.ts +11 -0
- package/examples/inngest/server.ts +17 -0
- package/examples/inngest/tsconfig.build.json +10 -0
- package/examples/iteration.ts +52 -0
- package/examples/parameterized-steps.ts +96 -0
- package/examples/project/tubeless.project.ts +46 -0
- package/examples/step-functions/handler.ts +110 -0
- package/examples/step-functions/input.json +1 -0
- package/examples/step-functions/pipeline.ts +41 -0
- package/examples/step-functions/state-machine.asl.json +41 -0
- package/examples/step-functions/template.json +42 -0
- package/examples/step-output-overrides.ts +41 -0
- package/examples/temporal/activities.ts +94 -0
- package/examples/temporal/client.ts +19 -0
- package/examples/temporal/pipeline.ts +41 -0
- package/examples/temporal/tsconfig.build.json +10 -0
- package/examples/temporal/worker.ts +21 -0
- package/examples/temporal/workflows.ts +16 -0
- package/package.json +13 -4
- package/skills/tubeless/SKILL.md +30 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AA8BxC,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChF,KAAK,MAAM,KAAK,IAAI,QAA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esContent":["import type {\n PipelineError,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport {\n createPipelineTraceEmitter,\n type PipelineTraceEmitter,\n} from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n log(\n level: \"error\" | \"log\" | \"warn\",\n message: unknown,\n params?: readonly unknown[],\n stepId?: string,\n attemptId?: string\n ): void;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nfunction snapshotRun(result: PipelineRun<unknown>): PipelineRun<unknown> {\n if (!result.finalized) return structuredClone(result);\n // Domain results may contain functions or class instances. Only lifecycle\n // metadata belongs to Tubeless; preserve the domain value's identity.\n const { value, ...metadata } = result;\n return { ...structuredClone(metadata), value };\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n trace: PipelineTraceEmitter | undefined\n): PipelineLifecycleObserver {\n return {\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) =>\n hooks.onStepProgress?.(structuredClone({ ...event, progress }))\n );\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n pipelineId: event.pipelineId,\n status: \"running\",\n step: structuredClone(event.step),\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n log: (level, message, params, stepId, attemptId) =>\n trace?.log(level, message, params, stepId, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) =>\n hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId })\n );\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n const lifecycle = createPipelineLifecycleObserver(\n pipelineId,\n runtime,\n createPipelineTraceEmitter(pipelineId, runtime.tracing, runtime.log, identity, runtime.now)\n );\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AA0B5E,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAI1D,SAAS,kBAAkB,CAAC,GAAmB;IAC7C,6EAA6E;IAC7E,OAAQ,GAA4B,CAAC,oBAAoB,CAAC,IAAI,GAAG,CAAC;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChF,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CA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Error,\n PipelineHooks,\n PipelineLogger,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport { createPipelineTraceEmitter } from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n readonly traceContext: PipelineTraceContext | undefined;\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n logger(stepId?: string, attemptId?: string): PipelineLogger;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n recordArtifact(stepId: string, attemptId: string, record: ArtifactRecord, preview: boolean): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nconst PIPELINE_LOGGER_BASE = Symbol(\"pipelineLoggerBase\");\n\ntype TracedPipelineLogger = PipelineLogger & { [PIPELINE_LOGGER_BASE]?: PipelineLogger };\n\nfunction basePipelineLogger(log: PipelineLogger): PipelineLogger {\n // SAFETY: the optional symbol exists only on loggers created by this module.\n return (log as TracedPipelineLogger)[PIPELINE_LOGGER_BASE] ?? log;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nfunction snapshotRun(result: PipelineRun<unknown>): PipelineRun<unknown> {\n if (!result.finalized) return structuredClone(result);\n // Domain results may contain functions or class instances. Only lifecycle\n // metadata belongs to Tubeless; preserve the domain value's identity.\n const { value, ...metadata } = result;\n return { ...structuredClone(metadata), value };\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n identity: PipelineTraceContext\n): PipelineLifecycleObserver {\n const base = basePipelineLogger(runtime.log);\n const trace = createPipelineTraceEmitter(\n pipelineId,\n runtime.tracing,\n base,\n identity,\n runtime.now\n );\n return {\n traceContext: trace?.context,\n logger(stepId, attemptId) {\n if (!trace) return runtime.log;\n // A child run inherits its parent's logger, but owns its own trace events.\n const log: TracedPipelineLogger = {\n error: (message, ...params) => {\n trace.log(\"error\", message, params, stepId, attemptId);\n base.error(message, ...params);\n },\n log: (message, ...params) => {\n trace.log(\"log\", message, params, stepId, attemptId);\n base.log(message, ...params);\n },\n warn: (message, ...params) => {\n trace.log(\"warn\", message, params, stepId, attemptId);\n base.warn(message, ...params);\n },\n };\n log[PIPELINE_LOGGER_BASE] = base;\n return log;\n },\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) =>\n hooks.onStepProgress?.(structuredClone({ ...event, progress }))\n );\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n ...(event.outputSource ? { outputSource: event.outputSource } : {}),\n pipelineId: event.pipelineId,\n status: \"running\",\n step: structuredClone(event.step),\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n recordArtifact: (stepId, attemptId, record, preview) =>\n trace?.artifact(stepId, attemptId, record, preview),\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) =>\n hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId })\n );\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n if (runtime.tracing?.iteration) identity.iteration = runtime.tracing.iteration;\n const lifecycle = createPipelineLifecycleObserver(pipelineId, runtime, identity);\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ArtifactMetadata } from "../tracing/artifact-metadata.js";
|
|
2
|
+
import type { PipelineStepContext } from "./pipeline-types.js";
|
|
3
|
+
/** Adapter result: the value flows to dependents; only artifact metadata is recorded. */
|
|
4
|
+
export interface ArtifactResult<TValue> {
|
|
5
|
+
readonly value: TValue;
|
|
6
|
+
readonly artifact: ArtifactMetadata;
|
|
7
|
+
}
|
|
8
|
+
/** Application-owned read boundary. Forward context.signal to cancellable I/O. */
|
|
9
|
+
export type ArtifactLoader<TInput, TValue, TOptions extends object = {}> = (input: TInput, context: PipelineStepContext<TOptions>) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;
|
|
10
|
+
/** Application-owned write boundary returning a typed receipt and separate trace metadata. */
|
|
11
|
+
export type ArtifactSaver<TInput, TValue, TOptions extends object = {}> = (input: TInput, context: PipelineStepContext<TOptions>) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-artifacts.js","sourceRoot":"","sources":["../../src/core/pipeline-artifacts.ts"],"names":[],"mappings":"","sourcesContent":["import type { ArtifactMetadata } from \"../tracing/artifact-metadata.js\";\nimport type { PipelineStepContext } from \"./pipeline-types.js\";\n\n/** Adapter result: the value flows to dependents; only artifact metadata is recorded. */\nexport interface ArtifactResult<TValue> {\n readonly value: TValue;\n readonly artifact: ArtifactMetadata;\n}\n\n/** Application-owned read boundary. Forward context.signal to cancellable I/O. */\nexport type ArtifactLoader<TInput, TValue, TOptions extends object = {}> = (\n input: TInput,\n context: PipelineStepContext<TOptions>\n) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;\n\n/** Application-owned write boundary returning a typed receipt and separate trace metadata. */\nexport type ArtifactSaver<TInput, TValue, TOptions extends object = {}> = (\n input: TInput,\n context: PipelineStepContext<TOptions>\n) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;\n"]}
|
|
@@ -9,6 +9,7 @@ export interface CompiledPipeline<TSteps extends readonly AnyStep[] = readonly A
|
|
|
9
9
|
readonly id: string;
|
|
10
10
|
readonly optionsSchema: StandardSchemaV1 | undefined;
|
|
11
11
|
readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];
|
|
12
|
+
readonly compiledByAuthorStep: ReadonlyMap<AnyStep, AnyStep>;
|
|
12
13
|
readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;
|
|
13
14
|
readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;
|
|
14
15
|
readonly resultSchema: TResultSchema | undefined;
|
|
@@ -49,6 +49,7 @@ export function compilePipeline(definition) {
|
|
|
49
49
|
? undefined
|
|
50
50
|
: compiledByAuthorStep.get(definition.steps[0])?.[STEP_OPTIONS_SCHEMA],
|
|
51
51
|
orderedSteps: Object.freeze([...orderedSteps]),
|
|
52
|
+
compiledByAuthorStep,
|
|
52
53
|
stepGraph,
|
|
53
54
|
requiredFinalizerSteps: compiledRequiredFinalizerSteps
|
|
54
55
|
? Object.freeze(compiledRequiredFinalizerSteps)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE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BAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC;QAC3E,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QAC9C,oBAAoB;QACpB,SAAS;QACT,sBAAsB,EAAE,8BAA8B;YACpD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,8BAA8B,CAAC;YAC/C,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { compileDefinitionSnapshot } from \"./pipeline-definition-identity.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { validatePipelineDefinition } from \"./pipeline-definition-validation.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { compilePipelineGraph, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionSnapshot, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport interface CompiledPipeline<\n TSteps extends readonly AnyStep[] = readonly AnyStep[],\n TResult = unknown,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n readonly definition: PipelineDefinitionSnapshot;\n readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: Extract<\n NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]>,\n (...args: never[]) => unknown\n >;\n readonly id: string;\n readonly optionsSchema: StandardSchemaV1 | undefined;\n readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly compiledByAuthorStep: ReadonlyMap<AnyStep, AnyStep>;\n readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n readonly resultSchema: TResultSchema | undefined;\n readonly stepIds: readonly string[];\n readonly targetIds: readonly string[];\n}\n\nexport function compilePipeline<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>\n): CompiledPipeline<TSteps, TResult, TTargets, TResultSchema> {\n const errors = validatePipelineDefinition(definition);\n if (errors.length > 0) {\n throw new PipelineDefinitionError(definition.id, errors);\n }\n type TOptions = StepsOptions<TSteps>;\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores\n // the `TOptions` generic that the tuple erased, without changing the values.\n const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(\n definition.steps as readonly AnyStep<TOptions>[]\n );\n const finalizerMetadata = requiredFinalizerMetadata<TOptions>(definition.finalize);\n const requiredFinalizerSteps = finalizerMetadata?.steps;\n const compiledTargets = definition.targets\n ? definition.targets.map((target) => compiledByAuthorStep.get(target)!)\n : orderedSteps.slice(-1);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const lastStepId = orderedSteps.at(-1)?.id;\n const authoredFinalize = definition.finalize;\n type Finalizer = CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : typeof authoredFinalize === \"function\"\n ? (outputs: Parameters<Finalizer>[0], context: Parameters<Finalizer>[1]) =>\n authoredFinalize.call(definition, outputs, context)\n : (outputs: Record<string, unknown>) =>\n lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)\n ? outputs[lastStepId]\n : undefined;\n const snapshot = compileDefinitionSnapshot({\n orderedSteps,\n stepGraph,\n targetIds: compiledTargets.map((step) => step.id),\n requiredFinalizerSteps: compiledRequiredFinalizerSteps,\n resultValidated: definition.resultSchema !== undefined,\n implementationVersion: definition.implementationVersion,\n });\n return Object.freeze({\n definition: snapshot,\n declaredTargets: Object.freeze(compiledTargets),\n // Invoke ordinary finalizers on the author's definition so method-style\n // implementations keep `this`. Required finalizers compile the same input\n // and context contract with stable required ids.\n // SAFETY: supplied finalizers preserve their signature; definePipeline checks\n // that an omitted finalizer can use the last step's output as its result.\n finalize: compiledFinalize as Finalizer,\n id: definition.id,\n optionsSchema:\n definition.steps.length === 0\n ? undefined\n : compiledByAuthorStep.get(definition.steps[0]!)?.[STEP_OPTIONS_SCHEMA],\n orderedSteps: Object.freeze([...orderedSteps]),\n compiledByAuthorStep,\n stepGraph,\n requiredFinalizerSteps: compiledRequiredFinalizerSteps\n ? Object.freeze(compiledRequiredFinalizerSteps)\n : undefined,\n resultSchema: definition.resultSchema,\n stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step)!.id)),\n targetIds: Object.freeze(compiledTargets.map((step) => step.id)),\n });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CompiledStepGraph } from "./pipeline-graph.js";
|
|
2
2
|
import type { AnyStep } from "./pipeline-steps.js";
|
|
3
3
|
import type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from "./pipeline-types.js";
|
|
4
|
-
/** Canonical
|
|
4
|
+
/** Canonical snapshot. Execution order matters; dependency and target sets do not. */
|
|
5
5
|
export declare function compileDefinitionSnapshot(input: {
|
|
6
6
|
orderedSteps: readonly AnyStep[];
|
|
7
7
|
stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;
|
|
@@ -10,5 +10,5 @@ export declare function compileDefinitionSnapshot(input: {
|
|
|
10
10
|
resultValidated: boolean;
|
|
11
11
|
implementationVersion: string | undefined;
|
|
12
12
|
}): PipelineDefinitionSnapshot;
|
|
13
|
-
/**
|
|
13
|
+
/** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */
|
|
14
14
|
export declare function createDefinitionIdentity(input: Omit<PipelineDefinitionSnapshot, "identity">, implementationVersion: string | undefined): PipelineDefinitionIdentity;
|
|
@@ -11,7 +11,25 @@ function freezeSnapshot(value) {
|
|
|
11
11
|
}
|
|
12
12
|
return value;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
function iterationFields(nested) {
|
|
15
|
+
if (nested.mode !== "iterate")
|
|
16
|
+
return {};
|
|
17
|
+
const controls = nested.controls;
|
|
18
|
+
const normalizedControls = {
|
|
19
|
+
...(controls?.dryRun !== undefined ? { dryRun: controls.dryRun } : {}),
|
|
20
|
+
...(controls?.continueOnError !== undefined
|
|
21
|
+
? { continueOnError: controls.continueOnError }
|
|
22
|
+
: {}),
|
|
23
|
+
...(controls?.maxConcurrency !== undefined ? { maxConcurrency: controls.maxConcurrency } : {}),
|
|
24
|
+
...(controls?.targets !== undefined ? { targets: [...controls.targets].sort() } : {}),
|
|
25
|
+
...(controls?.stepIds !== undefined ? { stepIds: [...controls.stepIds].sort() } : {}),
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
maxIterations: nested.maxIterations,
|
|
29
|
+
...(Object.keys(normalizedControls).length > 0 ? { controls: normalizedControls } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Canonical snapshot. Execution order matters; dependency and target sets do not. */
|
|
15
33
|
export function compileDefinitionSnapshot(input) {
|
|
16
34
|
const steps = input.orderedSteps.map((step) => {
|
|
17
35
|
const graph = input.stepGraph.get(step);
|
|
@@ -34,6 +52,7 @@ export function compileDefinitionSnapshot(input) {
|
|
|
34
52
|
nestedPipeline: {
|
|
35
53
|
pipelineId: nested.pipelineId,
|
|
36
54
|
mode: nested.mode,
|
|
55
|
+
...iterationFields(nested),
|
|
37
56
|
stepIds: [...nested.stepIds],
|
|
38
57
|
...(nested.identity ? { identity: { ...nested.identity } } : {}),
|
|
39
58
|
...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),
|
|
@@ -64,11 +83,14 @@ export function compileDefinitionSnapshot(input) {
|
|
|
64
83
|
...semantics,
|
|
65
84
|
});
|
|
66
85
|
}
|
|
67
|
-
/**
|
|
86
|
+
/** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */
|
|
68
87
|
export function createDefinitionIdentity(input, implementationVersion) {
|
|
88
|
+
const version = input.steps.some((step) => step.nestedPipeline?.mode === "iterate" || step.nestedPipeline?.identity?.version === 2)
|
|
89
|
+
? 2
|
|
90
|
+
: 1;
|
|
69
91
|
// Child handler versions participate in the combined identity, never the graph fingerprint.
|
|
70
92
|
const structuralFingerprint = fingerprint({
|
|
71
|
-
version
|
|
93
|
+
version,
|
|
72
94
|
steps: input.steps.map((step) => ({
|
|
73
95
|
id: step.id,
|
|
74
96
|
dependencies: [...step.dependencies].sort(),
|
|
@@ -82,6 +104,7 @@ export function createDefinitionIdentity(input, implementationVersion) {
|
|
|
82
104
|
nestedPipeline: {
|
|
83
105
|
pipelineId: step.nestedPipeline.pipelineId,
|
|
84
106
|
mode: step.nestedPipeline.mode,
|
|
107
|
+
...iterationFields(step.nestedPipeline),
|
|
85
108
|
stepIds: [...step.nestedPipeline.stepIds],
|
|
86
109
|
...(step.nestedPipeline.identity
|
|
87
110
|
? {
|
|
@@ -114,11 +137,11 @@ export function createDefinitionIdentity(input, implementationVersion) {
|
|
|
114
137
|
resultValidated: input.resultValidated,
|
|
115
138
|
});
|
|
116
139
|
return {
|
|
117
|
-
version
|
|
140
|
+
version,
|
|
118
141
|
structuralFingerprint,
|
|
119
142
|
...(implementationVersion !== undefined ? { implementationVersion } : {}),
|
|
120
143
|
definitionId: fingerprint({
|
|
121
|
-
version
|
|
144
|
+
version,
|
|
122
145
|
structuralFingerprint,
|
|
123
146
|
implementationVersion,
|
|
124
147
|
children: input.steps.map((step) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-definition-identity.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAGrC,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,cAAc,CAAI,KAAQ;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CAAC,KAOzC;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC1C,MAAM,MA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CAAC;YACJ,CAAC,CAAC;SACH,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from \"./pipeline-types.js\";\n\nfunction fingerprint(value: unknown): string {\n return `sha256:${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")}`;\n}\n\nfunction freezeSnapshot<T>(value: T): T {\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value)) freezeSnapshot(child);\n Object.freeze(value);\n }\n return value;\n}\n\n/** Canonical v1 semantics. Execution order matters; dependency and target sets do not. */\nexport function compileDefinitionSnapshot(input: {\n orderedSteps: readonly AnyStep[];\n stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n targetIds: readonly string[];\n requiredFinalizerSteps: readonly AnyStep[] | undefined;\n resultValidated: boolean;\n implementationVersion: string | undefined;\n}): PipelineDefinitionSnapshot {\n const steps = input.orderedSteps.map((step) => {\n const graph = input.stepGraph.get(step)!;\n const nested = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n return {\n id: step.id,\n dependencies: graph.dependsOn.map(({ id }) => id).sort(),\n optionalDependencies: graph.optionalDependsOn.map(({ id }) => id).sort(),\n skipAfterFailureOf: graph.skipAfterFailureOf.map(({ id }) => id).sort(),\n dryRun:\n step.dryRun === \"skip\"\n ? (\"skip\" as const)\n : step.dryRun\n ? (\"custom\" as const)\n : (\"run\" as const),\n runtimeSkipPossible: step.skip !== undefined,\n outputValidated: step.outputSchema !== undefined,\n ...(nested\n ? {\n nestedPipeline: {\n pipelineId: nested.pipelineId,\n mode: nested.mode,\n stepIds: [...nested.stepIds],\n ...(nested.identity ? { identity: { ...nested.identity } } : {}),\n ...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),\n },\n }\n : {}),\n ...(remote\n ? {\n remote: {\n engine: remote.engine,\n ...(remote.target !== undefined ? { target: remote.target } : {}),\n },\n }\n : {}),\n };\n });\n const semantics = {\n steps,\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerSteps\n ? { requiredFinalizerStepIds: input.requiredFinalizerSteps.map(({ id }) => id).sort() }\n : {}),\n optionsValidated: input.orderedSteps[0]?.[STEP_OPTIONS_SCHEMA] !== undefined,\n resultValidated: input.resultValidated,\n };\n return freezeSnapshot({\n identity: createDefinitionIdentity(semantics, input.implementationVersion),\n ...semantics,\n });\n}\n\n/** Rebuild v1 hashes from explicit fields, independent of JSON object property order. */\nexport function createDefinitionIdentity(\n input: Omit<PipelineDefinitionSnapshot, \"identity\">,\n implementationVersion: string | undefined\n): PipelineDefinitionIdentity {\n // Child handler versions participate in the combined identity, never the graph fingerprint.\n const structuralFingerprint = fingerprint({\n version: 1,\n steps: input.steps.map((step) => ({\n id: step.id,\n dependencies: [...step.dependencies].sort(),\n optionalDependencies: [...step.optionalDependencies].sort(),\n skipAfterFailureOf: [...step.skipAfterFailureOf].sort(),\n dryRun: step.dryRun,\n runtimeSkipPossible: step.runtimeSkipPossible,\n outputValidated: step.outputValidated,\n ...(step.nestedPipeline\n ? {\n nestedPipeline: {\n pipelineId: step.nestedPipeline.pipelineId,\n mode: step.nestedPipeline.mode,\n stepIds: [...step.nestedPipeline.stepIds],\n ...(step.nestedPipeline.identity\n ? {\n identity: {\n version: step.nestedPipeline.identity.version,\n structuralFingerprint: step.nestedPipeline.identity.structuralFingerprint,\n },\n }\n : {}),\n ...(step.nestedPipeline.concurrency !== undefined\n ? { concurrency: step.nestedPipeline.concurrency }\n : {}),\n },\n }\n : {}),\n ...(step.remote\n ? {\n remote: {\n engine: step.remote.engine,\n ...(step.remote.target !== undefined ? { target: step.remote.target } : {}),\n },\n }\n : {}),\n })),\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerStepIds\n ? { requiredFinalizerStepIds: [...input.requiredFinalizerStepIds].sort() }\n : {}),\n optionsValidated: input.optionsValidated,\n resultValidated: input.resultValidated,\n });\n return {\n version: 1,\n structuralFingerprint,\n ...(implementationVersion !== undefined ? { implementationVersion } : {}),\n definitionId: fingerprint({\n version: 1,\n structuralFingerprint,\n implementationVersion,\n children: input.steps.map((step) => {\n const child = step.nestedPipeline?.identity;\n if (!child) return null;\n // Bind every recorded child identity field, not just its opaque definition ID.\n return {\n version: child.version,\n structuralFingerprint: child.structuralFingerprint,\n ...(child.implementationVersion !== undefined\n ? { implementationVersion: child.implementationVersion }\n : {}),\n definitionId: child.definitionId,\n };\n }),\n }),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline-definition-identity.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAGrC,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,cAAc,CAAI,KAAQ;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CACtB,MAAkF;IAElF,IAAI,MAAM,CAAC,I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B;YACrB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC;gBAC5C,IAAI,CAAC,KAAK;oBAAE,OAAO,IAAI,CAAC;gBACxB,+EAA+E;gBAC/E,OAAO;oBACL,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;oBAClD,GAAG,CAAC,KAAK,CAAC,qBAAqB,KAAK,SAAS;wBAC3C,CAAC,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE;wBACxD,CAAC,CAAC,EAAE,CAAC;oBACP,YAAY,EAAE,KAAK,CAAC,YAAY;iBACjC,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from \"./pipeline-types.js\";\n\nfunction fingerprint(value: unknown): string {\n return `sha256:${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")}`;\n}\n\nfunction freezeSnapshot<T>(value: T): T {\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value)) freezeSnapshot(child);\n Object.freeze(value);\n }\n return value;\n}\n\nfunction iterationFields(\n nested: NonNullable<PipelineDefinitionSnapshot[\"steps\"][number][\"nestedPipeline\"]>\n) {\n if (nested.mode !== \"iterate\") return {};\n const controls = nested.controls;\n const normalizedControls = {\n ...(controls?.dryRun !== undefined ? { dryRun: controls.dryRun } : {}),\n ...(controls?.continueOnError !== undefined\n ? { continueOnError: controls.continueOnError }\n : {}),\n ...(controls?.maxConcurrency !== undefined ? { maxConcurrency: controls.maxConcurrency } : {}),\n ...(controls?.targets !== undefined ? { targets: [...controls.targets].sort() } : {}),\n ...(controls?.stepIds !== undefined ? { stepIds: [...controls.stepIds].sort() } : {}),\n };\n return {\n maxIterations: nested.maxIterations,\n ...(Object.keys(normalizedControls).length > 0 ? { controls: normalizedControls } : {}),\n };\n}\n\n/** Canonical snapshot. Execution order matters; dependency and target sets do not. */\nexport function compileDefinitionSnapshot(input: {\n orderedSteps: readonly AnyStep[];\n stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n targetIds: readonly string[];\n requiredFinalizerSteps: readonly AnyStep[] | undefined;\n resultValidated: boolean;\n implementationVersion: string | undefined;\n}): PipelineDefinitionSnapshot {\n const steps = input.orderedSteps.map((step) => {\n const graph = input.stepGraph.get(step)!;\n const nested = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n return {\n id: step.id,\n dependencies: graph.dependsOn.map(({ id }) => id).sort(),\n optionalDependencies: graph.optionalDependsOn.map(({ id }) => id).sort(),\n skipAfterFailureOf: graph.skipAfterFailureOf.map(({ id }) => id).sort(),\n dryRun:\n step.dryRun === \"skip\"\n ? (\"skip\" as const)\n : step.dryRun\n ? (\"custom\" as const)\n : (\"run\" as const),\n runtimeSkipPossible: step.skip !== undefined,\n outputValidated: step.outputSchema !== undefined,\n ...(nested\n ? {\n nestedPipeline: {\n pipelineId: nested.pipelineId,\n mode: nested.mode,\n ...iterationFields(nested),\n stepIds: [...nested.stepIds],\n ...(nested.identity ? { identity: { ...nested.identity } } : {}),\n ...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),\n },\n }\n : {}),\n ...(remote\n ? {\n remote: {\n engine: remote.engine,\n ...(remote.target !== undefined ? { target: remote.target } : {}),\n },\n }\n : {}),\n };\n });\n const semantics = {\n steps,\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerSteps\n ? { requiredFinalizerStepIds: input.requiredFinalizerSteps.map(({ id }) => id).sort() }\n : {}),\n optionsValidated: input.orderedSteps[0]?.[STEP_OPTIONS_SCHEMA] !== undefined,\n resultValidated: input.resultValidated,\n };\n return freezeSnapshot({\n identity: createDefinitionIdentity(semantics, input.implementationVersion),\n ...semantics,\n });\n}\n\n/** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */\nexport function createDefinitionIdentity(\n input: Omit<PipelineDefinitionSnapshot, \"identity\">,\n implementationVersion: string | undefined\n): PipelineDefinitionIdentity {\n const version = input.steps.some(\n (step) =>\n step.nestedPipeline?.mode === \"iterate\" || step.nestedPipeline?.identity?.version === 2\n )\n ? 2\n : 1;\n // Child handler versions participate in the combined identity, never the graph fingerprint.\n const structuralFingerprint = fingerprint({\n version,\n steps: input.steps.map((step) => ({\n id: step.id,\n dependencies: [...step.dependencies].sort(),\n optionalDependencies: [...step.optionalDependencies].sort(),\n skipAfterFailureOf: [...step.skipAfterFailureOf].sort(),\n dryRun: step.dryRun,\n runtimeSkipPossible: step.runtimeSkipPossible,\n outputValidated: step.outputValidated,\n ...(step.nestedPipeline\n ? {\n nestedPipeline: {\n pipelineId: step.nestedPipeline.pipelineId,\n mode: step.nestedPipeline.mode,\n ...iterationFields(step.nestedPipeline),\n stepIds: [...step.nestedPipeline.stepIds],\n ...(step.nestedPipeline.identity\n ? {\n identity: {\n version: step.nestedPipeline.identity.version,\n structuralFingerprint: step.nestedPipeline.identity.structuralFingerprint,\n },\n }\n : {}),\n ...(step.nestedPipeline.concurrency !== undefined\n ? { concurrency: step.nestedPipeline.concurrency }\n : {}),\n },\n }\n : {}),\n ...(step.remote\n ? {\n remote: {\n engine: step.remote.engine,\n ...(step.remote.target !== undefined ? { target: step.remote.target } : {}),\n },\n }\n : {}),\n })),\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerStepIds\n ? { requiredFinalizerStepIds: [...input.requiredFinalizerStepIds].sort() }\n : {}),\n optionsValidated: input.optionsValidated,\n resultValidated: input.resultValidated,\n });\n return {\n version,\n structuralFingerprint,\n ...(implementationVersion !== undefined ? { implementationVersion } : {}),\n definitionId: fingerprint({\n version,\n structuralFingerprint,\n implementationVersion,\n children: input.steps.map((step) => {\n const child = step.nestedPipeline?.identity;\n if (!child) return null;\n // Bind every recorded child identity field, not just its opaque definition ID.\n return {\n version: child.version,\n structuralFingerprint: child.structuralFingerprint,\n ...(child.implementationVersion !== undefined\n ? { implementationVersion: child.implementationVersion }\n : {}),\n definitionId: child.definitionId,\n };\n }),\n }),\n };\n}\n"]}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import type { CompiledPipeline } from "./pipeline-compiler.js";
|
|
2
2
|
import type { AnyStep } from "./pipeline-steps.js";
|
|
3
3
|
import type { InferSchemaOutput, PipelineContext, PipelinePlan, PipelineRun, PipelineRunControls, PipelineRuntime, StandardSchemaV1 } from "./pipeline-types.js";
|
|
4
|
-
/** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */
|
|
5
|
-
export declare class PipelineExecutionError extends Error {
|
|
6
|
-
readonly result: PipelineRun<unknown>;
|
|
7
|
-
constructor(result: PipelineRun<unknown>, message?: string);
|
|
8
|
-
}
|
|
9
|
-
export declare function isPipelineCancellation(error: unknown, runtime: PipelineRuntime): boolean;
|
|
10
4
|
export declare function executePlannedRun<TSteps extends readonly AnyStep[], TResult, TTargets extends readonly TSteps[number][], TResultSchema extends StandardSchemaV1 | undefined>(input: {
|
|
11
5
|
compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;
|
|
12
6
|
controls: PipelineRunControls;
|
|
13
7
|
domainOptions: object;
|
|
14
8
|
plan: PipelinePlan;
|
|
15
9
|
runtime: PipelineRuntime;
|
|
10
|
+
overrides?: ReadonlyMap<AnyStep, unknown>;
|
|
16
11
|
}): Promise<PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>>;
|
|
17
12
|
export declare function defaultPipelineContext(): PipelineContext;
|
|
18
13
|
export declare function resolvePipelineRuntime(context?: Partial<PipelineContext>): PipelineRuntime;
|
|
@@ -1,166 +1,15 @@
|
|
|
1
|
-
import { abortableSleep,
|
|
2
|
-
import { PipelineChildError } from "./child-execution.js";
|
|
3
|
-
import { brandTubelessError } from "../utilities/tubeless-error.js";
|
|
1
|
+
import { abortableSleep, throwIfAborted as throwIfSignalAborted } from "../utilities/abort.js";
|
|
4
2
|
import { createPipelineLifecycleObserver } from "./lifecycle.js";
|
|
5
|
-
import { formatPipelineError } from "./pipeline-diagnostics.js";
|
|
6
3
|
import { createRunId } from "./pipeline-ids.js";
|
|
7
4
|
import { decideStepDisposition } from "./pipeline-disposition.js";
|
|
8
5
|
import { schedulePipelineSteps } from "./pipeline-scheduler.js";
|
|
9
6
|
import { compiledStepGraph } from "./pipeline-graph.js";
|
|
10
7
|
import { planStepById, stepToPlanStep } from "./pipeline-plan.js";
|
|
11
|
-
import { PipelineRunState
|
|
8
|
+
import { PipelineRunState } from "./pipeline-run-state.js";
|
|
12
9
|
import { PIPELINE_FINALIZE_STEP_ID } from "./pipeline-step-metadata.js";
|
|
13
10
|
import { evaluateStepSkip, executeStepAttempt, validateStepOutput, } from "./pipeline-step-executor.js";
|
|
14
11
|
import { PipelineBoundaryValidationError, validateStandardSchema } from "./pipeline-validation.js";
|
|
15
|
-
import {
|
|
16
|
-
const PIPELINE_LOGGER_BASE = Symbol("pipelineLoggerBase");
|
|
17
|
-
function basePipelineLogger(log) {
|
|
18
|
-
// SAFETY: `TracedPipelineLogger` only adds the optional symbol-keyed base
|
|
19
|
-
// property; reading it off any `PipelineLogger` is safe because the property
|
|
20
|
-
// is absent unless a tracing wrapper installed it.
|
|
21
|
-
return log[PIPELINE_LOGGER_BASE] ?? log;
|
|
22
|
-
}
|
|
23
|
-
const originalPipelineErrors = new WeakMap();
|
|
24
|
-
function defaultExecutionErrorMessage(result) {
|
|
25
|
-
const firstError = result.errors[0];
|
|
26
|
-
const disposition = isCancellationOnly(result.errors) ? "cancelled" : "failed";
|
|
27
|
-
return firstError
|
|
28
|
-
? `Pipeline ${result.pipelineId} ${disposition}: ${formatPipelineError(firstError)}`
|
|
29
|
-
: `Pipeline ${result.pipelineId} ${disposition}`;
|
|
30
|
-
}
|
|
31
|
-
function firstOriginalPipelineError(errors) {
|
|
32
|
-
for (const error of errors) {
|
|
33
|
-
if (originalPipelineErrors.has(error))
|
|
34
|
-
return originalPipelineErrors.get(error);
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
/** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */
|
|
39
|
-
export class PipelineExecutionError extends Error {
|
|
40
|
-
result;
|
|
41
|
-
constructor(result, message = defaultExecutionErrorMessage(result)) {
|
|
42
|
-
const cause = firstOriginalPipelineError(result.errors);
|
|
43
|
-
super(message, cause === undefined ? undefined : { cause });
|
|
44
|
-
this.result = result;
|
|
45
|
-
this.name = "PipelineExecutionError";
|
|
46
|
-
brandTubelessError(this, "pipeline-execution");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const MAX_PIPELINE_CAUSE_DEPTH = 8;
|
|
50
|
-
function readErrorField(value, field) {
|
|
51
|
-
try {
|
|
52
|
-
// SAFETY: any object may be probed for an optional string-keyed field; a
|
|
53
|
-
// getter that throws is caught below, so the cast only enables the lookup.
|
|
54
|
-
return value[field];
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function safeErrorMessage(value) {
|
|
61
|
-
try {
|
|
62
|
-
return String(value);
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return "Unknown thrown value";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function normalizePipelineCause(value, seen, depth = 0) {
|
|
69
|
-
if (depth >= MAX_PIPELINE_CAUSE_DEPTH) {
|
|
70
|
-
return { message: "Cause chain truncated" };
|
|
71
|
-
}
|
|
72
|
-
if (typeof value !== "object" || value === null) {
|
|
73
|
-
return { message: safeErrorMessage(value) };
|
|
74
|
-
}
|
|
75
|
-
if (seen.has(value)) {
|
|
76
|
-
return { message: "Circular cause" };
|
|
77
|
-
}
|
|
78
|
-
seen.add(value);
|
|
79
|
-
const message = readErrorField(value, "message");
|
|
80
|
-
const name = readErrorField(value, "name");
|
|
81
|
-
const sourceCode = readErrorField(value, "code");
|
|
82
|
-
const nested = readErrorField(value, "cause");
|
|
83
|
-
const cause = {
|
|
84
|
-
message: typeof message === "string" ? message : safeErrorMessage(value),
|
|
85
|
-
};
|
|
86
|
-
if (typeof name === "string")
|
|
87
|
-
cause.name = name;
|
|
88
|
-
if (typeof sourceCode === "string")
|
|
89
|
-
cause.sourceCode = sourceCode;
|
|
90
|
-
if (nested !== undefined)
|
|
91
|
-
cause.cause = normalizePipelineCause(nested, seen, depth + 1);
|
|
92
|
-
return cause;
|
|
93
|
-
}
|
|
94
|
-
// Fan-out snapshots bound every string as well as cause depth and item count.
|
|
95
|
-
function fanOutCause(error) {
|
|
96
|
-
const cause = normalizePipelineCause(error, new WeakSet());
|
|
97
|
-
let current = cause;
|
|
98
|
-
while (current) {
|
|
99
|
-
current.message = current.message.slice(0, 1024);
|
|
100
|
-
if (current.name)
|
|
101
|
-
current.name = current.name.slice(0, 1024);
|
|
102
|
-
if (current.sourceCode)
|
|
103
|
-
current.sourceCode = current.sourceCode.slice(0, 1024);
|
|
104
|
-
current = current.cause;
|
|
105
|
-
}
|
|
106
|
-
return cause;
|
|
107
|
-
}
|
|
108
|
-
function normalizedNestedCause(error) {
|
|
109
|
-
if (typeof error !== "object" || error === null)
|
|
110
|
-
return undefined;
|
|
111
|
-
const cause = readErrorField(error, "cause");
|
|
112
|
-
if (cause === undefined)
|
|
113
|
-
return undefined;
|
|
114
|
-
const seen = new WeakSet();
|
|
115
|
-
seen.add(error);
|
|
116
|
-
return normalizePipelineCause(cause, seen);
|
|
117
|
-
}
|
|
118
|
-
function toPipelineError(error, classification) {
|
|
119
|
-
const sourceCode = typeof error === "object" && error !== null ? readErrorField(error, "code") : undefined;
|
|
120
|
-
const cause = normalizedNestedCause(error);
|
|
121
|
-
const pipelineError = {
|
|
122
|
-
...classification,
|
|
123
|
-
message: error instanceof Error ? error.message : safeErrorMessage(error),
|
|
124
|
-
};
|
|
125
|
-
if (error instanceof Error && error.stack)
|
|
126
|
-
pipelineError.stack = error.stack;
|
|
127
|
-
if (typeof sourceCode === "string")
|
|
128
|
-
pipelineError.sourceCode = sourceCode;
|
|
129
|
-
if (cause)
|
|
130
|
-
pipelineError.cause = cause;
|
|
131
|
-
if (error instanceof PipelineBoundaryValidationError)
|
|
132
|
-
pipelineError.issues = error.issues;
|
|
133
|
-
if (error instanceof PipelineChildError && error.fanOut) {
|
|
134
|
-
const { failures, failureCount, schedulerError } = error.fanOut;
|
|
135
|
-
pipelineError.fanOut = {
|
|
136
|
-
failures: failures.map(({ error: itemError, key, index, cancelled }) => ({
|
|
137
|
-
index,
|
|
138
|
-
key: key.slice(0, 1024),
|
|
139
|
-
keyTruncated: key.length > 1024,
|
|
140
|
-
cancelled,
|
|
141
|
-
error: fanOutCause(itemError),
|
|
142
|
-
})),
|
|
143
|
-
failureCount,
|
|
144
|
-
omittedFailureCount: failureCount - failures.length,
|
|
145
|
-
};
|
|
146
|
-
if (schedulerError !== undefined)
|
|
147
|
-
pipelineError.fanOut.schedulerError = fanOutCause(schedulerError);
|
|
148
|
-
}
|
|
149
|
-
originalPipelineErrors.set(pipelineError, error);
|
|
150
|
-
return pipelineError;
|
|
151
|
-
}
|
|
152
|
-
export function isPipelineCancellation(error, runtime) {
|
|
153
|
-
if (isAbortError(error))
|
|
154
|
-
return true;
|
|
155
|
-
if (runtime.signal?.aborted === true && error === runtime.signal.reason)
|
|
156
|
-
return true;
|
|
157
|
-
if (error instanceof PipelineChildError)
|
|
158
|
-
return error.cancelled;
|
|
159
|
-
return error instanceof PipelineExecutionError && isCancelledResult(error.result);
|
|
160
|
-
}
|
|
161
|
-
function isCancelledResult(result) {
|
|
162
|
-
return result.status === "cancelled";
|
|
163
|
-
}
|
|
12
|
+
import { finalizationError, stepExecutionError, toPipelineError, } from "./pipeline-execution-error.js";
|
|
164
13
|
function throwIfAborted(runtime) {
|
|
165
14
|
throwIfSignalAborted(runtime.signal, "Pipeline run");
|
|
166
15
|
}
|
|
@@ -175,29 +24,11 @@ export async function executePlannedRun(input) {
|
|
|
175
24
|
if (runtime.parentRunId)
|
|
176
25
|
identity.parentRunId = runtime.parentRunId;
|
|
177
26
|
const dryRun = controls.dryRun === true;
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const base = basePipelineLogger(runtime.log);
|
|
184
|
-
const log = {
|
|
185
|
-
error: (message, ...params) => {
|
|
186
|
-
lifecycle.log("error", message, params, stepId, attemptId);
|
|
187
|
-
base.error(message, ...params);
|
|
188
|
-
},
|
|
189
|
-
log: (message, ...params) => {
|
|
190
|
-
lifecycle.log("log", message, params, stepId, attemptId);
|
|
191
|
-
base.log(message, ...params);
|
|
192
|
-
},
|
|
193
|
-
warn: (message, ...params) => {
|
|
194
|
-
lifecycle.log("warn", message, params, stepId, attemptId);
|
|
195
|
-
base.warn(message, ...params);
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
log[PIPELINE_LOGGER_BASE] = base;
|
|
199
|
-
return log;
|
|
200
|
-
};
|
|
27
|
+
const lifecycle = createPipelineLifecycleObserver(compiled.id, runtime, {
|
|
28
|
+
...identity,
|
|
29
|
+
itemKey: runtime.tracing?.itemKey,
|
|
30
|
+
iteration: runtime.tracing?.iteration,
|
|
31
|
+
});
|
|
201
32
|
const state = new PipelineRunState(compiled.id, dryRun, startedAtMs, identity, runtime.now, lifecycle);
|
|
202
33
|
state.start(input.plan, compiled.targetIds);
|
|
203
34
|
if (!input.plan.ok) {
|
|
@@ -234,10 +65,10 @@ export async function executePlannedRun(input) {
|
|
|
234
65
|
const executionContext = {
|
|
235
66
|
...runtime,
|
|
236
67
|
dryRun,
|
|
237
|
-
log:
|
|
68
|
+
log: lifecycle.logger(),
|
|
238
69
|
options: pipelineOptions,
|
|
239
70
|
runId,
|
|
240
|
-
trace:
|
|
71
|
+
trace: lifecycle.traceContext,
|
|
241
72
|
};
|
|
242
73
|
const plannedSteps = planStepById(input.plan);
|
|
243
74
|
const stepsById = new Map(compiled.orderedSteps.map((step) => [step.id, step]));
|
|
@@ -297,27 +128,7 @@ export async function executePlannedRun(input) {
|
|
|
297
128
|
return true;
|
|
298
129
|
};
|
|
299
130
|
const recordStepExecutionFailure = (error, plannedStep, attempt) => {
|
|
300
|
-
const
|
|
301
|
-
const childFailure = error instanceof PipelineExecutionError || error instanceof PipelineChildError;
|
|
302
|
-
const validationFailure = error instanceof PipelineBoundaryValidationError;
|
|
303
|
-
const pipelineError = toPipelineError(error, {
|
|
304
|
-
code: cancelled
|
|
305
|
-
? "TUBELESS_RUN_CANCELLED"
|
|
306
|
-
: validationFailure
|
|
307
|
-
? "TUBELESS_STEP_OUTPUT_VALIDATION_FAILED"
|
|
308
|
-
: childFailure
|
|
309
|
-
? "TUBELESS_CHILD_FAILED"
|
|
310
|
-
: "TUBELESS_STEP_FAILED",
|
|
311
|
-
kind: cancelled
|
|
312
|
-
? "cancellation"
|
|
313
|
-
: validationFailure
|
|
314
|
-
? "validation"
|
|
315
|
-
: childFailure
|
|
316
|
-
? "child"
|
|
317
|
-
: "step",
|
|
318
|
-
phase: "execution",
|
|
319
|
-
stepId: plannedStep.id,
|
|
320
|
-
});
|
|
131
|
+
const pipelineError = stepExecutionError(error, runtime, plannedStep.id);
|
|
321
132
|
state.failStep(plannedStep, attempt, pipelineError);
|
|
322
133
|
if (!controls.continueOnError)
|
|
323
134
|
stopError ??= pipelineError;
|
|
@@ -345,6 +156,18 @@ export async function executePlannedRun(input) {
|
|
|
345
156
|
const plannedStep = plannedStepFor(step);
|
|
346
157
|
if (cancelBeforeStepStart(step))
|
|
347
158
|
return;
|
|
159
|
+
if (plannedStep.selected && input.overrides?.has(step)) {
|
|
160
|
+
const attempt = state.beginAttempt(plannedStep, runtime.now(), "override");
|
|
161
|
+
try {
|
|
162
|
+
const output = await validateStepOutput(step, input.overrides.get(step), `Pipeline ${compiled.id} step ${step.id} override output`);
|
|
163
|
+
throwIfAborted(runtime);
|
|
164
|
+
state.completeStep(plannedStep, attempt, output);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
recordStepExecutionFailure(error, plannedStep, attempt);
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
348
171
|
const graph = compiledStepGraph(compiled, step);
|
|
349
172
|
const disposition = decideStepDisposition({
|
|
350
173
|
dryRun,
|
|
@@ -370,7 +193,7 @@ export async function executePlannedRun(input) {
|
|
|
370
193
|
try {
|
|
371
194
|
skipDecision = await evaluateStepSkip(step, stepInputs, {
|
|
372
195
|
...executionContext,
|
|
373
|
-
log:
|
|
196
|
+
log: lifecycle.logger(step.id),
|
|
374
197
|
});
|
|
375
198
|
}
|
|
376
199
|
catch (error) {
|
|
@@ -392,7 +215,8 @@ export async function executePlannedRun(input) {
|
|
|
392
215
|
context: executionContext,
|
|
393
216
|
dryRun,
|
|
394
217
|
inputs: stepInputs,
|
|
395
|
-
log:
|
|
218
|
+
log: lifecycle.logger(step.id, attempt.attemptId),
|
|
219
|
+
onArtifact: (record, preview) => lifecycle.recordArtifact(step.id, attempt.attemptId, record, preview),
|
|
396
220
|
onProgress: (progress) => state.reportProgress(plannedStep, attempt, progress),
|
|
397
221
|
onReportAttempt: (number, attributes) => lifecycle.reportAttempt(step.id, number, attributes, attempt.attemptId),
|
|
398
222
|
outputBoundary: `Pipeline ${compiled.id} step ${step.id} output`,
|
|
@@ -429,7 +253,7 @@ export async function executePlannedRun(input) {
|
|
|
429
253
|
const finalOutputs = Object.fromEntries(state.outputs);
|
|
430
254
|
const finalizedValue = await compiled.finalize(finalOutputs, {
|
|
431
255
|
...executionContext,
|
|
432
|
-
log:
|
|
256
|
+
log: lifecycle.logger(PIPELINE_FINALIZE_STEP_ID),
|
|
433
257
|
});
|
|
434
258
|
// SAFETY: with a result schema the value is validated against
|
|
435
259
|
// `TPipelineResult`; without one the finalizer's declared return type
|
|
@@ -440,18 +264,7 @@ export async function executePlannedRun(input) {
|
|
|
440
264
|
state.completeFinalization(value, runtime.now() - finalizeStartedAt);
|
|
441
265
|
}
|
|
442
266
|
catch (error) {
|
|
443
|
-
const
|
|
444
|
-
const validationFailure = error instanceof PipelineBoundaryValidationError;
|
|
445
|
-
const pipelineError = toPipelineError(error, {
|
|
446
|
-
code: cancelled
|
|
447
|
-
? "TUBELESS_FINALIZATION_CANCELLED"
|
|
448
|
-
: validationFailure
|
|
449
|
-
? "TUBELESS_FINAL_RESULT_VALIDATION_FAILED"
|
|
450
|
-
: "TUBELESS_FINALIZATION_FAILED",
|
|
451
|
-
kind: cancelled ? "cancellation" : validationFailure ? "validation" : "finalization",
|
|
452
|
-
phase: "finalization",
|
|
453
|
-
stepId: PIPELINE_FINALIZE_STEP_ID,
|
|
454
|
-
});
|
|
267
|
+
const pipelineError = finalizationError(error, runtime);
|
|
455
268
|
state.failFinalization(pipelineError, runtime.now() - finalizeStartedAt);
|
|
456
269
|
}
|
|
457
270
|
}
|