Data Model
The data model as built, in Convex (packages/backend/convex/schema.ts). The table list below is generated from the schema, so it's always what's deployed; the prose around it is kept by hand. The April 2026 design, with entities that were never built, is in archive/superseded-2026-11/04-data-model-april-2026.md.
How it fits together
- Accounts and people. An account is a Clerk organisation (
account_records, keyed by clerkOrgId); people are user_profiles, one per Clerk user; account_members records who belongs to which account (kept by Clerk's membership webhooks). Every account-owned row carries accountId, and every public function checks it (lib/middleware.ts).
- Spaces hold the work.
spaces (shared, or one personal space per person) and space_members decide who sees tasks, lists and pages (lib/spaces.ts). Every task belongs to a space.
- Work objects are
tasks, list records (collections, collection_records, collection_views) and pages (the wiki, with attachments). Each has one write path (lib/taskWrites.ts, lib/recordWrites.ts, pages/writes.ts), and every write records a row in changes, the change log behind history, undo and, later, agents' proposals.
- Chats are
chats, chat_members and messages; one guard decides who reads and posts (lib/chats.ts).
- Agents are
agents (per account), from the platform's agent_catalog, with agent_threads linking a chat to the agent component's thread. Their model comes from the tiers: llm_models (OpenRouter's catalogue), llm_tiers (Thinklio's defaults) and account_model_pins (an account's pins).
- Files are in Cloudflare R2;
files and attachments hold their metadata (one mechanism is planned, DEC-21).
- Repos and imports:
repo_links and ingest_files read lists from connected repos; import_runs tracks Notion imports.
Legacy tables
Still in the schema, but from before spaces, and not to be built on:
- Items, contacts, notes and tags (
items, item_types, contacts, contact_interactions, notes, note_types, tags, entity_tags) and the old task_lists: account-wide, outside the change log. Lists and pages replace them (Q-8; tech debt D1, audit BE-1).
scheduled_agent_runs and event_triggers: nothing creates or runs them yet (tech debt B2; routines, RM-5).
spike_docs and spike_originals: the editor test's copies (DEC-4).
Tables
Generated by scripts/build-schema-doc.py from packages/backend/convex/schema.ts. Don't edit this block by hand.
92 tables.
Identity (synced from Clerk webhooks)
| Table |
What it holds |
Fields |
Indexes |
user_profiles |
— |
28 |
by_clerk_id, by_email, by_pseudonym, by_tester, by_lifecycle_and_deletionScheduledFor |
data_exports |
— |
13 |
by_subjectType_and_subjectId, by_status_and_expiresAt |
Help (novansa-help's reference, help standard § 6.6, § 8.3, § 9)
| Table |
What it holds |
Fields |
Indexes |
help_votes |
Was this helpful?: a count per article per day, with nobody attached. |
4 |
by_article_and_day, by_day |
help_feedback |
— |
4 |
by_userId, by_createdAt |
help_misses |
— |
4 |
by_text, by_lastAt |
Accounts (organisations): Thinklio's own since RM-7 (DEC-57)
| Table |
What it holds |
Fields |
Indexes |
account_records |
— |
20 |
by_accountId, by_lifecycle_and_closingScheduledFor |
Teams
| Table |
What it holds |
Fields |
Indexes |
teams |
— |
4 |
by_account |
team_members |
— |
3 |
by_team, by_user |
Chats (messaging)
| Table |
What it holds |
Fields |
Indexes |
chats |
— |
11 |
by_account, by_account_type, by_team, by_spaceId_and_type, by_objectType_and_objectId |
chat_members |
— |
10 |
by_chat, by_member, by_chat_member |
Messages
| Table |
What it holds |
Fields |
Indexes |
messages |
— |
15 |
by_chat, by_chatId_and_clientId, by_contentType, by_author_type_and_id, search_content (search) |
Notifications (RM-24; DEC-38 to DEC-40)
| Table |
What it holds |
Fields |
Indexes |
notifications |
One row per person per thing to tell them, in the app; push and email follow by their state. Repeats collapse by dedupeKey while unread. |
16 |
by_userId_and_updatedAt, by_userId_and_readAt, by_userId_and_dedupeKey, by_userId_and_email, by_userId_and_chatId_and_readAt, by_updatedAt, by_accountId |
delivery_log |
— |
8 |
— |
feedback |
— |
14 |
by_status, by_userId |
message_reactions |
— |
4 |
by_messageId, by_messageId_and_userId_and_emoji, by_userId |
Spaces (work-model proposal §3.1; pilot plan §5.1)
| Table |
What it holds |
Fields |
Indexes |
spaces |
An ongoing area of work: members (people, later agents), tasks, lists and pages. A personal space belongs to one person and only they see it. |
14 |
by_accountId_and_archived, by_accountId_and_slug, by_accountId_and_ownerId, by_ownerId |
space_members |
— |
12 |
by_spaceId, by_accountId_and_memberType_and_memberId, by_spaceId_and_memberType_and_memberId |
agent_listening_days |
— |
6 |
by_spaceId_and_agentId_and_day |
unasked_feedback |
— |
3 |
by_messageId_and_userId, by_userId |
unasked_mutes |
— |
4 |
by_userId_and_spaceId, by_userId, by_spaceId |
milestones |
— |
8 |
by_spaceId_and_position |
tasks |
— |
25 |
by_spaceId_and_updatedAt, by_accountId_and_updatedAt, by_spaceId_and_status, by_projectId_and_status, by_parentType_and_parentId, by_account_status, by_account_assigned, by_accountId_and_assignedAgentId_and_status, by_recurrence_parent, by_accountId_and_importAssignee, by_milestoneId_and_status, search_title (search) |
contacts |
— |
11 |
by_accountId_and_name, by_accountId_and_ownerKind_and_ownerId, by_organisationId, search_name (search) |
contact_addresses |
— |
6 |
by_contactId, by_accountId_and_kind_and_normalised |
contact_interactions |
— |
8 |
by_contactId_and_occurredAt |
tags |
— |
3 |
by_account |
object_tags |
— |
4 |
by_tag, by_object |
Files (RM-29, DEC-43, DEC-71)
| Table |
What it holds |
Fields |
Indexes |
files |
One row per stored file, in the deployment's R2 bucket under r2Key, with links to everywhere it's used (file_links). Field names follow RippleBase's media where they mean the same. Plan 2026-11-04-files.md. |
35 |
by_spaceId_and_inLibrary_and_archivedAt, by_spaceId_and_archivedAt, by_folderId, by_sourceId, by_pickedBy, by_r2Key, by_chatId, by_legacyAttachmentId, search_fileName (search) |
file_contents |
— |
8 |
by_fileId_and_kind, by_accountId |
file_links |
— |
7 |
by_fileId, by_objectType_and_objectId |
file_folders |
— |
8 |
by_spaceId_and_position, by_parentId, by_sourceId |
file_sources |
— |
19 |
by_spaceId, by_connectionId, by_accountId, by_state |
file_source_work |
— |
4 |
by_sourceId |
| Table |
What it holds |
Fields |
Indexes |
agent_catalog |
— |
17 |
by_slug, by_category, by_published |
Agent Configuration (account-level)
| Table |
What it holds |
Fields |
Indexes |
agents |
— |
26 |
by_account, by_account_status, by_account_slug, by_accountId_and_ownerUserId |
assistant_asks |
— |
12 |
by_accountId, by_fromUserId, by_toUserId |
Agent-Thread Mapping
| Table |
What it holds |
Fields |
Indexes |
agent_runs |
An agent working a task assigned to it (RM-40 part 2, DEC-154): one row per run, with the workflow that carries it (agentRuns.ts). A task has at most one that's running or waiting. Its work and its answer are in the task's comments (chatId), where the agent keeps one thread per task. |
15 |
by_taskId_and_status, by_accountId_and_status |
agent_threads |
— |
6 |
by_chat_agent, by_thread, by_lastActiveAt |
Memory (RM-39, DEC-88)
| Table |
What it holds |
Fields |
Indexes |
memories |
Small statements about a person, a team, the organisation or an agent. Not the content index and not knowledge (DEC-86): read only through lib/memory.ts, written only through lib/memoryWrites.ts. |
16 |
by_accountId_and_subjectType_and_subjectId, by_subjectType_and_subjectId, by_expiresAt |
Routines (RM-5)
| Table |
What it holds |
Fields |
Indexes |
routines |
Work an agent does with nobody asking just then: on a schedule, or when something happens in its space. Read through lib/routines.ts and written only through lib/routineWrites.ts, which records each change. |
17 |
by_spaceId, by_accountId, by_status_and_nextRunAt |
routine_runs |
— |
16 |
by_routineId, by_accountId |
User Agent Configuration
| Table |
What it holds |
Fields |
Indexes |
user_agent_config |
— |
5 |
by_user, by_user_agent |
The policy engine (RM-36, DEC-90)
| Table |
What it holds |
Fields |
Indexes |
policies |
Rules written at the organisation, a team or a person (lib/policyRules.ts); an organisation's rule may name a team or a person. lib/policySets.ts compiles each organisation's enabled rules into its one policy_sets row whenever one changes, so a decision is one read (lib/policyEngine.ts). |
8 |
by_accountId, by_accountId_and_userId |
policy_sets |
— |
3 |
by_accountId |
spending_alerts |
— |
3 |
by_accountId_and_key |
Approvals (RM-36, DEC-136)
| Table |
What it holds |
Fields |
Indexes |
pending_approvals |
A capability call the policy engine sent for review: a draft, for the person an agent acts for to change and do, or a confirm, to approve or decline as prepared, by that person or the organisation's admins. One row is the interaction protocol's action affordance: shown in Waiting on you and as a card in the chat, answered from either (approvals.ts). |
27 |
by_accountId_and_approver_and_status, by_approverId_and_status, by_onBehalfOf_and_status, by_accountId_and_requestId, by_chatId |
Usage Ledger (one row per billable event)
| Table |
What it holds |
Fields |
Indexes |
links |
Links between any two things (RM-49 step 1; the object model's § 2.3): about, blocks, relates_to, duplicates, and field for a relation field's value (DEC-117). lib/links.ts writes them; a link never grants access. |
9 |
by_from, by_to |
field_sets |
— |
7 |
by_owner |
task_views |
— |
6 |
by_spaceId_and_position, by_ownerId |
object_sources |
— |
9 |
by_external, by_object |
Connections to outside providers (RM-51; connections.ts)
| Table |
What it holds |
Fields |
Indexes |
connections |
One row for each provider an organisation, or later a person, has connected: Zoho first, then Google and Microsoft (DEC-190). The refresh token and the access token in use are sealed with a key from the deployment's environment (lib/secretBox.ts) and no query returns them. accountsServer and apiDomain are the provider's data centre for this account, as its sign-in gave them. |
21 |
by_accountId_and_provider, by_userId, by_kind_and_status |
A person's calendars at a provider (RM-51 step 16)
| Table |
What it holds |
Fields |
Indexes |
calendars |
One row per calendar their own connection can see. shown is theirs to set: their own calendars start shown, shared and group ones don't. |
11 |
by_connectionId, by_accountId_and_userId |
calendar_events |
— |
16 |
by_calendarId, by_accountId_and_userId_and_start |
connection_states |
— |
7 |
by_hash, by_expiresAt |
Channels (RM-51 § 8; doc 16; channels.ts)
| Table |
What it holds |
Fields |
Indexes |
channel_endpoints |
An organisation's bot on a channel (Cliq first): the hash of the secret in the address the channel sends to, and the channel's names for the bot. |
8 |
by_secretHash, by_accountId_and_channel |
channel_identities |
— |
15 |
by_replyChatId, by_accountId_and_channel_and_externalId, by_principalId, by_linkHash |
channel_rooms |
— |
8 |
by_endpointId_and_externalId, by_spaceId, by_accountId_and_channel |
The content index (RM-38; lib/contentIndex.ts)
| Table |
What it holds |
Fields |
Indexes |
index_queue |
Something in a space waiting to be indexed, or indexed again: one row for each object, moved later each time it changes, so an editing session is indexed once it goes quiet. |
7 |
by_objectType_and_objectId, by_accountId_and_state |
index_entries |
— |
10 |
by_objectType_and_objectId, by_accountId, by_spaceId |
index_chat_runs |
— |
5 |
by_chatId_and_firstAt, by_accountId |
index_jobs |
— |
18 |
by_accountId_and_kind |
usage_daily |
— |
12 |
by_accountId_and_day, by_key, by_accountId_and_userId_and_day |
api_calls_daily |
— |
7 |
by_accountId_and_day, by_accountId_and_day_and_capability_and_via |
usage_ledger |
— |
20 |
by_account_timestamp, by_account_service, by_account_user, by_account_agent, by_account_and_requestId |
Lists (work-model proposal §4; pilot plan §5.2)
| Table |
What it holds |
Fields |
Indexes |
collections |
A list ("collection") holds records with its own fields. Field IDs are stable and never reused, so renaming a field never touches records. A list read from a repo (source.kind "repo") is read-only here. |
11 |
by_spaceId_and_archived, by_spaceId_and_slug, by_accountId_and_archived |
collection_records |
— |
13 |
by_collectionId_and_updatedAt, by_collectionId_and_archivedAt_and_updatedAt, by_collectionId_and_archivedAt, by_collectionId_and_key, search_title (search) |
collection_views |
— |
5 |
by_collectionId_and_position, by_ownerId |
repo_links |
— |
12 |
by_repo, by_accountId |
ingest_files |
— |
4 |
by_repoLinkId_and_path |
Pages (the wiki; pilot plan §5.4, module architecture §8)
| Table |
What it holds |
Fields |
Indexes |
pages |
A page lives in a space, in a tree (parentId). Content is Markdown. A page imported from elsewhere has its source (object_sources), so an import never duplicates it; pages mirrored from a repo are read-only (source). |
14 |
by_spaceId_and_archivedAt, by_spaceId_and_slug, by_projectId, search_content (search), search_title (search) |
rich_texts |
— |
11 |
by_targetId, by_updatedAt |
rich_text_blocks |
— |
5 |
by_textId_and_order, by_textId_and_blockId |
comment_anchors |
— |
9 |
by_messageId, by_targetId_and_blockId |
Editor spike (Stage 0 of ~/dev/docs/standards/rich-text-editing.md)
| Table |
What it holds |
Fields |
Indexes |
spike_docs |
Test documents in the Novansa Document format, edited by the web editor (Labs → Editor test) and the Flutter app. Account admins only. Copies of pages, never the pages themselves; files are files with a spike_doc link. One document per row, as in the spike: Stage 1 stores one row per block. Removed when Stage 1 replaces them. |
11 |
by_accountId_and_updatedAt, by_pageId |
spike_originals |
— |
2 |
by_docId |
import_runs |
— |
7 |
by_accountId |
Change log (work-model proposal §6; pilot plan §5.1)
| Table |
What it holds |
Fields |
Indexes |
changes |
Every write to a work object records one row in the same transaction: who or what made it, from where, the field-level diff and its status. History, undo and "what changed" read from here. |
20 |
by_objectType_and_objectId, by_spaceId, by_accountId, by_accountId_and_requestId |
audit_log |
— |
18 |
by_account_timestamp, by_account_user, by_actor_type_and_id, by_event, by_account_and_requestId, by_account_and_event, by_account_and_actor, by_account_and_space, search_summary (search) |
Safety: Blocks and Reports
| Table |
What it holds |
Fields |
Indexes |
blocks |
— |
4 |
by_blocker, by_blocker_blocked, by_accountId |
reports |
— |
11 |
by_account_status, by_reporter |
Invite Links
| Table |
What it holds |
Fields |
Indexes |
invite_links |
— |
8 |
by_code, by_chat |
API tokens and keys (RM-2, DEC-93)
| Table |
What it holds |
Fields |
Indexes |
api_keys |
A credential for the Platform API and MCP. A personal token acts as the person who made it (DEC-174); organisation and team keys, each a caller of its own, come with the plan's part 3 (DEC-175). Only the secret's SHA-256 hash is kept, with its first characters so people can tell theirs apart. Scopes (tasks:read, *:write) and an optional list of spaces narrow what it reaches; it always expires (DEC-177). |
17 |
by_hash, by_accountId_and_kind, by_accountId_and_userId, by_userId, by_expiresAt |
api_idempotency |
— |
6 |
by_keyId_and_idempotencyKey, by_createdAt |
Account membership (RM-7, started in Stage 1)
| Table |
What it holds |
Fields |
Indexes |
account_members |
Who belongs to each account, kept by Clerk's organisation-membership webhooks (accounts.addMember, setMemberRole, removeMember). Roles are still read from the token for access checks; this is the record of membership for lists, pickers and checks that a user is in the account. |
5 |
by_accountId_and_userId, by_userId |
account_invitations |
— |
8 |
by_accountId, by_email |
| Table |
What it holds |
Fields |
Indexes |
app_settings |
Who may change platform-wide settings such as the LLM model registry. Granted with platformAdmins:grant (internal); not tied to any account. Settings for the whole app, one row (Settings › App admin; appSettings.ts). No row means the defaults. |
3 |
— |
platform_admins |
— |
3 |
by_clerkUserId |
The service registry (RM-41; services.ts)
| Table |
What it holds |
Fields |
Indexes |
services |
A service Thinklio can call, such as one of thinklio-services', kept by platform admins (DEC-226). credential is Thinklio's own key for it, sealed (lib/secretBox.ts), and no query returns it. tools is what its /meta and its MCP tool list said at the last look: a tool that reads nothing but changes something has reads false. Only an offered service can be turned on by an organisation. |
15 |
by_slug |
account_services |
— |
7 |
by_accountId_and_serviceId, by_serviceId |
Model tiers (lib/llm.ts; DEC-13)
| Table |
What it holds |
Fields |
Indexes |
llm_models |
OpenRouter's model catalogue, with the prices used for usage costs (USD per million tokens). Synced daily (llmRegistry:syncCatalogue); a model OpenRouter stops listing is kept, marked, for history and costs. |
9 |
by_modelId, by_listedOnOpenRouter |
llm_tiers |
— |
3 |
by_tier |
account_model_pins |
— |
4 |
by_accountId_and_tier |