pub struct EProcessConfig {
pub lambda: f64,
pub adaptive_lambda: bool,
pub grapa_eta: f64,
pub lambda_min: f64,
pub lambda_max: f64,
pub alpha: f64,
pub beta: f64,
pub sigma_ema_decay: f64,
pub sigma_floor_ms: f64,
pub warmup_frames: u32,
}Expand description
E-process-style evidence accumulator for gating degradation decisions.
§Mathematical Model
Inspired by anytime-valid e-processes; the accumulator is
E_t = Π_{j=1..t} exp(λ * r_j − λ² / 2)where:
r_jis the standardized residual at frame j:(frame_time − target) / σ̂σ̂is an EMA of absolute deviation (≈ 0.8σ for Gaussian noise), measured against the already-updated EMA mean of frame timesλis a tuning parameter controlling sensitivity (default: 0.5)
§Decision Rule
- Degrade only when
E_t > 1/α(evidence exceeds threshold). Default α = 0.05, so we needE_t > 20. - Upgrade only when
E_t < β(evidence that overload has passed). Default β = 0.5.
§Properties
- Check-every-frame: The gate can be evaluated after every frame; thresholds are tuned empirically rather than by fixed-sample theory.
- Heuristic threshold, not a formal α-bound: because σ̂ is a
mean-absolute-deviation EMA (biased low vs. true σ), residuals are
inflated and
E_tdrifts upward slightly even under healthy jitter, so Ville’s inequalityP(E_t > 1/α | H₀) ≤ αdoes NOT formally hold. In practice this makes the gate a little more eager to degrade than the α suggests, which errs on the fail-safe side. Treatalphaas a tuning knob, not a guaranteed false-positive rate. - Self-correcting: After a burst passes, E_t decays back toward 1.0, naturally enabling recovery.
§Failure Modes
- Sustained overload: E_t grows exponentially → rapid degradation.
- Transient spike: E_t grows briefly → may not cross threshold → PID handles short-term. Only persistent overload triggers e-process gate.
- σ estimation drift: We use an exponential moving average for σ with a warmup period of 10 frames to avoid unstable early estimates.
Fields§
§lambda: f64Initial/baseline sensitivity parameter λ. Higher values detect overload faster but increase false positive risk near the boundary. Default: 0.5.
adaptive_lambda: boolWhether to adapt λ online via the Gaussian-form GRAPA update
λ_{t+1} = clamp(λ_t + η (r_t − λ_t), λ_min, λ_max).
Default: true.
grapa_eta: f64Step size η for Gaussian-form GRAPA adaptation of λ. Default: 0.1.
lambda_min: f64Lower bound on the betting fraction λ. Default: 0.05.
lambda_max: f64Upper bound on the betting fraction λ. Default: 2.0.
alpha: f64Significance level α. Degrade when E_t > 1/α. Default: 0.05 (need E_t > 20 to degrade).
beta: f64Recovery threshold β. Upgrade allowed when E_t < β. Default: 0.5.
sigma_ema_decay: f64EMA decay for σ estimation. Closer to 1.0 = slower adaptation. Default: 0.9 (adapts over ~10 frames).
sigma_floor_ms: f64Minimum σ floor to prevent division by zero. Default: 1.0 ms.
warmup_frames: u32Warmup frame threshold before e-process degradation activates.
Because frames_observed is incremented before the gate check,
should_degrade returns false while frames_observed < warmup_frames
(the first warmup_frames - 1 observations) so cold-start jitter cannot
trigger degradation before sigma_ema calibrates, and activates on the
warmup_frames-th observation. should_upgrade returns true during
warmup so PID-driven recovery remains permitted.
Default: 10.