daemonic_error 0.1.1

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::Anchor;

/// Fixes a point or rate in time.
/// DB mapping: D9 (Temporal Stability) + D10 (Structural Depth)
///
/// DaemonicClock implements this. Mesh clock implements this.
/// The root Shade's tick 1 implements this.
pub trait TemporalAnchor: Anchor {
	/// The fixed tick value this anchor represents.
	fn anchor_tick(&self) -> u64;

	/// Is this the root temporal anchor (epoch, depth 0)?
	fn is_epoch(&self) -> bool {
		self.anchor_depth() == 0
	}

	/// Causal predecessors — what came before this in the
	/// cause-effect chain. Returns anchor IDs.
	fn causal_predecessors(&self) -> &[u64] { &[] }

	/// Expected tick rate (for drift detection).
	/// Default: 1.0 (one tick per unit time).
	fn expected_rate(&self) -> f64 { 1.0 }

	/// Measured tick rate (actual observed rate).
	/// Default: matches expected (no drift).
	fn measured_rate(&self) -> f64 { self.expected_rate() }

	/// Rate drift — deviation from expected.
	/// Positive = running fast. Negative = running slow.
	fn rate_drift(&self) -> f64 {
		self.measured_rate() - self.expected_rate()
	}
}
/// Fixes a clock rate for drift detection.
pub trait RateAnchor: TemporalAnchor {
	fn rexpected_rate(&self) -> f64;
	fn rmeasured_rate(&self) -> f64;
	fn rate_drift(&self) -> f64 {
		self.rmeasured_rate() - self.rexpected_rate()
	}
}
/// Fixes a point in a cause-effect chain.
pub trait CausalAnchor: TemporalAnchor {
	fn causal_predecessors(&self) -> &[u64]; // anchor IDs
}