pub struct FprMonitor { /* private fields */ }Expand description
Rolling-window FPR monitor with per-category drift detection.
Implementations§
Source§impl FprMonitor
impl FprMonitor
Sourcepub fn new(config: FprMonitorConfig) -> Self
pub fn new(config: FprMonitorConfig) -> Self
Create a new monitor with the given configuration.
Pre-initialises empty windows for each configured category.
Sourcepub fn record_event(
&mut self,
category: &str,
was_flagged: bool,
confidence: f64,
)
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.
Sourcepub fn record_event_at(
&mut self,
category: &str,
at: Instant,
was_flagged: bool,
confidence: f64,
)
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).
Sourcepub fn current_fpr(&mut self, category: &str) -> Option<f64>
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.
Sourcepub fn check_drift(
&mut self,
category: &str,
baseline_fpr: f64,
) -> Option<FprDriftAlert>
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.
Sourcepub fn check_all_drift(
&mut self,
baselines: &HashMap<String, f64>,
) -> Vec<FprDriftAlert>
pub fn check_all_drift( &mut self, baselines: &HashMap<String, f64>, ) -> Vec<FprDriftAlert>
Check drift across all categories against the provided baselines.
Sourcepub fn to_security_findings(alerts: &[FprDriftAlert]) -> Vec<SecurityFinding>
pub fn to_security_findings(alerts: &[FprDriftAlert]) -> Vec<SecurityFinding>
Convert a slice of drift alerts into SecurityFindings.
Sourcepub fn summary(&mut self) -> FprMonitorSummary
pub fn summary(&mut self) -> FprMonitorSummary
Produce a summary of all tracked categories.