Docs · Reference

Data model

Updated 2026-11-25 Shirish Kadam, Claude Source: docs/engineering/data-model.md Edit on GitHub

Every table the backend owns, what it records, and which one answers a given question. The models in backend/models/ are the source of truth for columns; this page is for the step before that, deciding where something lives. backend/tests/test_data_model_doc.py fails when a table exists that this page does not list.

Where is it recorded?

Read this before proposing a new table, event kind or log. Four stores already record what happens, and each has one job. Most "we need to store X" turns out to be "X is already in one of these, and nothing reads it yet."

QuestionTableWritten byShape
What was said, and what did each tool return?agent_eventsthe conversation recorder, every turnappend-only, one row per turn part, ordered by seq
Who did what to a project, and when?activity_logsservice/activity.py::log_activity, after each domain writeappend-only, one row per lifecycle transition, with actor (user / agent / auto) and conversation_id
What state is a proposed change in right now?execution_change_setsservice/execution/service.pymutable, one row per change set; per-change status and results in changes
What does the agent know that it cannot re-derive?project_memoriesmemory tools and consolidation, service/memory.pybi-temporal, typed, sourced; a later value for the same key supersedes the earlier one

How they relate: agent_events, activity_logs and artifacts are the raw evidence and stay append-only. project_memories is the layer distilled from them, the only one written to be put in front of a model (backend/models/memory.py, "Layer 1 of four").

A human decision on a change set (approve, reject, apply, rollback) is an activity_logs row and a status on execution_change_sets, never a third record.

Conversation state the model resumes from (LangGraph checkpoints) is not in this list: LangGraph creates and migrates its own tables outside Alembic (db/migrate.LANGGRAPH_TABLES, and backend/agents/core/checkpoint.py).

Tables by area

People and access

TableHolds
usersone row per person (or per desktop install, for a guest); user-scope switches like memory_paused
auth_identitieshow a user signs in: Google, guest install, or a linked ChatGPT account (a merge key, never a login alone)
oauth_statesshort-lived OAuth state values, single-use, with an expiry
mcp_tokenswhat an outside agent sends to Duct's MCP server: a pasted personal token, or an agent that signed in through the browser (its client id and a refresh token); hashes and a four-character hint, never a token, and accepted on /mcp only
projectsthe unit everything else hangs off: settings, autonomy_level, memory_paused, provenance (where each drafted field came from), the brand the content agent writes from (content_brand, including content_language), and up to three audience personas (audience.personas, each with up to three real quotes) that setup and the Brand tab both edit and the pre-publish review role-plays
project_memberswho can see a project. Authorization is membership, not projects.user_id
project_invitationspending email invites into a project
user_profilewho the operator is and how they want to be written to
user_model_settingsthe user's model per tier, and whether a run may step down a tier when out of quota

Connectors

TableHolds
connector_credentialsa user's connection to one provider account (OAuth refresh token or key), with residency (server or device)
project_connectorswhich credential a project uses, and which entity inside it (GA4 property, GSC site, GTM container)

Agents and conversations

TableHolds
agent_conversationsone thread: agent type, project, run status, compaction summary, seq allocator, optional link to the artifact it edits; meta holds the memory watermark and a plan proposal waiting on the person
agent_eventsthe thread's transcript (see above). kind is free text: user, assistant, thinking, tool_use, tool_result, question, answer, context, compacted, memory_*, failure, plan_decision, feed (what a plan from shipped work read)
activity_logssee above. The project's audit trail: change-set transitions, GTM publishes, artifact versions, a scheduled post its scheduler failed to publish (whose reason the post's card reads back). Not a mirror of tool calls
agent_contextsper project and agent, a JSON blob of working notes the agent carries between runs
artifactsevery version of every output (brief, report, image): group_id is the identity, one immutable row per version; bytes in object storage, never a public URL
project_memoriessee above. Scopes user, project, artifact in one table
model_usageone row per model call with tokens and cost, so a user can see their own bill

Schedules

TableHolds
agent_schedulesa run nobody starts by hand: the job and its settings, a preset cadence in a named time zone, enabled, the host that owns it (cloud / local), the monthly cap, the loop's own claim, lease and retry state, and for an on-release schedule (#563) the last release tag it saw (cursor) and a Run now that skips the check once (forced). What each run did is an activity_logs row (category schedule), linked to the conversation it left, never a second history

Execution

TableHolds
execution_change_setssee above. Status runs proposed → approved → applying → applied / partial / failed, or rejected, or rolled_back
execution_guardrailsper-account rules a change may never break; checked at propose and again at apply

Content studio

TableHolds
content_plansa content plan and its strategy (strategy.feed: the window a plan from shipped work read, where the next one starts, and set_aside, what it left out and why). A day planned from shipped work carries its sources and the brief its writer drafts from
content_postsone post, whatever platform it is bound for: type (slideshow, video, image, text), its words (caption), its own follow-ups under it (replies: an X reply, a LinkedIn first comment), slides (none for a text post), a video post's chosen clip (video), status, performance counts (perf: keys per service/content_metrics.py; typed-in ones listed in manual_keys, which no sync overwrites), its last pre-publish review (with each audience persona's reaction, the openings they chose between, and how the panel ranked the brand's past posts against their real numbers), and the TikTok it was cloned from (clone_source), and once sent, the scheduler holding it (publisher) with its ids there. What differs by platform is rules, not columns: agents/content/channels.RULES
content_assetsgenerated images and video clips (every take), uploads and references
content_formatsa project's library of post formats
content_avatarsa project's library of avatars
content_social_linkssocial accounts linked for publishing, each at the scheduler that holds it (publisher: PostBridge, Zernio)

Growth experiments

TableHolds
lead_magnetsan email captured by a free audit, with its report once the audit finishes
execution_interestwhich done-for-you services a lead asked about