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.

view source

Declarations
#

5 declarations

DagNode
#

dag.ts view source

DagNode import type {DagNode} from '@fuzdev/fuz_util/dag.js';

Minimum shape for a DAG node.

inheritance

extends: Sortable

id

type string

depends_on?

type Array<string>

DagNodeResult
#

dag.ts view source

DagNodeResult import type {DagNodeResult} from '@fuzdev/fuz_util/dag.js';

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> import type {DagOptions} from '@fuzdev/fuz_util/dag.js';

Options for running a DAG.

generics

DagOptions<T extends DagNode>
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 import type {DagResult} from '@fuzdev/fuz_util/dag.js';

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> import {run_dag} from '@fuzdev/fuz_util/dag.js';

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

generics

run_dag<T extends DagNode>
T
constraint DagNode

Depends on
#