1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Adaptive sampling module for tacet.
//!
//! Implements a two-phase approach for efficient timing analysis:
//!
//! 1. **Calibration** (spec §3.3, §3.5.4): Collect initial samples to estimate covariance
//! and set Bayesian priors. This establishes the "sigma rate" - covariance scaled by sample
//! count - which allows efficient scaling as more samples are collected.
//!
//! 2. **Adaptive loop** (spec §3.5): Collect batches until decision thresholds are reached:
//! - If P(leak > theta) > fail_threshold: Fail (timing leak detected)
//! - If P(leak > theta) < pass_threshold: Pass (no significant leak)
//! - If quality gates trigger: Inconclusive (measurement issues)
//!
//! ## Key Design Decisions
//!
//! - **Sigma rate scaling**: Instead of recomputing covariance for each batch, we estimate
//! Sigma_rate = Sigma_cal * n_cal from calibration, then scale as Sigma_n = Sigma_rate / n.
//! This assumes stationarity and avoids expensive bootstrap on each iteration.
//!
//! - **KL divergence tracking**: We track KL(posterior_new || posterior_old) to detect when
//! learning has stalled. If recent KL divergences sum to < 0.001, data isn't informative.
//!
//! - **Quality gates**: Multiple stopping conditions prevent wasted computation:
//! - Posterior too close to prior (variance ratio > 0.5)
//! - Learning rate collapsed (KL sum < 0.001 over 5 batches)
//! - Extrapolated time exceeds 10x budget
//! - Time budget exceeded
//! - Sample budget exceeded
//! - Condition drift detected (calibration assumptions violated)
// Re-export from tacet-core
pub use ;
// Local exports
pub use ;
pub use ;
pub use ;
pub use AdaptiveState;