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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! DAVO: Decay-Aware Value Optimization (Experimental).
//!
//! A self-improving database layer that treats data as decaying assets.
//! Every value can carry a decay rate λ so that freshness degrades over
//! time according to `e^(-λ × age_seconds)`.
//!
//! # Core Concepts
//!
//! | Concept | Type | Purpose |
//! |---------|------|---------|
//! | **DAVOAtom** | [`DAVOAtom`] | Value with decay metadata |
//! | **Forward Decay** | [`FreshnessIndexV2`] | O(k + log N) staleness queries via deadline index |
//! | **Bayesian Learning** | [`DecayPredictor`] | Learn optimal λ from observations |
//! | **Asymmetric Loss** | [`OutcomeTracker`] | Track TP/FP/TN/FN with weighted loss |
//! | **Lazy Evaluation** | [`Thunk`] / [`ThunkRegistry`] | Defer computation with probation GC |
//!
//! # Quick Start
//!
//! ```
//! use synadb::davo::{FreshnessIndexV2, DecayPredictor};
//!
//! // Track freshness of keys
//! let mut index = FreshnessIndexV2::new();
//! index.insert("sensor/temp", 0.001); // slow decay
//! index.insert("cache/user_1", 10.0); // fast decay
//!
//! // Query freshness
//! let f = index.get_freshness("sensor/temp").unwrap();
//! assert!(f > 0.99); // just inserted
//!
//! // Learn decay rates from observations
//! let mut predictor = DecayPredictor::new();
//! for _ in 0..50 {
//! predictor.observe(0.05);
//! }
//! assert!((predictor.predict() - 0.05).abs() < 0.02);
//! ```
//!
//! # Freshness Index Versions
//!
//! - **FreshnessIndex** (V1) — HashMap-based, O(N) staleness scans. **Deprecated.**
//! - **FreshnessIndexV2** (V2) — BTreeMap deadline index, O(k + log N) staleness scans.
//!
//! Always use [`FreshnessIndexV2`] for new code.
//!
//! # Status
//!
//! **Experimental** — API may change between minor versions.
// Re-exports
pub use ;
pub use FreshnessIndex;
pub use FreshnessIndexV2;
pub use ;
pub use DecayPredictor;
pub use ;