# `H.Task`
[🔗](https://github.com/parlant/harness/blob/v0.3.0/lib/h/task.ex#L1)

Versioned durable task record (`generation`, `tool_call`) and pure state
transitions (`pending`, `running`, `waiting`, `sleeping`, `terminal`).

# `abort`

```elixir
@spec abort(map(), String.t(), integer()) :: map()
```

Transitions a task to `terminal` due to cancellation/abort.

# `complete`

```elixir
@spec complete(map(), map(), integer()) :: map()
```

Transitions a task to `terminal` with an outcome map.

# `from_storage`

```elixir
@spec from_storage(map()) :: map()
```

Normalizes a task loaded from storage.

# `increment_restart`

```elixir
@spec increment_restart(map(), integer()) :: map()
```

Increments `restarts` on unclean crash recovery.

# `new`

```elixir
@spec new(map()) :: map()
```

Constructs a new durable task map.

# `reset_clean`

```elixir
@spec reset_clean(map(), integer()) :: map()
```

Resets a `running` task back to `pending` on clean shutdown without incrementing restarts.

# `sleep_until`

```elixir
@spec sleep_until(map(), integer(), String.t(), integer(), map()) :: map()
```

Transitions a task to `sleeping` until `until_ms`.

# `start_running`

```elixir
@spec start_running(map(), pos_integer(), integer(), map()) :: map()
```

Transitions a task to `running` with a new `attempt_id`.

# `start_waiting`

```elixir
@spec start_waiting(map(), integer(), map()) :: map()
```

Transitions a task to `waiting` (e.g. generation waiting on child tool calls).

# `to_wire`

```elixir
@spec to_wire(map()) :: map()
```

Formats a task for `H.Daemon.get_session_detail/2`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
