basic_usage/
basic_usage.rs1use omega_memory::{
4 CosmicMemory, Memory, MemoryContent, MemoryTier, QueryBuilder,
5};
6
7#[tokio::main]
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 println!("š§ ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11 let memory = CosmicMemory::new().await?;
13 println!("ā
Initialized 12-tier cosmic memory system\n");
14
15 println!("š Storing memories across tiers...\n");
17
18 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 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 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 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 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 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 println!("š Querying memories...\n");
80
81 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 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 println!("\nš Running automatic consolidation...");
123 memory.auto_consolidate().await?;
124 println!("ā
Consolidation complete\n");
125
126 println!("š Demo complete!");
127
128 Ok(())
129}