Skip to main content

ResidentController

Struct ResidentController 

Source
pub struct ResidentController {
Show 46 fields pub gate_state: L2GateState, pub retire_requested: bool, pub feedback_settled: bool, pub trust: TrustRegion, pub experts: ExpertAggregator, pub certificate: StabilityCertificate, pub cache: MetaCache, pub baseline_error: f64, pub ema_error: f64, pub ema_reward: f64, pub baseline_reward: f64, pub observations: u64, pub error_margin: f64, pub reward_drop_margin: f64, pub rollback_wakeup: u32, pub rollback_streak: u32, pub calm_streak: u32, pub calm_required: u32, pub max_error_history: usize, pub errors: Vec<f64>, pub rewards: Vec<f64>, pub window_rollbacks: u32, pub window_total: u32, pub beta_max: f64, pub meta_cache_hit: bool, pub surprise_started: bool, pub cache_prepared: bool, pub cache_prepared_fingerprint: Option<ContextFingerprint>, pub surprise_fingerprint: Option<ContextFingerprint>, pub episode_start_residual: f64, pub cached_this_episode: bool, pub entropy_sum: f64, pub last_selected_expert: usize, pub last_reward: f64, pub residual: f64, pub dayan_state: f64, pub dayan_relaxation: f64, pub residual_ema: f64, pub previous_error: f64, pub residual_slope: f64, pub residual_control_gain: f64, pub model_confidence: f64, pub veto_count: u64, pub cache_hits: u64, pub best_residual: f64, pub initial_residual: f64,
}
Expand description

Data structure representing resident controller.

Fields§

§gate_state: L2GateState

Gate state for this value.

§retire_requested: bool

Normal recovery is finalized at consequence settlement. Until then the commit snapshot remains valid for execution and feedback.

§feedback_settled: bool

Whether feedback settled is enabled or active.

§trust: TrustRegion

Trust for this value.

§experts: ExpertAggregator

Experts for this value.

§certificate: StabilityCertificate

Certificate for this value.

§cache: MetaCache

Cache for this value.

§baseline_error: f64

Baseline error for this value.

§ema_error: f64

Ema error for this value.

§ema_reward: f64

Ema reward for this value.

§baseline_reward: f64

Baseline reward for this value.

§observations: u64

Observations for this value.

§error_margin: f64

Error margin for this value.

§reward_drop_margin: f64

Reward drop margin for this value.

§rollback_wakeup: u32

Rollback wakeup for this value.

§rollback_streak: u32

Rollback streak for this value.

§calm_streak: u32

Calm streak for this value.

§calm_required: u32

Calm required for this value.

§max_error_history: usize

Maximum error history.

§errors: Vec<f64>

Collection of errors.

§rewards: Vec<f64>

Collection of rewards.

§window_rollbacks: u32

Window rollbacks for this value.

§window_total: u32

Window total for this value.

§beta_max: f64

Beta maximum for this value.

§meta_cache_hit: bool

Whether meta cache hit is enabled or active.

§surprise_started: bool

True only on the transition into ACTIVE, including a rollback wakeup.

§cache_prepared: bool

Whether cache prepared is enabled or active.

§cache_prepared_fingerprint: Option<ContextFingerprint>

Optional cache prepared fingerprint.

§surprise_fingerprint: Option<ContextFingerprint>

Optional surprise fingerprint.

§episode_start_residual: f64

Episode start residual for this value.

§cached_this_episode: bool

Whether cached this episode is enabled or active.

§entropy_sum: f64

Entropy sum for this value.

§last_selected_expert: usize

Most recent selected expert.

§last_reward: f64

Most recent reward.

§residual: f64

Residual for this value.

§dayan_state: f64

Residual relaxation state and its most recent frozen target. These fields retain their v4 names for snapshot compatibility.

§dayan_relaxation: f64

Dayan relaxation for this value.

§residual_ema: f64

Residual ema for this value.

§previous_error: f64

Previous error for this value.

§residual_slope: f64

Residual slope for this value.

§residual_control_gain: f64

Residual control gain for this value.

§model_confidence: f64

Model confidence for this value.

§veto_count: u64

Number of veto.

§cache_hits: u64

Cache hits for this value.

§best_residual: f64

Best residual for this value.

§initial_residual: f64

Initial residual for this value.

Implementations§

Source§

impl ResidentController

Source

pub fn observe(&mut self, feedback: ControlFeedback, policy: L2Policy)

Consume exactly one outcome for the policy that acted before this call. executed_expert = KEEP_L0 means no intervention was applied and the reward update uses L0’s own selection propensity (IPS still works). The policy remains noncommitted; its probabilities describe the actual selection rather than granting a new intervention.

Source

pub fn finish_cycle(&mut self)

Complete a normal retirement only after the acting policy’s feedback has been consumed. An unused pending commit keeps the gate snapshot valid until the next action and its consequence have both settled.

Source

pub fn fingerprint(&self) -> ContextFingerprint

Performs fingerprint for this type.

Source

pub fn prior(&self) -> [f64; 2]

Performs prior for this type.

Source

pub fn beta(&self) -> f64

Performs beta for this type.

Source

pub fn beta_for(&self, spectral_weighting: bool) -> f64

Return a regularization budget. Legacy controllers apply trust/confidence here; the spectral experiment applies them once at the KL boundary.

Source

pub fn predicted_residual(&self, error: f64, alpha: f64, expert: usize) -> f64

Predict one relaxation step from the current frozen target, then add the declared expert’s worst-case bounded disturbance. error is the observation associated with the latest target; alpha only bounds uncertainty, it is not treated as a guaranteed error reduction.

This is a model-based one-step check, not a claim that an expert can control the environment. For a frozen target, STABILIZE (which makes no additional perturbation in this model) recovers exactly the contraction r+ = (1 - lambda) r; EXPLORE/OBSERVE pay a transparent risk budget.

Source

pub fn update_dayan(&mut self, target_alignment: f64) -> f64

One explicit fixed-point iteration on the residual: r+ = (1-lambda) r + lambda |target - previous_target|. The latest observation supplies the omega=dayan target. For a frozen target and 0 < lambda <= 1 this is a contraction, hence V=r^2 decreases by (1-lambda)^2. On a regime change the target may move, which is why a separate single-step Lyapunov certificate guards every commit.

Source

pub fn expert_weights(&self) -> BTreeMap<String, f64>

Performs expert weights for this type.

Trait Implementations§

Source§

impl Clone for ResidentController

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 ResidentController

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ResidentController

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ResidentController

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ResidentController

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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