Spectre.Route (Spectre v0.3.0)

Copy Markdown View Source

Normalized routing decision returned by Spectre.

A route is the stable handoff between router and runner. It contains the selected label, handler, strategy, scores, and metadata needed for logging or host decisions.

Summary

Functions

Builds an accepted deterministic route from a compiled rule.

Builds a normalized route struct.

Types

t()

@type t() :: %Spectre.Route{
  accepted?: boolean(),
  confidence: float() | nil,
  core_route: term(),
  definition_injections: [Spectre.Prompt.Operation.t()],
  escalation_reason: String.t() | nil,
  fallback_error: term(),
  flow: atom() | nil,
  handler: Spectre.Rule.handler() | nil,
  injections: [Spectre.Prompt.Operation.t()],
  label: atom() | nil,
  labels: [atom()],
  local: map() | nil,
  margin: float() | nil,
  owner: module() | nil,
  raw: term(),
  rule: Spectre.Rule.t() | nil,
  scope: Spectre.Definition.scope() | nil,
  scores: map(),
  semantic_cache: term(),
  semantic_cache_after: term(),
  semantic_examples: [map()],
  strategy: atom(),
  terminal?: boolean()
}

Functions

from_rule(rule, strategy, raw)

@spec from_rule(Spectre.Rule.t(), atom(), String.t()) :: t()

Builds an accepted deterministic route from a compiled rule.

route = Spectre.Route.from_rule(rule, :regex, "hello")

new(route)

@spec new(map() | keyword() | t()) :: t()

Builds a normalized route struct.

route = Spectre.Route.new(label: :hello, accepted?: true)