import type { Goal, GoalStoreRef } from "./types.ts";
/**
 * One policy for every goal-lock contender. A goal read-modify-write takes milliseconds, so a
 * 10s stale window never mistakes a live holder (mtime refreshed every 2s) for a dead one,
 * while a holder killed mid-mutation is reclaimed within ~10s. The wait budget exceeds the
 * stale window, so waiters ride through a crashed holder instead of failing.
 */
export declare const GOAL_LOCK_OPTIONS: {
    readonly realpath: false;
    readonly stale: 10000;
    readonly update: 2000;
    readonly retries: 0;
};
export declare const GOAL_LOCK_WAIT_BUDGET_MS = 15000;
export declare class GoalStoreBusyError extends Error {
    readonly path: string;
    readonly waitedMs: number;
    constructor(path: string, waitedMs: number, cause?: unknown);
}
export declare class GoalStoreLockCompromisedError extends Error {
    readonly path: string;
    constructor(path: string, cause?: unknown);
}
/** Capabilities a mutation receives while it holds the goal lock. */
export interface HeldGoalLock {
    /** Throws GoalStoreLockCompromisedError when the lock was reclaimed; call before any side write. */
    assertHeld(): void;
    /** Writes the goal file only while the lock is still held. */
    write(goal: Goal | null): Promise<void>;
}
/**
 * The lock directory sits beside the goal file under a fixed-length name. proper-lockfile's
 * default `<file>.lock` would overflow NAME_MAX for a goal whose encoded basename is already
 * at the 255-byte component limit, which the store supports.
 */
export declare function goalLockFilePath(ref: GoalStoreRef): string;
/**
 * Serializes a goal mutation both within and across processes.
 *
 * The in-process promise tail (serializeByKey) runs first, so a process has at most one lock
 * acquisition in flight per goal. The file lock then guards the read-modify-write against
 * other processes, and `held.write` refuses to write once the lock has been reclaimed.
 */
export declare function withGoalFileLock<T>(ref: GoalStoreRef, fn: (held: HeldGoalLock) => Promise<T>): Promise<T>;
//# sourceMappingURL=goal-file-lock.d.ts.map