import { type Database } from "./database.js"; /** * Delete session content blobs that no stored row refers to any more. * * A model-request snapshot is kept per attempt and replaced by each later * request of that attempt, and every request writes the body chunks the * session does not hold yet. Without collection the chunks only a replaced * snapshot named stay until the session is archived, which on long attempts is * most of what `session_content_blobs` holds. Collection is lossless: a blob * goes only when no snapshot or tool catalog of its session names it, it is * older than ten minutes, and the session's content lock is free (writers and * snapshot readers hold it shared; see `lockSessionContentShared`). * * Discovery and deletion are SECURITY DEFINER routines (migration 1359): the * worker cannot enumerate FORCE-RLS workspaces and the runtime may not delete * blobs itself. Until a migration grants them to the runtime, a pass collects * nothing. */ export declare const SESSION_CONTENT_GARBAGE_CANDIDATES_ROUTINE = "opengeni_private.session_content_garbage_candidates_v1(integer)"; export declare const COLLECT_SESSION_CONTENT_GARBAGE_ROUTINE = "opengeni_private.collect_session_content_garbage_v1(uuid, uuid, integer)"; export type SessionContentGarbageCandidate = { accountId: string; workspaceId: string; sessionId: string; }; export type SessionContentGarbageCollectionResult = { /** False while the deployment's database withholds the routines. */ available: boolean; sessions: number; deleted: number; failed: number; }; export declare function sessionContentGarbageCollectionAvailable(db: Database): Promise; export declare function listSessionContentGarbageCandidates(db: Database, limit: number): Promise; /** * Delete up to `limit` unreferenced blobs of one session. Returns how many were * deleted; fewer than `limit` means the session is collected for now (0 also * when the session is busy, archived or out of scope, which records nothing). */ export declare function collectSessionContentGarbage(db: Database, candidate: SessionContentGarbageCandidate, limit: number): Promise; /** * One bounded collection pass over the sessions whose snapshots changed since * they were last collected, sessions never collected first. Each session is * collected in batches until it has nothing left or the deadline passes; a * failing session never aborts the pass and is retried by a later one. */ export declare function collectSessionContentGarbagePass(db: Database, options: { deadline: number; now?: () => number; candidatesPerBatch?: number; blobsPerCall?: number; onSessionError?: (candidate: SessionContentGarbageCandidate, error: unknown) => void; }): Promise;