/** * Retention: what a finished session leaves on disk is reclaimed on a calendar, * not by hand. * * One directory per session holds that session's records and its output files, * so "old" is a property of the directory: its modification time moves on every * record write, because each write creates and renames a file inside it. Only a * directory past the window costs more than one `stat`, so a large `.pi/tasks` * is scanned cheaply and only what is about to be deleted is read and walked. * * @author mystery4f <40482524+mystery4f@users.noreply.github.com> */ import { type TaskScope } from "./runtime-state.js"; /** What one sweep reclaimed, and what it could not. */ export interface PruneReport { /** Session directories removed. */ readonly sessions: number; /** Bytes those directories held, records and output together. */ readonly bytes: number; /** Directories left behind because they could not be read or removed. */ readonly failures: number; } export interface PruneOptions { /** The session running now; its own directory is never a candidate. */ readonly scope: TaskScope; /** How old a session must be, in whole days, before it is reclaimed. */ readonly retentionDays: number; /** Clock seam for tests; defaults to `Date.now`. */ readonly now?: () => number; /** Where a kept directory and the one summary line are sent; silent by default. */ readonly report?: (message: string) => void; /** The deletion step, so a failing filesystem is testable; defaults to `rm`. */ readonly remove?: (directory: string) => Promise; } /** * Reclaim every session directory older than the window. A sweep that finds * nothing to do costs one `readdir` and one `stat` per session. */ export declare function pruneSessions(options: PruneOptions): Promise;