/** * PipelineEngine — high-level pipeline orchestration facade. * * Provides a simplified API for pipeline lifecycle management: * createPipeline → advance → getStatus / listPipelines * * Composes the low-level PipelineEngine (src/pipeline/), GateEngine (src/gate/), * and an internal EventLedger for audit trail. * * Pipeline-level state machine: * created → running → completed | failed | blocked * * (arc42 §5.1, §5.2) */ import type { TaskLevel, StageId, StageResult, StageTransition, RuleVerdict } from '../types/index.js'; import { GateEngine } from '../gate/gate-engine.js'; import { EventLedger, type LedgerEvent } from './ledger.js'; export type PipelineLifecycle = 'created' | 'running' | 'completed' | 'failed' | 'blocked' | 'paused' | 'cancelled'; export interface PipelineSummary { pipelineId: string; slug: string; description: string; level: TaskLevel; lifecycle: PipelineLifecycle; currentStage: StageId | null; stages: StageId[]; createdAt: string; updatedAt: string; } export interface AdvanceResult { transition: StageTransition | null; lifecycle: PipelineLifecycle; gateVerdict?: RuleVerdict; events: readonly LedgerEvent[]; } export interface PipelineEngineOptions { /** Custom GateEngine instance. If omitted, a default empty GateEngine is used. */ gateEngine?: GateEngine; /** Custom EventLedger instance. If omitted, a new one is created. */ ledger?: EventLedger; } export declare class PipelineEngineFacade { private readonly pipelines; private readonly gateEngine; private readonly ledger; constructor(options?: PipelineEngineOptions); /** * Create a new pipeline for a project. * * Routes the task based on level, initializes the stage queue, * and sets lifecycle to 'created'. */ createPipeline(slug: string, description: string, level: TaskLevel): PipelineSummary; /** * Advance a pipeline to the next stage. * * If lifecycle is 'created', transitions to 'running' and activates the first stage. * If lifecycle is 'running', evaluates the current stage's gate and advances if passed. * Returns the transition result and updated lifecycle. */ advance(pipelineId: string): AdvanceResult; /** Get the current status of a pipeline. */ getStatus(pipelineId: string): PipelineSummary; /** List all pipelines. */ listPipelines(): PipelineSummary[]; /** Get the underlying GateEngine (for rule registration). */ getGateEngine(): GateEngine; /** Get the event ledger (for audit queries). */ getLedger(): EventLedger; /** * Pause a running pipeline. * Transitions lifecycle: running → paused. * Throws if pipeline is not in 'running' state. */ pause(pipelineId: string): PipelineSummary; /** * Resume a paused pipeline. * Transitions lifecycle: paused → running. * Throws if pipeline is not in 'paused' state. */ resume(pipelineId: string): PipelineSummary; /** * Cancel a pipeline from any non-terminal state. * Transitions lifecycle: * → cancelled (except completed/failed/cancelled). * Throws if pipeline is already in a terminal state. */ cancel(pipelineId: string): PipelineSummary; /** * Recover interrupted pipelines. * Scans all pipelines with lifecycle 'running' and checks if their * current active stage has been running without update for too long. * Returns the list of pipeline IDs that were found interrupted. */ recoverInterrupted(staleThresholdMs?: number): string[]; /** * Complete a stage with a result, then auto-advance. * This is the primary API for driving the pipeline forward from external events. */ completeStage(pipelineId: string, stageResult: StageResult): AdvanceResult; private getRecord; private activateFirst; private advanceRunning; private activateStage; private findNextPending; private appendArtifacts; private levelToScope; private toSummary; } //# sourceMappingURL=pipeline-engine.d.ts.map