Skip to main content

DependencyGraph

Struct DependencyGraph 

Source
pub struct DependencyGraph { /* private fields */ }
Expand description

Directed acyclic graph tracking issue dependencies.

Edges point from dependent to dependency: if A depends on B, edges[A] contains B. The graph enforces acyclicity on insertion.

Implementations§

Source§

impl DependencyGraph

Source

pub fn new(session_id: &str) -> Self

Source

pub fn session_id(&self) -> &str

Source

pub fn contains(&self, issue: u32) -> bool

Source

pub fn node(&self, issue: u32) -> Option<&GraphNode>

Source

pub fn node_count(&self) -> usize

Source

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

Source

pub fn add_edge(&mut self, from: u32, to: u32) -> bool

Add a dependency edge: from depends on to.

Returns false if the edge would create a cycle (edge not added).

Source

pub fn would_create_cycle(&self, from: u32, to: u32) -> bool

Check if adding an edge from -> to would create a cycle.

A cycle exists if to transitively depends on from.

Source

pub fn ready_issues(&self) -> Vec<u32>

Issues in Pending state whose dependencies are all Merged.

Source

pub fn awaiting_merge(&self) -> Vec<u32>

Issues currently in AwaitingMerge state.

Source

pub fn transition(&mut self, issue: u32, state: NodeState)

Transition a node to a new state.

Source

pub fn set_pr_number(&mut self, issue: u32, pr_number: u32)

Set the PR number on a node.

Source

pub fn set_run_id(&mut self, issue: u32, run_id: &str)

Set the run ID on a node.

Source

pub fn dependencies(&self, issue: u32) -> HashSet<u32>

Get the set of issues that issue depends on.

Source

pub fn dependents(&self, issue: u32) -> HashSet<u32>

Get the set of issues that depend on issue.

Source

pub fn all_terminal(&self) -> bool

Whether every node is in a terminal state (Merged or Failed).

Source

pub fn is_blocked(&self, issue: u32) -> bool

Whether a node is blocked because at least one dependency has failed.

Source

pub fn propagate_failure(&mut self, issue: u32) -> Vec<u32>

Propagate failure from a node to all transitive dependents.

Any Pending or InFlight node reachable via reverse_edges from the failed node is transitioned to Failed. Returns the list of issue numbers that were newly failed (excludes the original node).

Source

pub fn remove_node(&mut self, issue: u32)

Remove a node and all its edges (for stale issue cleanup).

Source

pub fn all_issues(&self) -> Vec<u32>

All issue numbers in the graph.

Source

pub fn from_db(conn: &Connection, session_id: &str) -> Result<Self>

Load graph state from the database.

Source

pub fn save_to_db(&self, conn: &Connection) -> Result<()>

Persist the full graph state to the database, replacing any existing data for this session. Runs inside a transaction so a crash mid-save cannot leave a partial graph.

Source

pub fn from_planner_output( session_id: &str, plan: &PlannerGraphOutput, issues: &[PipelineIssue], ) -> Self

Build a graph from planner output, matching issues by number.

Source

pub fn merge_planner_output( &mut self, plan: &PlannerGraphOutput, issues: &[PipelineIssue], )

Merge new planner output into an existing graph (polling mode).

Only adds nodes not already present. Edges between new nodes and existing nodes are added if they don’t create cycles.

Source

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

Render a layered box-drawing DAG visualization for terminal output.

Source

pub fn to_graph_context(&self) -> Vec<GraphContextNode>

Build planner context from the current graph state.

Produces one GraphContextNode per node so the planner can see in-flight work and avoid scheduling conflicts.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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