Skip to main content

ConfidenceCalibrator

Struct ConfidenceCalibrator 

Source
pub struct ConfidenceCalibrator { /* private fields */ }
Expand description

Confidence calibrator — computes overall system confidence (0.0–1.0) from current metric values and forecast accuracy.

Confidence is used by the dispatch pipeline:

  • <0.5 → conservative mode (prefer cached results, avoid risky operations)
  • ≥0.5 → normal mode

The calibrator weights metrics by importance:

  • Error rate (30%) — high weight, directly impacts reliability
  • Coherence (20%) — cognitive stability
  • CPU load (15%) — resource headroom
  • Memory pressure (15%) — resource headroom
  • Latency (10%) — responsiveness
  • Swap/disk I/O (10%) — I/O health

Implementations§

Source§

impl ConfidenceCalibrator

Source

pub const fn new() -> Self

Create a new calibrator with default smoothing (0.2).

Source

pub const fn with_smoothing(smoothing: f32) -> Self

Create with custom smoothing factor.

Source

pub fn update(&mut self, metrics: &[(MetricKind, f32)], forecast_accuracy: f32)

Update the calibrator with current metric values and forecast accuracy.

Source

pub const fn confidence(&self) -> f32

Get the current confidence value (0.0–1.0).

Source

pub fn is_conservative(&self) -> bool

Whether the system is in conservative mode (confidence < 0.5).

Source

pub const fn state(&self) -> (f32, f32)

Current calibrator state (last_confidence, smoothing) for persistence.

Source

pub const fn restore_state(&mut self, last_confidence: f32, smoothing: f32)

Restore calibrator state from persisted values.

Trait Implementations§

Source§

impl Default for ConfidenceCalibrator

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.