#[derive(Debug, thiserror::Error)]
pub enum RuntimeError {
#[error("memory store error: {0}")]
Memory(#[from] semantic_memory::MemoryError),
#[error("invalid config for '{field}': {reason}")]
InvalidConfig { field: &'static str, reason: String },
#[error("entity not found: {id}")]
EntityNotFound { id: String },
#[error("entity registry full (capacity {capacity})")]
RegistryFull { capacity: usize },
#[error("entity collision: name '{name}' already registered to {existing_id}, cannot assign to {new_id}")]
EntityCollision {
name: String,
existing_id: crate::ids::EntityId,
new_id: crate::ids::EntityId,
},
#[error("projection unavailable: {id} ({reason})")]
ProjectionUnavailable { id: String, reason: String },
#[error("adapter error: {0}")]
Adapter(String),
#[error("scope not fully enforced: upstream adapter only filters by namespace; unpushed dimensions: {unpushed_dimensions:?}")]
ScopeNotFullyEnforced {
unpushed_dimensions: Vec<String>,
},
#[error("temporal search not supported: results lack temporal metadata for expression '{temporal_expr}'")]
TemporalNotSupported {
temporal_expr: String,
},
}
impl RuntimeError {
pub fn kind(&self) -> &'static str {
match self {
Self::Memory(_) => "memory",
Self::InvalidConfig { .. } => "invalid_config",
Self::EntityNotFound { .. } => "entity_not_found",
Self::RegistryFull { .. } => "registry_full",
Self::ProjectionUnavailable { .. } => "projection_unavailable",
Self::Adapter(_) => "adapter",
Self::EntityCollision { .. } => "entity_collision",
Self::ScopeNotFullyEnforced { .. } => "scope_not_fully_enforced",
Self::TemporalNotSupported { .. } => "temporal_not_supported",
}
}
}