ruvector_consciousness/
error.rs1use std::time::Duration;
4
5#[derive(Debug, thiserror::Error)]
7pub enum ConsciousnessError {
8 #[error("phi did not converge after {iterations} iterations (current={current:.6}, delta={delta:.2e})")]
10 PhiNonConvergence {
11 iterations: usize,
12 current: f64,
13 delta: f64,
14 },
15
16 #[error("numerical instability at partition {partition}: {detail}")]
18 NumericalInstability { partition: usize, detail: String },
19
20 #[error("budget exhausted: {reason}")]
22 BudgetExhausted { reason: String, elapsed: Duration },
23
24 #[error("invalid input: {0}")]
26 InvalidInput(#[from] ValidationError),
27
28 #[error("system size {n} exceeds exact limit {max} — use approximate mode")]
30 SystemTooLarge { n: usize, max: usize },
31}
32
33#[derive(Debug, thiserror::Error)]
35pub enum ValidationError {
36 #[error("dimension mismatch: {0}")]
37 DimensionMismatch(String),
38
39 #[error("non-finite value at element ({row}, {col})")]
40 NonFiniteValue { row: usize, col: usize },
41
42 #[error("TPM rows must sum to 1.0 (row {row} sums to {sum:.6})")]
43 InvalidTPM { row: usize, sum: f64 },
44
45 #[error("parameter out of range: {name} = {value} (expected {expected})")]
46 ParameterOutOfRange {
47 name: String,
48 value: String,
49 expected: String,
50 },
51
52 #[error("empty system: need at least 2 elements")]
53 EmptySystem,
54}
55
56pub type Result<T> = std::result::Result<T, ConsciousnessError>;