pub struct Memory {
pub id: String,
pub tier: MemoryTier,
pub content: MemoryContent,
pub embedding: Vec<f32>,
pub importance: f64,
pub created_at: DateTime<Utc>,
pub accessed_at: DateTime<Utc>,
pub access_count: u64,
pub metadata: Value,
}Expand description
Core memory structure
Fields§
§id: String§tier: MemoryTier§content: MemoryContent§embedding: Vec<f32>§importance: f64§created_at: DateTime<Utc>§accessed_at: DateTime<Utc>§access_count: u64§metadata: ValueImplementations§
Source§impl Memory
impl Memory
Sourcepub fn new(
tier: MemoryTier,
content: MemoryContent,
embedding: Vec<f32>,
importance: f64,
) -> Self
pub fn new( tier: MemoryTier, content: MemoryContent, embedding: Vec<f32>, importance: f64, ) -> Self
Examples found in repository?
examples/consolidation.rs (lines 18-23)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 println!("🔄 ExoGenesis Omega - Memory Consolidation Demo\n");
10
11 let memory = CosmicMemory::new().await?;
12
13 // Create multiple instant memories with varying importance
14 println!("📝 Creating memories with varying importance...\n");
15
16 for i in 0..5 {
17 let importance = 0.2 + (i as f64 * 0.2);
18 let mem = Memory::new(
19 MemoryTier::Instant,
20 MemoryContent::Text(format!("Memory #{} with importance {:.1}", i, importance)),
21 vec![i as f32 / 5.0; 4],
22 importance,
23 );
24 memory.store(mem).await?;
25 println!(" Created instant memory #{} (importance: {:.1})", i, importance);
26 }
27
28 println!("\n📊 Initial statistics:");
29 let stats = memory.stats().await;
30 println!(" Instant: {}", stats.individual.instant);
31 println!(" Session: {}", stats.individual.session);
32 println!(" Episodic: {}", stats.individual.episodic);
33 println!(" Semantic: {}", stats.individual.semantic);
34
35 // Run auto-consolidation
36 println!("\n🔄 Running auto-consolidation...");
37 memory.auto_consolidate().await?;
38
39 println!("\n📊 Post-consolidation statistics:");
40 let stats = memory.stats().await;
41 println!(" Instant: {}", stats.individual.instant);
42 println!(" Session: {}", stats.individual.session);
43 println!(" Episodic: {}", stats.individual.episodic);
44 println!(" Semantic: {}", stats.individual.semantic);
45
46 println!("\n✅ High-importance memories were consolidated to higher tiers!");
47
48 Ok(())
49}More examples
examples/basic_usage.rs (lines 19-24)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 println!("🧠 ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11 // Initialize the cosmic memory system
12 let memory = CosmicMemory::new().await?;
13 println!("✅ Initialized 12-tier cosmic memory system\n");
14
15 // Store memories in different tiers
16 println!("📝 Storing memories across tiers...\n");
17
18 // Tier 1: Instant memory
19 let instant_mem = Memory::new(
20 MemoryTier::Instant,
21 MemoryContent::Text("Current thought: Processing user input".to_string()),
22 vec![0.1, 0.2, 0.3, 0.4],
23 0.3,
24 );
25 memory.store(instant_mem).await?;
26 println!(" [T1] Instant: Working memory stored");
27
28 // Tier 2: Session memory
29 let session_mem = Memory::new(
30 MemoryTier::Session,
31 MemoryContent::Text("Conversation context about Rust programming".to_string()),
32 vec![0.5, 0.6, 0.7, 0.8],
33 0.5,
34 );
35 memory.store(session_mem).await?;
36 println!(" [T2] Session: Conversation context stored");
37
38 // Tier 3: Episodic memory
39 let episodic_mem = Memory::new(
40 MemoryTier::Episodic,
41 MemoryContent::Text("Completed implementation of memory system on 2025-12-04".to_string()),
42 vec![0.2, 0.4, 0.6, 0.8],
43 0.7,
44 );
45 memory.store(episodic_mem).await?;
46 println!(" [T3] Episodic: Event memory stored");
47
48 // Tier 4: Semantic memory
49 let semantic_mem = Memory::new(
50 MemoryTier::Semantic,
51 MemoryContent::Text("Knowledge: Rust uses ownership for memory safety".to_string()),
52 vec![0.9, 0.8, 0.7, 0.6],
53 0.8,
54 );
55 memory.store(semantic_mem).await?;
56 println!(" [T4] Semantic: Knowledge stored");
57
58 // Tier 5: Collective memory
59 let collective_mem = Memory::new(
60 MemoryTier::Collective,
61 MemoryContent::Text("Shared pattern: Async/await improves concurrency".to_string()),
62 vec![0.7, 0.7, 0.7, 0.7],
63 0.75,
64 );
65 memory.store(collective_mem).await?;
66 println!(" [T5] Collective: Shared knowledge stored");
67
68 // Tier 12: Omega memory
69 let omega_mem = Memory::new(
70 MemoryTier::Omega,
71 MemoryContent::Text("Universal principle: Information cannot be destroyed".to_string()),
72 vec![1.0, 1.0, 1.0, 1.0],
73 0.99,
74 );
75 memory.store(omega_mem).await?;
76 println!(" [T12] Omega: Universal truth stored\n");
77
78 // Query memories
79 println!("🔍 Querying memories...\n");
80
81 // Query individual scale memories
82 let query = QueryBuilder::new()
83 .individual()
84 .min_importance(0.5)
85 .build();
86
87 let results = memory.recall(&query, &[
88 MemoryTier::Instant,
89 MemoryTier::Session,
90 MemoryTier::Episodic,
91 MemoryTier::Semantic,
92 ]).await?;
93
94 println!(" Found {} memories in individual scale (T1-T4):", results.len());
95 for mem in &results {
96 if let MemoryContent::Text(text) = &mem.content {
97 println!(" - {}: {}", mem.tier, text);
98 }
99 }
100
101 // Memory statistics
102 println!("\n📊 Memory Statistics:\n");
103 let stats = memory.stats().await;
104 println!(" Individual Scale (T1-T4):");
105 println!(" - Instant: {}", stats.individual.instant);
106 println!(" - Session: {}", stats.individual.session);
107 println!(" - Episodic: {}", stats.individual.episodic);
108 println!(" - Semantic: {}", stats.individual.semantic);
109 println!(" Species Scale (T5-T8):");
110 println!(" - Collective: {}", stats.species.collective);
111 println!(" - Evolutionary: {}", stats.species.evolutionary);
112 println!(" - Architectural: {}", stats.species.architectural);
113 println!(" - Substrate: {}", stats.species.substrate);
114 println!(" Cosmic Scale (T9-T12):");
115 println!(" - Civilizational: {}", stats.cosmic.civilizational);
116 println!(" - Temporal: {}", stats.cosmic.temporal);
117 println!(" - Physical: {}", stats.cosmic.physical);
118 println!(" - Omega: {}", stats.cosmic.omega);
119 println!("\n Total memories: {}", stats.total_memories);
120
121 // Run consolidation
122 println!("\n🔄 Running automatic consolidation...");
123 memory.auto_consolidate().await?;
124 println!("✅ Consolidation complete\n");
125
126 println!("🎉 Demo complete!");
127
128 Ok(())
129}pub fn touch(&mut self)
pub fn relevance_score(&self) -> f64
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Memory
impl<'de> Deserialize<'de> for Memory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnwindSafe for Memory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more