aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / aien-heartbeat / src / error.rs
| 1 | use std::fmt; |
| 2 | |
| 3 | /// Every failure is terminal for the ring (fail closed). |
| 4 | #[derive(Debug)] |
| 5 | pub enum HeartbeatError { |
| 6 | Io { |
| 7 | context: String, |
| 8 | source: std::io::Error, |
| 9 | }, |
| 10 | ShortRead { |
| 11 | expert: (u16, u16), |
| 12 | wanted: usize, |
| 13 | got: usize, |
| 14 | }, |
| 15 | DigestMismatch { |
| 16 | expert: (u16, u16), |
| 17 | }, |
| 18 | Manifest(String), |
| 19 | RingFailed, |
| 20 | SlotBusy(usize), |
| 21 | PayloadTooLarge { |
| 22 | slot: usize, |
| 23 | need: usize, |
| 24 | cap: usize, |
| 25 | }, |
| 26 | } |
| 27 | |
| 28 | impl fmt::Display for HeartbeatError { |
| 29 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 30 | match self { |
| 31 | Self::Io { context, source } => write!(f, "I/O error ({context}): {source}"), |
| 32 | Self::ShortRead { |
| 33 | expert, |
| 34 | wanted, |
| 35 | got, |
| 36 | } => { |
| 37 | write!( |
| 38 | f, |
| 39 | "short read for expert {expert:?}: wanted {wanted} got {got}" |
| 40 | ) |
| 41 | } |
| 42 | Self::DigestMismatch { expert } => write!(f, "digest mismatch for expert {expert:?}"), |
| 43 | Self::Manifest(m) => write!(f, "manifest: {m}"), |
| 44 | Self::RingFailed => write!(f, "ring has failed closed"), |
| 45 | Self::SlotBusy(s) => write!(f, "slot {s} is already being filled"), |
| 46 | Self::PayloadTooLarge { slot, need, cap } => { |
| 47 | write!(f, "slot {slot}: need {need} bytes, capacity {cap}") |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | impl std::error::Error for HeartbeatError {} |
| 54 | |
| 55 | impl HeartbeatError { |
| 56 | pub fn io(context: impl Into<String>, source: std::io::Error) -> Self { |
| 57 | Self::Io { |
| 58 | context: context.into(), |
| 59 | source, |
| 60 | } |
| 61 | } |
| 62 | } |