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

/// Observable — "I can be seen."
///
/// The target side of observation. Things that produce reflections
/// when looked at. A file is observable. A symbol is observable.
/// A running process is observable. A rock is observable.
///
/// Observable does not observe itself. Single-sided glass.
/// The observable doesn't know it's being observed (passive)
/// unless it implements Active observation mode (state-changing).
///
/// This is the rock. It reflects whether anyone is looking or not.
pub trait Observable {
	/// What does observing this produce?
	/// A file produces bytes. A symbol produces DaemonicIR.
	/// A process produces state snapshots.
	type Observed;
	
	/// Does observing this change it?
	/// Default: Passive. Looking doesn't modify.
	/// Override for types where observation extracts or mutates.
	/// Note: For Kernel Applications or Daemonic programs that run at Ring0, this should change to Active and from passive.
	fn observation_mode(&self) -> ObservationMode {
		ObservationMode::Passive
	}
	
	/// Self-assessment. What does this thing think its own
	/// fidelity is? Default: Unknown (honest uncertainty).
	///
	/// Override to self-assess. DaemonicBinary overrides this
	/// with a full dimensional assessment. A simple file
	/// might check if it exists and is readable.
	fn self_assess(&self) -> Severity {
		Severity::Unknown
	}
}

/// How observation affects the observed.
pub enum ObservationMode {
	/// Looking doesn't change state. Read-only.
	/// The rock sitting there. A file on disk.
	Passive,
	
	/// Looking extracts or modifies state.
	/// The act of observation changes the observed.
	Active {
		/// Does this consume the target?
		consuming: bool,
		/// Does this mutate the target?
		mutating: bool,
	},
}