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.
Summary
Functions
Appends a routing evidence candidate.
Appends several routing evidence candidates.
Marks route evaluation as halted.
Returns true when a router plug halted route evaluation.
Returns true when accepted hard evidence already identifies a runnable route.
Returns true when hard evidence may safely short-circuit later providers.
Stores the canonical privacy-safe arbitration explanation.
Appends an error event.
Replaces the normalized input after enrichment.
Stores non-terminal classifier/cache metadata for downstream plugs.
Stores the current route in context.
Appends a trace event.
Types
@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()] }
Functions
@spec add_candidate(t(), Spectre.Router.Candidate.t()) :: t()
Appends a routing evidence candidate.
context = Spectre.Router.Context.add_candidate(context, candidate)
@spec add_candidates(t(), [Spectre.Router.Candidate.t()]) :: t()
Appends several routing evidence candidates.
context = Spectre.Router.Context.add_candidates(context, candidates)
Marks route evaluation as halted.
Returns true when a router plug halted route evaluation.
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.
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.
Stores the canonical privacy-safe arbitration explanation.
Appends an error event.
@spec put_input(t(), Spectre.Input.t()) :: t()
Replaces the normalized input after enrichment.
Stores non-terminal classifier/cache metadata for downstream plugs.
Stores the current route in context.
Appends a trace event.