"""
Safety and Guardrails Framework

Comprehensive safety framework for autonomous agent operation.
Provides multi-layered protection including:
- Pre-execution validation
- Cost and budget controls
- Rate limiting
- Loop detection and prevention
- Human-in-the-loop approval
- Rollback and checkpointing
- Content filtering
- Sandboxed execution
- Emergency controls
- Complete audit trail

Usage:
    from app.services.safety import get_safety_guardian, SafetyGuardian

    guardian = await get_safety_guardian()
    result = await guardian.validate(action_request)

    if result.allowed:
        # Execute action
        pass
    else:
        # Handle denial
        print(f"Action denied: {result.reasons}")
"""

# Exceptions
# Audit
from .audit import (
    AuditLogger,
    get_audit_logger,
    reset_audit_logger,
    shutdown_audit_logger,
)

# Configuration
from .config import (
    AutonomyConfig,
    SafetyConfig,
    get_autonomy_config,
    get_default_policy,
    get_policy_for_autonomy_level,
    get_safety_config,
    load_policies_from_directory,
    load_policy_from_file,
    reset_config_cache,
)
from .exceptions import (
    ApprovalDeniedError,
    ApprovalRequiredError,
    ApprovalTimeoutError,
    BudgetExceededError,
    CheckpointError,
    ContentFilterError,
    EmergencyStopError,
    LoopDetectedError,
    PermissionDeniedError,
    PolicyViolationError,
    RateLimitExceededError,
    RollbackError,
    SafetyError,
    SandboxError,
    SandboxTimeoutError,
    ValidationError,
)

# Guardian
from .guardian import (
    SafetyGuardian,
    get_safety_guardian,
    reset_safety_guardian,
    shutdown_safety_guardian,
)

# Models
from .models import (
    ActionMetadata,
    ActionRequest,
    ActionResult,
    ActionType,
    ApprovalRequest,
    ApprovalResponse,
    ApprovalStatus,
    AuditEvent,
    AuditEventType,
    AutonomyLevel,
    BudgetScope,
    BudgetStatus,
    Checkpoint,
    CheckpointType,
    GuardianResult,
    PermissionLevel,
    RateLimitConfig,
    RateLimitStatus,
    ResourceType,
    RollbackResult,
    SafetyDecision,
    SafetyPolicy,
    ValidationResult,
    ValidationRule,
)

__all__ = [
    "ActionMetadata",
    "ActionRequest",
    "ActionResult",
    # Models
    "ActionType",
    "ApprovalDeniedError",
    "ApprovalRequest",
    "ApprovalRequiredError",
    "ApprovalResponse",
    "ApprovalStatus",
    "ApprovalTimeoutError",
    "AuditEvent",
    "AuditEventType",
    # Audit
    "AuditLogger",
    "AutonomyConfig",
    "AutonomyLevel",
    "BudgetExceededError",
    "BudgetScope",
    "BudgetStatus",
    "Checkpoint",
    "CheckpointError",
    "CheckpointType",
    "ContentFilterError",
    "EmergencyStopError",
    "GuardianResult",
    "LoopDetectedError",
    "PermissionDeniedError",
    "PermissionLevel",
    "PolicyViolationError",
    "RateLimitConfig",
    "RateLimitExceededError",
    "RateLimitStatus",
    "ResourceType",
    "RollbackError",
    "RollbackResult",
    # Configuration
    "SafetyConfig",
    "SafetyDecision",
    # Exceptions
    "SafetyError",
    # Guardian
    "SafetyGuardian",
    "SafetyPolicy",
    "SandboxError",
    "SandboxTimeoutError",
    "ValidationError",
    "ValidationResult",
    "ValidationRule",
    "get_audit_logger",
    "get_autonomy_config",
    "get_default_policy",
    "get_policy_for_autonomy_level",
    "get_safety_config",
    "get_safety_guardian",
    "load_policies_from_directory",
    "load_policy_from_file",
    "reset_audit_logger",
    "reset_config_cache",
    "reset_safety_guardian",
    "shutdown_audit_logger",
    "shutdown_safety_guardian",
]
