/**
 * Project writer lock (#1740).
 *
 * At most one long-lived MCP *writer* (shared daemon OR direct-mode /
 * in-process engine that owns the FileWatcher) may serve a given project.
 * The shared daemon already multiplexes N stdio proxies onto one writer; this
 * lock closes the same-OS gap where two direct-mode `serve --mcp` processes
 * (via `CODEGRAPH_NO_DAEMON=1` or proxy→in-process fallback) each start a
 * watcher, contend on `codegraph.lock`, and degrade auto-sync.
 *
 * Deliberately separate from `daemon.pid`: proxies probe the daemon socket
 * and may clear a live pid that has no socket. A direct-mode holder must not
 * look like a daemon. `writer.pid` is only about "who owns live auto-sync".
 */
/** Absolute path to the writer pid lockfile for `projectRoot`. */
export declare function getWriterPidPath(projectRoot: string, lockName?: 'writer.pid' | 'rebuild.pid'): string;
/** Structured contents of the writer pidfile. */
export interface WriterLockInfo {
    pid: number;
    /** `direct` | `daemon` | `fallback` — for actionable error text only. */
    mode: string;
    startedAt: number;
    /** False until the MCP owner has finished its initial catch-up. */
    ready?: boolean;
}
export type WriterAcquireResult = {
    kind: 'acquired';
    pidPath: string;
    info: WriterLockInfo;
} | {
    kind: 'taken';
    existing: WriterLockInfo | null;
    pidPath: string;
};
export declare function decodeWriterLockInfo(raw: string): WriterLockInfo | null;
/**
 * Atomically create `writer.pid` (link-into-place, O_EXCL fallback). If held
 * by a dead PID, clear and retry once. Does not steal from a live holder.
 */
export declare function tryAcquireWriterLock(projectRoot: string, mode: string, lockName?: 'writer.pid' | 'rebuild.pid'): WriterAcquireResult;
/** Publish catch-up readiness without exposing a partially-written pidfile. */
export declare function markWriterReady(projectRoot: string): void;
/** Release if we still own the lock (pid match). */
export declare function releaseWriterLock(projectRoot: string, lockName?: 'writer.pid' | 'rebuild.pid'): void;
/** Read current lock without acquiring. */
export declare function readWriterLock(projectRoot: string, lockName?: 'writer.pid' | 'rebuild.pid'): WriterLockInfo | null;
/**
 * Actionable message when another live process owns the writer lock (#1740).
 */
export declare function writerLockHeldMessage(existing: WriterLockInfo | null, pidPath: string): string;
/** Rebuild intent is separate from writer ownership: acquire BEFORE stopping
 * the daemon, so its disconnected proxies cannot reopen SQLite in the gap. */
/**
 * An index rebuild (`codegraph index`) owns the database. Expected and brief,
 * so the MCP layer answers it as guidance, never as a tool error (#1325).
 */
export declare class RebuildInProgressError extends Error {
    constructor();
}
export declare function assertNoRebuild(root: string): void;
//# sourceMappingURL=writer-lock.d.ts.map