/**
 * WASM parse worker pool with crash recovery.
 *
 * The WASM grammar can trigger uncatchable V8 fatal errors (#965) that kill
 * whichever thread is running it. Running parses in a worker_thread means the
 * crash kills only the worker — the pool detects the exit, marks the in-flight
 * file as skipped, respawns the worker, and continues with the rest.
 *
 * This is a single-worker pool; dispatch is sequential. Multi-worker parallelism
 * is a future optimization — correctness of crash isolation does not depend on
 * it. Sequential dispatch also simplifies attribution of a crash to a single
 * "in-flight" file.
 */
import type { ExtractorOutput } from '../types.js';
import type { WorkerAnalysisOpts } from './wasm-worker-protocol.js';
export declare class WasmWorkerPool {
    private worker;
    private nextId;
    private queue;
    private inFlight;
    private disposed;
    /** filePaths that already caused one worker crash — skipped rather than retried. */
    private crashedFiles;
    /**
     * Tracks the id of the job whose timeout fired and triggered `terminate()`.
     * Node timers are delivered before poll-phase I/O, so `onTimeout` can fire in
     * the same loop iteration that already has the worker's response queued. In
     * that race, `onMessage` resolves the timed-out job and starts the next one
     * BEFORE `onExit` arrives for the earlier `terminate()` — so the `inFlight`
     * job `onExit` sees is the innocent next job, not the one that actually hung.
     * `onExit` uses this field to detect the mismatch and re-queue the new job
     * instead of silently discarding it.
     */
    private timedOutJobId;
    /**
     * Parse a single file via the worker. Returns the fully pre-computed
     * ExtractorOutput, or `null` if the worker crashed on this file or
     * reported a soft error.
     */
    parse(filePath: string, code: string, opts: WorkerAnalysisOpts): Promise<ExtractorOutput | null>;
    /** Terminate the worker and drain pending jobs with null results. */
    dispose(): Promise<void>;
    private pump;
    /**
     * Called when the per-job watchdog fires. Terminate the worker so the
     * hang stops consuming CPU; `onExit` will then resolve the in-flight job
     * with `null` and blacklist the file via `crashedFiles`.
     */
    private onTimeout;
    private ensureWorker;
    private onMessage;
    private onError;
    private onExit;
}
/** Shared pool instance for the process. Callers share the worker across builds. */
export declare function getWasmWorkerPool(): WasmWorkerPool;
/** Dispose the shared pool (used by tests + `disposeParsers`). */
export declare function disposeWasmWorkerPool(): Promise<void>;
//# sourceMappingURL=wasm-worker-pool.d.ts.map