import lockfile from "proper-lockfile"; /** * Shared advisory-lock options for every file-backed store. * The cumulative retry budget (~24s) MUST exceed `stale` (10s): when a * process dies while holding a lock, waiters need to outlast the stale * window so they can steal the dead lock instead of throwing ELOCKED — * a failure mode the multiwriter soak's kill test reproduces. */ export declare const LOCK_OPTIONS: lockfile.LockOptions; export declare function enterReadOnlyMode(reason: string): void; /** Test-only escape hatch — module state would otherwise leak across tests. */ export declare function exitReadOnlyMode(): void; export declare function isReadOnly(): boolean; /** * Write a file atomically: write to a temp file in the same directory, then * rename over the target. Rename is atomic on POSIX, so readers observe * either the old content or the new content — never a torn write, even if * the process is killed mid-write. */ export declare function atomicWriteFileSync(filePath: string, content: string): void; /** * Create a file if and only if it does not exist yet (exclusive create). * The naive `if (!existsSync) writeFileSync(...)` has a cross-process race: * B can pass the existence check before A's file appears, then B's * initializer write clobbers data A committed in between — a lost-update * bug the multiwriter soak reproduces. O_EXCL makes creation atomic. */ export declare function ensureFileExists(filePath: string, initial?: string): void; /** * Read and parse a JSON file. Throws if file doesn't exist. * Retries once on a parse failure: with rename-based writes a torn read is * impossible, but this guards against files last written by older releases. */ export declare function readJSON(filePath: string): Promise; /** Write JSON to file atomically under advisory lock. */ export declare function writeJSON(filePath: string, data: unknown): Promise; /** Append a single JSON object as a line to a JSONL file under advisory lock. */ export declare function appendJSONL(filePath: string, data: unknown): Promise; /** * Read a JSONL file and parse each line. * Corrupt lines are skipped with a warning to stderr. * No locking needed for reads — appends are line-buffered and whole-file * rewrites are atomic renames, so a line is either absent, complete, or * (at worst, for a torn append tail) skipped by the parse guard below. */ export declare function readJSONL(filePath: string): Promise; /** * Overwrite a JSONL file atomically under lock. * Used by archiver to rewrite blackboard after removing archived entries. */ export declare function writeJSONL(filePath: string, data: unknown[]): Promise; /** Ensure a directory exists, creating it recursively if needed. */ export declare function ensureDir(dirPath: string): void; //# sourceMappingURL=file-store.d.ts.map