Buckets:

download
raw
3.22 kB
{
"role_mappings": [
{
"role": "Entity",
"status": "missing",
"symbol": "",
"file": "",
"lines": "",
"notes": "Requests come from external HTTP clients outside the repo. scripts/seed_system.py is an admin seeding script hitting /api/admin/* paths, which the RateLimitMiddleware skips, so it is not an Entity of the traced limiter; tests not counted."
},
{
"role": "Enforcer",
"status": "present",
"symbol": "dispatch",
"file": "swx_core/middleware/rate_limit_middleware.py",
"lines": "73",
"notes": "RateLimitMiddleware.dispatch (BaseHTTPMiddleware) derives actor id (user/admin/JWT sub or client IP via _get_actor_info:172), calls limiter.check_limit for 1m/1h/24h windows (lines 98, 112, 122) and returns 429 via _rate_limit_exceeded_response:217 when denied. Registered by apply_middleware (app.add_middleware at line 324), invoked by load_middleware in swx_core/utils/loader.py:184 from swx_core/main.py:194. Caveat: skip_paths (line 57-71) includes \"/\" and is matched with startswith, so in practice every path bypasses the check."
},
{
"role": "Limiter",
"status": "present",
"symbol": "check_limit",
"file": "swx_core/services/rate_limit/rate_limiter.py",
"lines": "69",
"notes": "Called from Enforcer dispatch at rate_limit_middleware.py:98/112/122. RateLimiter.check_limit implements a Redis sorted-set sliding window: counts requests in the window and allows iff current_count < limit (line 124); fails closed when Redis is unavailable. Instance set via set_rate_limiter in apply_middleware (rate_limit_middleware.py:316-317)."
},
{
"role": "HistoryProvider",
"status": "external",
"symbol": "zcard",
"file": "swx_core/services/rate_limit/rate_limiter.py",
"lines": "112",
"notes": "Reached from Limiter check_limit (rate_limiter.py:69). Request history is kept in Redis sorted sets per key (actor:feature:endpoint_class:window); zremrangebyscore (109) prunes, zcard (112) reads the history count, zadd (115) records the current request. Redis client (redis.asyncio from_url) is configured in rate_limit_middleware.py:300."
},
{
"role": "PolicyProvider",
"status": "present",
"symbol": "get_limit",
"file": "swx_core/services/rate_limit/limit_registry.py",
"lines": "116",
"notes": "Called by Enforcer dispatch at rate_limit_middleware.py:90/91/120 (after resolve_plan:150, get_feature_from_path:198, get_endpoint_class:177) and the limit is passed to check_limit. get_limit looks up the static RATE_LIMITS table (limit_registry.py:14) by plan/feature/endpoint class/window, returning 1 as fail-closed default."
},
{
"role": "System",
"status": "missing",
"symbol": "",
"file": "",
"lines": "",
"notes": "The Enforcer forwards via Starlette call_next (rate_limit_middleware.py:130) to the routed handler, but every core router prefix (/api/admin, /api/auth, /api/user/profile, /api/utils, /api/oauth) is in skip_paths, and \"/\" makes all paths skipped, so no concrete in-repo handler is reached only after a passed limit check."
}
]
}

Xet Storage Details

Size:
3.22 kB
·
Xet hash:
0d67a65168815bdf3738e8a585b0cd4a004806dd86622563cf3a3d28afd3d6ae

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.