pub struct CosmicMemory { /* private fields */ }Expand description
Main Cosmic Memory system integrating all tiers
Implementationsยง
Sourceยงimpl CosmicMemory
impl CosmicMemory
Sourcepub async fn new() -> Result<Self, MemoryError>
pub async fn new() -> Result<Self, MemoryError>
Examples found in repository?
examples/consolidation.rs (line 11)
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 (line 12)
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}Sourcepub async fn store(&self, memory: Memory) -> Result<String, MemoryError>
pub async fn store(&self, memory: Memory) -> Result<String, MemoryError>
Store a memory in the appropriate tier
Examples found in repository?
examples/consolidation.rs (line 24)
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 (line 25)
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}Sourcepub async fn recall(
&self,
query: &Query,
tiers: &[MemoryTier],
) -> Result<Vec<Memory>, MemoryError>
pub async fn recall( &self, query: &Query, tiers: &[MemoryTier], ) -> Result<Vec<Memory>, MemoryError>
Recall memories matching the query across specified tiers
Examples found in repository?
examples/basic_usage.rs (lines 87-92)
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}Sourcepub async fn consolidate(
&self,
from_tier: MemoryTier,
to_tier: MemoryTier,
) -> Result<(), MemoryError>
pub async fn consolidate( &self, from_tier: MemoryTier, to_tier: MemoryTier, ) -> Result<(), MemoryError>
Consolidate memories from one tier to another
Sourcepub async fn auto_consolidate(&self) -> Result<(), MemoryError>
pub async fn auto_consolidate(&self) -> Result<(), MemoryError>
Run automatic consolidation based on importance and age
Examples found in repository?
examples/consolidation.rs (line 37)
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 (line 123)
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}Sourcepub async fn stats(&self) -> MemoryStats
pub async fn stats(&self) -> MemoryStats
Get statistics about memory usage across all tiers
Examples found in repository?
examples/consolidation.rs (line 29)
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 (line 103)
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}Auto Trait Implementationsยง
impl !RefUnwindSafe for CosmicMemory
impl !UnwindSafe for CosmicMemory
impl Freeze for CosmicMemory
impl Send for CosmicMemory
impl Sync for CosmicMemory
impl Unpin for CosmicMemory
impl UnsafeUnpin for CosmicMemory
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