Buckets:

download
raw
3.41 kB
{
"role_mappings": [
{
"role": "Entity",
"status": "present",
"symbol": "request",
"file": "packages/py-cml/src/cml/transport/http.py",
"lines": "211",
"notes": "In-repo py-cml SDK client: HTTPTransport.request (http.py:211) sends requests to the CML API with the X-API-Key header built in _build_headers (http.py:147), which is exactly the identifier RateLimitMiddleware.dispatch keys on (src/api/middleware.py:97). An async twin exists in AsyncHTTPTransport."
},
{
"role": "Enforcer",
"status": "present",
"symbol": "dispatch",
"file": "src/api/middleware.py",
"lines": "90",
"notes": "RateLimitMiddleware.dispatch intercepts every request, derives the id (sha256 of X-API-Key, else client IP; middleware.py:111-114), calls _check_rate_limit (middleware.py:116) and returns HTTP 429 when blocked, else call_next. Registered via app.add_middleware(RateLimitMiddleware, ...) at src/api/app.py:138, but only when auth.rate_limit_requests_per_minute > 0, which defaults to 0 (off by default; mapped per rule 5 as the only matching flow). Health/OPTIONS, 'test-key' and admin key are exempt."
},
{
"role": "Limiter",
"status": "present",
"symbol": "_check_rate_limit_redis",
"file": "src/api/middleware.py",
"lines": "141",
"notes": "Reached from dispatch via _check_rate_limit (middleware.py:116 -> 130 -> 132), which picks Redis when app.state.db.redis exists. _check_rate_limit_redis increments the per-key counter in a 60s window and returns False when count > requests_per_minute (middleware.py:149). Fallback _check_rate_limit_in_memory (middleware.py:157) does the same with an in-process TTLCache when Redis is unavailable."
},
{
"role": "HistoryProvider",
"status": "external",
"symbol": "incr",
"file": "src/api/middleware.py",
"lines": "145",
"notes": "Called by the Limiter _check_rate_limit_redis: Redis (redis.asyncio client from src/storage/connection.py:124) stores the request counter under 'ratelimit:<key>' via pipeline incr/expire (middleware.py:145-146), returning the count (history) and recording the request; decr on block (middleware.py:150). Fallback history is the in-memory TTLCache self._buckets (middleware.py:83)."
},
{
"role": "PolicyProvider",
"status": "present",
"symbol": "rate_limit_requests_per_minute",
"file": "src/core/config.py",
"lines": "116",
"notes": "No method provides the policy; the limit is the AuthSettings field rate_limit_requests_per_minute (env AUTH__RATE_LIMIT_REQUESTS_PER_MINUTE, default 0 = disabled), read at src/api/app.py:136 and passed to RateLimitMiddleware.__init__ (middleware.py:80) as self.requests_per_minute, used by the Limiter at middleware.py:149 together with the fixed 60s window _RATE_LIMIT_WINDOW_SECONDS (middleware.py:16). Single global policy, not per-id."
},
{
"role": "System",
"status": "present",
"symbol": "write_memory",
"file": "src/api/routes.py",
"lines": "70",
"notes": "After dispatch passes (call_next at middleware.py:124), requests reach the /api/v1 routers included at src/api/app.py:141; e.g. POST /api/v1/memory/write handled by write_memory (routes.py:70), which the SDK Entity calls. All API routes except /api/v1/health are equally guarded."
}
]
}

Xet Storage Details

Size:
3.41 kB
·
Xet hash:
17645e04cca73523b4c263d50949303a015e0afe65efd73c34ae46b08918244b

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