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::daemonic_contract::daemonic_result::mirror_chemistry::stability::Stability::Stable;
use crate::daemonic::glass::Severity;
use crate::DaemonicError;
use super::{Glass, GlassStable};

/// Damaged but contained. Non-propagating.
/// The crack exists but isn't spreading.
/// Key property: can_cascade returns false.
pub trait GlassCracked<GLASS>: Glass<GLASS> + for<'error> DaemonicError<'error>
	// where
	// 	Self: ?Sized
{
	/// Is the crack stable or growing?
	fn is_holding(&self) -> bool;

	/// Attempt containment. Returns whether crack was stabilized.
	fn contain(&mut self) -> bool {
		// Default: already contained, return current holding state
		self.is_holding()
	}

	/// Optional repair closure.
	/// If provided, attempt repair. Costs a clock tick (work).
	/// Returns improved glass on success.
	fn repair(&self) -> Option<&dyn Fn(&GLASS) -> bool> {
		None
	}
}
/// Annotation on a Cracked observation.
/// "It's holding, and here's what cracked and why."
pub trait CrackedAnnotation<GLASS: Glass<GLASS>>: GlassCracked<GLASS>

{
	fn annotation(&self) -> &GLASS
	where
		GLASS: Glass<str>;

	/// Cracked annotations can carry a repair hint
	/// specific to the kind of crack observed.
	fn repair_hint(&self) -> Option<&impl Glass<GLASS>>;
}