tubeless 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cli/cli-command.d.ts +2 -2
  2. package/dist/cli/cli-command.js +28 -45
  3. package/dist/cli/cli-command.js.map +1 -1
  4. package/dist/cli/cli-pipeline-command.js +1 -1
  5. package/dist/cli/cli-pipeline-command.js.map +1 -1
  6. package/dist/core/child-execution.js +65 -4
  7. package/dist/core/child-execution.js.map +1 -1
  8. package/dist/core/child-progress.d.ts +6 -0
  9. package/dist/core/child-progress.js +48 -0
  10. package/dist/core/child-progress.js.map +1 -0
  11. package/dist/core/mapped-child-progress.d.ts +4 -2
  12. package/dist/core/mapped-child-progress.js.map +1 -1
  13. package/dist/core/pipeline-steps.d.ts +3 -3
  14. package/dist/core/pipeline-steps.js +12 -23
  15. package/dist/core/pipeline-steps.js.map +1 -1
  16. package/dist/core/pipeline-types.d.ts +8 -1
  17. package/dist/core/pipeline-types.js.map +1 -1
  18. package/dist/render/render.js +2 -6
  19. package/dist/render/render.js.map +1 -1
  20. package/dist/reporter/interactive-reporter.d.ts +1 -0
  21. package/dist/reporter/interactive-reporter.js +50 -15
  22. package/dist/reporter/interactive-reporter.js.map +1 -1
  23. package/dist/reporter/live-ticker-worker.js +8 -42
  24. package/dist/reporter/live-ticker-worker.js.map +1 -1
  25. package/dist/reporter/live-ticker.d.ts +10 -0
  26. package/dist/reporter/live-ticker.js +50 -47
  27. package/dist/reporter/live-ticker.js.map +1 -1
  28. package/dist/run-store/run-store-ndjson.js +8 -2
  29. package/dist/run-store/run-store-ndjson.js.map +1 -1
  30. package/dist/run-store/run-store.js +14 -33
  31. package/dist/run-store/run-store.js.map +1 -1
  32. package/dist/studio/run-store-ui-client-source.js +1 -1
  33. package/dist/studio/run-store-ui-client.d.ts +0 -1
  34. package/dist/studio/run-store-ui-client.js +5 -35
  35. package/dist/studio/run-store-ui-client.js.map +1 -1
  36. package/dist/studio/run-store-ui-page.d.ts +1 -1
  37. package/dist/studio/run-store-ui-page.js +1 -1
  38. package/dist/studio/run-store-ui-page.js.map +1 -1
  39. package/dist/tracing/tracing-internal.js +31 -5
  40. package/dist/tracing/tracing-internal.js.map +1 -1
  41. package/dist/workbench/pipeline-module.d.ts +2 -12
  42. package/dist/workbench/pipeline-module.js +4 -11
  43. package/dist/workbench/pipeline-module.js.map +1 -1
  44. package/dist/workbench/workbench-project-loader.js +1 -1
  45. package/dist/workbench/workbench-project-loader.js.map +1 -1
  46. package/dist/workbench/workbench-ui.js +1 -1
  47. package/dist/workbench/workbench-ui.js.map +1 -1
  48. package/docs/agent-guide.md +8 -0
  49. package/docs/api-reference.md +12 -12
  50. package/docs/api-report.json +12 -12
  51. package/docs/child-pipeline-composition.md +51 -19
  52. package/docs/cli.md +25 -0
  53. package/docs/recipes.md +2 -2
  54. package/examples/catalog/tubeless.project.ts +6 -0
  55. package/examples/fan-out-progress.ts +16 -2
  56. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"child-execution.js","sourceRoot":"","sources":["../../src/core/child-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,yBAAyB,GAG1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAgBvD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGhC,SAAS;IAET,MAAM;IAJjB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aACjC,CAAC,CAAC;QACL,CAAC;QACD,uEAAuE;QACvE,uEAAuE;QACvE,2EAA2E;QAC3E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAE,OAA0C,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { throwIfAborted } from \"../utilities/abort.js\";\nimport { emitRejectedPlanLifecycle } from \"./lifecycle.js\";\nimport { runConcurrentSettled } from \"../utilities/batch.js\";\nimport {\n toMappedChildStepProgress,\n type MappedChildProgressSnapshot,\n type ToMappedChildStepProgressOptions,\n} from \"./mapped-child-progress.js\";\nimport { createRunId, RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { duplicateValues } from \"../utilities/collections.js\";\nimport { EXECUTE_COMPILED_RUN, isCompiledPipeline } from \"./pipeline-plan.js\";\nimport { hasVisibleStepProgress } from \"./progress.js\";\nimport type {\n Pipeline,\n PipelineContext,\n PipelineExecutionContext,\n PipelineHooks,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRunOptions,\n PipelineRuntime,\n PipelineStepContext,\n} from \"./pipeline-types.js\";\nimport type { PipelineTracingOptions } from \"../tracing/tracing.js\";\n\nexport class PipelineChildError extends Error {\n constructor(\n message: string,\n readonly cancelled = false,\n cause?: unknown,\n readonly fanOut?: {\n failures: readonly { error: Error; key: string; index: number; cancelled: boolean }[];\n failureCount: number;\n schedulerError?: Error;\n }\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"PipelineChildError\";\n }\n}\n\ntype ChildPipeline = Pipeline<object, unknown, string, string>;\n\ntype CompiledChildExecute = (\n plan: PipelinePlan,\n options: PipelineRunOptions,\n controls: PipelineRunControls,\n context?: Partial<PipelineContext>\n) => Promise<PipelineRun<unknown>>;\n\ntype ExecutableChild = ChildPipeline & {\n [EXECUTE_COMPILED_RUN]?: CompiledChildExecute;\n};\n\nfunction compiledChildExecute(pipeline: ChildPipeline): CompiledChildExecute | undefined {\n if (!isCompiledPipeline(pipeline)) return undefined;\n // SAFETY: branded pipelines are the `definePipeline` object, which always\n // stamps `EXECUTE_COMPILED_RUN`. Wrappers that inherit the symbol are rejected\n // by the identity check above.\n return (pipeline as ExecutableChild)[EXECUTE_COMPILED_RUN];\n}\n\nfunction executeCompiledChild(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return pipeline.run(domainOptions, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\nfunction publicChildRuntime(context: PipelineContext): PipelineRuntime {\n const runtime: PipelineRuntime = {\n cwd: context.cwd,\n log: context.log,\n now: context.now ?? Date.now,\n sleep: context.sleep ?? (async () => undefined),\n };\n if (context.hooks) runtime.hooks = context.hooks;\n if (context.parentRunId) runtime.parentRunId = context.parentRunId;\n if (context.runId) runtime.runId = context.runId;\n if (context.signal) runtime.signal = context.signal;\n if (context.tracing) runtime.tracing = context.tracing;\n return runtime;\n}\n\nasync function failedPublicChildPlanRun(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const runtime = publicChildRuntime(context);\n const startedAtMs = runtime.now();\n const result: PipelineRun<unknown> = {\n pipelineId: pipeline.id,\n dryRun: controls.dryRun === true,\n errors: [...plan.errors],\n finalized: false,\n finishedAtMs: runtime.now(),\n runId: context.runId ?? createRunId(pipeline.id),\n startedAtMs,\n status: \"failed\",\n steps: [],\n version: RUN_MODEL_VERSION,\n };\n if (context.parentRunId) result.parentRunId = context.parentRunId;\n await emitRejectedPlanLifecycle(pipeline.id, pipeline.targetIds, plan, runtime, result);\n return result;\n}\n\nasync function rejectedChildPlanResult(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return failedPublicChildPlanRun(pipeline, plan, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\ntype ChildInputs = Record<string, unknown>;\n\ninterface ChildExecutionDependencies<TParentOptions extends object> {\n createExecutionError(result: PipelineRun<unknown>, message: string): Error;\n isCancellation(cause: unknown, context: PipelineExecutionContext<TParentOptions>): boolean;\n}\n\nexport interface SingleChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n mapOptions(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptions;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nexport interface MappedChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n items(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly unknown[] | Promise<readonly unknown[]>;\n key(item: unknown, index: number): string;\n concurrency?:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>) => number);\n progress?: ToMappedChildStepProgressOptions;\n mapOptions(\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptions;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nfunction childTracingOptions(\n context: PipelineExecutionContext<object>,\n itemKey = context.trace?.itemKey\n): PipelineTracingOptions | undefined {\n return context.tracing ? { ...context.tracing, itemKey } : undefined;\n}\n\nconst CHILD_RUN_CONTROL_KEYS = [\"continueOnError\", \"dryRun\", \"stepIds\", \"targets\"] as const;\n\nfunction isChildRunControlKey(\n property: PropertyKey\n): property is (typeof CHILD_RUN_CONTROL_KEYS)[number] {\n return (\n typeof property === \"string\" &&\n // SAFETY: `includes` membership over the literal tuple guarantees the cast\n // target is exactly one of the declared run-control keys.\n CHILD_RUN_CONTROL_KEYS.includes(property as (typeof CHILD_RUN_CONTROL_KEYS)[number])\n );\n}\n\ninterface ChildRunBags {\n controls: PipelineRunControls;\n domainOptions: PipelineRunOptions;\n}\n\nfunction splitChildRunOptions(options: PipelineRunOptions): ChildRunBags {\n const controls: PipelineRunControls = {};\n let hasControls = false;\n for (const key of CHILD_RUN_CONTROL_KEYS) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n hasControls = true;\n Object.assign(controls, { [key]: options[key] });\n }\n if (!hasControls) {\n return { controls, domainOptions: options };\n }\n return { controls, domainOptions: createChildDomainOptionsView(options) };\n}\n\nfunction createChildDomainOptionsView(options: PipelineRunOptions): PipelineRunOptions {\n // SAFETY: proxy an empty facade so hiding non-configurable control keys on a\n // frozen mapOptions bag does not violate proxy invariants. Reads still use\n // `options` as the receiver so accessors and methods keep their original `this`.\n return new Proxy({} as PipelineRunOptions, {\n get(_target, property) {\n if (isChildRunControlKey(property)) return undefined;\n const value = readChildOptionProperty(options, property);\n return value instanceof Function ? value.bind(options) : value;\n },\n has(_target, property) {\n return !isChildRunControlKey(property) && property in options;\n },\n ownKeys() {\n return Reflect.ownKeys(options).filter((property) => !isChildRunControlKey(property));\n },\n getOwnPropertyDescriptor(_target, property) {\n if (isChildRunControlKey(property)) return undefined;\n const descriptor = Reflect.getOwnPropertyDescriptor(options, property);\n if (descriptor === undefined) return undefined;\n return { ...descriptor, configurable: true };\n },\n getPrototypeOf() {\n return Object.getPrototypeOf(options);\n },\n set(_target, property, value) {\n if (isChildRunControlKey(property)) return true;\n return Reflect.set(options, property, value, options);\n },\n });\n}\n\nfunction readChildOptionProperty(options: PipelineRunOptions, property: PropertyKey): unknown {\n // SAFETY: child mapOptions is an untyped bag; this index reads the requested\n // key on that original object so accessors keep it as `this`.\n return options[property as keyof PipelineRunOptions];\n}\n\nfunction childRunBags(options: PipelineRunOptions, dryRun: boolean): ChildRunBags {\n const { controls, domainOptions } = splitChildRunOptions(options);\n return { controls: { ...controls, dryRun }, domainOptions };\n}\n\nfunction isConcurrencyFunction<TOptions extends object>(\n concurrency:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number)\n | undefined\n): concurrency is (inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number {\n return typeof concurrency === \"function\";\n}\n\nfunction firstChildFailure(result: PipelineRun<unknown>) {\n const firstFailedStep = result.steps.find(\n ({ status }) => status === \"failed\" || status === \"cancelled\"\n );\n const firstError =\n firstFailedStep && \"error\" in firstFailedStep ? firstFailedStep.error : result.errors[0];\n return {\n failureLocation: firstFailedStep?.id ?? firstError?.stepId ?? \"unknown step\",\n message: firstError?.message ?? \"unknown error\",\n };\n}\n\nasync function runChildPipeline(\n pipeline: ChildPipeline,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext,\n hooks: PipelineHooks,\n dependencies: ChildExecutionDependencies<object>,\n messagePrefix = \"\",\n plan: PipelinePlan\n): Promise<PipelineRun<unknown>> {\n if (!plan.ok) {\n const firstError = plan.errors[0];\n const result = await rejectedChildPlanResult(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n throw dependencies.createExecutionError(\n result,\n `${messagePrefix}could not start: ${firstError?.message ?? \"invalid plan\"}`\n );\n }\n\n const result = await executeCompiledChild(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n if (result.status !== \"completed\") {\n const { failureLocation, message } = firstChildFailure(result);\n throw dependencies.createExecutionError(\n result,\n `${messagePrefix}failed at ${failureLocation}: ${message}`\n );\n }\n return result;\n}\n\nexport function createSingleChildRunner<TParentOptions extends object>(\n config: SingleChildExecutionConfig<TParentOptions>,\n dependencies: ChildExecutionDependencies<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown> {\n return async (inputs, context) => {\n const { controls, domainOptions } = childRunBags(\n config.mapOptions(inputs, context),\n context.dryRun\n );\n const baseChildContext: PipelineContext = {\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context),\n };\n // Plan once for progress totals and execution. Invalid plans fail before child.run.\n const childPlan = config.pipeline.plan(controls);\n const selectedStepCount = childPlan.ok\n ? childPlan.steps.filter((step) => step.selected).length\n : 0;\n const terminalSteps = new Set<string>();\n const report = (step: PipelinePlanStep, message: string, terminal = false): void => {\n if (terminal) terminalSteps.add(step.id);\n context.reportProgress({\n completed: terminalSteps.size,\n total: Math.max(1, selectedStepCount),\n message: `${config.pipeline.id}/${step.name ?? step.id}: ${message}`,\n });\n };\n const childHooks: PipelineHooks = {\n onStepStart: ({ step }) => report(step, \"started\"),\n onStepProgress: ({ progress, step }) => {\n if (!hasVisibleStepProgress(progress)) return;\n report(step, progress.message ?? `${progress.completed} completed`);\n },\n onStepComplete: ({ step }) => report(step, \"complete\", true),\n onStepSkip: ({ reason, step }) => report(step, `skipped: ${reason}`, reason !== \"filtered\"),\n onStepCancel: ({ error, step }) => report(step, `cancelled: ${error.message}`, true),\n onStepFail: ({ error, step }) => report(step, `failed: ${error.message}`, true),\n };\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n baseChildContext,\n childHooks,\n dependencies,\n `Child pipeline ${config.pipeline.id} `,\n childPlan\n );\n\n return config.mapResult\n ? config.mapResult(childResult.value, childResult, context)\n : childResult.value;\n };\n}\n\nexport function createMappedChildRunner<TParentOptions extends object>(\n config: MappedChildExecutionConfig<TParentOptions>,\n dependencies: ChildExecutionDependencies<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown[]> {\n return async (inputs, context) => {\n const items = [...(await config.items(inputs, context))];\n const keys = items.map((item, index) => config.key(item, index));\n const duplicateKeys = duplicateValues(keys);\n if (duplicateKeys.length > 0) {\n throw new PipelineChildError(\n `Mapped child pipeline ${config.pipeline.id} received duplicate item keys: ${duplicateKeys.join(\", \")}`\n );\n }\n const concurrency = Math.max(\n 1,\n isConcurrencyFunction(config.concurrency)\n ? config.concurrency(inputs, context)\n : (config.concurrency ?? 1)\n );\n type Outcome =\n | { key: string; ok: true; value: unknown }\n | { error: Error; key: string; index: number; ok: false };\n\n const active = new Map<string, string>();\n const childTerminalSteps = new Map<string, Set<string>>();\n let finishedItems = 0;\n let failedItems = 0;\n let stepsPerItem = 0;\n let plannedChildSteps = 0;\n let plannedItems = 0;\n let terminalChildSteps = 0;\n\n const publishProgress = (spotlight?: string): void => {\n const snapshot: MappedChildProgressSnapshot = {\n active,\n concurrency,\n failedItems,\n finishedItems,\n itemCount: items.length,\n plannedChildSteps,\n plannedItems,\n stepsPerItem,\n terminalChildSteps,\n spotlight,\n };\n context.reportProgress(toMappedChildStepProgress(snapshot, config.progress));\n };\n const markChildTerminal = (itemKey: string, stepId: string, label: string): void => {\n let seen = childTerminalSteps.get(itemKey);\n if (!seen) {\n seen = new Set();\n childTerminalSteps.set(itemKey, seen);\n }\n if (!seen.has(stepId)) {\n seen.add(stepId);\n terminalChildSteps += 1;\n }\n active.set(itemKey, label);\n publishProgress();\n };\n\n if (items.length === 0) {\n publishProgress();\n return [];\n }\n publishProgress();\n\n const settled = await runConcurrentSettled(\n items,\n { concurrency, signal: context.signal },\n async (item, itemIndex): Promise<Outcome> => {\n const key = keys[itemIndex]!;\n active.set(key, \"starting\");\n publishProgress();\n try {\n throwIfAborted(context.signal, `Mapped child pipeline ${config.pipeline.id}`);\n const { controls, domainOptions } = childRunBags(\n config.mapOptions(item, itemIndex, inputs, context),\n context.dryRun\n );\n // Plan once per mapped-options bag for progress and execution.\n const childPlan = config.pipeline.plan(controls);\n if (childPlan.ok) {\n const plannedSteps = childPlan.steps.filter((step) => step.selected).length;\n plannedChildSteps += plannedSteps;\n plannedItems += 1;\n if (plannedSteps > stepsPerItem) stepsPerItem = plannedSteps;\n }\n\n const childHooks: PipelineHooks = {\n onStepStart: ({ step }) => {\n active.set(key, step.name ?? step.id);\n publishProgress();\n },\n onStepProgress: ({ progress, step }) => {\n if (!hasVisibleStepProgress(progress)) return;\n const detail =\n progress.message ??\n (progress.total !== undefined\n ? `${progress.completed}/${progress.total}`\n : `${progress.completed}`);\n active.set(key, `${step.name ?? step.id}:${detail}`);\n publishProgress();\n },\n onStepComplete: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:complete`),\n onStepSkip: ({ reason, step }) => {\n if (reason === \"filtered\") return;\n markChildTerminal(key, step.id, `${step.name ?? step.id}:skipped:${reason}`);\n },\n onStepCancel: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:cancelled`),\n onStepFail: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:failed`),\n };\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n {\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context, key),\n },\n childHooks,\n dependencies,\n \"\",\n childPlan\n );\n\n const seen = childTerminalSteps.get(key) ?? new Set<string>();\n if (childPlan.ok) {\n for (const planStep of childPlan.steps) {\n if (!planStep.selected || seen.has(planStep.id)) continue;\n seen.add(planStep.id);\n terminalChildSteps += 1;\n }\n }\n childTerminalSteps.set(key, seen);\n\n const value = config.mapResult\n ? config.mapResult(childResult.value, childResult, item, itemIndex, context)\n : childResult.value;\n active.delete(key);\n finishedItems += 1;\n publishProgress(`${key}: completed`);\n return { key, ok: true, value };\n } catch (error) {\n const cause = error instanceof Error ? error : new Error(String(error));\n active.delete(key);\n failedItems += 1;\n publishProgress(`${key}: failed`);\n return { error: cause, key, index: itemIndex, ok: false };\n }\n }\n );\n\n const outcomes = settled.results.filter((outcome): outcome is Outcome => outcome !== undefined);\n const schedulerFailure =\n settled.failure === undefined\n ? undefined\n : settled.failure instanceof Error\n ? settled.failure\n : new Error(String(settled.failure));\n\n const failures = outcomes.filter(\n (outcome): outcome is Extract<Outcome, { ok: false }> => !outcome.ok\n );\n if (failures.length > 0 || schedulerFailure !== undefined) {\n const details = failures.map(({ error, key }) => `${key}: ${error.message}`).join(\"; \");\n const cancelled =\n failures.every(({ error }) => dependencies.isCancellation(error, context)) &&\n (schedulerFailure === undefined || dependencies.isCancellation(schedulerFailure, context));\n const primaryError = cancelled\n ? (failures[0]?.error ?? schedulerFailure)\n : (failures.find(({ error }) => !dependencies.isCancellation(error, context))?.error ??\n failures[0]?.error ??\n schedulerFailure);\n const message =\n failures.length > 0\n ? `Mapped child pipeline ${config.pipeline.id} failed for ${failures.length} item(s): ${details}`\n : `Mapped child pipeline ${config.pipeline.id} failed: ${primaryError?.message ?? \"aborted\"}`;\n throw new PipelineChildError(message, cancelled, primaryError, {\n failures: failures.slice(0, 32).map(({ error, key, index }) => ({\n error,\n key,\n index,\n cancelled: dependencies.isCancellation(error, context),\n })),\n failureCount: failures.length,\n schedulerError: schedulerFailure,\n });\n }\n // SAFETY: when failures.length === 0 every outcome was produced by the\n // success branch (return { key, ok: true, value }), so each outcome is\n // necessarily `{ ok: true }`; the assertion narrows the union accordingly.\n return outcomes.map((outcome) => (outcome as Extract<Outcome, { ok: true }>).value);\n };\n}\n"]}
1
+ {"version":3,"file":"child-execution.js","sourceRoot":"","sources":["../../src/core/child-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,yBAAyB,GAG1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,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,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC9D,KAAK;oBACL,GAAG;oBACH,KAAK;oBACL,SAAS,EAAE,YAAY,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;iBACvD,CAAC,CAAC;gBACH,YAAY,EAAE,QAAQ,CAAC,MAAM;gBAC7B,cAAc,EAAE,gBAAgB;aACjC,CAAC,CAAC;QACL,CAAC;QACD,uEAAuE;QACvE,uEAAuE;QACvE,2EAA2E;QAC3E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAE,OAA0C,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { throwIfAborted } from \"../utilities/abort.js\";\nimport { emitRejectedPlanLifecycle } from \"./lifecycle.js\";\nimport { runConcurrentSettled } from \"../utilities/batch.js\";\nimport {\n toMappedChildStepProgress,\n type MappedChildProgressSnapshot,\n type ToMappedChildStepProgressOptions,\n} from \"./mapped-child-progress.js\";\nimport { createRunId, RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { duplicateValues } from \"../utilities/collections.js\";\nimport { EXECUTE_COMPILED_RUN, isCompiledPipeline } from \"./pipeline-plan.js\";\nimport { createChildProgress } from \"./child-progress.js\";\nimport { hasVisibleStepProgress } from \"./progress.js\";\nimport type {\n Pipeline,\n PipelineContext,\n PipelineExecutionContext,\n PipelineHooks,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineRunOptions,\n PipelineRuntime,\n PipelineStepContext,\n PipelineStepProgressDetail,\n} from \"./pipeline-types.js\";\nimport type { PipelineTracingOptions } from \"../tracing/tracing.js\";\n\nexport class PipelineChildError extends Error {\n constructor(\n message: string,\n readonly cancelled = false,\n cause?: unknown,\n readonly fanOut?: {\n failures: readonly { error: Error; key: string; index: number; cancelled: boolean }[];\n failureCount: number;\n schedulerError?: Error;\n }\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"PipelineChildError\";\n }\n}\n\nconst LIVE_FAN_OUT_GROUP_LIMIT = 32;\n\ntype ChildPipeline = Pipeline<object, unknown, string, string>;\n\ntype CompiledChildExecute = (\n plan: PipelinePlan,\n options: PipelineRunOptions,\n controls: PipelineRunControls,\n context?: Partial<PipelineContext>\n) => Promise<PipelineRun<unknown>>;\n\ntype ExecutableChild = ChildPipeline & {\n [EXECUTE_COMPILED_RUN]?: CompiledChildExecute;\n};\n\nfunction compiledChildExecute(pipeline: ChildPipeline): CompiledChildExecute | undefined {\n if (!isCompiledPipeline(pipeline)) return undefined;\n // SAFETY: branded pipelines are the `definePipeline` object, which always\n // stamps `EXECUTE_COMPILED_RUN`. Wrappers that inherit the symbol are rejected\n // by the identity check above.\n return (pipeline as ExecutableChild)[EXECUTE_COMPILED_RUN];\n}\n\nfunction executeCompiledChild(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return pipeline.run(domainOptions, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\nfunction publicChildRuntime(context: PipelineContext): PipelineRuntime {\n const runtime: PipelineRuntime = {\n cwd: context.cwd,\n log: context.log,\n now: context.now ?? Date.now,\n sleep: context.sleep ?? (async () => undefined),\n };\n if (context.hooks) runtime.hooks = context.hooks;\n if (context.parentRunId) runtime.parentRunId = context.parentRunId;\n if (context.runId) runtime.runId = context.runId;\n if (context.signal) runtime.signal = context.signal;\n if (context.tracing) runtime.tracing = context.tracing;\n return runtime;\n}\n\nasync function failedPublicChildPlanRun(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const runtime = publicChildRuntime(context);\n const startedAtMs = runtime.now();\n const result: PipelineRun<unknown> = {\n pipelineId: pipeline.id,\n dryRun: controls.dryRun === true,\n errors: [...plan.errors],\n finalized: false,\n finishedAtMs: runtime.now(),\n runId: context.runId ?? createRunId(pipeline.id),\n startedAtMs,\n status: \"failed\",\n steps: [],\n version: RUN_MODEL_VERSION,\n };\n if (context.parentRunId) result.parentRunId = context.parentRunId;\n await emitRejectedPlanLifecycle(pipeline.id, pipeline.targetIds, plan, runtime, result);\n return result;\n}\n\nasync function rejectedChildPlanResult(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return failedPublicChildPlanRun(pipeline, plan, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\ntype ChildInputs = Record<string, unknown>;\n\ninterface ChildExecutionDependencies<TParentOptions extends object> {\n createExecutionError(result: PipelineRun<unknown>, message: string): Error;\n isCancellation(cause: unknown, context: PipelineExecutionContext<TParentOptions>): boolean;\n}\n\nexport interface SingleChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n mapOptions(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptions;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nexport interface MappedChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n items(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly unknown[] | Promise<readonly unknown[]>;\n key(item: unknown, index: number): string;\n concurrency?:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>) => number);\n progress?: ToMappedChildStepProgressOptions;\n mapOptions(\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptions;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nfunction childTracingOptions(\n context: PipelineExecutionContext<object>,\n itemKey = context.trace?.itemKey\n): PipelineTracingOptions | undefined {\n return context.tracing ? { ...context.tracing, itemKey } : undefined;\n}\n\nconst CHILD_RUN_CONTROL_KEYS = [\"continueOnError\", \"dryRun\", \"stepIds\", \"targets\"] as const;\n\nfunction isChildRunControlKey(\n property: PropertyKey\n): property is (typeof CHILD_RUN_CONTROL_KEYS)[number] {\n return (\n typeof property === \"string\" &&\n // SAFETY: `includes` membership over the literal tuple guarantees the cast\n // target is exactly one of the declared run-control keys.\n CHILD_RUN_CONTROL_KEYS.includes(property as (typeof CHILD_RUN_CONTROL_KEYS)[number])\n );\n}\n\ninterface ChildRunBags {\n controls: PipelineRunControls;\n domainOptions: PipelineRunOptions;\n}\n\nfunction splitChildRunOptions(options: PipelineRunOptions): ChildRunBags {\n const controls: PipelineRunControls = {};\n let hasControls = false;\n for (const key of CHILD_RUN_CONTROL_KEYS) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n hasControls = true;\n Object.assign(controls, { [key]: options[key] });\n }\n if (!hasControls) {\n return { controls, domainOptions: options };\n }\n return { controls, domainOptions: createChildDomainOptionsView(options) };\n}\n\nfunction createChildDomainOptionsView(options: PipelineRunOptions): PipelineRunOptions {\n // SAFETY: proxy an empty facade so hiding non-configurable control keys on a\n // frozen mapOptions bag does not violate proxy invariants. Reads still use\n // `options` as the receiver so accessors and methods keep their original `this`.\n return new Proxy({} as PipelineRunOptions, {\n get(_target, property) {\n if (isChildRunControlKey(property)) return undefined;\n const value = readChildOptionProperty(options, property);\n return value instanceof Function ? value.bind(options) : value;\n },\n has(_target, property) {\n return !isChildRunControlKey(property) && property in options;\n },\n ownKeys() {\n return Reflect.ownKeys(options).filter((property) => !isChildRunControlKey(property));\n },\n getOwnPropertyDescriptor(_target, property) {\n if (isChildRunControlKey(property)) return undefined;\n const descriptor = Reflect.getOwnPropertyDescriptor(options, property);\n if (descriptor === undefined) return undefined;\n return { ...descriptor, configurable: true };\n },\n getPrototypeOf() {\n return Object.getPrototypeOf(options);\n },\n set(_target, property, value) {\n if (isChildRunControlKey(property)) return true;\n return Reflect.set(options, property, value, options);\n },\n });\n}\n\nfunction readChildOptionProperty(options: PipelineRunOptions, property: PropertyKey): unknown {\n // SAFETY: child mapOptions is an untyped bag; this index reads the requested\n // key on that original object so accessors keep it as `this`.\n return options[property as keyof PipelineRunOptions];\n}\n\nfunction childRunBags(options: PipelineRunOptions, dryRun: boolean): ChildRunBags {\n const { controls, domainOptions } = splitChildRunOptions(options);\n return { controls: { ...controls, dryRun }, domainOptions };\n}\n\nfunction isConcurrencyFunction<TOptions extends object>(\n concurrency:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number)\n | undefined\n): concurrency is (inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number {\n return typeof concurrency === \"function\";\n}\n\nfunction firstChildFailure(result: PipelineRun<unknown>) {\n const firstFailedStep = result.steps.find(\n ({ status }) => status === \"failed\" || status === \"cancelled\"\n );\n const firstError =\n firstFailedStep && \"error\" in firstFailedStep ? firstFailedStep.error : result.errors[0];\n return {\n failureLocation: firstFailedStep?.id ?? firstError?.stepId ?? \"unknown step\",\n message: firstError?.message ?? \"unknown error\",\n };\n}\n\nasync function runChildPipeline(\n pipeline: ChildPipeline,\n domainOptions: PipelineRunOptions,\n controls: PipelineRunControls,\n context: PipelineContext,\n hooks: PipelineHooks,\n dependencies: ChildExecutionDependencies<object>,\n messagePrefix = \"\",\n plan: PipelinePlan\n): Promise<PipelineRun<unknown>> {\n if (!plan.ok) {\n const firstError = plan.errors[0];\n const result = await rejectedChildPlanResult(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n throw dependencies.createExecutionError(\n result,\n `${messagePrefix}could not start: ${firstError?.message ?? \"invalid plan\"}`\n );\n }\n\n const result = await executeCompiledChild(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n if (result.status !== \"completed\") {\n const { failureLocation, message } = firstChildFailure(result);\n throw dependencies.createExecutionError(\n result,\n `${messagePrefix}failed at ${failureLocation}: ${message}`\n );\n }\n return result;\n}\n\nfunction hasProgressObserver(context: PipelineContext): boolean {\n const hooks = Array.isArray(context.hooks) ? context.hooks : [context.hooks];\n return (\n Boolean(context.tracing) || hooks.some((hook) => hook?.onStepProgress || hook?.onStepStatus)\n );\n}\n\nexport function createSingleChildRunner<TParentOptions extends object>(\n config: SingleChildExecutionConfig<TParentOptions>,\n dependencies: ChildExecutionDependencies<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown> {\n return async (inputs, context) => {\n const { controls, domainOptions } = childRunBags(\n config.mapOptions(inputs, context),\n context.dryRun\n );\n const baseChildContext: PipelineContext = {\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context),\n };\n // Plan once for progress totals and execution. Invalid plans fail before child.run.\n const childPlan = config.pipeline.plan(controls);\n const selectedStepCount = childPlan.ok\n ? childPlan.steps.filter((step) => step.selected).length\n : 0;\n const childProgress = hasProgressObserver(context) ? createChildProgress(childPlan) : undefined;\n const terminalSteps = new Set<string>();\n const report = (step: PipelinePlanStep, message: string, terminal = false): void => {\n if (!childProgress) return;\n if (terminal) terminalSteps.add(step.id);\n context.reportProgress({\n details: childProgress.details(),\n completed: terminalSteps.size,\n total: Math.max(1, selectedStepCount),\n message: `${config.pipeline.id}/${step.name ?? step.id}: ${message}`,\n });\n };\n const childHooks: PipelineHooks = {\n onStepStatus: childProgress?.update,\n onStepStart: ({ step }) => report(step, \"started\"),\n onStepProgress: ({ progress, step }) => {\n if (!hasVisibleStepProgress(progress)) return;\n report(step, progress.message ?? `${progress.completed} completed`);\n },\n onStepComplete: ({ step }) => report(step, \"complete\", true),\n onStepSkip: ({ reason, step }) => report(step, `skipped: ${reason}`, reason !== \"filtered\"),\n onStepCancel: ({ error, step }) => report(step, `cancelled: ${error.message}`, true),\n onStepFail: ({ error, step }) => report(step, `failed: ${error.message}`, true),\n };\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n baseChildContext,\n childProgress ? childHooks : {},\n dependencies,\n `Child pipeline ${config.pipeline.id} `,\n childPlan\n );\n\n return config.mapResult\n ? config.mapResult(childResult.value, childResult, context)\n : childResult.value;\n };\n}\n\nexport function createMappedChildRunner<TParentOptions extends object>(\n config: MappedChildExecutionConfig<TParentOptions>,\n dependencies: ChildExecutionDependencies<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown[]> {\n return async (inputs, context) => {\n const items = [...(await config.items(inputs, context))];\n const keys = items.map((item, index) => config.key(item, index));\n const duplicateKeys = duplicateValues(keys);\n if (duplicateKeys.length > 0) {\n throw new PipelineChildError(\n `Mapped child pipeline ${config.pipeline.id} received duplicate item keys: ${duplicateKeys.join(\", \")}`\n );\n }\n const concurrency = Math.max(\n 1,\n isConcurrencyFunction(config.concurrency)\n ? config.concurrency(inputs, context)\n : (config.concurrency ?? 1)\n );\n type Outcome =\n | { key: string; ok: true; value: unknown }\n | { error: Error; key: string; index: number; ok: false };\n\n const active = new Map<string, string>();\n const failedKeys = new Set<string>();\n const itemIndexes = new Map(keys.map((key, index) => [key, index]));\n const observesProgress = hasProgressObserver(context);\n const itemRows = new Map<string, PipelineStepProgressDetail>(\n keys.map((id) => [id, { id, status: \"pending\" }])\n );\n const itemProgress = new Map<string, ReturnType<typeof createChildProgress>>();\n const childTerminalSteps = new Map<string, Set<string>>();\n let finishedItems = 0;\n let failedItems = 0;\n let stepsPerItem = 0;\n let plannedChildSteps = 0;\n let plannedItems = 0;\n let terminalChildSteps = 0;\n\n const publishProgress = (spotlight?: string, final = false): void => {\n if (!observesProgress) return;\n const snapshot: MappedChildProgressSnapshot = {\n active,\n concurrency,\n failedItems,\n finishedItems,\n itemCount: items.length,\n plannedChildSteps,\n plannedItems,\n stepsPerItem,\n terminalChildSteps,\n spotlight,\n };\n // Materialize a bounded live window; expand the default final snapshot once.\n // Active and failed sets avoid scanning or sorting the full fan-out per event.\n const limit =\n Math.max(0, Math.floor(config.progress?.detailLimit ?? LIVE_FAN_OUT_GROUP_LIMIT)) || 0;\n let visibleKeys: readonly string[];\n if (final && config.progress?.detailLimit === undefined) {\n visibleKeys = keys;\n } else {\n const visible = new Set<string>();\n for (const candidates of [active.keys(), failedKeys.keys(), keys.values()]) {\n for (const key of candidates) {\n if (visible.size >= limit) break;\n visible.add(key);\n }\n }\n visibleKeys = [...visible].sort(\n (left, right) => itemIndexes.get(left)! - itemIndexes.get(right)!\n );\n }\n const details = visibleKeys.flatMap((key) => [\n { ...itemRows.get(key)! },\n ...(itemProgress.get(key)?.details() ?? []).map((detail) => ({\n ...detail,\n depth: (detail.depth ?? 0) + 1,\n })),\n ]);\n if (visibleKeys.length < keys.length) {\n details.push({ id: `+${keys.length - visibleKeys.length} more`, status: \"pending\" });\n }\n context.reportProgress({ ...toMappedChildStepProgress(snapshot, config.progress), details });\n };\n const markChildTerminal = (itemKey: string, stepId: string, label: string): void => {\n let seen = childTerminalSteps.get(itemKey);\n if (!seen) {\n seen = new Set();\n childTerminalSteps.set(itemKey, seen);\n }\n if (!seen.has(stepId)) {\n seen.add(stepId);\n terminalChildSteps += 1;\n }\n active.set(itemKey, label);\n publishProgress();\n };\n\n if (items.length === 0) {\n publishProgress();\n return [];\n }\n publishProgress();\n\n const settled = await runConcurrentSettled(\n items,\n { concurrency, signal: context.signal },\n async (item, itemIndex): Promise<Outcome> => {\n const key = keys[itemIndex]!;\n active.set(key, \"starting\");\n itemRows.set(key, { id: key, status: \"running\" });\n publishProgress();\n try {\n throwIfAborted(context.signal, `Mapped child pipeline ${config.pipeline.id}`);\n const { controls, domainOptions } = childRunBags(\n config.mapOptions(item, itemIndex, inputs, context),\n context.dryRun\n );\n // Plan once per mapped-options bag for progress and execution.\n const childPlan = config.pipeline.plan(controls);\n if (childPlan.ok) {\n const plannedSteps = childPlan.steps.filter((step) => step.selected).length;\n plannedChildSteps += plannedSteps;\n plannedItems += 1;\n if (plannedSteps > stepsPerItem) stepsPerItem = plannedSteps;\n }\n\n const childProgress = observesProgress ? createChildProgress(childPlan) : undefined;\n if (childProgress) itemProgress.set(key, childProgress);\n const childHooks: PipelineHooks = {\n onStepStatus: childProgress?.update,\n onStepStart: ({ step }) => {\n active.set(key, step.name ?? step.id);\n publishProgress();\n },\n onStepProgress: ({ progress, step }) => {\n if (!hasVisibleStepProgress(progress)) return;\n const detail =\n progress.message ??\n (progress.total !== undefined\n ? `${progress.completed}/${progress.total}`\n : `${progress.completed}`);\n active.set(key, `${step.name ?? step.id}:${detail}`);\n publishProgress();\n },\n onStepComplete: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:complete`),\n onStepSkip: ({ reason, step }) => {\n if (reason === \"filtered\") return;\n markChildTerminal(key, step.id, `${step.name ?? step.id}:skipped:${reason}`);\n },\n onStepCancel: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:cancelled`),\n onStepFail: ({ step }) =>\n markChildTerminal(key, step.id, `${step.name ?? step.id}:failed`),\n };\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n {\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context, key),\n },\n observesProgress ? childHooks : {},\n dependencies,\n \"\",\n childPlan\n );\n\n const seen = childTerminalSteps.get(key) ?? new Set<string>();\n if (childPlan.ok) {\n for (const planStep of childPlan.steps) {\n if (!planStep.selected || seen.has(planStep.id)) continue;\n seen.add(planStep.id);\n terminalChildSteps += 1;\n }\n }\n childTerminalSteps.set(key, seen);\n\n const value = config.mapResult\n ? config.mapResult(childResult.value, childResult, item, itemIndex, context)\n : childResult.value;\n active.delete(key);\n itemRows.set(key, { id: key, status: \"completed\" });\n finishedItems += 1;\n publishProgress(`${key}: completed`);\n return { key, ok: true, value };\n } catch (error) {\n const cause = error instanceof Error ? error : new Error(String(error));\n active.delete(key);\n itemRows.set(key, {\n id: key,\n status: dependencies.isCancellation(cause, context) ? \"cancelled\" : \"failed\",\n label: cause.message,\n });\n failedKeys.add(key);\n failedItems += 1;\n publishProgress(`${key}: failed`);\n return { error: cause, key, index: itemIndex, ok: false };\n }\n }\n );\n\n if (config.progress?.detailLimit === undefined && keys.length > LIVE_FAN_OUT_GROUP_LIMIT) {\n publishProgress(undefined, true);\n }\n const outcomes = settled.results.filter((outcome): outcome is Outcome => outcome !== undefined);\n const schedulerFailure =\n settled.failure === undefined\n ? undefined\n : settled.failure instanceof Error\n ? settled.failure\n : new Error(String(settled.failure));\n\n const failures = outcomes.filter(\n (outcome): outcome is Extract<Outcome, { ok: false }> => !outcome.ok\n );\n if (failures.length > 0 || schedulerFailure !== undefined) {\n const details = failures.map(({ error, key }) => `${key}: ${error.message}`).join(\"; \");\n const cancelled =\n failures.every(({ error }) => dependencies.isCancellation(error, context)) &&\n (schedulerFailure === undefined || dependencies.isCancellation(schedulerFailure, context));\n const primaryError = cancelled\n ? (failures[0]?.error ?? schedulerFailure)\n : (failures.find(({ error }) => !dependencies.isCancellation(error, context))?.error ??\n failures[0]?.error ??\n schedulerFailure);\n const message =\n failures.length > 0\n ? `Mapped child pipeline ${config.pipeline.id} failed for ${failures.length} item(s): ${details}`\n : `Mapped child pipeline ${config.pipeline.id} failed: ${primaryError?.message ?? \"aborted\"}`;\n throw new PipelineChildError(message, cancelled, primaryError, {\n failures: failures.slice(0, 32).map(({ error, key, index }) => ({\n error,\n key,\n index,\n cancelled: dependencies.isCancellation(error, context),\n })),\n failureCount: failures.length,\n schedulerError: schedulerFailure,\n });\n }\n // SAFETY: when failures.length === 0 every outcome was produced by the\n // success branch (return { key, ok: true, value }), so each outcome is\n // necessarily `{ ok: true }`; the assertion narrows the union accordingly.\n return outcomes.map((outcome) => (outcome as Extract<Outcome, { ok: true }>).value);\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { PipelinePlan, PipelineStepProgressDetail, PipelineStepStatus } from "./pipeline-types.js";
2
+ /** Retain one child's step states without forwarding its lifecycle to parent hooks. */
3
+ export declare function createChildProgress(plan: PipelinePlan): {
4
+ update(event: PipelineStepStatus): void;
5
+ details(): PipelineStepProgressDetail[];
6
+ };
@@ -0,0 +1,48 @@
1
+ import { hasVisibleStepProgress } from "./progress.js";
2
+ /** Retain one child's step states without forwarding its lifecycle to parent hooks. */
3
+ export function createChildProgress(plan) {
4
+ const rows = new Map();
5
+ const progress = new Map();
6
+ for (const step of plan.steps) {
7
+ if (step.selected)
8
+ rows.set(step.id, { id: step.id, name: step.name, status: "pending" });
9
+ }
10
+ return {
11
+ update(event) {
12
+ if (!rows.has(event.step.id))
13
+ return;
14
+ if (event.status === "running" && event.progress && hasVisibleStepProgress(event.progress)) {
15
+ progress.set(event.step.id, event.progress);
16
+ }
17
+ const latest = progress.get(event.step.id);
18
+ const row = {
19
+ id: event.step.id,
20
+ name: event.step.name,
21
+ status: event.status === "planned" ? "pending" : event.status,
22
+ };
23
+ if (latest) {
24
+ row.completed = latest.completed;
25
+ row.total = latest.total;
26
+ row.label = latest.message;
27
+ }
28
+ if (event.status === "failed" || event.status === "cancelled")
29
+ row.label = event.error.message;
30
+ if (event.status === "skipped")
31
+ row.label = event.message ?? event.reason;
32
+ rows.set(event.step.id, row);
33
+ },
34
+ details() {
35
+ return [...rows.values()].flatMap((row) => [
36
+ { ...row },
37
+ ...(progress.get(row.id)?.details ?? []).map((detail) => ({
38
+ ...detail,
39
+ depth: (detail.depth ?? 0) + 1,
40
+ status: (detail.status ?? "running") === "running" && row.status !== "running"
41
+ ? row.status
42
+ : detail.status,
43
+ })),
44
+ ]);
45
+ },
46
+ };
47
+ }
48
+ //# sourceMappingURL=child-progress.js.map
@@ -0,0 +1 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C;AACJ,CAAC","sourcesContent":["import type {\n PipelinePlan,\n PipelineStepProgress,\n PipelineStepProgressDetail,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport { hasVisibleStepProgress } from \"./progress.js\";\n\n/** Retain one child's step states without forwarding its lifecycle to parent hooks. */\nexport function createChildProgress(plan: PipelinePlan) {\n const rows = new Map<string, PipelineStepProgressDetail>();\n const progress = new Map<string, PipelineStepProgress>();\n for (const step of plan.steps) {\n if (step.selected) rows.set(step.id, { id: step.id, name: step.name, status: \"pending\" });\n }\n return {\n update(event: PipelineStepStatus): void {\n if (!rows.has(event.step.id)) return;\n if (event.status === \"running\" && event.progress && hasVisibleStepProgress(event.progress)) {\n progress.set(event.step.id, event.progress);\n }\n const latest = progress.get(event.step.id);\n const row: PipelineStepProgressDetail = {\n id: event.step.id,\n name: event.step.name,\n status: event.status === \"planned\" ? \"pending\" : event.status,\n };\n if (latest) {\n row.completed = latest.completed;\n row.total = latest.total;\n row.label = latest.message;\n }\n if (event.status === \"failed\" || event.status === \"cancelled\")\n row.label = event.error.message;\n if (event.status === \"skipped\") row.label = event.message ?? event.reason;\n rows.set(event.step.id, row);\n },\n details(): PipelineStepProgressDetail[] {\n return [...rows.values()].flatMap((row) => [\n { ...row },\n ...(progress.get(row.id)?.details ?? []).map((detail) => ({\n ...detail,\n depth: (detail.depth ?? 0) + 1,\n status:\n (detail.status ?? \"running\") === \"running\" && row.status !== \"running\"\n ? row.status\n : detail.status,\n })),\n ]);\n },\n };\n}\n"]}
@@ -42,8 +42,10 @@ export interface FormatMappedChildProgressOptions {
42
42
  */
43
43
  sampleLimit?: number;
44
44
  /**
45
- * Max detail rows emitted for multi-line reporters. Defaults to unlimited
46
- * (all active items). Use a positive cap for very large fan-outs.
45
+ * For `forEachPipeline`, cap visible item groups, including the final snapshot.
46
+ * By default, live snapshots show up to 32 groups and the final snapshot shows all.
47
+ * Larger caps increase per-event presentation work. Standalone formatting
48
+ * helpers apply this to active rows and default to all supplied active items.
47
49
  */
48
50
  detailLimit?: number;
49
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mapped-child-progress.js","sourceRoot":"","sources":["../../src/core/mapped-child-progress.ts"],"names":[],"mappings":"AA4DA;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAqC;IAErC,IAAI,QAAQ,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACpC,CAAC;IACD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC3C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IACrD,IAAI,YAAY,KAAK,SAAS,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAClE,IAAI,YAAY,IAAI,QAAQ,CAAC,SAAS,IAAI,iBAAiB,GAAG,CAAC,EAAE,CAAC;YAChE,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAC7B,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,EAC7C,QAAQ,CAAC,SAAS,CACnB,CAAC;YACF,MAAM,qBAAqB,GACzB,cAAc,KAAK,CAAC;gBAClB,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,GAAG,iBAAiB,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC3E,OAAO;gBACL,SAAS,EAAE,IAAI,CAAC,GAAG,CACjB,iBAAiB,EACjB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAC7D;gBACD,KAAK,EAAE,iBAAiB;aACzB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,SAAS,CAAC;YACtF,KAAK,EA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QAAQ,CAAC,SAAS,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACxE,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK;QACL,OAAO;QACP,OAAO,EAAE,0BAA0B,CAAC,QAAQ,EAAE;YAC5C,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import type { PipelineStepProgressDetail } from \"./pipeline-types.js\";\n\n/** Compatibility alias of the shared progress-detail shape. */\nexport type MappedChildProgressDetail = PipelineStepProgressDetail;\n\n/**\n * Live state for a `forEachPipeline` fan-out. Domain-agnostic: items can be\n * shards, URLs, files, jobs, or anything else the parent maps over.\n *\n * Runtime-free: only a type-only import of the shared progress detail.\n */\nexport interface MappedChildProgressSnapshot {\n /** Item key → short status label for currently in-flight children. */\n readonly active: ReadonlyMap<string, string>;\n /** Configured concurrency bound for the fan-out. */\n readonly concurrency: number;\n readonly failedItems: number;\n readonly finishedItems: number;\n readonly itemCount: number;\n /**\n * Maximum selected child steps per item seen so far. This is retained for\n * compatibility with callers that provide uniform plans; exact fan-out\n * totals use `plannedChildSteps` once every item plan is known.\n */\n readonly stepsPerItem: number;\n /** Total selected child steps across the item plans discovered so far. */\n readonly plannedChildSteps?: number;\n /** Number of item plans included in `plannedChildSteps`. */\n readonly plannedItems?: number;\n /** Cumulative terminal child steps across all items. */\n readonly terminalChildSteps: number;\n /** Optional one-off note (e.g. the item that just finished or failed). */\n readonly spotlight?: string;\n}\n\nexport interface MappedChildProgressUnits {\n completed: number;\n total: number;\n}\n\nexport interface FormatMappedChildProgressOptions {\n /**\n * Max in-flight item labels embedded in the one-line summary message.\n * Defaults to `0` — prefer `details` rows for multi-line reporters.\n * Set > 0 when a plain/one-line consumer needs samples in `message`.\n */\n sampleLimit?: number;\n /**\n * Max detail rows emitted for multi-line reporters. Defaults to unlimited\n * (all active items). Use a positive cap for very large fan-outs.\n */\n detailLimit?: number;\n /**\n * Plural noun for the mapped work unit in the default message.\n * Defaults to `\"items\"`. Domain packages pass their own label\n * (`\"shards\"`, `\"images\"`, `\"editions\"`) without custom formatters.\n */\n itemNoun?: string;\n}\n\n/**\n * Resolve determinate progress units for a mapped fan-out.\n *\n * When every item plan is known, progress advances on terminal child steps\n * using the exact sum of selected steps across items. The transition preserves\n * the prior item-level completion fraction, rounding up when necessary, so a\n * newly discovered denominator cannot make the reporter move backward. Until\n * then it falls back to item-level accounting. Legacy snapshots without the\n * exact plan fields retain the uniform `stepsPerItem` behavior.\n */\nexport function mappedChildProgressUnits(\n snapshot: MappedChildProgressSnapshot\n): MappedChildProgressUnits {\n if (snapshot.itemCount <= 0) {\n return { completed: 0, total: 0 };\n }\n const plannedItems = snapshot.plannedItems;\n const plannedChildSteps = snapshot.plannedChildSteps;\n if (plannedItems !== undefined && plannedChildSteps !== undefined) {\n if (plannedItems >= snapshot.itemCount && plannedChildSteps > 0) {\n const completedItems = Math.min(\n snapshot.finishedItems + snapshot.failedItems,\n snapshot.itemCount\n );\n const preservedItemProgress =\n completedItems === 0\n ? 0\n : Math.ceil((completedItems * plannedChildSteps) / snapshot.itemCount);\n return {\n completed: Math.min(\n plannedChildSteps,\n Math.max(snapshot.terminalChildSteps, preservedItemProgress)\n ),\n total: plannedChildSteps,\n };\n }\n return {\n completed: Math.min(snapshot.finishedItems + snapshot.failedItems, snapshot.itemCount),\n total: snapshot.itemCount,\n };\n }\n if (snapshot.stepsPerItem > 0) {\n const total = snapshot.itemCount * snapshot.stepsPerItem;\n return {\n completed: Math.min(snapshot.terminalChildSteps, total),\n total,\n };\n }\n return {\n completed: Math.min(snapshot.finishedItems + snapshot.failedItems, snapshot.itemCount),\n total: snapshot.itemCount,\n };\n}\n\n/**\n * Default domain-neutral one-line summary for mapped children.\n *\n * Example (no samples):\n * `3/10 items · 4 running (max 8)`\n *\n * Example with `sampleLimit: 2`:\n * `3/10 items · 4 running (max 8) · shard-a/parse · shard-b/write · +2 more`\n */\nexport function formatMappedChildProgressMessage(\n snapshot: MappedChildProgressSnapshot,\n options: FormatMappedChildProgressOptions = {}\n): string {\n const noun = options.itemNoun?.trim() || \"items\";\n if (snapshot.itemCount <= 0) {\n return `0 ${noun}`;\n }\n\n const sampleLimit = Math.max(0, Math.floor(options.sampleLimit ?? 0));\n const runningEntries = [...snapshot.active.entries()].sort(([left], [right]) =>\n left.localeCompare(right)\n );\n const runningSample = runningEntries\n .slice(0, sampleLimit)\n .map(([itemKey, label]) => `${itemKey}/${label}`)\n .join(\" · \");\n const overflow =\n sampleLimit > 0 && runningEntries.length > sampleLimit\n ? ` · +${runningEntries.length - sampleLimit} more`\n : \"\";\n\n const settled = snapshot.finishedItems + snapshot.failedItems;\n const parts = [\n `${snapshot.finishedItems}/${snapshot.itemCount} ${noun}`,\n snapshot.failedItems > 0 ? `${snapshot.failedItems} failed` : null,\n snapshot.active.size > 0\n ? `${snapshot.active.size} running (max ${snapshot.concurrency})`\n : settled >= snapshot.itemCount\n ? null\n : \"starting\",\n runningSample ? `${runningSample}${overflow}` : null,\n snapshot.spotlight,\n ].filter((part): part is string => Boolean(part));\n\n return parts.join(\" · \");\n}\n\n/**\n * Build sorted detail rows for in-flight mapped children.\n * Stable key order so multi-line UIs do not thrash row positions.\n */\nexport function mappedChildProgressDetails(\n snapshot: MappedChildProgressSnapshot,\n options: Pick<FormatMappedChildProgressOptions, \"detailLimit\"> = {}\n): MappedChildProgressDetail[] {\n const entries = [...snapshot.active.entries()].sort(([left], [right]) =>\n left.localeCompare(right)\n );\n const limit =\n options.detailLimit === undefined\n ? entries.length\n : Math.max(0, Math.floor(options.detailLimit));\n const visible = entries.slice(0, limit);\n const details: MappedChildProgressDetail[] = visible.map(([id, label]) => ({\n id,\n label,\n status: \"running\" as const,\n }));\n if (entries.length > visible.length) {\n details.push({\n id: `+${entries.length - visible.length} more`,\n status: \"pending\",\n });\n }\n return details;\n}\n\nexport interface ToMappedChildStepProgressOptions extends FormatMappedChildProgressOptions {\n /**\n * Replace the default message while keeping the same completed/total units.\n * Use this for domain labels without forking the fan-out runner.\n *\n * @example\n * formatMessage: (s) => `${s.finishedItems}/${s.itemCount} images`\n */\n formatMessage?: (\n snapshot: MappedChildProgressSnapshot,\n units: MappedChildProgressUnits\n ) => string;\n}\n\n/**\n * Build a progress payload for an opaque mapped-child parent step.\n * Shape matches `PipelineStepProgress` without importing the runtime module.\n *\n * `message` is a one-line summary; `details` lists each in-flight item for\n * multi-line reporters.\n */\nexport function toMappedChildStepProgress(\n snapshot: MappedChildProgressSnapshot,\n options: ToMappedChildStepProgressOptions = {}\n) {\n const units = mappedChildProgressUnits(snapshot);\n const message =\n options.formatMessage?.(snapshot, units) ??\n formatMappedChildProgressMessage(snapshot, {\n itemNoun: options.itemNoun,\n sampleLimit: options.sampleLimit,\n });\n // Empty fan-outs report total 0; otherwise keep total ≥ 1 so renderers can\n // show a determinate bar once work has been scheduled.\n const total =\n snapshot.itemCount === 0\n ? 0\n : Math.max(1, units.total === 0 ? snapshot.itemCount : units.total);\n return {\n completed: units.completed,\n total,\n message,\n details: mappedChildProgressDetails(snapshot, {\n detailLimit: options.detailLimit,\n }),\n };\n}\n"]}
1
+ {"version":3,"file":"mapped-child-progress.js","sourceRoot":"","sources":["../../src/core/mapped-child-progress.ts"],"names":[],"mappings":"AA8DA;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAqC;IAErC,IAAI,QAAQ,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACpC,CAAC;IACD,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC3C,MAAM,iBAAiB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;AACJ,CAAC","sourcesContent":["import type { PipelineStepProgressDetail } from \"./pipeline-types.js\";\n\n/** Compatibility alias of the shared progress-detail shape. */\nexport type MappedChildProgressDetail = PipelineStepProgressDetail;\n\n/**\n * Live state for a `forEachPipeline` fan-out. Domain-agnostic: items can be\n * shards, URLs, files, jobs, or anything else the parent maps over.\n *\n * Runtime-free: only a type-only import of the shared progress detail.\n */\nexport interface MappedChildProgressSnapshot {\n /** Item key → short status label for currently in-flight children. */\n readonly active: ReadonlyMap<string, string>;\n /** Configured concurrency bound for the fan-out. */\n readonly concurrency: number;\n readonly failedItems: number;\n readonly finishedItems: number;\n readonly itemCount: number;\n /**\n * Maximum selected child steps per item seen so far. This is retained for\n * compatibility with callers that provide uniform plans; exact fan-out\n * totals use `plannedChildSteps` once every item plan is known.\n */\n readonly stepsPerItem: number;\n /** Total selected child steps across the item plans discovered so far. */\n readonly plannedChildSteps?: number;\n /** Number of item plans included in `plannedChildSteps`. */\n readonly plannedItems?: number;\n /** Cumulative terminal child steps across all items. */\n readonly terminalChildSteps: number;\n /** Optional one-off note (e.g. the item that just finished or failed). */\n readonly spotlight?: string;\n}\n\nexport interface MappedChildProgressUnits {\n completed: number;\n total: number;\n}\n\nexport interface FormatMappedChildProgressOptions {\n /**\n * Max in-flight item labels embedded in the one-line summary message.\n * Defaults to `0` — prefer `details` rows for multi-line reporters.\n * Set > 0 when a plain/one-line consumer needs samples in `message`.\n */\n sampleLimit?: number;\n /**\n * For `forEachPipeline`, cap visible item groups, including the final snapshot.\n * By default, live snapshots show up to 32 groups and the final snapshot shows all.\n * Larger caps increase per-event presentation work. Standalone formatting\n * helpers apply this to active rows and default to all supplied active items.\n */\n detailLimit?: number;\n /**\n * Plural noun for the mapped work unit in the default message.\n * Defaults to `\"items\"`. Domain packages pass their own label\n * (`\"shards\"`, `\"images\"`, `\"editions\"`) without custom formatters.\n */\n itemNoun?: string;\n}\n\n/**\n * Resolve determinate progress units for a mapped fan-out.\n *\n * When every item plan is known, progress advances on terminal child steps\n * using the exact sum of selected steps across items. The transition preserves\n * the prior item-level completion fraction, rounding up when necessary, so a\n * newly discovered denominator cannot make the reporter move backward. Until\n * then it falls back to item-level accounting. Legacy snapshots without the\n * exact plan fields retain the uniform `stepsPerItem` behavior.\n */\nexport function mappedChildProgressUnits(\n snapshot: MappedChildProgressSnapshot\n): MappedChildProgressUnits {\n if (snapshot.itemCount <= 0) {\n return { completed: 0, total: 0 };\n }\n const plannedItems = snapshot.plannedItems;\n const plannedChildSteps = snapshot.plannedChildSteps;\n if (plannedItems !== undefined && plannedChildSteps !== undefined) {\n if (plannedItems >= snapshot.itemCount && plannedChildSteps > 0) {\n const completedItems = Math.min(\n snapshot.finishedItems + snapshot.failedItems,\n snapshot.itemCount\n );\n const preservedItemProgress =\n completedItems === 0\n ? 0\n : Math.ceil((completedItems * plannedChildSteps) / snapshot.itemCount);\n return {\n completed: Math.min(\n plannedChildSteps,\n Math.max(snapshot.terminalChildSteps, preservedItemProgress)\n ),\n total: plannedChildSteps,\n };\n }\n return {\n completed: Math.min(snapshot.finishedItems + snapshot.failedItems, snapshot.itemCount),\n total: snapshot.itemCount,\n };\n }\n if (snapshot.stepsPerItem > 0) {\n const total = snapshot.itemCount * snapshot.stepsPerItem;\n return {\n completed: Math.min(snapshot.terminalChildSteps, total),\n total,\n };\n }\n return {\n completed: Math.min(snapshot.finishedItems + snapshot.failedItems, snapshot.itemCount),\n total: snapshot.itemCount,\n };\n}\n\n/**\n * Default domain-neutral one-line summary for mapped children.\n *\n * Example (no samples):\n * `3/10 items · 4 running (max 8)`\n *\n * Example with `sampleLimit: 2`:\n * `3/10 items · 4 running (max 8) · shard-a/parse · shard-b/write · +2 more`\n */\nexport function formatMappedChildProgressMessage(\n snapshot: MappedChildProgressSnapshot,\n options: FormatMappedChildProgressOptions = {}\n): string {\n const noun = options.itemNoun?.trim() || \"items\";\n if (snapshot.itemCount <= 0) {\n return `0 ${noun}`;\n }\n\n const sampleLimit = Math.max(0, Math.floor(options.sampleLimit ?? 0));\n const runningEntries = [...snapshot.active.entries()].sort(([left], [right]) =>\n left.localeCompare(right)\n );\n const runningSample = runningEntries\n .slice(0, sampleLimit)\n .map(([itemKey, label]) => `${itemKey}/${label}`)\n .join(\" · \");\n const overflow =\n sampleLimit > 0 && runningEntries.length > sampleLimit\n ? ` · +${runningEntries.length - sampleLimit} more`\n : \"\";\n\n const settled = snapshot.finishedItems + snapshot.failedItems;\n const parts = [\n `${snapshot.finishedItems}/${snapshot.itemCount} ${noun}`,\n snapshot.failedItems > 0 ? `${snapshot.failedItems} failed` : null,\n snapshot.active.size > 0\n ? `${snapshot.active.size} running (max ${snapshot.concurrency})`\n : settled >= snapshot.itemCount\n ? null\n : \"starting\",\n runningSample ? `${runningSample}${overflow}` : null,\n snapshot.spotlight,\n ].filter((part): part is string => Boolean(part));\n\n return parts.join(\" · \");\n}\n\n/**\n * Build sorted detail rows for in-flight mapped children.\n * Stable key order so multi-line UIs do not thrash row positions.\n */\nexport function mappedChildProgressDetails(\n snapshot: MappedChildProgressSnapshot,\n options: Pick<FormatMappedChildProgressOptions, \"detailLimit\"> = {}\n): MappedChildProgressDetail[] {\n const entries = [...snapshot.active.entries()].sort(([left], [right]) =>\n left.localeCompare(right)\n );\n const limit =\n options.detailLimit === undefined\n ? entries.length\n : Math.max(0, Math.floor(options.detailLimit));\n const visible = entries.slice(0, limit);\n const details: MappedChildProgressDetail[] = visible.map(([id, label]) => ({\n id,\n label,\n status: \"running\" as const,\n }));\n if (entries.length > visible.length) {\n details.push({\n id: `+${entries.length - visible.length} more`,\n status: \"pending\",\n });\n }\n return details;\n}\n\nexport interface ToMappedChildStepProgressOptions extends FormatMappedChildProgressOptions {\n /**\n * Replace the default message while keeping the same completed/total units.\n * Use this for domain labels without forking the fan-out runner.\n *\n * @example\n * formatMessage: (s) => `${s.finishedItems}/${s.itemCount} images`\n */\n formatMessage?: (\n snapshot: MappedChildProgressSnapshot,\n units: MappedChildProgressUnits\n ) => string;\n}\n\n/**\n * Build a progress payload for an opaque mapped-child parent step.\n * Shape matches `PipelineStepProgress` without importing the runtime module.\n *\n * `message` is a one-line summary; `details` lists each in-flight item for\n * multi-line reporters.\n */\nexport function toMappedChildStepProgress(\n snapshot: MappedChildProgressSnapshot,\n options: ToMappedChildStepProgressOptions = {}\n) {\n const units = mappedChildProgressUnits(snapshot);\n const message =\n options.formatMessage?.(snapshot, units) ??\n formatMappedChildProgressMessage(snapshot, {\n itemNoun: options.itemNoun,\n sampleLimit: options.sampleLimit,\n });\n // Empty fan-outs report total 0; otherwise keep total ≥ 1 so renderers can\n // show a determinate bar once work has been scheduled.\n const total =\n snapshot.itemCount === 0\n ? 0\n : Math.max(1, units.total === 0 ? snapshot.itemCount : units.total);\n return {\n completed: units.completed,\n total,\n message,\n details: mappedChildProgressDetails(snapshot, {\n detailLimit: options.detailLimit,\n }),\n };\n}\n"]}
@@ -144,7 +144,7 @@ interface FromPipelineConstructor<TOptions extends object, TInputOptions extends
144
144
  <TId extends string, TChildPipeline extends Pipeline<object, unknown>, TOut, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
145
145
  skip?: never;
146
146
  mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, context: PipelineStepContext<TOptions>): TOut;
147
- }): Step<TId, TOut, TOptions, TInputOptions>;
147
+ }): Step<TId, Awaited<TOut>, TOptions, TInputOptions>;
148
148
  skippable: SkippableFromPipelineConstructor<TOptions, TInputOptions>;
149
149
  }
150
150
  interface SkippableFromPipelineConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
@@ -153,9 +153,9 @@ interface SkippableFromPipelineConstructor<TOptions extends object, TInputOption
153
153
  mapResult?: undefined;
154
154
  }): Step<TId, PipelineResultOf<TChildPipeline> | undefined, TOptions, TInputOptions>;
155
155
  <TId extends string, TChildPipeline extends Pipeline<object, unknown>, TOut, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
156
- skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<TOut>> | undefined;
156
+ skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<Awaited<TOut>>> | undefined;
157
157
  mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, context: PipelineStepContext<TOptions>): TOut;
158
- }): Step<TId, TOut | undefined, TOptions, TInputOptions>;
158
+ }): Step<TId, Awaited<TOut> | undefined, TOptions, TInputOptions>;
159
159
  }
160
160
  interface ForEachPipelineConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
161
161
  <TId extends string, TChildPipeline extends Pipeline<object, unknown>, TItem, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: MappedChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline, TItem> & {
@@ -39,15 +39,10 @@ function createStepFactory(optionsSchema) {
39
39
  isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),
40
40
  }),
41
41
  };
42
- if ("skip" in config && config.skip !== undefined) {
43
- const skip = config.skip;
44
- // SAFETY: the skip predicate is invoked with the step's own inputs and
45
- // returns a step-skip decision; the casts only align the generic
46
- // predicate signature with the concrete step context.
47
- return buildStep(id, {
48
- ...definition,
49
- skip: (inputs, context) => skip(inputs, context),
50
- });
42
+ const skip = config.skip;
43
+ if (skip !== undefined) {
44
+ // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.
45
+ definition.skip = (inputs, context) => skip(inputs, context);
51
46
  }
52
47
  return buildStep(id, definition);
53
48
  });
@@ -68,13 +63,10 @@ function createStepFactory(optionsSchema) {
68
63
  outputSchema: config.outputSchema,
69
64
  run: (inputs, context) => config.adapter.invoke(config.mapInput(inputs, context), context),
70
65
  };
71
- if ("skip" in config && config.skip !== undefined) {
72
- const skip = config.skip;
73
- return buildStep(id, {
74
- ...definition,
75
- // SAFETY: skippable fromRemote configs share the same dependency input map as the non-skippable overload.
76
- skip: (inputs, context) => skip(inputs, context),
77
- });
66
+ const skip = config.skip;
67
+ if (skip !== undefined) {
68
+ // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.
69
+ definition.skip = (inputs, context) => skip(inputs, context);
78
70
  }
79
71
  return buildStep(id, definition);
80
72
  });
@@ -101,13 +93,10 @@ function createStepFactory(optionsSchema) {
101
93
  isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),
102
94
  }),
103
95
  };
104
- if ("skip" in config && config.skip !== undefined) {
105
- const skip = config.skip;
106
- return buildStep(id, {
107
- ...definition,
108
- // SAFETY: skippable mapped-child configs share the same dependency input map as the non-skippable overload.
109
- skip: (inputs, context) => skip(inputs, context),
110
- });
96
+ const skip = config.skip;
97
+ if (skip !== undefined) {
98
+ // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.
99
+ definition.skip = (inputs, context) => skip(inputs, context);
111
100
  }
112
101
  return buildStep(id, definition);
113
102
  });
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-steps.js","sourceRoot":"","sources":["../../src/core/pipeline-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GAGxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA+jB5F,MAAM,UAAU,WAAW,CAAC,aAAgD;IAC1E,OAAO,iBAAiB,CAAS,aAAa,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,iBAAiB,CACxB,aAAgC;IAEhC,2EAA2E;IAC3E,sEA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AI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAClD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACzB,OAAO,SAAS,CAAC,EAAE,EAAE;gBACnB,GAAG,UAAU;gBACb,4GAA4G;gBAC5G,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,MAAe,EAAE,OAAO,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC,CAA4D,CAAC;IAE9D,0EAA0E;IAC1E,8EAA8E;IAC9E,sDAAsD;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QACvC,SAAS,EAAE,SAAS;QACpB,YAAY;QACZ,UAAU;QACV,eAAe;KAChB,CAAyC,CAAC;IAC3C,4EAA4E;IAC5E,6DAA6D;IAC7D,OAAO,CAAC,YAAY,CAAC,SAAS,GAAG,YAGH,CAAC;IAC/B,wEAAwE;IACxE,6DAA6D;IAC7D,OAAO,CAAC,UAAU,CAAC,SAAS,GAAG,UAGH,CAAC;IAC7B,+EAA+E;IAC/E,gEAAgE;IAChE,OAAO,CAAC,eAAe,CAAC,SAAS,GAAG,eAGH,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n createMappedChildRunner,\n createSingleChildRunner,\n type MappedChildExecutionConfig,\n type SingleChildExecutionConfig,\n} from \"./child-execution.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport { isPipelineCancellation, PipelineExecutionError } from \"./pipeline-execute.js\";\nimport { STEP_NESTED_PIPELINE, STEP_OPTIONS_SCHEMA, STEP_REMOTE } from \"./pipeline-plan.js\";\nimport type {\n InferSchemaInput,\n InferSchemaOutput,\n Pipeline,\n PipelineExecutionContext,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunOptions,\n PipelineStepContext,\n RemoteStepAdapter,\n StandardSchemaV1,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\n\n/**\n * A step's dependencies are references to the dependency's own step object, not string ids\n * into a hand-maintained output-type map. This buys two things no amount of extra generics\n * on a string-keyed design could:\n * - a step used before its dependency exists is a compile error (JS temporal dead zone on\n * `const`), so out-of-order and self/cyclic dependencies are caught by the language, not\n * a bespoke runtime check\n * - each step only ever states its own id/deps; the output-type map is derived, never\n * restated, and callers of `definePipeline`/`createSteps` never write out its generics\n */\ntype AnyStepDryRunHandler<TOptions extends object> = {\n bivarianceHack(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): unknown | Promise<unknown>;\n}[\"bivarianceHack\"];\n\nexport interface AnyStep<TOptions extends object = object> {\n readonly [STEP_NESTED_PIPELINE]?: NonNullable<PipelinePlanStep[\"nestedPipeline\"]>;\n readonly [STEP_REMOTE]?: NonNullable<PipelinePlanStep[\"remote\"]>;\n readonly [STEP_OPTIONS_SCHEMA]?: StandardSchemaV1;\n readonly id: string;\n readonly dependsOn?: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn?: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n readonly name?: string;\n readonly description?: string;\n /**\n * Dry-run policy. Omitted runs the normal handler, `\"skip\"` structurally\n * skips it, and a handler substitutes for `run` while preserving its output.\n */\n readonly dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n /** Optional Standard Schema for values published by this step. */\n readonly outputSchema?: StandardSchemaV1;\n /**\n * Optional runtime skip. Return a non-empty reason (or `{ reason, value }`) to\n * skip without calling `run`. Policy skips unlock dependents; structural skips\n * (dry-run, filtered, …) do not use this hook.\n */\n skip?(\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n ): StepSkipDecision | Promise<StepSkipDecision>;\n run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n}\n\n/** The step fields that `buildStep` merges onto the id-bearing shell. */\ntype StepDefinitionBody<TOptions extends object> = Omit<AnyStep<TOptions>, \"id\">;\n\nexport interface Step<\n TId extends string,\n TOut,\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TRunOut = TOut,\n> extends AnyStep<TOptions> {\n readonly id: TId;\n run(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): TRunOut | Promise<TRunOut>;\n /** Type-only: carries this step's output type for sibling inference. Never set at runtime. */\n readonly __outputType?: TOut;\n /** Type-only: carries pre-validation run options for pipeline call-site inference. */\n readonly __inputOptionsType?: TInputOptions;\n}\n\n/**\n * Extract a step's output type for dependency typing.\n * Prefer matching `Step<…, TOut, …>` over `{ __outputType?: infer T }`: optional-property\n * inference collapses `TOut | undefined` to `TOut`, which hides policy-skip widening.\n */\nexport type StepOutput<S> =\n S extends Step<string, infer TOut, infer _TOptions, infer _TInputOptions, infer _TRunOut>\n ? TOut\n : never;\n\ninterface StepToken {\n readonly id: string;\n readonly __outputType?: unknown;\n}\n\ntype RequiredInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype OptionalInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]?: StepOutput<S>;\n};\n\ntype PipelineResultOf<TPipeline> =\n TPipeline extends Pipeline<object, infer TResult, infer _TStepId, infer _TTargetId>\n ? TResult\n : never;\n\ntype PipelineRunOptionsOf<TPipeline> =\n TPipeline extends Pipeline<infer TOptions, unknown, infer TStepId, infer TTargetId>\n ? PipelineRunOptions<TOptions, TStepId, TTargetId>\n : never;\n\ntype ChildPipelineStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n mapOptions(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptionsOf<TChildPipeline>;\n};\n\n/** Child step without policy skip (dependents see the full child result type). */\ntype ChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = ChildPipelineStepDefinitionBase<TParentOptions, TDeps, TOptionalDeps, TChildPipeline>;\n\n/**\n * Presentation options for opaque `forEachPipeline` progress.\n * Defaults are domain-neutral (`N/M items · K running · key/step`).\n * Override `formatMessage` when a domain wants its own noun (images, shards, …).\n */\nexport type MappedChildProgressOptions = ToMappedChildStepProgressOptions;\n\ntype MappedChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n items(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly TItem[] | Promise<readonly TItem[]>;\n key(item: TItem, index: number): string;\n concurrency?:\n | number\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => number);\n /**\n * How the opaque parent step reports live fan-out progress.\n * Purely presentational — does not change scheduling or results.\n */\n progress?: MappedChildProgressOptions;\n mapOptions(\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptionsOf<TChildPipeline>;\n};\n\ntype StepSkipPredicate<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TOptions>\n) => StepSkipDecision<TOut> | Promise<StepSkipDecision<TOut>>;\n\ntype StepDryRunPolicy<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> =\n | \"skip\"\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => TOut | Promise<TOut>);\n\ntype PlainStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = {\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TOptions, TDeps, TOptionalDeps, TOut>;\n outputSchema?: never;\n run(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ): TOut | Promise<TOut>;\n};\n\ntype SchemaStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TSchema extends StandardSchemaV1,\n> = Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>,\n \"outputSchema\"\n> & {\n outputSchema: TSchema;\n};\n\ninterface StepConstructor<TOptions extends object, TInputOptions extends object = TOptions> {\n /** Ordinary steps never policy-skip, so dependents receive their full output. */\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & { skip?: never }\n ): Step<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n\n <\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & { skip?: never }\n ): Step<TId, TOut, TOptions, TInputOptions>;\n\n /** Explicit policy-skip constructor; dependents receive `TOut | undefined`. */\n skippable: SkippableStepConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableStepConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>\n | undefined;\n }\n ): Step<\n TId,\n InferSchemaOutput<TSchema> | undefined,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n\n <\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, TOut> | undefined;\n }\n ): Step<TId, TOut | undefined, TOptions, TInputOptions>;\n}\n\ninterface FromPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult?: undefined;\n }\n ): Step<TId, PipelineResultOf<TChildPipeline>, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, TOut, TOptions, TInputOptions>;\n\n skippable: SkippableFromPipelineConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableFromPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, PipelineResultOf<TChildPipeline>>\n | undefined;\n mapResult?: undefined;\n }\n ): Step<TId, PipelineResultOf<TChildPipeline> | undefined, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<TOut>> | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, TOut | undefined, TOptions, TInputOptions>;\n}\n\ninterface ForEachPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult?: undefined;\n }\n ): Step<TId, readonly PipelineResultOf<TChildPipeline>[], TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, readonly TOut[], TOptions, TInputOptions>;\n\n skippable: SkippableForEachPipelineConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableForEachPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n readonly PipelineResultOf<TChildPipeline>[]\n >\n | undefined;\n mapResult?: undefined;\n }\n ): Step<TId, readonly PipelineResultOf<TChildPipeline>[] | undefined, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<readonly TOut[]>> | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, readonly TOut[] | undefined, TOptions, TInputOptions>;\n}\n\ntype RemoteStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TPayload,\n TSchema extends StandardSchemaV1,\n> = {\n adapter: RemoteStepAdapter<TParentOptions, TPayload, InferSchemaInput<TSchema>>;\n mapInput(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TParentOptions>\n ): TPayload;\n outputSchema: TSchema;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TParentOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>;\n};\n\ninterface FromRemoteConstructor<TOptions extends object, TInputOptions extends object = TOptions> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip?: never;\n }\n ): Step<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n\n skippable: SkippableFromRemoteConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableFromRemoteConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>\n | undefined;\n }\n ): Step<\n TId,\n InferSchemaOutput<TSchema> | undefined,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n}\n\nexport interface StepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> extends StepConstructor<TOptions, TInputOptions> {\n fromPipeline: FromPipelineConstructor<TOptions, TInputOptions>;\n fromRemote: FromRemoteConstructor<TOptions, TInputOptions>;\n forEachPipeline: ForEachPipelineConstructor<TOptions, TInputOptions>;\n}\n\n/**\n * Returns a step factory scoped to one pipeline's domain options. Pass built-in\n * run controls as the second argument to `run` / `runOrThrow`. Child\n * `mapOptions` may still return domain options plus those controls.\n */\nexport function createSteps<TOptions extends object = {}>(): StepFactory<TOptions>;\nexport function createSteps<const TSchema extends StandardSchemaV1<object, object>>(\n optionsSchema: TSchema\n): StepFactory<InferSchemaOutput<TSchema>, InferSchemaInput<TSchema>>;\nexport function createSteps(optionsSchema?: StandardSchemaV1<object, object>): StepFactory<object> {\n return createStepFactory<object>(optionsSchema);\n}\n\nfunction createStepFactory<TOptions extends object, TInputOptions extends object = TOptions>(\n optionsSchema?: StandardSchemaV1\n): StepFactory<TOptions, TInputOptions> {\n // Runtime construction is deliberately simple; the public factory owns the\n // distinction between ordinary and explicitly skippable constructors.\n const buildStep = (id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> => {\n // SAFETY: `definition` carries the step's own fields; spreading it onto the\n // id-bearing shell yields a value whose shape matches `AnyStep<TOptions>`.\n const built = { id, ...definition } as AnyStep<TOptions>;\n if (optionsSchema) {\n Object.defineProperty(built, STEP_OPTIONS_SCHEMA, { value: optionsSchema });\n }\n return built;\n };\n\n // SAFETY: the closure's parameter and return shapes match the\n // `fromPipeline` constructor signature it is assigned to.\n const fromPipeline = ((\n id: string,\n config: ChildPipelineStepDefinitionBase<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>\n > & {\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n }\n ) => {\n const definition = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"single\" as const,\n pipelineId: config.pipeline.id,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n // SAFETY: the config carries `pipeline` and `mapResult`; the runner\n // derives `mapOptions` from the same fields, so the config is a valid\n // single-child execution config at runtime.\n run: createSingleChildRunner(config as SingleChildExecutionConfig<TOptions>, {\n createExecutionError: (result, message) => new PipelineExecutionError(result, message),\n isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),\n }),\n };\n\n if (\"skip\" in config && config.skip !== undefined) {\n const skip = config.skip;\n // SAFETY: the skip predicate is invoked with the step's own inputs and\n // returns a step-skip decision; the casts only align the generic\n // predicate signature with the concrete step context.\n return buildStep(id, {\n ...definition,\n skip: (\n inputs: RequiredInputs<readonly AnyStep<TOptions>[]> &\n OptionalInputs<readonly AnyStep<TOptions>[]>,\n context: PipelineExecutionContext<TOptions>\n ) => skip(inputs as never, context) as StepSkipDecision | Promise<StepSkipDecision>,\n });\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"fromPipeline\"];\n\n // SAFETY: the closure's parameter and return shapes match the\n // `fromRemote` constructor signature it is assigned to.\n const fromRemote = ((\n id: string,\n config: {\n adapter: RemoteStepAdapter<object, unknown, unknown>;\n mapInput: (\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n outputSchema: StandardSchemaV1;\n dependsOn?: readonly AnyStep<TOptions>[];\n optionalDependsOn?: readonly AnyStep<TOptions>[];\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const remote: NonNullable<PipelinePlanStep[\"remote\"]> = { engine: config.adapter.engine };\n if (config.adapter.target !== undefined) remote.target = config.adapter.target;\n const definition = {\n [STEP_REMOTE]: remote,\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n outputSchema: config.outputSchema,\n run: (inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>) =>\n config.adapter.invoke(config.mapInput(inputs, context), context),\n };\n if (\"skip\" in config && config.skip !== undefined) {\n const skip = config.skip;\n return buildStep(id, {\n ...definition,\n // SAFETY: skippable fromRemote configs share the same dependency input map as the non-skippable overload.\n skip: (inputs, context) => skip(inputs as never, context),\n });\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"fromRemote\"];\n\n // SAFETY: the closure's parameter and return shapes match the\n // `forEachPipeline` constructor signature it is assigned to.\n const forEachPipeline = ((\n id: string,\n config: MappedChildPipelineStepDefinition<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>,\n unknown\n > & {\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const definition = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"for-each\" as const,\n pipelineId: config.pipeline.id,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n // SAFETY: the config carries `pipeline`, `items`, `key`, and `mapResult`;\n // the runner derives the rest from those fields, so the config is a valid\n // mapped-child execution config at runtime.\n run: createMappedChildRunner(config as MappedChildExecutionConfig<TOptions>, {\n createExecutionError: (result, message) => new PipelineExecutionError(result, message),\n isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),\n }),\n };\n\n if (\"skip\" in config && config.skip !== undefined) {\n const skip = config.skip;\n return buildStep(id, {\n ...definition,\n // SAFETY: skippable mapped-child configs share the same dependency input map as the non-skippable overload.\n skip: (inputs, context) => skip(inputs as never, context),\n });\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"forEachPipeline\"];\n\n // SAFETY: `buildStep` is a callable; attaching the constructor properties\n // yields exactly the `StepFactory` surface (call + skippable + fromPipeline +\n // forEachPipeline), so the single assertion is sound.\n const factory = Object.assign(buildStep, {\n skippable: buildStep,\n fromPipeline,\n fromRemote,\n forEachPipeline,\n }) as StepFactory<TOptions, TInputOptions>;\n // SAFETY: `fromPipeline` is the same callable as `factory.fromPipeline`; it\n // carries the skippable variant, so the assignment is sound.\n factory.fromPipeline.skippable = fromPipeline as StepFactory<\n TOptions,\n TInputOptions\n >[\"fromPipeline\"][\"skippable\"];\n // SAFETY: `fromRemote` is the same callable as `factory.fromRemote`; it\n // carries the skippable variant, so the assignment is sound.\n factory.fromRemote.skippable = fromRemote as StepFactory<\n TOptions,\n TInputOptions\n >[\"fromRemote\"][\"skippable\"];\n // SAFETY: `forEachPipeline` is the same callable as `factory.forEachPipeline`;\n // it carries the skippable variant, so the assignment is sound.\n factory.forEachPipeline.skippable = forEachPipeline as StepFactory<\n TOptions,\n TInputOptions\n >[\"forEachPipeline\"][\"skippable\"];\n\n return factory;\n}\n"]}
1
+ {"version":3,"file":"pipeline-steps.js","sourceRoot":"","sources":["../../src/core/pipeline-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GAGxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA+jB5F,MAAM,UAAU,WAAW,CAAC,aAAgD;IAC1E,OAAO,iBAAiB,CAAS,aAAa,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,iBAAiB,CACxB,aAAgC;IAEhC,2EAA2E;IAC3E,sEAAsE;IACtE,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,UAAwC,EAAqB,EAAE;QAC5F,4EAA4E;QAC5E,2EAA2E;QAC3E,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,GAAG,UAAU,EAAuB,CAAC;QACzD,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,8DAA8D;IAC9D,0DA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A6D;IAC7D,OAAO,CAAC,UAAU,CAAC,SAAS,GAAG,UAGH,CAAC;IAC7B,+EAA+E;IAC/E,gEAAgE;IAChE,OAAO,CAAC,eAAe,CAAC,SAAS,GAAG,eAGH,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n createMappedChildRunner,\n createSingleChildRunner,\n type MappedChildExecutionConfig,\n type SingleChildExecutionConfig,\n} from \"./child-execution.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport { isPipelineCancellation, PipelineExecutionError } from \"./pipeline-execute.js\";\nimport { STEP_NESTED_PIPELINE, STEP_OPTIONS_SCHEMA, STEP_REMOTE } from \"./pipeline-plan.js\";\nimport type {\n InferSchemaInput,\n InferSchemaOutput,\n Pipeline,\n PipelineExecutionContext,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunOptions,\n PipelineStepContext,\n RemoteStepAdapter,\n StandardSchemaV1,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\n\n/**\n * A step's dependencies are references to the dependency's own step object, not string ids\n * into a hand-maintained output-type map. This buys two things no amount of extra generics\n * on a string-keyed design could:\n * - a step used before its dependency exists is a compile error (JS temporal dead zone on\n * `const`), so out-of-order and self/cyclic dependencies are caught by the language, not\n * a bespoke runtime check\n * - each step only ever states its own id/deps; the output-type map is derived, never\n * restated, and callers of `definePipeline`/`createSteps` never write out its generics\n */\ntype AnyStepDryRunHandler<TOptions extends object> = {\n bivarianceHack(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): unknown | Promise<unknown>;\n}[\"bivarianceHack\"];\n\nexport interface AnyStep<TOptions extends object = object> {\n readonly [STEP_NESTED_PIPELINE]?: NonNullable<PipelinePlanStep[\"nestedPipeline\"]>;\n readonly [STEP_REMOTE]?: NonNullable<PipelinePlanStep[\"remote\"]>;\n readonly [STEP_OPTIONS_SCHEMA]?: StandardSchemaV1;\n readonly id: string;\n readonly dependsOn?: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn?: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n readonly name?: string;\n readonly description?: string;\n /**\n * Dry-run policy. Omitted runs the normal handler, `\"skip\"` structurally\n * skips it, and a handler substitutes for `run` while preserving its output.\n */\n readonly dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n /** Optional Standard Schema for values published by this step. */\n readonly outputSchema?: StandardSchemaV1;\n /**\n * Optional runtime skip. Return a non-empty reason (or `{ reason, value }`) to\n * skip without calling `run`. Policy skips unlock dependents; structural skips\n * (dry-run, filtered, …) do not use this hook.\n */\n skip?(\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n ): StepSkipDecision | Promise<StepSkipDecision>;\n run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n}\n\n/** The step fields that `buildStep` merges onto the id-bearing shell. */\ntype StepDefinitionBody<TOptions extends object> = Omit<AnyStep<TOptions>, \"id\">;\n\nexport interface Step<\n TId extends string,\n TOut,\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TRunOut = TOut,\n> extends AnyStep<TOptions> {\n readonly id: TId;\n run(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): TRunOut | Promise<TRunOut>;\n /** Type-only: carries this step's output type for sibling inference. Never set at runtime. */\n readonly __outputType?: TOut;\n /** Type-only: carries pre-validation run options for pipeline call-site inference. */\n readonly __inputOptionsType?: TInputOptions;\n}\n\n/**\n * Extract a step's output type for dependency typing.\n * Prefer matching `Step<…, TOut, …>` over `{ __outputType?: infer T }`: optional-property\n * inference collapses `TOut | undefined` to `TOut`, which hides policy-skip widening.\n */\nexport type StepOutput<S> =\n S extends Step<string, infer TOut, infer _TOptions, infer _TInputOptions, infer _TRunOut>\n ? TOut\n : never;\n\ninterface StepToken {\n readonly id: string;\n readonly __outputType?: unknown;\n}\n\ntype RequiredInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype OptionalInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]?: StepOutput<S>;\n};\n\ntype PipelineResultOf<TPipeline> =\n TPipeline extends Pipeline<object, infer TResult, infer _TStepId, infer _TTargetId>\n ? TResult\n : never;\n\ntype PipelineRunOptionsOf<TPipeline> =\n TPipeline extends Pipeline<infer TOptions, unknown, infer TStepId, infer TTargetId>\n ? PipelineRunOptions<TOptions, TStepId, TTargetId>\n : never;\n\ntype ChildPipelineStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n mapOptions(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptionsOf<TChildPipeline>;\n};\n\n/** Child step without policy skip (dependents see the full child result type). */\ntype ChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = ChildPipelineStepDefinitionBase<TParentOptions, TDeps, TOptionalDeps, TChildPipeline>;\n\n/**\n * Presentation options for opaque `forEachPipeline` progress.\n * Defaults are domain-neutral (`N/M items · K running · key/step`).\n * Override `formatMessage` when a domain wants its own noun (images, shards, …).\n */\nexport type MappedChildProgressOptions = ToMappedChildStepProgressOptions;\n\ntype MappedChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n items(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly TItem[] | Promise<readonly TItem[]>;\n key(item: TItem, index: number): string;\n concurrency?:\n | number\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => number);\n /**\n * How the opaque parent step reports live fan-out progress.\n * Purely presentational — does not change scheduling or results.\n */\n progress?: MappedChildProgressOptions;\n mapOptions(\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineRunOptionsOf<TChildPipeline>;\n};\n\ntype StepSkipPredicate<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TOptions>\n) => StepSkipDecision<TOut> | Promise<StepSkipDecision<TOut>>;\n\ntype StepDryRunPolicy<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> =\n | \"skip\"\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => TOut | Promise<TOut>);\n\ntype PlainStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = {\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TOptions, TDeps, TOptionalDeps, TOut>;\n outputSchema?: never;\n run(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ): TOut | Promise<TOut>;\n};\n\ntype SchemaStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TSchema extends StandardSchemaV1,\n> = Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>,\n \"outputSchema\"\n> & {\n outputSchema: TSchema;\n};\n\ninterface StepConstructor<TOptions extends object, TInputOptions extends object = TOptions> {\n /** Ordinary steps never policy-skip, so dependents receive their full output. */\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & { skip?: never }\n ): Step<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n\n <\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & { skip?: never }\n ): Step<TId, TOut, TOptions, TInputOptions>;\n\n /** Explicit policy-skip constructor; dependents receive `TOut | undefined`. */\n skippable: SkippableStepConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableStepConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>\n | undefined;\n }\n ): Step<\n TId,\n InferSchemaOutput<TSchema> | undefined,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n\n <\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, TOut> | undefined;\n }\n ): Step<TId, TOut | undefined, TOptions, TInputOptions>;\n}\n\ninterface FromPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult?: undefined;\n }\n ): Step<TId, PipelineResultOf<TChildPipeline>, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, Awaited<TOut>, TOptions, TInputOptions>;\n\n skippable: SkippableFromPipelineConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableFromPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, PipelineResultOf<TChildPipeline>>\n | undefined;\n mapResult?: undefined;\n }\n ): Step<TId, PipelineResultOf<TChildPipeline> | undefined, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<Awaited<TOut>>> | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, Awaited<TOut> | undefined, TOptions, TInputOptions>;\n}\n\ninterface ForEachPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult?: undefined;\n }\n ): Step<TId, readonly PipelineResultOf<TChildPipeline>[], TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, readonly TOut[], TOptions, TInputOptions>;\n\n skippable: SkippableForEachPipelineConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableForEachPipelineConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n readonly PipelineResultOf<TChildPipeline>[]\n >\n | undefined;\n mapResult?: undefined;\n }\n ): Step<TId, readonly PipelineResultOf<TChildPipeline>[] | undefined, TOptions, TInputOptions>;\n\n <\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<readonly TOut[]>> | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): Step<TId, readonly TOut[] | undefined, TOptions, TInputOptions>;\n}\n\ntype RemoteStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TPayload,\n TSchema extends StandardSchemaV1,\n> = {\n adapter: RemoteStepAdapter<TParentOptions, TPayload, InferSchemaInput<TSchema>>;\n mapInput(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TParentOptions>\n ): TPayload;\n outputSchema: TSchema;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TParentOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>;\n};\n\ninterface FromRemoteConstructor<TOptions extends object, TInputOptions extends object = TOptions> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip?: never;\n }\n ): Step<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n\n skippable: SkippableFromRemoteConstructor<TOptions, TInputOptions>;\n}\n\ninterface SkippableFromRemoteConstructor<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> {\n <\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>\n | undefined;\n }\n ): Step<\n TId,\n InferSchemaOutput<TSchema> | undefined,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n}\n\nexport interface StepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n> extends StepConstructor<TOptions, TInputOptions> {\n fromPipeline: FromPipelineConstructor<TOptions, TInputOptions>;\n fromRemote: FromRemoteConstructor<TOptions, TInputOptions>;\n forEachPipeline: ForEachPipelineConstructor<TOptions, TInputOptions>;\n}\n\n/**\n * Returns a step factory scoped to one pipeline's domain options. Pass built-in\n * run controls as the second argument to `run` / `runOrThrow`. Child\n * `mapOptions` may still return domain options plus those controls.\n */\nexport function createSteps<TOptions extends object = {}>(): StepFactory<TOptions>;\nexport function createSteps<const TSchema extends StandardSchemaV1<object, object>>(\n optionsSchema: TSchema\n): StepFactory<InferSchemaOutput<TSchema>, InferSchemaInput<TSchema>>;\nexport function createSteps(optionsSchema?: StandardSchemaV1<object, object>): StepFactory<object> {\n return createStepFactory<object>(optionsSchema);\n}\n\nfunction createStepFactory<TOptions extends object, TInputOptions extends object = TOptions>(\n optionsSchema?: StandardSchemaV1\n): StepFactory<TOptions, TInputOptions> {\n // Runtime construction is deliberately simple; the public factory owns the\n // distinction between ordinary and explicitly skippable constructors.\n const buildStep = (id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> => {\n // SAFETY: `definition` carries the step's own fields; spreading it onto the\n // id-bearing shell yields a value whose shape matches `AnyStep<TOptions>`.\n const built = { id, ...definition } as AnyStep<TOptions>;\n if (optionsSchema) {\n Object.defineProperty(built, STEP_OPTIONS_SCHEMA, { value: optionsSchema });\n }\n return built;\n };\n\n // SAFETY: the closure's parameter and return shapes match the\n // `fromPipeline` constructor signature it is assigned to.\n const fromPipeline = ((\n id: string,\n config: ChildPipelineStepDefinitionBase<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>\n > & {\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"single\" as const,\n pipelineId: config.pipeline.id,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n // SAFETY: the config carries `pipeline` and `mapResult`; the runner\n // derives `mapOptions` from the same fields, so the config is a valid\n // single-child execution config at runtime.\n run: createSingleChildRunner(config as SingleChildExecutionConfig<TOptions>, {\n createExecutionError: (result, message) => new PipelineExecutionError(result, message),\n isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),\n }),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.\n definition.skip = (inputs, context) => skip(inputs as never, context);\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"fromPipeline\"];\n\n // SAFETY: the closure's parameter and return shapes match the\n // `fromRemote` constructor signature it is assigned to.\n const fromRemote = ((\n id: string,\n config: {\n adapter: RemoteStepAdapter<object, unknown, unknown>;\n mapInput: (\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n outputSchema: StandardSchemaV1;\n dependsOn?: readonly AnyStep<TOptions>[];\n optionalDependsOn?: readonly AnyStep<TOptions>[];\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const remote: NonNullable<PipelinePlanStep[\"remote\"]> = { engine: config.adapter.engine };\n if (config.adapter.target !== undefined) remote.target = config.adapter.target;\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_REMOTE]: remote,\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n outputSchema: config.outputSchema,\n run: (inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>) =>\n config.adapter.invoke(config.mapInput(inputs, context), context),\n };\n const skip = config.skip;\n if (skip !== undefined) {\n // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.\n definition.skip = (inputs, context) => skip(inputs as never, context);\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"fromRemote\"];\n\n // SAFETY: the closure's parameter and return shapes match the\n // `forEachPipeline` constructor signature it is assigned to.\n const forEachPipeline = ((\n id: string,\n config: MappedChildPipelineStepDefinition<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>,\n unknown\n > & {\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"for-each\" as const,\n pipelineId: config.pipeline.id,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n // SAFETY: the config carries `pipeline`, `items`, `key`, and `mapResult`;\n // the runner derives the rest from those fields, so the config is a valid\n // mapped-child execution config at runtime.\n run: createMappedChildRunner(config as MappedChildExecutionConfig<TOptions>, {\n createExecutionError: (result, message) => new PipelineExecutionError(result, message),\n isCancellation: (error, childContext) => isPipelineCancellation(error, childContext),\n }),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n // SAFETY: each constructor preserves the skip predicate's dependency inputs and context.\n definition.skip = (inputs, context) => skip(inputs as never, context);\n }\n return buildStep(id, definition);\n }) as StepFactory<TOptions, TInputOptions>[\"forEachPipeline\"];\n\n // SAFETY: `buildStep` is a callable; attaching the constructor properties\n // yields exactly the `StepFactory` surface (call + skippable + fromPipeline +\n // forEachPipeline), so the single assertion is sound.\n const factory = Object.assign(buildStep, {\n skippable: buildStep,\n fromPipeline,\n fromRemote,\n forEachPipeline,\n }) as StepFactory<TOptions, TInputOptions>;\n // SAFETY: `fromPipeline` is the same callable as `factory.fromPipeline`; it\n // carries the skippable variant, so the assignment is sound.\n factory.fromPipeline.skippable = fromPipeline as StepFactory<\n TOptions,\n TInputOptions\n >[\"fromPipeline\"][\"skippable\"];\n // SAFETY: `fromRemote` is the same callable as `factory.fromRemote`; it\n // carries the skippable variant, so the assignment is sound.\n factory.fromRemote.skippable = fromRemote as StepFactory<\n TOptions,\n TInputOptions\n >[\"fromRemote\"][\"skippable\"];\n // SAFETY: `forEachPipeline` is the same callable as `factory.forEachPipeline`;\n // it carries the skippable variant, so the assignment is sound.\n factory.forEachPipeline.skippable = forEachPipeline as StepFactory<\n TOptions,\n TInputOptions\n >[\"forEachPipeline\"][\"skippable\"];\n\n return factory;\n}\n"]}