Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.
Rust ai-agentsclaude-codeclicodexcoding-agentskanbanlocal-firstmcpmcp-servermodel-context-protocolproductivityproject-managementraspberry-pirustself-hostedsqlitetask-manager
Use a rollback journal instead of WAL
emanuele-em5fc49743b903
diff --git a/src/home.rs b/src/home.rsindex ebe3aed..7e89511 100644--- a/src/home.rs+++ b/src/home.rs@@ -25,10 +25,10 @@ mcp_http = true"#;const GITIGNORE: &str = "\-# SQLite temporary files; kanzo sync folds them into kanzo.db first.+# SQLite temporary files; kanzo sync makes sure kanzo.db is complete without them.+kanzo.db-journalkanzo.db-walkanzo.db-shm-kanzo.db-journal# Local to this machine.kanzo.lock*.bakdiff --git a/src/store.rs b/src/store.rsindex d4e1761..a8fc420 100644--- a/src/store.rs+++ b/src/store.rs@@ -1,4 +1,9 @@//! All reads and writes of `kanzo.db`. Plain SQL, one short-lived connection per operation.+//!+//! The database uses a rollback journal (`journal_mode = TRUNCATE`), not WAL. With a+//! connection per operation, WAL would set up and tear down its `-wal` and `-shm` files+//! on every request; the rollback journal makes a read touch no extra files at all and+//! measured about 3x faster per operation. Writes queue on the busy timeout.use std::fmt;use std::path::Path;@@ -100,8 +105,11 @@ impl Store {let conn = Connection::open(path)?;// The board and any number of agents share this file; wait instead of failing.conn.busy_timeout(Duration::from_secs(5))?;- conn.pragma_update_and_check(None, "journal_mode", "WAL", |_| Ok(()))?;- conn.pragma_update(None, "synchronous", "NORMAL")?;+ // Per connection, not stored in the file. Also turns a WAL database from an+ // older kanzo back into a rollback-journal one once nothing else has it open.+ // `synchronous` stays at SQLite's default FULL, which keeps the file intact+ // when a board loses power.+ conn.pragma_update_and_check(None, "journal_mode", "TRUNCATE", |_| Ok(()))?;conn.pragma_update(None, "foreign_keys", "ON")?;Ok(Self { conn, statuses, _lock: lock })}@@ -169,12 +177,10 @@ impl Store {Ok(self.conn.query_row(&format!("SELECT {NOW}"), [], |r| r.get(0))?)}- /// Moves everything from the WAL into `kanzo.db`, so the file alone is complete.- pub fn checkpoint(&self) -> Result<()> {- let busy: i64 = self.conn.query_row("PRAGMA wal_checkpoint(TRUNCATE)", [], |r| r.get(0))?;- if busy != 0 {- return Err(Error::Invalid("the database is busy; try again in a moment".into()));- }+ /// Makes `kanzo.db` complete on its own: rolls back a write that a crashed process+ /// left half done, and folds in a WAL left by an older kanzo.+ pub fn settle(&self) -> Result<()> {+ self.conn.query_row("SELECT count(*) FROM meta", [], |r| r.get::<_, i64>(0))?;Ok(())}diff --git a/src/sync.rs b/src/sync.rsindex fcc7018..47e0cd3 100644--- a/src/sync.rs+++ b/src/sync.rs@@ -35,7 +35,7 @@ pub fn sync(home: &Home, keep: Option<Keep>) -> Result<()> {let lock = home.lock_exclusive()?;{let store = crate::store::Store::open(&home.db_path(), home.config.statuses.clone(), None)?;- store.checkpoint()?;+ store.settle()?;}git(dir, &["add", "--all"])?;if !git_ok(dir, &["diff", "--cached", "--quiet"]) {