/** * Minimal tombstones (journal spec §1.7, NEW-2, R5-5; T12986, S3c). * * The sealer writes a FULL tombstone on D: the row meta with `deleted = 1`, * the delete HLC, the natural key and the before-image hash. GC never forgets * that a uid was deleted; once the stream is safely past a tombstone, * {@link compactTombstones} shrinks it to the minimal form * (`tbl`, `uid`, `hlc`, `deleted = 1`), so a receiver can still tell a * deleted uid from a never-seen one and a late op never resurrects the row. * It is found by its WITHOUT ROWID key and has no entry in the tombstone * index (which holds only full tombstones): about 155 B per row as measured, * within the spec's ~190 B. * * Append-only tables get no per-row tombstone at all (the sealer removes * their meta on D); the horizon fold into `_sync_tomb_fold` needs checkpoint * receive watermarks and is S4. * * What makes a tombstone compactable is stream state this slice does not own * (the latest verified checkpoint's `ReplicaHeads`, T12338; the inbox's * pending and void transactions, T12344), so the caller supplies it as a * {@link TombstoneGcPolicy}. * * @module store/sync/tombstones * @task T12986 * @epic T12323 */ import type { DatabaseSync } from 'node:sqlite'; /** Grace after a tombstone's physical time before it may be compacted (§1.7). */ export declare const TOMBSTONE_GRACE_MS: number; /** When a full tombstone may shrink to its minimal form. */ export interface TombstoneGcPolicy { /** * The highest HLC every live replica has covered: in the latest verified * checkpoint's `ReplicaHeads`, each live replica's `lastReplicaSeq` covers a * segment whose `hlcMax` is at least this. Retired replicas are left out by * the caller (§1.5). Only tombstones at or below it are compacted. */ readonly coveredHlc: string; /** Wall clock, ms. */ readonly now: number; /** @defaultValue {@link TOMBSTONE_GRACE_MS} */ readonly graceMs?: number; /** * Whether a `pending` or `void` inbox transaction references the uid * (T12344). Such a full tombstone is kept: the void may yet be revived. */ readonly referenced: (tbl: string, uid: string) => boolean; /** Most tombstones examined per call. @defaultValue 5000 */ readonly budget?: number; } /** What {@link compactTombstones} did. */ export interface TombstoneCompactReport { /** Full tombstones shrunk to the minimal form. */ readonly compacted: number; /** Eligible by HLC and age, kept because an inbox transaction references the uid. */ readonly referenced: number; /** Covered, but younger than the grace period. */ readonly young: number; } /** * Shrink full tombstones the stream no longer needs to their minimal form, * in one `BEGIN IMMEDIATE`. Never deletes a tombstone: a minimal one is kept * for good (NEW-2). * * The minimal form keeps `tbl`, `uid`, `hlc` and `deleted = 1`; `origin` and * `version` take their empty values (`''`, `0`) because the columns are * NOT NULL, and `sent`, `held` and `fk_excluded` are left as they are. */ export declare function compactTombstones(db: DatabaseSync, policy: TombstoneGcPolicy): TombstoneCompactReport; /** Tombstone counts for the doctor and the growth measurement (§1.7 R5-5). */ export declare function tombstoneCounts(db: DatabaseSync): { full: number; minimal: number; }; //# sourceMappingURL=tombstones.d.ts.map