import { Client } from '@atcute/client'; import { D as Database, S as Statement, C as ContrailConfig } from './types-CmjW-xL4.js'; declare const INGEST_DIAGNOSTIC_CATEGORIES: readonly ["unknown_collection", "invalid_json", "lexicon_validation", "cid_mismatch", "cid_encoding", "missing_cid", "record_filter", "unknown_actor", "unknown_subject", "superseded"]; type IngestDiagnosticCategory = (typeof INGEST_DIAGNOSTIC_CATEGORIES)[number]; interface IngestDiagnostic { category: IngestDiagnosticCategory; total: number; last_seen_at: number | null; } type IngestDiagnosticCounts = Partial>; /** Merge one ingest decision batch into a bounded in-memory aggregate. */ declare function addIngestDiagnosticCounts(target: IngestDiagnosticCounts, counts: IngestDiagnosticCounts): void; /** Build one bounded aggregate update for an ingest transaction. */ declare function ingestDiagnosticsStatement(db: Database, counts: IngestDiagnosticCounts, nowUs?: number): Statement | null; /** Private, aggregate-only diagnostics. Never includes DIDs, URIs, or records. */ declare function getIngestDiagnostics(db: Database): Promise; interface BackfillCollectionMetrics { requests: number; pages: number; fetched_records: number; accepted_records: number; record_bytes: number; fetch_ms: number; projection_and_checkpoint_ms: number; } interface BackfillRunMetrics { resolution_ms: number; derived_rebuild_ms: number; collections: Record; } type BackfillMetricsAccumulator = BackfillRunMetrics; interface BackfillOptions { /** Pre-resolved client — avoids redundant PDS lookups when batching by DID */ client?: Client; /** Complete relay-discovered actor set for dependent-record admission. */ knownDids?: ReadonlySet; /** Skip replay detection during initial backfill. */ skipReplayDetection?: boolean; /** Max retries per request (default: 3). Set to 0 for single-attempt mode. */ maxRetries?: number; /** Per-request timeout in ms (default: 10000). */ requestTimeout?: number; /** Mark the row terminal when this consecutive-failure count is reached. */ exhaustAfterAttempts?: number; /** Yield after this many successful pages without consuming a retry. */ maxPages?: number; /** Defer FTS and relation counts until the bulk pass finishes. */ skipDerivedProjections?: boolean; /** @internal Aggregate benchmark instrumentation owned by the bulk run. */ metrics?: BackfillMetricsAccumulator; /** @internal Cursor already loaded by the bulk scheduler. */ resumeState?: { cursor: string | null; }; /** @internal Bounded diagnostics shared by one bulk run. */ aggregateDiagnostics?: IngestDiagnosticCounts; } declare function backfillUser(db: Database, did: string, collection: string, deadline: number, config: ContrailConfig, options?: BackfillOptions): Promise; interface BackfillProgress { records: number; usersComplete: number; usersTotal: number; usersFailed: number; } interface BackfillAllOptions { /** Concurrent identity resolutions before work is grouped by PDS. Default: 100. */ concurrency?: number; /** PDS hosts allowed to fetch concurrently. Default: 20. */ pdsConcurrency?: number; /** Accounts allowed to fetch concurrently from one PDS. Default: 3. */ didsPerPds?: number; /** Per-request timeout in milliseconds. Default: 10000. */ requestTimeoutMs?: number; /** Immediate attempts per failed account. Default: 1; scheduled retries handle * later attempts. Values above 1 are retained for explicit manual recovery. */ maxAttempts?: number; onProgress?: (progress: BackfillProgress) => void; /** Receives aggregate source/projection timings after a complete invocation. */ onMetrics?: (metrics: BackfillRunMetrics) => void; } declare function backfillPending(db: Database, config: ContrailConfig, options?: BackfillAllOptions): Promise; interface BackfillRetryOptions { /** Maximum accounts to attempt in one scheduled slice. Default: 5. */ maxAccounts?: number; /** Failed scheduled attempts before automatic retries stop. Default: 10. */ maxAttempts?: number; /** Total wall-clock budget for the slice. Default: 10000ms. */ timeoutMs?: number; /** Deadline for each PDS request within the slice. Default: 3000ms. */ requestTimeoutMs?: number; } interface BackfillRetryResult { attempted: number; completed: number; failed: number; records: number; skipped: boolean; } /** Retry a small due slice without resetting persisted failure backoff. Safe for * scheduled runtimes: one database-backed run lease prevents overlap. */ declare function retryPendingBackfills(db: Database, config: ContrailConfig, options?: BackfillRetryOptions): Promise; interface DiscoverDIDsOptions { /** Legacy direct callers anchor the live cursor before discovery. A bootstrap * coordinator already owns a separate durable capture position. */ captureReplayBoundary?: boolean; signal?: AbortSignal; } declare function discoverDIDs(db: Database, config: ContrailConfig, deadline: number, options?: DiscoverDIDsOptions): Promise; interface DiscoverAndBackfillResult { discovered: string[]; backfilled: number; } /** Hold one lease across relay discovery and the complete initial PDS pass. */ declare function discoverAndBackfill(db: Database, config: ContrailConfig, options?: BackfillAllOptions, onDiscovered?: (count: number) => void): Promise; export { type BackfillRetryOptions as B, type DiscoverAndBackfillResult as D, type IngestDiagnostic as I, type BackfillAllOptions as a, type BackfillRetryResult as b, type IngestDiagnosticCounts as c, type BackfillCollectionMetrics as d, type BackfillOptions as e, type BackfillProgress as f, type BackfillRunMetrics as g, type DiscoverDIDsOptions as h, INGEST_DIAGNOSTIC_CATEGORIES as i, type IngestDiagnosticCategory as j, addIngestDiagnosticCounts as k, backfillPending as l, backfillUser as m, discoverAndBackfill as n, discoverDIDs as o, getIngestDiagnostics as p, ingestDiagnosticsStatement as q, retryPendingBackfills as r };