"""Shared flask-limiter instance. Anchored on remote address. In-memory backend for v1 (single-process gunicorn worker pool can drift; that's acceptable at this scale). M14 will switch to Redis if it becomes a real concern. The limiter is enforced in `APP_ENV in ("prod", "staging")` — dev and test deployments share an in-memory backend that's noisy across hot-reloads and would gate the Playwright e2e suite at 10 req/min/IP. The spec NF-security requirement is explicitly a *production* one (cf. tasks/spec.md §6 NF-security); a staging deployment is exposed to humans so the same limits apply there. """ from __future__ import annotations from flask_limiter import Limiter from flask_limiter.util import get_remote_address from app.core.config import settings limiter = Limiter( key_func=get_remote_address, default_limits=[], storage_uri="memory://", headers_enabled=True, strategy="fixed-window", enabled=settings.APP_ENV in ("prod", "staging"), )