Skip to main content

FprMonitor

Struct FprMonitor 

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

Rolling-window FPR monitor with per-category drift detection.

Implementations§

Source§

impl FprMonitor

Source

pub fn new(config: FprMonitorConfig) -> Self

Create a new monitor with the given configuration.

Pre-initialises empty windows for each configured category.

Source

pub fn record_event( &mut self, category: &str, was_flagged: bool, confidence: f64, )

Record a detection event for the given category.

If the category was not in the initial config, it is created on the fly.

Source

pub fn record_event_at( &mut self, category: &str, at: Instant, was_flagged: bool, confidence: f64, )

Record a detection event with an explicit timestamp (useful for testing).

Source

pub fn current_fpr(&mut self, category: &str) -> Option<f64>

Compute the current FPR for a category within the sliding window.

Returns None if the category has no recorded events.

Source

pub fn check_drift( &mut self, category: &str, baseline_fpr: f64, ) -> Option<FprDriftAlert>

Check whether the current FPR for category has drifted from baseline_fpr.

Returns Some(alert) when the absolute deviation exceeds the configured threshold and the window contains at least min_window_samples events. Returns None otherwise.

Source

pub fn check_all_drift( &mut self, baselines: &HashMap<String, f64>, ) -> Vec<FprDriftAlert>

Check drift across all categories against the provided baselines.

Source

pub fn to_security_findings(alerts: &[FprDriftAlert]) -> Vec<SecurityFinding>

Convert a slice of drift alerts into SecurityFindings.

Source

pub fn summary(&mut self) -> FprMonitorSummary

Produce a summary of all tracked categories.

Trait Implementations§

Source§

impl Debug for FprMonitor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V