pub struct NodeBudget {
pub layer1_max: usize,
pub layer2_max: usize,
pub layer3_max: usize,
pub layer1_count: usize,
pub layer2_count: usize,
pub layer3_count: usize,
}Expand description
Per-layer node budget allocation and tracking.
Fields§
§layer1_max: usizeMaximum nodes allowed for Layer 1 (Governance).
layer2_max: usizeMaximum nodes allowed for Layer 2 (Process).
layer3_max: usizeMaximum nodes allowed for Layer 3 (Accounting).
layer1_count: usizeCurrent count for Layer 1.
layer2_count: usizeCurrent count for Layer 2.
layer3_count: usizeCurrent count for Layer 3.
Implementations§
Source§impl NodeBudget
impl NodeBudget
Sourcepub fn new(max_nodes: usize) -> Self
pub fn new(max_nodes: usize) -> Self
Create a budget with the given total max nodes. Default allocation: L1 gets 20%, L3 gets 10%, L2 gets remainder (70%).
Sourcepub fn can_add(&self, layer: HypergraphLayer) -> bool
pub fn can_add(&self, layer: HypergraphLayer) -> bool
Check if a layer can accept more nodes.
Sourcepub fn record_add(&mut self, layer: HypergraphLayer)
pub fn record_add(&mut self, layer: HypergraphLayer)
Record a node addition.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total nodes across all layers.
Sourcepub fn suggest(
&self,
l1_demand: usize,
l2_demand: usize,
l3_demand: usize,
) -> NodeBudgetSuggestion
pub fn suggest( &self, l1_demand: usize, l2_demand: usize, l3_demand: usize, ) -> NodeBudgetSuggestion
Compute a suggested budget allocation based on actual demand per layer.
Each layer gets at least its demand (up to its current max). Surplus from layers that need less than their max is redistributed proportionally to layers that need more than their max.
Sourcepub fn rebalance(
&mut self,
l1_demand: usize,
l2_demand: usize,
l3_demand: usize,
)
pub fn rebalance( &mut self, l1_demand: usize, l2_demand: usize, l3_demand: usize, )
Rebalance the budget based on actual demand per layer.
Each layer gets at least its demand (capped at the total budget). Surplus from low-demand layers is redistributed proportionally to layers with unsatisfied demand. If no layer has unsatisfied demand, surplus goes to L2 (the largest consumer by convention).
Trait Implementations§
Source§impl Clone for NodeBudget
impl Clone for NodeBudget
Source§fn clone(&self) -> NodeBudget
fn clone(&self) -> NodeBudget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more