pub enum Decay {
None,
Linear {
span: u64,
},
Exponential {
half_life: u64,
},
}Expand description
How a record’s age is priced into its recall score.
The age term is the last term, deliberately: ADR-0013 depreciates by evidence first and clock last, so an anchor that no longer resolves and an explicit supersession both outrank age. Age is the tiebreak between records that are otherwise equally valid.
Age is measured in generations, not time. A generation is one written
record (MemoryRecord::id, AUTOINCREMENT), so “old” means a lot has been
learned since, not a while has passed. That is what makes it skew-proof: the
store is shared across worktrees and branches, where wall-clock is not
monotone and datetime('now') ties on intra-second writes.
The factor is computed on every read and never stored. A stored score that ticked down would rewrite the store on every read and would be wrong in between, making recall depend on when you last looked.
Variants§
None
No age term at all: every record’s factor is exactly 1.0.
This is the reproducible mode, and it is the default. With no age term the score depends only on what is stored and on the tree the anchors are resolved against, so the same store and the same tree recall the same records in the same order with the same scores — byte-identically, across runs and across machines. Every other mode is a deliberate trade of that property for recency.
Linear
Falls linearly to zero over span generations.
A record older than span scores 0.0 in the age term and therefore sorts
last — it is still returned and still labelled. Decay ranks; it never
filters and never deletes.
Exponential
Halves every half_life generations, and never reaches zero.
Implementations§
Source§impl Decay
impl Decay
Sourcepub fn factor(self, age: u64) -> f64
pub fn factor(self, age: u64) -> f64
The age factor for a record age generations old, always in [0.0, 1.0].
A pure function of (self, age): no clock, no store state, no I/O.
Sourcepub fn is_reproducible(self) -> bool
pub fn is_reproducible(self) -> bool
Whether this mode guarantees reproducible recall — true only for
Decay::None.
Trait Implementations§
impl Copy for Decay
Source§impl Default for Decay
impl Default for Decay
Source§fn default() -> Self
fn default() -> Self
Decay::None — the reproducible answer is the default answer, on the
same terms as crate::SearchOptions defaulting generated content off.
Source§impl<'de> Deserialize<'de> for Decay
impl<'de> Deserialize<'de> for Decay
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Decay
impl StructuralPartialEq for Decay
Auto Trait Implementations§
impl Freeze for Decay
impl RefUnwindSafe for Decay
impl Send for Decay
impl Sync for Decay
impl Unpin for Decay
impl UnsafeUnpin for Decay
impl UnwindSafe for Decay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.