/** * stale-policy — pure helper for stale detection and filtering on memory * and (future) retrospective entries. * * and the underlying `readMemoryIndex` load path). The retrospective index * loader shares the same shape (`updatedAt: string`) and will be wired to * the same helper in a future slice. * * Behavior: * - `isStale(updatedAt)` returns true when (now - updatedAt) > * thresholdDays * 86_400_000. Strict greater-than: a 30-day-old * entry is NOT stale. * - `applyStalePolicy(entries)` adds `stale: boolean` and * `ageDays: number` to every entry (computed at CLI load time, never * persisted to source `.md` files) and filters out entries where * `stale === true` unless `includeStale: true` is passed. * - Missing `updatedAt` is treated as fresh (`stale: false`, * `ageDays: 0`); we never throw, so older index.json entries that * lack the field stay loadable. */ export interface StalePolicyOptions { /** Reference clock (ms since epoch). Defaults to Date.now(). Injected for testability. */ now?: number; /** Threshold in days. Default 30. */ thresholdDays?: number; /** When true, keep stale entries in the returned array (with `stale: true` set). Default false. */ includeStale?: boolean; } export interface StaleAnnotated { stale: boolean; ageDays: number; } export type StaleAnnotatedEntry = T & StaleAnnotated; export interface StalePolicyResult { /** Filtered array, with stale entries removed (unless includeStale=true). */ entries: StaleAnnotatedEntry[]; /** Count of entries dropped as stale. */ droppedCount: number; /** Total count before filtering. */ totalCount: number; } export declare const DAY_MS = 86400000; export declare const DEFAULT_STALE_DAYS = 30; /** * Returns true when the entry is older than `thresholdDays`. Strict * greater-than: an entry exactly at the threshold is NOT stale. * * A missing or unparseable `updatedAt` is treated as fresh (false). This * is the "defensive — older index.json entries may lack the field" rule * from PRD R4. */ export declare function isStale(updatedAt: string | undefined | null, options?: StalePolicyOptions): boolean; /** * Age in days between `updatedAt` and `now` (default Date.now()). * Returns 0 for a missing / unparseable `updatedAt`. */ export declare function ageInDays(updatedAt: string | undefined | null, now?: number): number; /** * Apply the stale policy to a list of entries. Each entry is augmented * with `stale: boolean` and `ageDays: number` (immutably — a fresh * object is returned per entry). Stale entries are dropped from * `entries` unless `includeStale: true` is passed. */ export declare function applyStalePolicy(entries: T[], options?: StalePolicyOptions): StalePolicyResult;