/** * Concurrency-pool scene renderer — the PARALLEL counterpart to * `runAutoChain` (`execute-autochain.ts`). Where auto-chain renders scenes * SEQUENTIALLY (each seeded from the previous scene's output), the pool keeps up * to N independent scene renders in-flight at once and auto-refills as each * completes. There is no chaining — scenes are treated as independent units. * * This productizes the hand-written `pool-driver.mjs` operators used for the * cartoon gens 3-6 (keep N in-flight, refill on completion, resumable). Mirrors * the auto-chain shape: a PURE scheduler (`runScenePool`) plus an injectable * per-scene runner (`PoolSceneRunner`), so the scheduler is fully offline-testable * with a simulated runner. The real runner + the CLI handler live in * `src/cli/handlers/execution.ts`. */ export interface PoolSceneRunner { (sceneIndex: number): Promise<{ sceneIndex: number; status: 'done' | 'failed'; error?: string; }>; } export interface PoolSceneResult { sceneIndex: number; status: 'done' | 'failed' | 'skipped'; error?: string; } export interface PoolResult { results: PoolSceneResult[]; /** * The peak number of runner promises that were in-flight simultaneously. * INVARIANT: this must never exceed `maxConcurrent`. The scheduler enforces * the cap; this is the observable proof it held. */ maxObservedInFlight: number; } export interface RunScenePoolOptions { /** Ordered scene indices to render. */ scenes: number[]; /** Maximum number of runner promises in-flight at once (>= 1). */ maxConcurrent: number; /** Injectable per-scene runner — submit + poll + select for one scene. */ runner: PoolSceneRunner; /** * Resume hook: when it returns true for a scene, that scene is recorded as * 'skipped' and never handed to the runner (it is already done/selected). */ isAlreadyDone?: (sceneIndex: number) => boolean; /** Optional progress sink (a started/settled message per scene). */ onProgress?: (msg: string) => void; } /** * Render `scenes` with a concurrency cap, auto-refilling as each settles. * * The cap is enforced by a fixed pool of `maxConcurrent` worker loops, each of * which pulls the next not-yet-started scene index from a shared cursor and * awaits its runner before pulling the next. Because there are at most * `maxConcurrent` workers and each holds exactly one scene at a time, at most * `maxConcurrent` runner promises are ever pending simultaneously — that is the * mechanism that bounds `maxObservedInFlight`. A worker that finishes a scene * immediately claims the next index (auto-refill); when the cursor is exhausted * the worker exits. * * Resumable: scenes for which `isAlreadyDone` returns true are recorded * 'skipped' and never run. Failure-isolated: a runner that rejects or returns * status:'failed' frees its worker and the pool keeps going, so one bad scene * never blocks (or aborts) the rest. Results are returned deterministically * ordered by sceneIndex. * * PURE: no fs / provider / timer access beyond awaiting the injected runner. */ export declare function runScenePool(opts: RunScenePoolOptions): Promise; //# sourceMappingURL=execute-pool.d.ts.map