import { RecoveryStorageHealth } from "./compact-storage-health.ts";
import { type CompactFileRange, type CompactStorageFailure, type CompactStorageIo, type CompactStorageOperation } from "./compact-storage-io.ts";
/**
 * The spool file path of compact current-state storage (senpi#4272, R3.C6.4): one serial
 * asynchronous job chain, the private epoch directory, spool file writes, reads and reclamation,
 * and the failure ledger. `CompactContentStore` adds leaf ownership and spilling on top.
 */
export declare const RECLAIM_WORK_ALLOWANCE_BYTES: number;
export declare abstract class CompactSpoolStorage {
    readonly dir: string;
    readonly health: RecoveryStorageHealth;
    private readonly io;
    protected readonly failures: CompactStorageFailure[];
    private nextFile;
    private dirReady;
    private spoolToken;
    private chain;
    private queued;
    protected spillQueued: boolean;
    private halted;
    protected retired: boolean;
    protected pendingIoCopyBytes: number;
    protected spillBytesWritten: number;
    protected reclaimDebtBytes: number;
    private reads;
    private reading;
    assertReadable(): void;
    beginRead(): () => void;
    constructor(dir: string, io: CompactStorageIo, health?: RecoveryStorageHealth);
    /** Explicit availability repair: a real fsynced probe, then retry retained writes without changing accepted state. */
    repair(): Promise<string>;
    /** Resolves once every queued storage job, including the ones they queued, has completed. */
    idle(): Promise<void>;
    /**
     * Invalidates spilling, joins owned I/O, then removes the epoch directory only when this store
     * created it and it still passes the ownership checks; otherwise rejects with `CompactSpoolRefusedError`.
     */
    retire(): Promise<void>;
    /** Reads a committed file, or the `range` of it, and rejects a missing, unreadable or short one. */
    readFile(path: string, bytes: number, operation: CompactStorageOperation, range?: CompactFileRange): Promise<Buffer>;
    private readCommittedFile;
    /** Writes one new spool file; undefined means the write failed and was reported (a spill write also halts spilling). */
    writeFile(data: Buffer, operation: CompactStorageOperation, retainedInMemoryBytes: number): Promise<string | undefined>;
    /**
     * An unreferenced (or partially written) spool file: reclamation debt until its unlink completes or
     * finds it gone. Files dropped after retirement started belong to the directory retirement removes.
     */
    discard(path: string, bytes: number): void;
    /** A failed unlink keeps its debt and is retried with bounded backoff outside the job chain. */
    private reclaim;
    get spillAllowed(): boolean;
    /** True while a storage failure or unreclaimed debt above the work allowance holds spilling back. */
    protected get spillStopped(): boolean;
    enqueue(operation: CompactStorageOperation, job: () => Promise<void>): void;
    protected abstract scheduleSpill(): void;
    /** Creates the private epoch directory once; a refusal or failure halts spilling and is reported. */
    private ensureDir;
    private readFailure;
    private fail;
    private record;
}
//# sourceMappingURL=compact-spool-storage.d.ts.map