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: L2GateStateGate state for this value.
retire_requested: boolNormal recovery is finalized at consequence settlement. Until then the commit snapshot remains valid for execution and feedback.
feedback_settled: boolWhether feedback settled is enabled or active.
trust: TrustRegionTrust for this value.
experts: ExpertAggregatorExperts for this value.
certificate: StabilityCertificateCertificate for this value.
cache: MetaCacheCache for this value.
baseline_error: f64Baseline error for this value.
ema_error: f64Ema error for this value.
ema_reward: f64Ema reward for this value.
baseline_reward: f64Baseline reward for this value.
observations: u64Observations for this value.
error_margin: f64Error margin for this value.
reward_drop_margin: f64Reward drop margin for this value.
rollback_wakeup: u32Rollback wakeup for this value.
rollback_streak: u32Rollback streak for this value.
calm_streak: u32Calm streak for this value.
calm_required: u32Calm required for this value.
max_error_history: usizeMaximum error history.
errors: Vec<f64>Collection of errors.
rewards: Vec<f64>Collection of rewards.
window_rollbacks: u32Window rollbacks for this value.
window_total: u32Window total for this value.
beta_max: f64Beta maximum for this value.
meta_cache_hit: boolWhether meta cache hit is enabled or active.
surprise_started: boolTrue only on the transition into ACTIVE, including a rollback wakeup.
cache_prepared: boolWhether 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: f64Episode start residual for this value.
cached_this_episode: boolWhether cached this episode is enabled or active.
entropy_sum: f64Entropy sum for this value.
last_selected_expert: usizeMost recent selected expert.
last_reward: f64Most recent reward.
residual: f64Residual for this value.
dayan_state: f64Residual relaxation state and its most recent frozen target. These fields retain their v4 names for snapshot compatibility.
dayan_relaxation: f64Dayan relaxation for this value.
residual_ema: f64Residual ema for this value.
previous_error: f64Previous error for this value.
residual_slope: f64Residual slope for this value.
residual_control_gain: f64Residual control gain for this value.
model_confidence: f64Model confidence for this value.
veto_count: u64Number of veto.
cache_hits: u64Cache hits for this value.
best_residual: f64Best residual for this value.
initial_residual: f64Initial residual for this value.
Implementations§
Source§impl ResidentController
impl ResidentController
Sourcepub fn observe(&mut self, feedback: ControlFeedback, policy: L2Policy)
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.
Sourcepub fn finish_cycle(&mut self)
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.
Sourcepub fn fingerprint(&self) -> ContextFingerprint
pub fn fingerprint(&self) -> ContextFingerprint
Performs fingerprint for this type.
Sourcepub fn beta_for(&self, spectral_weighting: bool) -> f64
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.
Sourcepub fn predicted_residual(&self, error: f64, alpha: f64, expert: usize) -> f64
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.
Sourcepub fn update_dayan(&mut self, target_alignment: f64) -> f64
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.
Sourcepub fn expert_weights(&self) -> BTreeMap<String, f64>
pub fn expert_weights(&self) -> BTreeMap<String, f64>
Performs expert weights for this type.