# RAG Assistant — Phase 1 Database Design Version 1.3 · 2026-10-07 · Live document MVP persistence contract; proposed forward changes are not applied migrations. Companions: `RAG-Phase1-Implementation-Guide.md` and `RAG-Phase1-API-Catalog.md`. Scope: PostgreSQL + pgvector, one organization, existing ingestion foundation, retained review decisions and owned voice/session/tool metadata. Durable text turns/messages/citations are deferred. No deployed database was queried; the repository foundation migration was inspected statically for this documentation update. Only seven foundation tables are currently implemented; compare this complete proposal with actual migrations before applying it. Live tables/SDP fields are not applied foundation schema. Document revision 1.3 is not an Alembic schema revision. Preserve the seven applied foundation tables/migration. The active MVP adds four tables: auth_sessions, conversations, live_sessions and voice-only tool_calls (eleven total), plus forward changes for retained review state/audit action. The fourteen-table broader text design is deferred. Document identities remain direct; technical revisions/profiles are not content versions. ## 1. Conventions All IDs are application-generated UUIDs. `uuid PK` means primary key. Timestamps are `timestamptz` in UTC; `created_at` defaults to database now. Unless marked nullable, fields are NOT NULL. JSON defaults are `{}` or `[]` as appropriate. Status fields use text plus CHECK constraints for simple evolution. Hashes use lowercase SHA-256 hex (`char(64)`), except password hashes which use the selected password library's encoded format. Counters use integer/bigint and CHECK >= 0; revisions/sequence numbers start at 1. Tables other than settings have a UUID `id` PK. Settings uses `organization_id` as PK. Every organization-owned table has `organization_id uuid` referencing organizations, even where derivable. For all referenced scoped entities add `UNIQUE(organization_id,id)` and use composite scoped foreign keys. This prevents a valid UUID from another organization being attached accidentally. Do not treat UUID unpredictability as access control. Use RESTRICT/NO ACTION for normal deletion; no broad CASCADE from users/documents into historical chats. Soft deletion and explicit cleanup control lifecycle. Owners/roles are checked by application queries. Single-organization deployment does not justify dropping organization filtering. Row-level security is deferred, not claimed to be enabled. ## 2. Relationship overview The active MVP uses owned voice conversations and voice tool records: ```mermaid erDiagram documents ||--o{ document_chunks : contains documents ||--|| ingestion_jobs : processes users ||--o{ auth_sessions : authenticates users ||--o{ conversations : owns conversations ||--o{ live_sessions : hosts auth_sessions ||--o{ live_sessions : authorizes live_sessions ||--o{ tool_calls : executes ``` The following diagram is the deferred text-and-voice model; it is not a migration requirement for the current milestone: ```mermaid erDiagram documents ||--o{ document_chunks : contains documents ||--|| ingestion_jobs : processes conversations ||--o{ turns : contains turns ||--o{ messages : records turns ||--o{ citations : supports conversations ||--o{ live_sessions : hosts turns |o--o{ tool_calls : text_calls live_sessions |o--o{ tool_calls : voice_calls ``` The diagram omits identity/configuration/audit for readability. Each tool call belongs to exactly one text turn OR one live session. A citation also references the exact tool call/evidence that produced its chunk. These relationships are defined below. ## 3. Identity and organization tables ### 3.1 organizations | Column | Type/default | Meaning | | --- | --- | --- | | id | uuid PK | Fixed seeded organization | | name | varchar(200) | Display name | | created_at | timestamptz now | Creation | ### 3.2 users | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id | uuid | Identity and organization | | username | varchar(120) | Canonical lowercase login name | | password_hash | text | Salted adaptive password hash; never plaintext | | role | text | admin or user | | is_enabled | boolean true | Account authorization | | created_at, updated_at | timestamptz | Audit timestamps | Unique username globally for simple login without organization selector. CHECK role. Add UNIQUE(organization_id,id). Disabling a user revokes sessions and closes live sessions; account-management UI is deferred (maintenance command only). ### 3.3 auth_sessions | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, user_id | uuid | Session owner | | token_hash | char(64) UNIQUE | Hash of opaque cookie token | | created_at, expires_at, last_seen_at | timestamptz | Lifetime | | revoked_at | timestamptz nullable | Explicit revocation | Composite FK to users. CHECK expires_at > created_at. Index expires_at for cleanup. Never store raw cookie. Derive CSRF token from raw session cookie using a separate server-side HMAC secret (or an equivalent reviewed synchronizer mechanism); compare in constant time. `/me` can reproduce it without persisting a raw CSRF token. ### 3.4 organization_settings | Column | Type/default | Meaning | | --- | --- | --- | | organization_id | uuid PK/FK | One row per organization | | assistant_name | varchar(120) | UI/model name | | instruction | text | Organization instruction, API length limit | | revision | bigint 1 | Settings optimistic revision | | knowledge_revision | bigint 1 | Selected-set revision | | access_epoch | bigint 1 | Invalidation counter for removals | | updated_by | uuid nullable | Actor; scoped FK to users | | updated_at | timestamptz | Last configuration/selection mutation | CHECK all counters >= 1. Selection uses documents.is_active; no assignment table in Phase 1. Lock this row first for selection, context creation and finalization to impose a consistent order. ## 4. Knowledge tables ### 4.1 documents Each upload is one independent immutable document. This table owns file metadata and processing state directly. There is no document-version table or version-number field. Replacement means a new upload/document ID, followed by active-selection change after readiness. The same idempotent upload replay returns the original ID. | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, uploaded_by | uuid | Identity and admin actor | | title | varchar(200) | Display title | | original_filename | text | Display only, never trusted path | | upload_request_id | uuid | Upload Idempotency-Key | | upload_payload_hash | char(64) | File bytes + normalized metadata digest | | storage_key | text UNIQUE | Generated original-file reference | | file_sha256 | char(64) | Original bytes hash | | mime_type | text | Validated MIME | | size_bytes | bigint | Original size > 0 | | status | text queued | queued, processing, ready, failed | | processing_profile | jsonb | Extractor/chunk/embedding settings | | chunk_count | integer 0 | Published chunk count | | ready_at | timestamptz nullable | Successful publication | | is_active | boolean false | Organization selection | | deleted_at | timestamptz nullable | Soft deletion | | content_purged_at | timestamptz nullable | Explicit future cleanup marker | | created_at, updated_at | timestamptz | Timestamps | UNIQUE(organization_id,upload_request_id). Scoped FK uploaded_by→users. CHECK size_bytes > 0, chunk_count >= 0. CHECK ready implies ready_at IS NOT NULL and chunk_count > 0. CHECK is_active implies status='ready', deleted_at IS NULL and content_purged_at IS NULL. Storage keys are generated and unique; no automatic same-hash deduplication between documents. Do not overwrite the original bytes or republish a ready document. Manual retry accepts only eligible failed documents; first successful publication fixes the source/chunk identities. If content changes, upload a new independent document. Physical purging must first deactivate the document; retained metadata is a tombstone, never eligible search content. Freeze the actual snapshot produced by IngestionSettings.processing_profile, including current schema-2 extraction/normalization/chunking and embedding identity/request limits. Do not replace it with the older illustrative flat JSON profile. Current extraction/chunking/embedding components are implemented; their worker integration and atomic publication are implemented for the requested Phase 5 worker scope. Dimension D is explicit; equal dimensions alone do not make models compatible. LangChain integration does not change these snapshots or require re-embedding compatible vectors. ### 4.2 document_chunks | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, document_id | uuid | Source identity | | ordinal | integer | 0-based order | | text | text | Extracted evidence | | location | jsonb | `{page: integer-or-null, section: string-or-null}`; section may identify table/row/Q&A or image group | | token_count | integer nullable | Actual tokenizer count if available | | embedding | vector(D) | Model-compatible vector | | created_at | timestamptz | Publication | UNIQUE(document_id,ordinal); CHECK ordinal >= 0 and length(text)>0; token_count >= 0 when set. FK document scoped. Page is positive when present. Do not invent a page index for a format without pages. Index document_id; initial small-corpus search uses exact cosine distance after eligibility joins. Defer ANN/HNSW until measured latency requires it. If later added, validate filtered-search recall. Example query is parameterized and conceptual (D is a migration parameter): ```sql SELECT c.id, c.text, c.location, d.id AS document_id, c.embedding <=> CAST(:query_vector AS vector) AS distance FROM document_chunks c JOIN documents d ON d.id = c.document_id AND d.organization_id = c.organization_id WHERE d.organization_id = :organization_id AND d.is_active = true AND d.deleted_at IS NULL AND d.status = 'ready' AND d.content_purged_at IS NULL ORDER BY c.embedding <=> CAST(:query_vector AS vector), c.id LIMIT :top_k; ``` Server validates profile, dimension and bounded top_k before query. A nearest neighbor is not automatically sufficient evidence; no universal distance threshold is assumed. ### 4.3 ingestion_jobs | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, document_id | uuid | One job per document | | status | text queued | queued, processing, succeeded, failed | | stage | text extract | extract, chunk, embed, publish | | attempt_count | integer 0 | Claims within current retry generation | | retry_generation | integer 0 | Manual retries | | next_attempt_at | timestamptz now | Backoff scheduling | | claim_token | uuid nullable | Fencing token | | lease_expires_at | timestamptz nullable | Worker lease | | claimed_by | text nullable | Worker process identifier | | error_code, error_message | text nullable | Redacted failure | | error_retryable | boolean false | Eligibility hint | | created_at, updated_at | timestamptz | Timestamps | UNIQUE(document_id). CHECK processing requires claim_token and lease_expires_at; non-processing clears them. Index `(status,next_attempt_at)` and partial lease expiry for processing. Claim eligible rows with row lock/SKIP LOCKED, regenerate token and increment attempt count. Recovery excludes deleted documents and reclaims expired jobs within retry budget. Final publication locks job and checks token plus lease; an expired worker cannot publish even if its provider call completed. Manual retry uses audit idempotency record and updates this same job atomically. ### 4.4 Retained extraction, review and factual inclusion Existing code validates extraction envelopes and stores non-queryable candidates. Phase 5 implements durable current-claim complete_artifact attachment/reuse in forward revision 0002_worker_artifact, with documents.extraction_state jsonb NOT NULL DEFAULT '{}' and CHECK jsonb_typeof(extraction_state)='object'. Partial review candidates, decisions and factual inclusion below are implemented behind trusted backend services in forward revision 0003_extraction_review. Authenticated D06/D07 HTTP transport still requires identity/Origin/CSRF integration. This is derived-processing metadata, not a new document lifecycle or content version. Keep large image/block/envelope bodies in the separate durable extraction namespace. extraction_state holds bounded trusted references and decisions: | Logical field | Requirement | | --- | --- | | original_sha256, extraction_profile_sha256 | Source/frozen extraction identity | | complete_artifact | Nullable trusted storage key/digest for a complete validated envelope | | candidates | Bounded array of exact retained page/block or factual-corpus references, review kind, locator and evidence digest | | decisions | Evidence-bound approved/rejected status, required checks, note and authenticated reviewer identity | | factual_inclusion | Nullable approved extraction digest and whole excluded Q&A group IDs; never rewrites faithful text | Persist candidate image/block hashes and storage keys privately; public API returns authenticated preview paths and faithful blocks, not raw storage keys. Server recomputes review_digest using original, frozen extraction identity, locator, exact image and exact blocks. Bind factual approval/inclusion to the complete extraction digest and existing group IDs. Bound JSON/reference count, preview bytes, notes and groups under the recorded processing/deployment limits. Worker attachment/progress/completion writes lock document then job and verify current token, unexpired lease, original/profile and non-deletion. Write immutable file candidates before short transactions; orphan candidates are report-only until a separately approved cleanup policy. An unfenced late result cannot replace retained output or an approved decision. Complete-artifact attachment compares the validated candidate pointer under those locks: the identical pointer replays without changing other extraction_state fields; a different pointer cannot replace it. Both paths still require the current claim and valid lease. No replay bypasses fencing. When PDF/vision review is required, retain exact candidate output under the current claim, mark job/document failed with EXTRACTION_REVIEW_REQUIRED, clear claim ownership and publish zero chunks. Do not hold a lease for a human or add waiting_review. This outcome is not an automatically retried provider error. Admin D07 locks document then job, validates the same failed candidate/source/ profile, and commits decision plus unique extraction_review audit replay record atomically. Resolve an authorized replay before rechecking changing state. Concurrent changed decisions fail with REVIEW_ALREADY_DECIDED; stale candidate identity fails with REVIEW_STALE. Decisions do not mark ready or activate. D04 requeues the same eligible failed job after required approvals. Reuse exact approved retained page/block candidates to resume QC. An incomplete candidate is never treated as an indexable complete envelope. A fresh vision response requires fresh review. After all coverage and approvals succeed, assemble/validate and attach the complete extraction artifact under a valid claim. Preserve it independently of vector staging; no OCR repeat solely because chunking/embedding changes. For FAQ, record explicit factual authority and whole-group exclusions separately. Preserve all original Q&A associations in faithful extraction; only approved factual groups feed chunking. Governing context is resolved from the whole retained structure before selection and stays with each affected answer; context exclusive to excluded pairs is omitted. Review exposes the same context. Reviewer prose is stored as bounded inspection metadata separately from quality warnings and never interpreted as an extraction unreadability flag. Behavioral scenarios and live-data placeholders remain unsearchable factual content. No trustworthy remaining groups means visible failure. Client text/group labels cannot bypass validation. Chunk text stays faithful evidence; its embedding input and lexical/identifier matching use recorded normalization. Do not reverse numbers, drop exceptions or change meaning. Reindexing ready documents is separately designed controlled maintenance, not failed-job retry. Purging applies to originals, extraction candidates/artifacts, decisions, chunks and retained tool excerpts under an explicit policy; immediate logical exclusion remains required. ## 5. Minimal voice conversation and evidence; deferred text tables ### 5.1 conversations | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, owner_user_id | uuid | Ownership | | client_request_id | uuid | Create idempotency key | | request_hash | char(64) | Normalized create payload | | mode | text | text or voice | | title | varchar(120) nullable | Optional display label | | status | text active | active, stale, closed | | access_epoch | bigint | Knowledge-removal snapshot | | created_at, updated_at | timestamptz | Ordering | UNIQUE(owner_user_id,client_request_id). Scoped FK owner. Index owner/created_at/id. Effective status is stale if epoch differs even before explicit row updates. The MVP accepts mode=voice only, records owned identity/epoch and retains no message history. The proposed future mode=text branch is not enabled by merely adding the column. Add chain keys needed for live ownership; stale/closed conversations cannot start new media. ### 5.2 turns (deferred) | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, conversation_id | uuid | Text turn identity | | client_request_id | uuid | Chat retry correlation | | request_hash | char(64) | Conversation/message digest | | status | text running | running, answered, needs_clarification, insufficient_information, failed | | settings_revision, knowledge_revision, access_epoch | bigint | Actual snapshots | | execution_profile | jsonb | Model, actual organization instruction, prompt version, tool schema version and limits | | started_at, deadline_at | timestamptz | Execution timeout | | finished_at | timestamptz nullable | Terminal completion | | error_code, error_message | text nullable | Normalized failure | | error_retryable | boolean false | Technical retry hint | | created_at | timestamptz | Creation | UNIQUE(conversation_id,client_request_id). Partial UNIQUE(conversation_id) WHERE status='running'. CHECK terminal iff finished_at is not null; deadline_at > started_at. Scoped FK conversation. Mode=text is an application invariant checked while locking conversation. Message text resides in messages, not duplicated here. Reconstruct API response from messages/citations; replay does not call provider again. Startup/deadline cleanup marks interrupted turns failed. ### 5.3 messages (deferred) | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, conversation_id, turn_id | uuid | Ownership and text turn | | sequence_no | bigint | Stable conversation order, >=1 | | role | text | user or assistant | | content | text | Message body | | created_at | timestamptz | Creation | UNIQUE(conversation_id,sequence_no), UNIQUE(turn_id,role). Both roles may exist for completed turn; failed turn can have user only. Add UNIQUE(organization_id,conversation_id,id) as needed for matching references. Enforce `(organization_id,conversation_id,turn_id)` FK to a corresponding unique key on turns, not independent FKs that could attach a message to the wrong conversation. Allocate sequence while holding conversation row lock; no model tool/system messages in this table. ### 5.4 tool_calls (voice-only MVP) | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, live_session_id | uuid | Owned voice parent; live_session_id NOT NULL | | external_call_id | text | Provider call correlation | | tool_name | text | search_knowledge only | | arguments | jsonb | Validated query/context without model scope | | request_hash | char(64) | Canonical argument digest | | status | text running | running, succeeded, failed | | knowledge_revision, access_epoch | bigint | Retrieval snapshots | | result_json | jsonb nullable | Evidence IDs/text/locations, no_evidence or normalized error | | error_code | text nullable | Technical/cancellation reason | | created_at | timestamptz | Creation | | completed_at | timestamptz nullable | Terminal completion | UNIQUE(live_session_id,external_call_id); scoped FK to live_sessions. CHECK terminal iff completed_at is non-null; CHECK tool_name='search_knowledge'. No turn_id or FK to deferred turns/messages/citations is required in this migration. A later text extension must explicitly add its parent/constraint design; it is not implicit scope for this MVP. Same call ID/hash waits or replays saved output after fresh eligibility/epoch checks. Different hash conflicts. Cancelled, expired, stale or closed-parent work is terminal failed with safe reason, and cannot release late evidence or resume audio. API restart fails interrupted running calls and their old media sessions. Provider work is outside transactions. Source references are unique within a live turn; result_json retains actual document_id/chunk_id, title, faithful excerpt and nullable location. UI labels them retrieved evidence unless spoken attribution is verified. Redact revoked excerpts on poll/replay. Retained tool content is covered by purge policy; diagnostic logs must not contain document bodies/audio/secrets. ### 5.5 citations (deferred) | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, turn_id, tool_call_id | uuid | Answer/evidence correlation | | source_ref | text | S1, S2... unique across all searches within this turn | | document_id, chunk_id | uuid | Stable actual source IDs | | title_snapshot | text | Title at answer time | | location_snapshot | jsonb | Actual source locator | | excerpt | text nullable | Display evidence; cleared if policy requires purge | | created_at | timestamptz | Answer commit | UNIQUE(turn_id,source_ref). Scoped FKs for sources plus chain-consistent composite FKs: chunk belongs to the cited document, tool call belongs to the same turn. Add referenced unique keys on these chains. Application verifies source_ref belongs to tool result, not arbitrary model output. No assistant_message_id needed: UNIQUE(turn_id,role) resolves the assistant. Only terminal non-failed answers can have final citations (transaction invariant). Keep source identity rows as tombstones if allowed. `available` in API is computed from current access and retention state; revoked source excerpts are not emitted by source endpoints. Old answer prose cannot be retroactively withdrawn and remains owner-visible under history policy. Do not hard-delete referenced chunks through ordinary application DELETE. ## 6. Live and audit tables ### 6.1 live_sessions | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, conversation_id, owner_user_id, auth_session_id | uuid | Session ownership and logout correlation | | client_request_id | uuid | Creation correlation | | request_hash | char(64) | Normalized conversation/create-options digest; no SDP | | provider, model | text | Chosen live profile | | provider_session_id | text nullable | External reference | | status | text creating | creating, connecting, connected, closed, failed | | settings_revision, knowledge_revision, access_epoch | bigint | Creation snapshots | | execution_profile | jsonb | Instruction/prompt plus proposed audio/transcription capability snapshot | | expires_at, created_at, updated_at | timestamptz | TTL/lifecycle | | connected_at, closed_at | timestamptz nullable | Transition timestamps | | close_reason, error_code | text nullable | Normalized reason | UNIQUE(owner_user_id,client_request_id). Partial UNIQUE(conversation_id) WHERE status IN ('creating','connecting','connected'). Scoped and chain-consistent FKs ensure owner/auth session belong to same organization and user; live conversation is owned by that user. CHECK terminal implies closed_at set. No SDP replay field is required for the OpenAI Realtime WSS flow. Store no raw audio. Provider credentials are server configuration, never database plaintext. Application stream path derives from session ID; it is not a bearer provider credential. API instance owns the direct OpenAI Realtime WSS connection and audio relay in memory; DB stores mapping/state, not recoverable media. After API restart, mark nonterminal sessions failed and attempt cleanup. Reconnection uses a new session. Poll returns recent tool_calls, not a fabricated transcript. Available current-session provider transcripts are relayed to the UI with completion/interruption state; durable full voice message storage is deferred. Existing text messages/turns are not silently reused for voice. ### 6.2 audit_events | Column | Type/default | Meaning | | --- | --- | --- | | id, organization_id, actor_user_id | uuid (actor nullable) | Administrator/system action | | action | text | upload, selection_changed, document_deleted, ingestion_retry, extraction_review, configuration_changed, session_revoked | | target_id | uuid nullable | Referenced object; polymorphic diagnostic field | | request_id | text nullable | HTTP tracing | | idempotency_key | uuid nullable | Delete/retry idempotency | | request_hash | char(64) nullable | Mutation payload hash | | response_json | jsonb nullable | Replay of delete/retry outcome | | metadata | jsonb | Changed IDs/revisions, redacted reason | | created_at | timestamptz | Event time | Partial UNIQUE(organization_id,actor_user_id,action,target_id,idempotency_key) WHERE idempotency_key IS NOT NULL. Delete/retry/review require non-null actor and target. A forward migration extends the action CHECK and replay-required CHECK to extraction_review; never edit the initial revision. Insert audit replay record in SAME transaction as the mutation. Concurrent unique conflict reloads committed response. Preserve these records for the supported retry window; no cleanup duration is assumed. Avoid document text/secrets in audit metadata. ## 7. Transaction boundaries and invariant enforcement | Operation | One database transaction | Outside transaction | | --- | --- | --- | | Upload | Document + job + audit | File staging/write; reconcile orphans | | Claim | Row lock, new token/lease, attempt increment | Extraction and provider calls | | Publish | Lock document/job; verify token/lease; insert all chunks once; ready/succeeded | Already complete staged embeddings | | Selection | Settings lock, expected revision, active flags, revision/epoch, stale conversations, audit | Best-effort closing provider sessions after logical invalidation | | Review decision | Document/job lock, exact candidate/source/profile check, decision + audit replay | Reading exact retained preview; no provider call | | Review/artifact attachment | Document/job lock, current token/lease, trusted references/progress | Bounded candidate/artifact file writes | | Deferred chat admission | Settings/conversation locks, request lookup, turn + user message | Provider inference/tool loop | | Deferred chat completion | Settings/conversation locks, epoch validation, assistant + citations + terminal status | Browser delivery after commit | | Live create | Reservation/idempotency/ownership first; state update after provider | Provider creation and trusted control | | Delete/retry | State change + unique audit replay result | Physical cleanup or future worker execution | Use consistent lock order where resources overlap: organization settings → conversation or document → job or turn/session. Do not hold settings lock during remote calls. Publication does not acquire settings after a document lock; it leaves selection unchanged. Retry/publish paths lock document then job to avoid inversion. Claims lock only jobs and commit quickly. On active-document removal: database epoch invalidation is authoritative immediately for new operations. After transaction, notify/close provider sessions and discard stale pending evidence. Cannot recall previously delivered live audio. Session close failure remains observable and bounded by TTL; it is not represented as guaranteed erasure at the provider. ## 8. Migration plan Treat migrations/versions/0001_ingestion_foundation.py as applied and immutable. The generic 001_identity/002_knowledge/003_conversations sequence from revision 1.2 is not an instruction to recreate or combine the current foundation. | Forward change | Content and gate | | --- | --- | | Retained extraction/review | documents.extraction_state; extraction_review audit/check support; test fencing, stale decisions and idempotency | | Identity and voice | auth_sessions, owned voice conversations, live_sessions, voice-only tool_calls; scoped/owner-chain FKs and replay/partial uniqueness | | Later text milestone | turns/messages/citations plus explicit text-tool parent extension; not needed for voice shipment | Choose actual revision IDs after inspecting Alembic head. Create tables in FK dependency order and update compatibility/schema checks for new revisions without weakening original frozen embedding checks. Inspect bootstrap/consumers of changed contracts. Validate upgrades against isolated real PostgreSQL. The seven foundation tables already hold organizations/users/settings, documents/jobs/chunks and audit. Preserve IDs, profile snapshots, vectors and original files. No model/dimension/preprocessing change or content rewrite is authorized by framework integration. No applied migration was changed or new migration executed by this documentation update. ## 9. Essential database validation Require real PostgreSQL evidence for current MVP changes: cross-organization/ owner-chain FK rejection; upload/review/retry/live-create replay and changed payload conflicts; concurrent live reservation; claim/lease fencing; exact retained-output decisions and attachment races; retry of the same document/job; complete publication rollback/ambiguous commit/crash; inactive/deleted exclusion; epoch race before tool-result delivery; cancellation/restart terminal states. Tool sources must resolve to the actual document/chunk chain. Ordinary-suite skips do not establish database acceptance. Use the documented isolated TEST_DATABASE_URL with --require-postgres. Existing recorded foundation/ Phase 3/4 historical results and current Phase 5/6 worker/database acceptance are separate from pending authenticated transport/browser/Live acceptance and real-provider/Persian quality. Text finalization/history/citation tests belong to the later text milestone. ## 10. Deliberately absent from Phase 1 No per-organization vector database, message broker tables, raw audio blobs, arbitrary tool schema registry, retention scheduler, multi-version assignment workflow or model catalogue. Full document bodies are in file storage/chunks; original files and recordings are not PostgreSQL byte arrays. Keep no production capacity or retention claim until stakeholders supply those requirements.