pub struct SlaTracker { /* private fields */ }Expand description
Tracks observed outcome frequencies per node against the declared probabilities, and reports SLA anomalies when the divergence exceeds a threshold (ETDL §9.3).
The observed frequency of an outcome is the fraction of the node’s
evaluations in the rolling window that produced that outcome. This gives a
meaningful comparison against the declared probability: if a branch declares
SUCCESS = 0.95 but only 60% of evaluations actually succeed, the deviation
exceeds the threshold and an anomaly is reported.
Implementations§
Source§impl SlaTracker
impl SlaTracker
pub fn new() -> Self
pub fn with_config(window_size: usize, deviation_threshold: f64) -> Self
Sourcepub fn record(
&mut self,
node_id: &str,
outcome: &str,
declared_probability: f64,
occurred: bool,
) -> bool
pub fn record( &mut self, node_id: &str, outcome: &str, declared_probability: f64, occurred: bool, ) -> bool
Record one evaluation of node_id.
occurred is true when outcome was actually observed (the branch was
taken / the failure happened); false otherwise. The declared probability
for the outcome is remembered (the most recent value wins).
Returns true when the observed frequency for outcome deviates from
the declared probability by more than the threshold (with enough
observations to be meaningful).
Sourcepub fn observed_frequency(&self, node_id: &str, outcome: &str) -> f64
pub fn observed_frequency(&self, node_id: &str, outcome: &str) -> f64
The fraction of the node’s rolling window evaluations that produced
outcome. Returns 0.0 when there are no observations yet.
Sourcepub fn declared_probability(&self, node_id: &str, outcome: &str) -> Option<f64>
pub fn declared_probability(&self, node_id: &str, outcome: &str) -> Option<f64>
The most recently declared probability for (node_id, outcome), if any.