import { type ReadOnlyEvent } from '@dxos/async'; import { type Context, Resource } from '@dxos/context'; import { BaseError } from '@dxos/errors'; /** * Longest a trace append waits for the background pass that indexes it. An agent turn appends trace * messages continuously, and starting a pass per append kept the worker saturated for the whole turn; * a reader that needs them sooner (a feed-scoped query, `flush`) drives the pass itself. */ export declare const TRACE_INDEX_DELAY_MS = 1000; /** Wait before retrying after a failed pass, doubled on each further failure up to {@link INDEX_RETRY_MAX_DELAY_MS}. */ export declare const INDEX_RETRY_DELAY_MS = 1000; export declare const INDEX_RETRY_MAX_DELAY_MS = 60000; declare const IndexPassFailedError_base: { new (options?: import("@dxos/errors").BaseErrorOptions): { cause?: unknown; stack?: string; name: "IndexPassFailedError"; context: Record; readonly message: string; readonly _tag: "IndexPassFailedError"; }; isError(error: unknown): error is Error; name: "IndexPassFailedError"; is(error: unknown): error is BaseError; wrap(options?: Omit & { ifTypeDiffers?: boolean; }): (error: unknown) => { cause?: unknown; stack?: string; name: "IndexPassFailedError"; context: Record; readonly message: string; readonly _tag: "IndexPassFailedError"; }; extend(name: Name, message?: string): any; captureStackTrace(targetObject: object, constructorOpt?: Function): void; prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined; stackTraceLimit: number; }; /** A pass failed before the changes a caller waited for were indexed; the cause is the pass's error. */ export declare class IndexPassFailedError extends IndexPassFailedError_base { } /** * Every path that can start an indexing run. Logged on each run so an idle-churn loop is * attributable from `app.log` alone — the counts are otherwise indistinguishable between a * data-driven pass and a self-sustaining invalidation cycle. */ export type IndexRunReason = 'open' | 'feed-blocks' | 'trace-blocks' | 'documents-saved' | 'batch-continuation' | 'retry' | 'rpc-update-indexes' | 'feed-scoped-query' | 'epoch'; /** Requests that drive the indexer directly, as opposed to the events that schedule it. */ export type IndexRequestReason = Extract; /** What the scheduler needs to know about a finished pass; `undefined` means the host is closing. */ export type IndexPassResult = { /** The pass found nothing more to index. */ done: boolean; /** Every input that existed when the pass started is indexed. */ drained: boolean; }; export type IndexSchedulerProps = { /** `FeedStore.onNewBlocks`. */ feedBlocks: ReadOnlyEvent<{ spaceId: string; feedNamespace?: string; }>; /** `AutomergeHost.documentsSaved`. */ documentsSaved: ReadOnlyEvent; /** Runs one pass over every data source, given the reasons that accumulated since the last one. */ runPass: (ctx: Context, reasons: Record) => Promise; }; /** * Decides when the index runs: subscribes to the writes that need indexing, coalesces them into * passes, and lets callers wait for the inputs that existed when they asked. */ export declare class IndexScheduler extends Resource { #private; constructor({ feedBlocks, documentsSaved, runPass }: IndexSchedulerProps); protected _open(): Promise; /** * Drains an in-flight pass, so a waiter's `runBlocking` loop is not left to hit the disposed * context on its next iteration and escape as an unhandled rejection. */ protected _close(): Promise; /** Starts a pass soon, coalesced with any other request made before it starts. */ schedule(reason: IndexRunReason): void; /** * Waits until every change made before the call is indexed. Changes made during the wait are left * to later passes, so a stream of writes cannot hold the caller. A no-op once closed: a late * caller has nothing to wait for, and `runBlocking` would throw on the disposed context. * * @throws {IndexPassFailedError} when a pass fails before those changes are indexed. */ waitForIndexed(reason?: IndexRequestReason): Promise; } export {}; //# sourceMappingURL=index-scheduler.d.ts.map