Skip to main content

Crate gatekeep_sqlx

Crate gatekeep_sqlx 

Source
Expand description

SQLx support for gatekeep query lowering and durable decision audit.

This crate lowers a gatekeep::ResidualPolicy into trusted SQL fragments that can be appended to a sqlx::QueryBuilder.

It also provides Dovecote-backed gatekeep::AuditSink implementations for Postgres, SQLite, and MySQL. Run the selected Dovecote migration, call the adapter’s check_schema, configure an application-owned absolute event source, and pass the sink to gatekeep_axum::Gatekeeper.

Gatekeep does not maintain a SQL audit table. Each decision is serialized as one complete Dovecote event with a pending delivery. Use the concrete record_decision_audit_in_transaction method when application writes and the audit event need one caller-owned transaction.

Structs§

DecisionAuditConfig
Configuration required to write Gatekeep audit events.
NoGradeProjection
Projection that rejects grade lowering.
OrdinalProjection
Outcome projection backed by SqlOutcome.
PgDovecoteAudit
Postgres Dovecote-backed decision audit sink.
PostgresBackend
Postgres backend marker.
SqlxFragment
Trusted SQL plus ordered bind values for one SQLx backend.
SqlxLowerer
SQLx lowerer for gatekeep residual policies.

Enums§

DecisionAuditConfigError
Errors while validating the application-owned audit source.
DecisionAuditDecodeError
Errors returned while decoding a Dovecote event as a Gatekeep decision audit entry.
DecisionAuditEventError
Errors while converting a typed Gatekeep entry into a validated Dovecote event.
PgDovecoteAuditError
Errors returned by PgDovecoteAudit.
SqlxDriver
Supported SQLx database driver.
SqlxDriverError
Database driver configuration error.
SqlxValue
Scalar value carried by a lowered SQL fragment.

Constants§

DECISION_AUDIT_CONTENT_TYPE
The explicit JSON content type used for every decision audit event.
DECISION_AUDIT_EVENT_TYPE
The durable event type for Gatekeep decision audit events.
DEFAULT_AUDIT_STREAM
The default Dovecote stream for Gatekeep decision audit events.

Traits§

GatekeepSqlxBackend
SQLx backend supported by gatekeep lowering.
OutcomeProjection
Projection strategy for turning outcomes into SQL fragments.
PgFactPredicates
Maps a residual fact to a trusted Postgres predicate over the candidate row.
SqlOutcome
Maps a policy outcome to a total-order SQL ordinal.
SqlxFactPredicates
Maps a residual fact to a trusted predicate over the candidate row.

Functions§

decode_decision_audit
Decodes a Dovecote event from either live or snapshot paging into the complete typed Gatekeep audit entry.
infer_enabled_driver_from_url
Infers the SQLx driver from a database URL or SQLx-style SQLite memory URL.
validate_database_url_for_backend
Validates that a database URL matches a selected backend.

Type Aliases§

PgFragment
Trusted Postgres SQL plus ordered bind values.
PgLowerer
Postgres lowerer for gatekeep residual policies.
PgValue
Postgres scalar value carried by a lowered SQL fragment.