/** * Hook ↔ daemon IPC over the daemon's lock socket / Named Pipe. * * Client side ({@link submitRecord}): * 1. Connect to {@link getLockSocketPath}. * 2. Write a single newline-terminated JSON request. * 3. Read a single newline-terminated JSON response. * 4. Close. * The promise resolves only after the daemon has fsynced the record's * byte to `queue.log`. * * Server side ({@link createIpcConnectionHandler}): * - Wait for one line of data on the connection. * - Parse it as an {@link IpcRequest}. * - Dispatch the `append` op into the daemon's {@link BatchingWriter}. * - Once the writer's promise settles, write a one-line * {@link IpcResponse} and close. * - Connections that close before sending a line are liveness probes * (used by {@link isDaemonAlive}); we let them go silently. */ import { Socket } from 'node:net'; import { BatchingWriter } from './batching_writer'; import { WalRecord } from './types'; export declare const MAX_REQUEST_BYTES: number; export declare function ipcRequestByteLength(record: WalRecord): number; /** * Send `record` to the running daemon and wait for the post-fsync ACK. * * Delivery semantics: **at-least-once**. * * A successful resolution means the record was durably fsynced to * `queue.log` at least once. A rejection means the daemon could not be * acknowledged after 7 attempts (1 initial + 6 backoffs from * `CONNECT_RETRY_DELAYS_MS`), but the daemon may still have persisted * the record on one of those attempts before the failure surfaced. * * The internal retry loop retries on five connect-class codes: * `ECONNREFUSED`, `ENOENT`, `EPIPE`, `ECONNRESET`, and * `EDAEMONNORESPONSE`. The first two prove the request never reached a * daemon and are safe; the last three can fire *after* the daemon has * already fsynced (e.g. daemon crashed between fsync and ACK, or the * socket reset post-fsync), so a single logical submit can produce * more than one physical line in `queue.log` and more than one * `createTrace` call to the backend. * */ export declare function submitRecord(record: WalRecord): Promise; /** * Build the per-connection handler that the daemon installs on its * lock-socket server. Bound to a {@link BatchingWriter} so the * fsync-coalescing state persists across connections. */ export declare function createIpcConnectionHandler(writer: BatchingWriter): (socket: Socket) => void;