Schema Reference
This is a practical reference, not a replacement for the migrations.
clients and client_external_refs
clients is the canonical account record. client_external_refs stores stable account-level
identities such as a HubSpot company ID so connector matching does not depend on a mutable name.
Lead/admin account creation writes the client, initial project, memberships, operating profile,
signals, external references, idempotency record, and audit event in one database transaction.
projects
Important fields:
idorg_idclient_idnamecodeslugasana_gidtoggl_project_idhours_loggedhours_30dhours_synced_atproject_categorybudget_hoursbudget_amountactual_revenueactual_costrate_card_id
sources
Important fields:
idorg_idproject_idtypetitleurloccurred_atexternal_idbodymetadata
Fathom transcripts go in body.
approvals
Important fields:
idorg_idproject_idkindcodetitlebodystatuspayloadedited_payloadresultsource_idconfidenceproposed_byapproved_bycreated_atresolved_at
documents
Important fields:
idorg_idproject_idtitlecategorysource_systemsourcestorage_pathbodyembeddingrestrictedmime_typebyte_sizechecksum_sha256source_urlexternal_idsource_modified_atindexed_statusindexed_atindex_errorversionsupersedes_document_idmetadata
knowledge_chunks
Chunk-level semantic retrieval for documents, transcripts, spreadsheets, and future source text.
Important fields:
org_idproject_iddocument_idsource_idsource_typechunk_indextextmetadatarestrictedembedding_modelembeddingcontent_hashindexed_at
spreadsheet_rows
Structured workbook extraction for XLSX/XLSM/CSV/TSV files. Spreadsheets are not flattened like documents; rows retain workbook, sheet, table/range, row, columns, formulas, and display values.
Important fields:
org_idproject_iddocument_idworkbook_namesheet_nametable_namerow_numbercell_rangecolumnsdisplay_columnsformulasnormalized_textmetadatarestricted
ingest_jobs
Operational ledger for document/source indexing attempts.
Important fields:
org_idproject_iddocument_idsource_idsource_typestatusattempt_countlast_errorrequested_bystarted_atfinished_at
retrieval_events
Query-level retrieval telemetry for search and Ask SABLE.
Important fields:
org_idactor_person_idqueryfiltersresult_chunk_idscandidate_countreranked_countlatency_msembedding_modelrerank_model
rag_eval_questions and rag_eval_runs
Lead/admin evaluation tables for recall, citation correctness, leakage, and latency checks.
Important fields:
questionexpected_source_typeexpected_document_idexpected_source_idexpected_answer_containsrestrictedrecall_at_10citation_correctleakage_detected
audit
Used for external action trail and webhook replay checks.
Important fields:
org_idactoractiondetailcreated_at
For Fathom replay, detail.webhook_id is unique where action = 'fathom_webhook'.
Agency OS Pricing Tables
0010_agency_os_spine.sql adds:
project_categoriesrate_cardsbudget_linesestimate_casesscope_events
These tables turn outcome estimates from comparable-hour averages into a learning loop with project taxonomy, SOW budget lines, estimate cases, actual margin, and scope-change causes.
Client Portal Tables
0010_agency_os_spine.sql also adds:
client_membershipsclient_updatesclient_requestsdeliverables
Client users should read through /api/client-portal. The portal payload excludes internal decisions, promises, and unrestricted spine rows by default.
Released documents and sources can appear in the portal only when they are scoped to one of the
client user's allowed projects; raw document bodies, storage paths, and source transcripts stay out
of the client payload.
Deliverable Authoring Tables
0020_deliverable_authoring.sql adds:
deliverable_authoring_profilesdeliverable_canonical_targetsdeliverable_templatescontract_obligationsdeliverable_draftsdeliverable_evidencedeliverable_revision_events
Contracts/SOWs are extracted into obligations and budget lines for lead-only drafting. Drafts keep their evidence citations separate from the rendered body so reviewers can inspect source grounding before an approval publishes an update or releases a deliverable.
Authoring profiles store reusable client/project policy: required sections, standing facts, banned client-facing terms, source collection rules, QA policy, canonical export policy, and known out-of-scope items. Canonical targets identify the intended file destination and overwrite/versioning behavior for living deliverables such as a single Drive-backed SOW. Revision events record the in-document change history to preserve the old living-SOW workflow without keeping it as prompt-only behavior.