pub struct AnomalyInjector { /* private fields */ }Expand description
Main anomaly injection engine.
Implementations§
Source§impl AnomalyInjector
impl AnomalyInjector
Sourcepub fn new(config: AnomalyInjectorConfig) -> Self
pub fn new(config: AnomalyInjectorConfig) -> Self
Creates a new anomaly injector.
Sourcepub fn process_entries(
&mut self,
entries: &mut [JournalEntry],
) -> InjectionBatchResult
pub fn process_entries( &mut self, entries: &mut [JournalEntry], ) -> InjectionBatchResult
Processes a batch of journal entries, potentially injecting anomalies.
Sourcepub fn inject_specific(
&mut self,
entry: &mut JournalEntry,
anomaly_type: AnomalyType,
) -> Option<LabeledAnomaly>
pub fn inject_specific( &mut self, entry: &mut JournalEntry, anomaly_type: AnomalyType, ) -> Option<LabeledAnomaly>
Injects a specific anomaly type into an entry.
Sourcepub fn create_self_approval(
&mut self,
entry: &mut JournalEntry,
user_id: &str,
) -> Option<LabeledAnomaly>
pub fn create_self_approval( &mut self, entry: &mut JournalEntry, user_id: &str, ) -> Option<LabeledAnomaly>
Creates a self-approval anomaly.
Sourcepub fn create_sod_violation(
&mut self,
entry: &mut JournalEntry,
user_id: &str,
conflicting_duties: (&str, &str),
) -> Option<LabeledAnomaly>
pub fn create_sod_violation( &mut self, entry: &mut JournalEntry, user_id: &str, conflicting_duties: (&str, &str), ) -> Option<LabeledAnomaly>
Creates a segregation of duties violation.
Sourcepub fn create_ic_mismatch(
&mut self,
entry: &mut JournalEntry,
matching_company: &str,
expected_amount: Decimal,
actual_amount: Decimal,
) -> Option<LabeledAnomaly>
pub fn create_ic_mismatch( &mut self, entry: &mut JournalEntry, matching_company: &str, expected_amount: Decimal, actual_amount: Decimal, ) -> Option<LabeledAnomaly>
Creates an intercompany mismatch anomaly.
Sourcepub fn get_labels(&self) -> &[LabeledAnomaly]
pub fn get_labels(&self) -> &[LabeledAnomaly]
Returns all generated labels.
Sourcepub fn get_summary(&self) -> AnomalySummary
pub fn get_summary(&self) -> AnomalySummary
Returns the anomaly summary.
Sourcepub fn get_stats(&self) -> &InjectorStats
pub fn get_stats(&self) -> &InjectorStats
Returns injection statistics.
Sourcepub fn cluster_count(&self) -> usize
pub fn cluster_count(&self) -> usize
Returns the number of clusters created.
Sourcepub fn advance_schemes(
&mut self,
date: NaiveDate,
company_code: &str,
) -> Vec<SchemeAction>
pub fn advance_schemes( &mut self, date: NaiveDate, company_code: &str, ) -> Vec<SchemeAction>
Advances all active fraud schemes by one time step.
Call this method once per simulated day to generate scheme actions. Returns the scheme actions generated for this date.
Sourcepub fn maybe_start_scheme(
&mut self,
date: NaiveDate,
company_code: &str,
available_users: Vec<String>,
available_accounts: Vec<String>,
available_counterparties: Vec<String>,
) -> Option<Uuid>
pub fn maybe_start_scheme( &mut self, date: NaiveDate, company_code: &str, available_users: Vec<String>, available_accounts: Vec<String>, available_counterparties: Vec<String>, ) -> Option<Uuid>
Potentially starts a new fraud scheme based on probabilities.
Call this method periodically (e.g., once per period) to allow new schemes to start based on configured probabilities. Returns the scheme ID if a scheme was started.
Sourcepub fn get_near_miss_labels(&self) -> &[NearMissLabel]
pub fn get_near_miss_labels(&self) -> &[NearMissLabel]
Returns all near-miss labels generated.
Sourcepub fn get_scheme_actions(&self) -> &[SchemeAction]
pub fn get_scheme_actions(&self) -> &[SchemeAction]
Returns all scheme actions generated.
Sourcepub fn get_difficulty_distribution(
&self,
) -> &HashMap<AnomalyDetectionDifficulty, usize>
pub fn get_difficulty_distribution( &self, ) -> &HashMap<AnomalyDetectionDifficulty, usize>
Returns the detection difficulty distribution.
Sourcepub fn check_behavioral_deviations(
&self,
entity_id: &str,
observation: &Observation,
) -> Vec<BehavioralDeviation>
pub fn check_behavioral_deviations( &self, entity_id: &str, observation: &Observation, ) -> Vec<BehavioralDeviation>
Checks for behavioral deviations for an entity with an observation.
Sourcepub fn get_entity_baseline(&self, entity_id: &str) -> Option<&EntityBaseline>
pub fn get_entity_baseline(&self, entity_id: &str) -> Option<&EntityBaseline>
Gets the baseline for an entity.
Sourcepub fn active_scheme_count(&self) -> usize
pub fn active_scheme_count(&self) -> usize
Returns the number of active schemes.
Sourcepub fn has_enhanced_features(&self) -> bool
pub fn has_enhanced_features(&self) -> bool
Returns whether enhanced features are enabled.