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
impl ConformalFrameGuard
Sourcepub fn new(config: ConformalFrameGuardConfig) -> Self
pub fn new(config: ConformalFrameGuardConfig) -> Self
Create a new guard with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a guard with default configuration.
Sourcepub fn observe(&mut self, frame_time_us: f64, key: BucketKey)
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.
Sourcepub fn predict_p99(&mut self, budget_us: f64, key: BucketKey) -> P99Prediction
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.
Sourcepub fn state(&self) -> GuardState
pub fn state(&self) -> GuardState
Get the current guard state.
Sourcepub fn is_calibrated(&self) -> bool
pub fn is_calibrated(&self) -> bool
Whether the guard has enough calibration data for conformal intervals.
Sourcepub fn observations(&self) -> u64
pub fn observations(&self) -> u64
Total frame observations processed.
Sourcepub fn degradation_triggers(&self) -> u64
pub fn degradation_triggers(&self) -> u64
Total degradation triggers.
Sourcepub fn nonconformity_scores(&self) -> &VecDeque<f64>
pub fn nonconformity_scores(&self) -> &VecDeque<f64>
Access the rolling nonconformity scores.
Sourcepub fn frame_times(&self) -> &VecDeque<f64>
pub fn frame_times(&self) -> &VecDeque<f64>
Access the rolling frame time series.
Sourcepub fn predictor(&self) -> &ConformalPredictor
pub fn predictor(&self) -> &ConformalPredictor
Access the underlying conformal predictor.
Sourcepub fn config(&self) -> &ConformalFrameGuardConfig
pub fn config(&self) -> &ConformalFrameGuardConfig
Access the configuration.
Sourcepub fn nonconformity_summary(&self) -> Option<NonconformitySummary>
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.
Sourcepub fn suggest_action(
&self,
prediction: &P99Prediction,
current_level: DegradationLevel,
) -> Option<DegradationLevel>
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).
Sourcepub fn telemetry(&self) -> ConformalFrameGuardTelemetry
pub fn telemetry(&self) -> ConformalFrameGuardTelemetry
Capture a telemetry snapshot for structured logging.