Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/agent_comms/coordination/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/agent_comms/storage/typed_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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."""
Expand Down
Loading