/** * GC Runner — Core garbage collection logic for autonomous transcript cleanup. * * Performs disk-pressure-aware pruning of ephemeral transcript and temp files * under `~/.claude/projects/` using the five-tier threshold model from T751. * * Retention policy (per ADR-047 and docs/specs/memory-architecture-spec.md §8): * - `.temp/` files: 24h normal, 1h emergency * - Transcript directories (agent-*.jsonl, tool-results/): 7d normal, 1d emergency * - `.cleo/logs/`: 30d normal, 7d emergency * - `.cleo/agent-outputs/*.md` (committed artifacts): NEVER auto-pruned * * Circuit breaker: if `ANTHROPIC_API_KEY` is absent AND no local model configured, * skip extraction and only delete transcripts older than 30 days. * * @see ADR-047 — Autonomous GC and Disk Safety * @see docs/specs/memory-architecture-spec.md §8 * @task T731 * @epic T726 */ /** * Disk usage percentage thresholds. * * Values mirror the five-tier model recommended by T751 research §3.2: * - OK: < 70% — routine cleanup by age policy only * - WATCH: 70-85% — log + schedule next GC sooner * - WARN: 85-90% — log + set escalation flag for next CLI invocation * - URGENT: 90-95% — auto-prune oldest transcripts immediately * - EMERGENCY: ≥ 95% — auto-prune all transcripts > 1d, pause new writes */ export declare const DISK_THRESHOLDS: { readonly WATCH: 70; readonly WARN: 85; readonly URGENT: 90; readonly EMERGENCY: 95; }; /** Human-readable tier labels. */ export type DiskTier = 'ok' | 'watch' | 'warn' | 'urgent' | 'emergency'; /** * Result of a single GC run. */ export interface GCResult { /** Disk usage percentage at time of GC run (0–100). */ diskUsedPct: number; /** Disk tier classification. */ threshold: DiskTier; /** Files pruned during this run. */ pruned: Array<{ path: string; bytes: number; }>; /** Total bytes freed. */ bytesFreed: number; /** Whether escalation flag was set (disk ≥ WARN). */ escalationSet: boolean; /** Human-readable escalation reason (set when escalationSet=true). */ escalationReason: string | null; /** ISO-8601 timestamp of run completion. */ completedAt: string; } /** * Options for a GC run. */ export interface GCRunOptions { /** * Absolute path to the `.cleo/` directory (used for state file and disk check). * Defaults to `~/.cleo`. */ cleoDir?: string; /** * Override the default `~/.claude/projects/` scan directory. * Primarily used in tests to point at a temp directory. */ projectsDir?: string; /** * Paths from a previous crashed run to resume deletion from. * Written to `pendingPrune` in gc-state.json BEFORE starting deletion. */ resumeFrom?: string[]; /** * Dry-run mode: compute what would be pruned, but make zero filesystem changes. */ dryRun?: boolean; } /** * Classify a disk usage percentage into a tier. * * @param pct - Disk usage percentage (0–100) * @returns DiskTier */ export declare function classifyDiskTier(pct: number): DiskTier; /** * Compute retention threshold in milliseconds based on disk tier. * * Higher disk pressure → shorter retention → more aggressive pruning. * * @param tier - Current disk tier * @returns Maximum age in milliseconds for transcript retention */ export declare function retentionMs(tier: DiskTier): number; /** * Get the size of a path in bytes (file or directory recursively). * Returns 0 if the path does not exist. * * @param targetPath - Path to measure * @returns Size in bytes */ export declare function getPathBytes(targetPath: string): Promise; /** * Idempotently delete a path (file or directory). * * Silently ignores ENOENT — safe to call if path was already deleted. * Uses `force: true` to suppress errors on missing paths. * * @param targetPath - Path to delete */ export declare function idempotentRm(targetPath: string): Promise; /** * Execute a GC run: check disk pressure, determine retention threshold, * prune eligible transcript files, update gc-state.json. * * This function is idempotent and safe to call multiple times. Crash recovery * is implemented via the `pendingPrune` field in gc-state.json: * 1. Write paths to `pendingPrune` BEFORE starting deletion * 2. Remove each path from `pendingPrune` AFTER successful deletion * 3. Clear `pendingPrune` when the job completes * * @param opts - GC run options * @returns GC run results */ export declare function runGC(opts?: GCRunOptions): Promise; //# sourceMappingURL=runner.d.ts.map