daemonic_error 0.1.0

Errors that compose, predict, and leave receipts - Compose: algebraic combination (in active development) - Predict: Glass/Severity - Receipts: audit trail, position, checksum - Reflection: Runtime Reflection through TopologySegment (in active development)
use crate::daemonic::glass::Glass;
use crate::DaemonicError;

/// Should not exist. Medium or observer is broken.
/// Propagation ceiling exceeded. Laws violated.
/// If you're holding this, something is deeply wrong
/// and it's not the data — it's the system.
/// Impossible (hard): The state CANNOT be constructed. The type system prevents it. 
/// If you're holding an Impossible, a language invariant broke — the compiler failed to prevent something it should have prevented. 
/// This is a substrate-level failure. The entity didn't do anything wrong. The floor fell out from under it. 
/// The correct response is Broken Sword — document everything and terminate, 
/// because the system's guarantees have been violated and nothing can be trusted.
/// Paradox (soft impossible): The state LOOKS impossible from the current reference 
/// frame but might be valid from another frame. Incomplete context produces apparent 
/// impossibility. Two observations that each survive adversarial testing independently but 
/// contradict each other. This isn't a substrate failure — it's an information failure. The
/// correct response is Attend, not Abort. Gather more context. Check other frames. The paradox
/// might resolve with additional observation.
pub trait GlassImpossible: Glass<!> + for<'error> DaemonicError<'error> {
	/// What constraint was violated?
	fn violation_description(&self) -> &str;

	/// Is this an observer failure or a medium failure?
	fn failure_source(&self) -> ImpossibleSource;
}
/// Annotation on an Impossible observation.
/// "This shouldn't exist, here's what we think happened."
pub trait ImpossibleAnnotation: GlassImpossible {
	fn annotation(&self) -> &str;

	/// Best theory for how this impossible state arose.
	fn hypothesis(&self) -> Option<&str> { None }
}
pub enum ImpossibleSource {
	/// The observer itself is broken
	Observer,
	/// The medium (runtime, hardware, etc) is broken
	Medium,
	/// Can't determine which
	Unknown,
}