/** * Doc bytes on the sync stream (T13721). `docs_attachments` rows sync * (T12919), but their bodies live in `.cleo/blobs/blobs/`, which no * segment carries. After a push, each doc body this store has not put on the * stream goes up as an encrypted content-addressed blob * ({@link Journal.pushAttachment}); after a pull, each synced row whose body is * missing here is downloaded, verified and written * ({@link Journal.pullAttachment}). * * Healing a junk record (first writer wins on the server): a pull that refuses * a body clears its record when it may (E34); a push checks a recorded blob * before it trusts it, and re-checks a few bodies it already marked sent each * run, so a record cleared after it was marked is recorded again. * * Both legs walk the doc rows in sha256 order from a cursor kept in * `_sync_meta`, so rows that cannot move (no bytes anywhere yet, refused) * never starve the ones behind them. A server without the stream-attachment * routes answers 404: rows still sync, `docs fetch` reports no-content, and * one warning says why. No failure here fails the sync: it becomes a warning. * * @task T13721 */ import type { DatabaseSync } from 'node:sqlite'; import type { CloudWarning } from '@cleocode/contracts'; import { type Journal } from './journal.js'; /** What one run moved. */ export interface DocBytesReport { /** Bodies uploaded (push) or downloaded and written (pull). */ readonly moved: number; /** Bodies refused because they failed verification; nothing was written for them. */ readonly refused: number; } /** Options shared by {@link pushDocBytes} and {@link pullDocBytes}. */ export interface DocBytesOptions { /** The stream the bodies travel on. */ readonly stream: string; /** The store's `.cleo` directory (its blob store is `blobs/blobs/`). */ readonly cleoDir: string; /** Where warnings go. */ readonly warn: (w: CloudWarning) => void; /** The largest doc ciphertext either leg moves (default 64 MiB; tests shrink it). */ readonly maxBytes?: number; } /** * Put each doc body this store holds, and has not put on the stream, on it. * A body some member already recorded is checked, not uploaded again; a junk * record is cleared and replaced. Then a few bodies already marked sent are * re-checked, and recorded again when their record is gone. * * @param db - The project store. * @param journal - The stream's journal. * @param o - {@link DocBytesOptions}. * @returns What moved. */ export declare function pushDocBytes(db: DatabaseSync, journal: Pick, o: DocBytesOptions): Promise; /** * Download, verify and write each synced doc body missing from this store. * A body that fails verification is refused, nothing is written for it, and * its record is cleared when this device may (so a holder records it again). * * @param db - The project store. * @param journal - The stream's journal. * @param o - {@link DocBytesOptions}. * @returns What moved, and how many bodies were refused. */ export declare function pullDocBytes(db: DatabaseSync, journal: Pick, o: DocBytesOptions): Promise; //# sourceMappingURL=doc-bytes.d.ts.map