import { t as IamEngineTypes } from "./engine.types-CKIkd4ez.js"; //#region src/observability/metrics/index.d.ts /** IamMetrics observability types. Type-only namespace - zero bundle cost. */ declare namespace IamMetrics { /** * Aggregates the engine's `onMetrics` events in-process. * * Wire `.record` into `hooks.onMetrics` and read `.snapshot()` on demand (a * `/metrics` route, a Prom scrape, an OTel exporter). Holds a rolling sample * of recent durations to compute p50 / p95 / p99 without pulling in a * histogram library. Sample size defaults to `1000`; beyond that the oldest * sample is evicted via a fixed-size ring buffer. */ interface IAggregator { /** * Records a single metrics event. Bind directly to {@link IamEngineTypes.IHooks.onMetrics}. * * @param event - Receives the metrics event emitted by the engine after every check. */ record(event: IamEngineTypes.IMetricsEvent): void; /** * Computes the current rolling snapshot. Callers can poll at any interval. * * @returns Immutable {@link ISnapshot} summarising the rolling window. */ snapshot(): ISnapshot; /** Resets counters and clears the rolling sample buffer. */ reset(): void; } /** Immutable snapshot of aggregated metrics over the rolling window. */ interface ISnapshot { /** Total events recorded since the last reset. */ readonly total: number; /** Number of allow verdicts. */ readonly allow: number; /** Number of deny verdicts. */ readonly deny: number; /** * Number of allow verdicts that were attributable solely to the engine's * `defaultEffect: 'allow'` fallback (no applicable policy fired). Subset * of {@link allow}. Chart this to detect silent policy-set breakage. */ readonly failOpen: number; /** p50 latency in milliseconds over the rolling window. */ readonly p50: number; /** p95 latency in milliseconds over the rolling window. */ readonly p95: number; /** p99 latency in milliseconds over the rolling window. */ readonly p99: number; /** Maximum latency in the rolling window. */ readonly max: number; /** Window size (capped by the configured `sampleSize`). */ readonly samples: number; } /** Configures {@link iamCreateMetricsAggregator}. */ interface IConfig { /** * Maximum number of duration samples kept in the rolling window. Higher * values give more accurate tail percentiles at the cost of memory. * Defaults to `1000`. */ sampleSize?: number; } } /** * Creates an in-process metrics aggregator with a fixed-size ring buffer for * latency percentiles and running counters for allow/deny verdicts. * * Bind `.record` to {@link IamEngineTypes.IHooks.onMetrics} and read `.snapshot()` * on demand. * * @param config - Optionally overrides the sample size; see {@link IamMetrics.IConfig}. * @returns A new {@link IamMetrics.IAggregator} instance with zeroed counters. * @example * ```ts * const metrics = iamCreateMetricsAggregator({ sampleSize: 2000 }) * const engine = new IamEngine({ adapter, hooks: { onMetrics: metrics.record } }) * app.get('/metrics', (_, res) => res.json(metrics.snapshot())) * ``` */ declare function iamCreateMetricsAggregator(config?: IamMetrics.IConfig): IamMetrics.IAggregator; //#endregion export { iamCreateMetricsAggregator as n, IamMetrics as t }; //# sourceMappingURL=index-YSJPBFXj.d.ts.map