Skip to main content

ConfidenceController

Struct ConfidenceController 

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

Continuous confidence controller for genes and capsules.

Tracks per-asset success / failure outcomes within a rolling time window. When the failure rate exceeds the configured threshold and the minimum sample count is met, the asset’s confidence score is automatically downgraded and a DowngradeEvent is appended to an internal observability log. Successive successes can recover confidence.

§Selector integration

Call is_selectable before choosing a gene/capsule for reuse. Assets below ControllerConfig::min_selectable_confidence return false and should be skipped until they have been re-validated.

Implementations§

Source§

impl ConfidenceController

Source

pub fn new(config: ControllerConfig) -> Self

Create a new controller with the given configuration.

Source

pub fn with_default_config() -> Self

Create a controller using ControllerConfig::default.

Source

pub fn confidence(&self, asset_id: &str) -> f32

Current confidence score for asset_id. Returns ControllerConfig::initial_confidence for unknown assets.

Source

pub fn is_selectable(&self, asset_id: &str) -> bool

Returns true when the asset’s confidence is at or above ControllerConfig::min_selectable_confidence.

Source

pub fn record_success(&mut self, asset_id: &str, now_ms: i64)

Record a successful outcome for asset_id at now_ms.

Applies a recovery boost (capped at initial_confidence).

Source

pub fn record_failure(&mut self, asset_id: &str, now_ms: i64)

Record a failure outcome for asset_id at now_ms.

Immediately evaluates the rolling-window failure rate and downgrades confidence if the threshold is exceeded.

Source

pub fn run_downgrade_check(&mut self, now_ms: i64) -> Vec<DowngradeEvent>

Sweep all tracked assets and apply downgrade logic at now_ms.

Returns every DowngradeEvent generated in this sweep (also appended to the internal log).

Source

pub fn downgrade_log(&self) -> &[DowngradeEvent]

Full observability log of every downgrade event since construction.

Source

pub fn assets_requiring_revalidation(&self) -> Vec<String>

Asset IDs whose confidence has fallen below ControllerConfig::min_selectable_confidence and therefore require re-validation before they can be reused.

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> Same for T

Source§

type Output = T

Should always be Self
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.