diff --git a/src/agent_comms/coordination/database.py b/src/agent_comms/coordination/database.py index 92301520c0..b90570a5cd 100644 --- a/src/agent_comms/coordination/database.py +++ b/src/agent_comms/coordination/database.py @@ -140,9 +140,9 @@ def configure_connection(cls, connection: sqlite3.Connection) -> None: connection.execute("PRAGMA foreign_keys = ON") # WAL is set once, on the private stage before the file is published (or by the # coordinator_wal carry with every owner stopped), and persists in the file header, so - # no opener switches the mode and fresh openers cannot race over it. A commit is one - # sync of the log; the rollback journal took three (journal, file, directory). - connection.execute("PRAGMA synchronous = FULL") + # no opener switches the mode and fresh openers cannot race over it. The durability of + # a commit is the one StoreWriter policy every WAL writer shares, not a literal here. + connection.execute(f"PRAGMA synchronous = {cls.synchronous}") def _prepare_private_file(self) -> None: self.path.parent.mkdir(parents=True, exist_ok=True) diff --git a/src/agent_comms/storage/typed_table.py b/src/agent_comms/storage/typed_table.py index 1d1f10cfde..e3b181c667 100644 --- a/src/agent_comms/storage/typed_table.py +++ b/src/agent_comms/storage/typed_table.py @@ -3274,6 +3274,14 @@ class StoreWriter(PublishedSQLiteFile): CarriedFile kind or RuntimeFile, and a TypedStore inherits DurableStore or DerivedStore. """ + # The durability every WAL writer here applies, declared once for the family. WAL keeps + # the database file consistent at every synchronous level, so NORMAL is correct and loses + # nothing an application crash could take: only an OS crash or power loss can roll a WAL + # back, and only to the last checkpoint. FULL fsynced the log on every commit; a message + # ping committed ~58 times across the coordinator stores and paid ~58 fsyncs for it. A + # store that must survive power loss raises its own bar (goal stores declare EXTRA). + synchronous: ClassVar[str] = "NORMAL" + @property @abstractmethod def store(self) -> WrittenFile: @@ -3518,9 +3526,9 @@ class RuntimeWriter(RuntimeFile, StoreWriter): class WalStore(SQLiteReader, StoreWriter, StoreLockFile): - """One WAL file owns connection setup, attachment and retirement.""" + """One WAL file owns connection setup, attachment and retirement. - synchronous: ClassVar[str] = "FULL" + Its durability is StoreWriter.synchronous; a store that needs more overrides it.""" def _create_file(self) -> None: """Create only a new inode; never close a descriptor for a live SQLite inode."""