GPT-5 finding
BoundedUUIDSet breaks when constructed with capacity=0 (modulo-by-zero and ring misuse)
mediumbughigh
- src/bridge/bridgeMessaging.ts
- src/bridge/bridgeMessaging.ts
If capacity is 0 (e.g., from misconfiguration), the ring array has length 0 and writeIdx modulo capacity performs a modulo by zero, resulting in NaN and subsequent incorrect behavior. This can cause runtime errors or silent deduplication failures.
Recommendation
Validate capacity in the constructor: throw if capacity < 1, or coerce to 1. Optionally log a warning if capacity is suspiciously small.