Abstract
AI Drift provides continuous monitoring and detection of AI decision drift within the Prismatic Platform, identifying when machine learning models begin producing outputs that deviate from their expected behavioral baselines. The engine leverages Elixir's concurrency model and OTP supervision trees to deliver robust, fault-tolerant drift detection pipelines that operate continuously without downtime. Built as app_ai_drift within the umbrella architecture, the application implements a complete AI governance framework (HRAiME-compliant) with 20+ modules, 9 database tables, and 3,120 lines of test code. Each monitored model runs in its own isolated process, ensuring that a failure in one detection pipeline cannot cascade to others.
1. Introduction
1.1 Problem Statement
AI systems deployed in production environments gradually change their behavior over time due to concept drift, data distribution shifts, and model degradation. In regulated domains such as HR decision-making, credit scoring, and compliance screening, these behavioral changes can violate regulatory requirements and introduce unintended bias. Without continuous monitoring, organizations cannot demonstrate that their AI systems operate within acceptable parameters -- a requirement under emerging AI governance frameworks including the EU AI Act and HR-specific AI monitoring mandates.
AI Drift addresses this by providing continuous statistical monitoring of model outputs against established baselines, with multi-algorithm detection, risk scoring, and governance-compliant reporting.
1.2 Design Goals
- Multi-algorithm detection -- simultaneous application of KS test, PSI, Jensen-Shannon divergence, Wasserstein distance, and Anderson-Darling test for comprehensive drift coverage.
- Process-per-model isolation -- each monitored model runs in a supervised process preventing cascading failures.
- HRAiME governance compliance -- intent classification, risk accumulation, narrative generation, and stakeholder-specific alert routing.
- Multi-tenant security -- full tenant isolation with encrypted data separation and RBAC access control.
- NABLA epistemic integration -- all findings carry confidence scores with provenance chains validated by the Trinity Gate.
- Real-time and batch -- both streaming event ingestion and historical batch analysis capabilities.
1.3 Scope
AI Drift covers drift detection, risk scoring, and governance reporting. It does not implement the ML models themselves (which are external) or the visualization dashboard (handled by AI Drift Web). The REST API layer is pending Phase 4 integration.
2. Architecture
2.1 System Design
Model Output Stream ──> Ingestion Pipeline ──> Baseline Comparator ──> Drift Scorer
│ │ │ │
Raw Predictions Normalization Statistical Tests PSI / KS / JSD
Feature Vectors Windowing Threshold Check Confidence Score
│ │ │ │
└──────────────────────┴───────────────────────┴────────────────────┘
│
Alert Dispatcher ──> PubSub ──> Dashboard / API
│
Governance Engine ──> Narrative + Compliance
│
Trend Analyzer ──> Storage ──> Historical Archive2.2 Core Components
| Module | Responsibility |
|---|---|
AppAiDrift.Application | OTP application with supervised GenServer components |
AppAiDrift.Detection.DriftDetector | GenServer: multi-algorithm drift detection on event streams |
AppAiDrift.Detection.BaselineManager | GenServer: initial, rolling, and seasonal baseline management |
AppAiDrift.Detection.DriftAlgorithms | Statistical algorithms: KS, PSI, JS, Wasserstein, Anderson-Darling |
AppAiDrift.Detection.WindowManager | Sliding window management for temporal drift analysis |
AppAiDrift.Ingestion.EventProcessor | GenServer: high-throughput batch event ingestion |
AppAiDrift.Risk.RiskScorer | GenServer: multi-dimensional risk scoring with decay |
AppAiDrift.Risk.ImpactAnalyzer | Business impact assessment for detected drift |
AppAiDrift.Risk.ThresholdManager | Dynamic threshold management based on model characteristics |
AppAiDrift.Features.Extractor | Statistical, content, confidence, and temporal feature extraction |
AppAiDrift.Governance | Unified HRAiME governance interface |
AppAiDrift.Governance.DecisionRegistry | System identity and lifecycle management |
AppAiDrift.Governance.IntentClassifier | Drift intent classification (routine, optimization, emergency, etc.) |
AppAiDrift.Governance.RiskAccumulation | Cumulative risk tracking with configurable decay |
AppAiDrift.Governance.NarrativeGenerator | Human-readable governance reports for stakeholders |
AppAiDrift.Governance.AlertRouter | Role-based alert routing (executive, compliance, technical) |
AppAiDrift.Security.MultiTenant | GenServer: tenant isolation with encrypted separation |
AppAiDrift.Statistics.AndersonDarling | Anderson-Darling tail-sensitive statistical test |
AppAiDrift.Statistics.CramerVonMises | Cramer-von-Mises distributional test |
AppAiDrift.Utils.HyperLogLog | Probabilistic cardinality estimation (4-16 bit precision) |
2.3 Process Topology
AppAiDrift.Application (Supervisor, :one_for_one)
+-- AppAiDrift.Security.MultiTenant (GenServer, priority: 110)
| Tenant context isolation, encrypted data separation
+-- AppAiDrift.Ingestion.EventProcessor (GenServer, priority: 100)
| High-throughput batch event ingestion with configurable batch size
+-- AppAiDrift.Detection.DriftDetector (GenServer, priority: 100)
| Multi-algorithm drift detection with baseline comparison
+-- AppAiDrift.Detection.BaselineManager (GenServer, priority: 90)
| Baseline lifecycle: initial (30-day), rolling (7-day), seasonal (52-week)
+-- AppAiDrift.Risk.RiskScorer (GenServer, priority: 80)
| Risk calculation with weighted components and temporal decay
+-- AppAiDrift.WebhookNotifier (GenServer, priority: 60)
Alert dispatch via webhooks and PubSub2.4 Data Flow
Events enter through the EventProcessor GenServer, which buffers them in configurable batches (default 1,000 events, 100ms timeout). The DriftDetector applies multiple statistical tests against baselines managed by BaselineManager. Detected drift is scored by RiskScorer using weighted multi-dimensional assessment (drift magnitude 30%, confidence impact 25%, temporal risk 20%, business impact 15%, data quality 10%). The Governance module classifies drift intent, generates stakeholder narratives, and routes alerts to appropriate roles. All results persist to PostgreSQL through 9 dedicated tables with 20+ indexes including GIN indexes on JSONB features.
3. Implementation
3.1 Detection Algorithms
| Algorithm | Purpose | Complexity | Sensitivity |
|---|---|---|---|
| Kolmogorov-Smirnov | Distribution comparison | O(n log n) | General |
| PSI (Population Stability Index) | Categorical drift | O(n) | Categorical features |
| Jensen-Shannon Divergence | Symmetric KL divergence | O(n) | Probability distributions |
| Wasserstein Distance | Optimal transport | O(n log n) | Distribution shape |
| Anderson-Darling | Tail-sensitive testing | O(n log n) | Distribution tails |
| Cramer-von-Mises | Goodness of fit | O(n log n) | Distribution differences |
3.2 Risk Components
| Component | Weight | Description |
|---|---|---|
| Drift Magnitude | 30% | Size of detected statistical drift |
| Confidence Impact | 25% | Effect on model prediction confidence |
| Temporal Risk | 20% | Time-based risk factors and trend acceleration |
| Business Impact | 15% | Financial and operational impact assessment |
| Data Quality | 10% | Input data quality degradation signals |
3.3 API Surface
# Ingest events for drift monitoring
{:ok, _} = AppAiDrift.Ingestion.EventProcessor.process_event(%{
event_type: :inference,
system_id: "credit_scoring_v3",
tenant_id: "tenant-123",
timestamp: DateTime.utc_now(),
payload: %{prediction: 0.85, input_hash: "abc123"},
confidence: 0.92
})
# Detect drift on event batch
{:ok, drift} = AppAiDrift.Detection.DriftDetector.detect(events)
# => %{detected: true, magnitude: 0.45, confidence: 0.97, algorithm: :ks_test}
# Score risk with multi-dimensional assessment
{:ok, risk} = AppAiDrift.Risk.RiskScorer.score(drift)
# => %{score: 0.72, severity: :high, components: %{...}, recommendations: [...]}
# Run complete governance pipeline
{:ok, result} = AppAiDrift.Governance.process_drift_event(drift_event, system_context)
# => %{classification: :performance_optimization, risk_level: :medium,
# narrative_id: "narr_abc123", alerts_sent: [:risk_manager, :technical_lead]}3.4 Configuration
config :app_ai_drift,
detection_threshold: 0.95,
min_samples: 100,
window_size: 1000,
max_batch_size: 1000,
batch_timeout_ms: 100,
risk_decay_factor: 0.95,
accumulation_window: 3_600_000,
baseline_initial_days: 30,
rolling_window_days: 7,
seasonal_lookback_weeks: 524. Integration
4.1 Dependencies
| Application | Relationship |
|---|---|
| Prismatic Kernel | Core runtime services and process supervision |
| Prismatic Core | Shared protocols, types, and utilities |
| Prismatic Storage Core | Storage abstraction behaviors |
| Prismatic Storage Ecto | PostgreSQL persistence for drift data |
| Prismatic Telemetry | Performance metrics and distributed tracing |
4.2 Dependents
| Application | Relationship |
|---|---|
| AI Drift Web | LiveView dashboard for drift visualization |
4.3 External Dependencies
Ecto SQL with Postgrex for PostgreSQL, Oban for background job processing, NimbleCSV for data import, Timex for datetime utilities, Decimal for numeric precision, LibGraph for graph structures, and StreamData for property-based testing.
5. Testing Strategy
5.1 Test Structure (3,120 LOC)
test/app_ai_drift/
+-- core/ -- Schema validation tests
+-- detection/ -- Algorithm correctness tests
+-- features/ -- Feature extraction accuracy tests
+-- risk/ -- Risk scoring tests
+-- security/ -- Multi-tenant isolation tests
+-- statistics/ -- Statistical test validation
+-- governance/ -- Governance pipeline tests
+-- utils/ -- Utility function tests5.2 Property-Based Testing
StreamData generators produce random event sequences, baseline distributions, and risk parameters to verify that drift detection algorithms maintain statistical correctness and that risk scores remain within valid bounds under all valid inputs.
6. Performance
6.1 Benchmarks
| Operation | Latency | Notes |
|---|---|---|
| Event ingestion (batch of 1,000) | < 100ms | Buffered batch processing |
| KS test (1,000 samples) | < 10ms | O(n log n) comparison |
| PSI calculation | < 5ms | O(n) categorical drift |
| Full risk scoring | < 50ms | Multi-dimensional weighted assessment |
| Governance pipeline | < 200ms | Classification + narrative + routing |
6.2 Database Schema
9 tables with monthly time-based partitioning: ai_drift_events, ai_drift_baselines, ai_drift_detections, ai_drift_risk_scores, ai_drift_alerts, ai_drift_audit_trail, ai_drift_lineage. 20+ indexes on tenant_id, system_id, timestamp, and severity with GIN indexes on JSONB features.
7. NABLA Compliance
Every drift assessment is annotated with confidence scores derived from the platform's NABLA epistemic framework. The signal plurality axiom is enforced by requiring multiple statistical tests to agree before a drift finding is reported. The provenance axiom is satisfied through complete derivation chains linking every finding to its source events and algorithms. The Trinity Gate validation ensures structural, logical, and formal consistency of all reported findings.
8. Governance Framework (HRAiME Compliant)
8.1 Intent Classification
| Category | Description | Example |
|---|---|---|
routine_maintenance | Regular updates, retraining | Scheduled model refresh |
performance_optimization | Accuracy improvements | Feature engineering changes |
policy_change | Business rule updates | Threshold adjustments |
emergency_response | Critical fixes | Bias correction |
regulatory_compliance | Compliance changes | New regulatory requirement |
data_distribution_shift | Natural drift | Seasonal market changes |
8.2 Non-Conclusion Boundaries
The system explicitly does NOT: analyze individual behavior, evaluate personal performance, infer intent or motivation, make predictions about individuals, establish causal relationships, or make value judgments about people.
9. Security
9.1 Multi-Tenant Isolation
AppAiDrift.Security.MultiTenant.with_tenant(tenant_id, fn ->
# All operations scoped to tenant with encrypted data separation
AppAiDrift.Detection.DriftDetector.detect(events)
end)9.2 RBAC Roles
| Role | Permissions |
|---|---|
| Admin | Full access to all drift data and configuration |
| Analyst | Read + analyze drift data, acknowledge alerts |
| Viewer | Read-only access to dashboards and reports |
| Auditor | Audit trail access for compliance review |
10. Future Work
Phase 4 integration pending: REST API endpoints, webhook HTTP dispatch, dashboard connection, and database persistence completion. Planned enhancements include real-time streaming transcription, cross-model drift correlation, and automated remediation recommendations.
References
- AI Drift Web -- LiveView dashboard for drift visualization
- Prismatic Nabla -- Epistemic confidence framework
- Prismatic Detection Engine -- Complementary pattern detection
Related Agents
- Alert Management Specialist -- Drift alert lifecycle coordination and escalation
- Evolution Orchestrator Supreme -- Autonomous model evolution in response to detected drift
Related Capabilities
- Real-Time Monitoring -- Continuous drift surveillance infrastructure
- NABLA Axioms -- Epistemic confidence scoring for drift assessments
- Quality Gates -- Drift thresholds as quality enforcement checkpoints
Connect & Contribute
Created by Tomáš Korcak (korczis) | Open Source under GHL