Task model
The chosen resource model, task statuses, ownership, and access rules for WB-72.
WB-72 uses four persisted resources: Space, Task, TaskItem, and TaskRelationship. These decisions define the backend contract consumed by the WB-5 UI.
The diagrams use database column names; the API exposes them in camelCase, such as organization_id as organizationId. Each diagram expands one table and shows its referenced tables by name. PK marks a primary key and FK a foreign key; nullable fields are noted explicitly.
Space
A space groups tasks. Use finance, support, or growth to select a preset, or null for a custom space. Space names are unique within the owning organization and client business. Unbound spaces share a separate name scope within that organization. The database compares names after trimming leading and trailing spaces and converting to lowercase. The display name keeps its original formatting. See space sharing for how grants determine who can access it.
erDiagram
direction TB
space {
uuid id PK "Space identifier"
uuid user_id FK "User who created the record"
uuid organization_id FK "Active organization at creation"
uuid business_organization_id FK "Optional client business; firm retains ownership"
text name "Required display name"
enum type "finance, support, growth, or null"
text description "Optional context; nullable"
timestamp created_at "Creation time"
timestamp updated_at "Latest update time"
}
user ||..o{ space : creates
organization ||..o{ space : owns
Client business binding
The owning firm stays in organization_id. A nullable business_organization_id identifies the client business whose work the space contains. Creating a bound space accepts businessOrganizationId; PUT /spaces/:spaceId/business can bind an existing unbound space. Both require a current provider_admin or provider_lead membership in the active owning firm, an active business of kind legal_entity or individual, and a current client_of relationship from that business to the firm. Inaccessible businesses and spaces return 404.
The binding is write-once: repeating the same business is idempotent, and attempting another business returns 409. Generic updates cannot clear or change it. Rebinding requires a separately scoped client-data migration. Creator and owning organization remain unchanged. Each client can have a space called Finance under the same firm; names within one client remain unique.
Association grants no access. Existing space/task role and grant checks still apply. Reads and mutations also revalidate the bound business’s active status and current relationship; revocation denies access on the next request. Unbound spaces retain their previous behavior.
Server-side Finance setup uses requireFinanceBusiness(actor, { spaceId }) from domain/organizations/space-business.ts. This boundary additionally requires a Finance preset and returns the firm, business, space, and current relationship IDs. Resource grants alone never authorize setup. A setup operation should retain business and relationship attribution and check it against this boundary before reuse; a recreated relationship is a new authorization context. See conversations and selected sharing for audience-specific discussion around the same space and task.
Task
Task represents an issue in the UI. Each task belongs to one space.
erDiagram
direction TB
task {
uuid id PK "Issue identifier in the UI"
uuid user_id FK "User who created the record"
uuid organization_id FK "Active organization at creation"
uuid space_id FK "Containing space"
text title "Required issue title"
text description "Optional context; nullable"
text[] labels "Free-form labels; default empty"
enum status "ready, in_progress, needs_fixing, done, archived; default ready"
uuid assignee_user_id FK "Assigned user; nullable"
timestamptz due_at "When it is due; nullable"
timestamp created_at "Creation time"
timestamp updated_at "Latest update time"
}
user ||..o{ task : creates
user |o..o{ task : "is assigned to"
organization ||..o{ task : owns
space ||..o{ task : contains
Status has the same value for every viewer. An authorized update to the status field sets it independently of assignment and relationships. The API allows updates between any of the five values. The database default is ready.
due_at is when a task is due: one moment, which each viewer sees on their own clock. Create and update accept dueAt with a UTC offset as an optional field, and leaving it out keeps what is saved; it reads back in UTC. A due date always has a time, and picking a day starts with 5pm. It is part of the task, so a client who can read a shared task sees it.
The task page saves one changed title, description, status, assignee or due date at a time, with its original value as an expected precondition. Other API callers can supply the same optional precondition. The database compares those values atomically with the update. Changes to untouched fields are preserved; a changed field that no longer matches returns 409, and the page asks which value to keep. Unguarded updates retain their existing semantics.
New tasks default to the creating user, matching the list’s default Owner: You filter. Unassigned tasks appear under Owner: Unassigned or Everyone. The Owner picker loads current eligible members of the owning firm and the space’s bound client business. Banned accounts, unrelated clients and memberships without the matching work capability are excluded. The server rechecks eligibility when saving; a user ID alone is insufficient. An operator needs current creation or update authority on the work, and client assignment also requires sharing authority. Clients can read shared tasks and contribute through their Client conversation; they cannot change task status or ownership.
Assigning a client shares the task’s title and description with that person, grants read access to its parent space, and creates or reuses its Client conversation, including its existing history, with reply and upload access. The assignment, conversation and grants commit together; a failed share rolls back the task write. Grants remain scoped to the live client relationship and do not expose Team or private conversations, other tasks, or internal files. Changing the owner preserves existing shares and conversation history; it is not an unshare action. Removing membership or the relationship revokes access under the existing authorization rules.
Finance Wes uses task_assignees to find eligible owner IDs, task_create or task_update to assign the work, and task_link to retrieve its canonical URL and exact Client conversation. On an explicit publication request, client_post sends the task link into the selected Client chat. Task creation and link retrieval do not send a kickoff message by themselves.
The client’s space To-dos tab lists its authorized persisted tasks. A task link opens its page after rechecking that exact task against the actor-scoped directory. Human chat messages make pasted HTTP(S) links clickable while preserving literal text and mentions.
Task status and assignee are independent fields, matching the Paper To-do states design. The API values ready, in_progress, needs_fixing, done, and archived correspond to Ready, In progress, Needs fixing, Done, and Archived. Waiting on a teammate or client is represented by assignment, not a separate status. Run failed, Not delivered, and Reopened are reasons shown under Needs fixing; this API does not yet persist those reasons.
The status migration preserves existing tasks, mapping both legacy open and waiting values to ready. Existing done and archived values and assignees remain unchanged. Waiting alone does not establish that work is in progress.
Follow-up work includes unread flags, hold data, automatic task-state changes from conversations and client replies, and draft revision history with version-bound approval. Free-form labels do not implement these workflows.
The UI’s WorkItem.state describes attention: needs-you, with-owner, with-others, and with-wes identify whom an open to-do waits on. Keep that view separate from persisted Task.status; these attention values are not API workflow statuses. The shared done and archived spellings do not make the two types interchangeable. Connecting the fixture-backed UI requires deriving attention from the viewer, assignment, and future conversation/run data.
Task item
Task items belong to one task. Each item’s content field holds all of its content, including text and markup, for the UI to render.
erDiagram
direction TB
taskItem["task_item"] {
uuid id PK "Content record identifier"
uuid user_id FK "User who created the record"
uuid organization_id FK "Active organization at creation"
uuid task_id FK "Containing task"
text content "Current text content"
integer version "Content revision; starts at 1"
timestamp created_at "Creation time"
timestamp updated_at "Latest content update time"
}
user ||..o{ taskItem : creates
organization ||..o{ taskItem : owns
task ||..o{ taskItem : contains
task_item stores the latest content and its version. Updating an item replaces its content and atomically increments the version on the same record.
When a workflow needs earlier revisions, store snapshots in a separate append-only log table keyed by task item ID and version. Write each snapshot in the same transaction as the item change. For drafts that require approval before sending, capture the exact content and recipients in the snapshot and bind approval to the version the reviewer saw.
Task relationship
A task relationship is a directed, typed connection between two tasks.
erDiagram
direction TB
taskRelationship["task_relationship"] {
uuid id PK "Relationship identifier"
uuid source_task_id FK "Source task; child for subtask_of"
uuid target_task_id FK "Target task; parent for subtask_of"
enum type "subtask_of, blocks, duplicates, relates_to"
timestamp created_at "Creation time"
}
task ||..o{ taskRelationship : "is source of"
task ||..o{ taskRelationship : "is target of"
Subtasks and relationships
A subtask is an ordinary task connected to its parent by subtask_of. For example, “Provide transaction history” points to onboarding as its parent. Listing onboarding’s subtasks returns its immediate children.
Each task has at most one subtask_of parent, and the hierarchy has no cycles. A task with no parent is a root task. Updating the relationship reparents the task while preserving these rules.
The database enforces the single-parent rule with a unique index and checks for cycles on creation, endpoint changes, and type changes to subtask_of. A singleton task_relationship_graph_guard row serializes hierarchy writes so concurrent changes cannot bypass the cycle check. A second parent or a cycle returns HTTP 409, leaving existing relationships intact.
The other relationship types allow multiple links and cycles. All types reject self-links and duplicate source/target/type combinations. Creating a relationship does not move either task to another space or organization.
Ownership and access
user_id identifies the user who created the record. The user may be a person or an agent; every agent must have its own user record.
organization_id identifies the organization on whose behalf that user created the record. It is the user’s active organization at creation time. Spaces, tasks, and task items all take both fields from Actor; HTTP handlers obtain the actor from the authenticated user and session’s active organization. Agents and other trusted callers supply their user record and acting organization to the same domain operations, with the same membership and permission checks.
Developers and AI agents must treat both fields as write-once values. Switching the active organization, editing content, or assigning another user leaves them unchanged. The API excludes them from create and update payloads. Immutability is a development convention; the database does not enforce it.
A space, its tasks, and their items share one owning organization. The database enforces this with composite foreign keys from task (space_id, organization_id) to space (id, organization_id) and from task item (task_id, organization_id) to task (id, organization_id). Deleting either parent cascades to its children.
Updates preserve creator, owning organization, and the containing space or task. Reassigning a task changes only its assignee; it does not transfer ownership or grant access.
The shared API provides create, retrieve, list, update, and delete operations for the four resources, including listing tasks in a space and subtasks of a task. Spaces and tasks documents the routes and detailed permission rules.
WB-72 owns this persisted contract and its enforcement. WB-5 connects the UI to it through the frontend data-fetching layer.
Task visibility
Use access_grant as the source of truth for task visibility, following the space sharing model. Do not add a task.audience column, enum, or other stored visibility label. Derive the UI labels from the recipients of the task’s read grants.
| Label | Read grants on the task |
|---|---|
| Private | A single named user in the owning firm, identified by organization_id and user_id. |
| Team | The owning firm, identified by organization_id with user_id empty. |
| Client | The firm and one or more client organizations, with a separate grant per organization. Each client grant identifies the receiving organization and its client_of relationship to the firm. |
The server creates each new task and its default Team grant in one transaction. Deleting a task or its space removes the associated task grants in the same transaction. A workflow creating a Private task must write its individual grant as part of task creation. Posting a client question should create a separate Client task and link it to the internal parent with subtask_of. The client grants go on the question, and the relationship is readable only to people who can read both tasks.