/** * File-locked JSONL append for concurrent write safety. * * When multiple workers write to the same shared JSONL (orchestrator pattern), * this module ensures atomic appends via advisory file locking (flock). * Each write acquires an exclusive lock, appends the JSON line, and releases. * * Diagnostics: logs lock contention (wait > 100ms) and tracks write durations. */ /** * Append a JSON line to a JSONL file with process-level serialization. * * Uses an in-process queue (Promise chain) to serialize writes to the same file. * For multi-process safety (multiple gateway instances), the append is atomic * at the OS level for small writes (< PIPE_BUF, typically 4KB on Linux). * * @param filePath - Absolute path to the JSONL file * @param data - Object to serialize as a JSON line * @param writer - Optional label for diagnostic logging (e.g., "worker-1713000000") * @returns The serialized JSON line that was written */ export declare function lockedAppend(filePath: string, data: unknown, writer?: string): Promise; /** * Validate JSONL file integrity — check each line is parseable JSON. * Returns corrupted line numbers (1-indexed) and their raw content. */ export declare function validateJsonl(filePath: string): { valid: boolean; corrupted: Array<{ line: number; raw: string; }>; }; //# sourceMappingURL=jsonl-lock.d.ts.map