import type { TestTarget } from '@histoire/cli/protocol/tests';
import type { RuntimeCatalog } from '../../catalog/publication.js';
import type { ProjectRuntimeHandle } from '../../types.js';
import type { AffectedChange, AffectedSelection } from './types.js';
/** Inputs of one per-generation selector. */
export interface AffectedSelectorOptions {
    /** Active generation: its context, watcher and collection observations. */
    handle: Pick<ProjectRuntimeHandle, 'context' | 'server' | 'onCollection' | 'isActive'>;
    /** Canonical catalog of the generation; scope and removed IDs resolve against it. */
    catalog: RuntimeCatalog | undefined;
    /** Aborted when the generation is released: detach everything. */
    signal: AbortSignal;
    /** Quiet period after an outdating event before re-analysis (tests only). */
    settleMs?: number;
}
/** Receives every change that selects something, in event order. */
export type AffectedListener = (change: AffectedChange) => void;
/**
 * Computes affected-story membership for one runtime generation. It owns a
 * detached copy of the last complete dependency evidence, so the eligibility
 * service retiring or forgetting a graph (edit, deletion) never loses
 * ownership before the event is classified. It never schedules anything.
 * @param options Generation-scoped capabilities.
 */
export declare function createAffectedSelector(options: AffectedSelectorOptions): {
    /**
     * Rebuilds the evidence index from the eligibility service. Replaces the
     * retained index only on success; failure, cancellation or an edit during
     * analysis keep the old graph. Concurrent calls coalesce into one rerun.
     * @returns Whether the index was replaced by this call's pass.
     */
    refresh(): Promise<boolean>;
    /**
     * Classifies one file event against the retained index. Graphs the event
     * outdates are marked before anything is awaited, so evidence order equals
     * event order. Unwatched leaves are rechecked for any non-ignored event.
     * @param event Chokidar event name.
     * @param file Absolute changed path.
     */
    classify(event: string, file: string): Promise<AffectedChange>;
    /**
     * Rechecks unwatched leaves after a completed collection; unchanged
     * revalidation selects nothing.
     * @returns The leaf change, or `undefined` when nothing moved.
     */
    checkLeaves(): Promise<AffectedChange | undefined>;
    /**
     * Receives every change that selects something, from watcher events and
     * leaf rechecks. Slice 10 accumulates these and calls `select` when a run
     * is safe.
     * @param listener Change receiver.
     * @returns Unsubscribe.
     */
    onChange(listener: AffectedListener): () => void;
    /**
     * Intersects accumulated changes with an exact scope against the current catalog.
     * @param scope All, one story, or one variant.
     * @param changes Changes since the last scheduled run.
     */
    select(scope: TestTarget, changes: readonly AffectedChange[]): AffectedSelection;
    /** Resumes observing file and collection events (idempotent); the caller refreshes evidence afterwards. */
    attach: () => void;
    /** Stops observing and scheduled re-analysis (idempotent); the retained evidence is kept. */
    detach: () => void;
    /** Counts of the retained evidence, for status lines and tests. */
    status(): {
        known: boolean;
        proven: number;
        unresolved: number;
        stale: number | "all";
    };
};
/** Per-generation selector. */
export type AffectedSelector = ReturnType<typeof createAffectedSelector>;
//# sourceMappingURL=selector.d.ts.map