fix(audit): persist audit chain to SQLite WAL store on every append (AUDIT-001) - #276
Merged
Merged
Conversation
…AUDIT-001) Closes #145. Adds SqliteAuditStore that writes each AuditEntry synchronously (WAL mode, PRAGMA synchronous=FULL) before AuditChain.append() returns, so a crash or OOM kill cannot silently erase audit history. On gateway startup, orphaned sessions (session_start with no session_end) are detected and logged as a WARNING so operators can identify sessions that were open when the gateway last stopped. Config: add audit_db_path (default audit.db). Injected into RuntimeContext; SessionManager passes the store to every AuditChain it creates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Jun 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SqliteAuditStore(audit/store.py) — writes eachAuditEntrysynchronously to an SQLite WAL DB beforeAuditChain.append()returns. A crash or OOM kill can no longer silently erase audit history.session_endin the DB) trigger aWARNINGlog so operators can identify sessions open at time of last crash.audit_db_pathfield (defaultaudit.db). Injected intoRuntimeContext;SessionManagerpasses it to everyAuditChain.Closes #145. Supersedes #188 (already closed as duplicate).
Test plan
pytest tests/unit/test_audit_sqlite.py— all 7 passpytest tests/unit/— 592 pass, 2 pre-existing benchmark failures unrelatedaudit.dbis created and orphan check logs nothing🤖 Generated with Claude Code