Skip to main content

zeppelin_embed/tier/
thresholds.rs

1//! Tier thresholds, measured on the single-tenant crossover ladder
2//! (`tasks/evidence/20-crossover.md`, 27-B6b, 2026-08-26).
3
4/// Thresholds selected for one `(dimensions, quantization scheme)` bucket.
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
6pub struct TierThresholds {
7    /// Minimum sealed-segment row count that earns graph construction.
8    pub graph_min_rows: u32,
9}
10
11/// MEASURED (`tasks/evidence/20-crossover.md`): SIFT-128, one thread,
12/// three-process medians, Bit4+rescore scan against a forced Vamana graph.
13/// The task-20 rule (scan p50 >= 2x graph p50) first holds at 30,000 rows
14/// (ratio 4.24 at k = 10, 3.43 at k = 100, graph recall 0.9985 / 0.9924);
15/// at 10,000 rows the ratio is 1.82 / 1.75. The crossover therefore lies in
16/// the measured bracket (10,000, 30,000] and this constant is the first
17/// ladder point that satisfies the rule, not an interpolation. Only one
18/// `(dimensions, scheme)` bucket is measured, so `for_bucket` still returns
19/// this single arm for every bucket.
20pub const MEASURED_TIER_THRESHOLDS: TierThresholds = TierThresholds {
21    graph_min_rows: 30_000,
22};
23
24/// Kept as the name earlier tasks import; it now carries the measured value.
25pub const PROVISIONAL_TIER_THRESHOLDS: TierThresholds = MEASURED_TIER_THRESHOLDS;
26
27/// Selects the threshold bucket for a segment's dimensions and scheme.
28///
29/// One bucket (128-d, Bit4+rescore) is measured; other buckets reuse it
30/// until they are measured on the same ladder.
31#[must_use]
32pub const fn for_bucket(_dimensions: u32, _scheme: u16) -> TierThresholds {
33    MEASURED_TIER_THRESHOLDS
34}
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    /// Pins the measured crossover so a change is a policy decision with
41    /// evidence, never a refactor.
42    #[test]
43    fn graph_min_rows_is_the_first_ladder_point_satisfying_the_two_x_rule() {
44        assert_eq!(MEASURED_TIER_THRESHOLDS.graph_min_rows, 30_000);
45        assert_eq!(for_bucket(128, 0), MEASURED_TIER_THRESHOLDS);
46        assert_eq!(for_bucket(784, 1), MEASURED_TIER_THRESHOLDS);
47    }
48}