08 — Data, storage and secrets

PostgreSQL
Two physical roles of Postgres, same major version:
| Cluster | Hosts | Why separate |
|---|---|---|
Core (core-infra) | Zitadel DB, control-plane schema, Infisical DB, Pulumi state, pg-boss | Low, predictable load; strict HA/PITR; isolated from tenant spikes |
Tenant data pool (tenant-data-pool) | meet_<slug> databases, N shards | Bursty; hard DB boundary per tenant; blast radius = one shard |
Core conventions (kept from AGENTS.md)
One database (platform), one schema and role per product:
NN_init_<product>.sh idempotent scripts, search_path per role, default
privileges. Existing scripts: 01_init_platform, 02_init_meet (meet — will
move to the tenant pool), 03_init_keycloak (deprecated), 04_init_zitadel
(dedicated database per Zitadel's DSN).
Planned additions: 05_init_control_plane.sh (schema control_plane),
06_init_infisical.sh, 07_init_pulumi_state.sh (Pulumi's Postgres backend
uses its own table/DB). The same copy-adapt-run-manually procedure applies;
Postgres only runs init scripts on an empty data directory.
Tenant pool conventions
CREATE DATABASE meet_<slug> OWNER meet_<slug>_app; revokePUBLICconnect, grant only the app role. Extensions pre-created by superuser as in02_init_meet.sh(e.g.pg_trgm, needed by migrationcore.0002).- PgBouncer, transaction pooling; go-meet
max_open_conns=3, max_idle_conns=1. - go-meet migrations (
sql/migrations, currently through000013) run per tenant by the provisioner and on rollout, bounded concurrency, withschema_versiontracked in the registry. - TLS required (
sslmode=require); credentials from Infisical.
Object storage (RustFS)
- Bucket per tenant, key prefixes
recordings/,transcripts/, laterfiles/,chat-media/. Never a shared bucket with tenant prefixes: a path bug must not cross tenants. - Scoped access key per tenant limited by policy to that bucket. Used by go-meet for presign and by Egress per request. The RustFS root credential exists only in the provisioner's secret scope.
- Lifecycle rules at provisioning: expire
recordings/after the tenant's retention (default 30 days, configurable 7–90), abort incomplete multipart uploads after 2 days. - Presigned URLs only (15 minutes); no public buckets; direct browser ↔ RustFS transfers so the API tier never proxies media.
- Encryption at rest: RustFS supports SSE-S3 (
AES256), SSE-C and SSE-KMS. Per its docs, SSE-S3/SSE-KMS require a working KMS configuration and a provisioned key; setting a bucket default alone does not make writes succeed. The documented KMS backends are local, Vault KV2 and Vault Transit. Infisical is not a documented RustFS KMS backend, contrary to the discussion. Plan: start with SSE-S3 using the local KMS key held in/platform/rustfs; evaluate OpenBao/Vault Transit for per-tenant keys (Q-07). Downloads are transparently decrypted by RustFS on authorized reads.
Redis
| Instance | Used by | Notes |
|---|---|---|
| Core Redis (shared) | LiveKit node/room routing, CP cache | Auth + TLS; LiveKit's TLS settings injected by sed placeholders as in livekit-server.yaml |
| Tenant Redis | go-meet sessions, lobby, room-creation callbacks, throttling | One container per tenant, requirepass, TTL-bound data; required in production (in-memory store is mock/test only) |
Secrets (Infisical, shared — D2)
Layout
/platform/zitadel masterkey, login-client PAT (bootstrap)
/platform/livekit API key/secret (broker only)
/platform/pulumi secrets-provider key
/platform/coolify API token (worker only)
/platform/rustfs root creds, SSE key
/platform/backup backup key escrow
/tenants/<slug>/meet OIDC client, service-account key, DB URL,
S3 scoped key, webhook signing secret, session keys
/tenants/<slug>/chat Tuwunel config, appservice tokens
Access model
| Identity | Reads | Writes |
|---|---|---|
| CP worker | all of /platform/* it needs, /tenants/* (provisioning) | /tenants/* |
| CP broker | /platform/livekit only | — |
Tenant stack <slug>-stack | /tenants/<slug>/* | — |
| Humans | break-glass only, audited | via change process |
Distribution
Coolify holds only the stack's Infisical machine-identity credentials (and
non-secret config). The container entrypoint runs
infisical run --path /tenants/<slug>/meet -- go-meet, so real secrets never
persist in Coolify's database. Rotation = write new version → restart stack →
revoke old.
Infisical depends on Postgres and Redis; running it on the shared core instances is intended. Keep its
ENCRYPTION_KEY/auth secret in the host secret store with an offline escrow copy: losing it means losing every secret.
Application-level encryption already in go-meet
- OIDC refresh tokens stored in Redis sessions are Fernet-encrypted with
OIDC_STORE_REFRESH_TOKEN_KEY(changing the key invalidates those sessions by design). - Session cookie: HttpOnly, Secure, SameSite=Lax.
Backups
| Data | Method | Where | Retention |
|---|---|---|---|
| Tenant DB | pg_dump -Fc per DB, nightly + before migrations | Separate bucket/host, encrypted (age, per-tenant key) | 14–30 days |
| Core DB | PITR (WAL archiving) | Separate target | 7–14 days + weekly full |
| Tuwunel | Volume snapshot / supported backup, quiesced | Separate target, encrypted | 14 days |
| RustFS | Not replicated by default (recordings are lifecycle-bound) | — | — |
| Infisical | DB backup + ENCRYPTION_KEY escrow | Separate target | 30 days |
Restore drills: quarterly, per backup class, with timing recorded. Tenant erasure destroys that tenant's backup key (crypto-erase), so backups outside retention need no scrubbing.
Retention defaults (configurable per tenant)
| Artifact | Default |
|---|---|
| Recordings (audio/video) | 30 days |
| Transcripts / summaries | 12 months (or until tenant deletes) |
| Chat messages | until tenant policy / deletion |
| Meeting metadata | 24 months |
| Audit log (ids only) | 24 months |