import type { RepackedPort } from "./port";
export interface RepackedVfsOpenOptions {
    /** Creation extent size: 8 KiB–16 MiB in 8 KiB steps. Defaults to 64 KiB. */
    extentSize?: number;
}
export interface RepackedStat {
    /**
     * `symlink` is only ever reported by `lstat` — `stat` follows the link and reports its target.
     * A link's `size` is the UTF-8 byte length of its target, exactly as POSIX `lstat` reports it.
     */
    readonly kind: "directory" | "file" | "symlink";
    readonly mode: number;
    readonly size: bigint;
    readonly atimeMs: bigint;
    readonly mtimeMs: bigint;
    readonly ctimeMs: bigint;
}
export type RepackReason = "manual" | "time" | "log-bytes" | "log-frames" | "writer-limit" | "quarantine-pressure" | "quota";
export interface RepackedVfsMetrics {
    readonly generation: bigint;
    readonly totalExtents: bigint;
    readonly availableExtents: number;
    readonly quarantineExtents: number;
    readonly quarantineBytes: bigint;
    readonly activeLogBytes: number;
    readonly activeLogFrames: number;
    readonly lastRepackReason: RepackReason | null;
    readonly lastRepackDurationMs: number | null;
    readonly repackCount: number;
    readonly pendingRepackReason: RepackReason | null;
    readonly flushes: Readonly<{
        amortized: number;
        arena: number;
        metadata: number;
        zeroBarrier: number;
        manifest: number;
    }>;
}
/**
 * The file surface of a repacked store, as a TYPE.
 *
 * `RepackedVfs` is the one-store implementation; {@link MountedRepackedVfs} is a composite of
 * several. Everything that takes a store — the sync broker above all — takes this, so a host can
 * hand it either without the two knowing about each other.
 */
export interface RepackedFileSystem {
    strictSync(): void;
    assertHealthy(): void;
    fail(cause: unknown): never;
    metrics(): RepackedVfsMetrics;
    repack(reason?: RepackReason): void;
    runScheduledRepack(nowMs?: number): boolean;
    /** The link-free absolute path `path` names; `follow` governs the final component only. */
    resolvePath(path: string, follow?: boolean): string;
    stat(path: string): RepackedStat;
    lstat(path: string): RepackedStat;
    symlink(target: string, path: string, nowMs: bigint): void;
    readlink(path: string): string;
    readdir(path: string): string[];
    mkdir(path: string, options: {
        recursive?: boolean;
        mode?: number;
        nowMs: bigint;
    }): void;
    writeFile(path: string, data: string | Uint8Array, options: {
        encoding?: string;
        mode?: number;
        flag?: string;
        nowMs: bigint;
    }): void;
    readFile(path: string): Uint8Array;
    truncate(path: string, size: bigint, nowMs: bigint): void;
    open(path: string, flags?: string, mode?: number, nowMs?: bigint): number;
    fstat(fd: number): RepackedStat;
    read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: bigint): number;
    write(fd: number, buffer: Uint8Array, offset: number, length: number, position: bigint | undefined, nowMs: bigint): number;
    chmod(path: string, mode: number, nowMs: bigint): void;
    utimes(path: string, atimeMs: bigint, mtimeMs: bigint, ctimeMs: bigint): void;
    unlink(path: string, nowMs: bigint): void;
    rmdir(path: string, nowMs: bigint): void;
    rename(oldPath: string, newPath: string, nowMs: bigint): void;
    close(): void;
    close(fd: number): void;
}
export declare class RepackedVfs implements RepackedFileSystem {
    #private;
    private constructor();
    static open(port: RepackedPort, options?: RepackedVfsOpenOptions): Promise<RepackedVfs>;
    strictSync(): void;
    assertHealthy(): void;
    fail(cause: unknown): never;
    cleanupFailedInit(): void;
    metrics(): RepackedVfsMetrics;
    repack(reason?: RepackReason): void;
    runScheduledRepack(nowMs?: number): boolean;
    /**
     * The link-free absolute path `path` names, without touching anything. A composite VFS resolves
     * across a mount boundary with it: this store answers for the part of the path it holds, stops at
     * the first component it does not have, and carries the rest through verbatim.
     */
    resolvePath(path: string, follow?: boolean): string;
    /** Follows a symbolic link on the final component; every intermediate link is always followed. */
    stat(requestPath: string): RepackedStat;
    /** Reports the LINK itself when the final component is one. */
    lstat(requestPath: string): RepackedStat;
    /** Create a symbolic link at `path` pointing at the ABSOLUTE `target`. The target is not read. */
    symlink(target: string, requestPath: string, nowMs: bigint): void;
    /** The target of the symbolic link at `path`. `EINVAL` when the path is not a link. */
    readlink(requestPath: string): string;
    readdir(requestPath: string): string[];
    mkdir(requestPath: string, options: {
        recursive?: boolean;
        mode?: number;
        nowMs: bigint;
    }): void;
    writeFile(requestPath: string, data: string | Uint8Array, options: {
        encoding?: string;
        mode?: number;
        flag?: string;
        nowMs: bigint;
    }): void;
    readFile(requestPath: string): Uint8Array;
    truncate(requestPath: string, size: bigint, nowMs: bigint): void;
    open(requestPath: string, flags?: string, mode?: number, nowMs?: bigint): number;
    fstat(fd: number): RepackedStat;
    read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: bigint): number;
    write(fd: number, buffer: Uint8Array, offset: number, length: number, position: bigint | undefined, nowMs: bigint): number;
    chmod(requestPath: string, mode: number, nowMs: bigint): void;
    utimes(requestPath: string, atimeMs: bigint, mtimeMs: bigint, ctimeMs: bigint): void;
    /** Removes a file or a SYMBOLIC LINK. The final component is never followed. */
    unlink(requestPath: string, nowMs: bigint): void;
    rmdir(requestPath: string, nowMs: bigint): void;
    /** Renames the entry itself: a symbolic link moves as a link, and its target is never followed. */
    rename(oldRequestPath: string, newRequestPath: string, nowMs: bigint): void;
    close(): void;
    close(fd: number): void;
}
//# sourceMappingURL=repacked-vfs.d.ts.map