/** * Advisory locking for single-instance validation execution * * Uses proper-lockfile for cross-platform advisory locking with automatic * stale lock detection. Works reliably on Windows, macOS, and Linux. * * Note: Migrated from manual PID-based locking to proper-lockfile for * true advisory locking (99.9% reliability vs ~40% with manual approach). */ /** * Lock file information */ export interface LockInfo { /** Process ID holding the lock */ pid: number; /** Project directory path */ directory: string; /** Git tree hash at time of lock acquisition */ treeHash: string; /** ISO timestamp when lock was acquired */ startTime: string; } /** * Result of lock acquisition attempt */ export interface LockResult { /** Whether lock was successfully acquired */ acquired: boolean; /** Path to lock file */ lockFile: string; /** Information about existing lock (if acquisition failed) */ existingLock?: LockInfo; /** Release function (only present when acquired=true) */ release?: () => Promise; } /** * Lock scope options */ export interface LockOptions { /** * Concurrency scope for lock files * - 'directory': Each working directory has its own lock (default, allows parallel worktrees) * - 'project': All directories for the same project share a lock (prevents port/DB conflicts) */ scope?: 'directory' | 'project'; /** * Project identifier for project-scoped locking * Used when scope='project' to generate lock filename */ projectId?: string; } /** * Acquire validation lock using proper-lockfile * * Uses advisory locking with automatic stale lock detection. * If a lock already exists and is held by a running process, returns acquired=false. * Stale locks (from crashed processes) are automatically cleaned up. * * @param directory - Project directory to lock * @param treeHash - Current git tree hash * @param options - Lock scope options * @returns Lock acquisition result with release function */ export declare function acquireLock(directory: string, treeHash: string, options?: LockOptions): Promise; /** * Release validation lock * * Calls the release function returned by acquireLock. * Safe to call even if lock was already released. * * @param _lockFile - Path to lock file (for backwards compatibility, not used) * @param releaseFunc - Release function from acquireLock (preferred) */ export declare function releaseLock(_lockFile: string, releaseFunc?: () => Promise): Promise; /** * Check if a lock exists and is held by a running process * * @param directory - Project directory * @param options - Lock scope options * @returns Lock info if lock exists and is valid, null otherwise */ export declare function checkLock(directory: string, options?: LockOptions): Promise; /** * Wait for an existing lock to be released * * Polls the lock file until it's released or timeout is reached. * * @param directory - Project directory * @param timeoutSeconds - Maximum time to wait in seconds * @param pollInterval - How often to check in milliseconds * @param options - Lock scope options * @returns Object indicating if wait timed out */ export declare function waitForLock(directory: string, timeoutSeconds: number, pollInterval?: number, options?: LockOptions): Promise<{ timedOut: boolean; }>; //# sourceMappingURL=pid-lock.d.ts.map