busbar_sf_agentscript/graph/edges.rs
1//! Edge types for the reference graph.
2
3use serde::{Deserialize, Serialize};
4
5/// An edge in the reference graph representing a relationship between nodes.
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7pub enum RefEdge {
8 /// StartAgent routes to a topic
9 Routes,
10
11 /// Topic transitions to another topic (via `transition_to`)
12 TransitionsTo,
13
14 /// Topic delegates to another topic (via `topic_delegate`)
15 Delegates,
16
17 /// Reasoning action invokes an action definition
18 Invokes,
19
20 /// Action reads a variable (via `with` clause or condition)
21 Reads,
22
23 /// Action writes to a variable (via `set` clause)
24 Writes,
25
26 /// Action chains to another action (via `run` clause)
27 Chains,
28
29 /// Escalation routes to a connection
30 Escalates,
31}
32
33impl RefEdge {
34 /// Get a human-readable label for this edge type.
35 pub fn label(&self) -> &'static str {
36 match self {
37 RefEdge::Routes => "routes",
38 RefEdge::TransitionsTo => "transitions_to",
39 RefEdge::Delegates => "delegates",
40 RefEdge::Invokes => "invokes",
41 RefEdge::Reads => "reads",
42 RefEdge::Writes => "writes",
43 RefEdge::Chains => "chains",
44 RefEdge::Escalates => "escalates",
45 }
46 }
47
48 /// Check if this is a control flow edge (affects execution path).
49 pub fn is_control_flow(&self) -> bool {
50 matches!(
51 self,
52 RefEdge::Routes
53 | RefEdge::TransitionsTo
54 | RefEdge::Delegates
55 | RefEdge::Invokes
56 | RefEdge::Chains
57 | RefEdge::Escalates
58 )
59 }
60
61 /// Check if this is a data flow edge (affects data).
62 pub fn is_data_flow(&self) -> bool {
63 matches!(self, RefEdge::Reads | RefEdge::Writes)
64 }
65}