/** * Racing an in-flight storage observation against abort signals (WFT-84, WFT-85). * * Storage has no cancellation contract, so a stalled remote read cannot be * cut short. What can be cut short is the caller's wait: the moment any of the * signals fires, or the wait's own budget runs out, the observation is * reported as aborted and the read is left to settle on its own. Kept to the * fewest promise hops, because the deterministic fake-timer tests drain a * fixed number of microtask turns between ticks. * * @module core/application-primitive-abort */ import { WeftError } from './weft-error.ts'; /** The outcome of racing an in-flight observation against abort signals. */ export type Raced = { readonly aborted: false; readonly value: T; } | { readonly aborted: true; readonly reason: unknown; }; /** * Thrown by `Mailbox.awaitCleanup()` when a positive budget runs out * while the FIRST cleanup-state read is still in flight — there is no * observation yet to report as `pending`. Nothing durable changed; the wait is * simply over. * * @example * ```ts * import { WaitBudgetElapsedError } from '@lostgradient/weft'; * * const error = new WaitBudgetElapsedError(); * console.log(error.code); // 'WaitBudgetElapsedError' * ``` */ export declare class WaitBudgetElapsedError extends WeftError<'WaitBudgetElapsedError'> { constructor(); } /** * Run an observation unless any of the signals is, or becomes, aborted while * it is in flight. `undefined` signals are ignored. */ export declare function raceAbort(run: () => Promise, ...signals: readonly (AbortSignal | undefined)[]): Promise>; /** * `raceAbort` with a budget: when `budgetMs` is a positive number, a timer of * that length also ends the race, with `WaitBudgetElapsedError` as the reason. * A bounded wait is bounded by this even while a remote read is stalled; the * sleeps between observations are not the only place a budget can run out. */ export declare function raceAbortWithin(run: () => Promise, budgetMs: number | null, ...signals: readonly (AbortSignal | undefined)[]): Promise>;