/** * Async read/write lock. * * Many concurrent readers OR one exclusive writer. Used by the MCP * dispatcher to let read tools (`*_inspect`, `environment_status`, …) * run in parallel while still serializing writes against everything. * * **Writer preference.** Queued writers are admitted before queued * readers when a write releases. This is the right default for scai: * an agent issuing a steady stream of reads must not starve a queued * `recipe_push` waiting to grab the exclusive slot. * * **Cancellation.** This primitive does not unwind a queued acquire when * its caller is cancelled. Callers that care should check their * AbortSignal immediately after `withRead`/`withWrite` admits them and * bail before doing real work. Holding the lock for the duration of a * no-op bail is negligible. */ export interface RwLockSnapshot { readers: number; writerActive: boolean; waitingReaders: number; waitingWriters: number; } export declare class RwLock { private readers; private writerActive; private waitingReaders; private waitingWriters; withRead(task: () => Promise): Promise; withWrite(task: () => Promise): Promise; private acquireRead; private releaseRead; private acquireWrite; private releaseWrite; /** Snapshot of internal state — for tests and diagnostics. */ snapshot(): RwLockSnapshot; /** * Drop all state. Used by tests to ensure no Promise-chain residue * carries across `describe` blocks. Production callers don't need this. */ reset(): void; }