/** * Per-session memo of the miner's output, keyed on file content. * * This is what makes an LLM-read-everything pipeline affordable. A closed * session transcript never changes again, so the model needs to read it exactly * once in its life. Hash the bytes, keep the candidates, and a routine `/learn` * pays for the one or two sessions written since the last run while the other * eighteen come back for free. * * It also happens to be the right answer to "incremental vs. full history", * which an earlier design tried to solve with an mtime cursor. A cursor breaks * the counting: if a run only *reads* sessions newer than the cursor, a * directive said once today has a count of one, because the four earlier * occurrences were never in the scan. Caching moves the skipping to the * expensive step only — the reduce step still runs over every cached session * every time, so the cross-session counts stay exact no matter how little was * mined this run. * * The cache is disposable. Deleting it costs one re-mine and nothing else, so * every failure path here degrades to "mine it again" rather than to an error. */ import type { MinedCandidate } from "./mine.js"; export interface CachedMining { /** Session identity, carried so a cache hit does not need the transcript reparsed. */ sessionId: string; /** Session start time, ISO. */ timestamp: string; candidates: MinedCandidate[]; /** When this entry was written, ISO. */ minedAt: string; } export declare function getLearnCacheDir(agentDir: string): string; /** * Content hash of a session file. * * Content, not mtime: a resumed session gets a fresh mtime with identical * bytes, and a file copied between machines gets a new mtime too. Both would * force a needless re-mine. Content also makes the reverse mistake impossible — * a file whose bytes changed always misses the cache, which matters because the * live session is appended to between runs. */ export declare function hashSessionFile(file: string): string | undefined; /** Look up a previously mined session. Any unreadable entry reads as a miss. */ export declare function readCachedMining(agentDir: string, hash: string): CachedMining | undefined; /** Store a mined session. Failing to cache is never worth failing the run over. */ export declare function writeCachedMining(agentDir: string, hash: string, entry: CachedMining): void; /** * Drop entries nothing has referenced in a long time, so a machine that has * been running this for a year does not keep every session it ever saw. */ export declare function pruneLearnCache(agentDir: string, now?: Date): void; /** * Counting what a run still owes the model lives in `extract.ts:planMining`, * not here: the answer depends on which sessions the window actually selects, * and duplicating that selection is how the confirmation prompt ends up * quoting a number the run does not honour. */ //# sourceMappingURL=cache.d.ts.map