Summary
The rate limiter middleware exists but needs a comprehensive, configurable token-bucket implementation covering all endpoints with appropriate per-endpoint limits. Abuse of task submission, agent registration, and Venice-heavy endpoints can exhaust resources and incur unbounded Venice API costs.
Priority
P1 — Public endpoints are currently unthrottled and vulnerable to abuse.
Files to work on
backend/src/api/middleware/rateLimiter.ts
backend/src/config/index.ts
backend/src/api/rateLimitRules.ts
Requirements
- Implement a distributed token-bucket rate limiter (backed by shared store; fallback to in-memory)
- Configurable limits per endpoint via a rules table:
POST /api/tasks: 30/min per wallet
POST /api/agents/register: 10/hour per wallet
POST /api/payments: 30/min
- Global: 100 req/min per IP
- Daily quota per wallet for task submissions (default 100)
- Return
429 with Retry-After header and structured error body
- Emit
RATE_LIMITED event when limits are hit
- Expose
GET /api/ratelimit/status (admin) showing current usage per key
Acceptance Criteria
Summary
The rate limiter middleware exists but needs a comprehensive, configurable token-bucket implementation covering all endpoints with appropriate per-endpoint limits. Abuse of task submission, agent registration, and Venice-heavy endpoints can exhaust resources and incur unbounded Venice API costs.
Priority
P1 — Public endpoints are currently unthrottled and vulnerable to abuse.
Files to work on
Requirements
POST /api/tasks: 30/min per walletPOST /api/agents/register: 10/hour per walletPOST /api/payments: 30/min429withRetry-Afterheader and structured error bodyRATE_LIMITEDevent when limits are hitGET /api/ratelimit/status(admin) showing current usage per keyAcceptance Criteria
429withRetry-AfterRetry-Afterheader is always present on429