/** * runPool — generic in-flight-capped worker pool. * * Single concurrency primitive for the project: every "run N independent * operations with at most M in flight" need routes here. Currently consumed * by `batch_execute`; P2-T2 (web fetch + index) will reuse it. * * Design contract: * - Order-preserving: results[i] corresponds to jobs[i] regardless of * completion order. Implemented by writing into a fixed-index array. * - allSettled-shaped: one job throwing never strands its siblings. A job's * failure surfaces as a `rejected` entry, not a thrown promise. * - CPU-capped: `capByCpuCount` additionally clamps effective concurrency to * `os.cpus().length` for memory-pressure safety. * - Clamped to job count: requesting concurrency 8 for 3 jobs runs 3. * - STANDALONE: imports only `node:os`. Must NOT depend on executor or any * other massa-th0th service so it stays a clean reusable export. */ /** A unit of work. `run()` is invoked exactly once per job. */ export interface PoolJob { run(): Promise; } export interface RunPoolOptions { /** Hard concurrency cap (1-N). Auto-clamped to job count. */ concurrency: number; /** Also clamp by `os.cpus().length`. Default false. */ capByCpuCount?: boolean; /** Per-settled callback (progress / metrics). Optional. */ onSettled?: (idx: number, result: PromiseSettledResult) => void; } export interface RunPoolResult { /** Per-index settled result, ordered by input index (NOT completion). */ settled: PromiseSettledResult[]; /** Concurrency actually used after all caps applied. */ effectiveConcurrency: number; /** True when effectiveConcurrency < requested concurrency. */ capped: boolean; } /** * Run an array of jobs with bounded concurrency. Returns one settled result * per input job, in input order. * * Implementation: a pool of `effectiveConcurrency` workers pulls the next * index from a shared counter. Because each worker writes only to its claimed * index, the output array is naturally order-preserving without sorting. */ export declare function runPool(jobs: PoolJob[], opts: RunPoolOptions): Promise>; /** * Convenience: extract only the fulfilled values, preserving order. Rejected * entries are dropped (the caller already sees reasons via `settled`). */ export declare function fulfilledValues(result: RunPoolResult): T[]; //# sourceMappingURL=run-pool.d.ts.map