Skip to main content

rustkernel_compliance/
lib.rs

1//! # RustKernel Compliance
2//!
3//! GPU-accelerated compliance kernels for AML, KYC, sanctions screening, and transaction monitoring.
4//!
5//! ## Kernels
6//!
7//! ### AML (6 kernels)
8//! - `CircularFlowRatio` - SCC detection for circular transactions
9//! - `ReciprocityFlowRatio` - Mutual transaction detection
10//! - `RapidMovement` - Velocity analysis for structuring
11//! - `AMLPatternDetection` - Multi-pattern FSM detection
12//! - `FlowReversalPattern` - Transaction reversal detection (wash trading, round-tripping)
13//! - `FlowSplitRatio` - Transaction splitting/structuring detection
14//!
15//! ### KYC (2 kernels)
16//! - `KYCScoring` - Risk factor aggregation
17//! - `EntityResolution` - Fuzzy entity matching
18//!
19//! ### Sanctions (2 kernels)
20//! - `SanctionsScreening` - OFAC/UN/EU list matching
21//! - `PEPScreening` - Politically exposed persons
22//!
23//! ### Monitoring (1 kernel)
24//! - `TransactionMonitoring` - Real-time threshold alerts
25
26#![warn(missing_docs)]
27
28pub mod aml;
29pub mod kyc;
30pub mod messages;
31pub mod monitoring;
32pub mod ring_messages;
33pub mod sanctions;
34pub mod types;
35
36/// Prelude for convenient imports.
37pub mod prelude {
38    pub use crate::aml::*;
39    pub use crate::kyc::*;
40    pub use crate::messages::*;
41    pub use crate::monitoring::*;
42    pub use crate::ring_messages::*;
43    pub use crate::sanctions::*;
44    pub use crate::types::*;
45}
46
47// Re-export main types for convenience
48pub use aml::{
49    AMLPatternDetection, CircularFlowRatio, FlowReversalConfig, FlowReversalPattern,
50    FlowSplitConfig, FlowSplitRatio, RapidMovement, ReciprocityFlowRatio,
51};
52pub use kyc::{EntityResolution, KYCScoring};
53pub use monitoring::TransactionMonitoring;
54pub use sanctions::{PEPScreening, SanctionsScreening};
55
56/// Register all compliance kernels with a registry.
57pub fn register_all(
58    registry: &rustkernel_core::registry::KernelRegistry,
59) -> rustkernel_core::error::Result<()> {
60    tracing::info!("Registering compliance kernels");
61
62    // AML kernels (6)
63    registry.register_ring_metadata_from(aml::CircularFlowRatio::new)?;
64    registry.register_ring_metadata_from(aml::ReciprocityFlowRatio::new)?;
65    registry.register_ring_metadata_from(aml::RapidMovement::new)?;
66    registry.register_ring_metadata_from(aml::AMLPatternDetection::new)?;
67    registry.register_batch_metadata_from(aml::FlowReversalPattern::new)?;
68    registry.register_batch_metadata_from(aml::FlowSplitRatio::new)?;
69
70    // KYC kernels (2)
71    registry.register_batch_typed(kyc::KYCScoring::new)?;
72    registry.register_batch_typed(kyc::EntityResolution::new)?;
73
74    // Sanctions kernels (2)
75    registry.register_ring_metadata_from(sanctions::SanctionsScreening::new)?;
76    registry.register_ring_metadata_from(sanctions::PEPScreening::new)?;
77
78    // Monitoring kernel (1)
79    registry.register_ring_metadata_from(monitoring::TransactionMonitoring::new)?;
80
81    tracing::info!("Registered 11 compliance kernels");
82    Ok(())
83}
84
85#[cfg(test)]
86mod tests {
87    use super::*;
88    use rustkernel_core::registry::KernelRegistry;
89
90    #[test]
91    fn test_register_all() {
92        let registry = KernelRegistry::new();
93        register_all(&registry).expect("Failed to register compliance kernels");
94        assert_eq!(registry.total_count(), 11);
95    }
96}