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)
//! Daemonic Glyph System
//!
//!
//! **Abstract**
//!
//! Symbolic state encoding for compiler diagnostics.
//! Machine greppable, human readable, semantically dense.
//!
//! **Core Principles & Features**
//!
//! Semantic Density — Maximum meaning in minimum characters
//! Machine Greppable — Single-character states, parseable chains
//! Human Readable — Intuitive once learned, discoverable via help
//! Composable — Glyphs chain into narratives
//! Accessible — Text equivalents available
//!
//!
//! Glass State Glyphs
//! GlyphNameMeaningText Equivalent
//!
//! *`◇`* IntactNo error, system healthy[OK]
//!
//! *`◆`* WarningIssue detected, recoverable, state trustworthy[WARN]
//!
//! *`◈`* FracturedError occurred, partially recoverable, state questionable[ERROR]
//!
//! *`▓`* ShatteredUnrecoverable, state untrustworthy, halt[FATAL]
//!
//! Transition Glyphs
//! GlyphNameMeaningText Equivalent→TransitionState changed->⇒ForcedTransition forced (not natural progression)=>↻RecursiveState revisited (loop/cycle)[LOOP]⊗TerminatedProcess ended[TERM]⊕MergedStates combined[MERGE]⊖DivergedStates split[SPLIT]
//!
//! Action Glyphs
//! GlyphNameMeaningText Equivalent◇→SuggestionProposed fix (intact after)[SUGGEST]⚠AttentionRequires human review[ATTENTION]✓ResolvedIssue fixed[RESOLVED]✗FailedFix failed[FAILED]
//!
//! Operation Glyphs (Extended)
//! GlyphNameMeaningDomain⚗TransmuteType conversionTypes⚙MechanicalInternal operationSystem☿VolatileMutable/unstable stateMemory♄HeavyBlocking/expensive operationPerformance△ComputeWork being performedEntropy▽FlowData movementIO○CompleteOperation succeededStatus●PendingOperation in progressAsync
//!
//! Alchemical Extended Set
//! GlyphNameMeaningUsage🜁AirLight/fast operationPerformance hints🜂FireComputation/transformationActive processing🜃EarthStable/grounded stateCheckpoints🜄WaterData flow/streamingIO operations🜎GoldPerfect successOptimization achieved🜏LunaReflection/mirrorDebug/introspection🝊CrucibleActive transformationCompilation
//!
//! Chain Grammar
//! Basic chain: <state>(<transition><state>)*
//! Examples:
//! ◇           "intact"
//! ◇→◆         "intact, then warning"
//! ◇→◆→◈       "intact, warning, then error"
//! ◇→◆→◈→◇     "intact, warning, error, recovered"
//! ◈↻◈         "error, looped, still error"
//! ◇⇒▓         "intact, forced shatter" (catastrophic)
//! Extended chain: <state>(<transition><state>)*<terminator>?
//! Examples:
//! ◇→◆→◈⊗      "warning, error, terminated"
//! ◈↻◈↻◈⊗     "error loop (3x), terminated"
//! ◇→◆→◇✓      "warning, recovered, resolved"
//!
//! Output Format
//! Standard:
//! <glyph> <message>
//!   ├─ <detail>
//!   └─ <glyph> <suggestion>
//! Example:
//! ◈ invalid `repr(align)`: expected integer
//!   ├─ found: `align(foo)`
//!   └─ ◇→ try: `repr(align(8))`
//! Chained (multi-step process):
//! ◇→◆ parsing attributes
//!   └─ conflicting hints detected
//! ◆→◈ validation failed
//!   └─ repr(C) incompatible with repr(Rust)
//! ◈→◇ recovered with default
//!   └─ using repr(Rust)
//!
//!
//! Glass state indicators
pub mod glass {
	pub const STABLE: char = '';
	pub const WARNING: char = '';
	pub const FRACTURED: char = '';
	pub const SHATTERED: char = '';

	pub const ALL: [char; 4] = [STABLE, WARNING, FRACTURED, SHATTERED];
}

/// State transition indicators
pub mod transition {
	pub const NATURAL: &str = "";
	pub const FORCED: &str = "";
	pub const RECURSIVE: &str = "";
	pub const TERMINATED: &str = "";
	pub const MERGED: &str = "";
	pub const DIVERGED: &str = "";
}

/// Action indicators
pub mod action {
	pub const SUGGEST: &str = "◇→";
	pub const ATTENTION: char = '';
	pub const RESOLVED: char = '';
	pub const FAILED: char = '';
}

/// Operation type indicators
pub mod operation {
	pub const TRANSMUTE: char = '';
	pub const MECHANICAL: char = '';
	pub const VOLATILE: char = '';
	pub const HEAVY: char = '';
	pub const COMPUTE: char = '';
	pub const FLOW: char = '';
	pub const COMPLETE: char = '';
	pub const PENDING: char = '';
}

/// Alchemical extended set
pub mod alchemy {
	pub const AIR: char = '🜁';
	pub const FIRE: char = '🜂';
	pub const EARTH: char = '🜃';
	pub const WATER: char = '🜄';
	pub const GOLD: char = '🜎';
	pub const LUNA: char = '🜏';
	pub const CRUCIBLE: char = '🝊';
}

/// Text equivalents for accessibility
pub mod text {
	pub const INTACT: &str = "[OK]";
	pub const WARNING: &str = "[WARN]";
	pub const FRACTURED: &str = "[ERROR]";
	pub const SHATTERED: &str = "[FATAL]";
	pub const TRANSITION: &str = "->";
	pub const FORCED: &str = "=>";
	pub const RECURSIVE: &str = "[LOOP]";
	pub const TERMINATED: &str = "[TERM]";
	pub const SUGGEST: &str = "[SUGGEST]";
}

/// Glyph chain builder
pub struct GlyphChain {
	states: Vec<char>,
	transitions: Vec<&'static str>,
	terminator: Option<&'static str>,
}

impl GlyphChain {
	pub fn new(initial: char) -> Self {
		Self {
			states: vec![initial],
			transitions: vec![],
			terminator: None,
		}
	}

	pub fn then(mut self, transition: &'static str, state: char) -> Self {
		self.transitions.push(transition);
		self.states.push(state);
		self
	}

	pub fn terminate(mut self, terminator: &'static str) -> Self {
		self.terminator = Some(terminator);
		self
	}

	pub fn to_string(&self) -> String {
		let mut result = String::new();
		for (i, state) in self.states.iter().enumerate() {
			if i > 0 {
				result.push_str(self.transitions[i - 1]);
			}
			result.push(*state);
		}
		if let Some(term) = self.terminator {
			result.push_str(term);
		}
		result
	}
}