maple_runtime/types/
errors.rs1use super::coupling::CouplingValidationError;
4use super::ids::ResonatorId;
5use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum BootstrapError {
10 #[error("Configuration error: {0}")]
11 ConfigError(String),
12
13 #[error("Initialization failed: {0}")]
14 InitializationFailed(String),
15
16 #[error("Invariant validation failed: {0}")]
17 InvariantValidationFailed(String),
18}
19
20#[derive(Debug, Error)]
22pub enum ShutdownError {
23 #[error("Pending commitments could not be resolved")]
24 PendingCommitments,
25
26 #[error("Failed to persist state: {0}")]
27 PersistenceError(String),
28
29 #[error("Timeout waiting for shutdown")]
30 Timeout,
31}
32
33#[derive(Debug, Error)]
35pub enum RegistrationError {
36 #[error("Invalid specification: {0}")]
37 InvalidSpec(String),
38
39 #[error("Profile validation failed: {0}")]
40 ProfileValidation(String),
41
42 #[error("Invariant violation: {0}")]
43 InvariantViolation(String),
44
45 #[error("Identity conflict: {0}")]
46 IdentityConflict(String),
47}
48
49#[derive(Debug, Error)]
51pub enum ResumeError {
52 #[error("Invalid continuity proof")]
53 InvalidContinuityProof,
54
55 #[error("Continuity record not found")]
56 ContinuityRecordNotFound,
57
58 #[error("State restoration failed: {0}")]
59 StateRestorationFailed(String),
60
61 #[error("Commitment reconciliation failed: {0}")]
62 CommitmentReconciliationFailed(String),
63}
64
65#[derive(Debug, Error)]
67pub enum PresenceError {
68 #[error("Intrusive presence signal")]
69 IntrusiveSignal,
70
71 #[error("Resonator not found: {0}")]
72 ResonatorNotFound(ResonatorId),
73
74 #[error("Signal rate limit exceeded")]
75 RateLimitExceeded,
76}
77
78#[derive(Debug, Error)]
80pub enum CouplingError {
81 #[error("Insufficient attention (requested: {requested}, available: {available})")]
82 InsufficientAttention { requested: u64, available: u64 },
83
84 #[error("Initial coupling strength too aggressive")]
85 TooAggressiveInitialStrength,
86
87 #[error("Strengthening rate too rapid")]
88 StrengtheningTooRapid,
89
90 #[error("Coupling not found")]
91 NotFound,
92
93 #[error("Profile mismatch: {0}")]
94 ProfileMismatch(String),
95
96 #[error("Coupling validation failed: {0}")]
97 ValidationFailed(String),
98}
99
100#[derive(Debug, Error)]
102pub enum AttentionError {
103 #[error("Insufficient attention (requested: {requested}, available: {available})")]
104 InsufficientAttention { requested: u64, available: u64 },
105
106 #[error("Resonator not found")]
107 ResonatorNotFound,
108
109 #[error("Attention exhausted")]
110 Exhausted,
111
112 #[error("Invalid allocation amount")]
113 InvalidAmount,
114}
115
116#[derive(Debug, Error)]
118pub enum InvariantViolation {
119 #[error("Presence required before meaning formation")]
120 PresenceRequired,
121
122 #[error("Insufficient meaning for intent stabilization")]
123 InsufficientMeaning,
124
125 #[error("Intent not stabilized before commitment")]
126 UnstabilizedIntent,
127
128 #[error("No commitment for consequence")]
129 NoCommitment,
130
131 #[error("Attention capacity exceeded")]
132 AttentionExceeded,
133
134 #[error("Safety priority violated")]
135 SafetyPriority,
136
137 #[error("Human agency violation")]
138 HumanAgencyViolation,
139
140 #[error("Silent failure detected")]
141 SilentFailure,
142}
143
144#[derive(Debug, Error)]
146pub enum CommitmentError {
147 #[error("Commitment not found")]
148 NotFound,
149
150 #[error("Invalid commitment state transition")]
151 InvalidStateTransition,
152
153 #[error("Commitment already fulfilled")]
154 AlreadyFulfilled,
155
156 #[error("Commitment violated")]
157 Violated,
158
159 #[error("Risk assessment required")]
160 RiskAssessmentRequired,
161
162 #[error("Audit trail required")]
163 AuditTrailRequired,
164
165 #[error("Approval required")]
166 ApprovalRequired,
167}
168
169#[derive(Debug, Error)]
171pub enum ConsequenceError {
172 #[error("No commitment for consequence")]
173 NoCommitment,
174
175 #[error("Consequence not reversible")]
176 NotReversible,
177
178 #[error("Reversal failed: {0}")]
179 ReversalFailed(String),
180}
181
182#[derive(Debug, Error)]
184pub enum SchedulingError {
185 #[error("Circuit breaker open")]
186 CircuitBreakerOpen,
187
188 #[error("Attention unavailable")]
189 AttentionUnavailable,
190
191 #[error("Queue full")]
192 QueueFull,
193
194 #[error("Task rejected: {0}")]
195 TaskRejected(String),
196}
197
198#[derive(Debug, Error)]
200pub enum TemporalError {
201 #[error("Causal ordering violation")]
202 CausalOrderingViolation,
203
204 #[error("Temporal anchor not found")]
205 AnchorNotFound,
206
207 #[error("Causal cycle detected")]
208 CausalCycle,
209}
210
211impl From<AttentionError> for CouplingError {
213 fn from(err: AttentionError) -> Self {
214 match err {
215 AttentionError::InsufficientAttention {
216 requested,
217 available,
218 } => CouplingError::InsufficientAttention {
219 requested,
220 available,
221 },
222 _ => CouplingError::ValidationFailed(err.to_string()),
223 }
224 }
225}
226
227impl From<CouplingValidationError> for CouplingError {
228 fn from(err: CouplingValidationError) -> Self {
229 CouplingError::ValidationFailed(err.to_string())
230 }
231}