feat(memory): optional SQLite connection open timeout

- Add memory.sqlite_open_timeout_secs config (None = wait indefinitely).
- When set, open the DB in a thread with recv_timeout; cap at 300s.
- Default remains None for backward compatibility.
- Document in README; add tests for timeout path and default.
This commit is contained in:
Ademílson Tonato 2026-02-17 18:33:16 -03:00 committed by Chummy
parent b3b1679218
commit 73e675d298
5 changed files with 98 additions and 2 deletions

View file

@ -781,6 +781,12 @@ pub struct MemoryConfig {
/// Auto-hydrate from MEMORY_SNAPSHOT.md when brain.db is missing
#[serde(default = "default_true")]
pub auto_hydrate: bool,
// ── SQLite backend options ─────────────────────────────────
/// For sqlite backend: max seconds to wait when opening the DB (e.g. file locked).
/// None = wait indefinitely (default). Recommended max: 300.
#[serde(default)]
pub sqlite_open_timeout_secs: Option<u64>,
}
fn default_embedding_provider() -> String {
@ -845,6 +851,7 @@ impl Default for MemoryConfig {
snapshot_enabled: false,
snapshot_on_hygiene: false,
auto_hydrate: true,
sqlite_open_timeout_secs: None,
}
}
}
@ -2279,6 +2286,7 @@ default_temperature = 0.7
assert_eq!(m.archive_after_days, 7);
assert_eq!(m.purge_after_days, 30);
assert_eq!(m.conversation_retention_days, 30);
assert!(m.sqlite_open_timeout_secs.is_none());
}
#[test]