Database Models
Auto-generated from source on
2026-10-30 15:30 UTC. Do not edit manually — runmake specto 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:
usersMixins:
DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
auth0_id | String | No | ||
email | String | No | ||
email_verified | Boolean | Yes | ||
name | String | Yes | ||
picture | String | Yes | ||
is_active | Boolean | Yes | ||
is_superuser | Boolean | Yes | ||
platform_roles | JSON | No |
Relationships
organisations→UserOrganisationprojects→UserProject
Organisation
Table:
organisationsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
auth0_org_id | String | Yes | ||
cost_centre | String | Yes |
Relationships
members→UserOrganisationprojects→Project
UserOrganisation
Table:
user_organisationsMixins:
FKMixin.Role,DateMixin.Joined
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
organisation_id | UUID | Yes | ✓ | |
access | JSON | Yes |
Relationships
user→Userorganisation→Organisationrole→Role
Project
Table:
projectsMixins:
OwnableMixin.Resource,GenerationMixin.Tagged,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
cost_centre | String | Yes |
Relationships
members→UserProject
UserProject
Table:
user_projectsMixins:
FKMixin.Role,DateMixin.Joined
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
project_id | UUID | Yes | ✓ | |
access | JSON | Yes |
Relationships
user→Userproject→Projectrole→Role
Role
Table:
roles
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes |
Relationships
permissions→Permission
Permission
Table:
permissions
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
permission_code | Enum | No | ||
description | Text | Yes |
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_invitesMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
organisation_id | UUID | Yes | ||
project_id | UUID | Yes | ||
email | String | No | ||
role_id | UUID | No | ||
access | JSON | Yes | ||
token_hash | String | No | ||
created_by_user_id | UUID | Yes | ||
expires_at | DateTime | No | ||
accepted_at | DateTime | Yes | ||
accepted_by_user_id | UUID | Yes | ||
revoked_at | DateTime | Yes | ||
revoked_by_user_id | UUID | Yes |
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_versionsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
resource_type | Enum | No | ||
resource_id | UUID | No | ||
version_number | Integer | No | ||
action | Enum | No | ||
snapshot | JSON | No | ||
children_snapshot | JSON | Yes | ||
changed_fields | JSON | No | ||
actor_user_id | UUID | Yes | ||
generation_id | UUID | Yes | ||
origin | String | Yes |
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_runsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
flow | Enum | No | ||
status | Enum | No | ||
arguments | JSON | No | ||
ai_model_id | UUID | Yes | ||
provider | String | Yes | ||
model_name | String | Yes | ||
target_resource_type | Enum | Yes | ||
target_resource_id | UUID | Yes | ||
warnings | JSON | Yes | ||
error | Text | Yes | ||
proposal | JSON | Yes | ||
progress | JSON | Yes | ||
actor_user_id | UUID | Yes | ||
workspace_organisation_id | UUID | Yes | ||
workspace_project_id | UUID | Yes | ||
applied_at | DateTime | Yes |
Agent
Table:
agentsMixins:
OwnableMixin.Resource,ClonableMixin,SystemMixin,GenerationMixin.Tagged,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
agent_type | Enum | No | ||
icon | String | Yes | ||
accent | String | Yes | ||
system_prompt | Text | Yes | ||
tools | JSON | Yes | ||
config | JSON | Yes | ||
ai_model_id | UUID | Yes | ||
clarify_scope | Boolean | No | ||
cost_profile | String | No |
Relationships
conversations→Conversationindustries→ResourceIndustryroles→ResourceRole
AgentMemory
Table:
agent_memoryMixins:
FKMixin.Agent.Child,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
role | String | No | ||
content | Text | No | ||
created_at | DateTime | Yes |
Conversation
Table:
conversationsMixins:
OwnableMixin.LLMArtifact,OwnableMixin.Resource,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
total_input_tokens | Integer | No | Sum of system + user tokens | |
total_output_tokens | Integer | No | Sum of assistant tokens | |
total_tokens | Integer | No | Cached totalinputtokens + totaloutputtokens | |
workspace_organisation_id | UUID | Yes | ||
workspace_project_id | UUID | Yes |
Relationships
agent→Agentmessages→ChatMessage
ChatMessage
Table:
chat_messagesMixins:
FKMixin.Conversation.Child,DateMixin.Sent
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
role | Enum | No | ||
status | Enum | No | Outcome 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. | |
content | Text | No | ||
token_count | Integer | No | Token count for this message only | |
trace | JSON | Yes | Execution trace for assistant messages (graphplan/nodestart/nodeend/toolcall events) | |
meta | JSON | Yes | Request/response metadata: tokencount, temperature, outputformat, output_schema | |
invocation_id | UUID | Yes |
Relationships
conversation→Conversationsegments→ChatMessageSegment
ChatMessageSegment
Per-worker output segment for multi-agent skill executions.
Table:
chat_message_segments
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
message_id | UUID | No | ||
worker_slug | String | No | ||
content | Text | No | ||
sequence | Integer | No | Execution order within the message |
Relationships
message→ChatMessage
Knowledge
Table:
knowledgeMixins:
OwnableMixin.Resource,SystemMixin,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
source_type | String | No | ||
source_config | JSON | No |
KnowledgeDocument
Table:
knowledge_documentsMixins:
FKMixin.Knowledge.Child,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
source_id | String | No | ||
folder_path | String | No | ||
document_metadata | JSON | Yes |
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_crawlsMixins:
FKMixin.Knowledge.Child,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
trigger | String | No | ||
status | String | No | ||
actor_user_id | UUID | Yes | ||
started_at | DateTime | No | ||
finished_at | DateTime | Yes | ||
pages_fetched | Integer | No | ||
pages_new | Integer | No | ||
pages_changed | Integer | No | ||
pages_unchanged | Integer | No | ||
pages_failed | Integer | No | ||
pages_gone | Integer | No | ||
pages_expired | Integer | No | ||
usage | JSON | Yes | ||
note | Text | Yes |
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_versionsMixins:
FKMixin.Knowledge.Child,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
document_id | UUID | No | ||
crawl_id | UUID | Yes | ||
version_number | Integer | No | ||
url | String | No | ||
title | String | Yes | ||
content_hash | String | No | ||
http_status | Integer | Yes | ||
etag | String | Yes | ||
last_modified | String | Yes | ||
fetched_at | DateTime | No | ||
markdown_object | String | No | ||
html_object | String | Yes | ||
size_bytes | Integer | No |
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_repositoriesMixins:
OwnableMixin.Resource,SystemMixin,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
icon | String | Yes | ||
accent | String | Yes | ||
category | String | No |
Relationships
members→RepositoryKnowledge
RepositoryKnowledge
Junction: a knowledge base that belongs to a repository.
Table:
repository_knowledge
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
knowledge_id | UUID | No | ✓ |
Relationships
repository→KnowledgeRepositoryknowledge→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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
repository_id | UUID | No | ✓ | |
config | JSON | Yes |
Relationships
agent→Agentrepository→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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
message_id | UUID | No | ||
invocation_id | UUID | Yes | ||
knowledge_id | UUID | No | ||
document_id | UUID | Yes | ||
agent_id | UUID | Yes | ||
owner_user_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
workspace_user_id | UUID | Yes | ||
tool | String | Yes | ||
cited_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
message_id | UUID | No | ||
invocation_id | UUID | Yes | ||
agent_id | UUID | Yes | ||
owner_user_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
workspace_user_id | UUID | Yes | ||
query | Text | Yes | ||
live | Boolean | No | ||
complexity | String | Yes | ||
profile | String | Yes | ||
searched | Boolean | No | ||
nothing_relevant | Boolean | No | ||
came_up_short | Boolean | No | ||
gaps | JSON | Yes | ||
unresolved | JSON | Yes | ||
web_hosts | JSON | Yes | ||
scoped_out | JSON | Yes | ||
asked_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
turn_id | UUID | No | ||
knowledge_id | UUID | No | ||
agent_id | UUID | Yes | ||
owner_user_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
workspace_user_id | UUID | Yes | ||
category | String | Yes | ||
role | String | Yes | ||
found | Integer | No | ||
kept | Integer | No | ||
ruled_out | Integer | No | ||
out_of_window | Integer | No | ||
tool_searches | Integer | No | ||
asked_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
workspace_key | String | No | ||
kind | String | No | ||
subject | String | No | ||
fingerprint | String | No | ||
dismissed_by_user_id | UUID | Yes | ||
dismissed_at | DateTime | No |
Skill
Table:
skillsMixins:
OwnableMixin.Resource,ClonableMixin,SystemMixin,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
tags | JSON | No | ||
graph_definition | JSON | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
skill_id | UUID | Yes | ||
skill_name | String | No | ||
skill_version | Integer | Yes | ||
user_id | UUID | No | ||
workspace_organisation_id | UUID | Yes | ||
workspace_project_id | UUID | Yes | ||
status | String | No | ||
prompt | Text | Yes | ||
task | Text | Yes | ||
inputs | JSON | No | ||
output | Text | Yes | ||
outputs | JSON | Yes | ||
state | JSON | Yes | ||
steps | JSON | Yes | ||
citations | JSON | Yes | ||
rule_trace | JSON | Yes | ||
warnings | JSON | Yes | ||
error | Text | Yes | ||
input_tokens | Integer | No | ||
output_tokens | Integer | No | ||
latency_ms | Integer | Yes | ||
cost_usd | Numeric | Yes | ||
llm_calls | Integer | No | ||
unpriced_calls | Integer | No | ||
cost_detail | JSON | Yes | ||
interrupt | JSON | Yes | ||
responses | JSON | Yes | ||
invocation_id | UUID | Yes | ||
started_at | DateTime | No | ||
finished_at | DateTime | Yes |
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_workersMixins:
OwnableMixin.Resource,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
base_worker | String | Yes | ||
role | String | Yes | ||
system_prompt | Text | Yes | ||
tags | JSON | Yes | ||
model_overrides | JSON | Yes | ||
tools_enabled | Boolean | No | ||
mcp_server_ids | JSON | No | ||
input_schema | JSON | No | ||
output_schema | JSON | No | ||
definition_name | String | Yes |
MCPServer
User-configured MCP (Model Context Protocol) server connection.
Table:
mcp_serversMixins:
OwnableMixin.Resource,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
template_key | String | Yes | ||
connection_type | String | No | ||
connection_config | JSON | No | ||
tools_cache | JSON | Yes | ||
is_active | Boolean | No |
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:
toolkitsMixins:
OwnableMixin.Resource,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes |
Relationships
mcp_servers→ToolkitMCPServer
ToolkitMCPServer
Junction: an MCP server that belongs to a toolkit.
Table:
toolkit_mcp_servers
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
mcp_server_id | UUID | No | ✓ |
Relationships
toolkit→Toolkitmcp_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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
toolkit_id | UUID | No | ✓ | |
config | JSON | Yes |
Relationships
agent→Agenttoolkit→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:
skillsetsMixins:
OwnableMixin.Resource,ClonableMixin,SystemMixin,GenerationMixin.Provenance,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes |
Relationships
skills→SkillsetSkill
SkillsetSkill
Junction: a skill that belongs to a skillset.
Table:
skillset_skills
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
skill_id | UUID | No | ✓ |
Relationships
skillset→Skillsetskill→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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
skillset_id | UUID | No | ✓ | |
config | JSON | Yes |
Relationships
agent→Agentskillset→Skillset
ResourceIndustry
Table:
resource_industriesMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No |
Relationships
agents→Agent
ResourceRole
Table:
resource_rolesMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No |
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:
experimentsMixins:
OwnableMixin.Resource,SystemMixin,GenerationMixin.Tagged,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
status | Enum | No | ||
dataset_id | UUID | No | ||
scorer | Enum | No | ||
scorer_config | JSON | Yes | ||
judge | JSON | Yes | ||
config | JSON | Yes |
Relationships
dataset→TestSuitevariants→ExperimentVariantruns→ExperimentRunbatches→ExperimentBatch
ExperimentVariant
A named variant (prompt + config) within an experiment.
Table:
experiment_variantsMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
experiment_id | UUID | No | ||
name | String | No | ||
prompt | Text | Yes | ||
config | JSON | Yes |
Relationships
experiment→Experimentruns→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_runsMixins:
RunnableMixin.Run,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
experiment_id | UUID | Yes | ||
variant_id | UUID | Yes | ||
batch_id | UUID | Yes | ||
test_case_id | UUID | Yes | ||
input | JSON | Yes | ||
output | Text | Yes | ||
score | JSON | Yes | ||
score_reason | Text | Yes | ||
scorer | Enum | Yes | ||
passed | Boolean | Yes | ||
run_metadata | JSON | Yes |
Relationships
experiment→Experimentvariant→ExperimentVarianttest_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_batchesMixins:
RunnableMixin.Run,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
experiment_id | UUID | Yes | ||
started_by_user_id | UUID | Yes | ||
dataset_id | UUID | Yes | ||
dataset_version | Integer | Yes | ||
evaluation_version | Integer | Yes | ||
label | String | Yes | ||
variant_ids | JSON | Yes | ||
dataset | JSON | Yes | ||
config | JSON | Yes | ||
completed | Integer | No | ||
total | Integer | No | ||
summary | JSON | Yes | ||
leaderboard | JSON | Yes | ||
error | Text | Yes | ||
regression | JSON | Yes | ||
regression_verdict | String | Yes | ||
target_versions | JSON | Yes | ||
scorer | Enum | Yes | ||
mean_score | Float | Yes | ||
pass_rate | Float | Yes | ||
total_cases | Integer | Yes | ||
errors | Integer | Yes | ||
mean_latency_ms | Integer | Yes | ||
total_tokens | Integer | Yes | ||
duration_ms | Integer | Yes |
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_suitesMixins:
OwnableMixin.Resource,ClonableMixin,GenerationMixin.Tagged,SystemMixin,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
status | Enum | No | ||
criteria | JSON | Yes | ||
pass_mark | Float | Yes | ||
config | JSON | Yes |
Relationships
test_cases→TestCaseevaluations→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_casesMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
test_suite_id | UUID | No | ||
name | String | Yes | ||
input | JSON | No | ||
expected_output | Text | Yes | ||
criteria | JSON | Yes | ||
expected_behaviour | String | Yes | ||
examples | JSON | Yes | ||
expectation | JSON | Yes | ||
situation | JSON | Yes | ||
tags | JSON | Yes | ||
source_invocation_id | UUID | Yes |
Relationships
test_suite→TestSuiteresults→ExperimentRun
SimulationWorld
A game-theoretic simulation environment with defined rules and logic.
Table:
simulation_worldsMixins:
OwnableMixin.Resource,GenerationMixin.Tagged,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
status | Enum | No | ||
rules | JSON | Yes | ||
logic | JSON | Yes |
Relationships
scenarios→SimulationScenariosimulations→Simulation
SimulationScenario
A named evaluation scenario within a simulation world.
Table:
simulation_scenariosMixins:
DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
world_id | UUID | No | ||
name | String | No | ||
description | Text | Yes | ||
strategy | Enum | No | ||
tags | JSON | Yes | ||
config | JSON | Yes | ||
status | Enum | No |
Relationships
world→SimulationWorldsimulations→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_filesMixins:
OwnableMixin.Resource,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
content | Text | No | ||
mime_type | String | Yes | ||
content_sha256 | String | Yes | ||
status | String | No | ||
error | Text | Yes | ||
object_key | String | Yes | ||
size_bytes | BigInteger | Yes |
Simulation
An execution of an agent cluster within a simulation world and scenario.
Table:
simulationsMixins:
RunnableMixin.Run,DateMixin.Created
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
world_id | UUID | No | ||
scenario_id | UUID | Yes | ||
name | String | Yes | ||
description | Text | Yes | ||
agent_ids | JSON | Yes | ||
results | JSON | Yes | ||
run_metadata | JSON | Yes |
Relationships
world→SimulationWorldscenario→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:
rulesMixins:
OwnableMixin.Resource,ClonableMixin,GenerationMixin.Provenance,SystemMixin,DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
layer | Enum | No | ||
scope_type | Enum | No | ||
scope_id | UUID | Yes | ||
conditions | JSON | No | ||
actions | JSON | No | ||
is_active | Boolean | No | ||
priority | Integer | No | ||
based_on_rule_id | UUID | Yes | ||
based_on_version | Integer | Yes | ||
required_for_projects | Boolean | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
project_id | UUID | No | ||
kind | String | No | ||
resource_id | UUID | Yes | ||
declared_by_user_id | UUID | Yes | ||
created_at | DateTime | No |
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:
dashboardsMixins:
OwnableMixin.Resource,ClonableMixin,GenerationMixin.Tagged,SystemMixin,DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
icon | String | Yes | ||
accent | String | Yes | ||
is_home | Boolean | No | ||
position | Integer | No |
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_widgetsMixins:
DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
dashboard_id | UUID | No | ||
widget_type | Enum | No | ||
title | String | Yes | ||
config | JSON | No | ||
x | Integer | No | ||
y | Integer | No | ||
w | Integer | No | ||
h | Integer | No | ||
position | Integer | No | ||
refresh_interval_seconds | Integer | Yes | ||
cache_status | Enum | No | ||
cache_payload | JSON | Yes | ||
cache_error | Text | Yes | ||
cached_at | DateTime | Yes |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
owner_user_id | UUID | Yes | ||
scope_type | Enum | No | ||
scope_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
workspace_user_id | UUID | Yes | ||
execution_type | String | Yes | ||
ai_model_id | UUID | Yes | ||
input_tokens | Integer | No | ||
output_tokens | Integer | No | ||
estimated_cost_usd | Numeric | Yes | ||
latency_ms | Integer | Yes | ||
outcome | Enum | No | ||
source_type | String | Yes | ||
source_id | UUID | Yes | ||
llm_calls | Integer | No | ||
unpriced_calls | Integer | No | ||
unpriced_estimate_usd | Numeric | Yes | ||
invocation_id | UUID | Yes | ||
occurred_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
owner_user_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
rule_organisation_id | UUID | Yes | ||
kind | String | No | ||
rule_id | UUID | Yes | ||
rule_name | String | Yes | ||
rule_version | Integer | Yes | ||
scope_type | Enum | Yes | ||
scope_id | UUID | Yes | ||
reviewer | String | Yes | ||
execution_type | String | Yes | ||
conversation_id | UUID | Yes | ||
agent_id | UUID | Yes | ||
ai_model_id | UUID | Yes | ||
invocation_id | UUID | Yes | ||
excerpt | Text | Yes | ||
withheld_text | Text | Yes | ||
experiment_id | UUID | Yes | ||
batch_id | UUID | Yes | ||
status | Enum | No | ||
reviewed_by_user_id | UUID | Yes | ||
reviewed_at | DateTime | Yes | ||
reviewer_note | Text | Yes | ||
created_at | DateTime | No | ||
expires_at | DateTime | Yes |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
invocation_id | UUID | No | ||
kind | String | No | ||
verdict | String | No | ||
corrected_text | Text | Yes | ||
label | String | Yes | ||
note | Text | Yes | ||
source | String | No | ||
review_flag_id | UUID | Yes | ||
actor_user_id | UUID | No | ||
owner_user_id | UUID | Yes | ||
workspace_organisation_id | UUID | Yes | ||
workspace_project_id | UUID | Yes | ||
created_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
invocation_id | UUID | No | ||
owner_user_id | UUID | Yes | ||
reader_user_id | UUID | No | ||
access | String | No | ||
flag_id | UUID | Yes | ||
read_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
owner_user_id | UUID | No | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
workspace_user_id | UUID | Yes | ||
rule_id | UUID | Yes | ||
rule_name | String | Yes | ||
rule_version | Integer | Yes | ||
layer | Enum | No | ||
scope_type | Enum | Yes | ||
scope_id | UUID | Yes | ||
phase | Enum | No | ||
outcome | Enum | No | ||
enforced_in | Enum | No | ||
actions | JSON | No | ||
detail | JSON | No | ||
invocation_id | UUID | Yes | ||
execution_type | String | Yes | ||
conversation_id | UUID | Yes | ||
message_id | UUID | Yes | ||
agent_id | UUID | Yes | ||
ai_model_id | UUID | Yes | ||
created_at | DateTime | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
owner_user_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
kind | String | No | ||
trigger | String | No | ||
status | String | No | ||
subject_type | String | Yes | ||
subject_id | UUID | Yes | ||
subject_name | String | Yes | ||
summary | String | No | ||
detail | JSON | Yes | ||
reference | JSON | Yes | ||
error | String | Yes | ||
started_at | DateTime | Yes | ||
finished_at | DateTime | No | ||
duration_ms | Integer | Yes |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
last_started_at | DateTime | Yes | ||
last_finished_at | DateTime | Yes | ||
last_duration_ms | Integer | Yes | ||
last_status | Enum | Yes | ||
last_detail | String | Yes | ||
last_error | String | Yes | ||
last_error_at | DateTime | Yes | ||
run_count | Integer | No | ||
failure_count | Integer | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
workspace_key | String | No | ||
owner_user_id | UUID | Yes | ||
owner_organisation_id | UUID | Yes | ||
owner_project_id | UUID | Yes | ||
period_start | Date | No | ||
closed_at | DateTime | No | ||
schema_version | Integer | No | ||
content | JSON | No | ||
content_sha256 | String | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
recipient_user_id | UUID | No | ||
kind | String | No | ||
workspace_key | String | Yes | ||
workspace_name | String | Yes | ||
title | String | No | ||
body | Text | Yes | ||
link | String | Yes | ||
data | JSON | Yes | ||
dedupe_key | String | No | ||
created_at | DateTime | No | ||
read_at | DateTime | Yes |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
user_id | UUID | No | ||
name | String | No | ||
scenario | JSON | No | ||
scenario_sha256 | String | No | ||
project_id | UUID | Yes | ||
status | String | No | ||
progress | JSON | No | ||
results | JSON | Yes | ||
error | Text | Yes | ||
cancel_requested | Boolean | No | ||
created_at | DateTime | No | ||
updated_at | DateTime | No | ||
finished_at | DateTime | Yes |
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:
swarmsMixins:
OwnableMixin.Resource,GenerationMixin.Tagged,DateMixin.Updated
Columns
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
name | String | No | ||
description | Text | Yes | ||
topology | String | No | ||
params | JSON | No | ||
roster | JSON | No | ||
defaults | JSON | No |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
swarm_id | UUID | Yes | ||
swarm_name | String | No | ||
swarm_version | Integer | Yes | ||
parent_run_id | UUID | Yes | ||
thread_id | UUID | No | ||
thread_seq | Integer | No | ||
config | JSON | No | ||
user_id | UUID | No | ||
workspace_organisation_id | UUID | Yes | ||
workspace_project_id | UUID | Yes | ||
status | String | No | ||
task | Text | No | ||
file_ids | JSON | No | ||
budget_usd | Numeric | No | ||
time_cap_s | Integer | No | ||
deadline_at | DateTime | No | ||
reserve_usd | Numeric | No | ||
reserve_s | Integer | No | ||
wrap_up_reason | String | Yes | ||
plan | JSON | Yes | ||
ledger | JSON | No | ||
progress | JSON | No | ||
output | Text | Yes | ||
citations | JSON | Yes | ||
warnings | JSON | Yes | ||
error | Text | Yes | ||
cost_usd | Numeric | No | ||
spent_usd | Numeric | No | ||
llm_calls | Integer | No | ||
unpriced_calls | Integer | No | ||
input_tokens | Integer | No | ||
output_tokens | Integer | No | ||
cancel_requested | Boolean | No | ||
heartbeat_at | DateTime | Yes | ||
paused_at | DateTime | Yes | ||
created_at | DateTime | No | ||
finished_at | DateTime | Yes |
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
| Column | Type | Nullable | PK | Notes |
|---|---|---|---|---|
run_id | UUID | No | ||
parent_id | UUID | Yes | ||
seq | Integer | No | ||
depth | Integer | No | ||
kind | String | No | ||
handle | String | No | ||
title | String | No | ||
role | String | No | ||
agent_id | UUID | Yes | ||
agent_name | String | No | ||
tier | String | No | ||
cost_profile | String | Yes | ||
brief | JSON | No | ||
depends_on | JSON | No | ||
status | String | No | ||
attempts | Integer | No | ||
budget_usd | Numeric | Yes | ||
estimate_usd | Numeric | Yes | ||
limit_usd | Numeric | Yes | ||
cost_usd | Numeric | No | ||
spent_usd | Numeric | No | ||
llm_calls | Integer | No | ||
unpriced_calls | Integer | No | ||
input_tokens | Integer | No | ||
output_tokens | Integer | No | ||
latency_ms | Integer | Yes | ||
invocation_id | UUID | Yes | ||
output | Text | Yes | ||
result | JSON | Yes | ||
citations | JSON | Yes | ||
questions | JSON | Yes | ||
responses | JSON | Yes | ||
rule_events | JSON | Yes | ||
error | Text | Yes | ||
created_at | DateTime | No | ||
started_at | DateTime | Yes | ||
finished_at | DateTime | Yes |
Relationships
run→SwarmRun