-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Severity: HIGH
Issue
All application state is stored in-memory. Power loss or crash results in complete data loss:
- All groups lost
- All key packages lost
- All conversation history lost
- Cannot rejoin groups
Impact
For a chat application, this makes it unusable for any serious purpose. Users expect:
- Persistent conversation history
- Ability to restart without losing groups
- Recovery from crashes
- Migration between devices
Current State
pub struct StateActor {
groups: HashMap<String, MlsGroup>, // In memory
key_packages: HashMap<String, KeyPackageIn>, // In memory
active_group: Option<String>, // In memory
}What Needs Persistence
- MLS Groups: Group state, epochs, member list
- Key Packages: Cached KeyPackages from other users
- Credentials: Long-term identity (already persisted via SSH keys)
- Messages: Conversation history
- Configuration: Active group, preferences
Proposed Solution
Phase 1: Basic persistence
pub trait Storage {
async fn save_group(&self, name: &str, group: &MlsGroup) -> Result<()>;
async fn load_group(&self, name: &str) -> Result<Option<MlsGroup>>;
async fn save_key_package(&self, key: &str, kp: &KeyPackageIn) -> Result<()>;
async fn load_key_packages(&self) -> Result<HashMap<String, KeyPackageIn>>;
}Phase 2: Implement with SQLite
pub struct SqliteStorage {
pool: SqlitePool,
}
// Tables:
// - groups (name, mls_state, epoch, created_at)
// - key_packages (composite_key, package_data, cached_at)
// - messages (id, group_name, sender, content, timestamp)Phase 3: Migration and backups
- Schema versioning
- Automatic backups
- Import/export functionality
Alternative: Serialize to files
Simpler but less robust:
// groups.json, key_packages.json
std::fs::write("data/groups.json", serde_json::to_string(&groups)?)?;Related Issues
- No graceful shutdown (no chance to save state)
- No error recovery
- Makes testing harder (can't inspect persisted state)
Labels
enhancement, data-persistence, reliability
Metadata
Metadata
Assignees
Labels
No labels