Policy gate evaluator for pending effects.
A policy is a temporary deterministic router for one pending effect. While a policy is active, Spectre ignores normal flow routing and interprets the next user turn as approval, rejection, or retry.
Summary
Functions
Returns true when the state is waiting on a policy response.
Decides whether policy text accepts, rejects, or misses all policy branches.
Builds a policy struct from compiled DSL metadata.
Resolves the active policy from a trusted host decision without matching synthetic user text.
Resumes the active policy with the user's latest input.
Types
Functions
@spec awaiting?(Spectre.State.t()) :: boolean()
Returns true when the state is waiting on a policy response.
Decides whether policy text accepts, rejects, or misses all policy branches.
Builds a policy struct from compiled DSL metadata.
@spec resolve(resolution(), Spectre.Input.t(), Spectre.Context.t() | map()) :: {:ok, Spectre.Result.t()} | {:error, term()}
Resolves the active policy from a trusted host decision without matching synthetic user text.
The label must exist in the policy's corresponding accept/reject branches.
This is useful when an application already has durable proof that a policy is
satisfied. Callers should use Spectre.resolve_policy/4 so the resulting
state is persisted before execution.
@spec resume(Spectre.Input.t(), Spectre.Context.t()) :: {:ok, Spectre.Result.t()} | {:error, term()}
Resumes the active policy with the user's latest input.