dag.ts

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.

Declarations
#

5 declarations

view source

DagNode
#

dag.ts view source

DagNode

Minimum shape for a DAG node.

inheritance

extends:

id

type string

depends_on

type Array<string>

DagNodeResult
#

dag.ts view source

DagNodeResult

Result for a single node.

id

type string

status

type 'completed' | 'failed' | 'skipped'

error

type string

duration_ms

type number

DagOptions
#

dag.ts view source

DagOptions<T>

Options for running a DAG.

generics

T

constraint DagNode

nodes

Nodes to execute.

type Array<T>

execute

Execute a node. Throw on failure.

type (node: T) => Promise<void>

on_error

Called after a node fails. For observability — the error is already recorded.

type (node: T, error: Error) => Promise<void>

on_skip

Called when a node is skipped (pre-skip or dependency failure).

type (node: T, reason: string) => Promise<void>

should_skip

Return true to skip a node without executing. Dependents still proceed.

type (node: T) => boolean

max_concurrency

Maximum concurrent executions. Default: Infinity.

type number

stop_on_failure

Stop starting new nodes on first failure. Default: true.

type boolean

skip_validation

Skip internal graph validation (caller already validated).

type boolean

DagResult
#

dag.ts view source

DagResult

Result of a DAG execution.

success

Whether all executed nodes succeeded.

type boolean

results

Per-node results.

type Map<string, DagNodeResult>

completed

Number of nodes that completed successfully.

type number

failed

Number of nodes that failed.

type number

skipped

Number of nodes that were skipped.

type number

duration_ms

Total execution time in milliseconds.

type number

error

Error message if any nodes failed.

type string

run_dag
#

dag.ts view source

<T extends DagNode>(options: DagOptions<T>): Promise<DagResult>

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.

options

DAG execution options.

type DagOptions<T>

returns

Promise<DagResult>

Aggregated result with per-node details.

Depends on
#