Expand description
Conformal alert threshold calibration with anytime-valid e-process control.
This module provides change-point detection for action timeline events using:
- Conformal thresholding - Distribution-free threshold calibration
- E-process layer - Anytime-valid FPR control via test martingales
- Evidence ledger - Explainable alert decisions with full provenance
§Mathematical Model
§Conformal Thresholding (Primary)
Given calibration residuals R = {r_1, …, r_n}, the conformal threshold is:
q = quantile_{(1-alpha)(n+1)/n}(R)This is the (n+1) rule: we pretend the new observation is one of (n+1) equally likely positions, ensuring finite-sample coverage P(r_{n+1} <= q) >= 1-alpha.
§E-Process Layer (Anytime-Valid)
For early stopping without FPR inflation, we maintain an e-process:
e_t = exp(lambda * (z_t - mu_0) - lambda^2 * sigma_0^2 / 2)
E_t = prod_{s=1}^{t} e_swhere z_t = (r_t - mean) / std is the standardized residual. Alert when E_t > 1/alpha.
§Key Invariants
- Coverage guarantee: P(FP) <= alpha under H_0 for conformal threshold
- Anytime-valid: E_t is a supermartingale, so P(exists t: E_t >= 1/alpha) <= alpha
- Non-negative wealth: E_t >= 0 always (floored at epsilon)
- Calibration monotonicity: Threshold is non-decreasing in calibration set size
§Failure Modes
| Condition | Behavior | Rationale |
|---|---|---|
| n < min_calibration | Use fallback threshold | Insufficient data |
| sigma = 0 | Use epsilon floor | Degenerate data |
| E_t underflow | Floor at E_MIN | Prevent permanent zero-lock |
| All residuals identical | Wide threshold | No variance to detect |
§Usage
ⓘ
use ftui_runtime::conformal_alert::{ConformalAlert, AlertConfig};
let mut alerter = ConformalAlert::new(AlertConfig::default());
// Calibration phase: feed baseline residuals
for baseline_value in baseline_data {
alerter.calibrate(baseline_value);
}
// Detection phase: check new observations
let decision = alerter.observe(new_value);
if decision.is_alert() {
println!("Alert: {}", decision.evidence_summary());
}Structs§
- Alert
Config - Configuration for conformal alert calibration.
- Alert
Decision - Decision returned after observing a new value.
- Alert
Evidence - Evidence ledger entry for a single observation.
- Alert
Stats - Aggregate statistics for the alerter.
- Conformal
Alert - Conformal alert threshold calibrator with e-process control.
Enums§
- Alert
Reason - Reason for alert decision.