Pure transition engine for Work, Vigil and external operational controllers.
Slow execution is deliberately absent from this module. It prepares fenced
attempts and reduces their results; Spectre.Instance owns serialization,
canonical commit, supervision and scheduling.
The engine is split by concern: Runtime.Contract enforces the code-owned
definition, Runtime.Transitions builds loop-state transitions,
Runtime.Results reduces Runner results, Runtime.Controls handles the
control plane and Runtime.Recovery validates restored checkpoints. This
module keeps loop start, attempt preparation, trigger delivery and the
public entry points.
Summary
Functions
Advances a pending pause/update/resume sequence once the loop is quiescent.
Applies one correlated Runner result and leaves completion evaluation for the next commit.
Evaluates deterministic completion only after the result transition was committed.
Prepares the next registered operation from committed loop state.
Recovers portable loop state after an Agent restart and invalidates the old epoch.
Commits a durable control request without executing it reentrantly.
Reduces an unexpected DOWN for the currently fenced Runner.
Starts a data-only Work on the same fenced operational runtime.
Applies a correlated timer, event or human trigger to a waiting loop.
Validates a restored loop and its control plane against the current code-owned definition.
Types
Functions
@spec advance_control( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), env() ) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Advances a pending pause/update/resume sequence once the loop is quiescent.
@spec apply_result( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), Spectre.Operation.Result.t(), env() ) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:duplicate, Spectre.Operation.Loop.t()} | {:error, term()}
Applies one correlated Runner result and leaves completion evaluation for the next commit.
@spec evaluate(Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), env()) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Evaluates deterministic completion only after the result transition was committed.
@spec prepare(Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), env()) :: {:run, Spectre.Operation.Loop.t(), Spectre.Operation.Attempt.t(), Spectre.Operation.Spec.t(), Spectre.Operation.Request.t(), boolean(), [event_spec()]} | {:transition, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Prepares the next registered operation from committed loop state.
@spec recover(Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), env()) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Recovers portable loop state after an Agent restart and invalidates the old epoch.
@spec request_control( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), Spectre.Operation.Control.Command.t(), env() ) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), pid_action(), [event_spec()]} | {:duplicate, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t()} | {:error, term()}
Commits a durable control request without executing it reentrantly.
@spec runner_down( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), Spectre.Operation.Spec.t(), term(), env() ) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Reduces an unexpected DOWN for the currently fenced Runner.
@spec start(Spectre.Operation.Loop.kind(), module(), term(), keyword(), env()) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
@spec start_program(Spectre.Execution.Program.t(), term(), keyword(), env()) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Starts a data-only Work on the same fenced operational runtime.
@spec trigger( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), term(), keyword(), env() ) :: {:ok, Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), [event_spec()]} | {:error, term()}
Applies a correlated timer, event or human trigger to a waiting loop.
@spec validate_checkpoint( Spectre.Operation.Loop.t(), Spectre.Operation.Control.t(), env() ) :: :ok | {:error, term()}
Validates a restored loop and its control plane against the current code-owned definition.