/** * Retention cap enforcement for the local analytics sink (events.ndjson). * * Policy (enforced on server boot and periodically afterwards): * - Size cap: 50 MB — truncate to the newest events that fit. * - Age cap: 30 days — drop events older than this by their `ts` field. * The stricter of the two wins; oldest-first truncation always preserves * the newest events. * * Atomicity: rewrites happen via a temp-file rename so a crash mid-write * never leaves a corrupt or empty events file. The write path must be in * the same directory (same filesystem partition) as the target so rename() * is atomic. * * Concurrency: callers MUST run sweepNdjson() through EventStore.runExclusive() * so the sweep's read→filter→rename window never races a concurrent append. * The store serializes all appends through a promise queue; runExclusive() * chains the sweep onto that same queue, guaranteeing mutual exclusion. * See store.ts and server/index.ts for the wiring. * * Corruption tolerance: lines that fail JSON.parse are silently kept rather * than aborting the sweep — a single bad line never blocks retention. */ /** 50 MB default size cap. */ export declare const DEFAULT_MAX_SIZE_BYTES: number; /** 30 days default age cap. */ export declare const DEFAULT_MAX_AGE_MS: number; export interface SweepOptions { maxSizeBytes?: number; maxAgeMs?: number; } export interface SweepResult { /** Number of lines in the file before the sweep. */ linesBefore: number; /** Number of lines retained after the sweep. */ linesAfter: number; /** True when the file was actually rewritten (something was trimmed). */ rewritten: boolean; } /** * Enforces size and age caps on an ndjson file, retaining the newest events. * * Returns a SweepResult describing what happened. Never throws on ENOENT * (the file doesn't exist yet — that's fine). Propagates other I/O errors * to the caller. * * IMPORTANT: callers must run this through EventStore.runExclusive() to * prevent races with concurrent appends (see module-level docstring). */ export declare function sweepNdjson(filePath: string, options?: SweepOptions): Promise; //# sourceMappingURL=store-retention.d.ts.map