Runs input plugs before the Spectre runtime handles a turn.
Input normalization is a boundary concern. By running it before state loading,
policy matching, and routing, the rest of the runtime can depend on one
internal %Spectre.Input{} shape instead of repeatedly handling raw host
payloads.
specs = [
{Spectre.Input.Plugs.NormalizeText, trim?: true, case: :downcase}
]
{:ok, input} =
Spectre.Input.Pipeline.run(
Spectre.Input.new(" HELLO "),
%{agent: MyApp.Agent, opts: []},
specs
)
Summary
Types
@type plug_spec() :: module() | {module(), keyword()} | Spectre.Input.Pipeline.Spec.t()
Functions
@spec init_specs( [plug_spec()], keyword() ) :: {:ok, [Spectre.Input.Pipeline.Spec.t()]} | {:error, term()}
Initializes input plug specs.
Use this when a host process wants to prepare a reusable pipeline once and run it for many turns.
@spec run(Spectre.Input.t(), map(), [plug_spec()]) :: {:ok, Spectre.Input.t()} | {:error, term()}
Runs an input through initialized or ad-hoc plug specs.
A plug may continue with a new input, halt with a final input, or return an error. Halting is useful when a boundary plug can fully normalize or reject a turn before router/runtime work starts.