Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(store): drop the PRAGMA optimize at Store::open from the #1257 patch
AkitaOnRailsdd083e1e39f4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5e3829ff..5960e2a8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,10 +24,7 @@ version in [`docs/changelog/`](docs/changelog/):rescanned the whole project once per session; the probe now always uses thesession index (0.3 s on the same store). The session list and sessiondetail reads behind `/web`, `/api/v1` and `memory_read_session_observations`- ran the same per-session probes and are pinned the same way. The store also refreshes SQLite's- planner statistics on every start (`PRAGMA optimize`), which it had never- done. The first start of an existing store analyzes it once (about 12 s for- a 1.6 GB store); later starts only check table sizes. (#1257)+ ran the same per-session probes and are pinned the same way. (#1257)## [3.0.0] - 2026-10-13diff --git a/crates/ai-memory-store/src/lib.rs b/crates/ai-memory-store/src/lib.rsindex 64efc771..419f45c8 100644--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@ -201,19 +201,6 @@ impl Store {);}- // Refresh planner statistics, as SQLite recommends for a long-lived- // connection. Without `sqlite_stat1` the planner ranks indexes by- // equality-column count alone and can pick one that scans a whole- // project per row. This analyzes only tables lacking statistics or- // grown/shrunk tenfold since the last run, each capped by SQLite's- // built-in optimize analysis limit: the first open of a never-analyzed- // store pays once (about 12 s for a 1.6 GB store on an ARM VM), later- // opens are a size check per table. It runs here, not on a timer,- // because ANALYZE does not bump the schema cookie: pooled read- // connections keep the statistics they loaded when they opened, and- // they all open after this point.- conn.execute_batch("PRAGMA optimize=0x10002;")?;-let writer = WriterHandle::spawn(conn);let reader = ReaderPool::new(&db_path, READER_POOL_SOFT_CAP)?;Ok(Self {diff --git a/crates/ai-memory-store/tests/suite/session_observations.rs b/crates/ai-memory-store/tests/suite/session_observations.rsindex c4a1cf99..693e57ca 100644--- a/crates/ai-memory-store/tests/suite/session_observations.rs+++ b/crates/ai-memory-store/tests/suite/session_observations.rs@@ -826,24 +826,3 @@ async fn consolidation_queue_counts_states_and_bounds_times() {});}--/// Nothing else ever runs ANALYZE, so a store that never refreshed planner-/// statistics on open kept none for its whole life, and the planner then-/// rescanned a project's observations once per session for the per-agent-/// counts. Reopening a populated store must leave statistics for the index-/// that bounds those probes.-#[test]-fn reopening_a_populated_store_records_planner_statistics() {- let (tmp, store) = open_seeded();- drop(store);- let store = Store::open(tmp.path()).unwrap();- let conn = Connection::open(store.db_path()).unwrap();- let analyzed: i64 = conn- .query_row(- "SELECT COUNT(*) FROM sqlite_stat1 WHERE idx = 'idx_observations_session'",- [],- |row| row.get(0),- )- .unwrap();- assert_eq!(analyzed, 1);-}diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 39093fed..6c8a304f 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -419,10 +419,7 @@ prunable rather than only after it ages in place.reconciles outside edits.* `<data_dir>/db/memory.sqlite`: derived index. WAL mode. Onewriter actor owns the writer `Connection`; reads go through a- cloneable read-only pool. Every open runs `PRAGMA optimize=0x10002`- before the pool opens, so planner statistics exist and follow tenfold- table growth; the first open of a never-analyzed store pays a one-time- limited ANALYZE.+ cloneable read-only pool.* `<data_dir>/raw/`: immutable sanitized managed-workstream JSONL segments.Legacy raw fallback recall searches the durable `observations` table viaFTS5; lifecycle HookEnvelope JSON is not a complete transcript archive.