classifyDecay
classifyDecay(
m:DecayInput,now:number,policy?:Partial<DecayPolicy>):DecayVerdict
Defined in: src/lib/memory/decay.ts:182
Classify one memory into a decay verdict, reading only plaintext fields.
Rules, in order (first match wins): 0. Non-finite timestamps → keep (safe) + warn (corrupt row, observable).
- Already archived (
archivedAt != null): delete once past the hard-delete window, else keep — runs REGARDLESS ofsource, so the purge clock applies to archived manual rows too. source === "manual"→ keep — protects manual saves from AUTO-ARCHIVE only (rules 3/4). Delete-of-already-archived is handled above.plan/ongoing_contextwhose event has become past —eventTimeEndis set AND older thannow - grace→ archive. Anongoingstatus with a nulleventTimeEndis still ongoing, so this rule does not fire for it.- Age fallback —
now - updatedAt > TTL(factType)→ archive. Durable types have Infinity TTL, so this never fires for them; null/unknown use medium. EXCEPTION: aplan/ongoing_contextwith an upcoming event or an event within the grace period (eventTimeEnd >= now - pastEventGraceMs) stays active, even after its activity TTL expires. Rule 3 archives it after the grace period ends. - Otherwise → keep.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
Plaintext decay inputs for one row. | |
|
|
|
Reference time (Unix ms). Injected for determinism. |
|
|
|
Optional partial policy overriding DEFAULT_DECAY_POLICY. |
Returns
Last updated on