1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum AAPError {
8 #[error("AAP-001: validation error on field '{field}': {message}")]
10 Validation { field: String, message: String },
11
12 #[error("AAP-002: signature error: {0}")]
14 Signature(String),
15
16 #[error(
18 "AAP-003: Physical World Rule: Autonomous (Level 4) is forbidden \
19 for physical agent '{agent_id}'. Maximum level is Supervised (Level 3). \
20 This rule is not configurable."
21 )]
22 PhysicalWorldViolation { agent_id: String },
23
24 #[error("AAP-004: action '{action}' is not in scope for agent '{agent_id}'")]
26 Scope { action: String, agent_id: String },
27
28 #[error("AAP-005: '{id}' has been revoked")]
30 Revocation { id: String },
31
32 #[error("AAP-006: audit chain broken at entry '{entry_id}'")]
34 Chain { entry_id: String },
35
36 #[error("serialization error: {0}")]
38 Serde(#[from] serde_json::Error),
39}
40
41pub type Result<T> = std::result::Result<T, AAPError>;