pub struct BoundedWorkGraph { /* private fields */ }Expand description
Bounded, acyclic work graph with enforced fan-out and budget constraints.
Implementations§
Source§impl BoundedWorkGraph
impl BoundedWorkGraph
pub fn new(max_fan_out: usize, max_depth: u16) -> Self
Sourcepub fn add_root(
&mut self,
node_id: String,
agent_id: String,
capsule_ref: String,
budget: WorkNodeBudget,
) -> Result<&WorkNode, WorkGraphError>
pub fn add_root( &mut self, node_id: String, agent_id: String, capsule_ref: String, budget: WorkNodeBudget, ) -> Result<&WorkNode, WorkGraphError>
Add a root node (no parent).
Sourcepub fn delegate(
&mut self,
parent_node_id: &str,
child_node_id: String,
child_agent_id: String,
capsule_ref: String,
child_budget: WorkNodeBudget,
) -> Result<&WorkNode, WorkGraphError>
pub fn delegate( &mut self, parent_node_id: &str, child_node_id: String, child_agent_id: String, capsule_ref: String, child_budget: WorkNodeBudget, ) -> Result<&WorkNode, WorkGraphError>
Delegate work to a child node. Validates budget inheritance and fan-out.
Sourcepub fn allocate_child_budget(
&mut self,
parent_id: &str,
child_id: &str,
fraction: f64,
) -> Result<WorkNodeBudget, WorkGraphError>
pub fn allocate_child_budget( &mut self, parent_id: &str, child_id: &str, fraction: f64, ) -> Result<WorkNodeBudget, WorkGraphError>
Allocates budget for a child node using cascade rules.
The returned budget is reserved for child_id until it is passed to
Self::delegate, so chain allocation is not counted twice.
Sourcepub fn complete(
&mut self,
node_id: &str,
outcome_ref: String,
) -> Result<(), WorkGraphError>
pub fn complete( &mut self, node_id: &str, outcome_ref: String, ) -> Result<(), WorkGraphError>
Mark a node as completed with an outcome reference.
Sourcepub fn stop(
&mut self,
node_id: &str,
reason: StopReason,
) -> Result<Vec<String>, WorkGraphError>
pub fn stop( &mut self, node_id: &str, reason: StopReason, ) -> Result<Vec<String>, WorkGraphError>
Stop a node and all its descendants (cascade).
Sourcepub fn consume_budget(
&mut self,
node_id: &str,
tokens: u64,
cost_micros: u64,
) -> Result<bool, WorkGraphError>
pub fn consume_budget( &mut self, node_id: &str, tokens: u64, cost_micros: u64, ) -> Result<bool, WorkGraphError>
Record token consumption on a node.
Sourcepub fn consume_tokens(
&mut self,
node_id: &str,
tokens: u64,
) -> Result<(), WorkGraphError>
pub fn consume_tokens( &mut self, node_id: &str, tokens: u64, ) -> Result<(), WorkGraphError>
Records token consumption for a node and updates its chain budget.
Sourcepub fn chain_budget_for(&self, node_id: &str) -> Option<&ChainBudget>
pub fn chain_budget_for(&self, node_id: &str) -> Option<&ChainBudget>
Returns the chain budget for a given node’s chain.
Sourcepub fn over_budget_chains(&self, threshold_pct: f64) -> Vec<&ChainBudget>
pub fn over_budget_chains(&self, threshold_pct: f64) -> Vec<&ChainBudget>
Returns all chains at or above their utilization threshold.
Sourcepub fn enforce_stop_conditions(&mut self) -> Vec<(String, StopReason)>
pub fn enforce_stop_conditions(&mut self) -> Vec<(String, StopReason)>
Check all nodes for stop conditions and cascade.
pub fn get_node(&self, node_id: &str) -> Option<&WorkNode>
pub fn children_of(&self, node_id: &str) -> &[String]
pub fn active_count(&self) -> usize
pub fn total_count(&self) -> usize
Trait Implementations§
Source§impl Clone for BoundedWorkGraph
impl Clone for BoundedWorkGraph
Source§fn clone(&self) -> BoundedWorkGraph
fn clone(&self) -> BoundedWorkGraph
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoundedWorkGraph
impl Debug for BoundedWorkGraph
Source§impl Default for BoundedWorkGraph
impl Default for BoundedWorkGraph
Source§impl<'de> Deserialize<'de> for BoundedWorkGraph
impl<'de> Deserialize<'de> for BoundedWorkGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BoundedWorkGraph
impl RefUnwindSafe for BoundedWorkGraph
impl Send for BoundedWorkGraph
impl Sync for BoundedWorkGraph
impl Unpin for BoundedWorkGraph
impl UnsafeUnpin for BoundedWorkGraph
impl UnwindSafe for BoundedWorkGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more