export declare const STORAGE_WRITE_BEHIND_FAILED = "STORAGE_WRITE_BEHIND_FAILED"; /** * Guard against a write-behind flush clobbering a newer write. `expectedRevision` * is the revision the flush's payload was derived from; `fetchRevision` re-reads * the current revision of record (the DB row, not Storage) immediately before * each retry attempt. A mismatch means someone else's write landed after this * flush was scheduled — the flush is abandoned as a no-op rather than retried, * since retrying would overwrite the newer content with stale data. */ export interface RevisionGuard { expectedRevision: string; fetchRevision: () => Promise; } export declare class SupersededFlushError extends Error { constructor(); } export interface BoundedRetryOptions { maxAttempts?: number; baseDelayMs?: number; sleep?: (ms: number) => Promise; isRetryable?: (err: unknown) => boolean; revisionGuard?: RevisionGuard; } /** * Retry `fn` up to `maxAttempts` times with bounded exponential backoff * (baseDelayMs * 2^attempt between attempts). Only retries errors classified * as transient — permanent errors (404/401/plain 403/conflict) are rethrown * immediately on the first attempt. Rethrows the last error once attempts * are exhausted or a permanent error is hit; the thrown error carries an * `attempts` property recording how many attempts actually ran. * * When `revisionGuard` is supplied, it is checked before every retry attempt * (i.e. before attempt 2+): if the current revision no longer matches the * revision this flush was derived from, the retry loop abandons with a * `SupersededFlushError` instead of overwriting newer content. */ export declare function withBoundedRetry(fn: () => Promise, options?: BoundedRetryOptions): Promise; /** * Fire-and-forget write-behind flush with bounded retry. Never rejects: on * exhaustion it emits a terminal, greppable STORAGE_WRITE_BEHIND_FAILED log * (page name + attempt count) instead of leaving the drift silent. A flush * abandoned because a newer revision superseded it (see `revisionGuard`) is * treated as a success no-op and does not log a failure signal. */ export declare function flushWithRetry(fn: () => Promise, pageName: string, options?: BoundedRetryOptions): Promise; //# sourceMappingURL=writeBehindRetry.d.ts.map