pub struct HomeostaticLoop { /* private fields */ }Expand description
The Homeostatic Loop — graduated self-regulation based on harmony state.
Runs a sample cycle that reads the HarmonyVector and optional
AnomalyDetector alerts, evaluates thresholds, and produces
HomeostaticActions. Actions can be advisory (Observe/Advise) or
active (Correct/Intervene).
§Example
use wm_substrate::{HarmonyVector, SubstrateMonitor};
use wm_substrate::anomaly::{AnomalyDetector, AnomalyConfig};
use wm_substrate::homeostatic::{HomeostaticLoop, HomeostaticConfig};
let mut loop_ = HomeostaticLoop::new(HomeostaticConfig::default());
let mut monitor = SubstrateMonitor::new(100);
let mut detector = AnomalyDetector::new(AnomalyConfig::default());
let hv = monitor.sample();
detector.check(&hv);
let actions = loop_.sample_cycle(&hv, &detector);
for action in &actions {
println!("{:?}: {}", action.level, action.description);
}Implementations§
Source§impl HomeostaticLoop
impl HomeostaticLoop
Sourcepub fn new(config: HomeostaticConfig) -> Self
pub fn new(config: HomeostaticConfig) -> Self
Create a new homeostatic loop with the given configuration.
Sourcepub fn sample_cycle(
&mut self,
hv: &HarmonyVector,
detector: &AnomalyDetector,
) -> Vec<HomeostaticAction>
pub fn sample_cycle( &mut self, hv: &HarmonyVector, detector: &AnomalyDetector, ) -> Vec<HomeostaticAction>
Run a sample cycle — evaluates the harmony vector and anomaly alerts, returns the list of actions taken.
Sourcepub fn history(&self, limit: usize) -> Vec<&HomeostaticAction>
pub fn history(&self, limit: usize) -> Vec<&HomeostaticAction>
Get the action history (newest first, up to limit).
Sourcepub const fn total_actions(&self) -> u64
pub const fn total_actions(&self) -> u64
Total actions taken.
Sourcepub const fn actions_at_level(&self, level: ActionLevel) -> u64
pub const fn actions_at_level(&self, level: ActionLevel) -> u64
Actions at a specific level.
Trait Implementations§
Source§impl Debug for HomeostaticLoop
impl Debug for HomeostaticLoop
Auto Trait Implementations§
impl Freeze for HomeostaticLoop
impl RefUnwindSafe for HomeostaticLoop
impl Send for HomeostaticLoop
impl Sync for HomeostaticLoop
impl Unpin for HomeostaticLoop
impl UnsafeUnpin for HomeostaticLoop
impl UnwindSafe for HomeostaticLoop
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