Expand description
Atomic sliding-window rate limiter for tool dispatch.
Provides O(1) per-check rate limiting using lock-free atomics. Per-tool and global RPM enforcement with burst allowance.
§Configuration
Limits are configurable via RateLimiterConfig (defaults in
RateLimiterConfig::default) or the environment:
| Variable | Default | Description |
|---|---|---|
WM_DISPATCH_GLOBAL_RPM | 600 | Max total dispatches/min across all tools |
WM_DISPATCH_TOOL_RPM | 240 | Default per-tool RPM limit |
WM_DISPATCH_BURST | 20 | Extra burst capacity per tool |
WM_DISPATCH_TOOL_OVERRIDES | — | tool:rpm,tool2:rpm2 per-tool overrides |
Ported from v2-reference/safety/rate_limiter.rs — PyO3 and lazy_static removed.
Structs§
- Rate
Limiter - Rate limiter managing per-tool and global windows.
- Rate
Limiter Config - Configuration for a
RateLimiter. - Sliding
Window - A sliding-window counter using two half-windows for smooth transitions.
Constants§
- DEFAULT_
BURST - DEFAULT_
GLOBAL_ RPM - Default limits — the values used by
RateLimiter::default. - DEFAULT_
TOOL_ RPM