/** * Generic concurrent DAG executor. * * Executes nodes in a dependency graph with configurable concurrency, * failure handling, and skip semantics. Nodes without dependency edges * run in parallel (up to max_concurrency). Dependencies are respected * via per-node deferreds. * * @module */ import { type Sortable } from './sort.js'; /** * Minimum shape for a DAG node. */ export interface DagNode extends Sortable { id: string; depends_on?: Array; } /** * Options for running a DAG. */ export interface DagOptions { /** Nodes to execute. */ nodes: Array; /** Execute a node. Throw on failure. */ execute: (node: T) => Promise; /** Called after a node fails. For observability — the error is already recorded. */ on_error?: (node: T, error: Error) => Promise; /** Called when a node is skipped (pre-skip or dependency failure). */ on_skip?: (node: T, reason: string) => Promise; /** Return true to skip a node without executing. Dependents still proceed. */ should_skip?: (node: T) => boolean; /** Maximum concurrent executions. Default: Infinity. */ max_concurrency?: number; /** Stop starting new nodes on first failure. Default: true. */ stop_on_failure?: boolean; /** Skip internal graph validation (caller already validated). */ skip_validation?: boolean; } /** * Result for a single node. */ export interface DagNodeResult { id: string; status: 'completed' | 'failed' | 'skipped'; error?: string; duration_ms: number; } /** * Result of a DAG execution. */ export interface DagResult { /** Whether all executed nodes succeeded. */ success: boolean; /** Per-node results. */ results: Map; /** Number of nodes that completed successfully. */ completed: number; /** Number of nodes that failed. */ failed: number; /** Number of nodes that were skipped. */ skipped: number; /** Total execution time in milliseconds. */ duration_ms: number; /** Error message if any nodes failed. */ error?: string; } /** * Execute nodes in a dependency graph concurrently. * * Independent nodes (no unmet dependencies) run in parallel up to * `max_concurrency`. When a node completes, its dependents become * eligible to start. Failure cascading and stop-on-failure are handled * per the options. * * @param options - DAG execution options * @returns aggregated result with per-node details */ export declare const run_dag: (options: DagOptions) => Promise; //# sourceMappingURL=dag.d.ts.map