# `Reminisce.Decay`
[🔗](https://github.com/NoeticEcho/reminisce-elixir/blob/v0.6.0/lib/reminisce/decay.ex#L4)

Salience decay, and the consolidation pass the host runs.

The decay is exponential towards a floor:

    s' = floor + (s - floor) * exp(-Δdays / τ)

where `Δdays` runs from the memory's last moment of attention (the later of
its last recall, its recording, and the owner's previous pass) to the pass's
interval end, and `τ` is the longest of its aspects' time constants: a memory
that is semantic as well as episodic fades at the semantic pace.

An affect slows it (docs/spec.md §B.4): a memory with an active affective
memory the owner holds that concerns no subject decays with the time
constant `τ × (1 + s × weight / 1000)`, where `weight` is the largest such
affect's (`arousal × floor(salience × 1000) div 1000`, at most the store's
`observed_cap` for one resting on outside text) and `s` is the store's
`affect: [decay_slowing:]`. The first pass that slows a memory also writes
its `unslowed_salience`, the salience it would have with no affect, and
decays it at `τ` from then on; `:inactive_below` is tested on that number.
An affective memory decays at its own `τ` (`:affective`, default 90 days)
and is slowed by nothing.

Configuration, on the store as `decay: [...]`:

  * `:tau_days` — `%{aspect => days}`; default
    `%{episodic: 30, semantic: 365, procedural: 365, autobiographical: 730, prospective: 90,
    affective: 90}`;
  * `:default_tau_days` — for an aspect missing from the map; default 90;
  * `:floor` — default 0.05;
  * `:inactive_below` — when set, a pass moves an active memory whose decayed
    salience falls below it to `:inactive`, reason `"decayed"`: its
    `unslowed_salience` once an affect has slowed it. Default `nil` (off).
  * `:exempt_aspects` — aspects that never decay, default `[]`. A memory
    with any of them keeps its salience and its status through every pass,
    whatever its other aspects, as a strand of the persona does. An
    exempt affect (`exempt_aspects: [:affective]`) still slows its object,
    weighed at the salience it keeps. It is the
    way to say "never": a time constant cannot, because a memory decays at
    the longest constant of its aspects and a finite one still fades.
    `[:autobiographical]` keeps an agent's account of who it has become out
    of the pass entirely.

Nothing here schedules anything: the host calls `Reminisce.consolidate/3`.

# `decay`

```elixir
@spec decay(Reminisce.Memory.t(), keyword()) :: float()
```

The pure decay function: the salience `memory` would have at `opts[:at]`.

Options: `:at` (required), `:since` (default: the later of `last_recalled_at`
and `recorded_at`), the configuration keys above, and `:affect_weight`
(default 0) with `:decay_slowing` (default 1): the time constant becomes
`τ × (1 + decay_slowing × affect_weight / 1000)`. `decay(m, at: t)` is the
decay with no affect; a pass gives the weight.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
