Repository navigation
buzz-db: move the audit log SQL behind an AuditLog store - #10090
Open
TheSentinel454 wants to merge 6 commits into
Open
TheSentinel454 wants to merge 6 commits into
TheSentinel454 wants to merge 6 commits into
Conversation
TheSentinel454
requested review from
a team,
bradseiler,
ravarora2,
salman1993 and
wpfleger96
as code owners
December 1, 2026 21:55
🔐 Codex Security Review
|
TheSentinel454
had a problem deploying
to
codex-review
December 1, 2026 22:02 — with
GitHub Actions
Error
TheSentinel454
force-pushed
the
elrond/buzz-811-audit-store
branch
from
December 1, 2026 22:55
a810c87 to
23d48a3
Compare
Two merges each added tracing-subscriber to buzz-db's dev-dependencies. Cargo refuses a manifest with a duplicate key, so main does not build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
…he pool Production code outside buzz-db reached the writer pool through Db::pool() in five places. Each now calls a named Db method: - Db::insert_mentions (audio 48101 mentions) - Db::enable_search_outbox (relay startup) - Db::acquire_timeout (shared-read wait budget) - Db::session_identity (buzz-admin partition-audit read-only check) - the deletion worker clones its Db instead of rebuilding one from the pool The free insert_mentions and search_outbox::enable become crate-private. buzz-admin and buzz-deletion no longer use sqlx in production, so it moves to their dev-dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
SessionIdentity::is_read_only holds the check buzz-admin runs before partition-audit, with a table test of all four setting combinations. The docs now call the flags session settings: they do not show what the role is allowed to write. The session_identity Postgres test uses the fixture database instead of creating its own, so it needs no CREATEDB. The feed module doc names both mention-indexing paths: in the event transaction, and after commit for huddle mentions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
buzz-audit ran its own SQL on a raw pool: the admission guard, the chain lock, the head read, the insert, and the range reads. That SQL now lives in buzz_db::AuditLog, which owns the audit pool. - AuditLog::connect builds the audit pool (5 connections, audit role), which the relay used to build itself. - AuditLog::append takes a closure: buzz-audit builds and hashes the row from the chain head, inside the same transaction and locks. - AuditService::new takes an AuditLog instead of a PgPool. - AuditError::Database holds a DbError instead of sqlx::Error. Only AccessDenied maps to Admission. - The relay's retry check uses DbError::is_lock_timeout and is_statement_cancelled instead of matching SQLSTATE codes. - guard_community_write becomes crate-private: buzz-audit was its only outside caller. buzz-audit no longer uses sqlx in production, so it moves to its dev-dependencies. The audit pool GUC test moves from the relay to buzz-db. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Admission-step failures render a fixed message again, as they did before the move. The inner DbError keeps its type, so a lock or statement timeout on the admission lock is still retried. AuditLog::append now checks that the row extends the locked head: seq is one past the head's and prev_hash equals the head's hash. A test holds the chain lock while a fenced append must still be refused, which pins admission before the chain lock. Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Database errors render transparently now that admission failures have their own fixed text. AuditAppendError documents that a connection failure during commit can leave the outcome unknown. Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
TheSentinel454
force-pushed
the
elrond/buzz-811-audit-store
branch
from
December 2, 2026 00:10
23d48a3 to
a626713
Compare
TheSentinel454
changed the base branch from
main
to
elrond/buzz-811-relay-db-boundary
December 2, 2026 00:11
TheSentinel454
force-pushed
the
elrond/buzz-811-relay-db-boundary
branch
from
December 2, 2026 02:56
f1e2577 to
b2bfb90
Compare
This branch was successfully deployed
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.
Stacked on #10087. Merge that first.
Summary
buzz-auditran its own SQL on a raw pool: the community admission guard, the chain lock, the head read, the insert, and the range reads. That SQL now lives in abuzz_db::AuditLogstore, which owns the audit pool.buzz-auditkeeps the chain logic: it builds and hashes each row and verifies ranges.AuditLog::connectbuilds the audit pool (5 connections,auditrole). The relay used to build it itself.AuditLog::appendruns one transaction: admission, chain lock, head read, then a closure thatbuzz-audituses to build and hash the row, then the insert. The lock order and transaction scope are unchanged.AuditService::newtakes anAuditLoginstead of aPgPool.AuditError::Databaseholds aDbErrorinstead ofsqlx::Error. OnlyDbError::AccessDeniedmaps toAdmission.DbError::is_lock_timeoutand the existingis_statement_cancelled, instead of matching SQLSTATE codes onsqlxerrors.deletion::guard_community_writebecomes crate-private.buzz-auditwas its only outside caller.This is the second of three steps that take raw pool access and SQL out of every crate except
buzz-db. The first is #10087. The last moves the search pool and SQL.What got simpler
buzz-audithas no SQL. It still depends onsqlxonly because the datastore span trait (DatastoreSpanError::span_sqlx_error) namessqlx::Error; that dependency goes when the trait stops naming it.AuditErrorno longer has two variants that can both hold the same database failure.ARCHITECTURE.md"sanctioned exception" now names one store handle instead of a deletion internals function.Behavior
No behavior change. Retry classification is the same: a lock timeout (55P03) or statement cancel (57014) anywhere in the append retries; admission refusal is terminal.
Tests
audit_pool_installs_timeouts_and_bounds_advisory_lock_waitsinbuzz-db(moved from the relay, now throughAuditLog::connect; also checks the pool size).db_errors_split_into_admission_and_databasepins theDbError→AuditErrormapping the relay retry check depends on.buzz-auditPostgres tests (admission, chain links, per-community isolation, tamper detection) run unchanged through the new store.-D warnings) onbuzz-db,buzz-audit,buzz-relay; unit tests for those crates; the Postgres tests forbuzz-audit, the newbuzz-dbtest, and relay audit tests.🤖 Generated with Claude Code