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

Summary

Functions

Transitions a task to terminal due to cancellation/abort.

Transitions a task to terminal with an outcome map.

Normalizes a task loaded from storage.

Increments restarts on unclean crash recovery.

Constructs a new durable task map.

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

Transitions a task to sleeping until until_ms.

Transitions a task to running with a new attempt_id.

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

Functions

abort(task, reason, now)

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

Transitions a task to terminal due to cancellation/abort.

complete(task, outcome, now)

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

Transitions a task to terminal with an outcome map.

from_storage(raw)

@spec from_storage(map()) :: map()

Normalizes a task loaded from storage.

increment_restart(task, now)

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

Increments restarts on unclean crash recovery.

new(attrs)

@spec new(map()) :: map()

Constructs a new durable task map.

reset_clean(task, now)

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

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

sleep_until(task, until_ms, wake_reason, now, checkpoint_updates \\ %{})

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

Transitions a task to sleeping until until_ms.

start_running(task, attempt_id, now, checkpoint_updates \\ %{})

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

Transitions a task to running with a new attempt_id.

start_waiting(task, now, checkpoint_updates \\ %{})

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

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

to_wire(task)

@spec to_wire(map()) :: map()

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