/** * Write content to a file atomically. * Writes to a temp file first, then renames to the target path. * This ensures the file is never in a partially-written state. * If the process crashes between write and rename, the original file is intact. * * Durability note: no fsync is performed. This protects against torn or partial * writes within the process — it does not guarantee the data survives power loss. * * D16: through a symlink the rename lands on the link's TARGET (the link * survives, the target updates); a hardlinked file (nlink > 1) is written in * place so the shared inode observes the edit. */ export declare function atomicWriteFile(filePath: string, content: string): Promise; /** * Batch write, executed in three passes (D1): * * RESOLVE — compute resolveWriteTarget for every entry up front. * STAGE — write temp files for every non-inPlace entry only; NO in-place * writes yet, so a staging failure leaves ZERO user-visible writes. * COMMIT — in ORIGINAL batch order, rename each staged temp / writeFile each * in-place member. * * NOT a cross-file transaction. Each individual rename is atomic on the same * filesystem, but the batch as a whole is best-effort: a failure or crash * during COMMIT leaves earlier files updated and later files untouched — there * is no rollback of already-committed renames. "No partial updates" does not * hold across the commit phase. A failure during STAGE, by contrast, leaves * every file unmodified (nothing is committed until all temps are staged). * * Failures are reported as a structured BatchWriteError carrying the list of * filePaths whose content landed (`written`), the failing entry's filePath * (`failed`), and which phase failed (`phase`). * * D16: every entry resolves its write target exactly like atomicWriteFile — * symlinks are replaced at the link target, hardlinked files (nlink > 1) are * written in place. In-place members are committed during COMMIT (in batch * order), not during STAGE. */ export declare class BatchWriteError extends Error { /** filePaths whose content landed (temp renamed or in-place written) before the failure. */ readonly written: string[]; /** the failing entry's filePath. */ readonly failed: string; /** which pass the failure occurred in. */ readonly phase: "staging" | "commit"; constructor(opts: { written: string[]; failed: string; phase: "staging" | "commit"; cause: unknown; }); } export declare function atomicWriteBatch(writes: Array<{ filePath: string; content: string; }>): Promise; /** * Pre-write best-effort CAS: re-read the file and confirm it still matches the * content version observed earlier. Returns a human-readable conflict * description, or null when the file is unchanged (or, for a to-be-created * file, still absent). * * `expectedVersion === null` means the file did not exist during the read phase * and is expected to be created — any existing file at this point is a conflict. * * This is best-effort only: it does not lock the file against other processes, * so a file changed between this check and the subsequent rename is not * detected. It is NOT a strict cross-process CAS. */ export declare function verifyFileUnchanged(filePath: string, expectedVersion: string | null): Promise; //# sourceMappingURL=atomic-write.d.ts.map