Skip to main content

SlaTracker

Struct SlaTracker 

Source
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

Source

pub fn new() -> Self

Source

pub fn with_config(window_size: usize, deviation_threshold: f64) -> Self

Source

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).

Source

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.

Source

pub fn declared_probability(&self, node_id: &str, outcome: &str) -> Option<f64>

The most recently declared probability for (node_id, outcome), if any.

Source

pub fn total_evaluations(&self) -> usize

Trait Implementations§

Source§

impl Default for SlaTracker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.