Data, storage and secrets
Postgres sharding, RustFS, Infisical and keys.

PostgreSQL
Two physical roles of Postgres, same major version:
| Cluster | Hosts | Why separate |
|---|---|---|
Core (fortspace-platform) |
Zitadel DB, control-plane schema, Infisical DB, Pulumi state, pg-boss | Low, predictable load; strict HA/PITR; isolated from tenant spikes |
Tenant data pool (fortspace-data-pool) |
meet_<slug> databases, N shards |
Bursty; hard DB boundary per tenant; blast radius = one shard. The base stack creates only the project + environment on the fortspace-data-net network; shard instances are created on demand by the control plane’s shard.add |
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).
The base stack (bastion/) applies the same conventions through its
core-postgres-bootstrap one-shot (idempotent, re-runnable): dedicated
databases zitadel / infisical / pulumi_state, and in platform the
schemas control_plane (role control_plane, search_path set, plus
GRANT CREATE ON DATABASE — createdb flag — so the CP may create
databases) and pgboss (pg-boss queue schema, secondary schema of the same
role, no search_path). Postgres only runs init scripts on an empty data
directory, which is why Coolify’s database resource cannot be used for this.
Transport encryption (core cluster)
The core cluster runs with TLS (ssl=on, Coolify’s certificate) and is not
published: only the containers on the platform network reach it. Coolify’s API
refuses enable_ssl, so the switch is made in its UI (Servers > Databases >
core-postgres > Enable SSL); the bastion reads the real state
(base:corePostgresTls: required refuses to plan when TLS is off) and every
DSN follows it.
The certificate is signed by Coolify’s own CA, which is not in the apps’ trust store, so the two client families differ:
- the node clients (Infisical, the control plane — node-postgres) get
sslmode=no-verify: node-postgres turnsrequireinto a verified connection and would reject the certificate. - the libpq/pgx clients (psql, Zitadel, the Pulumi CLI) get
sslmode=require, which encrypts without verifying.
Both keep the traffic encrypted inside the host; neither verifies the certificate.
Pulumi state (pulumi_state)
The Pulumi DIY backend lives in its own database pulumi_state on the core
cluster, with its own role: only the worker holds its URL (hard rule 8),
the API has none. The backend is a single table
pulumi_state(key text, data json, updated_at timestamptz) that emulates a
bucket: the key prefix is the database name, then .pulumi/meta.yaml,
.pulumi/stacks/<project>/<stack>.json (+ .bak),
.pulumi/history/<project>/<stack>/…checkpoint.json|history.json,
.pulumi/backups/… and .pulumi/locks/organization/<project>/<stack>/<uuid>.json.
The data column holds {"data": "<base64 of the file>"}.
Consequences that matter for the design:
- The stack config is not in the backend. It lives in
Pulumi.<stack>.yamlin the workspace directory, so the adapter sets it from the registry on every run (setAllConfig) and the workspace is disposable. - The lock lives in the state. A second concurrent
upon one stack is refused (“the stack is currently locked by 1 lock(s)”); the adapter maps that toconflict. A lock left by a killed process is cleared withstack.cancel(), only by the job holding the tenant’s pg-boss singleton. - History grows with every operation. Retention/pruning is not implemented yet.
- The backend URL needs
sslmode=disableon the dev Postgres (no TLS there); production must use SSL.
See 04
for the stack naming (project tenant, stack <slug>) and
10 for the blast radius.
Tenant pool conventions
- Shard instances (Postgres + lockdown + PgBouncer) are created by the
control plane’s
shard.addjob inside thefortspace-data-poolproject, placed on thefortspace-data-netnetwork — not by the base stack. CREATE DATABASE meet_<slug> OWNER meet_<slug>_app(hyphens in the slug become_); revokePUBLICconnect, grant only the app role. Also revokePUBLICconnect onpostgresandtemplate1: a tenant role inheritsCONNECTon the maintenance databases throughPUBLICand must not reach them (the provisioner does this on every run; the admin is a superuser and unaffected, and a test connects as a tenant role to prove it). Extensions pre-created by superuser as in02_init_meet.sh(e.g.pg_trgm, needed by migrationcore.0002). The role gets a generated password; the full URL is stored only in Infisical (/tenants/<slug>/meet#DATABASE_URL).- Erasure is
DROP DATABASE … WITH (FORCE)(PostgreSQL 13+) thenDROP ROLE: terminating sessions and then dropping lets a tenant reconnect in between and fail the drop. Identifiers are validated (^[a-z][a-z0-9_]{0,62}$) and escaped because DDL cannot use bind parameters. - 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. The worker writes thesslmodeit is configured with intoDATABASE_URL(DATABASE_SSL_MODE,requireordisable; the prototype default isdisablebecause the dev shard has no TLS, so production must setrequire).
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. Naming: the scoped user’s
access key is the bucket name
tenant-<slug>, its canned policy istenant-<slug>-rw, and the policy resources are exactlyarn:aws:s3:::<bucket>andarn:aws:s3:::<bucket>/*(no trailing*on the bucket, ortenant-acme*would also matchtenant-acmex; a test with a prefix-collision bucket guards it). The adapter refuses any bucket or user name that does not start withtenant-and name a tenant, because the key is created with the root credentials and a name outside the namespace could address the root user or another tenant’s bucket. - 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.
- Admin API (verified on RustFS 1.0.6): base path
/rustfs/admin/v3, signed with SigV4 using service names3and the root credentials (there is no Nodemc adminlibrary).PUT /add-user?accessKey=<k>takes a plain JSON body{ "secretKey", "status": "enabled" }(not MinIO’s encrypted body);GET /user-infois 200 or 404 (NoSuchResource) and is the existence check;PUT /add-canned-policy?name=<n>overwrites idempotently;PUT /set-user-or-group-policy?policyName&userOrGroup&isGroup=false;DELETE /remove-userand/remove-canned-policy(404 is tolerated so deletes are repeatable). A user whose secret was never stored cannot be read back, so the scoped key is rotated by delete-and-recreate. - S3 region must match the server. The AWS SDK v3 sends
CreateBucketConfiguration.LocationConstraintwhenever the region is notus-east-1, and RustFS answers “location constraint does not match this server’s region” (the AWS CLI does not send it, so it hides the problem). The dev instance runs inus-east-1and the worker’sS3_REGIONdefaults to it. The string is only the bucket’s location constraint: EU sovereignty is about where the data lives, not about that name. - Lifecycle (
expire-recordingson prefixrecordings/plusabort-multipart) is accepted and read back intact; the adapter still downgrades a failure to a warning. The retention must be an integer ≥ 1. Encryption:PutBucketEncryption(AES256) is accepted and returned byGetBucketEncryptioneven with no KMS configured, but only the stored configuration was verified, not that objects are encrypted on disk; failures are not swallowed when SSE is requested. - Erasure (
emptyAndDeleteBucket) deletes every object version and delete marker (with versioning on, a plainDeleteObjectonly adds a marker), aborts unfinished multipart uploads, then deletes the bucket; a re-created bucket under the same name starts empty. The versions/markers path is proven by a live test (disabling it makes the test fail). The multipart-abort loop is kept as defence in depth but cannot be proven on RustFS 1.0.6: the server drops the bucket and its uploads anyway, so disabling the loop does not fail the test. - 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, Infisical | No TLS by default (Coolify’s CA is not available to LiveKit/Infisical); the control plane itself never uses it — tenants keep their own Redis |
| 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
The self-hosted free-tier Infisical (v0.167.13) has no custom roles or additional privileges (“plan RBAC restriction”), so path-scoped read access cannot be enforced inside one project. We keep one shared instance but use one project per trust scope, with built-in roles only (ADR-004).
Project fortspace-platform (only the CP worker identity, org admin, has access)
/platform/zitadel PROVISIONER_KEY_JSON (cp-provisioner key; written by the base
stack from the key it creates, ADR-033). The masterkey and the
operator password are NOT stored here: state + offline escrow,
SETUP_KEY_JSON (platform-setup key, IAM_OWNER: tools/prod and
superadmin.sh; replaces the revoked bootstrap PAT, ADR-023)
/platform/pulumi PASSPHRASE: the Pulumi secrets-provider passphrase
(ADR-021); read by the worker only
/platform/coolify TOKEN: the Coolify API token (read, write, deploy,
read:sensitive, delete); read by the worker only
/platform/rustfs ROOT_ACCESS_KEY, ROOT_SECRET_KEY, SSE key,
OIDC_CLIENT_ID, OIDC_CLIENT_SECRET (console login, Zitadel app)
/platform/postgres CORE_ADMIN_PASSWORD + one <ROLE>_PASSWORD per core role
(zitadel_app, infisical_app, pulumi_state_app, control_plane)
/platform/infisical (empty by design) ENCRYPTION_KEY and AUTH_SECRET are **escrow
offline only** — losing them loses every secret, so they never
sit in the system they unlock
/platform/data-pool DATA_POOL_PROJECT_UUID, DATA_POOL_ENVIRONMENT_UUID,
DATA_NETWORK_NAME, POSTGRES_IMAGE (shard.add reads these)
/platform/registry PASSWORD: GHCR token (read:packages) for the worker's
docker login of the Coolify server
/platform/cockpit SESSION_PASSWORD: cockpit session-cookie key
/platform/backup backup key escrow (planned)
/platform/shards/<name> #ADMIN_URL: shard admin DSN, written by shard.add
(referenced by db_shards.admin_secret_ref)
/platform/tenant-bootstrap/<slug>
#CLIENT_ID, #CLIENT_SECRET: the tenant stack's Infisical machine-identity credentials
Project fortspace-broker (worker writes; broker identity is viewer here only)
/platform/livekit API key/secret
/routing/webhook-secrets/<slug>#SECRET
tenant webhook signing secret, broker copy
(room_routes.webhook_secret_ref points here)
Project tenant-<slug> (created at provisioning, deleted at offboarding)
/tenants/<slug>/meet OIDC_RP_CLIENT_ID, ZITADEL_SA_KEY, DATABASE_URL,
S3_ACCESS_KEY/S3_SECRET_KEY/S3_BUCKET/S3_ENDPOINT,
WEBHOOK_SIGNING_SECRET (stack copy),
OIDC_STORE_REFRESH_TOKEN_KEY, SESSION_SECRET, REDIS_PASSWORD
/tenants/<slug>/chat Tuwunel config, appservice tokens
One secret of the platform is not here: the OIDC login of the Mailpit UI
(base:mailpitOidc of the bastion stack — client id, client secret, session key).
The Traefik plugin traefikoidc reads its configuration from the container’s Docker
labels and Coolify does not interpolate a label, so the values cannot be variables:
they sit in the Mailpit compose (encrypted in the Pulumi state) and in the labels on
the host (09, 10).
The worker reads the platform secrets of this phase through refs, never
values: PULUMI_PASSPHRASE_REF (infisical:/platform/pulumi#PASSPHRASE),
COOLIFY_TOKEN_REF (infisical:/platform/coolify#TOKEN) and
MEET_REGISTRY_PASSWORD_REF (infisical:/platform/registry#PASSWORD). The URL of the
Pulumi state backend (PULUMI_BACKEND_URL) is a credential too — it carries a
password — so it lives in the worker’s environment, never in the repo.
The sync point is the base stack itself once base:identityEnabled is set (ADR-033): its
Infisical provider writes the platform secrets from the values the stack generates (the LiveKit
and RustFS keys, the Postgres passwords, the data-pool ids) and the Zitadel provisioner key, in the
same plan, and hands the control plane its Infisical credentials and Zitadel ids directly, so
there is no copy step and no controlPlaneSecrets round trip; only the cockpit client secret and
session password stay in that config. The *_REF refs are derived by the bastion itself. What the
stack does not own: /platform/coolify, /platform/registry and /platform/pulumi (they come
from the workstation), and /platform/shards, which shard.add writes.
Until the switch is made (and on a fresh install unless platform-setup.sh --bootstrap is
used) the sync point is the old one: bastion/scripts/platform-setup.sh runs
control-plane/tools/prod, which writes all of the above into Infisical from the stack outputs and
then pulumi config set --secret controlPlaneSecrets. Infisical ENCRYPTION_KEY/AUTH_SECRET
and the Zitadel masterkey are not readable through the platform identities on purpose: they
are escrowed offline only. (The old tool did copy the masterkey and Infisical’s keys into
Infisical anyway; the rollout deletes those copies, see 12.)
The broker is not a viewer on fortspace-platform: that would expose the
RustFS, Zitadel and shard keys to the API process. The webhook signing secret is
therefore stored twice (stack copy under the tenant project, broker copy under
fortspace-broker).
Access model
| Identity | Project | Access |
|---|---|---|
| CP worker (org admin) | all | read/write (provisioning, rotation) |
| CP broker | fortspace-broker only |
viewer |
Tenant stack <slug>-stack |
tenant-<slug> only |
viewer |
| Humans | any | break-glass only, audited, via change process |
Production may later use Infisical Enterprise path-scoped roles instead of project-per-scope (adapter change only; see Q-15).
The adapter owns the path-to-project mapping. The rest of the control plane
speaks only in paths (/platform/livekit, /tenants/<slug>/meet); the Infisical
adapter routes each path to its project, so moving to path-scoped roles
changes the adapter and nothing else:
| Path | Project |
|---|---|
/routing/** and /platform/livekit |
fortspace-broker |
every other /platform/** |
fortspace-platform |
/tenants/<slug>/** |
tenant-<slug> |
| anything else | rejected (validation error) |
Deleting exactly /tenants/<slug> deletes the whole project, and it must be
a hard delete: DELETE /api/v1/projects/{id} is soft by default and keeps the
slug reserved (“held by a pending-deletion project”), so recreating the tenant
would fail; the adapter uses ?hardDelete=true, which also really removes the
tenant’s secrets at offboarding.
Verified on the self-hosted free tier (v0.167.13, plan tier -1,
rbac: false; control-plane repo docs/notes/infisical.md):
POST /api/v2/identity-project-additional-privilege(path- orsecretName-scoped read) answers 400 “Additional privileges are not available for project …”; new projects have no way to enable them.POST /api/v1/projects/{id}/roles(custom role) answers 400 “plan RBAC restriction”. So built-in roles only (admin,member,viewer,no-access) and path-scoped access inside one project is impossible.- The syntax that would work on Enterprise (hence an adapter-only change later):
conditions.secretPath.$globandconditions.secretName.$globwith the actionsdescribeSecret,readValue,read,create,edit,delete. - Isolation was proven live (
verify:infisical, 12/12): the broker identity readsfortspace-broker/platform/livekitand gets 403 onfortspace-platformand on any write; a freshly created identity that isvieweron one project reads that project and gets 403 on every other one, including both fixed projects. The adapter test repeats it for<slug>-stack, which also cannot write its own project. - Identities use universal auth (access token TTL 3600 s, max 86400 s). Client secrets are shown once; the adapter issues a new one only when the identity has no active secret, so a retried step recovers from a crash between creating the identity and storing its secret. Three failed logins lock the client for 5 minutes, so scripts try a secret once.
cp-workeris org-leveladminplus projectadmin: broader than “read/platform/*, write/tenants/*”, because creating and deleting projects needs it and no narrower built-in role exists (revisit with Enterprise roles). The flip side of keeping/platform/livekitinfortspace-broker:cp-brokercan read every tenant’s webhook signing secret (it needs them to sign forwarded events) but not the RustFS, Zitadel or shard keys.GET /api/v1/projectsis paginated; the adapter pages through it to find a project by name, and a caller only sees projects it can access (an identity without membership seesnull). Folders are created one level per call.- The instance bootstrap runs once and yields a 90-day admin token; if it is lost or expired the dev stack is reset.
Distribution
Coolify holds only the stack’s Infisical machine-identity credentials (and
non-secret config). The container entrypoint runs
infisical run --projectId <tenant-<slug> project id> --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.
Pulumi secrets (the one exception to “no secrets in a column”)
The control plane’s rule is that a secret never becomes a column, a log line, a job payload or audit detail — only a ref to Infisical. Pulumi’s state breaks that shape in one place, so it is an explicit, narrow exception (ADR-021):
| Where | What is stored | Encrypted? |
|---|---|---|
The Pulumi checkpoint in pulumi_state |
the tenant stacks’ secrets as pulumi.secret values: every tenant secret written to Infisical, the service-account key, the stack identity’s client secret, plus the provider credentials |
Yes — the passphrase secrets provider stores {"ciphertext": "v1:…"} |
Infisical /platform/pulumi#PASSPHRASE |
the passphrase | Yes (Infisical) |
| The worker’s environment | PULUMI_PASSPHRASE_REF, COOLIFY_TOKEN_REF (refs), PULUMI_BACKEND_URL (a URL with a password) |
n/a — env vars, never in the repo |
| Job payloads, step outputs, audit rows, logs | ids and refs only, exactly as before | n/a |
Rules that keep the exception narrow:
- The passphrase is read by the worker identity only; the API has neither the passphrase nor the Coolify token (hard rule 8).
- Nothing decrypted is ever written to a log, a step output, an audit row or an error message; the adapter redacts provider output.
- The state rows are ciphertext at rest; the passphrase is in Infisical, so losing the state without the passphrase is not a secret leak (it is a lost stack, and the stack is recreated from the registry).
- Rotation of the passphrase is not automated:
pulumi stack change-secrets-providerhas no non-interactive mode, so a rotation is an export/import batch job run per stack under its tenant singleton (see the control-plane notes).
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 |