Skip to main content

Decay

Enum Decay 

Source
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.

Fields

§span: u64

Generations over which the factor reaches zero. Clamped to at least 1.

§

Exponential

Halves every half_life generations, and never reaches zero.

Fields

§half_life: u64

Generations per halving. Clamped to at least 1.

Implementations§

Source§

impl Decay

Source

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.

Source

pub fn as_str(self) -> &'static str

Stable token naming the mode, without its parameter.

Source

pub fn is_reproducible(self) -> bool

Whether this mode guarantees reproducible recall — true only for Decay::None.

Trait Implementations§

Source§

impl Clone for Decay

Source§

fn clone(&self) -> Decay

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Decay

Source§

impl Debug for Decay

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Decay

Source§

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

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Decay

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Decay

Source§

impl FromStr for Decay

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

none | linear[:span] | exponential[:half-life].

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

impl PartialEq for Decay

Source§

fn eq(&self, other: &Decay) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Decay

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.