Buckets:

AnonymousSpottedToad/securityPatternsRecovery / ground_truth /python /limit_request_rate__tumma72_mlx-manager.json
download
raw
5.36 kB
{
"role_mappings": [
{
"patternRole": "Entity",
"entity": "run_single",
"file": "backend/mlx_manager/mlx_server/benchmark/runner.py",
"lines": "102",
"notes": "In-repo benchmark CLI client (BenchmarkRunner.run_single, driven by mlx_server/benchmark/cli.py) POSTs /v1/chat/completions to the MLX server (runner.py:139/158), whose requests pass the RateLimitMiddleware Enforcer. Caveat: it is a load/benchmark tool; other callers (frontend, OpenAI clients) are outside the repo.",
"status": "present",
"nodeId": null
},
{
"patternRole": "Enforcer",
"entity": "dispatch",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "110",
"notes": "RateLimitMiddleware.dispatch intercepts every request, derives the client IP (_get_client_ip, rate_limit.py:86), calls bucket.consume() (rate_limit.py:121) and returns 429 with Retry-After or forwards via call_next. Registered by app_instance.add_middleware in create_app (mlx_server/main.py:248), only when rate_limit_rpm > 0 (default 0 = disabled; opt-in via config).",
"status": "present",
"nodeId": null
},
{
"patternRole": "Limiter",
"entity": "consume",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "39",
"notes": "Called from dispatch (rate_limit.py:121). TokenBucket.consume refills tokens by elapsed time * rate (capped at capacity) and returns True/False to allow or block; it also updates the bucket state (history update step).",
"status": "present",
"nodeId": null
},
{
"patternRole": "HistoryProvider",
"entity": "_get_bucket",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "93",
"notes": "Called from dispatch (rate_limit.py:119); returns the per-IP TokenBucket from the in-memory dict self._buckets (rate_limit.py:82), whose tokens/last_refill encode the request history and are updated in consume. Stale buckets pruned by _maybe_cleanup (rate_limit.py:99).",
"status": "present",
"nodeId": null
},
{
"patternRole": "PolicyProvider",
"entity": "rate_limit_rpm",
"file": "backend/mlx_manager/mlx_server/config.py",
"lines": "169",
"notes": "Policy is the settings field rate_limit_rpm (requests per minute per IP, default 0), passed to RateLimitMiddleware(rpm=...) at mlx_server/main.py:248 and turned into bucket rate/capacity in __init__ (rate_limit.py:78) and _get_bucket (rate_limit.py:96). No dedicated get_policy method exists, so the config field is cited.",
"status": "present",
"nodeId": null
},
{
"patternRole": "System",
"entity": "create_chat_completion",
"file": "backend/mlx_manager/mlx_server/api/v1/chat.py",
"lines": "80",
"notes": "Reached via call_next in dispatch (rate_limit.py:139) through v1_router (api/v1/__init__.py:16, included at mlx_server/main.py:254); the /v1/chat/completions handler performs inference. Other v1 routes (completions, embeddings, messages, ...) are protected equally.",
"status": "present",
"nodeId": null
}
],
"interaction_order": {
"available": true,
"language": "python",
"repo": "tumma72_mlx-manager",
"reason": "",
"entryRole": "Enforcer",
"entryRule": "behaviour",
"interactions": [
{
"rank": 1,
"interaction": "Enforcer \u2192 HistoryProvider",
"from": "Enforcer",
"to": "HistoryProvider",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"line": 119,
"via": [],
"mechanism": "call",
"path": [
{
"caller": "backend/mlx_manager/mlx_server/middleware/rate_limit.py:<module>.RateLimitMiddleware.dispatch",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"line": 119,
"code": "self._get_bucket(ip)",
"callee": "backend/mlx_manager/mlx_server/middleware/rate_limit.py:<module>.RateLimitMiddleware._get_bucket",
"mechanism": "call"
}
],
"parent": ""
},
{
"rank": 2,
"interaction": "Enforcer \u2192 Limiter",
"from": "Enforcer",
"to": "Limiter",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"line": 121,
"via": [],
"mechanism": "call",
"path": [
{
"caller": "backend/mlx_manager/mlx_server/middleware/rate_limit.py:<module>.RateLimitMiddleware.dispatch",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"line": 121,
"code": "bucket.consume()",
"callee": "backend/mlx_manager/mlx_server/middleware/rate_limit.py:<module>.TokenBucket.consume",
"mechanism": "call"
}
],
"parent": ""
}
],
"anchoredRoles": [
{
"role": "Enforcer",
"kind": "METHOD"
},
{
"role": "HistoryProvider",
"kind": "METHOD"
},
{
"role": "Limiter",
"kind": "METHOD"
},
{
"role": "PolicyProvider",
"kind": "LOCAL"
}
],
"skippedRoles": [
"Entity",
"System"
]
}
}

Xet Storage Details

Size:
5.36 kB
·
Xet hash:
ed0bbb09df148752154682fdc79baad02cf050c56a79b7d804f8e8531d373cc2

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