Skip to main content

aivcs_core/sandbox/
error.rs

1//! Error types for the sandbox module.
2
3/// Errors produced by the sandbox layer.
4#[derive(Debug, thiserror::Error)]
5pub enum SandboxError {
6    #[error("policy denied: {reason}")]
7    PolicyDenied { reason: String },
8
9    #[error("tool execution timed out after {elapsed_ms}ms (limit {limit_ms}ms)")]
10    Timeout { elapsed_ms: u64, limit_ms: u64 },
11
12    #[error("tool execution failed after {attempts} attempt(s): {reason}")]
13    ExecutionFailed { attempts: u32, reason: String },
14
15    #[error(
16        "circuit breaker open: {consecutive_failures} consecutive failures (threshold {threshold})"
17    )]
18    CircuitBreakerOpen {
19        consecutive_failures: u32,
20        threshold: u32,
21    },
22
23    #[error("invalid sandbox configuration: {0}")]
24    InvalidConfig(String),
25
26    #[error("domain error: {0}")]
27    Domain(#[from] crate::domain::error::AivcsError),
28}
29
30/// Result type for sandbox operations.
31pub type SandboxResult<T> = std::result::Result<T, SandboxError>;