Skip to main content

Module rate_limiter

Module rate_limiter 

Source
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:

VariableDefaultDescription
WM_DISPATCH_GLOBAL_RPM600Max total dispatches/min across all tools
WM_DISPATCH_TOOL_RPM240Default per-tool RPM limit
WM_DISPATCH_BURST20Extra burst capacity per tool
WM_DISPATCH_TOOL_OVERRIDEStool:rpm,tool2:rpm2 per-tool overrides

Ported from v2-reference/safety/rate_limiter.rs — PyO3 and lazy_static removed.

Structs§

RateLimiter
Rate limiter managing per-tool and global windows.
RateLimiterConfig
Configuration for a RateLimiter.
SlidingWindow
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