Capability-free boundary for application deliberation.
A mind may route, plan, call application code and construct Candidates. It receives no Grant, broker or ledger writer, and its result remains only a proposal until each Candidate independently crosses the kernel boundary.
use Spectre.GAM.Mind, ref: "mind:my-app:v1" declares the behaviour and an
overridable ref/0. Implement deliberate/2 yourself. When this stateless
implementation is used by an Instance, the existing runtime bridge preserves
its local state unchanged.
For a stateful implementation, opt into stateful: true and implement
deliberate/3. The generated, overridable deliberate/2 calls it with nil
state and discards the returned state. A stateless call therefore starts
without local state; it never substitutes the options for that state. Your
callback must handle nil or you must override deliberate/2 explicitly.
This helper does not choose an Agent, flow, router, pipeline or fallback,
record derived Evidence, or submit Candidates. Those remain application
decisions. Plain @behaviour Spectre.GAM.Mind implementations remain supported.
Without the helper, deliberate/2 is always required; deliberate/3 is an
optional, explicit stateful variant. Define both arities separately. Do not
write def deliberate(turn, state, opts \ []): the generated /2 would
receive stateless turn options as state. The two callbacks also have
intentionally different success shapes:
def deliberate(turn, opts), do: {:ok, candidates(turn, opts)}
def deliberate(turn, state, opts) do
{:ok, candidates(turn, opts), next_state(state)}
end
Summary
Functions
Builds a Candidate whose trusted proposer and Scope come from the sealed Turn.
Builds a Candidate that may also cite validated derivations produced from the same Turn.
Invokes a mind and normalizes its output to scope-bound Candidates.
Invokes an optional stateful Mind callback without making its state authoritative.
Builds derived or generated Evidence bound to the exact sealed Turn context.
Callbacks
@callback deliberate( Spectre.GAM.Mind.Turn.t(), keyword() ) :: {:ok, Spectre.GAM.Candidate.t() | map() | keyword() | [Spectre.GAM.Candidate.t() | map() | keyword()]} | {:error, term()}
@callback deliberate(Spectre.GAM.Mind.Turn.t(), term(), keyword()) :: {:ok, Spectre.GAM.Candidate.t() | map() | keyword() | [Spectre.GAM.Candidate.t() | map() | keyword()], term()} | {:error, term()}
@callback ref() :: String.t()
Functions
@spec candidate(Spectre.GAM.Mind.Turn.t(), map() | keyword()) :: {:ok, Spectre.GAM.Candidate.t()} | {:error, term()}
Builds a Candidate whose trusted proposer and Scope come from the sealed Turn.
@spec candidate( Spectre.GAM.Mind.Turn.t(), Spectre.GAM.Evidence.t() | [Spectre.GAM.Evidence.t()], map() | keyword() ) :: {:ok, Spectre.GAM.Candidate.t()} | {:error, term()}
Builds a Candidate that may also cite validated derivations produced from the same Turn.
@spec deliberate(module(), Spectre.GAM.Mind.Turn.t(), keyword()) :: {:ok, [Spectre.GAM.Candidate.t()]} | {:error, term()}
Invokes a mind and normalizes its output to scope-bound Candidates.
@spec deliberate(module(), Spectre.GAM.Mind.Turn.t(), term(), keyword()) :: {:ok, [Spectre.GAM.Candidate.t()], term()} | {:error, term()}
Invokes an optional stateful Mind callback without making its state authoritative.
@spec evidence(Spectre.GAM.Mind.Turn.t(), integer(), map() | keyword()) :: {:ok, Spectre.GAM.Evidence.t()} | {:error, term()}
Builds derived or generated Evidence bound to the exact sealed Turn context.