aimds-core - AI Manipulation Defense System Core
Core type system, configuration, and error handling for AIMDS - Production-ready adversarial defense for AI applications.
Part of the AIMDS (AI Manipulation Defense System) by rUv - Real-time threat detection with formal verification.
Features
- 🎯 Type-Safe Design: Comprehensive type system for threats, policies, and responses
- ⚙️ Flexible Configuration: Environment-based config with sensible defaults
- 🛡️ Robust Error Handling: Hierarchical error types with severity levels and retryability
- 📊 Zero Dependencies: Minimal dependency footprint for core types
- 🚀 Production Ready: 100% test coverage, validated in production workloads
- 🔧 Extensible: Easy to extend with custom types and configurations
Quick Start
use ;
// Create configuration
let config = default;
// Create prompt input
let input = new;
// Type-safe threat severity
match input.severity
// Error handling with retryability
match some_operation
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
Core Types
Threat Types
// Threat severity levels
// Threat categories
Input Types
// Prompt input with metadata
Configuration
// System configuration
Error Handling
// Hierarchical error system
// Error severity for automated handling
Architecture
┌──────────────────────────────────────────────┐
│ aimds-core │
├──────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Types │ │ Config │ │
│ │ System │ │ Management │ │
│ └─────────────┘ └─────────────┘ │
│ │ │ │
│ └───────┬───────────┘ │
│ │ │
│ ┌───────▼────────┐ │
│ │ Error │ │
│ │ Handling │ │
│ └────────────────┘ │
│ │ │
│ ▼ │
│ Used by Detection, Analysis, Response │
│ │
└──────────────────────────────────────────────┘
Performance
- Zero Runtime Overhead: All types compile to efficient machine code
- Minimal Allocations: String-based types use
Arcsharing where possible - Fast Serialization: Optimized
serdeimplementations - Benchmark Results:
- Type creation: <100ns
- Error construction: <50ns
- Config parsing: <1ms
Use Cases
Type-Safe Threat Detection
use ;
Environment-Based Configuration
// Load from environment variables
let config = from_env?;
// Override specific settings
let config = Config ;
Structured Error Handling
Testing
Run tests:
Test coverage: 100% (7/7 tests passing)
Example tests:
- Configuration parsing and serialization
- Error severity classification
- Threat severity ordering
- Prompt input creation and validation
Documentation
- API Docs: https://docs.rs/aimds-core
- Examples: examples/
- Integration Guide: ../../INTEGRATION_VERIFICATION.md
Dependencies
Minimal dependency footprint:
serde- Serializationserde_json- JSON supportthiserror- Error derivationanyhow- Error contexttokio- Async runtimetracing- Loggingchrono- Timestampsuuid- Unique IDs
Contributing
See CONTRIBUTING.md for guidelines.
License
MIT OR Apache-2.0
Related Projects
- AIMDS - Main AIMDS platform
- aimds-detection - Real-time threat detection
- aimds-analysis - Behavioral analysis and verification
- aimds-response - Adaptive mitigation
- Midstream Platform - Core temporal analysis
Support
- Website: https://ruv.io/aimds
- Docs: https://ruv.io/aimds/docs
- GitHub: https://github.com/agenticsorg/midstream/tree/main/AIMDS/crates/aimds-core
- Discord: https://discord.gg/ruv