# Task

Runs one Verdalia task operation.

- Tag: `task`
- Input socket: `input`
- Output socket: `output`
- Operation fields render against canonical `input`, for example `{{ input.id }}`.
- Operation text fields are configured as text blocks and can interpolate `{{ input.* }}`.

## Operations

- `create`: `title`, `content_markdown`, optional `content_format`, `parent_id`, `blocked_by_json`, `related_json`, `objective_ids_json`, `resources_json`, `importance`, `urgency`, `label_ids_json`, `project_id`, `rank`, `scheduled`, `deadline`, `time_estimate_minutes`, `recurrence_rule`, `recurrence_timezone`, `recurrence_basis`.
- `list`: optional `states`, `importance`, `urgency`, `label_id`, `project_id`, `scheduled`, `deadline`, `scheduled_from`, `scheduled_to`, `deadline_from`, `deadline_to`, `due_from`, `due_to`, `sort`, `direction`, `text`, `limit`, `offset`. Set `scheduled` to `unset` and `states` to `todo,in_progress` to find active tasks without a scheduled date.
- `get`: `task_id`.
- `update`: `task_id`, optional `title`, `content_markdown`, `content_format`, `parent_id`, `blocked_by_json`, `related_json`, `objective_ids_json`, `resources_json`, `importance`, `urgency`, `label_ids_json`, `project_id`, `rank`, `scheduled`, `deadline`, `time_estimate_minutes`, `recurrence_rule`, `recurrence_timezone`, `recurrence_basis`, `state`. Empty `recurrence_rule` clears recurrence when provided.
- `update_state`: `task_id`, `state`. Use for all state transitions: `todo`, `in_progress`, `completed`, or `discarded`. Completing a recurring task advances the same task row to the next occurrence.
- `delete`: `task_id`.

Recurrence fields:

- `recurrence_rule`: RRULE text, for example `FREQ=WEEKLY;BYDAY=MO`.
- `recurrence_timezone`: IANA timezone. Defaults to `UTC`.
- `recurrence_basis`: `scheduled` repeats from the scheduled occurrence; `completion` repeats from completion time.

Schedule fields:

- `scheduled` and `deadline` accept either an RFC3339 datetime for a specific time, or `YYYY-MM-DD`
  for a whole day with no time of day.
- `scheduled` is when the work is meant to be done: an intention, and movable. `deadline` is when it
  must be complete: imposed from outside, and not movable. Neither is "when the thing happens" — a
  task does not happen at a time. Something that must be attended at a set time is a calendar block,
  not a task, and one never substitutes for the other.
- A task carrying a `deadline` normally carries a `scheduled` day comfortably before it. A cut-off
  with nothing scheduled against it gets met by luck.
- A `deadline` comes from a stated date: `sista dagen att hämta är 2026-09-09`, "collect within 14
  days or it is returned", "payment due 10 Sep", "your trial ends 27 Aug". "Act now", "limited time"
  and "don't miss out" are tone, not deadlines, and set nothing.
- Both are coordinates in time expressed in UTC, not readings off a local clock. A caller converts
  the clock a person saw into UTC before setting them, and the calendar converts back to display.
- A schedule naming no time is what places a task in the calendar's all-day row instead of at an
  hour nobody chose. Its clock is stored to the minute; seconds are dropped.

Priority fields:

- `importance` and `urgency` are two independent axes, each `low`, `medium`, `high`, or `critical`.
- `importance` is consequence: if this is never done at all, how bad is that? Money charged
  unintentionally, a parcel returned to sender, a domain lapsing, a person left waiting — high.
  Skippable with nothing lost — low.
- `urgency` is the clock: today or tomorrow is high, within a week or two is medium, further out or
  open-ended is low.

Every corner of the matrix is populated, so neither field predicts the other:

| `importance` | `urgency` | Example                                                                                                |
| ------------ | --------- | ------------------------------------------------------------------------------------------------------ |
| `high`       | `low`     | Pay an invoice due in three weeks. Renew a domain expiring next month.                                 |
| `high`       | `medium`  | Collect a parcel before it is returned to sender — days not hours, but miss the window and it is gone. |
| `low`        | `high`    | Reply about lunch today.                                                                               |
| `low`        | `low`     | Read an article someone sent.                                                                          |

Setting both fields to `medium` is the failure mode: it is what a caller writes when it has not
actually asked either question. Leave a field empty rather than filling it with `medium`.

Subtasks, links and resources:

- Break actionable work into subtasks with `parent_id`. On create, a subtask takes its parent's
  project and comes last among its siblings. On update, a new `parent_id` moves the task to the
  end of the new parent's subtasks and keeps its project. Leave the field blank to keep its
  parent; the node cannot clear it.
- Use `blocked_by_json` for tasks that must finish first and `related_json` for related work.
  Both render to JSON arrays of task ids. On update, leave the field blank to keep the links or
  use `[]` to clear them. Replacing related links applies to links made from either end.
- Use task ids from task results. A write refuses an id that names no task in the table, a
  self-link, a duplicate in a list, or a parent link that makes the task its own ancestor.
- Put design documents and web pages in `resources_json`, a JSON array of resource objects.
  Never put task links in the body. Use body checklists only for steps not worth tracking as tasks.
- Before discarding or deleting a parent, complete, discard, or move each open subtask.
  `update` and `update_state` refuse a transition to `discarded` while any To do or In progress
  subtask exists at any depth; `delete` also refuses. The error names the open subtasks.
  An edit that leaves an already discarded task in that state is allowed.
- Call `load_skill("task-planning")` for the full method.
- `objective_ids_json` renders to a JSON array of objective ids.
- Priority fields use `low`, `medium`, `high`, or `critical`. See Priority fields above for what each means.
- `rank` is the lexicographic planning rank. Prefer planning move APIs unless preserving an existing rank.

## Output

Task records carry `parent_id`, `subtask_rank`, `blocked_by`, and `related`. When present,
`subtask_progress` has `done` (completed direct subtasks) and `total` (direct subtasks excluding
discarded ones).

`get` returns `task` and `relations` on the same output. Read a task field such as `task.title`.
`relations` contains `parent`, `ancestors` (root first), `subtasks` (direct subtasks in sibling
order, in every state), `blocked_by`, `blocking`, `related` (both ends, each task once),
`resources`, and `open_subtask_count` (at all depths). Each linked task includes its `id`,
`title`, and `state`. Each resolved resource has `resource` and `title`; a Library document the
workflow cannot see has a null title.

## Task events

The [Task Event Trigger](/docs/nodes/task_event_trigger) reports changes to `parent_id`,
`subtask_rank`, `blocked_by`, and `related` in `changed_fields`. The event names the task that was
written, not the other end of a link. When closing a parent and its open subtasks, each closed task
gets its own event. Tasks whose links are cleared as part of deleting another task do not get an
event for that cleanup.

## Example

```json
{
  "id": "task-update-state",
  "node": {
    "task": {
      "operation": {
        "op": "update_state",
        "task_id": { "content": "{{ input.id }}" },
        "state": { "content": "completed" }
      }
    }
  },
  "position": { "x": 120, "y": 80 }
}
```
