omega_core/
lib.rs

1//! # ExoGenesis Omega - Core Types and Traits
2//!
3//! This crate provides the foundational types and traits for the ExoGenesis Omega
4//! universal intelligence orchestration system.
5//!
6//! ## Overview
7//!
8//! ExoGenesis Omega enables the orchestration of intelligence at all scales, from
9//! milliseconds to cosmic timescales, through:
10//!
11//! - **12-Tier Cosmic Memory**: Memory systems spanning from immediate (milliseconds)
12//!   to cosmic (billions of years) timescales
13//! - **7 Temporal Loops**: Multi-scale feedback and learning cycles from reflexive
14//!   to transcendent
15//! - **Universal Intelligence**: Support for any type of intelligence substrate from
16//!   digital to cosmic
17//!
18//! ## Architecture
19//!
20//! ### Intelligence Types
21//!
22//! The [`Intelligence`] type represents any form of intelligence, with support for:
23//! - Multiple paradigms (Neural, Symbolic, Quantum, Biological, etc.)
24//! - Various substrates (Digital, Biological, Social, Cosmic, etc.)
25//! - Dynamic capabilities and evolution
26//!
27//! ### Memory System
28//!
29//! The memory system provides 12 tiers of storage:
30//! 1. Immediate (milliseconds)
31//! 2. Short-term (seconds to minutes)
32//! 3. Session (hours)
33//! 4. Episodic (days)
34//! 5. Semantic (weeks)
35//! 6. Procedural (months)
36//! 7. Strategic (years)
37//! 8. Civilizational (decades to centuries)
38//! 9. Evolutionary (millennia)
39//! 10. Planetary (millions of years)
40//! 11. Galactic (billions of years)
41//! 12. Cosmic (age of universe)
42//!
43//! ### Temporal Loops
44//!
45//! Seven nested feedback loops enable learning and adaptation:
46//! 1. Reflexive (milliseconds)
47//! 2. Reactive (seconds)
48//! 3. Adaptive (minutes to hours)
49//! 4. Deliberative (days)
50//! 5. Evolutionary (weeks to months)
51//! 6. Transformative (years)
52//! 7. Transcendent (decades+)
53//!
54//! ## Usage
55//!
56//! ```rust
57//! use omega_core::*;
58//! use chrono::Utc;
59//!
60//! // Create an intelligence
61//! let architecture = Architecture {
62//!     id: "arch-1".to_string(),
63//!     name: "Neural Network".to_string(),
64//!     paradigm: Paradigm::Neural,
65//!     substrate: SubstrateType::Digital,
66//!     fitness: None,
67//!     lineage: vec![],
68//!     created_at: Utc::now(),
69//! };
70//!
71//! let intelligence = Intelligence::new(
72//!     "My AI".to_string(),
73//!     architecture,
74//! );
75//!
76//! // Create a memory
77//! let memory = Memory::new(
78//!     MemoryTier::Semantic,
79//!     MemoryType::Knowledge,
80//!     MemoryContent::Text("Important fact".to_string()),
81//!     0.9, // importance
82//! );
83//!
84//! // Create a temporal loop
85//! let mut loop_instance = TemporalLoop::new(
86//!     LoopType::Adaptive,
87//!     "Learning Loop".to_string(),
88//!     "Continuous learning from experience".to_string(),
89//! );
90//! ```
91
92pub mod types;
93pub mod traits;
94
95// Re-export all public types and traits
96pub use types::*;
97pub use traits::*;
98
99// Version information
100pub const VERSION: &str = env!("CARGO_PKG_VERSION");
101pub const NAME: &str = env!("CARGO_PKG_NAME");
102
103/// Error types for omega-core
104pub mod error {
105    use thiserror::Error;
106
107    #[derive(Error, Debug)]
108    pub enum OmegaError {
109        #[error("Intelligence not found: {0}")]
110        IntelligenceNotFound(String),
111
112        #[error("Memory not found: {0}")]
113        MemoryNotFound(String),
114
115        #[error("Loop not found: {0}")]
116        LoopNotFound(String),
117
118        #[error("Invalid tier: {0}")]
119        InvalidTier(String),
120
121        #[error("Invalid loop type: {0}")]
122        InvalidLoopType(String),
123
124        #[error("Operation failed: {0}")]
125        OperationFailed(String),
126
127        #[error("Serialization error: {0}")]
128        SerializationError(#[from] serde_json::Error),
129
130        #[error("Unknown error: {0}")]
131        Unknown(String),
132    }
133}
134
135pub use error::OmegaError;
136
137#[cfg(test)]
138mod tests {
139    use super::*;
140    use chrono::Utc;
141
142    #[test]
143    fn test_create_intelligence() {
144        let architecture = Architecture {
145            id: "test-arch".to_string(),
146            name: "Test Architecture".to_string(),
147            paradigm: Paradigm::Neural,
148            substrate: SubstrateType::Digital,
149            fitness: None,
150            lineage: vec![],
151            created_at: Utc::now(),
152        };
153
154        let intelligence = Intelligence::new("Test AI".to_string(), architecture);
155        assert_eq!(intelligence.name, "Test AI");
156        assert_eq!(intelligence.generation, 0);
157        assert_eq!(intelligence.status, IntelligenceStatus::Initializing);
158    }
159
160    #[test]
161    fn test_memory_tiers() {
162        let tiers = MemoryTier::all_tiers();
163        assert_eq!(tiers.len(), 12);
164        assert_eq!(tiers[0], MemoryTier::Immediate);
165        assert_eq!(tiers[11], MemoryTier::Cosmic);
166    }
167
168    #[test]
169    fn test_create_memory() {
170        let memory = Memory::new(
171            MemoryTier::Semantic,
172            MemoryType::Knowledge,
173            MemoryContent::Text("Test memory".to_string()),
174            0.8,
175        );
176
177        assert_eq!(memory.tier, MemoryTier::Semantic);
178        assert!(!memory.is_expired());
179        assert_eq!(memory.metadata.importance, 0.8);
180    }
181
182    #[test]
183    fn test_temporal_loops() {
184        let loops = LoopType::all_loops();
185        assert_eq!(loops.len(), 7);
186        assert_eq!(loops[0], LoopType::Reflexive);
187        assert_eq!(loops[6], LoopType::Transcendent);
188    }
189
190    #[test]
191    fn test_loop_cycle() {
192        let mut temporal_loop = TemporalLoop::new(
193            LoopType::Adaptive,
194            "Test Loop".to_string(),
195            "Test Description".to_string(),
196        );
197
198        let input = CycleInput {
199            data: std::collections::HashMap::new(),
200            context: "test".to_string(),
201            objectives: vec!["learn".to_string()],
202        };
203
204        let cycle_id = temporal_loop.start_cycle(input);
205        assert!(!cycle_id.is_empty());
206        assert!(temporal_loop.current_cycle.is_some());
207    }
208}