Persistence
Persistence
Alpha
DSAR is currently in alpha. APIs, package surfaces, configuration, and documentation may change as the project evolves.
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
| Driver | Package | Best For |
|---|---|---|
| Postgres | @dsar/persistence-pg | Production deployments with advisory-lock migration protection |
| SQLite | @dsar/persistence-sqlite | Local 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:
| Record | Purpose |
|---|---|
RequestRecord | DSAR request state and metadata |
AuditEventRecord | Tamper-evident audit trail |
ClockSegmentRecord | Compliance clock tracking |
FulfillmentArtifactRecord | Delivery artifact references |
PolicyAssignmentRecord | Jurisdiction policy bindings |
VerificationEvidenceRecord | Identity verification evidence |
RetentionPolicyRecord | Data retention schedules |
NotificationEventRecord | Notification lifecycle |
ChatStateRecord | Conversational state for inbound adapters |
Choosing a Driver
- Starting out? Use
persistence-sqlitewith in-memory mode for instant setup. - Production? Use
persistence-pgfor Postgres with advisory-lock migration protection.