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 observationtis 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
- Supermartingale:
E[W_t | W_{t-1}] ≤ W_{t-1}under H₀ - Anytime-valid Type I control:
P(∃t: W_t ≥ 1/α) ≤ αunder H₀ - Non-negative wealth:
W_t ≥ 0always - Bounded latency: hard deadline forces recompute regardless of
W_t
§Failure Modes
| Condition | Behavior | Rationale |
|---|---|---|
μ₀ = 0 | Clamp to μ₀ = ε (1e-6) | Division by zero guard |
μ₀ ≥ 1 | Clamp to 1 − ε | Degenerate: everything matches |
W_t underflow | Clamp to W_MIN (1e-12) | Prevents permanent zero-lock |
| Hard deadline exceeded | Force recompute | Bounded worst-case latency |
| No observations | No change to W_t | Idle 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§
- EProcess
Throttle - Anytime-valid recompute throttle using e-process (test martingale) control.
- Throttle
Config - Configuration for the e-process throttle.
- Throttle
Decision - Decision returned by the throttle on each observation.
- Throttle
Log - Decision log entry for observability.
- Throttle
Stats - Aggregate statistics for the throttle.