Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
queuefs: enable SQLite auto-vacuum for new queue databases (#2754)
Ben Sharir42891b9a0744
diff --git a/crates/ragfs/src/plugins/queuefs/backend.rs b/crates/ragfs/src/plugins/queuefs/backend.rsindex 253c2281a..13e88bf01 100644--- a/crates/ragfs/src/plugins/queuefs/backend.rs+++ b/crates/ragfs/src/plugins/queuefs/backend.rs@@ -336,6 +336,16 @@ impl SQLiteQueueBackend {.map_err(|e| Error::internal(format!("sqlite busy_timeout error: {}", e)))?;}+ if Self::is_new_database(&conn)? {+ conn.execute_batch(+ r#"+ PRAGMA auto_vacuum=FULL;+ VACUUM;+ "#,+ )+ .map_err(|e| Error::internal(format!("sqlite auto_vacuum pragma error: {}", e)))?;+ }+conn.execute_batch(r#"PRAGMA journal_mode=WAL;@@ -375,6 +385,17 @@ impl SQLiteQueueBackend {Ok(backend)}+ fn is_new_database(conn: &Connection) -> Result<bool> {+ let table_count: i64 = conn+ .query_row(+ "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'",+ [],+ |row| row.get(0),+ )+ .map_err(|e| Error::internal(format!("sqlite schema probe error: {}", e)))?;+ Ok(table_count == 0)+ }+fn run_migrations(&self) -> Result<()> {let conn = self.conn@@ -1029,6 +1050,49 @@ mod tests {);}+ #[test]+ fn test_sqlite_backend_enables_full_auto_vacuum_for_new_databases() {+ let (_dir, db_path, _backend) = sqlite_backend();++ let conn = Connection::open(db_path).unwrap();+ let auto_vacuum: i64 = conn.query_row("PRAGMA auto_vacuum", [], |row| row.get(0)).unwrap();+ assert_eq!(auto_vacuum, 1);+ }++ #[test]+ fn test_sqlite_backend_does_not_rewrite_existing_auto_vacuum_mode() {+ let dir = tempdir().unwrap();+ let db_path = dir.path().join("legacy-auto-vacuum.db");+ let db_path_str = db_path.to_str().unwrap().to_string();++ let conn = Connection::open(&db_path_str).unwrap();+ conn.execute_batch(+ r#"+ PRAGMA auto_vacuum=NONE;+ CREATE TABLE queue_metadata (+ queue_name TEXT PRIMARY KEY,+ created_at INTEGER DEFAULT (strftime('%s', 'now')),+ last_updated INTEGER DEFAULT (strftime('%s', 'now'))+ );+ CREATE TABLE queue_messages (+ id INTEGER PRIMARY KEY AUTOINCREMENT,+ queue_name TEXT NOT NULL,+ message_id TEXT NOT NULL,+ data TEXT NOT NULL,+ timestamp INTEGER NOT NULL+ );+ "#,+ )+ .unwrap();+ drop(conn);++ let _backend = SQLiteQueueBackend::open(&db_path_str, SQLiteQueueOptions::default()).unwrap();++ let conn = Connection::open(&db_path_str).unwrap();+ let auto_vacuum: i64 = conn.query_row("PRAGMA auto_vacuum", [], |row| row.get(0)).unwrap();+ assert_eq!(auto_vacuum, 0);+ }+#[test]fn test_sqlite_backend_operations_on_nonexistent_queue() {let (_dir, _db_path, mut backend) = sqlite_backend();