buzz-db: check events created_at floor in the app writers (phase 1)

Every channel-bearing INSERT INTO events now checks created_at against
database clock_timestamp() minus CREATED_AT_FLOOR_SECS on the admitted
transaction before inserting, and returns the typed, non-retryable
DbError::CreatedAtFloorRejected. The check samples the clock after BEGIN,
so the replica-fence wall min(oldest_xact_start, S) - floor - margin
still covers it. Migration 0021's deferred trigger and the writer-pool
GUC stay in place as the mixed-version backstop until phase 2.

A source policy requires the check on every channel-bearing events
INSERT and forbids production UPDATEs of events.created_at/channel_id.
The admin seed script now refuses non-local PGHOST.

Refs BUZZ-316.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
Elrond
2026-10-14 13:49:57 -04:00
parent e68977f270
commit 7d21362bb9
15 changed files with 685 additions and 65 deletions

View File

@@ -19,6 +19,15 @@ export PGUSER="${PGUSER:-buzz}"
export PGPASSWORD="${PGPASSWORD:-buzz_dev}"
export PGDATABASE="${PGDATABASE:-buzz}"
# This raw fixture writer is unarmed and must never target a live replica fence.
case "${PGHOST}" in
localhost|127.0.0.1|::1|/*) ;;
*)
echo "error: admin seed requires a local PostgreSQL target (PGHOST=${PGHOST})" >&2
exit 1
;;
esac
if command -v psql >/dev/null 2>&1; then
run_psql() {
PGPASSWORD="${PGPASSWORD}" psql -h "${PGHOST}" -p "${PGPORT}" \