Task page
Read and edit a single ReCoX or Linear task through one consolidated task-page API.
The task page API exposes one pair of routes (read and write) plus focused mutations for comments, labels, sub-issues, and relations. A caller works with either a ReCoX-native task (native_task:<id>) or a synced Linear task (linear:<id>); the domain layer assembles the same page shape and routes edits to the system that owns the task.
What this API area is for
A task may be native to RecoX or synced from another system. Its identity tells the API which record the caller means, while the route defines the permitted operation.
Console users open one task as a full page: fields, activity, labels, sub-issues, and relationships. The handlers in this module are thin wrappers around the task-page domain: GET only reads the page; PATCH applies every supplied change key and then returns a rebuilt page; each other route applies its one mutation and returns a rebuilt page. Reads do not require console write trust; every mutating handler calls require_console_write_trust on the incoming request before it runs.
Native ReCoX tasks are read and changed in the local database. Linear tasks are read from the archive plus a live Linear fetch when possible. Linear title, description, status, priority, due date, and assignee edits go through task_collab_runtime or task_update_runtime; expected is forwarded for title, description, status, and assignee only; project_key is rejected here; estimate and cycle are not applied to Linear tasks.
Routes
All paths are rooted at /api/tasks/page. The task_key path segment identifies the task (native_task:… or linear:…).
| Method | Path | Permission | Handler | What it does |
|---|---|---|---|---|
| GET | /{task_key} | work.read | get_task_page | Returns the full task page for the given key. |
| PATCH | /{task_key} | work.write | change_task_page | Applies field changes from the body and returns the updated page. |
| POST | /{task_key}/comments | work.write | add_task_comment | Adds a comment on the task. |
| PATCH | /{task_key}/comments/{comment_id} | work.write | edit_task_comment | Updates a native-task comment body. |
| DELETE | /{task_key}/comments/{comment_id} | work.write | delete_task_comment | Soft-deletes a native-task comment. |
| POST | /{task_key}/sub-issues | work.write | add_task_sub_issue | Creates a new sub-issue under the task. |
| PUT | /{task_key}/labels | work.write | change_task_label | Adds or removes one label. |
| POST | /{task_key}/relations | work.write | add_task_relation | Adds a relation between two ReCoX native tasks. |
| DELETE | /{task_key}/relations | work.write | remove_task_relation | Removes the stored row matching source, target, and relation_type, and also the inverse row with source and target swapped. |
| POST | /{task_key}/sub-issues/link-existing | work.write | link_existing_sub_issue | Links an existing native task as a sub-issue. |
| PUT | /{task_key}/sub-issues/{child_key}/replace | work.write | replace_sub_issue | Replaces one linked sub-issue with another task. |
| DELETE | /{task_key}/sub-issues/{child_key} | work.write | unlink_sub_issue | Removes the parent–child sub-issue link. |
| POST | /{task_key}/sub-issues/{child_key}/promote-to-blocker | work.write | promote_sub_issue_to_blocker | Unlinks the sub-issue and records a blocked_by relation from parent to child. |
Request models
Each body model forbids extra keys (extra='forbid').
CommentPayload
| Field | Type | Constraints |
|---|---|---|
body | str | min_length=1, max_length=20000 |
Used by add_task_comment and edit_task_comment.
SubIssuePayload
| Field | Type | Constraints |
|---|---|---|
title | str | min_length=1, max_length=500 |
Used by add_task_sub_issue.
LabelPayload
| Field | Type | Constraints |
|---|---|---|
add | str | None | default=None, max_length=40 |
remove | str | None | default=None, max_length=40 |
Used by change_task_label. The domain layer requires exactly one of add or remove to be set with a non-empty name.
RelationPayload
| Field | Type | Constraints |
|---|---|---|
target_task_key | str | min_length=1 |
relation_type | str | min_length=1 |
Used by add_task_relation. Valid relation types in the domain are blocked_by, blocks, relates_to, and duplicate_of; both tasks must be native ReCoX tasks.
RemoveRelationPayload
| Field | Type | Constraints |
|---|---|---|
target_task_key | str | min_length=1 |
relation_type | str | min_length=1 |
Used by remove_task_relation.
LinkExistingSubIssuePayload
| Field | Type | Constraints |
|---|---|---|
child_task_key | str | min_length=1 |
Used by link_existing_sub_issue.
ReplaceSubIssuePayload
| Field | Type | Constraints |
|---|---|---|
new_child_task_key | str | min_length=1 |
Used by replace_sub_issue. The path supplies child_key for the sub-issue being replaced.
ChangePayload
| Field | Type | Constraints |
|---|---|---|
changes | dict | required |
expected | dict | default {} |
Used by change_task_page. Allowed change keys in the domain are title, description, status, priority, assignee_email, due_date, project_key, estimate, and cycle. For native tasks, expected.version must be an integer when applying changes.
Response model
Successful handlers return a dict produced by task_page.page (after mutations, the same shape refreshed). Common top-level fields include:
| Field | Type | Meaning |
|---|---|---|
task_key | str | Canonical key (native_task:… or linear:…). |
source | str | "native" or "linear". |
key_label | str | Short display id. |
url | str | None | External URL when applicable (Linear). |
title | str | Task title. |
description | str | Task description. |
status | str | Current status. |
priority | str | None | Priority when set. |
assignee | object | None | { "name", "email" } when assigned. |
estimate | number | None | Planning estimate when set. |
cycle | object | None | { "name", "number" } when set. |
due_date | str | None | Due date. |
project | object | None | Project key and name. |
team | str | None | Team name (Linear). |
labels | list | Label objects with id, name, and optional color. |
parent | object | None | Parent task summary when present. |
sub_issues | list | Sub-issues include task_key (null for a Linear child not yet in the archive), key_label, title, status, assignee_name, and due_date. |
relations | list | Related native tasks (native pages only). |
activity | list | Timeline of events and comments. |
version | int | None | Optimistic version for native tasks. |
research | any | Research attachment when present on native tasks. |
editable | dict | Booleans per field indicating what the current caller may edit on the page. |
notes | list | Human-readable caveats (for example stale Linear sync or tasks ReCoX keeps itself). |
Activity items use kind "event" or "comment" with fields such as id, at, actor, icon, text, or comment body and edited.
Behaviour and errors
Task key. After the key is stripped, it is accepted only when it starts with native_task: or linear: and has a non-empty id after that prefix; otherwise the domain raises LookupError with message Unknown task.
Writable checks. Before edits, _writable requires work.write on the caller’s authorization snapshot. For native keys, if the task type’s handler is lab or experiment, lab.write is also required. Failure surfaces as PermissionError with messages such as You do not have permission to edit this task or You do not have permission to comment on this task.
HTTP mapping. Handler helpers map caught ValueError, LookupError, and PermissionError, plus native_tasks.TaskConflict, through _error:
LookupError→ 404PermissionError→ 403TaskConflict→ 409 (detail codeconflict)- Other caught errors → 400 (detail code
invalid)
Detail bodies use error_body with the exception string as the message.
Domain validation. Unknown or empty changes, a missing integer expected.version, invalid native priority, self-relations, bad relation types, blocker cycles, comment text, and label rules raise TaskPageError and map to 400; editing or deleting a Linear comment raises TaskConflict and maps to 409.
Trashed native tasks. Reads and several mutations raise LookupError when the native task is in Trash.
Comment edits. On native tasks, only the comment author or an admin (snap.role == principal.ADMIN) may edit or delete; others get CommentForbidden (PermissionError).
Console route gate. Separately from handler logic, signed-in users pass through gate, which checks ROUTE_PERMISSIONS for the endpoint key. A missing permission entry or a denied policy decision yields HTTP 403 with a denied error payload.
Pydantic. Invalid request bodies fail FastAPI validation before handlers run.
How the permission model applies
route_roles.py lists a ceiling permission per console endpoint. For this module, get_task_page requires work.read; every other handler listed above requires work.write. The table is enforced at startup (require_complete) and per request (gate): a signed-in user whose role does not hold the route permission is refused before the handler runs.
That ceiling does not replace narrower checks inside this module. _writable can deny edits even when work.write passed the gate—for example when a native lab or experiment task also requires lab.write. Mutators can still refuse Linear TaskConflicts and relation rules; a Linear task ReCoX keeps is only marked non-editable on read, and these write functions do not check that flag. Documented route permissions are therefore necessary but not sufficient for every mutation to succeed.
How is this page?
Last updated on