Database schema#
Models: apps/api/src/rvc_api/models.py. Migrations: infrastructure/migrations (Alembic;
0001 tables, 0002 pgvector column + HNSW index + full-text GIN indexes on PostgreSQL).
erDiagram
users ||--o{ sessions : has
users ||--o{ api_tokens : owns
organizations ||--o{ org_memberships : has
users ||--o{ org_memberships : member
organizations ||--o{ projects : owns
projects ||--o{ project_memberships : has
users ||--o{ project_memberships : member
organizations ||--o{ invitations : issues
projects ||--|| repositories : has
repositories ||--o{ refs : "CAS-updated"
repositories ||--o{ ref_logs : records
repositories ||--o{ branch_protections : rules
repositories ||--o{ stored_objects : stores
repositories ||--o{ upload_sessions : resumable
repositories ||--o{ commits : indexes
commits ||--o{ commit_parents : "child/parent"
repositories ||--o{ entity_versions : indexes
repositories ||--o{ graph_snapshots : indexes
graph_snapshots ||--o{ snapshot_nodes : contains
graph_snapshots ||--o{ snapshot_edges : contains
repositories ||--o{ experiment_runs : indexes
experiment_runs ||--o{ experiment_metrics : has
repositories ||--o{ releases : indexes
repositories ||--o{ embeddings : has
projects ||--o{ comments : has
projects ||--o{ review_requests : has
projects ||--o{ audit_findings : has
projects ||--o{ ai_annotations : has
projects ||--o{ integration_connections : has
integration_connections ||--o{ integration_events : receives
projects ||--o{ background_jobs : queues
projects ||--o{ activity_events : feed
Also: audit_logs (security events), usage_records (metering), idempotency_keys.
Invariants#
- Rows in
commits,commit_parents,entity_versions,graph_snapshots,snapshot_*,experiment_runs,experiment_metrics,releasesare a derived, append-only index of immutable objects. They are keyed by content ids (unique per repository), never updated, and can be rebuilt from the object store. refsis authoritative for cloud branch pointers and changes only via compare-and-swap inside a transaction (row lock on PostgreSQL); every change is appended toref_logs.- A ref may point only to an object whose full closure is present and schema-valid.
- Every content-keyed table is scoped by
repo_id; every collaboration table byproject_id; all API queries filter by the authorized project (cross-tenant isolation is tested). - Secrets are never stored in plain text: passwords (Argon2), session and API tokens (SHA-256 of high-entropy values), integration and BYOK AI keys (AES-GCM).
- All timestamps are timezone-aware UTC.
projects.versionprovides optimistic concurrency for settings changes (409 on mismatch).
JSON(B) columns are used only for extensible metadata (entity data, configs, evidence lists,
job payloads); identity, ownership and relationships are relational columns with FKs.