/** * Killable worker boundary for hosted declarative configuration evaluation. * * Each request receives a fresh worker. A synchronous parser stall therefore * cannot retain a pooled worker generation or block the host event loop. * * @module */ import { type PreparedDeclarativeConfigWorkerPayload } from "./declarative-evaluator.js"; import type { ConfigSnapshotRecord } from "./snapshot.js"; /** * Process-wide admission limits for cold hosted configuration evaluations. * * Evaluation results are expected to be cached by their source/context * identity. A deliberately small worker budget protects aggregate CPU and * memory when many unique or uncached sources arrive together. */ export declare const DECLARATIVE_CONFIG_WORKER_ADMISSION_LIMITS: { maxActive: number; maxQueued: number; }; /** Host-controlled lifecycle policy for one worker evaluation. */ export interface DeclarativeConfigWorkerRunnerOptions { /** Wall-clock deadline covering worker startup, parsing, and evaluation. */ readonly timeoutMs?: number; /** Optional cancellation signal owned by the hosted caller. */ readonly signal?: AbortSignal; } interface DeclarativeConfigWorkerEndpointListeners { readonly onMessage: (value: unknown) => void; readonly onError: () => void; readonly onMessageError: () => void; readonly onExit?: (code: number) => void; } interface DeclarativeConfigWorkerEndpoint { postMessage(value: PreparedDeclarativeConfigWorkerPayload): void; subscribe(listeners: DeclarativeConfigWorkerEndpointListeners): () => void; terminate(): void | Promise; } type DeclarativeConfigWorkerEndpointFactory = () => Promise; declare class DeclarativeConfigWorkerAdmissionController { #private; constructor(maxActive: number, maxQueued: number); acquire(timeoutMs: number, signal?: AbortSignal): Promise<() => void>; snapshot(): Readonly<{ active: number; queued: number; }>; } declare class DeclarativeConfigWorkerStartupController { #private; constructor(maxPending: number); acquire(): () => void; snapshot(): Readonly<{ pending: number; maxPending: number; }>; } declare function evaluateWithEndpointFactory(payload: PreparedDeclarativeConfigWorkerPayload, options: DeclarativeConfigWorkerRunnerOptions, endpointFactory: DeclarativeConfigWorkerEndpointFactory, terminationDrainTimeoutMs?: number): Promise; declare function evaluateWithAdmissionController(payload: PreparedDeclarativeConfigWorkerPayload, options: DeclarativeConfigWorkerRunnerOptions, endpointFactory: DeclarativeConfigWorkerEndpointFactory, admissionController: DeclarativeConfigWorkerAdmissionController, terminationDrainTimeoutMs?: number, startupController?: DeclarativeConfigWorkerStartupController, /** * Monotonic clock used to charge admission wait time against the caller * deadline. Seamed so a test can hold it still: the budget check below * otherwise races real time spent inside `acquire`, and a starved worker can * exhaust a short deadline before the startup permit is ever taken. Both * outcomes report `worker-timeout`, but only one leaves the orphan accounted * for, so a test asserting that accounting cannot depend on wall time. */ now?: () => number): Promise; /** * Evaluate one prepared hosted configuration in a fresh, bounded worker. * * The returned snapshot is decoded, recanonicalized, and deeply frozen by the * host before it crosses back into trusted application code. */ export declare function evaluatePreparedDeclarativeConfigInWorker(payload: PreparedDeclarativeConfigWorkerPayload, options?: DeclarativeConfigWorkerRunnerOptions): Promise; /** @internal Test seam for deterministic lifecycle and protocol tests. */ export declare const declarativeConfigWorkerRunnerInternals: { createAdmissionController(maxActive: number, maxQueued: number): DeclarativeConfigWorkerAdmissionController; createStartupController(maxPending: number): DeclarativeConfigWorkerStartupController; getGlobalLifecycleState(): Readonly<{ admission: Readonly<{ active: number; queued: number; }>; startup: Readonly<{ pending: number; maxPending: number; }>; }>; evaluateWithAdmissionController: typeof evaluateWithAdmissionController; evaluateWithEndpointFactory: typeof evaluateWithEndpointFactory; }; export {}; //# sourceMappingURL=declarative-evaluator-worker-runner.d.ts.map