Browse documentation

Database Reference

Postgres (Supabase) tables that custom code touches, grouped by purpose. Column lists are the ones custom code actually reads/writes — every table has id uuid plus created_at, and most have updated_at, is_active, account_id, app_id, created_by/updated_by, and stamped design_schema/validation_schema jsonb. The canonical DDL is .framework/migrations/001_core_schema.sql (base) plus later migrations. Every table is RLS-enabled — verified across all migrations; 046_security_missing_rls.sql closed the last gaps (account_paths, invites, alerts, observability, test_runs, test_cases, test_results, _spine_migrations).

Tenancy & identity

TablePurposeKey columns
accountsTenant boundary; every scoped row hangs off oneslug UNIQUE, display_name, parent_id, type_id, data, logs_retention_days, observability_retention_days
account_pathsClosure table for account hierarchiesancestor_id, descendant_id, depth (PK pair)
peopleHuman users (one per Supabase auth user + invite stubs)auth_uid UNIQUE, email UNIQUE, full_name, account_id, role_id, status, data
rolesRole definitions granting record/field permissionsslug UNIQUE, name, permissions jsonb, is_system, is_protected, account_id
system_settingsInstance/account-scoped key-value settingsscope, scope_id, key, value
invitesInvite tokens and placement configapp_id, account_id, slug, config, is_active

Types, apps, configuration

TablePurposeKey columns
typesType definitions — the design_schema contract lives herekind, slug (UNIQUE per kind,slug since 015), name, icon, color, design_schema, validation_schema, ownership, is_active, app_id
appsInstalled appsslug UNIQUE, name, app_type, source, renderer (generic/custom/none), route_prefix, required_roles, min_role, config (incl. registration), nav_items, manifest_path, config_source
link_typesNamed link semantics between recordsslug, name, config, source_kind, target_kind

Runtime records

Every runtime row is typed (type_id → types) and stamped with the type's schemas at insert. system: true fields are top-level columns; others live in data.

TablePurposeKey columns
itemsThe workhorse record kindtype_id, title, status, data, account_id, app_id
threadsConversation containers bound to a target recordtype_id, title, target_type, target_id, visibility (internal/external/public), status; UNIQUE (target_type, target_id, visibility)
messagesPosts inside threadsthread_id, type_id, content, direction, sequence, visibility, person_id; UNIQUE (thread_id, sequence)
linksTyped edges between recordslink_type_id, link_type, source_type/source_id, target_type/target_id; UNIQUE edge constraint
attachmentsFile recordsfilename, file_size, mime_type, storage_path, storage_provider, uploaded_by
watchersPeople watching a target recordtarget_type/target_id, person_id, watch_type, notification_level; UNIQUE (target_type, target_id, person_id)
item_progressPer-item pipeline progress rowsitem_id, slug, config, status fields

Automation

TablePurposeKey columns
pipelinesDeclarative stage sequencesslug, name, config/metadata (incl. stages[]), account_id, app_id, UNIQUE (app_id, slug)
pipeline_executionsPipeline run ledgerpipeline_id FK CASCADE, status, started_at, completed_at, input_data, output_data, error_message
triggersEvent→pipeline dispatch rulesslug, config (event type, entity, filters, pipeline_id), account_id, UNIQUE (app_id, slug)
trigger_executionsTrigger fire ledgertrigger_id FK CASCADE, status, input_data, output_data
timersScheduled work definitionsslug, config, account_id, UNIQUE (app_id, slug)
schedulesCron schedule principals (018)schedule rows bound to machine_principal_id with delegated_scopes
schedule_executionsSchedule run ledger (018)execution rows
actionsStage-type catalog for pipelines (018, seeded by 053)slug, name, config, default_machine_principal_id
episode_leasesAgent-episode concurrency leases (064)lease rows gated by lease_token
document_leasesKB ingest leases by content hash (054)lease rows
rate_limitsAtomic rate counters for rate_limit_hit RPC (035)key, window_start, count

AI & knowledge

TablePurposeKey columns
ai_agentsAgent configurationsslug, name, config (model, prompts, capabilities), account_id, UNIQUE (app_id, slug)
prompt_configsNamed prompt templatesslug, name, config, account_id, UNIQUE (app_id, slug)
embeddingsKB chunks with pgvectormodel_id, document_id, chunk_index, content, embedding vector(1536), content_hash, approved_at, revoked_at; UNIQUE (model_id, document_id, chunk_index)

Integrations & webhooks

TablePurposeKey columns
integrationsOutbound/inbound integration configsslug, name, config (credentials, adapters), account_id, UNIQUE (app_id, account_id, slug)
integration_routesInbound route definitionsslug, config (event path, handler), account_id
webhook_handlersDynamic handler registry (004)name, function_name, events[], account_id, is_deleted; UNIQUE (app_id, account_id, name)
webhook_deliveriesInbound+outbound delivery ledger (004)direction, integration_id, api_key_id, handler_name, action_slug, attempt/status fields
api_keysMachine principals and integration keyskey_prefix, key_hash, key_type (inbound/outbound/internal/cli), scopes[], rate_limit, machine_type, is_internal, expires_at, integration_id
api_key_usage_logsPer-key request ledger (004)api_key_id FK, request_method, request_path, request_ip, success

Observability & security

TablePurposeKey columns
logsAppend-only log/audit/span/event rowslevel, message, context, metadata, source/source_type/source_id
observabilityMetric pointsmetric_name, metric_value, metric_unit, context
alertsAlert rule configsslug, config
security_blocklistHard-blocked persons/accounts/emails/IPs (049)blocklist entries with type and value
notificationsUser notifications (050)recipient/title/body rows

Testing

test_runs (suite results incl. pipeline_execution_id), test_cases, test_results (018) — test definitions and outcomes.

Migration conventions

  • Files live in .framework/migrations/ (framework) and custom/migrations/ (project); migrate applies framework first, then custom, in filename order — .framework/cli/commands/migrate.ts.
  • Naming: NNN_snake_case_description.sql, three-digit prefix. Applied files are recorded in the _spine_migrations ledger (filename UNIQUE); each file runs in its own transaction and the run stops on first failure.
  • Known numbering gaps: 22–31, 39–41, 63 — numbers were reserved or consolidated during development (audit D-007). A gap is expected, not a missing migration.
  • idempotent by convention: framework migrations use IF NOT EXISTS / ON CONFLICT DO NOTHING so re-running a file is safe.

Why it exists

system-settings

Some behavior (log levels, feature flags, tool defaults) should be configurable at runtime without redeploying code.

Why it exists (5-whys):

  1. Environment variables require a redeploy to change, and scoped overrides (one account with louder logging, one tool's default) can't exist in env at all.
  2. These toggles don't belong in apps.config — they're cross-app, platform-owned, runtime-scoped. (apps.config.analytics was deliberately chosen over system_settings for app-shipped config — the distinction is ownership.)
  3. The store is scoped (global / app / account / source / principal / tool), not a flat map, because operability means "turn debug logging on for this account" — a flat toggle is all-or-nothing.
  4. It's lightly used today — logging.ts is the only live reader — because most app config legitimately lives in types, apps, and seed files.
  5. Root: a platform needs a narrow, scoped channel for behavior that changes at runtime without code deploys; everything else belongs in schema or app config. (confirmed 2026-11-13)

_spine-migrations

The migration CLI must know which files to skip on subsequent runs so it does not re-run migrations that have already been executed.

Why it exists (5-whys):

  1. Migrations must be idempotent-checked — the system needs to know what already ran or every migrate replays everything.
  2. Filenames (not version numbers or checksums) are ordered, human-readable identity (NNN_description.sql) — the ledger doubles as "what lineage built this database" for drift debugging.
  3. The tooling creates it (CREATE TABLE IF NOT EXISTS in the migrate CLI / apply-single-migration.mjs), not a migration — the ledger must exist before the first migration runs. It can't be row 001 of the thing it tracks.
  4. RLS is service-role-only (046) because the ledger is infrastructure — PostgREST exposure would leak platform internals, and tenants have no business in migration history.
  5. Root: reproducibility requires memory — the ledger is the smallest possible "what is true about this database's lineage" record, deliberately dumb so every tool that touches it can agree. (confirmed 2026-11-13)

Framework documentation — Verified November 15, 2026 · source revision 71dae29.

Was this page helpful? Ask a question · Report a documentation problem