Skip to content

Database Schema

Kind: reference

PostgreSQL 16 (CloudNativePG). Migrations are embedded SQL files under api/internal/migrations/ and run automatically on API startup via golang-migrate.

Tables

organizations

Top-level grouping. Each org contains projects.

Column Type Notes
id BIGSERIAL PK
name TEXT NOT NULL
description TEXT NOT NULL Default ''
gitea_org TEXT NULL Gitea organisation slug (e.g. Skatzi). NULL = no sync.
agents_paused_at TIMESTAMPTZ NULL Set while the organization's agent work is paused: its agent tasks stay queued. Migration 085
agents_paused_by TEXT NULL Who paused it. Migration 085
org_chart_v2 BOOLEAN NOT NULL The Org Chart v2 switch. Default false: the organization behaves as before. Migration 091
decision_role TEXT NULL Slug of the decision gate role (ADR-0026). No foreign key. With org_chart_v2 on, its verdicts go to decision_gate. Migration 091
dispatcher_role TEXT NULL Slug of the dispatcher role, which gets work no routing rule matches (ADR-0026 §2). No foreign key. Migration 091
minimum_model TEXT NULL The smallest tier the organization's agent tasks run on: small, medium or large (check constraint); NULL = no minimum, every tier as before. Tiers only, never a model id (ADR-0005). The trigger tasks_minimum_model raises task models below it on every write, and the claim raises what a run asks for (tasks, task_runs). Set by people only with PUT /api/organizations/{orgId}/minimum-model. Migration 094
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

projects

Belongs to one organization. Contains tasks and task groups.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
name TEXT NOT NULL
description TEXT NOT NULL Default ''
gitea_repo TEXT NULL Gitea repo name (e.g. platform). NULL = no sync. Gitea sync is active when both gitea_org (on the org) and gitea_repo are set.
review_persona TEXT NULL Persona slug that reviews agents' pull requests; setting it turns agent review on (ADR-0007). Never ''
review_model TEXT NULL Tier or model id for review runs. NULL = the runner's default
review_labels TEXT[] NOT NULL Required labels of review runs. Default '{role=reviewer}'
review_max_rounds INTEGER NOT NULL Review rounds before the task goes to a person; blocked and out_of_date verdicts do not count. 1–10. Default 3
escalate_models BOOLEAN NOT NULL Turns model tier escalation on/off (ADR-0007). Default true
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

task_groups

Kanban columns within a project (Backlog, In Progress, Done, etc.).

Column Type Notes
id BIGSERIAL PK
project_id BIGINT FK → projects.id CASCADE delete
name TEXT NOT NULL
position INT NOT NULL Display order
created_at TIMESTAMPTZ

tasks

Unit of work. Belongs to a project, optionally placed in a task group.

Column Type Notes
id BIGSERIAL PK
project_id BIGINT FK → projects.id CASCADE delete
group_id BIGINT FK → task_groups.id NULL SET NULL on delete
milestone_id BIGINT FK → milestones.id NULL SET NULL on delete
epic_id BIGINT FK → epics.id NULL SET NULL on delete
title TEXT NOT NULL
description TEXT NOT NULL Markdown. Default ''
done BOOLEAN NOT NULL Default false
priority SMALLINT NOT NULL 0=none 1=low 2=medium 3=high. Default 0
assignee TEXT NULL Username, or an agent_types.slug of the task's organization when assignee_type is 2
assignee_type SMALLINT NULL 1=user 2=agent
gitea_issue_number BIGINT NULL Issue number in the linked Gitea repo. NULL = not synced.
gitea_issue_closed BOOLEAN NULL The state the issue reconciler last saw the task's Gitea issue in: true closed, false open, NULL not checked yet. Written only by the reconciler, together with gitea_issue_number; the trigger tasks_gitea_issue_changed (below) resets it to NULL when the issue number changes. No backfill: existing issues start unchecked. Migration 077
required_labels TEXT[] NOT NULL Labels a runner must all have to claim the task. Default '{}' (runs anywhere)
dispatch_state TEXT NULL queued, dispatched or needs_attention. NULL for tasks that are not agent work
dispatch_reason TEXT NULL Shown in the task dialog while dispatch_state is needs_attention. Set when a claim parks an implementation or revision task still assigned to the project's review persona (Runners and Runs), or when a third out_of_date review verdict in a row parks the task (Agent review); cleared whenever the task is edited or requeued
dispatch_state_changed_at TIMESTAMPTZ NULL When the task entered its current dispatch_state; the Queue's wait time (Runners and Runs). Kept by the trigger tasks_dispatch_state_time: on insert with a state it is created_at (unless given); on update it is now() whenever dispatch_state changes, NULL when the state is cleared. Other edits leave it alone. Migration 037 backfilled it from updated_at for tasks that already had a state, so those rows' times are approximate
model TEXT NULL Tier (small, medium, large) or model id a runner must offer. NULL = the assigned persona's default_model (same organization), else the runner's default_model; never ''. When preferred_models is non-empty, model is the capacity fallback and must be a tier or NULL
preferred_models TEXT[] NOT NULL Model ids the task prefers, best first (ADR-0014). At most 3, distinct, no whitespace, never tiers. While it is non-empty, model must be a tier (small, medium, large) or NULL, because the tier is the capacity fallback. The API validates this; the database does not. Default '{}' (no preference). Migration 061
effort TEXT NULL How much the agent should reason: low, medium or high (check constraint). NULL = the runner's default. Provider-neutral beside model; not a claim requirement. Migration 053
model_escalation SMALLINT NOT NULL How many tiers up model currently sits, 0–2, capped at large (ADR-0007). Calculated from the resolved model (after persona default fallback). Default 0; reset to 0 when model changes
model_raised_from TEXT NULL The model a write asked for when the organization's minimum_model raised it (for example small when the task now holds medium); NULL when the model was not raised. Kept by the trigger tasks_minimum_model (below), not by the API. Migration 094
review_of_id BIGINT FK → tasks.id NULL Legacy review tasks: the task whose pull request is reviewed. CASCADE delete
review_pr_url TEXT NULL Pull request under review on a legacy review task
review_round INTEGER NULL Round on a legacy review task, starts at 1
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ
done_at TIMESTAMPTZ NULL Set to the API's clock the moment done flips from false to true, by any path (task API, MCP, Gitea sync, legacy review tasks); cleared when done goes back to false; left unchanged on any other edit. Backfilled for tasks already done when the column was added — the latest run's finished_at when it is after created_at, else updated_at — so older values are approximate (ADR-0008)
created_by_run_id BIGINT FK → task_runs.id NULL The agent run that created the task, if any; lets that run add a follow_up_of link from it (task_links), holds the task back from claims until that run has an outcome (Runners and Runs, task #1137), and lists the task under the request whose run created it. SET NULL on delete. Migration 036
created_by_routine_id BIGINT NULL The routine that created the task, if any; the API returns it as the read-only routine {id, name}, null for any other task. No foreign key on purpose: the id outlives a deleted routine, so the issue reconciler still knows the task was made without a Gitea issue on purpose. Indexed by tasks_created_by_routine where it is set. Migration 083
kind TEXT NOT NULL task, request (a project request), dependency_update (a Renovate pull request, migration 073) or incident (an Alertmanager alert group or a DR run report, migration 078). Checked by tasks_kind_check, which each of those migrations widens. Default task; read-only in the API. An incident task's API object carries incident, read from its incidents row (no column of its own). Migration 044
dependency JSONB NULL A dependency_update task's Renovate pull request: {repository, branch, pull_request, packages: [{name, datasource, from, to, type, released_at}], class, release_notes_url, merged_at}, pull_request as owner/repo#n, class one of trivial, standard, breaking, stateful, core. packages[].released_at is the new version's release time (RFC 3339, Renovate's releaseTimestamp), absent or empty when the taskbase:dep note gives none. merged_at is when the pull request merged (set by the merge webhook); absent while it is open and when it closed without merging. Both keys from task #1177, with no migration of their own. Set exactly when kind = 'dependency_update' (check tasks_dependency_kind). Written by the webhook; through the API only class may be raised. Migration 073
requested_by TEXT NULL On a request: who filed it, as the request list shows it. Migration 044
decision_question TEXT NULL The question of a decision task; NULL for an ordinary task. At most 2,000 characters (checked by the API). Migration 048
decision_options TEXT[] NOT NULL Suggested answers, at most 6 of 200 characters (checked by the API). For a decision with decision_choices, their labels in the same order, so readers of the plain options are unchanged. Default '{}'. Migration 048
decision_summary TEXT NULL Why the decision matters to the owner, in plain words, at most 300 characters (checked by the API); NULL when not given. Migration 095
decision_choices JSONB NULL The decision's structured options: [{label, description, recommended}], at most 4, the recommended one first (checked by the API). NULL for a decision with plain options only, which the API reads as choices. Migration 095
decision_answer TEXT NULL The answer once decided, at most 4,000 characters (checked by the API). The check constraint tasks_decision_has_question allows options and an answer only with a question, and tasks_decision_details_have_question (migration 095) keeps decision_summary and decision_choices NULL without one. Migration 048
decision_owner_only BOOLEAN NOT NULL A decision the owner keeps for themselves: it never goes to the decision gate. Set through decision.owner_only (task API, MCP create_task/update_task). Default false. Migration 093
decision_answered_at TIMESTAMPTZ NULL When decision_answer was set or last changed; NULL while there is no answer. Kept by the trigger tasks_decision_answered_at (below), not by the API. Read by the unplanned-decision sweep. Migration 072
attention_raised_at TIMESTAMPTZ NULL When Needs attention first raised an item on the task: the created_at of its first notifications row. NULL while none was ever raised. Kept by the trigger notifications_attention_raised_at (below), not by the API; never cleared. Read by the upgrade metrics as "merged with no person". Migration 075
start_after TIMESTAMPTZ NULL No runner claims the task before this time; NULL = no wait. depends_on and the other claim holds still apply on top. Set through the task API, MCP and UI (Start after, task #2405). Migration 090
complexity_points SMALLINT NULL Override of the delivered-points value for the effectiveness index, 1–13. Settable by people only through the task API/MCP/UI; an agent's attempt is refused, since it would be grading its own work. When NULL, points come from the task's own model tier instead (small 1, medium 3, large 8); a task with no tier (an explicit model id, or none) is unsized
routed_by TEXT NULL Why the Org Chart v2 router gave the task, created without an assignee, to its role: rule N (kind pattern), for example rule 2 (path internal/identity/**), or dispatcher. NULL for every task the router did not assign, so for every task while org_chart_v2 is off. Written only when the task is created; a later reassignment leaves it. The API returns it as the read-only routed, omitted when NULL (taskbase#714, task #2840). Migration 092

Partial index on (priority DESC, id) WHERE dispatch_state = 'queued' for the claim query, and on review_of_id where it is set. done_at is indexed for the effectiveness index's day-range queries. Migration 044 adds tasks_project_requests on (project_id, created_at DESC) WHERE kind = 'request' for the request list, and tasks_created_by_run on created_by_run_id where it is set. Migration 073 adds the unique partial index tasks_dependency_open on (lower(dependency->>'repository'), dependency->>'branch') WHERE kind = 'dependency_update' AND NOT done — one open dependency task per repository and Renovate branch — and tasks_dependency_pull_request on lower(dependency->>'pull_request') for the merge match. Migration 072 adds the partial index tasks_decision_answered_at on decision_answered_at WHERE decision_answered_at IS NOT NULL AND done, for the unplanned-decision sweep.

The trigger tasks_decision_answered_at (before an insert, or an update of decision_answer) sets decision_answered_at to now() when the answer is set or changes, and clears it when the answer is cleared. Migration 072 backfilled answers given before it from the resolved_at of the task's latest resolved decision_needed event; resolved events are kept 30 days, the sweep's whole window, so older answers stay NULL and are never flagged.

The trigger notifications_attention_raised_at (after an insert on notifications with a task_id, function tasks_attention_raised_at()) sets the task's attention_raised_at to the event's created_at when it is still NULL, so the first item raised is the one kept. The mark lives on the task because resolved events are deleted after 30 days. Migration 075 backfilled it from the earliest event still kept for each task; a task whose events were all deleted before it stays NULL.

The trigger tasks_gitea_issue_changed (before an update of gitea_issue_number that changes it, function tasks_gitea_issue_changed()) sets gitea_issue_closed to NULL — a new issue has not been checked — unless the same write also sets gitea_issue_closed, as the reconciler does when it records the issue it created or adopted (migration 077).

The trigger tasks_minimum_model (before an insert, or an update of model or project_id, function tasks_minimum_model()) raises a tier below the organization's minimum_model to that minimum, whichever path writes the task (people, agents, MCP, triage, routines, the decision gate, Renovate, incidents), and stores the tier asked for in model_raised_from. An insert, or an update that changes model, without a raise clears model_raised_from; an update that leaves the model alone keeps it. It compares with the SQL function model_at_least(model, minimum), which returns minimum when both are tiers and model is the smaller, and model unchanged otherwise: a NULL model, a model id or a NULL minimum is never raised. Setting a minimum does not rewrite existing tasks; the claim raises those (task_runs). Model escalation still raises from the stored tier. Migration 094 (task #2901).

A person's task that agent work waits on, or that asks an open decision, is raised on Needs attention and moved between the Blocked and Backlog columns by triggers (migrations 047, 048 and 069, Person tasks): tasks_blocking_agent_work_self (before an update of assignee_type, done, project_id, decision_question or decision_answer), tasks_blocking_agent_work_dependent (after a dependent's assignee_type or done changes), tasks_decision_created (after inserting an open decision for a person), tasks_decision_prerequisite (after an update of done: re-evaluates the open person decisions that depends_on the task) and task_links_blocking_agent_work (after a depends_on link is inserted or deleted: re-evaluates its target and, since migration 069, its source). All of them call person_task_attention().

An open decision is raised only once it is answerable: person_task_attention() raises nothing for it — no event and no move to Blocked — while the SQL function decision_waiting_for(task_id), the ids of the open tasks it depends_on in id order, is non-empty (Not answerable yet). The API returns that list as the read-only decision_waiting_for on an open decision (migration 069).

Org Chart v2 routing

With the organization's org_chart_v2 switch on, a task created through POST /api/projects/{id}/tasks (people, MCP create_task, agents' follow-ups, general chats) that is open, has no assignee and asks no decision goes to a role as an agent task, and routed_by records why (ADR-0026 §2, task #2840). The role is the first routing rule, in order, that the work matches; else the organization's dispatcher role; else nobody, and the task stays unassigned. A new task has no pull request or Gitea labels yet, so today only repository rules can match at creation. A role the project refuses (its review persona) also leaves the task unassigned. Tasks created with an assignee are never touched; Renovate, incident, deploy-failure, request, triage and routine tasks keep their own routes. With the switch off nothing is routed. The may_assign default also changes with the switch on; see organization_roles. Sources, read 2026-11-11: the role section of Taskbase's CLAUDE.md and api/internal/task/routing.go.

The project board pages each column on its own (migration 033):

Index On Serves
idx_tasks_project_id (project_id) Project-wide task queries, including the unpaged task list, which had no index on project_id before
idx_tasks_group_updated_at (group_id, updated_at DESC, id DESC) Every column except Done, newest change first
idx_tasks_group_done_at (group_id, (CASE WHEN done_at IS NULL THEN -1 ELSE 0 END) DESC, (COALESCE(done_at, updated_at)) DESC, id DESC) The Done column, by done_at; a task without one (e.g. moved into Done directly) sorts after every completed task, by updated_at

Typed links between two tasks (migration 036, ADR-0009). Both tasks are in the same organization, except that depends_on and relates_to may join two organizations; the API enforces this, not the schema (Task links). A claim imports one digest from a follow_up_of or depends_on predecessor in the same organization (Runners and Runs); a depends_on holds the claim regardless of organization.

Column Type Notes
id BIGSERIAL PK
source_id BIGINT FK → tasks.id CASCADE delete
target_id BIGINT FK → tasks.id CASCADE delete
kind TEXT NOT NULL relates_to, duplicates, depends_on or follow_up_of. depends_on and follow_up_of point from the dependent or follow-up task to its predecessor
created_at TIMESTAMPTZ NOT NULL Default now()

A task cannot link to itself. The symmetric kinds relates_to and duplicates are stored once, with source_id < target_id. Unique on (source_id, target_id, kind); indexed on target_id.

task_attachments

Images on a task description or comment. An upload starts unsent, then becomes a description image or is bound to a comment. Migration 088 (task #1828).

Column Type Notes
id BIGSERIAL PK
task_id BIGINT NOT NULL FK → tasks.id CASCADE delete
comment_id BIGINT FK → task_comments.id NULL CASCADE delete; NULL for a description image or unsent upload
in_description BOOLEAN NOT NULL Default false; true for a description image
name TEXT NOT NULL Default ''
mime TEXT NOT NULL Check: image/png, image/jpeg, image/webp or image/gif
size INTEGER NOT NULL Bytes; check: greater than 0
sha256 TEXT NOT NULL Image digest
data BYTEA NOT NULL Image bytes
created_by TEXT NOT NULL Uploader's username
created_at TIMESTAMPTZ NOT NULL Default now()

The check NOT (in_description AND comment_id IS NOT NULL) prevents a row from belonging to both a description and a comment. A row with comment_id NULL and in_description = false is unsent. The runner sweeper deletes unsent rows after 24 hours; saved images go with their task or comment through the foreign-key cascades.

Index Columns and condition Serves
task_attachments_task (task_id) Task lookup
task_attachments_comment (comment_id) WHERE comment_id IS NOT NULL Comment lookup
task_attachments_creator (created_by, created_at) Daily upload cap
task_attachments_unsent (created_at) WHERE comment_id IS NULL AND NOT in_description Unsent-upload sweep

Source: Taskbase migration api/internal/migrations/000088_task_attachments.up.sql and api/internal/attachment/task.go, reported from Skatzi/taskbase main at 047a302a46f8ea4f05ad8e55c4206247f0bc6a46 in task #1861 (read 2026-10-28).

milestones

Organization-level time-boxed milestones. Tasks and epics can be assigned to a milestone.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
title TEXT NOT NULL
description TEXT NOT NULL Markdown. Default ''
due_date TIMESTAMPTZ NULL
created_by_run_id BIGINT FK → task_runs.id NULL The agent run that created the milestone, if any, so a request lists it. SET NULL on delete; indexed where set. Migration 044
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

epics

Organization-level grouping that spans across projects.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
milestone_id BIGINT FK → milestones.id NULL SET NULL on delete
title TEXT NOT NULL
description TEXT NOT NULL Markdown. Default ''
status SMALLINT NOT NULL Default 0
created_by_run_id BIGINT FK → task_runs.id NULL The agent run that created the epic, if any, so a request lists it. SET NULL on delete; indexed where set. Migration 044
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

api_keys

Persistent API keys, sent as X-API-Key instead of a Keycloak JWT. A key with an owner is a personal key and acts as that user; a key without one is a service key that reaches every organization (see API keys).

Column Type Notes
id BIGSERIAL PK
name TEXT NOT NULL Human label
key_prefix TEXT NOT NULL First 8 chars for display
key_hash TEXT NOT NULL UNIQUE SHA-256 hex digest of the key; the plaintext is never stored
owner TEXT NULL Owner's Keycloak username when the key was created, for display. NULL for a service key. Migration 056
owner_subject TEXT NULL Owner's Keycloak user id (sub) — the identity the key acts as, so a renamed user keeps their keys. NULL for a service key; indexed. Migration 056
created_at TIMESTAMPTZ NOT NULL Default now()
last_used_at TIMESTAMPTZ NULL
expires_at TIMESTAMPTZ NULL NULL = never expires; an expired key is refused

Check api_keys_owner_complete: owner and owner_subject are both set or both NULL. Keys that existed before migration 056 have neither and are service keys.

organization_grants

Organization-level access control. A grant ties a Keycloak principal to one organization and confers full access to it and everything beneath it — projects, tasks, epics, milestones, task groups and comments. There are no finer-grained permissions by design.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
principal_type TEXT NOT NULL user (Keycloak username) or group (Keycloak group name)
principal TEXT NOT NULL Non-empty; the username or group name
created_at TIMESTAMPTZ

Unique on (organization_id, principal_type, principal); indexed on (principal_type, principal) for the per-request "which organizations can this caller reach" lookup.

Global admins are not stored here — they are configured out of band via the TASKBASE_ADMIN_GROUPS environment variable, so an empty table can never lock everyone out. Service API keys likewise bypass grants and reach every organization; a personal key has only its owner's grants.

agent_types

Agent personas (ADR-0005), synced into every organization from the shared agents repository (AGENTS_REPO, default Skatzi/skatzi-agents). A task is handed to one by assignee_type = 2 and assignee = slug; a runner claiming it receives body as the persona.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
slug TEXT NOT NULL Lowercase a-z, 0-9, -; the persona's file name
name TEXT NOT NULL From the persona's frontmatter
description TEXT NOT NULL From the frontmatter. Default ''
body TEXT NOT NULL The persona's markdown, used as the agent's system prompt. Default ''
is_active BOOLEAN NOT NULL False once the persona is removed from the repository. Default true
default_model TEXT NULL Tier or model id used when a task (or, for a session persona, a session turn) names no model. Set in Taskbase, or filled by sync from the persona file's default_model while NULL; sync never overwrites it. A CHECK rejects '' and whitespace. Migration 042
kind TEXT NOT NULL task (default) or session (check constraint), from the persona's optional kind frontmatter key. A session persona only chats in agent sessions and is never given a task: assigning one answers 400, and the claim and the Agent queue pass over it. Migration 058
last_synced_at TIMESTAMPTZ NULL
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

Unique on (organization_id, slug).

organization_roles

An organization's team: one row per task persona whose role someone edited (migration 085, task #1763, ADR-0024). A task persona without a row is a default role: titled with the persona's name, reporting to the people, may_assign NULL, active.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT NOT NULL FK → organizations.id CASCADE delete
slug TEXT NOT NULL The role's own slug, not '' (check organization_roles_slug_check). Migration 091 backfilled it from persona_slug; the BEFORE INSERT trigger organization_roles_default_slug fills it from persona_slug when an insert names none
persona_slug TEXT NOT NULL The role's base persona; several roles may share one (migration 091). FK (organization_id, persona_slug) → agent_types (organization_id, slug), CASCADE delete
title TEXT NOT NULL Not ''
reports_to BIGINT NULL The manager role; FK (organization_id, reports_to) → organization_roles (organization_id, id), so a manager is always in the same organization; no ON DELETE action, so a role others report to cannot be deleted. NULL = the organization's people
may_assign TEXT[] NULL Persona slugs the role's runs may assign tasks to. NULL = any. With the organization's org_chart_v2 switch on, NULL (a default role included) means the role's subtree and every team lead (a role others report to), plus, as before, itself and its manager (role.DefaultMayAssign, task #2840); an explicit list still narrows it
active BOOLEAN NOT NULL False: the role is paused. Default true
repo_read TEXT NULL task, organization or served (check constraint). NULL = the persona's default
mandate TEXT NOT NULL What the role does and how it escalates (ADR-0026). Default ''. Migration 091
owns TEXT NOT NULL The area the role owns. Default ''. Migration 091
decides TEXT NOT NULL What the role may decide on its own. Default ''. Migration 091
updated_at TIMESTAMPTZ NOT NULL Default now()
updated_by TEXT NOT NULL Default ''

Unique on (organization_id, slug) and (organization_id, id); migration 091 dropped the unique key on (organization_id, persona_slug) and added the plain index organization_roles_persona on it, which keeps the foreign key to agent_types fast. Cycles and chains deeper than 3 roles are refused by the API, not by the database (Rules for the tree).

organization_routing_rules

An organization's routing rules (ADR-0026 §2, migration 091, task #2838): work that matches pattern belongs to the role role_slug. Rules apply in position order; see Org Chart v2 routing.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT NOT NULL FK → organizations.id CASCADE delete
position INT NOT NULL Order of the rule
role_slug TEXT NOT NULL A stored role's slug or a persona's default role; not ''. No foreign key, because a default role has no row
kind TEXT NOT NULL repository, path or label (check constraint)
pattern TEXT NOT NULL Not ''
created_at TIMESTAMPTZ NOT NULL Default now()
created_by TEXT NOT NULL Default ''

Unique on (organization_id, position).

decision_gate

The organization's decision record for the decision gate (ADR-0026 §3, migration 093, task #2841, taskbase#718): one row per gate task. With the organization's org_chart_v2 switch on and decision_role set, a person's open decision and a run's needs_person: owner_decision item get a gate task for the gate role, and its verdict is recorded here. Hard limits (every other needs_person reason, legal included; the other people-only reasons; owner-only decisions, tasks.decision_owner_only) go to the owner as before.

Column Type Notes
id BIGSERIAL PK
gate_task_id BIGINT NULL FK → tasks.id The gate task. Unique. SET NULL on delete, so the record outlives its gate task
task_id BIGINT NOT NULL FK → tasks.id The task whose item asked for the decision. CASCADE delete
organization_id BIGINT NOT NULL FK → organizations.id CASCADE delete
gate_role TEXT NOT NULL The gate role's slug when the gate task was made
gate_title TEXT NOT NULL The gate role's title when the gate task was made
question TEXT NOT NULL
options TEXT[] NOT NULL Default '{}'
verdict TEXT NULL decided or forward (check constraint). NULL while the gate works on it
answer TEXT NULL Set with decided
reason TEXT NULL Set with decided
policy_line TEXT NULL Set with decided
recommendation TEXT NULL Set with forward
uncovered TEXT NULL Set with forward: why the policy did not cover the decision
run_id BIGINT NULL FK → task_runs.id SET NULL on delete
decided_at TIMESTAMPTZ NULL
policy_added TEXT NULL The line the owner added to the gate role's mandate from a forward
policy_added_at TIMESTAMPTZ NULL
policy_added_by TEXT NULL
created_at TIMESTAMPTZ NOT NULL Default now()

Indexes decision_gate_task on (task_id, created_at DESC) and decision_gate_organization on (organization_id, created_at DESC). Sources, read 2026-11-12: api/internal/migrations/000093_decision_gate.up.sql and the api/internal/decisiongate/ bullet of Taskbase's CLAUDE.md, both at the merge of taskbase#718.

runners

Machines running agent-runner (ADR-0006). Created in the control room, then registered by the runner, which logs in as the ordinary Keycloak user recorded as principal.

Column Type Notes
id BIGSERIAL PK
name TEXT NOT NULL UNIQUE Registration key
principal TEXT NOT NULL Keycloak username allowed to register as this runner
version TEXT NOT NULL Runner release, e.g. v0.4.0. Default ''
update_mode TEXT NOT NULL self (default) or image (version managed by the container image); check constraint. Migration 055
os TEXT NOT NULL Default ''
arch TEXT NOT NULL Default ''
labels TEXT[] NOT NULL From the runner's config plus os=/arch=. Default '{}'
slots INTEGER NOT NULL Concurrent runs, as the runner reports them. Default 1
slots_setting INTEGER NULL The number of slots set in Taskbase (ADR-0011 decision 1), 1–64 (check constraint). Claims use it over slots, and the heartbeat response sends it to the runner; NULL uses the slots the runner reports. Set with PUT /api/runners/{id}/slots (Runners and Runs). Migration 046
slots_source TEXT NOT NULL Where the runner says its slots came from: taskbase or config; empty from runners that predate it. Default ''. Migration 046
scope TEXT NOT NULL instance (claims from every organization) or organization (only those in runner_organizations). No default
adapters JSONB NOT NULL As reported by the runner: [{name, provider, subscription?, hold?, models: [{id, tiers}]}]; hold is {reason, detail, until?} (ADR-0006). Optional subscription defaults to the adapter name when omitted. Commands and credentials stay runner-local. Default '[]'
default_model TEXT NOT NULL Tier or model id used for tasks with no model. Default ''
dedicated_label TEXT NOT NULL One of labels; when set, the runner claims only tasks that require it (e.g. role=reviewer). Default ''
limits JSONB NOT NULL Its subscriptions' limits as the provider last reported them: [{subscription, provider, status, as_of, limited_until, use_first?, windows: [{name, length_seconds, used, resets_at, spent_usd?, credit_usd?}]}] (ADR-0008). use_first (bool) is stored only when true; spent_usd (≥ 0) and credit_usd (> 0) are dollars, stored only when reported, e.g. on a Claude API key's credit window, which is stored with length_seconds 0 (Runners and Runs). No migration: added in Taskbase PR #588. Default '[]'
caps JSONB NOT NULL Usage caps set by the runner's owners or an administrator, per subscription name: {"<subscription>": {session_max, week_max}}, each null or a whole percentage 1–100. A subscription without caps has no key. Holds the subscription at claim time once a window reaches its cap (Runners and Runs). Default '{}'. Migration 034
model_overrides JSONB NOT NULL Models and tiers the runner's owners or an administrator set in Taskbase, per adapter name, replacing those in the runner's agent-runner.yaml: {"claude": [{"id": "claude-opus-5-5", "tiers": ["medium", "large"]}]}. An adapter without a key uses the runner's config. Sent to the runner, which reports the models it then uses in adapters; claims match on those (Runners and Runs). Default '{}'. Migration 038
target_version TEXT NULL Per-runner target release override, e.g. v0.6.0; NULL follows runner_settings.target_runner_version for self runners. Ignored for image runners (Runners and Runs). Migration 030
reported_state TEXT NOT NULL idle, busy, draining or updating, from the heartbeat. Default idle
desired_state TEXT NOT NULL running, paused or draining, set in the control room. Default running
last_seen_at TIMESTAMPTZ NULL Online when under 3 minutes old (runner.OnlineWindow)
update_error JSONB NULL The runner's last failed self-update as it reported it on register or heartbeat: {version, error, retry_at}; NULL when its latest report had none. An image runner's reported error is discarded and stored as NULL (Runners and Runs). Only a self runner raises runner.update_failed when version is its effective target (Attention). Migration 040
session_turns BOOLEAN NOT NULL Whether the runner reports that it answers session turns (Agent Sessions), from registration and heartbeat. Default false. Migration 060
session_slots INTEGER NULL Session turns at once, set in Taskbase with PUT /api/runners/{id}/session-slots, 0–64 (check constraint); separate from slots. NULL = 1 for a runner with session_turns; 0 keeps the runner out of sessions. Sent to the runner in the heartbeat response (Runners and Runs). Migration 060
machine JSONB NULL The load of the runner's machine as its latest register or heartbeat reported it: {"load": [1m, 5m, 15m], "cpus", "memory_free_pct", "disk_free_bytes", "disk_total_bytes", "as_of"}, every key optional; NULL when the latest report had none (Runners and Runs). Migration 049
features TEXT[] NOT NULL Optional abilities the runner reported in its latest registration or heartbeat, such as claude_api_remote (Runners and Runs). Default '{}'. Migration 081
claude_api_state JSONB NULL The runner's applied Claude API state; NULL when it reports no key or does not report the field. Migration 082
claude_api_state_at TIMESTAMPTZ NULL Taskbase's time when the reported state last changed; NULL while the runner does not report one. Migration 082
created_at TIMESTAMPTZ

runner_settings

Instance-wide runner settings: a single row (id = 1, enforced by a check), inserted by its migration and never inserted or deleted again (migration 027).

Column Type Notes
id SMALLINT PK Always 1
target_runner_version TEXT NULL Default target release for every self runner without its own target_version (Runners and Runs). NULL = no target

runner_organizations

The organizations an organization-scoped runner claims from. Instance runners have no rows.

Column Type Notes
runner_id BIGINT FK → runners.id CASCADE delete
organization_id BIGINT FK → organizations.id CASCADE delete

Primary key (runner_id, organization_id); indexed on organization_id. Deleting an organization can leave a runner with no rows, and it then claims nothing.

runner_owners

The Keycloak users who may change and operate a runner, besides global administrators (Runners and Runs). Migration 052; runners that existed before it have no rows until an administrator adds owners.

Column Type Notes
runner_id BIGINT FK → runners.id CASCADE delete
username TEXT NOT NULL Keycloak username; never '' (check constraint)
added_by TEXT NOT NULL Who added the owner: a username, or api-key
added_at TIMESTAMPTZ NOT NULL Default now()

Primary key (runner_id, username).

task_runs

One attempt at a task by a runner. Active while outcome is NULL, holding a lease that heartbeats renew.

Column Type Notes
id BIGSERIAL PK
task_id BIGINT FK → tasks.id CASCADE delete
role TEXT NOT NULL implementation or review; review runs are recorded on the original task
review_round INTEGER NULL Review round number for a review run
runner_id BIGINT FK → runners.id NULL SET NULL on delete, so history outlives the runner
adapter TEXT NOT NULL Adapter the runner launched, e.g. claude. Default ''
model TEXT NOT NULL Model the run used, resolved at claim time, e.g. claude-haiku-4-5. Default ''
started_at TIMESTAMPTZ NOT NULL
lease_expires_at TIMESTAMPTZ NOT NULL An active run past this is marked lost
finished_at TIMESTAMPTZ NULL Set exactly when outcome is
outcome TEXT NULL succeeded, failed, cancelled or lost. NULL while active
summary TEXT NOT NULL Default ''
pr_url TEXT NULL
pr_unlinked BOOLEAN NOT NULL DEFAULT false Set when an implementation run records a Gitea PR in a disallowed repository; it does not qualify for review, but pr_url is retained for attention. Migration 000063_run_pr_unlinked
cancel_requested_at TIMESTAMPTZ NULL Set when the control room asks to cancel an active run; sent to the runner in its next heartbeat response
review_verdict TEXT NULL Review runs: approved, changes_requested, blocked, out_of_date or merge_handoff (check task_runs_review_verdict_check; merge_handoff from migration 089, Merge hand-off)
requested_model TEXT NULL What the claim asked for — the task's model (tier or id, shifted by model_escalation) or the runner's default_model — beside model, what it resolved to. It keeps the task's (possibly escalated) tier even when a preferred model ran, so usage grouped by tier still reflects task size
escalated_from TEXT NULL The task's own tier (small or medium) when the claim escalated it; NULL otherwise (ADR-0007)
model_raised_from TEXT NULL The tier the claim raised to the organization's minimum_model: the task's own tier, its persona's default_model or, for a review run, the project's review model. NULL when nothing was raised, and for a model id. With escalation the raise comes first: a small task under a medium minimum, escalated once, asks for large with escalated_from medium and model_raised_from small. NULL on runs from before migration 094
preferred_models TEXT[] NULL The task's preferred_models when the run was claimed (ADR-0014). Empty ('{}') for review runs, because preferences apply to implementation runs only. NULL on runs from before migration 062
model_choice TEXT NULL How the claim chose model: preferred — a preferred model ran; fallback — the task had preferences, but its tier ran; tier — the task had no preferences, or the run is a review. A check constraint allows only these values. NULL on runs from before migration 062 and on runs started without a claim
effort TEXT NULL The task's effort recorded at the claim, for implementation and review runs, so usage can be compared by effort; same check constraint (low, medium, high). NULL when the task had none (runner default) and for runs that predate migration 053
persona TEXT NULL Persona slug captured at claim time: the task's agent assignee for implementation or the project's reviewer for review. Older runs are NULL and usage trends fall back to the current assignment
input_tokens BIGINT NULL Tokens sent to the model, not counting cache reads (ADR-0008)
output_tokens BIGINT NULL Tokens the model generated
cache_read_tokens BIGINT NULL Input tokens served from the prompt cache
cache_write_tokens BIGINT NULL Input tokens written to the prompt cache
turns INTEGER NULL Model turns the agent took
cost_usd NUMERIC(12,6) NULL As the provider reports it; for a subscription an API-equivalent figure
model_usage JSONB NULL The same numbers per model: [{model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost_usd}]
reason TEXT NULL usage_limit on a failed run stopped by a subscription's limit; adapter_unavailable on one stopped by a held adapter (ADR-0006, migration 032); or runner_restart on a failed or cancelled run cut short by its runner shutting down or crashing (ADR-0011 decision 3, migration 045). Each requeues the task without model escalation; usage_limit and runner_restart park it once the task's last three runs all ended with that reason (Runners and Runs). A check constraint allows only these values
digest JSONB NULL Optional immutable handoff digest, written at finish only; bounded neutral fields and provenance. Migration 031
context_reuse JSONB NULL Per-run context reuse measurements: candidate/selected/stale/truncated digest counts, imported tokens, cache-prefix hit when available, and linked-task consultation. Migration 035
queued_at TIMESTAMPTZ NULL When the task last entered the queue before this run claimed it: copied from the task's dispatch_state_changed_at at the claim, capped at started_at (the queue time comes from the database clock, the start from the API's). The run's queue wait is started_at − queued_at. NULL for runs started without a claim, and for runs that predate migration 050, which has no backfill: their wait is unknown, not zero
subscription TEXT NULL The subscription the run uses: set at the claim from the adapter's subscription (its name when it has none), and replaced by the one the runner reports for the active run in a heartbeat. Active runs count 5 percentage points each toward their subscription's session cap (ADR-0011 decision 2, Usage caps). NULL for runs that predate migration 046, which filled it in for the runs active then

A partial unique index on task_id WHERE outcome IS NULL guarantees a task has at most one active run. Active runs are also indexed by lease_expires_at for the expiry sweep. Usage columns are NULL when the runner could not tell — never 0 — and finished_at is indexed for usage over time.

notifications

The attention outbox (ADR-0010, Attention): one row per event that needs a person, written in the same transaction as the state change that causes it. Migration 039.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id NULL CASCADE delete. The task's organization for task events; NULL for runner events, which are visible wherever the runner is
kind TEXT NOT NULL task.needs_attention, task.question, runner.offline, runner.adapter_held or runner.update_failed
task_id BIGINT FK → tasks.id NULL CASCADE delete. Exactly one of task_id and runner_id is set
runner_id BIGINT FK → runners.id NULL CASCADE delete
dedupe_key TEXT NOT NULL E.g. task.needs_attention:task=331:reason=review_blocked; not empty
payload JSONB NOT NULL Ids, reason, one-line detail, verdict, model, PR URL, first open question, adapter, version, the run's options and, once chosen, chosen and chosen_by — never descriptions, digests or secrets. At most 4096 bytes. Default '{}'
state TEXT NOT NULL open or resolved. Default open
created_at TIMESTAMPTZ NOT NULL
resolved_at TIMESTAMPTZ NULL Set exactly when state is resolved
sent_at TIMESTAMPTZ NULL When the notifier first posted the event to any organization; per-organization delivery is in notification_deliveries

A partial unique index on dedupe_key WHERE state = 'open' keeps an open event from being duplicated (writers insert ON CONFLICT DO NOTHING). The trigger tasks_resolve_notifications resolves a task's open events when the task is marked done or its dispatch_state changes to anything but needs_attention, except task.needs_attention events with reason blocking_agent_work or decision_needed, which the person-task triggers on tasks and task_links raise and resolve (tasks). Their payload adds waiting_task_ids (at most 20 ids, which may include tasks of another organization through a cross-organization depends_on) and, for decision_needed, the question. An open decision whose depends_on tasks are not all done has no such event (migration 069). Events with reason decision_unplanned are raised and resolved by the runner sweeper (attention.SyncUnplannedDecisions); the trigger does not skip them. Resolved events are deleted 30 days after resolved_at. The trigger notifications_attention_raised_at dates a task's first event in tasks.attention_raised_at, which outlives the deletion (tasks, migration 075).

A done task has no Needs attention item (task #1310). The writers (attention.openTask) insert no event for a done task, and the list (attention.Store.List) and the town's needs_attention count (organization.Store.Activity) leave out a done task's events. The list leaves them out whether they are open or resolved; the count only counts open events. The only exception is task.needs_attention with reason decision_unplanned (task #1091), which the sweeper raises on a done decision on purpose (attention.KeptOnDoneTask). Migration 076 resolved the events that were still open on done tasks.

organization_mattermost

An organization's Mattermost notice settings, set by an administrator. Migration 043.

Column Type Notes
organization_id BIGINT PK FK → organizations.id CASCADE delete
webhook_ciphertext BYTEA NULL Incoming webhook URL, AES-256-GCM (nonce ‖ ciphertext) with TASKBASE_SECRET_KEY, bound to the organization id. NULL = no webhook. Never returned by the API
webhook_set_at TIMESTAMPTZ NULL When the webhook went from unset to set; older events are not posted. NULL exactly when webhook_ciphertext is
mentions TEXT[] NOT NULL Mattermost usernames mentioned in each notice. Default '{}'
warn_runner_offline BOOLEAN NOT NULL Whether the organization is warned about runner.offline events, in Mattermost and on the attention page (Attention). Default true; an organization without a row warns. Migration 051
updated_at TIMESTAMPTZ NOT NULL

The notifier locks this row (FOR UPDATE SKIP LOCKED) while it posts for the organization.

notification_deliveries

One row per event and organization it is posted to. Migration 043.

Column Type Notes
notification_id BIGINT FK → notifications.id CASCADE delete
organization_id BIGINT FK → organizations.id CASCADE delete
state TEXT NOT NULL pending, sent, dropped (resolved before it was sent) or expired (not sent within 24 hours). Default pending
attempts INT NOT NULL Failed posts so far. Default 0
next_attempt_at TIMESTAMPTZ NOT NULL Default now()
last_error TEXT NULL The last failure, without the webhook URL
sent_at TIMESTAMPTZ NULL

Primary key (notification_id, organization_id); pending rows are indexed by (organization_id, next_attempt_at).

organization_notices

One row per notice posted, for the limit of 10 notices per organization per hour. Migration 043.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete
sent_at TIMESTAMPTZ NOT NULL Indexed with organization_id

diagrams

An organization's architecture diagram: semantic components and the connections between them. Migration 054. The model only changes through atomic op batches; each batch bumps revision and writes a diagram_revisions row. Positions are a separate layer and do not bump it.

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id CASCADE delete; indexed
title TEXT NOT NULL 1–120 characters (check constraint)
description TEXT NOT NULL Markdown. Default ''
revision BIGINT NOT NULL The current revision. Default 0
created_by TEXT NOT NULL Default ''
created_by_run_id BIGINT FK → task_runs.id NULL The agent run that created the diagram. SET NULL on delete
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ

diagram_components

The boxes of a diagram. Migration 054.

Column Type Notes
diagram_id BIGINT FK → diagrams.id CASCADE delete
key TEXT NOT NULL Stable slug agents refer to, matching ^[a-z0-9][a-z0-9-]{0,62}$; never changes
type TEXT NOT NULL group, service, datastore, queue, external, person or note
name TEXT NOT NULL 1–120 characters
parent TEXT NULL Key of a group in the same diagram. Checked by the API (cycles included), not a foreign key, so a batch may rewrite the tree in any order
tech TEXT NOT NULL Default ''
description TEXT NOT NULL Default ''
url TEXT NOT NULL Default ''
project_id BIGINT FK → projects.id NULL SET NULL on delete; partial index where set
linked_diagram_id BIGINT FK → diagrams.id NULL The diagram that details this component (linked diagrams). Migration 071. SET NULL on delete; check diagram_components_linked_diagram_not_self (not diagram_id); partial index where set. The API also requires a diagram of the same organization

Primary key (diagram_id, key).

diagram_connections

Edges between two components of the same diagram. Migration 054.

Column Type Notes
diagram_id BIGINT FK → diagrams.id CASCADE delete
key TEXT NOT NULL Generated by the API when an op omits it
from_key TEXT NOT NULL FK (diagram_id, from_key) → diagram_components; CASCADE delete
to_key TEXT NOT NULL FK (diagram_id, to_key) → diagram_components; CASCADE delete. Differs from from_key (check constraint)
label TEXT NOT NULL Default ''
protocol TEXT NOT NULL Default ''
bidirectional BOOLEAN NOT NULL Default false

Primary key (diagram_id, key). Removing a component removes its connections.

diagram_positions

The layout layer: where each component is drawn. Migration 054. Written on its own (last write wins), not part of any revision; a component without a row is placed automatically.

Column Type Notes
diagram_id BIGINT NOT NULL
component_key TEXT NOT NULL FK (diagram_id, component_key) → diagram_components; CASCADE delete
x DOUBLE PRECISION NOT NULL
y DOUBLE PRECISION NOT NULL
source TEXT NOT NULL auto or manual
updated_at TIMESTAMPTZ NOT NULL Default now()

Primary key (diagram_id, component_key).

diagram_revisions

One row per revision of a diagram's model. Migration 054. Revision 0 is the empty diagram, written on create.

Column Type Notes
diagram_id BIGINT FK → diagrams.id CASCADE delete
revision BIGINT NOT NULL
author TEXT NOT NULL
author_type TEXT NOT NULL person or agent
run_id BIGINT FK → task_runs.id NULL SET NULL on delete
summary TEXT NOT NULL At most 200 characters. Default ''
ops JSONB NOT NULL The ops as applied: generated connection keys filled in, or [{"restore": n}] for a restore
snapshot JSONB NOT NULL The whole model (components and connections) after the ops
created_at TIMESTAMPTZ NOT NULL Default now()

Primary key (diagram_id, revision).

sessions

Interactive agent sessions (ADR-0013, Agent Sessions): one person chatting with a kind = session persona about a subject. Migration 059; sessions about a task (ADR-0015) added in 064 and 065; the chosen runner and model in 067 and general chats in 068 (ADR-0016).

Column Type Notes
id BIGSERIAL PK
organization_id BIGINT FK → organizations.id NULL CASCADE delete; NULL exactly for a general chat (since 068)
project_id BIGINT FK → projects.id NULL CASCADE delete; NULL exactly for a general chat (since 068)
subject_type TEXT NOT NULL project_request, task or general (check)
subject_id BIGINT NULL NULL for a new request and a general chat (sessions_general_subject_check); the task's id for a session about a task, where it is required (sessions_task_subject_check)
persona TEXT NOT NULL Slug of the session persona, default request-builder; attention-helper for a task; assistant for a general chat; not ''
owner_subject TEXT NOT NULL Keycloak subject of the person; a session is private to them (and administrators reading)
owner_username TEXT NOT NULL Default ''
state TEXT NOT NULL open (default), confirmed, abandoned, expired or resolved (check; resolved: the subject task's attention events all resolved another way). closed_at is NULL exactly while open
draft JSONB NOT NULL For a request, the request draft: title, goal, scope {in, out}, acceptance_criteria, constraints, affected (project ids), related ([{type, id, note}]), open_questions. For a task, the action plan: summary, checklist, actions. Default '{}'
draft_revision INTEGER NOT NULL Bumped by each draft save; a save names the revision it is based on. Default 0
result_task_id BIGINT FK → tasks.id NULL The request task filed on confirm; SET NULL on delete
version BIGINT NOT NULL Counts every change a watcher must see; bumped by session_touch(id), compared by the long-poll. Default 1
created_at TIMESTAMPTZ NOT NULL
last_message_at TIMESTAMPTZ NULL An open session without a person message for 24 h expires (creation time when null)
plan_results JSONB NULL A task session's or general chat's result per action, set when its plan is confirmed: [{type, task_id, status, reason, summary, steps, tasks, created}] (created: what a create action made — kind, id, title, organization, project, url, gitea_issue). NULL before and for request sessions
closed_at TIMESTAMPTZ NULL Abandoned, expired and resolved sessions, and confirmed task sessions and general chats, are deleted 30 days after it
runner_id BIGINT FK → runners.id NULL The runner chosen to answer the session's turns; only it claims them. SET NULL on delete. While NULL (none chosen yet, or its runner deleted) no runner claims the session's turns (067)
model TEXT NULL The chosen tier or model id; NULL is the persona's default_model (else the runner's). Not '' (sessions_model_check, 067)

Checks since 068: sessions_general_scope_check CHECK ((subject_type = 'general') = (organization_id IS NULL AND project_id IS NULL)) and sessions_scope_pair_check (both NULL or neither). Indexed on (owner_subject, state), project_id and, for the claim, runner_id where state = 'open' (sessions_runner_open_idx, 067); the unique partial index sessions_open_task_idx on (subject_id, owner_subject) where subject_type = 'task' AND state = 'open' allows one open session per task and person. The triggers notifications_resolve_sessions (an open event resolves) and notifications_delete_resolve_sessions (an open event is deleted) call session_resolve_subject(task_id), which closes the task's open sessions as resolved once it has no open event, and ends their unfinished turns as session_closed. Every write to a session, its messages or its turns calls the SQL function session_touch(id), which bumps version and sends NOTIFY session_updated, which the API's long-polls wait on.

session_messages

A session's transcript: the person's messages and the agent's final replies, in order. No tool calls, tool results or partial text. Migration 059.

Column Type Notes
id BIGSERIAL PK
session_id BIGINT FK → sessions.id CASCADE delete
seq INTEGER NOT NULL 1, 2, …; unique with session_id
role TEXT NOT NULL person, agent or system (check)
body TEXT NOT NULL A person's message is at most 4,000 characters; an agent's reply is masked for secrets
turn_id BIGINT FK → session_turns.id NULL The turn that wrote an agent or system message; NULL for a person's. SET NULL on delete
created_at TIMESTAMPTZ NOT NULL

A partial index on created_at for role = 'person' serves the per-person rate limits.

session_attachments

Images a person attaches to their messages in an agent session (Images in chats). An image is uploaded first, unsent, and bound to the message it is sent with. Migration 087 (task #1787).

Column Type Notes
id BIGSERIAL PK
session_id BIGINT FK → sessions.id CASCADE delete
message_id BIGINT FK → session_messages.id NULL NULL while unsent; set when sent with a message. CASCADE delete
name TEXT NOT NULL File name from the upload's ?name=, at most 200 characters. Default ''
mime TEXT NOT NULL image/png, image/jpeg, image/webp or image/gif (check), sniffed from the bytes
size INTEGER NOT NULL Bytes, greater than 0 (check); at most 5 MB, enforced by the API
sha256 TEXT NOT NULL Hex SHA-256 of data; also the download's ETag
data BYTEA NOT NULL The image
created_by TEXT NOT NULL The uploader's username
created_at TIMESTAMPTZ NOT NULL Default now()

Indexed on session_id, and on message_id where it is not NULL. The sweeper deletes unsent rows older than 24 hours; the rest go with their session.

Why Postgres and not S3. The bytes are kept in bytea because the cluster's CloudNativePG backups already cover them and no new credentials are needed (the migration's header comment and the Taskbase CLAUDE.md, read 2026-10-27).

session_turns

One agent reply: created pending with the person's message, claimed and finished by a runner. Kept apart from task_runs, which needs a task. Usage columns mirror task_runs. Migration 059; migration 060 adds the indexes for running turns and leases.

Column Type Notes
id BIGSERIAL PK
session_id BIGINT FK → sessions.id CASCADE delete
trigger_message_id BIGINT FK → session_messages.id NULL The message the turn answers; SET NULL on delete
state TEXT NOT NULL pending (default), running, succeeded, failed, expired or lost (check). finished_at is NULL exactly while pending or running
runner_id BIGINT FK → runners.id NULL SET NULL on delete
adapter, model, requested_model, subscription TEXT As resolved by the claim, like task_runs; requested_model is the session's chosen model (or the persona's default)
scope_org_ids BIGINT[] NULL The organizations the turn may read, fixed at its claim: the session's organization, or for a general chat the owner's reach ∩ the runner's scope. NULL while unclaimed (cleared on requeue); the turn scope refuses a turn without it (068)
scope_project_id BIGINT NULL The one project the turn may read through project-keyed turn routes, such as the repository routes (ADR 0023, decision #1662). Fixed at its claim: a project_request session's project; a task session's task's project at the moment of the claim, so it follows a moved task (the session's project if the task is gone); NULL for a general session. NULL while unclaimed; a requeue clears it together with scope_org_ids. Those routes refuse a turn without it. No foreign key. Migration 084 filled it in for turns already running (084)
lease_expires_at TIMESTAMPTZ NULL 60 seconds from the claim and from each progress post
attempts INTEGER NOT NULL Claims so far; a turn is tried at most twice
created_at, claimed_at, finished_at TIMESTAMPTZ
partial_text, partial_seq, activity TEXT, INTEGER, TEXT Live view while running (masked), cleared at finish
error TEXT NOT NULL What the person sees when the turn failed. Default ''
reason TEXT NULL usage_limit, adapter_unavailable, runner_restart, timeout, unclaimed or session_closed (check)
input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, turns, cost_usd, model_usage Usage as the runner reported it, as on task_runs

At most one turn per session is pending or running (partial unique index). Indexed on (session_id, id), pending created_at, running runner_id and running lease_expires_at.

user_preferences

A person's own preferences, kept on their account so they follow them to every browser (task #1058). Migration 070. A row exists once the person saved a preference; the API is GET/PUT /api/me/preferences (Settings and theme).

Column Type Notes
subject TEXT PK Keycloak subject (sub) of the person
theme TEXT NULL UI theme id: classic, futuristic, sap, modern-corporate, hacker or scandinavian. Checked by the API (preference.Themes), not by the database. NULL = none chosen
updated_at TIMESTAMPTZ NOT NULL Default now(); set again on every save

deploy_failures

One row per post-merge failure that became a task (migration 074, task #1174): a Flux error event or a failed promote-prod, keyed by where it failed and at which revision. A repeated alert for the same key finds the row and adds no task (Post-merge failures).

Column Type Notes
cluster TEXT NOT NULL The event's metadata.cluster, e.g. hetzner-mgmt
kind TEXT NOT NULL HelmRelease, Kustomization or Promotion
namespace TEXT NOT NULL The failing object's namespace
name TEXT NOT NULL The failing object's name
revision TEXT NOT NULL The event's metadata.revision
task_id BIGINT FK → tasks.id The task made for the failure; CASCADE delete
created_at TIMESTAMPTZ NOT NULL Default now()

Primary key (cluster, kind, namespace, name, revision); indexed on task_id (deploy_failures_task).

incidents

One row per Alertmanager alert group, pointing at the group's incident task (migration 078, task

1337, Incidents from Alertmanager). The webhook reads a cluster's rows to decide

whether a notification refreshes, reopens, closes or creates an incident, and the task's incident object is read from its own or umbrella row.

Column Type Notes
cluster TEXT NOT NULL groupLabels.cluster
alertname TEXT NOT NULL groupLabels.alertname; empty on an umbrella row
namespace TEXT NOT NULL groupLabels.namespace; empty on an umbrella row
component TEXT NOT NULL groupLabels.component, else the namespace; empty on an umbrella row
task_id BIGINT NOT NULL FK → tasks.id The key's incident task, or the umbrella task for a member; CASCADE delete
role TEXT NOT NULL own (the key has its own task), umbrella (the cluster's "Incident storm" task) or member (a key listed on the umbrella)
severity TEXT NOT NULL critical or warning (checked by the API, not the database)
status TEXT NOT NULL firing or resolved, as Alertmanager last said
fingerprints TEXT[] NOT NULL The fingerprints of the group's firing alerts in the last notification, emptied by a resolved one. On a closed incident, the alerts it was closed with (repeat). Default '{}'
first_seen TIMESTAMPTZ NOT NULL The key's first firing notification
last_seen TIMESTAMPTZ NOT NULL Its latest firing notification
fire_count INT NOT NULL Firing notifications so far. Default 1
alertmanager_url TEXT NOT NULL The notification's externalURL. Default ''
opened_at TIMESTAMPTZ NOT NULL When the task was created or last reopened for the key; a run started since then keeps a resolved incident open
reopened_at TIMESTAMPTZ[] NOT NULL Every reopen. Default '{}'
flapping BOOLEAN NOT NULL Set by the second reopen within 24 h. Default false

Primary key (cluster, alertname, namespace, component), so a key has one row; when the key gets a new task, the row is overwritten and points at it. Indexed on task_id (incidents_task).

attention_triage

One row per triage task that Taskbase made for a task's open Needs attention item (migration 079, task #1457, Triage up the reporting line). Migration 086 (task #1767) added the columns that track an item's climb up the reporting line. The loop guard reads it: a task with an open triage task, or with 6 rows (task.MaxTriagesPerTask, 3 before task #1767), gets no new one, and an organization's open triage tasks are counted through it.

Column Type Notes
triage_task_id BIGINT PK FK → tasks.id The triage task; CASCADE delete
task_id BIGINT NOT NULL FK → tasks.id The task it triages; CASCADE delete
created_at TIMESTAMPTZ NOT NULL Default now()
level SMALLINT NOT NULL Default 1; the item's level in the climb, 1 for the first
chain_start BIGINT NULL The climb's first triage task; NULL means this row's own. No foreign key
task_assignee TEXT NULL The triaged task's persona when the row was created, used to spot a bounce
ended_at TIMESTAMPTZ NULL Set when the climb ends with the people after this level
end_reason TEXT NULL Why the climb ended; the values are listed under One level up

Indexed on task_id (attention_triage_task). Deleting a triage task deletes its row, so it no longer counts towards the task's 6 triages.

incident_reports

One row per DR run report a runner filed as an incident task (migration 080, task #1463, ADR 0020 §6), so a retried call returns the same task (POST /api/runners/{id}/incidents).

Column Type Notes
runner_id BIGINT NOT NULL FK → runners.id The runner that filed the report; CASCADE delete
client_key TEXT NOT NULL The request's key, the report's file name
task_id BIGINT NOT NULL FK → tasks.id The incident task made for the report; CASCADE delete
created_at TIMESTAMPTZ NOT NULL Default now()

Primary key (runner_id, client_key); no other index.

runner_claude_api

A runner's Claude API key and settings set from Taskbase (migration 081, task #1666, Runners and Runs). One row per runner; no row when no key was set from Taskbase.

Column Type Notes
runner_id BIGINT PK FK → runners.id CASCADE delete
generation BIGINT NOT NULL The latest change; default nextval('runner_claude_api_generation'), and every change and removal takes the next value. The sequence never repeats, so an acknowledgement of a deleted row's change cannot match a later one
state TEXT NOT NULL pending, active, rejected, expired or removing (check constraint)
reason TEXT NULL Why the runner rejected the change (at most 512 bytes), or why the key expired
key_sealed BYTEA NULL The key, AES-256-GCM (nonce ‖ ciphertext) with TASKBASE_SECRET_KEY, bound to the runner id. Set until the runner applies or rejects the generation, the key expires after 7 days, or it is removed; then NULL. Never returned by the API except to that runner's heartbeat
key_last4 TEXT NOT NULL The key's last 4 characters
key_set_at TIMESTAMPTZ NOT NULL When the key was set; the 7 days count from here
key_on_runner BOOLEAN NOT NULL The runner applied a key from Taskbase that has not been removed since. Default false
credit_usd DOUBLE PRECISION NULL Credit in dollars, > 0 (check constraint)
expires DATE NULL The last day the credit may be used
use_first BOOLEAN NOT NULL Default false
updated_by TEXT NOT NULL Who made the latest change
updated_at TIMESTAMPTZ NOT NULL
acknowledged_at TIMESTAMPTZ NULL When the runner last applied or rejected a change

No index besides the primary key.

routines

A project's recurring task: a task template created on a cron schedule (migration 083, task #1737, Routines). The API reads the template columns as one template object.

Column Type Notes
id BIGSERIAL PK
project_id BIGINT NOT NULL FK → projects.id CASCADE delete
name TEXT NOT NULL At most 200 characters (checked by the API)
schedule TEXT NOT NULL Five-field cron expression
timezone TEXT NOT NULL IANA time zone the schedule is read in
active BOOLEAN NOT NULL false while paused. Default true
title TEXT NOT NULL Template title; {date} becomes the date the task is created, in the routine's time zone
description TEXT NOT NULL Template description. Default ''
assignee TEXT NULL Template assignee, as tasks.assignee
assignee_type SMALLINT NULL 1=user 2=agent
model TEXT NOT NULL Template model, tier or id. Default ''
required_labels TEXT[] NOT NULL Template required labels. Default '{}'
priority SMALLINT NOT NULL 0–3. Default 0
epic_id BIGINT FK → epics.id NULL SET NULL on delete
milestone_id BIGINT FK → milestones.id NULL SET NULL on delete
skip_if_active BOOLEAN NOT NULL Skip a slot while the last task is open. Default true
create_gitea_issue BOOLEAN NOT NULL Give each task a Gitea issue. Default false
next_run_at TIMESTAMPTZ NULL The next slot; NULL while paused
last_run_at TIMESTAMPTZ NULL When the routine last created a task
last_task_id BIGINT FK → tasks.id NULL The newest task it created. SET NULL on delete
created_by TEXT NOT NULL Username of the person who created it. Default ''
created_at TIMESTAMPTZ NOT NULL
updated_at TIMESTAMPTZ NOT NULL

Indexes: routines_project on (project_id), and routines_due on (next_run_at) WHERE active for the scheduler's due query.

Migration history

# Migration Notes
001 create_tasks Initial tasks table
002 add_projects projects table + project_id on tasks
003 add_task_groups task_groups table + group_id on tasks
004 add_task_priority priority column on tasks
005 add_task_assignee assignee, assignee_type columns on tasks
006 add_organizations organizations table + organization_id on projects
007 fix_org_cascade Correct cascade behaviour on org delete
008 add_milestones milestones table + milestone_id on tasks
009 add_api_keys api_keys table
010 add_epics epics table + epic_id on tasks
011 add_gitea_fields gitea_org on organizations, gitea_repo on projects, gitea_issue_number on tasks
012 add_webhook_tables task_comments table + Gitea webhook bookkeeping
013 add_organization_grants organization_grants table — per-organization access control
014 add_runners_and_runs runners and task_runs tables; required_labels and dispatch_state on tasks (ADR-0006)
015 add_runner_scope scope on runners and the runner_organizations table
016 add_models model on tasks and task_runs; adapters and default_model on runners
017 add_run_cancel_request cancel_requested_at on task_runs
018 add_agent_types agent_types table (ADR-0005 personas)
019 add_agent_review review settings on projects, review links on tasks, review_verdict on task_runs, dedicated_label on runners (ADR-0007)
020 add_run_usage token usage and requested_model on task_runs (ADR-0008)
021 add_runner_limits limits on runners, reason on task_runs, index on task_runs (task_id) (ADR-0008)
022 review_runs_on_original_task role and round on task_runs; existing review-task runs are marked as reviews
023 add_blocked_review_verdict widens the review_verdict check constraint on task_runs to allow blocked
024 add_dispatch_reason Nullable dispatch_reason on tasks, set by the claim-time review-persona assignment guard
025 add_model_escalation model_escalation on tasks, escalate_models on projects, escalated_from on task_runs (ADR-0007)
026 add_run_persona Nullable persona on task_runs, captured at claim time so later reassignment does not change usage history
027 add_runner_settings Singleton runner_settings table with the default target runner version (ADR-0006, Self-update)
028 task_done_at done_at on tasks, indexed; backfilled for tasks already done (ADR-0008)
029 task_complexity_points complexity_points on tasks, 1–13 (ADR-0008)
030 runner_target_version Nullable per-runner target_version override on runners
031 run_digests Immutable digest JSONB on task_runs, with a size constraint and database trigger
032 adapter_unavailable Widens the task_runs.reason check constraint to allow adapter_unavailable (ADR-0006)
033 task_board_paging Indexes on tasks for per-column board paging: project_id, (group_id, updated_at), and the Done column's done_at order
034 runner_subscription_caps caps JSONB on runners — per-subscription session_max and week_max
035 context_reuse Context reuse measurement JSONB on task_runs
036 task_links task_links table, and created_by_run_id on tasks (ADR-0009)
037 dispatch_state_time dispatch_state_changed_at on tasks, kept by a trigger
038 runner_model_overrides model_overrides JSONB on runners — per-adapter models and tiers set in Taskbase
039 notifications notifications table (attention outbox) and the trigger that resolves task events (ADR-0010)
040 runner_update_error update_error JSONB on runners — the runner's last failed self-update
041 reassert_run_digest_guard Re-creates the run digest trigger function as migration 031 defines it (once a run has an outcome, its digest is final), repairing databases that ran a draft of 031 that only froze a digest after it was set. No schema change
042 agent_type_default_model default_model TEXT NULL on agent_types, per-persona override for task model resolution
043 mattermost_notices organization_mattermost, notification_deliveries and organization_notices tables (ADR-0010)
044 project_requests kind and requested_by on tasks; created_by_run_id on epics and milestones; their indexes (project requests)
045 runner_restart Widens the task_runs.reason check constraint to allow runner_restart (ADR-0011 decision 3)
046 runner_slots slots_setting and slots_source on runners, subscription on task_runs, backfilled for active runs (ADR-0011 decisions 1, 2 and 7)
047 blocking_agent_work Triggers that raise and resolve blocking_agent_work events on a person's task that an open agent task depends_on, and move it to Blocked and back to Backlog; resolve_task_notifications() skips these events. Flags the tasks that already block agent work
048 decision_tasks decision_question, decision_options and decision_answer on tasks with the tasks_decision_has_question check; person_task_attention() replaces blocking_agent_work() and adds the decision_needed reason; tasks_decision_created trigger; resolve_task_notifications() skips decision_needed too
049 runner_machine machine JSONB on runners — the load of the runner's machine as its latest heartbeat reported it
050 run_queued_at queued_at TIMESTAMPTZ NULL on task_runs — when the task entered the queue before the run claimed it; no backfill
051 warn_runner_offline warn_runner_offline BOOLEAN NOT NULL DEFAULT true on organization_mattermost; the down migration drops it
052 add_runner_owners runner_owners table — the users who may change and operate a runner besides global administrators; no backfill
053 task_effort effort TEXT NULL on tasks and on task_runs, each with a check allowing low, medium and high; no backfill
054 architecture_diagrams diagrams, diagram_components, diagram_connections, diagram_positions and diagram_revisions tables; the down migration drops them
055 runner_update_mode runners.update_mode TEXT NOT NULL DEFAULT 'self', checked to allow only self or image
056 api_key_owner owner and owner_subject TEXT NULL on api_keys, with the api_keys_owner_complete check and an index on owner_subject; existing keys stay service keys. The down migration deletes personal keys so none become service keys
057 add_out_of_date_review_verdict widens the task_runs_review_verdict_check constraint to approved, changes_requested, blocked and out_of_date (ADR-0007); the down migration rewrites out_of_date rows to changes_requested
058 agent_type_kind agent_types.kind TEXT NOT NULL DEFAULT 'task', checked to task or session (ADR-0013)
059 agent_sessions sessions, session_messages and session_turns tables (at most one unfinished turn per session) and the session_touch() function that bumps a session's version and notifies session_updated
060 session_turn_runners runners.session_turns BOOLEAN and runners.session_slots INTEGER NULL (0–64), and indexes on running turns by runner and lease
061 task_preferred_models tasks.preferred_models TEXT[] NOT NULL DEFAULT '{}' (ADR-0014)
062 run_model_choice task_runs.preferred_models TEXT[] NULL and task_runs.model_choice TEXT NULL, checked to preferred, fallback or tier; no backfill (ADR-0014)
063 run_pr_unlinked task_runs.pr_unlinked BOOLEAN NOT NULL DEFAULT false; disallowed cross-repository PRs are retained as links but excluded from review dispatch
064 session_task_subject Sessions about a task (ADR-0015): the sessions_task_subject_check check (a task session has its subject_id), state resolved, the unique index sessions_open_task_idx, session_resolve_subject() and its triggers on notifications. Also fixes resolve_task_notifications() from 048, which left events without a reason (every task.question) open after their task was requeued or done. The down migration deletes task sessions and restores the old function
065 session_plan_results sessions.plan_results JSONB NULL: a confirmed action plan's result per action; the down migration drops it
066 done_column_backfill One-off data fix (task #927): every done task not in its project's Done column moves there. No schema change; the down migration is a no-op because the previous column is not recorded
067 session_runner_choice sessions.runner_id BIGINT NULL FK → runners (SET NULL) and sessions.model TEXT NULL (not ''), and the index sessions_runner_open_idx on open sessions' runner (ADR-0016, task #983). No backfill: existing sessions get the owner's default runner on their next message. The down migration drops both columns and the index
068 session_general_subject General chats (ADR-0016, task #984): sessions.organization_id and project_id nullable, subject type general, the checks sessions_general_scope_check ((subject_type = 'general') = (organization_id IS NULL AND project_id IS NULL)), sessions_scope_pair_check and sessions_general_subject_check (no subject_id); session_turns.scope_org_ids BIGINT[] NULL, backfilled for running turns with their session's organization. The down migration deletes general sessions (their messages and turns cascade), drops scope_org_ids and the checks, and restores NOT NULL and the two-subject check
069 decision_answerable Raise a decision only once it is answerable (task #1014): the SQL function decision_waiting_for(task_id); person_task_attention() raises no event for an open decision while it returns any id; the trigger tasks_decision_prerequisite (AFTER UPDATE OF done) re-evaluates the open decisions that depends_on the task; task_links_blocking_agent_work() also re-evaluates the link's source. The up migration withdrew the events of decisions that were waiting. The down migration restores the functions of migration 048 and gives those decisions their events back
070 user_preferences user_preferences table — a person's UI theme kept on their account (task #1058); no backfill. The down migration drops the table
071 diagram_component_links diagram_components.linked_diagram_id BIGINT NULL FK → diagrams (SET NULL), the check diagram_components_linked_diagram_not_self and the partial index diagram_components_linked_diagram (task #1092). The down migration drops the column
072 decision_answered_at tasks.decision_answered_at TIMESTAMPTZ NULL, the trigger tasks_decision_answered_at that sets it when decision_answer is set or changes and clears it with the answer, a backfill from each answered task's latest resolved decision_needed event, and the partial index tasks_decision_answered_at on answered, done tasks (task #1091). The down migration drops the index, trigger, function and column
073 dependency_update_tasks Renovate dependency tasks (task #102): tasks.kind may be dependency_update; tasks.dependency JSONB NULL, the check tasks_dependency_kind, the unique partial index tasks_dependency_open and the index tasks_dependency_pull_request. The down migration turns dependency tasks into ordinary tasks (kind task) and drops the column, indexes and check
074 deploy_failures deploy_failures table — one task per post-merge failure (task #1174). The down migration drops the table; the failure tasks stay as ordinary tasks
075 task_attention_raised_at tasks.attention_raised_at TIMESTAMPTZ NULL, the function tasks_attention_raised_at() and the trigger notifications_attention_raised_at (AFTER INSERT ON notifications) that set it on a task's first event, and a backfill from the earliest kept event per task (task #1177). The down migration drops the trigger, function and column
076 resolve_done_task_events One-off: resolves every open notifications event whose task is done, except task.needs_attention with reason decision_unplanned (task #1310). No schema change; the down migration does nothing
077 task_gitea_issue_closed tasks.gitea_issue_closed BOOLEAN NULL, the state the issue reconciler last saw the task's issue in, and the function and trigger tasks_gitea_issue_changed that reset it to NULL when gitea_issue_number changes, unless the same write sets it (task #1383). No backfill. The down migration drops the trigger, function and column
078 incidents Alertmanager incidents (task #1337, ADR 0018 §3): tasks_kind_check widened to allow incident, and the incidents table with its index incidents_task. The down migration drops the table and turns incident tasks into ordinary tasks (kind task)
079 attention_triage attention_triage table — ties each triage task to the task it triages (task #1457). The down migration drops the table; the triage tasks stay as ordinary tasks
080 incident_reports incident_reports table — one incident task per runner and DR run report key (task #1463, ADR 0020 §6). The down migration drops the table; the tasks stay
081 runner_claude_api runners.features TEXT[] NOT NULL DEFAULT '{}', the sequence runner_claude_api_generation and the runner_claude_api table (task #1666). The down migration drops the table, the sequence and the column, so keys and settings set from Taskbase are lost; those already on runners stay there
082 runner_claude_api_state runners.claude_api_state JSONB and runners.claude_api_state_at TIMESTAMPTZ, both nullable (task #1673). The down migration drops both columns
083 routines The routines table with its indexes routines_project and routines_due, and tasks.created_by_routine_id BIGINT NULL with the partial index tasks_created_by_routine, deliberately without a foreign key so it outlives a deleted routine (task #1737). The down migration drops the column and the table
084 session_turn_scope_project session_turns.scope_project_id BIGINT NULL (ADR 0023, task #1755), backfilled for running turns with their session's project, or the task's project for a session about a task (the session's project if the task is gone). No foreign key. The down migration drops it
085 organization_roles The organization_roles table and organizations.agents_paused_at and agents_paused_by (task #1763). The down migration drops them
086 triage_escalation attention_triage.level SMALLINT NOT NULL DEFAULT 1 and chain_start, task_assignee, ended_at and end_reason, all nullable (task #1767). The down migration drops the five columns, so the climb's levels and end reasons are lost; the triage tasks and their rows stay
087 session_attachments The session_attachments table with its indexes session_attachments_session and the partial session_attachments_message (task #1787). The down migration drops the table, so every attached image is lost; the messages stay
088 task_attachments The task_attachments table and its four indexes (task #1828). The down migration drops the table, deleting all task and comment images
089 add_merge_handoff_review_verdict widens the task_runs_review_verdict_check constraint to add merge_handoff (Merge hand-off, task #2422). The down migration rewrites merge_handoff rows to blocked
090 add_task_start_after tasks.start_after TIMESTAMPTZ NULL (Start after, task #2405, taskbase#689). Existing tasks get NULL, so none waits
091 org_chart_v2 Org Chart v2 data (ADR-0026 §1–§3, task #2838, taskbase#712), expand-only: organization_roles.slug backfilled from persona_slug, with the trigger organization_roles_default_slug, the check organization_roles_slug_check and the unique key on (organization_id, slug); the unique key on (organization_id, persona_slug) replaced by the index organization_roles_persona; organization_roles.mandate, owns and decides; the organization_routing_rules table; organizations.org_chart_v2, decision_role and dispatcher_role. The down migration drops the new columns and table, points reports to roles of their own (slug <> persona_slug) at the people, deletes those roles, restores the unique key on (organization_id, persona_slug) and drops slug with its trigger
092 task_routed_by tasks.routed_by TEXT NULL: why the Org Chart v2 router gave a task to its role (ADR-0026 §2, task #2840, taskbase#714). Expand-only: existing tasks get NULL. The down migration drops the column
093 decision_gate The decision_gate table, the decision record of the decision gate, and tasks.decision_owner_only BOOLEAN NOT NULL DEFAULT false (ADR-0026 §3, task #2841, taskbase#718). Expand-only: no existing decision is owner-only. The down migration drops the column and the table
094 minimum_model organizations.minimum_model TEXT NULL, checked to small, medium or large; tasks.model_raised_from and task_runs.model_raised_from TEXT NULL; the SQL function model_at_least(model, minimum) and the trigger tasks_minimum_model (BEFORE INSERT OR UPDATE OF model, project_id on tasks), which raises a tier below the organization's minimum and records it (task #2901, taskbase#726). Expand-only: no organization has a minimum, so no task changes. The down migration drops the trigger, both functions and the three columns, so the raise records are lost; raised models stay
095 decision_choices tasks.decision_summary TEXT NULL and tasks.decision_choices JSONB NULL, a decision's summary and structured options (NULL: plain options only), with the check tasks_decision_details_have_question, which keeps both NULL without a question (task #3341, taskbase#740). decision_options keeps the labels. Expand-only: existing decisions get NULL and keep their plain options. The down migration drops both columns, and the check with them, so summaries and choice descriptions are lost; the labels stay in decision_options