Skip to main content

Engine

Struct Engine 

Source
pub struct Engine<O, P, G, D>{ /* private fields */ }
Expand description

Aria Engine — the Spec state machine with pluggable backends.

Implementations§

Source§

impl<O, P, GB, D> Engine<O, P, GB, D>

Source

pub fn new( config: AriaConfig, optical: O, predictor: P, graph_backend: GB, diffuser: D, ) -> Self

Create a new engine with backends and config.

Source

pub fn init( &self, psi0: Vec<Complex64>, g0: Graph, a0: Condition, ) -> Result<State, AriaError>

Init: create the initial state per FORMAL_SPEC §5.

ψ = ψ₀, z = I(ψ₀), G = G₀, t = 0, prevRes = d(I(ψ₀), P(I(ψ₀), a(0)))

Validates shapes up front: a field of the wrong length is a config error, not a downstream panic or a silently truncated mat-vec.

Source

pub fn apply( &self, state: State, action: Action, a: Condition, ) -> Result<State, AriaError>

Apply a single named action to the state.

Returns the new state on success, or an invariant violation. This is the Spec’s Next relation turned into a deterministic function.

Source

pub fn step_phi(&self, state: State, a: Condition) -> Result<State, AriaError>

Step one full Φ-cycle: OpticalStep → Predict → Match → Diffuse (𝐂4).

This is the preferred schedule. Each sub-step checks invariants. Returns the state after the full cycle, or the first invariant violation.

Source

pub fn run( &self, state: State, scheduler: &mut Scheduler, steps: u64, a: Condition, ) -> Result<(State, Trace), AriaError>

Run the engine for a number of steps with a scheduler.

Returns the final state and a trace of all steps.

Source

pub fn run_monitored( &self, state: State, scheduler: &mut Scheduler, steps: u64, a: Condition, ) -> Result<(State, Trace, GateReport), AriaError>

Run the engine, additionally monitoring the optional Inv5–Inv11 gates.

The monitor is a passive observer: it sees each completed step and can only report. Enabling a gate never changes which actions are taken, so the set of admissible behaviors is exactly the same as for [run].

Source

pub fn run_monitored_with_latents( &self, state: State, scheduler: &mut Scheduler, steps: u64, a: Condition, ) -> Result<MonitoredLatents, AriaError>

Same loop as Self::run_monitored, plus the post-step latent z.

Used by the post-hoc aria emit surface to recover the z-sequence of a completed run without writing z into the JSONL — so the default trace stays byte-stable and emit cannot feed anything back into Φ. Collecting z is state observation, not a Φ operator.

Source

pub fn run_monitored_fields( &self, state: State, scheduler: &mut Scheduler, steps: u64, a: Condition, ) -> Result<MonitoredFields, AriaError>

Same loop as Self::run_monitored_with_latents, plus (\arg\psi_0) after each step. The extra scalars are observer fields. They do not enter JSONL and they do not change apply.

Source

pub fn check(&self, state: &State, a: Condition) -> InvariantReport

Check all invariants on the current state without applying an action.

Source

pub fn residual(&self, state: &State, a: Condition) -> f64

JEPA residual Res(ψ, z, t) = d(z, P(I(ψ), a_t)).

Public so the WS6 streaming verifier can audit Inv2 / X4 without retaining a full in-memory crate::trace::Trace.

Source

pub fn config(&self) -> &AriaConfig

Access config.

Source

pub fn graph_backend(&self) -> &GB

Access the graph backend.

Read-only: the backend owns policy-layer state (the metric index) whose consistency with G is maintained through commit_ops/revert_ops, so callers may inspect it but never mutate it behind the engine’s back.

Trait Implementations§

Source§

impl<O, P, G, D> Debug for Engine<O, P, G, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<O, P, G, D> Freeze for Engine<O, P, G, D>
where O: Freeze, P: Freeze, G: Freeze, D: Freeze,

§

impl<O, P, G, D> RefUnwindSafe for Engine<O, P, G, D>

§

impl<O, P, G, D> Send for Engine<O, P, G, D>

§

impl<O, P, G, D> Sync for Engine<O, P, G, D>

§

impl<O, P, G, D> Unpin for Engine<O, P, G, D>
where O: Unpin, P: Unpin, G: Unpin, D: Unpin,

§

impl<O, P, G, D> UnsafeUnpin for Engine<O, P, G, D>

§

impl<O, P, G, D> UnwindSafe for Engine<O, P, G, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.