Skip to content

Database schema

Every tenant-scoped table carries org_id. The Drizzle schema widens that column with the branded OrgId type, so the L1 enforcement is at the type level.

TablePrimary purposeTenant key
organizationsTenant boundary (Better-Auth)self
usersSubject identity(global)
memberships(user, org, role)org_id
delegationsagent-on-behalf-of(user) rowsorg_id
acls(subject, resource, permission)org_id
platform_identitiesidentity-graph edgesorg_id
automationsdefinitions registered via defineAutomationorg_id
automation_eventscanonical trigger event rows; PK includes event_idorg_id
automation_runsidempotent on (automation_id, event_id); heartbeatorg_id
automation_stepsaction/delivery progressionorg_id
agentsdefinitions registered via defineAgentorg_id
agent_runsone row per agent.run invocationorg_id
agent_stepsappend-only turn log; pgvector embeddingorg_id
manifestscontent-addressed app manifestsorg_id + global hash
connectorsadapter registrationsorg_id
credentialsencrypted OAuth/API key blobs (proxy-only readable)org_id
connector_grants(app_instance, connector, scopes)org_id
audit_logper-call rows from proxy + auth + automationorg_id
outcomesRunOutcome shapeorg_id
eval_suitessuites registered via defineSuiteorg_id
eval_resultsper-suite, per-version score rowsorg_id
factory_runssoftware-factory outer-loop iterationsorg_id
cas_objects(sha256, size, parents[])global content + source_org_id
blobstore_refs(org_id, key, blob_kind, ref)org_id
secretsindirection rows + rotation timestampsorg_id
webhooks_inboundHMAC-verified inbound deliveriesorg_id
  • (org_id, created_at) on every tenant-scoped table
  • pgvector HNSW on agent_steps.embedding (cosine)
  • Partial: automation_runs(status='pending', heartbeat_at) for the leader sweep
  • audit_log(org_id, occurred_at DESC) for SIEM exports
  • Unique: (automation_id, event_id) on automation_runs — load-bearing for at-most-once dedupe