chain-rdeveloper portal
build

Database Models

Auto-generated from source on 2026-10-30 15:30 UTC. Do not edit manually — run make spec to regenerate.

SQLAlchemy ORM models — modules/svc-core/app/db/postgres/models.py.


User

Local representation of an Auth0 user. Auth0 is the source of truth for authentication.

  • Table: users

  • Mixins: DateMixin.Updated

Columns

ColumnTypeNullablePKNotes
auth0_idStringNo
emailStringNo
email_verifiedBooleanYes
nameStringYes
pictureStringYes
is_activeBooleanYes
is_superuserBooleanYes
platform_rolesJSONNo

Relationships

  • organisations → UserOrganisation

  • projects → UserProject


Organisation

  • Table: organisations

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
auth0_org_idStringYes
cost_centreStringYes

Relationships

  • members → UserOrganisation

  • projects → Project


UserOrganisation

  • Table: user_organisations

  • Mixins: FKMixin.Role, DateMixin.Joined

Columns

ColumnTypeNullablePKNotes
organisation_idUUIDYes✓
accessJSONYes

Relationships

  • user → User

  • organisation → Organisation

  • role → Role


Project

  • Table: projects

  • Mixins: OwnableMixin.Resource, GenerationMixin.Tagged, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
cost_centreStringYes

Relationships

  • members → UserProject


UserProject

  • Table: user_projects

  • Mixins: FKMixin.Role, DateMixin.Joined

Columns

ColumnTypeNullablePKNotes
project_idUUIDYes✓
accessJSONYes

Relationships

  • user → User

  • project → Project

  • role → Role


Role

  • Table: roles

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes

Relationships

  • permissions → Permission


Permission

  • Table: permissions

Columns

ColumnTypeNullablePKNotes
permission_codeEnumNo
descriptionTextYes

Relationships

  • roles → Role


MembershipInvite

A single-use link that admits one person to an organisation.

The stack sends no email, so an admin creates the invite and passes the link on themselves. Only a SHA-256 of the token is stored: the token is shown once, when the invite is made, and a copy of this table cannot be turned back into working links. The invite names the email it is for, and only a signed-in user with that email can accept it, so a forwarded link admits nobody else.

`organisation_id and project_id follow the ownership pattern — exactly one is set — so project invites need no migration when projects gain membership management. See app/services/membership.py`.

  • Table: membership_invites

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
organisation_idUUIDYes
project_idUUIDYes
emailStringNo
role_idUUIDNo
accessJSONYes
token_hashStringNo
created_by_user_idUUIDYes
expires_atDateTimeNo
accepted_atDateTimeYes
accepted_by_user_idUUIDYes
revoked_atDateTimeYes
revoked_by_user_idUUIDYes

Relationships

  • role → Role


ResourceVersion

One immutable snapshot of a resource's editable fields.

Supersedes the old `audit_logs table, which only recorded a bare action label with no snapshot/diff content. resource_id is a soft reference (no FK, same reasoning as LLMArtifact.ai_model_id) — history must outlive the resource itself, since a deleted resource's history is exactly when it matters most. resource_type + resource_id is the lookup key; version_number` is 1-based and monotonic per resource, like a git commit sequence.

  • Table: resource_versions

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
resource_typeEnumNo
resource_idUUIDNo
version_numberIntegerNo
actionEnumNo
snapshotJSONNo
children_snapshotJSONYes
changed_fieldsJSONNo
actor_user_idUUIDYes
generation_idUUIDYes
originStringYes

GenerationRun

One invocation of a generative flow, with the arguments it was given.

`is_ai_generated` on a resource says that it was generated; this row says how. It is written when the flow is invoked — before the user has accepted anything — so a proposal the user rejected is still on record, and a flow that failed is too.

`target_resource_type/target_resource_id are soft references (no FK, same reasoning as ResourceVersion.resource_id): the invocation must outlive whatever it produced. Resources point back the other way through GenerationMixin.Tagged.generation_id`, which is a real FK because a generation run is never deleted.

  • Table: generation_runs

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
flowEnumNo
statusEnumNo
argumentsJSONNo
ai_model_idUUIDYes
providerStringYes
model_nameStringYes
target_resource_typeEnumYes
target_resource_idUUIDYes
warningsJSONYes
errorTextYes
proposalJSONYes
progressJSONYes
actor_user_idUUIDYes
workspace_organisation_idUUIDYes
workspace_project_idUUIDYes
applied_atDateTimeYes

Agent

  • Table: agents

  • Mixins: OwnableMixin.Resource, ClonableMixin, SystemMixin, GenerationMixin.Tagged, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
agent_typeEnumNo
iconStringYes
accentStringYes
system_promptTextYes
toolsJSONYes
configJSONYes
ai_model_idUUIDYes
clarify_scopeBooleanNo
cost_profileStringNo

Relationships

  • conversations → Conversation

  • industries → ResourceIndustry

  • roles → ResourceRole


AgentMemory

  • Table: agent_memory

  • Mixins: FKMixin.Agent.Child, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
roleStringNo
contentTextNo
created_atDateTimeYes

Conversation

  • Table: conversations

  • Mixins: OwnableMixin.LLMArtifact, OwnableMixin.Resource, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
total_input_tokensIntegerNoSum of system + user tokens
total_output_tokensIntegerNoSum of assistant tokens
total_tokensIntegerNoCached totalinputtokens + totaloutputtokens
workspace_organisation_idUUIDYes
workspace_project_idUUIDYes

Relationships

  • agent → Agent

  • messages → ChatMessage


ChatMessage

  • Table: chat_messages

  • Mixins: FKMixin.Conversation.Child, DateMixin.Sent

Columns

ColumnTypeNullablePKNotes
roleEnumNo
statusEnumNoOutcome of this turn: completed, blocked by a policy rule, or errored — lets a failed/blocked exchange still be recorded for History/Activity instead of being silently dropped.
contentTextNo
token_countIntegerNoToken count for this message only
traceJSONYesExecution trace for assistant messages (graphplan/nodestart/nodeend/toolcall events)
metaJSONYesRequest/response metadata: tokencount, temperature, outputformat, output_schema
invocation_idUUIDYes

Relationships

  • conversation → Conversation

  • segments → ChatMessageSegment


ChatMessageSegment

Per-worker output segment for multi-agent skill executions.

  • Table: chat_message_segments

Columns

ColumnTypeNullablePKNotes
message_idUUIDNo
worker_slugStringNo
contentTextNo
sequenceIntegerNoExecution order within the message

Relationships

  • message → ChatMessage


Knowledge

  • Table: knowledge

  • Mixins: OwnableMixin.Resource, SystemMixin, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
source_typeStringNo
source_configJSONNo

KnowledgeDocument

  • Table: knowledge_documents

  • Mixins: FKMixin.Knowledge.Child, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
source_idStringNo
folder_pathStringNo
document_metadataJSONYes

KnowledgeCrawl

One crawl of a website knowledge source — scheduled, manual, or the first one after its URLs were set.

At most one per source is `running` at a time, enforced by a partial unique index rather than a check-then-insert: the scheduler and a "Refresh now" click can race, and only the database can settle it.

  • Table: knowledge_crawls

  • Mixins: FKMixin.Knowledge.Child, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
triggerStringNo
statusStringNo
actor_user_idUUIDYes
started_atDateTimeNo
finished_atDateTimeYes
pages_fetchedIntegerNo
pages_newIntegerNo
pages_changedIntegerNo
pages_unchangedIntegerNo
pages_failedIntegerNo
pages_goneIntegerNo
pages_expiredIntegerNo
usageJSONYes
noteTextYes

KnowledgePageVersion

One snapshot of one page of a website source.

Written only when the page's extracted text changes, so the versions of a page are exactly the moments it said something different. Immutable: the audit trail of what an agent could have read, and when. Only the newest is indexed for retrieval; the rest are kept for the record.

  • Table: knowledge_page_versions

  • Mixins: FKMixin.Knowledge.Child, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
document_idUUIDNo
crawl_idUUIDYes
version_numberIntegerNo
urlStringNo
titleStringYes
content_hashStringNo
http_statusIntegerYes
etagStringYes
last_modifiedStringYes
fetched_atDateTimeNo
markdown_objectStringNo
html_objectStringYes
size_bytesIntegerNo

KnowledgeRepository

A named collection of knowledge bases (sources).

Repositories let users logically group sources of different kinds (files, graphs, web, databases, APIs) and attach the whole collection to an agent instead of granting each source individually.

  • Table: knowledge_repositories

  • Mixins: OwnableMixin.Resource, SystemMixin, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
iconStringYes
accentStringYes
categoryStringNo

Relationships

  • members → RepositoryKnowledge


RepositoryKnowledge

Junction: a knowledge base that belongs to a repository.

  • Table: repository_knowledge

Columns

ColumnTypeNullablePKNotes
knowledge_idUUIDNo✓

Relationships

  • repository → KnowledgeRepository

  • knowledge → Knowledge


AgentRepository

Junction: a knowledge repository granted to an agent for retrieval.

At inference time the repository expands to its member knowledge bases, so agents can be granted a whole collection in one attachment.

  • Table: agent_repositories

Columns

ColumnTypeNullablePKNotes
repository_idUUIDNo✓
configJSONYes

Relationships

  • agent → Agent

  • repository → KnowledgeRepository


KnowledgeCitation

One knowledge source an answer cited — the record of use.

A grant says what an agent may retrieve from (reach); this says what an answer a person received actually cited, so a source's page can say how often it is used, by which agents, and which of its documents (`app/services/knowledge/citations.py, docs/guides/knowledge.md). Written once, when the answer is stored, from exactly the sources it stores (meta.cited_sources`): a withheld, blocked or failed answer cites nothing and writes nothing. Migration 110 backfilled the answers stored before it whose documents name their source.

Not a user-creatable resource: nothing edits these rows, so they carry no `ResourceVersion history and no ownership constraint. Stamped with the workspace the conversation was had in exactly as the usage ledger is (Workspace.ledger_stamp), so Workspace.stamped` reads it.

The answer's own row: deleting the conversation (or the message) deletes its citations, and counts are of answers on record. Deleting the source deletes them too; a document deleted since leaves its row, unnamed.

  • Table: knowledge_citations

Columns

ColumnTypeNullablePKNotes
message_idUUIDNo
invocation_idUUIDYes
knowledge_idUUIDNo
document_idUUIDYes
agent_idUUIDYes
owner_user_idUUIDYes
owner_organisation_idUUIDYes
owner_project_idUUIDYes
workspace_user_idUUIDYes
toolStringYes
cited_atDateTimeNo

KnowledgeTurn

One answered turn of an agent with knowledge: what it asked of that knowledge, and what the knowledge lacked — the retrieval record.

The citations record says which sources an answer cited (use); this says what a turn's knowledge gave and failed to give: a search that kept nothing that bore on the request, a gap the quality check named that the knowledge did not hold, a file the person named that no source has, or an answer the web gave while the knowledge was not searched (its cited web hosts). What says which knowledge to add (`app/services/knowledge/retrievals.py, docs/guides/knowledge.md). Each source's part is a :class:KnowledgeRetrieval`.

Written once, when the answer is stored, from svc-ai's report (`app/util/knowledge_report.py). The person's words in it (the request as searched, the gaps, the files named) are redacted as the input was, kept for none of a withheld answer, and cleared after KNOWLEDGE_TURN_TEXT_RETENTION_DAYS (KnowledgeTurnRetentionJob); the counts stay. Not a user-creatable resource: no history, no ownership constraint. Stamped as the usage ledger is (Workspace.ledger_stamp`). Deleting the answer deletes it.

  • Table: knowledge_turns

Columns

ColumnTypeNullablePKNotes
message_idUUIDNo
invocation_idUUIDYes
agent_idUUIDYes
owner_user_idUUIDYes
owner_organisation_idUUIDYes
owner_project_idUUIDYes
workspace_user_idUUIDYes
queryTextYes
liveBooleanNo
complexityStringYes
profileStringYes
searchedBooleanNo
nothing_relevantBooleanNo
came_up_shortBooleanNo
gapsJSONYes
unresolvedJSONYes
web_hostsJSONYes
scoped_outJSONYes
asked_atDateTimeNo

Relationships

  • sources → KnowledgeRetrieval


KnowledgeRetrieval

What one knowledge source gave one turn: passages found, kept for the agent, ruled out by the relevance judge or left out by the turn's window, and the agent's own searches of it. Read beside the citations record, it says what a source is retrieved for and how often that is used (`app/services/knowledge/stats.py). Stamped, and deleted, with its :class:KnowledgeTurn`; deleting the source deletes it too.

  • Table: knowledge_retrievals

Columns

ColumnTypeNullablePKNotes
turn_idUUIDNo
knowledge_idUUIDNo
agent_idUUIDYes
owner_user_idUUIDYes
owner_organisation_idUUIDYes
owner_project_idUUIDYes
workspace_user_idUUIDYes
categoryStringYes
roleStringYes
foundIntegerNo
keptIntegerNo
ruled_outIntegerNo
out_of_windowIntegerNo
tool_searchesIntegerNo
asked_atDateTimeNo

Relationships

  • turn → KnowledgeTurn


KnowledgeRecommendationDismissal

A workspace setting a knowledge recommendation aside: this kind, about this subject, while its evidence stays as it was (`app/services/knowledge/recommendations`).

`fingerprint` is what the evidence read when it was set aside. A recommendation whose evidence has moved on (more questions unanswered, a source's settings changed) has a new one and shows again. One row per workspace, kind and subject: setting it aside again replaces it.

A source map suggestion is set aside the same way (`map_suggestion`, the repository and the source as its subject).

Not a resource: no edit history. `workspace_key is the workspace's key, as on a notification, with no foreign key; dismissed_by_user_id` goes null when its person is deleted.

  • Table: knowledge_recommendation_dismissals

Columns

ColumnTypeNullablePKNotes
workspace_keyStringNo
kindStringNo
subjectStringNo
fingerprintStringNo
dismissed_by_user_idUUIDYes
dismissed_atDateTimeNo

Skill

  • Table: skills

  • Mixins: OwnableMixin.Resource, ClonableMixin, SystemMixin, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
tagsJSONNo
graph_definitionJSONNo

SkillRun

One standalone run of a skill — a skill used as a structured workflow.

A skill used to be reachable only as the body of an agent turn, where its result is a chat message. Run on its own, it takes typed inputs and produces typed outputs, and this row is the record of one such run: what was asked, under which revision, what each node did and what came back.

Written `running before the work is handed to a worker, and finished in place. Immutable after that — a record of something that happened, not a resource anyone edits — so it has no version trail of its own; the skill revision it ran under is skill_version`.

`skill_id is SET NULL` and the name is denormalised: a run is most worth reading when somebody is asking what a since-deleted skill did. Runs belong to the user who started them, as conversations do — a shared skill is shared, the inputs somebody gave it are not.

  • Table: skill_runs

Columns

ColumnTypeNullablePKNotes
skill_idUUIDYes
skill_nameStringNo
skill_versionIntegerYes
user_idUUIDNo
workspace_organisation_idUUIDYes
workspace_project_idUUIDYes
statusStringNo
promptTextYes
taskTextYes
inputsJSONNo
outputTextYes
outputsJSONYes
stateJSONYes
stepsJSONYes
citationsJSONYes
rule_traceJSONYes
warningsJSONYes
errorTextYes
input_tokensIntegerNo
output_tokensIntegerNo
latency_msIntegerYes
cost_usdNumericYes
llm_callsIntegerNo
unpriced_callsIntegerNo
cost_detailJSONYes
interruptJSONYes
responsesJSONYes
invocation_idUUIDYes
started_atDateTimeNo
finished_atDateTimeYes

CustomWorker

A user-built worker agent — the atomic reasoning unit for skill graphs.

The contract is deliberately small: name + prompt, optionally cloning a builtin (`base_worker), overriding the model, toggling the general toolset, and attaching MCP servers. On create the worker is registered in svc-ai's WorkerAgentDefinition registry under definition_name so it is referencable as a skill-graph agent_name` like any builtin.

  • Table: custom_workers

  • Mixins: OwnableMixin.Resource, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
base_workerStringYes
roleStringYes
system_promptTextYes
tagsJSONYes
model_overridesJSONYes
tools_enabledBooleanNo
mcp_server_idsJSONNo
input_schemaJSONNo
output_schemaJSONNo
definition_nameStringYes

MCPServer

User-configured MCP (Model Context Protocol) server connection.

  • Table: mcp_servers

  • Mixins: OwnableMixin.Resource, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
template_keyStringYes
connection_typeStringNo
connection_configJSONNo
tools_cacheJSONYes
is_activeBooleanNo

Toolkit

A named collection of MCP servers.

Toolkits let users group an agent's MCP servers together and attach the whole bundle to an agent in one step — the same pattern Skillset uses for skills, and KnowledgeRepository uses for knowledge bases. This is the sole mechanism for granting an MCP server to an agent — there is no direct agentmcpservers grant.

Built-in tools are deliberately not part of this: they are platform capabilities bound to every agent by svc-ai, not grants to administer. A toolkit that could also list them was an indirection whose entries never reached an invocation.

  • Table: toolkits

  • Mixins: OwnableMixin.Resource, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes

Relationships

  • mcp_servers → ToolkitMCPServer


ToolkitMCPServer

Junction: an MCP server that belongs to a toolkit.

  • Table: toolkit_mcp_servers

Columns

ColumnTypeNullablePKNotes
mcp_server_idUUIDNo✓

Relationships

  • toolkit → Toolkit

  • mcp_server → MCPServer


AgentToolkit

Junction: a toolkit granted to an agent.

At inference time the toolkit expands to its member tools and MCP servers — the sole path for either to reach an agent.

  • Table: agent_toolkits

Columns

ColumnTypeNullablePKNotes
toolkit_idUUIDNo✓
configJSONYes

Relationships

  • agent → Agent

  • toolkit → Toolkit


Skillset

A named collection of skills.

Skillsets let users group an agent's skills together and attach the whole bundle to an agent in one step — the same pattern KnowledgeRepository uses for knowledge bases, and Toolkit uses for tools/MCP servers. This is the sole mechanism for granting a skill to an agent — there is no direct agent_skills grant. Workers are deliberately not a member type here: a worker isn't granted to an agent directly, it's a building block a skill's graph references by name.

  • Table: skillsets

  • Mixins: OwnableMixin.Resource, ClonableMixin, SystemMixin, GenerationMixin.Provenance, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes

Relationships

  • skills → SkillsetSkill


SkillsetSkill

Junction: a skill that belongs to a skillset.

  • Table: skillset_skills

Columns

ColumnTypeNullablePKNotes
skill_idUUIDNo✓

Relationships

  • skillset → Skillset

  • skill → Skill


AgentSkillset

Junction: a skillset granted to an agent.

At inference time the skillset expands to its member skills — the sole path for a skill to reach an agent.

  • Table: agent_skillsets

Columns

ColumnTypeNullablePKNotes
skillset_idUUIDNo✓
configJSONYes

Relationships

  • agent → Agent

  • skillset → Skillset


ResourceIndustry

  • Table: resource_industries

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo

Relationships

  • agents → Agent


ResourceRole

  • Table: resource_roles

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo

Relationships

  • agents → Agent


Experiment

An evaluation: one dataset, one scoring mechanism, one or more variants.

The recipe, not an execution — a run of it is an :class:ExperimentBatch. The three things it names are the three things it owns: what is asked (`dataset_id), *how* an answer is judged (scorer, scorer_config, judge`) and who answers (its variants). Nothing else on the platform decides any of those, which is what makes two runs of one evaluation comparable and a regression verdict meaningful.

The table keeps its historical name: `experiment is a Postgres enum label on resource_versions` and cannot be dropped.

  • Table: experiments

  • Mixins: OwnableMixin.Resource, SystemMixin, GenerationMixin.Tagged, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
statusEnumNo
dataset_idUUIDNo
scorerEnumNo
scorer_configJSONYes
judgeJSONYes
configJSONYes

Relationships

  • dataset → TestSuite

  • variants → ExperimentVariant

  • runs → ExperimentRun

  • batches → ExperimentBatch


ExperimentVariant

A named variant (prompt + config) within an experiment.

  • Table: experiment_variants

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
experiment_idUUIDNo
nameStringNo
promptTextYes
configJSONYes

Relationships

  • experiment → Experiment

  • runs → ExperimentRun


ExperimentRun

One scored (target, case) cell — of an evaluation or of a dataset run.

This was two tables. `TestCaseResult recorded a dataset run's cell and this recorded an evaluation's, for the same _execute_matrix` call at different arity — so per-case regression only ever worked on one of them and leaderboards, promotion gates and reports only on the other. A user picked the surface by which feature they wanted rather than by which question they were asking.

  • Table: experiment_runs

  • Mixins: RunnableMixin.Run, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
experiment_idUUIDYes
variant_idUUIDYes
batch_idUUIDYes
test_case_idUUIDYes
inputJSONYes
outputTextYes
scoreJSONYes
score_reasonTextYes
scorerEnumYes
passedBooleanYes
run_metadataJSONYes

Relationships

  • experiment → Experiment

  • variant → ExperimentVariant

  • test_case → TestCase


ExperimentBatch

One execution of a (target x case) matrix — the platform's only run row.

An evaluation's batch runs several variants over a dataset; a dataset's own run is the same thing with one target and no variants. `TestSuiteRun` was that second case in its own table, which is why regression verdicts existed only there and leaderboards, promotion gates and cross-experiment reporting only here.

Batches lived on `Experiment.config['batches']` as JSON, capped at the twenty most recent. That was fine for the progress bar it existed to feed and useless for anything else: a question like "which experiments in this project scored below 0.7 last month" cannot be asked of a JSON array embedded in another table's column, so every cross-experiment figure had to be assembled in Python from rows that had already been loaded.

The display payloads — the full aggregate and the ranked leaderboard — stay JSON, because nothing filters on them. The figures a report actually groups, filters and orders by are columns.

  • Table: experiment_batches

  • Mixins: RunnableMixin.Run, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
experiment_idUUIDYes
started_by_user_idUUIDYes
dataset_idUUIDYes
dataset_versionIntegerYes
evaluation_versionIntegerYes
labelStringYes
variant_idsJSONYes
datasetJSONYes
configJSONYes
completedIntegerNo
totalIntegerNo
summaryJSONYes
leaderboardJSONYes
errorTextYes
regressionJSONYes
regression_verdictStringYes
target_versionsJSONYes
scorerEnumYes
mean_scoreFloatYes
pass_rateFloatYes
total_casesIntegerYes
errorsIntegerYes
mean_latency_msIntegerYes
total_tokensIntegerYes
duration_msIntegerYes

Relationships

  • experiment → Experiment


TestSuite

A dataset: the cases an evaluation asks, and nothing about how.

Data only. It carries no scorer, no target and no runs of its own — those belong to the evaluations that reference it (`Experiment`), so the same cases can be graded and re-run by many evaluations and every one of them says exactly what it did. A web-search prompt set, a refund tone set, a regression set: each is a dataset.

`is_system marks the platform's **gold datasets** — standard benchmarks (hallucination, tool use, political neutrality …) every user can run their own experiments on and copy into a dataset of their own (app.services.system_resources.datasets`).

The table keeps its historical name: `test_suite is a Postgres enum label on resource_versions` and cannot be dropped.

  • Table: test_suites

  • Mixins: OwnableMixin.Resource, ClonableMixin, GenerationMixin.Tagged, SystemMixin, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
statusEnumNo
criteriaJSONYes
pass_markFloatYes
configJSONYes

Relationships

  • test_cases → TestCase

  • evaluations → Experiment


TestCase

One case of a dataset: a question, and what a correct answer looks like.

A case is the data and its label. The data is the question and the situation it arrives in. The label is everything that says what a good answer is: the reference answer, criteria in words, graded example answers, and mechanical checks (format, must / must not contain, pattern). It never says how strictly to judge (that is the experiment's scorer) or who answers (that is a variant).

  • Table: test_cases

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
test_suite_idUUIDNo
nameStringYes
inputJSONNo
expected_outputTextYes
criteriaJSONYes
expected_behaviourStringYes
examplesJSONYes
expectationJSONYes
situationJSONYes
tagsJSONYes
source_invocation_idUUIDYes

Relationships

  • test_suite → TestSuite

  • results → ExperimentRun


SimulationWorld

A game-theoretic simulation environment with defined rules and logic.

  • Table: simulation_worlds

  • Mixins: OwnableMixin.Resource, GenerationMixin.Tagged, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
statusEnumNo
rulesJSONYes
logicJSONYes

Relationships

  • scenarios → SimulationScenario

  • simulations → Simulation


SimulationScenario

A named evaluation scenario within a simulation world.

  • Table: simulation_scenarios

  • Mixins: DateMixin.Created

Columns

ColumnTypeNullablePKNotes
world_idUUIDNo
nameStringNo
descriptionTextYes
strategyEnumNo
tagsJSONYes
configJSONYes
statusEnumNo

Relationships

  • world → SimulationWorld

  • simulations → Simulation


UploadedFile

A document parsed for chat and kept in a workspace's library, to be attached again in any chat there.

Owned like any resource, by the workspace it was uploaded in (migration 88): a person's Personal library, or an organisation's or project's, shared by its members. Who uploaded it is the actor on its `created` edit-history version — the uploader of a shared document is not its owner, and leaving or deleting their account leaves it with the team.

The text stays out of the edit history (`HISTORY_EXCLUDED_FIELDS): a deleted document's words go with it. content_sha256` names exactly which text each version described.

Its text is read after the upload has answered (migration 108): docling takes minutes on a long PDF, past what the proxy and Cloudflare wait for one request. `status` says how far that got.

The file as uploaded is kept in the object store (migration 109, `object_key`), so it can be opened again; one uploaded before then has its text only.

  • Table: uploaded_files

  • Mixins: OwnableMixin.Resource, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
nameStringNo
contentTextNo
mime_typeStringYes
content_sha256StringYes
statusStringNo
errorTextYes
object_keyStringYes
size_bytesBigIntegerYes

Simulation

An execution of an agent cluster within a simulation world and scenario.

  • Table: simulations

  • Mixins: RunnableMixin.Run, DateMixin.Created

Columns

ColumnTypeNullablePKNotes
world_idUUIDNo
scenario_idUUIDYes
nameStringYes
descriptionTextYes
agent_idsJSONYes
resultsJSONYes
run_metadataJSONYes

Relationships

  • world → SimulationWorld

  • scenario → SimulationScenario


Rule

A governance rule — in the Access, Input or Output layer — that controls LLM behaviour across agents, models, skills, and workers.

`conditions and actions` are stored as JSON arrays of condition/action blocks to support the visual rule builder without a rigid schema.

Condition block: {"field": str, "operator": str, "value": Any} Action block: {"type": str, ...params}

A built-in rule (`is_system) governs nobody. The engine loads only the rules a user owns, so a built-in is a definition users adopt: they create a rule of their own from it, scoped and tuned as they need, and that rule records which built-in it was based on and which release of it (based_on_rule_id / based_on_version`).

  • Table: rules

  • Mixins: OwnableMixin.Resource, ClonableMixin, GenerationMixin.Provenance, SystemMixin, DateMixin.Updated

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
layerEnumNo
scope_typeEnumNo
scope_idUUIDYes
conditionsJSONNo
actionsJSONNo
is_activeBooleanNo
priorityIntegerNo
based_on_rule_idUUIDYes
based_on_versionIntegerYes
required_for_projectsBooleanNo

WorkspaceInheritance

A project's declaration that it inherits from its parent — the person or organisation that owns it — by reference: one resource (`resource_id), or every resource of a kind (resource_id NULL), future ones included. kind is a key of app/services/inheritance.py`'s registry.

`resource_id is a soft reference, as ResourceVersion`'s is: it spans several tables, and a declaration whose resource has gone is inert, because inheriting also requires the parent to own the row. Declaring or withdrawing is a change to the project, and versions it.

  • Table: workspace_inheritance

Columns

ColumnTypeNullablePKNotes
project_idUUIDNo
kindStringNo
resource_idUUIDYes
declared_by_user_idUUIDYes
created_atDateTimeNo

Dashboard

A user-composed board of widgets.

Every owner has at most one `is_home` dashboard — the board shown by default. The rest are specialist boards the user creates and orders themselves. Placement lives on the widgets; a dashboard carries only its identity and presentation.

A built-in board (`is_system) is one row every user opens. Its platform tiles fetch the viewer's own data when drawn, so each user sees their own figures on it; its cached tiles (feeds, generated text) are the same for everyone, which is why only tiles holding nobody's data may go on one (WidgetRenderer.stores_user_content`).

  • Table: dashboards

  • Mixins: OwnableMixin.Resource, ClonableMixin, GenerationMixin.Tagged, SystemMixin, DateMixin.Updated

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
iconStringYes
accentStringYes
is_homeBooleanNo
positionIntegerNo

Relationships

  • widgets → DashboardWidget


DashboardWidget

One tile on a dashboard.

`config is the per-type payload validated by that type's renderer (see app.services.dashboards.widgets). Dynamic types additionally use refresh_interval_seconds plus the cache_*` columns to hold the last generated result, so a board loads instantly from cache and regenerates only once the cached value has aged past its interval.

  • Table: dashboard_widgets

  • Mixins: DateMixin.Updated

Columns

ColumnTypeNullablePKNotes
dashboard_idUUIDNo
widget_typeEnumNo
titleStringYes
configJSONNo
xIntegerNo
yIntegerNo
wIntegerNo
hIntegerNo
positionIntegerNo
refresh_interval_secondsIntegerYes
cache_statusEnumNo
cache_payloadJSONYes
cache_errorTextYes
cached_atDateTimeYes

Relationships

  • dashboard → Dashboard


GovernanceUsage

One row per governed LLM invocation — the counter rate limits read.

Policy rules can cap how often and how much an owner may invoke, and both questions need a number that exists before svc-ai is called. svc-ai owns the authoritative per-invocation record (`LLMInvocation`), but reading it would put a synchronous cross-service hop in front of every governed request and make a svc-ai outage a governance failure. So svc-core keeps its own append-only ledger, local to the database the rule engine already queries.

Deliberately not a user-creatable resource: nothing edits these rows, so they carry no `ResourceVersion` history and no ownership constraint. They are the audit evidence — an immutable record of what was spent against which policy scope.

`estimated_cost_usd is derived at write time from the invoked model's per-token price (see app.services.usage.estimate_cost`) and stored rather than recomputed, because a model's price can change afterwards and a cap must be judged against what the call cost then. It is nullable: a model whose price svc-ai does not publish yields no estimate, and a cost cap says so rather than silently reading it as zero.

  • Table: governance_usage

Columns

ColumnTypeNullablePKNotes
owner_user_idUUIDYes
scope_typeEnumNo
scope_idUUIDYes
owner_project_idUUIDYes
owner_organisation_idUUIDYes
workspace_user_idUUIDYes
execution_typeStringYes
ai_model_idUUIDYes
input_tokensIntegerNo
output_tokensIntegerNo
estimated_cost_usdNumericYes
latency_msIntegerYes
outcomeEnumNo
source_typeStringYes
source_idUUIDYes
llm_callsIntegerNo
unpriced_callsIntegerNo
unpriced_estimate_usdNumericYes
invocation_idUUIDYes
occurred_atDateTimeNo

ReviewFlag

One invocation an audit rule asked a person to look at.

`flag_for_review` used to record a trace event and nothing else: the flag was visible in a conversation's execution trace and nowhere a reviewer would ever look. This is where it lands, so "flag for review" means a queue somebody works through rather than a line in a log.

Like :class:GovernanceUsage this is an audit artifact, not a user-creatable resource, so it carries no `ResourceVersion history. The mutation a reviewer makes is recorded immutably on the row itself (reviewed_by_user_id, reviewed_at, reviewer_note`), and the status is terminal — there is no reopen — which is what makes that single record sufficient rather than a trail.

The rule identity is denormalised rather than joined. `Rule.name is mutable and a rule can be deleted outright, and a flag that resolved to nothing would be exactly the evidence an audit needed; rule_version` pins which revision of the rule fired.

  • Table: review_flags

Columns

ColumnTypeNullablePKNotes
owner_user_idUUIDYes
owner_organisation_idUUIDYes
owner_project_idUUIDYes
rule_organisation_idUUIDYes
kindStringNo
rule_idUUIDYes
rule_nameStringYes
rule_versionIntegerYes
scope_typeEnumYes
scope_idUUIDYes
reviewerStringYes
execution_typeStringYes
conversation_idUUIDYes
agent_idUUIDYes
ai_model_idUUIDYes
invocation_idUUIDYes
excerptTextYes
withheld_textTextYes
experiment_idUUIDYes
batch_idUUIDYes
statusEnumNo
reviewed_by_user_idUUIDYes
reviewed_atDateTimeYes
reviewer_noteTextYes
created_atDateTimeNo
expires_atDateTimeYes

DecisionOutcome

A person's verdict on a governed turn — accepted, edited (with the corrected text) or rejected — and an optional business-outcome label.

Append-only: a changed mind is a new row, and the newest is the turn's verdict, so the record keeps who said what and when. Read on the decision record (its `outcome section) and beside each answer in the chat, counted by the monthly statement as verified decisions, and the source of the cases "Add to dataset" makes (TestCase.source_invocation_id`).

An audit artifact like `ReviewFlag`: no history of its own (the rows are it), no FKs — it outlives the turn, the users and the flag it names.

  • Table: decision_outcomes

Columns

ColumnTypeNullablePKNotes
invocation_idUUIDNo
kindStringNo
verdictStringNo
corrected_textTextYes
labelStringYes
noteTextYes
sourceStringNo
review_flag_idUUIDYes
actor_user_idUUIDNo
owner_user_idUUIDYes
workspace_organisation_idUUIDYes
workspace_project_idUUIDYes
created_atDateTimeNo

DecisionReadLog

One read of a turn's decision record by somebody other than its owner.

The record holds a person's whole question and answer, and a reviewer may open it through a flag on the turn (`review.may_review). Each such read is appended here before the record is served — and the record is not served if it cannot be — so "who has looked at this conversation?" always has an answer. The owner's own reads are not logged. Shown on the record itself (its reads` section) and exported with the owner's data.

An audit artifact like `ReviewFlag`: append-only, no history, no FKs — it outlives the users it names.

  • Table: decision_reads

Columns

ColumnTypeNullablePKNotes
invocation_idUUIDNo
owner_user_idUUIDYes
reader_user_idUUIDNo
accessStringNo
flag_idUUIDYes
read_atDateTimeNo

GovernanceEvent

One rule, evaluated once, against one invocation.

The evidence that governance ran. `GovernanceUsage records what an invocation *consumed* and ReviewFlag` records what a rule asked a person to look at; this records the evaluation itself — every applicable rule, whether or not it matched, and what came of it.

Rules that did nothing are the point. Until this table existed, a rule's effects were visible only as events inside a conversation's execution trace, and an action that had nothing to do emitted no event at all. So a redaction rule over a prompt containing no PII looked exactly like a rule that had never been evaluated — and "was this invocation governed, and by what?" is the first question an audit asks. Every applicable rule gets a row, with `outcome` separating blocked, applied, ran and changed nothing and conditions did not hold.

What was redacted is recorded as kinds and counts, never values. `detail holds {"redact_pii": {"redacted": {"email": 2, "card": 1}}}, keyed by the action that ran (governance_activity.detail_of`). Storing the matched text would put the exact strings a redaction rule exists to remove into a table that is kept longer than the conversation — the log of a redaction must not be a copy of what was redacted.

Like its two siblings this is an audit artifact, not a user-creatable resource: nothing edits these rows, so they carry no `ResourceVersion history and no ownership constraint. The rule identity is denormalised (rule_name, rule_version`) and every reference is soft, because the record has to outlive the rule, the agent and the conversation — a rule that was deleted after it blocked somebody is exactly the case the log is kept for.

  • Table: governance_events

Columns

ColumnTypeNullablePKNotes
owner_user_idUUIDNo
owner_organisation_idUUIDYes
owner_project_idUUIDYes
workspace_user_idUUIDYes
rule_idUUIDYes
rule_nameStringYes
rule_versionIntegerYes
layerEnumNo
scope_typeEnumYes
scope_idUUIDYes
phaseEnumNo
outcomeEnumNo
enforced_inEnumNo
actionsJSONNo
detailJSONNo
invocation_idUUIDYes
execution_typeStringYes
conversation_idUUIDYes
message_idUUIDYes
agent_idUUIDYes
ai_model_idUUIDYes
created_atDateTimeNo

BackgroundEvent

One piece of work the platform did for an owner outside a request.

`scheduled_jobs` says a job ran and what it came to across the whole platform ("refreshed 12 widgets"). That answers an operator; it does not answer a user asking what happened to their things while they were away — which board tile regenerated, which website was re-crawled and what changed, which flags retention deleted. This does, one row per subject, and the Activity page reads it.

An audit artifact like `governance_events`: append-only, soft references, the subject's name denormalised, because the record has to outlive the board or source it describes.

  • Table: background_events

Columns

ColumnTypeNullablePKNotes
owner_user_idUUIDYes
owner_project_idUUIDYes
owner_organisation_idUUIDYes
kindStringNo
triggerStringNo
statusStringNo
subject_typeStringYes
subject_idUUIDYes
subject_nameStringYes
summaryStringNo
detailJSONYes
referenceJSONYes
errorStringYes
started_atDateTimeYes
finished_atDateTimeNo
duration_msIntegerYes

ScheduledJob

The last run of one background job — the scheduler's heartbeat.

One row per registered job, upserted rather than appended. That is the deliberate difference from the audit tables above: this is operational state, not evidence about a user's data. An append-only run log would grow without bound and need a retention policy of its own, which would have to be enforced by… a scheduled job. One row per job answers the question anyone actually asks — "when did this last run, and did it work?" — without that circularity.

Why it exists at all, when the jobs are idempotent and could schedule themselves from memory: "has the retention purge been running?" is an audit question, and a scheduler that could only be observed by reading logs is one nobody can answer it about. `GET /monitoring/scheduler` serves these rows.

The registry is the source of truth for which jobs exist; a row here is created the first time a job runs. A job removed from the registry leaves its row behind, which is the right way round — the record that it used to run outlives the code that ran it.

  • Table: scheduled_jobs

Columns

ColumnTypeNullablePKNotes
last_started_atDateTimeYes
last_finished_atDateTimeYes
last_duration_msIntegerYes
last_statusEnumYes
last_detailStringYes
last_errorStringYes
last_error_atDateTimeYes
run_countIntegerNo
failure_countIntegerNo

SpendStatement

One workspace's statement for one finished calendar month (UTC): its spend and what governed it (cost-control plan A4.1, the monthly organisation statement of `docs/business/mvp-roadmap.md`).

Written once, an hour after the month ends, by the `spend_statements job (app/services/statements), and never changed: a statement is what the month came to as the platform recorded it, kept so finance and an audit read the same figures every time. content is the statement as served, aggregate figures only — no prompt, answer or person's name — with content_sha256` over its canonical JSON.

A record like `DecisionReadLog, not a user resource: no edit history, and no foreign keys — it outlives the workspace and everything it counts. workspace_key is its workspace (Workspace.key`), unique with the month; the owner columns say whose data export holds it (a person's Personal workspace only).

  • Table: spend_statements

Columns

ColumnTypeNullablePKNotes
workspace_keyStringNo
owner_user_idUUIDYes
owner_organisation_idUUIDYes
owner_project_idUUIDYes
period_startDateNo
closed_atDateTimeNo
schema_versionIntegerNo
contentJSONNo
content_sha256StringNo

Notification

Something a person should know about without having to look: a budget passing a threshold, a statement ready to read (cost-control plan A2, the in-app inbox).

One row per recipient, written by the platform (`app/services/ notifications) and read in fe-core's inbox. kind is a registered kind; title and body are composed when it is written, from figures only — never a prompt, an answer or anyone else's spending by name. link is a page written against /user/…; fe-core moves it into workspace_key's workspace. dedupe_key` makes each alert once per recipient (a budget's threshold in one period, say).

Not a resource: no edit history and no foreign keys. Read ones are deleted after `notifications.RETENTION_DAYS`.

  • Table: notifications

Columns

ColumnTypeNullablePKNotes
recipient_user_idUUIDNo
kindStringNo
workspace_keyStringYes
workspace_nameStringYes
titleStringNo
bodyTextYes
linkStringYes
dataJSONYes
dedupe_keyStringNo
created_atDateTimeNo
read_atDateTimeYes

ScenarioRun

One scenario run (`app/services/scenarios`): a developer's scripted set of agent chats, run in a project of its own and kept for export.

Written `running before the work is handed to the runner's worker, with each turn's export appended to results as it finishes — so a run cut off by a restart keeps what it did — and finished in place. A record of something that happened, not a resource anyone edits: no version trail. The project it ran in is SET NULL`, so deleting that project by hand leaves the record readable.

  • Table: scenario_runs

Columns

ColumnTypeNullablePKNotes
user_idUUIDNo
nameStringNo
scenarioJSONNo
scenario_sha256StringNo
project_idUUIDYes
statusStringNo
progressJSONNo
resultsJSONYes
errorTextYes
cancel_requestedBooleanNo
created_atDateTimeNo
updated_atDateTimeNo
finished_atDateTimeYes

Swarm

A team of agents in a shape (`app/services/swarms`), saved so it can be sent on a task as often as it is wanted.

`topology names the shape — a class in swarms.topologies — and params its settings, validated by that class. roster is which of the workspace's agents play which part: [{handle, role, agent_id}]. defaults` are what a dispatch starts from (budget, time cap, parallelism, whether the plan is approved first, whether workers may ask).

Versioned like every user-created resource; a run stores the version it ran (`SwarmRun.swarm_version`) and a copy of what it ran, so editing a swarm never changes a run's record.

  • Table: swarms

  • Mixins: OwnableMixin.Resource, GenerationMixin.Tagged, DateMixin.Updated

Columns

ColumnTypeNullablePKNotes
nameStringNo
descriptionTextYes
topologyStringNo
paramsJSONNo
rosterJSONNo
defaultsJSONNo

SwarmRun

One dispatch of a swarm on a task, under a budget and a time cap.

Written before the work is handed to a coordinator and finished in place; a record of something that happened, so it has no version trail of its own. The swarm is `SET NULL and its name and configuration are copied (config`): a run is most worth reading when someone asks what a since-changed or deleted swarm did.

Its tasks (`swarm_tasks) are the tree the team worked through. The rows are the truth: a finished task is committed before anything is decided from it, so a coordinator lost to a restart is resumed from the last finished task (swarms.engine.watchdog`).

  • Table: swarm_runs

Columns

ColumnTypeNullablePKNotes
swarm_idUUIDYes
swarm_nameStringNo
swarm_versionIntegerYes
parent_run_idUUIDYes
thread_idUUIDNo
thread_seqIntegerNo
configJSONNo
user_idUUIDNo
workspace_organisation_idUUIDYes
workspace_project_idUUIDYes
statusStringNo
taskTextNo
file_idsJSONNo
budget_usdNumericNo
time_cap_sIntegerNo
deadline_atDateTimeNo
reserve_usdNumericNo
reserve_sIntegerNo
wrap_up_reasonStringYes
planJSONYes
ledgerJSONNo
progressJSONNo
outputTextYes
citationsJSONYes
warningsJSONYes
errorTextYes
cost_usdNumericNo
spent_usdNumericNo
llm_callsIntegerNo
unpriced_callsIntegerNo
input_tokensIntegerNo
output_tokensIntegerNo
cancel_requestedBooleanNo
heartbeat_atDateTimeYes
paused_atDateTimeYes
created_atDateTimeNo
finished_atDateTimeYes

Relationships

  • tasks → SwarmTask


SwarmTask

One piece of a swarm run: an agent's turn planning, working, reviewing or writing the answer.

Its own governed turn: `invocation_id joins it to its ledger rows, rule activity and svc-ai's traces, as a skill run's does. agent_id is SET NULL` with its name copied, as everywhere a record outlives what it names.

  • Table: swarm_tasks

Columns

ColumnTypeNullablePKNotes
run_idUUIDNo
parent_idUUIDYes
seqIntegerNo
depthIntegerNo
kindStringNo
handleStringNo
titleStringNo
roleStringNo
agent_idUUIDYes
agent_nameStringNo
tierStringNo
cost_profileStringYes
briefJSONNo
depends_onJSONNo
statusStringNo
attemptsIntegerNo
budget_usdNumericYes
estimate_usdNumericYes
limit_usdNumericYes
cost_usdNumericNo
spent_usdNumericNo
llm_callsIntegerNo
unpriced_callsIntegerNo
input_tokensIntegerNo
output_tokensIntegerNo
latency_msIntegerYes
invocation_idUUIDYes
outputTextYes
resultJSONYes
citationsJSONYes
questionsJSONYes
responsesJSONYes
rule_eventsJSONYes
errorTextYes
created_atDateTimeNo
started_atDateTimeYes
finished_atDateTimeYes

Relationships

  • run → SwarmRun