Public declaration syntax from forge-rs/crates/forge-contracts/src/error.rs Original source SHA-256: c1307a34bfd4e038c912a6bc4d7675b50595b2545f46ef4a243ba80c4f49b60e Function bodies and constant values are omitted. This is not the complete implementation. Source line 25 #[derive(Debug, Error)] pub enum ContractError { // ----------------------------------------------------------------------- // S-01: Agent Runtime // ----------------------------------------------------------------------- /// The requested agent does not exist or has been terminated. #[error("agent '{agent_id}' not found in runtime")] AgentNotFound { /// The agent identifier that was not found. agent_id: String, }, /// Agent creation failed due to invalid configuration. #[error("agent creation failed: {reason}")] AgentCreationFailed { /// Human-readable explanation of why creation failed. reason: String, }, /// An invalid lifecycle transition was attempted. #[error("invalid lifecycle transition from {from} to {to} for agent '{agent_id}'")] InvalidLifecycleTransition { /// The agent that owns the lifecycle. agent_id: String, /// The current state name. from: String, /// The requested target state name. to: String, }, // ----------------------------------------------------------------------- // S-02: Identity & Lineage // ----------------------------------------------------------------------- /// Identity derivation failed. #[error("identity derivation failed for path '{path}' from parent '{parent_did}': {reason}")] IdentityDerivationFailed { /// The parent DID from which derivation was attempted. parent_did: String, /// The derivation path that failed. path: String, /// Explanation of the failure. reason: String, }, /// Lineage verification failed at the specified depth. #[error("lineage verification failed at depth {depth} for '{did}': {reason}")] LineageVerificationFailed { /// The DID whose lineage failed verification. did: String, /// The depth at which verification failed. depth: u32, /// Explanation of the failure. reason: String, }, /// DID resolution failed. #[error("DID resolution failed for '{did}': {reason}")] DidResolutionFailed { /// The DID that could not be resolved. did: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-03: Auth & Delegation // ----------------------------------------------------------------------- /// Capability escalation denied: child requested more than parent has. #[error("capability escalation denied: agent '{agent_did}' requested scope '{requested}' but parent ACT only grants {available:?}")] CapabilityEscalation { /// The agent DID that attempted escalation. agent_did: String, /// The scope that was requested. requested: String, /// The scopes available to the parent. available: Vec, }, /// A capability token has expired. #[error("capability token '{token_id}' for agent '{agent_did}' expired at {expired_at}")] TokenExpired { /// The token identifier. token_id: String, /// The agent DID that owns the token. agent_did: String, /// ISO 8601 timestamp when the token expired. expired_at: String, }, /// Authorization check failed. #[error("authorization denied for agent '{agent_did}' on scope '{scope}': {reason}")] AuthorizationDenied { /// The agent DID that was denied. agent_did: String, /// The scope that was requested. scope: String, /// Explanation of why authorization was denied. reason: String, }, // ----------------------------------------------------------------------- // S-04: Provider Routing // ----------------------------------------------------------------------- /// No provider matched the routing policy. #[error("no provider matched routing policy for org '{org_id}': {reason}")] NoProviderAvailable { /// The organization identifier. org_id: String, /// Explanation of why no provider matched. reason: String, }, /// Provider session creation or management failed. #[error("provider session error for '{provider_ref}': {reason}")] ProviderSessionError { /// The provider reference string. provider_ref: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-05: Brew Plans // ----------------------------------------------------------------------- /// Plan resolution failed (unresolved symbols, cycles, etc.). #[error("brew plan '{plan_id}' resolution failed: {reason}")] PlanResolutionFailed { /// The plan identifier. plan_id: String, /// Explanation of the failure. reason: String, }, /// Plan execution failed at a specific node. #[error("brew plan '{plan_id}' failed at node '{node_id}': {reason}")] PlanExecutionFailed { /// The plan identifier. plan_id: String, /// The node that failed. node_id: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-06: Comm/Collab // ----------------------------------------------------------------------- /// Channel creation or operation failed. #[error("channel '{channel_id}' error: {reason}")] ChannelError { /// The channel identifier. channel_id: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-07: MCP // ----------------------------------------------------------------------- /// MCP server connection or operation failed. #[error("MCP server '{server_name}' error: {reason}")] McpError { /// The MCP server name. server_name: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-08: Telemetry & Health // ----------------------------------------------------------------------- /// Telemetry collection or aggregation failed. #[error("telemetry error: {reason}")] TelemetryError { /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-09: Flowers Bridge // ----------------------------------------------------------------------- /// Durable execution checkpoint or resume failed. #[error("flowers execution '{execution_id}' error: {reason}")] FlowersError { /// The Flowers execution identifier. execution_id: String, /// Explanation of the failure. reason: String, }, // ----------------------------------------------------------------------- // S-10: Memory // ----------------------------------------------------------------------- /// Memory read or write operation failed. #[error("memory error in scope '{scope}': {reason}")] MemoryError { /// The memory scope where the error occurred. scope: String, /// Explanation of the failure. reason: String, }, /// Memory access denied by policy. #[error("memory access denied for agent '{agent_did}' in scope '{scope}': {reason}")] MemoryAccessDenied { /// The agent DID that was denied. agent_did: String, /// The memory scope. scope: String, /// Explanation of the denial. reason: String, }, // ----------------------------------------------------------------------- // Cross-cutting // ----------------------------------------------------------------------- /// Contract version mismatch between Forge and Aut0. #[error("contract version mismatch: Forge has {forge_version}, Aut0 expects {aut0_version}")] VersionMismatch { /// The version Forge compiled against. forge_version: String, /// The version Aut0 compiled against. aut0_version: String, }, /// A required configuration field was missing or invalid. #[error("configuration error: {reason}")] ConfigurationError { /// Explanation of the configuration problem. reason: String, }, /// An internal Forge error that Aut0 should not need to handle in detail. #[error("internal error: {reason}")] Internal { /// Explanation for diagnostic purposes. reason: String, }, } Source line 265 pub type ContractResult = Result;