Skip to content

Improve SQLite concurrency and document EMILIA collaboration - #2

Open
TochusC wants to merge 1 commit into
masterfrom
codex/sqlite-concurrency-collaboration
Open

Improve SQLite concurrency and document EMILIA collaboration#2
TochusC wants to merge 1 commit into
masterfrom
codex/sqlite-concurrency-collaboration

Conversation

@TochusC

@TochusC TochusC commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • enable SQLite WAL mode and a 30-second busy timeout for replay, agent, and message stores
  • roll back failed writes and commit replay nonce pruning so write locks are released reliably
  • add regression coverage for concurrent access and transaction cleanup
  • add a README Collaboration section recognizing Iman Schrock and the EMILIA Protocol EP-receipt-over-ATP demo

Testing

  • 251 passed, 1 warning

Copilot AI review requested due to automatic review settings July 18, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves SQLite-backed storage reliability under contention by switching key stores to WAL mode with a consistent busy timeout, and by ensuring failed writes don’t leave transactions open (which can retain write locks). It also adds regression tests for concurrency/lock cleanup behavior and updates the README with a Collaboration acknowledgment.

Changes:

  • Enable SQLite WAL mode and set a 30s busy timeout for replay, agent, and message stores.
  • Add explicit rollbacks on failed writes and commit replay nonce pruning to release locks reliably.
  • Add regression tests for WAL/busy-timeout configuration and for ensuring rejected writes don’t leave locks behind; update README Collaboration section.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_replay.py Adds WAL/busy-timeout assertions and regression tests ensuring replay persistence failures don’t leave locks behind and pruning commits deletions.
tests/test_messages.py Adds regression coverage that duplicate-nonce enqueue doesn’t leave a write lock, plus WAL/busy-timeout assertions.
tests/test_agents.py Adds regression coverage that duplicate registration doesn’t leave a write lock, plus WAL/busy-timeout assertions.
src/atp/storage/messages.py Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on integrity errors to release locks.
src/atp/storage/agents.py Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on integrity errors to release locks.
src/atp/security/replay.py Configures SQLite connection with timeout + WAL + busy_timeout; rolls back on SQLite errors and commits prune deletions to release locks.
README.md Adds Collaboration section and updates top link row and contributing test command wording.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +43
self._conn = sqlite3.connect(str(db_path), timeout=30)
self._conn.row_factory = sqlite3.Row
self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA busy_timeout=30000")
Comment thread src/atp/storage/agents.py
Comment on lines +28 to +30
self._conn = sqlite3.connect(str(self._db_path), timeout=30)
self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA busy_timeout=30000")
Comment on lines +45 to +47
self._conn = sqlite3.connect(str(self._db_path), timeout=30)
self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA busy_timeout=30000")
Comment thread tests/test_replay.py
def test_sqlite_connection_uses_wal_and_busy_timeout(self, tmp_path):
guard = ReplayGuard(db_path=tmp_path / "nonces.db")
assert guard._conn is not None
assert guard._conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal"
Comment thread tests/test_messages.py

def test_sqlite_connection_uses_wal_and_busy_timeout(self, tmp_path: Path) -> None:
store = MessageStore(db_path=tmp_path / "test.db")
assert store._conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal"
Comment thread tests/test_agents.py

def test_sqlite_connection_uses_wal_and_busy_timeout(self, store):
conn = store._get_conn()
assert conn.execute("PRAGMA journal_mode").fetchone()[0] == "wal"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants