Persistence

Persistence

DSAR uses persistence drivers to store request state, audit events, policy assignments, and all other domain records in a database. Each driver implements the same PersistenceDriver contract, so you can swap databases without changing application code.

Available Drivers

DriverPackageBest For
Postgres@dsar/persistence-pgProduction deployments with advisory-lock migration protection
SQLite@dsar/persistence-sqliteLocal development, testing, and lightweight deployments

How Persistence Works

The persistence layer is tenant-scoped — every database operation runs within a tenant context. The withTenant helper scopes Effect programs to a specific tenant:

Domain Records

The persistence layer manages these record types:

RecordPurpose
RequestRecordDSAR request state and metadata
AuditEventRecordTamper-evident audit trail
ClockSegmentRecordCompliance clock tracking
FulfillmentArtifactRecordDelivery artifact references
PolicyAssignmentRecordJurisdiction policy bindings
VerificationEvidenceRecordIdentity verification evidence
RetentionPolicyRecordData retention schedules
NotificationEventRecordNotification lifecycle
ChatStateRecordConversational state for inbound adapters

Choosing a Driver

  • Starting out? Use persistence-sqlite with in-memory mode for instant setup.
  • Production? Use persistence-pg for Postgres with advisory-lock migration protection.

Wiring with the Backend

Related