Skip to main content

ConformalFrameGuard

Struct ConformalFrameGuard 

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

Conformal frame guard: wraps ConformalPredictor with p99 intervals.

Tracks frame render times as a time series, computes nonconformity scores, and emits coverage-guaranteed prediction intervals for the next frame. When the predicted p99 exceeds the frame budget, the guard signals degradation.

Implementations§

Source§

impl ConformalFrameGuard

Source

pub fn new(config: ConformalFrameGuardConfig) -> Self

Create a new guard with the given configuration.

Source

pub fn with_defaults() -> Self

Create a guard with default configuration.

Source

pub fn observe(&mut self, frame_time_us: f64, key: BucketKey)

Observe a realized frame time and update calibration.

frame_time_us: measured frame render time in microseconds. key: bucket key from the rendering context.

Source

pub fn predict_p99(&mut self, budget_us: f64, key: BucketKey) -> P99Prediction

Predict the p99 upper bound for the next frame.

budget_us: current frame budget in microseconds. key: bucket key for the upcoming rendering context.

Returns a P99Prediction with the interval and risk assessment.

Source

pub fn state(&self) -> GuardState

Get the current guard state.

Source

pub fn is_calibrated(&self) -> bool

Whether the guard has enough calibration data for conformal intervals.

Source

pub fn observations(&self) -> u64

Total frame observations processed.

Source

pub fn degradation_triggers(&self) -> u64

Total degradation triggers.

Source

pub fn nonconformity_scores(&self) -> &VecDeque<f64>

Access the rolling nonconformity scores.

Source

pub fn frame_times(&self) -> &VecDeque<f64>

Access the rolling frame time series.

Source

pub fn ema_us(&self) -> f64

Current EMA of frame times (µs).

Source

pub fn predictor(&self) -> &ConformalPredictor

Access the underlying conformal predictor.

Source

pub fn config(&self) -> &ConformalFrameGuardConfig

Access the configuration.

Source

pub fn nonconformity_summary(&self) -> Option<NonconformitySummary>

Compute summary statistics for the nonconformity score distribution.

Returns (mean, p50, p90, p99, max) or None if no scores exist.

Source

pub fn reset(&mut self)

Reset all calibration state (e.g., after a mode change).

Source

pub fn suggest_action( &self, prediction: &P99Prediction, current_level: DegradationLevel, ) -> Option<DegradationLevel>

Suggest what degradation action to take based on the prediction.

Returns Some(DegradationLevel::next()) if the p99 exceeds budget and the guard is calibrated, None otherwise (hold current level).

Source

pub fn telemetry(&self) -> ConformalFrameGuardTelemetry

Capture a telemetry snapshot for structured logging.

Trait Implementations§

Source§

impl Debug for ConformalFrameGuard

Source§

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

Formats the value using the given formatter. 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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