//! `TABLE_SPECS`, `TABLE_NAMES` and `DROPPED_TABLES` — how every column is stored and read.//!//! The codec is the file format: changing one here changes what an op already on disk decodes to. It travels with a `MIGRATIONS` entry and the totality tests in `crate::schema::specs`.//!//! `TABLE_SPECS`, `TABLE_NAMES` and `DROPPED_TABLES` from//! `packages/store/src/schema/tableSpecs.ts`, in declaration order.usecrate::schema::decl::{Codec, TableSpec};pubstatic TABLE_SPECS: &[TableSpec] = &[TableSpec { name: "cotton_arrivals", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("record_table", Codec::Text), ("record_id", Codec::Text), ("context", Codec::Json), ("seen_by", Codec::Text), ("seen_at", Codec::Timestamp), ("burst", Codec::Text), ("outcome", Codec::Text), ("reason", Codec::Text), ("retrieval", Codec::Json), ("changes", Codec::Json), ("ask", Codec::Text), ("decided_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ],natural_key:&[],fts_into:None },TableSpec { name: "cotton_filing_proposals", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("owner", Codec::Text), ("session", Codec::Text), ("source", Codec::Text), ("destination", Codec::Text), ("kind", Codec::Text), ("candidates", Codec::Json), ("arrivals", Codec::Json), ("revisions", Codec::Json), ("payload", Codec::Json), ("reason", Codec::Text), ("status", Codec::Text), ("decided_at", Codec::Timestamp), ("answer", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ],natural_key:&[],fts_into:None },TableSpec { name: "cotton_ai_jobs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("level", Codec::Int), ("subject_table", Codec::Text), ("subject_id", Codec::Text), ("input", Codec::Json), ("state", Codec::Text), ("taken_by", Codec::Text), ("taken_at", Codec::Timestamp), ("done_at", Codec::Timestamp), ("outcome", Codec::Json), ("attempts", Codec::Int), ("reason", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None },TableSpec { name: "cotton_ai_calls", pk: "id", columns: &[// Historical ISO text retains its original bytes when create receipts are published. ("at", Codec::Text), ("local_day", Codec::Text), ("id", Codec::Text), ("workspace_id", Codec::Text), ("legacy_id", Codec::Int), ("created_at", Codec::Text), ("function_name", Codec::Text), ("provider", Codec::Text), ("model", Codec::Text), ("status", Codec::Text), ("error_message", Codec::Text), ("input_tokens", Codec::Int), ("output_tokens", Codec::Int), ("cache_read_input_tokens", Codec::Int), ("cache_creation_input_tokens", Codec::Int), ("duration_seconds", Codec::Real), ("latency_ms", Codec::Int), ("cost_usd", Codec::Real), ("key_source", Codec::Text), ("is_preview", Codec::Int), ("metadata", Codec::Text), ("updated_at", Codec::Text), ("device_id", Codec::Text), ("cost_amount", Codec::Real), ("currency", Codec::Text), ("mode", Codec::Text), ("job_id", Codec::Text), ("drained_by", Codec::Text), ], natural_key: &[], fts_into: None },TableSpec { name: "cotton_ai_budgets", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("hourly_cap", Codec::Real), ("daily_cap", Codec::Real), ("currency", Codec::Text), ("usd_rate", Codec::Real), ("paused_until", Codec::Timestamp), ("pause_reason", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None },TableSpec { name: "cotton_usage", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device", Codec::Text), ("kind", Codec::Text), ("tool", Codec::Text), ("view", Codec::Text), ("record", Codec::Text), ("at", Codec::Timestamp), ("record_byline", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_ai_access", pk: "workspace_id", columns: &[ ("workspace_id", Codec::Text), ("owner_user_id", Codec::Text), ("trial_started_at", Codec::Timestamp), ("subscription_active", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_alarms", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("label", Codec::Text), ("hour", Codec::Int), ("minute", Codec::Int), ("repeat_days", Codec::Json), ("enabled", Codec::Bool), ("sound", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_blocked_senders", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("address", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &["workspace_id", "address"], fts_into: None, },TableSpec { name: "cotton_call_log", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("source", Codec::Text), ("external_id", Codec::Text), ("provider", Codec::Text), ("direction", Codec::Text), ("outcome", Codec::Text), ("started_at", Codec::Timestamp), ("duration_s", Codec::Int), ("handle", Codec::Text), ("contact_id", Codec::Text), ("person_id", Codec::Text), ("device", Codec::Text), ("meta", Codec::Json), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "source", "external_id"], fts_into: None, },TableSpec { name: "cotton_collections", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("name", Codec::Text), ("is_default", Codec::Bool), ("sort_key", Codec::Text), ("created_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("color", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_comments", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("parent_id", Codec::Text), ("body", Codec::Text), ("author_kind", Codec::Text), ("author_user_id", Codec::Text), ("author_label", Codec::Text), ("anchor", Codec::Json), ("resolved_at", Codec::Timestamp), ("resolved_by_kind", Codec::Text), ("resolved_by_label", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("kind", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_dictations", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("text", Codec::Text), ("raw_text", Codec::Text), ("source", Codec::Text), ("host_app", Codec::Text), ("words", Codec::Int), ("duration_ms", Codec::Int), ("spoken_at", Codec::Timestamp), ("external_id", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_document_pages", pk: "id", columns: &[ ("document_id", Codec::Text), ("workspace_id", Codec::Text), ("page", Codec::Int), ("text", Codec::Text), ("created_at", Codec::Timestamp), ("id", Codec::Text), ], natural_key: &["document_id", "page"], fts_into: Some("fts_document_pages"), },TableSpec { name: "cotton_documents", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("title", Codec::Text), ("original_name", Codec::Text), ("mime", Codec::Text), ("byte_size", Codec::Int), ("sha256", Codec::Text), ("storage_path", Codec::Text), ("decrypted_path", Codec::Text), ("password", Codec::Text), ("page_count", Codec::Int), ("status", Codec::Text), ("failed_stage", Codec::Text), ("error_code", Codec::Text), ("status_changed_at", Codec::Timestamp), ("doc_type", Codec::Text), ("document_date", Codec::Text), ("period_start", Codec::Text), ("period_end", Codec::Text), ("issuer", Codec::Text), ("summary", Codec::Text), ("facts", Codec::Json), ("text_extracted", Codec::Bool), ("source", Codec::Text), ("mcp_token_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ("secret_id", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &["workspace_id", "sha256"], fts_into: Some("fts_documents"), },TableSpec { name: "cotton_email_participants", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thread_id", Codec::Text), ("email", Codec::Text), ("display_name", Codec::Text), ("role", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["thread_id", "email"], fts_into: None, },TableSpec { name: "cotton_email_senders", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("address", Codec::Text), ("kind", Codec::Text), ("written_to", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp),// Version 119 — WHO DECIDED WHAT THIS SENDER IS (the junk lane,// 12 Oct 2026). `decided_by` is `owner` once the owner junked or// kept the sender on the Senders surface — final: the hourly// classifier never asks about, nor writes, such a row — and// `assistant` once the classifier answered for it; NULL is a// sender nobody has decided, which the classifier may ask about.// `verdict` is the word decided (person, service or junk; NULL// when the owner's Keep left it to the rule), `reason` the line// the Senders page shows ("junk: newsletter, never opened"), and// `decided_at` the instant, which Done for you counts a day by. ("decided_by", Codec::Text), ("verdict", Codec::Text), ("reason", Codec::Text), ("decided_at", Codec::Timestamp), ], natural_key: &["workspace_id", "address"], fts_into: None, },TableSpec { name: "cotton_email_threads", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("external_key", Codec::Text), ("subject", Codec::Text), ("first_at", Codec::Timestamp), ("last_at", Codec::Timestamp), ("email_count", Codec::Int), ("summary", Codec::Text), ("summary_updated_at", Codec::Timestamp), ("summary_by", Codec::Text), ("trashed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("sender_address", Codec::Text), ("sender_kind", Codec::Text), ("record_kind", Codec::Text), ("amount_minor", Codec::Int), ("currency", Codec::Text), ("merchant", Codec::Text), ("record_on", Codec::Text), ("reference", Codec::Text),// Version 121 — THE RECORDS EXTRACTOR'S LINE (the junk lane,// brief 2): what the model was asked about this thread and what// was taken ("asked: kind, amount; took: amount"), field names// only, never a value. NULL is a thread never asked; the rules// clear it whenever they type the thread again from new mail. ("record_reason", Codec::Text), ], natural_key: &["workspace_id", "external_key"], fts_into: None, },TableSpec { name: "cotton_emails", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thread_id", Codec::Text), ("external_id", Codec::Text), ("subject", Codec::Text), ("from_email", Codec::Text), ("from_name", Codec::Text), ("recipients", Codec::Json), ("sent_at", Codec::Timestamp), ("body", Codec::Text), ("snippet", Codec::Text), ("attachments", Codec::Json), ("gmail_id", Codec::Text), ("gmail_account", Codec::Text), ("account", Codec::Text), ("labels", Codec::Json), ("unread", Codec::Bool), ("starred", Codec::Bool), ("in_inbox", Codec::Bool), ("trashed_at", Codec::Timestamp), ("sync_state", Codec::Text), ("created_at", Codec::Timestamp),// Schema 152 (MAIL ALL ON PHONE, 24 Nov 2026): what Senders and a reply read of a mail, as the object// keeps it (the kit's email.json): its To and Cc lines, which way it went, its ids for a reply, the// headers the groups read, Gmail's category, and when Comms archived it. ("to_line", Codec::Text), ("cc_line", Codec::Text), ("direction", Codec::Text), ("message_id", Codec::Text), ("message_refs", Codec::Text), ("list_unsubscribe", Codec::Text), ("list_unsubscribe_post", Codec::Text), ("list_id", Codec::Text), ("precedence", Codec::Text), ("auto_submitted", Codec::Text), ("gmail_category", Codec::Text), ("archived_at", Codec::Timestamp),// Schema 157 (MAIL PREDICATE phase 2): when the mail landed on the server, by its clock; the row's own// `landed_at` beside `created_at`, never the mail's data. ("landed_at", Codec::Timestamp), ], natural_key: &["workspace_id", "external_id"], fts_into: Some("fts_emails"), },TableSpec { name: "cotton_event_attendees", pk: "id", columns: &[ ("id", Codec::Text), ("event_id", Codec::Text), ("email", Codec::Text), ("phone", Codec::Text), ("display_name", Codec::Text), ("response", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_events", pk: "id", columns: &[ ("id", Codec::Text), ("collection_id", Codec::Text), ("title", Codec::Text), ("notes", Codec::Text), ("starts_at", Codec::Timestamp), ("ends_at", Codec::Timestamp), ("all_day", Codec::Bool), ("rrule", Codec::Text), ("location", Codec::Text), ("source_inbox_id", Codec::Text), ("gcal_id", Codec::Text), ("gcal_etag", Codec::Text), ("sync_state", Codec::Text), ("organizer_is_self", Codec::Bool), ("my_response", Codec::Text), ("series_id", Codec::Text), ("original_starts_at", Codec::Timestamp), ("exdates", Codec::Json), ("trashed_at", Codec::Timestamp), ("erase_requested_at", Codec::Timestamp), ("ical_uid", Codec::Text), ("account", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("on_google", Codec::Bool), ("event_place", Codec::Text), ("country", Codec::Text), ("timezone", Codec::Text), ], natural_key: &[], fts_into: Some("fts_events"), },TableSpec { name: "cotton_feedback", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("image_sha256", Codec::Text), ("image_ext", Codec::Text), ("x", Codec::Real), ("y", Codec::Real), ("body", Codec::Text), ("author_kind", Codec::Text), ("author_user_id", Codec::Text), ("author_label", Codec::Text), ("person_id", Codec::Text), ("same_as", Codec::Text), ("share_id", Codec::Text), ("app", Codec::Text), ("context", Codec::Json), ("status", Codec::Text), ("resolved_at", Codec::Timestamp), ("resolved_by_kind", Codec::Text), ("resolved_by_label", Codec::Text), ("resolution_note", Codec::Text), ("parent_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_goals", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("title", Codec::Text), ("why", Codec::Text), ("target_date", Codec::Text), ("status", Codec::Text), ("achieved_at", Codec::Timestamp), ("sort_order", Codec::Real), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_google_accounts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("google_email", Codec::Text), ("refresh_token_enc", Codec::Text), ("sync_token", Codec::Text), ("channel_id", Codec::Text), ("channel_resource_id", Codec::Text), ("channel_expires_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec {// ONE row per workspace, keyed by the workspace itself — the shape// `cotton_vault_state` and `cotton_news_settings` already use. The// three arrays are `Codec::Json`, so a patch hands over a JSON array// and the column stores the text the file's own CHECK admits. name: "cotton_home_arrangement", pk: "workspace_id", columns: &[ ("workspace_id", Codec::Text), ("project_slugs", Codec::Json), ("tools", Codec::Json), ("view_ids", Codec::Json), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_inbox_items", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("raw_text", Codec::Text), ("audio_url", Codec::Text), ("captured_at", Codec::Timestamp), ("route_status", Codec::Text), ("routed_kind", Codec::Text), ("routed_id", Codec::Text), ("route_confidence", Codec::DecimalText), ("correction_of", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("transcript", Codec::Text), ("route_reason", Codec::Text), ("route_proposal", Codec::Json), ("routed_records", Codec::Json), ("route_plan", Codec::Json), ("route_plan_user_edited", Codec::Bool), ("swept_at", Codec::Timestamp), ("sweep_note", Codec::Text), ("said_table", Codec::Text), ("said_record_id", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_thoughts"), },TableSpec { name: "cotton_links", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("from_kind", Codec::Text), ("from_id", Codec::Text), ("to_kind", Codec::Text), ("to_id", Codec::Text), ("created_at", Codec::Timestamp),// Version 53 — the database the target lives in when it is not// this one; NULL is this one, and a link naming this database is// stored as NULL so both spellings are one link. ("to_database", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_locations", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("address", Codec::Text), ("lat", Codec::Real), ("lng", Codec::Real), ("note", Codec::Text), ("source_inbox_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ("place", Codec::Text), ("place_id", Codec::Text), ("country", Codec::Text), ("timezone", Codec::Text), ("near", Codec::Text), ], natural_key: &[], fts_into: Some("fts_locations"), },TableSpec { name: "cotton_mcp_audit", pk: "id", columns: &[ ("id", Codec::Text), ("token_id", Codec::Text), ("workspace_id", Codec::Text), ("tool", Codec::Text), ("args_summary", Codec::Text), ("ok", Codec::Bool), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_mcp_tokens", pk: "id", columns: &[ ("id", Codec::Text), ("owner_user_id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("token_hash", Codec::Text), ("scopes", Codec::Json), ("expires_at", Codec::Timestamp), ("revoked_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("last_used_at", Codec::Timestamp),// Version 53 — the device that minted the token, so revoking the// device can revoke what it minted. NULL until P3 writes it. ("minted_by_device", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_meeting_utterances", pk: "id", columns: &[ ("id", Codec::Text), ("meeting_id", Codec::Text), ("seq", Codec::Int), ("speaker_label", Codec::Text), ("t0_ms", Codec::Int), ("t1_ms", Codec::Int), ("text", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_meetings", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("title", Codec::Text), ("status", Codec::Text), ("source", Codec::Text), ("started_at", Codec::Timestamp), ("ended_at", Codec::Timestamp), ("duration_seconds", Codec::Int), ("language", Codec::Text), ("event_id", Codec::Text), ("speakers", Codec::Json), ("summary_md", Codec::Text), ("decisions", Codec::Json), ("vendor", Codec::Text), ("vendor_job_id", Codec::Text), ("poll_attempts", Codec::Int), ("status_changed_at", Codec::Timestamp), ("audio_deleted_at", Codec::Timestamp), ("failed_stage", Codec::Text), ("error_code", Codec::Text), ("segments", Codec::Json), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp),// Version 53 — the database `event_id` lives in when it is not// this one; NULL is this one. ("event_database", Codec::Text), ], natural_key: &[], fts_into: Some("fts_meetings"), },TableSpec { name: "cotton_media_duplicates", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("record_kind", Codec::Text), ("keep_id", Codec::Text), ("copy_id", Codec::Text), ("distance", Codec::Int), ("method", Codec::Text), ("state", Codec::Text), ("decided_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "keep_id", "copy_id"], fts_into: None, },TableSpec { name: "cotton_media_albums", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("state", Codec::Text), ("decided_at", Codec::Timestamp), ("title", Codec::Text), ("title_by", Codec::Text), ("starts_at", Codec::Text), ("ends_at", Codec::Text), ("home_label", Codec::Text), ("cover_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_media_album_items", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("album_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("added_by", Codec::Text), ("sort_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ], natural_key: &["album_id", "record_id"], fts_into: None, },TableSpec { name: "cotton_media_faces", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("source", Codec::Text), ("source_id", Codec::Text), ("x", Codec::Real), ("y", Codec::Real), ("w", Codec::Real), ("h", Codec::Real), ("quality", Codec::Real), ("cluster_id", Codec::Text), ("person_id", Codec::Text), ("suggested_person_id", Codec::Text), ("suggested_distance", Codec::Real), ("suggestion_dismissed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("embedding", Codec::Text), ("embedding_model", Codec::Text), ("person_by", Codec::Text), ], natural_key: &["workspace_id", "record_kind", "record_id", "source", "source_id"], fts_into: None, },TableSpec { name: "cotton_storage_rules", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("tool", Codec::Text), ("keep_rule", Codec::Text), ("held_bytes", Codec::Int), ("freeable_bytes", Codec::Int), ("held_count", Codec::Int), ("total_count", Codec::Int), ("measured_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id", "tool"], fts_into: None, },TableSpec { name: "cotton_device_keep", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("kind", Codec::Text), ("target", Codec::Text), ("rule", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id", "kind", "target"], fts_into: None, },TableSpec { name: "cotton_groups", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("table_id", Codec::Text), ("name", Codec::Text), ("filter", Codec::Json), ("position", Codec::Real), ("picture", Codec::Text), ("record_byline", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("deleted_at", Codec::Timestamp), ("hidden", Codec::Bool), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_group_members", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("group_id", Codec::Text), ("record_id", Codec::Text), ("place", Codec::Real), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["group_id", "record_id"], fts_into: None, },TableSpec { name: "cotton_tool_assets", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("tool_id", Codec::Text), ("name", Codec::Text), ("bytes", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "tool_id", "name"], fts_into: None, },TableSpec { name: "cotton_automation_runs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("automation", Codec::Text), ("changes", Codec::Json), ("root_first", Codec::Bool), ("started_at", Codec::Timestamp), ("ended_at", Codec::Timestamp), ("outcome", Codec::Text), ("summary", Codec::Text), ("record_byline", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("deleted_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_media_backups", pk: "id", columns: &[("id", Codec::Text), ("workspace_id", Codec::Text), ("object_key", Codec::Text), ("serving_epoch", Codec::Int), ("verified_at", Codec::Timestamp), ("missing_at", Codec::Timestamp)], natural_key: &["workspace_id", "serving_epoch", "object_key"], fts_into: None, },TableSpec { name: "cotton_media_holdings", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("object_key", Codec::Text), ("device_id", Codec::Text), ("tier", Codec::Text), ("bytes", Codec::Int), ("verified_at", Codec::Timestamp), ("dropped_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "object_key", "device_id", "tier"], fts_into: None, },TableSpec { name: "cotton_media_sightings", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("source", Codec::Text), ("source_id", Codec::Text), ("thread_id", Codec::Text), ("key", Codec::Text), ("seen_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_memories", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("slug", Codec::Text), ("title", Codec::Text), ("body", Codec::Text), ("status", Codec::Text), ("machine", Codec::Text), ("visibility", Codec::Text), ("origin_kind", Codec::Text), ("origin_label", Codec::Text), ("reviewed_at", Codec::Timestamp), ("source_external_id", Codec::Text), ("archived_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("source", Codec::Text), ("superseded_by", Codec::Text), ], natural_key: &["workspace_id", "slug"], fts_into: Some("fts_memories"), },TableSpec { name: "cotton_memory_projects", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("slug", Codec::Text), ("name", Codec::Text), ("repos", Codec::Json), ("brand", Codec::Json), ("description", Codec::Text), ("summary_updated_at", Codec::Timestamp), ("summary_by", Codec::Text), ("status", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text),// Version 14 — how this project's launches reach a Mac: the owner// picks every one (`manual`), the dispatcher proposes one// (`suggest`), or the dispatcher places it (`auto`).// Version 42 — the owner's order of the project's page, a list of// section keys; NULL until a section is first moved. ("section_order", Codec::Json), ("trashed_at", Codec::Timestamp), ], natural_key: &["workspace_id", "slug"], fts_into: None, },TableSpec { name: "cotton_money_accounts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("subtype", Codec::Text), ("name", Codec::Text), ("counterparty_person_id", Codec::Text), ("currency", Codec::Text), ("institution", Codec::Text), ("number_mask", Codec::Text), ("is_default", Codec::Bool), ("is_pooled", Codec::Bool), ("archived_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_money_evidence", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("transaction_id", Codec::Text), ("kind", Codec::Text), ("ref_id", Codec::Text), ("excerpt", Codec::Text), ("source_label", Codec::Text), ("attached_by", Codec::Text), ("attached_by_label", Codec::Text), ("created_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_money_statement_lines", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("statement_id", Codec::Text), ("page", Codec::Int), ("line_no", Codec::Int), ("posted_on", Codec::Text), ("text", Codec::Text), ("amount_minor", Codec::MoneyMinor), ("direction", Codec::Text), ("balance_after_minor", Codec::MoneyMinor), ("reference", Codec::Text), ("fingerprint", Codec::Text), ("ignored_reason", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_money_statements", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("document_id", Codec::Text), ("account_id", Codec::Text), ("kind", Codec::Text), ("period_start", Codec::Text), ("period_end", Codec::Text), ("opening_balance_minor", Codec::MoneyMinor), ("closing_balance_minor", Codec::MoneyMinor), ("currency", Codec::Text), ("read_status", Codec::Text), ("read_error", Codec::Text), ("read_by", Codec::Text), ("read_at", Codec::Timestamp), ("line_count", Codec::Int), ("sum_in_minor", Codec::MoneyMinor), ("sum_out_minor", Codec::MoneyMinor), ("balance_check", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_money_transactions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("occurred_on", Codec::Text), ("description", Codec::Text), ("payee_text", Codec::Text), ("account_id", Codec::Text), ("counterparty_person_id", Codec::Text), ("amount_minor", Codec::MoneyMinor), ("amount_known", Codec::Bool), ("direction", Codec::Text), ("currency", Codec::Text), ("for_period", Codec::Text), ("status", Codec::Text), ("certainty", Codec::Text), ("repeat", Codec::Text), ("repeat_day", Codec::Int), ("between_us", Codec::Bool), ("moves_money", Codec::Bool), ("tag", Codec::Text), ("transfer_of", Codec::Text), ("source", Codec::Text), ("external_hash", Codec::Text), ("notes", Codec::Text), ("settles_transaction_id", Codec::Text), ("due_date", Codec::Text), ("source_inbox_id", Codec::Text), ("created_by", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_moods", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("at", Codec::Timestamp), ("line", Codec::Text), ("emotions", Codec::Text), ("emotions_by", Codec::Text), ("local_day", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_moods"), },TableSpec { name: "cotton_msg_contacts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("phone_e164", Codec::Text), ("display_name", Codec::Text), ("person_id", Codec::Text), ("auth_user_id", Codec::Text), ("vip", Codec::Bool), ("muted", Codec::Bool), ("blocked", Codec::Bool), ("on_cotton_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp),// v90: a sender's profile picture (an Instagram avatar), a media// key the Bridge fetched — what a sender suggestion shows. ("avatar_key", Codec::Text), ], natural_key: &["workspace_id", "phone_e164"], fts_into: None, },TableSpec { name: "cotton_msg_contact_handles", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("contact_id", Codec::Text), ("kind", Codec::Text), ("value", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &["workspace_id", "kind", "value"], fts_into: None, },TableSpec { name: "cotton_msg_messages", pk: "id", columns: &[ ("id", Codec::Text), ("thread_id", Codec::Text), ("workspace_id", Codec::Text), ("direction", Codec::Text), ("channel", Codec::Text), ("origin", Codec::Text), ("body", Codec::Text), ("media", Codec::Json), ("external_id", Codec::Text), ("sent_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("read_at", Codec::Timestamp), ("reply_to_id", Codec::Text), ("reply_to_external_id", Codec::Text), ("reactions", Codec::Json), ("meta", Codec::Json), ("sender_contact_id", Codec::Text), ("sender_participant_id", Codec::Text), ("seq", Codec::Int), ("edited_at", Codec::Timestamp), ("deleted_at", Codec::Timestamp), ("forward_of_id", Codec::Text), ("mentions", Codec::Json), ("starred_at", Codec::Timestamp), ("hidden_at", Codec::Timestamp), ("send_state", Codec::Text), ("send_error", Codec::Text), ("send_attempts", Codec::Int), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_messages"), },TableSpec { name: "cotton_msg_reactions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thread_id", Codec::Text), ("message_id", Codec::Text), ("actor", Codec::Text), ("emoji", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &["message_id", "actor"], fts_into: None, },TableSpec { name: "cotton_stories", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("source", Codec::Text), ("account", Codec::Text), ("external_id", Codec::Text), ("person_id", Codec::Text), ("sender", Codec::Text), ("sender_label", Codec::Text), ("kind", Codec::Text), ("caption", Codec::Text), ("media_key", Codec::Text), ("media_content_type", Codec::Text), ("media_dropped_at", Codec::Timestamp), ("posted_at", Codec::Timestamp), ("expires_at", Codec::Timestamp), ("seen_at", Codec::Timestamp), ("kept", Codec::Bool), ("created_at", Codec::Timestamp), ], natural_key: &["workspace_id", "source", "external_id"], fts_into: None, },TableSpec { name: "cotton_msg_receipts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thread_id", Codec::Text), ("phone", Codec::Text), ("delivered_seq", Codec::Int), ("read_seq", Codec::Int), ("updated_at", Codec::Timestamp), ], natural_key: &["thread_id", "phone"], fts_into: None, },TableSpec { name: "cotton_msg_owner_settings", pk: "workspace_id", columns: &[ ("workspace_id", Codec::Text), ("handle", Codec::Text), ("display_name", Codec::Text), ("avatar_url", Codec::Text), ("availability_copy", Codec::Text), ("allow_new_contacts", Codec::Bool), ("app_download_url", Codec::Text), ("read_receipts", Codec::Bool), ("discoverable", Codec::Bool), ("last_seen_visible", Codec::Bool), ("share_requests", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_msg_thread_marks", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("database_id", Codec::Text), ("thread_id", Codec::Text), ("pinned_at", Codec::Timestamp), ("muted_until", Codec::Timestamp), ("archived", Codec::Bool), ("cleared_before", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "database_id", "thread_id"], fts_into: None, },TableSpec { name: "cotton_push_acks", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("push_id", Codec::Text), ("received_at", Codec::Timestamp), ("how", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id", "push_id"], fts_into: None, },TableSpec { name: "cotton_device_relay_keys", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("epoch", Codec::Int), ("relay_identity_key", Codec::Text), ("set_at", Codec::Timestamp), ("set_by", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id", "epoch"], fts_into: None, },TableSpec { name: "cotton_audiences", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("record_table", Codec::Text), ("record_id", Codec::Text), ("audience", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "record_table", "record_id"], fts_into: None, },TableSpec { name: "cotton_msg_thread_filings", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thread_id", Codec::Text), ("database_id", Codec::Text), ("state", Codec::Text), ("paused_by", Codec::Json), ("copied_through", Codec::Json), ("filed_at", Codec::Timestamp), ("unfiled_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "thread_id", "database_id"], fts_into: None, },TableSpec { name: "cotton_msg_thread_participants", pk: "id", columns: &[ ("id", Codec::Text), ("thread_id", Codec::Text), ("workspace_id", Codec::Text), ("contact_id", Codec::Text), ("display_name", Codec::Text), ("created_at", Codec::Timestamp), ("role", Codec::Text), ("left_at", Codec::Timestamp), ("is_self", Codec::Bool), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_msg_threads", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("contact_id", Codec::Text), ("kind", Codec::Text), ("last_message_at", Codec::Timestamp), ("last_message_preview", Codec::Text), ("archived", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("title", Codec::Text), ("external_key", Codec::Text), ("photo_key", Codec::Text), ("description", Codec::Text), ("created_by_phone", Codec::Text), ("read_seq", Codec::Int), ("delivered_seq", Codec::Int), ("muted_until", Codec::Timestamp), ("pinned_at", Codec::Timestamp), ("unread_marked_at", Codec::Timestamp), ("draft", Codec::Text), ("draft_reply_to_id", Codec::Text), ("cleared_before", Codec::Timestamp), ("summary", Codec::Text), ("summary_updated_at", Codec::Timestamp), ("summary_by", Codec::Text), ("trashed_at", Codec::Timestamp), ],// A thread has TWO natural keys, one per kind — `uq_cotton_msg_threads_dm`// on (workspace, contact) and `uq_cotton_msg_threads_group_key` on// (workspace, external key). This field holds one, so it holds the dm's;// `protocol::derived_id::{dm_thread_id, group_thread_id}` is where both// live, and they hash under different prefixes so the two cannot meet. natural_key: &["workspace_id", "contact_id"], fts_into: None, },TableSpec { name: "cotton_news_editions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("status", Codec::Text), ("trigger_kind", Codec::Text), ("edition_label", Codec::Text), ("covered_from", Codec::Timestamp), ("covered_to", Codec::Timestamp), ("story_count", Codec::Int), ("read_minutes", Codec::Int), ("quiet", Codec::Json), ("notes", Codec::Json), ("model", Codec::Text), ("opened_at", Codec::Timestamp), ("status_changed_at", Codec::Timestamp), ("failed_stage", Codec::Text), ("error_code", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_news_seen", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("topic_id", Codec::Text), ("key", Codec::Text), ("title_hash", Codec::Text), ("url", Codec::Text), ("source", Codec::Text), ("first_seen_at", Codec::Timestamp), ("story_id", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_news_settings", pk: "workspace_id", columns: &[ ("workspace_id", Codec::Text), ("edition_times", Codec::Json), ("timezone", Codec::Text), ("stale_after_minutes", Codec::Int), ("stale_refresh", Codec::Bool), ("notify", Codec::Bool), ("next_edition_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_news_stories", pk: "id", columns: &[ ("id", Codec::Text), ("edition_id", Codec::Text), ("topic_id", Codec::Text), ("rank", Codec::Int), ("headline", Codec::Text), ("lede", Codec::Text), ("bullets", Codec::Json), ("sources", Codec::Json), ("why_care", Codec::Text), ("read_minutes", Codec::Int), ("opened_at", Codec::Timestamp), ("feedback", Codec::Text), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_news_topics", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("brief", Codec::Text), ("exclusions", Codec::Text), ("kind", Codec::Text), ("source_url", Codec::Text), ("active", Codec::Bool), ("paused_reason", Codec::Text), ("unopened_streak", Codec::Int), ("last_new_at", Codec::Timestamp), ("sort_order", Codec::Real), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_note_attachments", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("note_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("position", Codec::Int), ("caption", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ],// `cotton_project_links`' key exactly, one table over: a note shows a// record at most once, and the id is DERIVED from these three// (`protocol::derived_id::note_attachment_id`) so two devices// attaching one picture arrive at one row. natural_key: &["note_id", "record_kind", "record_id"], fts_into: None, },TableSpec { name: "cotton_notes", pk: "id", columns: &[ ("id", Codec::Text), ("kind", Codec::Text), ("title", Codec::Text), ("body", Codec::Text), ("journal_date", Codec::Text), ("project_id", Codec::Text), ("published_at", Codec::Timestamp), ("public_slug", Codec::Text), ("source_inbox_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ("author_kind", Codec::Text), ("author_label", Codec::Text), ("managed_by", Codec::Text), ("external_id", Codec::Text), ("source_hash", Codec::Text), ("workspace_id", Codec::Text), ("origin_handle", Codec::Text),// Version 85 — pinned on its page (board 11, "Edit Pin Delete"). ("pinned", Codec::Bool), ], natural_key: &[], fts_into: Some("fts_notes"), },TableSpec { name: "cotton_pages", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("url", Codec::Text), ("host", Codec::Text), ("title", Codec::Text), ("read_at", Codec::Timestamp), ("source_inbox_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("text_state", Codec::Text), ("state", Codec::Text), ("text", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_pages"), },TableSpec { name: "cotton_people", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("full_name", Codec::Text), ("org", Codec::Text), ("role_title", Codec::Text), ("city", Codec::Text), ("summary", Codec::Text), ("summary_updated_at", Codec::Timestamp), ("summary_by", Codec::Text), ("contact_source", Codec::Text), ("device_contact_id", Codec::Text), ("archived_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("birth_month", Codec::Int), ("birth_day", Codec::Int), ("birth_year", Codec::Int), ("timezone", Codec::Text), ("avatar_url", Codec::Text), ("avatar_key", Codec::Text), ("device_contact_snapshot", Codec::Json), ("city_filled_at", Codec::Timestamp), ("avatar_photo_id", Codec::Text), ("trashed_at", Codec::Timestamp), ("language", Codec::Text), ("face_embedding", Codec::Text), ("face_embedding_model", Codec::Text), ("face_embedding_from", Codec::Text), ("city_place", Codec::Text), ("country", Codec::Text), ], natural_key: &[], fts_into: Some("fts_people"), },TableSpec { name: "cotton_person_notes", pk: "id", columns: &[ ("id", Codec::Text), ("person_id", Codec::Text), ("body", Codec::Text), ("noted_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("source_inbox_id", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_person_handles", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("person_id", Codec::Text), ("kind", Codec::Text), ("value", Codec::Text), ("normalised", Codec::Text), ("source", Codec::Text), ("verified_at", Codec::Timestamp), ("position", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &["workspace_id", "kind", "normalised"], fts_into: None, },TableSpec { name: "cotton_person_languages", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("person_id", Codec::Text), ("language", Codec::Text), ("proficiency", Codec::Text), ("position", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_person_suggestions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("person_id", Codec::Text), ("contact_id", Codec::Text), ("candidate_id", Codec::Text), ("reason", Codec::Text), ("score", Codec::Real), ("state", Codec::Text), ("decided_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "person_id", "candidate_id"], fts_into: None, },TableSpec { name: "cotton_photos", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("key", Codec::Text), ("sha256", Codec::Text), ("content_type", Codec::Text), ("size_bytes", Codec::Int), ("width", Codec::Int), ("height", Codec::Int), ("taken_at", Codec::Timestamp), ("preview", Codec::Text), ("caption", Codec::Text), ("summary", Codec::Text), ("summary_by", Codec::Text), ("summary_at", Codec::Timestamp), ("review_note", Codec::Text), ("review_by", Codec::Text), ("review_at", Codec::Timestamp), ("taken_offset", Codec::Int), ("latitude", Codec::Real), ("longitude", Codec::Real), ("place_name", Codec::Text), ("place_city", Codec::Text), ("place_region", Codec::Text), ("place_country", Codec::Text), ("camera_make", Codec::Text), ("camera_model", Codec::Text), ("orientation", Codec::Int), ("favourite", Codec::Bool), ("subtypes", Codec::Json), ("original_filename", Codec::Text), ("aesthetic_score", Codec::Real), ("curation_score", Codec::Real), ("labels", Codec::Json), ("phash", Codec::Text), ("ocr_text", Codec::Text), ("is_utility", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ("trashed_at", Codec::Timestamp), ("image_embedding", Codec::Text), ("image_embedding_model", Codec::Text), ], natural_key: &["workspace_id", "sha256"], fts_into: Some("fts_photos"), },TableSpec { name: "cotton_project_links", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("project_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("note", Codec::Text), ("applied_by", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("pinned", Codec::Bool), ("position", Codec::Real), ("origin_handle", Codec::Text), ], natural_key: &["project_id", "record_kind", "record_id"], fts_into: None, },TableSpec { name: "cotton_prompts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("session_id", Codec::Text), ("project_id", Codec::Text), ("seq", Codec::Int), ("ts", Codec::Timestamp), ("role", Codec::Text), ("text", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_prompts"), },TableSpec { name: "cotton_secrets", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("name", Codec::Text), ("site", Codec::Text), ("username", Codec::Text), ("service", Codec::Text), ("value_enc", Codec::Text), ("vmk_version", Codec::Int), ("hint", Codec::Text), ("last_used_at", Codec::Timestamp), ("expires_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("favourite_at", Codec::Timestamp), ("uses", Codec::Int), ("passkey_id", Codec::Text), ("changed_at", Codec::Timestamp), ("history_enc", Codec::Text), ],// The UNIQUE is PARTIAL since version 6 — it holds only where `service`// is not null, because two logins may share a name. natural_key: &["workspace_id", "service", "name"], fts_into: Some("fts_secrets"), },TableSpec { name: "cotton_vault_keys", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("public_key", Codec::Text), ("wrapped_vmk", Codec::Text), ("vmk_version", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id"], fts_into: None, },TableSpec { name: "cotton_vault_state", pk: "workspace_id", columns: &[ ("workspace_id", Codec::Text), ("vmk_version", Codec::Int), ("rotated_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_secret_placements", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("secret_id", Codec::Text), ("device_id", Codec::Text), ("path", Codec::Text), ("mode", Codec::Int), ("format", Codec::Text), ("env_name", Codec::Text), ("applied_at", Codec::Timestamp), ("applied_hash", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("apply_problem", Codec::Text), ], natural_key: &["workspace_id", "device_id", "path"], fts_into: None, },TableSpec { name: "cotton_placement_proposals", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// What the list is for, in the assistant's words ("Move the// signing keys into the vault"). ("title", Codec::Text),// The placements asked for, as a JSON array — never a value. ("items", Codec::Json), ("status", Codec::Text), ("decided_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_assistant_runs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("source_kind", Codec::Text), ("source_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("session_id", Codec::Text), ("class", Codec::Text), ("state", Codec::Text), ("task", Codec::Text), ("receipt", Codec::Text), ("turns", Codec::Int), ("input_tokens", Codec::Int), ("output_tokens", Codec::Int), ("cost_usd", Codec::Real), ("result_note_id", Codec::Text), ("stopped_reason", Codec::Text), ("error", Codec::Text), ("queued_at", Codec::Timestamp), ("started_at", Codec::Timestamp), ("finished_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_screenplay_characters", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("screenplay_id", Codec::Text), ("name", Codec::Text), ("aliases", Codec::Json), ("bio", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ("want", Codec::Text), ("arc", Codec::Text), ("age", Codec::Text), ("casting_thoughts", Codec::Text), ("picture_photo_id", Codec::Text), ], natural_key: &["screenplay_id", "name"], fts_into: None, },TableSpec { name: "cotton_screenplay_documents", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("screenplay_id", Codec::Text), ("kind", Codec::Text), ("body", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &["screenplay_id", "kind"], fts_into: None, },TableSpec { name: "cotton_screenplay_draft_scenes", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("draft_id", Codec::Text), ("scene_id", Codec::Text), ("position", Codec::Real), ("heading", Codec::Text), ("body", Codec::Text), ("purpose", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["draft_id", "scene_id"], fts_into: None, },TableSpec { name: "cotton_screenplay_drafts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("screenplay_id", Codec::Text), ("name", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_screenplay_scenes", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("screenplay_id", Codec::Text), ("position", Codec::Real), ("heading", Codec::Text), ("body", Codec::Text), ("purpose", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("act", Codec::Text), ("sequence", Codec::Text), ("status", Codec::Text), ("location", Codec::Text), ("characters_in_scene", Codec::Text), ("characters_set_by", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_screenplays", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("title", Codec::Text), ("logline", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("archived_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_session_messages", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("project_id", Codec::Text), ("to_kind", Codec::Text), ("to_session_id", Codec::Text), ("from_kind", Codec::Text), ("from_session_id", Codec::Text), ("kind", Codec::Text), ("body", Codec::Text), ("media", Codec::Json), ("reply_to", Codec::Text),// The pending permission id a `decision` answers (version 15) —// the agent's own, off `cotton_sessions.waiting_ref`, and never a// message id. `reply_to` is a foreign key into this table and a// permission is not a row in it. ("request_ref", Codec::Text), ("thought_id", Codec::Text), ("status", Codec::Text), ("claimed_by_session_id", Codec::Text), ("claimed_at", Codec::Timestamp), ("done_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_session_messages"), },TableSpec { name: "cotton_sessions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("project_id", Codec::Text), ("tool", Codec::Text), ("external_id", Codec::Text), ("machine", Codec::Text), ("account", Codec::Text), ("repo_url", Codec::Text), ("branch", Codec::Text), ("cwd", Codec::Text), ("started_at", Codec::Timestamp), ("last_active_at", Codec::Timestamp), ("listened_at", Codec::Timestamp), ("ended_at", Codec::Timestamp), ("summary", Codec::Text), ("title", Codec::Text), ("model", Codec::Text), ("shipped", Codec::Json), ("turn_count", Codec::Int), ("prompt_count", Codec::Int), ("transcript_ref", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp),// Version 13 — which DEVICE this session ran on, when the caller// could prove it. NULL everywhere else, never guessed from// `machine`. ("device_id", Codec::Text),// Version 14 — what the session is DOING, as the agent's own hooks// report it. `state` is NULL for every session logged before the// Code tool and for every session no helper owns; `last_line` is// the tail of the last assistant turn, capped at 280 characters by// the file itself.//// `launch_id` is gone at version 23: the launch folded INTO this// row, so there is nothing left to point at. ("state", Codec::Text), ("state_at", Codec::Timestamp), ("waiting_kind", Codec::Text), ("waiting_ref", Codec::Text), ("last_line", Codec::Text), ("exit_code", Codec::Int), ("permission_mode", Codec::Text), ("host_owned", Codec::Bool),// Version 23 — what the LAUNCH used to carry, on the one object.// `requested_device_id` is the Mac the owner asked for (NULL =// any Mac) and `device_id` above is where it actually went;// `chosen_by` says which of the two decided. `hold_reason` is the// sentence a queued row wears when nothing could place it, and is// cleared the moment something does. ("todo_id", Codec::Text), ("requested_device_id", Codec::Text), ("chosen_by", Codec::Text), ("prompt", Codec::Text), ("hold_reason", Codec::Text), ("claimed_at", Codec::Timestamp), ("report_message_id", Codec::Text), ("error", Codec::Text),// Version 31 — the project conversation. `kind` says whether this// row IS a project's standing conversation or one of the threads// it opens (every row that predates the rung is a `thread`, which// is the column's own default), and `parent_session_id` names the// conversation that opened it — NULL for a session the owner// started from the app. ("kind", Codec::Text), ("parent_session_id", Codec::Text),// Version 53 — the database `todo_id` lives in when it is not// this one; NULL is this one. ("todo_database", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_session_tasks", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("session_id", Codec::Text), ("seq", Codec::Int), ("text", Codec::Text), ("state", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ],// Empty, `cotton_prompts`' own answer for the same shape: the id is// DERIVED from `(session_id, seq)` — the table's UNIQUE —// (`protocol::derived_id::session_task_id`), so two tellings of one// task are one row without a key declared here. natural_key: &[], fts_into: None, },TableSpec { name: "cotton_todo_recurrences", pk: "id", columns: &[ ("id", Codec::Text), ("title", Codec::Text), ("notes", Codec::Text), ("priority", Codec::Int), ("rrule", Codec::Text), ("dtstart", Codec::Timestamp), ("paused", Codec::Bool), ("materialized_until", Codec::Timestamp), ("source_inbox_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("workspace_id", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_todos", pk: "id", columns: &[ ("id", Codec::Text), ("title", Codec::Text), ("notes", Codec::Text), ("label", Codec::Text), ("status", Codec::Text), ("due_at", Codec::Timestamp), ("snoozed_until", Codec::Timestamp), ("priority", Codec::Int), ("completed_at", Codec::Timestamp), ("source_inbox_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("recurrence_id", Codec::Text), ("occurrence_at", Codec::Timestamp), ("workspace_id", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_todos"), },TableSpec { name: "cotton_videos", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("key", Codec::Text), ("sha256", Codec::Text), ("content_type", Codec::Text), ("size_bytes", Codec::Int), ("width", Codec::Int), ("height", Codec::Int), ("duration_ms", Codec::Int), ("taken_at", Codec::Timestamp), ("preview", Codec::Text), ("poster_key", Codec::Text), ("caption", Codec::Text), ("summary", Codec::Text), ("summary_by", Codec::Text), ("summary_at", Codec::Timestamp), ("review_note", Codec::Text), ("review_by", Codec::Text), ("review_at", Codec::Timestamp), ("taken_offset", Codec::Int), ("latitude", Codec::Real), ("longitude", Codec::Real), ("place_name", Codec::Text), ("place_city", Codec::Text), ("place_region", Codec::Text), ("place_country", Codec::Text), ("camera_make", Codec::Text), ("camera_model", Codec::Text), ("orientation", Codec::Int), ("favourite", Codec::Bool), ("subtypes", Codec::Json), ("original_filename", Codec::Text), ("aesthetic_score", Codec::Real), ("curation_score", Codec::Real), ("labels", Codec::Json), ("phash", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("origin_handle", Codec::Text), ("trashed_at", Codec::Timestamp), ], natural_key: &["workspace_id", "sha256"], fts_into: Some("fts_videos"), },TableSpec { name: "cotton_voice_vocabulary", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("term", Codec::Text), ("source", Codec::Text), ("use_count", Codec::Int), ("last_used_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_outages", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("condition", Codec::Text), ("machine", Codec::Text), ("title", Codec::Text), ("effect", Codec::Text), ("doing", Codec::Text), ("started_at", Codec::Timestamp), ("ended_at", Codec::Timestamp), ("told_open_at", Codec::Timestamp), ("told_close_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_workspaces", pk: "id", columns: &[ ("id", Codec::Text), ("name", Codec::Text), ("owner_user_id", Codec::Text), ("created_at", Codec::Timestamp), ("city_name", Codec::Text), ("city_lat", Codec::Real), ("city_lon", Codec::Real), ("msg_import_self_names", Codec::Json),// The household's name on the relay (version 9) — a fact of the// LIFE, so it travels with the file rather than sitting in one// Mac's `role.json`. NULL until a name is claimed. ("relay_name", Codec::Text),// Version 14 — the permission mode a new session opens in. Its// neighbour `dispatch_paused` went with the dispatch modes at// version 23: a household that did not want a session did not// start one. ("session_permission_default", Codec::Text),// Version 53 — what this database is (`personal`, the person's// one own database, or `shared`, every project database from// birth) and the id its derived record ids take, which is the// file's own id for every database made from now on (an older id// only in the final move). Both are fixed when the row is made:// `mint` refuses any change. ("kind", Codec::Text), ("namespace", Codec::Text),// Version 84 — the owner's own person in People (Spec 10.3 "You").// A soft reference: it only points, so it holds no foreign key and// reads as empty while that person is not present. NULL until// `read.you` first links one; a merge carries it to the survivor. ("owner_person_id", Codec::Text),// Version 103 — WHICH RELAY the household is reached through: the// domain its `relay_name` is the first label under, and the host// its Macs dial (`cotton_core::relay_address`). Both NULL, which// is every household until one chooses otherwise, means Cotton's// own relay. Both set, or neither: `read_relay_address` refuses// half an address rather than a CHECK, because a synced table// holds no rule across two columns (`no_cross_column_checks`).// Written once, with the row (`fold::IDENTITY_WRITE_ONCE`).// A fact of the household like the name beside it, so it travels// with the file and every device reads the same answer. ("relay_domain", Codec::Text), ("relay_tunnel_host", Codec::Text),// Version 108 — HOW THE WORLD REACHES THE HOUSEHOLD: which door// its serving Mac keeps open (`cotton_core::front_door`). NULL,// which is every household until one chooses otherwise, is the// relay named just above; `tailscale_funnel` and `direct` are the// other two, and `front_door_address` is the host the world dials// through them — the serving Mac's own name on its tailnet, or// the household's attached domain. NOT write-once, unlike the// relay's three columns: a household changes its door, and a// change of door writes these two and nothing else, so it never// costs the household its relay name. No CHECK: a door this build// does not know is refused by the reader, never taken for the// relay and never a reason to refuse a newer device's write. ("front_door", Codec::Text), ("front_door_address", Codec::Text),// Version 117 — WHAT THE RELAY HOLDS FOR THIS HOUSEHOLD, in the// relay's own words: the JSON of the founder key, the live roster// and the revocations exactly as the last AUTH_OK or `roster.ok`// said them (`cotton_ffi::shell::relay_record`). The relay's// directory is a cache backed up nowhere (architect, 11 Oct// 2026); a relay that lost it learns the household again from// this, said back on every connect. Synced, so every Mac of the// household holds it and any of them can teach a relay that// forgot. NULL is a household no relay has confirmed yet, and a// Mac with nothing kept announces nothing. Plain last writer// wins: every Mac is told the same thing, so the first write is// the only change. ("relay_roster", Codec::Text), ], natural_key: &[], fts_into: None, },// ── version 9 — who may open this database, in the database ─────────────TableSpec { name: "cotton_devices", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("name", Codec::Text), ("platform", Codec::Text), ("app_version", Codec::Text), ("hardware_id", Codec::Text), ("takes_placements", Codec::Bool), ("keep_free_bytes", Codec::Int), ("keep_bytes", Codec::Text),// The owner's order "make this Mac a runner" (written only at an// owner's own screen) and the serving Mac's answer to it. ("runner_ordered_at", Codec::Timestamp), ("runner_confirmed_at", Codec::Timestamp), ("runner_problem", Codec::Text),// Whether this phone's Camera tool shots are also saved to its own// camera roll: a per-device choice, on (1) for every old row. ("camera_roll", Codec::Bool), ("relay_identity_key", Codec::Text), ("approved_at", Codec::Timestamp), ("approved_by_device", Codec::Text), ("revoked_at", Codec::Timestamp), ("revoked_by_device", Codec::Text), ("revoked_reason", Codec::Text), ("recovery_key_shown_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp),// Version 14 — the reading `cotton_machines` used to carry, on the// row that already says which Mac this is. Every device is the// writer of its own reading and per-field clocks are what make that// safe on one shared row. ("cpu_count", Codec::Int), ("mem_total_gb", Codec::Real), ("mem_free_pct", Codec::Int), ("load1", Codec::Real), ("disk_free_gb", Codec::Real), ("sessions_running", Codec::Int), ("sessions_cap", Codec::Int), ("kept_space_bytes", Codec::Int), ("build_lock_held", Codec::Bool),// JSON objects, because their KEYS are the agents — a second agent// must not be a schema change, and an absent key is "not// installed" rather than a NULL column. ("agents", Codec::Json), ("account_ids", Codec::Json), ("host_version", Codec::Text), ("sampled_at", Codec::Timestamp),// Version 24 — what this Mac has promised, what it may promise,// and what it has actually measured a session holding. Plain// numbers, nullable: a Mac that has never reported has none, and a// zero would read as a budget of nothing. They sit LAST, where the// rung's `ALTER TABLE … ADD COLUMN` puts them, so a file that// upgraded and a file this build created end in one order. ("mem_committed_gb", Codec::Real), ("mem_budget_gb", Codec::Real), ("session_peak_gb", Codec::Real), ("session_peak_samples", Codec::Int),// Version 29 — the SERVING ORDER of the Macs that can hold the// server: lower is preferred, NULL is last. A person's column, on// the row the Mac rewrites about itself; an INTEGER because an// order is counted, and nullable because a household nobody has// ordered has none. LAST, where the rung's `ALTER TABLE … ADD// COLUMN` puts it. ("serving_rank", Codec::Int),// Version 37. Which repositories this Mac can start a session in —// written by the Mac about itself, NULL until it has said. ("repos", Codec::Json),// Version 39. The machine's CONSTANTS — its chip, its OS version,// the size of the volume the data directory is on — recorded once// and rewritten only when the fact changes; not readings, and not// in `PRESENCE_COLUMNS`. NULL until the Mac has said. ("chip", Codec::Text), ("os_version", Codec::Text), ("disk_total_gb", Codec::Real), ("update_hold", Codec::Text), ("scope", Codec::Text),// KS0 — the person key of the member this device belongs to. NULL// is a device of the database's owner. Written at the create only. ("person_key", Codec::Text),// Where the serving Mac may ring this device — its Apple push// token, written by the serving Mac alone when the device// registers, retired when Apple says it is gone. On the synced row// so a standby can ring when the serving address is silent. ("push_token", Codec::Text), ("push_bundle_id", Codec::Text), ("push_environment", Codec::Text), ("push_registered_at", Codec::Timestamp), ("push_retired_at", Codec::Timestamp), ("push_retired_reason", Codec::Text),// Version 123 — when this Mac's own sender first rang the owner// (the first push). Written by that Mac alone, once. ("pushed_first_at", Codec::Timestamp),// Version 126 — what iOS last told this phone about Cotton's// notifications. Written by the registration route alone. ("push_authorization", Codec::Text),// Version 132 — the schema this Mac's copy is stamped with and// the moment that copy was last level with the Mac that serves.// Written by the Mac itself with its machine sample. ("schema_version", Codec::Int), ("copy_as_of", Codec::Timestamp),// Version 134 — what the serving Mac's Anthropic work is holding// and spent today (its server writes them on its own row), and// the owner's daily cap for it. ("ai_holds", Codec::Text), ("ai_spend", Codec::Json), ("ai_day_cap_usd", Codec::Real),// Version 135: what a device said of itself with its exchange. ("reported_state", Codec::Json), ],// NONE since version 41: a key holds one row per APPROVAL, so// `(workspace_id, device_id)` names a key's history, not one row. natural_key: &[], fts_into: None, },TableSpec { name: "cotton_oauth_clients", pk: "client_id", columns: &[ ("client_id", Codec::Text), ("kind", Codec::Text), ("secret_hash", Codec::Text), ("metadata_json", Codec::Json), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_oauth_grants", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("client_id", Codec::Text), ("client_name", Codec::Text), ("scope", Codec::Text), ("created_at", Codec::Timestamp), ("revoked_at", Codec::Timestamp),// Version 21. An id, a counter and a timestamp — never a token// and never a hash of one; `cotton_oauth_grants` is in a file that// syncs to every phone. ("token_id", Codec::Text), ("refresh_generation", Codec::Int), ("refresh_rotated_at", Codec::Timestamp),// Version 45. `<generation>:<sha-256 hex>:<writer>` of the current// generation's refresh token — a digest, never presentable, of a// token that carries random bytes no row holds. See// `schema::ddl::OAUTH_GRANTS_TABLE`. ("refresh_digest", Codec::Text),// Version 45. The device id of the Mac that minted the consent —// who the sync route takes the row from, and whose revocation// ends it. See `schema::ddl::OAUTH_GRANTS_TABLE`. ("minted_by", Codec::Text), ], natural_key: &[], fts_into: None, },// ── version 14 — the Code tool: the logins, and a bounded history ───────TableSpec { name: "cotton_agent_accounts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("provider", Codec::Text), ("email", Codec::Text), ("label", Codec::Text), ("five_hour_pct", Codec::Real), ("five_hour_resets_at", Codec::Timestamp), ("weekly_pct", Codec::Real), ("weekly_resets_at", Codec::Timestamp), ("seen_at", Codec::Timestamp), ("seen_on_device_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "provider", "email"], fts_into: None, },TableSpec { name: "cotton_device_samples", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("sampled_at", Codec::Timestamp), ("load1", Codec::Real), ("mem_free_pct", Codec::Int), ("disk_free_gb", Codec::Real), ("sessions_running", Codec::Int), ("build_lock_held", Codec::Bool), ], natural_key: &["workspace_id", "device_id", "sampled_at"], fts_into: None, },TableSpec { name: "cotton_account_usage_samples", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("account_id", Codec::Text), ("sampled_at", Codec::Timestamp), ("five_hour_pct", Codec::Real), ("weekly_pct", Codec::Real), ], natural_key: &["workspace_id", "account_id", "sampled_at"], fts_into: None, },// Version 16 — the repo viewer. Five supporting tables, every one of them// last-write-wins per column: the `repos` worker on the serving Mac is the// only writer, and what it writes is what the host said.TableSpec { name: "cotton_repos", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("key", Codec::Text), ("host", Codec::Text), ("owner", Codec::Text), ("name", Codec::Text), ("kind", Codec::Text), ("default_branch", Codec::Text), ("description", Codec::Text), ("web_url", Codec::Text), ("open_pulls", Codec::Int), ("open_issues", Codec::Int), ("sync_state", Codec::Text), ("last_error", Codec::Text), ("synced_at", Codec::Timestamp),// The cursors hold the newest remote `updated_at` seen, verbatim// as the host spelled it — text, so a poll compares the host's own// string rather than a re-rendered instant. ("pulls_cursor", Codec::Text), ("issues_cursor", Codec::Text),// Version 17 — what a phone says about a HELD repository without// asking anybody: whose disk the bytes are on (`held`), who// accepts a push (`origin`, NULL reading as the host `kind`),// where the refs were at the last pass, and the `repo-mirror`// worker's own state in words. ("held", Codec::Bool), ("origin", Codec::Text), ("head_sha", Codec::Text), ("held_at", Codec::Timestamp), ("bundle_state", Codec::Text), ("last_bundle_error", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "key"], fts_into: None, },TableSpec { name: "cotton_repo_pulls", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("number", Codec::Int), ("remote_id", Codec::Int), ("title", Codec::Text), ("body", Codec::Text), ("state", Codec::Text), ("merged", Codec::Bool), ("draft", Codec::Bool), ("author", Codec::Text), ("head_ref", Codec::Text), ("head_sha", Codec::Text), ("base_ref", Codec::Text), ("mergeable", Codec::Bool), ("additions", Codec::Int), ("deletions", Codec::Int), ("changed_files", Codec::Int), ("comments_count", Codec::Int), ("review_comments_count", Codec::Int), ("labels", Codec::Json), ("checks_state", Codec::Text), ("checks", Codec::Json), ("html_url", Codec::Text), ("remote_created_at", Codec::Timestamp), ("remote_updated_at", Codec::Timestamp), ("merged_at", Codec::Timestamp), ("closed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("merge_commit_sha", Codec::Text), ], natural_key: &["workspace_id", "repo_id", "number"], fts_into: Some("fts_repo_pulls"), },TableSpec { name: "cotton_repo_issues", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("number", Codec::Int), ("remote_id", Codec::Int), ("title", Codec::Text), ("body", Codec::Text), ("state", Codec::Text), ("author", Codec::Text), ("labels", Codec::Json), ("comments_count", Codec::Int), ("html_url", Codec::Text), ("remote_created_at", Codec::Timestamp), ("remote_updated_at", Codec::Timestamp), ("closed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "number"], fts_into: Some("fts_repo_issues"), },TableSpec { name: "cotton_repo_comments", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("target_kind", Codec::Text), ("target_number", Codec::Int), ("kind", Codec::Text), ("remote_id", Codec::Int), ("author", Codec::Text), ("body", Codec::Text), ("review_state", Codec::Text), ("path", Codec::Text), ("line", Codec::Int), ("html_url", Codec::Text), ("remote_created_at", Codec::Timestamp), ("remote_updated_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "kind", "remote_id"], fts_into: None, },TableSpec { name: "cotton_repo_commits", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("sha", Codec::Text), ("message", Codec::Text), ("author_name", Codec::Text), ("author_login", Codec::Text), ("authored_at", Codec::Timestamp), ("parents", Codec::Json), ("html_url", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "sha"], fts_into: None, },// Version 17 — code hosting, phase 0. Two more supporting tables, both// written by the `repo-mirror` worker on the serving Mac alone, so// last-write-wins per column is exactly right for either.TableSpec { name: "cotton_repo_bundles", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text),// The media key the bytes are under. The BYTES are an ordinary// media object; this row is the ledger entry that says a standby// has one more bundle to apply. ("object_key", Codec::Text), ("kind", Codec::Text), ("basis_sha", Codec::Text), ("head_sha", Codec::Text), ("refs_json", Codec::Json), ("bytes", Codec::Int), ("sha256", Codec::Text), ("superseded_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "sha256"], fts_into: None, },// Version 77 — each Mac's own clone of a held repository. One writer per// row (the Mac whose device key the row names), so plain last-write-wins// is exactly right, `cotton_media_holdings`' rule.TableSpec { name: "cotton_repo_clones", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("device_id", Codec::Text), ("state", Codec::Text), ("sentence", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "device_id"], fts_into: None, },TableSpec { name: "cotton_repo_releases", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("tag", Codec::Text), ("name", Codec::Text), ("body", Codec::Text), ("draft", Codec::Bool), ("prerelease", Codec::Bool), ("target_sha", Codec::Text), ("author", Codec::Text), ("published_at", Codec::Timestamp),// `[{name, key, bytes, contentType}]` — every `key` a media key// under `{ws}/repos/{repo_id}/releases/`, so the bytes replicate// and evict like every other object and a screen asks for one on a// tap. ("assets_json", Codec::Json), ("html_url", Codec::Text), ("remote_id", Codec::Int), ("synced_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "tag"], fts_into: None, },// Version 18 — the records the owner writes. Two more supporting tables:// a repository's branch protection and its labels. Both are written by// the `repos` worker when the origin is a host that has them, and by the// owner's own route when the origin is Cotton, so last-write-wins per// column is right for either.TableSpec { name: "cotton_repo_rules", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("branch", Codec::Text),// A JSON ARRAY of check context names. Empty is "no context is// required", which is why the column is NOT NULL: a NULL would be// a second spelling of the same fact. ("required_contexts_json", Codec::Json), ("required_approvals", Codec::Int), ("block_outdated", Codec::Bool), ("allow_push", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "branch"], fts_into: None, },TableSpec { name: "cotton_repo_labels", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("name", Codec::Text), ("color", Codec::Text), ("description", Codec::Text), ("remote_id", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "name"], fts_into: None, },// Version 20 — CI. Four more supporting tables. ONE of them is SERVER-ONLY// (`cotton_repo_vars`; `SERVER_ONLY_TABLES` below carries the reason): a// variable is a process's input and has no screen on a phone. The runs and// the jobs are handed over like any other row, because the runs list and// the checks block on a pull read them.//// **AND SINCE VERSION 26 SO IS THE RUNNER.** Its written reason was that a// runner "means nothing away from the server it polls" — true when the// server was one Mac, and the whole of why 22 Sep's hand-over left every// runner in the household reading "this runner is not registered with this// server". Which Mac answers the name is runtime; the registration is a// fact about the household's MACHINES, and every Mac that might be asked// for work has to hold it. The alternative — re-registering against// whichever Mac serves — cannot work: a Mac that has never seen the row// cannot invent the uuid, the labels or the capacity, and a runner that// re-registered on every hand-over would mint a fresh credential each time// and leave the table a graveyard.TableSpec { name: "cotton_repo_runners", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// NULL is a runner that takes work from EVERY repository in the// workspace — which is what both of the owner's are. ("repo_id", Codec::Text), ("uuid", Codec::Text), ("name", Codec::Text), ("labels_json", Codec::Json), ("device_id", Codec::Text),// The `cotton_code_credentials` grant the runner's signed token// names (version 29; a `registry.db` row before that). The TOKEN is// never here, and there is no hash of one anywhere any more. ("credential_id", Codec::Text), ("version", Codec::Text), ("last_seen_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "uuid"], fts_into: None, },TableSpec { name: "cotton_repo_runs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("index_in_repo", Codec::Int), ("workflow", Codec::Text), ("workflow_name", Codec::Text), ("event", Codec::Text), ("ref", Codec::Text), ("sha", Codec::Text), ("pull_id", Codec::Text), ("status", Codec::Text), ("conclusion", Codec::Text), ("triggered_by", Codec::Text), ("started_at", Codec::Timestamp), ("finished_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "index_in_repo"], fts_into: None, },TableSpec { name: "cotton_repo_jobs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("run_id", Codec::Text), ("index_in_run", Codec::Int),// The number the RUNNER knows this job by — the protocol's// `Task.id`, which is an int64 and cannot be a uuid. ("task_id", Codec::Int), ("name", Codec::Text), ("runs_on", Codec::Text), ("needs_json", Codec::Json), ("status", Codec::Text), ("conclusion", Codec::Text), ("runner_uuid", Codec::Text), ("timeout_minutes", Codec::Int), ("outputs_json", Codec::Json), ("steps_json", Codec::Json), ("summary", Codec::Text),// How many lines are on disk, and the index the runner is told to// trim to. The LINES are a file; these two are the bookkeeping. ("log_lines", Codec::Int), ("log_ack", Codec::Int), ("log_key", Codec::Text), ("cancel_requested", Codec::Bool),// How many times this job has been handed out again after its// runner went silent. The promise is ONCE. ("requeues", Codec::Int), ("started_at", Codec::Timestamp), ("finished_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp),// Version 44. The SHA-256 of the `run` token handed out with this// job — a `run` has no `cotton_code_credentials` row, the job is// its grant. Never the token. Rewritten when a re-queued job is// handed out again. ("token_digest", Codec::Text), ], natural_key: &["workspace_id", "run_id", "index_in_run"], fts_into: None, },TableSpec { name: "cotton_repo_vars", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("name", Codec::Text), ("value", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "repo_id", "name"], fts_into: None, },// Version 21 — which Macs run jobs. One supporting table, SYNCED and// deliberately NOT in `SERVER_ONLY_TABLES`: the phone writes the// declaration and the Mac named by `device_id` obeys it, so a row that// never left the server would put the setting back on the machine it is// about, which is the whole thing this rung undoes.TableSpec { name: "cotton_machine_runners", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// `cotton_devices.device_id` — the KEY, not the row id, because// that is what a Mac knows about itself. ("device_id", Codec::Text), ("enabled", Codec::Bool),// A JSON ARRAY of labels, a subset of the two a Mac may declare.// The VOCABULARY is refused by name on the route; what the column// holds is the shape. ("labels_json", Codec::Json), ("capacity", Codec::Int), ("ai_levels", Codec::Json), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &["workspace_id", "device_id"], fts_into: None, },// Version 29 — the code credential's GRANT, in the person's own file.// Cotton note "Code hosting — why a repository lives in Cotton" § Hand-over.//// The token is signed (`cotton_core::vault::code_tokens`) and lives// nowhere; this row is what a Mac reads to answer "is that grant still// standing", and it is NOT server-only for exactly that reason — a row only// the minting Mac holds is the bug this table exists to end.//// NO SECRET, which is what lets it travel at all. Since version 44 it does// carry the token's DIGEST — nothing a server accepts when presented, and// the one thing that admits a live credential after a key rotation (the// column's own comment below; `tests/no_bearer_in_the_file.rs` argues the// exemption). There is no row for a `run` credential either: a job's token// names its job, and the job reaching `completed` is the revocation.TableSpec { name: "cotton_code_credentials", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("name", Codec::Text), ("scope", Codec::Text), ("read_only", Codec::Int),// And NO `repo_id`: the one scope that names a repository is `run`,// and a `run` has no row here. A column that was NULL on every row// would also put this table on `REPO_CHILD_TABLES`, where a delete// would walk it for rows that cannot exist. ("created_at", Codec::Timestamp), ("expires_at", Codec::Timestamp),// The revocation's mirror, written only by `revocation::revoke()`;// the fold refuses a patch that clears it (`fold::no_un_revocation`). ("revoked_at", Codec::Timestamp), ("last_used_at", Codec::Timestamp),// Version 44. The SHA-256 of the token minted for this row — never// the token, and nothing a server accepts when presented. It is// what admits a live credential after the key it was signed under// has been rotated away. Written once; `fold::no_grant_rewrite`. ("token_digest", Codec::Text),// Version 44. The device id of the Mac that minted the token —// which device a grant is accepted from at sync, and whose// revocation revokes it. Written once; `fold::no_grant_rewrite`. ("minted_by", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_dev_jobs", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// The Mac's DEVICE KEY, as `cotton_sessions.device_id` is: it is// what a client already knows itself by, so the claim reads// `WHERE device_id = ?` against the key it holds. ("device_id", Codec::Text), ("command", Codec::Text), ("cwd", Codec::Text), ("timeout_seconds", Codec::Int), ("state", Codec::Text), ("exit_code", Codec::Int), ("failure", Codec::Text),// Where the WHOLE output is — an append-only file on the Mac that// ran the job. The next three are bookkeeping over it; the log// itself is never rows. ("log_path", Codec::Text), ("log_bytes", Codec::Int), ("log_lines", Codec::Int), ("output_tail", Codec::Text), ("created_at", Codec::Timestamp), ("claimed_at", Codec::Timestamp), ("finished_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ],// A plain uuid: a job is an EVENT the caller asked for, and asking// twice with the same command means two jobs, not one. natural_key: &[], fts_into: None, },TableSpec { name: "cotton_thought_attachments", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("thought_id", Codec::Text), ("record_kind", Codec::Text), ("record_id", Codec::Text), ("position", Codec::Int), ("caption", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ],// `cotton_note_attachments`' key with the owner renamed: a thought// shows a record at most once, and the id is DERIVED from these three// (`protocol::derived_id::thought_attachment_id`) so the phone and a// Mac attaching one picture arrive at one row. No `origin_handle`: a// thought is not shareable. natural_key: &["thought_id", "record_kind", "record_id"], fts_into: None, },TableSpec { name: "cotton_repo_merge_queue", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("repo_id", Codec::Text), ("pull_id", Codec::Text), ("pull_number", Codec::Int),// The branch the pull lands on — the train's base. Short (`main`). ("base_ref", Codec::Text),// The pull's head as the train took it. A push after that is a// different pull from the one the train carries, so the row is// ejected and the train it rode is dissolved. ("head_sha", Codec::Text), ("state", Codec::Text), ("failures", Codec::Int), ("reason", Codec::Text),// The train this row rides, or rode: the number in the ref the// checks run on, main when it formed, the chain's end, its run. ("train_number", Codec::Int), ("train_base_sha", Codec::Text), ("train_tip_sha", Codec::Text), ("train_run_id", Codec::Text),// This pull's own squash commit in the chain. ("landed_sha", Codec::Text), ("enqueued_at", Codec::Timestamp), ("finished_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("train_squash_sha", Codec::Text), ],// A plain uuid: a pull that is ejected and asks again is a second row,// with the first one's sentence still on the first. natural_key: &[], fts_into: None, },// v42 — `decision`.TableSpec { name: "cotton_decisions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// The decision, one sentence. ("title", Codec::Text),// The reasoning behind it, as long as it needs. ("why", Codec::Text),// The pull request that carried it: a number like #1025, or its// address. ("pull", Codec::Text),// Who decided: the session's label, e.g. claude-code@mac-b. ("decided_by", Codec::Text),// The bin (schema v33's shape): readers hide the row, Restore// clears it, emptying the bin erases. ("trashed_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_decisions"), },TableSpec { name: "cotton_table_definitions", pk: "id", columns: &[// The definition's own id, lowercase and never changing. ("id", Codec::Text), ("workspace_id", Codec::Text),// One definition as the shared-format JSON// (`cotton_core::definitions`), an object on the wire. ("definition", Codec::Json), ("builtin", Codec::Bool),// A person edited the definition's instructions; the launch seed// keeps theirs and replaces the rest. ("instructions_edited", Codec::Bool),// Retired storage column; no definitions reader uses it. ("builtin_revision", Codec::Int), ("builtin_hash", Codec::Text), ("builtin_stamp", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_tool_definitions", pk: "id", columns: &[// The definition's own id, lowercase and never changing. ("id", Codec::Text), ("workspace_id", Codec::Text),// One definition as the shared-format JSON// (`cotton_core::definitions`), an object on the wire. ("definition", Codec::Json), ("builtin", Codec::Bool),// A person edited the definition's instructions; the launch seed// keeps theirs and replaces the rest. ("instructions_edited", Codec::Bool), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_board_definitions", pk: "id", columns: &[// The board's own id, lowercase and never changing. ("id", Codec::Text), ("workspace_id", Codec::Text),// One board as its JSON (`cotton_core::definitions::board`), an// object on the wire, read tolerantly by every build. ("definition", Codec::Json), ("builtin", Codec::Bool),// The built-in revision that last wrote the row; a seed writes// only over a lower one. NULL for a row a person wrote.// Retired storage column; no definitions reader uses it. ("builtin_revision", Codec::Int), ("builtin_hash", Codec::Text), ("builtin_stamp", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_toolkits", pk: "id", columns: &[// The kit's own id, lowercase and never changing (`family`). ("id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("description", Codec::Text),// The kit's card picture, a `ToolPicture` as JSON; NULL for none. ("picture", Codec::Json),// The ordered tools, each a built-in key or a carried package// (`cotton_core::toolkits::KitTool`), an array on the wire. ("tools", Codec::Json),// The build seeded it; edited and deleted like any other row. ("shipped", Codec::Bool), ("position", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("trashed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_theme_definitions", pk: "id", columns: &[// The theme's own id, lowercase and never changing. ("id", Codec::Text), ("workspace_id", Codec::Text),// One theme as its JSON (`cotton_core::definitions::theme`), an// object on the wire, read tolerantly by every build. ("definition", Codec::Json), ("builtin", Codec::Bool),// The built-in revision that last wrote the row; a seed writes// only over a lower one. NULL for a row a person wrote.// Retired storage column; no definitions reader uses it. ("builtin_revision", Codec::Int), ("builtin_hash", Codec::Text), ("builtin_stamp", Codec::Int), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_records", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// The table definition's id (`cotton_table_definitions.id`). ("table_id", Codec::Text),// The record's values keyed by column key, an object on the wire// (`cotton_core::records` decides each type's JSON). The project// and the order column live in the two columns below instead. ("data", Codec::Json), ("project_id", Codec::Text), ("position", Codec::Real),// Who last wrote the record: an assistant's name, or "user". ("byline", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ("deleted_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_changes", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("table_id", Codec::Text),// NULL for a change spanning several records (a reorder). ("record_id", Codec::Text), ("verb", Codec::Text), ("byline", Codec::Text), ("before", Codec::Json), ("after", Codec::Json), ("created_at", Codec::Timestamp),// The record's kind (`VERSIONED_TABLES`); NULL on a generic verb's row. ("kind", Codec::Text),// The act's actor, as the receipts name it. ("actor", Codec::Text),// The stamp of the record's own write in this act. ("write_hlc", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_authors", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("device_id", Codec::Text), ("device_name", Codec::Text), ("minted_at", Codec::Timestamp), ("reason", Codec::Text), ("first_stamp", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_revocations", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("subject_table", Codec::Text), ("subject_id", Codec::Text), ("revoked_at", Codec::Timestamp), ("actor", Codec::Text), ("reason", Codec::Text), ("successor", Codec::Text), ("p_sig", Codec::Text), ("signer_person", Codec::Text), ("replaced_by", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_serving_machine", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("epoch", Codec::Int), ("device_credential_id", Codec::Text), ("author_id", Codec::Text), ("relay_key", Codec::Text), ("backup_access_key_id", Codec::Text), ("since", Codec::Timestamp), ("confirmed_by", Codec::Text), ("start_positions", Codec::Json), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_vault_retired_keys", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("version", Codec::Int), ("under_version", Codec::Int), ("under_kcv", Codec::Text), ("wrapped", Codec::Text), ("retired_at", Codec::Timestamp), ("actor", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_media_erasures", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("key", Codec::Text), ("record_table", Codec::Text), ("record_id", Codec::Text), ("erased_at", Codec::Timestamp), ("actor", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_undos", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("change_id", Codec::Text), ("undo_change_id", Codec::Text), ("at", Codec::Timestamp), ("actor", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_grant_rotations", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("grant_id", Codec::Text), ("generation", Codec::Int), ("digest", Codec::Text), ("rotated_at", Codec::Timestamp), ("actor", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_databases", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("name", Codec::Text), ("sort_order", Codec::Real), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_database_departures", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("database_id", Codec::Text), ("device_id", Codec::Text), ("reason", Codec::Text), ("departed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_person_keys", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("public_key", Codec::Text), ("name", Codec::Text), ("sealed_private", Codec::Text), ("vmk_version", Codec::Int), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_admissions", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("person_key", Codec::Text), ("person_name", Codec::Text), ("rights", Codec::Text), ("invite_id", Codec::Text), ("admitted_by_person", Codec::Text), ("p_sig", Codec::Text), ("admitted_at", Codec::Timestamp), ("suggested_person_id", Codec::Text), ("suggested_person_sig", Codec::Text), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_member_person_claims", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("admission_id", Codec::Text), ("person_key", Codec::Text), ("person_id", Codec::Text), ("p_sig", Codec::Text), ("claimed_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_device_statements", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("person_key", Codec::Text), ("device_key", Codec::Text), ("vault_public_key", Codec::Text), ("device_name", Codec::Text), ("p_sig", Codec::Text), ("d_sig", Codec::Text), ("made_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_invites", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("secret_hash", Codec::Text), ("rights", Codec::Text), ("expires_at", Codec::Timestamp), ("made_by_person", Codec::Text), ("p_sig", Codec::Text), ("made_at", Codec::Timestamp), ("recipient", Codec::Text), ("hands_over", Codec::Int), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_joined_places", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("database_id", Codec::Text), ("name", Codec::Text), ("origin", Codec::Text), ("server_device_id", Codec::Text), ("joined_at", Codec::Timestamp), ], natural_key: &["workspace_id", "database_id"], fts_into: None, },TableSpec { name: "cotton_imports", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("source", Codec::Text), ("title", Codec::Text), ("added", Codec::Int), ("skipped", Codec::Int), ("device_id", Codec::Text), ("finished_at", Codec::Timestamp), ("created_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },TableSpec { name: "cotton_connections", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text), ("kind", Codec::Text), ("name", Codec::Text), ("reaches", Codec::Text), ("state", Codec::Text), ("last_read_at", Codec::Timestamp), ("last_error", Codec::Text), ("read_requested_at", Codec::Timestamp), ("secret_id", Codec::Text), ("schedule", Codec::Text),// Per kind; an MCP server's carries its URL and `mapping`. ("config", Codec::Json), ("database_id", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: None, },// v86 — `post`.TableSpec { name: "cotton_posts", pk: "id", columns: &[ ("id", Codec::Text), ("workspace_id", Codec::Text),// The site the post came from: instagram, later facebook. ("source", Codec::Text),// The owner's handle on that site the post was read through. ("account", Codec::Text),// The site's own id for the post; with source and account it is// the dedupe key. ("external_id", Codec::Text),// 1 when the owner saved someone's post, 0 for his own. ("saved", Codec::Bool),// The author's handle on the site, when the site names it. ("author_handle", Codec::Text),// The author's name as the site showed it. ("author_name", Codec::Text),// The People record the author is linked to, by handle only; null// when unknown. ("person_id", Codec::Text), ("caption", Codec::Text),// Array of {key, kind photo|video, contentType}; keys are// originals in the media store. ("media", Codec::Json), ("posted_at", Codec::Timestamp), ("saved_at", Codec::Timestamp), ("permalink", Codec::Text), ("created_at", Codec::Timestamp), ("updated_at", Codec::Timestamp), ], natural_key: &[], fts_into: Some("fts_posts"), },// gen-kind: table-specs];/// Every spec's name, in the same order — `TABLE_NAMES` in tableSpecs.ts.pubstatic TABLE_NAMES: &[&str] = &["cotton_arrivals","cotton_filing_proposals","cotton_ai_jobs","cotton_ai_calls","cotton_ai_budgets","cotton_usage","cotton_ai_access","cotton_alarms","cotton_blocked_senders","cotton_call_log","cotton_collections","cotton_comments","cotton_dictations","cotton_document_pages","cotton_documents","cotton_email_participants","cotton_email_senders","cotton_email_threads","cotton_emails","cotton_event_attendees","cotton_events","cotton_feedback","cotton_goals","cotton_google_accounts","cotton_home_arrangement","cotton_inbox_items","cotton_links","cotton_locations","cotton_mcp_audit","cotton_mcp_tokens","cotton_meeting_utterances","cotton_meetings","cotton_media_duplicates","cotton_media_albums","cotton_media_album_items","cotton_media_faces","cotton_storage_rules","cotton_device_keep","cotton_groups","cotton_group_members","cotton_tool_assets","cotton_automation_runs","cotton_media_holdings","cotton_media_backups","cotton_media_sightings","cotton_memories","cotton_memory_projects","cotton_money_accounts","cotton_money_evidence","cotton_money_statement_lines","cotton_money_statements","cotton_money_transactions","cotton_moods","cotton_msg_contacts","cotton_msg_contact_handles","cotton_msg_messages","cotton_msg_reactions","cotton_stories","cotton_msg_receipts","cotton_msg_owner_settings","cotton_msg_thread_filings","cotton_msg_thread_marks","cotton_push_acks","cotton_device_relay_keys","cotton_audiences","cotton_msg_thread_participants","cotton_msg_threads","cotton_news_editions","cotton_news_seen","cotton_news_settings","cotton_news_stories","cotton_news_topics","cotton_note_attachments","cotton_notes","cotton_pages","cotton_people","cotton_person_notes","cotton_person_handles","cotton_person_languages","cotton_person_suggestions","cotton_photos","cotton_project_links","cotton_prompts","cotton_secrets","cotton_vault_keys","cotton_vault_state","cotton_secret_placements","cotton_placement_proposals","cotton_assistant_runs","cotton_screenplay_characters","cotton_screenplay_documents","cotton_screenplay_draft_scenes","cotton_screenplay_drafts","cotton_screenplay_scenes","cotton_screenplays","cotton_session_messages","cotton_sessions","cotton_session_tasks","cotton_todo_recurrences","cotton_todos","cotton_videos","cotton_voice_vocabulary","cotton_outages","cotton_workspaces","cotton_devices","cotton_oauth_clients","cotton_oauth_grants","cotton_agent_accounts","cotton_device_samples","cotton_account_usage_samples","cotton_repos","cotton_repo_pulls","cotton_repo_issues","cotton_repo_comments","cotton_repo_commits","cotton_repo_bundles","cotton_repo_clones","cotton_repo_releases","cotton_repo_rules","cotton_repo_labels","cotton_repo_runners","cotton_repo_runs","cotton_repo_jobs","cotton_repo_vars","cotton_machine_runners","cotton_code_credentials","cotton_dev_jobs","cotton_thought_attachments","cotton_repo_merge_queue","cotton_decisions","cotton_table_definitions","cotton_tool_definitions","cotton_board_definitions","cotton_toolkits","cotton_theme_definitions","cotton_records","cotton_changes","cotton_authors","cotton_revocations","cotton_serving_machine","cotton_vault_retired_keys","cotton_media_erasures","cotton_undos","cotton_grant_rotations","cotton_databases","cotton_database_departures","cotton_person_keys","cotton_admissions","cotton_member_person_claims","cotton_device_statements","cotton_invites","cotton_joined_places","cotton_imports","cotton_connections","cotton_posts",// gen-kind: table-names];/// The tables a server keeps to ITSELF — in every file's schema, written like/// any other row, and never handed over.////// A NAMED LIST with a written reason each, the `RETIRED_TABLES` shape and for/// the same cause: an op carries no origin version and no table carries a flag,/// so the only place "this one stays here" can be said is a list somebody has/// to read. It is NOT a retirement — the table is live, the server reads and/// writes it every day, and a file that already holds rows keeps them.////// Three readers, and together they are the whole of the exclusion:////// - **the stream skips it** — [`crate::changes`] walks/// [`handed_over_specs`] rather than [`TABLE_SPECS`], so no pull ever/// contains one of these rows;/// - **the ceiling skips it** — [`crate::cursors::cursor_ceiling`] reads the/// same list, because a row served by nobody must raise nobody's cursor or an/// author whose only newer writes are these reads as "behind" for ever;/// - **the outbox refuses it** — [`crate::outbox::queue_ops`] drops one rather/// than queueing it, so a device cannot push what a server would not serve.////// The fold still ACCEPTS one: a build that has already handed rows over should/// take them back rather than park them in `_parked`, and the snapshot/// strip ([`crate::snapshot::NOT_ON_A_PHONE`]) is what keeps a fresh phone from/// starting with any.pubstatic SERVER_ONLY_TABLES: &[(&str, &str)] = &[ ("cotton_ai_calls","METERING (architect, 14 Oct 2026): one row per model call the serving Mac made, written by that Mac's own model client and read by its quota and spend checks. A phone or a runner Mac holds no copy; the AI-usage screen reads them through one live call to the serving Mac. Synced, they were twenty-one thousand receipts one schema move minted at once, and they kept the owner's phone from syncing anything else", ), ("cotton_mcp_audit","one row per MCP tool call, and about two hundred thousand of them on the owner's own file. It answers \"what did an assistant do in my database\" — a question asked on the server, of the server, in the transparency log — and no screen on a phone reads it. Handing it over spends a phone's first sync on rows nothing there will ever open", ), ("cotton_repo_vars","an input to a process on a machine, set once beside the workflow that reads it, and no screen on a phone shows one: a variable is edited where the runner is, on the Mac's own Code hosting screen. The half that matters is elsewhere — a SECRET is a sealed `cotton_secrets` row under service `ci.<repo_id>`, while a value here is stored in the clear. Keeping it here is not a promise that a var's value never reaches a phone: `cotton_repo_jobs` syncs, and a job's log, summary and outputs carry whatever the build printed", ), ("cotton_repo_merge_queue","the serving Mac's own bookkeeping of which pulls asked to land and which train they ride: the `ci` worker on that Mac is the only writer and the only reader, and it forms the train from the clone that Mac holds. What a phone shows is on the pull row already — the train writes a `Merge queue` context into `cotton_repo_pulls.checks`, which syncs, so the screen a person looks at needs none of these rows", ),];/// The metering tables: the serving Mac's own record of what it spent, never/// synced. `cotton_ai_calls` is a server-only spec ([`SERVER_ONLY_TABLES`]);/// `_ai_batches` is a system table ([`crate::meta::SYSTEM_TABLE_NAMES`]), so no/// spec hands it over either.pubconst METERING_TABLES: &[&str] = &["cotton_ai_calls", "_ai_batches"];/// Is this table one a server keeps to itself?#[must_use]pubfn is_server_only(table: &str) -> bool { SERVER_ONLY_TABLES.iter().any(|(name, _)| *name == table)}/// Observations a device makes about itself (architect, 16 Oct 2026)./// They retain their typed rows and receipts locally, but never travel or/// become changes waiting to send. An act's usage event is telemetry too;/// the record the person actually changed is its own replicated write./// Latest device identity/admission and external message delivery receipts/// are shared state, not entries in this list. Push acknowledgements still/// reach the serving Mac through their explicit live call, not replication.pubstatic DEVICE_LOCAL_TABLES: &[(&str, &str)] = &[ ("cotton_usage", "this device's visits, route restoration and interaction history"), ("cotton_device_samples", "this device's machine and disk sample history"), ("cotton_account_usage_samples", "this device's sampled agent usage history"), ("cotton_push_acks", "this device's seen/opened push receipts"),];/// The queue and its pending count read the same exclusion as the receipt/// stream. `column` is an internal SQL identifier, never caller input.pub(crate) fn handed_over_clause(column: &str) -> String {let names = SERVER_ONLY_TABLES.iter().chain(DEVICE_LOCAL_TABLES) .map(|(name, _)| format!("'{name}'")).collect::<Vec<_>>().join(", "); format!("{column} NOT IN ({names})")}/// Is this table ever handed from one file to another?#[must_use]pubfn is_handed_over(table: &str) -> bool { !is_server_only(table) && !DEVICE_LOCAL_TABLES.iter().any(|(name, _)| *name == table)}/// Every spec that may be HANDED OVER — [`TABLE_SPECS`] less/// [`SERVER_ONLY_TABLES`] and [`DEVICE_LOCAL_TABLES`].////// The one reader of the table list on the sync path. Everything else —/// the fold, the codecs, the totality gate — still walks `TABLE_SPECS`, because/// a server-only table is a real table with a real codec; it simply/// never leaves.pubfn handed_over_specs() -> implIterator<Item = &'staticTableSpec> { TABLE_SPECS.iter().filter(|spec| is_handed_over(spec.name))}/// Names that live on the network, in nobody's file — `DROPPED_TABLES`.pubstatic DROPPED_TABLES: &[&str] = &["cotton_cell_routes",];/// The foreign keys that OWN their child: the child is present only while its/// parent is. `(child table, child column, parent table)`.////// In the file each one is a plain `REFERENCES parent(id)` with NO `ON DELETE`/// action — a tripwire, never a mover. SQLite used to cascade these, which/// removed a child with no receipt of its own; now the fold moves children/// itself when a parent is retracted, and the constraint only refuses a child/// written under a parent that is not there. `tests/no_cascade_between_replicated_tables.rs`/// holds the rule.////// Hand-written, and held equal to the file's own `PRAGMA foreign_key_list` by/// `tests/fresh_line_schema.rs` (`owning_refs_equal_the_live_schema_foreign_key_list`),/// whose ignored `print_the_ref_lists` regenerates the two lists it can read./// `workspace_id → cotton_workspaces` is left out of all three: every synced/// table has it, and the workspace is the file.pubconst OWNING_REFS: &[(&str, &str, &str)] = &[ ("cotton_comments", "parent_id", "cotton_comments"), ("cotton_document_pages", "document_id", "cotton_documents"), ("cotton_email_participants", "thread_id", "cotton_email_threads"), ("cotton_emails", "thread_id", "cotton_email_threads"), ("cotton_event_attendees", "event_id", "cotton_events"), ("cotton_feedback", "parent_id", "cotton_feedback"), ("cotton_group_members", "group_id", "cotton_groups"), ("cotton_media_album_items", "album_id", "cotton_media_albums"), ("cotton_meeting_utterances", "meeting_id", "cotton_meetings"), ("cotton_money_evidence","transaction_id","cotton_money_transactions", ), ("cotton_money_statement_lines","statement_id","cotton_money_statements", ), ("cotton_money_statements", "document_id", "cotton_documents"), ("cotton_msg_contact_handles","contact_id","cotton_msg_contacts", ), ("cotton_msg_messages", "thread_id", "cotton_msg_threads"), ("cotton_msg_reactions", "message_id", "cotton_msg_messages"), ("cotton_msg_reactions", "thread_id", "cotton_msg_threads"), ("cotton_msg_receipts", "thread_id", "cotton_msg_threads"), ("cotton_msg_thread_filings", "thread_id", "cotton_msg_threads"), ("cotton_msg_thread_participants", "contact_id", "cotton_msg_contacts"), ("cotton_msg_thread_participants", "thread_id", "cotton_msg_threads"), ("cotton_msg_threads", "contact_id", "cotton_msg_contacts"), ("cotton_news_seen", "topic_id", "cotton_news_topics"), ("cotton_news_stories", "edition_id", "cotton_news_editions"), ("cotton_note_attachments", "note_id", "cotton_notes"), ("cotton_person_handles", "person_id", "cotton_people"), ("cotton_person_languages", "person_id", "cotton_people"), ("cotton_person_notes", "person_id", "cotton_people"), ("cotton_project_links", "project_id", "cotton_memory_projects"), ("cotton_prompts", "session_id", "cotton_sessions"), ("cotton_repo_bundles", "repo_id", "cotton_repos"), ("cotton_repo_clones", "repo_id", "cotton_repos"), ("cotton_repo_comments", "repo_id", "cotton_repos"), ("cotton_repo_commits", "repo_id", "cotton_repos"), ("cotton_repo_issues", "repo_id", "cotton_repos"), ("cotton_repo_jobs", "run_id", "cotton_repo_runs"), ("cotton_repo_labels", "repo_id", "cotton_repos"), ("cotton_repo_pulls", "repo_id", "cotton_repos"), ("cotton_repo_releases", "repo_id", "cotton_repos"), ("cotton_repo_rules", "repo_id", "cotton_repos"), ("cotton_repo_runners", "repo_id", "cotton_repos"), ("cotton_repo_runs", "repo_id", "cotton_repos"), ("cotton_screenplay_characters", "screenplay_id", "cotton_screenplays"), ("cotton_screenplay_documents", "screenplay_id", "cotton_screenplays"), ("cotton_screenplay_draft_scenes", "draft_id", "cotton_screenplay_drafts"), ("cotton_screenplay_drafts", "screenplay_id", "cotton_screenplays"), ("cotton_screenplay_scenes", "screenplay_id", "cotton_screenplays"), ("cotton_secret_placements", "secret_id", "cotton_secrets"), ("cotton_session_messages", "to_session_id", "cotton_sessions"), ("cotton_session_tasks", "session_id", "cotton_sessions"), ("cotton_thought_attachments", "thought_id", "cotton_inbox_items"),];/// The foreign keys that only POINT: a value that reads as empty while its/// target is not present — removing the parent leaves the child standing./// Since schema 81 a soft column holds NO foreign key (a plain reference on/// the two money columns aside): every reader goes through `soft_absent`, and/// nothing nulls the value or refuses the parent's removal.pubconst SOFT_REFS: &[(&str, &str, &str)] = &[ ("cotton_call_log", "contact_id", "cotton_msg_contacts"), ("cotton_call_log", "person_id", "cotton_people"), ("cotton_stories", "person_id", "cotton_people"), ("cotton_documents", "mcp_token_id", "cotton_mcp_tokens"), ("cotton_documents", "secret_id", "cotton_secrets"), ("cotton_feedback", "person_id", "cotton_people"), ("cotton_inbox_items", "correction_of", "cotton_inbox_items"), ("cotton_meetings", "event_id", "cotton_events"), ("cotton_money_accounts","counterparty_person_id","cotton_people", ), ("cotton_money_statements","account_id","cotton_money_accounts", ), ("cotton_money_transactions","account_id","cotton_money_accounts", ), ("cotton_money_transactions","counterparty_person_id","cotton_people", ), ("cotton_money_transactions","settles_transaction_id","cotton_money_transactions", ), ("cotton_money_transactions","transfer_of","cotton_money_transactions", ), ("cotton_money_transactions","source_inbox_id","cotton_inbox_items", ), ("cotton_msg_contacts", "person_id", "cotton_people"), ("cotton_msg_messages", "reply_to_id", "cotton_msg_messages"), ("cotton_msg_messages", "sender_contact_id", "cotton_msg_contacts"), ("cotton_msg_messages", "sender_participant_id", "cotton_msg_thread_participants"), ("cotton_news_seen", "story_id", "cotton_news_stories"), ("cotton_news_stories", "topic_id", "cotton_news_topics"), ("cotton_prompts", "project_id", "cotton_memory_projects"), ("cotton_session_messages", "claimed_by_session_id", "cotton_sessions"), ("cotton_session_messages", "from_session_id", "cotton_sessions"), ("cotton_session_messages", "project_id", "cotton_memory_projects"), ("cotton_session_messages", "reply_to", "cotton_session_messages"), ("cotton_session_messages", "thought_id", "cotton_inbox_items"), ("cotton_sessions", "parent_session_id", "cotton_sessions"), ("cotton_sessions", "project_id", "cotton_memory_projects"), ("cotton_sessions", "todo_id", "cotton_todos"), ("cotton_todos", "recurrence_id", "cotton_todo_recurrences"), ("cotton_workspaces", "owner_person_id", "cotton_people"),];/// The soft references that may name a row in ANOTHER database, each with the/// column that says which: `(child table, soft column, database column)`./// While the database column is set, the soft column names a row in that/// database, which this file cannot see — so `soft_refs::soft_names` reads it/// as named, never as absent (several databases 4.2). Every entry is also a/// [`SOFT_REFS`] entry, and the only soft references with NO foreign key in/// the file: a key would refuse every name of a row in another database/// (`tests/fresh_line_schema.rs` holds both halves).pubconst SOFT_REF_DATABASES: &[(&str, &str, &str)] = &[ ("cotton_meetings", "event_id", "event_database"), ("cotton_sessions", "todo_id", "todo_database"),];/// The columns on a [`SERVER_ONLY_TABLES`] child that name a replicated parent/// — never handed over, so the reference never crosses a file boundary, and/// the file carries NO `FOREIGN KEY` for them at all: a server-only row is/// moved by the server's own code, not by the fold and not by SQLite.pubconst SERVER_ONLY_CHILD_REFS: &[(&str, &str, &str)] = &[ ("cotton_mcp_audit", "token_id", "cotton_mcp_tokens"), ("cotton_repo_vars", "repo_id", "cotton_repos"),];