import { JournalRowStore } from "./journal-row-store.js"; import { type StateStoreSnapshotChunks, type StateStoreSnapshotEncoding, type StateStoreSnapshotPayload } from "./sync/state-store.js"; import type { SyncJournal, V3JournalState } from "./types.js"; export declare const JOURNAL_SNAPSHOT_V4_MAGIC: Buffer; type JournalSnapshotPayload = StateStoreSnapshotPayload; /** Return the packed views installed while decoding an HQSNAP4 payload, if any. */ export declare function decodedV4JournalRows(journal: SyncJournal): JournalRowStore | undefined; /** Test-only seam after v4 chunks become one contiguous decoder payload. */ export declare function setV4JournalSnapshotDecodeMemorySampleHookForTest(hook: (() => void) | undefined): void; /** * HQSNAP4 payload, frozen for the reader-before-writer release. * * The outer 52-byte StateStore header is unchanged: bytes 0..7 are ASCII * `HQSNAP4\\0`; bytes 8..15 are the unsigned generation (big-endian); bytes * 16..19 are the unsigned payload length (big-endian); bytes 20..51 are the * 32-byte scope digest. A trailing SHA-256 covers that header and every payload * byte. The payload is the following ordered sequence of sections. Each section * is `u32be byteLength`, exact bytes, then zero padding until the next section's * data starts on an eight-byte boundary. There is no implicit or optional * section, and padding bytes must be zero. * * 1. metadata JSON: `{lastRecordSequence,state:{journal:{version,lastSync,pulls}},rowCount,messages?}`; * it deliberately omits `journal.files`; the optional `messages` side table * is sorted `[rowId,message]` data for sparse share notes. * 2. directories JSON string table (id 0 is `""`). * 3. leafBlob raw bytes; every leaf is the row-store's `u32le UTF-8 length` * followed by its UTF-8 bytes. * 4. hashes: `rowCount * 32` raw bytes. * 5. remoteEtags: `rowCount * 16` raw bytes. * 6. sizes, mtimes, ctimes, syncedAts: each `rowCount` IEEE-754 binary64 LE. * 7. flags: `rowCount` unsigned 16-bit LE values. * 8. createdBySubs, dirIds, leaves: each `rowCount` unsigned 32-bit LE values. * 9. propertyOrderIds: `rowCount` unsigned 16-bit LE values. * 10. iterationNext and iterationPrevious: each `rowCount` signed 32-bit LE values. * 11. buckets: unsigned 32-bit LE values; its power-of-two length is encoded by * this section's byte length. * 12. hashFallbacks, etagFallbacks, syncedAtFallbacks, leafFallbacks, removedAts, * removedReasons, localDeleteIntents, authors, and propertyOrders: one JSON * section each, in exactly that order. Map sections are sorted `[rowId,value]` * pairs; `authors` id 0 is `""`; property orders are string-key arrays. * * The raw typed-array sections are little-endian. Node deployments are * little-endian; a big-endian host rejects HQSNAP4 rather than writing or * interpreting a different byte format. */ export declare function encodeV4JournalSnapshot(generation: number, scopeDigest: Buffer, payload: JournalSnapshotPayload): Buffer; /** * Encode HQSNAP4 as ordered durable buffers. StateStore writes these directly * so a journal generation never makes a whole JSON payload or body buffer. */ export declare function encodeV4JournalSnapshotChunks(generation: number, scopeDigest: Buffer, payload: JournalSnapshotPayload): StateStoreSnapshotEncoding; /** Decode an authenticated HQSNAP4 payload into row-store views, never JSON rows. */ export declare function decodeV4JournalSnapshot(chunks: StateStoreSnapshotChunks): unknown; export {}; //# sourceMappingURL=journal-snapshot-v4.d.ts.map