wifi-densepose/vendor/midstream/AIMDS/docs/README.md

12 KiB

AIMDS Documentation

Documentation License

Comprehensive documentation for the AI Manipulation Defense System (AIMDS) - Production-ready adversarial defense for AI applications.

Part of the AIMDS platform by rUv.

📚 Documentation Index

Getting Started

Core Concepts

Detection Layer

Analysis Layer

Response Layer

API Reference

Rust APIs

  • aimds-core - Core types and configuration

    • Type system documentation
    • Configuration options
    • Error handling patterns
  • aimds-detection - Detection service API

    • DetectionService::new()
    • detect(), detect_batch()
    • Pattern matching and sanitization
  • aimds-analysis - Analysis engine API

    • AnalysisEngine::new()
    • analyze(), train_baseline()
    • Policy verification
  • aimds-response - Response system API

    • ResponseSystem::new()
    • mitigate(), rollback_last()
    • Meta-learning integration

TypeScript API Gateway

  • Gateway Server - REST API endpoints
    • /api/v1/defend - Single request defense
    • /api/v1/defend/batch - Batch processing
    • /api/v1/stats - Statistics endpoint
    • /metrics - Prometheus metrics

Integration Guides

Deployment

Performance & Optimization

Security

Examples

🎯 Use Case Guides

LLM API Gateway

Protect ChatGPT-style APIs from prompt injection:

use aimds_core::{Config, PromptInput};
use aimds_detection::DetectionService;
use aimds_analysis::AnalysisEngine;

let detector = DetectionService::new(Config::default()).await?;
let analyzer = AnalysisEngine::new(Config::default()).await?;

// Fast path: <10ms detection
let detection = detector.detect(&user_input).await?;

if detection.is_threat && detection.confidence > 0.8 {
    return Err("Malicious input detected");
}

// Deep path: <520ms analysis for suspicious inputs
if detection.requires_deep_analysis() {
    let analysis = analyzer.analyze(&user_input, Some(&detection)).await?;
    if analysis.is_threat() {
        responder.mitigate(&user_input, &analysis).await?;
    }
}

See: LLM API Gateway Guide

Multi-Agent Security

Coordinate defense across agent swarms:

// Initialize components for all agents
let detector = DetectionService::new(config).await?;
let analyzer = AnalysisEngine::new(config).await?;

// Detect anomalous behavior
for agent in swarm.agents() {
    let trace = agent.action_history();
    let result = analyzer.analyze_sequence(&trace).await?;

    if result.anomaly_score > 0.8 {
        coordinator.flag_agent(agent.id, result).await?;
    }
}

See: Multi-Agent Security Guide

Real-Time Chat

Sub-10ms defense for interactive UIs:

// WebSocket message handler
async fn on_message(msg: ChatMessage) {
    let input = PromptInput::new(&msg.text, None);

    // <10ms latency
    let result = detector.detect(&input).await?;

    if result.is_threat {
        send_error("Message blocked").await?;
    } else {
        process_message(msg).await?;
    }
}

See: Real-Time Chat Guide

Fraud Detection

Identify unusual transaction patterns:

// Train baseline on normal behavior
analyzer.train_baseline(&normal_transactions).await?;

// Analyze new transaction
let result = analyzer.analyze(&new_transaction, None).await?;

if result.anomaly_score > 0.9 {
    fraud_system.flag_for_review(new_transaction).await?;
}

See: Fraud Detection Guide

📊 Performance Targets

All performance targets validated in production:

Component Target Actual Documentation
Detection <10ms ~8ms Detection Benchmarks
Behavioral Analysis <100ms ~80ms Analysis Benchmarks
Policy Verification <500ms ~420ms Verification Benchmarks
Mitigation <50ms ~45ms Response Benchmarks
API Throughput >10,000 req/s >12,000 req/s Integration Report

🔧 Configuration Reference

Core Configuration

pub struct Config {
    // Detection
    pub detection_enabled: bool,
    pub detection_timeout_ms: u64,
    pub max_pattern_cache_size: usize,

    // Analysis
    pub behavioral_analysis_enabled: bool,
    pub behavioral_threshold: f64,
    pub policy_verification_enabled: bool,

    // Response
    pub adaptive_mitigation_enabled: bool,
    pub max_mitigation_attempts: usize,
    pub mitigation_timeout_ms: u64,

    // Logging
    pub log_level: String,
    pub metrics_enabled: bool,
    pub audit_logging_enabled: bool,
}

See: Configuration Guide

Environment Variables

# Detection
AIMDS_DETECTION_ENABLED=true
AIMDS_DETECTION_TIMEOUT_MS=10
AIMDS_MAX_PATTERN_CACHE_SIZE=10000

# Analysis
AIMDS_BEHAVIORAL_ANALYSIS_ENABLED=true
AIMDS_BEHAVIORAL_THRESHOLD=0.75
AIMDS_POLICY_VERIFICATION_ENABLED=true

# Response
AIMDS_ADAPTIVE_MITIGATION_ENABLED=true
AIMDS_MAX_MITIGATION_ATTEMPTS=3
AIMDS_MITIGATION_TIMEOUT_MS=50

# Logging
AIMDS_LOG_LEVEL=info
AIMDS_METRICS_ENABLED=true
AIMDS_AUDIT_LOGGING_ENABLED=true

See: Environment Configuration

📈 Monitoring & Observability

Prometheus Metrics

# Detection metrics
aimds_detection_requests_total
aimds_detection_latency_ms
aimds_pattern_cache_hit_rate

# Analysis metrics
aimds_analysis_latency_ms
aimds_anomaly_score_distribution
aimds_policy_violations_total

# Response metrics
aimds_mitigation_success_rate
aimds_rollback_total
aimds_strategy_effectiveness

See: Monitoring Guide

Structured Logging

{
  "timestamp": "2025-10-27T12:34:56.789Z",
  "level": "INFO",
  "target": "aimds_detection",
  "message": "Threat detected",
  "fields": {
    "threat_id": "thr_abc123",
    "severity": "HIGH",
    "confidence": 0.95,
    "latency_ms": 8.5
  }
}

See: Logging Configuration

🧪 Testing Guide

Running Tests

# All Rust tests
cargo test --all-features

# Specific crate
cargo test --package aimds-detection

# Integration tests
cargo test --test integration_tests

# TypeScript tests
npm test

# Benchmarks
cargo bench
npm run bench

See: Test Report

Test Coverage

  • aimds-core: 100% (7/7 tests)
  • aimds-detection: 90% (20/22 tests)
  • aimds-analysis: 100% (27/27 tests)
  • aimds-response: 97% (38/39 tests)
  • TypeScript: 100% (all integration tests)

See: Integration Verification

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Documentation Contributions

  1. Fork the repository
  2. Update documentation in relevant files
  3. Test code examples
  4. Submit pull request

Documentation locations:

  • Crate READMEs: /crates/*/README.md
  • Main README: /README.md
  • This index: /docs/README.md
  • Guides: /docs/*.md

📄 License

MIT OR Apache-2.0

Midstream Platform

External Projects

🆘 Support

📝 Documentation Changelog

Latest Updates

  • 2025-10-27: Initial comprehensive documentation
    • Added crate-specific READMEs
    • Created documentation index
    • Added use case guides
    • Included performance benchmarks

Built with ❤️ by rUv | GitHub | Twitter | LinkedIn

Keywords: AI security documentation, adversarial defense guide, prompt injection detection, Rust AI security, TypeScript API gateway, real-time threat detection, behavioral analysis, formal verification, LLM security, production AI safety