Skip to main content

WorkflowDag

Struct WorkflowDag 

Source
pub struct WorkflowDag {
    pub name: String,
    pub nodes: BTreeMap<String, DagNode>,
    pub levels: Vec<Vec<String>>,
    pub roots: Vec<String>,
    pub leaves: Vec<String>,
}
Expand description

The workflow DAG — compiled from WorkflowConfig.

Contains the full dependency graph and supports:

  • Topological ordering
  • Parallel level grouping
  • Dependency queries
  • Root/leaf detection

Fields§

§name: String

The workflow name.

§nodes: BTreeMap<String, DagNode>

All nodes in the DAG, keyed by step ID.

BTreeMap (not HashMap) is intentional: it makes iteration order deterministic across runs, so roots/leaves/levels are stable — important for reproducible workflow compilation and snapshot tests.

§levels: Vec<Vec<String>>

The execution levels (parallel groups). Level 0 contains root nodes (no dependencies), Level 1 contains nodes that depend only on Level 0, etc.

§roots: Vec<String>

Root node IDs (no dependencies).

§leaves: Vec<String>

Leaf node IDs (no children).

Implementations§

Source§

impl WorkflowDag

Source

pub fn new(name: impl Into<String>) -> Self

Create an empty DAG.

Source

pub fn add_node(&mut self, node: DagNode)

Add a node to the DAG.

Source

pub fn build(&mut self)

Build the dependency edges and compute levels.

After all nodes are added, call this to:

  1. Resolve depends_on → set children on parent nodes
  2. Compute parallel levels via BFS
  3. Identify root and leaf nodes
Source

pub fn get_node(&self, id: &str) -> Option<&DagNode>

Get a node by ID.

Source

pub fn node_count(&self) -> usize

Get the number of nodes.

Source

pub fn level_count(&self) -> usize

Get the number of levels (parallel groups).

Source

pub fn level_nodes(&self, level: usize) -> Vec<&DagNode>

Get nodes at a specific level.

Source

pub fn topological_order(&self) -> Vec<String>

Get all node IDs in topological order (level 0 → level N).

Source

pub fn has_cycle(&self) -> bool

Check if the DAG has any cycles.

Uses Kahn’s algorithm — if after removing all nodes with no dependencies, some nodes remain, there’s a cycle.

Source

pub fn transitive_deps(&self, node_id: &str) -> HashSet<String>

Get all dependencies (transitive) of a node.

Trait Implementations§

Source§

impl Clone for WorkflowDag

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowDag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WorkflowDag

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WorkflowDag

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WorkflowDag

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WorkflowDag

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more