rustkernel_behavioral/
lib.rs

1//! # RustKernel Behavioral Analytics
2//!
3//! GPU-accelerated behavioral analytics kernels for profiling and forensics.
4//!
5//! ## Kernels
6//! - `BehavioralProfiling` - Feature extraction for user behavior
7//! - `AnomalyProfiling` - Deviation scoring from behavioral baseline
8//! - `FraudSignatureDetection` - Known fraud pattern matching
9//! - `CausalGraphConstruction` - DAG inference from event streams
10//! - `ForensicQueryExecution` - Historical pattern search and analysis
11//! - `EventCorrelationKernel` - Temporal event correlation and clustering
12
13#![warn(missing_docs)]
14
15pub mod causal;
16pub mod correlation;
17pub mod forensics;
18pub mod profiling;
19pub mod signatures;
20pub mod types;
21
22/// Prelude for convenient imports.
23pub mod prelude {
24    pub use crate::causal::*;
25    pub use crate::correlation::*;
26    pub use crate::forensics::*;
27    pub use crate::profiling::*;
28    pub use crate::signatures::*;
29    pub use crate::types::*;
30}
31
32// Re-export main kernels
33pub use causal::CausalGraphConstruction;
34pub use correlation::EventCorrelationKernel;
35pub use forensics::ForensicQueryExecution;
36pub use profiling::{AnomalyProfiling, BehavioralProfiling};
37pub use signatures::FraudSignatureDetection;
38
39// Re-export key types
40pub use types::{
41    AnomalyResult, AnomalyType, BehaviorProfile, CausalEdge, CausalGraphResult, CausalNode,
42    CorrelationCluster, CorrelationResult, CorrelationType, EventCorrelation, EventValue,
43    FeatureDeviation, ForensicQuery, ForensicResult, FraudSignature, ProfilingResult, QueryType,
44    SignatureMatch, SignaturePattern, UserEvent,
45};
46
47/// Register all behavioral kernels with a registry.
48pub fn register_all(
49    registry: &rustkernel_core::registry::KernelRegistry,
50) -> rustkernel_core::error::Result<()> {
51    use rustkernel_core::traits::GpuKernel;
52
53    tracing::info!("Registering behavioral analytics kernels");
54
55    // Profiling kernels (2)
56    registry.register_metadata(profiling::BehavioralProfiling::new().metadata().clone())?;
57    registry.register_metadata(profiling::AnomalyProfiling::new().metadata().clone())?;
58
59    // Signature detection kernel (1)
60    registry.register_metadata(
61        signatures::FraudSignatureDetection::new()
62            .metadata()
63            .clone(),
64    )?;
65
66    // Causal kernel (1)
67    registry.register_metadata(causal::CausalGraphConstruction::new().metadata().clone())?;
68
69    // Forensics kernel (1)
70    registry.register_metadata(forensics::ForensicQueryExecution::new().metadata().clone())?;
71
72    // Correlation kernel (1)
73    registry.register_metadata(
74        correlation::EventCorrelationKernel::new()
75            .metadata()
76            .clone(),
77    )?;
78
79    tracing::info!("Registered 6 behavioral analytics kernels");
80    Ok(())
81}
82
83#[cfg(test)]
84mod tests {
85    use super::*;
86    use rustkernel_core::registry::KernelRegistry;
87
88    #[test]
89    fn test_register_all() {
90        let registry = KernelRegistry::new();
91        register_all(&registry).expect("Failed to register behavioral kernels");
92        assert_eq!(registry.total_count(), 6);
93    }
94}