/** * Burst policy, detects rapid notification floods within a short observation * window and collapses them into a batch group key. * * Unlike the rolling BatchPolicy (which uses a fixed time window), the burst * policy measures the event rate within a sliding observation window and * activates only when the rate exceeds a configured threshold. Once activated, * subsequent notifications in the group are collapsed until the burst subsides. * * A burst group key is `{domain}:{level}`, matching the BatchPolicy scheme * so downstream consumers can coalesce both batch types uniformly. */ import type { Notification } from '../types.js'; /** * BurstPolicy tracks notification arrival rates per domain:level group and * activates burst suppression when the rate exceeds the threshold. */ export declare class BurstPolicy { /** Active burst group entries keyed by `{domain}:{level}`. */ private readonly groups; /** Observation window in ms. */ private readonly observationWindowMs; /** Number of events within the window before burst activates. */ private readonly burstThreshold; /** Cooldown in ms after last event before the burst group resets. */ private readonly cooldownMs; constructor(observationWindowMs?: number, burstThreshold?: number, cooldownMs?: number); /** * Builds the burst group key for a notification. * * @param notification - The notification to key. * @returns A string key in the form `{domain}:{level}`. */ private buildKey; /** * Prune timestamps outside the current observation window. */ private pruneWindow; /** * Evaluates a notification against the burst policy. * * @param notification - Incoming notification to evaluate. * @returns The burst group key if the notification is being burst-collapsed, * or undefined if it should proceed to the next policy stage. */ evaluate(notification: Notification): string | undefined; /** * Returns the number of notifications collapsed in a burst group. * * @param key - The burst group key (`{domain}:{level}`). * @returns The collapsed count, or 0 if no group exists. */ getCollapsedCount(key: string): number; /** * Resets a specific burst group, clearing its state. * Call this when the burst window expires and the group is ready to * surface its summary. * * @param key - The burst group key to reset. */ resetGroup(key: string): void; /** * Returns all currently active burst group keys. * * Callers can use this to surface summary notifications for each active * burst group at flush time. */ getActiveGroups(): string[]; } //# sourceMappingURL=burst-policy.d.ts.map