Skip to main content

ClosedLoopSession

Struct ClosedLoopSession 

Source
pub struct ClosedLoopSession<O = MultiModalObserver, D = ConstrainedDecisionMaker, E = SandboxedExecutor>
where O: Observer, D: DecisionMaker, E: Executor,
{ pub kernel: Kernel<O, D, E>, /* private fields */ }
Available on crate feature std only.
Expand description

Stateful coordinator for running the kernel with internal or external telemetry.

The session retains layer switches, cooldown state, and external-step bookkeeping between calls. Create it from a kernel and a KernelConfig, then invoke one of the ClosedLoopKernel step methods.

§Examples

use omega_cognitive_kernel::{
    api::{ClosedLoopKernel, ClosedLoopSession},
    persist::MemoryStateStore,
    Kernel, KernelConfig,
};

fn main() -> omega_cognitive_kernel::Result<()> {
    let config = KernelConfig::default();
    let kernel = Kernel::open_with_store(Box::new(MemoryStateStore::new()))?;
    let mut session = ClosedLoopSession::from_kernel(kernel, &config);
    assert!(session.switches().l0);

    let directive = session.step_internal().expect("internal step succeeds");
    assert!(directive.step_id > 0);
    assert!(directive.keep_steady);
    Ok(())
}

Fields§

§kernel: Kernel<O, D, E>

Kernel instance managed by this session.

Implementations§

Source§

impl<O, D, E> ClosedLoopSession<O, D, E>
where O: Observer, D: DecisionMaker, E: Executor,

Source

pub fn from_kernel(kernel: Kernel<O, D, E>, config: &KernelConfig) -> Self

Creates a session from a kernel and configuration, restoring saved loop state when present.

Source

pub fn cooldown(&self) -> &CooldownTracker

Returns the cooldown tracker used to limit consecutive policy updates.

Trait Implementations§

Source§

impl<O, D, E> ClosedLoopKernel for ClosedLoopSession<O, D, E>
where O: Observer, D: DecisionMaker, E: Executor,

Source§

type Error = OmegaError

Error returned when a step cannot be processed.
Source§

fn switches(&self) -> LayerSwitches

Returns the layer switches currently used by the kernel.
Source§

fn step_internal(&mut self) -> Result<ControlDirective, Self::Error>

Runs one step using the kernel’s internal world adapters.
Source§

fn step_external( &mut self, telemetry: StepTelemetry, ) -> Result<ControlDirective, Self::Error>

Processes one externally measured step and returns the resulting control directive.

Auto Trait Implementations§

§

impl<O = MultiModalObserver, D = ConstrainedDecisionMaker, E = SandboxedExecutor> !Freeze for ClosedLoopSession<O, D, E>

§

impl<O = MultiModalObserver, D = ConstrainedDecisionMaker, E = SandboxedExecutor> !RefUnwindSafe for ClosedLoopSession<O, D, E>

§

impl<O = MultiModalObserver, D = ConstrainedDecisionMaker, E = SandboxedExecutor> !Sync for ClosedLoopSession<O, D, E>

§

impl<O = MultiModalObserver, D = ConstrainedDecisionMaker, E = SandboxedExecutor> !UnwindSafe for ClosedLoopSession<O, D, E>

§

impl<O, D, E> Forget for ClosedLoopSession<O, D, E>

§

impl<O, D, E> Move for ClosedLoopSession<O, D, E>

§

impl<O, D, E> Send for ClosedLoopSession<O, D, E>
where E: Send, D: Send, O: Send, RawVecInner: Send, NonZero<i32>: Send, Utc: Send, Cell<u32>: Send, NodeRef<Owned, String, Strategy, LeafOrInternal>: Send, BoxRaw<(String, Strategy)>: Send, NodeRef<Owned, String, f64, LeafOrInternal>: Send, BoxRaw<(String, f64)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, BoxRaw<dyn FnMut(&AuditEvent) + Send>: Send, BoxRaw<dyn StateStore>: Send,

§

impl<O, D, E> Unpin for ClosedLoopSession<O, D, E>
where E: Unpin, D: Unpin, O: Unpin, *const u8 is !null: Unpin, NonZero<i32>: Unpin, Utc: Unpin, *const LeafNode<String, Strategy> is !null: Unpin, Box<(String, Strategy)>: Unpin, *const LeafNode<String, f64> is !null: Unpin, Box<(String, f64)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, Box<dyn FnMut(&AuditEvent) + Send>: Unpin, Box<dyn StateStore>: Unpin,

§

impl<O, D, E> UnsafeUnpin for ClosedLoopSession<O, D, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more