Skip to main content

AdaptiveStateMachine

Struct AdaptiveStateMachine 

Source
pub struct AdaptiveStateMachine { /* private fields */ }
Expand description

Pure, no_std-compatible state machine implementing Adaptive Kernel Protocol v1.

Enforces single-pending-active gating, fail-closed payload conflict detection, full-snapshot application verification, single-consumption feedback attribution, monotonic recovery versioning, legacy-snapshot permission isolation, and expired-request tombstone safety.

Implementations§

Source§

impl AdaptiveStateMachine

Source

pub fn new( config: AdaptiveConfig, confirmed_policy: PolicySnapshot, ) -> Result<Self, AdaptiveError>

Creates a new state machine initialized with config and confirmed baseline parameters.

Source

pub fn from_legacy_snapshot( snapshot_version: u32, config: AdaptiveConfig, confirmed_policy: PolicySnapshot, ) -> Result<Self, AdaptiveError>

Restores a state machine from a legacy snapshot (e.g. schema v6).

Legacy snapshots never grant AdaptiveMode::Active permission even if the caller requests active mode; the session stays fail-closed in AdaptiveMode::Keep until explicitly migrated and re-authorized.

Source

pub fn export_state(&self) -> AdaptivePersistedState

Exports a serializable snapshot of the state machine for schema v7 persistence.

Source

pub fn from_persisted_state( config: AdaptiveConfig, state: AdaptivePersistedState, ) -> Result<Self, AdaptiveError>

Restores a state machine from a durable AdaptivePersistedState.

Active permission is never elevated above the lesser of config.mode and the persisted active_permission_granted flag.

Source

pub fn reconcile_journal(input: &JournalRecoveryInput) -> JournalRecoveryAction

Evaluates journal recovery state after an interrupted durable commit.

Source

pub fn record_expired_tombstone(&mut self, request_id: impl Into<String>)

Marks an old request_id as an expired tombstone so it can never be re-executed.

Source

pub fn confirmed_policy(&self) -> &PolicySnapshot

Returns the currently confirmed policy snapshot.

Source

pub fn next_candidate_version(&self) -> u64

Returns the next candidate policy version that will be allocated.

Source

pub fn revision(&self) -> u64

Returns the monotonic state revision counter.

Source

pub fn learning_updates(&self) -> u64

Returns the total count of consumed learning updates.

Source

pub fn checkpoint_count(&self) -> u64

Returns the total count of checkpoints created across proposals.

Source

pub fn active_permission_granted(&self) -> bool

Returns whether active adaptation permission is granted for this session.

Source

pub fn pending_active_proposal_id(&self) -> Option<&str>

Returns the currently pending active proposal identifier, if any.

Source

pub fn proposal_state(&self, proposal_id: &str) -> Option<ProposalState>

Returns the current lifecycle state of proposal_id, if tracked.

Source

pub fn propose( &mut self, req: ProposalRequest, ) -> Result<ProposalResponse, AdaptiveError>

Processes a proposal request with strict idempotency and conflict checking.

Source

pub fn acknowledge_applied( &mut self, receipt: ExecutionReceipt, ) -> Result<PolicySnapshot, AdaptiveError>

Acknowledges that the host applied an active proposal’s exact full snapshot.

Source

pub fn feedback( &mut self, req: FeedbackRequest, ) -> Result<FeedbackReceipt, AdaptiveError>

Records external outcome feedback for an applied execution, consuming it at most once.

Source

pub fn recommend_recovery( &self, recovery_params: BTreeMap<String, f64>, ) -> Result<RecoveryRecommendation, AdaptiveError>

Produces a recovery recommendation that restores recovery_params under a strictly newer version.

Trait Implementations§

Source§

impl Clone for AdaptiveStateMachine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AdaptiveStateMachine

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for AdaptiveStateMachine

§

impl Freeze for AdaptiveStateMachine
where *const LeafNode<String, f64> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, f64)>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, TrackedProposal> is !null: Freeze, PhantomData<Box<(String, TrackedProposal)>>: Freeze, *const LeafNode<String, StoredRequest> is !null: Freeze, PhantomData<Box<(String, StoredRequest)>>: Freeze, *const LeafNode<String, StoredFeedback> is !null: Freeze, PhantomData<Box<(String, StoredFeedback)>>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze,

§

impl Move for AdaptiveStateMachine

§

impl RefUnwindSafe for AdaptiveStateMachine

§

impl Send for AdaptiveStateMachine
where NodeRef<Owned, String, f64, LeafOrInternal>: Send, BoxRaw<(String, f64)>: Send, RawVecInner: Send, NodeRef<Owned, String, TrackedProposal, LeafOrInternal>: Send, BoxRaw<(String, TrackedProposal)>: Send, NodeRef<Owned, String, StoredRequest, LeafOrInternal>: Send, BoxRaw<(String, StoredRequest)>: Send, NodeRef<Owned, String, StoredFeedback, LeafOrInternal>: Send, BoxRaw<(String, StoredFeedback)>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send,

§

impl Sync for AdaptiveStateMachine
where NodeRef<Owned, String, f64, LeafOrInternal>: Sync, BoxRaw<(String, f64)>: Sync, RawVecInner: Sync, NodeRef<Owned, String, TrackedProposal, LeafOrInternal>: Sync, BoxRaw<(String, TrackedProposal)>: Sync, NodeRef<Owned, String, StoredRequest, LeafOrInternal>: Sync, BoxRaw<(String, StoredRequest)>: Sync, NodeRef<Owned, String, StoredFeedback, LeafOrInternal>: Sync, BoxRaw<(String, StoredFeedback)>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync,

§

impl Unpin for AdaptiveStateMachine
where *const LeafNode<String, f64> is !null: Unpin, Box<(String, f64)>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, TrackedProposal> is !null: Unpin, Box<(String, TrackedProposal)>: Unpin, *const LeafNode<String, StoredRequest> is !null: Unpin, Box<(String, StoredRequest)>: Unpin, *const LeafNode<String, StoredFeedback> is !null: Unpin, Box<(String, StoredFeedback)>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin,

§

impl UnsafeUnpin for AdaptiveStateMachine
where *const LeafNode<String, f64> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, f64)>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, TrackedProposal> is !null: UnsafeUnpin, PhantomData<Box<(String, TrackedProposal)>>: UnsafeUnpin, *const LeafNode<String, StoredRequest> is !null: UnsafeUnpin, PhantomData<Box<(String, StoredRequest)>>: UnsafeUnpin, *const LeafNode<String, StoredFeedback> is !null: UnsafeUnpin, PhantomData<Box<(String, StoredFeedback)>>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,

§

impl UnwindSafe for AdaptiveStateMachine
where BTreeMap<String, f64>: UnwindSafe, RawVecInner: UnwindSafe, BTreeMap<String, TrackedProposal>: UnwindSafe, BTreeMap<String, StoredRequest>: UnwindSafe, BTreeMap<String, StoredFeedback>: UnwindSafe, BTreeMap<String, SetValZST>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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