Skip to main content

Module eprocess_throttle

Module eprocess_throttle 

Source
Expand description

Anytime-valid throttle using e-process (test martingale) control.

This module provides an adaptive recompute throttle for streaming workloads (e.g., live log search). It uses a wealth-based betting strategy to decide when accumulated evidence warrants a full recomputation, while providing anytime-valid statistical guarantees.

§Mathematical Model

The throttle maintains a wealth process W_t:

W_0 = 1
W_t = W_{t-1} × (1 + λ_t × (X_t − μ₀))

where:

  • X_t ∈ {0, 1}: whether observation t is evidence for recompute (e.g., a log line matched the active search/filter query)
  • μ₀: null hypothesis match rate — the “normal” baseline match frequency
  • λ_t ∈ (0, 1/μ₀): betting fraction (adaptive via GRAPA)

When W_t ≥ 1/α (the e-value threshold), we reject H₀ (“results are still fresh”) and trigger recompute. After triggering, W resets to 1.

§Key Invariants

  1. Supermartingale: E[W_t | W_{t-1}] ≤ W_{t-1} under H₀
  2. Anytime-valid Type I control: P(∃t: W_t ≥ 1/α) ≤ α under H₀
  3. Non-negative wealth: W_t ≥ 0 always
  4. Bounded latency: hard deadline forces recompute regardless of W_t

§Failure Modes

ConditionBehaviorRationale
μ₀ = 0Clamp to μ₀ = ε (1e-6)Division by zero guard
μ₀ ≥ 1Clamp to 1 − εDegenerate: everything matches
W_t underflowClamp to W_MIN (1e-12)Prevents permanent zero-lock
Hard deadline exceededForce recomputeBounded worst-case latency
No observationsNo change to W_tIdle is not evidence

§Usage

use ftui_runtime::eprocess_throttle::{EProcessThrottle, ThrottleConfig};

let mut throttle = EProcessThrottle::new(ThrottleConfig::default());

// On each log line push:
let matched = line.contains(&query);
let decision = throttle.observe(matched);
if decision.should_recompute {
    recompute_search_results();
}

Structs§

EProcessThrottle
Anytime-valid recompute throttle using e-process (test martingale) control.
ThrottleConfig
Configuration for the e-process throttle.
ThrottleDecision
Decision returned by the throttle on each observation.
ThrottleLog
Decision log entry for observability.
ThrottleStats
Aggregate statistics for the throttle.