/** * Bounded first-seen dedup — the shared "storm guard" for error-reporting * sites (observer sinks, relay/bridge error callbacks). Evicts wholesale at * the cap: it is a storm guard, not a permanent ledger, so a previously-seen * key may report once more after eviction — an accepted trade for a bounded * footprint. (`uwc-bridge-child` keeps a local copy of this logic to stay * dependency-free; keep the two in sync.) */ export function createBoundedDedup(maxEntries: number): { /** true the FIRST time a key is seen (and records it); false on repeats. */ firstSeen(key: string): boolean } { const seen = new Set() return { firstSeen(key: string): boolean { if (seen.has(key)) return false if (seen.size >= maxEntries) seen.clear() seen.add(key) return true } } }