# `Aludel.Evals.Metric.Evaluator`
[🔗](https://github.com/ccarvalho-eng/aludel/blob/main/lib/aludel/evals/metric/evaluator.ex#L1)

Normalized execution details for the evaluator behind a metric result.

Deterministic metrics usually record only status and duration. Model-backed
evaluators can also attribute provider, model, token usage, and cost without
mixing that usage with the model output being evaluated.

# `status`

```elixir
@type status() :: :completed | :error | :unavailable
```

# `t`

```elixir
@type t() :: %Aludel.Evals.Metric.Evaluator{
  cost_usd: number() | nil,
  duration_ms: number() | nil,
  error: map() | nil,
  input_tokens: non_neg_integer() | nil,
  model: String.t() | nil,
  output_tokens: non_neg_integer() | nil,
  provider: String.t() | nil,
  status: status()
}
```

# `completed`

```elixir
@spec completed(number(), keyword()) :: t()
```

Records a successfully completed evaluator.

# `error`

```elixir
@spec error(map(), keyword()) :: t()
```

Records an evaluator infrastructure failure.

# `new`

```elixir
@spec new(status(), keyword()) :: t()
```

Creates evaluator details and validates the lifecycle status.

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts evaluator details to a JSON-compatible map, omitting absent values.

# `unavailable`

```elixir
@spec unavailable(map()) :: t()
```

Records an evaluator that could not be resolved or used.

# `with_duration`

```elixir
@spec with_duration(t(), number()) :: t()
```

Adds measured duration when the evaluator did not provide its own timing.

---

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