import { type DomainRecord } from "./domain-db.js"; export interface DomainSnapshot { created: string; schema_version: number; count: number; records: DomainRecord[]; } export interface RestoreClient { get(key: string): Promise; set(key: string, value: string, mode: "EX", ttl: number): Promise; } export interface RestoreResult { total: number; restored: number; skipped: number; } /** * Structural validation of a snapshot record before it is re-seeded into Valkey * (LOW-1). Snapshot files live in an operator-owned dir, but the restore path is * the one place external file contents flow back into the live domain-db, where * tier_stats_30d drives tier-skip routing and domain_stats rendering. Rejecting * malformed records here stops a crafted snapshot from injecting entries that * skew routing or crash domain_stats single mode. Beyond schema_version+domain, * require the last_fetch/first_seen strings and a numeric tier_stats_30d block. */ export declare function isStructurallyValidRecord(value: unknown): value is DomainRecord; /** Filesystem-safe, lexicographically-sortable snapshot filename for `now`. */ export declare function snapshotFilename(now: Date): string; /** * Write a snapshot of `records` to `dir` (created if absent). Returns the full * path and record count. */ export declare function writeSnapshot(dir: string, records: DomainRecord[], now?: Date): Promise<{ path: string; count: number; }>; /** List snapshot filenames in `dir`, oldest first. Missing dir → empty. */ export declare function listSnapshots(dir: string): Promise; /** * Delete snapshots beyond the newest `retention` files. Returns the deleted * filenames. `retention < 1` is treated as 1 (never prune everything). */ export declare function pruneSnapshots(dir: string, retention: number): Promise; /** Load and parse the newest snapshot in `dir`, or null if none/invalid. */ export declare function loadLatestSnapshot(dir: string): Promise; /** * Re-seed `records` into Valkey, restoring only keys that are missing or whose * live record is strictly staler than the snapshot (older last_fetch). Never * overwrites a fresher-or-equal live record. Structurally invalid or * stale-schema records are skipped (LOW-1 guard). Best-effort per key — a * single failure is counted as skipped, not fatal. */ export declare function applyRestore(client: RestoreClient, records: DomainRecord[]): Promise;