# `Spectre.Router.Context`
[🔗](https://github.com/elchemista/spectre/blob/0.3.0/lib/spectre/router/context.ex#L1)

Shared data passed through a Spectre router pipeline.

Router context is intentionally separate from runtime context. It is optimized
for evidence collection: candidate routes, traces, errors, visible labels, and
any input enrichment produced while routing.

# `t`

```elixir
@type t() :: %Spectre.Router.Context{
  arbitration: map() | nil,
  candidates: [Spectre.Router.Candidate.t()],
  errors: [term()],
  halted?: boolean(),
  host_context: map() | nil,
  input: Spectre.Input.t(),
  labels: [atom()],
  local_result: map() | nil,
  opts: keyword(),
  route: Spectre.Route.t() | nil,
  rules: [Spectre.Rule.t()],
  semantic_cache_query_embedding: [float()] | nil,
  traces: [term()]
}
```

# `add_candidate`

```elixir
@spec add_candidate(t(), Spectre.Router.Candidate.t()) :: t()
```

Appends a routing evidence candidate.

    context = Spectre.Router.Context.add_candidate(context, candidate)

# `add_candidates`

```elixir
@spec add_candidates(t(), [Spectre.Router.Candidate.t()]) :: t()
```

Appends several routing evidence candidates.

    context = Spectre.Router.Context.add_candidates(context, candidates)

# `halt`

```elixir
@spec halt(t()) :: t()
```

Marks route evaluation as halted.

# `halted?`

```elixir
@spec halted?(t()) :: boolean()
```

Returns true when a router plug halted route evaluation.

# `hard_candidate?`

```elixir
@spec hard_candidate?(t()) :: boolean()
```

Returns true when accepted hard evidence already identifies a runnable route.

Expensive probabilistic providers can use this to avoid work that cannot
change the default arbitration result. The arbitrator still owns the final
route decision.

# `hard_candidate_locked?`

```elixir
@spec hard_candidate_locked?(t()) :: boolean()
```

Returns true when hard evidence may safely short-circuit later providers.

This optimization is automatic for the built-in arbitrator. Custom
arbitrators retain the complete evidence stream unless they explicitly set
`hard_short_circuit?: true`.

# `put_arbitration`

```elixir
@spec put_arbitration(t(), map()) :: t()
```

Stores the canonical privacy-safe arbitration explanation.

# `put_error`

```elixir
@spec put_error(t(), term()) :: t()
```

Appends an error event.

# `put_input`

```elixir
@spec put_input(t(), Spectre.Input.t()) :: t()
```

Replaces the normalized input after enrichment.

# `put_local_result`

```elixir
@spec put_local_result(t(), map()) :: t()
```

Stores non-terminal classifier/cache metadata for downstream plugs.

# `put_route`

```elixir
@spec put_route(t(), map()) :: t()
```

Stores the current route in context.

# `put_trace`

```elixir
@spec put_trace(t(), term()) :: t()
```

Appends a trace event.

---

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