Skip to main content

AnomalyInjector

Struct AnomalyInjector 

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

Main anomaly injection engine.

Implementations§

Source§

impl AnomalyInjector

Source

pub fn new(config: AnomalyInjectorConfig) -> Self

Creates a new anomaly injector.

Source

pub fn process_entries( &mut self, entries: &mut [JournalEntry], ) -> InjectionBatchResult

Processes a batch of journal entries, potentially injecting anomalies.

Source

pub fn inject_specific( &mut self, entry: &mut JournalEntry, anomaly_type: AnomalyType, ) -> Option<LabeledAnomaly>

Injects a specific anomaly type into an entry.

Source

pub fn create_self_approval( &mut self, entry: &mut JournalEntry, user_id: &str, ) -> Option<LabeledAnomaly>

Creates a self-approval anomaly.

Source

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.

Source

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.

Source

pub fn get_labels(&self) -> &[LabeledAnomaly]

Returns all generated labels.

Source

pub fn get_summary(&self) -> AnomalySummary

Returns the anomaly summary.

Source

pub fn get_stats(&self) -> &InjectorStats

Returns injection statistics.

Source

pub fn reset(&mut self)

Clears all labels and resets statistics.

Source

pub fn cluster_count(&self) -> usize

Returns the number of clusters created.

Source

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.

Source

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.

Source

pub fn get_near_miss_labels(&self) -> &[NearMissLabel]

Returns all near-miss labels generated.

Source

pub fn get_scheme_actions(&self) -> &[SchemeAction]

Returns all scheme actions generated.

Source

pub fn get_difficulty_distribution( &self, ) -> &HashMap<AnomalyDetectionDifficulty, usize>

Returns the detection difficulty distribution.

Source

pub fn check_behavioral_deviations( &self, entity_id: &str, observation: &Observation, ) -> Vec<BehavioralDeviation>

Checks for behavioral deviations for an entity with an observation.

Source

pub fn get_entity_baseline(&self, entity_id: &str) -> Option<&EntityBaseline>

Gets the baseline for an entity.

Source

pub fn active_scheme_count(&self) -> usize

Returns the number of active schemes.

Source

pub fn has_enhanced_features(&self) -> bool

Returns whether enhanced features are enabled.

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