import { type FileHandle } from "node:fs/promises"; import { type PerformanceState } from "./schemas.js"; export declare const PERFORMANCE_FILENAME = "performance.json"; export declare const LOCK_FILENAME = "performance.lock"; export declare class PerformanceStoreError extends Error { readonly code: "corrupt" | "invalid_schema" | "io" | "busy" | "partial_write"; constructor(code: "corrupt" | "invalid_schema" | "io" | "busy" | "partial_write", message: string); } /** * Creates the data directory (0700) or validates an existing one: it must be a directory owned * by the current user, and group/other permission bits are removed. */ export declare function ensurePerformanceDirectory(directory?: string): Promise; /** * Opens a store file without following symlinks, then checks the handle: it must be a regular * file owned by the current user, and group/other permission bits are removed. Open errors other * than a symlink (e.g. ENOENT) are rethrown unchanged for the caller to classify. */ export declare function openPrivateFile(path: string, mode: "append" | "read", name: string): Promise; export declare function loadPerformanceState(directory?: string): Promise; /** Validates, then writes atomically (temp file + rename) with 0600 permissions. */ export declare function savePerformanceState(state: PerformanceState, directory?: string): Promise; export interface PerformanceUpdateOptions { lockTimeoutMs?: number; } type Mutator = (state: PerformanceState) => { state: PerformanceState; result: Result; } | Promise<{ state: PerformanceState; result: Result; }>; /** * Runs load → mutate → save → commit as one transaction. Writers are serialised in-process by a * queue and across processes by a lockfile. If `commit` (e.g. the audit append) fails, the * previous file contents are restored so callers can truthfully say nothing changed; if the * restore also fails, a `partial_write` error says so. */ export declare function commitPerformanceChange(mutate: Mutator, commit: (result: Result, state: PerformanceState) => Promise, directory?: string, options?: PerformanceUpdateOptions): Promise; export declare function updatePerformanceState(mutate: Mutator, directory?: string, options?: PerformanceUpdateOptions): Promise; export {}; //# sourceMappingURL=store.d.ts.map