GebSecure Docs v0.1.0

Architecture · All ADRs

ADR 0007 — Decision hot path: lazy transactions, one write, one Redis pipeline

Architecture decision record — status: Accepted.

Status: Accepted

Context#

EPIC 4 targets P95 < 20 ms for a simple authorization decision while still auditing every decision durably.

Decision#

  • Compiled policy sets, environment rows and risk rules are cached in-process and validated against a per-org version stamp in Redis; any authorization-affecting change bumps the stamp.
  • Authentication folds the rate-limit counter and the revocation check into one Redis pipeline; risk history (velocity, denials, baseline, alerts) plus the version stamp are one more.
  • Database.tenantLazy() opens a transaction only if a cache miss needs one. The decision record (risk assessment + audit ingest + outbox events) is written by one SECURITY DEFINER statement (gs_record_decision) which stamps every row with the caller's org.
  • Audit stays synchronous and durable (no synchronous_commit=off).

Consequences#

Measured on the development machine (Docker Desktop on Windows, ~1 ms per backend round trip): P50 10 ms / P95 14 ms single-stream. Throughput under concurrency on that machine is bounded by the virtualized disk and network relay (~360 decisions/s regardless of gateway workers); verification under production load belongs to EPIC 26.