/** * @module internal/config * @category Internal * * **The single home for every builder-facing config bag in act-core.** Any * options object an operator hands to `act().build()`, a builder method * (`.on(...)`, `.do(...)`, `.withLane(...)`), or a runtime cycle * (`drain(...)` / `settle(...)`) is validated here with Zod — never with a * hand-written `if (x < min) throw` ladder — so misconfiguration surfaces as * a `ZodError` at the entry point, not as `NaN` arithmetic on the first cycle * tick. * * Layout: one section per bag, each with its `DEFAULT_*` constants, an * internal `OptionsSchema`, an inferred `Config`, and a * `resolveConfig(options): Config`. The schema is never * re-exported — the public surface is the inferred type + resolver. * * Index of bags owned here: * - **Backoff** — retry pacing (`BackoffOptions`), nested in reaction/action. * - **Reaction** — `.do(handler, options)` (`blockOnError` / `maxRetries` / `backoff`). * - **Action** — `.on(entry, options)` (`maxRetries` / `backoff`). * - **Lane** — `.withLane({...})` (`leaseMillis` / `streamLimit` / `cycleMs`). * - **Drain / Settle** — `drain(...)` / `settle(...)` runtime knobs. * - **Autoclose** — the `.autocloses` / `ActOptions` autoclose knobs (+ window). * - **CircuitBreaker** — the store-op breaker on `ActOptions`. * - **Fold** — `projection(...).of(...)` batch-fold knobs. * * Sibling env/package config (`config()`, `NODE_ENV`, log level) lives in the * public `../config.ts` — a different concern (process environment, not * builder input). The `@rotorsoft/act-http` transport bags (`SseOptions`, * `OpenAPIOptions`) live in that package; core cannot own another package's * surface. * * Validation philosophy: reject only what is genuinely broken — `NaN`, * `±Infinity` (Zod 4's `z.number()` rejects both by default), and negatives * where nonsensical. A value that works today is never newly rejected. The * real strictness lands on `maxRetries` and `backoff`, the knobs whose bad * values silently corrupt the poison-quarantine and retry-loop-exit gates. * * @internal */ import { z } from "zod"; import type { ActOptions } from "../act.js"; import type { ActionOptions, BackoffOptions, DrainOptions, FoldOptions, LaneConfig, ReactionOptions, SettleOptions, ShutdownOptions } from "../types/index.js"; /** Validate a backoff bag, or pass `undefined` through. Throws `ZodError`. */ export declare function resolveBackoffConfig(options: BackoffOptions | undefined): BackoffOptions | undefined; declare const ReactionOptionsSchema: z.ZodObject<{ blockOnError: z.ZodBoolean; maxRetries: z.ZodNumber; backoff: z.ZodOptional; baseMs: z.ZodNumber; maxMs: z.ZodOptional; jitter: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>; /** Resolved reaction options. */ export type ReactionConfig = z.infer; /** Validate a fully-defaulted reaction options bag. Throws `ZodError`. */ export declare function resolveReactionConfig(options: ReactionOptions): ReactionConfig; declare const ActionOptionsSchema: z.ZodObject<{ maxRetries: z.ZodOptional; backoff: z.ZodOptional; baseMs: z.ZodNumber; maxMs: z.ZodOptional; jitter: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>; /** Resolved action options. */ export type ActionConfig = z.infer; /** Validate an action options bag. Throws `ZodError`. */ export declare function resolveActionConfig(options: ActionOptions): ActionConfig; /** Validate a lane config. Throws `ZodError`. Returns the input shape. */ export declare function resolveLaneConfig(options: LaneConfig): LaneConfig; /** Validate drain options, or pass `undefined` through. Throws `ZodError`. */ export declare function resolveDrainConfig(options: DrainOptions | undefined): DrainOptions | undefined; /** Validate settle options, or pass `undefined` through. Throws `ZodError`. */ export declare function resolveSettleConfig(options: SettleOptions | undefined): SettleOptions | undefined; /** * Ceiling on the derived shutdown grace budget. Without a cap, a lane * configured with a long lease (minutes, for a genuinely slow integration) * would let one parked handler hold a rolling deploy open for that whole * lease. 30s is the longest `leaseMillis` the production checklist * recommends, so it is the point past which "graceful" stops being the * operator's intent. */ export declare const MAX_SHUTDOWN_GRACE_MS = 30000; /** * Grace budget used when no lane pinned a `leaseMillis` — matches `drain()`'s * own `leaseMillis` fallback, so the default deployment gets a budget * consistent with how long its handlers were already allowed to hold a * stream. */ export declare const DEFAULT_SHUTDOWN_GRACE_MS = 10000; /** Validate shutdown options, or pass `undefined` through. Throws `ZodError`. */ export declare function resolveShutdownConfig(options: ShutdownOptions | undefined): ShutdownOptions | undefined; /** Validate the scalar `ActOptions` knobs at build. Throws `ZodError`. */ export declare function resolveActConfig(options: ActOptions | undefined): ActOptions | undefined; /** * @deprecated The cadence knob is derived from `autocloseWindow` now (#1175); * nothing consumes it. Kept for compat; removed in the next major. */ export declare const DEFAULT_AUTOCLOSE_CYCLE_MINUTES = 720; /** @deprecated Dead since #1090 removed the autoclose sweep. */ export declare const DEFAULT_CLOSE_BATCH_SIZE = 64; /** @deprecated Dead since #1090 removed the autoclose sweep. */ export declare const DEFAULT_CLOSE_YIELD_MS = 0; /** Default IANA zone for `autocloseWindow` when the operator omits one. */ export declare const DEFAULT_AUTOCLOSE_WINDOW_TZ = "UTC"; declare const AutocloseOptionsSchema: z.ZodObject<{ autocloseCycleMinutes: z.ZodDefault; closeBatchSize: z.ZodDefault; closeYieldMs: z.ZodDefault; closeOnError: z.ZodDefault; autocloseWindow: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>; /** Resolved autoclose configuration after validation + default expansion. */ export type AutocloseConfig = z.infer; /** Validate + default the autoclose knobs on `ActOptions`. Throws `ZodError`. */ export declare function resolveAutocloseConfig(options: ActOptions | undefined): AutocloseConfig; export declare const DEFAULT_CIRCUIT_FAILURE_THRESHOLD = 5; export declare const DEFAULT_CIRCUIT_COOLDOWN_MS = 30000; declare const CircuitBreakerOptionsSchema: z.ZodObject<{ failureThreshold: z.ZodDefault; cooldownMs: z.ZodDefault; }, z.core.$strip>; /** Public, all-optional circuit-breaker options bag for `act().build()`. */ export type CircuitBreakerOptions = z.input; /** Resolved circuit-breaker configuration. */ export type CircuitBreakerConfig = z.infer; /** Parse + apply defaults. Throws `ZodError` on out-of-range values. */ export declare const resolveCircuitBreakerConfig: (options?: CircuitBreakerOptions) => CircuitBreakerConfig; export declare const DEFAULT_FOLD_FLUSH_EVERY = 1000; export declare const DEFAULT_MAX_CACHED_STATES = 10000; declare const FoldOptionsSchema: z.ZodObject<{ flushEvery: z.ZodDefault; maxCachedStates: z.ZodDefault; }, z.core.$strip>; /** Resolved fold configuration. */ export type FoldConfig = z.infer; /** Validate + default the fold knobs. Throws `ZodError`. */ export declare function resolveFoldConfig(options: FoldOptions): FoldConfig; export {}; //# sourceMappingURL=config.d.ts.map