# `Aludel.Runs`
[🔗](https://github.com/ccarvalho-eng/aludel/blob/main/lib/aludel/runs.ex#L1)

Context for managing runs and run results.

# `change_run`

```elixir
@spec change_run(Aludel.Runs.Run.t(), map()) :: Ecto.Changeset.t()
```

Returns a changeset for tracking run changes.

# `create_run`

```elixir
@spec create_run(map()) :: {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}
```

Creates a new run.

# `create_run_result`

```elixir
@spec create_run_result(map()) ::
  {:ok, Aludel.Runs.RunResult.t()} | {:error, Ecto.Changeset.t()}
```

Creates a new run result.

# `delete_run`

```elixir
@spec delete_run(Aludel.Runs.Run.t()) ::
  {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}
```

Deletes a run.

# `execute_run`

```elixir
@spec execute_run(Aludel.Runs.Run.t(), [Aludel.Providers.Provider.t()]) ::
  {:ok, Aludel.Runs.Execution.t()} | {:error, term()}
```

Executes a run through the executor service and returns a structured outcome.

# `get_run!`

```elixir
@spec get_run!(binary()) :: Aludel.Runs.Run.t()
```

Gets a run by ID, raising if not found.

Preloads run_results and their associated providers, as well as
the prompt through the prompt_version.

# `get_run_result!`

```elixir
@spec get_run_result!(binary()) :: Aludel.Runs.RunResult.t()
```

Gets a run result by ID, raising if not found.

Preloads the associated provider so the result is ready for
rendering without additional database lookups.

# `launch_run`

```elixir
@spec launch_run(Aludel.Runs.Run.t(), [Aludel.Providers.Provider.t()]) ::
  DynamicSupervisor.on_start_child()
```

Launches a run under the executor supervisor.

# `list_recent_runs`

```elixir
@spec list_recent_runs(integer()) :: [Aludel.Runs.Run.t()]
```

Lists the most recent runs with preloaded associations.

Returns up to the specified limit of runs, ordered by insertion
time descending.

# `list_runs`

```elixir
@spec list_runs() :: [Aludel.Runs.Run.t()]
```

Lists all runs in the system.

# `total_cost`

```elixir
@spec total_cost() :: float()
```

Calculates the total cost across all run results and suite runs.

Returns the sum of cost_usd from all run_results plus the summed
per-test costs stored in suite_run results.

# `update_run`

```elixir
@spec update_run(Aludel.Runs.Run.t(), map()) ::
  {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}
```

Updates an existing run.

# `update_run_result`

```elixir
@spec update_run_result(Aludel.Runs.RunResult.t(), map()) ::
  {:ok, Aludel.Runs.RunResult.t()} | {:error, Ecto.Changeset.t()}
```

Updates an existing run result.

---

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