/** * Memory salience decay — pure, tested function. * * Borrowed from ai-memory's `decay.rs`. The score blends a recency-decayed * salience term with an access-reinforcement term: * * score = salience · exp(-λ · Δt_days) * + σ · log(1 + access) · exp(-μ · Δt_access_days) * * where: * - salience = memory.importance (∈ [0,1]) * - Δt_days = days since `lastAccessed ?? createdAt` * - Δt_access_days = days since `lastAccessed ?? createdAt` * - access = memory.accessCount (∈ ℕ) * * Properties (asserted in decay.test.ts): * - Monotonic non-increasing in Δt (holding access fixed). * - Pinned memories are decay-exempt: score === importance. * - Bounded in [0,1] for all finite inputs. * - Increasing accessCount (recency fixed) never decreases the access term. * - Scores below `coldThreshold` flag the memory as a prune candidate. * * This module has NO runtime dependencies beyond `@massa-th0th/shared`'s * `DecayParams` type — it is safe to unit-test without a database. */ import type { DecayParams } from "@massa-th0th/shared"; /** Minimal memory shape consumed by `decayScore` — decoupled from the row type. */ export interface DecayMemory { /** Salience ∈ [0,1]. Maps to `memories.importance`. */ importance: number; /** Number of times the memory has been accessed. */ accessCount?: number; /** Epoch-ms creation time. */ createdAt: number; /** Epoch-ms last access time (falls back to createdAt). */ lastAccessed?: number | null; /** Pinned memories are decay-exempt. Maps to `memories.pinned` (0/1 or bool). */ pinned?: number | boolean; } /** Canonical defaults, mirrored from ai-memory decay.rs. */ export declare const DEFAULT_DECAY_PARAMS: DecayParams; /** * Compute the decayed salience score for a memory. * * @param mem The memory (salience, access, timestamps, pinned flag). * @param params Decay tunables. Defaults to `DEFAULT_DECAY_PARAMS`. * @param now Epoch-ms "now"; defaults to `Date.now()`. Injected for tests. * @returns Score clamped to [0,1]. Pinned memories return `importance`. */ export declare function decayScore(mem: DecayMemory, params?: DecayParams, now?: number): number; /** * Whether a memory's decayed score is below the cold threshold, making it a * candidate for pruning. Pinned memories are never cold. */ export declare function isCold(mem: DecayMemory, params?: DecayParams, now?: number): boolean; //# sourceMappingURL=decay.d.ts.map