omega-persistence
SQLite-based persistence layer for ExoGenesis Omega with schema migrations and transactional storage.
Part of the ExoGenesis-Omega cognitive architecture.
Overview
omega-persistence provides durable, high-performance storage for all ExoGenesis Omega components. Built on SQLite with bundled native library support, it offers zero-dependency deployment with ACID guarantees for memories, skills, architectures, intelligences, causal graphs, and vector embeddings.
The crate implements a carefully designed schema with proper foreign key constraints, indexes for common queries, and support for backup/restore operations. All operations are transactional and type-safe.
Features
- Hierarchical Memory Storage: Store memories across all 12 tiers with importance tracking
- Skill Management: Track learned skills with usage statistics and pattern matching
- Architecture Versioning: Store evolved architectures with full lineage tracking
- Intelligence Lifecycle: Persist intelligence instances with state and capabilities
- Causal Graph Storage: Build and query causal relationships between memories
- Vector Embeddings: Store high-dimensional vectors with memory associations
- Reflexion Episodes: Capture agent learning episodes with context
- Transactional Operations: Full ACID guarantees for all mutations
- Backup & Restore: Built-in support for database snapshots
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
use Utc;
Core Concepts
OmegaStore
The main interface to the persistence layer. Provides methods for:
- Creating/opening databases
- Storing and retrieving all entity types
- Querying with filters
- Backup and restore operations
- Database statistics
Stored Entity Types
All entities are strongly typed with validation:
- StoredMemory: Memory with tier, importance, and optional embedding
- StoredSkill: Learned skill with trigger pattern and success tracking
- StoredArchitecture: Cognitive architecture with paradigm and fitness
- StoredIntelligence: Intelligence instance with capabilities and state
- StoredVector: High-dimensional embedding with dimension tracking
- StoredReflexionEpisode: Learning episode with trigger/action/outcome
- StoredCausalEdge: Directed causal relationship with weight
Schema Design
The database schema uses proper normalization with:
- Foreign key constraints for referential integrity
- Indexes on commonly queried columns
- JSON storage for flexible metadata
- BLOB storage for vector embeddings
- Timestamp tracking for all entities
Use Cases
1. Memory Management
use ;
use Utc;
let store = new?;
let now = now.timestamp;
// Store memories across tiers
for tier in 1..=12
// Query by tier with automatic importance ordering
let important_semantic = store.query_memories_by_tier?;
for mem in important_semantic
2. Skill Tracking
use ;
use Utc;
let store = new?;
let now = now.timestamp;
// Store a learned skill
let skill = StoredSkill ;
store.store_skill?;
// Increment success on use
store.increment_skill_success?;
// Find skills by pattern
let code_skills = store.get_skills_by_pattern?;
println!;
3. Architecture Evolution
use ;
use Utc;
let store = new?;
let now = now.timestamp;
// Store base architecture
let base = StoredArchitecture ;
store.store_architecture?;
// Store evolved version
let evolved = StoredArchitecture ;
store.store_architecture?;
// Query by paradigm
let neural_archs = store.get_architectures_by_paradigm?;
4. Causal Graph Construction
use ;
use Utc;
let store = new?;
let now = now.timestamp;
// Store cause and effect memories
let cause = StoredMemory ;
let effect = StoredMemory ;
store.store_memory?;
store.store_memory?;
// Create causal edge
let edge = StoredCausalEdge ;
store.store_causal_edge?;
// Query causal relationships
let effects = store.get_causal_edges_from?;
5. Intelligence Persistence
use ;
use Utc;
let store = new?;
let now = now.timestamp;
// First create architecture
let arch = StoredArchitecture ;
store.store_architecture?;
// Create intelligence instance
let intel = StoredIntelligence ;
store.store_intelligence?;
// Query intelligences by architecture
let instances = store.get_intelligences_by_arch?;
Examples
Database Backup and Restore
use OmegaStore;
let store = new?;
// ... store data ...
// Create backup
store.backup?;
// Later, open backup to verify
let backup_store = new?;
let stats = backup_store.get_statistics?;
println!;
Database Statistics
use OmegaStore;
let store = new?;
let stats = store.get_statistics?;
println!;
println!;
println!;
println!;
println!;
println!;
println!;
println!;
Architecture
omega-persistence provides the storage foundation for the Omega ecosystem:
┌──────────────────────────────────────┐
│ Higher-level Crates │
│ (omega-memory, omega-agentdb, etc) │
└────────────────┬─────────────────────┘
│
▼
┌──────────────────────────────────────┐
│ omega-persistence │
│ - OmegaStore │
│ - Schema Management │
│ - Transaction Handling │
└────────────────┬─────────────────────┘
│
▼
┌──────────────────────────────────────┐
│ rusqlite (SQLite) │
│ - ACID transactions │
│ - Bundled library │
│ - Zero external dependencies │
└──────────────────────────────────────┘
Performance
- Fast Queries: Indexed columns for common access patterns
- Batch Operations: Transactional bulk inserts
- Bundled SQLite: No external database setup required
- Memory Efficient: Streaming results for large datasets
- Optimized Schema: Proper normalization and denormalization balance
Key performance characteristics:
- Memory lookup by ID: O(1) with index
- Query by tier: O(n log n) with index + sort
- Skill pattern search: O(n) with full-text capabilities
- Causal graph queries: O(k) where k = edge count
Related Crates
- omega-core - Core types and traits
- omega-agentdb - Vector database for semantic search
- omega-memory - 12-tier memory system (uses persistence)
- omega-loops - Temporal loop orchestration
- omega-meta-sona - Architecture evolution
- omega-runtime - Production runtime
- omega-brain - Unified cognitive architecture
- omega-hippocampus - Memory storage layer
License
Licensed under the MIT License. See LICENSE for details.