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
impl DependencyGraph
pub fn new(session_id: &str) -> Self
pub fn session_id(&self) -> &str
pub fn contains(&self, issue: u32) -> bool
pub fn node(&self, issue: u32) -> Option<&GraphNode>
pub fn node_count(&self) -> usize
pub fn add_node(&mut self, node: GraphNode)
Sourcepub fn add_edge(&mut self, from: u32, to: u32) -> bool
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).
Sourcepub fn would_create_cycle(&self, from: u32, to: u32) -> bool
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.
Sourcepub fn ready_issues(&self) -> Vec<u32>
pub fn ready_issues(&self) -> Vec<u32>
Issues in Pending state whose dependencies are all Merged.
Sourcepub fn awaiting_merge(&self) -> Vec<u32>
pub fn awaiting_merge(&self) -> Vec<u32>
Issues currently in AwaitingMerge state.
Sourcepub fn transition(&mut self, issue: u32, state: NodeState)
pub fn transition(&mut self, issue: u32, state: NodeState)
Transition a node to a new state.
Sourcepub fn set_pr_number(&mut self, issue: u32, pr_number: u32)
pub fn set_pr_number(&mut self, issue: u32, pr_number: u32)
Set the PR number on a node.
Sourcepub fn set_run_id(&mut self, issue: u32, run_id: &str)
pub fn set_run_id(&mut self, issue: u32, run_id: &str)
Set the run ID on a node.
Sourcepub fn dependencies(&self, issue: u32) -> HashSet<u32>
pub fn dependencies(&self, issue: u32) -> HashSet<u32>
Get the set of issues that issue depends on.
Sourcepub fn dependents(&self, issue: u32) -> HashSet<u32>
pub fn dependents(&self, issue: u32) -> HashSet<u32>
Get the set of issues that depend on issue.
Sourcepub fn all_terminal(&self) -> bool
pub fn all_terminal(&self) -> bool
Whether every node is in a terminal state (Merged or Failed).
Sourcepub fn is_blocked(&self, issue: u32) -> bool
pub fn is_blocked(&self, issue: u32) -> bool
Whether a node is blocked because at least one dependency has failed.
Sourcepub fn propagate_failure(&mut self, issue: u32) -> Vec<u32>
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).
Sourcepub fn remove_node(&mut self, issue: u32)
pub fn remove_node(&mut self, issue: u32)
Remove a node and all its edges (for stale issue cleanup).
Sourcepub fn all_issues(&self) -> Vec<u32>
pub fn all_issues(&self) -> Vec<u32>
All issue numbers in the graph.
Sourcepub fn from_db(conn: &Connection, session_id: &str) -> Result<Self>
pub fn from_db(conn: &Connection, session_id: &str) -> Result<Self>
Load graph state from the database.
Sourcepub fn save_to_db(&self, conn: &Connection) -> Result<()>
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.
Sourcepub fn from_planner_output(
session_id: &str,
plan: &PlannerGraphOutput,
issues: &[PipelineIssue],
) -> Self
pub fn from_planner_output( session_id: &str, plan: &PlannerGraphOutput, issues: &[PipelineIssue], ) -> Self
Build a graph from planner output, matching issues by number.
Sourcepub fn merge_planner_output(
&mut self,
plan: &PlannerGraphOutput,
issues: &[PipelineIssue],
)
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.
Sourcepub fn display_layered(&self) -> Vec<String>
pub fn display_layered(&self) -> Vec<String>
Render a layered box-drawing DAG visualization for terminal output.
Sourcepub fn to_graph_context(&self) -> Vec<GraphContextNode>
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.