pub struct RouteGraph { /* private fields */ }Expand description
The route map, indexed for traversal.
Implementations§
Source§impl RouteGraph
impl RouteGraph
Sourcepub fn from_config(config: &Config) -> Self
pub fn from_config(config: &Config) -> Self
Builds a graph from a factory definition.
Routes that name several senders and several receivers expand to the full cross product,
which is what makes from = ["a", "b"] with to = "c" a rendezvous and from = "a" with
to = ["b", "c"] a fan-out.
Sourcepub fn is_spawn(&self, from: &AgentName, to: &AgentName) -> bool
pub fn is_spawn(&self, from: &AgentName, to: &AgentName) -> bool
Returns true when this edge opens a new itinerary rather than continuing one.
Sourcepub fn permits(&self, from: &AgentName, to: &AgentName) -> bool
pub fn permits(&self, from: &AgentName, to: &AgentName) -> bool
Returns true if from is permitted to send to to.
Sourcepub fn successors(&self, from: &AgentName) -> impl Iterator<Item = &AgentName>
pub fn successors(&self, from: &AgentName) -> impl Iterator<Item = &AgentName>
Returns the agents from may send to.
Sourcepub fn spawn_targets(&self) -> impl Iterator<Item = &AgentName>
pub fn spawn_targets(&self) -> impl Iterator<Item = &AgentName>
Every agent reached by a spawn edge.
These begin chains of their own, so for any question about hop depth they are entry points rather than destinations.
Sourcepub fn workflow_from(&self, entry: &AgentName) -> BTreeSet<AgentName>
pub fn workflow_from(&self, entry: &AgentName) -> BTreeSet<AgentName>
Every agent belonging to the workflow that starts at entry.
Unlike RouteGraph::reachable_from this does cross spawn edges. The two questions
are different: reachability asks what could still deliver into this itinerary, and a
spawned chain never can. Workflow membership asks what this way in sets in motion, and a
reviewer spawned by a sweep is unarguably part of the sweep.
Agents shared between workflows appear in both, which is the honest answer — the developer really is in the triage pipeline and the follow-up pipeline.
Sourcepub fn spawn_edges(&self) -> impl Iterator<Item = (&AgentName, &AgentName)>
pub fn spawn_edges(&self) -> impl Iterator<Item = (&AgentName, &AgentName)>
Every spawn edge, as a sender/receiver pair.
Sourcepub fn join_for(&self, agent: &AgentName) -> Option<&JoinSpec>
pub fn join_for(&self, agent: &AgentName) -> Option<&JoinSpec>
Returns the rendezvous condition guarding agent, if any.
Sourcepub fn reachable_from<'a>(
&self,
sources: impl IntoIterator<Item = &'a AgentName>,
) -> BTreeSet<AgentName>
pub fn reachable_from<'a>( &self, sources: impl IntoIterator<Item = &'a AgentName>, ) -> BTreeSet<AgentName>
Returns every agent reachable from sources, including the sources themselves.
Hops are deliberately ignored, which makes the answer conservative: an agent that Hops
would actually prevent from being reached is still reported as reachable. A barrier is
therefore never abandoned prematurely, and timeout_sec remains the backstop.
Sourcepub fn distances_from<'a>(
&self,
sources: impl IntoIterator<Item = &'a AgentName>,
) -> BTreeMap<AgentName, u32>
pub fn distances_from<'a>( &self, sources: impl IntoIterator<Item = &'a AgentName>, ) -> BTreeMap<AgentName, u32>
Returns every agent reachable from sources, each with its distance in edges.
The sources sit at distance zero. An agent at distance d is therefore woken by flight
d + 1 of a chain that began at a source, which is what makes the figure directly
comparable against max_hops — see crate::validate.
Shortest paths are an optimistic bound. A factory whose agents loop will spend far more hops than the distance suggests, so this proves an agent can be reached, never that a particular itinerary will get there.