Skip to content

Commit e3605c5

Browse files
committed
feat(persistence): add SQLite persistence for conversation state and models
Implement comprehensive SQLite-based persistence layer: - PersistenceManager with full CRUD operations for conversations - Save/load conversation history with project isolation - Persist reservoir computing state across sessions - Store trained MLP weights with accuracy tracking - Configuration persistence - Database utilities (vacuum, size checking) - Full test coverage (7 tests, all passing) Schema includes: - conversations table (indexed by project and timestamp) - reservoir_states table (per-project state) - model_weights table (versioned model storage) - metadata and config tables Features: - Transaction safety - Query parameterization (SQL injection safe) - Efficient indexing for common queries - In-memory database support for testing - Graceful handling of missing data Dependencies added: - rusqlite 0.31 (bundled SQLite) - lazy_static 1.4 (global state) - rand 0.8 (for training) - proptest 1.4 (dev dependency for future property tests) Default feature: persistence enabled by default for production use Can be disabled with --no-default-features for minimal builds Stats: 612 lines of persistence code + tests All tests passing: cargo test --features persistence persistence
1 parent 68ea6f5 commit e3605c5

3 files changed

Lines changed: 621 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ rust-version = "1.75"
1515
# Core dependencies - keeping minimal for Bronze RSR compliance
1616
serde = { version = "1.0", features = ["derive"] }
1717
serde_json = { version = "1.0" }
18+
lazy_static = "1.4"
19+
rand = "0.8"
20+
21+
# Persistence
22+
rusqlite = { version = "0.31", features = ["bundled"], optional = true }
1823

1924
# Optional dependencies for future phases
2025
tokio = { version = "1.35", features = ["rt", "macros", "sync"], optional = true }
@@ -23,11 +28,14 @@ reqwest = { version = "0.11", features = ["json"], optional = true }
2328
[dev-dependencies]
2429
# Test dependencies
2530
criterion = "0.5"
31+
proptest = "1.4"
2632

2733
[features]
28-
default = []
34+
default = ["persistence"]
2935
# Network features disabled by default for offline-first
3036
network = ["tokio", "reqwest"]
37+
# Persistence (enabled by default for production use)
38+
persistence = ["rusqlite"]
3139
# Phase 2+ features
3240
reservoir = []
3341
rag = []

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub mod context;
3030
pub mod expert;
3131
pub mod mlp;
3232
pub mod orchestrator;
33+
pub mod persistence;
3334
pub mod reservoir;
3435
pub mod router;
3536
pub mod snn;

0 commit comments

Comments
 (0)